summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authornechda <[email protected]>2024-08-29 23:50:27 +0300
committernechda <[email protected]>2024-08-30 00:05:25 +0300
commite10d6638f07a82edae3ea8197b9f5c0affcc07ea (patch)
tree571c38cec05813766a1ad290c9d51ce7ace52919 /contrib
parente79b38f2bbbf78d295d1901d2a79f898022d5224 (diff)
Update cpp-protobuf to 22.5
Привет!\ Этот PR переключат cpp & python библиотеки protobuf на версию 22.5 Если у вас возникли проблемы после влития этого PR: 1. Если начали падать канон тесты, то проведите их переканонизацию 2. Прочитайте <https://wiki.yandex-team.ru/users/nechda/obnovlenie-cpp-protobuf-22.5/> страничку с основными изменениями 3. Если страничка в вики не помогла, то пишите в [DEVTOOLSSUPPORT](https://st.yandex-team.ru/DEVTOOLSSUPPORT) 7fecade616c20a841b9e9af7b7998bdfc8d2807d
Diffstat (limited to 'contrib')
-rw-r--r--contrib/libs/grpc/include/grpcpp/impl/codegen/config_protobuf.h3
-rw-r--r--contrib/libs/protobuf/CHANGES.txt3413
-rw-r--r--contrib/libs/protobuf/CODE_OF_CONDUCT.md3
-rw-r--r--contrib/libs/protobuf/README.md34
-rw-r--r--contrib/libs/protobuf/src/README.md161
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/any.cc16
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/any.h34
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/any.pb.cc253
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/any.pb.h223
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/any.proto7
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/any_lite.cc35
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/api.pb.cc765
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/api.pb.h651
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/api.proto3
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/arena.cc938
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/arena.h435
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/arena_align.cc (renamed from contrib/libs/protobuf/src/google/protobuf/util/internal/error_listener.cc)13
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/arena_align.h221
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/arena_allocation_policy.h126
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/arena_cleanup.h224
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/arena_config.cc (renamed from contrib/libs/protobuf/src/google/protobuf/stubs/once.h)26
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/arena_config.h73
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/arena_impl.h686
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/arenastring.cc84
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/arenastring.h50
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/arenaz_sampler.cc153
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/arenaz_sampler.h116
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/descriptor.cc1886
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/descriptor.h389
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/descriptor.pb.cc6271
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/descriptor.pb.h7604
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/descriptor.proto100
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/descriptor_database.cc235
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/descriptor_database.h45
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/duration.pb.cc207
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/duration.pb.h175
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/duration.proto3
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/dynamic_message.cc87
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/dynamic_message.h36
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/empty.pb.cc123
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/empty.pb.h101
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/empty.proto2
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/endian.h4
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/explicitly_constructed.h8
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/extension_set.cc292
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/extension_set.h64
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/extension_set_heavy.cc95
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/extension_set_inl.h33
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/field_mask.pb.cc174
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/field_mask.pb.h144
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/field_mask.proto2
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_enum_reflection.h15
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_enum_util.cc8
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_enum_util.h13
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_bases.cc20
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_bases.h17
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_reflection.cc810
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_reflection.h111
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_decl.h106
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_full.cc57
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_gen.cc835
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_gen.h164
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_impl.h677
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_lite.cc1401
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_util.cc30
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/generated_message_util.h88
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/has_bits.h8
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/implicit_weak_message.cc12
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/implicit_weak_message.h15
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/inlined_string_field.cc16
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/inlined_string_field.h39
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/coded_stream.cc186
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/coded_stream.h115
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/gzip_stream.cc19
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/gzip_stream.h29
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/io_win32.cc2
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/io_win32.h6
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/printer.cc983
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/printer.h1094
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/strtod.cc217
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/strtod.h23
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/tokenizer.cc111
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/tokenizer.h59
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/zero_copy_sink.cc68
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/zero_copy_sink.h80
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream.cc101
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream.h64
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc32
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream_impl.h70
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc292
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h207
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/json/internal/descriptor_traits.h536
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/json/internal/lexer.cc540
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/json/internal/lexer.h359
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/json/internal/message_path.cc (renamed from contrib/libs/protobuf/src/google/protobuf/util/internal/location_tracker.h)53
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/json/internal/message_path.h84
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/json/internal/parser.cc1409
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/json/internal/parser.h59
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/json/internal/parser_traits.h423
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/json/internal/unparser.cc892
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/json/internal/unparser.h59
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/json/internal/unparser_traits.h438
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/json/internal/untyped_message.cc553
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/json/internal/untyped_message.h260
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/json/internal/writer.cc328
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/json/internal/writer.h241
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/json/internal/zero_copy_buffered_stream.cc148
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/json/internal/zero_copy_buffered_stream.h355
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/json/json.cc133
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/json/json.h200
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/json/old_json.cc134
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/map.cc4
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/map.h1862
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/map_entry.h22
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/map_entry_lite.h47
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/map_field.cc24
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/map_field.h104
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/map_field_inl.h24
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/map_field_lite.h27
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/map_type_handler.h12
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/message.cc217
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/message.h175
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/message_lite.cc307
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/message_lite.h100
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/messagext.cc12
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/metadata_lite.h77
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/parse_context.cc375
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/parse_context.h264
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/port.h144
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/port_def.inc351
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/port_undef.inc42
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/reflection.h9
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/reflection_internal.h13
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/reflection_ops.cc65
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/reflection_ops.h14
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/repeated_field.cc39
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/repeated_field.h715
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/repeated_ptr_field.cc38
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/repeated_ptr_field.h284
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/serial_arena.h434
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/service.cc2
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/service.h26
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/source_context.pb.cc201
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/source_context.pb.h162
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/source_context.proto2
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/string_block.h164
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/struct.pb.cc431
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/struct.pb.h443
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/struct.proto2
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/bytestream.cc194
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/bytestream.h351
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/callback.h56
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/casts.h138
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/common.cc241
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/common.h106
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/int128.cc193
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/int128.h387
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/logging.h239
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/macros.h93
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/map_util.h769
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/mathutil.h162
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/mutex.h218
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/platform_macros.h4
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/port.h133
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/status_macros.h23
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/statusor.h253
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/stl_util.h14
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/stringpiece.cc4
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/stringprintf.cc175
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/stringprintf.h85
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/strutil.cc91
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/substitute.cc9
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/time.cc365
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/stubs/time.h82
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/text_format.cc500
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/text_format.h149
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/thread_safe_arena.h290
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/timestamp.pb.cc207
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/timestamp.pb.h175
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/timestamp.proto5
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/type.pb.cc1124
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/type.pb.h1214
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/type.proto2
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/unknown_field_set.cc74
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/unknown_field_set.h28
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/delimited_message_util.cc5
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/delimited_message_util.h13
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/field_comparator.cc77
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/field_comparator.h33
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/field_mask_util.cc206
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/field_mask_util.h32
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/constants.h101
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/datapiece.cc441
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/datapiece.h219
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.cc642
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.h332
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/error_listener.h109
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/field_mask_utility.cc218
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/field_mask_utility.h74
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/json_escaping.cc372
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/json_escaping.h98
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/json_objectwriter.cc190
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/json_objectwriter.h278
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/json_stream_parser.cc995
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/json_stream_parser.h350
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/object_source.h85
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/object_writer.cc93
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/object_writer.h151
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/proto_writer.cc827
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/proto_writer.h389
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc1114
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectsource.h329
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.cc1401
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.h453
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/structured_objectwriter.h121
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/type_info.cc182
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/type_info.h97
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/utility.cc414
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/internal/utility.h204
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/json_util.cc284
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/json_util.h206
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/message_differencer.cc374
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/message_differencer.h140
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/time_util.cc195
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/time_util.h43
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/type_resolver.h21
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/type_resolver_util.cc83
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/util/type_resolver_util.h13
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/wire_format.cc107
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/wire_format.h40
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/wire_format_lite.cc55
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/wire_format_lite.h72
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/wrappers.pb.cc971
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/wrappers.pb.h586
-rw-r--r--contrib/libs/protobuf/src/google/protobuf/wrappers.proto4
-rw-r--r--contrib/libs/protobuf/third_party/utf8_range/CONTRIBUTING.md31
-rw-r--r--contrib/libs/protobuf/third_party/utf8_range/LICENSE22
-rw-r--r--contrib/libs/protobuf/third_party/utf8_range/README.md264
-rw-r--r--contrib/libs/protobuf/third_party/utf8_range/UTF-8-demo.txt212
-rw-r--r--contrib/libs/protobuf/third_party/utf8_range/utf8_validity.cc458
-rw-r--r--contrib/libs/protobuf/third_party/utf8_range/utf8_validity.h23
-rw-r--r--contrib/libs/protobuf/ya.make44
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/code_generator.cc52
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/code_generator.h26
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc575
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.h44
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum.cc782
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum.h57
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum_field.cc451
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum_field.h125
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.cc37
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.h12
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/field.cc522
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/field.h496
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/enum_field.cc471
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/generators.h98
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/map_field.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/map_field.cc)86
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/message_field.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/message_field.cc)344
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/primitive_field.cc582
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/string_field.cc922
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/file.cc1958
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/file.h137
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/generator.cc264
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/generator.h28
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/helpers.cc850
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/helpers.h387
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/map_field.h83
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/message.cc1947
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/message.h161
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/message_field.h148
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/message_layout_helper.h4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/names.h40
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/options.h12
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/padding_optimizer.cc107
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/padding_optimizer.h2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/parse_function_generator.cc1067
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/parse_function_generator.h73
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/primitive_field.cc539
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/primitive_field.h126
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/service.cc488
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/service.h64
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/string_field.cc957
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/string_field.h136
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/tracker.cc339
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/tracker.h58
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc15
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_doc_comment.h4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum.cc45
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum.h8
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum_field.cc20
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum_field.h4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_field_base.cc154
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_field_base.h21
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_generator.cc27
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_generator.h6
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_helpers.cc273
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_helpers.h43
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_map_field.cc23
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_map_field.h4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message.cc126
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message.h6
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message_field.cc26
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message_field.h4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_names.h111
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc40
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_primitive_field.h4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc41
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_reflection_class.h8
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc20
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc22
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc20
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc20
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc24
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/names.cc223
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/names.h150
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/importer.cc133
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/importer.h87
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/context.cc89
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/context.h28
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/doc_comment.cc184
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/doc_comment.h25
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/enum.cc79
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/enum.h7
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field.cc350
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field.h48
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field_lite.cc201
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field_lite.h28
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/enum_lite.cc91
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/enum_lite.h7
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/extension.cc51
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/extension.h19
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/extension_lite.cc28
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/extension_lite.h12
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/field.cc97
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/field.h49
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/file.cc150
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/file.h9
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/generator.cc80
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/generator.h15
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/generator_factory.cc20
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/generator_factory.h11
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/helpers.cc408
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/helpers.h91
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/kotlin_generator.cc23
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/kotlin_generator.h11
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/map_field.cc584
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/map_field.h12
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/map_field_lite.cc295
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/map_field_lite.h4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message.cc548
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message.h20
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder.cc576
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder.h20
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder_lite.cc72
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder_lite.h11
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message_field.cc496
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message_field.h69
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message_field_lite.cc137
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message_field_lite.h27
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message_lite.cc268
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message_lite.h9
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message_serialization.cc (renamed from contrib/libs/protobuf/src/google/protobuf/stubs/statusor.cc)21
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message_serialization.h103
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/name_resolver.cc99
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/name_resolver.h32
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/names.cc193
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/names.h37
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/options.h7
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field.cc343
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field.h48
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field_lite.cc195
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field_lite.h28
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/service.cc49
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/service.h12
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/shared_code_generator.cc63
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/shared_code_generator.h7
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/string_field.cc342
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/string_field.h44
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/string_field_lite.cc183
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/string_field_lite.h28
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/main.cc33
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/enum.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum.cc)156
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/enum.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum.h)15
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/enum_field.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc)58
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/enum_field.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h)22
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/extension.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_extension.cc)93
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/extension.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_extension.h)20
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/field.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.cc)188
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/field.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.h)70
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/file.cc736
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/file.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.h)102
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/generator.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_generator.cc)199
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/generator.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_generator.h)15
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/helpers.cc399
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/helpers.h155
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/import_writer.cc255
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/import_writer.h82
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/line_consumer.cc212
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/line_consumer.h74
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/map_field.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc)88
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/map_field.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_map_field.h)19
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/message.cc631
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/message.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message.h)54
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/message_field.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc)50
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/message_field.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.h)31
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/names.cc1247
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/names.h179
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/nsobject_methods.h227
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.cc681
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc2044
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_helpers.h355
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message.cc633
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_nsobject_methods.h197
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/oneof.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc)64
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/oneof.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_oneof.h)25
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/options.h (renamed from contrib/libs/protobuf/src/google/protobuf/util/internal/object_location_tracker.h)41
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/primitive_field.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc)49
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/primitive_field.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h)14
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/text_format_decode_data.cc254
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/text_format_decode_data.h83
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/parser.cc398
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/parser.h78
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/php/names.cc144
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/php/names.h73
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/php/php_generator.cc462
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/php/php_generator.h16
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc24
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/plugin.h4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc869
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h927
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/plugin.proto5
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/python/generator.cc526
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/python/generator.h51
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/python/helpers.cc77
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/python/helpers.h21
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/python/pyi_generator.cc408
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/python/pyi_generator.h61
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/retention.cc104
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/retention.h55
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/ruby/ruby_generator.cc65
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/ruby/ruby_generator.h6
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/scc.h51
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/subprocess.cc122
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/subprocess.h8
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.cc4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.h4
-rw-r--r--contrib/libs/protoc/ya.make52
-rw-r--r--contrib/python/protobuf/py3/.dist-info/METADATA21
-rw-r--r--contrib/python/protobuf/py3/.dist-info/top_level.txt1
-rw-r--r--contrib/python/protobuf/py3/CODE_OF_CONDUCT.md3
-rw-r--r--contrib/python/protobuf/py3/CONTRIBUTING.md120
-rw-r--r--contrib/python/protobuf/py3/CONTRIBUTORS.txt107
-rw-r--r--contrib/python/protobuf/py3/README.md160
-rw-r--r--contrib/python/protobuf/py3/SECURITY.md4
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/__init__.py2
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/descriptor.py72
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/descriptor_pool.py35
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/internal/__init__.py30
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/internal/_parameterized.py443
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/internal/api_implementation.cc78
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/internal/api_implementation.py7
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/internal/decoder.py3
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/internal/extension_dict.py5
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/internal/field_mask.py333
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/internal/python_message.py75
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/internal/python_protobuf.cc63
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/internal/testing_refleaks.py142
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/internal/type_checkers.py10
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/internal/well_known_types.py304
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/internal/wire_format.py2
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/json_format.py73
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/message.py15
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/message_factory.py184
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/proto_api.h7
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/proto_builder.py20
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/__init__.py4
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/descriptor.cc39
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/descriptor.h5
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_containers.cc53
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_database.cc26
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_database.h5
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_pool.cc75
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_pool.h2
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/extension_dict.cc35
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/extension_dict.h2
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/field.cc8
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/map_container.cc110
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/map_container.h6
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/message.cc172
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/message.h58
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/message_factory.cc11
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/message_factory.h4
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/message_module.cc12
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/repeated_composite_container.cc23
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/repeated_composite_container.h2
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/repeated_scalar_container.cc52
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/repeated_scalar_container.h4
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/safe_numerics.h5
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/scoped_pyobject_ptr.h6
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/unknown_field_set.cc12
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/unknown_field_set.h2
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/unknown_fields.cc15
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/pyext/unknown_fields.h2
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/python_protobuf.h58
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/reflection.py2
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/symbol_database.py28
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/text_encoding.py6
-rw-r--r--contrib/python/protobuf/py3/google/protobuf/text_format.py254
-rw-r--r--contrib/python/protobuf/py3/ya.make77
-rw-r--r--contrib/python/protobuf/py3/ya.make.inc57
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/base/config.h6
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_map.h889
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_set.h824
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree.h3048
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree_container.h763
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/layout.h839
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/crc/crc32c.h2
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/debugging/ya.make2
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/absl_check.h117
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/absl_log.h115
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/absl_vlog_is_on.h93
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/die_if_null.cc32
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/die_if_null.h76
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/flags.cc143
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/globals.cc178
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/globals.h231
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/initialize.cc38
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/initialize.h45
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/append_truncated.h47
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/check_impl.h150
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/check_op.cc138
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/check_op.h462
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/conditions.cc83
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/conditions.h239
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/config.h45
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/flags.h59
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/fnmatch.cc73
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/fnmatch.h35
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/globals.cc145
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/globals.h101
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_format.cc205
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_format.h78
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_impl.h282
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_message.cc726
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_message.h398
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_sink_set.cc296
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_sink_set.h54
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/nullguard.cc35
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/nullguard.h88
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/nullstream.h127
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/proto.cc220
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/proto.h288
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/strip.h108
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/vlog_config.cc340
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/vlog_config.h163
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/voidify.h44
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/log.h365
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/log_entry.cc41
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/log_entry.h221
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/log_sink.cc23
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/log_sink.h71
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/log_sink_registry.h61
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/log/ya.make58
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/status/internal/status_internal.h11
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/cordz_info.cc7
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/bind.h2
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/checker.h2
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/strings/ya.make4
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/mutex.cc7
-rw-r--r--contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/ya.make4
-rw-r--r--contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp4
-rw-r--r--contrib/tools/protoc/ya.make.induced_deps3
577 files changed, 71965 insertions, 56497 deletions
diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/config_protobuf.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/config_protobuf.h
index e1f3d40ac92..273981c9753 100644
--- a/contrib/libs/grpc/include/grpcpp/impl/codegen/config_protobuf.h
+++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/config_protobuf.h
@@ -68,8 +68,9 @@
#ifndef GRPC_CUSTOM_JSONUTIL
#include <google/protobuf/util/json_util.h>
#include <google/protobuf/util/type_resolver_util.h>
+#include <y_absl/status/status.h>
#define GRPC_CUSTOM_JSONUTIL ::google::protobuf::util
-#define GRPC_CUSTOM_UTIL_STATUS ::google::protobuf::util::Status
+#define GRPC_CUSTOM_UTIL_STATUS y_absl::Status
#endif
namespace grpc {
diff --git a/contrib/libs/protobuf/CHANGES.txt b/contrib/libs/protobuf/CHANGES.txt
deleted file mode 100644
index 9fc608eded2..00000000000
--- a/contrib/libs/protobuf/CHANGES.txt
+++ /dev/null
@@ -1,3413 +0,0 @@
-2022-07-19 version 21.3 (C++/Java/Python/PHP/Objective-C/C#/Ruby)
- C++
- * Add header search paths to Protobuf-C++.podspec (#10024)
- * Fixed Visual Studio constinit errors (#10232)
- * Fix #9947: make the ABI compatible between debug and non-debug builds (#10271)
-
- UPB
- * Allow empty package names (fixes behavior regression in 4.21.0)
- * Fix a SEGV bug when comparing a non-materialized sub-message (#10208)
- * Fix several bugs in descriptor mapping containers (eg. descriptor.services_by_name)
- * for x in mapping now yields keys rather than values, to match Python conventions and the behavior of the old library.
- * Lookup operations now correctly reject unhashable types as map keys.
- * We implement repr() to use the same format as dict.
- * Fix maps to use the ScalarMapContainer class when appropriate
- * Fix bug when parsing an unknown value in a proto2 enum extension (protocolbuffers/upb#717)
-
- PHP
- * Add "readonly" as a keyword for PHP and add previous classnames to descriptor pool (#10041)
-
- Python
- * Make //:protobuf_python and //:well_known_types_py_pb2 public (#10118)
-
- Bazel
- * Add back a filegroup for :well_known_protos (#10061)
-
-2022-06-27 version 21.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby)
- C++
- * ArenaString improvements (fix alignment issue)
-
- PHP
- * API changes for OneOf (#10102)
-
-
-2022-05-27 version 21.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby)
-
- C++
- * cmake: Revert "Fix cmake install targets (#9822)" (#10060)
- * Remove Abseil dependency from CMake build (#10056)
-
- Python
- * Update python wheel metadata with more information incl. required python version (#10058)
- * Fix segmentation fault when instantiating field via repeated field assignment (#10066)
-
-2022-05-25 version 21.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby)
-
- C++
- * cmake: Call get_filename_component() with DIRECTORY mode instead of PATH mode (#9614)
- * Escape GetObject macro inside protoc-generated code (#9739)
- * Update CMake configuration to add a dependency on Abseil (#9793)
- * Fix cmake install targets (#9822)
- * Use __constinit only in GCC 12.2 and up (#9936)
-
- Java
- * Update protobuf_version.bzl to separate protoc and per-language java … (#9900)
-
- Python
- * Increment python major version to 4 in version.json for python upb (#9926)
- * The C extension module for Python has been rewritten to use the upb library.
- This is expected to deliver significant performance benefits, especially when
- parsing large payloads. There are some minor breaking changes, but these
- should not impact most users. For more information see:
- https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
- * Fixed win32 build and fixed str(message) on all Windows platforms. (#9976)
- * The binary wheel for macOS now supports Apple silicon.
-
- PHP
- * [PHP] fix PHP build system (#9571)
- * Fix building packaged PHP extension (#9727)
- * fix: reserve "ReadOnly" keyword for PHP 8.1 and add compatibility (#9633)
- * fix: phpdoc syntax for repeatedfield parameters (#9784)
- * fix: phpdoc for repeatedfield (#9783)
- * Change enum string name for reserved words (#9780)
- * chore: [PHP] fix phpdoc for MapField keys (#9536)
- * Fixed PHP SEGV by not writing to shared memory for zend_class_entry. (#9996)
-
- Ruby
- * Allow pre-compiled binaries for ruby 3.1.0 (#9566)
- * Implement `respond_to?` in RubyMessage (#9677)
- * [Ruby] Fix RepeatedField#last, #first inconsistencies (#9722)
- * Do not use range based UTF-8 validation in truffleruby (#9769)
- * Improve range handling logic of `RepeatedField` (#9799)
- * Support x64-mingw-ucrt platform
-
- Other
- * [Kotlin] remove redundant public modifiers for compiled code (#9642)
- * [C#] Update GetExtension to support getting typed value (#9655)
- * Fix invalid dependency manifest when using `descriptor_set_out` (#9647)
- * Fix C# generator handling of a field named "none" in a oneof (#9636)
- * Add initial version.json file for 21-dev (#9840)
- * Remove duplicate java generated code (#9909)
- * Cherry-pick PR #9981 into 21.x branch (#10000)
-
-
-2022-05-19 version 21.0-rc2(C++/Java/Python/PHP/Objective-C/C#/Ruby)
-
- Python
- * Fix windows builds
- * Throw more helpful error if generated code is out of date
- * Fixed two reference leaks
-
- Ruby
- * Support x64-mingw-ucrt platform
-
- PHP
- * Fix SEGV by not writing to shared memory for zend_class_entry
-
- C#
- * Suppress warning CS8981
-
- Other
- * Fix Maven release to release actual osx_aarch64 binary
- * Fix protoc zips to have the proto files for well known types
-
-2022-05-10 version 21.0-rc1 (C++/Java/Python/PHP/Objective-C/C#/Ruby)
-
- C++
- * Rename main cmake/CMakeLists.txt to CMakeLists.txt (#9603)
- * avoid allocating memory if all extension are cleared (#9345)
- * cmake: Call get_filename_component() with DIRECTORY mode instead of PATH mode (#9614)
- * Escape GetObject macro inside protoc-generated code (#9739)
- * Update CMake configuration to add a dependency on Abseil (#9793)
- * Use __constinit only in GCC 12.2 and up (#9936)
- * Refactor generated message class layout
- * Optimize tokenizer ParseInteger by removing division
- * Reserve exactly the right amount of capacity in ExtensionSet::MergeFrom
- * Parse FLT_MAX correctly when represented in JSON
-
- Java
- * Update protobuf_version.bzl to separate protoc and per-language java … (#9900)
- * 6x speedup in ArrayEncoder.writeUInt32NotTag
-
- Python
- * Increment python major version to 4 in version.json for python upb (#9926)
- * The C extension module for Python has been rewritten to use the upb library.
- This is expected to deliver significant performance benefits, especially when
- parsing large payloads. There are some minor breaking changes, but these
- should not impact most users. For more information see:
- https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
- * Due to the breaking changes for Python, the major version number for Python
- has been incremented.
- * The binary wheel for macOS now supports Apple silicon.
-
-
- PHP
- * chore: [PHP] fix phpdoc for MapField keys (#9536)
- * [PHP] Remove unnecessary zval initialization (#9600)
- * [PHP] fix PHP build system (#9571)
- * Fix building packaged PHP extension (#9727)
- * fix: reserve "ReadOnly" keyword for PHP 8.1 and add compatibility (#9633)
- * fix: phpdoc syntax for repeatedfield parameters (#9784)
- * fix: phpdoc for repeatedfield (#9783)
- * Change enum string name for reserved words (#9780)
- * Fixed composer.json to only advertise compatibility with PHP 7.0+. (#9819)
-
- Ruby
- * Allow pre-compiled binaries for ruby 3.1.0 (#9566)
- * Implement `respond_to?` in RubyMessage (#9677)
- * [Ruby] Fix RepeatedField#last, #first inconsistencies (#9722)
- * Do not use range based UTF-8 validation in truffleruby (#9769)
- * Improve range handling logic of `RepeatedField` (#9799)
- * Disable the aarch64 build on macOS until it can be fixed. (#9816)
-
- Other
- * [Kotlin] remove redundant public modifiers for compiled code (#9642)
- * [C#] Update GetExtension to support getting typed value (#9655)
- * Fix invalid dependency manifest when using `descriptor_set_out` (#9647)
- * Fix C# generator handling of a field named "none" in a oneof (#9636)
- * Add initial version.json file for 21-dev (#9840)
- * Remove duplicate java generated code (#9909)
- * Fix versioning issues in 3.20.0
-
- Compiler
- * Protoc outputs the list of suggested field numbers when invalid field
- numbers are specified in the .proto file.
- * Require package names to be less than 512 bytes in length
-
-2022-04-21 version 3.20.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- PHP
- * Fix building packaged PHP extension (#9727)
-
- 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++
- * Make proto2::Message::DiscardUnknownFields() non-virtual
- * Separate RepeatedPtrField into its own header file
- * For default floating point values of 0, consider all bits significant
- * cmake: support `MSVC_RUNTIME_LIBRARY` property (#8851)
- * Fix shadowing warnings (#8926)
- * Fix for issue #8484, constant initialization doesn't compile in msvc clang-cl environment (#8993)
- * Fix build on AIX and SunOS (#8373) (#9065)
- * Add Android stlport and default toolchains to BUILD. (#8290)
-
- Java
- * For default floating point values of 0, consider all bits significant
- * Annotate `//java/com/google/protobuf/util/...` with nullness annotations
- * Use ArrayList copy constructor (#7853)
-
- 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
- * Make MessageToDict convert map keys to strings (#8122)
- * Add python-requires in setup.py (#8989)
- * Add python 3.10 (#9034)
-
- JavaScript
- * Skip exports if not available by CommonJS (#8856)
- * JS: Comply with CSP no-unsafe-eval. (#8864)
-
- PHP
- * Added "object" as a reserved name for PHP (#8962)
-
- Ruby
- * Override Map.clone to use Map's dup method (#7938)
- * Ruby: build extensions for arm64-darwin (#8232)
- * 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)
- * [C#] Make FieldDescriptor propertyName public (#7642)
-
-2021-10-04 version 3.18.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- Python
- * Update setup.py to reflect that we now require at least Python 3.5 (#8989)
- * Performance fix for DynamicMessage: force GetRaw() to be inlined (#9023)
-
- Ruby
- * Update ruby_generator.cc to allow proto2 imports in proto3 (#9003)
-
-2021-09-13 version 3.18.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- Python
- * Removed Python 2.x support.
- * Pure python descriptor_pool.AddSerializedFile() will always build the
- file and return FileDescriptor which is same with python c++ extension
- * type errors thrown by MergeFrom now report fully qualified class names
- * Protobuf python generated code are simplified. Some platforms that uses
- "is"("is not") to compare the enum or descriptor's label/type may fail,
- should use "=="("!=") instead.
-
- C++
- * Generated code now uses the c++11 standard integer types int{32,64}_t and
- uint{32,64}_t
- * Reduce memory usage of the DescriptorPool type.
- * Moved the zero-argument New() method on messages to the base class (internal
- optimization).
- * Unused return values marked with `PROTOBUF_MUST_USE_RESULT` are now
- correctly attributed.
- * Demotes PrintPath log for maps in MessageDifferencer down from WARNING to
- INFO.
- * Make sure FullMessageName() is always private.
- * Fix race condition in EnumDescriptor.
- * Remove MessageLite::GetMaybeArenaPointer.
-
- Java
- * Add @deprecated javadoc for set/get/has methods
- * correctly decode \? escape sequence in text protos
- * Avoid depending on Objects.requireNonNull() until we can verify that no
- users are depending on older Android versions.
- * disallow null string map values in put and putAll
- * Add `@CheckReturnValue` to `ByteString` API.
- * Make the `hasPresence` method public in `FieldDescriptor`.
- * Report more detailed messages in Duration and Timestamp proto parsing
- errors.
- * New Timestamps.fromDate utility method that converts a java.util.Date to a
- Timestamp proto object.
-
- Kotlin
- * Generated Kotlin code is Explicit API mode compatible
-
-2021-09-13 version 3.18.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
- C++
- * Fix warnings raised by clang 11 (#8664)
- * Make StringPiece constructible from std::string_view (#8707)
- * Add missing capability attributes for LLVM 12 (#8714)
- * Stop using std::iterator (deprecated in C++17). (#8741)
- * Move field_access_listener from libprotobuf-lite to libprotobuf (#8775)
- * Fix #7047 Safely handle setlocale (#8735)
- * Remove deprecated version of SetTotalBytesLimit() (#8794)
- * Support arena allocation of google::protobuf::AnyMetadata (#8758)
- * Fix undefined symbol error around SharedCtor() (#8827)
- * Fix default value of enum(int) in json_util with proto2 (#8835)
- * Better Smaller ByteSizeLong
- * Introduce event filters for inject_field_listener_events
- * Reduce memory usage of DescriptorPool
- * For lazy fields copy serialized form when allowed.
- * Re-introduce the InlinedStringField class
- * v2 access listener
- * Reduce padding in the proto's ExtensionRegistry map.
- * GetExtension performance optimizations
- * Make tracker a static variable rather than call static functions
- * Support extensions in field access listener
- * Annotate MergeFrom for field access listener
- * Fix incomplete types for field access listener
- * Add map_entry/new_map_entry to SpecificField in MessageDifferencer. They
- record the map items which are different in MessageDifferencer's reporter.
- * Reduce binary size due to fieldless proto messages
- * TextFormat: ParseInfoTree supports getting field end location in addition to
- start.
- * Fix repeated enum extension size in field listener
- * Enable Any Text Expansion for Descriptors::DebugString()
- * Switch from int{8,16,32,64} to int{8,16,32,64}_t
- * Reduce memory usage of the DescriptorPool type.
-
- Java
- * Fix errorprone conflict (#8723)
- * Removing deprecated TimeUtil class. (#8749)
- * Optimized FieldDescriptor.valueOf() to avoid array copying.
- * Removing deprecated TimeUtil class.
- * Add Durations.parseUnchecked(String) and Timestamps.parseUnchecked(String)
- * FieldMaskUtil: Add convenience method to mask the fields out of a given proto.
-
- JavaScript
- * Optimize binary parsing of repeated float64
- * Fix for optimization when reading doubles from binary wire format
- * Replace toArray implementation with toJSON.
-
- Python
- * Drops support for 2.7 and 3.5.
-
- PHP
- * Migrate PHP & Ruby to ABSL wyhash (#8854)
- * Added support for PHP 8.1 (currently in RC1) to the C extension (#8964)
- * Fixed PHP SEGV when constructing messages from a destructor. (#8969)
-
- Ruby
- * Move DSL implementation from C to pure Ruby (#8850)
- * Fixed a memory bug with RepeatedField#+. (#8970)
-
- Other
- * [csharp] ByteString.CreateCodedInput should use ArraySegment offset and count (#8740)
- * [ObjC] Add support for using the proto package to prefix symbols. (#8760)
- * field_presence.md: fix Go example (#8788)
-
-
- Kotlin
- * Suppress NOTHING_TO_INLINE in Kotlin generated inline functions.
-
-2021-06-04 version 3.17.3 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
- Python
- * Note: This is the last release to support Python 2.7. Future releases will
- require Python >= 3.5.
-
- C++
- * Introduce FieldAccessListener.
- * Stop emitting boilerplate {Copy/Merge}From in each ProtoBuf class
- * Fixed some uninitialized variable warnings in generated_message_reflection.cc.
-
- Kotlin
- * Fix duplicate proto files error (#8699)
-
- Java
- * Fixed parser to check that we are at a proper limit when a sub-message has
- finished parsing.
-
-2021-05-25 version 3.17.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
- Kotlin
- * Fix duplicate class error (#8653)
-
- PHP
- * Fixed SEGV in sub-message getters for well-known types when message is unset
- (#8670)
-
-2021-05-07 version 3.17.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
- PHP
- * Fixed PHP memory leaks and arginfo errors. (#8614)
- * Fixed JSON parser to allow multiple values from the same oneof as long as
- all but one are null.
-
- Ruby
- * Fixed memory bug: properly root repeated/map field when assigning. (#8639)
- * Fixed JSON parser to allow multiple values from the same oneof as long as
- all but one are null.
-
-
-2021-05-07 version 3.17.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- Protocol Compiler
- * Fix the generated source information for reserved values in Enums.
-
- C++
- * Fix -Wunused-parameter in map<string, int> fields (fixes #8494) (#8500)
- * Use byteswap.h when building against musl libc (#8503)
- * Fix -Wundefined-inline error when using SharedCtor() or SharedDtor() (#8532)
- * Fix bug where `Descriptor::DebugString()` printed proto3 synthetic oneofs.
- * Provide stable versions of `SortAndUnique()`.
- * Make sure to cache proto3 optional message fields when they are cleared.
- * Expose UnsafeArena methods to Reflection.
- * Use std::string::empty() rather than std::string::size() > 0.
-
- Kotlin
- * Restrict extension setter and getter operators to non-nullable T.
-
- Java
- * updating GSON and Guava to more recent versions (#8524)
- * Reduce the time spent evaluating isExtensionNumber by storing the extension
- ranges in a TreeMap for faster queries. This is particularly relevant for
- protos which define a large number of extension ranges, for example when
- each tag is defined as an extension.
- * Fix java bytecode estimation logic for optional fields.
- * Optimize Descriptor.isExtensionNumber.
-
- Python
- * Add MethodDescriptor.CopyToProto() (#8327)
- * Remove unused python_protobuf.{cc,h} (#8513)
- * Start publishing python aarch64 manylinux wheels normally (#8530)
- * Fix constness issue detected by MSVC standard conforming mode (#8568)
- * Make JSON parsing match C++ and Java when multiple fields from the same
- oneof are present and all but one is null.
-
- Ruby
- * Add support for proto3 json_name in compiler and field definitions (#8356)
- * Fixed memory leak of Ruby arena objects. (#8461)
- * Fix source gem compilation (#8471)
- * Fix various exceptions in Ruby on 64-bit Windows (#8563)
- * Fix crash when calculating Message hash values on 64-bit Windows (#8565)
-
- Conformance Tests
- * Added a conformance test for the case of multiple fields from the same
- oneof.
-
-2021-04-06 version 3.16.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
- Other
- * Opensourcing kotlin protos (#8272)
- * Use a newer version of rules_proto, with the new rule `proto_descriptor_set` (#8469)
-
- C++
- * Fix compiler warnings issue found in conformance_test_runner #8189 (#8190)
- * Fix MinGW-w64 build issues. (#8286)
- * [Protoc] C++ Resolved an issue where NO_DESTROY and CONSTINIT are in incorrect order (#8296)
- * Fix PROTOBUF_CONSTINIT macro redefinition (#8323)
- * Delete StringPiecePod (#8353)
- * Fix gcc error: comparison of unsigned expression in '>= 0' is always … (#8309)
- * Fix cmake install on iOS (#8301)
- * Create a CMake option to control whether or not RTTI is enabled (#8347)
- * Fix endian.h location on FreeBSD (#8351)
- * Refactor util::Status (#8354)
- * Make util::Status more similar to absl::Status (#8405)
- * Fix -Wsuggest-destructor-override for generated C++ proto classes. (#8408)
- * Refactor StatusOr and StringPiece (#8406)
- * Refactor uint128 (#8416)
- * The ::pb namespace is no longer exposed due to conflicts.
- * Allow MessageDifferencer::TreatAsSet() (and friends) to override previous
- calls instead of crashing.
- * Reduce the size of generated proto headers for protos with `string` or
- `bytes` fields.
- * Move arena() operation on uncommon path to out-of-line routine
- * For iterator-pair function parameter types, take both iterators by value.
- * Code-space savings and perhaps some modest performance improvements in
- RepeatedPtrField.
- * Eliminate nullptr check from every tag parse.
- * Remove unused _$name$_cached_byte_size_ fields.
- * Serialize extension ranges together when not broken by a proto field in the
- middle.
- * Do out-of-line allocation and deallocation of string object in ArenaString.
- * Streamline ParseContext::ParseMessage<T> to avoid code bloat and improve
- performance.
- * New member functions RepeatedField::Assign, RepeatedPtrField::{Add, Assign}.
- * Fix undefined behavior warning due to innocuous uninitialization of value
- on an error path.
- * Avoid expensive inlined code space for encoding message length for messages
- >= 128 bytes and instead do a procedure call to a shared out-of-line routine.
- * util::DefaultFieldComparator will be final in a future version of protobuf.
- Subclasses should inherit from SimpleFieldComparator instead.
-
- C#
- * Add .NET 5 target and improve WriteString performance with SIMD (#8147)
-
- Java
- * deps: update JUnit and Truth (#8319)
- * Detect invalid overflow of byteLimit and return InvalidProtocolBufferException as documented.
- * Exceptions thrown while reading from an InputStream in parseFrom are now
- included as causes.
- * Support potentially more efficient proto parsing from RopeByteStrings.
- * Clarify runtime of ByteString.Output.toStringBuffer().
- * Added UnsafeByteOperations to protobuf-lite (#8426)
-
- JavaScript
- * Make Any.pack() chainable.
-
- Python
- * Fix some constness / char literal issues being found by MSVC standard conforming mode (#8344)
- * Switch on "new" buffer API (#8339)
- * Enable crosscompiling aarch64 python wheels under dockcross manylinux docker image (#8280)
- * Fixed a bug in text format where a trailing colon was printed for repeated field.
- * When TextFormat encounters a duplicate message map key, replace the current
- one instead of merging.
-
- Objective-C
- * Move the class map to a CFDictionary. (#8328)
-
- PHP
- * read_property() handler is not supposed to return NULL (#8362)
- * Changed parameter type from long to integer (#7613)
- * fix: README supported PHP version for C extension (#8236)
-
- Ruby
- * Fixed quadratic memory usage when appending to arrays. (#8364)
- * Fixed memory leak of Ruby arena objects. (#8461)
- * Add support for proto3 json_name in compiler and field definitions. (#8356)
-
- Other
- * Some doc on AOT compilation and protobuf (#8294)
- * [CMake] Ability to pass options to protoc executable from cmake (#8374)
- * Add --fatal_warnings flag to treat warnings as errors (#8131)
- * [bazel] Remove deprecated way to depend on googletest (#8396)
- * add error returns missing from protoc to prevent it from exiting with… (#8409)
-
-
-2021-04-07 version 3.15.8 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- Ruby
- * Fixed memory leak of Ruby arena objects (#8461)
-
-2021-04-02 version 3.15.7 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- C++
- * Remove the ::pb namespace (alias) (#8423)
-
- Ruby
- * Fix unbounded memory growth for Ruby <2.7 (#8429)
- * Fixed message equality in cases where the message type is different (#8434)
-
-2021-03-10 version 3.15.6 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- Ruby
- * Fixed bug in string comparison logic (#8386)
-
-2021-03-04 version 3.15.5 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- Ruby
- * Fixed quadratic memory use in array append (#8379)
-
- PHP
- * Fixed quadratic memory use in array append (#8379)
-
- C++
- * Do not disable RTTI by default in the CMake build (#8377)
-
-2021-03-02 version 3.15.4 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- Ruby
- * Fixed SEGV when users pass nil messages (#8363)
- * Fixed quadratic memory usage when appending to arrays (#8364)
-
- C++
- * Create a CMake option to control whether or not RTTI is enabled (#8361)
-
- PHP
- * read_property() handler is not supposed to return NULL (#8362)
-
-2021-02-25 version 3.15.3 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- Ruby
- * Ruby <2.7 now uses WeakMap too, which prevents memory leaks. (#8341)
-
-2021-02-23 version 3.15.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- Ruby
- * Fix for FieldDescriptor.get(msg) (#8330)
-
- C++
- * Fix PROTOBUF_CONSTINIT macro redefinition (#8323)
-
-2021-02-05 version 3.15.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- Ruby
- * Bugfix for Message.[] for repeated or map fields (#8313)
-
-2021-02-05 version 3.15.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- Protocol Compiler
- * Optional fields for proto3 are enabled by default, and no longer require
- the --experimental_allow_proto3_optional flag.
-
- C++
- * MessageDifferencer: fixed bug when using custom ignore with multiple
- unknown fields
- * Use init_seg in MSVC to push initialization to an earlier phase.
- * Runtime no longer triggers -Wsign-compare warnings.
- * Fixed -Wtautological-constant-out-of-range-compare warning.
- * DynamicCastToGenerated works for nullptr input for even if RTTI is disabled
- * Arena is refactored and optimized.
- * Clarified/specified that the exact value of Arena::SpaceAllocated() is an
- implementation detail users must not rely on. It should not be used in
- unit tests.
- * Change the signature of Any::PackFrom() to return false on error.
- * Add fast reflection getter API for strings.
- * Constant initialize the global message instances
- * Avoid potential for missed wakeup in UnknownFieldSet
- * Now Proto3 Oneof fields have "has" methods for checking their presence in
- C++.
- * Bugfix for NVCC
- * Return early in _InternalSerialize for empty maps.
- * Adding functionality for outputting map key values in proto path logging
- output (does not affect comparison logic) and stop printing 'value' in the
- path. The modified print functionality is in the
- MessageDifferencer::StreamReporter.
- * Fixed https://github.com/protocolbuffers/protobuf/issues/8129
- * Ensure that null char symbol, package and file names do not result in a
- crash.
- * Constant initialize the global message instances
- * Pretty print 'max' instead of numeric values in reserved ranges.
- * Removed remaining instances of std::is_pod, which is deprecated in C++20.
- * Changes to reduce code size for unknown field handling by making uncommon
- cases out of line.
- * Fix std::is_pod deprecated in C++20 (#7180)
- * Fix some -Wunused-parameter warnings (#8053)
- * Fix detecting file as directory on zOS issue #8051 (#8052)
- * Don't include sys/param.h for _BYTE_ORDER (#8106)
- * remove CMAKE_THREAD_LIBS_INIT from pkgconfig CFLAGS (#8154)
- * Fix TextFormatMapTest.DynamicMessage issue#5136 (#8159)
- * Fix for compiler warning issue#8145 (#8160)
- * fix: support deprecated enums for GCC < 6 (#8164)
- * Fix some warning when compiling with Visual Studio 2019 on x64 target (#8125)
-
- Python
- * Provided an override for the reverse() method that will reverse the internal
- collection directly instead of using the other methods of the BaseContainer.
- * MessageFactory.CreateProtoype can be overridden to customize class creation.
- * Fix PyUnknownFields memory leak (#7928)
- * Add macOS Big Sur compatibility (#8126)
-
- JavaScript
- * Generate `getDescriptor` methods with `*` as their `this` type.
- * Enforce `let/const` for generated messages.
- * js/binary/utils.js: Fix jspb.utils.joinUnsignedDecimalString to work with negative bitsLow and low but non-zero bitsHigh parameter. (#8170)
-
- PHP
- * Added support for PHP 8. (#8105)
- * unregister INI entries and fix invalid read on shutdown (#8042)
- * Fix PhpDoc comments for message accessors to include "|null". (#8136)
- * fix: convert native PHP floats to single precision (#8187)
- * Fixed PHP to support field numbers >=2**28. (#8235)
- * feat: add support for deprecated fields to PHP compiler (#8223)
- * Protect against stack overflow if the user derives from Message. (#8248)
- * Fixed clone for Message, RepeatedField, and MapField. (#8245)
- * Updated upb to allow nonzero offset minutes in JSON timestamps. (#8258)
-
- Ruby
- * Added support for Ruby 3. (#8184)
- * Rewrote the data storage layer to be based on upb_msg objects from the
- upb library. This should lead to much better parsing performance,
- particularly for large messages. (#8184).
- * Fill out JRuby support (#7923)
- * [Ruby] Fix: (SIGSEGV) gRPC-Ruby issue on Windows. memory alloc infinite
- recursion/run out of memory (#8195)
- * Fix jruby support to handle messages nested more than 1 level deep (#8194)
-
- Java
- * Avoid possible UnsupportedOperationException when using CodedInputSteam
- with a direct ByteBuffer.
- * Make Durations.comparator() and Timestamps.comparator() Serializable.
- * Add more detailed error information for dynamic message field type
- validation failure
- * Removed declarations of functions declared in java_names.h from
- java_helpers.h.
- * Now Proto3 Oneof fields have "has" methods for checking their presence in
- Java.
- * Annotates Java proto generated *_FIELD_NUMBER constants.
- * Add -assumevalues to remove JvmMemoryAccessor on Android.
-
- C#
- * Fix parsing negative Int32Value that crosses segment boundary (#8035)
- * Change ByteString to use memory and support unsafe create without copy (#7645)
- * Optimize MapField serialization by removing MessageAdapter (#8143)
- * Allow FileDescriptors to be parsed with extension registries (#8220)
- * Optimize writing small strings (#8149)
-
-2020-11-11 version 3.14.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- Protocol Compiler
- * The proto compiler no longer requires a .proto filename when it is not
- generating code.
- * Added flag `--deterministic_output` to `protoc --encode=...`.
- * Fixed deadlock when using google.protobuf.Any embedded in aggregate options.
-
- C++
- * Arenas are now unconditionally enabled. cc_enable_arenas no longer has
- any effect.
- * Removed inlined string support, which is incompatible with arenas.
- * Fix a memory corruption bug in reflection when mixing optional and
- non-optional fields.
- * Make SpaceUsed() calculation more thorough for map fields.
- * Add stack overflow protection for text format with unknown field values.
- * FieldPath::FollowAll() now returns a bool to signal if an out-of-bounds
- error was encountered.
- * Performance improvements for Map.
- * Minor formatting fix when dumping a descriptor to .proto format with
- DebugString.
- * UBSAN fix in RepeatedField (#2073).
- * When running under ASAN, skip a test that makes huge allocations.
- * Fixed a crash that could happen when creating more than 256 extensions in
- a single message.
- * Fix a crash in BuildFile when passing in invalid descriptor proto.
- * Parser security fix when operating with CodedInputStream.
- * Warn against the use of AllowUnknownExtension.
- * Migrated to C++11 for-range loops instead of index-based loops where
- possible. This fixes a lot of warnings when compiling with -Wsign-compare.
- * Fix segment fault for proto3 optional (#7805)
- * Adds a CMake option to build `libprotoc` separately (#7949)
-
- Java
- * Bugfix in mergeFrom() when a oneof has multiple message fields.
- * Fix RopeByteString.RopeInputStream.read() returning -1 when told to read
- 0 bytes when not at EOF.
- * Redefine remove(Object) on primitive repeated field Lists to avoid
- autoboxing.
- * Support "\u" escapes in textformat string literals.
- * Trailing empty spaces are no longer ignored for FieldMask.
- * Fix FieldMaskUtil.subtract to recursively remove mask.
- * Mark enums with `@java.lang.Deprecated` if the proto enum has option
- `deprecated = true;`.
- * Adding forgotten duration.proto to the lite library (#7738)
-
- Python
- * Print google.protobuf.NullValue as null instead of "NULL_VALUE" when it is
- used outside WKT Value/Struct.
- * Fix bug occurring when attempting to deep copy an enum type in python 3.
- * Add a setuptools extension for generating Python protobufs (#7783)
- * Remove uses of pkg_resources in non-namespace packages. (#7902)
- * [bazel/py] Omit google/__init__.py from the Protobuf runtime. (#7908)
- * Removed the unnecessary setuptools package dependency for Python package (#7511)
- * Fix PyUnknownFields memory leak (#7928)
-
- PHP
- * Added support for "==" to the PHP C extension (#7883)
- * Added `==` operators for Map and Array. (#7900)
- * Native C well-known types (#7944)
- * Optimized away hex2bin() call in generated code (#8006)
- * New version of upb, and a new hash function wyhash in third_party. (#8000)
- * add missing hasOneof method to check presence of oneof fields (#8003)
-
- Go:
- * Update go_package options to reference google.golang.org/protobuf module.
-
- C#:
- * annotate ByteString.CopyFrom(ReadOnlySpan<byte>) as SecuritySafeCritical (#7701)
- * Fix C# optional field reflection when there are regular fields too (#7705)
- * Fix parsing negative Int32Value that crosses segment boundary (#8035)
-
- Javascript:
- * JS: parse (un)packed fields conditionally (#7379)
-
-2020-07-14 version 3.13.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- PHP:
- * The C extension is completely rewritten. The new C extension has significantly
- better parsing performance and fixes a handful of conformance issues. It will
- also make it easier to add support for more features like proto2 and proto3 presence.
- * The new C extension does not support PHP 5.x. PHP 5.x users can still use pure-PHP.
-
- C++:
- * Removed deprecated unsafe arena string accessors
- * Enabled heterogeneous lookup for std::string keys in maps.
- * Removed implicit conversion from StringPiece to std::string
- * Fix use-after-destroy bug when the Map is allocated in the arena.
- * Improved the randomness of map ordering
- * Added stack overflow protection for text format with unknown fields
- * Use std::hash for proto maps to help with portability.
- * Added more Windows macros to proto whitelist.
- * Arena constructors for map entry messages are now marked "explicit"
- (for regular messages they were already explicit).
- * Fix subtle aliasing bug in RepeatedField::Add
- * Fix mismatch between MapEntry ByteSize and Serialize with respect to unset
- fields.
-
- Python:
- * JSON format conformance fixes:
- * Reject lowercase t for Timestamp json format.
- * Print full_name directly for extensions (no camelCase).
- * Reject boolean values for integer fields.
- * Reject NaN, Infinity, -Infinity that is not quoted.
- * Base64 fixes for bytes fields: accept URL-safe base64 and missing padding.
- * Bugfix for fields/files named "async" or "await".
- * Improved the error message when AttributeError is returned from __getattr__
- in EnumTypeWrapper.
-
- Java:
- * Fixed a bug where setting optional proto3 enums with setFooValue() would
- not mark the value as present.
- * Add Subtract function to FieldMaskUtil.
-
- C#:
- * Dropped support for netstandard1.0 (replaced by support for netstandard1.1).
- This was required to modernize the parsing stack to use the `Span<byte>`
- type internally. (#7351)
- * Add `ParseFrom(ReadOnlySequence<byte>)` method to enable GC friendly
- parsing with reduced allocations and buffer copies. (#7351)
- * Add support for serialization directly to a `IBufferWriter<byte>` or
- to a `Span<byte>` to enable GC friendly serialization.
- The new API is available as extension methods on the `IMessage` type. (#7576)
- * Add `GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE` define to make
- generated code compatible with old C# compilers (pre-roslyn compilers
- from .NET framework and old versions of mono) that do not support
- ref structs. Users that are still on a legacy stack that does
- not support C# 7.2 compiler might need to use the new define
- in their projects to be able to build the newly generated code. (#7490)
- * Due to the major overhaul of parsing and serialization internals (#7351 and #7576),
- it is recommended to regenerate your generated code to achieve the best
- performance (the legacy generated code will still work, but might incur
- a slight performance penalty).
-
-2020-07-28 version 3.12.4 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
-This release contains no significant changes, but exists because 3.12.3 was
-mistakenly tagged at the wrong commit.
-
-2020-06-01 version 3.12.3 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- Objective-C
- * Tweak the union used for Extensions to support old generated code. #7573
-
-2020-05-26 version 3.12.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- C++
- * Simplified the template export macros to fix the build for mingw32. (#7539)
-
- Objective-C
- * Fix for the :protobuf_objc target in the Bazel BUILD file. (#7538)
-
-2020-05-20 version 3.12.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- Ruby
- * Re-add binary gems for Ruby 2.3 and 2.4. These are EOL upstream, however
- many people still use them and dropping support will require more
- coordination.
-
-2020-05-12 version 3.12.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- Protocol Compiler
- * [experimental] Singular, non-message typed fields in proto3 now support
- presence tracking. This is enabled by adding the "optional" field label and
- passing the --experimental_allow_proto3_optional flag to protoc.
- * For usage info, see docs/field_presence.md.
- * During this experimental phase, code generators should update to support
- proto3 presence, see docs/implementing_proto3_presence.md for instructions.
- * Allow duplicate symbol names when multiple descriptor sets are passed on
- the command-line, to match the behavior when multiple .proto files are passed.
- * Deterministic `protoc --descriptor_set_out` (#7175)
-
- C++
- * [experimental] Added proto3 presence support.
- * New descriptor APIs to support proto3 presence.
- * Enable Arenas by default on all .proto files.
- * Documented that users are not allowed to subclass Message or MessageLite.
- * Mark generated classes as final; inheriting from protos is strongly discouraged.
- * Add stack overflow protection for text format with unknown fields.
- * Add accessors for map key and value FieldDescriptors.
- * Add FieldMaskUtil::FromFieldNumbers().
- * MessageDifferencer: use ParsePartial() on Any fields so the diff does not
- fail when there are missing required fields.
- * ReflectionOps::Merge(): lookup messages in the right factory, if it can.
- * Added Descriptor::WellKnownTypes enum and Descriptor::well_known_type()
- accessor as an easier way of determining if a message is a Well-Known Type.
- * Optimized RepeatedField::Add() when it is used in a loop.
- * Made proto move/swap more efficient.
- * De-virtualize the GetArena() method in MessageLite.
- * Improves performance of json_stream_parser.cc by factor 1000 (#7230)
- * bug: #7076 undefine Windows OUT and OPTIONAL macros (#7087)
- * Fixed a bug in FieldDescriptor::DebugString() that would erroneously print
- an "optional" label for a field in a oneof.
- * Fix bug in parsing bool extensions that assumed they are always 1 byte.
- * Fix off-by-one error in FieldOptions::ByteSize() when extensions are present.
- * Clarified the comments to show an example of the difference between
- Descriptor::extension and DescriptorPool::FindAllExtensions.
- * Add a compiler option 'code_size' to force optimize_for=code_size on all
- protos where this is possible.
-
- Java
- * [experimental] Added proto3 presence support.
- * Mark java enum _VALUE constants as @Deprecated if the enum field is deprecated
- * reduce <clinit> size for enums with allow_alias set to true.
- * Sort map fields alphabetically by the field's key when printing textproto.
- * Fixed a bug in map sorting that appeared in -rc1 and -rc2 (#7508).
- * TextFormat.merge() handles Any as top level type.
- * Throw a descriptive IllegalArgumentException when calling
- getValueDescriptor() on enum special value UNRECOGNIZED instead of
- ArrayIndexOutOfBoundsException.
- * Fixed an issue with JsonFormat.printer() where setting printingEnumsAsInts()
- would override the configuration passed into includingDefaultValueFields().
- * Implement overrides of indexOf() and contains() on primitive lists returned
- for repeated fields to avoid autoboxing the list contents.
- * Add overload to FieldMaskUtil.fromStringList that accepts a descriptor.
- * [bazel] Move Java runtime/toolchains into //java (#7190)
-
- Python
- * [experimental] Added proto3 presence support.
- * [experimental] fast import protobuf module, only works with cpp generated code linked in.
- * Truncate 'float' fields to 4 bytes of precision in setters for pure-Python
- implementation (C++ extension was already doing this).
- * Fixed a memory leak in C++ bindings.
- * Added a deprecation warning when code tries to create Descriptor objects
- directly.
- * Fix unintended comparison between bytes and string in descriptor.py.
- * Avoid printing excess digits for float fields in TextFormat.
- * Remove Python 2.5 syntax compatibility from the proto compiler generated _pb2.py module code.
- * Drop 3.3, 3.4 and use single version docker images for all python tests (#7396)
-
- JavaScript
- * Fix js message pivot selection (#6813)
-
- PHP
- * Persistent Descriptor Pool (#6899)
- * Implement lazy loading of php class for proto messages (#6911)
- * Correct @return in Any.unpack docblock (#7089)
- * Ignore unknown enum value when ignore_unknown specified (#7455)
-
- Ruby
- * [experimental] Implemented proto3 presence for Ruby. (#7406)
- * Stop building binary gems for ruby <2.5 (#7453)
- * Fix for wrappers with a zero value (#7195)
- * Fix for JSON serialization of 0/empty-valued wrapper types (#7198)
- * Call "Class#new" over rb_class_new_instance in decoding (#7352)
- * Build extensions for Ruby 2.7 (#7027)
- * assigning 'nil' to submessage should clear the field. (#7397)
-
- C#
- * [experimental] Add support for proto3 presence fields in C# (#7382)
- * Mark GetOption API as obsolete and expose the "GetOptions()" method on descriptors instead (#7491)
- * Remove Has/Clear members for C# message fields in proto2 (#7429)
- * Enforce recursion depth checking for unknown fields (#7132)
- * Fix conformance test failures for Google.Protobuf (#6910)
- * Cleanup various bits of Google.Protobuf (#6674)
- * Fix latest ArgumentException for C# extensions (#6938)
- * Remove unnecessary branch from ReadTag (#7289)
-
- Objective-C
- * [experimental] ObjC Proto3 optional support (#7421)
- * Block subclassing of generated classes (#7124)
- * Use references to Obj C classes instead of names in descriptors. (#7026)
- * Revisit how the WKTs are bundled with ObjC. (#7173)
-
- Other
- * Add a proto_lang_toolchain for javalite (#6882)
- * [bazel] Update gtest and deprecate //external:{gtest,gtest_main} (#7237)
- * Add application note for explicit presence tracking. (#7390)
- * Howto doc for implementing proto3 presence in a code generator. (#7407)
-
-
-2020-02-14 version 3.11.4 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- C#
- * Fix latest ArgumentException for C# extensions (#7188)
- * Enforce recursion depth checking for unknown fields (#7210)
-
- Ruby
- * Fix wrappers with a zero value (#7195)
- * Fix JSON serialization of 0/empty-valued wrapper types (#7198)
-
-2020-01-31 version 3.11.3 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- C++
- * Add OUT and OPTIONAL to windows portability files (#7087)
-
- PHP
- * Refactored ulong to zend_ulong for php7.4 compatibility (#7147)
- * Call register_class before getClass from desc to fix segfault (#7077)
-
-
-2019-12-10 version 3.11.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- PHP
- * Make c extension portable for php 7.4 (#6968)
-
-
-2019-12-02 version 3.11.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- PHP
- * Extern declare protobuf_globals (#6946)
-
-
-2019-11-19 version 3.11.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- C++
- * Make serialization method naming consistent
- * Make proto runtime + generated code free of deprecation warnings
- * Moved ShutdownProtobufLibrary() to message_lite.h. For backward compatibility a declaration is still available in stubs/common.h, but users should prefer message_lite.h
- * Removed non-namespace macro EXPECT_OK()
- * Removed mathlimits.h from stubs in favor of using std::numeric_limits from C++11
- * Fixed bug in parser when ending on a group tag
- * Add a helper function to UnknownFieldSet to deal with the changing return value of message::unknown_fields()
- * Fix incorrect use of string_view iterators
- * Support direct pickling of nested messages
- * Skip extension tag validation for MessageSet if unknown dependencies are allowed
- * Updated deprecation macros to annotate deprecated code (#6612)
- * Remove conversion warning in MapEntryFuncs::ByteSizeLong (#6766)
- * Revert "Make shared libraries be able to link to MSVC static runtime libraries, so that VC runtime is not required." (#6914)
-
- Java
- * Remove the usage of MethodHandle, so that Android users prior to API version 26 can use protobuf-java
- * Publish ProGuard config for javalite
- * Fix for StrictMode disk read violation in ExtensionRegistryLite
- * Include part of the ByteString's content in its toString().
- * Include unknown fields when merging proto3 messages in Java lite builders
-
- Python
- * Add float_precision option in json format printer
- * Optionally print bytes fields as messages in unknown fields, if possible
- * FieldPath: fix testing IsSet on root path ''
- * Experimental code gen (fast import protobuf module) which only work with cpp generated code linked in
-
- JavaScript
- * Remove guard for Symbol iterator for jspb.Map
-
- PHP
- * Avoid too much overhead in layout_init (#6716)
- * Lazily Create Singular Wrapper Message (#6833)
- * Implement lazy loading of php class for proto messages (#6911)
-
- Ruby
- * Ruby lazy wrappers optimization (#6797)
-
- C#
- * (RepeatedField): Capacity property to resize the internal array (#6530)
- * Experimental proto2 support is now officially available (#4642, #5183, #5350, #5936)
- * Getting started doc: https://github.com/protocolbuffers/protobuf/blob/master/docs/csharp/proto2.md
- * Add length checks to ExtensionCollection (#6759)
- * Optimize parsing of some primitive and wrapper types (#6843)
- * Use 3 parameter Encoding.GetString for default string values (#6828)
- * Change _Extensions property to normal body rather than expression (#6856)
-
- Objective C
- * Fixed unaligned reads for 32bit arm with newer Xcode versions (#6678)
-
-
-2019-09-03 version 3.10.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- C++
- * Switch the proto parser to the faster MOMI parser.
- * Properly escape Struct keys in the proto3 JSON serializer.
- * Fix crash on uninitialized map entries.
- * Informed the compiler of has-bit invariant to produce better code
- * Unused imports of files defining descriptor extensions will now be reported
- * Add proto2::util::RemoveSubranges to remove multiple subranges in linear time.
- * Added BaseTextGenerator::GetCurrentIndentationSize()
- * Made implicit weak fields compatible with the Apple linker
- * Support 32 bit values for ProtoStreamObjectWriter to Struct.
- * Removed the internal-only header coded_stream_inl.h and the internal-only methods defined there.
- * Enforced no SWIG wrapping of descriptor_database.h (other headers already had this restriction).
- * Implementation of the equivalent of the MOMI parser for serialization. This removes one of the two serialization routines, by making the fast array serialization routine completely general. SerializeToCodedStream can now be implemented in terms of the much much faster array serialization. The array serialization regresses slightly, but when array serialization is not possible this wins big.
- * Do not convert unknown field name to snake case to accurately report error.
- * Fix a UBSAN warnings. (#6333)
- * Add podspec for C++ (#6404)
- * protoc: fix source code info location for missing label (#6436)
- * C++ Add move constructor for Reflection's SetString (#6477)
-
- Java
- * Call loadDescriptor outside of synchronized block to remove one possible source of deadlock.
- * Have oneof enums implement a separate interface (other than EnumLite) for clarity.
- * Opensource Android Memory Accessors
- * Update TextFormat to make use of the new TypeRegistry.
- * Support getFieldBuilder and getRepeatedFieldBuilder in ExtendableBuilder
- * Update JsonFormat to make use of the new TypeRegistry.
- * Add proguard config generator for GmmBenchmarkSuiteLite.
- * Change ProtobufArrayList to use Object[] instead of ArrayList for 5-10% faster parsing
- * Implement ProtobufArrayList.add(E) for 20% (5%-40%) faster overall protolite2 parsing
- * Make a copy of JsonFormat.TypeRegistry at the protobuf top level package. This will eventually replace JsonFormat.TypeRegistry.
- * Fix javadoc warnings in generated files (#6231)
- * Java: Add Automatic-Module-Name entries to the Manifest (#6568)
-
- Python
- * Add descriptor methods in descriptor_pool are deprecated.
- * Uses explicit imports to prevent multithread test failures in py3.
- * Added __delitem__ for Python extension dict
- * Update six version to 1.12.0 and fix legacy_create_init issue (#6391)
-
- JavaScript
- * Remove deprecated boolean option to getResultBase64String().
- * Fix sint64 zig-zag encoding.
- * Simplify hash64 string conversion to avoid DIGIT array. Should reduce overhead if these functions aren't used, and be more efficient by avoiding linear array searches.
- * Change the parameter types of binaryReaderFn in ExtensionFieldBinaryInfo to (number, ?, ?).
- * Create dates.ts and time_of_days.ts to mirror Java versions. This is a near-identical conversion of c.g.type.util.{Dates,TimeOfDays} respectively.
- * Migrate moneys to TypeScript.
-
- PHP
- * Fix incorrect leap day for Timestamp (#6696)
- * Initialize well known type values (#6713)
-
- Ruby
- * Fix scope resolution for Google namespace (#5878)
- * Support hashes for struct initializers (#5716)
- * Optimized away the creation of empty string objects. (#6502)
- * Roll forward Ruby upb changes now that protobuf Ruby build is fixed (#5866)
- * Optimized layout_mark() for Ruby (#6521)
- * Optimization for layout_init() (#6547)
- * Fix for GC of Ruby map frames. (#6533)
- * Fixed leap year handling by reworking upb_mktime() -> upb_timegm(). (#6695)
-
- Objective C
- * Remove OSReadLittle* due to alignment requirements (#6678)
- * Don't use unions and instead use memcpy for the type swaps. (#6672)
-
- Other
- * Override CocoaPods module to lowercase (#6464)
-
-
-2019-06-28 version 3.9.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- C++
- * Optimize and simplify implementation of RepeatedPtrFieldBase
- * Don't create unnecessary unknown field sets.
- * Remove branch from accessors to repeated field element array.
- * Added delimited parse and serialize util.
- * Reduce size by not emitting constants for fieldnumbers
- * Fix a bug when comparing finite and infinite field values with explicit tolerances.
- * TextFormat::Parser should use a custom Finder to look up extensions by number if one is provided.
- * Add MessageLite::Utf8DebugString() to make MessageLite more compatible with Message.
- * Fail fast for better performance in DescriptorPool::FindExtensionByNumber() if descriptor has no defined extensions.
- * Adding the file name to help debug colliding extensions
- * Added FieldDescriptor::PrintableNameForExtension() and DescriptorPool::FindExtensionByPrintableName().
- The latter will replace Reflection::FindKnownExtensionByName().
- * Replace NULL with nullptr
- * Created a new Add method in repeated field that allows adding a range of elements all at once.
- * Enabled enum name-to-value mapping functions for C++ lite
- * Avoid dynamic initialization in descriptor.proto generated code
- * Move stream functions to MessageLite from Message.
- * Move all zero_copy_stream functionality to io_lite.
- * Do not create array of matched fields for simple repeated fields
- * Enabling silent mode by default to reduce make compilation noise. (#6237)
-
- Java
- * Expose TextFormat.Printer and make it configurable. Deprecate the static methods.
- * Library for constructing google.protobuf.Struct and google.protobuf.Value
- * Make OneofDescriptor extend GenericDescriptor.
- * Expose streamingness of service methods from MethodDescriptor.
- * Fix a bug where TextFormat fails to parse Any filed with > 1 embedded message sub-fields.
- * Establish consistent JsonFormat behavior for nulls in oneofs, regardless of order.
- * Update GSON version to 3.8.5. (#6268)
- * Add `protobuf_java_lite` Bazel target. (#6177)
-
- Python
- * Change implementation of Name() for enums that allow aliases in proto2 in Python
- to be in line with claims in C++ implementation (to return first value).
- * Explicitly say what field cannot be set when the new value fails a type check.
- * Duplicate register in descriptor pool will raise errors
- * Add __slots__ to all well_known_types classes, custom attributes are not allowed anymore.
- * text_format only present 8 valid digits for float fields by default
-
- JavaScript
- * Add Oneof enum to the list of goog.provide
-
- PHP
- * Make php message class final to avoid mocking. (#6277)
- * Rename get/setXXXValue to get/setXXXWrapper. (#6295)
-
- Ruby
- * Remove to_hash methods. (#6166)
-
-
-2019-04-29 version 3.8.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- C++
- * Use std::atomic<int32> in case of myriad2 platform
- * Always declare enums to be int-sized
- * Added DebugString() and ShortDebugString() methods on MessageLite
- * Specialized different parse loop control flows
- * Make hasbits potentially in register. The or's start forming an obstacle because it's a read modify store on the same mem address on each iteration.
- * Move to an internal MACRO for parser validity checks.
- * Improve map parsing performance.
- * Make MergePartialFromCodedStream non virtual. This allows direct calls, potential inlining and is also a code health improvement
- * Add an overall limit to parse_context to prevent reading past it. This allows to remove a annoying level of indirection.
- * Fix a mistake, we shouldn't verify map key/value strings for utf8 in opt mode for proto2.
- * Further improvements to cut binary size.
- * Prepare to make MergePartialFromCodedStream non-virtual.
- * A report on some interesting behavior change in python (caused by b/27494216) made me realize there is a check that needs to be done in case the parse ended on a end group tag.
- * Add a note of caution to the comments around skip in CodedOutputStream.
- * Simplify end check.
- * Add overload for ParseMessage for MessageLite/Message types. If the explicit type is not known inlining won't help de-virtualizing the virtual call.
- * Reduce linker input. It turns out that ParseMessage is not inlined, producing template instantiations that are used only once and save nothing but cost more.
- * Improve the parser.
- * [c++17] Changed proto2::RepeatedPtrField iterators to no longer derive from the deprecated std::iterator class.
- * Change the default value of case_insensitive_enum_parsing to false for JsonStringToMessage.
- * Add a warning if a field name doesn't match the style guide.
- * Fix TextFormat not round-trip correctly when float value is max float.
- * Added locationed info for some errors at compiler
- * Python reserved keywords are now working with getattr()/setattr() for most descriptors.
- * Added AllowUnknownField() in text_format
- * Append '_' to C++ reserved keywords for message, enum, extension
- * Fix MSVC warning C4244 in protobuf's parse_context.h.
- * Updating Iterators to be compatible with C++17 in MSVC.
- * Use capability annotation in mutex.h
- * Fix "UndefinedBehaviorSanitizer: cfi-bad-type"
- * CriticalSectionLock class as a lightweight replacement for std::mutex on Windows platforms.
- * Removed vestigial wire_format_lite_inl.h
-
- C#
- * Added System.Memory dependency.
-
- Java
- * Make Java protoc code generator ignore optimize_for LITE_RUNTIME. Users should instead use the Java lite protoc plugin.
- * Change Extension getMessageDefaultInstance() to return Message instead of MessageLite.
- * Prevent malicious input streams from leaking buffers for ByteString or ByteBuffer parsing.
- * Release new Javalite runtime.
- * Show warning in case potential file name conflict.
- * Allow Java reserved keywords to be used in extensions.
- * Added setAllowUnknownFields() in text format
- * Add memoization to ExtensionRegistryLite.getEmptyRegistry()
- * Improve performance of CodedOutputStream.writeUInt32NoTag
- * Add an optimized mismatch-finding algorithm to UnsafeUtil.
- * When serializing uint32 varints, check that we have MAX_VARINT32_SIZE bytes left, not just MAX_VARINT_SIZE.
- * Minor optimization to RopeByteString.PieceIterator
-
- JavaScript
- * Simplify generated toObject code when the default value is used.
-
- Python
- * Changes implementation of Name() for enums that allow aliases in proto2 in Python to be in line with claims in C++ implementation (to return first value).
- * Added double_format option in text format printer.
- * Added iter and __contains__ to extension dict
- * Added allow_unknown_field option in python text format parser
- * Fixed Timestamp.ToDatetime() loses precision issue
- * Support unknown field in text format printer.
- * Float field will be convert to inf if bigger than struct.unpack('f', b'\xff\xff\x7f\x7f')[0] which is about 3.4028234664e+38,
- convert to -inf if smaller than -3.4028234664e+38
- * Allowed casting str->bytes in Message.__setstate__
-
- Ruby
- * Helper methods to get enum name for Ruby.
-
-
-2019-01-24 version 3.7.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- C++
- * Introduced new MOMI (maybe-outside-memory-interval) parser.
- * Add an option to json_util to parse enum as case-insensitive. In the future, enum parsing in json_util will become case-sensitive.
- * Added conformance test for enum aliases
- * Added support for --cpp_out=speed:...
- * Added use of C++ override keyword where appropriate
- * Many other cleanups and fixes.
-
- Java
- * Fix illegal reflective access warning in JDK 9+
- * Add BOM
-
- Python
- * Added Python 3.7 compatibility.
- * Modified ParseFromString to return bytes parsed .
- * Introduce Proto C API.
- * FindFileContainingSymbol in descriptor pool is now able to find field and enum values.
- * reflection.MakeClass() and reflection.ParseMessage() are deprecated.
- * Added DescriptorPool.FindMethodByName() method in pure python (c extension already has it)
- * Flipped proto3 to preserve unknown fields by default.
- * Added support for memoryview in python3 proto message parsing.
- * Added MergeFrom for repeated scalar fields in c extension (pure python already has it)
- * Surrogates are now rejected at setters in python3.
- * Added public unknown field API.
- * RecursionLimit is also set to max if allow_oversize_protos is enabled.
- * Disallow duplicate scalars in proto3 text_format parse.
- * Fix some segment faults for c extension map field.
-
- PHP
- * Most issues for json encoding/decoding in the c extension have been fixed. There are still some edge cases not fixed. For more details, check conformance/failure_list_php_c.txt.
- * Supports php 7.3
- * Added helper methods to convert between enum values and names.
- * Allow setting/getting wrapper message fields using primitive values.
- * Various bug fixes.
-
- Ruby
- * Ruby 2.6 support.
- * Drops support for ruby < 2.3.
- * Most issues for json encoding/decoding in the c extension have been fixed. There are still some edge cases not fixed. For more details, check conformance/failure_list_ruby.txt.
- * Json parsing can specify an option to ignore unknown fields: msg.decode_json(data, {ignore_unknown_fields: true}).
- * Added support for proto2 syntax (partially).
- * Various bug fixes.
-
- Csharp
- * More support for FieldMask include merge, intersect and more.
- * Increasing the default recursion limit to 100.
- * Support loading FileDescriptors dynamically.
- * Provide access to comments from descriptors.
- * Added Any.Is method.
- * Compatible with C# 6
- * Added IComparable and comparison operators on Timestamp.
-
- Objective C
- * Add ability to introspect list of enum values (#4678)
- * Copy the value when setting message/data fields (#5215)
- * Support suppressing the objc package prefix checks on a list of files (#5309)
- * More complete keyword and NSObject method (via categories) checks for field names, can result in more fields being rename, but avoids the collisions at runtime (#5289)
- * Small fixes to TextFormat generation for extensions (#5362)
- * Provide more details/context in deprecation messages (#5412)
- * Array/Dictionary enumeration blocks NS_NOESCAPE annotation for Swift (#5421)
- * Properly annotate extensions for ARC when their names imply behaviors (#5427)
- * Enum alias name collision improvements (#5480)
-
-
-2018-07-27 version 3.6.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- C++
- * Introduced workaround for Windows issue with std::atomic and std::once_flag
- initialization (#4777, #4773).
-
- PHP
- * Added compatibility with PHP 7.3 (#4898).
-
- Ruby
- * Fixed Ruby crash involving Any encoding (#4718).
-
-2018-06-01 version 3.6.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- C++
- * Starting from this release, we now require C++11. For those we cannot yet
- upgrade to C++11, we will try to keep the 3.5.x branch updated with
- critical bug fixes only. If you have any concerns about this, please
- comment on issue #2780.
- * Moved to C++11 types like std::atomic and std::unique_ptr and away from our
- old custom-built equivalents.
- * Added support for repeated message fields in lite protos using implicit
- weak fields. This is an experimental feature that allows the linker to
- strip out more unused messages than previously was possible.
- * Fixed SourceCodeInfo for interpreted options and extension range options.
- * Fixed always_print_enums_as_ints option for JSON serialization.
- * Added support for ignoring unknown enum values when parsing JSON.
- * Create std::string in Arena memory.
- * Fixed ValidateDateTime to correctly check the day.
- * Fixed bug in ZeroCopyStreamByteSink.
- * Various other cleanups and fixes.
-
- Java
- * Dropped support for Java 6.
- * Added a UTF-8 decoder that uses Unsafe to directly decode a byte buffer.
- * Added deprecation annotations to generated code for deprecated oneof
- fields.
- * Fixed map field serialization in DynamicMessage.
- * Cleanup and documentation for Java Lite runtime.
- * Various other fixes and cleanups
- * Fixed unboxed arraylists to handle an edge case
- * Improved performance for copying between unboxed arraylists
- * Fixed lite protobuf to avoid Java compiler warnings
- * Improved test coverage for lite runtime
- * Performance improvements for lite runtime
-
- Python
- * Fixed bytes/string map key incompatibility between C++ and pure-Python
- implementations (issue #4029)
- * Added __init__.py files to compiler and util subpackages
- * Use /MT for all Windows versions
- * Fixed an issue affecting the Python-C++ implementation when used with
- Cython (issue #2896)
- * Various text format fixes
- * Various fixes to resolve behavior differences between the pure-Python and
- Python-C++ implementations
-
- PHP
- * Added php_metadata_namespace to control the file path of generated metadata
- file.
- * Changed generated classes of nested message/enum. E.g., Foo.Bar, which
- previously generates Foo_Bar, now generates Foo/Bar
- * Added array constructor. When creating a message, users can pass a php
- array whose content is field name to value pairs into constructor. The
- created message will be initialized according to the array. Note that
- message field should use a message value instead of a sub-array.
- * Various bug fixes.
-
- Objective-C
- * We removed some helper class methods from GPBDictionary to shrink the size
- of the library, the functionary is still there, but you may need to do some
- specific +alloc / -init… methods instead.
- * Minor improvements in the performance of object field getters/setters by
- avoiding some memory management overhead.
- * Fix a memory leak during the raising of some errors.
- * Make header importing completely order independent.
- * Small code improvements for things the undefined behaviors compiler option
- was flagging.
-
- Ruby
- * Added ruby_package file option to control the module of generated class.
- * Various bug fixes.
-
- Javascript
- * Allow setting string to int64 field.
-
- Csharp
- * Unknown fields are now parsed and then sent back on the wire. They can be
- discarded at parse time via a CodedInputStream option.
- * Movement towards working with .NET 3.5 and Unity
- * Expression trees are no longer used
- * AOT generics issues in Unity/il2cpp have a workaround (see this commit for
- details)
- * Floating point values are now compared bitwise (affects NaN value
- comparisons)
- * The default size limit when parsing is now 2GB rather than 64MB
- * MessageParser now supports parsing from a slice of a byte array
- * JSON list parsing now accepts null values where the underlying proto
- representation does
-
-2017-12-20 version 3.5.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
- Planned Future Changes
- * Make C++ implementation C++11 only: we plan to require C++11 to build
- protobuf code starting from 3.6.0 release. Please join this github issue:
- https://github.com/protocolbuffers/protobuf/issues/2780 to provide your feedback.
-
- protoc
- * Fixed a bug introduced in 3.5.0 and protoc in Windows now accepts non-ascii
- characters in paths again.
-
- C++
- * Removed several usages of C++11 features in the code base.
- * Fixed some compiler warnings.
-
- PHP
- * Fixed memory leak in C-extension implementation.
- * Added discardUnknokwnFields API.
- * Removed duplicated typedef in C-extension headers.
- * Avoided calling private php methods (timelib_update_ts).
- * Fixed Any.php to use fully-qualified name for DescriptorPool.
-
- Ruby
- * Added Google_Protobuf_discard_unknown for discarding unknown fields in
- messages.
-
- C#
- * Unknown fields are now preserved by default.
- * Floating point values are now bitwise compared, affecting message equality
- check and Contains() API in map and repeated fields.
-
-
-2017-11-13 version 3.5.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
- Planned Future Changes
- * Make C++ implementation C++11 only: we plan to require C++11 to build
- protobuf code starting from 3.6.0 release. Please join this github issue:
- https://github.com/protocolbuffers/protobuf/issues/2780 to provide your feedback.
-
- General
- * Unknown fields are now preserved in proto3 for most of the language
- implementations for proto3 by default. See the per-language section for
- details.
- * reserve keyword are now supported in enums
-
- C++
- * Proto3 messages are now preserving unknown fields by default. If you rely on
- unknowns fields being dropped. Please use DiscardUnknownFields() explicitly.
- * Deprecated the unsafe_arena_release_* and unsafe_arena_add_allocated_*
- methods for string fields.
- * Added move constructor and move assignment to RepeatedField,
- RepeatedPtrField and google::protobuf::Any.
- * Added perfect forwarding in Arena::CreateMessage
- * In-progress experimental support for implicit weak fields with lite protos.
- This feature allows the linker to strip out more unused messages and reduce
- binary size.
- * Various performance optimizations.
-
- Java
- * Proto3 messages are now preserving unknown fields by default. If you’d like
- to drop unknown fields, please use the DiscardUnknownFieldsParser API. For
- example:
- Parser<Foo> parser = DiscardUnknownFieldsParser.wrap(Foo.parser());
- Foo foo = parser.parseFrom(input);
- * Added a new CodedInputStream decoder for Iterable<ByteBuffer> with direct
- ByteBuffers.
- * TextFormat now prints unknown length-delimited fields as messages if
- possible.
- * FieldMaskUtil.merge() no longer creates unnecessary empty messages when a
- message field is unset in both source message and destination message.
- * Various performance optimizations.
-
- Python
- * Proto3 messages are now preserving unknown fields by default. Use
- message.DiscardUnknownFields() to drop unknown fields.
- * Add FieldDescriptor.file in generated code.
- * Add descriptor pool FindOneofByName in pure python.
- * Change unknown enum values into unknown field set .
- * Add more Python dict/list compatibility for Struct/ListValue.
- * Add utf-8 support for text_format.Merge()/Parse().
- * Support numeric unknown enum values for proto3 JSON format.
- * Add warning for Unexpected end-group tag in cpp extension.
-
- PHP
- * Proto3 messages are now preserving unknown fields.
- * Provide well known type messages in runtime.
- * Add prefix ‘PB’ to generated class of reserved names.
- * Fixed all conformance tests for encode/decode json in php runtime. C
- extension needs more work.
-
- Objective-C
- * Fixed some issues around copying of messages with unknown fields and then
- mutating the unknown fields in the copy.
-
- C#
- * Added unknown field support in JsonParser.
- * Fixed oneof message field merge.
- * Simplify parsing messages from array slices.
-
- Ruby
- * Unknown fields are now preserved by default.
- * Fixed several bugs for segment fault.
-
- Javascript
- * Decoder can handle both paced and unpacked data no matter how the proto is
- defined.
- * Decoder now accept long varint for 32 bit integers.
-
-
-2017-08-14 version 3.4.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
- Planned Future Changes
- * There are some changes that are not included in this release but are planned
- for the near future
- - Preserve unknown fields in proto3: We are going to bring unknown fields
- back into proto3. In this release, some languages start to support
- preserving unknown fields in proto3, controlled by flags/options. Some
- languages also introduce explicit APIs to drop unknown fields for
- migration. Please read the change log sections by languages for details.
- For general timeline and plan:
-
- https://docs.google.com/document/d/1KMRX-G91Aa-Y2FkEaHeeviLRRNblgIahbsk4wA14gRk/view
-
- For issues and discussions:
-
- https://github.com/protocolbuffers/protobuf/issues/272
-
- - Make C++ implementation C++11 only: we plan to require C++11 to build
- protobuf code starting from 3.5.0 or 3.6.0 release, after unknown fields
- semantic changes are finished. Please join this
- github issue:
-
- https://github.com/protocolbuffers/protobuf/issues/2780
-
- to provide your feedback.
-
- General
- * Extension ranges now accept options and are customizable.
- * "reserve" keyword now supports “max” in field number ranges,
- e.g. reserve 1000 to max;
-
- C++
- * Proto3 messages are now able to preserve unknown fields. The default
- behavior is still to drop unknowns, which will be flipped in a future
- release. If you rely on unknowns fields being dropped. Please use
- Message::DiscardUnknownFields() explicitly.
- * Packable proto3 fields are now packed by default in serialization.
- * Following C++11 features are introduced when C++11 is available:
- - move-constructor and move-assignment are introduced to messages
- - Repeated fields constructor now takes std::initializer_list
- - rvalue setters are introduced for string fields
- * Experimental Table-Driven parsing and serialization available to test. To
- enable it, pass in table_driven_parsing table_driven_serialization protoc
- generator flags for C++
-
- $ protoc --cpp_out=table_driven_parsing,table_driven_serialization:./ \
- test.proto
-
- * lite generator parameter supported by the generator. Once set, all generated
- files, use lite runtime regardless of the optimizer_for setting in the
- .proto file.
- * Various optimizations to make C++ code more performant on PowerPC platform
- * Fixed maps data corruption when the maps are modified by both reflection API
- and generated API.
- * Deterministic serialization on maps reflection now uses stable sort.
- * file() accessors are introduced to various *Descriptor classes to make
- writing template function easier.
- * ByteSize() and SpaceUsed() are deprecated.Use ByteSizeLong() and
- SpaceUsedLong() instead
- * Consistent hash function is used for maps in DEBUG and NDEBUG build.
- * "using namespace std" is removed from stubs/common.h
- * Various performance optimizations and bug fixes
-
- Java
- * Introduced new parser API DiscardUnknownFieldsParser in preparation of
- proto3 unknown fields preservation change. Users who want to drop unknown
- fields should migrate to use this new parser API. For example:
-
- Parser<Foo> parser = DiscardUnknownFieldsParser.wrap(Foo.parser());
- Foo foo = parser.parseFrom(input);
-
- * Introduced new TextFormat API printUnicodeFieldValue() that prints field
- value without escaping unicode characters.
- * Added Durations.compare(Duration, Duration) and
- Timestamps.compare(Timestamp, Timestamp).
- * JsonFormat now accepts base64url encoded bytes fields.
- * Optimized CodedInputStream to do less copies when parsing large bytes
- fields.
- * Optimized TextFormat to allocate less memory when printing.
-
- Python
- * SerializeToString API is changed to SerializeToString(self, **kwargs),
- deterministic parameter is accepted for deterministic serialization.
- * Added sort_keys parameter in json format to make the output deterministic.
- * Added indent parameter in json format.
- * Added extension support in json format.
- * Added __repr__ support for repeated field in cpp implementation.
- * Added file in FieldDescriptor.
- * Added pretty-print filter to text format.
- * Services and method descriptors are always printed even if generic_service
- option is turned off.
- * Note: AppEngine 2.5 is deprecated on June 2017 that AppEngine 2.5 will
- never update protobuf runtime. Users who depend on AppEngine 2.5 should use
- old protoc.
-
- PHP
- * Support PHP generic services. Specify file option php_generic_service=true
- to enable generating service interface.
- * Message, repeated and map fields setters take value instead of reference.
- * Added map iterator in c extension.
- * Support json  encode/decode.
- * Added more type info in getter/setter phpdoc
- * Fixed the problem that c extension and php implementation cannot be used
- together.
- * Added file option php_namespace to use custom php namespace instead of
- package.
- * Added fluent setter.
- * Added descriptor API in runtime for custom encode/decode.
- * Various bug fixes.
-
- Objective-C
- * Fix for GPBExtensionRegistry copying and add tests.
- * Optimize GPBDictionary.m codegen to reduce size of overall library by 46K
- per architecture.
- * Fix some cases of reading of 64bit map values.
- * Properly error on a tag with field number zero.
- * Preserve unknown fields in proto3 syntax files.
- * Document the exceptions on some of the writing apis.
-
- C#
- * Implemented IReadOnlyDictionary<K,V> in MapField<K,V>
- * Added TryUnpack method for Any message in addition to Unpack.
- * Converted C# projects to MSBuild (csproj) format.
-
- Ruby
- * Several bug fixes.
-
- Javascript
- * Added support of field option js_type. Now one can specify the JS type of a
- 64-bit integer field to be string in the generated code by adding option
- [jstype = JS_STRING] on the field.
-
-2017-04-05 version 3.3.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
- Planned Future Changes
- * There are some changes that are not included in this release but are
- planned for the near future:
- - Preserve unknown fields in proto3: please read this doc:
-
- https://docs.google.com/document/d/1KMRX-G91Aa-Y2FkEaHeeviLRRNblgIahbsk4wA14gRk/view
-
- for the timeline and follow up this github issue:
-
- https://github.com/protocolbuffers/protobuf/issues/272
-
- for discussion.
- - Make C++ implementation C++11 only: we plan to require C++11 to build
- protobuf code starting from 3.4.0 or 3.5.0 release. Please join this
- github issue:
-
- https://github.com/protocolbuffers/protobuf/issues/2780
-
- to provide your feedback.
-
- C++
- * Fixed map fields serialization of DynamicMessage to correctly serialize
- both key and value regardless of their presence.
- * Parser now rejects field number 0 correctly.
- * New API Message::SpaceUsedLong() that’s equivalent to
- Message::SpaceUsed() but returns the value in size_t.
- * JSON support
- - New flag always_print_enums_as_ints in JsonPrintOptions.
- - New flag preserve_proto_field_names in JsonPrintOptions. It will instruct
- the JSON printer to use the original field name declared in the .proto
- file instead of converting them to lowerCamelCase when printing JSON.
- - JsonPrintOptions.always_print_primtive_fields now works for oneof message
- fields.
- - Fixed a bug that doesn’t allow different fields to set the same json_name
- value.
- - Fixed a performance bug that causes excessive memory copy when printing
- large messages.
- * Various performance optimizations.
-
- Java
- * Map field setters eagerly validate inputs and throw NullPointerExceptions
- as appropriate.
- * Added ByteBuffer overloads to the generated parsing methods and the Parser
- interface.
- * proto3 enum's getNumber() method now throws on UNRECOGNIZED values.
- * Output of JsonFormat is now locale independent.
-
- Python
- * Added FindServiceByName() in the pure-Python DescriptorPool. This works only
- for descriptors added with DescriptorPool.Add(). Generated descriptor_pool
- does not support this yet.
- * Added a descriptor_pool parameter for parsing Any in text_format.Parse().
- * descriptor_pool.FindFileContainingSymbol() now is able to find nested
- extensions.
- * Extending empty [] to repeated field now sets parent message presence.
-
- PHP
- * Added file option php_class_prefix. The prefix will be prepended to all
- generated classes defined in the file.
- * When encoding, negative int32 values are sign-extended to int64.
- * Repeated/Map field setter accepts a regular PHP array. Type checking is
- done on the array elements.
- * encode/decode are renamed to serializeToString/mergeFromString.
- * Added mergeFrom, clear method on Message.
- * Fixed a bug that oneof accessor didn’t return the field name that is
- actually set.
- * C extension now works with php7.
- * This is the first GA release of PHP. We guarantee that old generated code
- can always work with new runtime and new generated code.
-
- Objective-C
- * Fixed help for GPBTimestamp for dates before the epoch that contain
- fractional seconds.
- * Added GPBMessageDropUnknownFieldsRecursively() to remove unknowns from a
- message and any sub messages.
- * Addressed a threading race in extension registration/lookup.
- * Increased the max message parsing depth to 100 to match the other languages.
- * Removed some use of dispatch_once in favor of atomic compare/set since it
- needs to be heap based.
- * Fixes for new Xcode 8.3 warnings.
-
- C#
- * Fixed MapField.Values.CopyTo, which would throw an exception unnecessarily
- if provided exactly the right size of array to copy to.
- * Fixed enum JSON formatting when multiple names mapped to the same numeric
- value.
- * Added JSON formatting option to format enums as integers.
- * Modified RepeatedField<T> to implement IReadOnlyList<T>.
- * Introduced the start of custom option handling; it's not as pleasant as it
- might be, but the information is at least present. We expect to extend code
- generation to improve this in the future.
- * Introduced ByteString.FromStream and ByteString.FromStreamAsync to
- efficiently create a ByteString from a stream.
- * Added whole-message deprecation, which decorates the class with [Obsolete].
-
- Ruby
- * Fixed Message#to_h for messages with map fields.
- * Fixed memcpy() in binary gems to work for old glibc, without breaking the
- build for non-glibc libc’s like musl.
-
- Javascript
- * Added compatibility tests for version 3.0.0.
- * Added conformance tests.
- * Fixed serialization of extensions: we need to emit a value even if it is
- falsy (like the number 0).
- * Use closurebuilder.py in favor of calcdeps.py for compiling JavaScript.
-
-2017-01-23 version 3.2.0 (C++/Java/Python/PHP/Ruby/Objective-C/C#/JavaScript/Lite)
- General
- * Added protoc version number to protoc plugin protocol. It can be used by
- protoc plugin to detect which version of protoc is used with the plugin and
- mitigate known problems in certain version of protoc.
-
- C++
- * The default parsing byte size limit has been raised from 64MB to 2GB.
- * Added rvalue setters for non-arena string fields.
- * Enabled debug logging for Android.
- * Fixed a double-free problem when using Reflection::SetAllocatedMessage()
- with extension fields.
- * Fixed several deterministic serialization bugs:
- * MessageLite::SerializeAsString() now respects the global deterministic
- serialization flag.
- * Extension fields are serialized deterministically as well. Fixed protocol
- compiler to correctly report importing-self as an error.
- * Fixed FileDescriptor::DebugString() to print custom options correctly.
- * Various performance/codesize optimizations and cleanups.
-
- Java
- * The default parsing byte size limit has been raised from 64MB to 2GB.
- * Added recursion limit when parsing JSON.
- * Fixed a bug that enumType.getDescriptor().getOptions() doesn't have custom
- options.
- * Fixed generated code to support field numbers up to 2^29-1.
-
- Python
- * You can now assign NumPy scalars/arrays (np.int32, np.int64) to protobuf
- fields, and assigning other numeric types has been optimized for
- performance.
- * Pure-Python: message types are now garbage-collectable.
- * Python/C++: a lot of internal cleanup/refactoring.
-
- PHP (Alpha)
- * For 64-bit integers type (int64/uint64/sfixed64/fixed64/sint64), use PHP
- integer on 64-bit environment and PHP string on 32-bit environment.
- * PHP generated code also conforms to PSR-4 now.
- * Fixed ZTS build for c extension.
- * Fixed c extension build on Mac.
- * Fixed c extension build on 32-bit linux.
- * Fixed the bug that message without namespace is not found in the descriptor
- pool. (#2240)
- * Fixed the bug that repeated field is not iterable in c extension.
- * Message names Empty will be converted to GPBEmpty in generated code.
- * Added phpdoc in generated files.
- * The released API is almost stable. Unless there is large problem, we won't
- change it. See
- https://developers.google.com/protocol-buffers/docs/reference/php-generated
- for more details.
-
- Objective-C
- * Added support for push/pop of the stream limit on CodedInputStream for
- anyone doing manual parsing.
-
- C#
- * No changes.
-
- Ruby
- * Message objects now support #respond_to? for field getters/setters.
- * You can now compare “message == non_message_object” and it will return false
- instead of throwing an exception.
- * JRuby: fixed #hashCode to properly reflect the values in the message.
-
- Javascript
- * Deserialization of repeated fields no longer has quadratic performance
- behavior.
- * UTF-8 encoding/decoding now properly supports high codepoints.
- * Added convenience methods for some well-known types: Any, Struct, and
- Timestamp. These make it easier to convert data between native JavaScript
- types and the well-known protobuf types.
-
-2016-09-23 version 3.1.0 (C++/Java/Python/PHP/Ruby/Objective-C/C#/JavaScript/Lite)
- General
- * Proto3 support in PHP (alpha).
- * Various bug fixes.
-
- C++
- * Added MessageLite::ByteSizeLong() that’s equivalent to
- MessageLite::ByteSize() but returns the value in size_t. Useful to check
- whether a message is over the 2G size limit that protobuf can support.
- * Moved default_instances to global variables. This allows default_instance
- addresses to be known at compile time.
- * Adding missing generic gcc 64-bit atomicops.
- * Restore New*Callback into google::protobuf namespace since these are used
- by the service stubs code
- * JSON support.
- * Fixed some conformance issues.
- * Fixed a JSON serialization bug for bytes fields.
-
- Java
- * Fixed a bug in TextFormat that doesn’t accept empty repeated fields (i.e.,
- “field: [ ]”).
- * JSON support
- * Fixed JsonFormat to do correct snake_case-to-camelCase conversion for
- non-style-conforming field names.
- * Fixed JsonFormat to parse empty Any message correctly.
- * Added an option to JsonFormat.Parser to ignore unknown fields.
- * Experimental API
- * Added UnsafeByteOperations.unsafeWrap(byte[]) to wrap a byte array into
- ByteString without copy.
-
- Python
- * JSON support
- * Fixed some conformance issues.
-
- PHP (Alpha)
- * We have added the proto3 support for PHP via both a pure PHP package and a
- native c extension. The pure PHP package is intended to provide usability
- to wider range of PHP platforms, while the c extension is intended to
- provide higher performance. Both implementations provide the same runtime
- APIs and share the same generated code. Users don’t need to re-generate
- code for the same proto definition when they want to switch the
- implementation later. The pure PHP package is included in the php/src
- directory, and the c extension is included in the php/ext directory.
-
- Both implementations provide idiomatic PHP APIs:
- * All messages and enums are defined as PHP classes.
- * All message fields can only be accessed via getter/setter.
- * Both repeated field elements and map elements are stored in containers
- that act like a normal PHP array.
-
- Unlike several existing third-party PHP implementations for protobuf, our
- implementations are built on a "strongly-typed" philosophy: message fields
- and array/map containers will throw exceptions eagerly when values of the
- incorrect type (not including those that can be type converted, e.g.,
- double <-> integer <-> numeric string) are inserted.
-
- Currently, pure PHP runtime supports php5.5, 5.6 and 7 on linux. C
- extension runtime supports php5.5 and 5.6 on linux.
-
- See php/README.md for more details about installment. See
- https://developers.google.com/protocol-buffers/docs/phptutorial for more
- details about APIs.
-
- Objective-C
- * Helpers are now provided for working the Any well known type (see
- GPBWellKnownTypes.h for the api additions).
- * Some improvements in startup code (especially when extensions aren’t used).
-
- Javascript
- * Fixed missing import of jspb.Map
- * Fixed valueWriterFn variable name
-
- Ruby
- * Fixed hash computation for JRuby's RubyMessage
- * Make sure map parsing frames are GC-rooted.
- * Added API support for well-known types.
-
- C#
- * Removed check on dependency in the C# reflection API.
-
-2016-09-06 version 3.0.2 (C++/Java/Python/Ruby/Objective-C/C#/JavaScript/Lite)
- General
- * Various bug fixes.
-
- Objective C
- * Fix for oneofs in proto3 syntax files where fields were set to the zero
- value.
- * Fix for embedded null character in strings.
- * CocoaDocs support
-
- Ruby
- * Fixed memory corruption bug in parsing that could occur under GC pressure.
-
- Javascript
- * jspb.Map is now properly exported to CommonJS modules.
-
- C#
- * Removed legacy_enum_values flag.
-
-
-2016-07-27 version 3.0.0 (C++/Java/Python/Ruby/Objective-C/C#/JavaScript/Lite)
- General
- * This log only contains changes since the beta-4 release. Summarized change
- log since the last stable release (v2.6.1) can be found in the github
- release page.
-
- Compatibility Notice
- * v3.0.0 is the first API stable release of the v3.x series. We do not expect
- any future API breaking changes.
- * For C++, Java Lite and Objective-C, source level compatibility is
- guaranteed. Upgrading from v3.0.0 to newer minor version releases will be
- source compatible. For example, if your code compiles against protobuf
- v3.0.0, it will continue to compile after you upgrade protobuf library to
- v3.1.0.
- * For other languages, both source level compatibility and binary level
- compatibility are guaranteed. For example, if you have a Java binary built
- against protobuf v3.0.0. After switching the protobuf runtime binary to
- v3.1.0, your built binary should continue to work.
- * Compatibility is only guaranteed for documented API and documented
- behaviors. If you are using undocumented API (e.g., use anything in the C++
- internal namespace), it can be broken by minor version releases in an
- undetermined manner.
-
- Ruby
- * When you assign a string field `a.string_field = "X"`, we now call
- #encode(UTF-8) on the string and freeze the copy. This saves you from
- needing to ensure the string is already encoded as UTF-8. It also prevents
- you from mutating the string after it has been assigned (this is how we
- ensure it stays valid UTF-8).
- * The generated file for `foo.proto` is now `foo_pb.rb` instead of just
- `foo.rb`. This makes it easier to see which imports/requires are from
- protobuf generated code, and also prevents conflicts with any `foo.rb` file
- you might have written directly in Ruby. It is a backward-incompatible
- change: you will need to update all of your `require` statements.
- * For package names like `foo_bar`, we now translate this to the Ruby module
- `FooBar`. This is more idiomatic Ruby than what we used to do (`Foo_bar`).
-
- JavaScript
- * Scalar fields like numbers and boolean now return defaults instead of
- `undefined` or `null` when they are unset. You can test for presence
- explicitly by calling `hasFoo()`, which we now generate for scalar fields.
-
- Java Lite
- * Java Lite is now implemented as a separate plugin, maintained in the
- `javalite` branch. Both lite runtime and protoc artifacts will be available
- in Maven.
-
- C#
- * Target platforms now .NET 4.5, selected portable subsets and .NET Core.
- * legacy_enum_values option is no longer supported.
-
-2016-07-15 version 3.0.0-beta-4 (C++/Java/Python/Ruby/Objective-C/C#/JavaScript)
- General
- * Added a deterministic serialization API for C++. The deterministic
- serialization guarantees that given a binary, equal messages will be
- serialized to the same bytes. This allows applications like MapReduce to
- group equal messages based on the serialized bytes. The deterministic
- serialization is, however, NOT canonical across languages; it is also
- unstable across different builds with schema changes due to unknown fields.
- Users who need canonical serialization, e.g. persistent storage in a
- canonical form, fingerprinting, etc, should define their own
- canonicalization specification and implement the serializer using reflection
- APIs rather than relying on this API.
- * Added OneofOptions. You can now define custom options for oneof groups.
- import "google/protobuf/descriptor.proto";
- extend google.protobuf.OneofOptions {
- optional int32 my_oneof_extension = 12345;
- }
- message Foo {
- oneof oneof_group {
- (my_oneof_extension) = 54321;
- ...
- }
- }
-
- C++ (beta)
- * Introduced a deterministic serialization API in
- CodedOutputStream::SetSerializationDeterministic(bool). See the notes about
- deterministic serialization in the General section.
- * Added google::protobuf::Map::swap() to swap two map fields.
- * Fixed a memory leak when calling Reflection::ReleaseMessage() on a message
- allocated on arena.
- * Improved error reporting when parsing text format protos.
- * JSON
- - Added a new parser option to ignore unknown fields when parsing JSON.
- - Added convenient methods for message to/from JSON conversion.
- * Various performance optimizations.
-
- Java (beta)
- * File option "java_generate_equals_and_hash" is now deprecated. equals() and
- hashCode() methods are generated by default.
- * Added a new JSON printer option "omittingInsignificantWhitespace" to produce
- a more compact JSON output. The printer will pretty-print by default.
- * Updated Java runtime to be compatible with 2.5.0/2.6.1 generated protos.
-
- Python (beta)
- * Added support to pretty print Any messages in text format.
- * Added a flag to ignore unknown fields when parsing JSON.
- * Bugfix: "@type" field of a JSON Any message is now correctly put before
- other fields.
-
- Objective-C (beta)
- * Updated the code to support compiling with more compiler warnings
- enabled. (Issue 1616)
- * Exposing more detailed errors for parsing failures. (PR 1623)
- * Small (breaking) change to the naming of some methods on the support classes
- for map<>. There were collisions with the system provided KVO support, so
- the names were changed to avoid those issues. (PR 1699)
- * Fixed for proper Swift bridging of error handling during parsing. (PR 1712)
- * Complete support for generating sources that will go into a Framework and
- depend on generated sources from other Frameworks. (Issue 1457)
-
- C# (beta)
- * RepeatedField optimizations.
- * Support for .NET Core.
- * Minor bug fixes.
- * Ability to format a single value in JsonFormatter (advanced usage only).
- * Modifications to attributes applied to generated code.
-
- Javascript (alpha)
- * Maps now have a real map API instead of being treated as repeated fields.
- * Well-known types are now provided in the google-protobuf package, and the
- code generator knows to require() them from that package.
- * Bugfix: non-canonical varints are correctly decoded.
-
- Ruby (alpha)
- * Accessors for oneof fields now return default values instead of nil.
-
- Java Lite
- * Java lite support is removed from protocol compiler. It will be supported
- as a protocol compiler plugin in a separate code branch.
-
-2016-05-16 version 3.0.0-beta-3 (C++/Java/Python/Ruby/Nano/Objective-C/C#/JavaScript)
- General
- * Supported Proto3 lite-runtime in C++/Java for mobile platforms.
- * Any type now supports APIs to specify prefixes other than
- type.googleapis.com
- * Removed javanano_use_deprecated_package option; Nano will always has its own
- ".nano" package.
-
- C++ (Beta)
- * Improved hash maps.
- - Improved hash maps comments. In particular, please note that equal hash
- maps will not necessarily have the same iteration order and
- serialization.
- - Added a new hash maps implementation that will become the default in a
- later release.
- * Arenas
- - Several inlined methods in Arena were moved to out-of-line to improve
- build performance and code size.
- - Added SpaceAllocatedAndUsed() to report both space used and allocated
- - Added convenient class UnsafeArenaAllocatedRepeatedPtrFieldBackInserter
- * Any
- - Allow custom type URL prefixes in Any packing.
- - TextFormat now expand the Any type rather than printing bytes.
- * Performance optimizations and various bug fixes.
-
- Java (Beta)
- * Introduced an ExperimentalApi annotation. Annotated APIs are experimental
- and are subject to change in a backward incompatible way in future releases.
- * Introduced zero-copy serialization as an ExperimentalApi
- - Introduction of the `ByteOutput` interface. This is similar to
- `OutputStream` but provides semantics for lazy writing (i.e. no
- immediate copy required) of fields that are considered to be immutable.
- - `ByteString` now supports writing to a `ByteOutput`, which will directly
- expose the internals of the `ByteString` (i.e. `byte[]` or `ByteBuffer`)
- to the `ByteOutput` without copying.
- - `CodedOutputStream` now supports writing to a `ByteOutput`. `ByteString`
- instances that are too large to fit in the internal buffer will be
- (lazily) written to the `ByteOutput` directly.
- - This allows applications using large `ByteString` fields to avoid
- duplication of these fields entirely. Such an application can supply a
- `ByteOutput` that chains together the chunks received from
- `CodedOutputStream` before forwarding them onto the IO system.
- * Other related changes to `CodedOutputStream`
- - Additional use of `sun.misc.Unsafe` where possible to perform fast
- access to `byte[]` and `ByteBuffer` values and avoiding unnecessary
- range checking.
- - `ByteBuffer`-backed `CodedOutputStream` now writes directly to the
- `ByteBuffer` rather than to an intermediate array.
- * Improved lite-runtime.
- - Lite protos now implement deep equals/hashCode/toString
- - Significantly improved the performance of Builder#mergeFrom() and
- Builder#mergeDelimitedFrom()
- * Various bug fixes and small feature enhancement.
- - Fixed stack overflow when in hashCode() for infinite recursive oneofs.
- - Fixed the lazy field parsing in lite to merge rather than overwrite.
- - TextFormat now supports reporting line/column numbers on errors.
- - Updated to add appropriate @Override for better compiler errors.
-
- Python (Beta)
- * Added JSON format for Any, Struct, Value and ListValue
- * [ ] is now accepted for both repeated scalar fields and repeated message
- fields in text format parser.
- * Numerical field name is now supported in text format.
- * Added DiscardUnknownFields API for python protobuf message.
-
- Objective-C (Beta)
- * Proto comments now come over as HeaderDoc comments in the generated sources
- so Xcode can pick them up and display them.
- * The library headers have been updated to use HeaderDoc comments so Xcode can
- pick them up and display them.
- * The per message and per field overhead in both generated code and runtime
- object sizes was reduced.
- * Generated code now include deprecated annotations when the proto file
- included them.
-
- C# (Beta)
- In general: some changes are breaking, which require regenerating messages.
- Most user-written code will not be impacted *except* for the renaming of enum
- values.
-
- * Allow custom type URL prefixes in `Any` packing, and ignore them when
- unpacking
- * `protoc` is now in a separate NuGet package (Google.Protobuf.Tools)
- * New option: `internal_access` to generate internal classes
- * Enum values are now PascalCased, and if there's a prefix which matches the
- name of the enum, that is removed (so an enum `COLOR` with a value
- `COLOR_BLUE` would generate a value of just `Blue`). An option
- (`legacy_enum_values`) is temporarily available to disable this, but the
- option will be removed for GA.
- * `json_name` option is now honored
- * If group tags are encountered when parsing, they are validated more
- thoroughly (although we don't support actual groups)
- * NuGet dependencies are better specified
- * Breaking: `Preconditions` is renamed to `ProtoPreconditions`
- * Breaking: `GeneratedCodeInfo` is renamed to `GeneratedClrTypeInfo`
- * `JsonFormatter` now allows writing to a `TextWriter`
- * New interface, `ICustomDiagnosticMessage` to allow more compact
- representations from `ToString`
- * `CodedInputStream` and `CodedOutputStream` now implement `IDisposable`,
- which simply disposes of the streams they were constructed with
- * Map fields no longer support null values (in line with other languages)
- * Improvements in JSON formatting and parsing
-
- Javascript (Alpha)
- * Better support for "bytes" fields: bytes fields can be read as either a
- base64 string or UInt8Array (in environments where TypedArray is supported).
- * New support for CommonJS imports. This should make it easier to use the
- JavaScript support in Node.js and tools like WebPack. See js/README.md for
- more information.
- * Some significant internal refactoring to simplify and modularize the code.
-
- Ruby (Alpha)
- * JSON serialization now properly uses camelCased names, with a runtime option
- that will preserve original names from .proto files instead.
- * Well-known types are now included in the distribution.
- * Release now includes binary gems for Windows, Mac, and Linux instead of just
- source gems.
- * Bugfix for serializing oneofs.
-
- C++/Java Lite (Alpha)
- A new "lite" generator parameter was introduced in the protoc for C++ and
- Java for Proto3 syntax messages. Example usage:
-
- ./protoc --cpp_out=lite:$OUTPUT_PATH foo.proto
-
- The protoc will treat the current input and all the transitive dependencies
- as LITE. The same generator parameter must be used to generate the
- dependencies.
-
- In Proto3 syntax files, "optimized_for=LITE_RUNTIME" is no longer supported.
-
-
-2015-12-30 version 3.0.0-beta-2 (C++/Java/Python/Ruby/Nano/Objective-C/C#/JavaScript)
- General
- * Introduced a new language implementation: JavaScript.
- * Added a new field option "json_name". By default proto field names are
- converted to "lowerCamelCase" in proto3 JSON format. This option can be
- used to override this behavior and specify a different JSON name for the
- field.
- * Added conformance tests to ensure implementations are following proto3 JSON
- specification.
-
- C++ (Beta)
- * Various bug fixes and improvements to the JSON support utility:
- - Duplicate map keys in JSON are now rejected (i.e., translation will
- fail).
- - Fixed wire-format for google.protobuf.Value/ListValue.
- - Fixed precision loss when converting google.protobuf.Timestamp.
- - Fixed a bug when parsing invalid UTF-8 code points.
- - Fixed a memory leak.
- - Reduced call stack usage.
-
- Java (Beta)
- * Cleaned up some unused methods on CodedOutputStream.
- * Presized lists for packed fields during parsing in the lite runtime to
- reduce allocations and improve performance.
- * Improved the performance of unknown fields in the lite runtime.
- * Introduced UnsafeByteStrings to support zero-copy ByteString creation.
- * Various bug fixes and improvements to the JSON support utility:
- - Fixed a thread-safety bug.
- - Added a new option “preservingProtoFieldNames” to JsonFormat.
- - Added a new option “includingDefaultValueFields” to JsonFormat.
- - Updated the JSON utility to comply with proto3 JSON specification.
-
- Python (Beta)
- * Added proto3 JSON format utility. It includes support for all field types
- and a few well-known types except for Any and Struct.
- * Added runtime support for Any, Timestamp, Duration and FieldMask.
- * [ ] is now accepted for repeated scalar fields in text format parser.
- * Map fields now have proper O(1) performance for lookup/insert/delete
- when using the Python/C++ implementation. They were previously using O(n)
- search-based algorithms because the C++ reflection interface didn't
- support true map operations.
-
- Objective-C (Beta)
- * Various bug-fixes and code tweaks to pass more strict compiler warnings.
- * Now has conformance test coverage and is passing all tests.
-
- C# (Beta)
- * Various bug-fixes.
- * Code generation: Files generated in directories based on namespace.
- * Code generation: Include comments from .proto files in XML doc
- comments (naively)
- * Code generation: Change organization/naming of "reflection class" (access
- to file descriptor)
- * Code generation and library: Add Parser property to MessageDescriptor,
- and introduce a non-generic parser type.
- * Library: Added TypeRegistry to support JSON parsing/formatting of Any.
- * Library: Added Any.Pack/Unpack support.
- * Library: Implemented JSON parsing.
-
- Javascript (Alpha)
- * Added proto3 support for JavaScript. The runtime is written in pure
- JavaScript and works in browsers and in Node.js. To generate JavaScript
- code for your proto, invoke protoc with "--js_out". See js/README.md
- for more build instructions.
-
-2015-08-26 version 3.0.0-beta-1 (C++/Java/Python/Ruby/Nano/Objective-C/C#)
- About Beta
- * This is the first beta release of protobuf v3.0.0. Not all languages
- have reached beta stage. Languages not marked as beta are still in
- alpha (i.e., be prepared for API breaking changes).
-
- General
- * Proto3 JSON is supported in several languages (fully supported in C++
- and Java, partially supported in Ruby/C#). The JSON spec is defined in
- the proto3 language guide:
-
- https://developers.google.com/protocol-buffers/docs/proto3#json
-
- We will publish a more detailed spec to define the exact behavior of
- proto3-conformant JSON serializers and parsers. Until then, do not rely
- on specific behaviors of the implementation if it’s not documented in
- the above spec. More specifically, the behavior is not yet finalized for
- the following:
- - Parsing invalid JSON input (e.g., input with trailing commas).
- - Non-camelCase names in JSON input.
- - The same field appears multiple times in JSON input.
- - JSON arrays contain “null” values.
- - The message has unknown fields.
-
- * Proto3 now enforces strict UTF-8 checking. Parsing will fail if a string
- field contains non UTF-8 data.
-
- C++ (Beta)
- * Introduced new utility functions/classes in the google/protobuf/util
- directory:
- - MessageDifferencer: compare two proto messages and report their
- differences.
- - JsonUtil: support converting protobuf binary format to/from JSON.
- - TimeUtil: utility functions to work with well-known types Timestamp
- and Duration.
- - FieldMaskUtil: utility functions to work with FieldMask.
-
- * Performance optimization of arena construction and destruction.
- * Bug fixes for arena and maps support.
- * Changed to use cmake for Windows Visual Studio builds.
- * Added Bazel support.
-
- Java (Beta)
- * Introduced a new util package that will be distributed as a separate
- artifact in maven. It contains:
- - JsonFormat: convert proto messages to/from JSON.
- - TimeUtil: utility functions to work with Timestamp and Duration.
- - FieldMaskUtil: utility functions to work with FieldMask.
-
- * The static PARSER in each generated message is deprecated, and it will
- be removed in a future release. A static parser() getter is generated
- for each message type instead.
- * Performance optimizations for String fields serialization.
- * Performance optimizations for Lite runtime on Android:
- - Reduced allocations
- - Reduced method overhead after ProGuarding
- - Reduced code size after ProGuarding
-
- Python (Alpha)
- * Removed legacy Python 2.5 support.
- * Moved to a single Python 2.x/3.x-compatible codebase, instead of using 2to3.
- * Fixed build/tests on Python 2.6, 2.7, 3.3, and 3.4.
- - Pure-Python works on all four.
- - Python/C++ implementation works on all but 3.4, due to changes in the
- Python/C++ API in 3.4.
- * Some preliminary work has been done to allow for multiple DescriptorPools
- with Python/C++.
-
- Ruby (Alpha)
- * Many bugfixes:
- - fixed parsing/serialization of bytes, sint, sfixed types
- - other parser bugfixes
- - fixed memory leak affecting Ruby 2.2
-
- JavaNano (Alpha)
- * JavaNano generated code now will be put in a nano package by default to
- avoid conflicts with Java generated code.
-
- Objective-C (Alpha)
- * Added non-null markup to ObjC library. Requires SDK 8.4+ to build.
- * Many bugfixes:
- - Removed the class/enum filter.
- - Renamed some internal types to avoid conflicts with the well-known types
- protos.
- - Added missing support for parsing repeated primitive fields in packed or
- unpacked forms.
- - Added *Count for repeated and map<> fields to avoid auto-create when
- checking for them being set.
-
- C# (Alpha)
- * Namespace changed to Google.Protobuf (and NuGet package will be named
- correspondingly).
- * Target platforms now .NET 4.5 and selected portable subsets only.
- * Removed lite runtime.
- * Reimplementation to use mutable message types.
- * Null references used to represent "no value" for message type fields.
- * Proto3 semantics supported; proto2 files are prohibited for C# codegen.
- Most proto3 features supported:
- - JSON formatting (a.k.a. serialization to JSON), including well-known
- types (except for Any).
- - Wrapper types mapped to nullable value types (or string/ByteString
- allowing nullability). JSON parsing is not supported yet.
- - maps
- - oneof
- - enum unknown value preservation
-
-2015-05-25 version 3.0.0-alpha-3 (Objective-C/C#):
- General
- * Introduced two new language implementations (Objective-C, C#) to proto3.
- * Explicit "optional" keyword are disallowed in proto3 syntax, as fields are
- optional by default.
- * Group fields are no longer supported in proto3 syntax.
- * Changed repeated primitive fields to use packed serialization by default in
- proto3 (implemented for C++, Java, Python in this release). The user can
- still disable packed serialization by setting packed to false for now.
- * Added well-known type protos (any.proto, empty.proto, timestamp.proto,
- duration.proto, etc.). Users can import and use these protos just like
- regular proto files. Additional runtime support will be added for them in
- future releases (in the form of utility helper functions, or having them
- replaced by language specific types in generated code).
- * Added a "reserved" keyword in both proto2 and proto3 syntax. User can use
- this keyword to declare reserved field numbers and names to prevent them
- from being reused by other fields in the same message.
-
- To reserve field numbers, add a reserved declaration in your message:
-
- message TestMessage {
- reserved 2, 15, 9 to 11, 3;
- }
-
- This reserves field numbers 2, 3, 9, 10, 11 and 15. If a user uses any of
- these as field numbers, the protocol buffer compiler will report an error.
-
- Field names can also be reserved:
-
- message TestMessage {
- reserved "foo", "bar";
- }
-
- * Various bug fixes since 3.0.0-alpha-2
-
- Objective-C
- Objective-C includes a code generator and a native objective-c runtime
- library. By adding “--objc_out” to protoc, the code generator will generate
- a header(*.pbobjc.h) and an implementation file(*.pbobjc.m) for each proto
- file.
-
- In this first release, the generated interface provides: enums, messages,
- field support(single, repeated, map, oneof), proto2 and proto3 syntax
- support, parsing and serialization. It’s compatible with ARC and non-ARC
- usage. Besides, user can also access it via the swift bridging header.
-
- See objectivec/README.md for details.
-
- C#
- * C# protobufs are based on project
- https://github.com/jskeet/protobuf-csharp-port. The original project was
- frozen and all the new development will happen here.
- * Codegen plugin for C# was completely rewritten to C++ and is now an
- integral part of protoc.
- * Some refactorings and cleanup has been applied to the C# runtime library.
- * Only proto2 is supported in C# at the moment, proto3 support is in
- progress and will likely bring significant breaking changes to the API.
-
- See csharp/README.md for details.
-
- C++
- * Added runtime support for Any type. To use Any in your proto file, first
- import the definition of Any:
-
- // foo.proto
- import "google/protobuf/any.proto";
- message Foo {
- google.protobuf.Any any_field = 1;
- }
- message Bar {
- int32 value = 1;
- }
-
- Then in C++ you can access the Any field using PackFrom()/UnpackTo()
- methods:
-
- Foo foo;
- Bar bar = ...;
- foo.mutable_any_field()->PackFrom(bar);
- ...
- if (foo.any_field().IsType<Bar>()) {
- foo.any_field().UnpackTo(&bar);
- ...
- }
- * In text format, entries of a map field will be sorted by key.
-
- Java
- * Continued optimizations on the lite runtime to improve performance for
- Android.
-
- Python
- * Added map support.
- - maps now have a dict-like interface (msg.map_field[key] = value)
- - existing code that modifies maps via the repeated field interface
- will need to be updated.
-
- Ruby
- * Improvements to RepeatedField's emulation of the Ruby Array API.
- * Various speedups and internal cleanups.
-
-2015-02-26 version 3.0.0-alpha-2 (Python/Ruby/JavaNano):
- General
- * Introduced three new language implementations (Ruby, JavaNano, and
- Python) to proto3.
- * Various bug fixes since 3.0.0-alpha-1
-
- Python:
- Python has received several updates, most notably support for proto3
- semantics in any .proto file that declares syntax="proto3".
- Messages declared in proto3 files no longer represent field presence
- for scalar fields (number, enums, booleans, or strings). You can
- no longer call HasField() for such fields, and they are serialized
- based on whether they have a non-zero/empty/false value.
-
- One other notable change is in the C++-accelerated implementation.
- Descriptor objects (which describe the protobuf schema and allow
- reflection over it) are no longer duplicated between the Python
- and C++ layers. The Python descriptors are now simple wrappers
- around the C++ descriptors. This change should significantly
- reduce the memory usage of programs that use a lot of message
- types.
-
- Ruby:
- We have added proto3 support for Ruby via a native C extension.
-
- The Ruby extension itself is included in the ruby/ directory, and details on
- building and installing the extension are in ruby/README.md. The extension
- will also be published as a Ruby gem. Code generator support is included as
- part of `protoc` with the `--ruby_out` flag.
-
- The Ruby extension implements a user-friendly DSL to define message types
- (also generated by the code generator from `.proto` files). Once a message
- type is defined, the user may create instances of the message that behave in
- ways idiomatic to Ruby. For example:
-
- - Message fields are present as ordinary Ruby properties (getter method
- `foo` and setter method `foo=`).
- - Repeated field elements are stored in a container that acts like a native
- Ruby array, and map elements are stored in a container that acts like a
- native Ruby hashmap.
- - The usual well-known methods, such as `#to_s`, `#dup`, and the like, are
- present.
-
- Unlike several existing third-party Ruby extensions for protobuf, this
- extension is built on a "strongly-typed" philosophy: message fields and
- array/map containers will throw exceptions eagerly when values of the
- incorrect type are inserted.
-
- See ruby/README.md for details.
-
- JavaNano:
- JavaNano is a special code generator and runtime library designed especially
- for resource-restricted systems, like Android. It is very resource-friendly
- in both the amount of code and the runtime overhead. Here is an an overview
- of JavaNano features compared with the official Java protobuf:
-
- - No descriptors or message builders.
- - All messages are mutable; fields are public Java fields.
- - For optional fields only, encapsulation behind setter/getter/hazzer/
- clearer functions is opt-in, which provide proper 'has' state support.
- - For proto2, if not opted in, has state (field presence) is not available.
- Serialization outputs all fields not equal to their defaults.
- The behavior is consistent with proto3 semantics.
- - Required fields (proto2 only) are always serialized.
- - Enum constants are integers; protection against invalid values only
- when parsing from the wire.
- - Enum constants can be generated into container interfaces bearing
- the enum's name (so the referencing code is in Java style).
- - CodedInputByteBufferNano can only take byte[] (not InputStream).
- - Similarly CodedOutputByteBufferNano can only write to byte[].
- - Repeated fields are in arrays, not ArrayList or Vector. Null array
- elements are allowed and silently ignored.
- - Full support for serializing/deserializing repeated packed fields.
- - Support extensions (in proto2).
- - Unset messages/groups are null, not an immutable empty default
- instance.
- - toByteArray(...) and mergeFrom(...) are now static functions of
- MessageNano.
- - The 'bytes' type translates to the Java type byte[].
-
- See javanano/README.txt for details.
-
-2014-12-01 version 3.0.0-alpha-1 (C++/Java):
-
- General
- * Introduced Protocol Buffers language version 3 (aka proto3).
-
- When protobuf was initially opensourced it implemented Protocol Buffers
- language version 2 (aka proto2), which is why the version number
- started from v2.0.0. From v3.0.0, a new language version (proto3) is
- introduced while the old version (proto2) will continue to be supported.
-
- The main intent of introducing proto3 is to clean up protobuf before
- pushing the language as the foundation of Google's new API platform.
- In proto3, the language is simplified, both for ease of use and to
- make it available in a wider range of programming languages. At the
- same time a few features are added to better support common idioms
- found in APIs.
-
- The following are the main new features in language version 3:
-
- 1. Removal of field presence logic for primitive value fields, removal
- of required fields, and removal of default values. This makes proto3
- significantly easier to implement with open struct representations,
- as in languages like Android Java, Objective C, or Go.
- 2. Removal of unknown fields.
- 3. Removal of extensions, which are instead replaced by a new standard
- type called Any.
- 4. Fix semantics for unknown enum values.
- 5. Addition of maps.
- 6. Addition of a small set of standard types for representation of time,
- dynamic data, etc.
- 7. A well-defined encoding in JSON as an alternative to binary proto
- encoding.
-
- This release (v3.0.0-alpha-1) includes partial proto3 support for C++ and
- Java. Items 6 (well-known types) and 7 (JSON format) in the above feature
- list are not implemented.
-
- A new notion "syntax" is introduced to specify whether a .proto file
- uses proto2 or proto3:
-
- // foo.proto
- syntax = "proto3";
- message Bar {...}
-
- If omitted, the protocol compiler will generate a warning and "proto2" will
- be used as the default. This warning will be turned into an error in a
- future release.
-
- We recommend that new Protocol Buffers users use proto3. However, we do not
- generally recommend that existing users migrate from proto2 from proto3 due
- to API incompatibility, and we will continue to support proto2 for a long
- time.
-
- * Added support for map fields (implemented in C++/Java for both proto2 and
- proto3).
-
- Map fields can be declared using the following syntax:
-
- message Foo {
- map<string, string> values = 1;
- }
-
- Data of a map field will be stored in memory as an unordered map and it
- can be accessed through generated accessors.
-
- C++
- * Added arena allocation support (for both proto2 and proto3).
-
- Profiling shows memory allocation and deallocation constitutes a significant
- fraction of CPU-time spent in protobuf code and arena allocation is a
- technique introduced to reduce this cost. With arena allocation, new
- objects will be allocated from a large piece of preallocated memory and
- deallocation of these objects is almost free. Early adoption shows 20% to
- 50% improvement in some Google binaries.
-
- To enable arena support, add the following option to your .proto file:
-
- option cc_enable_arenas = true;
-
- Protocol compiler will generate additional code to make the generated
- message classes work with arenas. This does not change the existing API
- of protobuf messages and does not affect wire format. Your existing code
- should continue to work after adding this option. In the future we will
- make this option enabled by default.
-
- To actually take advantage of arena allocation, you need to use the arena
- APIs when creating messages. A quick example of using the arena API:
-
- {
- google::protobuf::Arena arena;
- // Allocate a protobuf message in the arena.
- MyMessage* message = Arena::CreateMessage<MyMessage>(&arena);
- // All submessages will be allocated in the same arena.
- if (!message->ParseFromString(data)) {
- // Deal with malformed input data.
- }
- // Must not delete the message here. It will be deleted automatically
- // when the arena is destroyed.
- }
-
- Currently arena does not work with map fields. Enabling arena in a .proto
- file containing map fields will result in compile errors in the generated
- code. This will be addressed in a future release.
-
-2014-10-20 version 2.6.1:
-
- C++
- * Added atomicops support for Solaris.
- * Released memory allocated by InitializeDefaultRepeatedFields() and
- GetEmptyString(). Some memory sanitizers reported them as memory leaks.
-
- Java
- * Updated DynamicMessage.setField() to handle repeated enum values
- correctly.
- * Fixed a bug that caused NullPointerException to be thrown when
- converting manually constructed FileDescriptorProto to
- FileDescriptor.
-
- Python
- * Fixed WhichOneof() to work with de-serialized protobuf messages.
- * Fixed a missing file problem of Python C++ implementation.
-
-2014-08-15 version 2.6.0:
-
- General
- * Added oneofs(unions) feature. Fields in the same oneof will share
- memory and at most one field can be set at the same time. Use the
- oneof keyword to define a oneof like:
- message SampleMessage {
- oneof test_oneof {
- string name = 4;
- YourMessage sub_message = 9;
- }
- }
- * Files, services, enums, messages, methods and enum values can be marked
- as deprecated now.
- * Added Support for list values, including lists of messages, when
- parsing text-formatted protos in C++ and Java.
- For example: foo: [1, 2, 3]
-
- C++
- * Enhanced customization on TestFormat printing.
- * Added SwapFields() in reflection API to swap a subset of fields.
- Added SetAllocatedMessage() in reflection API.
- * Repeated primitive extensions are now packable. The
- [packed=true] option only affects serializers. Therefore, it is
- possible to switch a repeated extension field to packed format
- without breaking backwards-compatibility.
- * Various speed optimizations.
-
- Java
- * writeTo() method in ByteString can now write a substring to an
- output stream. Added endWith() method for ByteString.
- * ByteString and ByteBuffer are now supported in CodedInputStream
- and CodedOutputStream.
- * java_generate_equals_and_hash can now be used with the LITE_RUNTIME.
-
- Python
- * A new C++-backed extension module (aka "cpp api v2") that replaces the
- old ("cpp api v1") one. Much faster than the pure Python code. This one
- resolves many bugs and is recommended for general use over the
- pure Python when possible.
- * Descriptors now have enum_types_by_name and extension_types_by_name dict
- attributes.
- * Support for Python 3.
-
-2013-02-27 version 2.5.0:
-
- General
- * New notion "import public" that allows a proto file to forward the content
- it imports to its importers. For example,
- // foo.proto
- import public "bar.proto";
- import "baz.proto";
-
- // qux.proto
- import "foo.proto";
- // Stuff defined in bar.proto may be used in this file, but stuff from
- // baz.proto may NOT be used without importing it explicitly.
- This is useful for moving proto files. To move a proto file, just leave
- a single "import public" in the old proto file.
- * New enum option "allow_alias" that specifies whether different symbols can
- be assigned the same numeric value. Default value is "true". Setting it to
- false causes the compiler to reject enum definitions where multiple symbols
- have the same numeric value.
- Note: We plan to flip the default value to "false" in a future release.
- Projects using enum aliases should set the option to "true" in their .proto
- files.
-
- C++
- * New generated method set_allocated_foo(Type* foo) for message and string
- fields. This method allows you to set the field to a pre-allocated object
- and the containing message takes the ownership of that object.
- * Added SetAllocatedExtension() and ReleaseExtension() to extensions API.
- * Custom options are now formatted correctly when descriptors are printed in
- text format.
- * Various speed optimizations.
-
- Java
- * Comments in proto files are now collected and put into generated code as
- comments for corresponding classes and data members.
- * Added Parser to parse directly into messages without a Builder. For
- example,
- Foo foo = Foo.PARSER.ParseFrom(input);
- Using Parser is ~25% faster than using Builder to parse messages.
- * Added getters/setters to access the underlying ByteString of a string field
- directly.
- * ByteString now supports more operations: substring(), prepend(), and
- append(). The implementation of ByteString uses a binary tree structure
- to support these operations efficiently.
- * New method findInitializationErrors() that lists all missing required
- fields.
- * Various code size and speed optimizations.
-
- Python
- * Added support for dynamic message creation. DescriptorDatabase,
- DescriptorPool, and MessageFactory work like their C++ counterparts to
- simplify Descriptor construction from *DescriptorProtos, and MessageFactory
- provides a message instance from a Descriptor.
- * Added pickle support for protobuf messages.
- * Unknown fields are now preserved after parsing.
- * Fixed bug where custom options were not correctly populated. Custom
- options can be accessed now.
- * Added EnumTypeWrapper that provides better accessibility to enum types.
- * Added ParseMessage(descriptor, bytes) to generate a new Message instance
- from a descriptor and a byte string.
-
-2011-05-01 version 2.4.1:
-
- C++
- * Fixed the friendship problem for old compilers to make the library now gcc 3
- compatible again.
- * Fixed vcprojects/extract_includes.bat to extract compiler/plugin.h.
-
- Java
- * Removed usages of JDK 1.6 only features to make the library now JDK 1.5
- compatible again.
- * Fixed a bug about negative enum values.
- * serialVersionUID is now defined in generated messages for java serializing.
- * Fixed protoc to use java.lang.Object, which makes "Object" now a valid
- message name again.
-
- Python
- * Experimental C++ implementation now requires C++ protobuf library installed.
- See the README.txt in the python directory for details.
-
-2011-02-02 version 2.4.0:
-
- General
- * The RPC (cc|java|py)_generic_services default value is now false instead of
- true.
- * Custom options can have aggregate types. For example,
- message MyOption {
- optional string comment = 1;
- optional string author = 2;
- }
- extend google.protobuf.FieldOptions {
- optional MyOption myoption = 12345;
- }
- This option can now be set as follows:
- message SomeType {
- optional int32 field = 1 [(myoption) = { comment:'x' author:'y' }];
- }
-
- C++
- * Various speed and code size optimizations.
- * Added a release_foo() method on string and message fields.
- * Fixed gzip_output_stream sub-stream handling.
-
- Java
- * Builders now maintain sub-builders for sub-messages. Use getFooBuilder() to
- get the builder for the sub-message "foo". This allows you to repeatedly
- modify deeply-nested sub-messages without rebuilding them.
- * Builder.build() no longer invalidates the Builder for generated messages
- (You may continue to modify it and then build another message).
- * Code generator will generate efficient equals() and hashCode()
- implementations if new option java_generate_equals_and_hash is enabled.
- (Otherwise, reflection-based implementations are used.)
- * Generated messages now implement Serializable.
- * Fields with [deprecated=true] will be marked with @Deprecated in Java.
- * Added lazy conversion of UTF-8 encoded strings to String objects to improve
- performance.
- * Various optimizations.
- * Enum value can be accessed directly, instead of calling getNumber() on the
- enum member.
- * For each enum value, an integer constant is also generated with the suffix
- _VALUE.
-
- Python
- * Added an experimental C++ implementation for Python messages via a Python
- extension. Implementation type is controlled by an environment variable
- PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION (valid values: "cpp" and "python")
- The default value is currently "python" but will be changed to "cpp" in
- future release.
- * Improved performance on message instantiation significantly.
- Most of the work on message instantiation is done just once per message
- class, instead of once per message instance.
- * Improved performance on text message parsing.
- * Allow add() to forward keyword arguments to the concrete class.
- E.g. instead of
- item = repeated_field.add()
- item.foo = bar
- item.baz = quux
- You can do:
- repeated_field.add(foo=bar, baz=quux)
- * Added a sort() interface to the BaseContainer.
- * Added an extend() method to repeated composite fields.
- * Added UTF8 debug string support.
-
-2010-01-08 version 2.3.0:
-
- General
- * Parsers for repeated numeric fields now always accept both packed and
- unpacked input. The [packed=true] option only affects serializers.
- Therefore, it is possible to switch a field to packed format without
- breaking backwards-compatibility -- as long as all parties are using
- protobuf 2.3.0 or above, at least.
- * The generic RPC service code generated by the C++, Java, and Python
- generators can be disabled via file options:
- option cc_generic_services = false;
- option java_generic_services = false;
- option py_generic_services = false;
- This allows plugins to generate alternative code, possibly specific to some
- particular RPC implementation.
-
- protoc
- * Now supports a plugin system for code generators. Plugins can generate
- code for new languages or inject additional code into the output of other
- code generators. Plugins are just binaries which accept a protocol buffer
- on stdin and write a protocol buffer to stdout, so they may be written in
- any language. See src/google/protobuf/compiler/plugin.proto.
- **WARNING**: Plugins are experimental. The interface may change in a
- future version.
- * If the output location ends in .zip or .jar, protoc will write its output
- to a zip/jar archive instead of a directory. For example:
- protoc --java_out=myproto_srcs.jar --python_out=myproto.zip myproto.proto
- Currently the archive contents are not compressed, though this could change
- in the future.
- * inf, -inf, and nan can now be used as default values for float and double
- fields.
-
- C++
- * Various speed and code size optimizations.
- * DynamicMessageFactory is now fully thread-safe.
- * Message::Utf8DebugString() method is like DebugString() but avoids escaping
- UTF-8 bytes.
- * Compiled-in message types can now contain dynamic extensions, through use
- of CodedInputStream::SetExtensionRegistry().
- * Now compiles shared libraries (DLLs) by default on Cygwin and MinGW, to
- match other platforms. Use --disable-shared to avoid this.
-
- Java
- * parseDelimitedFrom() and mergeDelimitedFrom() now detect EOF and return
- false/null instead of throwing an exception.
- * Fixed some initialization ordering bugs.
- * Fixes for OpenJDK 7.
-
- Python
- * 10-25 times faster than 2.2.0, still pure-Python.
- * Calling a mutating method on a sub-message always instantiates the message
- in its parent even if the mutating method doesn't actually mutate anything
- (e.g. parsing from an empty string).
- * Expanded descriptors a bit.
-
-2009-08-11 version 2.2.0:
-
- C++
- * Lite mode: The "optimize_for = LITE_RUNTIME" option causes the compiler
- to generate code which only depends libprotobuf-lite, which is much smaller
- than libprotobuf but lacks descriptors, reflection, and some other features.
- * Fixed bug where Message.Swap(Message) was only implemented for
- optimize_for_speed. Swap now properly implemented in both modes
- (Issue 91).
- * Added RemoveLast and SwapElements(index1, index2) to Reflection
- interface for repeated elements.
- * Added Swap(Message) to Reflection interface.
- * Floating-point literals in generated code that are intended to be
- single-precision now explicitly have 'f' suffix to avoid pedantic warnings
- produced by some compilers.
- * The [deprecated=true] option now causes the C++ code generator to generate
- a GCC-style deprecation annotation (no-op on other compilers).
- * google::protobuf::GetEnumDescriptor<SomeGeneratedEnumType>() returns the
- EnumDescriptor for that type -- useful for templates which cannot call
- SomeGeneratedEnumType_descriptor().
- * Various optimizations and obscure bug fixes.
-
- Java
- * Lite mode: The "optimize_for = LITE_RUNTIME" option causes the compiler
- to generate code which only depends libprotobuf-lite, which is much smaller
- than libprotobuf but lacks descriptors, reflection, and some other features.
- * Lots of style cleanups.
-
- Python
- * Fixed endianness bug with floats and doubles.
- * Text format parsing support.
- * Fix bug with parsing packed repeated fields in embedded messages.
- * Ability to initialize fields by passing keyword args to constructor.
- * Support iterators in extend and __setslice__ for containers.
-
-2009-05-13 version 2.1.0:
-
- General
- * Repeated fields of primitive types (types other that string, group, and
- nested messages) may now use the option [packed = true] to get a more
- efficient encoding. In the new encoding, the entire list is written
- as a single byte blob using the "length-delimited" wire type. Within
- this blob, the individual values are encoded the same way they would
- be normally except without a tag before each value (thus, they are
- tightly "packed").
- * For each field, the generated code contains an integer constant assigned
- to the field number. For example, the .proto file:
- message Foo { optional int bar_baz = 123; }
- would generate the following constants, all with the integer value 123:
- C++: Foo::kBarBazFieldNumber
- Java: Foo.BAR_BAZ_FIELD_NUMBER
- Python: Foo.BAR_BAZ_FIELD_NUMBER
- Constants are also generated for extensions, with the same naming scheme.
- These constants may be used as switch cases.
- * Updated bundled Google Test to version 1.3.0. Google Test is now bundled
- in its verbatim form as a nested autoconf package, so you can drop in any
- other version of Google Test if needed.
- * optimize_for = SPEED is now the default, by popular demand. Use
- optimize_for = CODE_SIZE if code size is more important in your app.
- * It is now an error to define a default value for a repeated field.
- Previously, this was silently ignored (it had no effect on the generated
- code).
- * Fields can now be marked deprecated like:
- optional int32 foo = 1 [deprecated = true];
- Currently this does not have any actual effect, but in the future the code
- generators may generate deprecation annotations in each language.
- * Cross-compiling should now be possible using the --with-protoc option to
- configure. See README.txt for more info.
-
- protoc
- * --error_format=msvs option causes errors to be printed in Visual Studio
- format, which should allow them to be clicked on in the build log to go
- directly to the error location.
- * The type name resolver will no longer resolve type names to fields. For
- example, this now works:
- message Foo {}
- message Bar {
- optional int32 Foo = 1;
- optional Foo baz = 2;
- }
- Previously, the type of "baz" would resolve to "Bar.Foo", and you'd get
- an error because Bar.Foo is a field, not a type. Now the type of "baz"
- resolves to the message type Foo. This change is unlikely to make a
- difference to anyone who follows the Protocol Buffers style guide.
-
- C++
- * Several optimizations, including but not limited to:
- - Serialization, especially to flat arrays, is 10%-50% faster, possibly
- more for small objects.
- - Several descriptor operations which previously required locking no longer
- do.
- - Descriptors are now constructed lazily on first use, rather than at
- process startup time. This should save memory in programs which do not
- use descriptors or reflection.
- - UnknownFieldSet completely redesigned to be more efficient (especially in
- terms of memory usage).
- - Various optimizations to reduce code size (though the serialization speed
- optimizations increased code size).
- * Message interface has method ParseFromBoundedZeroCopyStream() which parses
- a limited number of bytes from an input stream rather than parsing until
- EOF.
- * GzipInputStream and GzipOutputStream support reading/writing gzip- or
- zlib-compressed streams if zlib is available.
- (google/protobuf/io/gzip_stream.h)
- * DescriptorPool::FindAllExtensions() and corresponding
- DescriptorDatabase::FindAllExtensions() can be used to enumerate all
- extensions of a given type.
- * For each enum type Foo, protoc will generate functions:
- const string& Foo_Name(Foo value);
- bool Foo_Parse(const string& name, Foo* result);
- The former returns the name of the enum constant corresponding to the given
- value while the latter finds the value corresponding to a name.
- * RepeatedField and RepeatedPtrField now have back-insertion iterators.
- * String fields now have setters that take a char* and a size, in addition
- to the existing ones that took char* or const string&.
- * DescriptorPool::AllowUnknownDependencies() may be used to tell
- DescriptorPool to create placeholder descriptors for unknown entities
- referenced in a FileDescriptorProto. This can allow you to parse a .proto
- file without having access to other .proto files that it imports, for
- example.
- * Updated gtest to latest version. The gtest package is now included as a
- nested autoconf package, so it should be able to drop new versions into the
- "gtest" subdirectory without modification.
-
- Java
- * Fixed bug where Message.mergeFrom(Message) failed to merge extensions.
- * Message interface has new method toBuilder() which is equivalent to
- newBuilderForType().mergeFrom(this).
- * All enums now implement the ProtocolMessageEnum interface.
- * Setting a field to null now throws NullPointerException.
- * Fixed tendency for TextFormat's parsing to overflow the stack when
- parsing large string values. The underlying problem is with Java's
- regex implementation (which unfortunately uses recursive backtracking
- rather than building an NFA). Worked around by making use of possessive
- quantifiers.
- * Generated service classes now also generate pure interfaces. For a service
- Foo, Foo.Interface is a pure interface containing all of the service's
- defined methods. Foo.newReflectiveService() can be called to wrap an
- instance of this interface in a class that implements the generic
- RpcService interface, which provides reflection support that is usually
- needed by RPC server implementations.
- * RPC interfaces now support blocking operation in addition to non-blocking.
- The protocol compiler generates separate blocking and non-blocking stubs
- which operate against separate blocking and non-blocking RPC interfaces.
- RPC implementations will have to implement the new interfaces in order to
- support blocking mode.
- * New I/O methods parseDelimitedFrom(), mergeDelimitedFrom(), and
- writeDelimitedTo() read and write "delimited" messages from/to a stream,
- meaning that the message size precedes the data. This way, you can write
- multiple messages to a stream without having to worry about delimiting
- them yourself.
- * Throw a more descriptive exception when build() is double-called.
- * Add a method to query whether CodedInputStream is at the end of the input
- stream.
- * Add a method to reset a CodedInputStream's size counter; useful when
- reading many messages with the same stream.
- * equals() and hashCode() now account for unknown fields.
-
- Python
- * Added slicing support for repeated scalar fields. Added slice retrieval and
- removal of repeated composite fields.
- * Updated RPC interfaces to allow for blocking operation. A client may
- now pass None for a callback when making an RPC, in which case the
- call will block until the response is received, and the response
- object will be returned directly to the caller. This interface change
- cannot be used in practice until RPC implementations are updated to
- implement it.
- * Changes to input_stream.py should make protobuf compatible with appengine.
-
-2008-11-25 version 2.0.3:
-
- protoc
- * Enum values may now have custom options, using syntax similar to field
- options.
- * Fixed bug where .proto files which use custom options but don't actually
- define them (i.e. they import another .proto file defining the options)
- had to explicitly import descriptor.proto.
- * Adjacent string literals in .proto files will now be concatenated, like in
- C.
- * If an input file is a Windows absolute path (e.g. "C:\foo\bar.proto") and
- the import path only contains "." (or contains "." but does not contain
- the file), protoc incorrectly thought that the file was under ".", because
- it thought that the path was relative (since it didn't start with a slash).
- This has been fixed.
-
- C++
- * Generated message classes now have a Swap() method which efficiently swaps
- the contents of two objects.
- * All message classes now have a SpaceUsed() method which returns an estimate
- of the number of bytes of allocated memory currently owned by the object.
- This is particularly useful when you are reusing a single message object
- to improve performance but want to make sure it doesn't bloat up too large.
- * New method Message::SerializeAsString() returns a string containing the
- serialized data. May be more convenient than calling
- SerializeToString(string*).
- * In debug mode, log error messages when string-type fields are found to
- contain bytes that are not valid UTF-8.
- * Fixed bug where a message with multiple extension ranges couldn't parse
- extensions.
- * Fixed bug where MergeFrom(const Message&) didn't do anything if invoked on
- a message that contained no fields (but possibly contained extensions).
- * Fixed ShortDebugString() to not be O(n^2). Durr.
- * Fixed crash in TextFormat parsing if the first token in the input caused a
- tokenization error.
- * Fixed obscure bugs in zero_copy_stream_impl.cc.
- * Added support for HP C++ on Tru64.
- * Only build tests on "make check", not "make".
- * Fixed alignment issue that caused crashes when using DynamicMessage on
- 64-bit Sparc machines.
- * Simplify template usage to work with MSVC 2003.
- * Work around GCC 4.3.x x86_64 compiler bug that caused crashes on startup.
- (This affected Fedora 9 in particular.)
- * Now works on "Solaris 10 using recent Sun Studio".
-
- Java
- * New overload of mergeFrom() which parses a slice of a byte array instead
- of the whole thing.
- * New method ByteString.asReadOnlyByteBuffer() does what it sounds like.
- * Improved performance of isInitialized() when optimizing for code size.
-
- Python
- * Corrected ListFields() signature in Message base class to match what
- subclasses actually implement.
- * Some minor refactoring.
- * Don't pass self as first argument to superclass constructor (no longer
- allowed in Python 2.6).
-
-2008-09-29 version 2.0.2:
-
- General
- * License changed from Apache 2.0 to 3-Clause BSD.
- * It is now possible to define custom "options", which are basically
- annotations which may be placed on definitions in a .proto file.
- For example, you might define a field option called "foo" like so:
- import "google/protobuf/descriptor.proto"
- extend google.protobuf.FieldOptions {
- optional string foo = 12345;
- }
- Then you annotate a field using the "foo" option:
- message MyMessage {
- optional int32 some_field = 1 [(foo) = "bar"]
- }
- The value of this option is then visible via the message's
- Descriptor:
- const FieldDescriptor* field =
- MyMessage::descriptor()->FindFieldByName("some_field");
- assert(field->options().GetExtension(foo) == "bar");
- This feature has been implemented and tested in C++ and Java.
- Other languages may or may not need to do extra work to support
- custom options, depending on how they construct descriptors.
-
- C++
- * Fixed some GCC warnings that only occur when using -pedantic.
- * Improved static initialization code, making ordering more
- predictable among other things.
- * TextFormat will no longer accept messages which contain multiple
- instances of a singular field. Previously, the latter instance
- would overwrite the former.
- * Now works on systems that don't have hash_map.
-
- Java
- * Print @Override annotation in generated code where appropriate.
-
- Python
- * Strings now use the "unicode" type rather than the "str" type.
- String fields may still be assigned ASCII "str" values; they will
- automatically be converted.
- * Adding a property to an object representing a repeated field now
- raises an exception. For example:
- # No longer works (and never should have).
- message.some_repeated_field.foo = 1
-
- Windows
- * We now build static libraries rather than DLLs by default on MSVC.
- See vsprojects/readme.txt for more information.
-
-2008-08-15 version 2.0.1:
-
- protoc
- * New flags --encode and --decode can be used to convert between protobuf text
- format and binary format from the command-line.
- * New flag --descriptor_set_out can be used to write FileDescriptorProtos for
- all parsed files directly into a single output file. This is particularly
- useful if you wish to parse .proto files from programs written in languages
- other than C++: just run protoc as a background process and have it output
- a FileDescriptorList, then parse that natively.
- * Improved error message when an enum value's name conflicts with another
- symbol defined in the enum type's scope, e.g. if two enum types declared
- in the same scope have values with the same name. This is disallowed for
- compatibility with C++, but this wasn't clear from the error.
- * Fixed absolute output paths on Windows.
- * Allow trailing slashes in --proto_path mappings.
-
- C++
- * Reflection objects are now per-class rather than per-instance. To make this
- possible, the Reflection interface had to be changed such that all methods
- take the Message instance as a parameter. This change improves performance
- significantly in memory-bandwidth-limited use cases, since it makes the
- message objects smaller. Note that source-incompatible interface changes
- like this will not be made again after the library leaves beta.
- * Heuristically detect sub-messages when printing unknown fields.
- * Fix static initialization ordering bug that caused crashes at startup when
- compiling on Mac with static linking.
- * Fixed TokenizerTest when compiling with -DNDEBUG on Linux.
- * Fixed incorrect definition of kint32min.
- * Fix bytes type setter to work with byte sequences with embedded NULLs.
- * Other irrelevant tweaks.
-
- Java
- * Fixed UnknownFieldSet's parsing of varints larger than 32 bits.
- * Fixed TextFormat's parsing of "inf" and "nan".
- * Fixed TextFormat's parsing of comments.
- * Added info to Java POM that will be required when we upload the
- package to a Maven repo.
-
- Python
- * MergeFrom(message) and CopyFrom(message) are now implemented.
- * SerializeToString() raises an exception if the message is missing required
- fields.
- * Code organization improvements.
- * Fixed doc comments for RpcController and RpcChannel, which had somehow been
- swapped.
- * Fixed text_format_test on Windows where floating-point exponents sometimes
- contain extra zeros.
- * Fix Python service CallMethod() implementation.
-
- Other
- * Improved readmes.
- * VIM syntax highlighting improvements.
-
-2008-07-07 version 2.0.0:
-
- * First public release.
diff --git a/contrib/libs/protobuf/CODE_OF_CONDUCT.md b/contrib/libs/protobuf/CODE_OF_CONDUCT.md
new file mode 100644
index 00000000000..ba190630834
--- /dev/null
+++ b/contrib/libs/protobuf/CODE_OF_CONDUCT.md
@@ -0,0 +1,3 @@
+This project is governed by
+[Protobuf's Code of Conduct](https://github.com/protocolbuffers/.github/blob/main/profile/CODE_OF_CONDUCT.md).
+
diff --git a/contrib/libs/protobuf/README.md b/contrib/libs/protobuf/README.md
index c2e6575f90e..3bfeb0f1690 100644
--- a/contrib/libs/protobuf/README.md
+++ b/contrib/libs/protobuf/README.md
@@ -3,7 +3,7 @@ Protocol Buffers - Google's data interchange format
Copyright 2008 Google Inc.
-https://developers.google.com/protocol-buffers/
+[Protocol Buffers documentation](https://developers.google.com/protocol-buffers/)
Overview
--------
@@ -24,26 +24,21 @@ the [C++ Installation Instructions](src/README.md) to install protoc along
with the C++ runtime.
For non-C++ users, the simplest way to install the protocol compiler is to
-download a pre-built binary from our release page:
-
- [https://github.com/protocolbuffers/protobuf/releases](https://github.com/protocolbuffers/protobuf/releases)
+download a pre-built binary from our [GitHub release page](https://github.com/protocolbuffers/protobuf/releases).
In the downloads section of each release, you can find pre-built binaries in
-zip packages: protoc-$VERSION-$PLATFORM.zip. It contains the protoc binary
-as well as a set of standard .proto files distributed along with protobuf.
+zip packages: `protoc-$VERSION-$PLATFORM.zip`. It contains the protoc binary
+as well as a set of standard `.proto` files distributed along with protobuf.
If you are looking for an old version that is not available in the release
-page, check out the maven repo here:
-
- [https://repo1.maven.org/maven2/com/google/protobuf/protoc/](https://repo1.maven.org/maven2/com/google/protobuf/protoc/)
+page, check out the [Maven repository](https://repo1.maven.org/maven2/com/google/protobuf/protoc/).
These pre-built binaries are only provided for released versions. If you want
to use the github main version at HEAD, or you need to modify protobuf code,
or you are using C++, it's recommended to build your own protoc binary from
source.
-If you would like to build protoc binary from source, see the [C++ Installation
-Instructions](src/README.md).
+If you would like to build protoc binary from source, see the [C++ Installation Instructions](src/README.md).
Protobuf Runtime Installation
-----------------------------
@@ -63,14 +58,13 @@ how to install protobuf runtime for that specific language:
| Go | [protocolbuffers/protobuf-go](https://github.com/protocolbuffers/protobuf-go)|
| PHP | [php](php) |
| Dart | [dart-lang/protobuf](https://github.com/dart-lang/protobuf) |
+| Javascript | [protocolbuffers/protobuf-javascript](https://github.com/protocolbuffers/protobuf-javascript)|
Quick Start
-----------
-The best way to learn how to use protobuf is to follow the tutorials in our
-developer guide:
-
-https://developers.google.com/protocol-buffers/docs/tutorials
+The best way to learn how to use protobuf is to follow the [tutorials in our
+developer guide](https://developers.google.com/protocol-buffers/docs/tutorials).
If you want to learn from code examples, take a look at the examples in the
[examples](examples) directory.
@@ -78,7 +72,11 @@ If you want to learn from code examples, take a look at the examples in the
Documentation
-------------
-The complete documentation for Protocol Buffers is available via the
-web at:
+The complete documentation is available via the [Protocol Buffers documentation](https://developers.google.com/protocol-buffers/).
+
+Developer Community
+-------------------
+
+To be alerted to upcoming changes in Protocol Buffers and connect with protobuf developers and users,
+[join the Google Group](https://groups.google.com/g/protobuf).
-https://developers.google.com/protocol-buffers/
diff --git a/contrib/libs/protobuf/src/README.md b/contrib/libs/protobuf/src/README.md
index cf843d7595f..4453a6d40be 100644
--- a/contrib/libs/protobuf/src/README.md
+++ b/contrib/libs/protobuf/src/README.md
@@ -5,26 +5,31 @@ Copyright 2008 Google Inc.
https://developers.google.com/protocol-buffers/
-C++ Installation - Unix
+CMake Installation
+-----------------------
+
+To compile or install protobuf from source using CMake, see
+[cmake/README.md](../cmake/README.md).
+
+C++ Protobuf - Unix
-----------------------
To build protobuf from source, the following tools are needed:
- * autoconf
- * automake
- * libtool
- * make
+ * bazel
+ * git
* g++
- * unzip
-On Ubuntu/Debian, you can install them with:
+On Ubuntu/Debian, for example, you can install them with:
- sudo apt-get install autoconf automake libtool curl make g++ unzip
+ sudo apt-get install g++ git bazel
On other platforms, please use the corresponding package managing tool to
-install them before proceeding.
+install them before proceeding. See https://bazel.build/install for further
+instructions on installing Bazel, or to build from source using CMake, see
+[cmake/README.md](../cmake/README.md).
-To get the source, download one of the release .tar.gz or .zip packages in the
+To get the source, download the release .tar.gz or .zip package in the
release page:
https://github.com/protocolbuffers/protobuf/releases/latest
@@ -41,79 +46,23 @@ if you are using a release .tar.gz or .zip package):
git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf
git submodule update --init --recursive
- ./autogen.sh
-
-To build and install the C++ Protocol Buffer runtime and the Protocol
-Buffer compiler (protoc) execute the following:
-
- ./configure
- make -j$(nproc) # $(nproc) ensures it uses all cores for compilation
- make check
- sudo make install
- sudo ldconfig # refresh shared library cache.
+To build the C++ Protocol Buffer runtime and the Protocol Buffer compiler
+(protoc) execute the following:
-If "make check" fails, you can still install, but it is likely that
-some features of this library will not work correctly on your system.
-Proceed at your own risk.
+ bazel build :protoc :protobuf
-For advanced usage information on configure and make, please refer to the
-autoconf documentation:
+The compiler can then be installed, for example on Linux:
- http://www.gnu.org/software/autoconf/manual/autoconf.html#Running-configure-Scripts
+ cp bazel-bin/protoc /usr/local/bin
-**Hint on install location**
-
-By default, the package will be installed to /usr/local. However,
-on many platforms, /usr/local/lib is not part of LD_LIBRARY_PATH.
-You can add it, but it may be easier to just install to /usr
-instead. To do this, invoke configure as follows:
-
- ./configure --prefix=/usr
-
-If you already built the package with a different prefix, make sure
-to run "make clean" before building again.
+For more usage information on Bazel, please refer to http://bazel.build.
**Compiling dependent packages**
-To compile a package that uses Protocol Buffers, you need to pass
-various flags to your compiler and linker. As of version 2.2.0,
-Protocol Buffers integrates with pkg-config to manage this. If you
-have pkg-config installed, then you can invoke it to get a list of
-flags like so:
-
-
- pkg-config --cflags protobuf # print compiler flags
- pkg-config --libs protobuf # print linker flags
- pkg-config --cflags --libs protobuf # print both
-
-
-For example:
-
- c++ my_program.cc my_proto.pb.cc `pkg-config --cflags --libs protobuf`
-
-Note that packages written prior to the 2.2.0 release of Protocol
-Buffers may not yet integrate with pkg-config to get flags, and may
-not pass the correct set of flags to correctly link against
-libprotobuf. If the package in question uses autoconf, you can
-often fix the problem by invoking its configure script like:
-
-
- configure CXXFLAGS="$(pkg-config --cflags protobuf)" \
- LIBS="$(pkg-config --libs protobuf)"
-
-This will force it to use the correct flags.
-
-If you are writing an autoconf-based package that uses Protocol
-Buffers, you should probably use the PKG_CHECK_MODULES macro in your
-configure script like:
-
- PKG_CHECK_MODULES([protobuf], [protobuf])
-
-See the pkg-config man page for more info.
-
-If you only want protobuf-lite, substitute "protobuf-lite" in place
-of "protobuf" in these examples.
+To compile a package that uses Protocol Buffers, you need to setup a Bazel
+WORKSPACE that's hooked up to the protobuf repository and loads its
+dependencies. For an example, see [WORKSPACE](../examples/WORKSPACE).
**Note for Mac users**
@@ -127,64 +76,16 @@ To install Unix tools, you can install "port" following the instructions at
https://www.macports.org . This will reside in /opt/local/bin/port for most
Mac installations.
- sudo /opt/local/bin/port install autoconf automake libtool
+ sudo /opt/local/bin/port install bazel
Alternative for Homebrew users:
- brew install autoconf automake libtool
+ brew install bazel
Then follow the Unix instructions above.
-**Note for cross-compiling**
-
-The makefiles normally invoke the protoc executable that they just
-built in order to build tests. When cross-compiling, the protoc
-executable may not be executable on the host machine. In this case,
-you must build a copy of protoc for the host machine first, then use
-the --with-protoc option to tell configure to use it instead. For
-example:
-
- ./configure --with-protoc=protoc
-
-This will use the installed protoc (found in your $PATH) instead of
-trying to execute the one built during the build process. You can
-also use an executable that hasn't been installed. For example, if
-you built the protobuf package for your host machine in ../host,
-you might do:
-
- ./configure --with-protoc=../host/src/protoc
-
-Either way, you must make sure that the protoc executable you use
-has the same version as the protobuf source code you are trying to
-use it with.
-
-**Note for Solaris users**
-
-Solaris 10 x86 has a bug that will make linking fail, complaining
-about libstdc++.la being invalid. We have included a work-around
-in this package. To use the work-around, run configure as follows:
-
- ./configure LDFLAGS=-L$PWD/src/solaris
-
-See src/solaris/libstdc++.la for more info on this bug.
-**Note for HP C++ Tru64 users**
-
-To compile invoke configure as follows:
-
- ./configure CXXFLAGS="-O -std ansi -ieee -D__USE_STD_IOSTREAM"
-
-Also, you will need to use gmake instead of make.
-
-**Note for AIX users**
-
-Compile using the IBM xlC C++ compiler as follows:
-
- ./configure CXX=xlC
-
-Also, you will need to use GNU `make` (`gmake`) instead of AIX `make`.
-
-C++ Installation - Windows
+C++ Protobuf - Windows
--------------------------
If you only need the protoc binary, you can download it from the release
@@ -220,10 +121,10 @@ That is, if you linked an executable against an older version of
libprotobuf, it is unlikely to work with a newer version without
re-compiling. This problem, when it occurs, will normally be detected
immediately on startup of your app. Still, you may want to consider
-using static linkage. You can configure this package to install
-static libraries only using:
+using static linkage. You can configure this in your `cc_binary` Bazel rules
+by specifying:
- ./configure --disable-shared
+ linkstatic=True
Usage
-----
@@ -231,4 +132,4 @@ Usage
The complete documentation for Protocol Buffers is available via the
web at:
-https://developers.google.com/protocol-buffers/
+https://protobuf.dev/
diff --git a/contrib/libs/protobuf/src/google/protobuf/any.cc b/contrib/libs/protobuf/src/google/protobuf/any.cc
index 346fa19f17a..7d61b8f5aae 100644
--- a/contrib/libs/protobuf/src/google/protobuf/any.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/any.cc
@@ -28,15 +28,15 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <google/protobuf/any.h>
+#include "google/protobuf/any.h"
-#include <google/protobuf/arenastring.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/generated_message_util.h>
-#include <google/protobuf/message.h>
+#include "google/protobuf/arenastring.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/generated_message_util.h"
+#include "google/protobuf/message.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -47,7 +47,7 @@ bool AnyMetadata::PackFrom(Arena* arena, const Message& message) {
}
bool AnyMetadata::PackFrom(Arena* arena, const Message& message,
- StringPiece type_url_prefix) {
+ y_absl::string_view type_url_prefix) {
type_url_->Set(
GetTypeUrl(message.GetDescriptor()->full_name(), type_url_prefix), arena);
return message.SerializeToString(value_->Mutable(arena));
@@ -79,4 +79,4 @@ bool GetAnyFieldDescriptors(const Message& message,
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protobuf/src/google/protobuf/any.h b/contrib/libs/protobuf/src/google/protobuf/any.h
index a9f23bf2a52..25ab40840e8 100644
--- a/contrib/libs/protobuf/src/google/protobuf/any.h
+++ b/contrib/libs/protobuf/src/google/protobuf/any.h
@@ -33,12 +33,12 @@
#include <string>
-#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/arenastring.h"
+#include "google/protobuf/message_lite.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -52,8 +52,8 @@ extern const char kAnyFullTypeName[]; // "google.protobuf.Any".
extern const char kTypeGoogleApisComPrefix[]; // "type.googleapis.com/".
extern const char kTypeGoogleProdComPrefix[]; // "type.googleprod.com/".
-TProtoStringType GetTypeUrl(StringPiece message_name,
- StringPiece type_url_prefix);
+TProtoStringType GetTypeUrl(y_absl::string_view message_name,
+ y_absl::string_view type_url_prefix);
// Helper class used to implement google::protobuf::Any.
class PROTOBUF_EXPORT AnyMetadata {
@@ -63,6 +63,8 @@ class PROTOBUF_EXPORT AnyMetadata {
// AnyMetadata does not take ownership of "type_url" and "value".
constexpr AnyMetadata(UrlType* type_url, ValueType* value)
: type_url_(type_url), value_(value) {}
+ AnyMetadata(const AnyMetadata&) = delete;
+ AnyMetadata& operator=(const AnyMetadata&) = delete;
// Packs a message using the default type URL prefix: "type.googleapis.com".
// The resulted type URL will be "type.googleapis.com/<message_full_name>".
@@ -84,13 +86,13 @@ class PROTOBUF_EXPORT AnyMetadata {
// Returns false if serializing the message failed.
template <typename T>
bool PackFrom(Arena* arena, const T& message,
- StringPiece type_url_prefix) {
+ y_absl::string_view type_url_prefix) {
return InternalPackFrom(arena, message, type_url_prefix,
T::FullMessageName());
}
bool PackFrom(Arena* arena, const Message& message,
- StringPiece type_url_prefix);
+ y_absl::string_view type_url_prefix);
// Unpacks the payload into the given message. Returns false if the message's
// type doesn't match the type specified in the type URL (i.e., the full
@@ -113,16 +115,14 @@ class PROTOBUF_EXPORT AnyMetadata {
private:
bool InternalPackFrom(Arena* arena, const MessageLite& message,
- StringPiece type_url_prefix,
- StringPiece type_name);
- bool InternalUnpackTo(StringPiece type_name,
+ y_absl::string_view type_url_prefix,
+ y_absl::string_view type_name);
+ bool InternalUnpackTo(y_absl::string_view type_name,
MessageLite* message) const;
- bool InternalIs(StringPiece type_name) const;
+ bool InternalIs(y_absl::string_view type_name) const;
UrlType* type_url_;
ValueType* value_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(AnyMetadata);
};
// Get the proto type name from Any::type_url value. For example, passing
@@ -132,14 +132,14 @@ class PROTOBUF_EXPORT AnyMetadata {
//
// NOTE: this function is available publicly as a static method on the
// generated message type: google::protobuf::Any::ParseAnyTypeUrl()
-bool ParseAnyTypeUrl(StringPiece type_url, TProtoStringType* full_type_name);
+bool ParseAnyTypeUrl(y_absl::string_view type_url, TProtoStringType* full_type_name);
// Get the proto type name and prefix from Any::type_url value. For example,
// passing "type.googleapis.com/rpc.QueryOrigin" will return
// "type.googleapis.com/" in *url_prefix and "rpc.QueryOrigin" in
// *full_type_name. Returns false if the type_url does not have a "/" in the
// type url separating the full type name.
-bool ParseAnyTypeUrl(StringPiece type_url, TProtoStringType* url_prefix,
+bool ParseAnyTypeUrl(y_absl::string_view type_url, TProtoStringType* url_prefix,
TProtoStringType* full_type_name);
// See if message is of type google.protobuf.Any, if so, return the descriptors
@@ -152,6 +152,6 @@ bool GetAnyFieldDescriptors(const Message& message,
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_ANY_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/any.pb.cc b/contrib/libs/protobuf/src/google/protobuf/any.pb.cc
index 4226a72340a..89e9def671a 100644
--- a/contrib/libs/protobuf/src/google/protobuf/any.pb.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/any.pb.cc
@@ -1,93 +1,123 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/any.proto
-#include <google/protobuf/any.pb.h>
+#include "google/protobuf/any.pb.h"
#include <algorithm>
-
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/extension_set.h>
-#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/reflection_ops.h>
-#include <google/protobuf/wire_format.h>
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/extension_set.h"
+#include "google/protobuf/wire_format_lite.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/reflection_ops.h"
+#include "google/protobuf/wire_format.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+// Must be included last.
+#include "google/protobuf/port_def.inc"
PROTOBUF_PRAGMA_INIT_SEG
-
namespace _pb = ::PROTOBUF_NAMESPACE_ID;
-namespace _pbi = _pb::internal;
-
+namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal;
#if defined(__llvm__)
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wuninitialized"
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wuninitialized"
#endif // __llvm__
PROTOBUF_NAMESPACE_OPEN
PROTOBUF_CONSTEXPR Any::Any(
::_pbi::ConstantInitialized): _impl_{
- /*decltype(_impl_.type_url_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.value_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
+ /*decltype(_impl_.type_url_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.value_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
, /*decltype(_impl_._cached_size_)*/{}
, /*decltype(_impl_._any_metadata_)*/{&_impl_.type_url_, &_impl_.value_}} {}
struct AnyDefaultTypeInternal {
- PROTOBUF_CONSTEXPR AnyDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR AnyDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~AnyDefaultTypeInternal() {}
union {
Any _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 AnyDefaultTypeInternal _Any_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 AnyDefaultTypeInternal _Any_default_instance_;
PROTOBUF_NAMESPACE_CLOSE
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_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Any, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Any, _impl_.type_url_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Any, _impl_.value_),
+static constexpr const ::_pb::EnumDescriptor**
+ file_level_enum_descriptors_google_2fprotobuf_2fany_2eproto = nullptr;
+static constexpr const ::_pb::ServiceDescriptor**
+ 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_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Any, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Any, _impl_.type_url_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Any, _impl_.value_),
};
-static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
- { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Any)},
+
+static const ::_pbi::MigrationSchema
+ schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Any)},
};
static const ::_pb::Message* const file_default_instances[] = {
- &::PROTOBUF_NAMESPACE_ID::_Any_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_Any_default_instance_._instance,
};
-
-const char descriptor_table_protodef_google_2fprotobuf_2fany_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
- "\n\031google/protobuf/any.proto\022\017google.prot"
- "obuf\"&\n\003Any\022\020\n\010type_url\030\001 \001(\t\022\r\n\005value\030\002"
- " \001(\014Bv\n\023com.google.protobufB\010AnyProtoP\001Z"
- ",google.golang.org/protobuf/types/known/"
- "anypb\242\002\003GPB\252\002\036Google.Protobuf.WellKnownT"
- "ypesb\006proto3"
- ;
-static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fany_2eproto_once;
+const char descriptor_table_protodef_google_2fprotobuf_2fany_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ "\n\031google/protobuf/any.proto\022\017google.prot"
+ "obuf\"&\n\003Any\022\020\n\010type_url\030\001 \001(\t\022\r\n\005value\030\002"
+ " \001(\014Bv\n\023com.google.protobufB\010AnyProtoP\001Z"
+ ",google.golang.org/protobuf/types/known/"
+ "anypb\242\002\003GPB\252\002\036Google.Protobuf.WellKnownT"
+ "ypesb\006proto3"
+};
+static ::y_absl::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,
+ 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,
+ &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,
};
+
+// This function exists to be marked as weak.
+// It can significantly speed up compilation by breaking up LLVM's SCC
+// in the .pb.cc translation units. Large translation units see a
+// reduction of more than 35% of walltime for optimized builds. Without
+// the weak attribute all the messages in the file, including all the
+// vtables and everything they use become part of the same SCC through
+// a cycle like:
+// GetMetadata -> descriptor table -> default instances ->
+// 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 ::_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_PRIORITY2 static ::_pbi::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
-
// ===================================================================
bool Any::GetAnyFieldDescriptors(
@@ -98,7 +128,7 @@ bool Any::GetAnyFieldDescriptors(
message, type_url_field, value_field);
}
bool Any::ParseAnyTypeUrl(
- ::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url,
+ ::y_absl::string_view type_url,
TProtoStringType* full_type_name) {
return ::_pbi::ParseAnyTypeUrl(type_url, full_type_name);
}
@@ -107,59 +137,58 @@ class Any::_Internal {
public:
};
-Any::Any(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+Any::Any(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Any)
}
Any::Any(const Any& from)
: ::PROTOBUF_NAMESPACE_ID::Message() {
Any* const _this = this; (void)_this;
new (&_impl_) Impl_{
- decltype(_impl_.type_url_){}
- , decltype(_impl_.value_){}
+ decltype(_impl_.type_url_) {}
+
+ , decltype(_impl_.value_) {}
+
, /*decltype(_impl_._cached_size_)*/{}
, /*decltype(_impl_._any_metadata_)*/{&_impl_.type_url_, &_impl_.value_}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.type_url_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.type_url_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_type_url().empty()) {
- _this->_impl_.type_url_.Set(from._internal_type_url(),
- _this->GetArenaForAllocation());
+ _this->_impl_.type_url_.Set(from._internal_type_url(), _this->GetArenaForAllocation());
}
_impl_.value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.value_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.value_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_value().empty()) {
- _this->_impl_.value_.Set(from._internal_value(),
- _this->GetArenaForAllocation());
+ _this->_impl_.value_.Set(from._internal_value(), _this->GetArenaForAllocation());
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.Any)
}
-inline void Any::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void Any::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
- decltype(_impl_.type_url_){}
- , decltype(_impl_.value_){}
+ decltype(_impl_.type_url_) {}
+
+ , decltype(_impl_.value_) {}
+
, /*decltype(_impl_._cached_size_)*/{}
, /*decltype(_impl_._any_metadata_)*/{&_impl_.type_url_, &_impl_.value_}
};
_impl_.type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.type_url_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.type_url_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.value_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.value_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
Any::~Any() {
@@ -172,7 +201,7 @@ Any::~Any() {
}
inline void Any::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.type_url_.Destroy();
_impl_.value_.Destroy();
_impl_._any_metadata_.~AnyMetadata();
@@ -184,7 +213,7 @@ void Any::SetCachedSize(int size) const {
void Any::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Any)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -196,27 +225,29 @@ void Any::Clear() {
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;
+ ::arc_ui32 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)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_type_url();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Any.type_url"));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// bytes value = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) {
auto str = _internal_mutable_value();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -241,26 +272,24 @@ failure:
#undef CHK_
}
-uint8_t* Any::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* Any::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Any)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// string type_url = 1;
if (!this->_internal_type_url().empty()) {
+ const TProtoStringType& _s = this->_internal_type_url();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
- this->_internal_type_url().data(), static_cast<int>(this->_internal_type_url().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
- "google.protobuf.Any.type_url");
- target = stream->WriteStringMaybeAliased(
- 1, this->_internal_type_url(), target);
+ _s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Any.type_url");
+ target = stream->WriteStringMaybeAliased(1, _s, target);
}
// bytes value = 2;
if (!this->_internal_value().empty()) {
- target = stream->WriteBytesMaybeAliased(
- 2, this->_internal_value(), target);
+ const TProtoStringType& _s = this->_internal_value();
+ target = stream->WriteBytesMaybeAliased(2, _s, target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
@@ -271,26 +300,24 @@ uint8_t* Any::_InternalSerialize(
return target;
}
-size_t Any::ByteSizeLong() const {
+::size_t Any::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Any)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// string type_url = 1;
if (!this->_internal_type_url().empty()) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_type_url());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_type_url());
}
// bytes value = 2;
if (!this->_internal_value().empty()) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize(
- this->_internal_value());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize(
+ this->_internal_value());
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -307,8 +334,8 @@ void Any::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_N
auto* const _this = static_cast<Any*>(&to_msg);
auto& from = static_cast<const Any&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Any)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
if (!from._internal_type_url().empty()) {
@@ -336,14 +363,10 @@ void Any::InternalSwap(Any* other) {
auto* lhs_arena = GetArenaForAllocation();
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.type_url_, lhs_arena,
- &other->_impl_.type_url_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.value_, lhs_arena,
- &other->_impl_.value_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.type_url_, lhs_arena,
+ &other->_impl_.type_url_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.value_, lhs_arena,
+ &other->_impl_.value_, rhs_arena);
}
::PROTOBUF_NAMESPACE_ID::Metadata Any::GetMetadata() const {
@@ -351,7 +374,6 @@ void Any::InternalSwap(Any* other) {
&descriptor_table_google_2fprotobuf_2fany_2eproto_getter, &descriptor_table_google_2fprotobuf_2fany_2eproto_once,
file_level_metadata_google_2fprotobuf_2fany_2eproto[0]);
}
-
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
@@ -360,9 +382,8 @@ 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
+#pragma clang diagnostic pop
#endif // __llvm__
-#include <google/protobuf/port_undef.inc>
+#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 218d7832bc7..fe5f9dfe527 100644
--- a/contrib/libs/protobuf/src/google/protobuf/any.pb.h
+++ b/contrib/libs/protobuf/src/google/protobuf/any.pb.h
@@ -1,38 +1,43 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/any.proto
-#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fany_2eproto
-#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fany_2eproto
+#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fany_2eproto_2epb_2eh
+#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fany_2eproto_2epb_2eh
#include <limits>
#include <string>
-
-#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3021000
-#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 3021003 < 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.
-#endif
-
-#include <google/protobuf/port_undef.inc>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/arena.h>
-#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_util.h>
-#include <google/protobuf/metadata_lite.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h> // IWYU pragma: export
-#include <google/protobuf/extension_set.h> // IWYU pragma: export
-#include <google/protobuf/unknown_field_set.h>
+#include <type_traits>
+
+#include "google/protobuf/port_def.inc"
+#if PROTOBUF_VERSION < 4022000
+#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 // PROTOBUF_VERSION
+
+#if 4022005 < 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."
+#endif // PROTOBUF_MIN_PROTOC_VERSION
+#include "google/protobuf/port_undef.inc"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/arena.h"
+#include "google/protobuf/arenastring.h"
+#include "google/protobuf/generated_message_util.h"
+#include "google/protobuf/metadata_lite.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/repeated_field.h" // IWYU pragma: export
+#include "google/protobuf/extension_set.h" // IWYU pragma: export
+#include "google/protobuf/unknown_field_set.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fany_2eproto PROTOBUF_EXPORT
+
PROTOBUF_NAMESPACE_OPEN
namespace internal {
class AnyMetadata;
@@ -41,21 +46,25 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fany_2eproto {
- static const arc_ui32 offsets[];
+ static const ::arc_ui32 offsets[];
};
-PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fany_2eproto;
+PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable
+ descriptor_table_google_2fprotobuf_2fany_2eproto;
PROTOBUF_NAMESPACE_OPEN
class Any;
struct AnyDefaultTypeInternal;
PROTOBUF_EXPORT extern AnyDefaultTypeInternal _Any_default_instance_;
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Any* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Any>(Arena*);
PROTOBUF_NAMESPACE_CLOSE
-PROTOBUF_NAMESPACE_OPEN
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Any* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Any>(Arena*);
-PROTOBUF_NAMESPACE_CLOSE
+
PROTOBUF_NAMESPACE_OPEN
// ===================================================================
+
+// -------------------------------------------------------------------
+
class PROTOBUF_EXPORT Any final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Any) */ {
public:
@@ -109,12 +118,12 @@ class PROTOBUF_EXPORT Any final :
// implements Any -----------------------------------------------
bool PackFrom(const ::PROTOBUF_NAMESPACE_ID::Message& message) {
- GOOGLE_DCHECK_NE(&message, this);
+ Y_ABSL_DCHECK_NE(&message, this);
return _impl_._any_metadata_.PackFrom(GetArena(), message);
}
bool PackFrom(const ::PROTOBUF_NAMESPACE_ID::Message& message,
- ::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url_prefix) {
- GOOGLE_DCHECK_NE(&message, this);
+ ::y_absl::string_view type_url_prefix) {
+ Y_ABSL_DCHECK_NE(&message, this);
return _impl_._any_metadata_.PackFrom(GetArena(), message, type_url_prefix);
}
bool UnpackTo(::PROTOBUF_NAMESPACE_ID::Message* message) const {
@@ -130,7 +139,7 @@ class PROTOBUF_EXPORT Any final :
}
template <typename T, class = typename std::enable_if<!std::is_convertible<T, const ::PROTOBUF_NAMESPACE_ID::Message&>::value>::type>
bool PackFrom(const T& message,
- ::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url_prefix) {
+ ::y_absl::string_view type_url_prefix) {
return _impl_._any_metadata_.PackFrom<T>(GetArena(), message, type_url_prefix);}
template <typename T, class = typename std::enable_if<!std::is_convertible<T, const ::PROTOBUF_NAMESPACE_ID::Message&>::value>::type>
bool UnpackTo(T* message) const {
@@ -139,7 +148,7 @@ class PROTOBUF_EXPORT Any final :
template<typename T> bool Is() const {
return _impl_._any_metadata_.Is<T>();
}
- static bool ParseAnyTypeUrl(::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url,
+ static bool ParseAnyTypeUrl(::y_absl::string_view type_url,
TProtoStringType* full_type_name);
friend void swap(Any& a, Any& b) {
a.Swap(&b);
@@ -159,7 +168,7 @@ class PROTOBUF_EXPORT Any final :
}
void UnsafeArenaSwap(Any* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -180,26 +189,25 @@ class PROTOBUF_EXPORT Any final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(Any* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.Any";
}
protected:
- explicit Any(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit Any(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -216,33 +224,45 @@ class PROTOBUF_EXPORT Any final :
kValueFieldNumber = 2,
};
// string type_url = 1;
- void clear_type_url();
+ void clear_type_url() ;
const TProtoStringType& type_url() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_type_url(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_type_url(Arg_&& arg, Args_... args);
TProtoStringType* mutable_type_url();
PROTOBUF_NODISCARD TProtoStringType* release_type_url();
- void set_allocated_type_url(TProtoStringType* type_url);
+ void set_allocated_type_url(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_type_url() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_type_url(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_type_url(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_type_url();
- public:
+ public:
// bytes value = 2;
- void clear_value();
+ void clear_value() ;
const TProtoStringType& value() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_value(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_value(Arg_&& arg, Args_... args);
TProtoStringType* mutable_value();
PROTOBUF_NODISCARD TProtoStringType* release_value();
- void set_allocated_value(TProtoStringType* value);
+ void set_allocated_value(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_value() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_value(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_value(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_value();
- public:
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.Any)
private:
class _Internal;
@@ -259,15 +279,21 @@ class PROTOBUF_EXPORT Any final :
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fany_2eproto;
};
+
// ===================================================================
+
+
// ===================================================================
+
#ifdef __GNUC__
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
+// -------------------------------------------------------------------
+
// Any
// string type_url = 1;
@@ -278,11 +304,11 @@ inline const TProtoStringType& Any::type_url() const {
// @@protoc_insertion_point(field_get:google.protobuf.Any.type_url)
return _internal_type_url();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void Any::set_type_url(ArgT0&& arg0, ArgT... args) {
-
- _impl_.type_url_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void Any::set_type_url(Arg_&& arg,
+ Args_... args) {
+ ;
+ _impl_.type_url_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Any.type_url)
}
inline TProtoStringType* Any::mutable_type_url() {
@@ -294,29 +320,26 @@ inline const TProtoStringType& Any::_internal_type_url() const {
return _impl_.type_url_.Get();
}
inline void Any::_internal_set_type_url(const TProtoStringType& value) {
-
+ ;
+
+
_impl_.type_url_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Any::_internal_mutable_type_url() {
-
- return _impl_.type_url_.Mutable(GetArenaForAllocation());
+ ;
+ return _impl_.type_url_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* Any::release_type_url() {
// @@protoc_insertion_point(field_release:google.protobuf.Any.type_url)
return _impl_.type_url_.Release();
}
-inline void Any::set_allocated_type_url(TProtoStringType* type_url) {
- if (type_url != nullptr) {
-
- } else {
-
- }
- _impl_.type_url_.SetAllocated(type_url, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.type_url_.IsDefault()) {
- _impl_.type_url_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+inline void Any::set_allocated_type_url(TProtoStringType* value) {
+ _impl_.type_url_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.type_url_.IsDefault()) {
+ _impl_.type_url_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.type_url)
}
@@ -328,11 +351,11 @@ inline const TProtoStringType& Any::value() const {
// @@protoc_insertion_point(field_get:google.protobuf.Any.value)
return _internal_value();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void Any::set_value(ArgT0&& arg0, ArgT... args) {
-
- _impl_.value_.SetBytes(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void Any::set_value(Arg_&& arg,
+ Args_... args) {
+ ;
+ _impl_.value_.SetBytes(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Any.value)
}
inline TProtoStringType* Any::mutable_value() {
@@ -344,41 +367,39 @@ inline const TProtoStringType& Any::_internal_value() const {
return _impl_.value_.Get();
}
inline void Any::_internal_set_value(const TProtoStringType& value) {
-
+ ;
+
+
_impl_.value_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Any::_internal_mutable_value() {
-
- return _impl_.value_.Mutable(GetArenaForAllocation());
+ ;
+ return _impl_.value_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* Any::release_value() {
// @@protoc_insertion_point(field_release:google.protobuf.Any.value)
return _impl_.value_.Release();
}
inline void Any::set_allocated_value(TProtoStringType* value) {
- if (value != nullptr) {
-
- } else {
-
- }
_impl_.value_.SetAllocated(value, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.value_.IsDefault()) {
- _impl_.value_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.value_.IsDefault()) {
+ _impl_.value_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value)
}
#ifdef __GNUC__
- #pragma GCC diagnostic pop
+#pragma GCC diagnostic pop
#endif // __GNUC__
// @@protoc_insertion_point(namespace_scope)
-
PROTOBUF_NAMESPACE_CLOSE
+
// @@protoc_insertion_point(global_scope)
-#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fany_2eproto
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fany_2eproto_2epb_2eh
diff --git a/contrib/libs/protobuf/src/google/protobuf/any.proto b/contrib/libs/protobuf/src/google/protobuf/any.proto
index e2c2042fdc0..561da0cb151 100644
--- a/contrib/libs/protobuf/src/google/protobuf/any.proto
+++ b/contrib/libs/protobuf/src/google/protobuf/any.proto
@@ -32,12 +32,12 @@ syntax = "proto3";
package google.protobuf;
-option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option go_package = "google.golang.org/protobuf/types/known/anypb";
option java_package = "com.google.protobuf";
option java_outer_classname = "AnyProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
+option csharp_namespace = "Google.Protobuf.WellKnownTypes";
// `Any` contains an arbitrary serialized protocol buffer message along with a
// URL that describes the type of the serialized message.
@@ -63,6 +63,10 @@ option objc_class_prefix = "GPB";
// if (any.is(Foo.class)) {
// foo = any.unpack(Foo.class);
// }
+// // or ...
+// if (any.isSameTypeAs(Foo.getDefaultInstance())) {
+// foo = any.unpack(Foo.getDefaultInstance());
+// }
//
// Example 3: Pack and unpack a message in Python.
//
@@ -93,7 +97,6 @@ option objc_class_prefix = "GPB";
// in the type URL, for example "foo.bar.com/x/y.z" will yield type
// name "y.z".
//
-//
// JSON
//
// The JSON representation of an `Any` value uses the regular
diff --git a/contrib/libs/protobuf/src/google/protobuf/any_lite.cc b/contrib/libs/protobuf/src/google/protobuf/any_lite.cc
index 387b6b7708b..f2b0261c5dd 100644
--- a/contrib/libs/protobuf/src/google/protobuf/any_lite.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/any_lite.cc
@@ -28,23 +28,24 @@
// (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/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 "y_absl/strings/match.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/any.h"
+#include "google/protobuf/arenastring.h"
+#include "google/protobuf/generated_message_util.h"
+#include "google/protobuf/io/zero_copy_stream_impl_lite.h"
namespace google {
namespace protobuf {
namespace internal {
-TProtoStringType GetTypeUrl(StringPiece message_name,
- StringPiece type_url_prefix) {
+TProtoStringType GetTypeUrl(y_absl::string_view message_name,
+ y_absl::string_view type_url_prefix) {
if (!type_url_prefix.empty() &&
type_url_prefix[type_url_prefix.size() - 1] == '/') {
- return StrCat(type_url_prefix, message_name);
+ return y_absl::StrCat(type_url_prefix, message_name);
} else {
- return StrCat(type_url_prefix, "/", message_name);
+ return y_absl::StrCat(type_url_prefix, "/", message_name);
}
}
@@ -53,13 +54,13 @@ const char kTypeGoogleApisComPrefix[] = "type.googleapis.com/";
const char kTypeGoogleProdComPrefix[] = "type.googleprod.com/";
bool AnyMetadata::InternalPackFrom(Arena* arena, const MessageLite& message,
- StringPiece type_url_prefix,
- StringPiece type_name) {
+ y_absl::string_view type_url_prefix,
+ y_absl::string_view type_name) {
type_url_->Set(GetTypeUrl(type_name, type_url_prefix), arena);
return message.SerializeToString(value_->Mutable(arena));
}
-bool AnyMetadata::InternalUnpackTo(StringPiece type_name,
+bool AnyMetadata::InternalUnpackTo(y_absl::string_view type_name,
MessageLite* message) const {
if (!InternalIs(type_name)) {
return false;
@@ -67,14 +68,14 @@ bool AnyMetadata::InternalUnpackTo(StringPiece type_name,
return message->ParseFromString(value_->Get());
}
-bool AnyMetadata::InternalIs(StringPiece type_name) const {
- StringPiece type_url = type_url_->Get();
+bool AnyMetadata::InternalIs(y_absl::string_view type_name) const {
+ y_absl::string_view type_url = type_url_->Get();
return type_url.size() >= type_name.size() + 1 &&
type_url[type_url.size() - type_name.size() - 1] == '/' &&
- HasSuffixString(type_url, type_name);
+ y_absl::EndsWith(type_url, type_name);
}
-bool ParseAnyTypeUrl(StringPiece type_url, TProtoStringType* url_prefix,
+bool ParseAnyTypeUrl(y_absl::string_view type_url, TProtoStringType* url_prefix,
TProtoStringType* full_type_name) {
size_t pos = type_url.find_last_of('/');
if (pos == TProtoStringType::npos || pos + 1 == type_url.size()) {
@@ -87,7 +88,7 @@ bool ParseAnyTypeUrl(StringPiece type_url, TProtoStringType* url_prefix,
return true;
}
-bool ParseAnyTypeUrl(StringPiece type_url, TProtoStringType* full_type_name) {
+bool ParseAnyTypeUrl(y_absl::string_view type_url, TProtoStringType* full_type_name) {
return ParseAnyTypeUrl(type_url, nullptr, full_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 1859a5d349a..aba124aff1f 100644
--- a/contrib/libs/protobuf/src/google/protobuf/api.pb.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/api.pb.cc
@@ -1,173 +1,229 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/api.proto
-#include <google/protobuf/api.pb.h>
+#include "google/protobuf/api.pb.h"
#include <algorithm>
-
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/extension_set.h>
-#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/reflection_ops.h>
-#include <google/protobuf/wire_format.h>
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/extension_set.h"
+#include "google/protobuf/wire_format_lite.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/reflection_ops.h"
+#include "google/protobuf/wire_format.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+// Must be included last.
+#include "google/protobuf/port_def.inc"
PROTOBUF_PRAGMA_INIT_SEG
-
namespace _pb = ::PROTOBUF_NAMESPACE_ID;
-namespace _pbi = _pb::internal;
-
+namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal;
PROTOBUF_NAMESPACE_OPEN
PROTOBUF_CONSTEXPR Api::Api(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_.methods_)*/{}
, /*decltype(_impl_.options_)*/{}
, /*decltype(_impl_.mixins_)*/{}
- , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.version_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
+ , /*decltype(_impl_.name_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.version_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
, /*decltype(_impl_.source_context_)*/nullptr
- , /*decltype(_impl_.syntax_)*/0
+ , /*decltype(_impl_.syntax_)*/ 0
+
, /*decltype(_impl_._cached_size_)*/{}} {}
struct ApiDefaultTypeInternal {
- PROTOBUF_CONSTEXPR ApiDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR ApiDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~ApiDefaultTypeInternal() {}
union {
Api _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ApiDefaultTypeInternal _Api_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ApiDefaultTypeInternal _Api_default_instance_;
PROTOBUF_CONSTEXPR Method::Method(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_.options_)*/{}
- , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.request_type_url_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.response_type_url_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.request_streaming_)*/false
- , /*decltype(_impl_.response_streaming_)*/false
- , /*decltype(_impl_.syntax_)*/0
+ , /*decltype(_impl_.name_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.request_type_url_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.response_type_url_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.request_streaming_)*/ false
+
+ , /*decltype(_impl_.response_streaming_)*/ false
+
+ , /*decltype(_impl_.syntax_)*/ 0
+
, /*decltype(_impl_._cached_size_)*/{}} {}
struct MethodDefaultTypeInternal {
- PROTOBUF_CONSTEXPR MethodDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR MethodDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~MethodDefaultTypeInternal() {}
union {
Method _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodDefaultTypeInternal _Method_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodDefaultTypeInternal _Method_default_instance_;
PROTOBUF_CONSTEXPR Mixin::Mixin(
::_pbi::ConstantInitialized): _impl_{
- /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.root_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
+ /*decltype(_impl_.name_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.root_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
, /*decltype(_impl_._cached_size_)*/{}} {}
struct MixinDefaultTypeInternal {
- PROTOBUF_CONSTEXPR MixinDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR MixinDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~MixinDefaultTypeInternal() {}
union {
Mixin _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MixinDefaultTypeInternal _Mixin_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MixinDefaultTypeInternal _Mixin_default_instance_;
PROTOBUF_NAMESPACE_CLOSE
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_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.name_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.methods_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.options_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.version_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.source_context_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.mixins_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.syntax_),
- ~0u, // no _has_bits_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.name_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.request_type_url_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.request_streaming_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.response_type_url_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.response_streaming_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.options_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.syntax_),
- ~0u, // no _has_bits_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Mixin, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Mixin, _impl_.name_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Mixin, _impl_.root_),
+static constexpr const ::_pb::EnumDescriptor**
+ file_level_enum_descriptors_google_2fprotobuf_2fapi_2eproto = nullptr;
+static constexpr const ::_pb::ServiceDescriptor**
+ 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_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.name_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.methods_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.options_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.version_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.source_context_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.mixins_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.syntax_),
+ ~0u, // no _has_bits_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.name_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.request_type_url_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.request_streaming_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.response_type_url_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.response_streaming_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.options_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.syntax_),
+ ~0u, // no _has_bits_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Mixin, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Mixin, _impl_.name_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Mixin, _impl_.root_),
};
-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 const ::_pbi::MigrationSchema
+ schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Api)},
+ { 15, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Method)},
+ { 30, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Mixin)},
};
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,
+ &::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) =
- "\n\031google/protobuf/api.proto\022\017google.prot"
- "obuf\032$google/protobuf/source_context.pro"
- "to\032\032google/protobuf/type.proto\"\201\002\n\003Api\022\014"
- "\n\004name\030\001 \001(\t\022(\n\007methods\030\002 \003(\0132\027.google.p"
- "rotobuf.Method\022(\n\007options\030\003 \003(\0132\027.google"
- ".protobuf.Option\022\017\n\007version\030\004 \001(\t\0226\n\016sou"
- "rce_context\030\005 \001(\0132\036.google.protobuf.Sour"
- "ceContext\022&\n\006mixins\030\006 \003(\0132\026.google.proto"
- "buf.Mixin\022\'\n\006syntax\030\007 \001(\0162\027.google.proto"
- "buf.Syntax\"\325\001\n\006Method\022\014\n\004name\030\001 \001(\t\022\030\n\020r"
- "equest_type_url\030\002 \001(\t\022\031\n\021request_streami"
- "ng\030\003 \001(\010\022\031\n\021response_type_url\030\004 \001(\t\022\032\n\022r"
- "esponse_streaming\030\005 \001(\010\022(\n\007options\030\006 \003(\013"
- "2\027.google.protobuf.Option\022\'\n\006syntax\030\007 \001("
- "\0162\027.google.protobuf.Syntax\"#\n\005Mixin\022\014\n\004n"
- "ame\030\001 \001(\t\022\014\n\004root\030\002 \001(\tBv\n\023com.google.pr"
- "otobufB\010ApiProtoP\001Z,google.golang.org/pr"
- "otobuf/types/known/apipb\242\002\003GPB\252\002\036Google."
- "Protobuf.WellKnownTypesb\006proto3"
- ;
-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,
+const char descriptor_table_protodef_google_2fprotobuf_2fapi_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ "\n\031google/protobuf/api.proto\022\017google.prot"
+ "obuf\032$google/protobuf/source_context.pro"
+ "to\032\032google/protobuf/type.proto\"\201\002\n\003Api\022\014"
+ "\n\004name\030\001 \001(\t\022(\n\007methods\030\002 \003(\0132\027.google.p"
+ "rotobuf.Method\022(\n\007options\030\003 \003(\0132\027.google"
+ ".protobuf.Option\022\017\n\007version\030\004 \001(\t\0226\n\016sou"
+ "rce_context\030\005 \001(\0132\036.google.protobuf.Sour"
+ "ceContext\022&\n\006mixins\030\006 \003(\0132\026.google.proto"
+ "buf.Mixin\022\'\n\006syntax\030\007 \001(\0162\027.google.proto"
+ "buf.Syntax\"\325\001\n\006Method\022\014\n\004name\030\001 \001(\t\022\030\n\020r"
+ "equest_type_url\030\002 \001(\t\022\031\n\021request_streami"
+ "ng\030\003 \001(\010\022\031\n\021response_type_url\030\004 \001(\t\022\032\n\022r"
+ "esponse_streaming\030\005 \001(\010\022(\n\007options\030\006 \003(\013"
+ "2\027.google.protobuf.Option\022\'\n\006syntax\030\007 \001("
+ "\0162\027.google.protobuf.Syntax\"#\n\005Mixin\022\014\n\004n"
+ "ame\030\001 \001(\t\022\014\n\004root\030\002 \001(\tBv\n\023com.google.pr"
+ "otobufB\010ApiProtoP\001Z,google.golang.org/pr"
+ "otobuf/types/known/apipb\242\002\003GPB\252\002\036Google."
+ "Protobuf.WellKnownTypesb\006proto3"
};
-static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fapi_2eproto_once;
+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 ::y_absl::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,
+ 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,
+ &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,
};
+
+// This function exists to be marked as weak.
+// It can significantly speed up compilation by breaking up LLVM's SCC
+// in the .pb.cc translation units. Large translation units see a
+// reduction of more than 35% of walltime for optimized builds. Without
+// the weak attribute all the messages in the file, including all the
+// vtables and everything they use become part of the same SCC through
+// a cycle like:
+// GetMetadata -> descriptor table -> default instances ->
+// 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 ::_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_PRIORITY2 static ::_pbi::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
-
// ===================================================================
class Api::_Internal {
@@ -188,10 +244,9 @@ void Api::clear_source_context() {
}
_impl_.source_context_ = nullptr;
}
-Api::Api(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+Api::Api(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Api)
}
Api::Api(const Api& from)
@@ -201,28 +256,29 @@ Api::Api(const Api& from)
decltype(_impl_.methods_){from._impl_.methods_}
, decltype(_impl_.options_){from._impl_.options_}
, decltype(_impl_.mixins_){from._impl_.mixins_}
- , decltype(_impl_.name_){}
- , decltype(_impl_.version_){}
+ , decltype(_impl_.name_) {}
+
+ , decltype(_impl_.version_) {}
+
, decltype(_impl_.source_context_){nullptr}
- , decltype(_impl_.syntax_){}
+ , decltype(_impl_.syntax_) {}
+
, /*decltype(_impl_._cached_size_)*/{}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) {
- _this->_impl_.name_.Set(from._internal_name(),
- _this->GetArenaForAllocation());
+ _this->_impl_.name_.Set(from._internal_name(), _this->GetArenaForAllocation());
}
_impl_.version_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.version_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.version_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_version().empty()) {
- _this->_impl_.version_.Set(from._internal_version(),
- _this->GetArenaForAllocation());
+ _this->_impl_.version_.Set(from._internal_version(), _this->GetArenaForAllocation());
}
if (from._internal_has_source_context()) {
_this->_impl_.source_context_ = new ::PROTOBUF_NAMESPACE_ID::SourceContext(*from._impl_.source_context_);
@@ -231,28 +287,29 @@ Api::Api(const Api& from)
// @@protoc_insertion_point(copy_constructor:google.protobuf.Api)
}
-inline void Api::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void Api::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_.methods_){arena}
, decltype(_impl_.options_){arena}
, decltype(_impl_.mixins_){arena}
- , decltype(_impl_.name_){}
- , decltype(_impl_.version_){}
+ , decltype(_impl_.name_) {}
+
+ , decltype(_impl_.version_) {}
+
, decltype(_impl_.source_context_){nullptr}
- , decltype(_impl_.syntax_){0}
+ , decltype(_impl_.syntax_) { 0 }
+
, /*decltype(_impl_._cached_size_)*/{}
};
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.version_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.version_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.version_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
Api::~Api() {
@@ -265,7 +322,7 @@ Api::~Api() {
}
inline void Api::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.methods_.~RepeatedPtrField();
_impl_.options_.~RepeatedPtrField();
_impl_.mixins_.~RepeatedPtrField();
@@ -280,7 +337,7 @@ void Api::SetCachedSize(int size) const {
void Api::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Api)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -300,22 +357,23 @@ void Api::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// string name = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Api.name"));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.Method methods = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) {
ptr -= 1;
do {
ptr += 1;
@@ -323,12 +381,13 @@ const char* Api::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.Option options = 3;
case 3:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 26)) {
ptr -= 1;
do {
ptr += 1;
@@ -336,30 +395,33 @@ const char* Api::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// string version = 4;
case 4:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 34)) {
auto str = _internal_mutable_version();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Api.version"));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// .google.protobuf.SourceContext source_context = 5;
case 5:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 42)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 42)) {
ptr = ctx->ParseMessage(_internal_mutable_source_context(), ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.Mixin mixins = 6;
case 6:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 50)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 50)) {
ptr -= 1;
do {
ptr += 1;
@@ -367,17 +429,19 @@ const char* Api::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// .google.protobuf.Syntax syntax = 7;
case 7:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 56)) {
- arc_ui64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 56)) {
+ ::arc_ui32 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
_internal_set_syntax(static_cast<::PROTOBUF_NAMESPACE_ID::Syntax>(val));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -402,20 +466,18 @@ failure:
#undef CHK_
}
-uint8_t* Api::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* Api::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Api)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// string name = 1;
if (!this->_internal_name().empty()) {
+ const TProtoStringType& _s = this->_internal_name();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
- this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
- "google.protobuf.Api.name");
- target = stream->WriteStringMaybeAliased(
- 1, this->_internal_name(), target);
+ _s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Api.name");
+ target = stream->WriteStringMaybeAliased(1, _s, target);
}
// repeated .google.protobuf.Method methods = 2;
@@ -436,12 +498,10 @@ uint8_t* Api::_InternalSerialize(
// string version = 4;
if (!this->_internal_version().empty()) {
+ const TProtoStringType& _s = this->_internal_version();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
- this->_internal_version().data(), static_cast<int>(this->_internal_version().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
- "google.protobuf.Api.version");
- target = stream->WriteStringMaybeAliased(
- 4, this->_internal_version(), target);
+ _s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Api.version");
+ target = stream->WriteStringMaybeAliased(4, _s, target);
}
// .google.protobuf.SourceContext source_context = 5;
@@ -463,7 +523,7 @@ uint8_t* Api::_InternalSerialize(
if (this->_internal_syntax() != 0) {
target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::WriteEnumToArray(
- 7, this->_internal_syntax(), target);
+ 7, this->_internal_syntax(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
@@ -474,11 +534,11 @@ uint8_t* Api::_InternalSerialize(
return target;
}
-size_t Api::ByteSizeLong() const {
+::size_t Api::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Api)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -505,16 +565,14 @@ size_t Api::ByteSizeLong() const {
// string name = 1;
if (!this->_internal_name().empty()) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_name());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_name());
}
// string version = 4;
if (!this->_internal_version().empty()) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_version());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_version());
}
// .google.protobuf.SourceContext source_context = 5;
@@ -527,7 +585,7 @@ size_t Api::ByteSizeLong() const {
// .google.protobuf.Syntax syntax = 7;
if (this->_internal_syntax() != 0) {
total_size += 1 +
- ::_pbi::WireFormatLite::EnumSize(this->_internal_syntax());
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_syntax());
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -544,8 +602,8 @@ void Api::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_N
auto* const _this = static_cast<Api*>(&to_msg);
auto& from = static_cast<const Api&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Api)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.methods_.MergeFrom(from._impl_.methods_);
@@ -586,14 +644,10 @@ void Api::InternalSwap(Api* other) {
_impl_.methods_.InternalSwap(&other->_impl_.methods_);
_impl_.options_.InternalSwap(&other->_impl_.options_);
_impl_.mixins_.InternalSwap(&other->_impl_.mixins_);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.name_, lhs_arena,
- &other->_impl_.name_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.version_, lhs_arena,
- &other->_impl_.version_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, lhs_arena,
+ &other->_impl_.name_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.version_, lhs_arena,
+ &other->_impl_.version_, rhs_arena);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(Api, _impl_.syntax_)
+ sizeof(Api::_impl_.syntax_)
@@ -607,7 +661,6 @@ void Api::InternalSwap(Api* other) {
&descriptor_table_google_2fprotobuf_2fapi_2eproto_getter, &descriptor_table_google_2fprotobuf_2fapi_2eproto_once,
file_level_metadata_google_2fprotobuf_2fapi_2eproto[0]);
}
-
// ===================================================================
class Method::_Internal {
@@ -617,10 +670,9 @@ class Method::_Internal {
void Method::clear_options() {
_impl_.options_.Clear();
}
-Method::Method(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+Method::Method(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Method)
}
Method::Method(const Method& from)
@@ -628,71 +680,78 @@ Method::Method(const Method& from)
Method* const _this = this; (void)_this;
new (&_impl_) Impl_{
decltype(_impl_.options_){from._impl_.options_}
- , decltype(_impl_.name_){}
- , decltype(_impl_.request_type_url_){}
- , decltype(_impl_.response_type_url_){}
- , decltype(_impl_.request_streaming_){}
- , decltype(_impl_.response_streaming_){}
- , decltype(_impl_.syntax_){}
+ , decltype(_impl_.name_) {}
+
+ , decltype(_impl_.request_type_url_) {}
+
+ , decltype(_impl_.response_type_url_) {}
+
+ , decltype(_impl_.request_streaming_) {}
+
+ , decltype(_impl_.response_streaming_) {}
+
+ , decltype(_impl_.syntax_) {}
+
, /*decltype(_impl_._cached_size_)*/{}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) {
- _this->_impl_.name_.Set(from._internal_name(),
- _this->GetArenaForAllocation());
+ _this->_impl_.name_.Set(from._internal_name(), _this->GetArenaForAllocation());
}
_impl_.request_type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.request_type_url_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.request_type_url_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_request_type_url().empty()) {
- _this->_impl_.request_type_url_.Set(from._internal_request_type_url(),
- _this->GetArenaForAllocation());
+ _this->_impl_.request_type_url_.Set(from._internal_request_type_url(), _this->GetArenaForAllocation());
}
_impl_.response_type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.response_type_url_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.response_type_url_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_response_type_url().empty()) {
- _this->_impl_.response_type_url_.Set(from._internal_response_type_url(),
- _this->GetArenaForAllocation());
+ _this->_impl_.response_type_url_.Set(from._internal_response_type_url(), _this->GetArenaForAllocation());
}
::memcpy(&_impl_.request_streaming_, &from._impl_.request_streaming_,
- static_cast<size_t>(reinterpret_cast<char*>(&_impl_.syntax_) -
+ static_cast<::size_t>(reinterpret_cast<char*>(&_impl_.syntax_) -
reinterpret_cast<char*>(&_impl_.request_streaming_)) + sizeof(_impl_.syntax_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.Method)
}
-inline void Method::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void Method::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_.options_){arena}
- , decltype(_impl_.name_){}
- , decltype(_impl_.request_type_url_){}
- , decltype(_impl_.response_type_url_){}
- , decltype(_impl_.request_streaming_){false}
- , decltype(_impl_.response_streaming_){false}
- , decltype(_impl_.syntax_){0}
+ , decltype(_impl_.name_) {}
+
+ , decltype(_impl_.request_type_url_) {}
+
+ , decltype(_impl_.response_type_url_) {}
+
+ , decltype(_impl_.request_streaming_) { false }
+
+ , decltype(_impl_.response_streaming_) { false }
+
+ , decltype(_impl_.syntax_) { 0 }
+
, /*decltype(_impl_._cached_size_)*/{}
};
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.request_type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.request_type_url_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.request_type_url_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.response_type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.response_type_url_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.response_type_url_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
Method::~Method() {
@@ -705,7 +764,7 @@ Method::~Method() {
}
inline void Method::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.options_.~RepeatedPtrField();
_impl_.name_.Destroy();
_impl_.request_type_url_.Destroy();
@@ -718,7 +777,7 @@ void Method::SetCachedSize(int size) const {
void Method::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Method)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -726,7 +785,7 @@ void Method::Clear() {
_impl_.name_.ClearToEmpty();
_impl_.request_type_url_.ClearToEmpty();
_impl_.response_type_url_.ClearToEmpty();
- ::memset(&_impl_.request_streaming_, 0, static_cast<size_t>(
+ ::memset(&_impl_.request_streaming_, 0, static_cast<::size_t>(
reinterpret_cast<char*>(&_impl_.syntax_) -
reinterpret_cast<char*>(&_impl_.request_streaming_)) + sizeof(_impl_.syntax_));
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
@@ -735,58 +794,63 @@ void Method::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// string name = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Method.name"));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// string request_type_url = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) {
auto str = _internal_mutable_request_type_url();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Method.request_type_url"));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// bool request_streaming = 3;
case 3:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 24)) {
_impl_.request_streaming_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// string response_type_url = 4;
case 4:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 34)) {
auto str = _internal_mutable_response_type_url();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Method.response_type_url"));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// bool response_streaming = 5;
case 5:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 40)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 40)) {
_impl_.response_streaming_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.Option options = 6;
case 6:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 50)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 50)) {
ptr -= 1;
do {
ptr += 1;
@@ -794,17 +858,19 @@ const char* Method::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// .google.protobuf.Syntax syntax = 7;
case 7:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 56)) {
- arc_ui64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 56)) {
+ ::arc_ui32 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
_internal_set_syntax(static_cast<::PROTOBUF_NAMESPACE_ID::Syntax>(val));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -829,52 +895,48 @@ failure:
#undef CHK_
}
-uint8_t* Method::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* Method::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Method)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// string name = 1;
if (!this->_internal_name().empty()) {
+ const TProtoStringType& _s = this->_internal_name();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
- this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
- "google.protobuf.Method.name");
- target = stream->WriteStringMaybeAliased(
- 1, this->_internal_name(), target);
+ _s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Method.name");
+ target = stream->WriteStringMaybeAliased(1, _s, target);
}
// string request_type_url = 2;
if (!this->_internal_request_type_url().empty()) {
+ const TProtoStringType& _s = this->_internal_request_type_url();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
- this->_internal_request_type_url().data(), static_cast<int>(this->_internal_request_type_url().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
- "google.protobuf.Method.request_type_url");
- target = stream->WriteStringMaybeAliased(
- 2, this->_internal_request_type_url(), target);
+ _s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Method.request_type_url");
+ target = stream->WriteStringMaybeAliased(2, _s, target);
}
// bool request_streaming = 3;
if (this->_internal_request_streaming() != 0) {
target = stream->EnsureSpace(target);
- target = ::_pbi::WireFormatLite::WriteBoolToArray(3, this->_internal_request_streaming(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(
+ 3, this->_internal_request_streaming(), target);
}
// string response_type_url = 4;
if (!this->_internal_response_type_url().empty()) {
+ const TProtoStringType& _s = this->_internal_response_type_url();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
- this->_internal_response_type_url().data(), static_cast<int>(this->_internal_response_type_url().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
- "google.protobuf.Method.response_type_url");
- target = stream->WriteStringMaybeAliased(
- 4, this->_internal_response_type_url(), target);
+ _s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Method.response_type_url");
+ target = stream->WriteStringMaybeAliased(4, _s, target);
}
// bool response_streaming = 5;
if (this->_internal_response_streaming() != 0) {
target = stream->EnsureSpace(target);
- target = ::_pbi::WireFormatLite::WriteBoolToArray(5, this->_internal_response_streaming(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(
+ 5, this->_internal_response_streaming(), target);
}
// repeated .google.protobuf.Option options = 6;
@@ -889,7 +951,7 @@ uint8_t* Method::_InternalSerialize(
if (this->_internal_syntax() != 0) {
target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::WriteEnumToArray(
- 7, this->_internal_syntax(), target);
+ 7, this->_internal_syntax(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
@@ -900,11 +962,11 @@ uint8_t* Method::_InternalSerialize(
return target;
}
-size_t Method::ByteSizeLong() const {
+::size_t Method::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Method)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -917,39 +979,36 @@ size_t Method::ByteSizeLong() const {
// string name = 1;
if (!this->_internal_name().empty()) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_name());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_name());
}
// string request_type_url = 2;
if (!this->_internal_request_type_url().empty()) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_request_type_url());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_request_type_url());
}
// string response_type_url = 4;
if (!this->_internal_response_type_url().empty()) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_response_type_url());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_response_type_url());
}
// bool request_streaming = 3;
if (this->_internal_request_streaming() != 0) {
- total_size += 1 + 1;
+ total_size += 2;
}
// bool response_streaming = 5;
if (this->_internal_response_streaming() != 0) {
- total_size += 1 + 1;
+ total_size += 2;
}
// .google.protobuf.Syntax syntax = 7;
if (this->_internal_syntax() != 0) {
total_size += 1 +
- ::_pbi::WireFormatLite::EnumSize(this->_internal_syntax());
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_syntax());
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -966,8 +1025,8 @@ void Method::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBU
auto* const _this = static_cast<Method*>(&to_msg);
auto& from = static_cast<const Method&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Method)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.options_.MergeFrom(from._impl_.options_);
@@ -1009,18 +1068,12 @@ void Method::InternalSwap(Method* other) {
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
_impl_.options_.InternalSwap(&other->_impl_.options_);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.name_, lhs_arena,
- &other->_impl_.name_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.request_type_url_, lhs_arena,
- &other->_impl_.request_type_url_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.response_type_url_, lhs_arena,
- &other->_impl_.response_type_url_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, lhs_arena,
+ &other->_impl_.name_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.request_type_url_, lhs_arena,
+ &other->_impl_.request_type_url_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.response_type_url_, lhs_arena,
+ &other->_impl_.response_type_url_, rhs_arena);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(Method, _impl_.syntax_)
+ sizeof(Method::_impl_.syntax_)
@@ -1034,64 +1087,62 @@ void Method::InternalSwap(Method* other) {
&descriptor_table_google_2fprotobuf_2fapi_2eproto_getter, &descriptor_table_google_2fprotobuf_2fapi_2eproto_once,
file_level_metadata_google_2fprotobuf_2fapi_2eproto[1]);
}
-
// ===================================================================
class Mixin::_Internal {
public:
};
-Mixin::Mixin(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+Mixin::Mixin(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Mixin)
}
Mixin::Mixin(const Mixin& from)
: ::PROTOBUF_NAMESPACE_ID::Message() {
Mixin* const _this = this; (void)_this;
new (&_impl_) Impl_{
- decltype(_impl_.name_){}
- , decltype(_impl_.root_){}
+ decltype(_impl_.name_) {}
+
+ , decltype(_impl_.root_) {}
+
, /*decltype(_impl_._cached_size_)*/{}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) {
- _this->_impl_.name_.Set(from._internal_name(),
- _this->GetArenaForAllocation());
+ _this->_impl_.name_.Set(from._internal_name(), _this->GetArenaForAllocation());
}
_impl_.root_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.root_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.root_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_root().empty()) {
- _this->_impl_.root_.Set(from._internal_root(),
- _this->GetArenaForAllocation());
+ _this->_impl_.root_.Set(from._internal_root(), _this->GetArenaForAllocation());
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.Mixin)
}
-inline void Mixin::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void Mixin::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
- decltype(_impl_.name_){}
- , decltype(_impl_.root_){}
+ decltype(_impl_.name_) {}
+
+ , decltype(_impl_.root_) {}
+
, /*decltype(_impl_._cached_size_)*/{}
};
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.root_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.root_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.root_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
Mixin::~Mixin() {
@@ -1104,7 +1155,7 @@ Mixin::~Mixin() {
}
inline void Mixin::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.name_.Destroy();
_impl_.root_.Destroy();
}
@@ -1115,7 +1166,7 @@ void Mixin::SetCachedSize(int size) const {
void Mixin::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Mixin)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -1127,28 +1178,30 @@ void Mixin::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// string name = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Mixin.name"));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// string root = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) {
auto str = _internal_mutable_root();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Mixin.root"));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -1173,30 +1226,26 @@ failure:
#undef CHK_
}
-uint8_t* Mixin::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* Mixin::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Mixin)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// string name = 1;
if (!this->_internal_name().empty()) {
+ const TProtoStringType& _s = this->_internal_name();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
- this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
- "google.protobuf.Mixin.name");
- target = stream->WriteStringMaybeAliased(
- 1, this->_internal_name(), target);
+ _s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Mixin.name");
+ target = stream->WriteStringMaybeAliased(1, _s, target);
}
// string root = 2;
if (!this->_internal_root().empty()) {
+ const TProtoStringType& _s = this->_internal_root();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
- this->_internal_root().data(), static_cast<int>(this->_internal_root().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
- "google.protobuf.Mixin.root");
- target = stream->WriteStringMaybeAliased(
- 2, this->_internal_root(), target);
+ _s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Mixin.root");
+ target = stream->WriteStringMaybeAliased(2, _s, target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
@@ -1207,26 +1256,24 @@ uint8_t* Mixin::_InternalSerialize(
return target;
}
-size_t Mixin::ByteSizeLong() const {
+::size_t Mixin::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Mixin)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// string name = 1;
if (!this->_internal_name().empty()) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_name());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_name());
}
// string root = 2;
if (!this->_internal_root().empty()) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_root());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_root());
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -1243,8 +1290,8 @@ void Mixin::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF
auto* const _this = static_cast<Mixin*>(&to_msg);
auto& from = static_cast<const Mixin&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Mixin)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
if (!from._internal_name().empty()) {
@@ -1272,14 +1319,10 @@ void Mixin::InternalSwap(Mixin* other) {
auto* lhs_arena = GetArenaForAllocation();
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.name_, lhs_arena,
- &other->_impl_.name_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.root_, lhs_arena,
- &other->_impl_.root_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, lhs_arena,
+ &other->_impl_.name_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.root_, lhs_arena,
+ &other->_impl_.root_, rhs_arena);
}
::PROTOBUF_NAMESPACE_ID::Metadata Mixin::GetMetadata() const {
@@ -1287,7 +1330,6 @@ void Mixin::InternalSwap(Mixin* other) {
&descriptor_table_google_2fprotobuf_2fapi_2eproto_getter, &descriptor_table_google_2fprotobuf_2fapi_2eproto_once,
file_level_metadata_google_2fprotobuf_2fapi_2eproto[2]);
}
-
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
@@ -1304,6 +1346,5 @@ Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Mixin >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Mixin >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
-
// @@protoc_insertion_point(global_scope)
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protobuf/src/google/protobuf/api.pb.h b/contrib/libs/protobuf/src/google/protobuf/api.pb.h
index 069b350b709..5a9feb3ca0d 100644
--- a/contrib/libs/protobuf/src/google/protobuf/api.pb.h
+++ b/contrib/libs/protobuf/src/google/protobuf/api.pb.h
@@ -1,40 +1,45 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/api.proto
-#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fapi_2eproto
-#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fapi_2eproto
+#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fapi_2eproto_2epb_2eh
+#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fapi_2eproto_2epb_2eh
#include <limits>
#include <string>
-
-#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3021000
-#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 3021003 < 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.
-#endif
-
-#include <google/protobuf/port_undef.inc>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/arena.h>
-#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_util.h>
-#include <google/protobuf/metadata_lite.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h> // IWYU pragma: export
-#include <google/protobuf/extension_set.h> // IWYU pragma: export
-#include <google/protobuf/unknown_field_set.h>
-#include <google/protobuf/source_context.pb.h>
-#include <google/protobuf/type.pb.h>
+#include <type_traits>
+
+#include "google/protobuf/port_def.inc"
+#if PROTOBUF_VERSION < 4022000
+#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 // PROTOBUF_VERSION
+
+#if 4022005 < 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."
+#endif // PROTOBUF_MIN_PROTOC_VERSION
+#include "google/protobuf/port_undef.inc"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/arena.h"
+#include "google/protobuf/arenastring.h"
+#include "google/protobuf/generated_message_util.h"
+#include "google/protobuf/metadata_lite.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/repeated_field.h" // IWYU pragma: export
+#include "google/protobuf/extension_set.h" // IWYU pragma: export
+#include "google/protobuf/unknown_field_set.h"
+#include "google/protobuf/source_context.pb.h"
+#include "google/protobuf/type.pb.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fapi_2eproto PROTOBUF_EXPORT
+
PROTOBUF_NAMESPACE_OPEN
namespace internal {
class AnyMetadata;
@@ -43,9 +48,10 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fapi_2eproto {
- static const arc_ui32 offsets[];
+ static const ::arc_ui32 offsets[];
};
-PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fapi_2eproto;
+PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable
+ descriptor_table_google_2fprotobuf_2fapi_2eproto;
PROTOBUF_NAMESPACE_OPEN
class Api;
struct ApiDefaultTypeInternal;
@@ -56,16 +62,21 @@ PROTOBUF_EXPORT extern MethodDefaultTypeInternal _Method_default_instance_;
class Mixin;
struct MixinDefaultTypeInternal;
PROTOBUF_EXPORT extern MixinDefaultTypeInternal _Mixin_default_instance_;
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Api* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Api>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Method* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Method>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Mixin* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Mixin>(Arena*);
PROTOBUF_NAMESPACE_CLOSE
-PROTOBUF_NAMESPACE_OPEN
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Api* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Api>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Method* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Method>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Mixin* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Mixin>(Arena*);
-PROTOBUF_NAMESPACE_CLOSE
+
PROTOBUF_NAMESPACE_OPEN
// ===================================================================
+
+// -------------------------------------------------------------------
+
class PROTOBUF_EXPORT Api final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Api) */ {
public:
@@ -134,7 +145,7 @@ class PROTOBUF_EXPORT Api final :
}
void UnsafeArenaSwap(Api* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -155,26 +166,25 @@ class PROTOBUF_EXPORT Api final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(Api* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.Api";
}
protected:
- explicit Api(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit Api(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -199,8 +209,9 @@ class PROTOBUF_EXPORT Api final :
int methods_size() const;
private:
int _internal_methods_size() const;
+
public:
- void clear_methods();
+ void clear_methods() ;
::PROTOBUF_NAMESPACE_ID::Method* mutable_methods(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Method >*
mutable_methods();
@@ -212,13 +223,13 @@ class PROTOBUF_EXPORT Api final :
::PROTOBUF_NAMESPACE_ID::Method* add_methods();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Method >&
methods() const;
-
// repeated .google.protobuf.Option options = 3;
int options_size() const;
private:
int _internal_options_size() const;
+
public:
- void clear_options();
+ void clear_options() ;
::PROTOBUF_NAMESPACE_ID::Option* mutable_options(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >*
mutable_options();
@@ -230,13 +241,13 @@ class PROTOBUF_EXPORT Api final :
::PROTOBUF_NAMESPACE_ID::Option* add_options();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >&
options() const;
-
// repeated .google.protobuf.Mixin mixins = 6;
int mixins_size() const;
private:
int _internal_mixins_size() const;
+
public:
- void clear_mixins();
+ void clear_mixins() ;
::PROTOBUF_NAMESPACE_ID::Mixin* mutable_mixins(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Mixin >*
mutable_mixins();
@@ -248,41 +259,53 @@ class PROTOBUF_EXPORT Api final :
::PROTOBUF_NAMESPACE_ID::Mixin* add_mixins();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Mixin >&
mixins() const;
-
// string name = 1;
- void clear_name();
+ void clear_name() ;
const TProtoStringType& name() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_name(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_name(Arg_&& arg, Args_... args);
TProtoStringType* mutable_name();
PROTOBUF_NODISCARD TProtoStringType* release_name();
- void set_allocated_name(TProtoStringType* name);
+ void set_allocated_name(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_name() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_name();
- public:
+ public:
// string version = 4;
- void clear_version();
+ void clear_version() ;
const TProtoStringType& version() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_version(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_version(Arg_&& arg, Args_... args);
TProtoStringType* mutable_version();
PROTOBUF_NODISCARD TProtoStringType* release_version();
- void set_allocated_version(TProtoStringType* version);
+ void set_allocated_version(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_version() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_version(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_version(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_version();
- public:
+ public:
// .google.protobuf.SourceContext source_context = 5;
bool has_source_context() const;
private:
bool _internal_has_source_context() const;
+
public:
- void clear_source_context();
+ void clear_source_context() ;
const ::PROTOBUF_NAMESPACE_ID::SourceContext& source_context() const;
PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::SourceContext* release_source_context();
::PROTOBUF_NAMESPACE_ID::SourceContext* mutable_source_context();
@@ -294,16 +317,16 @@ class PROTOBUF_EXPORT Api final :
void unsafe_arena_set_allocated_source_context(
::PROTOBUF_NAMESPACE_ID::SourceContext* source_context);
::PROTOBUF_NAMESPACE_ID::SourceContext* unsafe_arena_release_source_context();
-
// .google.protobuf.Syntax syntax = 7;
- void clear_syntax();
+ void clear_syntax() ;
::PROTOBUF_NAMESPACE_ID::Syntax syntax() const;
void set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value);
+
private:
::PROTOBUF_NAMESPACE_ID::Syntax _internal_syntax() const;
void _internal_set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value);
- public:
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.Api)
private:
class _Internal;
@@ -323,8 +346,7 @@ class PROTOBUF_EXPORT Api final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fapi_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT Method final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Method) */ {
@@ -394,7 +416,7 @@ class PROTOBUF_EXPORT Method final :
}
void UnsafeArenaSwap(Method* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -415,26 +437,25 @@ class PROTOBUF_EXPORT Method final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(Method* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.Method";
}
protected:
- explicit Method(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit Method(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -459,8 +480,9 @@ class PROTOBUF_EXPORT Method final :
int options_size() const;
private:
int _internal_options_size() const;
+
public:
- void clear_options();
+ void clear_options() ;
::PROTOBUF_NAMESPACE_ID::Option* mutable_options(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >*
mutable_options();
@@ -472,76 +494,96 @@ class PROTOBUF_EXPORT Method final :
::PROTOBUF_NAMESPACE_ID::Option* add_options();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >&
options() const;
-
// string name = 1;
- void clear_name();
+ void clear_name() ;
const TProtoStringType& name() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_name(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_name(Arg_&& arg, Args_... args);
TProtoStringType* mutable_name();
PROTOBUF_NODISCARD TProtoStringType* release_name();
- void set_allocated_name(TProtoStringType* name);
+ void set_allocated_name(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_name() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_name();
- public:
+ public:
// string request_type_url = 2;
- void clear_request_type_url();
+ void clear_request_type_url() ;
const TProtoStringType& request_type_url() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_request_type_url(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_request_type_url(Arg_&& arg, Args_... args);
TProtoStringType* mutable_request_type_url();
PROTOBUF_NODISCARD TProtoStringType* release_request_type_url();
- void set_allocated_request_type_url(TProtoStringType* request_type_url);
+ void set_allocated_request_type_url(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_request_type_url() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_request_type_url(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_request_type_url(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_request_type_url();
- public:
+ public:
// string response_type_url = 4;
- void clear_response_type_url();
+ void clear_response_type_url() ;
const TProtoStringType& response_type_url() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_response_type_url(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_response_type_url(Arg_&& arg, Args_... args);
TProtoStringType* mutable_response_type_url();
PROTOBUF_NODISCARD TProtoStringType* release_response_type_url();
- void set_allocated_response_type_url(TProtoStringType* response_type_url);
+ void set_allocated_response_type_url(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_response_type_url() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_response_type_url(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_response_type_url(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_response_type_url();
- public:
+ public:
// bool request_streaming = 3;
- void clear_request_streaming();
+ void clear_request_streaming() ;
bool request_streaming() const;
void set_request_streaming(bool value);
+
private:
bool _internal_request_streaming() const;
void _internal_set_request_streaming(bool value);
- public:
+ public:
// bool response_streaming = 5;
- void clear_response_streaming();
+ void clear_response_streaming() ;
bool response_streaming() const;
void set_response_streaming(bool value);
+
private:
bool _internal_response_streaming() const;
void _internal_set_response_streaming(bool value);
- public:
+ public:
// .google.protobuf.Syntax syntax = 7;
- void clear_syntax();
+ void clear_syntax() ;
::PROTOBUF_NAMESPACE_ID::Syntax syntax() const;
void set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value);
+
private:
::PROTOBUF_NAMESPACE_ID::Syntax _internal_syntax() const;
void _internal_set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value);
- public:
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.Method)
private:
class _Internal;
@@ -561,8 +603,7 @@ class PROTOBUF_EXPORT Method final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fapi_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT Mixin final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Mixin) */ {
@@ -632,7 +673,7 @@ class PROTOBUF_EXPORT Mixin final :
}
void UnsafeArenaSwap(Mixin* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -653,26 +694,25 @@ class PROTOBUF_EXPORT Mixin final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(Mixin* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.Mixin";
}
protected:
- explicit Mixin(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit Mixin(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -689,33 +729,45 @@ class PROTOBUF_EXPORT Mixin final :
kRootFieldNumber = 2,
};
// string name = 1;
- void clear_name();
+ void clear_name() ;
const TProtoStringType& name() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_name(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_name(Arg_&& arg, Args_... args);
TProtoStringType* mutable_name();
PROTOBUF_NODISCARD TProtoStringType* release_name();
- void set_allocated_name(TProtoStringType* name);
+ void set_allocated_name(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_name() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_name();
- public:
+ public:
// string root = 2;
- void clear_root();
+ void clear_root() ;
const TProtoStringType& root() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_root(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_root(Arg_&& arg, Args_... args);
TProtoStringType* mutable_root();
PROTOBUF_NODISCARD TProtoStringType* release_root();
- void set_allocated_root(TProtoStringType* root);
+ void set_allocated_root(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_root() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_root(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_root(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_root();
- public:
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.Mixin)
private:
class _Internal;
@@ -731,15 +783,21 @@ class PROTOBUF_EXPORT Mixin final :
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fapi_2eproto;
};
+
// ===================================================================
+
+
// ===================================================================
+
#ifdef __GNUC__
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
+// -------------------------------------------------------------------
+
// Api
// string name = 1;
@@ -750,11 +808,11 @@ inline const TProtoStringType& Api::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Api.name)
return _internal_name();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void Api::set_name(ArgT0&& arg0, ArgT... args) {
-
- _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void Api::set_name(Arg_&& arg,
+ Args_... args) {
+ ;
+ _impl_.name_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Api.name)
}
inline TProtoStringType* Api::mutable_name() {
@@ -766,29 +824,26 @@ inline const TProtoStringType& Api::_internal_name() const {
return _impl_.name_.Get();
}
inline void Api::_internal_set_name(const TProtoStringType& value) {
-
+ ;
+
+
_impl_.name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Api::_internal_mutable_name() {
-
- return _impl_.name_.Mutable(GetArenaForAllocation());
+ ;
+ return _impl_.name_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* Api::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Api.name)
return _impl_.name_.Release();
}
-inline void Api::set_allocated_name(TProtoStringType* name) {
- if (name != nullptr) {
-
- } else {
-
- }
- _impl_.name_.SetAllocated(name, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+inline void Api::set_allocated_name(TProtoStringType* value) {
+ _impl_.name_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.name_.IsDefault()) {
+ _impl_.name_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.name)
}
@@ -877,11 +932,11 @@ inline const TProtoStringType& Api::version() const {
// @@protoc_insertion_point(field_get:google.protobuf.Api.version)
return _internal_version();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void Api::set_version(ArgT0&& arg0, ArgT... args) {
-
- _impl_.version_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void Api::set_version(Arg_&& arg,
+ Args_... args) {
+ ;
+ _impl_.version_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Api.version)
}
inline TProtoStringType* Api::mutable_version() {
@@ -893,29 +948,26 @@ inline const TProtoStringType& Api::_internal_version() const {
return _impl_.version_.Get();
}
inline void Api::_internal_set_version(const TProtoStringType& value) {
-
+ ;
+
+
_impl_.version_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Api::_internal_mutable_version() {
-
- return _impl_.version_.Mutable(GetArenaForAllocation());
+ ;
+ return _impl_.version_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* Api::release_version() {
// @@protoc_insertion_point(field_release:google.protobuf.Api.version)
return _impl_.version_.Release();
}
-inline void Api::set_allocated_version(TProtoStringType* version) {
- if (version != nullptr) {
-
- } else {
-
- }
- _impl_.version_.SetAllocated(version, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.version_.IsDefault()) {
- _impl_.version_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+inline void Api::set_allocated_version(TProtoStringType* value) {
+ _impl_.version_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.version_.IsDefault()) {
+ _impl_.version_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.version)
}
@@ -941,11 +993,6 @@ inline void Api::unsafe_arena_set_allocated_source_context(
delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.source_context_);
}
_impl_.source_context_ = source_context;
- if (source_context) {
-
- } else {
-
- }
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Api.source_context)
}
inline ::PROTOBUF_NAMESPACE_ID::SourceContext* Api::release_source_context() {
@@ -996,9 +1043,9 @@ inline void Api::set_allocated_source_context(::PROTOBUF_NAMESPACE_ID::SourceCon
source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, source_context, submessage_arena);
}
-
+
} else {
-
+
}
_impl_.source_context_ = source_context;
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.source_context)
@@ -1048,21 +1095,21 @@ Api::mixins() const {
inline void Api::clear_syntax() {
_impl_.syntax_ = 0;
}
-inline ::PROTOBUF_NAMESPACE_ID::Syntax Api::_internal_syntax() const {
- return static_cast< ::PROTOBUF_NAMESPACE_ID::Syntax >(_impl_.syntax_);
-}
inline ::PROTOBUF_NAMESPACE_ID::Syntax Api::syntax() const {
// @@protoc_insertion_point(field_get:google.protobuf.Api.syntax)
return _internal_syntax();
}
-inline void Api::_internal_set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) {
-
- _impl_.syntax_ = value;
-}
inline void Api::set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) {
- _internal_set_syntax(value);
+ _internal_set_syntax(value);
// @@protoc_insertion_point(field_set:google.protobuf.Api.syntax)
}
+inline ::PROTOBUF_NAMESPACE_ID::Syntax Api::_internal_syntax() const {
+ return static_cast<::PROTOBUF_NAMESPACE_ID::Syntax>(_impl_.syntax_);
+}
+inline void Api::_internal_set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) {
+ ;
+ _impl_.syntax_ = value;
+}
// -------------------------------------------------------------------
@@ -1076,11 +1123,11 @@ inline const TProtoStringType& Method::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Method.name)
return _internal_name();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void Method::set_name(ArgT0&& arg0, ArgT... args) {
-
- _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void Method::set_name(Arg_&& arg,
+ Args_... args) {
+ ;
+ _impl_.name_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Method.name)
}
inline TProtoStringType* Method::mutable_name() {
@@ -1092,29 +1139,26 @@ inline const TProtoStringType& Method::_internal_name() const {
return _impl_.name_.Get();
}
inline void Method::_internal_set_name(const TProtoStringType& value) {
-
+ ;
+
+
_impl_.name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Method::_internal_mutable_name() {
-
- return _impl_.name_.Mutable(GetArenaForAllocation());
+ ;
+ return _impl_.name_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* Method::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Method.name)
return _impl_.name_.Release();
}
-inline void Method::set_allocated_name(TProtoStringType* name) {
- if (name != nullptr) {
-
- } else {
-
- }
- _impl_.name_.SetAllocated(name, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+inline void Method::set_allocated_name(TProtoStringType* value) {
+ _impl_.name_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.name_.IsDefault()) {
+ _impl_.name_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.name)
}
@@ -1126,11 +1170,11 @@ inline const TProtoStringType& Method::request_type_url() const {
// @@protoc_insertion_point(field_get:google.protobuf.Method.request_type_url)
return _internal_request_type_url();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void Method::set_request_type_url(ArgT0&& arg0, ArgT... args) {
-
- _impl_.request_type_url_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void Method::set_request_type_url(Arg_&& arg,
+ Args_... args) {
+ ;
+ _impl_.request_type_url_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url)
}
inline TProtoStringType* Method::mutable_request_type_url() {
@@ -1142,29 +1186,26 @@ inline const TProtoStringType& Method::_internal_request_type_url() const {
return _impl_.request_type_url_.Get();
}
inline void Method::_internal_set_request_type_url(const TProtoStringType& value) {
-
+ ;
+
+
_impl_.request_type_url_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Method::_internal_mutable_request_type_url() {
-
- return _impl_.request_type_url_.Mutable(GetArenaForAllocation());
+ ;
+ return _impl_.request_type_url_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* Method::release_request_type_url() {
// @@protoc_insertion_point(field_release:google.protobuf.Method.request_type_url)
return _impl_.request_type_url_.Release();
}
-inline void Method::set_allocated_request_type_url(TProtoStringType* request_type_url) {
- if (request_type_url != nullptr) {
-
- } else {
-
- }
- _impl_.request_type_url_.SetAllocated(request_type_url, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.request_type_url_.IsDefault()) {
- _impl_.request_type_url_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+inline void Method::set_allocated_request_type_url(TProtoStringType* value) {
+ _impl_.request_type_url_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.request_type_url_.IsDefault()) {
+ _impl_.request_type_url_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.request_type_url)
}
@@ -1172,21 +1213,21 @@ inline void Method::set_allocated_request_type_url(TProtoStringType* request_typ
inline void Method::clear_request_streaming() {
_impl_.request_streaming_ = false;
}
-inline bool Method::_internal_request_streaming() const {
- return _impl_.request_streaming_;
-}
inline bool Method::request_streaming() const {
// @@protoc_insertion_point(field_get:google.protobuf.Method.request_streaming)
return _internal_request_streaming();
}
-inline void Method::_internal_set_request_streaming(bool value) {
-
- _impl_.request_streaming_ = value;
-}
inline void Method::set_request_streaming(bool value) {
_internal_set_request_streaming(value);
// @@protoc_insertion_point(field_set:google.protobuf.Method.request_streaming)
}
+inline bool Method::_internal_request_streaming() const {
+ return _impl_.request_streaming_;
+}
+inline void Method::_internal_set_request_streaming(bool value) {
+ ;
+ _impl_.request_streaming_ = value;
+}
// string response_type_url = 4;
inline void Method::clear_response_type_url() {
@@ -1196,11 +1237,11 @@ inline const TProtoStringType& Method::response_type_url() const {
// @@protoc_insertion_point(field_get:google.protobuf.Method.response_type_url)
return _internal_response_type_url();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void Method::set_response_type_url(ArgT0&& arg0, ArgT... args) {
-
- _impl_.response_type_url_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void Method::set_response_type_url(Arg_&& arg,
+ Args_... args) {
+ ;
+ _impl_.response_type_url_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url)
}
inline TProtoStringType* Method::mutable_response_type_url() {
@@ -1212,29 +1253,26 @@ inline const TProtoStringType& Method::_internal_response_type_url() const {
return _impl_.response_type_url_.Get();
}
inline void Method::_internal_set_response_type_url(const TProtoStringType& value) {
-
+ ;
+
+
_impl_.response_type_url_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Method::_internal_mutable_response_type_url() {
-
- return _impl_.response_type_url_.Mutable(GetArenaForAllocation());
+ ;
+ return _impl_.response_type_url_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* Method::release_response_type_url() {
// @@protoc_insertion_point(field_release:google.protobuf.Method.response_type_url)
return _impl_.response_type_url_.Release();
}
-inline void Method::set_allocated_response_type_url(TProtoStringType* response_type_url) {
- if (response_type_url != nullptr) {
-
- } else {
-
- }
- _impl_.response_type_url_.SetAllocated(response_type_url, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.response_type_url_.IsDefault()) {
- _impl_.response_type_url_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+inline void Method::set_allocated_response_type_url(TProtoStringType* value) {
+ _impl_.response_type_url_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.response_type_url_.IsDefault()) {
+ _impl_.response_type_url_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.response_type_url)
}
@@ -1242,21 +1280,21 @@ inline void Method::set_allocated_response_type_url(TProtoStringType* response_t
inline void Method::clear_response_streaming() {
_impl_.response_streaming_ = false;
}
-inline bool Method::_internal_response_streaming() const {
- return _impl_.response_streaming_;
-}
inline bool Method::response_streaming() const {
// @@protoc_insertion_point(field_get:google.protobuf.Method.response_streaming)
return _internal_response_streaming();
}
-inline void Method::_internal_set_response_streaming(bool value) {
-
- _impl_.response_streaming_ = value;
-}
inline void Method::set_response_streaming(bool value) {
_internal_set_response_streaming(value);
// @@protoc_insertion_point(field_set:google.protobuf.Method.response_streaming)
}
+inline bool Method::_internal_response_streaming() const {
+ return _impl_.response_streaming_;
+}
+inline void Method::_internal_set_response_streaming(bool value) {
+ ;
+ _impl_.response_streaming_ = value;
+}
// repeated .google.protobuf.Option options = 6;
inline int Method::_internal_options_size() const {
@@ -1299,21 +1337,21 @@ Method::options() const {
inline void Method::clear_syntax() {
_impl_.syntax_ = 0;
}
-inline ::PROTOBUF_NAMESPACE_ID::Syntax Method::_internal_syntax() const {
- return static_cast< ::PROTOBUF_NAMESPACE_ID::Syntax >(_impl_.syntax_);
-}
inline ::PROTOBUF_NAMESPACE_ID::Syntax Method::syntax() const {
// @@protoc_insertion_point(field_get:google.protobuf.Method.syntax)
return _internal_syntax();
}
-inline void Method::_internal_set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) {
-
- _impl_.syntax_ = value;
-}
inline void Method::set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) {
- _internal_set_syntax(value);
+ _internal_set_syntax(value);
// @@protoc_insertion_point(field_set:google.protobuf.Method.syntax)
}
+inline ::PROTOBUF_NAMESPACE_ID::Syntax Method::_internal_syntax() const {
+ return static_cast<::PROTOBUF_NAMESPACE_ID::Syntax>(_impl_.syntax_);
+}
+inline void Method::_internal_set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) {
+ ;
+ _impl_.syntax_ = value;
+}
// -------------------------------------------------------------------
@@ -1327,11 +1365,11 @@ inline const TProtoStringType& Mixin::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Mixin.name)
return _internal_name();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void Mixin::set_name(ArgT0&& arg0, ArgT... args) {
-
- _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void Mixin::set_name(Arg_&& arg,
+ Args_... args) {
+ ;
+ _impl_.name_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Mixin.name)
}
inline TProtoStringType* Mixin::mutable_name() {
@@ -1343,29 +1381,26 @@ inline const TProtoStringType& Mixin::_internal_name() const {
return _impl_.name_.Get();
}
inline void Mixin::_internal_set_name(const TProtoStringType& value) {
-
+ ;
+
+
_impl_.name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Mixin::_internal_mutable_name() {
-
- return _impl_.name_.Mutable(GetArenaForAllocation());
+ ;
+ return _impl_.name_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* Mixin::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Mixin.name)
return _impl_.name_.Release();
}
-inline void Mixin::set_allocated_name(TProtoStringType* name) {
- if (name != nullptr) {
-
- } else {
-
- }
- _impl_.name_.SetAllocated(name, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+inline void Mixin::set_allocated_name(TProtoStringType* value) {
+ _impl_.name_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.name_.IsDefault()) {
+ _impl_.name_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.name)
}
@@ -1377,11 +1412,11 @@ inline const TProtoStringType& Mixin::root() const {
// @@protoc_insertion_point(field_get:google.protobuf.Mixin.root)
return _internal_root();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void Mixin::set_root(ArgT0&& arg0, ArgT... args) {
-
- _impl_.root_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void Mixin::set_root(Arg_&& arg,
+ Args_... args) {
+ ;
+ _impl_.root_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Mixin.root)
}
inline TProtoStringType* Mixin::mutable_root() {
@@ -1393,45 +1428,39 @@ inline const TProtoStringType& Mixin::_internal_root() const {
return _impl_.root_.Get();
}
inline void Mixin::_internal_set_root(const TProtoStringType& value) {
-
+ ;
+
+
_impl_.root_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Mixin::_internal_mutable_root() {
-
- return _impl_.root_.Mutable(GetArenaForAllocation());
+ ;
+ return _impl_.root_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* Mixin::release_root() {
// @@protoc_insertion_point(field_release:google.protobuf.Mixin.root)
return _impl_.root_.Release();
}
-inline void Mixin::set_allocated_root(TProtoStringType* root) {
- if (root != nullptr) {
-
- } else {
-
- }
- _impl_.root_.SetAllocated(root, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.root_.IsDefault()) {
- _impl_.root_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+inline void Mixin::set_allocated_root(TProtoStringType* value) {
+ _impl_.root_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.root_.IsDefault()) {
+ _impl_.root_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.root)
}
#ifdef __GNUC__
- #pragma GCC diagnostic pop
+#pragma GCC diagnostic pop
#endif // __GNUC__
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
// @@protoc_insertion_point(namespace_scope)
-
PROTOBUF_NAMESPACE_CLOSE
+
// @@protoc_insertion_point(global_scope)
-#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fapi_2eproto
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fapi_2eproto_2epb_2eh
diff --git a/contrib/libs/protobuf/src/google/protobuf/api.proto b/contrib/libs/protobuf/src/google/protobuf/api.proto
index 3d598fc8590..afc9cc15629 100644
--- a/contrib/libs/protobuf/src/google/protobuf/api.proto
+++ b/contrib/libs/protobuf/src/google/protobuf/api.proto
@@ -35,11 +35,11 @@ package google.protobuf;
import "google/protobuf/source_context.proto";
import "google/protobuf/type.proto";
-option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option java_package = "com.google.protobuf";
option java_outer_classname = "ApiProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
+option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option go_package = "google.golang.org/protobuf/types/known/apipb";
// Api is a light-weight descriptor for an API Interface.
@@ -82,7 +82,6 @@ message Api {
// be omitted. Zero major versions must only be used for
// experimental, non-GA interfaces.
//
- //
string version = 4;
// Source context for the protocol buffer service represented by this
diff --git a/contrib/libs/protobuf/src/google/protobuf/arena.cc b/contrib/libs/protobuf/src/google/protobuf/arena.cc
index b19c1c4b4a8..35e3e1f64e4 100644
--- a/contrib/libs/protobuf/src/google/protobuf/arena.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/arena.cc
@@ -28,33 +28,63 @@
// (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/arena.h>
+#include "google/protobuf/arena.h"
#include <algorithm>
#include <atomic>
#include <cstddef>
#include <cstdint>
#include <limits>
+#include <string>
#include <typeinfo>
-#include <google/protobuf/arena_impl.h>
-#include <google/protobuf/arenaz_sampler.h>
-#include <google/protobuf/port.h>
+#include "y_absl/base/attributes.h"
+#include "y_absl/container/internal/btree.h"
+#include "y_absl/synchronization/mutex.h"
+#include "google/protobuf/arena_allocation_policy.h"
+#include "google/protobuf/arenaz_sampler.h"
+#include "google/protobuf/port.h"
+#include "google/protobuf/serial_arena.h"
+#include "google/protobuf/thread_safe_arena.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>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
namespace internal {
+namespace {
+
+#if defined(__GNUC__) && __GNUC__ >= 5
+// kSentryArenaBlock is used for arenas which can be referenced pre-main. So,
+// constexpr is required.
+constexpr ArenaBlock kSentryArenaBlock;
+
+ArenaBlock* SentryArenaBlock() {
+ // const_cast<> is okay as kSentryArenaBlock will never be mutated.
+ return const_cast<ArenaBlock*>(&kSentryArenaBlock);
+}
+#else
+// TODO(b/248322260) Remove this once we're not using GCC 4.9 for tests.
+// There is a compiler bug in this version that causes the above constexpr to
+// fail. This version is no longer in our support window, but we use it in
+// some of our aarch64 docker images.
+ArenaBlock* SentryArenaBlock() {
+ static const ArenaBlock kSentryArenaBlock;
+ // const_cast<> is okay as kSentryArenaBlock will never be mutated.
+ return const_cast<ArenaBlock*>(&kSentryArenaBlock);
+}
+#endif
+
+} // namespace
-static SerialArena::Memory AllocateMemory(const AllocationPolicy* policy_ptr,
- size_t last_size, size_t min_bytes) {
+static SizedPtr AllocateMemory(const AllocationPolicy* policy_ptr,
+ size_t last_size, size_t min_bytes) {
AllocationPolicy policy; // default policy
if (policy_ptr) policy = *policy_ptr;
size_t size;
@@ -66,17 +96,14 @@ static SerialArena::Memory AllocateMemory(const AllocationPolicy* policy_ptr,
size = policy.start_block_size;
}
// Verify that min_bytes + kBlockHeaderSize won't overflow.
- GOOGLE_CHECK_LE(min_bytes,
- std::numeric_limits<size_t>::max() - SerialArena::kBlockHeaderSize);
+ Y_ABSL_CHECK_LE(min_bytes, std::numeric_limits<size_t>::max() -
+ SerialArena::kBlockHeaderSize);
size = std::max(size, SerialArena::kBlockHeaderSize + min_bytes);
- void* mem;
if (policy.block_alloc == nullptr) {
- mem = ::operator new(size);
- } else {
- mem = policy.block_alloc(size);
+ return AllocateAtLeast(size);
}
- return {mem, size};
+ return {policy.block_alloc(size), size};
}
class GetDeallocator {
@@ -85,18 +112,18 @@ class GetDeallocator {
: dealloc_(policy ? policy->block_dealloc : nullptr),
space_allocated_(space_allocated) {}
- void operator()(SerialArena::Memory mem) const {
+ void operator()(SizedPtr mem) const {
#ifdef ADDRESS_SANITIZER
// This memory was provided by the underlying allocator as unpoisoned,
// so return it in an unpoisoned state.
- ASAN_UNPOISON_MEMORY_REGION(mem.ptr, mem.size);
+ ASAN_UNPOISON_MEMORY_REGION(mem.p, mem.n);
#endif // ADDRESS_SANITIZER
if (dealloc_) {
- dealloc_(mem.ptr, mem.size);
+ dealloc_(mem.p, mem.n);
} else {
- internal::SizedDelete(mem.ptr, mem.size);
+ internal::SizedDelete(mem.p, mem.n);
}
- *space_allocated_ += mem.size;
+ *space_allocated_ += mem.n;
}
private:
@@ -104,28 +131,57 @@ class GetDeallocator {
size_t* space_allocated_;
};
-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;
+// It is guaranteed that this is constructed in `b`. IOW, this is not the first
+// arena and `b` cannot be sentry.
+SerialArena::SerialArena(ArenaBlock* b, ThreadSafeArena& parent)
+ : ptr_{b->Pointer(kBlockHeaderSize + ThreadSafeArena::kSerialArenaSize)},
+ limit_{b->Limit()},
+ head_{b},
+ space_allocated_{b->size},
+ parent_{parent} {
+ Y_ABSL_DCHECK(!b->IsSentry());
}
-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, stats);
+// It is guaranteed that this is the first SerialArena. Use sentry block.
+SerialArena::SerialArena(ThreadSafeArena& parent)
+ : head_{SentryArenaBlock()}, parent_{parent} {}
+
+// It is guaranteed that this is the first SerialArena but `b` may be user
+// provided or newly allocated to store AllocationPolicy.
+SerialArena::SerialArena(FirstSerialArena, ArenaBlock* b,
+ ThreadSafeArena& parent)
+ : head_{b}, space_allocated_{b->size}, parent_{parent} {
+ if (b->IsSentry()) return;
+
+ set_ptr(b->Pointer(kBlockHeaderSize));
+ limit_ = b->Limit();
+}
+
+void SerialArena::Init(ArenaBlock* b, size_t offset) {
+ set_ptr(b->Pointer(offset));
+ limit_ = b->Limit();
+ head_.store(b, std::memory_order_relaxed);
+ space_used_.store(0, std::memory_order_relaxed);
+ space_allocated_.store(b->size, std::memory_order_relaxed);
+ cached_block_length_ = 0;
+ cached_blocks_ = nullptr;
+ string_block_ = nullptr;
+ string_block_unused_.store(0, std::memory_order_relaxed);
+}
+
+SerialArena* SerialArena::New(SizedPtr mem, ThreadSafeArena& parent) {
+ Y_ABSL_DCHECK_LE(kBlockHeaderSize + ThreadSafeArena::kSerialArenaSize, mem.n);
+ ThreadSafeArenaStats::RecordAllocateStats(parent.arena_stats_.MutableStats(),
+ /*used=*/0, /*allocated=*/mem.n,
+ /*wasted=*/0);
+ auto b = new (mem.p) ArenaBlock{nullptr, mem.n};
+ return new (b->Pointer(kBlockHeaderSize)) SerialArena(b, parent);
}
template <typename Deallocator>
-SerialArena::Memory SerialArena::Free(Deallocator deallocator) {
- Block* b = head_;
- Memory mem = {b, b->size};
+SizedPtr SerialArena::Free(Deallocator deallocator) {
+ ArenaBlock* b = head();
+ SizedPtr mem = {b, b->size};
while (b->next) {
b = b->next; // We must first advance before deleting this block
deallocator(mem);
@@ -135,80 +191,304 @@ SerialArena::Memory SerialArena::Free(Deallocator deallocator) {
}
PROTOBUF_NOINLINE
-std::pair<void*, SerialArena::CleanupNode*>
-SerialArena::AllocateAlignedWithCleanupFallback(
- size_t n, const AllocationPolicy* policy) {
- AllocateNewBlock(n + kCleanupSize, policy);
- return AllocateFromExistingWithCleanupFallback(n);
+void* SerialArena::AllocateAlignedFallback(size_t n) {
+ AllocateNewBlock(n);
+ return AllocateFromExisting(n);
}
PROTOBUF_NOINLINE
-void* SerialArena::AllocateAlignedFallback(size_t n,
- const AllocationPolicy* policy) {
- AllocateNewBlock(n, policy);
- return AllocateFromExisting(n);
+void* SerialArena::AllocateFromStringBlockFallback() {
+ if (string_block_) {
+ Y_ABSL_DCHECK_EQ(string_block_unused_.load(std::memory_order_relaxed), 0U);
+ space_used_.store(space_used_.load(std::memory_order_relaxed) +
+ string_block_->effective_size(),
+ std::memory_order_relaxed);
+ }
+
+ string_block_ = StringBlock::New(string_block_);
+ space_allocated_.store(space_allocated_.load(std::memory_order_relaxed) +
+ string_block_->allocated_size(),
+ std::memory_order_relaxed);
+
+ size_t unused = string_block_->effective_size() - sizeof(TProtoStringType);
+ string_block_unused_.store(unused, std::memory_order_relaxed);
+ return string_block_->AtOffset(unused);
}
-void SerialArena::AllocateNewBlock(size_t n, const AllocationPolicy* policy) {
- // Sync limit to block
- head_->start = reinterpret_cast<CleanupNode*>(limit_);
+PROTOBUF_NOINLINE
+void* SerialArena::AllocateAlignedWithCleanupFallback(
+ size_t n, size_t align, void (*destructor)(void*)) {
+ size_t required = AlignUpTo(n, align) + cleanup::Size(destructor);
+ AllocateNewBlock(required);
+ return AllocateFromExistingWithCleanupFallback(n, align, destructor);
+}
- // Record how much used in this block.
- size_t used = ptr_ - head_->Pointer(kBlockHeaderSize);
- size_t wasted = head_->size - used;
- space_used_ += used;
+PROTOBUF_NOINLINE
+void SerialArena::AddCleanupFallback(void* elem, void (*destructor)(void*)) {
+ size_t required = cleanup::Size(destructor);
+ AllocateNewBlock(required);
+ AddCleanupFromExisting(elem, destructor);
+}
+
+void SerialArena::AllocateNewBlock(size_t n) {
+ size_t used = 0;
+ size_t wasted = 0;
+ ArenaBlock* old_head = head();
+ if (!old_head->IsSentry()) {
+ // Sync limit to block
+ old_head->cleanup_nodes = limit_;
+
+ // Record how much used in this block.
+ used = static_cast<size_t>(ptr() - old_head->Pointer(kBlockHeaderSize));
+ wasted = old_head->size - used;
+ space_used_.store(space_used_.load(std::memory_order_relaxed) + used,
+ std::memory_order_relaxed);
+ }
// 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);
+ auto mem = AllocateMemory(parent_.AllocPolicy(), old_head->size, n);
// We don't want to emit an expensive RMW instruction that requires
// exclusive access to a cacheline. Hence we write it in terms of a
// 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);
+ space_allocated_.store(
+ space_allocated_.load(std::memory_order_relaxed) + mem.n,
+ std::memory_order_relaxed);
+ ThreadSafeArenaStats::RecordAllocateStats(parent_.arena_stats_.MutableStats(),
+ /*used=*/used,
+ /*allocated=*/mem.n, wasted);
+ auto* new_head = new (mem.p) ArenaBlock{old_head, mem.n};
+ set_ptr(new_head->Pointer(kBlockHeaderSize));
+ limit_ = new_head->Limit();
+ // Previous writes must take effect before writing new head.
+ head_.store(new_head, std::memory_order_release);
#ifdef ADDRESS_SANITIZER
- ASAN_POISON_MEMORY_REGION(ptr_, limit_ - ptr_);
+ ASAN_POISON_MEMORY_REGION(ptr(), limit_ - ptr());
#endif // ADDRESS_SANITIZER
}
arc_ui64 SerialArena::SpaceUsed() const {
- arc_ui64 space_used = ptr_ - head_->Pointer(kBlockHeaderSize);
- space_used += space_used_;
- // Remove the overhead of the SerialArena itself.
- space_used -= ThreadSafeArena::kSerialArenaSize;
- return space_used;
+ // Note: the calculation below technically causes a race with
+ // AllocateNewBlock when called from another thread (which happens in
+ // ThreadSafeArena::SpaceUsed). However, worst-case space_used_ will have
+ // stale data and the calculation will incorrectly assume 100%
+ // usage of the *current* block.
+ // TODO(mkruskal) Consider eliminating this race in exchange for a possible
+ // performance hit on ARM (see cl/455186837).
+ arc_ui64 current_space_used =
+ string_block_ ? string_block_->effective_size() -
+ string_block_unused_.load(std::memory_order_relaxed)
+ : 0;
+ const ArenaBlock* h = head_.load(std::memory_order_acquire);
+ if (h->IsSentry()) return current_space_used;
+
+ const arc_ui64 current_block_size = h->size;
+ current_space_used += std::min(
+ static_cast<arc_ui64>(
+ ptr() - const_cast<ArenaBlock*>(h)->Pointer(kBlockHeaderSize)),
+ current_block_size);
+ return current_space_used + space_used_.load(std::memory_order_relaxed);
+}
+
+size_t SerialArena::FreeStringBlocks(StringBlock* string_block,
+ size_t unused_bytes) {
+ Y_ABSL_DCHECK(string_block != nullptr);
+ StringBlock* next = string_block->next();
+ TProtoStringType* end = string_block->end();
+ for (TProtoStringType* s = string_block->AtOffset(unused_bytes); s != end; ++s) {
+ s->~TBasicString();
+ }
+ size_t deallocated = StringBlock::Delete(string_block);
+
+ while ((string_block = next) != nullptr) {
+ next = string_block->next();
+ for (TProtoStringType& s : *string_block) {
+ s.~TBasicString();
+ }
+ deallocated += StringBlock::Delete(string_block);
+ }
+ return deallocated;
}
void SerialArena::CleanupList() {
- Block* b = head_;
- b->start = reinterpret_cast<CleanupNode*>(limit_);
+ ArenaBlock* b = head();
+ if (b->IsSentry()) return;
+
+ b->cleanup_nodes = limit_;
do {
- auto* limit = reinterpret_cast<CleanupNode*>(
- b->Pointer(b->size & static_cast<size_t>(-8)));
- auto it = b->start;
- auto num = limit - it;
- if (num > 0) {
- for (; it < limit; it++) {
- it->cleanup(it->elem);
- }
+ char* limit = b->Limit();
+ char* it = reinterpret_cast<char*>(b->cleanup_nodes);
+ Y_ABSL_DCHECK(!b->IsSentry() || it == limit);
+ while (it < limit) {
+ it += cleanup::DestroyNode(it);
}
b = b->next;
} while (b);
}
+// Stores arrays of void* and SerialArena* instead of linked list of
+// SerialArena* to speed up traversing all SerialArena. The cost of walk is non
+// trivial when there are many nodes. Separately storing "ids" minimizes cache
+// footprints and more efficient when looking for matching arena.
+//
+// Uses y_absl::container_internal::Layout to emulate the following:
+//
+// struct SerialArenaChunk {
+// struct SerialArenaChunkHeader {
+// SerialArenaChunk* next_chunk;
+// arc_ui32 capacity;
+// std::atomic<arc_ui32> size;
+// } header;
+// std::atomic<void*> ids[];
+// std::atomic<SerialArena*> arenas[];
+// };
+//
+// where the size of "ids" and "arenas" is determined at runtime; hence the use
+// of Layout.
+struct SerialArenaChunkHeader {
+ constexpr SerialArenaChunkHeader(arc_ui32 capacity, arc_ui32 size)
+ : next_chunk(nullptr), capacity(capacity), size(size) {}
+
+ ThreadSafeArena::SerialArenaChunk* next_chunk;
+ arc_ui32 capacity;
+ std::atomic<arc_ui32> size;
+};
-ThreadSafeArena::CacheAlignedLifecycleIdGenerator
- ThreadSafeArena::lifecycle_id_generator_;
-#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)
+class ThreadSafeArena::SerialArenaChunk {
+ public:
+ SerialArenaChunk(arc_ui32 capacity, void* me, SerialArena* serial) {
+ new (&header()) SerialArenaChunkHeader{capacity, 1};
+
+ new (&id(0)) std::atomic<void*>{me};
+ for (arc_ui32 i = 1; i < capacity; ++i) {
+ new (&id(i)) std::atomic<void*>{nullptr};
+ }
+
+ new (&arena(0)) std::atomic<SerialArena*>{serial};
+ for (arc_ui32 i = 1; i < capacity; ++i) {
+ new (&arena(i)) std::atomic<void*>{nullptr};
+ }
+ }
+
+ bool IsSentry() const { return capacity() == 0; }
+
+ // next_chunk
+ const SerialArenaChunk* next_chunk() const { return header().next_chunk; }
+ SerialArenaChunk* next_chunk() { return header().next_chunk; }
+ void set_next(SerialArenaChunk* next_chunk) {
+ header().next_chunk = next_chunk;
+ }
+
+ // capacity
+ arc_ui32 capacity() const { return header().capacity; }
+ void set_capacity(arc_ui32 capacity) { header().capacity = capacity; }
+
+ // ids: returns up to size().
+ y_absl::Span<const std::atomic<void*>> ids() const {
+ return Layout(capacity()).Slice<kIds>(ptr()).first(safe_size());
+ }
+ y_absl::Span<std::atomic<void*>> ids() {
+ return Layout(capacity()).Slice<kIds>(ptr()).first(safe_size());
+ }
+ std::atomic<void*>& id(arc_ui32 i) {
+ Y_ABSL_DCHECK_LT(i, capacity());
+ return Layout(capacity()).Pointer<kIds>(ptr())[i];
+ }
+
+ // arenas: returns up to size().
+ y_absl::Span<const std::atomic<SerialArena*>> arenas() const {
+ return Layout(capacity()).Slice<kArenas>(ptr()).first(safe_size());
+ }
+ y_absl::Span<std::atomic<SerialArena*>> arenas() {
+ return Layout(capacity()).Slice<kArenas>(ptr()).first(safe_size());
+ }
+ const std::atomic<SerialArena*>& arena(arc_ui32 i) const {
+ Y_ABSL_DCHECK_LT(i, capacity());
+ return Layout(capacity()).Pointer<kArenas>(ptr())[i];
+ }
+ std::atomic<SerialArena*>& arena(arc_ui32 i) {
+ Y_ABSL_DCHECK_LT(i, capacity());
+ return Layout(capacity()).Pointer<kArenas>(ptr())[i];
+ }
+
+ // Tries to insert {id, serial} to head chunk. Returns false if the head is
+ // already full.
+ //
+ // Note that the updating "size", "id", "arena" is individually atomic but
+ // those are not protected by a mutex. This is acceptable because concurrent
+ // lookups from SpaceUsed or SpaceAllocated accept inaccuracy due to race. On
+ // other paths, either race is not possible (GetSerialArenaFallback) or must
+ // be prevented by users (CleanupList, Free).
+ bool insert(void* me, SerialArena* serial) {
+ arc_ui32 idx = size().fetch_add(1, std::memory_order_relaxed);
+ // Bail out if this chunk is full.
+ if (idx >= capacity()) {
+ // Write old value back to avoid potential overflow.
+ size().store(capacity(), std::memory_order_relaxed);
+ return false;
+ }
+
+ id(idx).store(me, std::memory_order_relaxed);
+ arena(idx).store(serial, std::memory_order_release);
+ return true;
+ }
+
+ constexpr static size_t AllocSize(size_t n) { return Layout(n).AllocSize(); }
+
+ private:
+ constexpr static int kHeader = 0;
+ constexpr static int kIds = 1;
+ constexpr static int kArenas = 2;
+
+ using layout_type = y_absl::container_internal::Layout<
+ SerialArenaChunkHeader, std::atomic<void*>, std::atomic<SerialArena*>>;
+
+ const char* ptr() const { return reinterpret_cast<const char*>(this); }
+ char* ptr() { return reinterpret_cast<char*>(this); }
+
+ SerialArenaChunkHeader& header() {
+ return *layout_type::Partial().Pointer<kHeader>(ptr());
+ }
+ const SerialArenaChunkHeader& header() const {
+ return *layout_type::Partial().Pointer<kHeader>(ptr());
+ }
+
+ std::atomic<arc_ui32>& size() { return header().size; }
+ const std::atomic<arc_ui32>& size() const { return header().size; }
+
+ // Returns the size capped by the capacity as fetch_add may result in a size
+ // greater than capacity.
+ arc_ui32 safe_size() const {
+ return std::min(capacity(), size().load(std::memory_order_relaxed));
+ }
+
+ constexpr static layout_type Layout(size_t n) {
+ return layout_type(
+ /*header*/ 1,
+ /*ids*/ n,
+ /*arenas*/ n);
+ }
+};
+
+constexpr SerialArenaChunkHeader kSentryArenaChunk = {0, 0};
+
+ThreadSafeArena::SerialArenaChunk* ThreadSafeArena::SentrySerialArenaChunk() {
+ // const_cast is okay because the sentry chunk is never mutated. Also,
+ // reinterpret_cast is acceptable here as it should be identical to
+ // SerialArenaChunk with zero payload. This is a necessary trick to
+ // constexpr initialize kSentryArenaChunk.
+ return reinterpret_cast<SerialArenaChunk*>(
+ const_cast<SerialArenaChunkHeader*>(&kSentryArenaChunk));
+}
+
+
+alignas(kCacheAlignment) Y_ABSL_CONST_INIT
+ std::atomic<ThreadSafeArena::LifecycleId> ThreadSafeArena::lifecycle_id_{0};
+#if defined(PROTOBUF_NO_THREADLOCAL)
ThreadSafeArena::ThreadCache& ThreadSafeArena::thread_cache() {
static internal::ThreadLocalStorage<ThreadCache>* thread_cache_ =
new internal::ThreadLocalStorage<ThreadCache>();
@@ -216,123 +496,172 @@ ThreadSafeArena::ThreadCache& ThreadSafeArena::thread_cache() {
}
#elif defined(PROTOBUF_USE_DLLS)
ThreadSafeArena::ThreadCache& ThreadSafeArena::thread_cache() {
- static PROTOBUF_THREAD_LOCAL ThreadCache thread_cache_ = {
- 0, static_cast<LifecycleIdAtomic>(-1), nullptr};
- return thread_cache_;
+ static PROTOBUF_THREAD_LOCAL ThreadCache thread_cache;
+ return thread_cache;
}
#else
-PROTOBUF_THREAD_LOCAL ThreadSafeArena::ThreadCache
- ThreadSafeArena::thread_cache_ = {0, static_cast<LifecycleIdAtomic>(-1),
- nullptr};
+PROTOBUF_CONSTINIT PROTOBUF_THREAD_LOCAL
+ ThreadSafeArena::ThreadCache ThreadSafeArena::thread_cache_;
#endif
-void ThreadSafeArena::InitializeFrom(void* mem, size_t size) {
- GOOGLE_DCHECK_EQ(reinterpret_cast<uintptr_t>(mem) & 7, 0u);
- GOOGLE_DCHECK(!AllocPolicy()); // Reset should call InitializeWithPolicy instead.
+ThreadSafeArena::ThreadSafeArena() : first_arena_(*this) { Init(); }
+
+ThreadSafeArena::ThreadSafeArena(char* mem, size_t size)
+ : first_arena_(FirstSerialArena{}, FirstBlock(mem, size), *this) {
Init();
+}
+
+ThreadSafeArena::ThreadSafeArena(void* mem, size_t size,
+ const AllocationPolicy& policy)
+ : first_arena_(FirstSerialArena{}, FirstBlock(mem, size, policy), *this) {
+ InitializeWithPolicy(policy);
+}
+
+ArenaBlock* ThreadSafeArena::FirstBlock(void* buf, size_t size) {
+ Y_ABSL_DCHECK_EQ(reinterpret_cast<uintptr_t>(buf) & 7, 0u);
+ if (buf == nullptr || size <= kBlockHeaderSize) {
+ return SentryArenaBlock();
+ }
+ // Record user-owned block.
+ alloc_policy_.set_is_user_owned_initial_block(true);
+ return new (buf) ArenaBlock{nullptr, size};
+}
+
+ArenaBlock* ThreadSafeArena::FirstBlock(void* buf, size_t size,
+ const AllocationPolicy& policy) {
+ if (policy.IsDefault()) return FirstBlock(buf, size);
- // Ignore initial block if it is too small.
- if (mem != nullptr && size >= kBlockHeaderSize + kSerialArenaSize) {
+ Y_ABSL_DCHECK_EQ(reinterpret_cast<uintptr_t>(buf) & 7, 0u);
+
+ SizedPtr mem;
+ if (buf == nullptr || size < kBlockHeaderSize + kAllocPolicySize) {
+ mem = AllocateMemory(&policy, 0, kAllocPolicySize);
+ } else {
+ mem = {buf, size};
+ // Record user-owned block.
alloc_policy_.set_is_user_owned_initial_block(true);
- SetInitialBlock(mem, size);
}
+
+ return new (mem.p) ArenaBlock{nullptr, mem.n};
}
-void ThreadSafeArena::InitializeWithPolicy(void* mem, size_t size,
- AllocationPolicy policy) {
+void ThreadSafeArena::InitializeWithPolicy(const AllocationPolicy& policy) {
+ Init();
+
+ if (policy.IsDefault()) return;
+
#ifndef NDEBUG
const arc_ui64 old_alloc_policy = alloc_policy_.get_raw();
// If there was a policy (e.g., in Reset()), make sure flags were preserved.
-#define GOOGLE_DCHECK_POLICY_FLAGS_() \
- if (old_alloc_policy > 3) \
- GOOGLE_CHECK_EQ(old_alloc_policy & 3, alloc_policy_.get_raw() & 3)
+#define Y_ABSL_DCHECK_POLICY_FLAGS_() \
+ if (old_alloc_policy > 3) \
+ Y_ABSL_CHECK_EQ(old_alloc_policy & 3, alloc_policy_.get_raw() & 3)
#else
-#define GOOGLE_DCHECK_POLICY_FLAGS_()
+#define Y_ABSL_DCHECK_POLICY_FLAGS_()
#endif // NDEBUG
- if (policy.IsDefault()) {
- // Legacy code doesn't use the API above, but provides the initial block
- // through ArenaOptions. I suspect most do not touch the allocation
- // policy parameters.
- InitializeFrom(mem, size);
- GOOGLE_DCHECK_POLICY_FLAGS_();
- return;
- }
- GOOGLE_DCHECK_EQ(reinterpret_cast<uintptr_t>(mem) & 7, 0u);
- Init();
-
- // Ignore initial block if it is too small. We include an optional
- // AllocationPolicy in this check, so that this can be allocated on the
- // first block.
- constexpr size_t kAPSize = internal::AlignUpTo8(sizeof(AllocationPolicy));
- constexpr size_t kMinimumSize = kBlockHeaderSize + kSerialArenaSize + kAPSize;
-
- // The value for alloc_policy_ stores whether or not allocations should be
- // recorded.
- alloc_policy_.set_should_record_allocs(
- policy.metrics_collector != nullptr &&
- policy.metrics_collector->RecordAllocs());
- // Make sure we have an initial block to store the AllocationPolicy.
- if (mem != nullptr && size >= kMinimumSize) {
- alloc_policy_.set_is_user_owned_initial_block(true);
- } else {
- auto tmp = AllocateMemory(&policy, 0, kMinimumSize);
- mem = tmp.ptr;
- size = tmp.size;
- }
- SetInitialBlock(mem, size);
-
- auto sa = threads_.load(std::memory_order_relaxed);
// We ensured enough space so this cannot fail.
void* p;
- if (!sa || !sa->MaybeAllocateAligned(kAPSize, &p)) {
- GOOGLE_LOG(FATAL) << "MaybeAllocateAligned cannot fail here.";
+ if (!first_arena_.MaybeAllocateAligned(kAllocPolicySize, &p)) {
+ Y_ABSL_LOG(FATAL) << "MaybeAllocateAligned cannot fail here.";
return;
}
new (p) AllocationPolicy{policy};
// Low bits store flags, so they mustn't be overwritten.
- GOOGLE_DCHECK_EQ(0, reinterpret_cast<uintptr_t>(p) & 3);
+ Y_ABSL_DCHECK_EQ(0u, reinterpret_cast<uintptr_t>(p) & 3);
alloc_policy_.set_policy(reinterpret_cast<AllocationPolicy*>(p));
- GOOGLE_DCHECK_POLICY_FLAGS_();
+ Y_ABSL_DCHECK_POLICY_FLAGS_();
-#undef GOOGLE_DCHECK_POLICY_FLAGS_
+#undef Y_ABSL_DCHECK_POLICY_FLAGS_
}
-void ThreadSafeArena::Init() {
-#ifndef NDEBUG
- const bool was_message_owned = IsMessageOwned();
-#endif // NDEBUG
+arc_ui64 ThreadSafeArena::GetNextLifeCycleId() {
ThreadCache& tc = thread_cache();
- auto id = tc.next_lifecycle_id;
- // We increment lifecycle_id's by multiples of two so we can use bit 0 as
- // a tag.
- constexpr arc_ui64 kDelta = 2;
- constexpr arc_ui64 kInc = ThreadCache::kPerThreadIds * kDelta;
+ arc_ui64 id = tc.next_lifecycle_id;
+ constexpr arc_ui64 kInc = ThreadCache::kPerThreadIds;
if (PROTOBUF_PREDICT_FALSE((id & (kInc - 1)) == 0)) {
- constexpr auto relaxed = std::memory_order_relaxed;
// On platforms that don't support arc_ui64 atomics we can certainly not
// afford to increment by large intervals and expect uniqueness due to
// wrapping, hence we only add by 1.
- id = lifecycle_id_generator_.id.fetch_add(1, relaxed) * kInc;
- }
- tc.next_lifecycle_id = id + kDelta;
- // Message ownership is stored in tag_and_id_, and is set in the constructor.
- // This flag bit must be preserved, even across calls to Reset().
- tag_and_id_ = id | (tag_and_id_ & kMessageOwnedArena);
- hint_.store(nullptr, std::memory_order_relaxed);
- threads_.store(nullptr, std::memory_order_relaxed);
-#ifndef NDEBUG
- GOOGLE_CHECK_EQ(was_message_owned, IsMessageOwned());
-#endif // NDEBUG
- arena_stats_ = Sample();
+ id = lifecycle_id_.fetch_add(1, std::memory_order_relaxed) * kInc;
+ }
+ tc.next_lifecycle_id = id + 1;
+ return id;
}
-void ThreadSafeArena::SetInitialBlock(void* mem, size_t size) {
- SerialArena* serial = SerialArena::New({mem, size}, &thread_cache(),
- arena_stats_.MutableStats());
- serial->set_next(NULL);
- threads_.store(serial, std::memory_order_relaxed);
- CacheSerialArena(serial);
+// We assume that #threads / arena is bimodal; i.e. majority small ones are
+// single threaded but some big ones are highly concurrent. To balance between
+// memory overhead and minimum pointer chasing, we start with few entries and
+// exponentially (4x) grow with a limit (255 entries). Note that parameters are
+// picked for x64 architectures as hint and the actual size is calculated by
+// Layout.
+ThreadSafeArena::SerialArenaChunk* ThreadSafeArena::NewSerialArenaChunk(
+ arc_ui32 prev_capacity, void* id, SerialArena* serial) {
+ constexpr size_t kMaxBytes = 4096; // Can hold up to 255 entries.
+ constexpr size_t kGrowthFactor = 4;
+ constexpr size_t kHeaderSize = SerialArenaChunk::AllocSize(0);
+ constexpr size_t kEntrySize = SerialArenaChunk::AllocSize(1) - kHeaderSize;
+
+ // On x64 arch: {4, 16, 64, 256, 256, ...} * 16.
+ size_t prev_bytes = SerialArenaChunk::AllocSize(prev_capacity);
+ size_t next_bytes = std::min(kMaxBytes, prev_bytes * kGrowthFactor);
+ arc_ui32 next_capacity =
+ static_cast<arc_ui32>(next_bytes - kHeaderSize) / kEntrySize;
+ // Growth based on bytes needs to be adjusted by AllocSize.
+ next_bytes = SerialArenaChunk::AllocSize(next_capacity);
+
+ // If we allocate bigger memory than requested, we should expand
+ // size to use that extra space, and add extra entries permitted
+ // by the extra space.
+ SizedPtr mem = AllocateAtLeast(next_bytes);
+ next_capacity = static_cast<arc_ui32>(mem.n - kHeaderSize) / kEntrySize;
+ Y_ABSL_DCHECK_LE(SerialArenaChunk::AllocSize(next_capacity), mem.n);
+ return new (mem.p) SerialArenaChunk{next_capacity, id, serial};
+}
+
+// Tries to reserve an entry by atomic fetch_add. If the head chunk is already
+// full (size >= capacity), acquires the mutex and adds a new head.
+void ThreadSafeArena::AddSerialArena(void* id, SerialArena* serial) {
+ SerialArenaChunk* head = head_.load(std::memory_order_acquire);
+ // Fast path without acquiring mutex.
+ if (!head->IsSentry() && head->insert(id, serial)) {
+ return;
+ }
+
+ // Slow path with acquiring mutex.
+ y_absl::MutexLock lock(&mutex_);
+
+ // Refetch and if someone else installed a new head, try allocating on that!
+ SerialArenaChunk* new_head = head_.load(std::memory_order_acquire);
+ if (new_head != head) {
+ if (new_head->insert(id, serial)) return;
+ // Update head to link to the latest one.
+ head = new_head;
+ }
+
+ new_head = NewSerialArenaChunk(head->capacity(), id, serial);
+ new_head->set_next(head);
+
+ // Use "std::memory_order_release" to make sure prior stores are visible after
+ // this one.
+ head_.store(new_head, std::memory_order_release);
+}
+
+void ThreadSafeArena::Init() {
+ tag_and_id_ = GetNextLifeCycleId();
+ arena_stats_ = Sample();
+ head_.store(SentrySerialArenaChunk(), std::memory_order_relaxed);
+ first_owner_ = &thread_cache();
+
+ // Record allocation for the first block that was either user-provided or
+ // newly allocated.
+ ThreadSafeArenaStats::RecordAllocateStats(
+ arena_stats_.MutableStats(),
+ /*used=*/0,
+ /*allocated=*/first_arena_.SpaceAllocated(),
+ /*wasted=*/0);
+
+ CacheSerialArena(&first_arena_);
}
ThreadSafeArena::~ThreadSafeArena() {
@@ -342,32 +671,44 @@ ThreadSafeArena::~ThreadSafeArena() {
size_t space_allocated = 0;
auto mem = Free(&space_allocated);
-
- // Policy is about to get deleted.
- auto* p = alloc_policy_.get();
- 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);
+ ASAN_UNPOISON_MEMORY_REGION(mem.p, mem.n);
#endif // ADDRESS_SANITIZER
- space_allocated += mem.size;
- } else {
+ space_allocated += mem.n;
+ } else if (mem.n > 0) {
GetDeallocator(alloc_policy_.get(), &space_allocated)(mem);
}
-
- if (collector) collector->OnDestroy(space_allocated);
}
-SerialArena::Memory ThreadSafeArena::Free(size_t* space_allocated) {
- SerialArena::Memory mem = {nullptr, 0};
+SizedPtr ThreadSafeArena::Free(size_t* space_allocated) {
auto deallocator = GetDeallocator(alloc_policy_.get(), space_allocated);
- PerSerialArena([deallocator, &mem](SerialArena* a) {
- if (mem.ptr) deallocator(mem);
- mem = a->Free(deallocator);
+
+ WalkSerialArenaChunk([&](SerialArenaChunk* chunk) {
+ y_absl::Span<std::atomic<SerialArena*>> span = chunk->arenas();
+ // Walks arenas backward to handle the first serial arena the last. Freeing
+ // in reverse-order to the order in which objects were created may not be
+ // necessary to Free and we should revisit this. (b/247560530)
+ for (auto it = span.rbegin(); it != span.rend(); ++it) {
+ SerialArena* serial = it->load(std::memory_order_relaxed);
+ Y_ABSL_DCHECK_NE(serial, nullptr);
+ // Free string blocks
+ *space_allocated += serial->FreeStringBlocks();
+ // Always frees the first block of "serial" as it cannot be user-provided.
+ SizedPtr mem = serial->Free(deallocator);
+ Y_ABSL_DCHECK_NE(mem.p, nullptr);
+ deallocator(mem);
+ }
+
+ // Delete the chunk as we're done with it.
+ internal::SizedDelete(chunk,
+ SerialArenaChunk::AllocSize(chunk->capacity()));
});
- return mem;
+
+ // The first block of the first arena is special and let the caller handle it.
+ *space_allocated += first_arena_.FreeStringBlocks();
+ return first_arena_.Free(deallocator);
}
arc_ui64 ThreadSafeArena::Reset() {
@@ -375,132 +716,178 @@ arc_ui64 ThreadSafeArena::Reset() {
// refer to memory in other blocks.
CleanupList();
- // Discard all blocks except the special block (if present).
+ // Discard all blocks except the first one. Whether it is user-provided or
+ // allocated, always reuse the first block for the first arena.
size_t space_allocated = 0;
auto mem = Free(&space_allocated);
- arena_stats_.RecordReset();
-
- AllocationPolicy* policy = alloc_policy_.get();
- if (policy) {
- auto saved_policy = *policy;
- if (alloc_policy_.is_user_owned_initial_block()) {
- space_allocated += mem.size;
- } else {
- GetDeallocator(alloc_policy_.get(), &space_allocated)(mem);
- mem.ptr = nullptr;
- mem.size = 0;
- }
- ArenaMetricsCollector* collector = saved_policy.metrics_collector;
- if (collector) collector->OnReset(space_allocated);
- InitializeWithPolicy(mem.ptr, mem.size, saved_policy);
+ space_allocated += mem.n;
+
+ // Reset the first arena with the first block. This avoids redundant
+ // free / allocation and re-allocating for AllocationPolicy. Adjust offset if
+ // we need to preserve alloc_policy_.
+ if (alloc_policy_.is_user_owned_initial_block() ||
+ alloc_policy_.get() != nullptr) {
+ size_t offset = alloc_policy_.get() == nullptr
+ ? kBlockHeaderSize
+ : kBlockHeaderSize + kAllocPolicySize;
+ first_arena_.Init(new (mem.p) ArenaBlock{nullptr, mem.n}, offset);
} else {
- GOOGLE_DCHECK(!alloc_policy_.should_record_allocs());
- // Nullptr policy
- if (alloc_policy_.is_user_owned_initial_block()) {
- space_allocated += mem.size;
- InitializeFrom(mem.ptr, mem.size);
- } else {
- GetDeallocator(alloc_policy_.get(), &space_allocated)(mem);
- Init();
- }
+ first_arena_.Init(SentryArenaBlock(), 0);
}
+ // Since the first block and potential alloc_policy on the first block is
+ // preserved, this can be initialized by Init().
+ Init();
+
return space_allocated;
}
-std::pair<void*, SerialArena::CleanupNode*>
-ThreadSafeArena::AllocateAlignedWithCleanup(size_t n,
- const std::type_info* type) {
+void* ThreadSafeArena::AllocateAlignedWithCleanup(size_t n, size_t align,
+ void (*destructor)(void*)) {
SerialArena* arena;
- if (PROTOBUF_PREDICT_TRUE(!alloc_policy_.should_record_allocs() &&
- GetSerialArenaFast(&arena))) {
- return arena->AllocateAlignedWithCleanup(n, alloc_policy_.get());
+ if (PROTOBUF_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
+ return arena->AllocateAlignedWithCleanup(n, align, destructor);
} else {
- return AllocateAlignedWithCleanupFallback(n, type);
+ return AllocateAlignedWithCleanupFallback(n, align, destructor);
}
}
void ThreadSafeArena::AddCleanup(void* elem, void (*cleanup)(void*)) {
SerialArena* arena;
if (PROTOBUF_PREDICT_FALSE(!GetSerialArenaFast(&arena))) {
- arena = GetSerialArenaFallback(&thread_cache());
+ arena = GetSerialArenaFallback(kMaxCleanupNodeSize);
}
- arena->AddCleanup(elem, cleanup, AllocPolicy());
+ arena->AddCleanup(elem, cleanup);
}
PROTOBUF_NOINLINE
-void* ThreadSafeArena::AllocateAlignedFallback(size_t n,
- const std::type_info* type) {
- if (alloc_policy_.should_record_allocs()) {
- alloc_policy_.RecordAlloc(type, n);
- SerialArena* arena;
- if (PROTOBUF_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
- return arena->AllocateAligned(n, alloc_policy_.get());
- }
- }
- return GetSerialArenaFallback(&thread_cache())
- ->AllocateAligned(n, alloc_policy_.get());
+void* ThreadSafeArena::AllocateAlignedWithCleanupFallback(
+ size_t n, size_t align, void (*destructor)(void*)) {
+ return GetSerialArenaFallback(n + kMaxCleanupNodeSize)
+ ->AllocateAlignedWithCleanup(n, align, destructor);
}
PROTOBUF_NOINLINE
-std::pair<void*, SerialArena::CleanupNode*>
-ThreadSafeArena::AllocateAlignedWithCleanupFallback(
- size_t n, const std::type_info* type) {
- if (alloc_policy_.should_record_allocs()) {
- alloc_policy_.RecordAlloc(type, n);
- SerialArena* arena;
- if (GetSerialArenaFast(&arena)) {
- return arena->AllocateAlignedWithCleanup(n, alloc_policy_.get());
- }
+void* ThreadSafeArena::AllocateFromStringBlock() {
+ SerialArena* arena;
+ if (PROTOBUF_PREDICT_FALSE(!GetSerialArenaFast(&arena))) {
+ arena = GetSerialArenaFallback(0);
}
- return GetSerialArenaFallback(&thread_cache())
- ->AllocateAlignedWithCleanup(n, alloc_policy_.get());
+ return arena->AllocateFromStringBlock();
}
-arc_ui64 ThreadSafeArena::SpaceAllocated() const {
- SerialArena* serial = threads_.load(std::memory_order_acquire);
- arc_ui64 res = 0;
- for (; serial; serial = serial->next()) {
- res += serial->SpaceAllocated();
+template <typename Functor>
+void ThreadSafeArena::WalkConstSerialArenaChunk(Functor fn) const {
+ const SerialArenaChunk* chunk = head_.load(std::memory_order_acquire);
+
+ for (; !chunk->IsSentry(); chunk = chunk->next_chunk()) {
+ fn(chunk);
}
- return res;
}
-arc_ui64 ThreadSafeArena::SpaceUsed() const {
- SerialArena* serial = threads_.load(std::memory_order_acquire);
- arc_ui64 space_used = 0;
- for (; serial; serial = serial->next()) {
- space_used += serial->SpaceUsed();
+template <typename Functor>
+void ThreadSafeArena::WalkSerialArenaChunk(Functor fn) {
+ // By omitting an Acquire barrier we help the sanitizer that any user code
+ // that doesn't properly synchronize Reset() or the destructor will throw a
+ // TSAN warning.
+ SerialArenaChunk* chunk = head_.load(std::memory_order_relaxed);
+
+ while (!chunk->IsSentry()) {
+ // Cache next chunk in case this chunk is destroyed.
+ SerialArenaChunk* next_chunk = chunk->next_chunk();
+ fn(chunk);
+ chunk = next_chunk;
}
+}
+
+template <typename Functor>
+void ThreadSafeArena::PerConstSerialArenaInChunk(Functor fn) const {
+ WalkConstSerialArenaChunk([&fn](const SerialArenaChunk* chunk) {
+ for (const auto& each : chunk->arenas()) {
+ const SerialArena* serial = each.load(std::memory_order_acquire);
+ // It is possible that newly added SerialArena is not updated although
+ // size was. This is acceptable for SpaceAllocated and SpaceUsed.
+ if (serial == nullptr) continue;
+ fn(serial);
+ }
+ });
+}
+
+arc_ui64 ThreadSafeArena::SpaceAllocated() const {
+ arc_ui64 space_allocated = first_arena_.SpaceAllocated();
+ PerConstSerialArenaInChunk([&space_allocated](const SerialArena* serial) {
+ space_allocated += serial->SpaceAllocated();
+ });
+ return space_allocated;
+}
+
+arc_ui64 ThreadSafeArena::SpaceUsed() const {
+ // First arena is inlined to ThreadSafeArena and the first block's overhead is
+ // smaller than others that contain SerialArena.
+ arc_ui64 space_used = first_arena_.SpaceUsed();
+ PerConstSerialArenaInChunk([&space_used](const SerialArena* serial) {
+ // SerialArena on chunks directly allocated from the block and needs to be
+ // subtracted from SpaceUsed.
+ space_used += serial->SpaceUsed() - kSerialArenaSize;
+ });
return space_used - (alloc_policy_.get() ? sizeof(AllocationPolicy) : 0);
}
+template <AllocationClient alloc_client>
+PROTOBUF_NOINLINE void* ThreadSafeArena::AllocateAlignedFallback(size_t n) {
+ return GetSerialArenaFallback(n)->AllocateAligned<alloc_client>(n);
+}
+
+template void* ThreadSafeArena::AllocateAlignedFallback<
+ AllocationClient::kDefault>(size_t);
+template void*
+ ThreadSafeArena::AllocateAlignedFallback<AllocationClient::kArray>(size_t);
+
void ThreadSafeArena::CleanupList() {
- PerSerialArena([](SerialArena* a) { a->CleanupList(); });
+ WalkSerialArenaChunk([](SerialArenaChunk* chunk) {
+ y_absl::Span<std::atomic<SerialArena*>> span = chunk->arenas();
+ // Walks arenas backward to handle the first serial arena the last.
+ // Destroying in reverse-order to the construction is often assumed by users
+ // and required not to break inter-object dependencies. (b/247560530)
+ for (auto it = span.rbegin(); it != span.rend(); ++it) {
+ SerialArena* serial = it->load(std::memory_order_relaxed);
+ Y_ABSL_DCHECK_NE(serial, nullptr);
+ serial->CleanupList();
+ }
+ });
+ // First arena must be cleaned up last. (b/247560530)
+ first_arena_.CleanupList();
}
PROTOBUF_NOINLINE
-SerialArena* ThreadSafeArena::GetSerialArenaFallback(void* me) {
- // Look for this SerialArena in our linked list.
- SerialArena* serial = threads_.load(std::memory_order_acquire);
- for (; serial; serial = serial->next()) {
- if (serial->owner() == me) {
- break;
- }
+SerialArena* ThreadSafeArena::GetSerialArenaFallback(size_t n) {
+ void* const id = &thread_cache();
+ if (id == first_owner_) {
+ CacheSerialArena(&first_arena_);
+ return &first_arena_;
}
+ // Search matching SerialArena.
+ SerialArena* serial = nullptr;
+ WalkConstSerialArenaChunk([&serial, id](const SerialArenaChunk* chunk) {
+ y_absl::Span<const std::atomic<void*>> ids = chunk->ids();
+ for (arc_ui32 i = 0; i < ids.size(); ++i) {
+ if (ids[i].load(std::memory_order_relaxed) == id) {
+ serial = chunk->arena(i).load(std::memory_order_relaxed);
+ Y_ABSL_DCHECK_NE(serial, nullptr);
+ break;
+ }
+ }
+ });
+
if (!serial) {
// 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.
+ // have any blocks yet. So we'll allocate its first block now. It must be
+ // big enough to host SerialArena and the pending request.
serial = SerialArena::New(
- AllocateMemory(alloc_policy_.get(), 0, kSerialArenaSize), me,
- arena_stats_.MutableStats());
+ AllocateMemory(alloc_policy_.get(), 0, n + kSerialArenaSize), *this);
- SerialArena* head = threads_.load(std::memory_order_relaxed);
- do {
- serial->set_next(head);
- } while (!threads_.compare_exchange_weak(
- head, serial, std::memory_order_release, std::memory_order_relaxed));
+ AddSerialArena(id, serial);
}
CacheSerialArena(serial);
@@ -509,29 +896,18 @@ SerialArena* ThreadSafeArena::GetSerialArenaFallback(void* me) {
} // namespace internal
-PROTOBUF_FUNC_ALIGN(32)
-void* Arena::AllocateAlignedNoHook(size_t n) {
- return impl_.AllocateAligned(n, nullptr);
-}
-
-PROTOBUF_FUNC_ALIGN(32)
-void* Arena::AllocateAlignedWithHook(size_t n, const std::type_info* type) {
- return impl_.AllocateAligned(n, type);
-}
+void* Arena::Allocate(size_t n) { return impl_.AllocateAligned(n); }
-PROTOBUF_FUNC_ALIGN(32)
-void* Arena::AllocateAlignedWithHookForArray(size_t n,
- const std::type_info* type) {
- return impl_.AllocateAligned<internal::AllocationClient::kArray>(n, type);
+void* Arena::AllocateForArray(size_t n) {
+ return impl_.AllocateAligned<internal::AllocationClient::kArray>(n);
}
-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);
+void* Arena::AllocateAlignedWithCleanup(size_t n, size_t align,
+ void (*destructor)(void*)) {
+ return impl_.AllocateAlignedWithCleanup(n, align, destructor);
}
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protobuf/src/google/protobuf/arena.h b/contrib/libs/protobuf/src/google/protobuf/arena.h
index 05e2234d5d4..9c15294c0ed 100644
--- a/contrib/libs/protobuf/src/google/protobuf/arena.h
+++ b/contrib/libs/protobuf/src/google/protobuf/arena.h
@@ -33,7 +33,6 @@
#ifndef GOOGLE_PROTOBUF_ARENA_H__
#define GOOGLE_PROTOBUF_ARENA_H__
-
#include <limits>
#include <type_traits>
#include <utility>
@@ -48,12 +47,15 @@ using type_info = ::type_info;
#include <typeinfo>
#endif
-#include <type_traits>
-#include <google/protobuf/arena_impl.h>
-#include <google/protobuf/port.h>
+#include "y_absl/meta/type_traits.h"
+#include "google/protobuf/arena_align.h"
+#include "google/protobuf/arena_config.h"
+#include "google/protobuf/port.h"
+#include "google/protobuf/serial_arena.h"
+#include "google/protobuf/thread_safe_arena.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
#ifdef SWIG
#error "You cannot SWIG proto headers"
@@ -86,25 +88,15 @@ 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
+class TcParser; // defined in generated_message_tctable_impl.h
template <typename Type>
class GenericTypeHandler; // defined in repeated_field.h
-inline PROTOBUF_ALWAYS_INLINE
-void* AlignTo(void* ptr, size_t align) {
- return reinterpret_cast<void*>(
- (reinterpret_cast<uintptr_t>(ptr) + align - 1) & (~align + 1));
-}
-
-// Templated cleanup methods.
-template <typename T>
-void arena_destruct_object(void* object) {
- reinterpret_cast<T*>(object)->~T();
-}
-
template <bool destructor_skippable, typename T>
struct ObjectDestructor {
- constexpr static void (*destructor)(void*) = &arena_destruct_object<T>;
+ constexpr static void (*destructor)(void*) =
+ &internal::cleanup::arena_destruct_object<T>;
};
template <typename T>
@@ -123,77 +115,48 @@ void arena_delete_object(void* object) {
struct ArenaOptions {
// This defines the size of the first block requested from the system malloc.
// Subsequent block sizes will increase in a geometric series up to a maximum.
- size_t start_block_size;
+ size_t start_block_size = internal::AllocationPolicy::kDefaultStartBlockSize;
// This defines the maximum block size requested from system malloc (unless an
// individual arena allocation request occurs with a size larger than this
// maximum). Requested block sizes increase up to this value, then remain
// here.
- size_t max_block_size;
+ size_t max_block_size = internal::GetDefaultArenaMaxBlockSize();
- // An initial block of memory for the arena to use, or NULL for none. If
+ // An initial block of memory for the arena to use, or nullptr for none. If
// provided, the block must live at least as long as the arena itself. The
// creator of the Arena retains ownership of the block after the Arena is
// destroyed.
- char* initial_block;
+ char* initial_block = nullptr;
// The size of the initial block, if provided.
- size_t initial_block_size;
+ size_t initial_block_size = 0;
// A function pointer to an alloc method that returns memory blocks of size
// requested. By default, it contains a ptr to the malloc function.
//
// NOTE: block_alloc and dealloc functions are expected to behave like
// malloc and free, including Asan poisoning.
- void* (*block_alloc)(size_t);
+ void* (*block_alloc)(size_t) = nullptr;
// A function pointer to a dealloc method that takes ownership of the blocks
// from the arena. By default, it contains a ptr to a wrapper function that
// calls free.
- void (*block_dealloc)(void*, size_t);
-
- ArenaOptions()
- : start_block_size(internal::AllocationPolicy::kDefaultStartBlockSize),
- max_block_size(internal::AllocationPolicy::kDefaultMaxBlockSize),
- initial_block(NULL),
- initial_block_size(0),
- block_alloc(nullptr),
- block_dealloc(nullptr),
- make_metrics_collector(nullptr) {}
+ void (*block_dealloc)(void*, size_t) = nullptr;
private:
- // If make_metrics_collector is not nullptr, it will be called at Arena init
- // time. It may return a pointer to a collector instance that will be notified
- // of interesting events related to the arena.
- internal::ArenaMetricsCollector* (*make_metrics_collector)();
-
- internal::ArenaMetricsCollector* MetricsCollector() const {
- return make_metrics_collector ? (*make_metrics_collector)() : nullptr;
- }
-
internal::AllocationPolicy AllocationPolicy() const {
internal::AllocationPolicy res;
res.start_block_size = start_block_size;
res.max_block_size = max_block_size;
res.block_alloc = block_alloc;
res.block_dealloc = block_dealloc;
- res.metrics_collector = MetricsCollector();
return res;
}
- friend void arena_metrics::EnableArenaMetrics(ArenaOptions*);
-
friend class Arena;
friend class ArenaOptionsTestFriend;
};
-// Support for non-RTTI environments. (The metrics hooks API uses type
-// information.)
-#if PROTOBUF_RTTI
-#define RTTI_TYPE_ID(type) (&typeid(type))
-#else
-#define RTTI_TYPE_ID(type) (NULL)
-#endif
-
// Arena allocator. Arena allocation replaces ordinary (heap-based) allocation
// with new/delete, and improves performance by aggregating allocations into
// larger blocks and freeing allocations all at once. Protocol messages are
@@ -221,7 +184,7 @@ struct ArenaOptions {
// with `args` (without `arena`), called when a T is allocated on the heap;
// and a constructor callable with `Arena* arena, Args&&... args`, called when
// a T is allocated on an arena. If the second constructor is called with a
-// NULL arena pointer, it must be equivalent to invoking the first
+// null arena pointer, it must be equivalent to invoking the first
// (`args`-only) constructor.
//
// - The type T must have a particular type trait: a nested type
@@ -231,7 +194,7 @@ struct ArenaOptions {
//
// - The type T *may* have the type trait |DestructorSkippable_|. If this type
// trait is present in the type, then its destructor will not be called if and
-// only if it was passed a non-NULL arena pointer. If this type trait is not
+// only if it was passed a non-null arena pointer. If this type trait is not
// present on the type, then its destructor is always called when the
// containing arena is destroyed.
//
@@ -270,13 +233,10 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
inline ~Arena() {}
- // TODO(protobuf-team): Fix callers to use constructor and delete this method.
- void Init(const ArenaOptions&) {}
-
// API to create proto2 message objects on the arena. If the arena passed in
- // is NULL, then a heap allocated object is returned. Type T must be a message
- // defined in a .proto file with cc_enable_arenas set to true, otherwise a
- // compilation error will occur.
+ // is nullptr, then a heap allocated object is returned. Type T must be a
+ // message defined in a .proto file with cc_enable_arenas set to true,
+ // otherwise a compilation error will occur.
//
// RepeatedField and RepeatedPtrField may also be instantiated directly on an
// arena with this method.
@@ -311,21 +271,33 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
// is obtained from the arena).
template <typename T, typename... Args>
PROTOBUF_NDEBUG_INLINE static T* Create(Arena* arena, Args&&... args) {
- return CreateInternal<T>(arena, std::is_convertible<T*, MessageLite*>(),
- static_cast<Args&&>(args)...);
+ if (PROTOBUF_PREDICT_FALSE(arena == nullptr)) {
+ return new T(std::forward<Args>(args)...);
+ }
+ return new (arena->AllocateInternal<T>()) T(std::forward<Args>(args)...);
+ }
+
+ // API to delete any objects not on an arena. This can be used to safely
+ // clean up messages or repeated fields without knowing whether or not they're
+ // owned by an arena. The pointer passed to this function should not be used
+ // again.
+ template <typename T>
+ PROTOBUF_ALWAYS_INLINE static void Destroy(T* obj) {
+ if (InternalGetOwningArena(obj) == nullptr) delete obj;
}
// 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));
+ if (align <= internal::ArenaAlignDefault::align) {
+ return Allocate(internal::ArenaAlignDefault::Ceil(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);
+ auto align_as = internal::ArenaAlignAs(align);
+ return align_as.Ceil(Allocate(align_as.Padded(size)));
}
}
@@ -342,12 +314,15 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
"CreateArray requires a trivially constructible type");
static_assert(std::is_trivially_destructible<T>::value,
"CreateArray requires a trivially destructible type");
- GOOGLE_CHECK_LE(num_elements, std::numeric_limits<size_t>::max() / sizeof(T))
+ Y_ABSL_CHECK_LE(num_elements, std::numeric_limits<size_t>::max() / sizeof(T))
<< "Requested size is too large to fit into size_t.";
- if (arena == NULL) {
+ if (PROTOBUF_PREDICT_FALSE(arena == nullptr)) {
return static_cast<T*>(::operator new[](num_elements * sizeof(T)));
} else {
- return arena->CreateInternalRawArray<T>(num_elements);
+ // We count on compiler to realize that if sizeof(T) is a multiple of
+ // 8 AlignUpTo can be elided.
+ return static_cast<T*>(
+ arena->AllocateAlignedForArray(sizeof(T) * num_elements, alignof(T)));
}
}
@@ -359,9 +334,12 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
// sizes of the underlying blocks.
arc_ui64 SpaceAllocated() const { return impl_.SpaceAllocated(); }
// Returns the total space used by the arena. Similar to SpaceAllocated but
- // does not include free space and block overhead. The total space returned
- // may not include space used by other threads executing concurrently with
- // the call to this method.
+ // does not include free space and block overhead. This is a best-effort
+ // estimate and may inaccurately calculate space used by other threads
+ // executing concurrently with the call to this method. These inaccuracies
+ // are due to race conditions, and are bounded but unpredictable. Stale data
+ // can lead to underestimates of the space used, and race conditions can lead
+ // to overestimates (up to the current block size).
arc_ui64 SpaceUsed() const { return impl_.SpaceUsed(); }
// Frees all storage allocated by this arena after calling destructors
@@ -375,7 +353,15 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
// when the arena is destroyed or reset.
template <typename T>
PROTOBUF_ALWAYS_INLINE void Own(T* object) {
- OwnInternal(object, std::is_convertible<T*, MessageLite*>());
+ // Collapsing all template instantiations to one for generic Message reduces
+ // code size, using the virtual destructor instead.
+ using TypeToUse =
+ std::conditional_t<std::is_convertible<T*, MessageLite*>::value,
+ MessageLite, T>;
+ if (object != nullptr) {
+ impl_.AddCleanup(static_cast<TypeToUse*>(object),
+ &internal::arena_delete_object<TypeToUse>);
+ }
}
// Adds |object| to a list of objects whose destructors will be manually
@@ -385,8 +371,8 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
// arena-allocated memory.
template <typename T>
PROTOBUF_ALWAYS_INLINE void OwnDestructor(T* object) {
- if (object != NULL) {
- impl_.AddCleanup(object, &internal::arena_destruct_object<T>);
+ if (object != nullptr) {
+ impl_.AddCleanup(object, &internal::cleanup::arena_destruct_object<T>);
}
}
@@ -400,51 +386,73 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
}
// Retrieves the arena associated with |value| if |value| is an arena-capable
- // message, or NULL otherwise. If possible, the call resolves at compile time.
- // Note that we can often devirtualize calls to `value->GetArena()` so usually
- // calling this method is unnecessary.
+ // message, or nullptr otherwise. If possible, the call resolves at compile
+ // time. Note that we can often devirtualize calls to `value->GetArena()` so
+ // usually calling this method is unnecessary.
template <typename T>
- PROTOBUF_ALWAYS_INLINE static Arena* GetArena(const T* value) {
+ PROTOBUF_ALWAYS_INLINE static Arena* GetArena(T* value) {
return GetArenaInternal(value);
}
template <typename T>
class InternalHelper {
private:
- // Provides access to protected GetOwningArena to generated messages.
- static Arena* GetOwningArena(const T* p) { return p->GetOwningArena(); }
+ // A SFINAE friendly trait that probes for `U` but always evalues to
+ // `Arena*`.
+ template <typename U>
+ using EnableIfArena =
+ typename std::enable_if<std::is_same<Arena*, U>::value, Arena*>::type;
+
+ // Rather than use SFINAE that must fully cover the space of options in a
+ // mutually exclusive fashion, we use implicit conversions to base classes
+ // to force an explicit ranking for our preferences. The lowest ranked
+ // version that compiles will be accepted.
+ struct Rank2 {};
+ struct Rank1 : Rank2 {};
+ struct Rank0 : Rank1 {};
+
+ static Arena* GetOwningArena(const T* p) {
+ return GetOwningArena(Rank0{}, p);
+ }
- static void InternalSwap(T* a, T* b) { a->InternalSwap(b); }
+ template <typename U>
+ static auto GetOwningArena(Rank0, const U* p)
+ -> EnableIfArena<decltype(p->GetOwningArena())> {
+ return p->GetOwningArena();
+ }
- static Arena* GetArenaForAllocationInternal(
- const T* p, std::true_type /*is_derived_from<MessageLite>*/) {
- return p->GetArenaForAllocation();
+ template <typename U>
+ static Arena* GetOwningArena(Rank1, const U*) {
+ return nullptr;
}
- static Arena* GetArenaForAllocationInternal(
- const T* p, std::false_type /*is_derived_from<MessageLite>*/) {
- return GetArenaForAllocationForNonMessage(
- p, typename is_arena_constructable::type());
+ static void InternalSwap(T* a, T* b) { a->InternalSwap(b); }
+
+ static Arena* GetArenaForAllocation(T* p) {
+ return GetArenaForAllocation(Rank0{}, p);
}
- static Arena* GetArenaForAllocationForNonMessage(
- const T* p, std::true_type /*is_arena_constructible*/) {
- return p->GetArena();
+ static Arena* GetArena(T* p) {
+ // Rather than replicate probing for `GetArena` with fallback to nullptr,
+ // we borrow the implementation of `GetArenaForAllocation` but skip
+ // `Rank0` which probes for `GetArenaForAllocation`.
+ return GetArenaForAllocation(Rank1{}, p);
}
- static Arena* GetArenaForAllocationForNonMessage(
- const T* p, std::false_type /*is_arena_constructible*/) {
- return GetArenaForAllocationForNonMessageNonArenaConstructible(
- p, typename has_get_arena::type());
+ template <typename U>
+ static auto GetArenaForAllocation(Rank0, U* p)
+ -> EnableIfArena<decltype(p->GetArenaForAllocation())> {
+ return p->GetArenaForAllocation();
}
- static Arena* GetArenaForAllocationForNonMessageNonArenaConstructible(
- const T* p, std::true_type /*has_get_arena*/) {
+ template <typename U>
+ static auto GetArenaForAllocation(Rank1, U* p)
+ -> EnableIfArena<decltype(p->GetArena())> {
return p->GetArena();
}
- static Arena* GetArenaForAllocationForNonMessageNonArenaConstructible(
- const T* /* p */, std::false_type /*has_get_arena*/) {
+ template <typename U>
+ static Arena* GetArenaForAllocation(Rank2, U*) {
return nullptr;
}
@@ -470,18 +478,6 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
sizeof(char)>
is_arena_constructable;
- template <typename U,
- typename std::enable_if<
- std::is_same<Arena*, decltype(std::declval<const U>()
- .GetArena())>::value,
- int>::type = 0>
- static char HasGetArena(decltype(&U::GetArena));
- template <typename U>
- static double HasGetArena(...);
-
- typedef std::integral_constant<bool, sizeof(HasGetArena<T>(nullptr)) ==
- sizeof(char)>
- has_get_arena;
template <typename... Args>
static T* Construct(void* ptr, Args&&... args) {
@@ -492,8 +488,6 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
return new T(nullptr);
}
- static Arena* GetArena(const T* p) { return p->GetArena(); }
-
friend class Arena;
friend class TestUtil::ReflectionTester;
};
@@ -508,19 +502,10 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
// 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{});
+ static Arena* InternalGetArenaForAllocation(T* p) {
+ return InternalHelper<T>::GetArenaForAllocation(p);
}
- // 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.
@@ -542,17 +527,6 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
private:
internal::ThreadSafeArena impl_;
- template <typename T>
- struct has_get_arena : InternalHelper<T>::has_get_arena {};
-
- // Constructor solely used by message-owned arena.
- inline Arena(internal::MessageOwned) : impl_(internal::MessageOwned{}) {}
-
- // Checks whether this arena is message-owned.
- PROTOBUF_ALWAYS_INLINE bool IsMessageOwned() const {
- return impl_.IsMessageOwned();
- }
-
void ReturnArrayMemory(void* p, size_t size) {
impl_.ReturnArrayMemory(p, size);
}
@@ -563,7 +537,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
static_assert(
InternalHelper<T>::is_arena_constructable::value,
"CreateMessage can only construct types that are ArenaConstructable");
- if (arena == NULL) {
+ if (PROTOBUF_PREDICT_FALSE(arena == nullptr)) {
return new T(nullptr, static_cast<Args&&>(args)...);
} else {
return arena->DoCreateMessage<T>(static_cast<Args&&>(args)...);
@@ -578,7 +552,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
static_assert(
InternalHelper<T>::is_arena_constructable::value,
"CreateMessage can only construct types that are ArenaConstructable");
- if (arena == NULL) {
+ if (arena == nullptr) {
// Generated arena constructor T(Arena*) is protected. Call via
// InternalHelper.
return InternalHelper<T>::New();
@@ -587,27 +561,13 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
}
}
- // Allocate and also optionally call collector with the allocated type info
- // when allocation recording is enabled.
- PROTOBUF_NDEBUG_INLINE void* AllocateInternal(size_t size, size_t align,
- void (*destructor)(void*),
- const std::type_info* type) {
- // Monitor allocation if needed.
- if (destructor == nullptr) {
- return AllocateAlignedWithHook(size, align, type);
+ template <typename T, bool trivial = std::is_trivially_destructible<T>::value>
+ PROTOBUF_NDEBUG_INLINE void* AllocateInternal() {
+ if (trivial) {
+ return AllocateAligned(sizeof(T), alignof(T));
} else {
- if (align <= 8) {
- auto res = AllocateAlignedWithCleanup(internal::AlignUpTo8(size), type);
- res.second->elem = res.first;
- res.second->cleanup = destructor;
- return res.first;
- } else {
- auto res = AllocateAlignedWithCleanup(size + align - 8, type);
- auto ptr = internal::AlignTo(res.first, align);
- res.second->elem = ptr;
- res.second->cleanup = destructor;
- return ptr;
- }
+ constexpr auto dtor = &internal::cleanup::arena_destruct_object<T>;
+ return AllocateAlignedWithCleanup(sizeof(T), alignof(T), dtor);
}
}
@@ -637,28 +597,11 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
std::forward<Args>(args)...);
}
- // Just allocate the required size for the given type assuming the
- // type has a trivial constructor.
- template <typename T>
- PROTOBUF_NDEBUG_INLINE T* CreateInternalRawArray(size_t num_elements) {
- GOOGLE_CHECK_LE(num_elements, std::numeric_limits<size_t>::max() / sizeof(T))
- << "Requested size is too large to fit into size_t.";
- // We count on compiler to realize that if sizeof(T) is a multiple of
- // 8 AlignUpTo can be elided.
- const size_t n = sizeof(T) * num_elements;
- return static_cast<T*>(
- AllocateAlignedWithHookForArray(n, alignof(T), RTTI_TYPE_ID(T)));
- }
-
template <typename T, typename... Args>
PROTOBUF_NDEBUG_INLINE T* DoCreateMessage(Args&&... args) {
return InternalHelper<T>::Construct(
- AllocateInternal(sizeof(T), alignof(T),
- internal::ObjectDestructor<
- InternalHelper<T>::is_destructor_skippable::value,
- T>::destructor,
- RTTI_TYPE_ID(T)),
- this, std::forward<Args>(args)...);
+ AllocateInternal<T, is_destructor_skippable<T>::value>(), this,
+ std::forward<Args>(args)...);
}
// CreateInArenaStorage is used to implement map field. Without it,
@@ -669,7 +612,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
CreateInArenaStorageInternal(ptr, arena,
typename is_arena_constructable<T>::type(),
std::forward<Args>(args)...);
- if (arena != nullptr) {
+ if (PROTOBUF_PREDICT_TRUE(arena != nullptr)) {
RegisterDestructorInternal(
ptr, arena,
typename InternalHelper<T>::is_destructor_skippable::type());
@@ -696,141 +639,39 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
arena->OwnDestructor(ptr);
}
- // These implement Create(). The second parameter has type 'true_type' if T is
- // a subtype of Message and 'false_type' otherwise.
- template <typename T, typename... Args>
- PROTOBUF_ALWAYS_INLINE static T* CreateInternal(Arena* arena, std::true_type,
- Args&&... args) {
- if (arena == nullptr) {
- return new T(std::forward<Args>(args)...);
- } else {
- auto destructor =
- internal::ObjectDestructor<std::is_trivially_destructible<T>::value,
- T>::destructor;
- T* result =
- new (arena->AllocateInternal(sizeof(T), alignof(T), destructor,
- RTTI_TYPE_ID(T)))
- T(std::forward<Args>(args)...);
- return result;
- }
- }
- template <typename T, typename... Args>
- PROTOBUF_ALWAYS_INLINE static T* CreateInternal(Arena* arena, std::false_type,
- Args&&... args) {
- if (arena == nullptr) {
- return new T(std::forward<Args>(args)...);
- } else {
- auto destructor =
- internal::ObjectDestructor<std::is_trivially_destructible<T>::value,
- T>::destructor;
- return new (arena->AllocateInternal(sizeof(T), alignof(T), destructor,
- RTTI_TYPE_ID(T)))
- T(std::forward<Args>(args)...);
- }
- }
-
- // These implement Own(), which registers an object for deletion (destructor
- // call and operator delete()). The second parameter has type 'true_type' if T
- // is a subtype of Message and 'false_type' otherwise. Collapsing
- // all template instantiations to one for generic Message reduces code size,
- // using the virtual destructor instead.
- template <typename T>
- PROTOBUF_ALWAYS_INLINE void OwnInternal(T* object, std::true_type) {
- if (object != NULL) {
- impl_.AddCleanup(object, &internal::arena_delete_object<MessageLite>);
- }
- }
- template <typename T>
- PROTOBUF_ALWAYS_INLINE void OwnInternal(T* object, std::false_type) {
- if (object != NULL) {
- impl_.AddCleanup(object, &internal::arena_delete_object<T>);
- }
- }
-
// Implementation for GetArena(). Only message objects with
// InternalArenaConstructable_ tags can be associated with an arena, and such
// objects must implement a GetArena() method.
- template <typename T, typename std::enable_if<
- is_arena_constructable<T>::value, int>::type = 0>
- PROTOBUF_ALWAYS_INLINE static Arena* GetArenaInternal(const T* value) {
- return InternalHelper<T>::GetArena(value);
- }
- template <typename T,
- typename std::enable_if<!is_arena_constructable<T>::value &&
- has_get_arena<T>::value,
- int>::type = 0>
- PROTOBUF_ALWAYS_INLINE static Arena* GetArenaInternal(const T* value) {
- return value->GetArena();
- }
- template <typename T,
- typename std::enable_if<!is_arena_constructable<T>::value &&
- !has_get_arena<T>::value,
- int>::type = 0>
- PROTOBUF_ALWAYS_INLINE static Arena* GetArenaInternal(const T* value) {
- (void)value;
- return nullptr;
- }
-
- template <typename T>
- PROTOBUF_ALWAYS_INLINE static Arena* GetOwningArena(const T* value) {
- return GetOwningArenaInternal(
- value, std::is_convertible<T*, MessageLite*>());
- }
-
- // Implementation for GetOwningArena(). All and only message objects have
- // GetOwningArena() method.
- template <typename T>
- PROTOBUF_ALWAYS_INLINE static Arena* GetOwningArenaInternal(
- const T* value, std::true_type) {
- return InternalHelper<T>::GetOwningArena(value);
- }
template <typename T>
- PROTOBUF_ALWAYS_INLINE static Arena* GetOwningArenaInternal(
- const T* /* value */, std::false_type) {
- return nullptr;
- }
-
- void* AllocateAlignedWithHookForArray(size_t n, size_t align,
- const std::type_info* type) {
- if (align <= 8) {
- 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(
- AllocateAlignedWithHookForArray(n + align - 8, type), align);
- }
+ PROTOBUF_ALWAYS_INLINE static Arena* GetArenaInternal(T* value) {
+ return InternalHelper<T>::GetArena(value);
}
- void* AllocateAlignedWithHook(size_t n, size_t align,
- const std::type_info* type) {
- if (align <= 8) {
- return AllocateAlignedWithHook(internal::AlignUpTo8(n), type);
+ void* AllocateAlignedForArray(size_t n, size_t align) {
+ if (align <= internal::ArenaAlignDefault::align) {
+ return AllocateForArray(internal::ArenaAlignDefault::Ceil(n));
} 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(AllocateAlignedWithHook(n + align - 8, type),
- align);
+ auto align_as = internal::ArenaAlignAs(align);
+ return align_as.Ceil(AllocateForArray(align_as.Padded(n)));
}
}
- 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);
+ void* Allocate(size_t n);
+ void* AllocateForArray(size_t n);
+ void* AllocateAlignedWithCleanup(size_t n, size_t align,
+ void (*destructor)(void*));
template <typename Type>
friend class internal::GenericTypeHandler;
friend class internal::InternalMetadata; // For user_arena().
friend class internal::LazyField; // For CreateMaybeMessage.
friend class internal::EpsCopyInputStream; // For parser performance
+ friend class internal::TcParser; // For parser performance
friend class MessageLite;
template <typename Key, typename T>
friend class Map;
@@ -840,12 +681,14 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena {
friend struct internal::ArenaTestPeer;
};
-// Defined above for supporting environments without RTTI.
-#undef RTTI_TYPE_ID
+template <>
+inline void* Arena::AllocateInternal<TProtoStringType, false>() {
+ return impl_.AllocateFromStringBlock();
+}
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_ARENA_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/error_listener.cc b/contrib/libs/protobuf/src/google/protobuf/arena_align.cc
index 538307bae2f..882ae5a826a 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/error_listener.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/arena_align.cc
@@ -28,15 +28,18 @@
// (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/util/internal/error_listener.h>
+#include "google/protobuf/arena_align.h"
+
+#include <cstddef>
+#include <cstdint>
namespace google {
namespace protobuf {
-namespace util {
-namespace converter {
+namespace internal {
+// There are still compilers (open source) requiring a definition for constexpr.
+constexpr size_t ArenaAlignDefault::align; // NOLINT
-} // namespace converter
-} // namespace util
+} // namespace internal
} // namespace protobuf
} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/arena_align.h b/contrib/libs/protobuf/src/google/protobuf/arena_align.h
new file mode 100644
index 00000000000..900fd348344
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/arena_align.h
@@ -0,0 +1,221 @@
+// 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.
+
+// This file provides alignment utilities for use in arenas.
+//
+// `ArenaAlign` contains a single `align` data member and provides
+// the below functions which operate on the given alignment.
+//
+// Ceil(size_t n) - rounds `n` up to the nearest `align` boundary.
+// Floor(size_t n) - rounds `n` down to the nearest `align` boundary.
+// Padded(size_t n) - returns the unaligned size to align 'n' bytes. (1)
+
+// Ceil(T* P) - rounds `p` up to the nearest `align` boundary. (2)
+// IsAligned(size_t n) - returns true if `n` is aligned to `align`
+// IsAligned(T* p) - returns true if `p` is aligned to `align`
+// CheckAligned(T* p) - returns `p`. Checks alignment of `p` in debug.
+//
+// 1) `Padded(n)` returns the minimum size needed to align an object of size 'n'
+// into a memory area that is default aligned. For example, allocating 'n'
+// bytes aligned at 32 bytes requires a size of 'n + 32 - 8' to align at 32
+// bytes for any 8 byte boundary.
+//
+// 2) There is an optimized `CeilDefaultAligned(T*)` method which is equivalent
+// to `Ceil(ArenaAlignDefault::CheckAlign(p))` but more efficiently
+// implemented as a 'check only' for ArenaAlignDefault.
+//
+// These classes allow for generic arena logic using 'alignment policies'.
+//
+// For example:
+//
+// template <Align>
+// void* NaiveAlloc(size_t n, Align align) {
+// Y_ABSL_ASSERT(align.IsAligned(n));
+// const size_t required = align.Padded(n);
+// if (required <= static_cast<size_t>(ptr_ - limit_)) {
+// uint8_t* ptr = align.CeilDefaultAligned(ptr_);
+// ptr_ = ptr + n;
+// return ptr;
+// }
+// return nullptr;
+// }
+//
+// void CallSites() {
+// void *p1 = NaiveAlloc(n, ArenaAlignDefault());
+// void *p2 = NaiveAlloc(n, ArenaAlignAs(32));
+// }
+//
+#ifndef GOOGLE_PROTOBUF_ARENA_ALIGN_H__
+#define GOOGLE_PROTOBUF_ARENA_ALIGN_H__
+
+#include <cstddef>
+#include <cstdint>
+
+#include "y_absl/log/absl_check.h"
+#include "y_absl/numeric/bits.h"
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace internal {
+
+struct ArenaAlignDefault {
+ PROTOBUF_EXPORT static constexpr size_t align = 8; // NOLINT
+
+ static constexpr bool IsAligned(size_t n) { return (n & (align - 1)) == 0U; }
+
+ template <typename T>
+ static inline PROTOBUF_ALWAYS_INLINE bool IsAligned(T* ptr) {
+ return (reinterpret_cast<uintptr_t>(ptr) & (align - 1)) == 0U;
+ }
+
+ static inline PROTOBUF_ALWAYS_INLINE constexpr size_t Ceil(size_t n) {
+ return (n + align - 1) & ~(align - 1);
+ }
+ static inline PROTOBUF_ALWAYS_INLINE constexpr size_t Floor(size_t n) {
+ return (n & ~(align - 1));
+ }
+
+ static inline PROTOBUF_ALWAYS_INLINE size_t Padded(size_t n) {
+ Y_ABSL_ASSERT(IsAligned(n));
+ return n;
+ }
+
+ template <typename T>
+ static inline PROTOBUF_ALWAYS_INLINE T* Ceil(T* ptr) {
+ uintptr_t intptr = reinterpret_cast<uintptr_t>(ptr);
+ return reinterpret_cast<T*>((intptr + align - 1) & ~(align - 1));
+ }
+
+ template <typename T>
+ static inline PROTOBUF_ALWAYS_INLINE T* CeilDefaultAligned(T* ptr) {
+ Y_ABSL_ASSERT(IsAligned(ptr));
+ return ptr;
+ }
+
+ // Address sanitizer enabled alignment check
+ template <typename T>
+ static inline PROTOBUF_ALWAYS_INLINE T* CheckAligned(T* ptr) {
+ Y_ABSL_ASSERT(IsAligned(ptr));
+ return ptr;
+ }
+};
+
+struct ArenaAlign {
+ static constexpr bool IsDefault() { return false; };
+
+ size_t align;
+
+ constexpr bool IsAligned(size_t n) const { return (n & (align - 1)) == 0U; }
+
+ template <typename T>
+ bool IsAligned(T* ptr) const {
+ return (reinterpret_cast<uintptr_t>(ptr) & (align - 1)) == 0U;
+ }
+
+ constexpr size_t Ceil(size_t n) const {
+ return (n + align - 1) & ~(align - 1);
+ }
+ constexpr size_t Floor(size_t n) const { return (n & ~(align - 1)); }
+
+ constexpr size_t Padded(size_t n) const {
+ // TODO(mvels): there are direct callers of AllocateAligned() that violate
+ // `size` being a multiple of `align`: that should be an error / assert.
+ // Y_ABSL_ASSERT(IsAligned(n));
+ Y_ABSL_ASSERT(ArenaAlignDefault::IsAligned(align));
+ return n + align - ArenaAlignDefault::align;
+ }
+
+ template <typename T>
+ T* Ceil(T* ptr) const {
+ uintptr_t intptr = reinterpret_cast<uintptr_t>(ptr);
+ return reinterpret_cast<T*>((intptr + align - 1) & ~(align - 1));
+ }
+
+ template <typename T>
+ T* CeilDefaultAligned(T* ptr) const {
+ Y_ABSL_ASSERT(ArenaAlignDefault::IsAligned(ptr));
+ return Ceil(ptr);
+ }
+
+ // Address sanitizer enabled alignment check
+ template <typename T>
+ T* CheckAligned(T* ptr) const {
+ Y_ABSL_ASSERT(IsAligned(ptr));
+ return ptr;
+ }
+};
+
+inline ArenaAlign ArenaAlignAs(size_t align) {
+ // align must be a non zero power of 2 >= 8
+ Y_ABSL_DCHECK_NE(align, 0U);
+ Y_ABSL_DCHECK(y_absl::has_single_bit(align)) << "Invalid alignment " << align;
+ return ArenaAlign{align};
+}
+
+template <bool, size_t align>
+struct AlignFactory {
+ static_assert(align > ArenaAlignDefault::align, "Not over-aligned");
+ static_assert((align & (align - 1)) == 0U, "Not power of 2");
+ static constexpr ArenaAlign Create() { return ArenaAlign{align}; }
+};
+
+template <size_t align>
+struct AlignFactory<true, align> {
+ static_assert(align <= ArenaAlignDefault::align, "Over-aligned");
+ static_assert((align & (align - 1)) == 0U, "Not power of 2");
+ static constexpr ArenaAlignDefault Create() { return ArenaAlignDefault{}; }
+};
+
+// Returns an `ArenaAlignDefault` instance for `align` less than or equal to the
+// default alignment, and `AlignAs(align)` for over-aligned values of `align`.
+// The purpose is to take advantage of invoking functions accepting a template
+// overloaded 'Align align` argument reducing the alignment operations on
+// `ArenaAlignDefault` implementations to no-ops.
+template <size_t align>
+inline constexpr auto ArenaAlignAs() {
+ return AlignFactory<align <= ArenaAlignDefault::align, align>::Create();
+}
+
+// Returns ArenaAlignAs<alignof(T)>
+template <typename T>
+inline constexpr auto ArenaAlignOf() {
+ return ArenaAlignAs<alignof(T)>();
+}
+
+} // namespace internal
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_ARENA_ALIGN_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/arena_allocation_policy.h b/contrib/libs/protobuf/src/google/protobuf/arena_allocation_policy.h
new file mode 100644
index 00000000000..2427cf4c7d7
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/arena_allocation_policy.h
@@ -0,0 +1,126 @@
+// 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_ARENA_ALLOCATION_POLICY_H__
+#define GOOGLE_PROTOBUF_ARENA_ALLOCATION_POLICY_H__
+
+#include <cstddef>
+#include <cstdint>
+
+#include "google/protobuf/arena_config.h"
+
+namespace google {
+namespace protobuf {
+namespace internal {
+
+// `AllocationPolicy` defines `Arena` allocation policies. Applications can
+// customize the initial and maximum sizes for arena allocation, as well as set
+// custom allocation and deallocation functions. `AllocationPolicy` is for
+// protocol buffer internal use only, and typically created from a user facing
+// public configuration class such as `ArenaOptions`.
+struct AllocationPolicy {
+ static constexpr size_t kDefaultStartBlockSize = 256;
+
+ size_t start_block_size = kDefaultStartBlockSize;
+ size_t max_block_size = GetDefaultArenaMaxBlockSize();
+
+ void* (*block_alloc)(size_t) = nullptr;
+ void (*block_dealloc)(void*, size_t) = nullptr;
+
+ bool IsDefault() const {
+ return start_block_size == kDefaultStartBlockSize &&
+ max_block_size == GetDefaultArenaMaxBlockSize() &&
+ block_alloc == nullptr && block_dealloc == nullptr;
+ }
+};
+
+// Tagged pointer to an AllocationPolicy.
+class TaggedAllocationPolicyPtr {
+ public:
+ constexpr TaggedAllocationPolicyPtr() : policy_(0) {}
+
+ explicit TaggedAllocationPolicyPtr(AllocationPolicy* policy)
+ : policy_(reinterpret_cast<uintptr_t>(policy)) {}
+
+ void set_policy(AllocationPolicy* policy) {
+ auto bits = policy_ & kTagsMask;
+ policy_ = reinterpret_cast<uintptr_t>(policy) | bits;
+ }
+
+ AllocationPolicy* get() {
+ return reinterpret_cast<AllocationPolicy*>(policy_ & kPtrMask);
+ }
+ const AllocationPolicy* get() const {
+ return reinterpret_cast<const AllocationPolicy*>(policy_ & kPtrMask);
+ }
+
+ AllocationPolicy& operator*() { return *get(); }
+ const AllocationPolicy& operator*() const { return *get(); }
+
+ AllocationPolicy* operator->() { return get(); }
+ const AllocationPolicy* operator->() const { return get(); }
+
+ bool is_user_owned_initial_block() const {
+ return static_cast<bool>(get_mask<kUserOwnedInitialBlock>());
+ }
+ void set_is_user_owned_initial_block(bool v) {
+ set_mask<kUserOwnedInitialBlock>(v);
+ }
+
+ uintptr_t get_raw() const { return policy_; }
+
+ private:
+ enum : uintptr_t {
+ kUserOwnedInitialBlock = 1,
+ };
+
+ static constexpr uintptr_t kTagsMask = 7;
+ static constexpr uintptr_t kPtrMask = ~kTagsMask;
+
+ template <uintptr_t kMask>
+ uintptr_t get_mask() const {
+ return policy_ & kMask;
+ }
+ template <uintptr_t kMask>
+ void set_mask(bool v) {
+ if (v) {
+ policy_ |= kMask;
+ } else {
+ policy_ &= ~kMask;
+ }
+ }
+ uintptr_t policy_;
+};
+
+} // namespace internal
+} // namespace protobuf
+} // namespace google
+
+#endif // GOOGLE_PROTOBUF_ARENA_ALLOCATION_POLICY_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/arena_cleanup.h b/contrib/libs/protobuf/src/google/protobuf/arena_cleanup.h
new file mode 100644
index 00000000000..6e624ee44d1
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/arena_cleanup.h
@@ -0,0 +1,224 @@
+// 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_ARENA_CLEANUP_H__
+#define GOOGLE_PROTOBUF_ARENA_CLEANUP_H__
+
+#include <cstddef>
+#include <cstdint>
+#include <string>
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/cord.h"
+
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace internal {
+namespace cleanup {
+
+// Helper function invoking the destructor of `object`
+template <typename T>
+void arena_destruct_object(void* object) {
+ reinterpret_cast<T*>(object)->~T();
+}
+
+// Tag defines the type of cleanup / cleanup object. This tag is stored in the
+// lowest 2 bits of the `elem` value identifying the type of node. All node
+// types must start with a `uintptr_t` that stores `Tag` in its low two bits.
+enum class Tag : uintptr_t {
+ kDynamic = 0, // DynamicNode
+ kString = 1, // TaggedNode (TProtoStringType)
+ kCord = 2, // TaggedNode (y_absl::Cord)
+};
+
+// DynamicNode contains the object (`elem`) that needs to be
+// destroyed, and the function to destroy it (`destructor`)
+// elem must be aligned at minimum on a 4 byte boundary.
+struct DynamicNode {
+ uintptr_t elem;
+ void (*destructor)(void*);
+};
+
+// TaggedNode contains a `TProtoStringType` or `y_absl::Cord` object (`elem`) that
+// needs to be destroyed. The lowest 2 bits of `elem` contain the non-zero
+// `kString` or `kCord` tag.
+struct TaggedNode {
+ uintptr_t elem;
+};
+
+// EnableSpecializedTags() return true if the alignment of tagged objects
+// such as TProtoStringType allow us to poke tags in the 2 LSB bits.
+inline constexpr bool EnableSpecializedTags() {
+ // For now we require 2 bits
+ return alignof(TProtoStringType) >= 8 && alignof(y_absl::Cord) >= 8;
+}
+
+// Adds a cleanup entry identified by `tag` at memory location `pos`.
+inline Y_ABSL_ATTRIBUTE_ALWAYS_INLINE void CreateNode(Tag tag, void* pos,
+ const void* elem_raw,
+ void (*destructor)(void*)) {
+ auto elem = reinterpret_cast<uintptr_t>(elem_raw);
+ if (EnableSpecializedTags()) {
+ Y_ABSL_DCHECK_EQ(elem & 3, 0ULL); // Must be aligned
+ switch (tag) {
+ case Tag::kString: {
+ TaggedNode n = {elem | static_cast<uintptr_t>(Tag::kString)};
+ memcpy(pos, &n, sizeof(n));
+ return;
+ }
+ case Tag::kCord: {
+ TaggedNode n = {elem | static_cast<uintptr_t>(Tag::kCord)};
+ memcpy(pos, &n, sizeof(n));
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ DynamicNode n = {elem, destructor};
+ memcpy(pos, &n, sizeof(n));
+}
+
+// Optimization: performs a prefetch on `elem_address`.
+// Returns the size of the cleanup (meta) data at this address, allowing the
+// caller to advance cleanup iterators without needing to examine or know
+// anything about the underlying cleanup node or cleanup meta data / tags.
+inline Y_ABSL_ATTRIBUTE_ALWAYS_INLINE size_t
+PrefetchNode(const void* elem_address) {
+ if (EnableSpecializedTags()) {
+ uintptr_t elem;
+ memcpy(&elem, elem_address, sizeof(elem));
+ if (static_cast<Tag>(elem & 3) != Tag::kDynamic) {
+ return sizeof(TaggedNode);
+ }
+ }
+ return sizeof(DynamicNode);
+}
+
+// Destroys the object referenced by the cleanup node at memory location `pos`.
+// Returns the size of the cleanup (meta) data at this address, allowing the
+// caller to advance cleanup iterators without needing to examine or know
+// anything about the underlying cleanup node or cleanup meta data / tags.
+inline Y_ABSL_ATTRIBUTE_ALWAYS_INLINE size_t DestroyNode(const void* pos) {
+ uintptr_t elem;
+ memcpy(&elem, pos, sizeof(elem));
+ if (EnableSpecializedTags()) {
+ switch (static_cast<Tag>(elem & 3)) {
+ case Tag::kString: {
+ // Some compilers don't like fully qualified explicit dtor calls,
+ // so use an alias to avoid having to type `::`.
+ using T = TProtoStringType;
+ reinterpret_cast<T*>(elem - static_cast<uintptr_t>(Tag::kString))->~T();
+ return sizeof(TaggedNode);
+ }
+ case Tag::kCord: {
+ using T = y_absl::Cord;
+ reinterpret_cast<T*>(elem - static_cast<uintptr_t>(Tag::kCord))->~T();
+ return sizeof(TaggedNode);
+ }
+ default:
+ break;
+ }
+ }
+ static_cast<const DynamicNode*>(pos)->destructor(
+ reinterpret_cast<void*>(elem - static_cast<uintptr_t>(Tag::kDynamic)));
+ return sizeof(DynamicNode);
+}
+
+// Returns the `tag` identifying the type of object for `destructor` or
+// kDynamic if `destructor` does not identify a well know object type.
+inline Y_ABSL_ATTRIBUTE_ALWAYS_INLINE Tag Type(void (*destructor)(void*)) {
+ if (EnableSpecializedTags()) {
+ if (destructor == &arena_destruct_object<TProtoStringType>) {
+ return Tag::kString;
+ }
+ if (destructor == &arena_destruct_object<y_absl::Cord>) {
+ return Tag::kCord;
+ }
+ }
+ return Tag::kDynamic;
+}
+
+// Returns the `tag` identifying the type of object stored at memory location
+// `elem`, which represents the first uintptr_t value in the node.
+inline Y_ABSL_ATTRIBUTE_ALWAYS_INLINE Tag Type(void* raw) {
+ if (!EnableSpecializedTags()) return Tag::kDynamic;
+
+ uintptr_t elem;
+ memcpy(&elem, raw, sizeof(elem));
+ switch (static_cast<Tag>(elem & 0x7ULL)) {
+ case Tag::kDynamic:
+ return Tag::kDynamic;
+ case Tag::kString:
+ return Tag::kString;
+ case Tag::kCord:
+ return Tag::kCord;
+ default:
+ Y_ABSL_LOG(FATAL) << "Corrupted cleanup tag: " << (elem & 0x7ULL);
+ return Tag::kDynamic;
+ }
+}
+
+// Returns the required size in bytes off the node type identified by `tag`.
+inline Y_ABSL_ATTRIBUTE_ALWAYS_INLINE size_t Size(Tag tag) {
+ if (!EnableSpecializedTags()) return sizeof(DynamicNode);
+
+ switch (tag) {
+ case Tag::kDynamic:
+ return sizeof(DynamicNode);
+ case Tag::kString:
+ return sizeof(TaggedNode);
+ case Tag::kCord:
+ return sizeof(TaggedNode);
+ default:
+ Y_ABSL_LOG(FATAL) << "Corrupted cleanup tag: " << static_cast<int>(tag);
+ return sizeof(DynamicNode);
+ }
+}
+
+// Returns the required size in bytes off the node type for `destructor`.
+inline Y_ABSL_ATTRIBUTE_ALWAYS_INLINE size_t Size(void (*destructor)(void*)) {
+ return destructor == nullptr ? 0 : Size(Type(destructor));
+}
+
+} // namespace cleanup
+} // namespace internal
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_ARENA_CLEANUP_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/once.h b/contrib/libs/protobuf/src/google/protobuf/arena_config.cc
index 070d36d1930..1fe7d05d06f 100644
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/once.h
+++ b/contrib/libs/protobuf/src/google/protobuf/arena_config.cc
@@ -28,28 +28,26 @@
// (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_STUBS_ONCE_H__
-#define GOOGLE_PROTOBUF_STUBS_ONCE_H__
+#include "google/protobuf/arena_config.h"
-#include <mutex>
-#include <utility>
+#include <atomic>
+#include <cstddef>
-#include <google/protobuf/port_def.inc>
+// Must be included last.
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
namespace internal {
-using once_flag = std::once_flag;
-template <typename... Args>
-void call_once(Args&&... args ) {
- std::call_once(std::forward<Args>(args)...);
-}
+PROTOBUF_CONSTINIT const size_t kDefaultDefaultArenaMaxBlockSize = 32 << 10;
+namespace arena_config_internal {
+
+std::atomic<size_t> default_arena_max_block_size{
+ kDefaultDefaultArenaMaxBlockSize};
+
+} // namespace arena_config_internal
} // namespace internal
} // namespace protobuf
} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#endif // GOOGLE_PROTOBUF_STUBS_ONCE_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/arena_config.h b/contrib/libs/protobuf/src/google/protobuf/arena_config.h
new file mode 100644
index 00000000000..f16d86a5ec6
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/arena_config.h
@@ -0,0 +1,73 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef GOOGLE_PROTOBUF_ARENA_CONFIG_H__
+#define GOOGLE_PROTOBUF_ARENA_CONFIG_H__
+
+#include <atomic>
+#include <cstddef>
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace internal {
+namespace arena_config_internal {
+
+// We use an atomic here only for correctness so that we can read/write
+// concurrently. We don't have memory order requirements so we use relaxed
+// memory ordering.
+PROTOBUF_EXPORT extern std::atomic<size_t> default_arena_max_block_size;
+
+} // namespace arena_config_internal
+
+// The default value to use for DefaultArenaMaxBlockSize when
+// SetDefaultArenaMaxBlockSize hasn't been called.
+PROTOBUF_EXPORT extern const size_t kDefaultDefaultArenaMaxBlockSize;
+
+// The default value to use for arena max block size when no value is provided
+// in ArenaOptions.
+inline size_t GetDefaultArenaMaxBlockSize() {
+ return arena_config_internal::default_arena_max_block_size.load(
+ std::memory_order_relaxed);
+}
+inline void SetDefaultArenaMaxBlockSize(size_t default_arena_max_block_size) {
+ return arena_config_internal::default_arena_max_block_size.store(
+ default_arena_max_block_size, std::memory_order_relaxed);
+}
+
+} // namespace internal
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_ARENA_CONFIG_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/arena_impl.h b/contrib/libs/protobuf/src/google/protobuf/arena_impl.h
deleted file mode 100644
index e8ab03ef801..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/arena_impl.h
+++ /dev/null
@@ -1,686 +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.
-
-// This file defines an Arena allocator for better allocation performance.
-
-#ifndef GOOGLE_PROTOBUF_ARENA_IMPL_H__
-#define GOOGLE_PROTOBUF_ARENA_IMPL_H__
-
-#include <atomic>
-#include <limits>
-#include <typeinfo>
-
-#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>
-
-
-namespace google {
-namespace protobuf {
-namespace internal {
-
-// To prevent sharing cache lines between threads
-#ifdef __cpp_aligned_new
-enum { kCacheAlignment = 64 };
-#else
-enum { kCacheAlignment = alignof(max_align_t) }; // do the best we can
-#endif
-
-inline constexpr size_t AlignUpTo8(size_t n) {
- // Align n to next multiple of 8 (from Hacker's Delight, Chapter 3.)
- return (n + 7) & static_cast<size_t>(-8);
-}
-
-using LifecycleIdAtomic = arc_ui64;
-
-// MetricsCollector collects stats for a particular arena.
-class PROTOBUF_EXPORT ArenaMetricsCollector {
- public:
- ArenaMetricsCollector(bool record_allocs) : record_allocs_(record_allocs) {}
-
- // Invoked when the arena is about to be destroyed. This method will
- // typically finalize any metric collection and delete the collector.
- // space_allocated is the space used by the arena.
- virtual void OnDestroy(arc_ui64 space_allocated) = 0;
-
- // OnReset() is called when the associated arena is reset.
- // space_allocated is the space used by the arena just before the reset.
- virtual void OnReset(arc_ui64 space_allocated) = 0;
-
- // OnAlloc is called when an allocation happens.
- // type_info is promised to be static - its lifetime extends to
- // match program's lifetime (It is given by typeid operator).
- // Note: typeid(void) will be passed as allocated_type every time we
- // intentionally want to avoid monitoring an allocation. (i.e. internal
- // allocations for managing the arena)
- virtual void OnAlloc(const std::type_info* allocated_type,
- arc_ui64 alloc_size) = 0;
-
- // Does OnAlloc() need to be called? If false, metric collection overhead
- // will be reduced since we will not do extra work per allocation.
- bool RecordAllocs() { return record_allocs_; }
-
- protected:
- // This class is destructed by the call to OnDestroy().
- ~ArenaMetricsCollector() = default;
- const bool record_allocs_;
-};
-
-struct AllocationPolicy {
- static constexpr size_t kDefaultStartBlockSize = 256;
- static constexpr size_t kDefaultMaxBlockSize = 8192;
-
- size_t start_block_size = kDefaultStartBlockSize;
- size_t max_block_size = kDefaultMaxBlockSize;
- void* (*block_alloc)(size_t) = nullptr;
- void (*block_dealloc)(void*, size_t) = nullptr;
- ArenaMetricsCollector* metrics_collector = nullptr;
-
- bool IsDefault() const {
- return start_block_size == kDefaultMaxBlockSize &&
- max_block_size == kDefaultMaxBlockSize && block_alloc == nullptr &&
- block_dealloc == nullptr && metrics_collector == nullptr;
- }
-};
-
-// Tagged pointer to an AllocationPolicy.
-class TaggedAllocationPolicyPtr {
- public:
- constexpr TaggedAllocationPolicyPtr() : policy_(0) {}
-
- explicit TaggedAllocationPolicyPtr(AllocationPolicy* policy)
- : policy_(reinterpret_cast<uintptr_t>(policy)) {}
-
- void set_policy(AllocationPolicy* policy) {
- auto bits = policy_ & kTagsMask;
- policy_ = reinterpret_cast<uintptr_t>(policy) | bits;
- }
-
- AllocationPolicy* get() {
- return reinterpret_cast<AllocationPolicy*>(policy_ & kPtrMask);
- }
- const AllocationPolicy* get() const {
- return reinterpret_cast<const AllocationPolicy*>(policy_ & kPtrMask);
- }
-
- AllocationPolicy& operator*() { return *get(); }
- const AllocationPolicy& operator*() const { return *get(); }
-
- AllocationPolicy* operator->() { return get(); }
- const AllocationPolicy* operator->() const { return get(); }
-
- bool is_user_owned_initial_block() const {
- return static_cast<bool>(get_mask<kUserOwnedInitialBlock>());
- }
- void set_is_user_owned_initial_block(bool v) {
- set_mask<kUserOwnedInitialBlock>(v);
- }
-
- bool should_record_allocs() const {
- return static_cast<bool>(get_mask<kRecordAllocs>());
- }
- void set_should_record_allocs(bool v) { set_mask<kRecordAllocs>(v); }
-
- uintptr_t get_raw() const { return policy_; }
-
- inline void RecordAlloc(const std::type_info* allocated_type,
- size_t n) const {
- get()->metrics_collector->OnAlloc(allocated_type, n);
- }
-
- private:
- enum : uintptr_t {
- kUserOwnedInitialBlock = 1,
- kRecordAllocs = 2,
- };
-
- static constexpr uintptr_t kTagsMask = 7;
- static constexpr uintptr_t kPtrMask = ~kTagsMask;
-
- template <uintptr_t kMask>
- uintptr_t get_mask() const {
- return policy_ & kMask;
- }
- template <uintptr_t kMask>
- void set_mask(bool v) {
- if (v) {
- policy_ |= kMask;
- } else {
- policy_ &= ~kMask;
- }
- }
- 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
-// for ThreadSafeArena, which provides a thread-safe arena allocator.
-//
-// This class manages
-// 1) Arena bump allocation + owning memory blocks.
-// 2) Maintaining a cleanup list.
-// It delagetes the actual memory allocation back to ThreadSafeArena, which
-// contains the information on block growth policy and backing memory allocation
-// used.
-class PROTOBUF_EXPORT SerialArena {
- public:
- struct Memory {
- void* ptr;
- size_t size;
- };
-
- // Node contains the ptr of the object to be cleaned up and the associated
- // cleanup function ptr.
- struct CleanupNode {
- void* elem; // Pointer to the object to be cleaned up.
- void (*cleanup)(void*); // Function pointer to the destructor or deleter.
- };
-
- void CleanupList();
- arc_ui64 SpaceAllocated() const {
- return space_allocated_.load(std::memory_order_relaxed);
- }
- arc_ui64 SpaceUsed() const;
-
- 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);
- }
- return AllocateFromExisting(n);
- }
-
- private:
- void* AllocateFromExisting(size_t n) {
- void* ret = ptr_;
- ptr_ += n;
-#ifdef ADDRESS_SANITIZER
- ASAN_UNPOISON_MEMORY_REGION(ret, n);
-#endif // ADDRESS_SANITIZER
- 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) {
- GOOGLE_DCHECK_EQ(internal::AlignUpTo8(n), n); // Must be already aligned.
- GOOGLE_DCHECK_GE(limit_, ptr_);
- if (PROTOBUF_PREDICT_FALSE(!HasSpace(n))) return false;
- *out = AllocateFromExisting(n);
- return true;
- }
-
- std::pair<void*, CleanupNode*> AllocateAlignedWithCleanup(
- size_t n, const AllocationPolicy* policy) {
- GOOGLE_DCHECK_EQ(internal::AlignUpTo8(n), n); // Must be already aligned.
- if (PROTOBUF_PREDICT_FALSE(!HasSpace(n + kCleanupSize))) {
- return AllocateAlignedWithCleanupFallback(n, policy);
- }
- return AllocateFromExistingWithCleanupFallback(n);
- }
-
- private:
- std::pair<void*, CleanupNode*> AllocateFromExistingWithCleanupFallback(
- size_t n) {
- void* ret = ptr_;
- ptr_ += n;
- limit_ -= kCleanupSize;
-#ifdef ADDRESS_SANITIZER
- ASAN_UNPOISON_MEMORY_REGION(ret, n);
- ASAN_UNPOISON_MEMORY_REGION(limit_, kCleanupSize);
-#endif // ADDRESS_SANITIZER
- return CreatePair(ret, reinterpret_cast<CleanupNode*>(limit_));
- }
-
- public:
- void AddCleanup(void* elem, void (*cleanup)(void*),
- const AllocationPolicy* policy) {
- auto res = AllocateAlignedWithCleanup(0, policy);
- res.second->elem = elem;
- res.second->cleanup = cleanup;
- }
-
- void* owner() const { return owner_; }
- SerialArena* next() const { return next_; }
- void set_next(SerialArena* next) { next_ = next; }
-
- private:
- friend class ThreadSafeArena;
- friend class ArenaBenchmark;
-
- // Creates a new SerialArena inside mem using the remaining memory as for
- // future allocations.
- 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);
-
- // Blocks are variable length malloc-ed objects. The following structure
- // describes the common header for all blocks.
- struct Block {
- Block(Block* next, size_t size) : next(next), size(size), start(nullptr) {}
-
- char* Pointer(size_t n) {
- GOOGLE_DCHECK(n <= size);
- return reinterpret_cast<char*>(this) + n;
- }
-
- Block* const next;
- const size_t size;
- CleanupNode* start;
- // data follows
- };
-
- void* owner_; // &ThreadCache of this thread;
- Block* head_; // Head of linked list of blocks.
- SerialArena* next_; // Next SerialArena in this linked list.
- size_t space_used_ = 0; // Necessary for metrics.
- std::atomic<size_t> space_allocated_;
-
- // Next pointer to allocate from. Always 8-byte aligned. Points inside
- // 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, ThreadSafeArenaStats* stats);
- void* AllocateAlignedFallback(size_t n, const AllocationPolicy* policy);
- std::pair<void*, CleanupNode*> AllocateAlignedWithCleanupFallback(
- size_t n, const AllocationPolicy* policy);
- void AllocateNewBlock(size_t n, const AllocationPolicy* policy);
-
- std::pair<void*, CleanupNode*> CreatePair(void* ptr, CleanupNode* node) {
- return {ptr, node};
- }
-
- public:
- static constexpr size_t kBlockHeaderSize = AlignUpTo8(sizeof(Block));
- static constexpr size_t kCleanupSize = AlignUpTo8(sizeof(CleanupNode));
-};
-
-// Tag type used to invoke the constructor of message-owned arena.
-// Only message-owned arenas use this constructor for creation.
-// Such constructors are internal implementation details of the library.
-struct MessageOwned {
- explicit MessageOwned() = default;
-};
-
-// This class provides the core Arena memory allocation library. Different
-// implementations only need to implement the public interface below.
-// Arena is not a template type as that would only be useful if all protos
-// in turn would be templates, which will/cannot happen. However separating
-// the memory allocation part from the cruft of the API users expect we can
-// use #ifdef the select the best implementation based on hardware / OS.
-class PROTOBUF_EXPORT ThreadSafeArena {
- public:
- ThreadSafeArena() { Init(); }
-
- // Constructor solely used by message-owned arena.
- ThreadSafeArena(internal::MessageOwned) : tag_and_id_(kMessageOwnedArena) {
- Init();
- }
-
- ThreadSafeArena(char* mem, size_t size) { InitializeFrom(mem, size); }
-
- explicit ThreadSafeArena(void* mem, size_t size,
- const AllocationPolicy& policy) {
- InitializeWithPolicy(mem, size, policy);
- }
-
- // Destructor deletes all owned heap allocated objects, and destructs objects
- // that have non-trivial destructors, except for proto2 message objects whose
- // destructors can be skipped. Also, frees all blocks except the initial block
- // if it was passed in.
- ~ThreadSafeArena();
-
- arc_ui64 Reset();
-
- 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<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
- // have fallback function calls in tail position. This substantially improves
- // code for the happy path.
- PROTOBUF_NDEBUG_INLINE bool MaybeAllocateAligned(size_t n, void** out) {
- SerialArena* arena;
- if (PROTOBUF_PREDICT_TRUE(!alloc_policy_.should_record_allocs() &&
- GetSerialArenaFromThreadCache(&arena))) {
- return arena->MaybeAllocateAligned(n, out);
- }
- return false;
- }
-
- std::pair<void*, SerialArena::CleanupNode*> AllocateAlignedWithCleanup(
- size_t n, const std::type_info* type);
-
- // Add object pointer and cleanup function pointer to the list.
- void AddCleanup(void* elem, void (*cleanup)(void*));
-
- // Checks whether this arena is message-owned.
- PROTOBUF_ALWAYS_INLINE bool IsMessageOwned() const {
- return tag_and_id_ & kMessageOwnedArena;
- }
-
- private:
- // Unique for each arena. Changes on Reset().
- arc_ui64 tag_and_id_ = 0;
- // The LSB of tag_and_id_ indicates if the arena is message-owned.
- enum : arc_ui64 { kMessageOwnedArena = 1 };
-
- 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
-
- const AllocationPolicy* AllocPolicy() const { return alloc_policy_.get(); }
- void InitializeFrom(void* mem, size_t size);
- void InitializeWithPolicy(void* mem, size_t size, AllocationPolicy policy);
- void* AllocateAlignedFallback(size_t n, const std::type_info* type);
- std::pair<void*, SerialArena::CleanupNode*>
- AllocateAlignedWithCleanupFallback(size_t n, const std::type_info* type);
-
- void Init();
- void SetInitialBlock(void* mem, size_t size);
-
- // Delete or Destruct all objects owned by the arena.
- void CleanupList();
-
- inline arc_ui64 LifeCycleId() const {
- return tag_and_id_ & ~kMessageOwnedArena;
- }
-
- inline void CacheSerialArena(SerialArena* serial) {
- thread_cache().last_serial_arena = serial;
- thread_cache().last_lifecycle_id_seen = tag_and_id_;
- // TODO(haberman): evaluate whether we would gain efficiency by getting rid
- // of hint_. It's the only write we do to ThreadSafeArena in the allocation
- // path, which will dirty the cache line.
-
- hint_.store(serial, std::memory_order_release);
- }
-
- PROTOBUF_NDEBUG_INLINE bool GetSerialArenaFast(SerialArena** arena) {
- if (GetSerialArenaFromThreadCache(arena)) return true;
-
- // Check whether we own the last accessed SerialArena on this arena. This
- // fast path optimizes the case where a single thread uses multiple arenas.
- ThreadCache* tc = &thread_cache();
- SerialArena* serial = hint_.load(std::memory_order_acquire);
- if (PROTOBUF_PREDICT_TRUE(serial != nullptr && serial->owner() == tc)) {
- *arena = serial;
- return true;
- }
- return false;
- }
-
- PROTOBUF_NDEBUG_INLINE bool GetSerialArenaFromThreadCache(
- SerialArena** arena) {
- // If this thread already owns a block in this arena then try to use that.
- // This fast path optimizes the case where multiple threads allocate from
- // the same arena.
- ThreadCache* tc = &thread_cache();
- if (PROTOBUF_PREDICT_TRUE(tc->last_lifecycle_id_seen == tag_and_id_)) {
- *arena = tc->last_serial_arena;
- return true;
- }
- return false;
- }
- SerialArena* GetSerialArenaFallback(void* me);
-
- template <typename Functor>
- void PerSerialArena(Functor fn) {
- // By omitting an Acquire barrier we ensure that any user code that doesn't
- // properly synchronize Reset() or the destructor will throw a TSAN warning.
- SerialArena* serial = threads_.load(std::memory_order_relaxed);
-
- for (; serial; serial = serial->next()) fn(serial);
- }
-
- // Releases all memory except the first block which it returns. The first
- // block might be owned by the user and thus need some extra checks before
- // deleting.
- SerialArena::Memory Free(size_t* space_allocated);
-
-#ifdef _MSC_VER
-#pragma warning(disable : 4324)
-#endif
- struct alignas(kCacheAlignment) ThreadCache {
-#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)
- // If we are using the ThreadLocalStorage class to store the ThreadCache,
- // then the ThreadCache's default constructor has to be responsible for
- // initializing it.
- ThreadCache()
- : next_lifecycle_id(0),
- last_lifecycle_id_seen(-1),
- last_serial_arena(nullptr) {}
-#endif
-
- // Number of per-thread lifecycle IDs to reserve. Must be power of two.
- // To reduce contention on a global atomic, each thread reserves a batch of
- // IDs. The following number is calculated based on a stress test with
- // ~6500 threads all frequently allocating a new arena.
- static constexpr size_t kPerThreadIds = 256;
- // Next lifecycle ID available to this thread. We need to reserve a new
- // batch, if `next_lifecycle_id & (kPerThreadIds - 1) == 0`.
- arc_ui64 next_lifecycle_id;
- // The ThreadCache is considered valid as long as this matches the
- // lifecycle_id of the arena being used.
- arc_ui64 last_lifecycle_id_seen;
- SerialArena* last_serial_arena;
- };
-
- // Lifecycle_id can be highly contended variable in a situation of lots of
- // arena creation. Make sure that other global variables are not sharing the
- // cacheline.
-#ifdef _MSC_VER
-#pragma warning(disable : 4324)
-#endif
- struct alignas(kCacheAlignment) CacheAlignedLifecycleIdGenerator {
- std::atomic<LifecycleIdAtomic> id;
- };
- static CacheAlignedLifecycleIdGenerator lifecycle_id_generator_;
-#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)
- // iOS does not support __thread keyword so we use a custom thread local
- // storage class we implemented.
- static ThreadCache& thread_cache();
-#elif defined(PROTOBUF_USE_DLLS)
- // Thread local variables cannot be exposed through DLL interface but we can
- // wrap them in static functions.
- static ThreadCache& thread_cache();
-#else
- static PROTOBUF_THREAD_LOCAL ThreadCache thread_cache_;
- 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.
- ThreadSafeArena(ThreadSafeArena&&) = delete;
- ThreadSafeArena& operator=(ThreadSafeArena&&) = delete;
-
- public:
- // kBlockHeaderSize is sizeof(Block), aligned up to the nearest multiple of 8
- // to protect the invariant that pos is always at a multiple of 8.
- static constexpr size_t kBlockHeaderSize = SerialArena::kBlockHeaderSize;
- static constexpr size_t kSerialArenaSize =
- (sizeof(SerialArena) + 7) & static_cast<size_t>(-8);
- static_assert(kBlockHeaderSize % 8 == 0,
- "kBlockHeaderSize must be a multiple of 8.");
- static_assert(kSerialArenaSize % 8 == 0,
- "kSerialArenaSize must be a multiple of 8.");
-};
-
-} // namespace internal
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#endif // GOOGLE_PROTOBUF_ARENA_IMPL_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/arenastring.cc b/contrib/libs/protobuf/src/google/protobuf/arenastring.cc
index a818c253d03..4c4eb75da1d 100644
--- a/contrib/libs/protobuf/src/google/protobuf/arenastring.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/arenastring.cc
@@ -28,20 +28,19 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <google/protobuf/arenastring.h>
+#include "google/protobuf/arenastring.h"
#include <cstddef>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/io/coded_stream.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>
+
+#include "y_absl/log/absl_check.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/synchronization/mutex.h"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/message_lite.h"
+#include "google/protobuf/parse_context.h"
// clang-format off
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
// clang-format on
namespace google {
@@ -50,7 +49,8 @@ namespace internal {
namespace {
-// Enforce that allocated data aligns to at least 8 bytes, and that
+// TaggedStringPtr::Flags uses the lower 2 bits as tags.
+// Enforce that allocated data aligns to at least 4 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
@@ -64,13 +64,13 @@ 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, "");
+static_assert((kStringAlign > kNewAlign ? kStringAlign : kNewAlign) >= 4, "");
+static_assert(alignof(ExplicitlyConstructedArenaString) >= 4, "");
} // namespace
const TProtoStringType& LazyString::Init() const {
- static WrappedMutex mu{GOOGLE_PROTOBUF_LINKER_INITIALIZED};
+ static y_absl::Mutex mu{y_absl::kConstInit};
mu.Lock();
const TProtoStringType* res = inited_.load(std::memory_order_acquire);
if (res == nullptr) {
@@ -86,7 +86,7 @@ const TProtoStringType& LazyString::Init() const {
namespace {
-#if defined(NDEBUG) || !GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL
+#if defined(NDEBUG) || !defined(GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL)
class ScopedCheckPtrInvariants {
public:
@@ -96,17 +96,16 @@ class ScopedCheckPtrInvariants {
#endif // NDEBUG || !GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL
// Creates a heap allocated TProtoStringType value.
-inline TaggedStringPtr CreateString(ConstStringParam value) {
+inline TaggedStringPtr CreateString(const TProtoStringType& value) {
TaggedStringPtr res;
- // better than TProtoStringType(value.data(), value.length())
res.SetAllocated(new TProtoStringType(value));
return res;
}
-#if !GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL
+#ifndef GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL
// Creates an arena allocated TProtoStringType value.
-TaggedStringPtr CreateArenaString(Arena& arena, ConstStringParam s) {
+TaggedStringPtr CreateArenaString(Arena& arena, y_absl::string_view s) {
TaggedStringPtr res;
res.SetMutableArena(Arena::Create<TProtoStringType>(&arena, s.data(), s.length()));
return res;
@@ -116,7 +115,7 @@ TaggedStringPtr CreateArenaString(Arena& arena, ConstStringParam s) {
} // namespace
-void ArenaStringPtr::Set(ConstStringParam value, Arena* arena) {
+void ArenaStringPtr::Set(const TProtoStringType& value, Arena* arena) {
ScopedCheckPtrInvariants check(&tagged_ptr_);
if (IsDefault()) {
// If we're not on an arena, skip straight to a true string to avoid
@@ -124,7 +123,44 @@ void ArenaStringPtr::Set(ConstStringParam value, Arena* arena) {
tagged_ptr_ = arena != nullptr ? CreateArenaString(*arena, value)
: CreateString(value);
} else {
+#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (arena == nullptr) {
+ auto* old = tagged_ptr_.GetIfAllocated();
+ tagged_ptr_ = CreateString(value);
+ delete old;
+ } else {
+ auto* old = UnsafeMutablePointer();
+ tagged_ptr_ = CreateArenaString(*arena, value);
+ old->assign("garbagedata");
+ }
+#else // PROTOBUF_FORCE_COPY_DEFAULT_STRING
UnsafeMutablePointer()->assign(value.data(), value.length());
+#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ }
+}
+
+template <>
+void ArenaStringPtr::Set(const TProtoStringType& 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 {
+#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (arena == nullptr) {
+ auto* old = tagged_ptr_.GetIfAllocated();
+ tagged_ptr_ = CreateString(value);
+ delete old;
+ } else {
+ auto* old = UnsafeMutablePointer();
+ tagged_ptr_ = CreateArenaString(*arena, value);
+ old->assign("garbagedata");
+ }
+#else // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ UnsafeMutablePointer()->assign(value);
+#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
}
@@ -166,7 +202,7 @@ TProtoStringType* ArenaStringPtr::MutableNoCopy(Arena* arena) {
if (tagged_ptr_.IsMutable()) {
return tagged_ptr_.Get();
} else {
- GOOGLE_DCHECK(IsDefault());
+ Y_ABSL_DCHECK(IsDefault());
// Allocate empty. The contents are not relevant.
return NewString(arena);
}
@@ -175,7 +211,7 @@ TProtoStringType* ArenaStringPtr::MutableNoCopy(Arena* arena) {
template <typename... Lazy>
TProtoStringType* ArenaStringPtr::MutableSlow(::google::protobuf::Arena* arena,
const Lazy&... lazy_default) {
- GOOGLE_DCHECK(IsDefault());
+ Y_ABSL_DCHECK(IsDefault());
// For empty defaults, this ends up calling the default constructor which is
// more efficient than a copy construction from
@@ -249,7 +285,7 @@ const char* EpsCopyInputStream::ReadArenaString(const char* ptr,
ArenaStringPtr* s,
Arena* arena) {
ScopedCheckPtrInvariants check(&s->tagged_ptr_);
- GOOGLE_DCHECK(arena != nullptr);
+ Y_ABSL_DCHECK(arena != nullptr);
int size = ReadSize(&ptr);
if (!ptr) return nullptr;
@@ -264,4 +300,4 @@ const char* EpsCopyInputStream::ReadArenaString(const char* ptr,
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protobuf/src/google/protobuf/arenastring.h b/contrib/libs/protobuf/src/google/protobuf/arenastring.h
index b897c1e5490..62a1ae3d4a8 100644
--- a/contrib/libs/protobuf/src/google/protobuf/arenastring.h
+++ b/contrib/libs/protobuf/src/google/protobuf/arenastring.h
@@ -36,14 +36,14 @@
#include <type_traits>
#include <utility>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/arena.h>
-#include <google/protobuf/port.h>
-#include <google/protobuf/explicitly_constructed.h>
+#include "y_absl/log/absl_check.h"
+#include "google/protobuf/arena.h"
+#include "google/protobuf/port.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/explicitly_constructed.h"
// must be last:
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
#ifdef SWIG
#error "You cannot SWIG proto headers"
@@ -99,9 +99,9 @@ class TaggedStringPtr {
// Bit flags qualifying string properties. We can use 2 bits as
// ptr_ is guaranteed and enforced to be aligned on 4 byte boundaries.
enum Flags {
- kArenaBit = 0x1, // ptr is arena allocated
- kMutableBit = 0x2, // ptr contents are fully mutable
- kMask = 0x3 // Bit mask
+ kArenaBit = 0x1, // ptr is arena allocated
+ kMutableBit = 0x2, // ptr contents are fully mutable
+ kMask = 0x3 // Bit mask
};
// Composed logical types
@@ -167,7 +167,7 @@ class TaggedStringPtr {
// If the current string is a heap-allocated mutable value, returns a pointer
// to it. Returns nullptr otherwise.
- inline TProtoStringType *GetIfAllocated() const {
+ inline TProtoStringType* GetIfAllocated() const {
auto allocated = as_int() ^ kAllocated;
if (allocated & kMask) return nullptr;
@@ -197,11 +197,11 @@ class TaggedStringPtr {
private:
static inline void assert_aligned(const void* p) {
- GOOGLE_DCHECK_EQ(reinterpret_cast<uintptr_t>(p) & kMask, 0UL);
+ Y_ABSL_DCHECK_EQ(reinterpret_cast<uintptr_t>(p) & kMask, 0UL);
}
inline TProtoStringType* TagAs(Type type, TProtoStringType* p) {
- GOOGLE_DCHECK(p != nullptr);
+ Y_ABSL_DCHECK(p != nullptr);
assert_aligned(p);
ptr_ = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(p) | type);
return p;
@@ -259,13 +259,16 @@ struct PROTOBUF_EXPORT ArenaStringPtr {
// instance known to not carry any heap allocated value.
inline void InitAllocated(TProtoStringType* str, Arena* arena);
- void Set(ConstStringParam value, Arena* arena);
+ void Set(const TProtoStringType& value, Arena* arena);
void Set(TProtoStringType&& value, Arena* arena);
+ template <typename... OverloadDisambiguator>
+ void Set(const 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);
+ template <typename... OverloadDisambiguator>
+ void SetBytes(const TProtoStringType& value, Arena* arena);
void SetBytes(const char* s, Arena* arena);
void SetBytes(const void* p, size_t n, Arena* arena);
@@ -406,14 +409,19 @@ inline void ArenaStringPtr::InitAllocated(TProtoStringType* str, Arena* arena) {
}
inline void ArenaStringPtr::Set(const char* s, Arena* arena) {
- Set(ConstStringParam{s}, arena);
+ Set(TProtoStringType{s}, arena);
}
inline void ArenaStringPtr::Set(const char* s, size_t n, Arena* arena) {
- Set(ConstStringParam{s, n}, arena);
+ Set(TProtoStringType(s, s + n), arena);
}
-inline void ArenaStringPtr::SetBytes(ConstStringParam value, Arena* arena) {
+template <>
+PROTOBUF_EXPORT void ArenaStringPtr::Set(const TProtoStringType& value,
+ Arena* arena);
+
+template <>
+inline void ArenaStringPtr::SetBytes(const TProtoStringType& value, Arena* arena) {
Set(value, arena);
}
@@ -426,7 +434,7 @@ inline void ArenaStringPtr::SetBytes(const char* s, Arena* arena) {
}
inline void ArenaStringPtr::SetBytes(const void* p, size_t n, Arena* arena) {
- Set(ConstStringParam{static_cast<const char*>(p), n}, arena);
+ Set(TProtoStringType(static_cast<const char*>(p), static_cast<const char*>(p) + n), arena);
}
// Make sure rhs_arena allocated rhs, and lhs_arena allocated lhs.
@@ -465,8 +473,8 @@ inline void ArenaStringPtr::ClearNonDefaultToEmpty() {
}
inline TProtoStringType* ArenaStringPtr::UnsafeMutablePointer() {
- GOOGLE_DCHECK(tagged_ptr_.IsMutable());
- GOOGLE_DCHECK(tagged_ptr_.Get() != nullptr);
+ Y_ABSL_DCHECK(tagged_ptr_.IsMutable());
+ Y_ABSL_DCHECK(tagged_ptr_.Get() != nullptr);
return tagged_ptr_.Get();
}
@@ -475,6 +483,6 @@ inline TProtoStringType* ArenaStringPtr::UnsafeMutablePointer() {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_ARENASTRING_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/arenaz_sampler.cc b/contrib/libs/protobuf/src/google/protobuf/arenaz_sampler.cc
index 7fde878e416..45cf27acf5f 100644
--- a/contrib/libs/protobuf/src/google/protobuf/arenaz_sampler.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/arenaz_sampler.cc
@@ -28,15 +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.
-#include <google/protobuf/arenaz_sampler.h>
+#include "google/protobuf/arenaz_sampler.h"
#include <atomic>
#include <cstdint>
#include <limits>
+#include <utility>
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -56,64 +57,93 @@ namespace {
PROTOBUF_CONSTINIT std::atomic<bool> g_arenaz_enabled{true};
PROTOBUF_CONSTINIT std::atomic<arc_i32> g_arenaz_sample_parameter{1 << 10};
-PROTOBUF_THREAD_LOCAL absl::profiling_internal::ExponentialBiased
+PROTOBUF_CONSTINIT std::atomic<ThreadSafeArenazConfigListener>
+ g_arenaz_config_listener{nullptr};
+PROTOBUF_THREAD_LOCAL y_absl::profiling_internal::ExponentialBiased
g_exponential_biased_generator;
+void TriggerThreadSafeArenazConfigListener() {
+ auto* listener = g_arenaz_config_listener.load(std::memory_order_acquire);
+ if (listener != nullptr) listener();
+}
+
} // namespace
-PROTOBUF_THREAD_LOCAL arc_i64 global_next_sample = 1LL << 10;
+PROTOBUF_THREAD_LOCAL SamplingState global_sampling_state = {
+ /*next_sample=*/0, /*sample_stride=*/0};
-ThreadSafeArenaStats::ThreadSafeArenaStats() { PrepareForSampling(); }
+ThreadSafeArenaStats::ThreadSafeArenaStats() { PrepareForSampling(0); }
ThreadSafeArenaStats::~ThreadSafeArenaStats() = default;
-void ThreadSafeArenaStats::PrepareForSampling() {
+void ThreadSafeArenaStats::BlockStats::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_used.store(0, std::memory_order_relaxed);
bytes_wasted.store(0, std::memory_order_relaxed);
- max_bytes_allocated.store(0, std::memory_order_relaxed);
+}
+
+void ThreadSafeArenaStats::PrepareForSampling(arc_i64 stride) {
+ for (auto& blockstats : block_histogram) blockstats.PrepareForSampling();
+ max_block_size.store(0, std::memory_order_relaxed);
thread_ids.store(0, std::memory_order_relaxed);
+ weight = stride;
// 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);
+ depth = y_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);
+size_t ThreadSafeArenaStats::FindBin(size_t bytes) {
+ if (bytes <= kMaxSizeForBinZero) return 0;
+ if (bytes <= kMaxSizeForPenultimateBin) {
+ // y_absl::bit_width() returns one plus the base-2 logarithm of x, with any
+ // fractional part discarded.
+ return y_absl::bit_width(y_absl::bit_ceil(bytes)) - kLogMaxSizeForBinZero - 1;
}
- 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);
+ return kBlockHistogramBins - 1;
}
-void RecordAllocateSlow(ThreadSafeArenaStats* info, size_t requested,
+std::pair<size_t, size_t> ThreadSafeArenaStats::MinMaxBlockSizeForBin(
+ size_t bin) {
+ Y_ABSL_ASSERT(bin < kBlockHistogramBins);
+ if (bin == 0) return {1, kMaxSizeForBinZero};
+ if (bin < kBlockHistogramBins - 1) {
+ return {(1 << (kLogMaxSizeForBinZero + bin - 1)) + 1,
+ 1 << (kLogMaxSizeForBinZero + bin)};
+ }
+ return {kMaxSizeForPenultimateBin + 1, std::numeric_limits<size_t>::max()};
+}
+
+void RecordAllocateSlow(ThreadSafeArenaStats* info, size_t used,
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);
+ // Update the allocated bytes for the current block.
+ ThreadSafeArenaStats::BlockStats& curr =
+ info->block_histogram[ThreadSafeArenaStats::FindBin(allocated)];
+ curr.bytes_allocated.fetch_add(allocated, std::memory_order_relaxed);
+ curr.num_allocations.fetch_add(1, std::memory_order_relaxed);
+
+ // Update the used and wasted bytes for the previous block.
+ ThreadSafeArenaStats::BlockStats& prev =
+ info->block_histogram[ThreadSafeArenaStats::FindBin(used + wasted)];
+ prev.bytes_used.fetch_add(used, std::memory_order_relaxed);
+ prev.bytes_wasted.fetch_add(wasted, std::memory_order_relaxed);
+
+ if (info->max_block_size.load(std::memory_order_relaxed) < allocated) {
+ info->max_block_size.store(allocated, std::memory_order_relaxed);
}
+ const arc_ui64 tid = 1ULL << (GetCachedTID() % 63);
+ info->thread_ids.fetch_or(tid, std::memory_order_relaxed);
}
-ThreadSafeArenaStats* SampleSlow(arc_i64* next_sample) {
- bool first = *next_sample < 0;
- *next_sample = g_exponential_biased_generator.GetStride(
+ThreadSafeArenaStats* SampleSlow(SamplingState& sampling_state) {
+ bool first = sampling_state.next_sample < 0;
+ const arc_i64 next_stride = 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);
+ Y_ABSL_ASSERT(next_stride >= 1);
+ sampling_state.next_sample = next_stride;
+ const arc_i64 old_stride =
+ y_absl::exchange(sampling_state.sample_stride, next_stride);
// 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
@@ -122,40 +152,72 @@ ThreadSafeArenaStats* SampleSlow(arc_i64* next_sample) {
// 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);
+ if (PROTOBUF_PREDICT_TRUE(--sampling_state.next_sample > 0)) return nullptr;
+ return SampleSlow(sampling_state);
}
- return GlobalThreadSafeArenazSampler().Register();
+ return GlobalThreadSafeArenazSampler().Register(old_stride);
+}
+
+void SetThreadSafeArenazConfigListener(ThreadSafeArenazConfigListener l) {
+ g_arenaz_config_listener.store(l, std::memory_order_release);
+}
+
+bool IsThreadSafeArenazEnabled() {
+ return g_arenaz_enabled.load(std::memory_order_acquire);
}
void SetThreadSafeArenazEnabled(bool enabled) {
+ SetThreadSafeArenazEnabledInternal(enabled);
+ TriggerThreadSafeArenazConfigListener();
+}
+
+void SetThreadSafeArenazEnabledInternal(bool enabled) {
g_arenaz_enabled.store(enabled, std::memory_order_release);
}
void SetThreadSafeArenazSampleParameter(arc_i32 rate) {
+ SetThreadSafeArenazSampleParameterInternal(rate);
+ TriggerThreadSafeArenazConfigListener();
+}
+
+void SetThreadSafeArenazSampleParameterInternal(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",
+ Y_ABSL_RAW_LOG(ERROR, "Invalid thread safe arenaz sample rate: %lld",
static_cast<long long>(rate)); // NOLINT(runtime/int)
}
}
+arc_i32 ThreadSafeArenazSampleParameter() {
+ return g_arenaz_sample_parameter.load(std::memory_order_relaxed);
+}
+
void SetThreadSafeArenazMaxSamples(arc_i32 max) {
+ SetThreadSafeArenazMaxSamplesInternal(max);
+ TriggerThreadSafeArenazConfigListener();
+}
+
+void SetThreadSafeArenazMaxSamplesInternal(arc_i32 max) {
if (max > 0) {
GlobalThreadSafeArenazSampler().SetMaxSamples(max);
} else {
- ABSL_RAW_LOG(ERROR, "Invalid thread safe arenaz max samples: %lld",
+ Y_ABSL_RAW_LOG(ERROR, "Invalid thread safe arenaz max samples: %lld",
static_cast<long long>(max)); // NOLINT(runtime/int)
}
}
+size_t ThreadSafeArenazMaxSamples() {
+ return GlobalThreadSafeArenazSampler().GetMaxSamples();
+}
+
void SetThreadSafeArenazGlobalNextSample(arc_i64 next_sample) {
if (next_sample >= 0) {
- global_next_sample = next_sample;
+ global_sampling_state.next_sample = next_sample;
+ global_sampling_state.sample_stride = next_sample;
} else {
- ABSL_RAW_LOG(ERROR, "Invalid thread safe arenaz next sample: %lld",
+ Y_ABSL_RAW_LOG(ERROR, "Invalid thread safe arenaz next sample: %lld",
static_cast<long long>(next_sample)); // NOLINT(runtime/int)
}
}
@@ -166,9 +228,16 @@ ThreadSafeArenaStats* SampleSlow(arc_i64* next_sample) {
return nullptr;
}
+void SetThreadSafeArenazConfigListener(ThreadSafeArenazConfigListener) {}
void SetThreadSafeArenazEnabled(bool enabled) {}
+void SetThreadSafeArenazEnabledInternal(bool enabled) {}
+bool IsThreadSafeArenazEnabled() { return false; }
void SetThreadSafeArenazSampleParameter(arc_i32 rate) {}
+void SetThreadSafeArenazSampleParameterInternal(arc_i32 rate) {}
+arc_i32 ThreadSafeArenazSampleParameter() { return 0; }
void SetThreadSafeArenazMaxSamples(arc_i32 max) {}
+void SetThreadSafeArenazMaxSamplesInternal(arc_i32 max) {}
+size_t ThreadSafeArenazMaxSamples() { return 0; }
void SetThreadSafeArenazGlobalNextSample(arc_i64 next_sample) {}
#endif // defined(PROTOBUF_ARENAZ_SAMPLE)
diff --git a/contrib/libs/protobuf/src/google/protobuf/arenaz_sampler.h b/contrib/libs/protobuf/src/google/protobuf/arenaz_sampler.h
index 470b660e83e..2d139e94b22 100644
--- a/contrib/libs/protobuf/src/google/protobuf/arenaz_sampler.h
+++ b/contrib/libs/protobuf/src/google/protobuf/arenaz_sampler.h
@@ -31,14 +31,16 @@
#ifndef GOOGLE_PROTOBUF_SRC_GOOGLE_PROTOBUF_ARENAZ_SAMPLER_H__
#define GOOGLE_PROTOBUF_SRC_GOOGLE_PROTOBUF_ARENAZ_SAMPLER_H__
+#include <array>
#include <atomic>
#include <cstddef>
#include <cstdint>
+#include <utility>
#include <google/protobuf/stubs/port.h>
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -46,33 +48,54 @@ namespace internal {
#if defined(PROTOBUF_ARENAZ_SAMPLE)
struct ThreadSafeArenaStats;
-void RecordResetSlow(ThreadSafeArenaStats* info);
-void RecordAllocateSlow(ThreadSafeArenaStats* info, size_t requested,
+void RecordAllocateSlow(ThreadSafeArenaStats* info, size_t used,
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> {
+ : public y_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);
+ // blocking for any readers that are currently sampling the object. The
+ // 'stride' parameter is the number of ThreadSafeArenas that were instantiated
+ // between this sample and the previous one.
+ void PrepareForSampling(arc_i64 stride)
+ Y_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.
+ struct BlockStats {
+ std::atomic<int> num_allocations;
+ std::atomic<size_t> bytes_allocated;
+ std::atomic<size_t> bytes_used;
+ std::atomic<size_t> bytes_wasted;
+
+ void PrepareForSampling();
+ };
+
+ // block_histogram is a kBlockHistogramBins sized histogram. The zeroth bin
+ // stores info about blocks of size \in [1, 1 << kLogMaxSizeForBinZero]. Bin
+ // i, where i > 0, stores info for blocks of size \in (max_size_bin (i-1),
+ // 1 << (kLogMaxSizeForBinZero + i)]. The final bin stores info about blocks
+ // of size \in [kMaxSizeForPenultimateBin + 1,
+ // std::numeric_limits<size_t>::max()].
+ static constexpr size_t kBlockHistogramBins = 15;
+ static constexpr size_t kLogMaxSizeForBinZero = 7;
+ static constexpr size_t kMaxSizeForBinZero = (1 << kLogMaxSizeForBinZero);
+ static constexpr size_t kMaxSizeForPenultimateBin =
+ 1 << (kLogMaxSizeForBinZero + kBlockHistogramBins - 2);
+ std::array<BlockStats, kBlockHistogramBins> block_histogram;
+
+ // Records the largest block allocated for the arena.
+ std::atomic<size_t> max_block_size;
+ // Bit `i` is set to 1 indicates that a thread with `tid % 63 = i` accessed
+ // the underlying arena. We use `% 63` as a rudimentary hash to ensure some
+ // bit mixing for thread-ids; `% 64` would only grab the low bits and might
+ // create sampling artifacts.
std::atomic<arc_ui64> thread_ids;
// All of the fields below are set by `PrepareForSampling`, they must not
@@ -83,14 +106,32 @@ struct ThreadSafeArenaStats
static constexpr int kMaxStackDepth = 64;
arc_i32 depth;
void* stack[kMaxStackDepth];
- static void RecordAllocateStats(ThreadSafeArenaStats* info, size_t requested,
+ static void RecordAllocateStats(ThreadSafeArenaStats* info, size_t used,
size_t allocated, size_t wasted) {
if (PROTOBUF_PREDICT_TRUE(info == nullptr)) return;
- RecordAllocateSlow(info, requested, allocated, wasted);
+ RecordAllocateSlow(info, used, allocated, wasted);
}
+
+ // Returns the bin for the provided size.
+ static size_t FindBin(size_t bytes);
+
+ // Returns the min and max bytes that can be stored in the histogram for
+ // blocks in the provided bin.
+ static std::pair<size_t, size_t> MinMaxBlockSizeForBin(size_t bin);
+};
+
+struct SamplingState {
+ // Number of ThreadSafeArenas that should be instantiated before the next
+ // ThreadSafeArena is sampled. This variable is decremented with each
+ // instantiation.
+ arc_i64 next_sample;
+ // When we make a sampling decision, we record that distance between from the
+ // previous sample so we can weight each sample. 'distance' here is the
+ // number of instantiations of ThreadSafeArena.
+ arc_i64 sample_stride;
};
-ThreadSafeArenaStats* SampleSlow(arc_i64* next_sample);
+ThreadSafeArenaStats* SampleSlow(SamplingState& sampling_state);
void UnsampleSlow(ThreadSafeArenaStats* info);
class ThreadSafeArenaStatsHandle {
@@ -105,22 +146,17 @@ class ThreadSafeArenaStatsHandle {
}
ThreadSafeArenaStatsHandle(ThreadSafeArenaStatsHandle&& other) noexcept
- : info_(absl::exchange(other.info_, nullptr)) {}
+ : info_(y_absl::exchange(other.info_, nullptr)) {}
ThreadSafeArenaStatsHandle& operator=(
ThreadSafeArenaStatsHandle&& other) noexcept {
if (PROTOBUF_PREDICT_FALSE(info_ != nullptr)) {
UnsampleSlow(info_);
}
- info_ = absl::exchange(other.info_, nullptr);
+ info_ = y_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,
@@ -135,26 +171,29 @@ class ThreadSafeArenaStatsHandle {
};
using ThreadSafeArenazSampler =
- ::absl::profiling_internal::SampleRecorder<ThreadSafeArenaStats>;
+ ::y_absl::profiling_internal::SampleRecorder<ThreadSafeArenaStats>;
-extern PROTOBUF_THREAD_LOCAL arc_i64 global_next_sample;
+extern PROTOBUF_THREAD_LOCAL SamplingState global_sampling_state;
// 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)) {
+ if (PROTOBUF_PREDICT_TRUE(--global_sampling_state.next_sample > 0)) {
return ThreadSafeArenaStatsHandle(nullptr);
}
- return ThreadSafeArenaStatsHandle(SampleSlow(&global_next_sample));
+ return ThreadSafeArenaStatsHandle(SampleSlow(global_sampling_state));
}
#else
+
+using SamplingState = arc_i64;
+
struct ThreadSafeArenaStats {
static void RecordAllocateStats(ThreadSafeArenaStats*, size_t /*requested*/,
size_t /*allocated*/, size_t /*wasted*/) {}
};
-ThreadSafeArenaStats* SampleSlow(arc_i64* next_sample);
+ThreadSafeArenaStats* SampleSlow(SamplingState& next_sample);
void UnsampleSlow(ThreadSafeArenaStats* info);
class ThreadSafeArenaStatsHandle {
@@ -188,14 +227,29 @@ inline ThreadSafeArenaStatsHandle Sample() {
// Returns a global Sampler.
ThreadSafeArenazSampler& GlobalThreadSafeArenazSampler();
+using ThreadSafeArenazConfigListener = void (*)();
+void SetThreadSafeArenazConfigListener(ThreadSafeArenazConfigListener l);
+
// Enables or disables sampling for thread safe arenas.
void SetThreadSafeArenazEnabled(bool enabled);
+void SetThreadSafeArenazEnabledInternal(bool enabled);
+
+// Returns true if sampling is on, false otherwise.
+bool IsThreadSafeArenazEnabled();
// Sets the rate at which thread safe arena will be sampled.
void SetThreadSafeArenazSampleParameter(arc_i32 rate);
+void SetThreadSafeArenazSampleParameterInternal(arc_i32 rate);
+
+// Returns the rate at which thread safe arena will be sampled.
+arc_i32 ThreadSafeArenazSampleParameter();
// Sets a soft max for the number of samples that will be kept.
void SetThreadSafeArenazMaxSamples(arc_i32 max);
+void SetThreadSafeArenazMaxSamplesInternal(arc_i32 max);
+
+// Returns the max number of samples that will be kept.
+size_t ThreadSafeArenazMaxSamples();
// Sets the current value for when arenas should be next sampled.
void SetThreadSafeArenazGlobalNextSample(arc_i64 next_sample);
@@ -204,5 +258,5 @@ void SetThreadSafeArenazGlobalNextSample(arc_i64 next_sample);
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#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 ed6d2dc5cca..461375c914b 100644
--- a/contrib/libs/protobuf/src/google/protobuf/descriptor.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/descriptor.cc
@@ -32,65 +32,64 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/descriptor.h>
+#include "google/protobuf/descriptor.h"
#include <algorithm>
#include <array>
+#include <cstdlib>
#include <functional>
+#include <iterator>
#include <limits>
-#include <map>
#include <memory>
-#include <set>
#include <sstream>
#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/strutil.h>
-#include <google/protobuf/stubs/once.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_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/stubs/map_util.h>
-#include <google/protobuf/stubs/stl_util.h>
-#include <google/protobuf/stubs/hash.h>
-
-#undef PACKAGE // autoheader #defines this. :(
+#include "google/protobuf/stubs/common.h"
+#include "y_absl/base/call_once.h"
+#include "y_absl/base/casts.h"
+#include "y_absl/base/dynamic_annotations.h"
+#include "y_absl/container/btree_map.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/hash/hash.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/escaping.h"
+#include "y_absl/strings/match.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/str_join.h"
+#include "y_absl/strings/str_split.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/strings/strip.h"
+#include "y_absl/strings/substitute.h"
+#include "y_absl/synchronization/mutex.h"
+#include "y_absl/types/optional.h"
+#include "google/protobuf/any.h"
+#include "google/protobuf/descriptor.pb.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/io/tokenizer.h"
+#include "google/protobuf/port.h"
+#include "google/protobuf/text_format.h"
+#include "google/protobuf/unknown_field_set.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
-
namespace {
+using ::google::protobuf::internal::DownCast;
+
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;
@@ -101,7 +100,7 @@ TProtoStringType ToCamelCase(const TProtoStringType& input, bool lower_first) {
if (character == '_') {
capitalize_next = true;
} else if (capitalize_next) {
- result.push_back(ToUpper(character));
+ result.push_back(y_absl::ascii_toupper(character));
capitalize_next = false;
} else {
result.push_back(character);
@@ -110,7 +109,7 @@ TProtoStringType ToCamelCase(const TProtoStringType& input, bool lower_first) {
// Lower-case the first letter.
if (lower_first && !result.empty()) {
- result[0] = ToLower(result[0]);
+ result[0] = y_absl::ascii_tolower(result[0]);
}
return result;
@@ -125,7 +124,7 @@ TProtoStringType ToJsonName(const TProtoStringType& input) {
if (character == '_') {
capitalize_next = true;
} else if (capitalize_next) {
- result.push_back(ToUpper(character));
+ result.push_back(y_absl::ascii_toupper(character));
capitalize_next = false;
} else {
result.push_back(character);
@@ -135,6 +134,18 @@ TProtoStringType ToJsonName(const TProtoStringType& input) {
return result;
}
+template <typename OptionsT>
+bool IsLegacyJsonFieldConflictEnabled(const OptionsT& options) {
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+ return options.deprecated_legacy_json_field_conflicts();
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+}
+
// Backport of fold expressions for the comma operator to C++11.
// Usage: Fold({expr...});
// Guaranteed to evaluate left-to-right
@@ -367,7 +378,7 @@ class FlatAllocatorImpl {
template <typename U>
void PlanArray(int array_size) {
// We can't call PlanArray after FinalizePlanning has been called.
- GOOGLE_CHECK(!has_allocated());
+ Y_ABSL_CHECK(!has_allocated());
if (std::is_trivially_destructible<U>::value) {
// Trivial types are aligned to 8 bytes.
static_assert(alignof(U) <= 8, "");
@@ -388,13 +399,13 @@ class FlatAllocatorImpl {
using TypeToUse = typename std::conditional<trivial, char, U>::type;
// We can only allocate after FinalizePlanning has been called.
- GOOGLE_CHECK(has_allocated());
+ Y_ABSL_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>());
+ Y_ABSL_CHECK_LE(used, total_.template Get<TypeToUse>());
return res;
}
@@ -413,7 +424,7 @@ class FlatAllocatorImpl {
// and the other 3 indices are specified in the result.
void PlanFieldNames(const TProtoStringType& name,
const TProtoStringType* opt_json_name) {
- GOOGLE_CHECK(!has_allocated());
+ Y_ABSL_CHECK(!has_allocated());
// Fast path for snake_case names, which follow the style guide.
if (opt_json_name == nullptr) {
@@ -430,13 +441,13 @@ class FlatAllocatorImpl {
}
TProtoStringType lowercase_name = name;
- LowerString(&lowercase_name);
+ y_absl::AsciiStrToLower(&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,
+ y_absl::string_view all_names[] = {name, lowercase_name, camelcase_name,
json_name};
std::sort(all_names, all_names + 4);
int unique =
@@ -454,10 +465,10 @@ class FlatAllocatorImpl {
FieldNamesResult AllocateFieldNames(const TProtoStringType& name,
const TProtoStringType& scope,
const TProtoStringType* opt_json_name) {
- GOOGLE_CHECK(has_allocated());
+ Y_ABSL_CHECK(has_allocated());
TProtoStringType full_name =
- scope.empty() ? name : StrCat(scope, ".", name);
+ scope.empty() ? name : y_absl::StrCat(scope, ".", name);
// Fast path for snake_case names, which follow the style guide.
if (opt_json_name == nullptr) {
@@ -494,7 +505,7 @@ class FlatAllocatorImpl {
FieldNamesResult result{nullptr, 0, 0, 0};
TProtoStringType lowercase_name = name;
- LowerString(&lowercase_name);
+ y_absl::AsciiStrToLower(&lowercase_name);
result.lowercase_index = push_name(std::move(lowercase_name));
result.camelcase_index =
push_name(ToCamelCase(name, /* lower_first = */ true));
@@ -510,11 +521,11 @@ class FlatAllocatorImpl {
template <typename Alloc>
void FinalizePlanning(Alloc& alloc) {
- GOOGLE_CHECK(!has_allocated());
+ Y_ABSL_CHECK(!has_allocated());
pointers_ = alloc->CreateFlatAlloc(total_)->Pointers();
- GOOGLE_CHECK(has_allocated());
+ Y_ABSL_CHECK(has_allocated());
}
void ExpectConsumed() const {
@@ -550,7 +561,7 @@ class FlatAllocatorImpl {
template <typename U>
bool ExpectConsumed() const {
- GOOGLE_CHECK_EQ(total_.template Get<U>(), used_.template Get<U>());
+ Y_ABSL_CHECK_EQ(total_.template Get<U>(), used_.template Get<U>());
return true;
}
@@ -575,7 +586,6 @@ class Symbol {
METHOD,
FULL_PACKAGE,
SUB_PACKAGE,
- QUERY_KEY
};
Symbol() {
@@ -641,35 +651,6 @@ class Symbol {
: nullptr;
}
- // 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};
- }
- };
- // 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 static_cast<Type>(ptr_->symbol_type_); }
@@ -707,7 +688,7 @@ class Symbol {
}
}
- StringPiece full_name() const {
+ y_absl::string_view full_name() const {
switch (type()) {
case MESSAGE:
return descriptor()->full_name();
@@ -726,17 +707,15 @@ class Symbol {
case FULL_PACKAGE:
return file_descriptor()->package();
case SUB_PACKAGE:
- return StringPiece(sub_package_file_descriptor()->file->package())
+ return y_absl::string_view(sub_package_file_descriptor()->file->package())
.substr(0, sub_package_file_descriptor()->name_size);
- case QUERY_KEY:
- return query_key()->full_name();
default:
- GOOGLE_CHECK(false);
+ Y_ABSL_CHECK(false);
}
return "";
}
- std::pair<const void*, StringPiece> parent_name_key() const {
+ std::pair<const void*, y_absl::string_view> parent_name_key() const {
const auto or_file = [&](const void* p) { return p ? p : GetFile(); };
switch (type()) {
case MESSAGE:
@@ -763,26 +742,8 @@ class Symbol {
return {GetFile(), service_descriptor()->name()};
case METHOD:
return {method_descriptor()->service(), method_descriptor()->name()};
- case QUERY_KEY:
- return query_key()->parent_name_key();
- default:
- GOOGLE_CHECK(false);
- }
- return {};
- }
-
- std::pair<const void*, int> parent_number_key() const {
- switch (type()) {
- case FIELD:
- return {field_descriptor()->containing_type(),
- field_descriptor()->number()};
- case ENUM_VALUE:
- return {enum_value_descriptor()->type(),
- enum_value_descriptor()->number()};
- case QUERY_KEY:
- return query_key()->parent_number_key();
default:
- GOOGLE_CHECK(false);
+ Y_ABSL_CHECK(false);
}
return {};
}
@@ -870,7 +831,7 @@ const char* FileDescriptor::SyntaxName(FileDescriptor::Syntax syntax) {
case SYNTAX_UNKNOWN:
return "unknown";
}
- GOOGLE_LOG(FATAL) << "can't reach here.";
+ Y_ABSL_LOG(FATAL) << "can't reach here.";
return nullptr;
}
@@ -894,9 +855,9 @@ TProtoStringType EnumValueToPascalCase(const TProtoStringType& input) {
next_upper = true;
} else {
if (next_upper) {
- result.push_back(ToUpper(character));
+ result.push_back(y_absl::ascii_toupper(character));
} else {
- result.push_back(ToLower(character));
+ result.push_back(y_absl::ascii_tolower(character));
}
next_upper = false;
}
@@ -908,18 +869,18 @@ TProtoStringType EnumValueToPascalCase(const TProtoStringType& input) {
// Class to remove an enum prefix from enum values.
class PrefixRemover {
public:
- PrefixRemover(StringPiece prefix) {
+ PrefixRemover(y_absl::string_view prefix) {
// Strip underscores and lower-case the prefix.
for (char character : prefix) {
if (character != '_') {
- prefix_ += ascii_tolower(character);
+ prefix_ += y_absl::ascii_tolower(character);
}
}
}
// Tries to remove the enum prefix from this enum value.
// If this is not possible, returns the input verbatim.
- TProtoStringType MaybeRemove(StringPiece str) {
+ TProtoStringType MaybeRemove(y_absl::string_view str) {
// We can't just lowercase and strip str and look for a prefix.
// We need to properly recognize the difference between:
//
@@ -938,7 +899,7 @@ class PrefixRemover {
continue;
}
- if (ascii_tolower(str[i]) != prefix_[j++]) {
+ if (y_absl::ascii_tolower(str[i]) != prefix_[j++]) {
return TProtoStringType(str);
}
}
@@ -975,60 +936,16 @@ class PrefixRemover {
// hash-maps for each object.
//
// The keys to these hash-maps are (parent, name) or (parent, number) pairs.
-
-typedef std::pair<const void*, StringPiece> PointerStringPair;
-
-typedef std::pair<const Descriptor*, int> DescriptorIntPair;
-
-#define HASH_MAP std::unordered_map
-#define HASH_SET std::unordered_set
-#define HASH_FXN hash
-
-template <typename PairType>
-struct PointerIntegerPairHash {
- size_t operator()(const PairType& p) const {
- static const size_t prime1 = 16777499;
- static const size_t prime2 = 16777619;
- return reinterpret_cast<size_t>(p.first) * prime1 ^
- static_cast<size_t>(p.second) * prime2;
- }
-
-#ifdef _MSC_VER
- // Used only by MSVC and platforms where hash_map is not available.
- static const size_t bucket_size = 4;
- static const size_t min_buckets = 8;
-#endif
- inline bool operator()(const PairType& a, const PairType& b) const {
- return a < b;
- }
+struct FullNameQuery {
+ y_absl::string_view query;
+ y_absl::string_view full_name() const { return query; }
};
-
-struct PointerStringPairHash {
- size_t operator()(const PointerStringPair& p) const {
- static const size_t prime = 16777619;
- hash<StringPiece> string_hash;
- return reinterpret_cast<size_t>(p.first) * prime ^
- static_cast<size_t>(string_hash(p.second));
- }
-
-#ifdef _MSC_VER
- // Used only by MSVC and platforms where hash_map is not available.
- static const size_t bucket_size = 4;
- static const size_t min_buckets = 8;
-#endif
- inline bool operator()(const PointerStringPair& a,
- const PointerStringPair& b) const {
- return a < b;
- }
-};
-
-
struct SymbolByFullNameHash {
using is_transparent = void;
template <typename T>
size_t operator()(const T& s) const {
- return HASH_FXN<StringPiece>{}(s.full_name());
+ return y_absl::HashOf(s.full_name());
}
};
struct SymbolByFullNameEq {
@@ -1040,14 +957,20 @@ struct SymbolByFullNameEq {
}
};
using SymbolsByNameSet =
- HASH_SET<Symbol, SymbolByFullNameHash, SymbolByFullNameEq>;
+ y_absl::flat_hash_set<Symbol, SymbolByFullNameHash, SymbolByFullNameEq>;
+struct ParentNameQuery {
+ std::pair<const void*, y_absl::string_view> query;
+ std::pair<const void*, y_absl::string_view> parent_name_key() const {
+ return query;
+ }
+};
struct SymbolByParentHash {
using is_transparent = void;
template <typename T>
size_t operator()(const T& s) const {
- return PointerStringPairHash{}(s.parent_name_key());
+ return y_absl::HashOf(s.parent_name_key());
}
};
struct SymbolByParentEq {
@@ -1059,52 +982,94 @@ struct SymbolByParentEq {
}
};
using SymbolsByParentSet =
- HASH_SET<Symbol, SymbolByParentHash, SymbolByParentEq>;
+ y_absl::flat_hash_set<Symbol, SymbolByParentHash, SymbolByParentEq>;
-typedef HASH_MAP<StringPiece, const FileDescriptor*,
- HASH_FXN<StringPiece>>
- FilesByNameMap;
+struct FilesByNameHash {
+ using is_transparent = void;
+
+ size_t operator()(y_absl::string_view name) const { return y_absl::HashOf(name); }
-typedef HASH_MAP<PointerStringPair, const FieldDescriptor*,
- PointerStringPairHash>
- FieldsByNameMap;
+ size_t operator()(const FileDescriptor* file) const {
+ return y_absl::HashOf(file->name());
+ }
+};
-struct FieldsByNumberHash {
+struct FilesByNameEq {
+ using is_transparent = void;
+
+ bool operator()(y_absl::string_view lhs, y_absl::string_view rhs) const {
+ return lhs == rhs;
+ }
+ bool operator()(y_absl::string_view lhs, const FileDescriptor* rhs) const {
+ return lhs == rhs->name();
+ }
+ bool operator()(const FileDescriptor* lhs, y_absl::string_view rhs) const {
+ return lhs->name() == rhs;
+ }
+ bool operator()(const FileDescriptor* lhs, const FileDescriptor* rhs) const {
+ return lhs == rhs || lhs->name() == rhs->name();
+ }
+};
+using FilesByNameSet =
+ y_absl::flat_hash_set<const FileDescriptor*, FilesByNameHash, FilesByNameEq>;
+
+using FieldsByNameMap =
+ y_absl::flat_hash_map<std::pair<const void*, y_absl::string_view>,
+ const FieldDescriptor*>;
+
+struct ParentNumberQuery {
+ std::pair<const void*, int> query;
+};
+std::pair<const void*, int> ObjectToParentNumber(const FieldDescriptor* field) {
+ return {field->containing_type(), field->number()};
+}
+std::pair<const void*, int> ObjectToParentNumber(
+ const EnumValueDescriptor* enum_value) {
+ return {enum_value->type(), enum_value->number()};
+}
+std::pair<const void*, int> ObjectToParentNumber(ParentNumberQuery query) {
+ return query.query;
+}
+struct ParentNumberHash {
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());
+ size_t operator()(const T& t) const {
+ return y_absl::HashOf(ObjectToParentNumber(t));
}
};
-struct FieldsByNumberEq {
+struct ParentNumberEq {
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();
+ return ObjectToParentNumber(a) == ObjectToParentNumber(b);
}
};
-using FieldsByNumberSet =
- HASH_SET<Symbol, FieldsByNumberHash, FieldsByNumberEq>;
-using EnumValuesByNumberSet = FieldsByNumberSet;
+using FieldsByNumberSet = y_absl::flat_hash_set<const FieldDescriptor*,
+ ParentNumberHash, ParentNumberEq>;
+using EnumValuesByNumberSet =
+ y_absl::flat_hash_set<const EnumValueDescriptor*, ParentNumberHash,
+ ParentNumberEq>;
// This is a map rather than a hash-map, since we use it to iterate
// through all the extensions that extend a given Descriptor, and an
// ordered data structure that implements lower_bound is convenient
// for that.
-typedef std::map<DescriptorIntPair, const FieldDescriptor*>
- ExtensionsGroupedByDescriptorMap;
-typedef HASH_MAP<TProtoStringType, const SourceCodeInfo_Location*>
- LocationsByPathMap;
+using ExtensionsGroupedByDescriptorMap =
+ y_absl::btree_map<std::pair<const Descriptor*, int>, const FieldDescriptor*>;
+using LocationsByPathMap =
+ y_absl::flat_hash_map<TProtoStringType, const SourceCodeInfo_Location*>;
-std::set<TProtoStringType>* NewAllowedProto3Extendee() {
- auto allowed_proto3_extendees = new std::set<TProtoStringType>;
+y_absl::flat_hash_set<TProtoStringType>* NewAllowedProto3Extendee() {
const char* kOptionNames[] = {
"FileOptions", "MessageOptions", "FieldOptions",
"EnumOptions", "EnumValueOptions", "ServiceOptions",
"MethodOptions", "OneofOptions", "ExtensionRangeOptions"};
+ auto allowed_proto3_extendees = new y_absl::flat_hash_set<TProtoStringType>();
+ allowed_proto3_extendees->reserve(sizeof(kOptionNames) /
+ sizeof(kOptionNames[0]));
+
for (const char* option_name : kOptionNames) {
// descriptor.proto has a different package name in opensource. We allow
// both so the opensource protocol compiler can also compile internal
@@ -1113,7 +1078,7 @@ std::set<TProtoStringType>* NewAllowedProto3Extendee() {
option_name);
// Split the word to trick the opensource processing scripts so they
// will keep the original package name.
- allowed_proto3_extendees->insert(TProtoStringType("proto") + "2." + option_name);
+ allowed_proto3_extendees->insert(TProtoStringType("proto2.") + option_name);
}
return allowed_proto3_extendees;
}
@@ -1151,16 +1116,19 @@ class FileDescriptorTables {
// Finding items.
// Returns a null Symbol (symbol.IsNull() is true) if not found.
+ // TODO(sbenza): All callers to this function know the type they are looking
+ // for. If we propagate that information statically we can make the query
+ // faster.
inline Symbol FindNestedSymbol(const void* parent,
- StringPiece name) const;
+ y_absl::string_view 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;
+ const void* parent, y_absl::string_view lowercase_name) const;
inline const FieldDescriptor* FindFieldByCamelcaseName(
- const void* parent, StringPiece camelcase_name) const;
+ const void* parent, y_absl::string_view 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.
@@ -1172,13 +1140,13 @@ class FileDescriptorTables {
// 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,
+ bool AddAliasUnderParent(const void* parent, y_absl::string_view name,
Symbol symbol);
bool AddFieldByNumber(FieldDescriptor* field);
bool AddEnumValueByNumber(EnumValueDescriptor* value);
// Populates p->first->locations_by_path_ from p->second.
- // Unusual signature dictated by internal::call_once.
+ // Unusual signature dictated by y_absl::call_once.
static void BuildLocationsByPath(
std::pair<const FileDescriptorTables*, const SourceCodeInfo*>* p);
@@ -1203,8 +1171,8 @@ class FileDescriptorTables {
void FieldsByCamelcaseNamesLazyInitInternal() const;
SymbolsByParentSet symbols_by_parent_;
- mutable internal::once_flag fields_by_lowercase_name_once_;
- mutable internal::once_flag fields_by_camelcase_name_once_;
+ mutable y_absl::once_flag fields_by_lowercase_name_once_;
+ mutable y_absl::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.
@@ -1216,12 +1184,12 @@ class FileDescriptorTables {
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 y_absl::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_;
+ mutable y_absl::Mutex unknown_enum_values_mu_;
};
namespace internal {
@@ -1303,39 +1271,39 @@ class DescriptorPool::Tables {
// execution of the current public API call, but for compatibility with
// legacy clients, this is cleared at the beginning of each public API call.
// Not used when fallback_database_ == nullptr.
- HASH_SET<TProtoStringType> known_bad_files_;
+ y_absl::flat_hash_set<TProtoStringType> known_bad_files_;
// A set of symbols which we have tried to load from the fallback database
// and encountered errors. We will not attempt to load them again during
// execution of the current public API call, but for compatibility with
// legacy clients, this is cleared at the beginning of each public API call.
- HASH_SET<TProtoStringType> known_bad_symbols_;
+ y_absl::flat_hash_set<TProtoStringType> known_bad_symbols_;
// The set of descriptors for which we've already loaded the full
// set of extensions numbers from fallback_database_.
- HASH_SET<const Descriptor*> extensions_loaded_from_db_;
+ y_absl::flat_hash_set<const Descriptor*> extensions_loaded_from_db_;
// Maps type name to Descriptor::WellKnownType. This is logically global
// and const, but we make it a member here to simplify its construction and
// destruction. This only has 20-ish entries and is one per DescriptorPool,
// so the overhead is small.
- HASH_MAP<TProtoStringType, Descriptor::WellKnownType> well_known_types_;
+ y_absl::flat_hash_map<TProtoStringType, Descriptor::WellKnownType> well_known_types_;
// -----------------------------------------------------------------
// Finding items.
// Find symbols. This returns a null Symbol (symbol.IsNull() is true)
// if not found.
- inline Symbol FindSymbol(StringPiece key) const;
+ inline Symbol FindSymbol(y_absl::string_view key) const;
// This implements the body of DescriptorPool::Find*ByName(). It should
// really be a private method of DescriptorPool, but that would require
// declaring Symbol in descriptor.h, which would drag all kinds of other
// stuff into the header. Yay C++.
- Symbol FindByNameHelper(const DescriptorPool* pool, StringPiece name);
+ Symbol FindByNameHelper(const DescriptorPool* pool, y_absl::string_view name);
// These return nullptr if not found.
- inline const FileDescriptor* FindFile(StringPiece key) const;
+ inline const FileDescriptor* FindFile(y_absl::string_view key) const;
inline const FieldDescriptor* FindExtension(const Descriptor* extendee,
int number) const;
inline void FindAllExtensions(const Descriptor* extendee,
@@ -1348,7 +1316,7 @@ class DescriptorPool::Tables {
// the key already exists in the table. For AddSymbol(), the string passed
// in must be one that was constructed using AllocateString(), as it will
// be used as a key in the symbols_by_name_ map without copying.
- bool AddSymbol(const TProtoStringType& full_name, Symbol symbol);
+ bool AddSymbol(y_absl::string_view full_name, Symbol symbol);
bool AddFile(const FileDescriptor* file);
bool AddExtension(const FieldDescriptor* field);
@@ -1394,7 +1362,7 @@ class DescriptorPool::Tables {
flat_allocs_;
SymbolsByNameSet symbols_by_name_;
- FilesByNameMap files_by_name_;
+ FilesByNameSet files_by_name_;
ExtensionsGroupedByDescriptorMap extensions_;
struct CheckPoint {
@@ -1418,7 +1386,7 @@ class DescriptorPool::Tables {
std::vector<CheckPoint> checkpoints_;
std::vector<Symbol> symbols_after_checkpoint_;
std::vector<const FileDescriptor*> files_after_checkpoint_;
- std::vector<DescriptorIntPair> extensions_after_checkpoint_;
+ std::vector<std::pair<const Descriptor*, int>> extensions_after_checkpoint_;
};
DescriptorPool::Tables::Tables() {
@@ -1442,7 +1410,7 @@ DescriptorPool::Tables::Tables() {
});
}
-DescriptorPool::Tables::~Tables() { GOOGLE_DCHECK(checkpoints_.empty()); }
+DescriptorPool::Tables::~Tables() { Y_ABSL_DCHECK(checkpoints_.empty()); }
FileDescriptorTables::FileDescriptorTables() {}
@@ -1458,11 +1426,11 @@ inline const FileDescriptorTables& FileDescriptorTables::GetEmptyInstance() {
}
void DescriptorPool::Tables::AddCheckpoint() {
- checkpoints_.push_back(CheckPoint(this));
+ checkpoints_.emplace_back(this);
}
void DescriptorPool::Tables::ClearLastCheckpoint() {
- GOOGLE_DCHECK(!checkpoints_.empty());
+ Y_ABSL_DCHECK(!checkpoints_.empty());
checkpoints_.pop_back();
if (checkpoints_.empty()) {
// All checkpoints have been cleared: we can now commit all of the pending
@@ -1474,7 +1442,7 @@ void DescriptorPool::Tables::ClearLastCheckpoint() {
}
void DescriptorPool::Tables::RollbackToLastCheckpoint() {
- GOOGLE_DCHECK(!checkpoints_.empty());
+ Y_ABSL_DCHECK(!checkpoints_.empty());
const CheckPoint& checkpoint = checkpoints_.back();
for (size_t i = checkpoint.pending_symbols_before_checkpoint;
@@ -1483,7 +1451,7 @@ void DescriptorPool::Tables::RollbackToLastCheckpoint() {
}
for (size_t i = checkpoint.pending_files_before_checkpoint;
i < files_after_checkpoint_.size(); i++) {
- files_by_name_.erase(files_after_checkpoint_[i]->name());
+ files_by_name_.erase(files_after_checkpoint_[i]);
}
for (size_t i = checkpoint.pending_extensions_before_checkpoint;
i < extensions_after_checkpoint_.size(); i++) {
@@ -1503,33 +1471,28 @@ void DescriptorPool::Tables::RollbackToLastCheckpoint() {
// -------------------------------------------------------------------
-inline Symbol DescriptorPool::Tables::FindSymbol(StringPiece key) const {
- Symbol::QueryKey name;
- name.name = key;
- auto it = symbols_by_name_.find(name);
+inline Symbol DescriptorPool::Tables::FindSymbol(y_absl::string_view key) const {
+ auto it = symbols_by_name_.find(FullNameQuery{key});
return it == symbols_by_name_.end() ? Symbol() : *it;
}
inline Symbol FileDescriptorTables::FindNestedSymbol(
- const void* parent, StringPiece name) const {
- Symbol::QueryKey query;
- query.name = name;
- query.parent = parent;
- auto it = symbols_by_parent_.find(query);
+ const void* parent, y_absl::string_view name) const {
+ auto it = symbols_by_parent_.find(ParentNameQuery{{parent, name}});
return it == symbols_by_parent_.end() ? Symbol() : *it;
}
Symbol DescriptorPool::Tables::FindByNameHelper(const DescriptorPool* pool,
- StringPiece name) {
+ y_absl::string_view name) {
if (pool->mutex_ != nullptr) {
// Fast path: the Symbol is already cached. This is just a hash lookup.
- ReaderMutexLock lock(pool->mutex_);
+ y_absl::ReaderMutexLock lock(pool->mutex_);
if (known_bad_symbols_.empty() && known_bad_files_.empty()) {
Symbol result = FindSymbol(name);
if (!result.IsNull()) return result;
}
}
- MutexLockMaybe lock(pool->mutex_);
+ y_absl::MutexLockMaybe lock(pool->mutex_);
if (pool->fallback_database_ != nullptr) {
known_bad_symbols_.clear();
known_bad_files_.clear();
@@ -1552,8 +1515,10 @@ Symbol DescriptorPool::Tables::FindByNameHelper(const DescriptorPool* pool,
}
inline const FileDescriptor* DescriptorPool::Tables::FindFile(
- StringPiece key) const {
- return FindPtrOrNull(files_by_name_, key);
+ y_absl::string_view key) const {
+ auto it = files_by_name_.find(key);
+ if (it == files_by_name_.end()) return nullptr;
+ return *it;
}
inline const FieldDescriptor* FileDescriptorTables::FindFieldByNumber(
@@ -1565,12 +1530,8 @@ inline const FieldDescriptor* FileDescriptorTables::FindFieldByNumber(
return parent->field(number - 1);
}
- Symbol::QueryKey query;
- query.parent = parent;
- query.field_number = number;
-
- auto it = fields_by_number_.find(query);
- return it == fields_by_number_.end() ? nullptr : it->field_descriptor();
+ auto it = fields_by_number_.find(ParentNumberQuery{{parent, number}});
+ return it == fields_by_number_.end() ? nullptr : *it;
}
const void* FileDescriptorTables::FindParentForFieldsByMap(
@@ -1603,13 +1564,15 @@ void FileDescriptorTables::FieldsByLowercaseNamesLazyInitInternal() const {
}
inline const FieldDescriptor* FileDescriptorTables::FindFieldByLowercaseName(
- const void* parent, StringPiece lowercase_name) const {
- internal::call_once(
- fields_by_lowercase_name_once_,
- &FileDescriptorTables::FieldsByLowercaseNamesLazyInitStatic, this);
- return FindPtrOrNull(
- *fields_by_lowercase_name_.load(std::memory_order_acquire),
- PointerStringPair(parent, lowercase_name));
+ const void* parent, y_absl::string_view lowercase_name) const {
+ y_absl::call_once(fields_by_lowercase_name_once_,
+ &FileDescriptorTables::FieldsByLowercaseNamesLazyInitStatic,
+ this);
+ const auto* fields =
+ fields_by_lowercase_name_.load(std::memory_order_acquire);
+ auto it = fields->find({parent, lowercase_name});
+ if (it == fields->end()) return nullptr;
+ return it->second;
}
void FileDescriptorTables::FieldsByCamelcaseNamesLazyInitStatic(
@@ -1629,13 +1592,14 @@ void FileDescriptorTables::FieldsByCamelcaseNamesLazyInitInternal() const {
}
inline const FieldDescriptor* FileDescriptorTables::FindFieldByCamelcaseName(
- const void* parent, StringPiece camelcase_name) const {
- internal::call_once(
- fields_by_camelcase_name_once_,
- FileDescriptorTables::FieldsByCamelcaseNamesLazyInitStatic, this);
- return FindPtrOrNull(
- *fields_by_camelcase_name_.load(std::memory_order_acquire),
- PointerStringPair(parent, camelcase_name));
+ const void* parent, y_absl::string_view camelcase_name) const {
+ y_absl::call_once(fields_by_camelcase_name_once_,
+ FileDescriptorTables::FieldsByCamelcaseNamesLazyInitStatic,
+ this);
+ auto* fields = fields_by_camelcase_name_.load(std::memory_order_acquire);
+ auto it = fields->find({parent, camelcase_name});
+ if (it == fields->end()) return nullptr;
+ return it->second;
}
inline const EnumValueDescriptor* FileDescriptorTables::FindEnumValueByNumber(
@@ -1648,13 +1612,8 @@ inline const EnumValueDescriptor* FileDescriptorTables::FindEnumValueByNumber(
return parent->value(number - base);
}
- Symbol::QueryKey query;
- query.parent = parent;
- query.field_number = number;
-
- auto it = enum_values_by_number_.find(query);
- return it == enum_values_by_number_.end() ? nullptr
- : it->enum_value_descriptor();
+ auto it = enum_values_by_number_.find(ParentNumberQuery{{parent, number}});
+ return it == enum_values_by_number_.end() ? nullptr : *it;
}
inline const EnumValueDescriptor*
@@ -1668,34 +1627,30 @@ FileDescriptorTables::FindEnumValueByNumberCreatingIfUnknown(
}
}
- Symbol::QueryKey query;
- query.parent = parent;
- query.field_number = number;
+ const ParentNumberQuery query{{parent, number}};
// Second try, with reader lock held on unknown enum values: common case.
{
- ReaderMutexLock l(&unknown_enum_values_mu_);
+ y_absl::ReaderMutexLock l(&unknown_enum_values_mu_);
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();
+ if (it != unknown_enum_values_by_number_.end()) {
+ return *it;
}
}
// If not found, try again with writer lock held, and create new descriptor if
// necessary.
{
- WriterMutexLock l(&unknown_enum_values_mu_);
+ y_absl::WriterMutexLock l(&unknown_enum_values_mu_);
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();
+ if (it != unknown_enum_values_by_number_.end()) {
+ return *it;
}
// Create an EnumValueDescriptor dynamically. We don't insert it into the
// 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(
+ TProtoStringType enum_value_name = y_absl::StrFormat(
"UNKNOWN_ENUM_VALUE_%s_%d", parent->name().c_str(), number);
auto* pool = DescriptorPool::generated_pool();
auto* tables = const_cast<DescriptorPool::Tables*>(pool->tables_.get());
@@ -1705,24 +1660,26 @@ FileDescriptorTables::FindEnumValueByNumberCreatingIfUnknown(
{
// Must lock the pool because we will do allocations in the shared arena.
- MutexLockMaybe l2(pool->mutex_);
+ y_absl::MutexLockMaybe l2(pool->mutex_);
alloc.FinalizePlanning(tables);
}
EnumValueDescriptor* result = alloc.AllocateArray<EnumValueDescriptor>(1);
result->all_names_ = alloc.AllocateStrings(
enum_value_name,
- StrCat(parent->full_name(), ".", enum_value_name));
+ y_absl::StrCat(parent->full_name(), ".", enum_value_name));
result->number_ = number;
result->type_ = parent;
result->options_ = &EnumValueOptions::default_instance();
- unknown_enum_values_by_number_.insert(Symbol::EnumValue(result, 0));
+ unknown_enum_values_by_number_.insert(result);
return result;
}
}
inline const FieldDescriptor* DescriptorPool::Tables::FindExtension(
const Descriptor* extendee, int number) const {
- return FindPtrOrNull(extensions_, std::make_pair(extendee, number));
+ auto it = extensions_.find({extendee, number});
+ if (it == extensions_.end()) return nullptr;
+ return it->second;
}
inline void DescriptorPool::Tables::FindAllExtensions(
@@ -1737,9 +1694,9 @@ inline void DescriptorPool::Tables::FindAllExtensions(
// -------------------------------------------------------------------
-bool DescriptorPool::Tables::AddSymbol(const TProtoStringType& full_name,
+bool DescriptorPool::Tables::AddSymbol(y_absl::string_view full_name,
Symbol symbol) {
- GOOGLE_DCHECK_EQ(full_name, symbol.full_name());
+ Y_ABSL_DCHECK_EQ(full_name, symbol.full_name());
if (symbols_by_name_.insert(symbol).second) {
symbols_after_checkpoint_.push_back(symbol);
return true;
@@ -1749,15 +1706,15 @@ bool DescriptorPool::Tables::AddSymbol(const TProtoStringType& full_name,
}
bool FileDescriptorTables::AddAliasUnderParent(const void* parent,
- const TProtoStringType& name,
+ y_absl::string_view name,
Symbol symbol) {
- GOOGLE_DCHECK_EQ(name, symbol.parent_name_key().second);
- GOOGLE_DCHECK_EQ(parent, symbol.parent_name_key().first);
+ Y_ABSL_DCHECK_EQ(name, symbol.parent_name_key().second);
+ Y_ABSL_DCHECK_EQ(parent, symbol.parent_name_key().first);
return symbols_by_parent_.insert(symbol).second;
}
bool DescriptorPool::Tables::AddFile(const FileDescriptor* file) {
- if (InsertIfNotPresent(&files_by_name_, file->name(), file)) {
+ if (files_by_name_.insert(file).second) {
files_after_checkpoint_.push_back(file);
return true;
} else {
@@ -1780,7 +1737,7 @@ bool FileDescriptorTables::AddFieldByNumber(FieldDescriptor* field) {
return field->containing_type()->field(field->number() - 1) == field;
}
- return fields_by_number_.insert(Symbol(field)).second;
+ return fields_by_number_.insert(field).second;
}
bool FileDescriptorTables::AddEnumValueByNumber(EnumValueDescriptor* value) {
@@ -1790,13 +1747,14 @@ bool FileDescriptorTables::AddEnumValueByNumber(EnumValueDescriptor* value) {
value->number() <=
static_cast<arc_i64>(base) + value->type()->sequential_value_limit_)
return true;
- return enum_values_by_number_.insert(Symbol::EnumValue(value, 0)).second;
+ return enum_values_by_number_.insert(value).second;
}
bool DescriptorPool::Tables::AddExtension(const FieldDescriptor* field) {
- DescriptorIntPair key(field->containing_type(), field->number());
- if (InsertIfNotPresent(&extensions_, key, field)) {
- extensions_after_checkpoint_.push_back(key);
+ auto it_inserted =
+ extensions_.insert({{field->containing_type(), field->number()}, field});
+ if (it_inserted.second) {
+ extensions_after_checkpoint_.push_back(it_inserted.first->first);
return true;
} else {
return false;
@@ -1842,7 +1800,7 @@ void FileDescriptorTables::BuildLocationsByPath(
std::pair<const FileDescriptorTables*, const SourceCodeInfo*>* p) {
for (int i = 0, len = p->second->location_size(); i < len; ++i) {
const SourceCodeInfo_Location* loc = &p->second->location().Get(i);
- p->first->locations_by_path_[Join(loc->path(), ",")] = loc;
+ p->first->locations_by_path_[y_absl::StrJoin(loc->path(), ",")] = loc;
}
}
@@ -1850,9 +1808,11 @@ const SourceCodeInfo_Location* FileDescriptorTables::GetSourceLocation(
const std::vector<int>& path, const SourceCodeInfo* info) const {
std::pair<const FileDescriptorTables*, const SourceCodeInfo*> p(
std::make_pair(this, info));
- internal::call_once(locations_by_path_once_,
- FileDescriptorTables::BuildLocationsByPath, &p);
- return FindPtrOrNull(locations_by_path_, Join(path, ","));
+ y_absl::call_once(locations_by_path_once_,
+ FileDescriptorTables::BuildLocationsByPath, &p);
+ auto it = locations_by_path_.find(y_absl::StrJoin(path, ","));
+ if (it == locations_by_path_.end()) return nullptr;
+ return it->second;
}
// ===================================================================
@@ -1870,11 +1830,12 @@ DescriptorPool::DescriptorPool()
lazily_build_dependencies_(false),
allow_unknown_(false),
enforce_weak_(false),
- disallow_enforce_utf8_(false) {}
+ disallow_enforce_utf8_(false),
+ deprecated_legacy_json_field_conflicts_(false) {}
DescriptorPool::DescriptorPool(DescriptorDatabase* fallback_database,
ErrorCollector* error_collector)
- : mutex_(new internal::WrappedMutex),
+ : mutex_(new y_absl::Mutex),
fallback_database_(fallback_database),
default_error_collector_(error_collector),
underlay_(nullptr),
@@ -1883,7 +1844,8 @@ DescriptorPool::DescriptorPool(DescriptorDatabase* fallback_database,
lazily_build_dependencies_(false),
allow_unknown_(false),
enforce_weak_(false),
- disallow_enforce_utf8_(false) {}
+ disallow_enforce_utf8_(false),
+ deprecated_legacy_json_field_conflicts_(false) {}
DescriptorPool::DescriptorPool(const DescriptorPool* underlay)
: mutex_(nullptr),
@@ -1895,7 +1857,8 @@ DescriptorPool::DescriptorPool(const DescriptorPool* underlay)
lazily_build_dependencies_(false),
allow_unknown_(false),
enforce_weak_(false),
- disallow_enforce_utf8_(false) {}
+ disallow_enforce_utf8_(false),
+ deprecated_legacy_json_field_conflicts_(false) {}
DescriptorPool::~DescriptorPool() {
if (mutex_ != nullptr) delete mutex_;
@@ -1908,17 +1871,18 @@ void DescriptorPool::InternalDontEnforceDependencies() {
enforce_dependencies_ = false;
}
-void DescriptorPool::AddUnusedImportTrackFile(ConstStringParam file_name,
+void DescriptorPool::AddUnusedImportTrackFile(y_absl::string_view file_name,
bool is_error) {
- unused_import_track_files_[TProtoStringType(file_name)] = is_error;
+ unused_import_track_files_[file_name] = is_error;
}
+
void DescriptorPool::ClearUnusedImportTrackFiles() {
unused_import_track_files_.clear();
}
-bool DescriptorPool::InternalIsFileLoaded(ConstStringParam filename) const {
- MutexLockMaybe lock(mutex_);
+bool DescriptorPool::InternalIsFileLoaded(y_absl::string_view filename) const {
+ y_absl::MutexLockMaybe lock(mutex_);
return tables_->FindFile(filename) != nullptr;
}
@@ -1953,7 +1917,10 @@ DescriptorPool* DescriptorPool::internal_generated_pool() {
const DescriptorPool* DescriptorPool::generated_pool() {
const DescriptorPool* pool = internal_generated_pool();
- // Ensure that descriptor.proto has been registered in the generated pool.
+ // Ensure that descriptor.proto gets registered in the generated pool. It is a
+ // special case because it is included in the full runtime. We have to avoid
+ // registering it pre-main, because we need to ensure that the linker
+ // --gc-sections step can strip out the full runtime if it is unused.
DescriptorProto::descriptor();
return pool;
}
@@ -1983,7 +1950,7 @@ void DescriptorPool::InternalAddGeneratedFile(
// Therefore, when we parse one, we have to be very careful to avoid using
// any descriptor-based operations, since this might cause infinite recursion
// or deadlock.
- GOOGLE_CHECK(GeneratedDatabase()->Add(encoded_file_descriptor, size));
+ Y_ABSL_CHECK(GeneratedDatabase()->Add(encoded_file_descriptor, size));
}
@@ -1994,8 +1961,8 @@ void DescriptorPool::InternalAddGeneratedFile(
// there's nothing more important to do (read: never).
const FileDescriptor* DescriptorPool::FindFileByName(
- ConstStringParam name) const {
- MutexLockMaybe lock(mutex_);
+ y_absl::string_view name) const {
+ y_absl::MutexLockMaybe lock(mutex_);
if (fallback_database_ != nullptr) {
tables_->known_bad_symbols_.clear();
tables_->known_bad_files_.clear();
@@ -2014,8 +1981,8 @@ const FileDescriptor* DescriptorPool::FindFileByName(
}
const FileDescriptor* DescriptorPool::FindFileContainingSymbol(
- ConstStringParam symbol_name) const {
- MutexLockMaybe lock(mutex_);
+ y_absl::string_view symbol_name) const {
+ y_absl::MutexLockMaybe lock(mutex_);
if (fallback_database_ != nullptr) {
tables_->known_bad_symbols_.clear();
tables_->known_bad_files_.clear();
@@ -2035,12 +2002,12 @@ const FileDescriptor* DescriptorPool::FindFileContainingSymbol(
}
const Descriptor* DescriptorPool::FindMessageTypeByName(
- ConstStringParam name) const {
+ y_absl::string_view name) const {
return tables_->FindByNameHelper(this, name).descriptor();
}
const FieldDescriptor* DescriptorPool::FindFieldByName(
- ConstStringParam name) const {
+ y_absl::string_view name) const {
if (const FieldDescriptor* field =
tables_->FindByNameHelper(this, name).field_descriptor()) {
if (!field->is_extension()) {
@@ -2051,7 +2018,7 @@ const FieldDescriptor* DescriptorPool::FindFieldByName(
}
const FieldDescriptor* DescriptorPool::FindExtensionByName(
- ConstStringParam name) const {
+ y_absl::string_view name) const {
if (const FieldDescriptor* field =
tables_->FindByNameHelper(this, name).field_descriptor()) {
if (field->is_extension()) {
@@ -2062,27 +2029,27 @@ const FieldDescriptor* DescriptorPool::FindExtensionByName(
}
const OneofDescriptor* DescriptorPool::FindOneofByName(
- ConstStringParam name) const {
+ y_absl::string_view name) const {
return tables_->FindByNameHelper(this, name).oneof_descriptor();
}
const EnumDescriptor* DescriptorPool::FindEnumTypeByName(
- ConstStringParam name) const {
+ y_absl::string_view name) const {
return tables_->FindByNameHelper(this, name).enum_descriptor();
}
const EnumValueDescriptor* DescriptorPool::FindEnumValueByName(
- ConstStringParam name) const {
+ y_absl::string_view name) const {
return tables_->FindByNameHelper(this, name).enum_value_descriptor();
}
const ServiceDescriptor* DescriptorPool::FindServiceByName(
- ConstStringParam name) const {
+ y_absl::string_view name) const {
return tables_->FindByNameHelper(this, name).service_descriptor();
}
const MethodDescriptor* DescriptorPool::FindMethodByName(
- ConstStringParam name) const {
+ y_absl::string_view name) const {
return tables_->FindByNameHelper(this, name).method_descriptor();
}
@@ -2092,13 +2059,13 @@ const FieldDescriptor* DescriptorPool::FindExtensionByNumber(
// A faster path to reduce lock contention in finding extensions, assuming
// most extensions will be cache hit.
if (mutex_ != nullptr) {
- ReaderMutexLock lock(mutex_);
+ y_absl::ReaderMutexLock lock(mutex_);
const FieldDescriptor* result = tables_->FindExtension(extendee, number);
if (result != nullptr) {
return result;
}
}
- MutexLockMaybe lock(mutex_);
+ y_absl::MutexLockMaybe lock(mutex_);
if (fallback_database_ != nullptr) {
tables_->known_bad_symbols_.clear();
tables_->known_bad_files_.clear();
@@ -2138,7 +2105,7 @@ const FieldDescriptor* DescriptorPool::InternalFindExtensionByNumberNoLock(
}
const FieldDescriptor* DescriptorPool::FindExtensionByPrintableName(
- const Descriptor* extendee, ConstStringParam printable_name) const {
+ const Descriptor* extendee, y_absl::string_view printable_name) const {
if (extendee->extension_range_count() == 0) return nullptr;
const FieldDescriptor* result = FindExtensionByName(printable_name);
if (result != nullptr && result->containing_type() == extendee) {
@@ -2167,7 +2134,7 @@ const FieldDescriptor* DescriptorPool::FindExtensionByPrintableName(
void DescriptorPool::FindAllExtensions(
const Descriptor* extendee,
std::vector<const FieldDescriptor*>* out) const {
- MutexLockMaybe lock(mutex_);
+ y_absl::MutexLockMaybe lock(mutex_);
if (fallback_database_ != nullptr) {
tables_->known_bad_symbols_.clear();
tables_->known_bad_files_.clear();
@@ -2208,7 +2175,7 @@ const FieldDescriptor* Descriptor::FindFieldByNumber(int key) const {
}
const FieldDescriptor* Descriptor::FindFieldByLowercaseName(
- ConstStringParam key) const {
+ y_absl::string_view key) const {
const FieldDescriptor* result =
file()->tables_->FindFieldByLowercaseName(this, key);
if (result == nullptr || result->is_extension()) {
@@ -2219,7 +2186,7 @@ const FieldDescriptor* Descriptor::FindFieldByLowercaseName(
}
const FieldDescriptor* Descriptor::FindFieldByCamelcaseName(
- ConstStringParam key) const {
+ y_absl::string_view key) const {
const FieldDescriptor* result =
file()->tables_->FindFieldByCamelcaseName(this, key);
if (result == nullptr || result->is_extension()) {
@@ -2229,25 +2196,27 @@ const FieldDescriptor* Descriptor::FindFieldByCamelcaseName(
}
}
-const FieldDescriptor* Descriptor::FindFieldByName(ConstStringParam key) const {
+const FieldDescriptor* Descriptor::FindFieldByName(
+ y_absl::string_view key) const {
const FieldDescriptor* field =
file()->tables_->FindNestedSymbol(this, key).field_descriptor();
return field != nullptr && !field->is_extension() ? field : nullptr;
}
-const OneofDescriptor* Descriptor::FindOneofByName(ConstStringParam key) const {
+const OneofDescriptor* Descriptor::FindOneofByName(
+ y_absl::string_view key) const {
return file()->tables_->FindNestedSymbol(this, key).oneof_descriptor();
}
const FieldDescriptor* Descriptor::FindExtensionByName(
- ConstStringParam key) const {
+ y_absl::string_view key) const {
const FieldDescriptor* field =
file()->tables_->FindNestedSymbol(this, key).field_descriptor();
return field != nullptr && field->is_extension() ? field : nullptr;
}
const FieldDescriptor* Descriptor::FindExtensionByLowercaseName(
- ConstStringParam key) const {
+ y_absl::string_view key) const {
const FieldDescriptor* result =
file()->tables_->FindFieldByLowercaseName(this, key);
if (result == nullptr || !result->is_extension()) {
@@ -2258,7 +2227,7 @@ const FieldDescriptor* Descriptor::FindExtensionByLowercaseName(
}
const FieldDescriptor* Descriptor::FindExtensionByCamelcaseName(
- ConstStringParam key) const {
+ y_absl::string_view key) const {
const FieldDescriptor* result =
file()->tables_->FindFieldByCamelcaseName(this, key);
if (result == nullptr || !result->is_extension()) {
@@ -2268,34 +2237,35 @@ const FieldDescriptor* Descriptor::FindExtensionByCamelcaseName(
}
}
-const Descriptor* Descriptor::FindNestedTypeByName(ConstStringParam key) const {
+const Descriptor* Descriptor::FindNestedTypeByName(
+ y_absl::string_view key) const {
return file()->tables_->FindNestedSymbol(this, key).descriptor();
}
const EnumDescriptor* Descriptor::FindEnumTypeByName(
- ConstStringParam key) const {
+ y_absl::string_view key) const {
return file()->tables_->FindNestedSymbol(this, key).enum_descriptor();
}
const EnumValueDescriptor* Descriptor::FindEnumValueByName(
- ConstStringParam key) const {
+ y_absl::string_view key) const {
return file()->tables_->FindNestedSymbol(this, key).enum_value_descriptor();
}
const FieldDescriptor* Descriptor::map_key() const {
if (!options().map_entry()) return nullptr;
- GOOGLE_DCHECK_EQ(field_count(), 2);
+ Y_ABSL_DCHECK_EQ(field_count(), 2);
return field(0);
}
const FieldDescriptor* Descriptor::map_value() const {
if (!options().map_entry()) return nullptr;
- GOOGLE_DCHECK_EQ(field_count(), 2);
+ Y_ABSL_DCHECK_EQ(field_count(), 2);
return field(1);
}
const EnumValueDescriptor* EnumDescriptor::FindValueByName(
- ConstStringParam key) const {
+ y_absl::string_view key) const {
return file()->tables_->FindNestedSymbol(this, key).enum_value_descriptor();
}
@@ -2309,39 +2279,39 @@ const EnumValueDescriptor* EnumDescriptor::FindValueByNumberCreatingIfUnknown(
}
const MethodDescriptor* ServiceDescriptor::FindMethodByName(
- ConstStringParam key) const {
+ y_absl::string_view key) const {
return file()->tables_->FindNestedSymbol(this, key).method_descriptor();
}
const Descriptor* FileDescriptor::FindMessageTypeByName(
- ConstStringParam key) const {
+ y_absl::string_view key) const {
return tables_->FindNestedSymbol(this, key).descriptor();
}
const EnumDescriptor* FileDescriptor::FindEnumTypeByName(
- ConstStringParam key) const {
+ y_absl::string_view key) const {
return tables_->FindNestedSymbol(this, key).enum_descriptor();
}
const EnumValueDescriptor* FileDescriptor::FindEnumValueByName(
- ConstStringParam key) const {
+ y_absl::string_view key) const {
return tables_->FindNestedSymbol(this, key).enum_value_descriptor();
}
const ServiceDescriptor* FileDescriptor::FindServiceByName(
- ConstStringParam key) const {
+ y_absl::string_view key) const {
return tables_->FindNestedSymbol(this, key).service_descriptor();
}
const FieldDescriptor* FileDescriptor::FindExtensionByName(
- ConstStringParam key) const {
+ y_absl::string_view key) const {
const FieldDescriptor* field =
tables_->FindNestedSymbol(this, key).field_descriptor();
return field != nullptr && field->is_extension() ? field : nullptr;
}
const FieldDescriptor* FileDescriptor::FindExtensionByLowercaseName(
- ConstStringParam key) const {
+ y_absl::string_view key) const {
const FieldDescriptor* result = tables_->FindFieldByLowercaseName(this, key);
if (result == nullptr || !result->is_extension()) {
return nullptr;
@@ -2351,7 +2321,7 @@ const FieldDescriptor* FileDescriptor::FindExtensionByLowercaseName(
}
const FieldDescriptor* FileDescriptor::FindExtensionByCamelcaseName(
- ConstStringParam key) const {
+ y_absl::string_view key) const {
const FieldDescriptor* result = tables_->FindFieldByCamelcaseName(this, key);
if (result == nullptr || !result->is_extension()) {
return nullptr;
@@ -2408,22 +2378,28 @@ EnumDescriptor::FindReservedRangeContainingNumber(int number) const {
// -------------------------------------------------------------------
bool DescriptorPool::TryFindFileInFallbackDatabase(
- StringPiece name) const {
+ y_absl::string_view name) const {
if (fallback_database_ == nullptr) return false;
- auto name_string = TProtoStringType(name);
- if (tables_->known_bad_files_.count(name_string) > 0) return false;
+ if (tables_->known_bad_files_.contains(name)) return false;
- FileDescriptorProto file_proto;
- if (!fallback_database_->FindFileByName(name_string, &file_proto) ||
- BuildFileFromDatabase(file_proto) == nullptr) {
- tables_->known_bad_files_.insert(std::move(name_string));
+ // NOINLINE to reduce the stack cost of the operation in the caller.
+ const auto find_file = [](DescriptorDatabase& database,
+ y_absl::string_view filename,
+ FileDescriptorProto& output) PROTOBUF_NOINLINE {
+ return database.FindFileByName(TProtoStringType(filename), &output);
+ };
+
+ auto file_proto = y_absl::make_unique<FileDescriptorProto>();
+ if (!find_file(*fallback_database_, name, *file_proto) ||
+ BuildFileFromDatabase(*file_proto) == nullptr) {
+ tables_->known_bad_files_.emplace(name);
return false;
}
return true;
}
-bool DescriptorPool::IsSubSymbolOfBuiltType(StringPiece name) const {
+bool DescriptorPool::IsSubSymbolOfBuiltType(y_absl::string_view name) const {
auto prefix = TProtoStringType(name);
for (;;) {
TProtoStringType::size_type dot_pos = prefix.find_last_of('.');
@@ -2446,13 +2422,13 @@ bool DescriptorPool::IsSubSymbolOfBuiltType(StringPiece name) const {
}
bool DescriptorPool::TryFindSymbolInFallbackDatabase(
- StringPiece name) const {
+ y_absl::string_view name) const {
if (fallback_database_ == nullptr) return false;
- auto name_string = TProtoStringType(name);
- if (tables_->known_bad_symbols_.count(name_string) > 0) return false;
+ if (tables_->known_bad_symbols_.contains(name)) return false;
- FileDescriptorProto file_proto;
+ TProtoStringType name_string(name);
+ auto file_proto = y_absl::make_unique<FileDescriptorProto>();
if ( // We skip looking in the fallback database if the name is a sub-symbol
// of any descriptor that already exists in the descriptor pool (except
// for package descriptors). This is valid because all symbols except
@@ -2472,15 +2448,16 @@ bool DescriptorPool::TryFindSymbolInFallbackDatabase(
IsSubSymbolOfBuiltType(name)
// Look up file containing this symbol in fallback database.
- || !fallback_database_->FindFileContainingSymbol(name_string, &file_proto)
+ || !fallback_database_->FindFileContainingSymbol(name_string,
+ file_proto.get())
// Check if we've already built this file. If so, it apparently doesn't
// contain the symbol we're looking for. Some DescriptorDatabases
// return false positives.
- || tables_->FindFile(file_proto.name()) != nullptr
+ || tables_->FindFile(file_proto->name()) != nullptr
// Build the file.
- || BuildFileFromDatabase(file_proto) == nullptr) {
+ || BuildFileFromDatabase(*file_proto) == nullptr) {
tables_->known_bad_symbols_.insert(std::move(name_string));
return false;
}
@@ -2492,20 +2469,20 @@ bool DescriptorPool::TryFindExtensionInFallbackDatabase(
const Descriptor* containing_type, int field_number) const {
if (fallback_database_ == nullptr) return false;
- FileDescriptorProto file_proto;
+ auto file_proto = y_absl::make_unique<FileDescriptorProto>();
if (!fallback_database_->FindFileContainingExtension(
- containing_type->full_name(), field_number, &file_proto)) {
+ containing_type->full_name(), field_number, file_proto.get())) {
return false;
}
- if (tables_->FindFile(file_proto.name()) != nullptr) {
+ if (tables_->FindFile(file_proto->name()) != nullptr) {
// We've already loaded this file, and it apparently doesn't contain the
// extension we're looking for. Some DescriptorDatabases return false
// positives.
return false;
}
- if (BuildFileFromDatabase(file_proto) == nullptr) {
+ if (BuildFileFromDatabase(*file_proto) == nullptr) {
return false;
}
@@ -2520,28 +2497,28 @@ bool FieldDescriptor::is_map_message_type() const {
TProtoStringType FieldDescriptor::DefaultValueAsString(
bool quote_string_type) const {
- GOOGLE_CHECK(has_default_value()) << "No default value";
+ Y_ABSL_CHECK(has_default_value()) << "No default value";
switch (cpp_type()) {
case CPPTYPE_INT32:
- return StrCat(default_value_arc_i32());
+ return y_absl::StrCat(default_value_arc_i32());
case CPPTYPE_INT64:
- return StrCat(default_value_arc_i64());
+ return y_absl::StrCat(default_value_arc_i64());
case CPPTYPE_UINT32:
- return StrCat(default_value_arc_ui32());
+ return y_absl::StrCat(default_value_arc_ui32());
case CPPTYPE_UINT64:
- return StrCat(default_value_arc_ui64());
+ return y_absl::StrCat(default_value_arc_ui64());
case CPPTYPE_FLOAT:
- return SimpleFtoa(default_value_float());
+ return io::SimpleFtoa(default_value_float());
case CPPTYPE_DOUBLE:
- return SimpleDtoa(default_value_double());
+ return io::SimpleDtoa(default_value_double());
case CPPTYPE_BOOL:
return default_value_bool() ? "true" : "false";
case CPPTYPE_STRING:
if (quote_string_type) {
- return "\"" + CEscape(default_value_string()) + "\"";
+ return y_absl::StrCat("\"", y_absl::CEscape(default_value_string()), "\"");
} else {
if (type() == TYPE_BYTES) {
- return CEscape(default_value_string());
+ return y_absl::CEscape(default_value_string());
} else {
return default_value_string();
}
@@ -2549,20 +2526,17 @@ TProtoStringType FieldDescriptor::DefaultValueAsString(
case CPPTYPE_ENUM:
return default_value_enum()->name();
case CPPTYPE_MESSAGE:
- GOOGLE_LOG(DFATAL) << "Messages can't have default values!";
+ Y_ABSL_DLOG(FATAL) << "Messages can't have default values!";
break;
}
- GOOGLE_LOG(FATAL) << "Can't get here: failed to get default value as string";
+ Y_ABSL_LOG(FATAL) << "Can't get here: failed to get default value as string";
return "";
}
// CopyTo methods ====================================================
void FileDescriptor::CopyTo(FileDescriptorProto* proto) const {
- proto->set_name(name());
- if (!package().empty()) proto->set_package(package());
- // TODO(liujisi): Also populate when syntax="proto2".
- if (syntax() == SYNTAX_PROTO3) proto->set_syntax(SyntaxName(syntax()));
+ CopyHeadingTo(proto);
for (int i = 0; i < dependency_count(); i++) {
proto->add_dependency(dependency(i)->name());
@@ -2588,16 +2562,28 @@ void FileDescriptor::CopyTo(FileDescriptorProto* proto) const {
for (int i = 0; i < extension_count(); i++) {
extension(i)->CopyTo(proto->add_extension());
}
+}
+
+void FileDescriptor::CopyHeadingTo(FileDescriptorProto* proto) const {
+ proto->set_name(name());
+ if (!package().empty()) {
+ proto->set_package(package());
+ }
+ // TODO(liujisi): Also populate when syntax="proto2".
+ if (syntax() == SYNTAX_PROTO3
+ ) {
+ proto->set_syntax(SyntaxName(syntax()));
+ }
if (&options() != &FileOptions::default_instance()) {
- proto->mutable_options()->CopyFrom(options());
+ *proto->mutable_options() = options();
}
}
void FileDescriptor::CopyJsonNameTo(FileDescriptorProto* proto) const {
if (message_type_count() != proto->message_type_size() ||
extension_count() != proto->extension_size()) {
- GOOGLE_LOG(ERROR) << "Cannot copy json_name to a proto of a different size.";
+ Y_ABSL_LOG(ERROR) << "Cannot copy json_name to a proto of a different size.";
return;
}
for (int i = 0; i < message_type_count(); i++) {
@@ -2654,7 +2640,7 @@ void Descriptor::CopyJsonNameTo(DescriptorProto* proto) const {
if (field_count() != proto->field_size() ||
nested_type_count() != proto->nested_type_size() ||
extension_count() != proto->extension_size()) {
- GOOGLE_LOG(ERROR) << "Cannot copy json_name to a proto of a different size.";
+ Y_ABSL_LOG(ERROR) << "Cannot copy json_name to a proto of a different size.";
return;
}
for (int i = 0; i < field_count(); i++) {
@@ -2680,9 +2666,9 @@ void FieldDescriptor::CopyTo(FieldDescriptorProto* proto) const {
// Some compilers do not allow static_cast directly between two enum types,
// so we must cast to int first.
proto->set_label(static_cast<FieldDescriptorProto::Label>(
- implicit_cast<int>(label())));
+ y_absl::implicit_cast<int>(label())));
proto->set_type(static_cast<FieldDescriptorProto::Type>(
- implicit_cast<int>(type())));
+ y_absl::implicit_cast<int>(type())));
if (is_extension()) {
if (!containing_type()->is_unqualified_placeholder_) {
@@ -2836,11 +2822,11 @@ bool RetrieveOptionsAssumingRightPool(
}
TProtoStringType name;
if (field->is_extension()) {
- name = "(." + field->full_name() + ")";
+ name = y_absl::StrCat("(.", field->full_name(), ")");
} else {
name = field->name();
}
- option_entries->push_back(name + " = " + fieldval);
+ option_entries->push_back(y_absl::StrCat(name, " = ", fieldval));
}
}
return !option_entries->empty();
@@ -2876,8 +2862,8 @@ bool RetrieveOptions(int depth, const Message& options,
return RetrieveOptionsAssumingRightPool(depth, *dynamic_options,
option_entries);
} else {
- GOOGLE_LOG(ERROR) << "Found invalid proto option data for: "
- << options.GetDescriptor()->full_name();
+ Y_ABSL_LOG(ERROR) << "Found invalid proto option data for: "
+ << options.GetDescriptor()->full_name();
return RetrieveOptionsAssumingRightPool(depth, options, option_entries);
}
}
@@ -2889,7 +2875,7 @@ bool FormatBracketedOptions(int depth, const Message& options,
const DescriptorPool* pool, TProtoStringType* output) {
std::vector<TProtoStringType> all_options;
if (RetrieveOptions(depth, options, pool, &all_options)) {
- output->append(Join(all_options, ", "));
+ output->append(y_absl::StrJoin(all_options, ", "));
}
return !all_options.empty();
}
@@ -2901,7 +2887,7 @@ bool FormatLineOptions(int depth, const Message& options,
std::vector<TProtoStringType> all_options;
if (RetrieveOptions(depth, options, pool, &all_options)) {
for (const TProtoStringType& option : all_options) {
- strings::SubstituteAndAppend(output, "$0option $1;\n", prefix, option);
+ y_absl::SubstituteAndAppend(output, "$0option $1;\n", prefix, option);
}
}
return !all_options.empty();
@@ -2933,18 +2919,17 @@ class SourceLocationCommentPrinter {
// Detached leading comments.
for (const TProtoStringType& leading_detached_comment :
source_loc_.leading_detached_comments) {
- *output += FormatComment(leading_detached_comment);
- *output += "\n";
+ y_absl::StrAppend(output, FormatComment(leading_detached_comment), "\n");
}
// Attached leading comments.
if (!source_loc_.leading_comments.empty()) {
- *output += FormatComment(source_loc_.leading_comments);
+ y_absl::StrAppend(output, FormatComment(source_loc_.leading_comments));
}
}
}
void AddPostComment(TProtoStringType* output) {
if (have_source_loc_ && source_loc_.trailing_comments.size() > 0) {
- *output += FormatComment(source_loc_.trailing_comments);
+ y_absl::StrAppend(output, FormatComment(source_loc_.trailing_comments));
}
}
@@ -2952,11 +2937,11 @@ class SourceLocationCommentPrinter {
// the DebugString() output.
TProtoStringType FormatComment(const TProtoStringType& comment_text) {
TProtoStringType stripped_comment = comment_text;
- StripWhitespace(&stripped_comment);
- std::vector<TProtoStringType> lines = Split(stripped_comment, "\n");
+ y_absl::StripAsciiWhitespace(&stripped_comment);
+ std::vector<TProtoStringType> lines = y_absl::StrSplit(stripped_comment, "\n");
TProtoStringType output;
for (const TProtoStringType& line : lines) {
- strings::SubstituteAndAppend(&output, "$0// $1\n", prefix_, line);
+ y_absl::SubstituteAndAppend(&output, "$0// $1\n", prefix_, line);
}
return output;
}
@@ -2985,7 +2970,7 @@ TProtoStringType FileDescriptor::DebugStringWithOptions(
SourceLocationCommentPrinter syntax_comment(this, path, "",
debug_string_options);
syntax_comment.AddPreComment(&contents);
- strings::SubstituteAndAppend(&contents, "syntax = \"$0\";\n\n",
+ y_absl::SubstituteAndAppend(&contents, "syntax = \"$0\";\n\n",
SyntaxName(syntax()));
syntax_comment.AddPostComment(&contents);
}
@@ -2993,22 +2978,20 @@ TProtoStringType FileDescriptor::DebugStringWithOptions(
SourceLocationCommentPrinter comment_printer(this, "", debug_string_options);
comment_printer.AddPreComment(&contents);
- std::set<int> public_dependencies;
- std::set<int> weak_dependencies;
- public_dependencies.insert(public_dependencies_,
- public_dependencies_ + public_dependency_count_);
- weak_dependencies.insert(weak_dependencies_,
- weak_dependencies_ + weak_dependency_count_);
+ y_absl::flat_hash_set<int> public_dependencies(
+ public_dependencies_, public_dependencies_ + public_dependency_count_);
+ y_absl::flat_hash_set<int> weak_dependencies(
+ weak_dependencies_, weak_dependencies_ + weak_dependency_count_);
for (int i = 0; i < dependency_count(); i++) {
- if (public_dependencies.count(i) > 0) {
- strings::SubstituteAndAppend(&contents, "import public \"$0\";\n",
+ if (public_dependencies.contains(i)) {
+ y_absl::SubstituteAndAppend(&contents, "import public \"$0\";\n",
dependency(i)->name());
- } else if (weak_dependencies.count(i) > 0) {
- strings::SubstituteAndAppend(&contents, "import weak \"$0\";\n",
+ } else if (weak_dependencies.contains(i)) {
+ y_absl::SubstituteAndAppend(&contents, "import weak \"$0\";\n",
dependency(i)->name());
} else {
- strings::SubstituteAndAppend(&contents, "import \"$0\";\n",
+ y_absl::SubstituteAndAppend(&contents, "import \"$0\";\n",
dependency(i)->name());
}
}
@@ -3019,7 +3002,7 @@ TProtoStringType FileDescriptor::DebugStringWithOptions(
SourceLocationCommentPrinter package_comment(this, path, "",
debug_string_options);
package_comment.AddPreComment(&contents);
- strings::SubstituteAndAppend(&contents, "package $0;\n\n", package());
+ y_absl::SubstituteAndAppend(&contents, "package $0;\n\n", package());
package_comment.AddPostComment(&contents);
}
@@ -3034,7 +3017,7 @@ TProtoStringType FileDescriptor::DebugStringWithOptions(
// Find all the 'group' type extensions; we will not output their nested
// definitions (those will be done with their group field descriptor).
- std::set<const Descriptor*> groups;
+ y_absl::flat_hash_set<const Descriptor*> groups;
for (int i = 0; i < extension_count(); i++) {
if (extension(i)->type() == FieldDescriptor::TYPE_GROUP) {
groups.insert(extension(i)->message_type());
@@ -3042,7 +3025,7 @@ TProtoStringType FileDescriptor::DebugStringWithOptions(
}
for (int i = 0; i < message_type_count(); i++) {
- if (groups.count(message_type(i)) == 0) {
+ if (!groups.contains(message_type(i))) {
message_type(i)->DebugString(0, &contents, debug_string_options,
/* include_opening_clause */ true);
contents.append("\n");
@@ -3059,7 +3042,7 @@ TProtoStringType FileDescriptor::DebugStringWithOptions(
if (extension(i)->containing_type() != containing_type) {
if (i > 0) contents.append("}\n\n");
containing_type = extension(i)->containing_type();
- strings::SubstituteAndAppend(&contents, "extend .$0 {\n",
+ y_absl::SubstituteAndAppend(&contents, "extend .$0 {\n",
containing_type->full_name());
}
extension(i)->DebugString(1, &contents, debug_string_options);
@@ -3098,7 +3081,7 @@ void Descriptor::DebugString(int depth, TProtoStringType* contents,
comment_printer.AddPreComment(contents);
if (include_opening_clause) {
- strings::SubstituteAndAppend(contents, "$0message $1", prefix, name());
+ y_absl::SubstituteAndAppend(contents, "$0message $1", prefix, name());
}
contents->append(" {\n");
@@ -3107,7 +3090,7 @@ void Descriptor::DebugString(int depth, TProtoStringType* contents,
// Find all the 'group' types for fields and extensions; we will not output
// their nested definitions (those will be done with their group field
// descriptor).
- std::set<const Descriptor*> groups;
+ y_absl::flat_hash_set<const Descriptor*> groups;
for (int i = 0; i < field_count(); i++) {
if (field(i)->type() == FieldDescriptor::TYPE_GROUP) {
groups.insert(field(i)->message_type());
@@ -3120,7 +3103,7 @@ void Descriptor::DebugString(int depth, TProtoStringType* contents,
}
for (int i = 0; i < nested_type_count(); i++) {
- if (groups.count(nested_type(i)) == 0) {
+ if (!groups.contains(nested_type(i))) {
nested_type(i)->DebugString(depth, contents, debug_string_options,
/* include_opening_clause */ true);
}
@@ -3139,7 +3122,7 @@ void Descriptor::DebugString(int depth, TProtoStringType* contents,
}
for (int i = 0; i < extension_range_count(); i++) {
- strings::SubstituteAndAppend(contents, "$0 extensions $1 to $2;\n", prefix,
+ y_absl::SubstituteAndAppend(contents, "$0 extensions $1 to $2;\n", prefix,
extension_range(i)->start,
extension_range(i)->end - 1);
}
@@ -3148,26 +3131,26 @@ void Descriptor::DebugString(int depth, TProtoStringType* contents,
const Descriptor* containing_type = nullptr;
for (int i = 0; i < extension_count(); i++) {
if (extension(i)->containing_type() != containing_type) {
- if (i > 0) strings::SubstituteAndAppend(contents, "$0 }\n", prefix);
+ if (i > 0) y_absl::SubstituteAndAppend(contents, "$0 }\n", prefix);
containing_type = extension(i)->containing_type();
- strings::SubstituteAndAppend(contents, "$0 extend .$1 {\n", prefix,
+ y_absl::SubstituteAndAppend(contents, "$0 extend .$1 {\n", prefix,
containing_type->full_name());
}
extension(i)->DebugString(depth + 1, contents, debug_string_options);
}
if (extension_count() > 0)
- strings::SubstituteAndAppend(contents, "$0 }\n", prefix);
+ y_absl::SubstituteAndAppend(contents, "$0 }\n", prefix);
if (reserved_range_count() > 0) {
- strings::SubstituteAndAppend(contents, "$0 reserved ", prefix);
+ y_absl::SubstituteAndAppend(contents, "$0 reserved ", prefix);
for (int i = 0; i < reserved_range_count(); i++) {
const Descriptor::ReservedRange* range = reserved_range(i);
if (range->end == range->start + 1) {
- strings::SubstituteAndAppend(contents, "$0, ", range->start);
+ y_absl::SubstituteAndAppend(contents, "$0, ", range->start);
} else if (range->end > FieldDescriptor::kMaxNumber) {
- strings::SubstituteAndAppend(contents, "$0 to max, ", range->start);
+ y_absl::SubstituteAndAppend(contents, "$0 to max, ", range->start);
} else {
- strings::SubstituteAndAppend(contents, "$0 to $1, ", range->start,
+ y_absl::SubstituteAndAppend(contents, "$0 to $1, ", range->start,
range->end - 1);
}
}
@@ -3175,15 +3158,15 @@ void Descriptor::DebugString(int depth, TProtoStringType* contents,
}
if (reserved_name_count() > 0) {
- strings::SubstituteAndAppend(contents, "$0 reserved ", prefix);
+ y_absl::SubstituteAndAppend(contents, "$0 reserved ", prefix);
for (int i = 0; i < reserved_name_count(); i++) {
- strings::SubstituteAndAppend(contents, "\"$0\", ",
- CEscape(reserved_name(i)));
+ y_absl::SubstituteAndAppend(contents, "\"$0\", ",
+ y_absl::CEscape(reserved_name(i)));
}
contents->replace(contents->size() - 2, 2, ";\n");
}
- strings::SubstituteAndAppend(contents, "$0}\n", prefix);
+ y_absl::SubstituteAndAppend(contents, "$0}\n", prefix);
comment_printer.AddPostComment(contents);
}
@@ -3197,7 +3180,7 @@ TProtoStringType FieldDescriptor::DebugStringWithOptions(
TProtoStringType contents;
int depth = 0;
if (is_extension()) {
- strings::SubstituteAndAppend(&contents, "extend .$0 {\n",
+ y_absl::SubstituteAndAppend(&contents, "extend .$0 {\n",
containing_type()->full_name());
depth = 1;
}
@@ -3212,9 +3195,9 @@ TProtoStringType FieldDescriptor::DebugStringWithOptions(
TProtoStringType FieldDescriptor::FieldTypeNameDebugString() const {
switch (type()) {
case TYPE_MESSAGE:
- return "." + message_type()->full_name();
+ return y_absl::StrCat(".", message_type()->full_name());
case TYPE_ENUM:
- return "." + enum_type()->full_name();
+ return y_absl::StrCat(".", enum_type()->full_name());
default:
return kTypeToName[type()];
}
@@ -3228,7 +3211,7 @@ void FieldDescriptor::DebugString(
// Special case map fields.
if (is_map()) {
- strings::SubstituteAndAppend(
+ y_absl::SubstituteAndAppend(
&field_type, "map<$0, $1>",
message_type()->field(0)->FieldTypeNameDebugString(),
message_type()->field(1)->FieldTypeNameDebugString());
@@ -3236,7 +3219,7 @@ void FieldDescriptor::DebugString(
field_type = FieldTypeNameDebugString();
}
- TProtoStringType label = StrCat(kLabelToName[this->label()], " ");
+ TProtoStringType label = y_absl::StrCat(kLabelToName[this->label()], " ");
// Label is omitted for maps, oneof, and plain proto3 fields.
if (is_map() || real_containing_oneof() ||
@@ -3248,14 +3231,14 @@ void FieldDescriptor::DebugString(
debug_string_options);
comment_printer.AddPreComment(contents);
- strings::SubstituteAndAppend(
+ y_absl::SubstituteAndAppend(
contents, "$0$1$2 $3 = $4", prefix, label, field_type,
type() == TYPE_GROUP ? message_type()->name() : name(), number());
bool bracketed = false;
if (has_default_value()) {
bracketed = true;
- strings::SubstituteAndAppend(contents, " [default = $0",
+ y_absl::SubstituteAndAppend(contents, " [default = $0",
DefaultValueAsString(true));
}
if (has_json_name_) {
@@ -3266,7 +3249,7 @@ void FieldDescriptor::DebugString(
contents->append(", ");
}
contents->append("json_name = \"");
- contents->append(CEscape(json_name()));
+ contents->append(y_absl::CEscape(json_name()));
contents->append("\"");
}
@@ -3316,7 +3299,7 @@ void OneofDescriptor::DebugString(
SourceLocationCommentPrinter comment_printer(this, prefix,
debug_string_options);
comment_printer.AddPreComment(contents);
- strings::SubstituteAndAppend(contents, "$0oneof $1 {", prefix, name());
+ y_absl::SubstituteAndAppend(contents, "$0oneof $1 {", prefix, name());
FormatLineOptions(depth, options(), containing_type()->file()->pool(),
contents);
@@ -3328,7 +3311,7 @@ void OneofDescriptor::DebugString(
for (int i = 0; i < field_count(); i++) {
field(i)->DebugString(depth, contents, debug_string_options);
}
- strings::SubstituteAndAppend(contents, "$0}\n", prefix);
+ y_absl::SubstituteAndAppend(contents, "$0}\n", prefix);
}
comment_printer.AddPostComment(contents);
}
@@ -3355,7 +3338,7 @@ void EnumDescriptor::DebugString(
debug_string_options);
comment_printer.AddPreComment(contents);
- strings::SubstituteAndAppend(contents, "$0enum $1 {\n", prefix, name());
+ y_absl::SubstituteAndAppend(contents, "$0enum $1 {\n", prefix, name());
FormatLineOptions(depth, options(), file()->pool(), contents);
@@ -3364,15 +3347,15 @@ void EnumDescriptor::DebugString(
}
if (reserved_range_count() > 0) {
- strings::SubstituteAndAppend(contents, "$0 reserved ", prefix);
+ y_absl::SubstituteAndAppend(contents, "$0 reserved ", prefix);
for (int i = 0; i < reserved_range_count(); i++) {
const EnumDescriptor::ReservedRange* range = reserved_range(i);
if (range->end == range->start) {
- strings::SubstituteAndAppend(contents, "$0, ", range->start);
+ y_absl::SubstituteAndAppend(contents, "$0, ", range->start);
} else if (range->end == INT_MAX) {
- strings::SubstituteAndAppend(contents, "$0 to max, ", range->start);
+ y_absl::SubstituteAndAppend(contents, "$0 to max, ", range->start);
} else {
- strings::SubstituteAndAppend(contents, "$0 to $1, ", range->start,
+ y_absl::SubstituteAndAppend(contents, "$0 to $1, ", range->start,
range->end);
}
}
@@ -3380,15 +3363,15 @@ void EnumDescriptor::DebugString(
}
if (reserved_name_count() > 0) {
- strings::SubstituteAndAppend(contents, "$0 reserved ", prefix);
+ y_absl::SubstituteAndAppend(contents, "$0 reserved ", prefix);
for (int i = 0; i < reserved_name_count(); i++) {
- strings::SubstituteAndAppend(contents, "\"$0\", ",
- CEscape(reserved_name(i)));
+ y_absl::SubstituteAndAppend(contents, "\"$0\", ",
+ y_absl::CEscape(reserved_name(i)));
}
contents->replace(contents->size() - 2, 2, ";\n");
}
- strings::SubstituteAndAppend(contents, "$0}\n", prefix);
+ y_absl::SubstituteAndAppend(contents, "$0}\n", prefix);
comment_printer.AddPostComment(contents);
}
@@ -3414,12 +3397,12 @@ void EnumValueDescriptor::DebugString(
debug_string_options);
comment_printer.AddPreComment(contents);
- strings::SubstituteAndAppend(contents, "$0$1 = $2", prefix, name(), number());
+ y_absl::SubstituteAndAppend(contents, "$0$1 = $2", prefix, name(), number());
TProtoStringType formatted_options;
if (FormatBracketedOptions(depth, options(), type()->file()->pool(),
&formatted_options)) {
- strings::SubstituteAndAppend(contents, " [$0]", formatted_options);
+ y_absl::SubstituteAndAppend(contents, " [$0]", formatted_options);
}
contents->append(";\n");
@@ -3445,7 +3428,7 @@ void ServiceDescriptor::DebugString(
debug_string_options);
comment_printer.AddPreComment(contents);
- strings::SubstituteAndAppend(contents, "service $0 {\n", name());
+ y_absl::SubstituteAndAppend(contents, "service $0 {\n", name());
FormatLineOptions(1, options(), file()->pool(), contents);
@@ -3480,7 +3463,7 @@ void MethodDescriptor::DebugString(
debug_string_options);
comment_printer.AddPreComment(contents);
- strings::SubstituteAndAppend(
+ y_absl::SubstituteAndAppend(
contents, "$0rpc $1($4.$2) returns ($5.$3)", prefix, name(),
input_type()->full_name(), output_type()->full_name(),
client_streaming() ? "stream " : "", server_streaming() ? "stream " : "");
@@ -3488,7 +3471,7 @@ void MethodDescriptor::DebugString(
TProtoStringType formatted_options;
if (FormatLineOptions(depth, options(), service()->file()->pool(),
&formatted_options)) {
- strings::SubstituteAndAppend(contents, " {\n$0$1}\n", formatted_options,
+ y_absl::SubstituteAndAppend(contents, " {\n$0$1}\n", formatted_options,
prefix);
} else {
contents->append(";\n");
@@ -3501,7 +3484,7 @@ void MethodDescriptor::DebugString(
bool FileDescriptor::GetSourceLocation(const std::vector<int>& path,
SourceLocation* out_location) const {
- GOOGLE_CHECK(out_location != nullptr);
+ Y_ABSL_CHECK(out_location != nullptr);
if (source_code_info_) {
if (const SourceCodeInfo_Location* loc =
tables_->GetSourceLocation(path, source_code_info_)) {
@@ -3653,7 +3636,7 @@ namespace {
// pointers in the original options, not the mutable copy). The Message must be
// one of the Options messages in descriptor.proto.
struct OptionsToInterpret {
- OptionsToInterpret(const TProtoStringType& ns, const TProtoStringType& el,
+ OptionsToInterpret(y_absl::string_view ns, y_absl::string_view el,
const std::vector<int>& path, const Message* orig_opt,
Message* opt)
: name_scope(ns),
@@ -3672,13 +3655,21 @@ struct OptionsToInterpret {
class DescriptorBuilder {
public:
- DescriptorBuilder(const DescriptorPool* pool, DescriptorPool::Tables* tables,
- DescriptorPool::ErrorCollector* error_collector);
+ static std::unique_ptr<DescriptorBuilder> New(
+ const DescriptorPool* pool, DescriptorPool::Tables* tables,
+ DescriptorPool::ErrorCollector* error_collector) {
+ return std::unique_ptr<DescriptorBuilder>(
+ new DescriptorBuilder(pool, tables, error_collector));
+ }
+
~DescriptorBuilder();
const FileDescriptor* BuildFile(const FileDescriptorProto& proto);
private:
+ DescriptorBuilder(const DescriptorPool* pool, DescriptorPool::Tables* tables,
+ DescriptorPool::ErrorCollector* error_collector);
+
friend class OptionInterpreter;
// Non-recursive part of BuildFile functionality.
@@ -3698,7 +3689,7 @@ class DescriptorBuilder {
TProtoStringType filename_;
FileDescriptor* file_;
FileDescriptorTables* file_tables_;
- std::set<const FileDescriptor*> dependencies_;
+ y_absl::flat_hash_set<const FileDescriptor*> dependencies_;
struct MessageHints {
int fields_to_suggest = 0;
@@ -3721,11 +3712,11 @@ class DescriptorBuilder {
}
};
- std::unordered_map<const Descriptor*, MessageHints> message_hints_;
+ y_absl::flat_hash_map<const Descriptor*, MessageHints> message_hints_;
// unused_dependency_ is used to record the unused imported files.
// Note: public import is not considered.
- std::set<const FileDescriptor*> unused_dependency_;
+ y_absl::flat_hash_set<const FileDescriptor*> unused_dependency_;
// If LookupSymbol() finds a symbol that is in a file which is not a declared
// dependency of this file, it will fail, but will set
@@ -3773,7 +3764,7 @@ class DescriptorBuilder {
// Silly helper which determines if the given file is in the given package.
// I.e., either file->package() == package_name or file->package() is a
// nested package within package_name.
- bool IsInPackage(const FileDescriptor* file, const TProtoStringType& package_name);
+ bool IsInPackage(const FileDescriptor* file, y_absl::string_view package_name);
// Helper function which finds all public dependencies of the given file, and
// stores the them in the dependencies_ set in the builder.
@@ -3849,7 +3840,7 @@ class DescriptorBuilder {
template <class DescriptorT>
void AllocateOptions(const typename DescriptorT::OptionsType& orig_options,
DescriptorT* descriptor, int options_field_tag,
- const TProtoStringType& option_name,
+ y_absl::string_view option_name,
internal::FlatAllocator& alloc);
// Specialization for FileOptions.
void AllocateOptions(const FileOptions& orig_options,
@@ -3859,10 +3850,10 @@ class DescriptorBuilder {
// Implementation for AllocateOptions(). Don't call this directly.
template <class DescriptorT>
void AllocateOptionsImpl(
- const TProtoStringType& name_scope, const TProtoStringType& element_name,
+ y_absl::string_view name_scope, y_absl::string_view element_name,
const typename DescriptorT::OptionsType& orig_options,
DescriptorT* descriptor, const std::vector<int>& options_path,
- const TProtoStringType& option_name, internal::FlatAllocator& alloc);
+ y_absl::string_view 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.
@@ -3901,8 +3892,6 @@ class DescriptorBuilder {
internal::FlatAllocator& alloc);
void BuildOneof(const OneofDescriptorProto& proto, Descriptor* parent,
OneofDescriptor* result, internal::FlatAllocator& alloc);
- void CheckEnumValueUniqueness(const EnumDescriptorProto& proto,
- const EnumDescriptor* result);
void BuildEnum(const EnumDescriptorProto& proto, const Descriptor* parent,
EnumDescriptor* result, internal::FlatAllocator& alloc);
void BuildEnumValue(const EnumValueDescriptorProto& proto,
@@ -3914,6 +3903,15 @@ class DescriptorBuilder {
const ServiceDescriptor* parent, MethodDescriptor* result,
internal::FlatAllocator& alloc);
+ void CheckFieldJsonNameUniqueness(const DescriptorProto& proto,
+ const Descriptor* result);
+ void CheckFieldJsonNameUniqueness(const TProtoStringType& message_name,
+ const DescriptorProto& message,
+ FileDescriptor::Syntax syntax,
+ bool use_custom_names);
+ void CheckEnumValueUniqueness(const EnumDescriptorProto& proto,
+ const EnumDescriptor* result);
+
void LogUnusedDependency(const FileDescriptorProto& proto,
const FileDescriptor* result);
@@ -3949,6 +3947,8 @@ class DescriptorBuilder {
// specified builder, which must not be nullptr. We don't take ownership of
// the builder.
explicit OptionInterpreter(DescriptorBuilder* builder);
+ OptionInterpreter(const OptionInterpreter&) = delete;
+ OptionInterpreter& operator=(const OptionInterpreter&) = delete;
~OptionInterpreter();
@@ -4055,18 +4055,16 @@ class DescriptorBuilder {
// This maps the element path of uninterpreted options to the element path
// of the resulting interpreted option. This is used to modify a file's
// source code info to account for option interpretation.
- std::map<std::vector<int>, std::vector<int>> interpreted_paths_;
+ y_absl::flat_hash_map<std::vector<int>, std::vector<int>> interpreted_paths_;
// This maps the path to a repeated option field to the known number of
// elements the field contains. This is used to track the compute the
// index portion of the element path when interpreting a single option.
- std::map<std::vector<int>, int> repeated_option_counts_;
+ y_absl::flat_hash_map<std::vector<int>, int> repeated_option_counts_;
// Factory used to create the dynamic messages we need to parse
// any aggregate option values we encounter.
DynamicMessageFactory dynamic_factory_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(OptionInterpreter);
};
// Work-around for broken compilers: According to the C++ standard,
@@ -4140,38 +4138,38 @@ class DescriptorBuilder {
const FileDescriptor* DescriptorPool::BuildFile(
const FileDescriptorProto& proto) {
- GOOGLE_CHECK(fallback_database_ == nullptr)
+ Y_ABSL_CHECK(fallback_database_ == nullptr)
<< "Cannot call BuildFile on a DescriptorPool that uses a "
"DescriptorDatabase. You must instead find a way to get your file "
"into the underlying database.";
- GOOGLE_CHECK(mutex_ == nullptr); // Implied by the above GOOGLE_CHECK.
+ Y_ABSL_CHECK(mutex_ == nullptr); // Implied by the above Y_ABSL_CHECK.
tables_->known_bad_symbols_.clear();
tables_->known_bad_files_.clear();
- return DescriptorBuilder(this, tables_.get(), nullptr).BuildFile(proto);
+ return DescriptorBuilder::New(this, tables_.get(), nullptr)->BuildFile(proto);
}
const FileDescriptor* DescriptorPool::BuildFileCollectingErrors(
const FileDescriptorProto& proto, ErrorCollector* error_collector) {
- GOOGLE_CHECK(fallback_database_ == nullptr)
+ Y_ABSL_CHECK(fallback_database_ == nullptr)
<< "Cannot call BuildFile on a DescriptorPool that uses a "
"DescriptorDatabase. You must instead find a way to get your file "
"into the underlying database.";
- GOOGLE_CHECK(mutex_ == nullptr); // Implied by the above GOOGLE_CHECK.
+ Y_ABSL_CHECK(mutex_ == nullptr); // Implied by the above Y_ABSL_CHECK.
tables_->known_bad_symbols_.clear();
tables_->known_bad_files_.clear();
- return DescriptorBuilder(this, tables_.get(), error_collector)
- .BuildFile(proto);
+ return DescriptorBuilder::New(this, tables_.get(), error_collector)
+ ->BuildFile(proto);
}
const FileDescriptor* DescriptorPool::BuildFileFromDatabase(
const FileDescriptorProto& proto) const {
mutex_->AssertHeld();
- if (tables_->known_bad_files_.count(proto.name()) > 0) {
+ if (tables_->known_bad_files_.contains(proto.name())) {
return nullptr;
}
const FileDescriptor* result =
- DescriptorBuilder(this, tables_.get(), default_error_collector_)
- .BuildFile(proto);
+ DescriptorBuilder::New(this, tables_.get(), default_error_collector_)
+ ->BuildFile(proto);
if (result == nullptr) {
tables_->known_bad_files_.insert(proto.name());
}
@@ -4190,76 +4188,77 @@ DescriptorBuilder::DescriptorBuilder(
DescriptorBuilder::~DescriptorBuilder() {}
-void DescriptorBuilder::AddError(
+PROTOBUF_NOINLINE void DescriptorBuilder::AddError(
const TProtoStringType& element_name, const Message& descriptor,
DescriptorPool::ErrorCollector::ErrorLocation location,
const TProtoStringType& error) {
if (error_collector_ == nullptr) {
if (!had_errors_) {
- GOOGLE_LOG(ERROR) << "Invalid proto descriptor for file \"" << filename_
- << "\":";
+ Y_ABSL_LOG(ERROR) << "Invalid proto descriptor for file \"" << filename_
+ << "\":";
}
- GOOGLE_LOG(ERROR) << " " << element_name << ": " << error;
+ Y_ABSL_LOG(ERROR) << " " << element_name << ": " << error;
} else {
- error_collector_->AddError(filename_, element_name, &descriptor, location,
- error);
+ error_collector_->RecordError(filename_, element_name, &descriptor,
+ location, error);
}
had_errors_ = true;
}
-void DescriptorBuilder::AddError(
+PROTOBUF_NOINLINE void DescriptorBuilder::AddError(
const TProtoStringType& element_name, const Message& descriptor,
DescriptorPool::ErrorCollector::ErrorLocation location, const char* error) {
AddError(element_name, descriptor, location, TProtoStringType(error));
}
-void DescriptorBuilder::AddNotDefinedError(
+PROTOBUF_NOINLINE void DescriptorBuilder::AddNotDefinedError(
const TProtoStringType& element_name, const Message& descriptor,
DescriptorPool::ErrorCollector::ErrorLocation location,
const TProtoStringType& undefined_symbol) {
if (possible_undeclared_dependency_ == nullptr &&
undefine_resolved_name_.empty()) {
AddError(element_name, descriptor, location,
- "\"" + undefined_symbol + "\" is not defined.");
+ y_absl::StrCat("\"", undefined_symbol, "\" is not defined."));
} else {
if (possible_undeclared_dependency_ != nullptr) {
AddError(element_name, descriptor, location,
- "\"" + possible_undeclared_dependency_name_ +
- "\" seems to be defined in \"" +
- possible_undeclared_dependency_->name() +
- "\", which is not "
- "imported by \"" +
- filename_ +
- "\". To use it here, please "
- "add the necessary import.");
+ y_absl::StrCat("\"", possible_undeclared_dependency_name_,
+ "\" seems to be defined in \"",
+ possible_undeclared_dependency_->name(),
+ "\", which is not "
+ "imported by \"",
+ filename_,
+ "\". To use it here, please "
+ "add the necessary import."));
}
if (!undefine_resolved_name_.empty()) {
AddError(element_name, descriptor, location,
- "\"" + undefined_symbol + "\" is resolved to \"" +
- undefine_resolved_name_ +
+ y_absl::StrCat(
+ "\"", undefined_symbol, "\" is resolved to \"",
+ undefine_resolved_name_,
"\", which is not defined. "
"The innermost scope is searched first in name resolution. "
- "Consider using a leading '.'(i.e., \"." +
- undefined_symbol + "\") to start from the outermost scope.");
+ "Consider using a leading '.'(i.e., \".",
+ undefined_symbol, "\") to start from the outermost scope."));
}
}
}
-void DescriptorBuilder::AddWarning(
+PROTOBUF_NOINLINE void DescriptorBuilder::AddWarning(
const TProtoStringType& element_name, const Message& descriptor,
DescriptorPool::ErrorCollector::ErrorLocation location,
const TProtoStringType& error) {
if (error_collector_ == nullptr) {
- GOOGLE_LOG(WARNING) << filename_ << " " << element_name << ": " << error;
+ Y_ABSL_LOG(WARNING) << filename_ << " " << element_name << ": " << error;
} else {
- error_collector_->AddWarning(filename_, element_name, &descriptor, location,
- error);
+ error_collector_->RecordWarning(filename_, element_name, &descriptor,
+ location, error);
}
}
bool DescriptorBuilder::IsInPackage(const FileDescriptor* file,
- const TProtoStringType& package_name) {
- return HasPrefixString(file->package(), package_name) &&
+ y_absl::string_view package_name) {
+ return y_absl::StartsWith(file->package(), package_name) &&
(file->package().size() == package_name.size() ||
file->package()[package_name.size()] == '.');
}
@@ -4275,7 +4274,7 @@ Symbol DescriptorBuilder::FindSymbolNotEnforcingDepsHelper(
const DescriptorPool* pool, const TProtoStringType& name, bool build_it) {
// If we are looking at an underlay, we must lock its mutex_, since we are
// accessing the underlay's tables_ directly.
- MutexLockMaybe lock((pool == pool_) ? nullptr : pool->mutex_);
+ y_absl::MutexLockMaybe lock((pool == pool_) ? nullptr : pool->mutex_);
Symbol result = pool->tables_->FindSymbol(name);
if (result.IsNull() && pool->underlay_ != nullptr) {
@@ -4305,7 +4304,7 @@ Symbol DescriptorBuilder::FindSymbolNotEnforcingDeps(const TProtoStringType& nam
// Only find symbols which were defined in this file or one of its
// dependencies.
const FileDescriptor* file = result.GetFile();
- if (file == file_ || dependencies_.count(file) > 0) {
+ if (file == file_ || dependencies_.contains(file)) {
unused_dependency_.erase(file);
}
return result;
@@ -4324,7 +4323,7 @@ Symbol DescriptorBuilder::FindSymbol(const TProtoStringType& name, bool build_it
// Only find symbols which were defined in this file or one of its
// dependencies.
const FileDescriptor* file = result.GetFile();
- if (file == file_ || dependencies_.count(file) > 0) {
+ if (file == file_ || dependencies_.contains(file)) {
return result;
}
@@ -4337,11 +4336,9 @@ Symbol DescriptorBuilder::FindSymbol(const TProtoStringType& name, bool build_it
// dependency also defines the same package. We can't really rule out this
// symbol unless none of the dependencies define it.
if (IsInPackage(file_, name)) return result;
- for (std::set<const FileDescriptor*>::const_iterator it =
- dependencies_.begin();
- it != dependencies_.end(); ++it) {
+ for (const auto* dep : dependencies_) {
// Note: A dependency may be nullptr if it was not found or had errors.
- if (*it != nullptr && IsInPackage(*it, name)) return result;
+ if (dep != nullptr && IsInPackage(dep, name)) return result;
}
}
@@ -4439,7 +4436,7 @@ Symbol DescriptorBuilder::LookupSymbol(
return result;
}
-static bool ValidateQualifiedName(StringPiece name) {
+static bool ValidateQualifiedName(y_absl::string_view name) {
bool last_was_period = false;
for (char character : name) {
@@ -4459,20 +4456,20 @@ static bool ValidateQualifiedName(StringPiece name) {
return !name.empty() && !last_was_period;
}
-Symbol DescriptorPool::NewPlaceholder(StringPiece name,
+Symbol DescriptorPool::NewPlaceholder(y_absl::string_view name,
PlaceholderType placeholder_type) const {
- MutexLockMaybe lock(mutex_);
+ y_absl::MutexLockMaybe lock(mutex_);
return NewPlaceholderWithMutexHeld(name, placeholder_type);
}
Symbol DescriptorPool::NewPlaceholderWithMutexHeld(
- StringPiece name, PlaceholderType placeholder_type) const {
+ y_absl::string_view name, PlaceholderType placeholder_type) const {
if (mutex_) {
mutex_->AssertHeld();
}
// Compute names.
- StringPiece placeholder_full_name;
- StringPiece placeholder_name;
+ y_absl::string_view placeholder_full_name;
+ y_absl::string_view placeholder_name;
const TProtoStringType* placeholder_package;
if (!ValidateQualifiedName(name)) return Symbol();
@@ -4512,7 +4509,7 @@ Symbol DescriptorPool::NewPlaceholderWithMutexHeld(
}
FileDescriptor* placeholder_file = NewPlaceholderFileWithMutexHeld(
- StrCat(placeholder_full_name, ".placeholder.proto"), alloc);
+ y_absl::StrCat(placeholder_full_name, ".placeholder.proto"), alloc);
placeholder_file->package_ = placeholder_package;
if (placeholder_type == PLACEHOLDER_ENUM) {
@@ -4541,9 +4538,10 @@ Symbol DescriptorPool::NewPlaceholderWithMutexHeld(
// Note that enum value names are siblings of their type, not children.
placeholder_value->all_names_ = alloc.AllocateStrings(
- "PLACEHOLDER_VALUE", placeholder_package->empty()
- ? "PLACEHOLDER_VALUE"
- : *placeholder_package + ".PLACEHOLDER_VALUE");
+ "PLACEHOLDER_VALUE",
+ placeholder_package->empty()
+ ? "PLACEHOLDER_VALUE"
+ : y_absl::StrCat(*placeholder_package, ".PLACEHOLDER_VALUE"));
placeholder_value->number_ = 0;
placeholder_value->type_ = placeholder_enum;
@@ -4581,8 +4579,8 @@ Symbol DescriptorPool::NewPlaceholderWithMutexHeld(
}
FileDescriptor* DescriptorPool::NewPlaceholderFile(
- StringPiece name) const {
- MutexLockMaybe lock(mutex_);
+ y_absl::string_view name) const {
+ y_absl::MutexLockMaybe lock(mutex_);
internal::FlatAllocator alloc;
alloc.PlanArray<FileDescriptor>(1);
alloc.PlanArray<TProtoStringType>(1);
@@ -4592,7 +4590,7 @@ FileDescriptor* DescriptorPool::NewPlaceholderFile(
}
FileDescriptor* DescriptorPool::NewPlaceholderFileWithMutexHeld(
- StringPiece name, internal::FlatAllocator& alloc) const {
+ y_absl::string_view name, internal::FlatAllocator& alloc) const {
if (mutex_) {
mutex_->AssertHeld();
}
@@ -4620,9 +4618,9 @@ bool DescriptorBuilder::AddSymbol(const TProtoStringType& full_name,
// Use its file as the parent instead.
if (parent == nullptr) parent = file_;
- if (full_name.find('\0') != TProtoStringType::npos) {
+ if (y_absl::StrContains(full_name, '\0')) {
AddError(full_name, proto, DescriptorPool::ErrorCollector::NAME,
- "\"" + full_name + "\" contains null character.");
+ y_absl::StrCat("\"", full_name, "\" contains null character."));
return false;
}
if (tables_->AddSymbol(full_name, symbol)) {
@@ -4630,10 +4628,10 @@ bool DescriptorBuilder::AddSymbol(const TProtoStringType& full_name,
// This is only possible if there was already an error adding something of
// the same name.
if (!had_errors_) {
- GOOGLE_LOG(DFATAL) << "\"" << full_name
- << "\" not previously defined in "
- "symbols_by_name_, but was defined in "
- "symbols_by_parent_; this shouldn't be possible.";
+ Y_ABSL_DLOG(FATAL) << "\"" << full_name
+ << "\" not previously defined in "
+ "symbols_by_name_, but was defined in "
+ "symbols_by_parent_; this shouldn't be possible.";
}
return false;
}
@@ -4644,19 +4642,20 @@ bool DescriptorBuilder::AddSymbol(const TProtoStringType& full_name,
TProtoStringType::size_type dot_pos = full_name.find_last_of('.');
if (dot_pos == TProtoStringType::npos) {
AddError(full_name, proto, DescriptorPool::ErrorCollector::NAME,
- "\"" + full_name + "\" is already defined.");
+ y_absl::StrCat("\"", full_name, "\" is already defined."));
} else {
AddError(full_name, proto, DescriptorPool::ErrorCollector::NAME,
- "\"" + full_name.substr(dot_pos + 1) +
- "\" is already defined in \"" +
- full_name.substr(0, dot_pos) + "\".");
+ y_absl::StrCat("\"", full_name.substr(dot_pos + 1),
+ "\" is already defined in \"",
+ full_name.substr(0, dot_pos), "\"."));
}
} else {
// Symbol seems to have been defined in a different file.
- AddError(full_name, proto, DescriptorPool::ErrorCollector::NAME,
- "\"" + full_name + "\" is already defined in file \"" +
- (other_file == nullptr ? "null" : other_file->name()) +
- "\".");
+ AddError(
+ full_name, proto, DescriptorPool::ErrorCollector::NAME,
+ y_absl::StrCat("\"", full_name, "\" is already defined in file \"",
+ (other_file == nullptr ? "null" : other_file->name()),
+ "\"."));
}
return false;
}
@@ -4666,14 +4665,14 @@ void DescriptorBuilder::AddPackage(const TProtoStringType& name,
const Message& proto, FileDescriptor* file) {
if (name.find('\0') != TProtoStringType::npos) {
AddError(name, proto, DescriptorPool::ErrorCollector::NAME,
- "\"" + name + "\" contains null character.");
+ y_absl::StrCat("\"", name, "\" contains null character."));
return;
}
Symbol existing_symbol = tables_->FindSymbol(name);
// It's OK to redefine a package.
if (existing_symbol.IsNull()) {
- if (&name == &file->package()) {
+ if (name.data() == file->package().data()) {
// It is the toplevel package name, so insert the descriptor directly.
tables_->AddSymbol(file->package(), Symbol(file));
} else {
@@ -4698,10 +4697,11 @@ void DescriptorBuilder::AddPackage(const TProtoStringType& name,
// 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 \"" +
- (other_file == nullptr ? "null" : other_file->name()) + "\".");
+ y_absl::StrCat("\"", name,
+ "\" is already defined (as something other than "
+ "a package) in file \"",
+ (other_file == nullptr ? "null" : other_file->name()),
+ "\"."));
}
}
@@ -4718,7 +4718,7 @@ void DescriptorBuilder::ValidateSymbolName(const TProtoStringType& name,
(character < 'A' || 'Z' < character) &&
(character < '0' || '9' < character) && (character != '_')) {
AddError(full_name, proto, DescriptorPool::ErrorCollector::NAME,
- "\"" + name + "\" is not a valid identifier.");
+ y_absl::StrCat("\"", name, "\" is not a valid identifier."));
return;
}
}
@@ -4733,7 +4733,7 @@ template <class DescriptorT>
void DescriptorBuilder::AllocateOptions(
const typename DescriptorT::OptionsType& orig_options,
DescriptorT* descriptor, int options_field_tag,
- const TProtoStringType& option_name, internal::FlatAllocator& alloc) {
+ y_absl::string_view option_name, internal::FlatAllocator& alloc) {
std::vector<int> options_path;
descriptor->GetLocationPath(&options_path);
options_path.push_back(options_field_tag);
@@ -4749,21 +4749,21 @@ void DescriptorBuilder::AllocateOptions(const FileOptions& orig_options,
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", alloc);
+ AllocateOptionsImpl(y_absl::StrCat(descriptor->package(), ".dummy"),
+ descriptor->name(), orig_options, descriptor,
+ options_path, "google.protobuf.FileOptions", alloc);
}
template <class DescriptorT>
void DescriptorBuilder::AllocateOptionsImpl(
- const TProtoStringType& name_scope, const TProtoStringType& element_name,
+ y_absl::string_view name_scope, y_absl::string_view element_name,
const typename DescriptorT::OptionsType& orig_options,
DescriptorT* descriptor, const std::vector<int>& options_path,
- const TProtoStringType& option_name, internal::FlatAllocator& alloc) {
+ y_absl::string_view option_name, internal::FlatAllocator& alloc) {
auto* options = alloc.AllocateArray<typename DescriptorT::OptionsType>(1);
if (!orig_options.IsInitialized()) {
- AddError(name_scope + "." + element_name, orig_options,
+ AddError(y_absl::StrCat(name_scope, ".", element_name), orig_options,
DescriptorPool::ErrorCollector::OPTION_NAME,
"Uninterpreted option is missing name or value.");
return;
@@ -4819,7 +4819,7 @@ void DescriptorBuilder::AllocateOptionsImpl(
METHOD(INPUT.NAME(i), PARENT, OUTPUT->NAME##s_ + i, alloc); \
}
-void DescriptorBuilder::AddRecursiveImportError(
+PROTOBUF_NOINLINE void DescriptorBuilder::AddRecursiveImportError(
const FileDescriptorProto& proto, int from_here) {
TProtoStringType error_message("File recursively imports itself: ");
for (size_t i = from_here; i < tables_->pending_files_.size(); i++) {
@@ -4841,24 +4841,26 @@ void DescriptorBuilder::AddTwiceListedError(const FileDescriptorProto& proto,
int index) {
AddError(proto.dependency(index), proto,
DescriptorPool::ErrorCollector::IMPORT,
- "Import \"" + proto.dependency(index) + "\" was listed twice.");
+ y_absl::StrCat("Import \"", proto.dependency(index),
+ "\" was listed twice."));
}
void DescriptorBuilder::AddImportError(const FileDescriptorProto& proto,
int index) {
TProtoStringType message;
if (pool_->fallback_database_ == nullptr) {
- message = "Import \"" + proto.dependency(index) + "\" has not been loaded.";
+ message = y_absl::StrCat("Import \"", proto.dependency(index),
+ "\" has not been loaded.");
} else {
- message = "Import \"" + proto.dependency(index) +
- "\" was not found or had errors.";
+ message = y_absl::StrCat("Import \"", proto.dependency(index),
+ "\" was not found or had errors.");
}
AddError(proto.dependency(index), proto,
DescriptorPool::ErrorCollector::IMPORT, message);
}
-static bool ExistingFileMatchesProto(const FileDescriptor* existing_file,
- const FileDescriptorProto& proto) {
+PROTOBUF_NOINLINE static bool ExistingFileMatchesProto(
+ const FileDescriptor* existing_file, const FileDescriptorProto& proto) {
FileDescriptorProto existing_proto;
existing_file->CopyTo(&existing_proto);
// TODO(liujisi): Remove it when CopyTo supports copying syntax params when
@@ -4876,7 +4878,7 @@ static bool ExistingFileMatchesProto(const FileDescriptor* existing_file,
// 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.
+// enough memory and will Y_ABSL_CHECK-fail.
static void PlanAllocationSize(
const RepeatedPtrField<EnumValueDescriptorProto>& values,
internal::FlatAllocator& alloc) {
@@ -4982,7 +4984,8 @@ static void PlanAllocationSize(const FileDescriptorProto& proto,
internal::FlatAllocator& alloc) {
alloc.PlanArray<FileDescriptor>(1);
alloc.PlanArray<FileDescriptorTables>(1);
- alloc.PlanArray<TProtoStringType>(2); // name + package
+ alloc.PlanArray<TProtoStringType>(2
+ ); // name + package
if (proto.has_options()) alloc.PlanArray<FileOptions>(1);
if (proto.has_source_code_info()) alloc.PlanArray<SourceCodeInfo>(1);
@@ -5061,16 +5064,16 @@ const FileDescriptor* DescriptorBuilder::BuildFile(
// Checkpoint the tables so that we can roll back if something goes wrong.
tables_->AddCheckpoint();
- internal::FlatAllocator alloc;
- PlanAllocationSize(proto, alloc);
- alloc.FinalizePlanning(tables_);
- FileDescriptor* result = BuildFileImpl(proto, alloc);
+ auto alloc = y_absl::make_unique<internal::FlatAllocator>();
+ PlanAllocationSize(proto, *alloc);
+ alloc->FinalizePlanning(tables_);
+ FileDescriptor* result = BuildFileImpl(proto, *alloc);
file_tables_->FinalizeTables();
if (result) {
tables_->ClearLastCheckpoint();
result->finished_building_ = true;
- alloc.ExpectConsumed();
+ alloc->ExpectConsumed();
} else {
tables_->RollbackToLastCheckpoint();
}
@@ -5111,7 +5114,7 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl(
} else {
file_->syntax_ = FileDescriptor::SYNTAX_UNKNOWN;
AddError(proto.name(), proto, DescriptorPool::ErrorCollector::OTHER,
- "Unrecognized syntax: " + proto.syntax());
+ y_absl::StrCat("Unrecognized syntax: ", proto.syntax()));
}
result->name_ = alloc.AllocateStrings(proto.name());
@@ -5128,7 +5131,7 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl(
if (result->name().find('\0') != TProtoStringType::npos) {
AddError(result->name(), proto, DescriptorPool::ErrorCollector::NAME,
- "\"" + result->name() + "\" contains null character.");
+ y_absl::StrCat("\"", result->name(), "\" contains null character."));
return nullptr;
}
@@ -5151,13 +5154,13 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl(
}
// Make sure all dependencies are loaded.
- std::set<TProtoStringType> seen_dependencies;
+ y_absl::flat_hash_set<y_absl::string_view> seen_dependencies;
result->dependency_count_ = proto.dependency_size();
result->dependencies_ =
alloc.AllocateArray<const FileDescriptor*>(proto.dependency_size());
result->dependencies_once_ = nullptr;
unused_dependency_.clear();
- std::set<int> weak_deps;
+ y_absl::flat_hash_set<int> weak_deps;
for (int i = 0; i < proto.weak_dependency_size(); ++i) {
weak_deps.insert(proto.weak_dependency(i));
}
@@ -5183,7 +5186,7 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl(
if (dependency == nullptr) {
if (!pool_->lazily_build_dependencies_) {
if (pool_->allow_unknown_ ||
- (!pool_->enforce_weak_ && weak_deps.find(i) != weak_deps.end())) {
+ (!pool_->enforce_weak_ && weak_deps.contains(i))) {
internal::FlatAllocator lazy_dep_alloc;
lazy_dep_alloc.PlanArray<FileDescriptor>(1);
lazy_dep_alloc.PlanArray<TProtoStringType>(1);
@@ -5220,8 +5223,8 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl(
}
void* data = tables_->AllocateBytes(
- static_cast<int>(sizeof(internal::once_flag) + total_char_size));
- result->dependencies_once_ = ::new (data) internal::once_flag{};
+ static_cast<int>(sizeof(y_absl::once_flag)) + total_char_size);
+ result->dependencies_once_ = ::new (data) y_absl::once_flag{};
char* name_data = reinterpret_cast<char*>(result->dependencies_once_ + 1);
for (int i = 0; i < proto.dependency_size(); i++) {
@@ -5358,7 +5361,7 @@ const TProtoStringType* DescriptorBuilder::AllocateNameStrings(
return alloc.AllocateStrings(proto_name, proto_name);
} else {
return alloc.AllocateStrings(proto_name,
- StrCat(scope, ".", proto_name));
+ y_absl::StrCat(scope, ".", proto_name));
}
}
@@ -5452,7 +5455,7 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto,
if (range1.end() > range2.start() && range2.end() > range1.start()) {
AddError(result->full_name(), proto.reserved_range(i),
DescriptorPool::ErrorCollector::NUMBER,
- strings::Substitute("Reserved range $0 to $1 overlaps with "
+ y_absl::Substitute("Reserved range $0 to $1 overlaps with "
"already-defined range $2 to $3.",
range2.start(), range2.end() - 1,
range1.start(), range1.end() - 1));
@@ -5460,19 +5463,19 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto,
}
}
- HASH_SET<TProtoStringType> reserved_name_set;
+ y_absl::flat_hash_set<TProtoStringType> reserved_name_set;
for (int i = 0; i < proto.reserved_name_size(); i++) {
const TProtoStringType& name = proto.reserved_name(i);
- if (reserved_name_set.find(name) == reserved_name_set.end()) {
- reserved_name_set.insert(name);
- } else {
+ if (!reserved_name_set.insert(name).second) {
AddError(name, proto, DescriptorPool::ErrorCollector::NAME,
- strings::Substitute("Field name \"$0\" is reserved multiple times.",
+ y_absl::Substitute("Field name \"$0\" is reserved multiple times.",
name));
}
}
+ // Check that fields aren't using reserved names or numbers and that they
+ // aren't using extension numbers.
for (int i = 0; i < result->field_count(); i++) {
const FieldDescriptor* field = result->field(i);
for (int j = 0; j < result->extension_range_count(); j++) {
@@ -5483,7 +5486,7 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto,
AddError(
field->full_name(), proto.extension_range(j),
DescriptorPool::ErrorCollector::NUMBER,
- strings::Substitute(
+ y_absl::Substitute(
"Extension range $0 to $1 includes field \"$2\" ($3).",
range->start, range->end - 1, field->name(), field->number()));
}
@@ -5495,7 +5498,7 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto,
proto.reserved_range(j), DescriptorPool::ErrorCollector::NUMBER);
AddError(field->full_name(), proto.reserved_range(j),
DescriptorPool::ErrorCollector::NUMBER,
- strings::Substitute("Field \"$0\" uses reserved number $1.",
+ y_absl::Substitute("Field \"$0\" uses reserved number $1.",
field->name(), field->number()));
}
}
@@ -5503,7 +5506,7 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto,
AddError(
field->full_name(), proto.field(i),
DescriptorPool::ErrorCollector::NAME,
- strings::Substitute("Field name \"$0\" is reserved.", field->name()));
+ y_absl::Substitute("Field name \"$0\" is reserved.", field->name()));
}
}
@@ -5517,7 +5520,7 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto,
if (range1->end > range2->start && range2->end > range1->start) {
AddError(result->full_name(), proto.extension_range(i),
DescriptorPool::ErrorCollector::NUMBER,
- strings::Substitute("Extension range $0 to $1 overlaps with "
+ y_absl::Substitute("Extension range $0 to $1 overlaps with "
"reserved range $2 to $3.",
range1->start, range1->end - 1, range2->start,
range2->end - 1));
@@ -5528,7 +5531,7 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto,
if (range1->end > range2->start && range2->end > range1->start) {
AddError(result->full_name(), proto.extension_range(i),
DescriptorPool::ErrorCollector::NUMBER,
- strings::Substitute("Extension range $0 to $1 overlaps with "
+ y_absl::Substitute("Extension range $0 to $1 overlaps with "
"already-defined range $2 to $3.",
range2->start, range2->end - 1, range1->start,
range1->end - 1));
@@ -5537,6 +5540,104 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto,
}
}
+void DescriptorBuilder::CheckFieldJsonNameUniqueness(
+ const DescriptorProto& proto, const Descriptor* result) {
+ FileDescriptor::Syntax syntax = result->file()->syntax();
+ TProtoStringType message_name = result->full_name();
+ if (pool_->deprecated_legacy_json_field_conflicts_ ||
+ IsLegacyJsonFieldConflictEnabled(result->options())) {
+ if (syntax == FileDescriptor::SYNTAX_PROTO3) {
+ // Only check default JSON names for conflicts in proto3. This is legacy
+ // behavior that will be removed in a later version.
+ CheckFieldJsonNameUniqueness(message_name, proto, syntax, false);
+ }
+ } else {
+ // Check both with and without taking json_name into consideration. This is
+ // needed for field masks, which don't use json_name.
+ CheckFieldJsonNameUniqueness(message_name, proto, syntax, false);
+ CheckFieldJsonNameUniqueness(message_name, proto, syntax, true);
+ }
+}
+
+namespace {
+// Helpers for function below
+
+struct JsonNameDetails {
+ const FieldDescriptorProto* field;
+ TProtoStringType orig_name;
+ bool is_custom;
+};
+
+JsonNameDetails GetJsonNameDetails(const FieldDescriptorProto* field,
+ bool use_custom) {
+ TProtoStringType default_json_name = ToJsonName(field->name());
+ if (use_custom && field->has_json_name() &&
+ field->json_name() != default_json_name) {
+ return {field, field->json_name(), true};
+ }
+ return {field, default_json_name, false};
+}
+
+bool JsonNameLooksLikeExtension(TProtoStringType name) {
+ return !name.empty() && name.front() == '[' && name.back() == ']';
+}
+
+} // namespace
+
+void DescriptorBuilder::CheckFieldJsonNameUniqueness(
+ const TProtoStringType& message_name, const DescriptorProto& message,
+ FileDescriptor::Syntax syntax, bool use_custom_names) {
+ y_absl::flat_hash_map<TProtoStringType, JsonNameDetails> name_to_field;
+ for (const FieldDescriptorProto& field : message.field()) {
+ JsonNameDetails details = GetJsonNameDetails(&field, use_custom_names);
+ if (details.is_custom && JsonNameLooksLikeExtension(details.orig_name)) {
+ TProtoStringType error_message = y_absl::StrFormat(
+ "The custom JSON name of field \"%s\" (\"%s\") is invalid: "
+ "JSON names may not start with '[' and end with ']'.",
+ field.name(), details.orig_name);
+ AddError(message_name, field, DescriptorPool::ErrorCollector::NAME,
+ error_message);
+ continue;
+ }
+ auto it_inserted = name_to_field.try_emplace(details.orig_name, details);
+ if (it_inserted.second) {
+ continue;
+ }
+ JsonNameDetails& match = it_inserted.first->second;
+ if (use_custom_names && !details.is_custom && !match.is_custom) {
+ // if this pass is considering custom JSON names, but neither of the
+ // names involved in the conflict are custom, don't bother with a
+ // message. That will have been reported from other pass (non-custom
+ // JSON names).
+ continue;
+ }
+ y_absl::string_view this_type = details.is_custom ? "custom" : "default";
+ y_absl::string_view existing_type = match.is_custom ? "custom" : "default";
+ // If the matched name differs (which it can only differ in case), include
+ // it in the error message, for maximum clarity to user.
+ TProtoStringType name_suffix = "";
+ if (details.orig_name != match.orig_name) {
+ name_suffix = y_absl::StrCat(" (\"", match.orig_name, "\")");
+ }
+ TProtoStringType error_message = y_absl::StrFormat(
+ "The %s JSON name of field \"%s\" (\"%s\") conflicts "
+ "with the %s JSON name of field \"%s\"%s.",
+ this_type, field.name(), details.orig_name, existing_type,
+ match.field->name(), name_suffix);
+
+ bool involves_default = !details.is_custom || !match.is_custom;
+ if (syntax == FileDescriptor::SYNTAX_PROTO2 && involves_default) {
+ // TODO(b/261750676) Upgrade this to an error once downstream protos have
+ // been fixed.
+ AddWarning(message_name, field, DescriptorPool::ErrorCollector::NAME,
+ error_message);
+ } else {
+ AddError(message_name, field, DescriptorPool::ErrorCollector::NAME,
+ error_message);
+ }
+ }
+}
+
void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto,
Descriptor* parent,
FieldDescriptor* result,
@@ -5566,9 +5667,10 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto,
if (proto.proto3_optional() &&
file_->syntax() != FileDescriptor::SYNTAX_PROTO3) {
AddError(result->full_name(), proto, DescriptorPool::ErrorCollector::TYPE,
- "The [proto3_optional=true] option may only be set on proto3"
- "fields, not " +
- result->full_name());
+ y_absl::StrCat(
+ "The [proto3_optional=true] option may only be set on proto3"
+ "fields, not ",
+ result->full_name()));
}
result->has_json_name_ = proto.has_json_name();
@@ -5576,9 +5678,9 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto,
// Some compilers do not allow static_cast directly between two enum types,
// so we must cast to int first.
result->type_ = static_cast<FieldDescriptor::Type>(
- implicit_cast<int>(proto.type()));
+ y_absl::implicit_cast<int>(proto.type()));
result->label_ = static_cast<FieldDescriptor::Label>(
- implicit_cast<int>(proto.label()));
+ y_absl::implicit_cast<int>(proto.label()));
if (result->label_ == FieldDescriptor::LABEL_REQUIRED) {
// An extension cannot have a required field (b/13365836).
@@ -5590,7 +5692,8 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto,
// `ErrorCollector` interface to extend them to handle the new
// error location type properly.
DescriptorPool::ErrorCollector::TYPE,
- "The extension " + result->full_name() + " cannot be required.");
+ y_absl::StrCat("The extension ", result->full_name(),
+ " cannot be required."));
}
}
@@ -5612,19 +5715,23 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto,
switch (result->cpp_type()) {
case FieldDescriptor::CPPTYPE_INT32:
result->default_value_arc_i32_ =
- strtol(proto.default_value().c_str(), &end_pos, 0);
+ std::strtol(proto.default_value().c_str(), &end_pos, 0);
break;
case FieldDescriptor::CPPTYPE_INT64:
+ static_assert(sizeof(arc_i64) == sizeof(long long),
+ "sizeof arc_i64 is not sizeof long long");
result->default_value_arc_i64_ =
- strto64(proto.default_value().c_str(), &end_pos, 0);
+ std::strtoll(proto.default_value().c_str(), &end_pos, 0);
break;
case FieldDescriptor::CPPTYPE_UINT32:
result->default_value_arc_ui32_ =
- strtoul(proto.default_value().c_str(), &end_pos, 0);
+ std::strtoul(proto.default_value().c_str(), &end_pos, 0);
break;
case FieldDescriptor::CPPTYPE_UINT64:
+ static_assert(sizeof(arc_ui64) == sizeof(unsigned long long),
+ "sizeof arc_ui64 is not sizeof unsigned long long");
result->default_value_arc_ui64_ =
- strtou64(proto.default_value().c_str(), &end_pos, 0);
+ std::strtoull(proto.default_value().c_str(), &end_pos, 0);
break;
case FieldDescriptor::CPPTYPE_FLOAT:
if (proto.default_value() == "inf") {
@@ -5673,8 +5780,9 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto,
break;
case FieldDescriptor::CPPTYPE_STRING:
if (result->type() == FieldDescriptor::TYPE_BYTES) {
- result->default_value_string_ = alloc.AllocateStrings(
- UnescapeCEscapeString(proto.default_value()));
+ TProtoStringType value;
+ y_absl::CUnescape(proto.default_value(), &value);
+ result->default_value_string_ = alloc.AllocateStrings(value);
} else {
result->default_value_string_ =
alloc.AllocateStrings(proto.default_value());
@@ -5696,8 +5804,8 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto,
if (proto.default_value().empty() || *end_pos != '\0') {
AddError(result->full_name(), proto,
DescriptorPool::ErrorCollector::DEFAULT_VALUE,
- "Couldn't parse default value \"" + proto.default_value() +
- "\".");
+ y_absl::StrCat("Couldn't parse default value \"",
+ proto.default_value(), "\"."));
}
}
} else {
@@ -5755,18 +5863,8 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto,
message_hints_[parent].RequestHintOnFieldNumbers(
proto, DescriptorPool::ErrorCollector::NUMBER);
AddError(result->full_name(), proto, DescriptorPool::ErrorCollector::NUMBER,
- strings::Substitute("Field numbers cannot be greater than $0.",
+ y_absl::Substitute("Field numbers cannot be greater than $0.",
FieldDescriptor::kMaxNumber));
- } else if (result->number() >= FieldDescriptor::kFirstReservedNumber &&
- result->number() <= FieldDescriptor::kLastReservedNumber) {
- message_hints_[parent].RequestHintOnFieldNumbers(
- proto, DescriptorPool::ErrorCollector::NUMBER);
- AddError(result->full_name(), proto, DescriptorPool::ErrorCollector::NUMBER,
- strings::Substitute(
- "Field numbers $0 through $1 are reserved for the protocol "
- "buffer library implementation.",
- FieldDescriptor::kFirstReservedNumber,
- FieldDescriptor::kLastReservedNumber));
}
if (is_extension) {
@@ -5797,7 +5895,7 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto,
proto.oneof_index() >= parent->oneof_decl_count()) {
AddError(result->full_name(), proto,
DescriptorPool::ErrorCollector::TYPE,
- strings::Substitute("FieldDescriptorProto.oneof_index $0 is "
+ y_absl::Substitute("FieldDescriptorProto.oneof_index $0 is "
"out of range for type \"$1\".",
proto.oneof_index(), parent->name()));
} else {
@@ -5939,13 +6037,12 @@ void DescriptorBuilder::CheckEnumValueUniqueness(
// NAME_TYPE_LAST_NAME = 2,
// }
PrefixRemover remover(result->name());
- std::map<TProtoStringType, const EnumValueDescriptor*> values;
+ y_absl::flat_hash_map<TProtoStringType, const EnumValueDescriptor*> values;
for (int i = 0; i < result->value_count(); i++) {
const EnumValueDescriptor* value = result->value(i);
TProtoStringType stripped =
EnumValueToPascalCase(remover.MaybeRemove(value->name()));
- std::pair<std::map<TProtoStringType, const EnumValueDescriptor*>::iterator, bool>
- insert_result = values.insert(std::make_pair(stripped, value));
+ auto insert_result = values.try_emplace(stripped, value);
bool inserted = insert_result.second;
// We don't throw the error if the two conflicting symbols are identical, or
@@ -5956,22 +6053,22 @@ void DescriptorBuilder::CheckEnumValueUniqueness(
// stripping should de-dup the labels in this case).
if (!inserted && insert_result.first->second->name() != value->name() &&
insert_result.first->second->number() != value->number()) {
- TProtoStringType error_message =
- "Enum name " + value->name() + " has the same name as " +
- values[stripped]->name() +
- " if you ignore case and strip out the enum name prefix (if any). "
- "This is error-prone and can lead to undefined behavior. "
- "Please avoid doing this. If you are using allow_alias, please "
- "assign the same numeric value to both enums.";
+ TProtoStringType error_message = y_absl::StrFormat(
+ "Enum name %s has the same name as %s if you ignore case and strip "
+ "out the enum name prefix (if any). (If you are using allow_alias, "
+ "please assign the same numeric value to both enums.)",
+ value->name(), insert_result.first->second->name());
// There are proto2 enums out there with conflicting names, so to preserve
// compatibility we issue only a warning for proto2.
- if (result->file()->syntax() == FileDescriptor::SYNTAX_PROTO2) {
+ if ((pool_->deprecated_legacy_json_field_conflicts_ ||
+ IsLegacyJsonFieldConflictEnabled(result->options())) &&
+ result->file()->syntax() == FileDescriptor::SYNTAX_PROTO2) {
AddWarning(value->full_name(), proto.value(i),
DescriptorPool::ErrorCollector::NAME, error_message);
- } else {
- AddError(value->full_name(), proto.value(i),
- DescriptorPool::ErrorCollector::NAME, error_message);
+ continue;
}
+ AddError(value->full_name(), proto.value(i),
+ DescriptorPool::ErrorCollector::NAME, error_message);
}
}
}
@@ -6025,8 +6122,6 @@ void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto,
alloc.AllocateStrings(proto.reserved_name(i));
}
- CheckEnumValueUniqueness(proto, result);
-
// Copy options.
result->options_ = nullptr; // Set to default_instance later if necessary.
if (proto.has_options()) {
@@ -6046,7 +6141,7 @@ void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto,
if (range1.end() >= range2.start() && range2.end() >= range1.start()) {
AddError(result->full_name(), proto.reserved_range(i),
DescriptorPool::ErrorCollector::NUMBER,
- strings::Substitute("Reserved range $0 to $1 overlaps with "
+ y_absl::Substitute("Reserved range $0 to $1 overlaps with "
"already-defined range $2 to $3.",
range2.start(), range2.end(), range1.start(),
range1.end()));
@@ -6054,14 +6149,14 @@ void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto,
}
}
- HASH_SET<TProtoStringType> reserved_name_set;
+ y_absl::flat_hash_set<TProtoStringType> reserved_name_set;
for (int i = 0; i < proto.reserved_name_size(); i++) {
const TProtoStringType& name = proto.reserved_name(i);
if (reserved_name_set.find(name) == reserved_name_set.end()) {
reserved_name_set.insert(name);
} else {
AddError(name, proto, DescriptorPool::ErrorCollector::NAME,
- strings::Substitute("Enum value \"$0\" is reserved multiple times.",
+ y_absl::Substitute("Enum value \"$0\" is reserved multiple times.",
name));
}
}
@@ -6073,7 +6168,7 @@ void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto,
if (range->start <= value->number() && value->number() <= range->end) {
AddError(value->full_name(), proto.reserved_range(j),
DescriptorPool::ErrorCollector::NUMBER,
- strings::Substitute("Enum value \"$0\" uses reserved number $1.",
+ y_absl::Substitute("Enum value \"$0\" uses reserved number $1.",
value->name(), value->number()));
}
}
@@ -6081,7 +6176,7 @@ void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto,
AddError(
value->full_name(), proto.value(i),
DescriptorPool::ErrorCollector::NAME,
- strings::Substitute("Enum value \"$0\" is reserved.", value->name()));
+ y_absl::Substitute("Enum value \"$0\" is reserved.", value->name()));
}
}
}
@@ -6141,15 +6236,16 @@ void DescriptorBuilder::BuildEnumValue(const EnumValueDescriptorProto& proto,
if (outer_scope.empty()) {
outer_scope = "the global scope";
} else {
- outer_scope = "\"" + outer_scope + "\"";
+ outer_scope = y_absl::StrCat("\"", outer_scope, "\"");
}
AddError(result->full_name(), proto, DescriptorPool::ErrorCollector::NAME,
- "Note that enum values use C++ scoping rules, meaning that "
- "enum values are siblings of their type, not children of it. "
- "Therefore, \"" +
- result->name() + "\" must be unique within " + outer_scope +
- ", not just within \"" + parent->name() + "\".");
+ y_absl::StrCat(
+ "Note that enum values use C++ scoping rules, meaning that "
+ "enum values are siblings of their type, not children of it. "
+ "Therefore, \"",
+ result->name(), "\" must be unique within ", outer_scope,
+ ", not just within \"", parent->name(), "\"."));
}
// An enum is allowed to define two numbers that refer to the same value.
@@ -6277,9 +6373,10 @@ void DescriptorBuilder::CrossLinkMessage(Descriptor* message,
// safe.
if (oneof_decl->field_count() > 0 &&
message->field(i - 1)->containing_oneof() != oneof_decl) {
- AddError(message->full_name() + "." + message->field(i - 1)->name(),
+ AddError(y_absl::StrCat(message->full_name(), ".",
+ message->field(i - 1)->name()),
proto.field(i - 1), DescriptorPool::ErrorCollector::TYPE,
- strings::Substitute(
+ y_absl::Substitute(
"Fields in the same oneof must be defined consecutively. "
"\"$0\" cannot be defined before the completion of the "
"\"$1\" oneof definition.",
@@ -6296,8 +6393,8 @@ void DescriptorBuilder::CrossLinkMessage(Descriptor* message,
// Verify that they are contiguous.
// This is assumed by OneofDescriptor::field(i).
// But only if there are no errors.
- GOOGLE_CHECK_EQ(out_oneof_decl.fields_ + out_oneof_decl.field_count_,
- message->field(i));
+ Y_ABSL_CHECK_EQ(out_oneof_decl.fields_ + out_oneof_decl.field_count_,
+ message->field(i));
}
++out_oneof_decl.field_count_;
}
@@ -6308,7 +6405,7 @@ void DescriptorBuilder::CrossLinkMessage(Descriptor* message,
OneofDescriptor* oneof_decl = &message->oneof_decls_[i];
if (oneof_decl->field_count() == 0) {
- AddError(message->full_name() + "." + oneof_decl->name(),
+ AddError(y_absl::StrCat(message->full_name(), ".", oneof_decl->name()),
proto.oneof_decl(i), DescriptorPool::ErrorCollector::NAME,
"Oneof must have at least one field.");
}
@@ -6363,6 +6460,7 @@ void DescriptorBuilder::CrossLinkExtensionRange(
}
}
+
void DescriptorBuilder::CrossLinkField(FieldDescriptor* field,
const FieldDescriptorProto& proto) {
if (field->options_ == nullptr) {
@@ -6379,9 +6477,9 @@ void DescriptorBuilder::CrossLinkField(FieldDescriptor* field,
proto.extendee());
return;
} else if (extendee.type() != Symbol::MESSAGE) {
- AddError(field->full_name(), proto,
- DescriptorPool::ErrorCollector::EXTENDEE,
- "\"" + proto.extendee() + "\" is not a message type.");
+ AddError(
+ field->full_name(), proto, DescriptorPool::ErrorCollector::EXTENDEE,
+ y_absl::StrCat("\"", proto.extendee(), "\" is not a message type."));
return;
}
field->containing_type_ = extendee.descriptor();
@@ -6399,7 +6497,7 @@ void DescriptorBuilder::CrossLinkField(FieldDescriptor* field,
if (!skip_check) {
AddError(field->full_name(), proto,
DescriptorPool::ErrorCollector::NUMBER,
- strings::Substitute("\"$0\" does not declare $1 as an "
+ y_absl::Substitute("\"$0\" does not declare $1 as an "
"extension number.",
field->containing_type()->full_name(),
field->number()));
@@ -6449,8 +6547,9 @@ void DescriptorBuilder::CrossLinkField(FieldDescriptor* field,
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{};
+ field->type_once_ = ::new (tables_->AllocateBytes(
+ static_cast<int>(sizeof(y_absl::once_flag)) + name_sizes))
+ y_absl::once_flag{};
char* names = reinterpret_cast<char*>(field->type_once_ + 1);
memcpy(names, name.c_str(), name.size() + 1);
@@ -6491,7 +6590,7 @@ void DescriptorBuilder::CrossLinkField(FieldDescriptor* field,
} else {
AddError(field->full_name(), proto,
DescriptorPool::ErrorCollector::TYPE,
- "\"" + proto.type_name() + "\" is not a type.");
+ y_absl::StrCat("\"", proto.type_name(), "\" is not a type."));
return;
}
}
@@ -6499,9 +6598,9 @@ void DescriptorBuilder::CrossLinkField(FieldDescriptor* field,
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
field->type_descriptor_.message_type = type.descriptor();
if (field->type_descriptor_.message_type == nullptr) {
- AddError(field->full_name(), proto,
- DescriptorPool::ErrorCollector::TYPE,
- "\"" + proto.type_name() + "\" is not a message type.");
+ AddError(
+ field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE,
+ y_absl::StrCat("\"", proto.type_name(), "\" is not a message type."));
return;
}
@@ -6513,9 +6612,9 @@ void DescriptorBuilder::CrossLinkField(FieldDescriptor* field,
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {
field->type_descriptor_.enum_type = type.enum_descriptor();
if (field->type_descriptor_.enum_type == nullptr) {
- AddError(field->full_name(), proto,
- DescriptorPool::ErrorCollector::TYPE,
- "\"" + proto.type_name() + "\" is not an enum type.");
+ AddError(
+ field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE,
+ y_absl::StrCat("\"", proto.type_name(), "\" is not an enum type."));
return;
}
@@ -6548,11 +6647,12 @@ void DescriptorBuilder::CrossLinkField(FieldDescriptor* field,
default_value->type() == field->enum_type()) {
field->default_value_enum_ = default_value;
} else {
- AddError(field->full_name(), proto,
- DescriptorPool::ErrorCollector::DEFAULT_VALUE,
- "Enum type \"" + field->enum_type()->full_name() +
- "\" has no value named \"" + proto.default_value() +
- "\".");
+ AddError(
+ field->full_name(), proto,
+ DescriptorPool::ErrorCollector::DEFAULT_VALUE,
+ y_absl::StrCat("Enum type \"", field->enum_type()->full_name(),
+ "\" has no value named \"", proto.default_value(),
+ "\"."));
}
}
} else if (field->enum_type()->value_count() > 0) {
@@ -6589,14 +6689,14 @@ void DescriptorBuilder::CrossLinkField(FieldDescriptor* field,
if (field->is_extension()) {
AddError(field->full_name(), proto,
DescriptorPool::ErrorCollector::NUMBER,
- strings::Substitute("Extension number $0 has already been used "
+ y_absl::Substitute("Extension number $0 has already been used "
"in \"$1\" by extension \"$2\".",
field->number(), containing_type_name,
conflicting_field->full_name()));
} else {
AddError(field->full_name(), proto,
DescriptorPool::ErrorCollector::NUMBER,
- strings::Substitute("Field number $0 has already been used in "
+ y_absl::Substitute("Field number $0 has already been used in "
"\"$1\" by field \"$2\".",
field->number(), containing_type_name,
conflicting_field->name()));
@@ -6610,7 +6710,7 @@ void DescriptorBuilder::CrossLinkField(FieldDescriptor* field,
field->containing_type() == nullptr
? "unknown"
: field->containing_type()->full_name();
- TProtoStringType error_msg = strings::Substitute(
+ TProtoStringType error_msg = y_absl::Substitute(
"Extension number $0 has already been used in \"$1\" by extension "
"\"$2\" defined in $3.",
field->number(), containing_type_name,
@@ -6675,9 +6775,9 @@ void DescriptorBuilder::CrossLinkMethod(MethodDescriptor* method,
method->input_type_.SetLazy(proto.input_type(), file_);
}
} else if (input_type.type() != Symbol::MESSAGE) {
- AddError(method->full_name(), proto,
- DescriptorPool::ErrorCollector::INPUT_TYPE,
- "\"" + proto.input_type() + "\" is not a message type.");
+ AddError(
+ method->full_name(), proto, DescriptorPool::ErrorCollector::INPUT_TYPE,
+ y_absl::StrCat("\"", proto.input_type(), "\" is not a message type."));
} else {
method->input_type_.Set(input_type.descriptor());
}
@@ -6695,9 +6795,9 @@ void DescriptorBuilder::CrossLinkMethod(MethodDescriptor* method,
method->output_type_.SetLazy(proto.output_type(), file_);
}
} else if (output_type.type() != Symbol::MESSAGE) {
- AddError(method->full_name(), proto,
- DescriptorPool::ErrorCollector::OUTPUT_TYPE,
- "\"" + proto.output_type() + "\" is not a message type.");
+ AddError(
+ method->full_name(), proto, DescriptorPool::ErrorCollector::OUTPUT_TYPE,
+ y_absl::StrCat("\"", proto.output_type(), "\" is not a message type."));
} else {
method->output_type_.Set(output_type.descriptor());
}
@@ -6708,8 +6808,9 @@ void DescriptorBuilder::SuggestFieldNumbers(FileDescriptor* file,
for (int message_index = 0; message_index < file->message_type_count();
message_index++) {
const Descriptor* message = &file->message_types_[message_index];
- auto* hints = FindOrNull(message_hints_, message);
- if (!hints) continue;
+ auto hints_it = message_hints_.find(message);
+ if (hints_it == message_hints_.end()) continue;
+ auto* hints = &hints_it->second;
constexpr int kMaxSuggestions = 3;
int fields_to_suggest = std::min(kMaxSuggestions, hints->fields_to_suggest);
if (fields_to_suggest <= 0) continue;
@@ -6807,10 +6908,10 @@ void DescriptorBuilder::ValidateFileOptions(FileDescriptor* file,
AddError(
file->dependency(i)->name(), proto,
DescriptorPool::ErrorCollector::IMPORT,
- "Files that do not use optimize_for = LITE_RUNTIME cannot import "
- "files which do use this option. This file is not lite, but it "
- "imports \"" +
- file->dependency(i)->name() + "\" which is.");
+ y_absl::StrCat("Files that do not use optimize_for = LITE_RUNTIME "
+ "cannot import files which do use this option. This "
+ "file is not lite, but it imports \"",
+ file->dependency(i)->name(), "\" which is."));
break;
}
}
@@ -6833,20 +6934,6 @@ void DescriptorBuilder::ValidateProto3(FileDescriptor* file,
}
}
-static TProtoStringType ToLowercaseWithoutUnderscores(const TProtoStringType& name) {
- TProtoStringType result;
- for (char character : name) {
- if (character != '_') {
- if (character >= 'A' && character <= 'Z') {
- result.push_back(character - 'A' + 'a');
- } else {
- result.push_back(character);
- }
- }
- }
- return result;
-}
-
void DescriptorBuilder::ValidateProto3Message(Descriptor* message,
const DescriptorProto& proto) {
for (int i = 0; i < message->nested_type_count(); ++i) {
@@ -6871,25 +6958,6 @@ void DescriptorBuilder::ValidateProto3Message(Descriptor* message,
AddError(message->full_name(), proto, DescriptorPool::ErrorCollector::NAME,
"MessageSet is not supported in proto3.");
}
-
- // In proto3, we reject field names if they conflict in camelCase.
- // Note that we currently enforce a stricter rule: Field names must be
- // unique after being converted to lowercase with underscores removed.
- std::map<TProtoStringType, const FieldDescriptor*> name_to_field;
- for (int i = 0; i < message->field_count(); ++i) {
- TProtoStringType lowercase_name =
- ToLowercaseWithoutUnderscores(message->field(i)->name());
- if (name_to_field.find(lowercase_name) != name_to_field.end()) {
- AddError(message->full_name(), proto.field(i),
- DescriptorPool::ErrorCollector::NAME,
- "The JSON camel-case name of field \"" +
- message->field(i)->name() + "\" conflicts with field \"" +
- name_to_field[lowercase_name]->name() + "\". This is not " +
- "allowed in proto3.");
- } else {
- name_to_field[lowercase_name] = message->field(i);
- }
- }
}
void DescriptorBuilder::ValidateProto3Field(FieldDescriptor* field,
@@ -6916,10 +6984,10 @@ void DescriptorBuilder::ValidateProto3Field(FieldDescriptor* field,
// Proto3 messages can only use Proto3 enum types; otherwise we can't
// guarantee that the default value is zero.
AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE,
- "Enum type \"" + field->enum_type()->full_name() +
- "\" is not a proto3 enum, but is used in \"" +
- field->containing_type()->full_name() +
- "\" which is a proto3 message type.");
+ y_absl::StrCat("Enum type \"", field->enum_type()->full_name(),
+ "\" is not a proto3 enum, but is used in \"",
+ field->containing_type()->full_name(),
+ "\" which is a proto3 message type."));
}
if (field->type() == FieldDescriptor::TYPE_GROUP) {
AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE,
@@ -6943,6 +7011,8 @@ void DescriptorBuilder::ValidateMessageOptions(Descriptor* message,
VALIDATE_OPTIONS_FROM_ARRAY(message, enum_type, Enum);
VALIDATE_OPTIONS_FROM_ARRAY(message, extension, Field);
+ CheckFieldJsonNameUniqueness(proto, message);
+
const arc_i64 max_extension_range =
static_cast<arc_i64>(message->options().message_set_wire_format()
? std::numeric_limits<arc_i32>::max()
@@ -6951,7 +7021,7 @@ void DescriptorBuilder::ValidateMessageOptions(Descriptor* message,
if (message->extension_range(i)->end > max_extension_range + 1) {
AddError(message->full_name(), proto.extension_range(i),
DescriptorPool::ErrorCollector::NUMBER,
- strings::Substitute("Extension numbers cannot be greater than $0.",
+ y_absl::Substitute("Extension numbers cannot be greater than $0.",
max_extension_range));
}
@@ -7029,7 +7099,7 @@ void DescriptorBuilder::ValidateFieldOptions(
// determine whether the json_name option is set on the field. Here we
// compare it against the default calculated json_name value and consider
// the option set if they are different. This won't catch the case when
- // an user explicitly sets json_name to the default value, but should be
+ // a user explicitly sets json_name to the default value, but should be
// good enough to catch common misuses.
if (field->is_extension() &&
(field->has_json_name() &&
@@ -7044,24 +7114,27 @@ void DescriptorBuilder::ValidateFieldOptions(
void DescriptorBuilder::ValidateEnumOptions(EnumDescriptor* enm,
const EnumDescriptorProto& proto) {
VALIDATE_OPTIONS_FROM_ARRAY(enm, value, EnumValue);
+
+ CheckEnumValueUniqueness(proto, enm);
+
if (!enm->options().has_allow_alias() || !enm->options().allow_alias()) {
- std::map<int, TProtoStringType> used_values;
+ y_absl::flat_hash_map<int, TProtoStringType> used_values;
for (int i = 0; i < enm->value_count(); ++i) {
const EnumValueDescriptor* enum_value = enm->value(i);
- if (used_values.find(enum_value->number()) != used_values.end()) {
- TProtoStringType error =
- "\"" + enum_value->full_name() +
- "\" uses the same enum value as \"" +
- used_values[enum_value->number()] +
+ auto insert_result =
+ used_values.emplace(enum_value->number(), enum_value->full_name());
+ bool inserted = insert_result.second;
+ if (!inserted) {
+ TProtoStringType error = y_absl::StrCat(
+ "\"", enum_value->full_name(), "\" uses the same enum value as \"",
+ insert_result.first->second,
"\". If this is intended, set "
- "'option allow_alias = true;' to the enum definition.";
+ "'option allow_alias = true;' to the enum definition.");
if (!enm->options().allow_alias()) {
// Generate error if duplicated enum values are explicitly disallowed.
AddError(enm->full_name(), proto.value(i),
DescriptorPool::ErrorCollector::NUMBER, error);
}
- } else {
- used_values[enum_value->number()] = enum_value->full_name();
}
}
}
@@ -7111,7 +7184,8 @@ bool DescriptorBuilder::ValidateMapEntry(FieldDescriptor* field,
// Must contain exactly two fields
message->field_count() != 2 ||
// Field name and message name must match
- message->name() != ToCamelCase(field->name(), false) + "Entry" ||
+ message->name() !=
+ y_absl::StrCat(ToCamelCase(field->name(), false), "Entry") ||
// Entry message must be in the same containing type of the field.
field->containing_type() != message->containing_type()) {
return false;
@@ -7173,18 +7247,18 @@ bool DescriptorBuilder::ValidateMapEntry(FieldDescriptor* field,
void DescriptorBuilder::DetectMapConflicts(const Descriptor* message,
const DescriptorProto& proto) {
- std::map<TProtoStringType, const Descriptor*> seen_types;
+ y_absl::flat_hash_map<TProtoStringType, const Descriptor*> seen_types;
for (int i = 0; i < message->nested_type_count(); ++i) {
const Descriptor* nested = message->nested_type(i);
- std::pair<std::map<TProtoStringType, const Descriptor*>::iterator, bool> result =
- seen_types.insert(std::make_pair(nested->name(), nested));
- if (!result.second) {
- if (result.first->second->options().map_entry() ||
+ auto insert_result = seen_types.emplace(nested->name(), nested);
+ bool inserted = insert_result.second;
+ if (!inserted) {
+ if (insert_result.first->second->options().map_entry() ||
nested->options().map_entry()) {
- AddError(message->full_name(), proto,
- DescriptorPool::ErrorCollector::NAME,
- "Expanded map entry type " + nested->name() +
- " conflicts with an existing nested message type.");
+ AddError(
+ message->full_name(), proto, DescriptorPool::ErrorCollector::NAME,
+ y_absl::StrCat("Expanded map entry type ", nested->name(),
+ " conflicts with an existing nested message type."));
break;
}
}
@@ -7194,37 +7268,34 @@ void DescriptorBuilder::DetectMapConflicts(const Descriptor* message,
// Check for conflicted field names.
for (int i = 0; i < message->field_count(); ++i) {
const FieldDescriptor* field = message->field(i);
- std::map<TProtoStringType, const Descriptor*>::iterator iter =
- seen_types.find(field->name());
+ auto iter = seen_types.find(field->name());
if (iter != seen_types.end() && iter->second->options().map_entry()) {
AddError(message->full_name(), proto,
DescriptorPool::ErrorCollector::NAME,
- "Expanded map entry type " + iter->second->name() +
- " conflicts with an existing field.");
+ y_absl::StrCat("Expanded map entry type ", iter->second->name(),
+ " conflicts with an existing field."));
}
}
// Check for conflicted enum names.
for (int i = 0; i < message->enum_type_count(); ++i) {
const EnumDescriptor* enum_desc = message->enum_type(i);
- std::map<TProtoStringType, const Descriptor*>::iterator iter =
- seen_types.find(enum_desc->name());
+ auto iter = seen_types.find(enum_desc->name());
if (iter != seen_types.end() && iter->second->options().map_entry()) {
AddError(message->full_name(), proto,
DescriptorPool::ErrorCollector::NAME,
- "Expanded map entry type " + iter->second->name() +
- " conflicts with an existing enum type.");
+ y_absl::StrCat("Expanded map entry type ", iter->second->name(),
+ " conflicts with an existing enum type."));
}
}
// Check for conflicted oneof names.
for (int i = 0; i < message->oneof_decl_count(); ++i) {
const OneofDescriptor* oneof_desc = message->oneof_decl(i);
- std::map<TProtoStringType, const Descriptor*>::iterator iter =
- seen_types.find(oneof_desc->name());
+ auto iter = seen_types.find(oneof_desc->name());
if (iter != seen_types.end() && iter->second->options().map_entry()) {
AddError(message->full_name(), proto,
DescriptorPool::ErrorCollector::NAME,
- "Expanded map entry type " + iter->second->name() +
- " conflicts with an existing oneof type.");
+ y_absl::StrCat("Expanded map entry type ", iter->second->name(),
+ " conflicts with an existing oneof type."));
}
}
}
@@ -7250,9 +7321,10 @@ void DescriptorBuilder::ValidateJSType(FieldDescriptor* field,
return;
}
AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE,
- "Illegal jstype for int64, uint64, sint64, fixed64 "
- "or sfixed64 field: " +
- FieldOptions_JSType_descriptor()->value(jstype)->name());
+ y_absl::StrCat(
+ "Illegal jstype for int64, uint64, sint64, fixed64 "
+ "or sfixed64 field: ",
+ FieldOptions_JSType_descriptor()->value(jstype)->name()));
break;
// No other types permit a jstype option.
@@ -7271,7 +7343,7 @@ void DescriptorBuilder::ValidateJSType(FieldDescriptor* field,
DescriptorBuilder::OptionInterpreter::OptionInterpreter(
DescriptorBuilder* builder)
: builder_(builder) {
- GOOGLE_CHECK(builder_);
+ Y_ABSL_CHECK(builder_);
}
DescriptorBuilder::OptionInterpreter::~OptionInterpreter() {}
@@ -7290,7 +7362,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretOptions(
// and clear them, since we're about to interpret them.
const FieldDescriptor* uninterpreted_options_field =
options->GetDescriptor()->FindFieldByName("uninterpreted_option");
- GOOGLE_CHECK(uninterpreted_options_field != nullptr)
+ Y_ABSL_CHECK(uninterpreted_options_field != nullptr)
<< "No field named \"uninterpreted_option\" in the Options proto.";
options->GetReflection()->ClearField(options, uninterpreted_options_field);
@@ -7301,7 +7373,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretOptions(
const FieldDescriptor* original_uninterpreted_options_field =
original_options->GetDescriptor()->FindFieldByName(
"uninterpreted_option");
- GOOGLE_CHECK(original_uninterpreted_options_field != nullptr)
+ Y_ABSL_CHECK(original_uninterpreted_options_field != nullptr)
<< "No field named \"uninterpreted_option\" in the Options proto.";
const int num_uninterpreted_options =
@@ -7309,7 +7381,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretOptions(
*original_options, original_uninterpreted_options_field);
for (int i = 0; i < num_uninterpreted_options; ++i) {
src_path.push_back(i);
- uninterpreted_option_ = down_cast<const UninterpretedOption*>(
+ uninterpreted_option_ = DownCast<const UninterpretedOption*>(
&original_options->GetReflection()->GetRepeatedMessage(
*original_options, original_uninterpreted_options_field, i));
if (!InterpretSingleOption(options, src_path,
@@ -7344,13 +7416,14 @@ bool DescriptorBuilder::OptionInterpreter::InterpretOptions(
builder_->AddError(
options_to_interpret->element_name, *original_options,
DescriptorPool::ErrorCollector::OTHER,
- "Some options could not be correctly parsed using the proto "
- "descriptors compiled into this binary.\n"
- "Unparsed options: " +
- unparsed_options->ShortDebugString() +
+ y_absl::StrCat(
+ "Some options could not be correctly parsed using the proto "
+ "descriptors compiled into this binary.\n"
+ "Unparsed options: ",
+ unparsed_options->ShortDebugString(),
"\n"
- "Parsing attempt: " +
- options->ShortDebugString());
+ "Parsing attempt: ",
+ options->ShortDebugString()));
// Restore the unparsed options.
options->GetReflection()->Swap(unparsed_options.get(), options);
}
@@ -7370,8 +7443,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption(
}
if (uninterpreted_option_->name(0).name_part() == "uninterpreted_option") {
return AddNameError(
- "Option must not use reserved name "
- "\"uninterpreted_option\".");
+ "Option must not use reserved name \"uninterpreted_option\".");
}
const Descriptor* options_descriptor = nullptr;
@@ -7394,7 +7466,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption(
// generated pool's mutex, so we can search it the straightforward way.
options_descriptor = options->GetDescriptor();
}
- GOOGLE_CHECK(options_descriptor);
+ Y_ABSL_CHECK(options_descriptor);
// We iterate over the name parts to drill into the submessages until we find
// the leaf field for the option. As we drill down we remember the current
@@ -7412,11 +7484,11 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption(
for (int i = 0; i < uninterpreted_option_->name_size(); ++i) {
builder_->undefine_resolved_name_.clear();
const TProtoStringType& name_part = uninterpreted_option_->name(i).name_part();
- if (debug_msg_name.size() > 0) {
- debug_msg_name += ".";
+ if (!debug_msg_name.empty()) {
+ y_absl::StrAppend(&debug_msg_name, ".");
}
if (uninterpreted_option_->name(i).is_extension()) {
- debug_msg_name += "(" + name_part + ")";
+ y_absl::StrAppend(&debug_msg_name, "(", name_part, ")");
// Search for the extension's descriptor as an extension in the builder's
// pool. Note that we use DescriptorBuilder::LookupSymbol(), not
// DescriptorPool::FindExtensionByName(), for two reasons: 1) It allows
@@ -7430,7 +7502,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption(
// pool. We require that you import the file that defines any extensions
// you use, so they must be present in the builder's pool.
} else {
- debug_msg_name += name_part;
+ y_absl::StrAppend(&debug_msg_name, name_part);
// Search for the field's descriptor as a regular field.
field = descriptor->FindFieldByName(name_part);
}
@@ -7443,18 +7515,17 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption(
return true;
} else if (!(builder_->undefine_resolved_name_).empty()) {
// Option is resolved to a name which is not defined.
- return AddNameError(
- "Option \"" + debug_msg_name + "\" is resolved to \"(" +
- builder_->undefine_resolved_name_ +
+ return AddNameError(y_absl::StrCat(
+ "Option \"", debug_msg_name, "\" is resolved to \"(",
+ builder_->undefine_resolved_name_,
")\", which is not defined. The innermost scope is searched first "
- "in name resolution. Consider using a leading '.'(i.e., \"(." +
- debug_msg_name.substr(1) +
- "\") to start from the outermost scope.");
+ "in name resolution. Consider using a leading '.'(i.e., \"(.",
+ debug_msg_name.substr(1),
+ "\") to start from the outermost scope."));
} else {
- return AddNameError(
- "Option \"" + debug_msg_name +
- "\" unknown. Ensure that your proto" +
- " definition file imports the proto which defines the option.");
+ return AddNameError(y_absl::StrCat(
+ "Option \"", debug_msg_name, "\" unknown. Ensure that your proto",
+ " definition file imports the proto which defines the option."));
}
} else if (field->containing_type() != descriptor) {
if (get_is_placeholder(field->containing_type())) {
@@ -7469,9 +7540,10 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption(
// This can only happen if, due to some insane misconfiguration of the
// pools, we find the options message in one pool but the field in
// another. This would probably imply a hefty bug somewhere.
- return AddNameError("Option field \"" + debug_msg_name +
- "\" is not a field or extension of message \"" +
- descriptor->name() + "\".");
+ return AddNameError(
+ y_absl::StrCat("Option field \"", debug_msg_name,
+ "\" is not a field or extension of message \"",
+ descriptor->name(), "\"."));
}
} else {
// accumulate field numbers to form path to interpreted option
@@ -7479,13 +7551,15 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption(
if (i < uninterpreted_option_->name_size() - 1) {
if (field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) {
- return AddNameError("Option \"" + debug_msg_name +
- "\" is an atomic type, not a message.");
+ return AddNameError(
+ y_absl::StrCat("Option \"", debug_msg_name,
+ "\" is an atomic type, not a message."));
} else if (field->is_repeated()) {
- return AddNameError("Option field \"" + debug_msg_name +
- "\" is a repeated message. Repeated message "
- "options must be initialized using an "
- "aggregate value.");
+ return AddNameError(
+ y_absl::StrCat("Option field \"", debug_msg_name,
+ "\" is a repeated message. Repeated message "
+ "options must be initialized using an "
+ "aggregate value."));
} else {
// Drill down into the submessage.
intermediate_fields.push_back(field);
@@ -7529,7 +7603,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption(
case FieldDescriptor::TYPE_MESSAGE: {
TProtoStringType* outstr =
parent_unknown_fields->AddLengthDelimited((*iter)->number());
- GOOGLE_CHECK(unknown_fields->SerializeToString(outstr))
+ Y_ABSL_CHECK(unknown_fields->SerializeToString(outstr))
<< "Unexpected failure while serializing option submessage "
<< debug_msg_name << "\".";
break;
@@ -7542,8 +7616,8 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption(
}
default:
- GOOGLE_LOG(FATAL) << "Invalid wire type for CPPTYPE_MESSAGE: "
- << (*iter)->type();
+ Y_ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_MESSAGE: "
+ << (*iter)->type();
return false;
}
unknown_fields.reset(parent_unknown_fields.release());
@@ -7617,8 +7691,7 @@ void DescriptorBuilder::OptionInterpreter::UpdateSourceCodeInfo(
pathv.push_back(loc->path(j));
}
- std::map<std::vector<int>, std::vector<int>>::iterator entry =
- interpreted_paths_.find(pathv);
+ auto entry = interpreted_paths_.find(pathv);
if (entry == interpreted_paths_.end()) {
// not a match
@@ -7661,7 +7734,7 @@ void DescriptorBuilder::OptionInterpreter::AddWithoutInterpreting(
const UninterpretedOption& uninterpreted_option, Message* options) {
const FieldDescriptor* field =
options->GetDescriptor()->FindFieldByName("uninterpreted_option");
- GOOGLE_CHECK(field != nullptr);
+ Y_ABSL_CHECK(field != nullptr);
options->GetReflection()
->AddMessage(options, field)
@@ -7682,8 +7755,8 @@ bool DescriptorBuilder::OptionInterpreter::ExamineIfOptionIsSet(
// We're at the innermost submessage.
for (int i = 0; i < unknown_fields.field_count(); i++) {
if (unknown_fields.field(i).number() == innermost_field->number()) {
- return AddNameError("Option \"" + debug_msg_name +
- "\" was already set.");
+ return AddNameError(
+ y_absl::StrCat("Option \"", debug_msg_name, "\" was already set."));
}
}
return true;
@@ -7721,7 +7794,7 @@ bool DescriptorBuilder::OptionInterpreter::ExamineIfOptionIsSet(
break;
default:
- GOOGLE_LOG(FATAL) << "Invalid wire type for CPPTYPE_MESSAGE: " << type;
+ Y_ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_MESSAGE: " << type;
return false;
}
}
@@ -7729,6 +7802,27 @@ bool DescriptorBuilder::OptionInterpreter::ExamineIfOptionIsSet(
return true;
}
+namespace {
+// Helpers for method below
+
+template <typename T> TProtoStringType ValueOutOfRange(
+ y_absl::string_view type_name, y_absl::string_view option_name) {
+ return y_absl::StrFormat(
+ "Value out of range, %d to %d, for %s option \"%s\".", \
+ std::numeric_limits<T>::min(), std::numeric_limits<T>::max(),
+ type_name, option_name);
+}
+
+template <typename T> TProtoStringType ValueMustBeInt(
+ y_absl::string_view type_name, y_absl::string_view option_name) {
+ return y_absl::StrFormat(
+ "Value must be integer, from %d to %d, for %s option \"%s\".", \
+ std::numeric_limits<T>::min(), std::numeric_limits<T>::max(),
+ type_name, option_name);
+}
+
+} // namespace
+
bool DescriptorBuilder::OptionInterpreter::SetOptionValue(
const FieldDescriptor* option_field, UnknownFieldSet* unknown_fields) {
// We switch on the CppType to validate.
@@ -7737,8 +7831,7 @@ bool DescriptorBuilder::OptionInterpreter::SetOptionValue(
if (uninterpreted_option_->has_positive_int_value()) {
if (uninterpreted_option_->positive_int_value() >
static_cast<arc_ui64>(std::numeric_limits<arc_i32>::max())) {
- return AddValueError("Value out of range for int32 option \"" +
- option_field->full_name() + "\".");
+ return AddValueError(ValueOutOfRange<arc_i32>("int32", option_field->full_name()));
} else {
SetInt32(option_field->number(),
uninterpreted_option_->positive_int_value(),
@@ -7747,16 +7840,14 @@ bool DescriptorBuilder::OptionInterpreter::SetOptionValue(
} else if (uninterpreted_option_->has_negative_int_value()) {
if (uninterpreted_option_->negative_int_value() <
static_cast<arc_i64>(std::numeric_limits<arc_i32>::min())) {
- return AddValueError("Value out of range for int32 option \"" +
- option_field->full_name() + "\".");
+ return AddValueError(ValueOutOfRange<arc_i32>("int32", option_field->full_name()));
} else {
SetInt32(option_field->number(),
uninterpreted_option_->negative_int_value(),
option_field->type(), unknown_fields);
}
} else {
- return AddValueError("Value must be integer for int32 option \"" +
- option_field->full_name() + "\".");
+ return AddValueError(ValueMustBeInt<arc_i32>("int32", option_field->full_name()));
}
break;
@@ -7764,8 +7855,7 @@ bool DescriptorBuilder::OptionInterpreter::SetOptionValue(
if (uninterpreted_option_->has_positive_int_value()) {
if (uninterpreted_option_->positive_int_value() >
static_cast<arc_ui64>(std::numeric_limits<arc_i64>::max())) {
- return AddValueError("Value out of range for int64 option \"" +
- option_field->full_name() + "\".");
+ return AddValueError(ValueOutOfRange<arc_i64>("int64", option_field->full_name()));
} else {
SetInt64(option_field->number(),
uninterpreted_option_->positive_int_value(),
@@ -7776,8 +7866,7 @@ bool DescriptorBuilder::OptionInterpreter::SetOptionValue(
uninterpreted_option_->negative_int_value(),
option_field->type(), unknown_fields);
} else {
- return AddValueError("Value must be integer for int64 option \"" +
- option_field->full_name() + "\".");
+ return AddValueError(ValueMustBeInt<arc_i64>("int64", option_field->full_name()));
}
break;
@@ -7785,18 +7874,14 @@ bool DescriptorBuilder::OptionInterpreter::SetOptionValue(
if (uninterpreted_option_->has_positive_int_value()) {
if (uninterpreted_option_->positive_int_value() >
std::numeric_limits<arc_ui32>::max()) {
- return AddValueError("Value out of range for uint32 option \"" +
- option_field->name() + "\".");
+ return AddValueError(ValueOutOfRange<arc_ui32>("uint32", option_field->full_name()));
} else {
SetUInt32(option_field->number(),
uninterpreted_option_->positive_int_value(),
option_field->type(), unknown_fields);
}
} else {
- return AddValueError(
- "Value must be non-negative integer for uint32 "
- "option \"" +
- option_field->full_name() + "\".");
+ return AddValueError(ValueMustBeInt<arc_ui32>("uint32", option_field->full_name()));
}
break;
@@ -7806,10 +7891,7 @@ bool DescriptorBuilder::OptionInterpreter::SetOptionValue(
uninterpreted_option_->positive_int_value(),
option_field->type(), unknown_fields);
} else {
- return AddValueError(
- "Value must be non-negative integer for uint64 "
- "option \"" +
- option_field->full_name() + "\".");
+ return AddValueError(ValueMustBeInt<arc_ui64>("uint64", option_field->full_name()));
}
break;
@@ -7822,8 +7904,9 @@ bool DescriptorBuilder::OptionInterpreter::SetOptionValue(
} else if (uninterpreted_option_->has_negative_int_value()) {
value = uninterpreted_option_->negative_int_value();
} else {
- return AddValueError("Value must be number for float option \"" +
- option_field->full_name() + "\".");
+ return AddValueError(
+ y_absl::StrCat("Value must be number for float option \"",
+ option_field->full_name(), "\"."));
}
unknown_fields->AddFixed32(option_field->number(),
internal::WireFormatLite::EncodeFloat(value));
@@ -7839,8 +7922,9 @@ bool DescriptorBuilder::OptionInterpreter::SetOptionValue(
} else if (uninterpreted_option_->has_negative_int_value()) {
value = uninterpreted_option_->negative_int_value();
} else {
- return AddValueError("Value must be number for double option \"" +
- option_field->full_name() + "\".");
+ return AddValueError(
+ y_absl::StrCat("Value must be number for double option \"",
+ option_field->full_name(), "\"."));
}
unknown_fields->AddFixed64(option_field->number(),
internal::WireFormatLite::EncodeDouble(value));
@@ -7851,19 +7935,17 @@ bool DescriptorBuilder::OptionInterpreter::SetOptionValue(
arc_ui64 value;
if (!uninterpreted_option_->has_identifier_value()) {
return AddValueError(
- "Value must be identifier for boolean option "
- "\"" +
- option_field->full_name() + "\".");
+ y_absl::StrCat("Value must be identifier for boolean option \"",
+ option_field->full_name(), "\"."));
}
if (uninterpreted_option_->identifier_value() == "true") {
value = 1;
} else if (uninterpreted_option_->identifier_value() == "false") {
value = 0;
} else {
- return AddValueError(
- "Value must be \"true\" or \"false\" for boolean "
- "option \"" +
- option_field->full_name() + "\".");
+ return AddValueError(y_absl::StrCat(
+ "Value must be \"true\" or \"false\" for boolean option \"",
+ option_field->full_name(), "\"."));
}
unknown_fields->AddVarint(option_field->number(), value);
break;
@@ -7871,9 +7953,8 @@ bool DescriptorBuilder::OptionInterpreter::SetOptionValue(
case FieldDescriptor::CPPTYPE_ENUM: {
if (!uninterpreted_option_->has_identifier_value()) {
return AddValueError(
- "Value must be identifier for enum-valued option "
- "\"" +
- option_field->full_name() + "\".");
+ y_absl::StrCat("Value must be identifier for enum-valued option \"",
+ option_field->full_name(), "\"."));
}
const EnumDescriptor* enum_type = option_field->enum_type();
const TProtoStringType& value_name = uninterpreted_option_->identifier_value();
@@ -7895,11 +7976,11 @@ bool DescriptorBuilder::OptionInterpreter::SetOptionValue(
builder_->FindSymbolNotEnforcingDeps(fully_qualified_name);
if (auto* candicate_descriptor = symbol.enum_value_descriptor()) {
if (candicate_descriptor->type() != enum_type) {
- return AddValueError(
- "Enum type \"" + enum_type->full_name() +
- "\" has no value named \"" + value_name + "\" for option \"" +
- option_field->full_name() +
- "\". This appears to be a value from a sibling type.");
+ return AddValueError(y_absl::StrCat(
+ "Enum type \"", enum_type->full_name(),
+ "\" has no value named \"", value_name, "\" for option \"",
+ option_field->full_name(),
+ "\". This appears to be a value from a sibling type."));
} else {
enum_value = candicate_descriptor;
}
@@ -7911,12 +7992,10 @@ bool DescriptorBuilder::OptionInterpreter::SetOptionValue(
}
if (enum_value == nullptr) {
- return AddValueError("Enum type \"" +
- option_field->enum_type()->full_name() +
- "\" has no value named \"" + value_name +
- "\" for "
- "option \"" +
- option_field->full_name() + "\".");
+ return AddValueError(
+ y_absl::StrCat("Enum type \"", option_field->enum_type()->full_name(),
+ "\" has no value named \"", value_name,
+ "\" for option \"", option_field->full_name(), "\"."));
} else {
// Sign-extension is not a problem, since we cast directly from arc_i32
// to arc_ui64, without first going through arc_ui32.
@@ -7930,9 +8009,8 @@ bool DescriptorBuilder::OptionInterpreter::SetOptionValue(
case FieldDescriptor::CPPTYPE_STRING:
if (!uninterpreted_option_->has_string_value()) {
return AddValueError(
- "Value must be quoted string for string option "
- "\"" +
- option_field->full_name() + "\".");
+ y_absl::StrCat("Value must be quoted string for string option \"",
+ option_field->full_name(), "\"."));
}
// The string has already been unquoted and unescaped by the parser.
unknown_fields->AddLengthDelimited(option_field->number(),
@@ -8002,16 +8080,16 @@ class AggregateErrorCollector : public io::ErrorCollector {
public:
TProtoStringType error_;
- void AddError(int /* line */, int /* column */,
- const TProtoStringType& message) override {
+ void RecordError(int /* line */, int /* column */,
+ const y_absl::string_view message) override {
if (!error_.empty()) {
- error_ += "; ";
+ y_absl::StrAppend(&error_, "; ");
}
- error_ += message;
+ y_absl::StrAppend(&error_, message);
}
- void AddWarning(int /* line */, int /* column */,
- const TProtoStringType& /* message */) override {
+ void RecordWarning(int /* line */, int /* column */,
+ const y_absl::string_view /* message */) override {
// Ignore warnings
}
};
@@ -8023,19 +8101,19 @@ class AggregateErrorCollector : public io::ErrorCollector {
bool DescriptorBuilder::OptionInterpreter::SetAggregateOption(
const FieldDescriptor* option_field, UnknownFieldSet* unknown_fields) {
if (!uninterpreted_option_->has_aggregate_value()) {
- return AddValueError("Option \"" + option_field->full_name() +
- "\" is a message. To set the entire message, use "
- "syntax like \"" +
- option_field->name() +
- " = { <proto text format> }\". "
- "To set fields within it, use "
- "syntax like \"" +
- option_field->name() + ".foo = value\".");
+ return AddValueError(
+ y_absl::StrCat("Option \"", option_field->full_name(),
+ "\" is a message. "
+ "To set the entire message, use syntax like \"",
+ option_field->name(),
+ " = { <proto text format> }\". "
+ "To set fields within it, use syntax like \"",
+ option_field->name(), ".foo = value\"."));
}
const Descriptor* type = option_field->message_type();
std::unique_ptr<Message> dynamic(dynamic_factory_.GetPrototype(type)->New());
- GOOGLE_CHECK(dynamic.get() != nullptr)
+ Y_ABSL_CHECK(dynamic.get() != nullptr)
<< "Could not create an instance of " << option_field->DebugString();
AggregateErrorCollector collector;
@@ -8046,8 +8124,8 @@ bool DescriptorBuilder::OptionInterpreter::SetAggregateOption(
parser.SetFinder(&finder);
if (!parser.ParseFromString(uninterpreted_option_->aggregate_value(),
dynamic.get())) {
- AddValueError("Error while parsing option value for \"" +
- option_field->name() + "\": " + collector.error_);
+ AddValueError(y_absl::StrCat("Error while parsing option value for \"",
+ option_field->name(), "\": ", collector.error_));
return false;
} else {
TProtoStringType serial;
@@ -8055,7 +8133,7 @@ bool DescriptorBuilder::OptionInterpreter::SetAggregateOption(
if (option_field->type() == FieldDescriptor::TYPE_MESSAGE) {
unknown_fields->AddLengthDelimited(option_field->number(), serial);
} else {
- GOOGLE_CHECK_EQ(option_field->type(), FieldDescriptor::TYPE_GROUP);
+ Y_ABSL_CHECK_EQ(option_field->type(), FieldDescriptor::TYPE_GROUP);
UnknownFieldSet* group = unknown_fields->AddGroup(option_field->number());
group->ParseFromString(serial);
}
@@ -8082,7 +8160,7 @@ void DescriptorBuilder::OptionInterpreter::SetInt32(
break;
default:
- GOOGLE_LOG(FATAL) << "Invalid wire type for CPPTYPE_INT32: " << type;
+ Y_ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_INT32: " << type;
break;
}
}
@@ -8105,7 +8183,7 @@ void DescriptorBuilder::OptionInterpreter::SetInt64(
break;
default:
- GOOGLE_LOG(FATAL) << "Invalid wire type for CPPTYPE_INT64: " << type;
+ Y_ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_INT64: " << type;
break;
}
}
@@ -8123,7 +8201,7 @@ void DescriptorBuilder::OptionInterpreter::SetUInt32(
break;
default:
- GOOGLE_LOG(FATAL) << "Invalid wire type for CPPTYPE_UINT32: " << type;
+ Y_ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_UINT32: " << type;
break;
}
}
@@ -8141,7 +8219,7 @@ void DescriptorBuilder::OptionInterpreter::SetUInt64(
break;
default:
- GOOGLE_LOG(FATAL) << "Invalid wire type for CPPTYPE_UINT64: " << type;
+ Y_ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_UINT64: " << type;
break;
}
}
@@ -8154,22 +8232,21 @@ void DescriptorBuilder::LogUnusedDependency(const FileDescriptorProto& proto,
auto itr = pool_->unused_import_track_files_.find(proto.name());
bool is_error =
itr != pool_->unused_import_track_files_.end() && itr->second;
- for (std::set<const FileDescriptor*>::const_iterator it =
- unused_dependency_.begin();
- it != unused_dependency_.end(); ++it) {
- TProtoStringType error_message = "Import " + (*it)->name() + " is unused.";
+ for (const auto* unused : unused_dependency_) {
+ TProtoStringType error_message =
+ y_absl::StrCat("Import ", unused->name(), " is unused.");
if (is_error) {
- AddError((*it)->name(), proto, DescriptorPool::ErrorCollector::IMPORT,
+ AddError(unused->name(), proto, DescriptorPool::ErrorCollector::IMPORT,
error_message);
} else {
- AddWarning((*it)->name(), proto, DescriptorPool::ErrorCollector::IMPORT,
- error_message);
+ AddWarning(unused->name(), proto,
+ DescriptorPool::ErrorCollector::IMPORT, error_message);
}
}
}
}
-Symbol DescriptorPool::CrossLinkOnDemandHelper(StringPiece name,
+Symbol DescriptorPool::CrossLinkOnDemandHelper(y_absl::string_view name,
bool expecting_enum) const {
(void)expecting_enum; // Parameter is used by Google-internal code.
auto lookup_name = TProtoStringType(name);
@@ -8185,7 +8262,7 @@ Symbol DescriptorPool::CrossLinkOnDemandHelper(StringPiece name,
// be looked up when the accessor for the type was called. Set type_,
// enum_type_, message_type_, and default_value_enum_ appropriately.
void FieldDescriptor::InternalTypeOnceInit() const {
- GOOGLE_CHECK(file()->finished_building_ == true);
+ Y_ABSL_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 =
@@ -8208,7 +8285,8 @@ void FieldDescriptor::InternalTypeOnceInit() const {
// 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 = y_absl::StrCat(name.substr(0, last_dot), ".",
+ lazy_default_value_enum_name);
} else {
name = lazy_default_value_enum_name;
}
@@ -8220,7 +8298,7 @@ void FieldDescriptor::InternalTypeOnceInit() const {
if (!default_value_enum_) {
// We use the first defined value as the default
// if a default is not explicitly defined.
- GOOGLE_CHECK(enum_type->value_count());
+ Y_ABSL_CHECK(enum_type->value_count());
default_value_enum_ = enum_type->value(0);
}
}
@@ -8231,11 +8309,11 @@ void FieldDescriptor::TypeOnceInit(const FieldDescriptor* to_init) {
}
// message_type(), enum_type(), default_value_enum(), and type()
-// all share the same internal::call_once init path to do lazy
+// all share the same y_absl::call_once init path to do lazy
// import building and cross linking of a field of a message.
const Descriptor* FieldDescriptor::message_type() const {
if (type_once_) {
- internal::call_once(*type_once_, FieldDescriptor::TypeOnceInit, this);
+ y_absl::call_once(*type_once_, FieldDescriptor::TypeOnceInit, this);
}
return type_ == TYPE_MESSAGE || type_ == TYPE_GROUP
? type_descriptor_.message_type
@@ -8244,14 +8322,14 @@ const Descriptor* FieldDescriptor::message_type() const {
const EnumDescriptor* FieldDescriptor::enum_type() const {
if (type_once_) {
- internal::call_once(*type_once_, FieldDescriptor::TypeOnceInit, this);
+ y_absl::call_once(*type_once_, FieldDescriptor::TypeOnceInit, this);
}
return type_ == TYPE_ENUM ? type_descriptor_.enum_type : nullptr;
}
const EnumValueDescriptor* FieldDescriptor::default_value_enum() const {
if (type_once_) {
- internal::call_once(*type_once_, FieldDescriptor::TypeOnceInit, this);
+ y_absl::call_once(*type_once_, FieldDescriptor::TypeOnceInit, this);
}
return default_value_enum_;
}
@@ -8266,7 +8344,7 @@ const TProtoStringType& FieldDescriptor::PrintableNameForExtension() const {
}
void FileDescriptor::InternalDependenciesOnceInit() const {
- GOOGLE_CHECK(finished_building_ == true);
+ Y_ABSL_CHECK(finished_building_ == true);
const char* names_ptr = reinterpret_cast<const char*>(dependencies_once_ + 1);
for (int i = 0; i < dependency_count(); i++) {
const char* name = names_ptr;
@@ -8284,9 +8362,9 @@ void FileDescriptor::DependenciesOnceInit(const FileDescriptor* to_init) {
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_,
- FileDescriptor::DependenciesOnceInit, this);
+ // be called, and saves on y_absl::call_once allocations.
+ y_absl::call_once(*dependencies_once_, FileDescriptor::DependenciesOnceInit,
+ this);
}
return dependencies_[index];
}
@@ -8301,20 +8379,20 @@ const Descriptor* MethodDescriptor::output_type() const {
namespace internal {
void LazyDescriptor::Set(const Descriptor* descriptor) {
- GOOGLE_CHECK(!once_);
+ Y_ABSL_CHECK(!once_);
descriptor_ = descriptor;
}
-void LazyDescriptor::SetLazy(StringPiece name,
+void LazyDescriptor::SetLazy(y_absl::string_view name,
const FileDescriptor* file) {
// verify Init() has been called and Set hasn't been called yet.
- GOOGLE_CHECK(!descriptor_);
- GOOGLE_CHECK(!once_);
- GOOGLE_CHECK(file && file->pool_);
- GOOGLE_CHECK(file->pool_->lazily_build_dependencies_);
- GOOGLE_CHECK(!file->finished_building_);
+ Y_ABSL_CHECK(!descriptor_);
+ Y_ABSL_CHECK(!once_);
+ Y_ABSL_CHECK(file && file->pool_);
+ Y_ABSL_CHECK(file->pool_->lazily_build_dependencies_);
+ Y_ABSL_CHECK(!file->finished_building_);
once_ = ::new (file->pool_->tables_->AllocateBytes(static_cast<int>(
- sizeof(internal::once_flag) + name.size() + 1))) internal::once_flag{};
+ sizeof(y_absl::once_flag) + name.size() + 1))) y_absl::once_flag{};
char* lazy_name = reinterpret_cast<char*>(once_ + 1);
memcpy(lazy_name, name.data(), name.size());
lazy_name[name.size()] = 0;
@@ -8322,9 +8400,9 @@ void LazyDescriptor::SetLazy(StringPiece name,
void LazyDescriptor::Once(const ServiceDescriptor* service) {
if (once_) {
- internal::call_once(*once_, [&] {
+ y_absl::call_once(*once_, [&] {
auto* file = service->file();
- GOOGLE_CHECK(file->finished_building_);
+ Y_ABSL_CHECK(file->finished_building_);
const char* lazy_name = reinterpret_cast<const char*>(once_ + 1);
descriptor_ =
file->pool_->CrossLinkOnDemandHelper(lazy_name, false).descriptor();
@@ -8332,9 +8410,51 @@ void LazyDescriptor::Once(const ServiceDescriptor* service) {
}
}
+namespace cpp {
+bool HasPreservingUnknownEnumSemantics(const FieldDescriptor* field) {
+ return field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3;
+}
+
+bool HasHasbit(const FieldDescriptor* field) {
+ // This predicate includes proto3 message fields only if they have "optional".
+ // Foo submsg1 = 1; // HasHasbit() == false
+ // optional Foo submsg2 = 2; // HasHasbit() == true
+ // This is slightly odd, as adding "optional" to a singular proto3 field does
+ // not change the semantics or API. However whenever any field in a message
+ // has a hasbit, it forces reflection to include hasbit offsets for *all*
+ // fields, even if almost all of them are set to -1 (no hasbit). So to avoid
+ // causing a sudden size regression for ~all proto3 messages, we give proto3
+ // message fields a hasbit only if "optional" is present. If the user is
+ // explicitly writing "optional", it is likely they are writing it on
+ // primitive fields also.
+ return (field->has_optional_keyword() || field->is_required()) &&
+ !field->options().weak();
+}
+
+static bool FieldEnforceUtf8(const FieldDescriptor* field) {
+ return true;
+}
+
+static bool FileUtf8Verification(const FileDescriptor* file) {
+ return true;
+}
+
+// Which level of UTF-8 enforcemant is placed on this file.
+Utf8CheckMode GetUtf8CheckMode(const FieldDescriptor* field, bool is_lite) {
+ if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 &&
+ FieldEnforceUtf8(field)) {
+ return Utf8CheckMode::kStrict;
+ } else if (!is_lite && FileUtf8Verification(field->file())) {
+ return Utf8CheckMode::kVerify;
+ } else {
+ return Utf8CheckMode::kNone;
+ }
+}
+
+} // namespace cpp
} // namespace internal
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protobuf/src/google/protobuf/descriptor.h b/contrib/libs/protobuf/src/google/protobuf/descriptor.h
index 57af37c6c10..abd8d2a09a7 100644
--- a/contrib/libs/protobuf/src/google/protobuf/descriptor.h
+++ b/contrib/libs/protobuf/src/google/protobuf/descriptor.h
@@ -54,27 +54,27 @@
#ifndef GOOGLE_PROTOBUF_DESCRIPTOR_H__
#define GOOGLE_PROTOBUF_DESCRIPTOR_H__
-
#include <atomic>
-#include <map>
+#include <cstdint>
+#include <iterator>
#include <memory>
-#include <set>
#include <string>
#include <vector>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/mutex.h>
-#include <google/protobuf/stubs/once.h>
-#include <google/protobuf/port.h>
+#include "google/protobuf/stubs/common.h"
+#include "google/protobuf/port.h"
+#include "y_absl/base/attributes.h"
+#include "y_absl/base/call_once.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/synchronization/mutex.h"
+#include "y_absl/types/optional.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.
-#ifdef TYPE_BOOL
-#undef TYPE_BOOL
-#endif // TYPE_BOOL
+#include "google/protobuf/port_def.inc"
#ifdef SWIG
#define PROTOBUF_EXPORT
@@ -117,6 +117,7 @@ class MethodOptions;
class FileOptions;
class UninterpretedOption;
class SourceCodeInfo;
+class ExtensionMetadata;
// Defined in message.h
class Message;
@@ -141,6 +142,7 @@ class Formatter;
namespace descriptor_unittest {
class DescriptorTest;
+class ValidationErrorTest;
} // namespace descriptor_unittest
// Defined in printer.h
@@ -220,7 +222,7 @@ class PROTOBUF_EXPORT LazyDescriptor {
// build time if the symbol wasn't found and building of the file containing
// that type is delayed because lazily_build_dependencies_ is set on the pool.
// Should not be called after Set() has been called.
- void SetLazy(StringPiece name, const FileDescriptor* file);
+ void SetLazy(y_absl::string_view name, const FileDescriptor* file);
// Returns the current value of the descriptor, thread-safe. If SetLazy(...)
// has been called, will do a one-time cross link of the type specified,
@@ -235,7 +237,7 @@ class PROTOBUF_EXPORT LazyDescriptor {
const Descriptor* descriptor_;
// The once_ flag is followed by a NUL terminated string for the type name.
- internal::once_flag* once_;
+ y_absl::once_flag* once_;
};
class PROTOBUF_EXPORT SymbolBase {
@@ -261,6 +263,10 @@ class PROTOBUF_EXPORT SymbolBaseN : public SymbolBase {};
class PROTOBUF_EXPORT Descriptor : private internal::SymbolBase {
public:
typedef DescriptorProto Proto;
+#ifndef SWIG
+ Descriptor(const Descriptor&) = delete;
+ Descriptor& operator=(const Descriptor&) = delete;
+#endif
// The name of the message type, not including its scope.
const TProtoStringType& name() const;
@@ -349,20 +355,20 @@ class PROTOBUF_EXPORT Descriptor : private internal::SymbolBase {
// exists.
const FieldDescriptor* FindFieldByNumber(int number) const;
// Looks up a field by name. Returns nullptr if no such field exists.
- const FieldDescriptor* FindFieldByName(ConstStringParam name) const;
+ const FieldDescriptor* FindFieldByName(y_absl::string_view name) const;
// Looks up a field by lowercased name (as returned by lowercase_name()).
// This lookup may be ambiguous if multiple field names differ only by case,
// in which case the field returned is chosen arbitrarily from the matches.
const FieldDescriptor* FindFieldByLowercaseName(
- ConstStringParam lowercase_name) const;
+ y_absl::string_view lowercase_name) const;
// Looks up a field by camel-case name (as returned by camelcase_name()).
// This lookup may be ambiguous if multiple field names differ in a way that
// leads them to have identical camel-case names, in which case the field
// returned is chosen arbitrarily from the matches.
const FieldDescriptor* FindFieldByCamelcaseName(
- ConstStringParam camelcase_name) const;
+ y_absl::string_view camelcase_name) const;
// The number of oneofs in this message type.
int oneof_decl_count() const;
@@ -375,7 +381,7 @@ class PROTOBUF_EXPORT Descriptor : private internal::SymbolBase {
const OneofDescriptor* oneof_decl(int index) const;
// Looks up a oneof by name. Returns nullptr if no such oneof exists.
- const OneofDescriptor* FindOneofByName(ConstStringParam name) const;
+ const OneofDescriptor* FindOneofByName(y_absl::string_view name) const;
// Nested type stuff -----------------------------------------------
@@ -387,7 +393,7 @@ class PROTOBUF_EXPORT Descriptor : private internal::SymbolBase {
// Looks up a nested type by name. Returns nullptr if no such nested type
// exists.
- const Descriptor* FindNestedTypeByName(ConstStringParam name) const;
+ const Descriptor* FindNestedTypeByName(y_absl::string_view name) const;
// Enum stuff ------------------------------------------------------
@@ -399,11 +405,11 @@ class PROTOBUF_EXPORT Descriptor : private internal::SymbolBase {
// Looks up an enum type by name. Returns nullptr if no such enum type
// exists.
- const EnumDescriptor* FindEnumTypeByName(ConstStringParam name) const;
+ const EnumDescriptor* FindEnumTypeByName(y_absl::string_view name) const;
// Looks up an enum value by name, among all enum types in this message.
// Returns nullptr if no such value exists.
- const EnumValueDescriptor* FindEnumValueByName(ConstStringParam name) const;
+ const EnumValueDescriptor* FindEnumValueByName(y_absl::string_view name) const;
// Extensions ------------------------------------------------------
@@ -467,17 +473,17 @@ class PROTOBUF_EXPORT Descriptor : private internal::SymbolBase {
// Looks up a named extension (which extends some *other* message type)
// defined within this message type's scope.
- const FieldDescriptor* FindExtensionByName(ConstStringParam name) const;
+ const FieldDescriptor* FindExtensionByName(y_absl::string_view name) const;
// Similar to FindFieldByLowercaseName(), but finds extensions defined within
// this message type's scope.
const FieldDescriptor* FindExtensionByLowercaseName(
- ConstStringParam name) const;
+ y_absl::string_view name) const;
// Similar to FindFieldByCamelcaseName(), but finds extensions defined within
// this message type's scope.
const FieldDescriptor* FindExtensionByCamelcaseName(
- ConstStringParam name) const;
+ y_absl::string_view name) const;
// Reserved fields -------------------------------------------------
@@ -507,7 +513,7 @@ class PROTOBUF_EXPORT Descriptor : private internal::SymbolBase {
const TProtoStringType& reserved_name(int index) const;
// Returns true if the field name is reserved.
- bool IsReservedName(ConstStringParam name) const;
+ bool IsReservedName(y_absl::string_view name) const;
// Source Location ---------------------------------------------------
@@ -609,7 +615,6 @@ class PROTOBUF_EXPORT Descriptor : private internal::SymbolBase {
friend class OneofDescriptor;
friend class MethodDescriptor;
friend class FileDescriptor;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Descriptor);
};
PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(Descriptor, 136);
@@ -628,6 +633,11 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase {
public:
typedef FieldDescriptorProto Proto;
+#ifndef SWIG
+ FieldDescriptor(const FieldDescriptor&) = delete;
+ FieldDescriptor& operator=(const FieldDescriptor&) = delete;
+#endif
+
// Identifies a field type. 0 is reserved for errors. The order is weird
// for historical reasons. Types 12 and up are new in proto2.
enum Type {
@@ -754,6 +764,10 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase {
// Reflection::HasField() is semantically meaningful.
bool has_presence() const;
+ // Returns true if this TYPE_STRING-typed field requires UTF-8 validation on
+ // parse.
+ bool requires_utf8_validation() const;
+
// Index of this field within the message's field array, or the file or
// extension scope's extensions array.
int index() const;
@@ -896,7 +910,7 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase {
// formats the default value appropriately and returns it as a string.
// Must have a default value to call this. If quote_string_type is true, then
- // types of CPPTYPE_STRING whill be surrounded by quotes and CEscaped.
+ // types of CPPTYPE_STRING will be surrounded by quotes and CEscaped.
TProtoStringType DefaultValueAsString(bool quote_string_type) const;
// Helper function that returns the field type name for DebugString.
@@ -941,7 +955,7 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase {
// 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_;
+ y_absl::once_flag* type_once_;
static void TypeOnceInit(const FieldDescriptor* to_init);
void InternalTypeOnceInit() const;
const Descriptor* containing_type_;
@@ -986,7 +1000,6 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase {
friend class FileDescriptor;
friend class Descriptor;
friend class OneofDescriptor;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldDescriptor);
};
PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(FieldDescriptor, 72);
@@ -996,6 +1009,11 @@ class PROTOBUF_EXPORT OneofDescriptor : private internal::SymbolBase {
public:
typedef OneofDescriptorProto Proto;
+#ifndef SWIG
+ OneofDescriptor(const OneofDescriptor&) = delete;
+ OneofDescriptor& operator=(const OneofDescriptor&) = delete;
+#endif
+
const TProtoStringType& name() const; // Name of this oneof.
const TProtoStringType& full_name() const; // Fully-qualified name of the oneof.
@@ -1067,7 +1085,6 @@ class PROTOBUF_EXPORT OneofDescriptor : private internal::SymbolBase {
OneofDescriptor() {}
friend class DescriptorBuilder;
friend class Descriptor;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(OneofDescriptor);
};
PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(OneofDescriptor, 40);
@@ -1079,6 +1096,11 @@ class PROTOBUF_EXPORT EnumDescriptor : private internal::SymbolBase {
public:
typedef EnumDescriptorProto Proto;
+#ifndef SWIG
+ EnumDescriptor(const EnumDescriptor&) = delete;
+ EnumDescriptor& operator=(const EnumDescriptor&) = delete;
+#endif
+
// The name of this enum type in the containing scope.
const TProtoStringType& name() const;
@@ -1099,7 +1121,7 @@ class PROTOBUF_EXPORT EnumDescriptor : private internal::SymbolBase {
const EnumValueDescriptor* value(int index) const;
// Looks up a value by name. Returns nullptr if no such value exists.
- const EnumValueDescriptor* FindValueByName(ConstStringParam name) const;
+ const EnumValueDescriptor* FindValueByName(y_absl::string_view name) const;
// Looks up a value by number. Returns nullptr if no such value exists. If
// multiple values have this number, the first one defined is returned.
const EnumValueDescriptor* FindValueByNumber(int number) const;
@@ -1128,6 +1150,25 @@ class PROTOBUF_EXPORT EnumDescriptor : private internal::SymbolBase {
// with AllowUnknownDependencies() set.
bool is_placeholder() const;
+ // Returns true whether this is a "closed" enum, meaning that it:
+ // - Has a fixed set of values, rather than being equivalent to an int32.
+ // - Encountering values not in this set causes them to be treated as unknown
+ // fields.
+ // - The first value (i.e., the default) may be nonzero.
+ //
+ // WARNING: Some runtimes currently have a quirk where non-closed enums are
+ // treated as closed when used as the type of fields defined in a
+ // `syntax = proto2;` file. This quirk is not present in all runtimes; as of
+ // writing, we know that:
+ //
+ // - C++, Java, and C++-based Python share this quirk.
+ // - UPB and UPB-based Python do not.
+ // - PHP and Ruby treat all enums as open regardless of declaration.
+ //
+ // Care should be taken when using this function to respect the target
+ // runtime's enum handling quirks.
+ bool is_closed() const;
+
// Reserved fields -------------------------------------------------
// A range of reserved field numbers.
@@ -1157,7 +1198,7 @@ class PROTOBUF_EXPORT EnumDescriptor : private internal::SymbolBase {
const TProtoStringType& reserved_name(int index) const;
// Returns true if the field name is reserved.
- bool IsReservedName(ConstStringParam name) const;
+ bool IsReservedName(y_absl::string_view name) const;
// Source Location ---------------------------------------------------
@@ -1238,7 +1279,6 @@ class PROTOBUF_EXPORT EnumDescriptor : private internal::SymbolBase {
friend class FileDescriptor;
friend class DescriptorPool;
friend class Reflection;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumDescriptor);
};
PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(EnumDescriptor, 72);
@@ -1253,6 +1293,11 @@ class PROTOBUF_EXPORT EnumValueDescriptor : private internal::SymbolBaseN<0>,
public:
typedef EnumValueDescriptorProto Proto;
+#ifndef SWIG
+ EnumValueDescriptor(const EnumValueDescriptor&) = delete;
+ EnumValueDescriptor& operator=(const EnumValueDescriptor&) = delete;
+#endif
+
const TProtoStringType& name() const; // Name of this enum constant.
int index() const; // Index within the enums's Descriptor.
int number() const; // Numeric value of this enum constant.
@@ -1323,7 +1368,6 @@ class PROTOBUF_EXPORT EnumValueDescriptor : private internal::SymbolBaseN<0>,
friend class DescriptorPool;
friend class FileDescriptorTables;
friend class Reflection;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumValueDescriptor);
};
PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(EnumValueDescriptor, 32);
@@ -1334,6 +1378,11 @@ class PROTOBUF_EXPORT ServiceDescriptor : private internal::SymbolBase {
public:
typedef ServiceDescriptorProto Proto;
+#ifndef SWIG
+ ServiceDescriptor(const ServiceDescriptor&) = delete;
+ ServiceDescriptor& operator=(const ServiceDescriptor&) = delete;
+#endif
+
// The name of the service, not including its containing scope.
const TProtoStringType& name() const;
// The fully-qualified name of the service, scope delimited by periods.
@@ -1357,7 +1406,7 @@ class PROTOBUF_EXPORT ServiceDescriptor : private internal::SymbolBase {
const MethodDescriptor* method(int index) const;
// Look up a MethodDescriptor by name.
- const MethodDescriptor* FindMethodByName(ConstStringParam name) const;
+ const MethodDescriptor* FindMethodByName(y_absl::string_view name) const;
// See Descriptor::CopyTo().
void CopyTo(ServiceDescriptorProto* proto) const;
@@ -1406,7 +1455,6 @@ class PROTOBUF_EXPORT ServiceDescriptor : private internal::SymbolBase {
friend class DescriptorBuilder;
friend class FileDescriptor;
friend class MethodDescriptor;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceDescriptor);
};
PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(ServiceDescriptor, 48);
@@ -1419,6 +1467,11 @@ class PROTOBUF_EXPORT MethodDescriptor : private internal::SymbolBase {
public:
typedef MethodDescriptorProto Proto;
+#ifndef SWIG
+ MethodDescriptor(const MethodDescriptor&) = delete;
+ MethodDescriptor& operator=(const MethodDescriptor&) = delete;
+#endif
+
// Name of this method, not including containing scope.
const TProtoStringType& name() const;
// The fully-qualified name of the method, scope delimited by periods.
@@ -1495,7 +1548,6 @@ class PROTOBUF_EXPORT MethodDescriptor : private internal::SymbolBase {
MethodDescriptor() {}
friend class DescriptorBuilder;
friend class ServiceDescriptor;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MethodDescriptor);
};
PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(MethodDescriptor, 64);
@@ -1507,6 +1559,11 @@ class PROTOBUF_EXPORT FileDescriptor : private internal::SymbolBase {
public:
typedef FileDescriptorProto Proto;
+#ifndef SWIG
+ FileDescriptor(const FileDescriptor&) = delete;
+ FileDescriptor& operator=(const FileDescriptor&) = delete;
+#endif
+
// The filename, relative to the source tree.
// e.g. "foo/bar/baz.proto"
const TProtoStringType& name() const;
@@ -1574,7 +1631,11 @@ class PROTOBUF_EXPORT FileDescriptor : private internal::SymbolBase {
const FileOptions& options() const;
// Syntax of this file.
- enum Syntax {
+ enum Syntax
+#ifndef SWIG
+ : int
+#endif // !SWIG
+ {
SYNTAX_UNKNOWN = 0,
SYNTAX_PROTO2 = 2,
SYNTAX_PROTO3 = 3,
@@ -1584,25 +1645,25 @@ class PROTOBUF_EXPORT FileDescriptor : private internal::SymbolBase {
// Find a top-level message type by name (not full_name). Returns nullptr if
// not found.
- const Descriptor* FindMessageTypeByName(ConstStringParam name) const;
+ const Descriptor* FindMessageTypeByName(y_absl::string_view name) const;
// Find a top-level enum type by name. Returns nullptr if not found.
- const EnumDescriptor* FindEnumTypeByName(ConstStringParam name) const;
+ const EnumDescriptor* FindEnumTypeByName(y_absl::string_view name) const;
// Find an enum value defined in any top-level enum by name. Returns nullptr
// if not found.
- const EnumValueDescriptor* FindEnumValueByName(ConstStringParam name) const;
+ const EnumValueDescriptor* FindEnumValueByName(y_absl::string_view name) const;
// Find a service definition by name. Returns nullptr if not found.
- const ServiceDescriptor* FindServiceByName(ConstStringParam name) const;
+ const ServiceDescriptor* FindServiceByName(y_absl::string_view name) const;
// Find a top-level extension definition by name. Returns nullptr if not
// found.
- const FieldDescriptor* FindExtensionByName(ConstStringParam name) const;
+ const FieldDescriptor* FindExtensionByName(y_absl::string_view name) const;
// Similar to FindExtensionByName(), but searches by lowercased-name. See
// Descriptor::FindFieldByLowercaseName().
const FieldDescriptor* FindExtensionByLowercaseName(
- ConstStringParam name) const;
+ y_absl::string_view name) const;
// Similar to FindExtensionByName(), but searches by camelcased-name. See
// Descriptor::FindFieldByCamelcaseName().
const FieldDescriptor* FindExtensionByCamelcaseName(
- ConstStringParam name) const;
+ y_absl::string_view name) const;
// See Descriptor::CopyTo().
// Notes:
@@ -1615,6 +1676,9 @@ class PROTOBUF_EXPORT FileDescriptor : private internal::SymbolBase {
// Fill the json_name field of FieldDescriptorProto for all fields. Can only
// be called after CopyTo().
void CopyJsonNameTo(FileDescriptorProto* proto) const;
+ // Fills in the file-level settings of this file (e.g. syntax, package,
+ // file options) to `proto`.
+ void CopyHeadingTo(FileDescriptorProto* proto) const;
// See Descriptor::DebugString().
TProtoStringType DebugString() const;
@@ -1660,7 +1724,7 @@ class PROTOBUF_EXPORT FileDescriptor : private internal::SymbolBase {
// 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_;
+ y_absl::once_flag* dependencies_once_;
static void DependenciesOnceInit(const FileDescriptor* to_init);
void InternalDependenciesOnceInit() const;
@@ -1699,10 +1763,9 @@ class PROTOBUF_EXPORT FileDescriptor : private internal::SymbolBase {
friend class EnumValueDescriptor;
friend class MethodDescriptor;
friend class ServiceDescriptor;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileDescriptor);
};
-PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(FileDescriptor, 144);
+PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(FileDescriptor, 152);
// ===================================================================
@@ -1751,7 +1814,7 @@ class PROTOBUF_EXPORT DescriptorPool {
// this pool will be slower, since they will have to obtain locks too.
// - An ErrorCollector may optionally be given to collect validation errors
// in files loaded from the database. If not given, errors will be printed
- // to GOOGLE_LOG(ERROR). Remember that files are built on-demand, so this
+ // to Y_ABSL_LOG(ERROR). Remember that files are built on-demand, so this
// ErrorCollector may be called from any thread that calls one of the
// Find*By*() methods.
// - The DescriptorDatabase must not be mutated during the lifetime of
@@ -1762,6 +1825,10 @@ class PROTOBUF_EXPORT DescriptorPool {
explicit DescriptorPool(DescriptorDatabase* fallback_database,
ErrorCollector* error_collector = nullptr);
+#ifndef SWIG
+ DescriptorPool(const DescriptorPool&) = delete;
+ DescriptorPool& operator=(const DescriptorPool&) = delete;
+#endif
~DescriptorPool();
// Get a pointer to the generated pool. Generated protocol message classes
@@ -1772,28 +1839,28 @@ class PROTOBUF_EXPORT DescriptorPool {
// Find a FileDescriptor in the pool by file name. Returns nullptr if not
// found.
- const FileDescriptor* FindFileByName(ConstStringParam name) const;
+ const FileDescriptor* FindFileByName(y_absl::string_view name) const;
// Find the FileDescriptor in the pool which defines the given symbol.
// If any of the Find*ByName() methods below would succeed, then this is
// equivalent to calling that method and calling the result's file() method.
// Otherwise this returns nullptr.
const FileDescriptor* FindFileContainingSymbol(
- ConstStringParam symbol_name) const;
+ y_absl::string_view symbol_name) const;
// Looking up descriptors ------------------------------------------
// These find descriptors by fully-qualified name. These will find both
// top-level descriptors and nested descriptors. They return nullptr if not
// found.
- const Descriptor* FindMessageTypeByName(ConstStringParam name) const;
- const FieldDescriptor* FindFieldByName(ConstStringParam name) const;
- const FieldDescriptor* FindExtensionByName(ConstStringParam name) const;
- const OneofDescriptor* FindOneofByName(ConstStringParam name) const;
- const EnumDescriptor* FindEnumTypeByName(ConstStringParam name) const;
- const EnumValueDescriptor* FindEnumValueByName(ConstStringParam name) const;
- const ServiceDescriptor* FindServiceByName(ConstStringParam name) const;
- const MethodDescriptor* FindMethodByName(ConstStringParam name) const;
+ const Descriptor* FindMessageTypeByName(y_absl::string_view name) const;
+ const FieldDescriptor* FindFieldByName(y_absl::string_view name) const;
+ const FieldDescriptor* FindExtensionByName(y_absl::string_view name) const;
+ const OneofDescriptor* FindOneofByName(y_absl::string_view name) const;
+ const EnumDescriptor* FindEnumTypeByName(y_absl::string_view name) const;
+ const EnumValueDescriptor* FindEnumValueByName(y_absl::string_view name) const;
+ const ServiceDescriptor* FindServiceByName(y_absl::string_view name) const;
+ const MethodDescriptor* FindMethodByName(y_absl::string_view name) const;
// Finds an extension of the given type by number. The extendee must be
// a member of this DescriptorPool or one of its underlays.
@@ -1806,7 +1873,7 @@ class PROTOBUF_EXPORT DescriptorPool {
// or one of its underlays. Returns nullptr if there is no known message
// extension with the given printable name.
const FieldDescriptor* FindExtensionByPrintableName(
- const Descriptor* extendee, ConstStringParam printable_name) const;
+ const Descriptor* extendee, y_absl::string_view printable_name) const;
// Finds extensions of extendee. The extensions will be appended to
// out in an undefined order. Only extensions defined directly in
@@ -1824,6 +1891,10 @@ class PROTOBUF_EXPORT DescriptorPool {
class PROTOBUF_EXPORT ErrorCollector {
public:
inline ErrorCollector() {}
+#ifndef SWIG
+ ErrorCollector(const ErrorCollector&) = delete;
+ ErrorCollector& operator=(const ErrorCollector&) = delete;
+#endif
virtual ~ErrorCollector();
// These constants specify what exact part of the construct is broken.
@@ -1845,35 +1916,62 @@ class PROTOBUF_EXPORT DescriptorPool {
// Reports an error in the FileDescriptorProto. Use this function if the
// problem occurred should interrupt building the FileDescriptorProto.
- virtual void AddError(
- const TProtoStringType& filename, // File name in which the error occurred.
- const TProtoStringType& element_name, // Full name of the erroneous element.
- const Message* descriptor, // Descriptor of the erroneous element.
- ErrorLocation location, // One of the location constants, above.
- const TProtoStringType& message // Human-readable error message.
- ) = 0;
+ // Provided the following arguments:
+ // filename - File name in which the error occurred.
+ // element_name - Full name of the erroneous element.
+ // descriptor - Descriptor of the erroneous element.
+ // location - One of the location constants, above.
+ // message - Human-readable error message.
+ virtual void RecordError(y_absl::string_view filename,
+ y_absl::string_view element_name,
+ const Message* descriptor, ErrorLocation location,
+ y_absl::string_view message) {
+ PROTOBUF_IGNORE_DEPRECATION_START
+ AddError(TProtoStringType(filename), TProtoStringType(element_name), descriptor,
+ location, TProtoStringType(message));
+ PROTOBUF_IGNORE_DEPRECATION_STOP
+ }
// Reports a warning in the FileDescriptorProto. Use this function if the
// problem occurred should NOT interrupt building the FileDescriptorProto.
- virtual void AddWarning(
- const TProtoStringType& /*filename*/, // File name in which the error
- // occurred.
- const TProtoStringType& /*element_name*/, // Full name of the erroneous
- // element.
- const Message* /*descriptor*/, // Descriptor of the erroneous element.
- ErrorLocation /*location*/, // One of the location constants, above.
- const TProtoStringType& /*message*/ // Human-readable error message.
- ) {}
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ErrorCollector);
+ // Provided the following arguments:
+ // filename - File name in which the error occurred.
+ // element_name - Full name of the erroneous element.
+ // descriptor - Descriptor of the erroneous element.
+ // location - One of the location constants, above.
+ // message - Human-readable error message.
+ virtual void RecordWarning(y_absl::string_view filename,
+ y_absl::string_view element_name,
+ const Message* descriptor,
+ ErrorLocation location,
+ y_absl::string_view message) {
+ PROTOBUF_IGNORE_DEPRECATION_START
+ AddWarning(TProtoStringType(filename), TProtoStringType(element_name), descriptor,
+ location, TProtoStringType(message));
+ PROTOBUF_IGNORE_DEPRECATION_STOP
+ }
+
+ // These should never be called directly, but if a legacy class overrides
+ // them they'll get routed to by the Record* methods.
+
+ virtual void AddError(const TProtoStringType& filename,
+ const TProtoStringType& element_name,
+ const Message* descriptor, ErrorLocation location,
+ const TProtoStringType& message) {
+ Y_ABSL_LOG(FATAL) << "AddError or RecordError must be implemented.";
+ }
+
+ virtual void AddWarning(const TProtoStringType& filename,
+ const TProtoStringType& element_name,
+ const Message* descriptor, ErrorLocation location,
+ const TProtoStringType& message) {}
};
// Convert the FileDescriptorProto to real descriptors and place them in
// this DescriptorPool. All dependencies of the file must already be in
// the pool. Returns the resulting FileDescriptor, or nullptr if there were
// problems with the input (e.g. the message was invalid, or dependencies
- // were missing). Details about the errors are written to GOOGLE_LOG(ERROR).
+ // were missing). Details about the errors are written to Y_ABSL_LOG(ERROR).
const FileDescriptor* BuildFile(const FileDescriptorProto& proto);
// Same as BuildFile() except errors are sent to the given ErrorCollector.
@@ -1939,6 +2037,12 @@ class PROTOBUF_EXPORT DescriptorPool {
// Disallow [enforce_utf8 = false] in .proto files.
void DisallowEnforceUtf8() { disallow_enforce_utf8_ = true; }
+ // Use the deprecated legacy behavior for handling JSON field name conflicts.
+
+ void UseDeprecatedLegacyJsonFieldConflicts() {
+ deprecated_legacy_json_field_conflicts_ = true;
+ }
+
// For internal use only: Gets a non-const pointer to the generated pool.
// This is called at static-initialization time only, so thread-safety is
@@ -1979,11 +2083,11 @@ class PROTOBUF_EXPORT DescriptorPool {
// For internal (unit test) use only: Returns true if a FileDescriptor has
// been constructed for the given file, false otherwise. Useful for testing
// lazy descriptor initialization behavior.
- bool InternalIsFileLoaded(ConstStringParam filename) const;
+ bool InternalIsFileLoaded(y_absl::string_view filename) const;
// Add a file to unused_import_track_files_. DescriptorBuilder will log
// warnings or errors for those files if there is any unused import.
- void AddUnusedImportTrackFile(ConstStringParam file_name,
+ void AddUnusedImportTrackFile(y_absl::string_view file_name,
bool is_error = false);
void ClearUnusedImportTrackFiles();
@@ -1997,18 +2101,19 @@ class PROTOBUF_EXPORT DescriptorPool {
friend class FileDescriptor;
friend class DescriptorBuilder;
friend class FileDescriptorTables;
+ friend class google::protobuf::descriptor_unittest::ValidationErrorTest;
// Return true if the given name is a sub-symbol of any non-package
// descriptor that already exists in the descriptor pool. (The full
// definition of such types is already known.)
- bool IsSubSymbolOfBuiltType(StringPiece name) const;
+ bool IsSubSymbolOfBuiltType(y_absl::string_view name) const;
// Tries to find something in the fallback database and link in the
// corresponding proto file. Returns true if successful, in which case
// the caller should search for the thing again. These are declared
// const because they are called by (semantically) const methods.
- bool TryFindFileInFallbackDatabase(StringPiece name) const;
- bool TryFindSymbolInFallbackDatabase(StringPiece name) const;
+ bool TryFindFileInFallbackDatabase(y_absl::string_view name) const;
+ bool TryFindSymbolInFallbackDatabase(y_absl::string_view name) const;
bool TryFindExtensionInFallbackDatabase(const Descriptor* containing_type,
int field_number) const;
@@ -2029,13 +2134,13 @@ class PROTOBUF_EXPORT DescriptorPool {
// symbol is defined if necessary. Will create a placeholder if the type
// doesn't exist in the fallback database, or the file doesn't build
// successfully.
- Symbol CrossLinkOnDemandHelper(StringPiece name,
+ Symbol CrossLinkOnDemandHelper(y_absl::string_view name,
bool expecting_enum) const;
// Create a placeholder FileDescriptor of the specified name
- FileDescriptor* NewPlaceholderFile(StringPiece name) const;
+ FileDescriptor* NewPlaceholderFile(y_absl::string_view name) const;
FileDescriptor* NewPlaceholderFileWithMutexHeld(
- StringPiece name, internal::FlatAllocator& alloc) const;
+ y_absl::string_view name, internal::FlatAllocator& alloc) const;
enum PlaceholderType {
PLACEHOLDER_MESSAGE,
@@ -2043,14 +2148,14 @@ class PROTOBUF_EXPORT DescriptorPool {
PLACEHOLDER_EXTENDABLE_MESSAGE
};
// Create a placeholder Descriptor of the specified name
- Symbol NewPlaceholder(StringPiece name,
+ Symbol NewPlaceholder(y_absl::string_view name,
PlaceholderType placeholder_type) const;
- Symbol NewPlaceholderWithMutexHeld(StringPiece name,
+ Symbol NewPlaceholderWithMutexHeld(y_absl::string_view name,
PlaceholderType placeholder_type) const;
// If fallback_database_ is nullptr, this is nullptr. Otherwise, this is a
// mutex which must be locked while accessing tables_.
- internal::WrappedMutex* mutex_;
+ y_absl::Mutex* mutex_;
// See constructor.
DescriptorDatabase* fallback_database_;
@@ -2067,12 +2172,12 @@ class PROTOBUF_EXPORT DescriptorPool {
bool allow_unknown_;
bool enforce_weak_;
bool disallow_enforce_utf8_;
+ bool deprecated_legacy_json_field_conflicts_;
// Set of files to track for unused imports. The bool value when true means
// unused imports are treated as errors (and as warnings when false).
- std::map<TProtoStringType, bool> unused_import_track_files_;
+ y_absl::flat_hash_map<TProtoStringType, bool> unused_import_track_files_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DescriptorPool);
};
@@ -2163,6 +2268,10 @@ PROTOBUF_DEFINE_ARRAY_ACCESSOR(EnumDescriptor, reserved_range,
const EnumDescriptor::ReservedRange*)
PROTOBUF_DEFINE_ACCESSOR(EnumDescriptor, reserved_name_count, int)
+inline bool EnumDescriptor::is_closed() const {
+ return file()->syntax() != FileDescriptor::SYNTAX_PROTO3;
+}
+
PROTOBUF_DEFINE_NAME_ACCESSOR(EnumValueDescriptor)
PROTOBUF_DEFINE_ACCESSOR(EnumValueDescriptor, number, int)
PROTOBUF_DEFINE_ACCESSOR(EnumValueDescriptor, type, const EnumDescriptor*)
@@ -2219,9 +2328,9 @@ inline bool Descriptor::IsReservedNumber(int number) const {
return FindReservedRangeContainingNumber(number) != nullptr;
}
-inline bool Descriptor::IsReservedName(ConstStringParam name) const {
+inline bool Descriptor::IsReservedName(y_absl::string_view name) const {
for (int i = 0; i < reserved_name_count(); i++) {
- if (name == static_cast<ConstStringParam>(reserved_name(i))) {
+ if (name == static_cast<y_absl::string_view>(reserved_name(i))) {
return true;
}
}
@@ -2238,9 +2347,9 @@ inline bool EnumDescriptor::IsReservedNumber(int number) const {
return FindReservedRangeContainingNumber(number) != nullptr;
}
-inline bool EnumDescriptor::IsReservedName(ConstStringParam name) const {
+inline bool EnumDescriptor::IsReservedName(y_absl::string_view name) const {
for (int i = 0; i < reserved_name_count(); i++) {
- if (name == static_cast<ConstStringParam>(reserved_name(i))) {
+ if (name == static_cast<y_absl::string_view>(reserved_name(i))) {
return true;
}
}
@@ -2270,12 +2379,12 @@ inline const OneofDescriptor* FieldDescriptor::containing_oneof() const {
}
inline int FieldDescriptor::index_in_oneof() const {
- GOOGLE_DCHECK(is_oneof_);
+ Y_ABSL_DCHECK(is_oneof_);
return static_cast<int>(this - scope_.containing_oneof->field(0));
}
inline const Descriptor* FieldDescriptor::extension_scope() const {
- GOOGLE_CHECK(is_extension_);
+ Y_ABSL_CHECK(is_extension_);
return scope_.extension_scope;
}
@@ -2285,7 +2394,7 @@ inline FieldDescriptor::Label FieldDescriptor::label() const {
inline FieldDescriptor::Type FieldDescriptor::type() const {
if (type_once_) {
- internal::call_once(*type_once_, &FieldDescriptor::TypeOnceInit, this);
+ y_absl::call_once(*type_once_, &FieldDescriptor::TypeOnceInit, this);
}
return static_cast<Type>(type_);
}
@@ -2327,6 +2436,11 @@ inline bool FieldDescriptor::has_presence() const {
file()->syntax() == FileDescriptor::SYNTAX_PROTO2;
}
+inline bool FieldDescriptor::requires_utf8_validation() const {
+ return type() == TYPE_STRING &&
+ file()->syntax() == FileDescriptor::SYNTAX_PROTO3;
+}
+
// To save space, index() is computed by looking at the descriptor's position
// in the parent's array of children.
inline int FieldDescriptor::index() const {
@@ -2431,10 +2545,79 @@ inline FileDescriptor::Syntax FileDescriptor::syntax() const {
return static_cast<Syntax>(syntax_);
}
+namespace internal {
+
+// FieldRange(desc) provides an iterable range for the fields of a
+// descriptor type, appropriate for range-for loops.
+
+template <typename T>
+struct FieldRangeImpl;
+
+template <typename T>
+FieldRangeImpl<T> FieldRange(const T* desc) {
+ return {desc};
+}
+
+template <typename T>
+struct FieldRangeImpl {
+ struct Iterator {
+ using iterator_category = std::forward_iterator_tag;
+ using value_type = const FieldDescriptor*;
+ using difference_type = int;
+
+ value_type operator*() { return descriptor->field(idx); }
+
+ friend bool operator==(const Iterator& a, const Iterator& b) {
+ Y_ABSL_DCHECK(a.descriptor == b.descriptor);
+ return a.idx == b.idx;
+ }
+ friend bool operator!=(const Iterator& a, const Iterator& b) {
+ return !(a == b);
+ }
+
+ Iterator& operator++() {
+ idx++;
+ return *this;
+ }
+
+ int idx;
+ const T* descriptor;
+ };
+
+ Iterator begin() const { return {0, descriptor}; }
+ Iterator end() const { return {descriptor->field_count(), descriptor}; }
+
+ const T* descriptor;
+};
+
+// The context for these functions under `cpp` is "for the C++ implementation".
+// In particular, questions like "does this field have a has bit?" have a
+// different answer depending on the language.
+namespace cpp {
+// Returns true if 'enum' semantics are such that unknown values are preserved
+// in the enum field itself, rather than going to the UnknownFieldSet.
+PROTOBUF_EXPORT bool HasPreservingUnknownEnumSemantics(
+ const FieldDescriptor* field);
+
+PROTOBUF_EXPORT bool HasHasbit(const FieldDescriptor* field);
+
+#ifndef SWIG
+enum class Utf8CheckMode {
+ kStrict = 0, // Parsing will fail if non UTF-8 data is in string fields.
+ kVerify = 1, // Only log an error but parsing will succeed.
+ kNone = 2, // No UTF-8 check.
+};
+PROTOBUF_EXPORT Utf8CheckMode GetUtf8CheckMode(const FieldDescriptor* field,
+ bool is_lite);
+#endif // !SWIG
+
+} // namespace cpp
+} // namespace internal
+
} // namespace protobuf
} // namespace google
#undef PROTOBUF_INTERNAL_CHECK_CLASS_SIZE
-#include <google/protobuf/port_undef.inc>
+#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 18b2c609542..cc46e4fd98b 100644
--- a/contrib/libs/protobuf/src/google/protobuf/descriptor.pb.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/descriptor.pb.cc
@@ -1,39 +1,38 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/descriptor.proto
-#include <google/protobuf/descriptor.pb.h>
+#include "google/protobuf/descriptor.pb.h"
#include <algorithm>
-
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/extension_set.h>
-#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/reflection_ops.h>
-#include <google/protobuf/wire_format.h>
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/extension_set.h"
+#include "google/protobuf/wire_format_lite.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/reflection_ops.h"
+#include "google/protobuf/wire_format.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+// Must be included last.
+#include "google/protobuf/port_def.inc"
PROTOBUF_PRAGMA_INIT_SEG
-
namespace _pb = ::PROTOBUF_NAMESPACE_ID;
-namespace _pbi = _pb::internal;
-
+namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal;
PROTOBUF_NAMESPACE_OPEN
PROTOBUF_CONSTEXPR FileDescriptorSet::FileDescriptorSet(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_.file_)*/{}
, /*decltype(_impl_._cached_size_)*/{}} {}
struct FileDescriptorSetDefaultTypeInternal {
- PROTOBUF_CONSTEXPR FileDescriptorSetDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR FileDescriptorSetDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~FileDescriptorSetDefaultTypeInternal() {}
union {
FileDescriptorSet _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_;
PROTOBUF_CONSTEXPR FileDescriptorProto::FileDescriptorProto(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
@@ -43,53 +42,75 @@ PROTOBUF_CONSTEXPR FileDescriptorProto::FileDescriptorProto(
, /*decltype(_impl_.enum_type_)*/{}
, /*decltype(_impl_.service_)*/{}
, /*decltype(_impl_.extension_)*/{}
- , /*decltype(_impl_.public_dependency_)*/{}
- , /*decltype(_impl_.weak_dependency_)*/{}
- , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.package_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.syntax_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
+ , /*decltype(_impl_.public_dependency_)*/ {}
+
+ , /*decltype(_impl_.weak_dependency_)*/ {}
+
+ , /*decltype(_impl_.name_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.package_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.syntax_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.edition_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
, /*decltype(_impl_.options_)*/nullptr
, /*decltype(_impl_.source_code_info_)*/nullptr} {}
struct FileDescriptorProtoDefaultTypeInternal {
- PROTOBUF_CONSTEXPR FileDescriptorProtoDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR FileDescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~FileDescriptorProtoDefaultTypeInternal() {}
union {
FileDescriptorProto _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_;
PROTOBUF_CONSTEXPR DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
, /*decltype(_impl_.options_)*/nullptr
- , /*decltype(_impl_.start_)*/0
- , /*decltype(_impl_.end_)*/0} {}
+ , /*decltype(_impl_.start_)*/ 0
+
+ , /*decltype(_impl_.end_)*/ 0
+} {}
struct DescriptorProto_ExtensionRangeDefaultTypeInternal {
- PROTOBUF_CONSTEXPR DescriptorProto_ExtensionRangeDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR DescriptorProto_ExtensionRangeDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~DescriptorProto_ExtensionRangeDefaultTypeInternal() {}
union {
DescriptorProto_ExtensionRange _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_;
PROTOBUF_CONSTEXPR DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
- , /*decltype(_impl_.start_)*/0
- , /*decltype(_impl_.end_)*/0} {}
+ , /*decltype(_impl_.start_)*/ 0
+
+ , /*decltype(_impl_.end_)*/ 0
+} {}
struct DescriptorProto_ReservedRangeDefaultTypeInternal {
- PROTOBUF_CONSTEXPR DescriptorProto_ReservedRangeDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR DescriptorProto_ReservedRangeDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~DescriptorProto_ReservedRangeDefaultTypeInternal() {}
union {
DescriptorProto_ReservedRange _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_;
PROTOBUF_CONSTEXPR DescriptorProto::DescriptorProto(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
@@ -102,85 +123,118 @@ PROTOBUF_CONSTEXPR DescriptorProto::DescriptorProto(
, /*decltype(_impl_.oneof_decl_)*/{}
, /*decltype(_impl_.reserved_range_)*/{}
, /*decltype(_impl_.reserved_name_)*/{}
- , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
+ , /*decltype(_impl_.name_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
, /*decltype(_impl_.options_)*/nullptr} {}
struct DescriptorProtoDefaultTypeInternal {
- PROTOBUF_CONSTEXPR DescriptorProtoDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR DescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~DescriptorProtoDefaultTypeInternal() {}
union {
DescriptorProto _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_;
PROTOBUF_CONSTEXPR ExtensionRangeOptions::ExtensionRangeOptions(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._extensions_)*/{}
, /*decltype(_impl_.uninterpreted_option_)*/{}
, /*decltype(_impl_._cached_size_)*/{}} {}
struct ExtensionRangeOptionsDefaultTypeInternal {
- PROTOBUF_CONSTEXPR ExtensionRangeOptionsDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR ExtensionRangeOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~ExtensionRangeOptionsDefaultTypeInternal() {}
union {
ExtensionRangeOptions _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ExtensionRangeOptionsDefaultTypeInternal _ExtensionRangeOptions_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ExtensionRangeOptionsDefaultTypeInternal _ExtensionRangeOptions_default_instance_;
PROTOBUF_CONSTEXPR FieldDescriptorProto::FieldDescriptorProto(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
- , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.extendee_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.type_name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.default_value_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.json_name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
+ , /*decltype(_impl_.name_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.extendee_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.type_name_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.default_value_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.json_name_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
, /*decltype(_impl_.options_)*/nullptr
- , /*decltype(_impl_.number_)*/0
- , /*decltype(_impl_.oneof_index_)*/0
- , /*decltype(_impl_.proto3_optional_)*/false
- , /*decltype(_impl_.label_)*/1
- , /*decltype(_impl_.type_)*/1} {}
+ , /*decltype(_impl_.number_)*/ 0
+
+ , /*decltype(_impl_.oneof_index_)*/ 0
+
+ , /*decltype(_impl_.proto3_optional_)*/ false
+
+ , /*decltype(_impl_.label_)*/ 1
+
+ , /*decltype(_impl_.type_)*/ 1
+} {}
struct FieldDescriptorProtoDefaultTypeInternal {
- PROTOBUF_CONSTEXPR FieldDescriptorProtoDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR FieldDescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~FieldDescriptorProtoDefaultTypeInternal() {}
union {
FieldDescriptorProto _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_;
PROTOBUF_CONSTEXPR OneofDescriptorProto::OneofDescriptorProto(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
- , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
+ , /*decltype(_impl_.name_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
, /*decltype(_impl_.options_)*/nullptr} {}
struct OneofDescriptorProtoDefaultTypeInternal {
- PROTOBUF_CONSTEXPR OneofDescriptorProtoDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR OneofDescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~OneofDescriptorProtoDefaultTypeInternal() {}
union {
OneofDescriptorProto _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_;
PROTOBUF_CONSTEXPR EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
- , /*decltype(_impl_.start_)*/0
- , /*decltype(_impl_.end_)*/0} {}
+ , /*decltype(_impl_.start_)*/ 0
+
+ , /*decltype(_impl_.end_)*/ 0
+} {}
struct EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal {
- PROTOBUF_CONSTEXPR EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal() {}
union {
EnumDescriptorProto_EnumReservedRange _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal _EnumDescriptorProto_EnumReservedRange_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal _EnumDescriptorProto_EnumReservedRange_default_instance_;
PROTOBUF_CONSTEXPR EnumDescriptorProto::EnumDescriptorProto(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
@@ -188,968 +242,1216 @@ PROTOBUF_CONSTEXPR EnumDescriptorProto::EnumDescriptorProto(
, /*decltype(_impl_.value_)*/{}
, /*decltype(_impl_.reserved_range_)*/{}
, /*decltype(_impl_.reserved_name_)*/{}
- , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
+ , /*decltype(_impl_.name_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
, /*decltype(_impl_.options_)*/nullptr} {}
struct EnumDescriptorProtoDefaultTypeInternal {
- PROTOBUF_CONSTEXPR EnumDescriptorProtoDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR EnumDescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~EnumDescriptorProtoDefaultTypeInternal() {}
union {
EnumDescriptorProto _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_;
PROTOBUF_CONSTEXPR EnumValueDescriptorProto::EnumValueDescriptorProto(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
- , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
+ , /*decltype(_impl_.name_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
, /*decltype(_impl_.options_)*/nullptr
- , /*decltype(_impl_.number_)*/0} {}
+ , /*decltype(_impl_.number_)*/ 0
+} {}
struct EnumValueDescriptorProtoDefaultTypeInternal {
- PROTOBUF_CONSTEXPR EnumValueDescriptorProtoDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR EnumValueDescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~EnumValueDescriptorProtoDefaultTypeInternal() {}
union {
EnumValueDescriptorProto _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_;
PROTOBUF_CONSTEXPR ServiceDescriptorProto::ServiceDescriptorProto(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
, /*decltype(_impl_.method_)*/{}
- , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
+ , /*decltype(_impl_.name_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
, /*decltype(_impl_.options_)*/nullptr} {}
struct ServiceDescriptorProtoDefaultTypeInternal {
- PROTOBUF_CONSTEXPR ServiceDescriptorProtoDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR ServiceDescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~ServiceDescriptorProtoDefaultTypeInternal() {}
union {
ServiceDescriptorProto _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_;
PROTOBUF_CONSTEXPR MethodDescriptorProto::MethodDescriptorProto(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
- , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.input_type_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.output_type_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
+ , /*decltype(_impl_.name_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.input_type_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.output_type_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
, /*decltype(_impl_.options_)*/nullptr
- , /*decltype(_impl_.client_streaming_)*/false
- , /*decltype(_impl_.server_streaming_)*/false} {}
+ , /*decltype(_impl_.client_streaming_)*/ false
+
+ , /*decltype(_impl_.server_streaming_)*/ false
+} {}
struct MethodDescriptorProtoDefaultTypeInternal {
- PROTOBUF_CONSTEXPR MethodDescriptorProtoDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR MethodDescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~MethodDescriptorProtoDefaultTypeInternal() {}
union {
MethodDescriptorProto _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_;
PROTOBUF_CONSTEXPR FileOptions::FileOptions(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._extensions_)*/{}
, /*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
, /*decltype(_impl_.uninterpreted_option_)*/{}
- , /*decltype(_impl_.java_package_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.java_outer_classname_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.go_package_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.objc_class_prefix_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.csharp_namespace_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.swift_prefix_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.php_class_prefix_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.php_namespace_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.php_metadata_namespace_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.ruby_package_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.java_multiple_files_)*/false
- , /*decltype(_impl_.java_generate_equals_and_hash_)*/false
- , /*decltype(_impl_.java_string_check_utf8_)*/false
- , /*decltype(_impl_.cc_generic_services_)*/false
- , /*decltype(_impl_.java_generic_services_)*/false
- , /*decltype(_impl_.py_generic_services_)*/false
- , /*decltype(_impl_.php_generic_services_)*/false
- , /*decltype(_impl_.deprecated_)*/false
- , /*decltype(_impl_.optimize_for_)*/1
- , /*decltype(_impl_.cc_enable_arenas_)*/true} {}
+ , /*decltype(_impl_.java_package_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.java_outer_classname_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.go_package_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.objc_class_prefix_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.csharp_namespace_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.swift_prefix_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.php_class_prefix_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.php_namespace_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.php_metadata_namespace_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.ruby_package_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.java_multiple_files_)*/ false
+
+ , /*decltype(_impl_.java_generate_equals_and_hash_)*/ false
+
+ , /*decltype(_impl_.java_string_check_utf8_)*/ false
+
+ , /*decltype(_impl_.cc_generic_services_)*/ false
+
+ , /*decltype(_impl_.java_generic_services_)*/ false
+
+ , /*decltype(_impl_.py_generic_services_)*/ false
+
+ , /*decltype(_impl_.php_generic_services_)*/ false
+
+ , /*decltype(_impl_.deprecated_)*/ false
+
+ , /*decltype(_impl_.optimize_for_)*/ 1
+
+ , /*decltype(_impl_.cc_enable_arenas_)*/ true
+} {}
struct FileOptionsDefaultTypeInternal {
- PROTOBUF_CONSTEXPR FileOptionsDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR FileOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~FileOptionsDefaultTypeInternal() {}
union {
FileOptions _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileOptionsDefaultTypeInternal _FileOptions_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileOptionsDefaultTypeInternal _FileOptions_default_instance_;
PROTOBUF_CONSTEXPR MessageOptions::MessageOptions(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._extensions_)*/{}
, /*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
, /*decltype(_impl_.uninterpreted_option_)*/{}
- , /*decltype(_impl_.message_set_wire_format_)*/false
- , /*decltype(_impl_.no_standard_descriptor_accessor_)*/false
- , /*decltype(_impl_.deprecated_)*/false
- , /*decltype(_impl_.map_entry_)*/false} {}
+ , /*decltype(_impl_.message_set_wire_format_)*/ false
+
+ , /*decltype(_impl_.no_standard_descriptor_accessor_)*/ false
+
+ , /*decltype(_impl_.deprecated_)*/ false
+
+ , /*decltype(_impl_.map_entry_)*/ false
+
+ , /*decltype(_impl_.deprecated_legacy_json_field_conflicts_)*/ false
+} {}
struct MessageOptionsDefaultTypeInternal {
- PROTOBUF_CONSTEXPR MessageOptionsDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR MessageOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~MessageOptionsDefaultTypeInternal() {}
union {
MessageOptions _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_;
PROTOBUF_CONSTEXPR FieldOptions::FieldOptions(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._extensions_)*/{}
, /*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
, /*decltype(_impl_.uninterpreted_option_)*/{}
- , /*decltype(_impl_.ctype_)*/0
- , /*decltype(_impl_.jstype_)*/0
- , /*decltype(_impl_.packed_)*/false
- , /*decltype(_impl_.lazy_)*/false
- , /*decltype(_impl_.unverified_lazy_)*/false
- , /*decltype(_impl_.deprecated_)*/false
- , /*decltype(_impl_.weak_)*/false} {}
+ , /*decltype(_impl_.ctype_)*/ 0
+
+ , /*decltype(_impl_.jstype_)*/ 0
+
+ , /*decltype(_impl_.packed_)*/ false
+
+ , /*decltype(_impl_.lazy_)*/ false
+
+ , /*decltype(_impl_.unverified_lazy_)*/ false
+
+ , /*decltype(_impl_.deprecated_)*/ false
+
+ , /*decltype(_impl_.weak_)*/ false
+
+ , /*decltype(_impl_.debug_redact_)*/ false
+
+ , /*decltype(_impl_.retention_)*/ 0
+
+ , /*decltype(_impl_.target_)*/ 0
+} {}
struct FieldOptionsDefaultTypeInternal {
- PROTOBUF_CONSTEXPR FieldOptionsDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR FieldOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~FieldOptionsDefaultTypeInternal() {}
union {
FieldOptions _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_;
PROTOBUF_CONSTEXPR OneofOptions::OneofOptions(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._extensions_)*/{}
, /*decltype(_impl_.uninterpreted_option_)*/{}
, /*decltype(_impl_._cached_size_)*/{}} {}
struct OneofOptionsDefaultTypeInternal {
- PROTOBUF_CONSTEXPR OneofOptionsDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR OneofOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~OneofOptionsDefaultTypeInternal() {}
union {
OneofOptions _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_;
PROTOBUF_CONSTEXPR EnumOptions::EnumOptions(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._extensions_)*/{}
, /*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
, /*decltype(_impl_.uninterpreted_option_)*/{}
- , /*decltype(_impl_.allow_alias_)*/false
- , /*decltype(_impl_.deprecated_)*/false} {}
+ , /*decltype(_impl_.allow_alias_)*/ false
+
+ , /*decltype(_impl_.deprecated_)*/ false
+
+ , /*decltype(_impl_.deprecated_legacy_json_field_conflicts_)*/ false
+} {}
struct EnumOptionsDefaultTypeInternal {
- PROTOBUF_CONSTEXPR EnumOptionsDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR EnumOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~EnumOptionsDefaultTypeInternal() {}
union {
EnumOptions _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_;
PROTOBUF_CONSTEXPR EnumValueOptions::EnumValueOptions(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._extensions_)*/{}
, /*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
, /*decltype(_impl_.uninterpreted_option_)*/{}
- , /*decltype(_impl_.deprecated_)*/false} {}
+ , /*decltype(_impl_.deprecated_)*/ false
+} {}
struct EnumValueOptionsDefaultTypeInternal {
- PROTOBUF_CONSTEXPR EnumValueOptionsDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR EnumValueOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~EnumValueOptionsDefaultTypeInternal() {}
union {
EnumValueOptions _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_;
PROTOBUF_CONSTEXPR ServiceOptions::ServiceOptions(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._extensions_)*/{}
, /*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
, /*decltype(_impl_.uninterpreted_option_)*/{}
- , /*decltype(_impl_.deprecated_)*/false} {}
+ , /*decltype(_impl_.deprecated_)*/ false
+} {}
struct ServiceOptionsDefaultTypeInternal {
- PROTOBUF_CONSTEXPR ServiceOptionsDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR ServiceOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~ServiceOptionsDefaultTypeInternal() {}
union {
ServiceOptions _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_;
PROTOBUF_CONSTEXPR MethodOptions::MethodOptions(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._extensions_)*/{}
, /*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
, /*decltype(_impl_.uninterpreted_option_)*/{}
- , /*decltype(_impl_.deprecated_)*/false
- , /*decltype(_impl_.idempotency_level_)*/0} {}
+ , /*decltype(_impl_.deprecated_)*/ false
+
+ , /*decltype(_impl_.idempotency_level_)*/ 0
+} {}
struct MethodOptionsDefaultTypeInternal {
- PROTOBUF_CONSTEXPR MethodOptionsDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR MethodOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~MethodOptionsDefaultTypeInternal() {}
union {
MethodOptions _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_;
PROTOBUF_CONSTEXPR UninterpretedOption_NamePart::UninterpretedOption_NamePart(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
- , /*decltype(_impl_.name_part_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.is_extension_)*/false} {}
+ , /*decltype(_impl_.name_part_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.is_extension_)*/ false
+} {}
struct UninterpretedOption_NamePartDefaultTypeInternal {
- PROTOBUF_CONSTEXPR UninterpretedOption_NamePartDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR UninterpretedOption_NamePartDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~UninterpretedOption_NamePartDefaultTypeInternal() {}
union {
UninterpretedOption_NamePart _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_;
PROTOBUF_CONSTEXPR UninterpretedOption::UninterpretedOption(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
, /*decltype(_impl_.name_)*/{}
- , /*decltype(_impl_.identifier_value_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.string_value_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.aggregate_value_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.positive_int_value_)*/arc_ui64{0u}
- , /*decltype(_impl_.negative_int_value_)*/arc_i64{0}
- , /*decltype(_impl_.double_value_)*/0} {}
+ , /*decltype(_impl_.identifier_value_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.string_value_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.aggregate_value_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.positive_int_value_)*/ ::arc_ui64{0u}
+
+ , /*decltype(_impl_.negative_int_value_)*/ ::arc_i64{0}
+
+ , /*decltype(_impl_.double_value_)*/ 0
+} {}
struct UninterpretedOptionDefaultTypeInternal {
- PROTOBUF_CONSTEXPR UninterpretedOptionDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR UninterpretedOptionDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~UninterpretedOptionDefaultTypeInternal() {}
union {
UninterpretedOption _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_;
PROTOBUF_CONSTEXPR SourceCodeInfo_Location::SourceCodeInfo_Location(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
- , /*decltype(_impl_.path_)*/{}
- , /*decltype(_impl_._path_cached_byte_size_)*/{0}
- , /*decltype(_impl_.span_)*/{}
- , /*decltype(_impl_._span_cached_byte_size_)*/{0}
+ , /*decltype(_impl_.path_)*/ {}
+ ,/* _impl_._path_cached_byte_size_ = */ { 0 }
+
+ , /*decltype(_impl_.span_)*/ {}
+ ,/* _impl_._span_cached_byte_size_ = */ { 0 }
+
, /*decltype(_impl_.leading_detached_comments_)*/{}
- , /*decltype(_impl_.leading_comments_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.trailing_comments_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}} {}
+ , /*decltype(_impl_.leading_comments_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.trailing_comments_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+} {}
struct SourceCodeInfo_LocationDefaultTypeInternal {
- PROTOBUF_CONSTEXPR SourceCodeInfo_LocationDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR SourceCodeInfo_LocationDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~SourceCodeInfo_LocationDefaultTypeInternal() {}
union {
SourceCodeInfo_Location _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_;
PROTOBUF_CONSTEXPR SourceCodeInfo::SourceCodeInfo(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_.location_)*/{}
, /*decltype(_impl_._cached_size_)*/{}} {}
struct SourceCodeInfoDefaultTypeInternal {
- PROTOBUF_CONSTEXPR SourceCodeInfoDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR SourceCodeInfoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~SourceCodeInfoDefaultTypeInternal() {}
union {
SourceCodeInfo _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_;
PROTOBUF_CONSTEXPR GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
- , /*decltype(_impl_.path_)*/{}
- , /*decltype(_impl_._path_cached_byte_size_)*/{0}
- , /*decltype(_impl_.source_file_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.begin_)*/0
- , /*decltype(_impl_.end_)*/0} {}
+ , /*decltype(_impl_.path_)*/ {}
+ ,/* _impl_._path_cached_byte_size_ = */ { 0 }
+
+ , /*decltype(_impl_.source_file_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.begin_)*/ 0
+
+ , /*decltype(_impl_.end_)*/ 0
+
+ , /*decltype(_impl_.semantic_)*/ 0
+} {}
struct GeneratedCodeInfo_AnnotationDefaultTypeInternal {
- PROTOBUF_CONSTEXPR GeneratedCodeInfo_AnnotationDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR GeneratedCodeInfo_AnnotationDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~GeneratedCodeInfo_AnnotationDefaultTypeInternal() {}
union {
GeneratedCodeInfo_Annotation _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_;
PROTOBUF_CONSTEXPR GeneratedCodeInfo::GeneratedCodeInfo(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_.annotation_)*/{}
, /*decltype(_impl_._cached_size_)*/{}} {}
struct GeneratedCodeInfoDefaultTypeInternal {
- PROTOBUF_CONSTEXPR GeneratedCodeInfoDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR GeneratedCodeInfoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~GeneratedCodeInfoDefaultTypeInternal() {}
union {
GeneratedCodeInfo _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_;
PROTOBUF_NAMESPACE_CLOSE
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_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorSet, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorSet, _impl_.file_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.name_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.package_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.dependency_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.public_dependency_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.weak_dependency_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.message_type_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.enum_type_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.service_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.extension_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.options_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.source_code_info_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.syntax_),
- 0,
- 1,
- ~0u,
- ~0u,
- ~0u,
- ~0u,
- ~0u,
- ~0u,
- ~0u,
- 3,
- 4,
- 2,
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.start_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.end_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.options_),
- 1,
- 2,
- 0,
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _impl_.start_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _impl_.end_),
- 0,
- 1,
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.name_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.field_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.extension_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.nested_type_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.enum_type_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.extension_range_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.oneof_decl_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.options_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.reserved_range_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.reserved_name_),
- 0,
- ~0u,
- ~0u,
- ~0u,
- ~0u,
- ~0u,
- ~0u,
- 1,
- ~0u,
- ~0u,
- ~0u, // no _has_bits_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, _internal_metadata_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, _impl_._extensions_),
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, _impl_.uninterpreted_option_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.name_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.number_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.label_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.type_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.type_name_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.extendee_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.default_value_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.oneof_index_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.json_name_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.options_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.proto3_optional_),
- 0,
- 6,
- 9,
- 10,
- 2,
- 1,
- 3,
- 7,
- 4,
- 5,
- 8,
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _impl_.name_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _impl_.options_),
- 0,
- 1,
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _impl_.start_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _impl_.end_),
- 0,
- 1,
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.name_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.value_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.options_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.reserved_range_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.reserved_name_),
- 0,
- ~0u,
- 1,
- ~0u,
- ~0u,
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.name_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.number_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.options_),
- 0,
- 2,
- 1,
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.name_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.method_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.options_),
- 0,
- ~0u,
- 1,
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.name_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.input_type_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.output_type_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.options_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.client_streaming_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.server_streaming_),
- 0,
- 1,
- 2,
- 3,
- 4,
- 5,
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _internal_metadata_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_._extensions_),
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_package_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_outer_classname_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_multiple_files_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_generate_equals_and_hash_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_string_check_utf8_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.optimize_for_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.go_package_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.cc_generic_services_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_generic_services_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.py_generic_services_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_generic_services_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.deprecated_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.cc_enable_arenas_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.objc_class_prefix_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.csharp_namespace_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.swift_prefix_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_class_prefix_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_namespace_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_metadata_namespace_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.ruby_package_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.uninterpreted_option_),
- 0,
- 1,
- 10,
- 11,
- 12,
- 18,
- 2,
- 13,
- 14,
- 15,
- 16,
- 17,
- 19,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9,
- ~0u,
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _internal_metadata_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_._extensions_),
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.message_set_wire_format_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.no_standard_descriptor_accessor_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.deprecated_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.map_entry_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.uninterpreted_option_),
- 0,
- 1,
- 2,
- 3,
- ~0u,
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _internal_metadata_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_._extensions_),
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.ctype_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.packed_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.jstype_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.lazy_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.unverified_lazy_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.deprecated_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.weak_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.uninterpreted_option_),
- 0,
- 2,
- 1,
- 3,
- 4,
- 5,
- 6,
- ~0u,
- ~0u, // no _has_bits_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _internal_metadata_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _impl_._extensions_),
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _impl_.uninterpreted_option_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _internal_metadata_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_._extensions_),
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.allow_alias_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.deprecated_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.uninterpreted_option_),
- 0,
- 1,
- ~0u,
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _internal_metadata_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_._extensions_),
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_.deprecated_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_.uninterpreted_option_),
- 0,
- ~0u,
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _internal_metadata_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_._extensions_),
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_.deprecated_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_.uninterpreted_option_),
- 0,
- ~0u,
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _internal_metadata_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_._extensions_),
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.deprecated_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.idempotency_level_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.uninterpreted_option_),
- 0,
- 1,
- ~0u,
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _impl_.name_part_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _impl_.is_extension_),
- 0,
- 1,
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.name_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.identifier_value_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.positive_int_value_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.negative_int_value_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.double_value_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.string_value_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.aggregate_value_),
- ~0u,
- 0,
- 3,
- 4,
- 5,
- 1,
- 2,
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.path_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.span_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.leading_comments_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.trailing_comments_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.leading_detached_comments_),
- ~0u,
- ~0u,
- 0,
- 1,
- ~0u,
- ~0u, // no _has_bits_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo, _impl_.location_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.path_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.source_file_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.begin_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.end_),
- ~0u,
- 0,
- 1,
- 2,
- ~0u, // no _has_bits_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo, _impl_.annotation_),
+static const ::_pb::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[9];
+static constexpr const ::_pb::ServiceDescriptor**
+ 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_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorSet, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorSet, _impl_.file_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.name_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.package_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.dependency_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.public_dependency_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.weak_dependency_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.message_type_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.enum_type_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.service_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.extension_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.options_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.source_code_info_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.syntax_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.edition_),
+ 0,
+ 1,
+ ~0u,
+ ~0u,
+ ~0u,
+ ~0u,
+ ~0u,
+ ~0u,
+ ~0u,
+ 4,
+ 5,
+ 2,
+ 3,
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.start_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.end_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.options_),
+ 1,
+ 2,
+ 0,
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _impl_.start_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _impl_.end_),
+ 0,
+ 1,
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.name_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.field_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.extension_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.nested_type_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.enum_type_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.extension_range_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.oneof_decl_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.options_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.reserved_range_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.reserved_name_),
+ 0,
+ ~0u,
+ ~0u,
+ ~0u,
+ ~0u,
+ ~0u,
+ ~0u,
+ 1,
+ ~0u,
+ ~0u,
+ ~0u, // no _has_bits_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, _impl_._extensions_),
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, _impl_.uninterpreted_option_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.name_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.number_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.label_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.type_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.type_name_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.extendee_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.default_value_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.oneof_index_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.json_name_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.options_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.proto3_optional_),
+ 0,
+ 6,
+ 9,
+ 10,
+ 2,
+ 1,
+ 3,
+ 7,
+ 4,
+ 5,
+ 8,
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _impl_.name_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _impl_.options_),
+ 0,
+ 1,
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _impl_.start_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _impl_.end_),
+ 0,
+ 1,
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.name_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.value_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.options_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.reserved_range_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.reserved_name_),
+ 0,
+ ~0u,
+ 1,
+ ~0u,
+ ~0u,
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.name_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.number_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.options_),
+ 0,
+ 2,
+ 1,
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.name_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.method_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.options_),
+ 0,
+ ~0u,
+ 1,
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.name_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.input_type_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.output_type_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.options_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.client_streaming_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.server_streaming_),
+ 0,
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_._extensions_),
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_package_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_outer_classname_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_multiple_files_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_generate_equals_and_hash_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_string_check_utf8_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.optimize_for_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.go_package_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.cc_generic_services_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_generic_services_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.py_generic_services_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_generic_services_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.deprecated_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.cc_enable_arenas_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.objc_class_prefix_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.csharp_namespace_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.swift_prefix_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_class_prefix_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_namespace_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_metadata_namespace_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.ruby_package_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.uninterpreted_option_),
+ 0,
+ 1,
+ 10,
+ 11,
+ 12,
+ 18,
+ 2,
+ 13,
+ 14,
+ 15,
+ 16,
+ 17,
+ 19,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ ~0u,
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_._extensions_),
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.message_set_wire_format_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.no_standard_descriptor_accessor_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.deprecated_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.map_entry_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.deprecated_legacy_json_field_conflicts_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.uninterpreted_option_),
+ 0,
+ 1,
+ 2,
+ 3,
+ 4,
+ ~0u,
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_._extensions_),
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.ctype_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.packed_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.jstype_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.lazy_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.unverified_lazy_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.deprecated_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.weak_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.debug_redact_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.retention_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.target_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.uninterpreted_option_),
+ 0,
+ 2,
+ 1,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ ~0u,
+ ~0u, // no _has_bits_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _impl_._extensions_),
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _impl_.uninterpreted_option_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_._extensions_),
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.allow_alias_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.deprecated_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.deprecated_legacy_json_field_conflicts_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.uninterpreted_option_),
+ 0,
+ 1,
+ 2,
+ ~0u,
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_._extensions_),
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_.deprecated_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_.uninterpreted_option_),
+ 0,
+ ~0u,
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_._extensions_),
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_.deprecated_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_.uninterpreted_option_),
+ 0,
+ ~0u,
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _internal_metadata_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_._extensions_),
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.deprecated_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.idempotency_level_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.uninterpreted_option_),
+ 0,
+ 1,
+ ~0u,
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _impl_.name_part_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _impl_.is_extension_),
+ 0,
+ 1,
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.name_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.identifier_value_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.positive_int_value_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.negative_int_value_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.double_value_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.string_value_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.aggregate_value_),
+ ~0u,
+ 0,
+ 3,
+ 4,
+ 5,
+ 1,
+ 2,
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.path_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.span_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.leading_comments_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.trailing_comments_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.leading_detached_comments_),
+ ~0u,
+ ~0u,
+ 0,
+ 1,
+ ~0u,
+ ~0u, // no _has_bits_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo, _impl_.location_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.path_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.source_file_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.begin_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.end_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.semantic_),
+ ~0u,
+ 0,
+ 1,
+ 2,
+ 3,
+ ~0u, // no _has_bits_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo, _impl_.annotation_),
};
-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)},
- { 49, 57, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange)},
- { 59, 75, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto)},
- { 85, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions)},
- { 92, 109, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto)},
- { 120, 128, -1, sizeof(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto)},
- { 130, 138, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange)},
- { 140, 151, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto)},
- { 156, 165, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto)},
- { 168, 177, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto)},
- { 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, 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 const ::_pbi::MigrationSchema
+ schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileDescriptorSet)},
+ { 9, 30, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto)},
+ { 43, 54, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange)},
+ { 57, 67, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange)},
+ { 69, 87, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto)},
+ { 97, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions)},
+ { 106, 125, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto)},
+ { 136, 146, -1, sizeof(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto)},
+ { 148, 158, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange)},
+ { 160, 173, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto)},
+ { 178, 189, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto)},
+ { 192, 203, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto)},
+ { 206, 220, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto)},
+ { 226, 255, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileOptions)},
+ { 276, 290, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MessageOptions)},
+ { 296, 315, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldOptions)},
+ { 326, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::OneofOptions)},
+ { 335, 347, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumOptions)},
+ { 351, 361, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValueOptions)},
+ { 363, 373, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ServiceOptions)},
+ { 375, 386, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MethodOptions)},
+ { 389, 399, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart)},
+ { 401, 416, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption)},
+ { 423, 436, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location)},
+ { 441, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo)},
+ { 450, 463, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation)},
+ { 468, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo)},
};
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,
+ &::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) =
- "\n google/protobuf/descriptor.proto\022\017goog"
- "le.protobuf\"G\n\021FileDescriptorSet\0222\n\004file"
- "\030\001 \003(\0132$.google.protobuf.FileDescriptorP"
- "roto\"\333\003\n\023FileDescriptorProto\022\014\n\004name\030\001 \001"
- "(\t\022\017\n\007package\030\002 \001(\t\022\022\n\ndependency\030\003 \003(\t\022"
- "\031\n\021public_dependency\030\n \003(\005\022\027\n\017weak_depen"
- "dency\030\013 \003(\005\0226\n\014message_type\030\004 \003(\0132 .goog"
- "le.protobuf.DescriptorProto\0227\n\tenum_type"
- "\030\005 \003(\0132$.google.protobuf.EnumDescriptorP"
- "roto\0228\n\007service\030\006 \003(\0132\'.google.protobuf."
- "ServiceDescriptorProto\0228\n\textension\030\007 \003("
- "\0132%.google.protobuf.FieldDescriptorProto"
- "\022-\n\007options\030\010 \001(\0132\034.google.protobuf.File"
- "Options\0229\n\020source_code_info\030\t \001(\0132\037.goog"
- "le.protobuf.SourceCodeInfo\022\016\n\006syntax\030\014 \001"
- "(\t\"\251\005\n\017DescriptorProto\022\014\n\004name\030\001 \001(\t\0224\n\005"
- "field\030\002 \003(\0132%.google.protobuf.FieldDescr"
- "iptorProto\0228\n\textension\030\006 \003(\0132%.google.p"
- "rotobuf.FieldDescriptorProto\0225\n\013nested_t"
- "ype\030\003 \003(\0132 .google.protobuf.DescriptorPr"
- "oto\0227\n\tenum_type\030\004 \003(\0132$.google.protobuf"
- ".EnumDescriptorProto\022H\n\017extension_range\030"
- "\005 \003(\0132/.google.protobuf.DescriptorProto."
- "ExtensionRange\0229\n\noneof_decl\030\010 \003(\0132%.goo"
- "gle.protobuf.OneofDescriptorProto\0220\n\007opt"
- "ions\030\007 \001(\0132\037.google.protobuf.MessageOpti"
- "ons\022F\n\016reserved_range\030\t \003(\0132..google.pro"
- "tobuf.DescriptorProto.ReservedRange\022\025\n\rr"
- "eserved_name\030\n \003(\t\032e\n\016ExtensionRange\022\r\n\005"
- "start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\0227\n\007options\030\003 \001("
- "\0132&.google.protobuf.ExtensionRangeOption"
- "s\032+\n\rReservedRange\022\r\n\005start\030\001 \001(\005\022\013\n\003end"
- "\030\002 \001(\005\"g\n\025ExtensionRangeOptions\022C\n\024unint"
- "erpreted_option\030\347\007 \003(\0132$.google.protobuf"
- ".UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"\325\005\n\024Fiel"
- "dDescriptorProto\022\014\n\004name\030\001 \001(\t\022\016\n\006number"
- "\030\003 \001(\005\022:\n\005label\030\004 \001(\0162+.google.protobuf."
- "FieldDescriptorProto.Label\0228\n\004type\030\005 \001(\016"
- "2*.google.protobuf.FieldDescriptorProto."
- "Type\022\021\n\ttype_name\030\006 \001(\t\022\020\n\010extendee\030\002 \001("
- "\t\022\025\n\rdefault_value\030\007 \001(\t\022\023\n\013oneof_index\030"
- "\t \001(\005\022\021\n\tjson_name\030\n \001(\t\022.\n\007options\030\010 \001("
- "\0132\035.google.protobuf.FieldOptions\022\027\n\017prot"
- "o3_optional\030\021 \001(\010\"\266\002\n\004Type\022\017\n\013TYPE_DOUBL"
- "E\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\nTYPE_INT64\020\003\022\017\n\013T"
- "YPE_UINT64\020\004\022\016\n\nTYPE_INT32\020\005\022\020\n\014TYPE_FIX"
- "ED64\020\006\022\020\n\014TYPE_FIXED32\020\007\022\r\n\tTYPE_BOOL\020\010\022"
- "\017\n\013TYPE_STRING\020\t\022\016\n\nTYPE_GROUP\020\n\022\020\n\014TYPE"
- "_MESSAGE\020\013\022\016\n\nTYPE_BYTES\020\014\022\017\n\013TYPE_UINT3"
- "2\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rTYPE_SFIXED32\020\017\022\021\n"
- "\rTYPE_SFIXED64\020\020\022\017\n\013TYPE_SINT32\020\021\022\017\n\013TYP"
- "E_SINT64\020\022\"C\n\005Label\022\022\n\016LABEL_OPTIONAL\020\001\022"
- "\022\n\016LABEL_REQUIRED\020\002\022\022\n\016LABEL_REPEATED\020\003\""
- "T\n\024OneofDescriptorProto\022\014\n\004name\030\001 \001(\t\022.\n"
- "\007options\030\002 \001(\0132\035.google.protobuf.OneofOp"
- "tions\"\244\002\n\023EnumDescriptorProto\022\014\n\004name\030\001 "
- "\001(\t\0228\n\005value\030\002 \003(\0132).google.protobuf.Enu"
- "mValueDescriptorProto\022-\n\007options\030\003 \001(\0132\034"
- ".google.protobuf.EnumOptions\022N\n\016reserved"
- "_range\030\004 \003(\01326.google.protobuf.EnumDescr"
- "iptorProto.EnumReservedRange\022\025\n\rreserved"
- "_name\030\005 \003(\t\032/\n\021EnumReservedRange\022\r\n\005star"
- "t\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\"l\n\030EnumValueDescrip"
- "torProto\022\014\n\004name\030\001 \001(\t\022\016\n\006number\030\002 \001(\005\0222"
- "\n\007options\030\003 \001(\0132!.google.protobuf.EnumVa"
- "lueOptions\"\220\001\n\026ServiceDescriptorProto\022\014\n"
- "\004name\030\001 \001(\t\0226\n\006method\030\002 \003(\0132&.google.pro"
- "tobuf.MethodDescriptorProto\0220\n\007options\030\003"
- " \001(\0132\037.google.protobuf.ServiceOptions\"\301\001"
- "\n\025MethodDescriptorProto\022\014\n\004name\030\001 \001(\t\022\022\n"
- "\ninput_type\030\002 \001(\t\022\023\n\013output_type\030\003 \001(\t\022/"
- "\n\007options\030\004 \001(\0132\036.google.protobuf.Method"
- "Options\022\037\n\020client_streaming\030\005 \001(\010:\005false"
- "\022\037\n\020server_streaming\030\006 \001(\010:\005false\"\245\006\n\013Fi"
- "leOptions\022\024\n\014java_package\030\001 \001(\t\022\034\n\024java_"
- "outer_classname\030\010 \001(\t\022\"\n\023java_multiple_f"
- "iles\030\n \001(\010:\005false\022)\n\035java_generate_equal"
- "s_and_hash\030\024 \001(\010B\002\030\001\022%\n\026java_string_chec"
- "k_utf8\030\033 \001(\010:\005false\022F\n\014optimize_for\030\t \001("
- "\0162).google.protobuf.FileOptions.Optimize"
- "Mode:\005SPEED\022\022\n\ngo_package\030\013 \001(\t\022\"\n\023cc_ge"
- "neric_services\030\020 \001(\010:\005false\022$\n\025java_gene"
- "ric_services\030\021 \001(\010:\005false\022\"\n\023py_generic_"
- "services\030\022 \001(\010:\005false\022#\n\024php_generic_ser"
- "vices\030* \001(\010:\005false\022\031\n\ndeprecated\030\027 \001(\010:\005"
- "false\022\036\n\020cc_enable_arenas\030\037 \001(\010:\004true\022\031\n"
- "\021objc_class_prefix\030$ \001(\t\022\030\n\020csharp_names"
- "pace\030% \001(\t\022\024\n\014swift_prefix\030\' \001(\t\022\030\n\020php_"
- "class_prefix\030( \001(\t\022\025\n\rphp_namespace\030) \001("
- "\t\022\036\n\026php_metadata_namespace\030, \001(\t\022\024\n\014rub"
- "y_package\030- \001(\t\022C\n\024uninterpreted_option\030"
- "\347\007 \003(\0132$.google.protobuf.UninterpretedOp"
- "tion\":\n\014OptimizeMode\022\t\n\005SPEED\020\001\022\r\n\tCODE_"
- "SIZE\020\002\022\020\n\014LITE_RUNTIME\020\003*\t\010\350\007\020\200\200\200\200\002J\004\010&\020"
- "\'\"\204\002\n\016MessageOptions\022&\n\027message_set_wire"
- "_format\030\001 \001(\010:\005false\022.\n\037no_standard_desc"
- "riptor_accessor\030\002 \001(\010:\005false\022\031\n\ndeprecat"
- "ed\030\003 \001(\010:\005false\022\021\n\tmap_entry\030\007 \001(\010\022C\n\024un"
- "interpreted_option\030\347\007 \003(\0132$.google.proto"
- "buf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005"
- "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\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"
- "*\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 ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once;
+const char descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ "\n google/protobuf/descriptor.proto\022\017goog"
+ "le.protobuf\"G\n\021FileDescriptorSet\0222\n\004file"
+ "\030\001 \003(\0132$.google.protobuf.FileDescriptorP"
+ "roto\"\354\003\n\023FileDescriptorProto\022\014\n\004name\030\001 \001"
+ "(\t\022\017\n\007package\030\002 \001(\t\022\022\n\ndependency\030\003 \003(\t\022"
+ "\031\n\021public_dependency\030\n \003(\005\022\027\n\017weak_depen"
+ "dency\030\013 \003(\005\0226\n\014message_type\030\004 \003(\0132 .goog"
+ "le.protobuf.DescriptorProto\0227\n\tenum_type"
+ "\030\005 \003(\0132$.google.protobuf.EnumDescriptorP"
+ "roto\0228\n\007service\030\006 \003(\0132\'.google.protobuf."
+ "ServiceDescriptorProto\0228\n\textension\030\007 \003("
+ "\0132%.google.protobuf.FieldDescriptorProto"
+ "\022-\n\007options\030\010 \001(\0132\034.google.protobuf.File"
+ "Options\0229\n\020source_code_info\030\t \001(\0132\037.goog"
+ "le.protobuf.SourceCodeInfo\022\016\n\006syntax\030\014 \001"
+ "(\t\022\017\n\007edition\030\r \001(\t\"\251\005\n\017DescriptorProto\022"
+ "\014\n\004name\030\001 \001(\t\0224\n\005field\030\002 \003(\0132%.google.pr"
+ "otobuf.FieldDescriptorProto\0228\n\textension"
+ "\030\006 \003(\0132%.google.protobuf.FieldDescriptor"
+ "Proto\0225\n\013nested_type\030\003 \003(\0132 .google.prot"
+ "obuf.DescriptorProto\0227\n\tenum_type\030\004 \003(\0132"
+ "$.google.protobuf.EnumDescriptorProto\022H\n"
+ "\017extension_range\030\005 \003(\0132/.google.protobuf"
+ ".DescriptorProto.ExtensionRange\0229\n\noneof"
+ "_decl\030\010 \003(\0132%.google.protobuf.OneofDescr"
+ "iptorProto\0220\n\007options\030\007 \001(\0132\037.google.pro"
+ "tobuf.MessageOptions\022F\n\016reserved_range\030\t"
+ " \003(\0132..google.protobuf.DescriptorProto.R"
+ "eservedRange\022\025\n\rreserved_name\030\n \003(\t\032e\n\016E"
+ "xtensionRange\022\r\n\005start\030\001 \001(\005\022\013\n\003end\030\002 \001("
+ "\005\0227\n\007options\030\003 \001(\0132&.google.protobuf.Ext"
+ "ensionRangeOptions\032+\n\rReservedRange\022\r\n\005s"
+ "tart\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\"g\n\025ExtensionRang"
+ "eOptions\022C\n\024uninterpreted_option\030\347\007 \003(\0132"
+ "$.google.protobuf.UninterpretedOption*\t\010"
+ "\350\007\020\200\200\200\200\002\"\325\005\n\024FieldDescriptorProto\022\014\n\004nam"
+ "e\030\001 \001(\t\022\016\n\006number\030\003 \001(\005\022:\n\005label\030\004 \001(\0162+"
+ ".google.protobuf.FieldDescriptorProto.La"
+ "bel\0228\n\004type\030\005 \001(\0162*.google.protobuf.Fiel"
+ "dDescriptorProto.Type\022\021\n\ttype_name\030\006 \001(\t"
+ "\022\020\n\010extendee\030\002 \001(\t\022\025\n\rdefault_value\030\007 \001("
+ "\t\022\023\n\013oneof_index\030\t \001(\005\022\021\n\tjson_name\030\n \001("
+ "\t\022.\n\007options\030\010 \001(\0132\035.google.protobuf.Fie"
+ "ldOptions\022\027\n\017proto3_optional\030\021 \001(\010\"\266\002\n\004T"
+ "ype\022\017\n\013TYPE_DOUBLE\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\n"
+ "TYPE_INT64\020\003\022\017\n\013TYPE_UINT64\020\004\022\016\n\nTYPE_IN"
+ "T32\020\005\022\020\n\014TYPE_FIXED64\020\006\022\020\n\014TYPE_FIXED32\020"
+ "\007\022\r\n\tTYPE_BOOL\020\010\022\017\n\013TYPE_STRING\020\t\022\016\n\nTYP"
+ "E_GROUP\020\n\022\020\n\014TYPE_MESSAGE\020\013\022\016\n\nTYPE_BYTE"
+ "S\020\014\022\017\n\013TYPE_UINT32\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rT"
+ "YPE_SFIXED32\020\017\022\021\n\rTYPE_SFIXED64\020\020\022\017\n\013TYP"
+ "E_SINT32\020\021\022\017\n\013TYPE_SINT64\020\022\"C\n\005Label\022\022\n\016"
+ "LABEL_OPTIONAL\020\001\022\022\n\016LABEL_REQUIRED\020\002\022\022\n\016"
+ "LABEL_REPEATED\020\003\"T\n\024OneofDescriptorProto"
+ "\022\014\n\004name\030\001 \001(\t\022.\n\007options\030\002 \001(\0132\035.google"
+ ".protobuf.OneofOptions\"\244\002\n\023EnumDescripto"
+ "rProto\022\014\n\004name\030\001 \001(\t\0228\n\005value\030\002 \003(\0132).go"
+ "ogle.protobuf.EnumValueDescriptorProto\022-"
+ "\n\007options\030\003 \001(\0132\034.google.protobuf.EnumOp"
+ "tions\022N\n\016reserved_range\030\004 \003(\01326.google.p"
+ "rotobuf.EnumDescriptorProto.EnumReserved"
+ "Range\022\025\n\rreserved_name\030\005 \003(\t\032/\n\021EnumRese"
+ "rvedRange\022\r\n\005start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\"l\n"
+ "\030EnumValueDescriptorProto\022\014\n\004name\030\001 \001(\t\022"
+ "\016\n\006number\030\002 \001(\005\0222\n\007options\030\003 \001(\0132!.googl"
+ "e.protobuf.EnumValueOptions\"\220\001\n\026ServiceD"
+ "escriptorProto\022\014\n\004name\030\001 \001(\t\0226\n\006method\030\002"
+ " \003(\0132&.google.protobuf.MethodDescriptorP"
+ "roto\0220\n\007options\030\003 \001(\0132\037.google.protobuf."
+ "ServiceOptions\"\301\001\n\025MethodDescriptorProto"
+ "\022\014\n\004name\030\001 \001(\t\022\022\n\ninput_type\030\002 \001(\t\022\023\n\013ou"
+ "tput_type\030\003 \001(\t\022/\n\007options\030\004 \001(\0132\036.googl"
+ "e.protobuf.MethodOptions\022\037\n\020client_strea"
+ "ming\030\005 \001(\010:\005false\022\037\n\020server_streaming\030\006 "
+ "\001(\010:\005false\"\245\006\n\013FileOptions\022\024\n\014java_packa"
+ "ge\030\001 \001(\t\022\034\n\024java_outer_classname\030\010 \001(\t\022\""
+ "\n\023java_multiple_files\030\n \001(\010:\005false\022)\n\035ja"
+ "va_generate_equals_and_hash\030\024 \001(\010B\002\030\001\022%\n"
+ "\026java_string_check_utf8\030\033 \001(\010:\005false\022F\n\014"
+ "optimize_for\030\t \001(\0162).google.protobuf.Fil"
+ "eOptions.OptimizeMode:\005SPEED\022\022\n\ngo_packa"
+ "ge\030\013 \001(\t\022\"\n\023cc_generic_services\030\020 \001(\010:\005f"
+ "alse\022$\n\025java_generic_services\030\021 \001(\010:\005fal"
+ "se\022\"\n\023py_generic_services\030\022 \001(\010:\005false\022#"
+ "\n\024php_generic_services\030* \001(\010:\005false\022\031\n\nd"
+ "eprecated\030\027 \001(\010:\005false\022\036\n\020cc_enable_aren"
+ "as\030\037 \001(\010:\004true\022\031\n\021objc_class_prefix\030$ \001("
+ "\t\022\030\n\020csharp_namespace\030% \001(\t\022\024\n\014swift_pre"
+ "fix\030\' \001(\t\022\030\n\020php_class_prefix\030( \001(\t\022\025\n\rp"
+ "hp_namespace\030) \001(\t\022\036\n\026php_metadata_names"
+ "pace\030, \001(\t\022\024\n\014ruby_package\030- \001(\t\022C\n\024unin"
+ "terpreted_option\030\347\007 \003(\0132$.google.protobu"
+ "f.UninterpretedOption\":\n\014OptimizeMode\022\t\n"
+ "\005SPEED\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_RUNTIME\020"
+ "\003*\t\010\350\007\020\200\200\200\200\002J\004\010&\020\'\"\270\002\n\016MessageOptions\022&\n"
+ "\027message_set_wire_format\030\001 \001(\010:\005false\022.\n"
+ "\037no_standard_descriptor_accessor\030\002 \001(\010:\005"
+ "false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\021\n\tmap_"
+ "entry\030\007 \001(\010\0222\n&deprecated_legacy_json_fi"
+ "eld_conflicts\030\013 \001(\010B\002\030\001\022C\n\024uninterpreted"
+ "_option\030\347\007 \003(\0132$.google.protobuf.Uninter"
+ "pretedOption*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005J\004\010\005\020\006J\004\010\006\020"
+ "\007J\004\010\010\020\tJ\004\010\t\020\n\"\303\007\n\014FieldOptions\022:\n\005ctype\030"
+ "\001 \001(\0162#.google.protobuf.FieldOptions.CTy"
+ "pe:\006STRING\022\016\n\006packed\030\002 \001(\010\022\?\n\006jstype\030\006 \001"
+ "(\0162$.google.protobuf.FieldOptions.JSType"
+ ":\tJS_NORMAL\022\023\n\004lazy\030\005 \001(\010:\005false\022\036\n\017unve"
+ "rified_lazy\030\017 \001(\010:\005false\022\031\n\ndeprecated\030\003"
+ " \001(\010:\005false\022\023\n\004weak\030\n \001(\010:\005false\022\033\n\014debu"
+ "g_redact\030\020 \001(\010:\005false\022@\n\tretention\030\021 \001(\016"
+ "2-.google.protobuf.FieldOptions.OptionRe"
+ "tention\022>\n\006target\030\022 \001(\0162..google.protobu"
+ "f.FieldOptions.OptionTargetType\022C\n\024unint"
+ "erpreted_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\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_NUMB"
+ "ER\020\002\"U\n\017OptionRetention\022\025\n\021RETENTION_UNK"
+ "NOWN\020\000\022\025\n\021RETENTION_RUNTIME\020\001\022\024\n\020RETENTI"
+ "ON_SOURCE\020\002\"\214\002\n\020OptionTargetType\022\027\n\023TARG"
+ "ET_TYPE_UNKNOWN\020\000\022\024\n\020TARGET_TYPE_FILE\020\001\022"
+ "\037\n\033TARGET_TYPE_EXTENSION_RANGE\020\002\022\027\n\023TARG"
+ "ET_TYPE_MESSAGE\020\003\022\025\n\021TARGET_TYPE_FIELD\020\004"
+ "\022\025\n\021TARGET_TYPE_ONEOF\020\005\022\024\n\020TARGET_TYPE_E"
+ "NUM\020\006\022\032\n\026TARGET_TYPE_ENUM_ENTRY\020\007\022\027\n\023TAR"
+ "GET_TYPE_SERVICE\020\010\022\026\n\022TARGET_TYPE_METHOD"
+ "\020\t*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005\"^\n\014OneofOptions\022C\n\024u"
+ "ninterpreted_option\030\347\007 \003(\0132$.google.prot"
+ "obuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"\307\001\n\013"
+ "EnumOptions\022\023\n\013allow_alias\030\002 \001(\010\022\031\n\ndepr"
+ "ecated\030\003 \001(\010:\005false\0222\n&deprecated_legacy"
+ "_json_field_conflicts\030\006 \001(\010B\002\030\001\022C\n\024unint"
+ "erpreted_option\030\347\007 \003(\0132$.google.protobuf"
+ ".UninterpretedOption*\t\010\350\007\020\200\200\200\200\002J\004\010\005\020\006\"}\n"
+ "\020EnumValueOptions\022\031\n\ndeprecated\030\001 \001(\010:\005f"
+ "alse\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.go"
+ "ogle.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(\013"
+ "2$.google.protobuf.UninterpretedOption*\t"
+ "\010\350\007\020\200\200\200\200\002\"\255\002\n\rMethodOptions\022\031\n\ndeprecate"
+ "d\030! \001(\010:\005false\022_\n\021idempotency_level\030\" \001("
+ "\0162/.google.protobuf.MethodOptions.Idempo"
+ "tencyLevel:\023IDEMPOTENCY_UNKNOWN\022C\n\024unint"
+ "erpreted_option\030\347\007 \003(\0132$.google.protobuf"
+ ".UninterpretedOption\"P\n\020IdempotencyLevel"
+ "\022\027\n\023IDEMPOTENCY_UNKNOWN\020\000\022\023\n\017NO_SIDE_EFF"
+ "ECTS\020\001\022\016\n\nIDEMPOTENT\020\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023Un"
+ "interpretedOption\022;\n\004name\030\002 \003(\0132-.google"
+ ".protobuf.UninterpretedOption.NamePart\022\030"
+ "\n\020identifier_value\030\003 \001(\t\022\032\n\022positive_int"
+ "_value\030\004 \001(\004\022\032\n\022negative_int_value\030\005 \001(\003"
+ "\022\024\n\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\010NamePar"
+ "t\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.Locatio"
+ "n\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\021"
+ "trailing_comments\030\004 \001(\t\022!\n\031leading_detac"
+ "hed_comments\030\006 \003(\t\"\234\002\n\021GeneratedCodeInfo"
+ "\022A\n\nannotation\030\001 \003(\0132-.google.protobuf.G"
+ "eneratedCodeInfo.Annotation\032\303\001\n\nAnnotati"
+ "on\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(\005\022H\n\010semanti"
+ "c\030\005 \001(\01626.google.protobuf.GeneratedCodeI"
+ "nfo.Annotation.Semantic\"(\n\010Semantic\022\010\n\004N"
+ "ONE\020\000\022\007\n\003SET\020\001\022\t\n\005ALIAS\020\002B~\n\023com.google."
+ "protobufB\020DescriptorProtosH\001Z-google.gol"
+ "ang.org/protobuf/types/descriptorpb\370\001\001\242\002"
+ "\003GPB\252\002\032Google.Protobuf.Reflection"
+};
+static ::y_absl::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,
+ false,
+ false,
+ 6833,
+ 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,
+ &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,
};
+
+// This function exists to be marked as weak.
+// It can significantly speed up compilation by breaking up LLVM's SCC
+// in the .pb.cc translation units. Large translation units see a
+// reduction of more than 35% of walltime for optimized builds. Without
+// the weak attribute all the messages in the file, including all the
+// vtables and everything they use become part of the same SCC through
+// a cycle like:
+// GetMetadata -> descriptor table -> default instances ->
+// 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 ::_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_PRIORITY2 static ::_pbi::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);
@@ -1180,8 +1482,9 @@ bool FieldDescriptorProto_Type_IsValid(int value) {
return false;
}
}
+#if (__cplusplus < 201703) && \
+ (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
-#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
constexpr FieldDescriptorProto_Type FieldDescriptorProto::TYPE_DOUBLE;
constexpr FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FLOAT;
constexpr FieldDescriptorProto_Type FieldDescriptorProto::TYPE_INT64;
@@ -1203,7 +1506,9 @@ constexpr FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SINT64;
constexpr FieldDescriptorProto_Type FieldDescriptorProto::Type_MIN;
constexpr FieldDescriptorProto_Type FieldDescriptorProto::Type_MAX;
constexpr int FieldDescriptorProto::Type_ARRAYSIZE;
-#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
+
+#endif // (__cplusplus < 201703) &&
+ // (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* FieldDescriptorProto_Label_descriptor() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto);
return file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[1];
@@ -1218,15 +1523,18 @@ bool FieldDescriptorProto_Label_IsValid(int value) {
return false;
}
}
+#if (__cplusplus < 201703) && \
+ (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
-#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
constexpr FieldDescriptorProto_Label FieldDescriptorProto::LABEL_OPTIONAL;
constexpr FieldDescriptorProto_Label FieldDescriptorProto::LABEL_REQUIRED;
constexpr FieldDescriptorProto_Label FieldDescriptorProto::LABEL_REPEATED;
constexpr FieldDescriptorProto_Label FieldDescriptorProto::Label_MIN;
constexpr FieldDescriptorProto_Label FieldDescriptorProto::Label_MAX;
constexpr int FieldDescriptorProto::Label_ARRAYSIZE;
-#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
+
+#endif // (__cplusplus < 201703) &&
+ // (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* FileOptions_OptimizeMode_descriptor() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto);
return file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[2];
@@ -1241,15 +1549,18 @@ bool FileOptions_OptimizeMode_IsValid(int value) {
return false;
}
}
+#if (__cplusplus < 201703) && \
+ (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
-#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
constexpr FileOptions_OptimizeMode FileOptions::SPEED;
constexpr FileOptions_OptimizeMode FileOptions::CODE_SIZE;
constexpr FileOptions_OptimizeMode FileOptions::LITE_RUNTIME;
constexpr FileOptions_OptimizeMode FileOptions::OptimizeMode_MIN;
constexpr FileOptions_OptimizeMode FileOptions::OptimizeMode_MAX;
constexpr int FileOptions::OptimizeMode_ARRAYSIZE;
-#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
+
+#endif // (__cplusplus < 201703) &&
+ // (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* FieldOptions_CType_descriptor() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto);
return file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[3];
@@ -1264,15 +1575,18 @@ bool FieldOptions_CType_IsValid(int value) {
return false;
}
}
+#if (__cplusplus < 201703) && \
+ (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
-#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
constexpr FieldOptions_CType FieldOptions::STRING;
constexpr FieldOptions_CType FieldOptions::CORD;
constexpr FieldOptions_CType FieldOptions::STRING_PIECE;
constexpr FieldOptions_CType FieldOptions::CType_MIN;
constexpr FieldOptions_CType FieldOptions::CType_MAX;
constexpr int FieldOptions::CType_ARRAYSIZE;
-#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
+
+#endif // (__cplusplus < 201703) &&
+ // (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* FieldOptions_JSType_descriptor() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto);
return file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[4];
@@ -1287,19 +1601,88 @@ bool FieldOptions_JSType_IsValid(int value) {
return false;
}
}
+#if (__cplusplus < 201703) && \
+ (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
-#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
constexpr FieldOptions_JSType FieldOptions::JS_NORMAL;
constexpr FieldOptions_JSType FieldOptions::JS_STRING;
constexpr FieldOptions_JSType FieldOptions::JS_NUMBER;
constexpr FieldOptions_JSType FieldOptions::JSType_MIN;
constexpr FieldOptions_JSType FieldOptions::JSType_MAX;
constexpr int FieldOptions::JSType_ARRAYSIZE;
-#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
-const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* MethodOptions_IdempotencyLevel_descriptor() {
+
+#endif // (__cplusplus < 201703) &&
+ // (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
+const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* FieldOptions_OptionRetention_descriptor() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto);
return file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[5];
}
+bool FieldOptions_OptionRetention_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ case 2:
+ return true;
+ default:
+ return false;
+ }
+}
+#if (__cplusplus < 201703) && \
+ (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
+
+constexpr FieldOptions_OptionRetention FieldOptions::RETENTION_UNKNOWN;
+constexpr FieldOptions_OptionRetention FieldOptions::RETENTION_RUNTIME;
+constexpr FieldOptions_OptionRetention FieldOptions::RETENTION_SOURCE;
+constexpr FieldOptions_OptionRetention FieldOptions::OptionRetention_MIN;
+constexpr FieldOptions_OptionRetention FieldOptions::OptionRetention_MAX;
+constexpr int FieldOptions::OptionRetention_ARRAYSIZE;
+
+#endif // (__cplusplus < 201703) &&
+ // (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
+const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* FieldOptions_OptionTargetType_descriptor() {
+ ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto);
+ return file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[6];
+}
+bool FieldOptions_OptionTargetType_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ return true;
+ default:
+ return false;
+ }
+}
+#if (__cplusplus < 201703) && \
+ (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
+
+constexpr FieldOptions_OptionTargetType FieldOptions::TARGET_TYPE_UNKNOWN;
+constexpr FieldOptions_OptionTargetType FieldOptions::TARGET_TYPE_FILE;
+constexpr FieldOptions_OptionTargetType FieldOptions::TARGET_TYPE_EXTENSION_RANGE;
+constexpr FieldOptions_OptionTargetType FieldOptions::TARGET_TYPE_MESSAGE;
+constexpr FieldOptions_OptionTargetType FieldOptions::TARGET_TYPE_FIELD;
+constexpr FieldOptions_OptionTargetType FieldOptions::TARGET_TYPE_ONEOF;
+constexpr FieldOptions_OptionTargetType FieldOptions::TARGET_TYPE_ENUM;
+constexpr FieldOptions_OptionTargetType FieldOptions::TARGET_TYPE_ENUM_ENTRY;
+constexpr FieldOptions_OptionTargetType FieldOptions::TARGET_TYPE_SERVICE;
+constexpr FieldOptions_OptionTargetType FieldOptions::TARGET_TYPE_METHOD;
+constexpr FieldOptions_OptionTargetType FieldOptions::OptionTargetType_MIN;
+constexpr FieldOptions_OptionTargetType FieldOptions::OptionTargetType_MAX;
+constexpr int FieldOptions::OptionTargetType_ARRAYSIZE;
+
+#endif // (__cplusplus < 201703) &&
+ // (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
+const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* MethodOptions_IdempotencyLevel_descriptor() {
+ ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto);
+ return file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[7];
+}
bool MethodOptions_IdempotencyLevel_IsValid(int value) {
switch (value) {
case 0:
@@ -1310,26 +1693,53 @@ bool MethodOptions_IdempotencyLevel_IsValid(int value) {
return false;
}
}
+#if (__cplusplus < 201703) && \
+ (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
-#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
constexpr MethodOptions_IdempotencyLevel MethodOptions::IDEMPOTENCY_UNKNOWN;
constexpr MethodOptions_IdempotencyLevel MethodOptions::NO_SIDE_EFFECTS;
constexpr MethodOptions_IdempotencyLevel MethodOptions::IDEMPOTENT;
constexpr MethodOptions_IdempotencyLevel MethodOptions::IdempotencyLevel_MIN;
constexpr MethodOptions_IdempotencyLevel MethodOptions::IdempotencyLevel_MAX;
constexpr int MethodOptions::IdempotencyLevel_ARRAYSIZE;
-#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
+#endif // (__cplusplus < 201703) &&
+ // (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
+const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* GeneratedCodeInfo_Annotation_Semantic_descriptor() {
+ ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto);
+ return file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[8];
+}
+bool GeneratedCodeInfo_Annotation_Semantic_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ case 2:
+ return true;
+ default:
+ return false;
+ }
+}
+#if (__cplusplus < 201703) && \
+ (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
+
+constexpr GeneratedCodeInfo_Annotation_Semantic GeneratedCodeInfo_Annotation::NONE;
+constexpr GeneratedCodeInfo_Annotation_Semantic GeneratedCodeInfo_Annotation::SET;
+constexpr GeneratedCodeInfo_Annotation_Semantic GeneratedCodeInfo_Annotation::ALIAS;
+constexpr GeneratedCodeInfo_Annotation_Semantic GeneratedCodeInfo_Annotation::Semantic_MIN;
+constexpr GeneratedCodeInfo_Annotation_Semantic GeneratedCodeInfo_Annotation::Semantic_MAX;
+constexpr int GeneratedCodeInfo_Annotation::Semantic_ARRAYSIZE;
+
+#endif // (__cplusplus < 201703) &&
+ // (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
// ===================================================================
class FileDescriptorSet::_Internal {
public:
};
-FileDescriptorSet::FileDescriptorSet(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+FileDescriptorSet::FileDescriptorSet(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.FileDescriptorSet)
}
FileDescriptorSet::FileDescriptorSet(const FileDescriptorSet& from)
@@ -1343,10 +1753,8 @@ FileDescriptorSet::FileDescriptorSet(const FileDescriptorSet& from)
// @@protoc_insertion_point(copy_constructor:google.protobuf.FileDescriptorSet)
}
-inline void FileDescriptorSet::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void FileDescriptorSet::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_.file_){arena}
, /*decltype(_impl_._cached_size_)*/{}
@@ -1363,7 +1771,7 @@ FileDescriptorSet::~FileDescriptorSet() {
}
inline void FileDescriptorSet::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.file_.~RepeatedPtrField();
}
@@ -1373,7 +1781,7 @@ void FileDescriptorSet::SetCachedSize(int size) const {
void FileDescriptorSet::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FileDescriptorSet)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -1384,12 +1792,12 @@ void FileDescriptorSet::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated .google.protobuf.FileDescriptorProto file = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
ptr -= 1;
do {
ptr += 1;
@@ -1397,8 +1805,9 @@ const char* FileDescriptorSet::_InternalParse(const char* ptr, ::_pbi::ParseCont
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -1423,10 +1832,10 @@ failure:
#undef CHK_
}
-uint8_t* FileDescriptorSet::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* FileDescriptorSet::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FileDescriptorSet)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .google.protobuf.FileDescriptorProto file = 1;
@@ -1445,11 +1854,11 @@ uint8_t* FileDescriptorSet::_InternalSerialize(
return target;
}
-size_t FileDescriptorSet::ByteSizeLong() const {
+::size_t FileDescriptorSet::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileDescriptorSet)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -1474,8 +1883,8 @@ void FileDescriptorSet::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, cons
auto* const _this = static_cast<FileDescriptorSet*>(&to_msg);
auto& from = static_cast<const FileDescriptorSet&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorSet)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.file_.MergeFrom(from._impl_.file_);
@@ -1506,12 +1915,13 @@ void FileDescriptorSet::InternalSwap(FileDescriptorSet* other) {
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[0]);
}
-
// ===================================================================
class FileDescriptorProto::_Internal {
public:
using HasBits = decltype(std::declval<FileDescriptorProto>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(FileDescriptorProto, _impl_._has_bits_);
static void set_has_name(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -1520,15 +1930,18 @@ class FileDescriptorProto::_Internal {
}
static const ::PROTOBUF_NAMESPACE_ID::FileOptions& options(const FileDescriptorProto* msg);
static void set_has_options(HasBits* has_bits) {
- (*has_bits)[0] |= 8u;
+ (*has_bits)[0] |= 16u;
}
static const ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo& source_code_info(const FileDescriptorProto* msg);
static void set_has_source_code_info(HasBits* has_bits) {
- (*has_bits)[0] |= 16u;
+ (*has_bits)[0] |= 32u;
}
static void set_has_syntax(HasBits* has_bits) {
(*has_bits)[0] |= 4u;
}
+ static void set_has_edition(HasBits* has_bits) {
+ (*has_bits)[0] |= 8u;
+ }
};
const ::PROTOBUF_NAMESPACE_ID::FileOptions&
@@ -1539,10 +1952,9 @@ const ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo&
FileDescriptorProto::_Internal::source_code_info(const FileDescriptorProto* msg) {
return *msg->_impl_.source_code_info_;
}
-FileDescriptorProto::FileDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+FileDescriptorProto::FileDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.FileDescriptorProto)
}
FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from)
@@ -1556,52 +1968,61 @@ FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from)
, decltype(_impl_.enum_type_){from._impl_.enum_type_}
, decltype(_impl_.service_){from._impl_.service_}
, decltype(_impl_.extension_){from._impl_.extension_}
- , decltype(_impl_.public_dependency_){from._impl_.public_dependency_}
- , decltype(_impl_.weak_dependency_){from._impl_.weak_dependency_}
- , decltype(_impl_.name_){}
- , decltype(_impl_.package_){}
- , decltype(_impl_.syntax_){}
+ , decltype(_impl_.public_dependency_) { from._impl_.public_dependency_ }
+
+ , decltype(_impl_.weak_dependency_) { from._impl_.weak_dependency_ }
+
+ , decltype(_impl_.name_) {}
+
+ , decltype(_impl_.package_) {}
+
+ , decltype(_impl_.syntax_) {}
+
+ , decltype(_impl_.edition_) {}
+
, decltype(_impl_.options_){nullptr}
, decltype(_impl_.source_code_info_){nullptr}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_name()) {
- _this->_impl_.name_.Set(from._internal_name(),
- _this->GetArenaForAllocation());
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
+ _this->_impl_.name_.Set(from._internal_name(), _this->GetArenaForAllocation());
}
_impl_.package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.package_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_package()) {
- _this->_impl_.package_.Set(from._internal_package(),
- _this->GetArenaForAllocation());
+ _impl_.package_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000002u) != 0) {
+ _this->_impl_.package_.Set(from._internal_package(), _this->GetArenaForAllocation());
}
_impl_.syntax_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.syntax_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_syntax()) {
- _this->_impl_.syntax_.Set(from._internal_syntax(),
- _this->GetArenaForAllocation());
+ _impl_.syntax_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000004u) != 0) {
+ _this->_impl_.syntax_.Set(from._internal_syntax(), _this->GetArenaForAllocation());
+ }
+ _impl_.edition_.InitDefault();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.edition_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000008u) != 0) {
+ _this->_impl_.edition_.Set(from._internal_edition(), _this->GetArenaForAllocation());
}
- if (from._internal_has_options()) {
+ if ((from._impl_._has_bits_[0] & 0x00000010u) != 0) {
_this->_impl_.options_ = new ::PROTOBUF_NAMESPACE_ID::FileOptions(*from._impl_.options_);
}
- if (from._internal_has_source_code_info()) {
+ if ((from._impl_._has_bits_[0] & 0x00000020u) != 0) {
_this->_impl_.source_code_info_ = new ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo(*from._impl_.source_code_info_);
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.FileDescriptorProto)
}
-inline void FileDescriptorProto::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void FileDescriptorProto::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
@@ -1610,26 +2031,37 @@ inline void FileDescriptorProto::SharedCtor(
, decltype(_impl_.enum_type_){arena}
, decltype(_impl_.service_){arena}
, decltype(_impl_.extension_){arena}
- , decltype(_impl_.public_dependency_){arena}
- , decltype(_impl_.weak_dependency_){arena}
- , decltype(_impl_.name_){}
- , decltype(_impl_.package_){}
- , decltype(_impl_.syntax_){}
+ , decltype(_impl_.public_dependency_) { arena }
+
+ , decltype(_impl_.weak_dependency_) { arena }
+
+ , decltype(_impl_.name_) {}
+
+ , decltype(_impl_.package_) {}
+
+ , decltype(_impl_.syntax_) {}
+
+ , decltype(_impl_.edition_) {}
+
, decltype(_impl_.options_){nullptr}
, decltype(_impl_.source_code_info_){nullptr}
};
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.package_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.package_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.syntax_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.syntax_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.syntax_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.edition_.InitDefault();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.edition_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
FileDescriptorProto::~FileDescriptorProto() {
@@ -1642,7 +2074,7 @@ FileDescriptorProto::~FileDescriptorProto() {
}
inline void FileDescriptorProto::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.dependency_.~RepeatedPtrField();
_impl_.message_type_.~RepeatedPtrField();
_impl_.enum_type_.~RepeatedPtrField();
@@ -1653,6 +2085,7 @@ inline void FileDescriptorProto::SharedDtor() {
_impl_.name_.Destroy();
_impl_.package_.Destroy();
_impl_.syntax_.Destroy();
+ _impl_.edition_.Destroy();
if (this != internal_default_instance()) delete _impl_.options_;
if (this != internal_default_instance()) delete _impl_.source_code_info_;
}
@@ -1663,7 +2096,7 @@ void FileDescriptorProto::SetCachedSize(int size) const {
void FileDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FileDescriptorProto)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -1675,7 +2108,7 @@ void FileDescriptorProto::Clear() {
_impl_.public_dependency_.Clear();
_impl_.weak_dependency_.Clear();
cached_has_bits = _impl_._has_bits_[0];
- if (cached_has_bits & 0x0000001fu) {
+ if (cached_has_bits & 0x0000003fu) {
if (cached_has_bits & 0x00000001u) {
_impl_.name_.ClearNonDefaultToEmpty();
}
@@ -1686,11 +2119,14 @@ void FileDescriptorProto::Clear() {
_impl_.syntax_.ClearNonDefaultToEmpty();
}
if (cached_has_bits & 0x00000008u) {
- GOOGLE_DCHECK(_impl_.options_ != nullptr);
- _impl_.options_->Clear();
+ _impl_.edition_.ClearNonDefaultToEmpty();
}
if (cached_has_bits & 0x00000010u) {
- GOOGLE_DCHECK(_impl_.source_code_info_ != nullptr);
+ Y_ABSL_DCHECK(_impl_.options_ != nullptr);
+ _impl_.options_->Clear();
+ }
+ if (cached_has_bits & 0x00000020u) {
+ Y_ABSL_DCHECK(_impl_.source_code_info_ != nullptr);
_impl_.source_code_info_->Clear();
}
}
@@ -1702,36 +2138,38 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseCo
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 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)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.FileDescriptorProto.name");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string package = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) {
auto str = _internal_mutable_package();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.FileDescriptorProto.package");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated string dependency = 3;
case 3:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 26)) {
ptr -= 1;
do {
ptr += 1;
@@ -1743,12 +2181,13 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseCo
#endif // !NDEBUG
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.DescriptorProto message_type = 4;
case 4:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 34)) {
ptr -= 1;
do {
ptr += 1;
@@ -1756,12 +2195,13 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseCo
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.EnumDescriptorProto enum_type = 5;
case 5:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 42)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 42)) {
ptr -= 1;
do {
ptr += 1;
@@ -1769,12 +2209,13 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseCo
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<42>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.ServiceDescriptorProto service = 6;
case 6:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 50)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 50)) {
ptr -= 1;
do {
ptr += 1;
@@ -1782,12 +2223,13 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseCo
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.FieldDescriptorProto extension = 7;
case 7:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 58)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 58)) {
ptr -= 1;
do {
ptr += 1;
@@ -1795,28 +2237,31 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseCo
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<58>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional .google.protobuf.FileOptions options = 8;
case 8:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 66)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 66)) {
ptr = ctx->ParseMessage(_internal_mutable_options(), ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional .google.protobuf.SourceCodeInfo source_code_info = 9;
case 9:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 74)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 74)) {
ptr = ctx->ParseMessage(_internal_mutable_source_code_info(), ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated int32 public_dependency = 10;
case 10:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 80)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 80)) {
ptr -= 1;
do {
ptr += 1;
@@ -1824,15 +2269,16 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseCo
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<80>(ptr));
- } else if (static_cast<uint8_t>(tag) == 82) {
+ } else if (static_cast<::uint8_t>(tag) == 82) {
ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(_internal_mutable_public_dependency(), ptr, ctx);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated int32 weak_dependency = 11;
case 11:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 88)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 88)) {
ptr -= 1;
do {
ptr += 1;
@@ -1840,23 +2286,38 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseCo
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<88>(ptr));
- } else if (static_cast<uint8_t>(tag) == 90) {
+ } else if (static_cast<::uint8_t>(tag) == 90) {
ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(_internal_mutable_weak_dependency(), ptr, ctx);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string syntax = 12;
case 12:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 98)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 98)) {
auto str = _internal_mutable_syntax();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.FileDescriptorProto.syntax");
#endif // !NDEBUG
- } else
+ } else {
+ goto handle_unusual;
+ }
+ continue;
+ // optional string edition = 13;
+ case 13:
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 106)) {
+ auto str = _internal_mutable_edition();
+ ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
+ CHK_(ptr);
+ #ifndef NDEBUG
+ ::_pbi::VerifyUTF8(str, "google.protobuf.FileDescriptorProto.edition");
+ #endif // !NDEBUG
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -1882,40 +2343,34 @@ failure:
#undef CHK_
}
-uint8_t* FileDescriptorProto::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* FileDescriptorProto::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FileDescriptorProto)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.FileDescriptorProto.name");
- target = stream->WriteStringMaybeAliased(
- 1, this->_internal_name(), target);
+ const TProtoStringType& _s = this->_internal_name();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FileDescriptorProto.name");
+ target = stream->WriteStringMaybeAliased(1, _s, target);
}
// optional string package = 2;
if (cached_has_bits & 0x00000002u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_package().data(), static_cast<int>(this->_internal_package().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.FileDescriptorProto.package");
- target = stream->WriteStringMaybeAliased(
- 2, this->_internal_package(), target);
+ const TProtoStringType& _s = this->_internal_package();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FileDescriptorProto.package");
+ target = stream->WriteStringMaybeAliased(2, _s, target);
}
// repeated string dependency = 3;
- for (int i = 0, n = this->_internal_dependency_size(); i < n; i++) {
+ for (int i = 0, n = this->_internal_dependency_size(); i < n; ++i) {
const auto& s = this->_internal_dependency(i);
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- s.data(), static_cast<int>(s.length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.FileDescriptorProto.dependency");
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(s.data(), static_cast<int>(s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FileDescriptorProto.dependency");
target = stream->WriteString(3, s, target);
}
@@ -1952,39 +2407,47 @@ uint8_t* FileDescriptorProto::_InternalSerialize(
}
// optional .google.protobuf.FileOptions options = 8;
- if (cached_has_bits & 0x00000008u) {
+ if (cached_has_bits & 0x00000010u) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(8, _Internal::options(this),
_Internal::options(this).GetCachedSize(), target, stream);
}
// optional .google.protobuf.SourceCodeInfo source_code_info = 9;
- if (cached_has_bits & 0x00000010u) {
+ if (cached_has_bits & 0x00000020u) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
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++) {
+ for (int i = 0, n = this->_internal_public_dependency_size(); i < n; ++i) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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++) {
+ for (int i = 0, n = this->_internal_weak_dependency_size(); i < n; ++i) {
target = stream->EnsureSpace(target);
- target = ::_pbi::WireFormatLite::WriteInt32ToArray(11, this->_internal_weak_dependency(i), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(
+ 11, this->_internal_weak_dependency(i), target);
}
// optional string syntax = 12;
if (cached_has_bits & 0x00000004u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_syntax().data(), static_cast<int>(this->_internal_syntax().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.FileDescriptorProto.syntax");
- target = stream->WriteStringMaybeAliased(
- 12, this->_internal_syntax(), target);
+ const TProtoStringType& _s = this->_internal_syntax();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FileDescriptorProto.syntax");
+ target = stream->WriteStringMaybeAliased(12, _s, target);
+ }
+
+ // optional string edition = 13;
+ if (cached_has_bits & 0x00000008u) {
+ const TProtoStringType& _s = this->_internal_edition();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FileDescriptorProto.edition");
+ target = stream->WriteStringMaybeAliased(13, _s, target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
@@ -1995,20 +2458,18 @@ uint8_t* FileDescriptorProto::_InternalSerialize(
return target;
}
-size_t FileDescriptorProto::ByteSizeLong() const {
+::size_t FileDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileDescriptorProto)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// repeated string dependency = 3;
- total_size += 1 *
- ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.dependency_.size());
- for (int i = 0, n = _impl_.dependency_.size(); i < n; i++) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- _impl_.dependency_.Get(i));
+ total_size += 1 * ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.dependency_.size());
+ for (int i = 0, n = _impl_.dependency_.size(); i < n; ++i) {
+ total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(_impl_.dependency_.Get(i));
}
// repeated .google.protobuf.DescriptorProto message_type = 4;
@@ -2041,54 +2502,59 @@ size_t FileDescriptorProto::ByteSizeLong() const {
// repeated int32 public_dependency = 10;
{
- size_t data_size = ::_pbi::WireFormatLite::
- Int32Size(this->_impl_.public_dependency_);
- total_size += 1 *
- ::_pbi::FromIntSize(this->_internal_public_dependency_size());
- total_size += data_size;
+ std::size_t data_size = ::_pbi::WireFormatLite::Int32Size(this->_impl_.public_dependency_)
+ ;
+ std::size_t tag_size = std::size_t{1} *
+ ::_pbi::FromIntSize(this->_internal_public_dependency_size());
+ ;
+ total_size += tag_size + data_size;
}
// repeated int32 weak_dependency = 11;
{
- size_t data_size = ::_pbi::WireFormatLite::
- Int32Size(this->_impl_.weak_dependency_);
- total_size += 1 *
- ::_pbi::FromIntSize(this->_internal_weak_dependency_size());
- total_size += data_size;
+ std::size_t data_size = ::_pbi::WireFormatLite::Int32Size(this->_impl_.weak_dependency_)
+ ;
+ std::size_t tag_size = std::size_t{1} *
+ ::_pbi::FromIntSize(this->_internal_weak_dependency_size());
+ ;
+ total_size += tag_size + data_size;
}
cached_has_bits = _impl_._has_bits_[0];
- if (cached_has_bits & 0x0000001fu) {
+ if (cached_has_bits & 0x0000003fu) {
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_name());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_name());
}
// optional string package = 2;
if (cached_has_bits & 0x00000002u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_package());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_package());
}
// optional string syntax = 12;
if (cached_has_bits & 0x00000004u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_syntax());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_syntax());
}
- // optional .google.protobuf.FileOptions options = 8;
+ // optional string edition = 13;
if (cached_has_bits & 0x00000008u) {
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_edition());
+ }
+
+ // optional .google.protobuf.FileOptions options = 8;
+ if (cached_has_bits & 0x00000010u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
*_impl_.options_);
}
// optional .google.protobuf.SourceCodeInfo source_code_info = 9;
- if (cached_has_bits & 0x00000010u) {
+ if (cached_has_bits & 0x00000020u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
*_impl_.source_code_info_);
@@ -2109,8 +2575,8 @@ void FileDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, co
auto* const _this = static_cast<FileDescriptorProto*>(&to_msg);
auto& from = static_cast<const FileDescriptorProto&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorProto)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.dependency_.MergeFrom(from._impl_.dependency_);
@@ -2121,7 +2587,7 @@ void FileDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, co
_this->_impl_.public_dependency_.MergeFrom(from._impl_.public_dependency_);
_this->_impl_.weak_dependency_.MergeFrom(from._impl_.weak_dependency_);
cached_has_bits = from._impl_._has_bits_[0];
- if (cached_has_bits & 0x0000001fu) {
+ if (cached_has_bits & 0x0000003fu) {
if (cached_has_bits & 0x00000001u) {
_this->_internal_set_name(from._internal_name());
}
@@ -2132,10 +2598,13 @@ void FileDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, co
_this->_internal_set_syntax(from._internal_syntax());
}
if (cached_has_bits & 0x00000008u) {
+ _this->_internal_set_edition(from._internal_edition());
+ }
+ if (cached_has_bits & 0x00000010u) {
_this->_internal_mutable_options()->::PROTOBUF_NAMESPACE_ID::FileOptions::MergeFrom(
from._internal_options());
}
- if (cached_has_bits & 0x00000010u) {
+ if (cached_has_bits & 0x00000020u) {
_this->_internal_mutable_source_code_info()->::PROTOBUF_NAMESPACE_ID::SourceCodeInfo::MergeFrom(
from._internal_source_code_info());
}
@@ -2159,7 +2628,7 @@ bool FileDescriptorProto::IsInitialized() const {
return false;
if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.extension_))
return false;
- if (_internal_has_options()) {
+ if ((_impl_._has_bits_[0] & 0x00000010u) != 0) {
if (!_impl_.options_->IsInitialized()) return false;
}
return true;
@@ -2178,18 +2647,14 @@ void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) {
_impl_.extension_.InternalSwap(&other->_impl_.extension_);
_impl_.public_dependency_.InternalSwap(&other->_impl_.public_dependency_);
_impl_.weak_dependency_.InternalSwap(&other->_impl_.weak_dependency_);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.name_, lhs_arena,
- &other->_impl_.name_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.package_, lhs_arena,
- &other->_impl_.package_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.syntax_, lhs_arena,
- &other->_impl_.syntax_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, lhs_arena,
+ &other->_impl_.name_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.package_, lhs_arena,
+ &other->_impl_.package_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.syntax_, lhs_arena,
+ &other->_impl_.syntax_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.edition_, lhs_arena,
+ &other->_impl_.edition_, rhs_arena);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(FileDescriptorProto, _impl_.source_code_info_)
+ sizeof(FileDescriptorProto::_impl_.source_code_info_)
@@ -2203,12 +2668,13 @@ void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) {
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[1]);
}
-
// ===================================================================
class DescriptorProto_ExtensionRange::_Internal {
public:
using HasBits = decltype(std::declval<DescriptorProto_ExtensionRange>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(DescriptorProto_ExtensionRange, _impl_._has_bits_);
static void set_has_start(HasBits* has_bits) {
(*has_bits)[0] |= 2u;
}
@@ -2225,10 +2691,9 @@ const ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions&
DescriptorProto_ExtensionRange::_Internal::options(const DescriptorProto_ExtensionRange* msg) {
return *msg->_impl_.options_;
}
-DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.DescriptorProto.ExtensionRange)
}
DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(const DescriptorProto_ExtensionRange& from)
@@ -2238,29 +2703,31 @@ DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(const DescriptorP
decltype(_impl_._has_bits_){from._impl_._has_bits_}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.options_){nullptr}
- , decltype(_impl_.start_){}
- , decltype(_impl_.end_){}};
+ , decltype(_impl_.start_) {}
+
+ , decltype(_impl_.end_) {}
+ };
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- if (from._internal_has_options()) {
+ if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
_this->_impl_.options_ = new ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions(*from._impl_.options_);
}
::memcpy(&_impl_.start_, &from._impl_.start_,
- static_cast<size_t>(reinterpret_cast<char*>(&_impl_.end_) -
+ static_cast<::size_t>(reinterpret_cast<char*>(&_impl_.end_) -
reinterpret_cast<char*>(&_impl_.start_)) + sizeof(_impl_.end_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto.ExtensionRange)
}
-inline void DescriptorProto_ExtensionRange::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void DescriptorProto_ExtensionRange::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.options_){nullptr}
- , decltype(_impl_.start_){0}
- , decltype(_impl_.end_){0}
+ , decltype(_impl_.start_) { 0 }
+
+ , decltype(_impl_.end_) { 0 }
+
};
}
@@ -2274,7 +2741,7 @@ DescriptorProto_ExtensionRange::~DescriptorProto_ExtensionRange() {
}
inline void DescriptorProto_ExtensionRange::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
if (this != internal_default_instance()) delete _impl_.options_;
}
@@ -2284,17 +2751,17 @@ void DescriptorProto_ExtensionRange::SetCachedSize(int size) const {
void DescriptorProto_ExtensionRange::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto.ExtensionRange)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x00000001u) {
- GOOGLE_DCHECK(_impl_.options_ != nullptr);
+ Y_ABSL_DCHECK(_impl_.options_ != nullptr);
_impl_.options_->Clear();
}
if (cached_has_bits & 0x00000006u) {
- ::memset(&_impl_.start_, 0, static_cast<size_t>(
+ ::memset(&_impl_.start_, 0, static_cast<::size_t>(
reinterpret_cast<char*>(&_impl_.end_) -
reinterpret_cast<char*>(&_impl_.start_)) + sizeof(_impl_.end_));
}
@@ -2306,34 +2773,37 @@ const char* DescriptorProto_ExtensionRange::_InternalParse(const char* ptr, ::_p
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional int32 start = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) {
_Internal::set_has_start(&has_bits);
_impl_.start_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional int32 end = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 16)) {
_Internal::set_has_end(&has_bits);
_impl_.end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional .google.protobuf.ExtensionRangeOptions options = 3;
case 3:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 26)) {
ptr = ctx->ParseMessage(_internal_mutable_options(), ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -2359,23 +2829,25 @@ failure:
#undef CHK_
}
-uint8_t* DescriptorProto_ExtensionRange::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* DescriptorProto_ExtensionRange::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DescriptorProto.ExtensionRange)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
// optional int32 start = 1;
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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 = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_end(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(
+ 2, this->_internal_end(), target);
}
// optional .google.protobuf.ExtensionRangeOptions options = 3;
@@ -2393,11 +2865,11 @@ uint8_t* DescriptorProto_ExtensionRange::_InternalSerialize(
return target;
}
-size_t DescriptorProto_ExtensionRange::ByteSizeLong() const {
+::size_t DescriptorProto_ExtensionRange::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto.ExtensionRange)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -2412,12 +2884,14 @@ size_t DescriptorProto_ExtensionRange::ByteSizeLong() const {
// optional int32 start = 1;
if (cached_has_bits & 0x00000002u) {
- total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_start());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(
+ this->_internal_start());
}
// optional int32 end = 2;
if (cached_has_bits & 0x00000004u) {
- total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_end());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(
+ this->_internal_end());
}
}
@@ -2435,8 +2909,8 @@ void DescriptorProto_ExtensionRange::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message&
auto* const _this = static_cast<DescriptorProto_ExtensionRange*>(&to_msg);
auto& from = static_cast<const DescriptorProto_ExtensionRange&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ExtensionRange)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._impl_._has_bits_[0];
@@ -2464,7 +2938,7 @@ void DescriptorProto_ExtensionRange::CopyFrom(const DescriptorProto_ExtensionRan
}
bool DescriptorProto_ExtensionRange::IsInitialized() const {
- if (_internal_has_options()) {
+ if ((_impl_._has_bits_[0] & 0x00000001u) != 0) {
if (!_impl_.options_->IsInitialized()) return false;
}
return true;
@@ -2487,12 +2961,13 @@ void DescriptorProto_ExtensionRange::InternalSwap(DescriptorProto_ExtensionRange
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[2]);
}
-
// ===================================================================
class DescriptorProto_ReservedRange::_Internal {
public:
using HasBits = decltype(std::declval<DescriptorProto_ReservedRange>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(DescriptorProto_ReservedRange, _impl_._has_bits_);
static void set_has_start(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -2501,37 +2976,27 @@ class DescriptorProto_ReservedRange::_Internal {
}
};
-DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.DescriptorProto.ReservedRange)
}
DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(const DescriptorProto_ReservedRange& from)
- : ::PROTOBUF_NAMESPACE_ID::Message() {
- DescriptorProto_ReservedRange* const _this = this; (void)_this;
- new (&_impl_) Impl_{
- decltype(_impl_._has_bits_){from._impl_._has_bits_}
- , /*decltype(_impl_._cached_size_)*/{}
- , decltype(_impl_.start_){}
- , decltype(_impl_.end_){}};
-
- _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- ::memcpy(&_impl_.start_, &from._impl_.start_,
- static_cast<size_t>(reinterpret_cast<char*>(&_impl_.end_) -
- reinterpret_cast<char*>(&_impl_.start_)) + sizeof(_impl_.end_));
+ : ::PROTOBUF_NAMESPACE_ID::Message(), _impl_(from._impl_) {
+ _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(
+ from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto.ReservedRange)
}
-inline void DescriptorProto_ReservedRange::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void DescriptorProto_ReservedRange::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
- , decltype(_impl_.start_){0}
- , decltype(_impl_.end_){0}
+ , decltype(_impl_.start_) { 0 }
+
+ , decltype(_impl_.end_) { 0 }
+
};
}
@@ -2545,7 +3010,7 @@ DescriptorProto_ReservedRange::~DescriptorProto_ReservedRange() {
}
inline void DescriptorProto_ReservedRange::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
}
void DescriptorProto_ReservedRange::SetCachedSize(int size) const {
@@ -2554,13 +3019,13 @@ void DescriptorProto_ReservedRange::SetCachedSize(int size) const {
void DescriptorProto_ReservedRange::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto.ReservedRange)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x00000003u) {
- ::memset(&_impl_.start_, 0, static_cast<size_t>(
+ ::memset(&_impl_.start_, 0, static_cast<::size_t>(
reinterpret_cast<char*>(&_impl_.end_) -
reinterpret_cast<char*>(&_impl_.start_)) + sizeof(_impl_.end_));
}
@@ -2572,26 +3037,28 @@ const char* DescriptorProto_ReservedRange::_InternalParse(const char* ptr, ::_pb
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional int32 start = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) {
_Internal::set_has_start(&has_bits);
_impl_.start_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional int32 end = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 16)) {
_Internal::set_has_end(&has_bits);
_impl_.end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -2617,23 +3084,25 @@ failure:
#undef CHK_
}
-uint8_t* DescriptorProto_ReservedRange::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* DescriptorProto_ReservedRange::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DescriptorProto.ReservedRange)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
// optional int32 start = 1;
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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 = ::_pbi::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())) {
@@ -2644,11 +3113,11 @@ uint8_t* DescriptorProto_ReservedRange::_InternalSerialize(
return target;
}
-size_t DescriptorProto_ReservedRange::ByteSizeLong() const {
+::size_t DescriptorProto_ReservedRange::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto.ReservedRange)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -2656,12 +3125,14 @@ size_t DescriptorProto_ReservedRange::ByteSizeLong() const {
if (cached_has_bits & 0x00000003u) {
// optional int32 start = 1;
if (cached_has_bits & 0x00000001u) {
- total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_start());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(
+ this->_internal_start());
}
// optional int32 end = 2;
if (cached_has_bits & 0x00000002u) {
- total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_end());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(
+ this->_internal_end());
}
}
@@ -2679,8 +3150,8 @@ void DescriptorProto_ReservedRange::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message&
auto* const _this = static_cast<DescriptorProto_ReservedRange*>(&to_msg);
auto& from = static_cast<const DescriptorProto_ReservedRange&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ReservedRange)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._impl_._has_bits_[0];
@@ -2724,12 +3195,13 @@ void DescriptorProto_ReservedRange::InternalSwap(DescriptorProto_ReservedRange*
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[3]);
}
-
// ===================================================================
class DescriptorProto::_Internal {
public:
using HasBits = decltype(std::declval<DescriptorProto>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(DescriptorProto, _impl_._has_bits_);
static void set_has_name(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -2743,10 +3215,9 @@ const ::PROTOBUF_NAMESPACE_ID::MessageOptions&
DescriptorProto::_Internal::options(const DescriptorProto* msg) {
return *msg->_impl_.options_;
}
-DescriptorProto::DescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+DescriptorProto::DescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.DescriptorProto)
}
DescriptorProto::DescriptorProto(const DescriptorProto& from)
@@ -2763,28 +3234,26 @@ DescriptorProto::DescriptorProto(const DescriptorProto& from)
, decltype(_impl_.oneof_decl_){from._impl_.oneof_decl_}
, decltype(_impl_.reserved_range_){from._impl_.reserved_range_}
, decltype(_impl_.reserved_name_){from._impl_.reserved_name_}
- , decltype(_impl_.name_){}
+ , decltype(_impl_.name_) {}
+
, decltype(_impl_.options_){nullptr}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_name()) {
- _this->_impl_.name_.Set(from._internal_name(),
- _this->GetArenaForAllocation());
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
+ _this->_impl_.name_.Set(from._internal_name(), _this->GetArenaForAllocation());
}
- if (from._internal_has_options()) {
+ if ((from._impl_._has_bits_[0] & 0x00000002u) != 0) {
_this->_impl_.options_ = new ::PROTOBUF_NAMESPACE_ID::MessageOptions(*from._impl_.options_);
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto)
}
-inline void DescriptorProto::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void DescriptorProto::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
@@ -2796,13 +3265,14 @@ inline void DescriptorProto::SharedCtor(
, decltype(_impl_.oneof_decl_){arena}
, decltype(_impl_.reserved_range_){arena}
, decltype(_impl_.reserved_name_){arena}
- , decltype(_impl_.name_){}
+ , decltype(_impl_.name_) {}
+
, decltype(_impl_.options_){nullptr}
};
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
DescriptorProto::~DescriptorProto() {
@@ -2815,7 +3285,7 @@ DescriptorProto::~DescriptorProto() {
}
inline void DescriptorProto::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.field_.~RepeatedPtrField();
_impl_.nested_type_.~RepeatedPtrField();
_impl_.enum_type_.~RepeatedPtrField();
@@ -2834,7 +3304,7 @@ void DescriptorProto::SetCachedSize(int size) const {
void DescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -2852,7 +3322,7 @@ void DescriptorProto::Clear() {
_impl_.name_.ClearNonDefaultToEmpty();
}
if (cached_has_bits & 0x00000002u) {
- GOOGLE_DCHECK(_impl_.options_ != nullptr);
+ Y_ABSL_DCHECK(_impl_.options_ != nullptr);
_impl_.options_->Clear();
}
}
@@ -2864,24 +3334,25 @@ const char* DescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContex
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 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)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.DescriptorProto.name");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.FieldDescriptorProto field = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) {
ptr -= 1;
do {
ptr += 1;
@@ -2889,12 +3360,13 @@ const char* DescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContex
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.DescriptorProto nested_type = 3;
case 3:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 26)) {
ptr -= 1;
do {
ptr += 1;
@@ -2902,12 +3374,13 @@ const char* DescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContex
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.EnumDescriptorProto enum_type = 4;
case 4:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 34)) {
ptr -= 1;
do {
ptr += 1;
@@ -2915,12 +3388,13 @@ const char* DescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContex
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;
case 5:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 42)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 42)) {
ptr -= 1;
do {
ptr += 1;
@@ -2928,12 +3402,13 @@ const char* DescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContex
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<42>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.FieldDescriptorProto extension = 6;
case 6:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 50)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 50)) {
ptr -= 1;
do {
ptr += 1;
@@ -2941,20 +3416,22 @@ const char* DescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContex
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional .google.protobuf.MessageOptions options = 7;
case 7:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 58)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 58)) {
ptr = ctx->ParseMessage(_internal_mutable_options(), ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;
case 8:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 66)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 66)) {
ptr -= 1;
do {
ptr += 1;
@@ -2962,12 +3439,13 @@ const char* DescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContex
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<66>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;
case 9:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 74)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 74)) {
ptr -= 1;
do {
ptr += 1;
@@ -2975,12 +3453,13 @@ const char* DescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContex
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<74>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated string reserved_name = 10;
case 10:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 82)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 82)) {
ptr -= 1;
do {
ptr += 1;
@@ -2992,8 +3471,9 @@ const char* DescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContex
#endif // !NDEBUG
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<82>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -3019,21 +3499,19 @@ failure:
#undef CHK_
}
-uint8_t* DescriptorProto::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* DescriptorProto::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DescriptorProto)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.DescriptorProto.name");
- target = stream->WriteStringMaybeAliased(
- 1, this->_internal_name(), target);
+ const TProtoStringType& _s = this->_internal_name();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.DescriptorProto.name");
+ target = stream->WriteStringMaybeAliased(1, _s, target);
}
// repeated .google.protobuf.FieldDescriptorProto field = 2;
@@ -3100,12 +3578,10 @@ uint8_t* DescriptorProto::_InternalSerialize(
}
// repeated string reserved_name = 10;
- for (int i = 0, n = this->_internal_reserved_name_size(); i < n; i++) {
+ for (int i = 0, n = this->_internal_reserved_name_size(); i < n; ++i) {
const auto& s = this->_internal_reserved_name(i);
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- s.data(), static_cast<int>(s.length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.DescriptorProto.reserved_name");
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(s.data(), static_cast<int>(s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.DescriptorProto.reserved_name");
target = stream->WriteString(10, s, target);
}
@@ -3117,11 +3593,11 @@ uint8_t* DescriptorProto::_InternalSerialize(
return target;
}
-size_t DescriptorProto::ByteSizeLong() const {
+::size_t DescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -3175,20 +3651,17 @@ size_t DescriptorProto::ByteSizeLong() const {
}
// repeated string reserved_name = 10;
- total_size += 1 *
- ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.reserved_name_.size());
- for (int i = 0, n = _impl_.reserved_name_.size(); i < n; i++) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- _impl_.reserved_name_.Get(i));
+ total_size += 1 * ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.reserved_name_.size());
+ for (int i = 0, n = _impl_.reserved_name_.size(); i < n; ++i) {
+ total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(_impl_.reserved_name_.Get(i));
}
cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x00000003u) {
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_name());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_name());
}
// optional .google.protobuf.MessageOptions options = 7;
@@ -3213,8 +3686,8 @@ void DescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const
auto* const _this = static_cast<DescriptorProto*>(&to_msg);
auto& from = static_cast<const DescriptorProto&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.field_.MergeFrom(from._impl_.field_);
@@ -3258,7 +3731,7 @@ bool DescriptorProto::IsInitialized() const {
return false;
if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.oneof_decl_))
return false;
- if (_internal_has_options()) {
+ if ((_impl_._has_bits_[0] & 0x00000002u) != 0) {
if (!_impl_.options_->IsInitialized()) return false;
}
return true;
@@ -3278,10 +3751,8 @@ void DescriptorProto::InternalSwap(DescriptorProto* other) {
_impl_.oneof_decl_.InternalSwap(&other->_impl_.oneof_decl_);
_impl_.reserved_range_.InternalSwap(&other->_impl_.reserved_range_);
_impl_.reserved_name_.InternalSwap(&other->_impl_.reserved_name_);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.name_, lhs_arena,
- &other->_impl_.name_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, lhs_arena,
+ &other->_impl_.name_, rhs_arena);
swap(_impl_.options_, other->_impl_.options_);
}
@@ -3290,17 +3761,15 @@ void DescriptorProto::InternalSwap(DescriptorProto* other) {
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[4]);
}
-
// ===================================================================
class ExtensionRangeOptions::_Internal {
public:
};
-ExtensionRangeOptions::ExtensionRangeOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+ExtensionRangeOptions::ExtensionRangeOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.ExtensionRangeOptions)
}
ExtensionRangeOptions::ExtensionRangeOptions(const ExtensionRangeOptions& from)
@@ -3316,10 +3785,8 @@ ExtensionRangeOptions::ExtensionRangeOptions(const ExtensionRangeOptions& from)
// @@protoc_insertion_point(copy_constructor:google.protobuf.ExtensionRangeOptions)
}
-inline void ExtensionRangeOptions::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void ExtensionRangeOptions::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
/*decltype(_impl_._extensions_)*/{::_pbi::ArenaInitialized(), arena}
, decltype(_impl_.uninterpreted_option_){arena}
@@ -3337,7 +3804,7 @@ ExtensionRangeOptions::~ExtensionRangeOptions() {
}
inline void ExtensionRangeOptions::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_._extensions_.~ExtensionSet();
_impl_.uninterpreted_option_.~RepeatedPtrField();
}
@@ -3348,7 +3815,7 @@ void ExtensionRangeOptions::SetCachedSize(int size) const {
void ExtensionRangeOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.ExtensionRangeOptions)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -3360,12 +3827,12 @@ void ExtensionRangeOptions::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 58)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 58)) {
ptr -= 2;
do {
ptr += 2;
@@ -3373,8 +3840,9 @@ const char* ExtensionRangeOptions::_InternalParse(const char* ptr, ::_pbi::Parse
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<7994>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -3404,10 +3872,10 @@ failure:
#undef CHK_
}
-uint8_t* ExtensionRangeOptions::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* ExtensionRangeOptions::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.ExtensionRangeOptions)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
@@ -3430,13 +3898,13 @@ uint8_t* ExtensionRangeOptions::_InternalSerialize(
return target;
}
-size_t ExtensionRangeOptions::ByteSizeLong() const {
+::size_t ExtensionRangeOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.ExtensionRangeOptions)
- size_t total_size = 0;
+ ::size_t total_size = 0;
total_size += _impl_._extensions_.ByteSize();
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -3461,8 +3929,8 @@ void ExtensionRangeOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg,
auto* const _this = static_cast<ExtensionRangeOptions*>(&to_msg);
auto& from = static_cast<const ExtensionRangeOptions&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ExtensionRangeOptions)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.uninterpreted_option_.MergeFrom(from._impl_.uninterpreted_option_);
@@ -3478,7 +3946,7 @@ void ExtensionRangeOptions::CopyFrom(const ExtensionRangeOptions& from) {
}
bool ExtensionRangeOptions::IsInitialized() const {
- if (!_impl_._extensions_.IsInitialized()) {
+ if (!_impl_._extensions_.IsInitialized(internal_default_instance())) {
return false;
}
@@ -3499,12 +3967,13 @@ void ExtensionRangeOptions::InternalSwap(ExtensionRangeOptions* other) {
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[5]);
}
-
// ===================================================================
class FieldDescriptorProto::_Internal {
public:
using HasBits = decltype(std::declval<FieldDescriptorProto>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(FieldDescriptorProto, _impl_._has_bits_);
static void set_has_name(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -3545,10 +4014,9 @@ const ::PROTOBUF_NAMESPACE_ID::FieldOptions&
FieldDescriptorProto::_Internal::options(const FieldDescriptorProto* msg) {
return *msg->_impl_.options_;
}
-FieldDescriptorProto::FieldDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+FieldDescriptorProto::FieldDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.FieldDescriptorProto)
}
FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from)
@@ -3557,107 +4025,120 @@ FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from)
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){from._impl_._has_bits_}
, /*decltype(_impl_._cached_size_)*/{}
- , decltype(_impl_.name_){}
- , decltype(_impl_.extendee_){}
- , decltype(_impl_.type_name_){}
- , decltype(_impl_.default_value_){}
- , decltype(_impl_.json_name_){}
+ , decltype(_impl_.name_) {}
+
+ , decltype(_impl_.extendee_) {}
+
+ , decltype(_impl_.type_name_) {}
+
+ , decltype(_impl_.default_value_) {}
+
+ , decltype(_impl_.json_name_) {}
+
, decltype(_impl_.options_){nullptr}
- , decltype(_impl_.number_){}
- , decltype(_impl_.oneof_index_){}
- , decltype(_impl_.proto3_optional_){}
- , decltype(_impl_.label_){}
- , decltype(_impl_.type_){}};
+ , decltype(_impl_.number_) {}
+
+ , decltype(_impl_.oneof_index_) {}
+
+ , decltype(_impl_.proto3_optional_) {}
+
+ , decltype(_impl_.label_) {}
+
+ , decltype(_impl_.type_) {}
+ };
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_name()) {
- _this->_impl_.name_.Set(from._internal_name(),
- _this->GetArenaForAllocation());
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
+ _this->_impl_.name_.Set(from._internal_name(), _this->GetArenaForAllocation());
}
_impl_.extendee_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.extendee_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_extendee()) {
- _this->_impl_.extendee_.Set(from._internal_extendee(),
- _this->GetArenaForAllocation());
+ _impl_.extendee_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000002u) != 0) {
+ _this->_impl_.extendee_.Set(from._internal_extendee(), _this->GetArenaForAllocation());
}
_impl_.type_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.type_name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_type_name()) {
- _this->_impl_.type_name_.Set(from._internal_type_name(),
- _this->GetArenaForAllocation());
+ _impl_.type_name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000004u) != 0) {
+ _this->_impl_.type_name_.Set(from._internal_type_name(), _this->GetArenaForAllocation());
}
_impl_.default_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.default_value_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_default_value()) {
- _this->_impl_.default_value_.Set(from._internal_default_value(),
- _this->GetArenaForAllocation());
+ _impl_.default_value_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000008u) != 0) {
+ _this->_impl_.default_value_.Set(from._internal_default_value(), _this->GetArenaForAllocation());
}
_impl_.json_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.json_name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_json_name()) {
- _this->_impl_.json_name_.Set(from._internal_json_name(),
- _this->GetArenaForAllocation());
+ _impl_.json_name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000010u) != 0) {
+ _this->_impl_.json_name_.Set(from._internal_json_name(), _this->GetArenaForAllocation());
}
- if (from._internal_has_options()) {
+ if ((from._impl_._has_bits_[0] & 0x00000020u) != 0) {
_this->_impl_.options_ = new ::PROTOBUF_NAMESPACE_ID::FieldOptions(*from._impl_.options_);
}
::memcpy(&_impl_.number_, &from._impl_.number_,
- static_cast<size_t>(reinterpret_cast<char*>(&_impl_.type_) -
+ static_cast<::size_t>(reinterpret_cast<char*>(&_impl_.type_) -
reinterpret_cast<char*>(&_impl_.number_)) + sizeof(_impl_.type_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.FieldDescriptorProto)
}
-inline void FieldDescriptorProto::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void FieldDescriptorProto::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
- , decltype(_impl_.name_){}
- , decltype(_impl_.extendee_){}
- , decltype(_impl_.type_name_){}
- , decltype(_impl_.default_value_){}
- , decltype(_impl_.json_name_){}
+ , decltype(_impl_.name_) {}
+
+ , decltype(_impl_.extendee_) {}
+
+ , decltype(_impl_.type_name_) {}
+
+ , decltype(_impl_.default_value_) {}
+
+ , decltype(_impl_.json_name_) {}
+
, decltype(_impl_.options_){nullptr}
- , decltype(_impl_.number_){0}
- , decltype(_impl_.oneof_index_){0}
- , decltype(_impl_.proto3_optional_){false}
- , decltype(_impl_.label_){1}
- , decltype(_impl_.type_){1}
+ , decltype(_impl_.number_) { 0 }
+
+ , decltype(_impl_.oneof_index_) { 0 }
+
+ , decltype(_impl_.proto3_optional_) { false }
+
+ , decltype(_impl_.label_) { 1 }
+
+ , decltype(_impl_.type_) { 1 }
+
};
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.extendee_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.extendee_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.extendee_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.type_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.type_name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.type_name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.default_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.default_value_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.default_value_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.json_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.json_name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.json_name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
FieldDescriptorProto::~FieldDescriptorProto() {
@@ -3670,7 +4151,7 @@ FieldDescriptorProto::~FieldDescriptorProto() {
}
inline void FieldDescriptorProto::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.name_.Destroy();
_impl_.extendee_.Destroy();
_impl_.type_name_.Destroy();
@@ -3685,7 +4166,7 @@ void FieldDescriptorProto::SetCachedSize(int size) const {
void FieldDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FieldDescriptorProto)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -3707,12 +4188,12 @@ void FieldDescriptorProto::Clear() {
_impl_.json_name_.ClearNonDefaultToEmpty();
}
if (cached_has_bits & 0x00000020u) {
- GOOGLE_DCHECK(_impl_.options_ != nullptr);
+ Y_ABSL_DCHECK(_impl_.options_ != nullptr);
_impl_.options_->Clear();
}
}
if (cached_has_bits & 0x000000c0u) {
- ::memset(&_impl_.number_, 0, static_cast<size_t>(
+ ::memset(&_impl_.number_, 0, static_cast<::size_t>(
reinterpret_cast<char*>(&_impl_.oneof_index_) -
reinterpret_cast<char*>(&_impl_.number_)) + sizeof(_impl_.oneof_index_));
}
@@ -3729,129 +4210,140 @@ const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseC
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 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)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.name");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string extendee = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) {
auto str = _internal_mutable_extendee();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.extendee");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional int32 number = 3;
case 3:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 24)) {
_Internal::set_has_number(&has_bits);
_impl_.number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional .google.protobuf.FieldDescriptorProto.Label label = 4;
case 4:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 32)) {
- arc_ui64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 32)) {
+ ::arc_ui32 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- if (PROTOBUF_PREDICT_TRUE(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label_IsValid(val))) {
+ if (PROTOBUF_PREDICT_TRUE(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label_IsValid(static_cast<int>(val)))) {
_internal_set_label(static_cast<::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label>(val));
} else {
::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(4, val, mutable_unknown_fields());
}
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional .google.protobuf.FieldDescriptorProto.Type type = 5;
case 5:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 40)) {
- arc_ui64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 40)) {
+ ::arc_ui32 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- if (PROTOBUF_PREDICT_TRUE(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type_IsValid(val))) {
+ if (PROTOBUF_PREDICT_TRUE(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type_IsValid(static_cast<int>(val)))) {
_internal_set_type(static_cast<::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type>(val));
} else {
::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(5, val, mutable_unknown_fields());
}
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string type_name = 6;
case 6:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 50)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 50)) {
auto str = _internal_mutable_type_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.type_name");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string default_value = 7;
case 7:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 58)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 58)) {
auto str = _internal_mutable_default_value();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.default_value");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional .google.protobuf.FieldOptions options = 8;
case 8:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 66)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 66)) {
ptr = ctx->ParseMessage(_internal_mutable_options(), ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional int32 oneof_index = 9;
case 9:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 72)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 72)) {
_Internal::set_has_oneof_index(&has_bits);
_impl_.oneof_index_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string json_name = 10;
case 10:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 82)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 82)) {
auto str = _internal_mutable_json_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.json_name");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional bool proto3_optional = 17;
case 17:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 136)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 136)) {
_Internal::set_has_proto3_optional(&has_bits);
_impl_.proto3_optional_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -3877,71 +4369,64 @@ failure:
#undef CHK_
}
-uint8_t* FieldDescriptorProto::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* FieldDescriptorProto::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldDescriptorProto)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.FieldDescriptorProto.name");
- target = stream->WriteStringMaybeAliased(
- 1, this->_internal_name(), target);
+ const TProtoStringType& _s = this->_internal_name();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FieldDescriptorProto.name");
+ target = stream->WriteStringMaybeAliased(1, _s, target);
}
// optional string extendee = 2;
if (cached_has_bits & 0x00000002u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_extendee().data(), static_cast<int>(this->_internal_extendee().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.FieldDescriptorProto.extendee");
- target = stream->WriteStringMaybeAliased(
- 2, this->_internal_extendee(), target);
+ const TProtoStringType& _s = this->_internal_extendee();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FieldDescriptorProto.extendee");
+ target = stream->WriteStringMaybeAliased(2, _s, target);
}
// optional int32 number = 3;
if (cached_has_bits & 0x00000040u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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 = ::_pbi::WireFormatLite::WriteEnumToArray(
- 4, this->_internal_label(), target);
+ 4, this->_internal_label(), target);
}
// optional .google.protobuf.FieldDescriptorProto.Type type = 5;
if (cached_has_bits & 0x00000400u) {
target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::WriteEnumToArray(
- 5, this->_internal_type(), target);
+ 5, this->_internal_type(), target);
}
// optional string type_name = 6;
if (cached_has_bits & 0x00000004u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_type_name().data(), static_cast<int>(this->_internal_type_name().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.FieldDescriptorProto.type_name");
- target = stream->WriteStringMaybeAliased(
- 6, this->_internal_type_name(), target);
+ const TProtoStringType& _s = this->_internal_type_name();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FieldDescriptorProto.type_name");
+ target = stream->WriteStringMaybeAliased(6, _s, target);
}
// optional string default_value = 7;
if (cached_has_bits & 0x00000008u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_default_value().data(), static_cast<int>(this->_internal_default_value().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.FieldDescriptorProto.default_value");
- target = stream->WriteStringMaybeAliased(
- 7, this->_internal_default_value(), target);
+ const TProtoStringType& _s = this->_internal_default_value();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FieldDescriptorProto.default_value");
+ target = stream->WriteStringMaybeAliased(7, _s, target);
}
// optional .google.protobuf.FieldOptions options = 8;
@@ -3954,23 +4439,23 @@ uint8_t* FieldDescriptorProto::_InternalSerialize(
// optional int32 oneof_index = 9;
if (cached_has_bits & 0x00000080u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::WireFormatLite::WriteInt32ToArray(9, this->_internal_oneof_index(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(
+ 9, this->_internal_oneof_index(), target);
}
// optional string json_name = 10;
if (cached_has_bits & 0x00000010u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_json_name().data(), static_cast<int>(this->_internal_json_name().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.FieldDescriptorProto.json_name");
- target = stream->WriteStringMaybeAliased(
- 10, this->_internal_json_name(), target);
+ const TProtoStringType& _s = this->_internal_json_name();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FieldDescriptorProto.json_name");
+ target = stream->WriteStringMaybeAliased(10, _s, target);
}
// optional bool proto3_optional = 17;
if (cached_has_bits & 0x00000100u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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())) {
@@ -3981,11 +4466,11 @@ uint8_t* FieldDescriptorProto::_InternalSerialize(
return target;
}
-size_t FieldDescriptorProto::ByteSizeLong() const {
+::size_t FieldDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldDescriptorProto)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -3993,37 +4478,32 @@ size_t FieldDescriptorProto::ByteSizeLong() const {
if (cached_has_bits & 0x000000ffu) {
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_name());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_name());
}
// optional string extendee = 2;
if (cached_has_bits & 0x00000002u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_extendee());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_extendee());
}
// optional string type_name = 6;
if (cached_has_bits & 0x00000004u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_type_name());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_type_name());
}
// optional string default_value = 7;
if (cached_has_bits & 0x00000008u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_default_value());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_default_value());
}
// optional string json_name = 10;
if (cached_has_bits & 0x00000010u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_json_name());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_json_name());
}
// optional .google.protobuf.FieldOptions options = 8;
@@ -4035,31 +4515,33 @@ size_t FieldDescriptorProto::ByteSizeLong() const {
// optional int32 number = 3;
if (cached_has_bits & 0x00000040u) {
- total_size += ::_pbi::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 += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_oneof_index());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(
+ this->_internal_oneof_index());
}
}
if (cached_has_bits & 0x00000700u) {
// optional bool proto3_optional = 17;
if (cached_has_bits & 0x00000100u) {
- total_size += 2 + 1;
+ total_size += 3;
}
// optional .google.protobuf.FieldDescriptorProto.Label label = 4;
if (cached_has_bits & 0x00000200u) {
total_size += 1 +
- ::_pbi::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 +
- ::_pbi::WireFormatLite::EnumSize(this->_internal_type());
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_type());
}
}
@@ -4077,8 +4559,8 @@ void FieldDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, c
auto* const _this = static_cast<FieldDescriptorProto*>(&to_msg);
auto& from = static_cast<const FieldDescriptorProto&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldDescriptorProto)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._impl_._has_bits_[0];
@@ -4133,7 +4615,7 @@ void FieldDescriptorProto::CopyFrom(const FieldDescriptorProto& from) {
}
bool FieldDescriptorProto::IsInitialized() const {
- if (_internal_has_options()) {
+ if ((_impl_._has_bits_[0] & 0x00000020u) != 0) {
if (!_impl_.options_->IsInitialized()) return false;
}
return true;
@@ -4145,34 +4627,22 @@ void FieldDescriptorProto::InternalSwap(FieldDescriptorProto* other) {
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.name_, lhs_arena,
- &other->_impl_.name_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.extendee_, lhs_arena,
- &other->_impl_.extendee_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.type_name_, lhs_arena,
- &other->_impl_.type_name_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.default_value_, lhs_arena,
- &other->_impl_.default_value_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.json_name_, lhs_arena,
- &other->_impl_.json_name_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, lhs_arena,
+ &other->_impl_.name_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.extendee_, lhs_arena,
+ &other->_impl_.extendee_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.type_name_, lhs_arena,
+ &other->_impl_.type_name_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.default_value_, lhs_arena,
+ &other->_impl_.default_value_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.json_name_, lhs_arena,
+ &other->_impl_.json_name_, rhs_arena);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
- PROTOBUF_FIELD_OFFSET(FieldDescriptorProto, _impl_.proto3_optional_)
- + sizeof(FieldDescriptorProto::_impl_.proto3_optional_)
+ PROTOBUF_FIELD_OFFSET(FieldDescriptorProto, _impl_.type_)
+ + sizeof(FieldDescriptorProto::_impl_.type_)
- PROTOBUF_FIELD_OFFSET(FieldDescriptorProto, _impl_.options_)>(
reinterpret_cast<char*>(&_impl_.options_),
reinterpret_cast<char*>(&other->_impl_.options_));
- swap(_impl_.label_, other->_impl_.label_);
- swap(_impl_.type_, other->_impl_.type_);
}
::PROTOBUF_NAMESPACE_ID::Metadata FieldDescriptorProto::GetMetadata() const {
@@ -4180,12 +4650,13 @@ void FieldDescriptorProto::InternalSwap(FieldDescriptorProto* other) {
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[6]);
}
-
// ===================================================================
class OneofDescriptorProto::_Internal {
public:
using HasBits = decltype(std::declval<OneofDescriptorProto>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(OneofDescriptorProto, _impl_._has_bits_);
static void set_has_name(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -4199,10 +4670,9 @@ const ::PROTOBUF_NAMESPACE_ID::OneofOptions&
OneofDescriptorProto::_Internal::options(const OneofDescriptorProto* msg) {
return *msg->_impl_.options_;
}
-OneofDescriptorProto::OneofDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+OneofDescriptorProto::OneofDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.OneofDescriptorProto)
}
OneofDescriptorProto::OneofDescriptorProto(const OneofDescriptorProto& from)
@@ -4211,38 +4681,37 @@ OneofDescriptorProto::OneofDescriptorProto(const OneofDescriptorProto& from)
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){from._impl_._has_bits_}
, /*decltype(_impl_._cached_size_)*/{}
- , decltype(_impl_.name_){}
+ , decltype(_impl_.name_) {}
+
, decltype(_impl_.options_){nullptr}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_name()) {
- _this->_impl_.name_.Set(from._internal_name(),
- _this->GetArenaForAllocation());
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
+ _this->_impl_.name_.Set(from._internal_name(), _this->GetArenaForAllocation());
}
- if (from._internal_has_options()) {
+ if ((from._impl_._has_bits_[0] & 0x00000002u) != 0) {
_this->_impl_.options_ = new ::PROTOBUF_NAMESPACE_ID::OneofOptions(*from._impl_.options_);
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.OneofDescriptorProto)
}
-inline void OneofDescriptorProto::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void OneofDescriptorProto::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
- , decltype(_impl_.name_){}
+ , decltype(_impl_.name_) {}
+
, decltype(_impl_.options_){nullptr}
};
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
OneofDescriptorProto::~OneofDescriptorProto() {
@@ -4255,7 +4724,7 @@ OneofDescriptorProto::~OneofDescriptorProto() {
}
inline void OneofDescriptorProto::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.name_.Destroy();
if (this != internal_default_instance()) delete _impl_.options_;
}
@@ -4266,7 +4735,7 @@ void OneofDescriptorProto::SetCachedSize(int size) const {
void OneofDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.OneofDescriptorProto)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -4276,7 +4745,7 @@ void OneofDescriptorProto::Clear() {
_impl_.name_.ClearNonDefaultToEmpty();
}
if (cached_has_bits & 0x00000002u) {
- GOOGLE_DCHECK(_impl_.options_ != nullptr);
+ Y_ABSL_DCHECK(_impl_.options_ != nullptr);
_impl_.options_->Clear();
}
}
@@ -4288,28 +4757,30 @@ const char* OneofDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseC
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 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)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.OneofDescriptorProto.name");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional .google.protobuf.OneofOptions options = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) {
ptr = ctx->ParseMessage(_internal_mutable_options(), ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -4335,21 +4806,19 @@ failure:
#undef CHK_
}
-uint8_t* OneofDescriptorProto::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* OneofDescriptorProto::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.OneofDescriptorProto)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.OneofDescriptorProto.name");
- target = stream->WriteStringMaybeAliased(
- 1, this->_internal_name(), target);
+ const TProtoStringType& _s = this->_internal_name();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.OneofDescriptorProto.name");
+ target = stream->WriteStringMaybeAliased(1, _s, target);
}
// optional .google.protobuf.OneofOptions options = 2;
@@ -4367,11 +4836,11 @@ uint8_t* OneofDescriptorProto::_InternalSerialize(
return target;
}
-size_t OneofDescriptorProto::ByteSizeLong() const {
+::size_t OneofDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.OneofDescriptorProto)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -4379,9 +4848,8 @@ size_t OneofDescriptorProto::ByteSizeLong() const {
if (cached_has_bits & 0x00000003u) {
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_name());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_name());
}
// optional .google.protobuf.OneofOptions options = 2;
@@ -4406,8 +4874,8 @@ void OneofDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, c
auto* const _this = static_cast<OneofDescriptorProto*>(&to_msg);
auto& from = static_cast<const OneofDescriptorProto&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofDescriptorProto)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._impl_._has_bits_[0];
@@ -4431,7 +4899,7 @@ void OneofDescriptorProto::CopyFrom(const OneofDescriptorProto& from) {
}
bool OneofDescriptorProto::IsInitialized() const {
- if (_internal_has_options()) {
+ if ((_impl_._has_bits_[0] & 0x00000002u) != 0) {
if (!_impl_.options_->IsInitialized()) return false;
}
return true;
@@ -4443,10 +4911,8 @@ void OneofDescriptorProto::InternalSwap(OneofDescriptorProto* other) {
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.name_, lhs_arena,
- &other->_impl_.name_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, lhs_arena,
+ &other->_impl_.name_, rhs_arena);
swap(_impl_.options_, other->_impl_.options_);
}
@@ -4455,12 +4921,13 @@ void OneofDescriptorProto::InternalSwap(OneofDescriptorProto* other) {
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[7]);
}
-
// ===================================================================
class EnumDescriptorProto_EnumReservedRange::_Internal {
public:
using HasBits = decltype(std::declval<EnumDescriptorProto_EnumReservedRange>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(EnumDescriptorProto_EnumReservedRange, _impl_._has_bits_);
static void set_has_start(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -4469,37 +4936,27 @@ class EnumDescriptorProto_EnumReservedRange::_Internal {
}
};
-EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.EnumDescriptorProto.EnumReservedRange)
}
EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange(const EnumDescriptorProto_EnumReservedRange& from)
- : ::PROTOBUF_NAMESPACE_ID::Message() {
- EnumDescriptorProto_EnumReservedRange* const _this = this; (void)_this;
- new (&_impl_) Impl_{
- decltype(_impl_._has_bits_){from._impl_._has_bits_}
- , /*decltype(_impl_._cached_size_)*/{}
- , decltype(_impl_.start_){}
- , decltype(_impl_.end_){}};
-
- _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- ::memcpy(&_impl_.start_, &from._impl_.start_,
- static_cast<size_t>(reinterpret_cast<char*>(&_impl_.end_) -
- reinterpret_cast<char*>(&_impl_.start_)) + sizeof(_impl_.end_));
+ : ::PROTOBUF_NAMESPACE_ID::Message(), _impl_(from._impl_) {
+ _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(
+ from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:google.protobuf.EnumDescriptorProto.EnumReservedRange)
}
-inline void EnumDescriptorProto_EnumReservedRange::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void EnumDescriptorProto_EnumReservedRange::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
- , decltype(_impl_.start_){0}
- , decltype(_impl_.end_){0}
+ , decltype(_impl_.start_) { 0 }
+
+ , decltype(_impl_.end_) { 0 }
+
};
}
@@ -4513,7 +4970,7 @@ EnumDescriptorProto_EnumReservedRange::~EnumDescriptorProto_EnumReservedRange()
}
inline void EnumDescriptorProto_EnumReservedRange::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
}
void EnumDescriptorProto_EnumReservedRange::SetCachedSize(int size) const {
@@ -4522,13 +4979,13 @@ void EnumDescriptorProto_EnumReservedRange::SetCachedSize(int size) const {
void EnumDescriptorProto_EnumReservedRange::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumDescriptorProto.EnumReservedRange)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x00000003u) {
- ::memset(&_impl_.start_, 0, static_cast<size_t>(
+ ::memset(&_impl_.start_, 0, static_cast<::size_t>(
reinterpret_cast<char*>(&_impl_.end_) -
reinterpret_cast<char*>(&_impl_.start_)) + sizeof(_impl_.end_));
}
@@ -4540,26 +4997,28 @@ const char* EnumDescriptorProto_EnumReservedRange::_InternalParse(const char* pt
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional int32 start = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) {
_Internal::set_has_start(&has_bits);
_impl_.start_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional int32 end = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 16)) {
_Internal::set_has_end(&has_bits);
_impl_.end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -4585,23 +5044,25 @@ failure:
#undef CHK_
}
-uint8_t* EnumDescriptorProto_EnumReservedRange::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* EnumDescriptorProto_EnumReservedRange::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumDescriptorProto.EnumReservedRange)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
// optional int32 start = 1;
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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 = ::_pbi::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())) {
@@ -4612,11 +5073,11 @@ uint8_t* EnumDescriptorProto_EnumReservedRange::_InternalSerialize(
return target;
}
-size_t EnumDescriptorProto_EnumReservedRange::ByteSizeLong() const {
+::size_t EnumDescriptorProto_EnumReservedRange::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumDescriptorProto.EnumReservedRange)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -4624,12 +5085,14 @@ size_t EnumDescriptorProto_EnumReservedRange::ByteSizeLong() const {
if (cached_has_bits & 0x00000003u) {
// optional int32 start = 1;
if (cached_has_bits & 0x00000001u) {
- total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_start());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(
+ this->_internal_start());
}
// optional int32 end = 2;
if (cached_has_bits & 0x00000002u) {
- total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_end());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(
+ this->_internal_end());
}
}
@@ -4647,8 +5110,8 @@ void EnumDescriptorProto_EnumReservedRange::MergeImpl(::PROTOBUF_NAMESPACE_ID::M
auto* const _this = static_cast<EnumDescriptorProto_EnumReservedRange*>(&to_msg);
auto& from = static_cast<const EnumDescriptorProto_EnumReservedRange&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumDescriptorProto.EnumReservedRange)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._impl_._has_bits_[0];
@@ -4692,12 +5155,13 @@ void EnumDescriptorProto_EnumReservedRange::InternalSwap(EnumDescriptorProto_Enu
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[8]);
}
-
// ===================================================================
class EnumDescriptorProto::_Internal {
public:
using HasBits = decltype(std::declval<EnumDescriptorProto>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(EnumDescriptorProto, _impl_._has_bits_);
static void set_has_name(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -4711,10 +5175,9 @@ const ::PROTOBUF_NAMESPACE_ID::EnumOptions&
EnumDescriptorProto::_Internal::options(const EnumDescriptorProto* msg) {
return *msg->_impl_.options_;
}
-EnumDescriptorProto::EnumDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+EnumDescriptorProto::EnumDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.EnumDescriptorProto)
}
EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from)
@@ -4726,41 +5189,40 @@ EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from)
, decltype(_impl_.value_){from._impl_.value_}
, decltype(_impl_.reserved_range_){from._impl_.reserved_range_}
, decltype(_impl_.reserved_name_){from._impl_.reserved_name_}
- , decltype(_impl_.name_){}
+ , decltype(_impl_.name_) {}
+
, decltype(_impl_.options_){nullptr}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_name()) {
- _this->_impl_.name_.Set(from._internal_name(),
- _this->GetArenaForAllocation());
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
+ _this->_impl_.name_.Set(from._internal_name(), _this->GetArenaForAllocation());
}
- if (from._internal_has_options()) {
+ if ((from._impl_._has_bits_[0] & 0x00000002u) != 0) {
_this->_impl_.options_ = new ::PROTOBUF_NAMESPACE_ID::EnumOptions(*from._impl_.options_);
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.EnumDescriptorProto)
}
-inline void EnumDescriptorProto::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void EnumDescriptorProto::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.value_){arena}
, decltype(_impl_.reserved_range_){arena}
, decltype(_impl_.reserved_name_){arena}
- , decltype(_impl_.name_){}
+ , decltype(_impl_.name_) {}
+
, decltype(_impl_.options_){nullptr}
};
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
EnumDescriptorProto::~EnumDescriptorProto() {
@@ -4773,7 +5235,7 @@ EnumDescriptorProto::~EnumDescriptorProto() {
}
inline void EnumDescriptorProto::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.value_.~RepeatedPtrField();
_impl_.reserved_range_.~RepeatedPtrField();
_impl_.reserved_name_.~RepeatedPtrField();
@@ -4787,7 +5249,7 @@ void EnumDescriptorProto::SetCachedSize(int size) const {
void EnumDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumDescriptorProto)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -4800,7 +5262,7 @@ void EnumDescriptorProto::Clear() {
_impl_.name_.ClearNonDefaultToEmpty();
}
if (cached_has_bits & 0x00000002u) {
- GOOGLE_DCHECK(_impl_.options_ != nullptr);
+ Y_ABSL_DCHECK(_impl_.options_ != nullptr);
_impl_.options_->Clear();
}
}
@@ -4812,24 +5274,25 @@ const char* EnumDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseCo
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 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)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.EnumDescriptorProto.name");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.EnumValueDescriptorProto value = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) {
ptr -= 1;
do {
ptr += 1;
@@ -4837,20 +5300,22 @@ const char* EnumDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseCo
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional .google.protobuf.EnumOptions options = 3;
case 3:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 26)) {
ptr = ctx->ParseMessage(_internal_mutable_options(), ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4;
case 4:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 34)) {
ptr -= 1;
do {
ptr += 1;
@@ -4858,12 +5323,13 @@ const char* EnumDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseCo
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated string reserved_name = 5;
case 5:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 42)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 42)) {
ptr -= 1;
do {
ptr += 1;
@@ -4875,8 +5341,9 @@ const char* EnumDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseCo
#endif // !NDEBUG
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<42>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -4902,21 +5369,19 @@ failure:
#undef CHK_
}
-uint8_t* EnumDescriptorProto::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* EnumDescriptorProto::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumDescriptorProto)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.EnumDescriptorProto.name");
- target = stream->WriteStringMaybeAliased(
- 1, this->_internal_name(), target);
+ const TProtoStringType& _s = this->_internal_name();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.EnumDescriptorProto.name");
+ target = stream->WriteStringMaybeAliased(1, _s, target);
}
// repeated .google.protobuf.EnumValueDescriptorProto value = 2;
@@ -4943,12 +5408,10 @@ uint8_t* EnumDescriptorProto::_InternalSerialize(
}
// repeated string reserved_name = 5;
- for (int i = 0, n = this->_internal_reserved_name_size(); i < n; i++) {
+ for (int i = 0, n = this->_internal_reserved_name_size(); i < n; ++i) {
const auto& s = this->_internal_reserved_name(i);
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- s.data(), static_cast<int>(s.length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.EnumDescriptorProto.reserved_name");
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(s.data(), static_cast<int>(s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.EnumDescriptorProto.reserved_name");
target = stream->WriteString(5, s, target);
}
@@ -4960,11 +5423,11 @@ uint8_t* EnumDescriptorProto::_InternalSerialize(
return target;
}
-size_t EnumDescriptorProto::ByteSizeLong() const {
+::size_t EnumDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumDescriptorProto)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -4983,20 +5446,17 @@ size_t EnumDescriptorProto::ByteSizeLong() const {
}
// repeated string reserved_name = 5;
- total_size += 1 *
- ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.reserved_name_.size());
- for (int i = 0, n = _impl_.reserved_name_.size(); i < n; i++) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- _impl_.reserved_name_.Get(i));
+ total_size += 1 * ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.reserved_name_.size());
+ for (int i = 0, n = _impl_.reserved_name_.size(); i < n; ++i) {
+ total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(_impl_.reserved_name_.Get(i));
}
cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x00000003u) {
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_name());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_name());
}
// optional .google.protobuf.EnumOptions options = 3;
@@ -5021,8 +5481,8 @@ void EnumDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, co
auto* const _this = static_cast<EnumDescriptorProto*>(&to_msg);
auto& from = static_cast<const EnumDescriptorProto&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumDescriptorProto)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.value_.MergeFrom(from._impl_.value_);
@@ -5051,7 +5511,7 @@ void EnumDescriptorProto::CopyFrom(const EnumDescriptorProto& from) {
bool EnumDescriptorProto::IsInitialized() const {
if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.value_))
return false;
- if (_internal_has_options()) {
+ if ((_impl_._has_bits_[0] & 0x00000002u) != 0) {
if (!_impl_.options_->IsInitialized()) return false;
}
return true;
@@ -5066,10 +5526,8 @@ void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) {
_impl_.value_.InternalSwap(&other->_impl_.value_);
_impl_.reserved_range_.InternalSwap(&other->_impl_.reserved_range_);
_impl_.reserved_name_.InternalSwap(&other->_impl_.reserved_name_);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.name_, lhs_arena,
- &other->_impl_.name_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, lhs_arena,
+ &other->_impl_.name_, rhs_arena);
swap(_impl_.options_, other->_impl_.options_);
}
@@ -5078,12 +5536,13 @@ void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) {
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[9]);
}
-
// ===================================================================
class EnumValueDescriptorProto::_Internal {
public:
using HasBits = decltype(std::declval<EnumValueDescriptorProto>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(EnumValueDescriptorProto, _impl_._has_bits_);
static void set_has_name(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -5100,10 +5559,9 @@ const ::PROTOBUF_NAMESPACE_ID::EnumValueOptions&
EnumValueDescriptorProto::_Internal::options(const EnumValueDescriptorProto* msg) {
return *msg->_impl_.options_;
}
-EnumValueDescriptorProto::EnumValueDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+EnumValueDescriptorProto::EnumValueDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.EnumValueDescriptorProto)
}
EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProto& from)
@@ -5112,41 +5570,42 @@ EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProt
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){from._impl_._has_bits_}
, /*decltype(_impl_._cached_size_)*/{}
- , decltype(_impl_.name_){}
+ , decltype(_impl_.name_) {}
+
, decltype(_impl_.options_){nullptr}
- , decltype(_impl_.number_){}};
+ , decltype(_impl_.number_) {}
+ };
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_name()) {
- _this->_impl_.name_.Set(from._internal_name(),
- _this->GetArenaForAllocation());
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
+ _this->_impl_.name_.Set(from._internal_name(), _this->GetArenaForAllocation());
}
- if (from._internal_has_options()) {
+ if ((from._impl_._has_bits_[0] & 0x00000002u) != 0) {
_this->_impl_.options_ = new ::PROTOBUF_NAMESPACE_ID::EnumValueOptions(*from._impl_.options_);
}
_this->_impl_.number_ = from._impl_.number_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValueDescriptorProto)
}
-inline void EnumValueDescriptorProto::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void EnumValueDescriptorProto::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
- , decltype(_impl_.name_){}
+ , decltype(_impl_.name_) {}
+
, decltype(_impl_.options_){nullptr}
- , decltype(_impl_.number_){0}
+ , decltype(_impl_.number_) { 0 }
+
};
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
EnumValueDescriptorProto::~EnumValueDescriptorProto() {
@@ -5159,7 +5618,7 @@ EnumValueDescriptorProto::~EnumValueDescriptorProto() {
}
inline void EnumValueDescriptorProto::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.name_.Destroy();
if (this != internal_default_instance()) delete _impl_.options_;
}
@@ -5170,7 +5629,7 @@ void EnumValueDescriptorProto::SetCachedSize(int size) const {
void EnumValueDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValueDescriptorProto)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -5180,7 +5639,7 @@ void EnumValueDescriptorProto::Clear() {
_impl_.name_.ClearNonDefaultToEmpty();
}
if (cached_has_bits & 0x00000002u) {
- GOOGLE_DCHECK(_impl_.options_ != nullptr);
+ Y_ABSL_DCHECK(_impl_.options_ != nullptr);
_impl_.options_->Clear();
}
}
@@ -5193,37 +5652,40 @@ const char* EnumValueDescriptorProto::_InternalParse(const char* ptr, ::_pbi::Pa
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 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)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.EnumValueDescriptorProto.name");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional int32 number = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 16)) {
_Internal::set_has_number(&has_bits);
_impl_.number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional .google.protobuf.EnumValueOptions options = 3;
case 3:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 26)) {
ptr = ctx->ParseMessage(_internal_mutable_options(), ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -5249,27 +5711,26 @@ failure:
#undef CHK_
}
-uint8_t* EnumValueDescriptorProto::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* EnumValueDescriptorProto::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumValueDescriptorProto)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.EnumValueDescriptorProto.name");
- target = stream->WriteStringMaybeAliased(
- 1, this->_internal_name(), target);
+ const TProtoStringType& _s = this->_internal_name();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.EnumValueDescriptorProto.name");
+ target = stream->WriteStringMaybeAliased(1, _s, target);
}
// optional int32 number = 2;
if (cached_has_bits & 0x00000004u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_number(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(
+ 2, this->_internal_number(), target);
}
// optional .google.protobuf.EnumValueOptions options = 3;
@@ -5287,11 +5748,11 @@ uint8_t* EnumValueDescriptorProto::_InternalSerialize(
return target;
}
-size_t EnumValueDescriptorProto::ByteSizeLong() const {
+::size_t EnumValueDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValueDescriptorProto)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -5299,9 +5760,8 @@ size_t EnumValueDescriptorProto::ByteSizeLong() const {
if (cached_has_bits & 0x00000007u) {
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_name());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_name());
}
// optional .google.protobuf.EnumValueOptions options = 3;
@@ -5313,7 +5773,8 @@ size_t EnumValueDescriptorProto::ByteSizeLong() const {
// optional int32 number = 2;
if (cached_has_bits & 0x00000004u) {
- total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_number());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(
+ this->_internal_number());
}
}
@@ -5331,8 +5792,8 @@ void EnumValueDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_ms
auto* const _this = static_cast<EnumValueDescriptorProto*>(&to_msg);
auto& from = static_cast<const EnumValueDescriptorProto&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueDescriptorProto)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._impl_._has_bits_[0];
@@ -5360,7 +5821,7 @@ void EnumValueDescriptorProto::CopyFrom(const EnumValueDescriptorProto& from) {
}
bool EnumValueDescriptorProto::IsInitialized() const {
- if (_internal_has_options()) {
+ if ((_impl_._has_bits_[0] & 0x00000002u) != 0) {
if (!_impl_.options_->IsInitialized()) return false;
}
return true;
@@ -5372,10 +5833,8 @@ void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* other) {
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.name_, lhs_arena,
- &other->_impl_.name_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, lhs_arena,
+ &other->_impl_.name_, rhs_arena);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(EnumValueDescriptorProto, _impl_.number_)
+ sizeof(EnumValueDescriptorProto::_impl_.number_)
@@ -5389,12 +5848,13 @@ void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* other) {
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[10]);
}
-
// ===================================================================
class ServiceDescriptorProto::_Internal {
public:
using HasBits = decltype(std::declval<ServiceDescriptorProto>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(ServiceDescriptorProto, _impl_._has_bits_);
static void set_has_name(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -5408,10 +5868,9 @@ const ::PROTOBUF_NAMESPACE_ID::ServiceOptions&
ServiceDescriptorProto::_Internal::options(const ServiceDescriptorProto* msg) {
return *msg->_impl_.options_;
}
-ServiceDescriptorProto::ServiceDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+ServiceDescriptorProto::ServiceDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.ServiceDescriptorProto)
}
ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& from)
@@ -5421,39 +5880,38 @@ ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& fro
decltype(_impl_._has_bits_){from._impl_._has_bits_}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.method_){from._impl_.method_}
- , decltype(_impl_.name_){}
+ , decltype(_impl_.name_) {}
+
, decltype(_impl_.options_){nullptr}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_name()) {
- _this->_impl_.name_.Set(from._internal_name(),
- _this->GetArenaForAllocation());
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
+ _this->_impl_.name_.Set(from._internal_name(), _this->GetArenaForAllocation());
}
- if (from._internal_has_options()) {
+ if ((from._impl_._has_bits_[0] & 0x00000002u) != 0) {
_this->_impl_.options_ = new ::PROTOBUF_NAMESPACE_ID::ServiceOptions(*from._impl_.options_);
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.ServiceDescriptorProto)
}
-inline void ServiceDescriptorProto::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void ServiceDescriptorProto::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.method_){arena}
- , decltype(_impl_.name_){}
+ , decltype(_impl_.name_) {}
+
, decltype(_impl_.options_){nullptr}
};
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
ServiceDescriptorProto::~ServiceDescriptorProto() {
@@ -5466,7 +5924,7 @@ ServiceDescriptorProto::~ServiceDescriptorProto() {
}
inline void ServiceDescriptorProto::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.method_.~RepeatedPtrField();
_impl_.name_.Destroy();
if (this != internal_default_instance()) delete _impl_.options_;
@@ -5478,7 +5936,7 @@ void ServiceDescriptorProto::SetCachedSize(int size) const {
void ServiceDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.ServiceDescriptorProto)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -5489,7 +5947,7 @@ void ServiceDescriptorProto::Clear() {
_impl_.name_.ClearNonDefaultToEmpty();
}
if (cached_has_bits & 0x00000002u) {
- GOOGLE_DCHECK(_impl_.options_ != nullptr);
+ Y_ABSL_DCHECK(_impl_.options_ != nullptr);
_impl_.options_->Clear();
}
}
@@ -5501,24 +5959,25 @@ const char* ServiceDescriptorProto::_InternalParse(const char* ptr, ::_pbi::Pars
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 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)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.ServiceDescriptorProto.name");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.MethodDescriptorProto method = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) {
ptr -= 1;
do {
ptr += 1;
@@ -5526,16 +5985,18 @@ const char* ServiceDescriptorProto::_InternalParse(const char* ptr, ::_pbi::Pars
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional .google.protobuf.ServiceOptions options = 3;
case 3:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 26)) {
ptr = ctx->ParseMessage(_internal_mutable_options(), ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -5561,21 +6022,19 @@ failure:
#undef CHK_
}
-uint8_t* ServiceDescriptorProto::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* ServiceDescriptorProto::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.ServiceDescriptorProto)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.ServiceDescriptorProto.name");
- target = stream->WriteStringMaybeAliased(
- 1, this->_internal_name(), target);
+ const TProtoStringType& _s = this->_internal_name();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.ServiceDescriptorProto.name");
+ target = stream->WriteStringMaybeAliased(1, _s, target);
}
// repeated .google.protobuf.MethodDescriptorProto method = 2;
@@ -5601,11 +6060,11 @@ uint8_t* ServiceDescriptorProto::_InternalSerialize(
return target;
}
-size_t ServiceDescriptorProto::ByteSizeLong() const {
+::size_t ServiceDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.ServiceDescriptorProto)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -5620,9 +6079,8 @@ size_t ServiceDescriptorProto::ByteSizeLong() const {
if (cached_has_bits & 0x00000003u) {
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_name());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_name());
}
// optional .google.protobuf.ServiceOptions options = 3;
@@ -5647,8 +6105,8 @@ void ServiceDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg,
auto* const _this = static_cast<ServiceDescriptorProto*>(&to_msg);
auto& from = static_cast<const ServiceDescriptorProto&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceDescriptorProto)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.method_.MergeFrom(from._impl_.method_);
@@ -5675,7 +6133,7 @@ void ServiceDescriptorProto::CopyFrom(const ServiceDescriptorProto& from) {
bool ServiceDescriptorProto::IsInitialized() const {
if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.method_))
return false;
- if (_internal_has_options()) {
+ if ((_impl_._has_bits_[0] & 0x00000002u) != 0) {
if (!_impl_.options_->IsInitialized()) return false;
}
return true;
@@ -5688,10 +6146,8 @@ void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
_impl_.method_.InternalSwap(&other->_impl_.method_);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.name_, lhs_arena,
- &other->_impl_.name_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, lhs_arena,
+ &other->_impl_.name_, rhs_arena);
swap(_impl_.options_, other->_impl_.options_);
}
@@ -5700,12 +6156,13 @@ void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) {
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[11]);
}
-
// ===================================================================
class MethodDescriptorProto::_Internal {
public:
using HasBits = decltype(std::declval<MethodDescriptorProto>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(MethodDescriptorProto, _impl_._has_bits_);
static void set_has_name(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -5731,10 +6188,9 @@ const ::PROTOBUF_NAMESPACE_ID::MethodOptions&
MethodDescriptorProto::_Internal::options(const MethodDescriptorProto* msg) {
return *msg->_impl_.options_;
}
-MethodDescriptorProto::MethodDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+MethodDescriptorProto::MethodDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.MethodDescriptorProto)
}
MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from)
@@ -5743,73 +6199,78 @@ MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from)
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){from._impl_._has_bits_}
, /*decltype(_impl_._cached_size_)*/{}
- , decltype(_impl_.name_){}
- , decltype(_impl_.input_type_){}
- , decltype(_impl_.output_type_){}
+ , decltype(_impl_.name_) {}
+
+ , decltype(_impl_.input_type_) {}
+
+ , decltype(_impl_.output_type_) {}
+
, decltype(_impl_.options_){nullptr}
- , decltype(_impl_.client_streaming_){}
- , decltype(_impl_.server_streaming_){}};
+ , decltype(_impl_.client_streaming_) {}
+
+ , decltype(_impl_.server_streaming_) {}
+ };
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_name()) {
- _this->_impl_.name_.Set(from._internal_name(),
- _this->GetArenaForAllocation());
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
+ _this->_impl_.name_.Set(from._internal_name(), _this->GetArenaForAllocation());
}
_impl_.input_type_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.input_type_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_input_type()) {
- _this->_impl_.input_type_.Set(from._internal_input_type(),
- _this->GetArenaForAllocation());
+ _impl_.input_type_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000002u) != 0) {
+ _this->_impl_.input_type_.Set(from._internal_input_type(), _this->GetArenaForAllocation());
}
_impl_.output_type_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.output_type_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_output_type()) {
- _this->_impl_.output_type_.Set(from._internal_output_type(),
- _this->GetArenaForAllocation());
+ _impl_.output_type_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000004u) != 0) {
+ _this->_impl_.output_type_.Set(from._internal_output_type(), _this->GetArenaForAllocation());
}
- if (from._internal_has_options()) {
+ if ((from._impl_._has_bits_[0] & 0x00000008u) != 0) {
_this->_impl_.options_ = new ::PROTOBUF_NAMESPACE_ID::MethodOptions(*from._impl_.options_);
}
::memcpy(&_impl_.client_streaming_, &from._impl_.client_streaming_,
- static_cast<size_t>(reinterpret_cast<char*>(&_impl_.server_streaming_) -
+ static_cast<::size_t>(reinterpret_cast<char*>(&_impl_.server_streaming_) -
reinterpret_cast<char*>(&_impl_.client_streaming_)) + sizeof(_impl_.server_streaming_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.MethodDescriptorProto)
}
-inline void MethodDescriptorProto::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void MethodDescriptorProto::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
- , decltype(_impl_.name_){}
- , decltype(_impl_.input_type_){}
- , decltype(_impl_.output_type_){}
+ , decltype(_impl_.name_) {}
+
+ , decltype(_impl_.input_type_) {}
+
+ , decltype(_impl_.output_type_) {}
+
, decltype(_impl_.options_){nullptr}
- , decltype(_impl_.client_streaming_){false}
- , decltype(_impl_.server_streaming_){false}
+ , decltype(_impl_.client_streaming_) { false }
+
+ , decltype(_impl_.server_streaming_) { false }
+
};
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.input_type_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.input_type_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.input_type_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.output_type_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.output_type_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.output_type_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
MethodDescriptorProto::~MethodDescriptorProto() {
@@ -5822,7 +6283,7 @@ MethodDescriptorProto::~MethodDescriptorProto() {
}
inline void MethodDescriptorProto::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.name_.Destroy();
_impl_.input_type_.Destroy();
_impl_.output_type_.Destroy();
@@ -5835,7 +6296,7 @@ void MethodDescriptorProto::SetCachedSize(int size) const {
void MethodDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.MethodDescriptorProto)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -5851,11 +6312,11 @@ void MethodDescriptorProto::Clear() {
_impl_.output_type_.ClearNonDefaultToEmpty();
}
if (cached_has_bits & 0x00000008u) {
- GOOGLE_DCHECK(_impl_.options_ != nullptr);
+ Y_ABSL_DCHECK(_impl_.options_ != nullptr);
_impl_.options_->Clear();
}
}
- ::memset(&_impl_.client_streaming_, 0, static_cast<size_t>(
+ ::memset(&_impl_.client_streaming_, 0, static_cast<::size_t>(
reinterpret_cast<char*>(&_impl_.server_streaming_) -
reinterpret_cast<char*>(&_impl_.client_streaming_)) + sizeof(_impl_.server_streaming_));
_impl_._has_bits_.Clear();
@@ -5866,70 +6327,76 @@ const char* MethodDescriptorProto::_InternalParse(const char* ptr, ::_pbi::Parse
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 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)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.MethodDescriptorProto.name");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string input_type = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) {
auto str = _internal_mutable_input_type();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.MethodDescriptorProto.input_type");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string output_type = 3;
case 3:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 26)) {
auto str = _internal_mutable_output_type();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.MethodDescriptorProto.output_type");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional .google.protobuf.MethodOptions options = 4;
case 4:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 34)) {
ptr = ctx->ParseMessage(_internal_mutable_options(), ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional bool client_streaming = 5 [default = false];
case 5:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 40)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 40)) {
_Internal::set_has_client_streaming(&has_bits);
_impl_.client_streaming_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional bool server_streaming = 6 [default = false];
case 6:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 48)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 48)) {
_Internal::set_has_server_streaming(&has_bits);
_impl_.server_streaming_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -5955,41 +6422,35 @@ failure:
#undef CHK_
}
-uint8_t* MethodDescriptorProto::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* MethodDescriptorProto::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.MethodDescriptorProto)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.MethodDescriptorProto.name");
- target = stream->WriteStringMaybeAliased(
- 1, this->_internal_name(), target);
+ const TProtoStringType& _s = this->_internal_name();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.MethodDescriptorProto.name");
+ target = stream->WriteStringMaybeAliased(1, _s, target);
}
// optional string input_type = 2;
if (cached_has_bits & 0x00000002u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_input_type().data(), static_cast<int>(this->_internal_input_type().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.MethodDescriptorProto.input_type");
- target = stream->WriteStringMaybeAliased(
- 2, this->_internal_input_type(), target);
+ const TProtoStringType& _s = this->_internal_input_type();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.MethodDescriptorProto.input_type");
+ target = stream->WriteStringMaybeAliased(2, _s, target);
}
// optional string output_type = 3;
if (cached_has_bits & 0x00000004u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_output_type().data(), static_cast<int>(this->_internal_output_type().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.MethodDescriptorProto.output_type");
- target = stream->WriteStringMaybeAliased(
- 3, this->_internal_output_type(), target);
+ const TProtoStringType& _s = this->_internal_output_type();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.MethodDescriptorProto.output_type");
+ target = stream->WriteStringMaybeAliased(3, _s, target);
}
// optional .google.protobuf.MethodOptions options = 4;
@@ -6002,13 +6463,15 @@ uint8_t* MethodDescriptorProto::_InternalSerialize(
// optional bool client_streaming = 5 [default = false];
if (cached_has_bits & 0x00000010u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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 = ::_pbi::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())) {
@@ -6019,11 +6482,11 @@ uint8_t* MethodDescriptorProto::_InternalSerialize(
return target;
}
-size_t MethodDescriptorProto::ByteSizeLong() const {
+::size_t MethodDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.MethodDescriptorProto)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -6031,23 +6494,20 @@ size_t MethodDescriptorProto::ByteSizeLong() const {
if (cached_has_bits & 0x0000003fu) {
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_name());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_name());
}
// optional string input_type = 2;
if (cached_has_bits & 0x00000002u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_input_type());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_input_type());
}
// optional string output_type = 3;
if (cached_has_bits & 0x00000004u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_output_type());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_output_type());
}
// optional .google.protobuf.MethodOptions options = 4;
@@ -6059,12 +6519,12 @@ size_t MethodDescriptorProto::ByteSizeLong() const {
// optional bool client_streaming = 5 [default = false];
if (cached_has_bits & 0x00000010u) {
- total_size += 1 + 1;
+ total_size += 2;
}
// optional bool server_streaming = 6 [default = false];
if (cached_has_bits & 0x00000020u) {
- total_size += 1 + 1;
+ total_size += 2;
}
}
@@ -6082,8 +6542,8 @@ void MethodDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg,
auto* const _this = static_cast<MethodDescriptorProto*>(&to_msg);
auto& from = static_cast<const MethodDescriptorProto&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodDescriptorProto)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._impl_._has_bits_[0];
@@ -6120,7 +6580,7 @@ void MethodDescriptorProto::CopyFrom(const MethodDescriptorProto& from) {
}
bool MethodDescriptorProto::IsInitialized() const {
- if (_internal_has_options()) {
+ if ((_impl_._has_bits_[0] & 0x00000008u) != 0) {
if (!_impl_.options_->IsInitialized()) return false;
}
return true;
@@ -6132,18 +6592,12 @@ void MethodDescriptorProto::InternalSwap(MethodDescriptorProto* other) {
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.name_, lhs_arena,
- &other->_impl_.name_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.input_type_, lhs_arena,
- &other->_impl_.input_type_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.output_type_, lhs_arena,
- &other->_impl_.output_type_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, lhs_arena,
+ &other->_impl_.name_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.input_type_, lhs_arena,
+ &other->_impl_.input_type_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.output_type_, lhs_arena,
+ &other->_impl_.output_type_, rhs_arena);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(MethodDescriptorProto, _impl_.server_streaming_)
+ sizeof(MethodDescriptorProto::_impl_.server_streaming_)
@@ -6157,12 +6611,13 @@ void MethodDescriptorProto::InternalSwap(MethodDescriptorProto* other) {
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[12]);
}
-
// ===================================================================
class FileOptions::_Internal {
public:
using HasBits = decltype(std::declval<FileOptions>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(FileOptions, _impl_._has_bits_);
static void set_has_java_package(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -6225,10 +6680,9 @@ class FileOptions::_Internal {
}
};
-FileOptions::FileOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+FileOptions::FileOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.FileOptions)
}
FileOptions::FileOptions(const FileOptions& from)
@@ -6239,185 +6693,213 @@ FileOptions::FileOptions(const FileOptions& from)
, decltype(_impl_._has_bits_){from._impl_._has_bits_}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.uninterpreted_option_){from._impl_.uninterpreted_option_}
- , decltype(_impl_.java_package_){}
- , decltype(_impl_.java_outer_classname_){}
- , decltype(_impl_.go_package_){}
- , decltype(_impl_.objc_class_prefix_){}
- , decltype(_impl_.csharp_namespace_){}
- , decltype(_impl_.swift_prefix_){}
- , decltype(_impl_.php_class_prefix_){}
- , decltype(_impl_.php_namespace_){}
- , decltype(_impl_.php_metadata_namespace_){}
- , decltype(_impl_.ruby_package_){}
- , decltype(_impl_.java_multiple_files_){}
- , decltype(_impl_.java_generate_equals_and_hash_){}
- , decltype(_impl_.java_string_check_utf8_){}
- , decltype(_impl_.cc_generic_services_){}
- , decltype(_impl_.java_generic_services_){}
- , decltype(_impl_.py_generic_services_){}
- , decltype(_impl_.php_generic_services_){}
- , decltype(_impl_.deprecated_){}
- , decltype(_impl_.optimize_for_){}
- , decltype(_impl_.cc_enable_arenas_){}};
+ , decltype(_impl_.java_package_) {}
+
+ , decltype(_impl_.java_outer_classname_) {}
+
+ , decltype(_impl_.go_package_) {}
+
+ , decltype(_impl_.objc_class_prefix_) {}
+
+ , decltype(_impl_.csharp_namespace_) {}
+
+ , decltype(_impl_.swift_prefix_) {}
+
+ , decltype(_impl_.php_class_prefix_) {}
+
+ , decltype(_impl_.php_namespace_) {}
+
+ , decltype(_impl_.php_metadata_namespace_) {}
+
+ , decltype(_impl_.ruby_package_) {}
+
+ , decltype(_impl_.java_multiple_files_) {}
+
+ , decltype(_impl_.java_generate_equals_and_hash_) {}
+
+ , decltype(_impl_.java_string_check_utf8_) {}
+
+ , decltype(_impl_.cc_generic_services_) {}
+
+ , decltype(_impl_.java_generic_services_) {}
+
+ , decltype(_impl_.py_generic_services_) {}
+
+ , decltype(_impl_.php_generic_services_) {}
+
+ , decltype(_impl_.deprecated_) {}
+
+ , decltype(_impl_.optimize_for_) {}
+
+ , decltype(_impl_.cc_enable_arenas_) {}
+ };
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_);
_impl_.java_package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.java_package_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_java_package()) {
- _this->_impl_.java_package_.Set(from._internal_java_package(),
- _this->GetArenaForAllocation());
+ _impl_.java_package_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
+ _this->_impl_.java_package_.Set(from._internal_java_package(), _this->GetArenaForAllocation());
}
_impl_.java_outer_classname_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.java_outer_classname_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_java_outer_classname()) {
- _this->_impl_.java_outer_classname_.Set(from._internal_java_outer_classname(),
- _this->GetArenaForAllocation());
+ _impl_.java_outer_classname_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000002u) != 0) {
+ _this->_impl_.java_outer_classname_.Set(from._internal_java_outer_classname(), _this->GetArenaForAllocation());
}
_impl_.go_package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.go_package_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_go_package()) {
- _this->_impl_.go_package_.Set(from._internal_go_package(),
- _this->GetArenaForAllocation());
+ _impl_.go_package_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000004u) != 0) {
+ _this->_impl_.go_package_.Set(from._internal_go_package(), _this->GetArenaForAllocation());
}
_impl_.objc_class_prefix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.objc_class_prefix_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_objc_class_prefix()) {
- _this->_impl_.objc_class_prefix_.Set(from._internal_objc_class_prefix(),
- _this->GetArenaForAllocation());
+ _impl_.objc_class_prefix_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000008u) != 0) {
+ _this->_impl_.objc_class_prefix_.Set(from._internal_objc_class_prefix(), _this->GetArenaForAllocation());
}
_impl_.csharp_namespace_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.csharp_namespace_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_csharp_namespace()) {
- _this->_impl_.csharp_namespace_.Set(from._internal_csharp_namespace(),
- _this->GetArenaForAllocation());
+ _impl_.csharp_namespace_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000010u) != 0) {
+ _this->_impl_.csharp_namespace_.Set(from._internal_csharp_namespace(), _this->GetArenaForAllocation());
}
_impl_.swift_prefix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.swift_prefix_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_swift_prefix()) {
- _this->_impl_.swift_prefix_.Set(from._internal_swift_prefix(),
- _this->GetArenaForAllocation());
+ _impl_.swift_prefix_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000020u) != 0) {
+ _this->_impl_.swift_prefix_.Set(from._internal_swift_prefix(), _this->GetArenaForAllocation());
}
_impl_.php_class_prefix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.php_class_prefix_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_php_class_prefix()) {
- _this->_impl_.php_class_prefix_.Set(from._internal_php_class_prefix(),
- _this->GetArenaForAllocation());
+ _impl_.php_class_prefix_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000040u) != 0) {
+ _this->_impl_.php_class_prefix_.Set(from._internal_php_class_prefix(), _this->GetArenaForAllocation());
}
_impl_.php_namespace_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.php_namespace_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_php_namespace()) {
- _this->_impl_.php_namespace_.Set(from._internal_php_namespace(),
- _this->GetArenaForAllocation());
+ _impl_.php_namespace_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000080u) != 0) {
+ _this->_impl_.php_namespace_.Set(from._internal_php_namespace(), _this->GetArenaForAllocation());
}
_impl_.php_metadata_namespace_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.php_metadata_namespace_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_php_metadata_namespace()) {
- _this->_impl_.php_metadata_namespace_.Set(from._internal_php_metadata_namespace(),
- _this->GetArenaForAllocation());
+ _impl_.php_metadata_namespace_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000100u) != 0) {
+ _this->_impl_.php_metadata_namespace_.Set(from._internal_php_metadata_namespace(), _this->GetArenaForAllocation());
}
_impl_.ruby_package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.ruby_package_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_ruby_package()) {
- _this->_impl_.ruby_package_.Set(from._internal_ruby_package(),
- _this->GetArenaForAllocation());
+ _impl_.ruby_package_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000200u) != 0) {
+ _this->_impl_.ruby_package_.Set(from._internal_ruby_package(), _this->GetArenaForAllocation());
}
::memcpy(&_impl_.java_multiple_files_, &from._impl_.java_multiple_files_,
- static_cast<size_t>(reinterpret_cast<char*>(&_impl_.cc_enable_arenas_) -
+ static_cast<::size_t>(reinterpret_cast<char*>(&_impl_.cc_enable_arenas_) -
reinterpret_cast<char*>(&_impl_.java_multiple_files_)) + sizeof(_impl_.cc_enable_arenas_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.FileOptions)
}
-inline void FileOptions::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void FileOptions::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
/*decltype(_impl_._extensions_)*/{::_pbi::ArenaInitialized(), arena}
, decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.uninterpreted_option_){arena}
- , decltype(_impl_.java_package_){}
- , decltype(_impl_.java_outer_classname_){}
- , decltype(_impl_.go_package_){}
- , decltype(_impl_.objc_class_prefix_){}
- , decltype(_impl_.csharp_namespace_){}
- , decltype(_impl_.swift_prefix_){}
- , decltype(_impl_.php_class_prefix_){}
- , decltype(_impl_.php_namespace_){}
- , decltype(_impl_.php_metadata_namespace_){}
- , decltype(_impl_.ruby_package_){}
- , decltype(_impl_.java_multiple_files_){false}
- , decltype(_impl_.java_generate_equals_and_hash_){false}
- , decltype(_impl_.java_string_check_utf8_){false}
- , decltype(_impl_.cc_generic_services_){false}
- , decltype(_impl_.java_generic_services_){false}
- , decltype(_impl_.py_generic_services_){false}
- , decltype(_impl_.php_generic_services_){false}
- , decltype(_impl_.deprecated_){false}
- , decltype(_impl_.optimize_for_){1}
- , decltype(_impl_.cc_enable_arenas_){true}
+ , decltype(_impl_.java_package_) {}
+
+ , decltype(_impl_.java_outer_classname_) {}
+
+ , decltype(_impl_.go_package_) {}
+
+ , decltype(_impl_.objc_class_prefix_) {}
+
+ , decltype(_impl_.csharp_namespace_) {}
+
+ , decltype(_impl_.swift_prefix_) {}
+
+ , decltype(_impl_.php_class_prefix_) {}
+
+ , decltype(_impl_.php_namespace_) {}
+
+ , decltype(_impl_.php_metadata_namespace_) {}
+
+ , decltype(_impl_.ruby_package_) {}
+
+ , decltype(_impl_.java_multiple_files_) { false }
+
+ , decltype(_impl_.java_generate_equals_and_hash_) { false }
+
+ , decltype(_impl_.java_string_check_utf8_) { false }
+
+ , decltype(_impl_.cc_generic_services_) { false }
+
+ , decltype(_impl_.java_generic_services_) { false }
+
+ , decltype(_impl_.py_generic_services_) { false }
+
+ , decltype(_impl_.php_generic_services_) { false }
+
+ , decltype(_impl_.deprecated_) { false }
+
+ , decltype(_impl_.optimize_for_) { 1 }
+
+ , decltype(_impl_.cc_enable_arenas_) { true }
+
};
_impl_.java_package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.java_package_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.java_package_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.java_outer_classname_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.java_outer_classname_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.java_outer_classname_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.go_package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.go_package_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.go_package_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.objc_class_prefix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.objc_class_prefix_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.objc_class_prefix_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.csharp_namespace_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.csharp_namespace_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.csharp_namespace_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.swift_prefix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.swift_prefix_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.swift_prefix_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.php_class_prefix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.php_class_prefix_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.php_class_prefix_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.php_namespace_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.php_namespace_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.php_namespace_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.php_metadata_namespace_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.php_metadata_namespace_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.php_metadata_namespace_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.ruby_package_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.ruby_package_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.ruby_package_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
FileOptions::~FileOptions() {
@@ -6430,7 +6912,7 @@ FileOptions::~FileOptions() {
}
inline void FileOptions::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_._extensions_.~ExtensionSet();
_impl_.uninterpreted_option_.~RepeatedPtrField();
_impl_.java_package_.Destroy();
@@ -6451,7 +6933,7 @@ void FileOptions::SetCachedSize(int size) const {
void FileOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FileOptions)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -6493,12 +6975,12 @@ void FileOptions::Clear() {
}
}
if (cached_has_bits & 0x0000fc00u) {
- ::memset(&_impl_.java_multiple_files_, 0, static_cast<size_t>(
+ ::memset(&_impl_.java_multiple_files_, 0, static_cast<::size_t>(
reinterpret_cast<char*>(&_impl_.py_generic_services_) -
reinterpret_cast<char*>(&_impl_.java_multiple_files_)) + sizeof(_impl_.py_generic_services_));
}
if (cached_has_bits & 0x000f0000u) {
- ::memset(&_impl_.php_generic_services_, 0, static_cast<size_t>(
+ ::memset(&_impl_.php_generic_services_, 0, static_cast<::size_t>(
reinterpret_cast<char*>(&_impl_.deprecated_) -
reinterpret_cast<char*>(&_impl_.php_generic_services_)) + sizeof(_impl_.deprecated_));
_impl_.optimize_for_ = 1;
@@ -6512,226 +6994,246 @@ const char* FileOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* c
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 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)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_java_package();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.java_package");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string java_outer_classname = 8;
case 8:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 66)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 66)) {
auto str = _internal_mutable_java_outer_classname();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.java_outer_classname");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
case 9:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 72)) {
- arc_ui64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 72)) {
+ ::arc_ui32 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- if (PROTOBUF_PREDICT_TRUE(::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode_IsValid(val))) {
+ if (PROTOBUF_PREDICT_TRUE(::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode_IsValid(static_cast<int>(val)))) {
_internal_set_optimize_for(static_cast<::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode>(val));
} else {
::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(9, val, mutable_unknown_fields());
}
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional bool java_multiple_files = 10 [default = false];
case 10:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 80)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 80)) {
_Internal::set_has_java_multiple_files(&has_bits);
_impl_.java_multiple_files_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string go_package = 11;
case 11:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 90)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 90)) {
auto str = _internal_mutable_go_package();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.go_package");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional bool cc_generic_services = 16 [default = false];
case 16:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 128)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 128)) {
_Internal::set_has_cc_generic_services(&has_bits);
_impl_.cc_generic_services_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional bool java_generic_services = 17 [default = false];
case 17:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 136)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 136)) {
_Internal::set_has_java_generic_services(&has_bits);
_impl_.java_generic_services_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional bool py_generic_services = 18 [default = false];
case 18:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 144)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 144)) {
_Internal::set_has_py_generic_services(&has_bits);
_impl_.py_generic_services_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional bool java_generate_equals_and_hash = 20 [deprecated = true];
case 20:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 160)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 160)) {
_Internal::set_has_java_generate_equals_and_hash(&has_bits);
_impl_.java_generate_equals_and_hash_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional bool deprecated = 23 [default = false];
case 23:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 184)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 184)) {
_Internal::set_has_deprecated(&has_bits);
_impl_.deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional bool java_string_check_utf8 = 27 [default = false];
case 27:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 216)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 216)) {
_Internal::set_has_java_string_check_utf8(&has_bits);
_impl_.java_string_check_utf8_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional bool cc_enable_arenas = 31 [default = true];
case 31:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 248)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 248)) {
_Internal::set_has_cc_enable_arenas(&has_bits);
_impl_.cc_enable_arenas_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string objc_class_prefix = 36;
case 36:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 34)) {
auto str = _internal_mutable_objc_class_prefix();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.objc_class_prefix");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string csharp_namespace = 37;
case 37:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 42)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 42)) {
auto str = _internal_mutable_csharp_namespace();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.csharp_namespace");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string swift_prefix = 39;
case 39:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 58)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 58)) {
auto str = _internal_mutable_swift_prefix();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.swift_prefix");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string php_class_prefix = 40;
case 40:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 66)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 66)) {
auto str = _internal_mutable_php_class_prefix();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.php_class_prefix");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string php_namespace = 41;
case 41:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 74)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 74)) {
auto str = _internal_mutable_php_namespace();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.php_namespace");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional bool php_generic_services = 42 [default = false];
case 42:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 80)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 80)) {
_Internal::set_has_php_generic_services(&has_bits);
_impl_.php_generic_services_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string php_metadata_namespace = 44;
case 44:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 98)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 98)) {
auto str = _internal_mutable_php_metadata_namespace();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.php_metadata_namespace");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string ruby_package = 45;
case 45:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 106)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 106)) {
auto str = _internal_mutable_ruby_package();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.ruby_package");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 58)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 58)) {
ptr -= 2;
do {
ptr += 2;
@@ -6739,8 +7241,9 @@ const char* FileOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* c
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<7994>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -6771,172 +7274,161 @@ failure:
#undef CHK_
}
-uint8_t* FileOptions::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* FileOptions::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FileOptions)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
// optional string java_package = 1;
if (cached_has_bits & 0x00000001u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_java_package().data(), static_cast<int>(this->_internal_java_package().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.FileOptions.java_package");
- target = stream->WriteStringMaybeAliased(
- 1, this->_internal_java_package(), target);
+ const TProtoStringType& _s = this->_internal_java_package();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FileOptions.java_package");
+ target = stream->WriteStringMaybeAliased(1, _s, target);
}
// optional string java_outer_classname = 8;
if (cached_has_bits & 0x00000002u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_java_outer_classname().data(), static_cast<int>(this->_internal_java_outer_classname().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.FileOptions.java_outer_classname");
- target = stream->WriteStringMaybeAliased(
- 8, this->_internal_java_outer_classname(), target);
+ const TProtoStringType& _s = this->_internal_java_outer_classname();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FileOptions.java_outer_classname");
+ target = stream->WriteStringMaybeAliased(8, _s, target);
}
// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
if (cached_has_bits & 0x00040000u) {
target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::WriteEnumToArray(
- 9, this->_internal_optimize_for(), target);
+ 9, this->_internal_optimize_for(), target);
}
// optional bool java_multiple_files = 10 [default = false];
if (cached_has_bits & 0x00000400u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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;
if (cached_has_bits & 0x00000004u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_go_package().data(), static_cast<int>(this->_internal_go_package().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.FileOptions.go_package");
- target = stream->WriteStringMaybeAliased(
- 11, this->_internal_go_package(), target);
+ const TProtoStringType& _s = this->_internal_go_package();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FileOptions.go_package");
+ target = stream->WriteStringMaybeAliased(11, _s, target);
}
// optional bool cc_generic_services = 16 [default = false];
if (cached_has_bits & 0x00002000u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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 = ::_pbi::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 = ::_pbi::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 = ::_pbi::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 = ::_pbi::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 = ::_pbi::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 = ::_pbi::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;
if (cached_has_bits & 0x00000008u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_objc_class_prefix().data(), static_cast<int>(this->_internal_objc_class_prefix().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.FileOptions.objc_class_prefix");
- target = stream->WriteStringMaybeAliased(
- 36, this->_internal_objc_class_prefix(), target);
+ const TProtoStringType& _s = this->_internal_objc_class_prefix();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FileOptions.objc_class_prefix");
+ target = stream->WriteStringMaybeAliased(36, _s, target);
}
// optional string csharp_namespace = 37;
if (cached_has_bits & 0x00000010u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_csharp_namespace().data(), static_cast<int>(this->_internal_csharp_namespace().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.FileOptions.csharp_namespace");
- target = stream->WriteStringMaybeAliased(
- 37, this->_internal_csharp_namespace(), target);
+ const TProtoStringType& _s = this->_internal_csharp_namespace();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FileOptions.csharp_namespace");
+ target = stream->WriteStringMaybeAliased(37, _s, target);
}
// optional string swift_prefix = 39;
if (cached_has_bits & 0x00000020u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_swift_prefix().data(), static_cast<int>(this->_internal_swift_prefix().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.FileOptions.swift_prefix");
- target = stream->WriteStringMaybeAliased(
- 39, this->_internal_swift_prefix(), target);
+ const TProtoStringType& _s = this->_internal_swift_prefix();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FileOptions.swift_prefix");
+ target = stream->WriteStringMaybeAliased(39, _s, target);
}
// optional string php_class_prefix = 40;
if (cached_has_bits & 0x00000040u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_php_class_prefix().data(), static_cast<int>(this->_internal_php_class_prefix().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.FileOptions.php_class_prefix");
- target = stream->WriteStringMaybeAliased(
- 40, this->_internal_php_class_prefix(), target);
+ const TProtoStringType& _s = this->_internal_php_class_prefix();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FileOptions.php_class_prefix");
+ target = stream->WriteStringMaybeAliased(40, _s, target);
}
// optional string php_namespace = 41;
if (cached_has_bits & 0x00000080u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_php_namespace().data(), static_cast<int>(this->_internal_php_namespace().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.FileOptions.php_namespace");
- target = stream->WriteStringMaybeAliased(
- 41, this->_internal_php_namespace(), target);
+ const TProtoStringType& _s = this->_internal_php_namespace();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FileOptions.php_namespace");
+ target = stream->WriteStringMaybeAliased(41, _s, target);
}
// optional bool php_generic_services = 42 [default = false];
if (cached_has_bits & 0x00010000u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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;
if (cached_has_bits & 0x00000100u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_php_metadata_namespace().data(), static_cast<int>(this->_internal_php_metadata_namespace().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.FileOptions.php_metadata_namespace");
- target = stream->WriteStringMaybeAliased(
- 44, this->_internal_php_metadata_namespace(), target);
+ const TProtoStringType& _s = this->_internal_php_metadata_namespace();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FileOptions.php_metadata_namespace");
+ target = stream->WriteStringMaybeAliased(44, _s, target);
}
// optional string ruby_package = 45;
if (cached_has_bits & 0x00000200u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_ruby_package().data(), static_cast<int>(this->_internal_ruby_package().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.FileOptions.ruby_package");
- target = stream->WriteStringMaybeAliased(
- 45, this->_internal_ruby_package(), target);
+ const TProtoStringType& _s = this->_internal_ruby_package();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FileOptions.ruby_package");
+ target = stream->WriteStringMaybeAliased(45, _s, target);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
@@ -6959,13 +7451,13 @@ uint8_t* FileOptions::_InternalSerialize(
return target;
}
-size_t FileOptions::ByteSizeLong() const {
+::size_t FileOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileOptions)
- size_t total_size = 0;
+ ::size_t total_size = 0;
total_size += _impl_._extensions_.ByteSize();
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -6980,127 +7472,117 @@ size_t FileOptions::ByteSizeLong() const {
if (cached_has_bits & 0x000000ffu) {
// optional string java_package = 1;
if (cached_has_bits & 0x00000001u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_java_package());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_java_package());
}
// optional string java_outer_classname = 8;
if (cached_has_bits & 0x00000002u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_java_outer_classname());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_java_outer_classname());
}
// optional string go_package = 11;
if (cached_has_bits & 0x00000004u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_go_package());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_go_package());
}
// optional string objc_class_prefix = 36;
if (cached_has_bits & 0x00000008u) {
- total_size += 2 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_objc_class_prefix());
+ total_size += 2 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_objc_class_prefix());
}
// optional string csharp_namespace = 37;
if (cached_has_bits & 0x00000010u) {
- total_size += 2 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_csharp_namespace());
+ total_size += 2 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_csharp_namespace());
}
// optional string swift_prefix = 39;
if (cached_has_bits & 0x00000020u) {
- total_size += 2 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_swift_prefix());
+ total_size += 2 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_swift_prefix());
}
// optional string php_class_prefix = 40;
if (cached_has_bits & 0x00000040u) {
- total_size += 2 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_php_class_prefix());
+ total_size += 2 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_php_class_prefix());
}
// optional string php_namespace = 41;
if (cached_has_bits & 0x00000080u) {
- total_size += 2 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_php_namespace());
+ total_size += 2 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_php_namespace());
}
}
if (cached_has_bits & 0x0000ff00u) {
// optional string php_metadata_namespace = 44;
if (cached_has_bits & 0x00000100u) {
- total_size += 2 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_php_metadata_namespace());
+ total_size += 2 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_php_metadata_namespace());
}
// optional string ruby_package = 45;
if (cached_has_bits & 0x00000200u) {
- total_size += 2 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_ruby_package());
+ total_size += 2 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_ruby_package());
}
// optional bool java_multiple_files = 10 [default = false];
if (cached_has_bits & 0x00000400u) {
- total_size += 1 + 1;
+ total_size += 2;
}
// optional bool java_generate_equals_and_hash = 20 [deprecated = true];
if (cached_has_bits & 0x00000800u) {
- total_size += 2 + 1;
+ total_size += 3;
}
// optional bool java_string_check_utf8 = 27 [default = false];
if (cached_has_bits & 0x00001000u) {
- total_size += 2 + 1;
+ total_size += 3;
}
// optional bool cc_generic_services = 16 [default = false];
if (cached_has_bits & 0x00002000u) {
- total_size += 2 + 1;
+ total_size += 3;
}
// optional bool java_generic_services = 17 [default = false];
if (cached_has_bits & 0x00004000u) {
- total_size += 2 + 1;
+ total_size += 3;
}
// optional bool py_generic_services = 18 [default = false];
if (cached_has_bits & 0x00008000u) {
- total_size += 2 + 1;
+ total_size += 3;
}
}
if (cached_has_bits & 0x000f0000u) {
// optional bool php_generic_services = 42 [default = false];
if (cached_has_bits & 0x00010000u) {
- total_size += 2 + 1;
+ total_size += 3;
}
// optional bool deprecated = 23 [default = false];
if (cached_has_bits & 0x00020000u) {
- total_size += 2 + 1;
+ total_size += 3;
}
// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
if (cached_has_bits & 0x00040000u) {
total_size += 1 +
- ::_pbi::WireFormatLite::EnumSize(this->_internal_optimize_for());
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_optimize_for());
}
// optional bool cc_enable_arenas = 31 [default = true];
if (cached_has_bits & 0x00080000u) {
- total_size += 2 + 1;
+ total_size += 3;
}
}
@@ -7118,8 +7600,8 @@ void FileOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PR
auto* const _this = static_cast<FileOptions*>(&to_msg);
auto& from = static_cast<const FileOptions&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileOptions)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.uninterpreted_option_.MergeFrom(from._impl_.uninterpreted_option_);
@@ -7204,7 +7686,7 @@ void FileOptions::CopyFrom(const FileOptions& from) {
}
bool FileOptions::IsInitialized() const {
- if (!_impl_._extensions_.IsInitialized()) {
+ if (!_impl_._extensions_.IsInitialized(internal_default_instance())) {
return false;
}
@@ -7221,54 +7703,32 @@ void FileOptions::InternalSwap(FileOptions* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
_impl_.uninterpreted_option_.InternalSwap(&other->_impl_.uninterpreted_option_);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.java_package_, lhs_arena,
- &other->_impl_.java_package_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.java_outer_classname_, lhs_arena,
- &other->_impl_.java_outer_classname_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.go_package_, lhs_arena,
- &other->_impl_.go_package_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.objc_class_prefix_, lhs_arena,
- &other->_impl_.objc_class_prefix_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.csharp_namespace_, lhs_arena,
- &other->_impl_.csharp_namespace_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.swift_prefix_, lhs_arena,
- &other->_impl_.swift_prefix_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.php_class_prefix_, lhs_arena,
- &other->_impl_.php_class_prefix_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.php_namespace_, lhs_arena,
- &other->_impl_.php_namespace_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.php_metadata_namespace_, lhs_arena,
- &other->_impl_.php_metadata_namespace_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.ruby_package_, lhs_arena,
- &other->_impl_.ruby_package_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.java_package_, lhs_arena,
+ &other->_impl_.java_package_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.java_outer_classname_, lhs_arena,
+ &other->_impl_.java_outer_classname_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.go_package_, lhs_arena,
+ &other->_impl_.go_package_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.objc_class_prefix_, lhs_arena,
+ &other->_impl_.objc_class_prefix_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.csharp_namespace_, lhs_arena,
+ &other->_impl_.csharp_namespace_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.swift_prefix_, lhs_arena,
+ &other->_impl_.swift_prefix_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.php_class_prefix_, lhs_arena,
+ &other->_impl_.php_class_prefix_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.php_namespace_, lhs_arena,
+ &other->_impl_.php_namespace_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.php_metadata_namespace_, lhs_arena,
+ &other->_impl_.php_metadata_namespace_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.ruby_package_, lhs_arena,
+ &other->_impl_.ruby_package_, rhs_arena);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
- PROTOBUF_FIELD_OFFSET(FileOptions, _impl_.deprecated_)
- + sizeof(FileOptions::_impl_.deprecated_)
+ PROTOBUF_FIELD_OFFSET(FileOptions, _impl_.cc_enable_arenas_)
+ + sizeof(FileOptions::_impl_.cc_enable_arenas_)
- PROTOBUF_FIELD_OFFSET(FileOptions, _impl_.java_multiple_files_)>(
reinterpret_cast<char*>(&_impl_.java_multiple_files_),
reinterpret_cast<char*>(&other->_impl_.java_multiple_files_));
- swap(_impl_.optimize_for_, other->_impl_.optimize_for_);
- swap(_impl_.cc_enable_arenas_, other->_impl_.cc_enable_arenas_);
}
::PROTOBUF_NAMESPACE_ID::Metadata FileOptions::GetMetadata() const {
@@ -7276,12 +7736,13 @@ void FileOptions::InternalSwap(FileOptions* other) {
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[13]);
}
-
// ===================================================================
class MessageOptions::_Internal {
public:
using HasBits = decltype(std::declval<MessageOptions>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(MessageOptions, _impl_._has_bits_);
static void set_has_message_set_wire_format(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -7294,12 +7755,14 @@ class MessageOptions::_Internal {
static void set_has_map_entry(HasBits* has_bits) {
(*has_bits)[0] |= 8u;
}
+ static void set_has_deprecated_legacy_json_field_conflicts(HasBits* has_bits) {
+ (*has_bits)[0] |= 16u;
+ }
};
-MessageOptions::MessageOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+MessageOptions::MessageOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.MessageOptions)
}
MessageOptions::MessageOptions(const MessageOptions& from)
@@ -7310,32 +7773,42 @@ MessageOptions::MessageOptions(const MessageOptions& from)
, decltype(_impl_._has_bits_){from._impl_._has_bits_}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.uninterpreted_option_){from._impl_.uninterpreted_option_}
- , decltype(_impl_.message_set_wire_format_){}
- , decltype(_impl_.no_standard_descriptor_accessor_){}
- , decltype(_impl_.deprecated_){}
- , decltype(_impl_.map_entry_){}};
+ , decltype(_impl_.message_set_wire_format_) {}
+
+ , decltype(_impl_.no_standard_descriptor_accessor_) {}
+
+ , decltype(_impl_.deprecated_) {}
+
+ , decltype(_impl_.map_entry_) {}
+
+ , decltype(_impl_.deprecated_legacy_json_field_conflicts_) {}
+ };
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_);
::memcpy(&_impl_.message_set_wire_format_, &from._impl_.message_set_wire_format_,
- static_cast<size_t>(reinterpret_cast<char*>(&_impl_.map_entry_) -
- reinterpret_cast<char*>(&_impl_.message_set_wire_format_)) + sizeof(_impl_.map_entry_));
+ static_cast<::size_t>(reinterpret_cast<char*>(&_impl_.deprecated_legacy_json_field_conflicts_) -
+ reinterpret_cast<char*>(&_impl_.message_set_wire_format_)) + sizeof(_impl_.deprecated_legacy_json_field_conflicts_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.MessageOptions)
}
-inline void MessageOptions::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void MessageOptions::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
/*decltype(_impl_._extensions_)*/{::_pbi::ArenaInitialized(), arena}
, decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.uninterpreted_option_){arena}
- , decltype(_impl_.message_set_wire_format_){false}
- , decltype(_impl_.no_standard_descriptor_accessor_){false}
- , decltype(_impl_.deprecated_){false}
- , decltype(_impl_.map_entry_){false}
+ , decltype(_impl_.message_set_wire_format_) { false }
+
+ , decltype(_impl_.no_standard_descriptor_accessor_) { false }
+
+ , decltype(_impl_.deprecated_) { false }
+
+ , decltype(_impl_.map_entry_) { false }
+
+ , decltype(_impl_.deprecated_legacy_json_field_conflicts_) { false }
+
};
}
@@ -7349,7 +7822,7 @@ MessageOptions::~MessageOptions() {
}
inline void MessageOptions::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_._extensions_.~ExtensionSet();
_impl_.uninterpreted_option_.~RepeatedPtrField();
}
@@ -7360,15 +7833,18 @@ void MessageOptions::SetCachedSize(int size) const {
void MessageOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.MessageOptions)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
_impl_._extensions_.Clear();
_impl_.uninterpreted_option_.Clear();
- ::memset(&_impl_.message_set_wire_format_, 0, static_cast<size_t>(
- reinterpret_cast<char*>(&_impl_.map_entry_) -
- reinterpret_cast<char*>(&_impl_.message_set_wire_format_)) + sizeof(_impl_.map_entry_));
+ cached_has_bits = _impl_._has_bits_[0];
+ if (cached_has_bits & 0x0000001fu) {
+ ::memset(&_impl_.message_set_wire_format_, 0, static_cast<::size_t>(
+ reinterpret_cast<char*>(&_impl_.deprecated_legacy_json_field_conflicts_) -
+ reinterpret_cast<char*>(&_impl_.message_set_wire_format_)) + sizeof(_impl_.deprecated_legacy_json_field_conflicts_));
+ }
_impl_._has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
@@ -7377,48 +7853,62 @@ const char* MessageOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional bool message_set_wire_format = 1 [default = false];
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) {
_Internal::set_has_message_set_wire_format(&has_bits);
_impl_.message_set_wire_format_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional bool no_standard_descriptor_accessor = 2 [default = false];
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 16)) {
_Internal::set_has_no_standard_descriptor_accessor(&has_bits);
_impl_.no_standard_descriptor_accessor_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional bool deprecated = 3 [default = false];
case 3:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 24)) {
_Internal::set_has_deprecated(&has_bits);
_impl_.deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional bool map_entry = 7;
case 7:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 56)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 56)) {
_Internal::set_has_map_entry(&has_bits);
_impl_.map_entry_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
+ continue;
+ // optional bool deprecated_legacy_json_field_conflicts = 11 [deprecated = true];
+ case 11:
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 88)) {
+ _Internal::set_has_deprecated_legacy_json_field_conflicts(&has_bits);
+ _impl_.deprecated_legacy_json_field_conflicts_ = ::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)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 58)) {
ptr -= 2;
do {
ptr += 2;
@@ -7426,8 +7916,9 @@ const char* MessageOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<7994>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -7458,35 +7949,46 @@ failure:
#undef CHK_
}
-uint8_t* MessageOptions::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* MessageOptions::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.MessageOptions)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
// optional bool message_set_wire_format = 1 [default = false];
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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 = ::_pbi::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 = ::_pbi::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 = ::_pbi::WireFormatLite::WriteBoolToArray(7, this->_internal_map_entry(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(
+ 7, this->_internal_map_entry(), target);
+ }
+
+ // optional bool deprecated_legacy_json_field_conflicts = 11 [deprecated = true];
+ if (cached_has_bits & 0x00000010u) {
+ target = stream->EnsureSpace(target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(
+ 11, this->_internal_deprecated_legacy_json_field_conflicts(), target);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
@@ -7509,13 +8011,13 @@ uint8_t* MessageOptions::_InternalSerialize(
return target;
}
-size_t MessageOptions::ByteSizeLong() const {
+::size_t MessageOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.MessageOptions)
- size_t total_size = 0;
+ ::size_t total_size = 0;
total_size += _impl_._extensions_.ByteSize();
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -7527,25 +8029,30 @@ size_t MessageOptions::ByteSizeLong() const {
}
cached_has_bits = _impl_._has_bits_[0];
- if (cached_has_bits & 0x0000000fu) {
+ if (cached_has_bits & 0x0000001fu) {
// optional bool message_set_wire_format = 1 [default = false];
if (cached_has_bits & 0x00000001u) {
- total_size += 1 + 1;
+ total_size += 2;
}
// optional bool no_standard_descriptor_accessor = 2 [default = false];
if (cached_has_bits & 0x00000002u) {
- total_size += 1 + 1;
+ total_size += 2;
}
// optional bool deprecated = 3 [default = false];
if (cached_has_bits & 0x00000004u) {
- total_size += 1 + 1;
+ total_size += 2;
}
// optional bool map_entry = 7;
if (cached_has_bits & 0x00000008u) {
- total_size += 1 + 1;
+ total_size += 2;
+ }
+
+ // optional bool deprecated_legacy_json_field_conflicts = 11 [deprecated = true];
+ if (cached_has_bits & 0x00000010u) {
+ total_size += 2;
}
}
@@ -7563,13 +8070,13 @@ void MessageOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const :
auto* const _this = static_cast<MessageOptions*>(&to_msg);
auto& from = static_cast<const MessageOptions&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MessageOptions)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.uninterpreted_option_.MergeFrom(from._impl_.uninterpreted_option_);
cached_has_bits = from._impl_._has_bits_[0];
- if (cached_has_bits & 0x0000000fu) {
+ if (cached_has_bits & 0x0000001fu) {
if (cached_has_bits & 0x00000001u) {
_this->_impl_.message_set_wire_format_ = from._impl_.message_set_wire_format_;
}
@@ -7582,6 +8089,9 @@ void MessageOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const :
if (cached_has_bits & 0x00000008u) {
_this->_impl_.map_entry_ = from._impl_.map_entry_;
}
+ if (cached_has_bits & 0x00000010u) {
+ _this->_impl_.deprecated_legacy_json_field_conflicts_ = from._impl_.deprecated_legacy_json_field_conflicts_;
+ }
_this->_impl_._has_bits_[0] |= cached_has_bits;
}
_this->_impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_);
@@ -7596,7 +8106,7 @@ void MessageOptions::CopyFrom(const MessageOptions& from) {
}
bool MessageOptions::IsInitialized() const {
- if (!_impl_._extensions_.IsInitialized()) {
+ if (!_impl_._extensions_.IsInitialized(internal_default_instance())) {
return false;
}
@@ -7612,8 +8122,8 @@ void MessageOptions::InternalSwap(MessageOptions* other) {
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
_impl_.uninterpreted_option_.InternalSwap(&other->_impl_.uninterpreted_option_);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
- PROTOBUF_FIELD_OFFSET(MessageOptions, _impl_.map_entry_)
- + sizeof(MessageOptions::_impl_.map_entry_)
+ PROTOBUF_FIELD_OFFSET(MessageOptions, _impl_.deprecated_legacy_json_field_conflicts_)
+ + sizeof(MessageOptions::_impl_.deprecated_legacy_json_field_conflicts_)
- PROTOBUF_FIELD_OFFSET(MessageOptions, _impl_.message_set_wire_format_)>(
reinterpret_cast<char*>(&_impl_.message_set_wire_format_),
reinterpret_cast<char*>(&other->_impl_.message_set_wire_format_));
@@ -7624,12 +8134,13 @@ void MessageOptions::InternalSwap(MessageOptions* other) {
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[14]);
}
-
// ===================================================================
class FieldOptions::_Internal {
public:
using HasBits = decltype(std::declval<FieldOptions>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(FieldOptions, _impl_._has_bits_);
static void set_has_ctype(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -7651,12 +8162,20 @@ class FieldOptions::_Internal {
static void set_has_weak(HasBits* has_bits) {
(*has_bits)[0] |= 64u;
}
+ static void set_has_debug_redact(HasBits* has_bits) {
+ (*has_bits)[0] |= 128u;
+ }
+ static void set_has_retention(HasBits* has_bits) {
+ (*has_bits)[0] |= 256u;
+ }
+ static void set_has_target(HasBits* has_bits) {
+ (*has_bits)[0] |= 512u;
+ }
};
-FieldOptions::FieldOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+FieldOptions::FieldOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.FieldOptions)
}
FieldOptions::FieldOptions(const FieldOptions& from)
@@ -7667,38 +8186,62 @@ FieldOptions::FieldOptions(const FieldOptions& from)
, decltype(_impl_._has_bits_){from._impl_._has_bits_}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.uninterpreted_option_){from._impl_.uninterpreted_option_}
- , decltype(_impl_.ctype_){}
- , decltype(_impl_.jstype_){}
- , decltype(_impl_.packed_){}
- , decltype(_impl_.lazy_){}
- , decltype(_impl_.unverified_lazy_){}
- , decltype(_impl_.deprecated_){}
- , decltype(_impl_.weak_){}};
+ , decltype(_impl_.ctype_) {}
+
+ , decltype(_impl_.jstype_) {}
+
+ , decltype(_impl_.packed_) {}
+
+ , decltype(_impl_.lazy_) {}
+
+ , decltype(_impl_.unverified_lazy_) {}
+
+ , decltype(_impl_.deprecated_) {}
+
+ , decltype(_impl_.weak_) {}
+
+ , decltype(_impl_.debug_redact_) {}
+
+ , decltype(_impl_.retention_) {}
+
+ , decltype(_impl_.target_) {}
+ };
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_);
::memcpy(&_impl_.ctype_, &from._impl_.ctype_,
- static_cast<size_t>(reinterpret_cast<char*>(&_impl_.weak_) -
- reinterpret_cast<char*>(&_impl_.ctype_)) + sizeof(_impl_.weak_));
+ static_cast<::size_t>(reinterpret_cast<char*>(&_impl_.target_) -
+ reinterpret_cast<char*>(&_impl_.ctype_)) + sizeof(_impl_.target_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.FieldOptions)
}
-inline void FieldOptions::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void FieldOptions::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
/*decltype(_impl_._extensions_)*/{::_pbi::ArenaInitialized(), arena}
, decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.uninterpreted_option_){arena}
- , decltype(_impl_.ctype_){0}
- , decltype(_impl_.jstype_){0}
- , decltype(_impl_.packed_){false}
- , decltype(_impl_.lazy_){false}
- , decltype(_impl_.unverified_lazy_){false}
- , decltype(_impl_.deprecated_){false}
- , decltype(_impl_.weak_){false}
+ , decltype(_impl_.ctype_) { 0 }
+
+ , decltype(_impl_.jstype_) { 0 }
+
+ , decltype(_impl_.packed_) { false }
+
+ , decltype(_impl_.lazy_) { false }
+
+ , decltype(_impl_.unverified_lazy_) { false }
+
+ , decltype(_impl_.deprecated_) { false }
+
+ , decltype(_impl_.weak_) { false }
+
+ , decltype(_impl_.debug_redact_) { false }
+
+ , decltype(_impl_.retention_) { 0 }
+
+ , decltype(_impl_.target_) { 0 }
+
};
}
@@ -7712,7 +8255,7 @@ FieldOptions::~FieldOptions() {
}
inline void FieldOptions::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_._extensions_.~ExtensionSet();
_impl_.uninterpreted_option_.~RepeatedPtrField();
}
@@ -7723,17 +8266,22 @@ void FieldOptions::SetCachedSize(int size) const {
void FieldOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FieldOptions)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
_impl_._extensions_.Clear();
_impl_.uninterpreted_option_.Clear();
cached_has_bits = _impl_._has_bits_[0];
- if (cached_has_bits & 0x0000007fu) {
- ::memset(&_impl_.ctype_, 0, static_cast<size_t>(
- reinterpret_cast<char*>(&_impl_.weak_) -
- reinterpret_cast<char*>(&_impl_.ctype_)) + sizeof(_impl_.weak_));
+ if (cached_has_bits & 0x000000ffu) {
+ ::memset(&_impl_.ctype_, 0, static_cast<::size_t>(
+ reinterpret_cast<char*>(&_impl_.debug_redact_) -
+ reinterpret_cast<char*>(&_impl_.ctype_)) + sizeof(_impl_.debug_redact_));
+ }
+ if (cached_has_bits & 0x00000300u) {
+ ::memset(&_impl_.retention_, 0, static_cast<::size_t>(
+ reinterpret_cast<char*>(&_impl_.target_) -
+ reinterpret_cast<char*>(&_impl_.retention_)) + sizeof(_impl_.target_));
}
_impl_._has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
@@ -7743,83 +8291,128 @@ const char* FieldOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext*
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
- arc_ui64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) {
+ ::arc_ui32 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- if (PROTOBUF_PREDICT_TRUE(::PROTOBUF_NAMESPACE_ID::FieldOptions_CType_IsValid(val))) {
+ if (PROTOBUF_PREDICT_TRUE(::PROTOBUF_NAMESPACE_ID::FieldOptions_CType_IsValid(static_cast<int>(val)))) {
_internal_set_ctype(static_cast<::PROTOBUF_NAMESPACE_ID::FieldOptions_CType>(val));
} else {
::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields());
}
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional bool packed = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 16)) {
_Internal::set_has_packed(&has_bits);
_impl_.packed_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional bool deprecated = 3 [default = false];
case 3:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 24)) {
_Internal::set_has_deprecated(&has_bits);
_impl_.deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional bool lazy = 5 [default = false];
case 5:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 40)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 40)) {
_Internal::set_has_lazy(&has_bits);
_impl_.lazy_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];
case 6:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 48)) {
- arc_ui64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 48)) {
+ ::arc_ui32 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- if (PROTOBUF_PREDICT_TRUE(::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType_IsValid(val))) {
+ if (PROTOBUF_PREDICT_TRUE(::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType_IsValid(static_cast<int>(val)))) {
_internal_set_jstype(static_cast<::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType>(val));
} else {
::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(6, val, mutable_unknown_fields());
}
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional bool weak = 10 [default = false];
case 10:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 80)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 80)) {
_Internal::set_has_weak(&has_bits);
_impl_.weak_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional bool unverified_lazy = 15 [default = false];
case 15:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 120)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 120)) {
_Internal::set_has_unverified_lazy(&has_bits);
_impl_.unverified_lazy_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
+ goto handle_unusual;
+ }
+ continue;
+ // optional bool debug_redact = 16 [default = false];
+ case 16:
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 128)) {
+ _Internal::set_has_debug_redact(&has_bits);
+ _impl_.debug_redact_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
+ CHK_(ptr);
+ } else {
goto handle_unusual;
+ }
+ continue;
+ // optional .google.protobuf.FieldOptions.OptionRetention retention = 17;
+ case 17:
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 136)) {
+ ::arc_ui32 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
+ CHK_(ptr);
+ if (PROTOBUF_PREDICT_TRUE(::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionRetention_IsValid(static_cast<int>(val)))) {
+ _internal_set_retention(static_cast<::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionRetention>(val));
+ } else {
+ ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(17, val, mutable_unknown_fields());
+ }
+ } else {
+ goto handle_unusual;
+ }
+ continue;
+ // optional .google.protobuf.FieldOptions.OptionTargetType target = 18;
+ case 18:
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 144)) {
+ ::arc_ui32 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
+ CHK_(ptr);
+ if (PROTOBUF_PREDICT_TRUE(::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionTargetType_IsValid(static_cast<int>(val)))) {
+ _internal_set_target(static_cast<::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionTargetType>(val));
+ } else {
+ ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(18, val, mutable_unknown_fields());
+ }
+ } else {
+ goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 58)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 58)) {
ptr -= 2;
do {
ptr += 2;
@@ -7827,8 +8420,9 @@ const char* FieldOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext*
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<7994>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -7859,10 +8453,10 @@ failure:
#undef CHK_
}
-uint8_t* FieldOptions::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* FieldOptions::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldOptions)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
@@ -7870,44 +8464,70 @@ uint8_t* FieldOptions::_InternalSerialize(
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::WriteEnumToArray(
- 1, this->_internal_ctype(), target);
+ 1, this->_internal_ctype(), target);
}
// optional bool packed = 2;
if (cached_has_bits & 0x00000004u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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 & 0x00000020u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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 & 0x00000008u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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 & 0x00000002u) {
target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::WriteEnumToArray(
- 6, this->_internal_jstype(), target);
+ 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);
+ 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 = ::_pbi::WireFormatLite::WriteBoolToArray(15, this->_internal_unverified_lazy(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(
+ 15, this->_internal_unverified_lazy(), target);
+ }
+
+ // optional bool debug_redact = 16 [default = false];
+ if (cached_has_bits & 0x00000080u) {
+ target = stream->EnsureSpace(target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(
+ 16, this->_internal_debug_redact(), target);
+ }
+
+ // optional .google.protobuf.FieldOptions.OptionRetention retention = 17;
+ if (cached_has_bits & 0x00000100u) {
+ target = stream->EnsureSpace(target);
+ target = ::_pbi::WireFormatLite::WriteEnumToArray(
+ 17, this->_internal_retention(), target);
+ }
+
+ // optional .google.protobuf.FieldOptions.OptionTargetType target = 18;
+ if (cached_has_bits & 0x00000200u) {
+ target = stream->EnsureSpace(target);
+ target = ::_pbi::WireFormatLite::WriteEnumToArray(
+ 18, this->_internal_target(), target);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
@@ -7930,13 +8550,13 @@ uint8_t* FieldOptions::_InternalSerialize(
return target;
}
-size_t FieldOptions::ByteSizeLong() const {
+::size_t FieldOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldOptions)
- size_t total_size = 0;
+ ::size_t total_size = 0;
total_size += _impl_._extensions_.ByteSize();
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -7948,42 +8568,61 @@ size_t FieldOptions::ByteSizeLong() const {
}
cached_has_bits = _impl_._has_bits_[0];
- if (cached_has_bits & 0x0000007fu) {
+ if (cached_has_bits & 0x000000ffu) {
// optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];
if (cached_has_bits & 0x00000001u) {
total_size += 1 +
- ::_pbi::WireFormatLite::EnumSize(this->_internal_ctype());
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_ctype());
}
// optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];
if (cached_has_bits & 0x00000002u) {
total_size += 1 +
- ::_pbi::WireFormatLite::EnumSize(this->_internal_jstype());
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_jstype());
}
// optional bool packed = 2;
if (cached_has_bits & 0x00000004u) {
- total_size += 1 + 1;
+ total_size += 2;
}
// optional bool lazy = 5 [default = false];
if (cached_has_bits & 0x00000008u) {
- total_size += 1 + 1;
+ total_size += 2;
}
// optional bool unverified_lazy = 15 [default = false];
if (cached_has_bits & 0x00000010u) {
- total_size += 1 + 1;
+ total_size += 2;
}
// optional bool deprecated = 3 [default = false];
if (cached_has_bits & 0x00000020u) {
- total_size += 1 + 1;
+ total_size += 2;
}
// optional bool weak = 10 [default = false];
if (cached_has_bits & 0x00000040u) {
- total_size += 1 + 1;
+ total_size += 2;
+ }
+
+ // optional bool debug_redact = 16 [default = false];
+ if (cached_has_bits & 0x00000080u) {
+ total_size += 3;
+ }
+
+ }
+ if (cached_has_bits & 0x00000300u) {
+ // optional .google.protobuf.FieldOptions.OptionRetention retention = 17;
+ if (cached_has_bits & 0x00000100u) {
+ total_size += 2 +
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_retention());
+ }
+
+ // optional .google.protobuf.FieldOptions.OptionTargetType target = 18;
+ if (cached_has_bits & 0x00000200u) {
+ total_size += 2 +
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_target());
}
}
@@ -8001,13 +8640,13 @@ void FieldOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::P
auto* const _this = static_cast<FieldOptions*>(&to_msg);
auto& from = static_cast<const FieldOptions&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldOptions)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.uninterpreted_option_.MergeFrom(from._impl_.uninterpreted_option_);
cached_has_bits = from._impl_._has_bits_[0];
- if (cached_has_bits & 0x0000007fu) {
+ if (cached_has_bits & 0x000000ffu) {
if (cached_has_bits & 0x00000001u) {
_this->_impl_.ctype_ = from._impl_.ctype_;
}
@@ -8029,6 +8668,18 @@ void FieldOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::P
if (cached_has_bits & 0x00000040u) {
_this->_impl_.weak_ = from._impl_.weak_;
}
+ if (cached_has_bits & 0x00000080u) {
+ _this->_impl_.debug_redact_ = from._impl_.debug_redact_;
+ }
+ _this->_impl_._has_bits_[0] |= cached_has_bits;
+ }
+ if (cached_has_bits & 0x00000300u) {
+ if (cached_has_bits & 0x00000100u) {
+ _this->_impl_.retention_ = from._impl_.retention_;
+ }
+ if (cached_has_bits & 0x00000200u) {
+ _this->_impl_.target_ = from._impl_.target_;
+ }
_this->_impl_._has_bits_[0] |= cached_has_bits;
}
_this->_impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_);
@@ -8043,7 +8694,7 @@ void FieldOptions::CopyFrom(const FieldOptions& from) {
}
bool FieldOptions::IsInitialized() const {
- if (!_impl_._extensions_.IsInitialized()) {
+ if (!_impl_._extensions_.IsInitialized(internal_default_instance())) {
return false;
}
@@ -8059,8 +8710,8 @@ void FieldOptions::InternalSwap(FieldOptions* other) {
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
_impl_.uninterpreted_option_.InternalSwap(&other->_impl_.uninterpreted_option_);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
- PROTOBUF_FIELD_OFFSET(FieldOptions, _impl_.weak_)
- + sizeof(FieldOptions::_impl_.weak_)
+ PROTOBUF_FIELD_OFFSET(FieldOptions, _impl_.target_)
+ + sizeof(FieldOptions::_impl_.target_)
- PROTOBUF_FIELD_OFFSET(FieldOptions, _impl_.ctype_)>(
reinterpret_cast<char*>(&_impl_.ctype_),
reinterpret_cast<char*>(&other->_impl_.ctype_));
@@ -8071,17 +8722,15 @@ void FieldOptions::InternalSwap(FieldOptions* other) {
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[15]);
}
-
// ===================================================================
class OneofOptions::_Internal {
public:
};
-OneofOptions::OneofOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+OneofOptions::OneofOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.OneofOptions)
}
OneofOptions::OneofOptions(const OneofOptions& from)
@@ -8097,10 +8746,8 @@ OneofOptions::OneofOptions(const OneofOptions& from)
// @@protoc_insertion_point(copy_constructor:google.protobuf.OneofOptions)
}
-inline void OneofOptions::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void OneofOptions::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
/*decltype(_impl_._extensions_)*/{::_pbi::ArenaInitialized(), arena}
, decltype(_impl_.uninterpreted_option_){arena}
@@ -8118,7 +8765,7 @@ OneofOptions::~OneofOptions() {
}
inline void OneofOptions::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_._extensions_.~ExtensionSet();
_impl_.uninterpreted_option_.~RepeatedPtrField();
}
@@ -8129,7 +8776,7 @@ void OneofOptions::SetCachedSize(int size) const {
void OneofOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.OneofOptions)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -8141,12 +8788,12 @@ void OneofOptions::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 58)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 58)) {
ptr -= 2;
do {
ptr += 2;
@@ -8154,8 +8801,9 @@ const char* OneofOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext*
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<7994>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -8185,10 +8833,10 @@ failure:
#undef CHK_
}
-uint8_t* OneofOptions::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* OneofOptions::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.OneofOptions)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
@@ -8211,13 +8859,13 @@ uint8_t* OneofOptions::_InternalSerialize(
return target;
}
-size_t OneofOptions::ByteSizeLong() const {
+::size_t OneofOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.OneofOptions)
- size_t total_size = 0;
+ ::size_t total_size = 0;
total_size += _impl_._extensions_.ByteSize();
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -8242,8 +8890,8 @@ void OneofOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::P
auto* const _this = static_cast<OneofOptions*>(&to_msg);
auto& from = static_cast<const OneofOptions&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofOptions)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.uninterpreted_option_.MergeFrom(from._impl_.uninterpreted_option_);
@@ -8259,7 +8907,7 @@ void OneofOptions::CopyFrom(const OneofOptions& from) {
}
bool OneofOptions::IsInitialized() const {
- if (!_impl_._extensions_.IsInitialized()) {
+ if (!_impl_._extensions_.IsInitialized(internal_default_instance())) {
return false;
}
@@ -8280,24 +8928,27 @@ void OneofOptions::InternalSwap(OneofOptions* other) {
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[16]);
}
-
// ===================================================================
class EnumOptions::_Internal {
public:
using HasBits = decltype(std::declval<EnumOptions>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(EnumOptions, _impl_._has_bits_);
static void set_has_allow_alias(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
static void set_has_deprecated(HasBits* has_bits) {
(*has_bits)[0] |= 2u;
}
+ static void set_has_deprecated_legacy_json_field_conflicts(HasBits* has_bits) {
+ (*has_bits)[0] |= 4u;
+ }
};
-EnumOptions::EnumOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+EnumOptions::EnumOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.EnumOptions)
}
EnumOptions::EnumOptions(const EnumOptions& from)
@@ -8308,28 +8959,34 @@ EnumOptions::EnumOptions(const EnumOptions& from)
, decltype(_impl_._has_bits_){from._impl_._has_bits_}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.uninterpreted_option_){from._impl_.uninterpreted_option_}
- , decltype(_impl_.allow_alias_){}
- , decltype(_impl_.deprecated_){}};
+ , decltype(_impl_.allow_alias_) {}
+
+ , decltype(_impl_.deprecated_) {}
+
+ , decltype(_impl_.deprecated_legacy_json_field_conflicts_) {}
+ };
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_);
::memcpy(&_impl_.allow_alias_, &from._impl_.allow_alias_,
- static_cast<size_t>(reinterpret_cast<char*>(&_impl_.deprecated_) -
- reinterpret_cast<char*>(&_impl_.allow_alias_)) + sizeof(_impl_.deprecated_));
+ static_cast<::size_t>(reinterpret_cast<char*>(&_impl_.deprecated_legacy_json_field_conflicts_) -
+ reinterpret_cast<char*>(&_impl_.allow_alias_)) + sizeof(_impl_.deprecated_legacy_json_field_conflicts_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.EnumOptions)
}
-inline void EnumOptions::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void EnumOptions::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
/*decltype(_impl_._extensions_)*/{::_pbi::ArenaInitialized(), arena}
, decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.uninterpreted_option_){arena}
- , decltype(_impl_.allow_alias_){false}
- , decltype(_impl_.deprecated_){false}
+ , decltype(_impl_.allow_alias_) { false }
+
+ , decltype(_impl_.deprecated_) { false }
+
+ , decltype(_impl_.deprecated_legacy_json_field_conflicts_) { false }
+
};
}
@@ -8343,7 +9000,7 @@ EnumOptions::~EnumOptions() {
}
inline void EnumOptions::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_._extensions_.~ExtensionSet();
_impl_.uninterpreted_option_.~RepeatedPtrField();
}
@@ -8354,15 +9011,15 @@ void EnumOptions::SetCachedSize(int size) const {
void EnumOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumOptions)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
_impl_._extensions_.Clear();
_impl_.uninterpreted_option_.Clear();
- ::memset(&_impl_.allow_alias_, 0, static_cast<size_t>(
- reinterpret_cast<char*>(&_impl_.deprecated_) -
- reinterpret_cast<char*>(&_impl_.allow_alias_)) + sizeof(_impl_.deprecated_));
+ ::memset(&_impl_.allow_alias_, 0, static_cast<::size_t>(
+ reinterpret_cast<char*>(&_impl_.deprecated_legacy_json_field_conflicts_) -
+ reinterpret_cast<char*>(&_impl_.allow_alias_)) + sizeof(_impl_.deprecated_legacy_json_field_conflicts_));
_impl_._has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
@@ -8371,30 +9028,42 @@ const char* EnumOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* c
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional bool allow_alias = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 16)) {
_Internal::set_has_allow_alias(&has_bits);
_impl_.allow_alias_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional bool deprecated = 3 [default = false];
case 3:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 24)) {
_Internal::set_has_deprecated(&has_bits);
_impl_.deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
+ goto handle_unusual;
+ }
+ continue;
+ // optional bool deprecated_legacy_json_field_conflicts = 6 [deprecated = true];
+ case 6:
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 48)) {
+ _Internal::set_has_deprecated_legacy_json_field_conflicts(&has_bits);
+ _impl_.deprecated_legacy_json_field_conflicts_ = ::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)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 58)) {
ptr -= 2;
do {
ptr += 2;
@@ -8402,8 +9071,9 @@ const char* EnumOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* c
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<7994>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -8434,23 +9104,32 @@ failure:
#undef CHK_
}
-uint8_t* EnumOptions::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* EnumOptions::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumOptions)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
// optional bool allow_alias = 2;
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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 = ::_pbi::WireFormatLite::WriteBoolToArray(3, this->_internal_deprecated(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(
+ 3, this->_internal_deprecated(), target);
+ }
+
+ // optional bool deprecated_legacy_json_field_conflicts = 6 [deprecated = true];
+ if (cached_has_bits & 0x00000004u) {
+ target = stream->EnsureSpace(target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(
+ 6, this->_internal_deprecated_legacy_json_field_conflicts(), target);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
@@ -8473,13 +9152,13 @@ uint8_t* EnumOptions::_InternalSerialize(
return target;
}
-size_t EnumOptions::ByteSizeLong() const {
+::size_t EnumOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumOptions)
- size_t total_size = 0;
+ ::size_t total_size = 0;
total_size += _impl_._extensions_.ByteSize();
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -8491,15 +9170,20 @@ size_t EnumOptions::ByteSizeLong() const {
}
cached_has_bits = _impl_._has_bits_[0];
- if (cached_has_bits & 0x00000003u) {
+ if (cached_has_bits & 0x00000007u) {
// optional bool allow_alias = 2;
if (cached_has_bits & 0x00000001u) {
- total_size += 1 + 1;
+ total_size += 2;
}
// optional bool deprecated = 3 [default = false];
if (cached_has_bits & 0x00000002u) {
- total_size += 1 + 1;
+ total_size += 2;
+ }
+
+ // optional bool deprecated_legacy_json_field_conflicts = 6 [deprecated = true];
+ if (cached_has_bits & 0x00000004u) {
+ total_size += 2;
}
}
@@ -8517,19 +9201,22 @@ void EnumOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PR
auto* const _this = static_cast<EnumOptions*>(&to_msg);
auto& from = static_cast<const EnumOptions&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumOptions)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.uninterpreted_option_.MergeFrom(from._impl_.uninterpreted_option_);
cached_has_bits = from._impl_._has_bits_[0];
- if (cached_has_bits & 0x00000003u) {
+ if (cached_has_bits & 0x00000007u) {
if (cached_has_bits & 0x00000001u) {
_this->_impl_.allow_alias_ = from._impl_.allow_alias_;
}
if (cached_has_bits & 0x00000002u) {
_this->_impl_.deprecated_ = from._impl_.deprecated_;
}
+ if (cached_has_bits & 0x00000004u) {
+ _this->_impl_.deprecated_legacy_json_field_conflicts_ = from._impl_.deprecated_legacy_json_field_conflicts_;
+ }
_this->_impl_._has_bits_[0] |= cached_has_bits;
}
_this->_impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_);
@@ -8544,7 +9231,7 @@ void EnumOptions::CopyFrom(const EnumOptions& from) {
}
bool EnumOptions::IsInitialized() const {
- if (!_impl_._extensions_.IsInitialized()) {
+ if (!_impl_._extensions_.IsInitialized(internal_default_instance())) {
return false;
}
@@ -8560,8 +9247,8 @@ void EnumOptions::InternalSwap(EnumOptions* other) {
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
_impl_.uninterpreted_option_.InternalSwap(&other->_impl_.uninterpreted_option_);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
- PROTOBUF_FIELD_OFFSET(EnumOptions, _impl_.deprecated_)
- + sizeof(EnumOptions::_impl_.deprecated_)
+ PROTOBUF_FIELD_OFFSET(EnumOptions, _impl_.deprecated_legacy_json_field_conflicts_)
+ + sizeof(EnumOptions::_impl_.deprecated_legacy_json_field_conflicts_)
- PROTOBUF_FIELD_OFFSET(EnumOptions, _impl_.allow_alias_)>(
reinterpret_cast<char*>(&_impl_.allow_alias_),
reinterpret_cast<char*>(&other->_impl_.allow_alias_));
@@ -8572,21 +9259,21 @@ void EnumOptions::InternalSwap(EnumOptions* other) {
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[17]);
}
-
// ===================================================================
class EnumValueOptions::_Internal {
public:
using HasBits = decltype(std::declval<EnumValueOptions>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(EnumValueOptions, _impl_._has_bits_);
static void set_has_deprecated(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
};
-EnumValueOptions::EnumValueOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+EnumValueOptions::EnumValueOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.EnumValueOptions)
}
EnumValueOptions::EnumValueOptions(const EnumValueOptions& from)
@@ -8597,7 +9284,8 @@ EnumValueOptions::EnumValueOptions(const EnumValueOptions& from)
, decltype(_impl_._has_bits_){from._impl_._has_bits_}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.uninterpreted_option_){from._impl_.uninterpreted_option_}
- , decltype(_impl_.deprecated_){}};
+ , decltype(_impl_.deprecated_) {}
+ };
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_);
@@ -8605,16 +9293,15 @@ EnumValueOptions::EnumValueOptions(const EnumValueOptions& from)
// @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValueOptions)
}
-inline void EnumValueOptions::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void EnumValueOptions::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
/*decltype(_impl_._extensions_)*/{::_pbi::ArenaInitialized(), arena}
, decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.uninterpreted_option_){arena}
- , decltype(_impl_.deprecated_){false}
+ , decltype(_impl_.deprecated_) { false }
+
};
}
@@ -8628,7 +9315,7 @@ EnumValueOptions::~EnumValueOptions() {
}
inline void EnumValueOptions::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_._extensions_.~ExtensionSet();
_impl_.uninterpreted_option_.~RepeatedPtrField();
}
@@ -8639,7 +9326,7 @@ void EnumValueOptions::SetCachedSize(int size) const {
void EnumValueOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValueOptions)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -8654,21 +9341,22 @@ const char* EnumValueOptions::_InternalParse(const char* ptr, ::_pbi::ParseConte
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional bool deprecated = 1 [default = false];
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) {
_Internal::set_has_deprecated(&has_bits);
_impl_.deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 58)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 58)) {
ptr -= 2;
do {
ptr += 2;
@@ -8676,8 +9364,9 @@ const char* EnumValueOptions::_InternalParse(const char* ptr, ::_pbi::ParseConte
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<7994>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -8708,17 +9397,18 @@ failure:
#undef CHK_
}
-uint8_t* EnumValueOptions::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* EnumValueOptions::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumValueOptions)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
// optional bool deprecated = 1 [default = false];
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::WireFormatLite::WriteBoolToArray(1, this->_internal_deprecated(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(
+ 1, this->_internal_deprecated(), target);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
@@ -8741,13 +9431,13 @@ uint8_t* EnumValueOptions::_InternalSerialize(
return target;
}
-size_t EnumValueOptions::ByteSizeLong() const {
+::size_t EnumValueOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValueOptions)
- size_t total_size = 0;
+ ::size_t total_size = 0;
total_size += _impl_._extensions_.ByteSize();
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -8761,7 +9451,7 @@ size_t EnumValueOptions::ByteSizeLong() const {
// optional bool deprecated = 1 [default = false];
cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x00000001u) {
- total_size += 1 + 1;
+ total_size += 2;
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -8778,12 +9468,12 @@ void EnumValueOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const
auto* const _this = static_cast<EnumValueOptions*>(&to_msg);
auto& from = static_cast<const EnumValueOptions&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueOptions)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.uninterpreted_option_.MergeFrom(from._impl_.uninterpreted_option_);
- if (from._internal_has_deprecated()) {
+ if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
_this->_internal_set_deprecated(from._internal_deprecated());
}
_this->_impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_);
@@ -8798,7 +9488,7 @@ void EnumValueOptions::CopyFrom(const EnumValueOptions& from) {
}
bool EnumValueOptions::IsInitialized() const {
- if (!_impl_._extensions_.IsInitialized()) {
+ if (!_impl_._extensions_.IsInitialized(internal_default_instance())) {
return false;
}
@@ -8813,6 +9503,7 @@ void EnumValueOptions::InternalSwap(EnumValueOptions* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
_impl_.uninterpreted_option_.InternalSwap(&other->_impl_.uninterpreted_option_);
+
swap(_impl_.deprecated_, other->_impl_.deprecated_);
}
@@ -8821,21 +9512,21 @@ void EnumValueOptions::InternalSwap(EnumValueOptions* other) {
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[18]);
}
-
// ===================================================================
class ServiceOptions::_Internal {
public:
using HasBits = decltype(std::declval<ServiceOptions>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(ServiceOptions, _impl_._has_bits_);
static void set_has_deprecated(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
};
-ServiceOptions::ServiceOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+ServiceOptions::ServiceOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.ServiceOptions)
}
ServiceOptions::ServiceOptions(const ServiceOptions& from)
@@ -8846,7 +9537,8 @@ ServiceOptions::ServiceOptions(const ServiceOptions& from)
, decltype(_impl_._has_bits_){from._impl_._has_bits_}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.uninterpreted_option_){from._impl_.uninterpreted_option_}
- , decltype(_impl_.deprecated_){}};
+ , decltype(_impl_.deprecated_) {}
+ };
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_);
@@ -8854,16 +9546,15 @@ ServiceOptions::ServiceOptions(const ServiceOptions& from)
// @@protoc_insertion_point(copy_constructor:google.protobuf.ServiceOptions)
}
-inline void ServiceOptions::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void ServiceOptions::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
/*decltype(_impl_._extensions_)*/{::_pbi::ArenaInitialized(), arena}
, decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.uninterpreted_option_){arena}
- , decltype(_impl_.deprecated_){false}
+ , decltype(_impl_.deprecated_) { false }
+
};
}
@@ -8877,7 +9568,7 @@ ServiceOptions::~ServiceOptions() {
}
inline void ServiceOptions::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_._extensions_.~ExtensionSet();
_impl_.uninterpreted_option_.~RepeatedPtrField();
}
@@ -8888,7 +9579,7 @@ void ServiceOptions::SetCachedSize(int size) const {
void ServiceOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.ServiceOptions)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -8903,21 +9594,22 @@ const char* ServiceOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional bool deprecated = 33 [default = false];
case 33:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) {
_Internal::set_has_deprecated(&has_bits);
_impl_.deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 58)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 58)) {
ptr -= 2;
do {
ptr += 2;
@@ -8925,8 +9617,9 @@ const char* ServiceOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<7994>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -8957,17 +9650,18 @@ failure:
#undef CHK_
}
-uint8_t* ServiceOptions::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* ServiceOptions::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.ServiceOptions)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
// optional bool deprecated = 33 [default = false];
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::WireFormatLite::WriteBoolToArray(33, this->_internal_deprecated(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(
+ 33, this->_internal_deprecated(), target);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
@@ -8990,13 +9684,13 @@ uint8_t* ServiceOptions::_InternalSerialize(
return target;
}
-size_t ServiceOptions::ByteSizeLong() const {
+::size_t ServiceOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.ServiceOptions)
- size_t total_size = 0;
+ ::size_t total_size = 0;
total_size += _impl_._extensions_.ByteSize();
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -9010,7 +9704,7 @@ size_t ServiceOptions::ByteSizeLong() const {
// optional bool deprecated = 33 [default = false];
cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x00000001u) {
- total_size += 2 + 1;
+ total_size += 3;
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -9027,12 +9721,12 @@ void ServiceOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const :
auto* const _this = static_cast<ServiceOptions*>(&to_msg);
auto& from = static_cast<const ServiceOptions&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceOptions)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.uninterpreted_option_.MergeFrom(from._impl_.uninterpreted_option_);
- if (from._internal_has_deprecated()) {
+ if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
_this->_internal_set_deprecated(from._internal_deprecated());
}
_this->_impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_);
@@ -9047,7 +9741,7 @@ void ServiceOptions::CopyFrom(const ServiceOptions& from) {
}
bool ServiceOptions::IsInitialized() const {
- if (!_impl_._extensions_.IsInitialized()) {
+ if (!_impl_._extensions_.IsInitialized(internal_default_instance())) {
return false;
}
@@ -9062,6 +9756,7 @@ void ServiceOptions::InternalSwap(ServiceOptions* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
_impl_.uninterpreted_option_.InternalSwap(&other->_impl_.uninterpreted_option_);
+
swap(_impl_.deprecated_, other->_impl_.deprecated_);
}
@@ -9070,12 +9765,13 @@ void ServiceOptions::InternalSwap(ServiceOptions* other) {
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[19]);
}
-
// ===================================================================
class MethodOptions::_Internal {
public:
using HasBits = decltype(std::declval<MethodOptions>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(MethodOptions, _impl_._has_bits_);
static void set_has_deprecated(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -9084,10 +9780,9 @@ class MethodOptions::_Internal {
}
};
-MethodOptions::MethodOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+MethodOptions::MethodOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.MethodOptions)
}
MethodOptions::MethodOptions(const MethodOptions& from)
@@ -9098,28 +9793,30 @@ MethodOptions::MethodOptions(const MethodOptions& from)
, decltype(_impl_._has_bits_){from._impl_._has_bits_}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.uninterpreted_option_){from._impl_.uninterpreted_option_}
- , decltype(_impl_.deprecated_){}
- , decltype(_impl_.idempotency_level_){}};
+ , decltype(_impl_.deprecated_) {}
+
+ , decltype(_impl_.idempotency_level_) {}
+ };
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_);
::memcpy(&_impl_.deprecated_, &from._impl_.deprecated_,
- static_cast<size_t>(reinterpret_cast<char*>(&_impl_.idempotency_level_) -
+ static_cast<::size_t>(reinterpret_cast<char*>(&_impl_.idempotency_level_) -
reinterpret_cast<char*>(&_impl_.deprecated_)) + sizeof(_impl_.idempotency_level_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.MethodOptions)
}
-inline void MethodOptions::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void MethodOptions::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
/*decltype(_impl_._extensions_)*/{::_pbi::ArenaInitialized(), arena}
, decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.uninterpreted_option_){arena}
- , decltype(_impl_.deprecated_){false}
- , decltype(_impl_.idempotency_level_){0}
+ , decltype(_impl_.deprecated_) { false }
+
+ , decltype(_impl_.idempotency_level_) { 0 }
+
};
}
@@ -9133,7 +9830,7 @@ MethodOptions::~MethodOptions() {
}
inline void MethodOptions::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_._extensions_.~ExtensionSet();
_impl_.uninterpreted_option_.~RepeatedPtrField();
}
@@ -9144,7 +9841,7 @@ void MethodOptions::SetCachedSize(int size) const {
void MethodOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.MethodOptions)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -9152,7 +9849,7 @@ void MethodOptions::Clear() {
_impl_.uninterpreted_option_.Clear();
cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x00000003u) {
- ::memset(&_impl_.deprecated_, 0, static_cast<size_t>(
+ ::memset(&_impl_.deprecated_, 0, static_cast<::size_t>(
reinterpret_cast<char*>(&_impl_.idempotency_level_) -
reinterpret_cast<char*>(&_impl_.deprecated_)) + sizeof(_impl_.idempotency_level_));
}
@@ -9164,34 +9861,36 @@ const char* MethodOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext*
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional bool deprecated = 33 [default = false];
case 33:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) {
_Internal::set_has_deprecated(&has_bits);
_impl_.deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];
case 34:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
- arc_ui64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 16)) {
+ ::arc_ui32 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- if (PROTOBUF_PREDICT_TRUE(::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel_IsValid(val))) {
+ if (PROTOBUF_PREDICT_TRUE(::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel_IsValid(static_cast<int>(val)))) {
_internal_set_idempotency_level(static_cast<::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel>(val));
} else {
::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(34, val, mutable_unknown_fields());
}
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 58)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 58)) {
ptr -= 2;
do {
ptr += 2;
@@ -9199,8 +9898,9 @@ const char* MethodOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext*
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<7994>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -9231,24 +9931,25 @@ failure:
#undef CHK_
}
-uint8_t* MethodOptions::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* MethodOptions::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.MethodOptions)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
// optional bool deprecated = 33 [default = false];
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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 = ::_pbi::WireFormatLite::WriteEnumToArray(
- 34, this->_internal_idempotency_level(), target);
+ 34, this->_internal_idempotency_level(), target);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
@@ -9271,13 +9972,13 @@ uint8_t* MethodOptions::_InternalSerialize(
return target;
}
-size_t MethodOptions::ByteSizeLong() const {
+::size_t MethodOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.MethodOptions)
- size_t total_size = 0;
+ ::size_t total_size = 0;
total_size += _impl_._extensions_.ByteSize();
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -9292,13 +9993,13 @@ size_t MethodOptions::ByteSizeLong() const {
if (cached_has_bits & 0x00000003u) {
// optional bool deprecated = 33 [default = false];
if (cached_has_bits & 0x00000001u) {
- total_size += 2 + 1;
+ total_size += 3;
}
// optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];
if (cached_has_bits & 0x00000002u) {
total_size += 2 +
- ::_pbi::WireFormatLite::EnumSize(this->_internal_idempotency_level());
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_idempotency_level());
}
}
@@ -9316,8 +10017,8 @@ void MethodOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::
auto* const _this = static_cast<MethodOptions*>(&to_msg);
auto& from = static_cast<const MethodOptions&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodOptions)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.uninterpreted_option_.MergeFrom(from._impl_.uninterpreted_option_);
@@ -9343,7 +10044,7 @@ void MethodOptions::CopyFrom(const MethodOptions& from) {
}
bool MethodOptions::IsInitialized() const {
- if (!_impl_._extensions_.IsInitialized()) {
+ if (!_impl_._extensions_.IsInitialized(internal_default_instance())) {
return false;
}
@@ -9371,12 +10072,13 @@ void MethodOptions::InternalSwap(MethodOptions* other) {
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[20]);
}
-
// ===================================================================
class UninterpretedOption_NamePart::_Internal {
public:
using HasBits = decltype(std::declval<UninterpretedOption_NamePart>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(UninterpretedOption_NamePart, _impl_._has_bits_);
static void set_has_name_part(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -9388,10 +10090,9 @@ class UninterpretedOption_NamePart::_Internal {
}
};
-UninterpretedOption_NamePart::UninterpretedOption_NamePart(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+UninterpretedOption_NamePart::UninterpretedOption_NamePart(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.UninterpretedOption.NamePart)
}
UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOption_NamePart& from)
@@ -9400,36 +10101,37 @@ UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOp
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){from._impl_._has_bits_}
, /*decltype(_impl_._cached_size_)*/{}
- , decltype(_impl_.name_part_){}
- , decltype(_impl_.is_extension_){}};
+ , decltype(_impl_.name_part_) {}
+
+ , decltype(_impl_.is_extension_) {}
+ };
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.name_part_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_part_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_name_part()) {
- _this->_impl_.name_part_.Set(from._internal_name_part(),
- _this->GetArenaForAllocation());
+ _impl_.name_part_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
+ _this->_impl_.name_part_.Set(from._internal_name_part(), _this->GetArenaForAllocation());
}
_this->_impl_.is_extension_ = from._impl_.is_extension_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption.NamePart)
}
-inline void UninterpretedOption_NamePart::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void UninterpretedOption_NamePart::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
- , decltype(_impl_.name_part_){}
- , decltype(_impl_.is_extension_){false}
+ , decltype(_impl_.name_part_) {}
+
+ , decltype(_impl_.is_extension_) { false }
+
};
_impl_.name_part_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_part_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_part_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
UninterpretedOption_NamePart::~UninterpretedOption_NamePart() {
@@ -9442,7 +10144,7 @@ UninterpretedOption_NamePart::~UninterpretedOption_NamePart() {
}
inline void UninterpretedOption_NamePart::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.name_part_.Destroy();
}
@@ -9452,7 +10154,7 @@ void UninterpretedOption_NamePart::SetCachedSize(int size) const {
void UninterpretedOption_NamePart::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.UninterpretedOption.NamePart)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -9469,29 +10171,31 @@ const char* UninterpretedOption_NamePart::_InternalParse(const char* ptr, ::_pbi
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 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)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name_part();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.UninterpretedOption.NamePart.name_part");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// required bool is_extension = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 16)) {
_Internal::set_has_is_extension(&has_bits);
_impl_.is_extension_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -9517,27 +10221,26 @@ failure:
#undef CHK_
}
-uint8_t* UninterpretedOption_NamePart::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* UninterpretedOption_NamePart::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UninterpretedOption.NamePart)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
// required string name_part = 1;
if (cached_has_bits & 0x00000001u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_name_part().data(), static_cast<int>(this->_internal_name_part().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.UninterpretedOption.NamePart.name_part");
- target = stream->WriteStringMaybeAliased(
- 1, this->_internal_name_part(), target);
+ const TProtoStringType& _s = this->_internal_name_part();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.UninterpretedOption.NamePart.name_part");
+ target = stream->WriteStringMaybeAliased(1, _s, target);
}
// required bool is_extension = 2;
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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())) {
@@ -9548,41 +10251,39 @@ uint8_t* UninterpretedOption_NamePart::_InternalSerialize(
return target;
}
-size_t UninterpretedOption_NamePart::RequiredFieldsByteSizeFallback() const {
+::size_t UninterpretedOption_NamePart::RequiredFieldsByteSizeFallback() const {
// @@protoc_insertion_point(required_fields_byte_size_fallback_start:google.protobuf.UninterpretedOption.NamePart)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- if (_internal_has_name_part()) {
+ if ((_impl_._has_bits_[0] & 0x00000001u) != 0) {
// required string name_part = 1;
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_name_part());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_name_part());
}
- if (_internal_has_is_extension()) {
+ if ((_impl_._has_bits_[0] & 0x00000002u) != 0) {
// required bool is_extension = 2;
- total_size += 1 + 1;
+ total_size += 2;
}
return total_size;
}
-size_t UninterpretedOption_NamePart::ByteSizeLong() const {
+::size_t UninterpretedOption_NamePart::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.UninterpretedOption.NamePart)
- size_t total_size = 0;
+ ::size_t total_size = 0;
if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present.
// required string name_part = 1;
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_name_part());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_name_part());
// required bool is_extension = 2;
- total_size += 1 + 1;
+ total_size += 2;
} else {
total_size += RequiredFieldsByteSizeFallback();
}
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -9600,8 +10301,8 @@ void UninterpretedOption_NamePart::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& t
auto* const _this = static_cast<UninterpretedOption_NamePart*>(&to_msg);
auto& from = static_cast<const UninterpretedOption_NamePart&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption.NamePart)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._impl_._has_bits_[0];
@@ -9635,10 +10336,9 @@ void UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* ot
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.name_part_, lhs_arena,
- &other->_impl_.name_part_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_part_, lhs_arena,
+ &other->_impl_.name_part_, rhs_arena);
+
swap(_impl_.is_extension_, other->_impl_.is_extension_);
}
@@ -9647,12 +10347,13 @@ void UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* ot
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[21]);
}
-
// ===================================================================
class UninterpretedOption::_Internal {
public:
using HasBits = decltype(std::declval<UninterpretedOption>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(UninterpretedOption, _impl_._has_bits_);
static void set_has_identifier_value(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -9673,10 +10374,9 @@ class UninterpretedOption::_Internal {
}
};
-UninterpretedOption::UninterpretedOption(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+UninterpretedOption::UninterpretedOption(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.UninterpretedOption)
}
UninterpretedOption::UninterpretedOption(const UninterpretedOption& from)
@@ -9686,71 +10386,78 @@ UninterpretedOption::UninterpretedOption(const UninterpretedOption& from)
decltype(_impl_._has_bits_){from._impl_._has_bits_}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.name_){from._impl_.name_}
- , decltype(_impl_.identifier_value_){}
- , decltype(_impl_.string_value_){}
- , decltype(_impl_.aggregate_value_){}
- , decltype(_impl_.positive_int_value_){}
- , decltype(_impl_.negative_int_value_){}
- , decltype(_impl_.double_value_){}};
+ , decltype(_impl_.identifier_value_) {}
+
+ , decltype(_impl_.string_value_) {}
+
+ , decltype(_impl_.aggregate_value_) {}
+
+ , decltype(_impl_.positive_int_value_) {}
+
+ , decltype(_impl_.negative_int_value_) {}
+
+ , decltype(_impl_.double_value_) {}
+ };
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.identifier_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.identifier_value_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_identifier_value()) {
- _this->_impl_.identifier_value_.Set(from._internal_identifier_value(),
- _this->GetArenaForAllocation());
+ _impl_.identifier_value_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
+ _this->_impl_.identifier_value_.Set(from._internal_identifier_value(), _this->GetArenaForAllocation());
}
_impl_.string_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.string_value_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_string_value()) {
- _this->_impl_.string_value_.Set(from._internal_string_value(),
- _this->GetArenaForAllocation());
+ _impl_.string_value_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000002u) != 0) {
+ _this->_impl_.string_value_.Set(from._internal_string_value(), _this->GetArenaForAllocation());
}
_impl_.aggregate_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.aggregate_value_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_aggregate_value()) {
- _this->_impl_.aggregate_value_.Set(from._internal_aggregate_value(),
- _this->GetArenaForAllocation());
+ _impl_.aggregate_value_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000004u) != 0) {
+ _this->_impl_.aggregate_value_.Set(from._internal_aggregate_value(), _this->GetArenaForAllocation());
}
::memcpy(&_impl_.positive_int_value_, &from._impl_.positive_int_value_,
- static_cast<size_t>(reinterpret_cast<char*>(&_impl_.double_value_) -
+ static_cast<::size_t>(reinterpret_cast<char*>(&_impl_.double_value_) -
reinterpret_cast<char*>(&_impl_.positive_int_value_)) + sizeof(_impl_.double_value_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption)
}
-inline void UninterpretedOption::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void UninterpretedOption::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.name_){arena}
- , decltype(_impl_.identifier_value_){}
- , decltype(_impl_.string_value_){}
- , decltype(_impl_.aggregate_value_){}
- , decltype(_impl_.positive_int_value_){arc_ui64{0u}}
- , decltype(_impl_.negative_int_value_){arc_i64{0}}
- , decltype(_impl_.double_value_){0}
+ , decltype(_impl_.identifier_value_) {}
+
+ , decltype(_impl_.string_value_) {}
+
+ , decltype(_impl_.aggregate_value_) {}
+
+ , decltype(_impl_.positive_int_value_) { ::arc_ui64{0u} }
+
+ , decltype(_impl_.negative_int_value_) { ::arc_i64{0} }
+
+ , decltype(_impl_.double_value_) { 0 }
+
};
_impl_.identifier_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.identifier_value_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.identifier_value_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.string_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.string_value_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.string_value_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.aggregate_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.aggregate_value_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.aggregate_value_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
UninterpretedOption::~UninterpretedOption() {
@@ -9763,7 +10470,7 @@ UninterpretedOption::~UninterpretedOption() {
}
inline void UninterpretedOption::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.name_.~RepeatedPtrField();
_impl_.identifier_value_.Destroy();
_impl_.string_value_.Destroy();
@@ -9776,7 +10483,7 @@ void UninterpretedOption::SetCachedSize(int size) const {
void UninterpretedOption::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.UninterpretedOption)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -9794,7 +10501,7 @@ void UninterpretedOption::Clear() {
}
}
if (cached_has_bits & 0x00000038u) {
- ::memset(&_impl_.positive_int_value_, 0, static_cast<size_t>(
+ ::memset(&_impl_.positive_int_value_, 0, static_cast<::size_t>(
reinterpret_cast<char*>(&_impl_.double_value_) -
reinterpret_cast<char*>(&_impl_.positive_int_value_)) + sizeof(_impl_.double_value_));
}
@@ -9806,12 +10513,12 @@ const char* UninterpretedOption::_InternalParse(const char* ptr, ::_pbi::ParseCo
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated .google.protobuf.UninterpretedOption.NamePart name = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) {
ptr -= 1;
do {
ptr += 1;
@@ -9819,68 +10526,75 @@ const char* UninterpretedOption::_InternalParse(const char* ptr, ::_pbi::ParseCo
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string identifier_value = 3;
case 3:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 26)) {
auto str = _internal_mutable_identifier_value();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.UninterpretedOption.identifier_value");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional uint64 positive_int_value = 4;
case 4:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 32)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 32)) {
_Internal::set_has_positive_int_value(&has_bits);
_impl_.positive_int_value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional int64 negative_int_value = 5;
case 5:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 40)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 40)) {
_Internal::set_has_negative_int_value(&has_bits);
_impl_.negative_int_value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional double double_value = 6;
case 6:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 49)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 49)) {
_Internal::set_has_double_value(&has_bits);
_impl_.double_value_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<double>(ptr);
ptr += sizeof(double);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional bytes string_value = 7;
case 7:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 58)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 58)) {
auto str = _internal_mutable_string_value();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string aggregate_value = 8;
case 8:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 66)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 66)) {
auto str = _internal_mutable_aggregate_value();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.UninterpretedOption.aggregate_value");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -9906,10 +10620,10 @@ failure:
#undef CHK_
}
-uint8_t* UninterpretedOption::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* UninterpretedOption::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UninterpretedOption)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .google.protobuf.UninterpretedOption.NamePart name = 2;
@@ -9923,46 +10637,45 @@ uint8_t* UninterpretedOption::_InternalSerialize(
cached_has_bits = _impl_._has_bits_[0];
// optional string identifier_value = 3;
if (cached_has_bits & 0x00000001u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_identifier_value().data(), static_cast<int>(this->_internal_identifier_value().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.UninterpretedOption.identifier_value");
- target = stream->WriteStringMaybeAliased(
- 3, this->_internal_identifier_value(), target);
+ const TProtoStringType& _s = this->_internal_identifier_value();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.UninterpretedOption.identifier_value");
+ target = stream->WriteStringMaybeAliased(3, _s, target);
}
// optional uint64 positive_int_value = 4;
if (cached_has_bits & 0x00000008u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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 = ::_pbi::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 = ::_pbi::WireFormatLite::WriteDoubleToArray(6, this->_internal_double_value(), target);
+ target = ::_pbi::WireFormatLite::WriteDoubleToArray(
+ 6, this->_internal_double_value(), target);
}
// optional bytes string_value = 7;
if (cached_has_bits & 0x00000002u) {
- target = stream->WriteBytesMaybeAliased(
- 7, this->_internal_string_value(), target);
+ const TProtoStringType& _s = this->_internal_string_value();
+ target = stream->WriteBytesMaybeAliased(7, _s, target);
}
// optional string aggregate_value = 8;
if (cached_has_bits & 0x00000004u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_aggregate_value().data(), static_cast<int>(this->_internal_aggregate_value().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.UninterpretedOption.aggregate_value");
- target = stream->WriteStringMaybeAliased(
- 8, this->_internal_aggregate_value(), target);
+ const TProtoStringType& _s = this->_internal_aggregate_value();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.UninterpretedOption.aggregate_value");
+ target = stream->WriteStringMaybeAliased(8, _s, target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
@@ -9973,11 +10686,11 @@ uint8_t* UninterpretedOption::_InternalSerialize(
return target;
}
-size_t UninterpretedOption::ByteSizeLong() const {
+::size_t UninterpretedOption::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.UninterpretedOption)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -9992,38 +10705,37 @@ size_t UninterpretedOption::ByteSizeLong() const {
if (cached_has_bits & 0x0000003fu) {
// optional string identifier_value = 3;
if (cached_has_bits & 0x00000001u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_identifier_value());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_identifier_value());
}
// optional bytes string_value = 7;
if (cached_has_bits & 0x00000002u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize(
- this->_internal_string_value());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize(
+ this->_internal_string_value());
}
// optional string aggregate_value = 8;
if (cached_has_bits & 0x00000004u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_aggregate_value());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_aggregate_value());
}
// optional uint64 positive_int_value = 4;
if (cached_has_bits & 0x00000008u) {
- total_size += ::_pbi::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 += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_negative_int_value());
+ total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(
+ this->_internal_negative_int_value());
}
// optional double double_value = 6;
if (cached_has_bits & 0x00000020u) {
- total_size += 1 + 8;
+ total_size += 9;
}
}
@@ -10041,8 +10753,8 @@ void UninterpretedOption::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, co
auto* const _this = static_cast<UninterpretedOption*>(&to_msg);
auto& from = static_cast<const UninterpretedOption&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.name_.MergeFrom(from._impl_.name_);
@@ -10091,18 +10803,12 @@ void UninterpretedOption::InternalSwap(UninterpretedOption* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
_impl_.name_.InternalSwap(&other->_impl_.name_);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.identifier_value_, lhs_arena,
- &other->_impl_.identifier_value_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.string_value_, lhs_arena,
- &other->_impl_.string_value_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.aggregate_value_, lhs_arena,
- &other->_impl_.aggregate_value_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.identifier_value_, lhs_arena,
+ &other->_impl_.identifier_value_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.string_value_, lhs_arena,
+ &other->_impl_.string_value_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.aggregate_value_, lhs_arena,
+ &other->_impl_.aggregate_value_, rhs_arena);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(UninterpretedOption, _impl_.double_value_)
+ sizeof(UninterpretedOption::_impl_.double_value_)
@@ -10116,12 +10822,13 @@ void UninterpretedOption::InternalSwap(UninterpretedOption* other) {
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[22]);
}
-
// ===================================================================
class SourceCodeInfo_Location::_Internal {
public:
using HasBits = decltype(std::declval<SourceCodeInfo_Location>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(SourceCodeInfo_Location, _impl_._has_bits_);
static void set_has_leading_comments(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -10130,10 +10837,9 @@ class SourceCodeInfo_Location::_Internal {
}
};
-SourceCodeInfo_Location::SourceCodeInfo_Location(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+SourceCodeInfo_Location::SourceCodeInfo_Location(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.SourceCodeInfo.Location)
}
SourceCodeInfo_Location::SourceCodeInfo_Location(const SourceCodeInfo_Location& from)
@@ -10142,57 +10848,61 @@ SourceCodeInfo_Location::SourceCodeInfo_Location(const SourceCodeInfo_Location&
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){from._impl_._has_bits_}
, /*decltype(_impl_._cached_size_)*/{}
- , decltype(_impl_.path_){from._impl_.path_}
- , /*decltype(_impl_._path_cached_byte_size_)*/{0}
- , decltype(_impl_.span_){from._impl_.span_}
- , /*decltype(_impl_._span_cached_byte_size_)*/{0}
+ , decltype(_impl_.path_) { from._impl_.path_ }
+ ,/* _impl_._path_cached_byte_size_ = */ { 0 }
+
+ , decltype(_impl_.span_) { from._impl_.span_ }
+ ,/* _impl_._span_cached_byte_size_ = */ { 0 }
+
, decltype(_impl_.leading_detached_comments_){from._impl_.leading_detached_comments_}
- , decltype(_impl_.leading_comments_){}
- , decltype(_impl_.trailing_comments_){}};
+ , decltype(_impl_.leading_comments_) {}
+
+ , decltype(_impl_.trailing_comments_) {}
+ };
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.leading_comments_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.leading_comments_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_leading_comments()) {
- _this->_impl_.leading_comments_.Set(from._internal_leading_comments(),
- _this->GetArenaForAllocation());
+ _impl_.leading_comments_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
+ _this->_impl_.leading_comments_.Set(from._internal_leading_comments(), _this->GetArenaForAllocation());
}
_impl_.trailing_comments_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.trailing_comments_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_trailing_comments()) {
- _this->_impl_.trailing_comments_.Set(from._internal_trailing_comments(),
- _this->GetArenaForAllocation());
+ _impl_.trailing_comments_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000002u) != 0) {
+ _this->_impl_.trailing_comments_.Set(from._internal_trailing_comments(), _this->GetArenaForAllocation());
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo.Location)
}
-inline void SourceCodeInfo_Location::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void SourceCodeInfo_Location::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
- , decltype(_impl_.path_){arena}
- , /*decltype(_impl_._path_cached_byte_size_)*/{0}
- , decltype(_impl_.span_){arena}
- , /*decltype(_impl_._span_cached_byte_size_)*/{0}
+ , decltype(_impl_.path_) { arena }
+ ,/* _impl_._path_cached_byte_size_ = */ { 0 }
+
+ , decltype(_impl_.span_) { arena }
+ ,/* _impl_._span_cached_byte_size_ = */ { 0 }
+
, decltype(_impl_.leading_detached_comments_){arena}
- , decltype(_impl_.leading_comments_){}
- , decltype(_impl_.trailing_comments_){}
+ , decltype(_impl_.leading_comments_) {}
+
+ , decltype(_impl_.trailing_comments_) {}
+
};
_impl_.leading_comments_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.leading_comments_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.leading_comments_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.trailing_comments_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.trailing_comments_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.trailing_comments_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
SourceCodeInfo_Location::~SourceCodeInfo_Location() {
@@ -10205,7 +10915,7 @@ SourceCodeInfo_Location::~SourceCodeInfo_Location() {
}
inline void SourceCodeInfo_Location::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.path_.~RepeatedField();
_impl_.span_.~RepeatedField();
_impl_.leading_detached_comments_.~RepeatedPtrField();
@@ -10219,7 +10929,7 @@ void SourceCodeInfo_Location::SetCachedSize(int size) const {
void SourceCodeInfo_Location::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo.Location)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -10243,58 +10953,62 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* ptr, ::_pbi::Par
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated int32 path = 1 [packed = true];
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(_internal_mutable_path(), ptr, ctx);
CHK_(ptr);
- } else if (static_cast<uint8_t>(tag) == 8) {
+ } else if (static_cast<::uint8_t>(tag) == 8) {
_internal_add_path(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr));
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated int32 span = 2 [packed = true];
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) {
ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(_internal_mutable_span(), ptr, ctx);
CHK_(ptr);
- } else if (static_cast<uint8_t>(tag) == 16) {
+ } else if (static_cast<::uint8_t>(tag) == 16) {
_internal_add_span(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr));
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string leading_comments = 3;
case 3:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 26)) {
auto str = _internal_mutable_leading_comments();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.SourceCodeInfo.Location.leading_comments");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string trailing_comments = 4;
case 4:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 34)) {
auto str = _internal_mutable_trailing_comments();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.SourceCodeInfo.Location.trailing_comments");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated string leading_detached_comments = 6;
case 6:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 50)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 50)) {
ptr -= 1;
do {
ptr += 1;
@@ -10306,8 +11020,9 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* ptr, ::_pbi::Par
#endif // !NDEBUG
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -10333,58 +11048,52 @@ failure:
#undef CHK_
}
-uint8_t* SourceCodeInfo_Location::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* SourceCodeInfo_Location::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceCodeInfo.Location)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated int32 path = 1 [packed = true];
{
- int byte_size = _impl_._path_cached_byte_size_.load(std::memory_order_relaxed);
+ int byte_size = _impl_._path_cached_byte_size_.Get();
if (byte_size > 0) {
- target = stream->WriteInt32Packed(
- 1, _internal_path(), byte_size, target);
+ target = stream->WriteInt32Packed(1, _internal_path(),
+ byte_size, target);
}
}
// repeated int32 span = 2 [packed = true];
{
- int byte_size = _impl_._span_cached_byte_size_.load(std::memory_order_relaxed);
+ int byte_size = _impl_._span_cached_byte_size_.Get();
if (byte_size > 0) {
- target = stream->WriteInt32Packed(
- 2, _internal_span(), byte_size, target);
+ target = stream->WriteInt32Packed(2, _internal_span(),
+ byte_size, target);
}
}
cached_has_bits = _impl_._has_bits_[0];
// optional string leading_comments = 3;
if (cached_has_bits & 0x00000001u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_leading_comments().data(), static_cast<int>(this->_internal_leading_comments().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.SourceCodeInfo.Location.leading_comments");
- target = stream->WriteStringMaybeAliased(
- 3, this->_internal_leading_comments(), target);
+ const TProtoStringType& _s = this->_internal_leading_comments();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.SourceCodeInfo.Location.leading_comments");
+ target = stream->WriteStringMaybeAliased(3, _s, target);
}
// optional string trailing_comments = 4;
if (cached_has_bits & 0x00000002u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_trailing_comments().data(), static_cast<int>(this->_internal_trailing_comments().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.SourceCodeInfo.Location.trailing_comments");
- target = stream->WriteStringMaybeAliased(
- 4, this->_internal_trailing_comments(), target);
+ const TProtoStringType& _s = this->_internal_trailing_comments();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.SourceCodeInfo.Location.trailing_comments");
+ target = stream->WriteStringMaybeAliased(4, _s, target);
}
// repeated string leading_detached_comments = 6;
- for (int i = 0, n = this->_internal_leading_detached_comments_size(); i < n; i++) {
+ for (int i = 0, n = this->_internal_leading_detached_comments_size(); i < n; ++i) {
const auto& s = this->_internal_leading_detached_comments(i);
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- s.data(), static_cast<int>(s.length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.SourceCodeInfo.Location.leading_detached_comments");
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(s.data(), static_cast<int>(s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.SourceCodeInfo.Location.leading_detached_comments");
target = stream->WriteString(6, s, target);
}
@@ -10396,64 +11105,58 @@ uint8_t* SourceCodeInfo_Location::_InternalSerialize(
return target;
}
-size_t SourceCodeInfo_Location::ByteSizeLong() const {
+::size_t SourceCodeInfo_Location::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceCodeInfo.Location)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// repeated int32 path = 1 [packed = true];
{
- size_t data_size = ::_pbi::WireFormatLite::
- Int32Size(this->_impl_.path_);
- if (data_size > 0) {
- total_size += 1 +
- ::_pbi::WireFormatLite::Int32Size(static_cast<arc_i32>(data_size));
- }
- int cached_size = ::_pbi::ToCachedSize(data_size);
- _impl_._path_cached_byte_size_.store(cached_size,
- std::memory_order_relaxed);
- total_size += data_size;
+ std::size_t data_size = ::_pbi::WireFormatLite::Int32Size(this->_impl_.path_)
+ ;
+ _impl_._path_cached_byte_size_.Set(::_pbi::ToCachedSize(data_size));
+ std::size_t tag_size = data_size == 0
+ ? 0
+ : 1 + ::_pbi::WireFormatLite::Int32Size(
+ static_cast<arc_i32>(data_size))
+ ;
+ total_size += tag_size + data_size;
}
// repeated int32 span = 2 [packed = true];
{
- size_t data_size = ::_pbi::WireFormatLite::
- Int32Size(this->_impl_.span_);
- if (data_size > 0) {
- total_size += 1 +
- ::_pbi::WireFormatLite::Int32Size(static_cast<arc_i32>(data_size));
- }
- int cached_size = ::_pbi::ToCachedSize(data_size);
- _impl_._span_cached_byte_size_.store(cached_size,
- std::memory_order_relaxed);
- total_size += data_size;
+ std::size_t data_size = ::_pbi::WireFormatLite::Int32Size(this->_impl_.span_)
+ ;
+ _impl_._span_cached_byte_size_.Set(::_pbi::ToCachedSize(data_size));
+ std::size_t tag_size = data_size == 0
+ ? 0
+ : 1 + ::_pbi::WireFormatLite::Int32Size(
+ static_cast<arc_i32>(data_size))
+ ;
+ total_size += tag_size + data_size;
}
// repeated string leading_detached_comments = 6;
- total_size += 1 *
- ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.leading_detached_comments_.size());
- for (int i = 0, n = _impl_.leading_detached_comments_.size(); i < n; i++) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- _impl_.leading_detached_comments_.Get(i));
+ total_size += 1 * ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.leading_detached_comments_.size());
+ for (int i = 0, n = _impl_.leading_detached_comments_.size(); i < n; ++i) {
+ total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(_impl_.leading_detached_comments_.Get(i));
}
cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x00000003u) {
// optional string leading_comments = 3;
if (cached_has_bits & 0x00000001u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_leading_comments());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_leading_comments());
}
// optional string trailing_comments = 4;
if (cached_has_bits & 0x00000002u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_trailing_comments());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_trailing_comments());
}
}
@@ -10471,8 +11174,8 @@ void SourceCodeInfo_Location::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg
auto* const _this = static_cast<SourceCodeInfo_Location*>(&to_msg);
auto& from = static_cast<const SourceCodeInfo_Location&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo.Location)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.path_.MergeFrom(from._impl_.path_);
@@ -10510,14 +11213,10 @@ void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) {
_impl_.path_.InternalSwap(&other->_impl_.path_);
_impl_.span_.InternalSwap(&other->_impl_.span_);
_impl_.leading_detached_comments_.InternalSwap(&other->_impl_.leading_detached_comments_);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.leading_comments_, lhs_arena,
- &other->_impl_.leading_comments_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.trailing_comments_, lhs_arena,
- &other->_impl_.trailing_comments_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.leading_comments_, lhs_arena,
+ &other->_impl_.leading_comments_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.trailing_comments_, lhs_arena,
+ &other->_impl_.trailing_comments_, rhs_arena);
}
::PROTOBUF_NAMESPACE_ID::Metadata SourceCodeInfo_Location::GetMetadata() const {
@@ -10525,17 +11224,15 @@ void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) {
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[23]);
}
-
// ===================================================================
class SourceCodeInfo::_Internal {
public:
};
-SourceCodeInfo::SourceCodeInfo(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+SourceCodeInfo::SourceCodeInfo(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.SourceCodeInfo)
}
SourceCodeInfo::SourceCodeInfo(const SourceCodeInfo& from)
@@ -10549,10 +11246,8 @@ SourceCodeInfo::SourceCodeInfo(const SourceCodeInfo& from)
// @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo)
}
-inline void SourceCodeInfo::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void SourceCodeInfo::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_.location_){arena}
, /*decltype(_impl_._cached_size_)*/{}
@@ -10569,7 +11264,7 @@ SourceCodeInfo::~SourceCodeInfo() {
}
inline void SourceCodeInfo::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.location_.~RepeatedPtrField();
}
@@ -10579,7 +11274,7 @@ void SourceCodeInfo::SetCachedSize(int size) const {
void SourceCodeInfo::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -10590,12 +11285,12 @@ void SourceCodeInfo::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated .google.protobuf.SourceCodeInfo.Location location = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
ptr -= 1;
do {
ptr += 1;
@@ -10603,8 +11298,9 @@ const char* SourceCodeInfo::_InternalParse(const char* ptr, ::_pbi::ParseContext
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -10629,10 +11325,10 @@ failure:
#undef CHK_
}
-uint8_t* SourceCodeInfo::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* SourceCodeInfo::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceCodeInfo)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .google.protobuf.SourceCodeInfo.Location location = 1;
@@ -10651,11 +11347,11 @@ uint8_t* SourceCodeInfo::_InternalSerialize(
return target;
}
-size_t SourceCodeInfo::ByteSizeLong() const {
+::size_t SourceCodeInfo::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceCodeInfo)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -10680,8 +11376,8 @@ void SourceCodeInfo::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const :
auto* const _this = static_cast<SourceCodeInfo*>(&to_msg);
auto& from = static_cast<const SourceCodeInfo&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.location_.MergeFrom(from._impl_.location_);
@@ -10710,12 +11406,13 @@ void SourceCodeInfo::InternalSwap(SourceCodeInfo* other) {
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[24]);
}
-
// ===================================================================
class GeneratedCodeInfo_Annotation::_Internal {
public:
using HasBits = decltype(std::declval<GeneratedCodeInfo_Annotation>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _impl_._has_bits_);
static void set_has_source_file(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -10725,12 +11422,14 @@ class GeneratedCodeInfo_Annotation::_Internal {
static void set_has_end(HasBits* has_bits) {
(*has_bits)[0] |= 4u;
}
+ static void set_has_semantic(HasBits* has_bits) {
+ (*has_bits)[0] |= 8u;
+ }
};
-GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.GeneratedCodeInfo.Annotation)
}
GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(const GeneratedCodeInfo_Annotation& from)
@@ -10739,44 +11438,53 @@ GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(const GeneratedCodeIn
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){from._impl_._has_bits_}
, /*decltype(_impl_._cached_size_)*/{}
- , decltype(_impl_.path_){from._impl_.path_}
- , /*decltype(_impl_._path_cached_byte_size_)*/{0}
- , decltype(_impl_.source_file_){}
- , decltype(_impl_.begin_){}
- , decltype(_impl_.end_){}};
+ , decltype(_impl_.path_) { from._impl_.path_ }
+ ,/* _impl_._path_cached_byte_size_ = */ { 0 }
+
+ , decltype(_impl_.source_file_) {}
+
+ , decltype(_impl_.begin_) {}
+
+ , decltype(_impl_.end_) {}
+
+ , decltype(_impl_.semantic_) {}
+ };
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.source_file_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.source_file_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_source_file()) {
- _this->_impl_.source_file_.Set(from._internal_source_file(),
- _this->GetArenaForAllocation());
+ _impl_.source_file_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
+ _this->_impl_.source_file_.Set(from._internal_source_file(), _this->GetArenaForAllocation());
}
::memcpy(&_impl_.begin_, &from._impl_.begin_,
- static_cast<size_t>(reinterpret_cast<char*>(&_impl_.end_) -
- reinterpret_cast<char*>(&_impl_.begin_)) + sizeof(_impl_.end_));
+ static_cast<::size_t>(reinterpret_cast<char*>(&_impl_.semantic_) -
+ reinterpret_cast<char*>(&_impl_.begin_)) + sizeof(_impl_.semantic_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.GeneratedCodeInfo.Annotation)
}
-inline void GeneratedCodeInfo_Annotation::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void GeneratedCodeInfo_Annotation::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
- , decltype(_impl_.path_){arena}
- , /*decltype(_impl_._path_cached_byte_size_)*/{0}
- , decltype(_impl_.source_file_){}
- , decltype(_impl_.begin_){0}
- , decltype(_impl_.end_){0}
+ , decltype(_impl_.path_) { arena }
+ ,/* _impl_._path_cached_byte_size_ = */ { 0 }
+
+ , decltype(_impl_.source_file_) {}
+
+ , decltype(_impl_.begin_) { 0 }
+
+ , decltype(_impl_.end_) { 0 }
+
+ , decltype(_impl_.semantic_) { 0 }
+
};
_impl_.source_file_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.source_file_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.source_file_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
GeneratedCodeInfo_Annotation::~GeneratedCodeInfo_Annotation() {
@@ -10789,7 +11497,7 @@ GeneratedCodeInfo_Annotation::~GeneratedCodeInfo_Annotation() {
}
inline void GeneratedCodeInfo_Annotation::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.path_.~RepeatedField();
_impl_.source_file_.Destroy();
}
@@ -10800,7 +11508,7 @@ void GeneratedCodeInfo_Annotation::SetCachedSize(int size) const {
void GeneratedCodeInfo_Annotation::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.GeneratedCodeInfo.Annotation)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -10809,10 +11517,10 @@ void GeneratedCodeInfo_Annotation::Clear() {
if (cached_has_bits & 0x00000001u) {
_impl_.source_file_.ClearNonDefaultToEmpty();
}
- if (cached_has_bits & 0x00000006u) {
- ::memset(&_impl_.begin_, 0, static_cast<size_t>(
- reinterpret_cast<char*>(&_impl_.end_) -
- reinterpret_cast<char*>(&_impl_.begin_)) + sizeof(_impl_.end_));
+ if (cached_has_bits & 0x0000000eu) {
+ ::memset(&_impl_.begin_, 0, static_cast<::size_t>(
+ reinterpret_cast<char*>(&_impl_.semantic_) -
+ reinterpret_cast<char*>(&_impl_.begin_)) + sizeof(_impl_.semantic_));
}
_impl_._has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
@@ -10822,49 +11530,67 @@ const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* ptr, ::_pbi
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated int32 path = 1 [packed = true];
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(_internal_mutable_path(), ptr, ctx);
CHK_(ptr);
- } else if (static_cast<uint8_t>(tag) == 8) {
+ } else if (static_cast<::uint8_t>(tag) == 8) {
_internal_add_path(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr));
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string source_file = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) {
auto str = _internal_mutable_source_file();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.GeneratedCodeInfo.Annotation.source_file");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional int32 begin = 3;
case 3:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 24)) {
_Internal::set_has_begin(&has_bits);
_impl_.begin_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional int32 end = 4;
case 4:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 32)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 32)) {
_Internal::set_has_end(&has_bits);
_impl_.end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- } else
+ } else {
+ goto handle_unusual;
+ }
+ continue;
+ // optional .google.protobuf.GeneratedCodeInfo.Annotation.Semantic semantic = 5;
+ case 5:
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 40)) {
+ ::arc_ui32 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
+ CHK_(ptr);
+ if (PROTOBUF_PREDICT_TRUE(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation_Semantic_IsValid(static_cast<int>(val)))) {
+ _internal_set_semantic(static_cast<::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation_Semantic>(val));
+ } else {
+ ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(5, val, mutable_unknown_fields());
+ }
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -10890,42 +11616,49 @@ failure:
#undef CHK_
}
-uint8_t* GeneratedCodeInfo_Annotation::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* GeneratedCodeInfo_Annotation::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.GeneratedCodeInfo.Annotation)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated int32 path = 1 [packed = true];
{
- int byte_size = _impl_._path_cached_byte_size_.load(std::memory_order_relaxed);
+ int byte_size = _impl_._path_cached_byte_size_.Get();
if (byte_size > 0) {
- target = stream->WriteInt32Packed(
- 1, _internal_path(), byte_size, target);
+ target = stream->WriteInt32Packed(1, _internal_path(),
+ byte_size, target);
}
}
cached_has_bits = _impl_._has_bits_[0];
// optional string source_file = 2;
if (cached_has_bits & 0x00000001u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_source_file().data(), static_cast<int>(this->_internal_source_file().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.GeneratedCodeInfo.Annotation.source_file");
- target = stream->WriteStringMaybeAliased(
- 2, this->_internal_source_file(), target);
+ const TProtoStringType& _s = this->_internal_source_file();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.GeneratedCodeInfo.Annotation.source_file");
+ target = stream->WriteStringMaybeAliased(2, _s, target);
}
// optional int32 begin = 3;
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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 = ::_pbi::WireFormatLite::WriteInt32ToArray(4, this->_internal_end(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(
+ 4, this->_internal_end(), target);
+ }
+
+ // optional .google.protobuf.GeneratedCodeInfo.Annotation.Semantic semantic = 5;
+ if (cached_has_bits & 0x00000008u) {
+ target = stream->EnsureSpace(target);
+ target = ::_pbi::WireFormatLite::WriteEnumToArray(
+ 5, this->_internal_semantic(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
@@ -10936,45 +11669,51 @@ uint8_t* GeneratedCodeInfo_Annotation::_InternalSerialize(
return target;
}
-size_t GeneratedCodeInfo_Annotation::ByteSizeLong() const {
+::size_t GeneratedCodeInfo_Annotation::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.GeneratedCodeInfo.Annotation)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// repeated int32 path = 1 [packed = true];
{
- size_t data_size = ::_pbi::WireFormatLite::
- Int32Size(this->_impl_.path_);
- if (data_size > 0) {
- total_size += 1 +
- ::_pbi::WireFormatLite::Int32Size(static_cast<arc_i32>(data_size));
- }
- int cached_size = ::_pbi::ToCachedSize(data_size);
- _impl_._path_cached_byte_size_.store(cached_size,
- std::memory_order_relaxed);
- total_size += data_size;
+ std::size_t data_size = ::_pbi::WireFormatLite::Int32Size(this->_impl_.path_)
+ ;
+ _impl_._path_cached_byte_size_.Set(::_pbi::ToCachedSize(data_size));
+ std::size_t tag_size = data_size == 0
+ ? 0
+ : 1 + ::_pbi::WireFormatLite::Int32Size(
+ static_cast<arc_i32>(data_size))
+ ;
+ total_size += tag_size + data_size;
}
cached_has_bits = _impl_._has_bits_[0];
- if (cached_has_bits & 0x00000007u) {
+ if (cached_has_bits & 0x0000000fu) {
// optional string source_file = 2;
if (cached_has_bits & 0x00000001u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_source_file());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_source_file());
}
// optional int32 begin = 3;
if (cached_has_bits & 0x00000002u) {
- total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_begin());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(
+ this->_internal_begin());
}
// optional int32 end = 4;
if (cached_has_bits & 0x00000004u) {
- total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_end());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(
+ this->_internal_end());
+ }
+
+ // optional .google.protobuf.GeneratedCodeInfo.Annotation.Semantic semantic = 5;
+ if (cached_has_bits & 0x00000008u) {
+ total_size += 1 +
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_semantic());
}
}
@@ -10992,13 +11731,13 @@ void GeneratedCodeInfo_Annotation::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& t
auto* const _this = static_cast<GeneratedCodeInfo_Annotation*>(&to_msg);
auto& from = static_cast<const GeneratedCodeInfo_Annotation&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo.Annotation)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.path_.MergeFrom(from._impl_.path_);
cached_has_bits = from._impl_._has_bits_[0];
- if (cached_has_bits & 0x00000007u) {
+ if (cached_has_bits & 0x0000000fu) {
if (cached_has_bits & 0x00000001u) {
_this->_internal_set_source_file(from._internal_source_file());
}
@@ -11008,6 +11747,9 @@ void GeneratedCodeInfo_Annotation::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& t
if (cached_has_bits & 0x00000004u) {
_this->_impl_.end_ = from._impl_.end_;
}
+ if (cached_has_bits & 0x00000008u) {
+ _this->_impl_.semantic_ = from._impl_.semantic_;
+ }
_this->_impl_._has_bits_[0] |= cached_has_bits;
}
_this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
@@ -11031,13 +11773,11 @@ void GeneratedCodeInfo_Annotation::InternalSwap(GeneratedCodeInfo_Annotation* ot
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
_impl_.path_.InternalSwap(&other->_impl_.path_);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.source_file_, lhs_arena,
- &other->_impl_.source_file_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.source_file_, lhs_arena,
+ &other->_impl_.source_file_, rhs_arena);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
- PROTOBUF_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _impl_.end_)
- + sizeof(GeneratedCodeInfo_Annotation::_impl_.end_)
+ PROTOBUF_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _impl_.semantic_)
+ + sizeof(GeneratedCodeInfo_Annotation::_impl_.semantic_)
- PROTOBUF_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _impl_.begin_)>(
reinterpret_cast<char*>(&_impl_.begin_),
reinterpret_cast<char*>(&other->_impl_.begin_));
@@ -11048,17 +11788,15 @@ void GeneratedCodeInfo_Annotation::InternalSwap(GeneratedCodeInfo_Annotation* ot
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[25]);
}
-
// ===================================================================
class GeneratedCodeInfo::_Internal {
public:
};
-GeneratedCodeInfo::GeneratedCodeInfo(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+GeneratedCodeInfo::GeneratedCodeInfo(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.GeneratedCodeInfo)
}
GeneratedCodeInfo::GeneratedCodeInfo(const GeneratedCodeInfo& from)
@@ -11072,10 +11810,8 @@ GeneratedCodeInfo::GeneratedCodeInfo(const GeneratedCodeInfo& from)
// @@protoc_insertion_point(copy_constructor:google.protobuf.GeneratedCodeInfo)
}
-inline void GeneratedCodeInfo::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void GeneratedCodeInfo::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_.annotation_){arena}
, /*decltype(_impl_._cached_size_)*/{}
@@ -11092,7 +11828,7 @@ GeneratedCodeInfo::~GeneratedCodeInfo() {
}
inline void GeneratedCodeInfo::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.annotation_.~RepeatedPtrField();
}
@@ -11102,7 +11838,7 @@ void GeneratedCodeInfo::SetCachedSize(int size) const {
void GeneratedCodeInfo::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.GeneratedCodeInfo)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -11113,12 +11849,12 @@ void GeneratedCodeInfo::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
ptr -= 1;
do {
ptr += 1;
@@ -11126,8 +11862,9 @@ const char* GeneratedCodeInfo::_InternalParse(const char* ptr, ::_pbi::ParseCont
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -11152,10 +11889,10 @@ failure:
#undef CHK_
}
-uint8_t* GeneratedCodeInfo::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* GeneratedCodeInfo::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.GeneratedCodeInfo)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;
@@ -11174,11 +11911,11 @@ uint8_t* GeneratedCodeInfo::_InternalSerialize(
return target;
}
-size_t GeneratedCodeInfo::ByteSizeLong() const {
+::size_t GeneratedCodeInfo::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.GeneratedCodeInfo)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -11203,8 +11940,8 @@ void GeneratedCodeInfo::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, cons
auto* const _this = static_cast<GeneratedCodeInfo*>(&to_msg);
auto& from = static_cast<const GeneratedCodeInfo&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.annotation_.MergeFrom(from._impl_.annotation_);
@@ -11233,7 +11970,6 @@ void GeneratedCodeInfo::InternalSwap(GeneratedCodeInfo* other) {
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[26]);
}
-
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
@@ -11346,6 +12082,5 @@ Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo >(Arena* a
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
-
// @@protoc_insertion_point(global_scope)
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protobuf/src/google/protobuf/descriptor.pb.h b/contrib/libs/protobuf/src/google/protobuf/descriptor.pb.h
index d47cd32f801..ad10dc19294 100644
--- a/contrib/libs/protobuf/src/google/protobuf/descriptor.pb.h
+++ b/contrib/libs/protobuf/src/google/protobuf/descriptor.pb.h
@@ -1,39 +1,44 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/descriptor.proto
-#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fdescriptor_2eproto
-#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fdescriptor_2eproto
+#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fdescriptor_2eproto_2epb_2eh
+#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fdescriptor_2eproto_2epb_2eh
#include <limits>
#include <string>
-
-#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3021000
-#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 3021003 < 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.
-#endif
-
-#include <google/protobuf/port_undef.inc>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/arena.h>
-#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_util.h>
-#include <google/protobuf/metadata_lite.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h> // IWYU pragma: export
-#include <google/protobuf/extension_set.h> // IWYU pragma: export
-#include <google/protobuf/generated_enum_reflection.h>
-#include <google/protobuf/unknown_field_set.h>
+#include <type_traits>
+
+#include "google/protobuf/port_def.inc"
+#if PROTOBUF_VERSION < 4022000
+#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 // PROTOBUF_VERSION
+
+#if 4022005 < 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."
+#endif // PROTOBUF_MIN_PROTOC_VERSION
+#include "google/protobuf/port_undef.inc"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/arena.h"
+#include "google/protobuf/arenastring.h"
+#include "google/protobuf/generated_message_util.h"
+#include "google/protobuf/metadata_lite.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/repeated_field.h" // IWYU pragma: export
+#include "google/protobuf/extension_set.h" // IWYU pragma: export
+#include "google/protobuf/generated_enum_reflection.h"
+#include "google/protobuf/unknown_field_set.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto PROTOBUF_EXPORT
+
PROTOBUF_NAMESPACE_OPEN
namespace internal {
class AnyMetadata;
@@ -42,9 +47,10 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fdescriptor_2eproto {
- static const arc_ui32 offsets[];
+ static const ::arc_ui32 offsets[];
};
-PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fdescriptor_2eproto;
+PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable
+ descriptor_table_google_2fprotobuf_2fdescriptor_2eproto;
PROTOBUF_NAMESPACE_OPEN
class DescriptorProto;
struct DescriptorProtoDefaultTypeInternal;
@@ -127,38 +133,63 @@ PROTOBUF_EXPORT extern UninterpretedOptionDefaultTypeInternal _UninterpretedOpti
class UninterpretedOption_NamePart;
struct UninterpretedOption_NamePartDefaultTypeInternal;
PROTOBUF_EXPORT extern UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_;
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::DescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::DescriptorProto>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumOptions>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumValueOptions>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FieldOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FieldOptions>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FileDescriptorProto>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FileDescriptorSet* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FileDescriptorSet>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FileOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FileOptions>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::MessageOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::MessageOptions>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::MethodOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::MethodOptions>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::OneofOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::OneofOptions>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::ServiceOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::ServiceOptions>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::SourceCodeInfo>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::UninterpretedOption>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart>(Arena*);
PROTOBUF_NAMESPACE_CLOSE
-PROTOBUF_NAMESPACE_OPEN
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::DescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::DescriptorProto>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumOptions>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumValueOptions>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FieldOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FieldOptions>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FileDescriptorProto>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FileDescriptorSet* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FileDescriptorSet>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FileOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FileOptions>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::MessageOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::MessageOptions>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::MethodOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::MethodOptions>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::OneofOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::OneofOptions>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::ServiceOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::ServiceOptions>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::SourceCodeInfo>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::UninterpretedOption>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart>(Arena*);
-PROTOBUF_NAMESPACE_CLOSE
-PROTOBUF_NAMESPACE_OPEN
+PROTOBUF_NAMESPACE_OPEN
enum FieldDescriptorProto_Type : int {
FieldDescriptorProto_Type_TYPE_DOUBLE = 1,
FieldDescriptorProto_Type_TYPE_FLOAT = 2,
@@ -177,149 +208,277 @@ enum FieldDescriptorProto_Type : int {
FieldDescriptorProto_Type_TYPE_SFIXED32 = 15,
FieldDescriptorProto_Type_TYPE_SFIXED64 = 16,
FieldDescriptorProto_Type_TYPE_SINT32 = 17,
- FieldDescriptorProto_Type_TYPE_SINT64 = 18
+ FieldDescriptorProto_Type_TYPE_SINT64 = 18,
};
+
PROTOBUF_EXPORT bool FieldDescriptorProto_Type_IsValid(int value);
-constexpr FieldDescriptorProto_Type FieldDescriptorProto_Type_Type_MIN = FieldDescriptorProto_Type_TYPE_DOUBLE;
-constexpr FieldDescriptorProto_Type FieldDescriptorProto_Type_Type_MAX = FieldDescriptorProto_Type_TYPE_SINT64;
-constexpr int FieldDescriptorProto_Type_Type_ARRAYSIZE = FieldDescriptorProto_Type_Type_MAX + 1;
-
-PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* FieldDescriptorProto_Type_descriptor();
-template<typename T>
-inline const TProtoStringType& FieldDescriptorProto_Type_Name(T enum_t_value) {
- static_assert(::std::is_same<T, FieldDescriptorProto_Type>::value ||
- ::std::is_integral<T>::value,
- "Incorrect type passed to function FieldDescriptorProto_Type_Name.");
- return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum(
- FieldDescriptorProto_Type_descriptor(), enum_t_value);
-}
-inline bool FieldDescriptorProto_Type_Parse(
- ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, FieldDescriptorProto_Type* value) {
+constexpr FieldDescriptorProto_Type FieldDescriptorProto_Type_Type_MIN = static_cast<FieldDescriptorProto_Type>(1);
+constexpr FieldDescriptorProto_Type FieldDescriptorProto_Type_Type_MAX = static_cast<FieldDescriptorProto_Type>(18);
+constexpr int FieldDescriptorProto_Type_Type_ARRAYSIZE = 18 + 1;
+PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
+FieldDescriptorProto_Type_descriptor();
+template <typename T>
+const TProtoStringType& FieldDescriptorProto_Type_Name(T value) {
+ static_assert(std::is_same<T, FieldDescriptorProto_Type>::value ||
+ std::is_integral<T>::value,
+ "Incorrect type passed to Type_Name().");
+ return FieldDescriptorProto_Type_Name(static_cast<FieldDescriptorProto_Type>(value));
+}
+template <>
+inline const TProtoStringType& FieldDescriptorProto_Type_Name(FieldDescriptorProto_Type value) {
+ return ::PROTOBUF_NAMESPACE_ID::internal::NameOfDenseEnum<FieldDescriptorProto_Type_descriptor,
+ 1, 18>(
+ static_cast<int>(value));
+}
+inline bool FieldDescriptorProto_Type_Parse(y_absl::string_view name, FieldDescriptorProto_Type* value) {
return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum<FieldDescriptorProto_Type>(
- FieldDescriptorProto_Type_descriptor(), name, value);
+ FieldDescriptorProto_Type_descriptor(), name, value);
}
enum FieldDescriptorProto_Label : int {
FieldDescriptorProto_Label_LABEL_OPTIONAL = 1,
FieldDescriptorProto_Label_LABEL_REQUIRED = 2,
- FieldDescriptorProto_Label_LABEL_REPEATED = 3
+ FieldDescriptorProto_Label_LABEL_REPEATED = 3,
};
+
PROTOBUF_EXPORT bool FieldDescriptorProto_Label_IsValid(int value);
-constexpr FieldDescriptorProto_Label FieldDescriptorProto_Label_Label_MIN = FieldDescriptorProto_Label_LABEL_OPTIONAL;
-constexpr FieldDescriptorProto_Label FieldDescriptorProto_Label_Label_MAX = FieldDescriptorProto_Label_LABEL_REPEATED;
-constexpr int FieldDescriptorProto_Label_Label_ARRAYSIZE = FieldDescriptorProto_Label_Label_MAX + 1;
-
-PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* FieldDescriptorProto_Label_descriptor();
-template<typename T>
-inline const TProtoStringType& FieldDescriptorProto_Label_Name(T enum_t_value) {
- static_assert(::std::is_same<T, FieldDescriptorProto_Label>::value ||
- ::std::is_integral<T>::value,
- "Incorrect type passed to function FieldDescriptorProto_Label_Name.");
- return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum(
- FieldDescriptorProto_Label_descriptor(), enum_t_value);
-}
-inline bool FieldDescriptorProto_Label_Parse(
- ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, FieldDescriptorProto_Label* value) {
+constexpr FieldDescriptorProto_Label FieldDescriptorProto_Label_Label_MIN = static_cast<FieldDescriptorProto_Label>(1);
+constexpr FieldDescriptorProto_Label FieldDescriptorProto_Label_Label_MAX = static_cast<FieldDescriptorProto_Label>(3);
+constexpr int FieldDescriptorProto_Label_Label_ARRAYSIZE = 3 + 1;
+PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
+FieldDescriptorProto_Label_descriptor();
+template <typename T>
+const TProtoStringType& FieldDescriptorProto_Label_Name(T value) {
+ static_assert(std::is_same<T, FieldDescriptorProto_Label>::value ||
+ std::is_integral<T>::value,
+ "Incorrect type passed to Label_Name().");
+ return FieldDescriptorProto_Label_Name(static_cast<FieldDescriptorProto_Label>(value));
+}
+template <>
+inline const TProtoStringType& FieldDescriptorProto_Label_Name(FieldDescriptorProto_Label value) {
+ return ::PROTOBUF_NAMESPACE_ID::internal::NameOfDenseEnum<FieldDescriptorProto_Label_descriptor,
+ 1, 3>(
+ static_cast<int>(value));
+}
+inline bool FieldDescriptorProto_Label_Parse(y_absl::string_view name, FieldDescriptorProto_Label* value) {
return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum<FieldDescriptorProto_Label>(
- FieldDescriptorProto_Label_descriptor(), name, value);
+ FieldDescriptorProto_Label_descriptor(), name, value);
}
enum FileOptions_OptimizeMode : int {
FileOptions_OptimizeMode_SPEED = 1,
FileOptions_OptimizeMode_CODE_SIZE = 2,
- FileOptions_OptimizeMode_LITE_RUNTIME = 3
+ FileOptions_OptimizeMode_LITE_RUNTIME = 3,
};
+
PROTOBUF_EXPORT bool FileOptions_OptimizeMode_IsValid(int value);
-constexpr FileOptions_OptimizeMode FileOptions_OptimizeMode_OptimizeMode_MIN = FileOptions_OptimizeMode_SPEED;
-constexpr FileOptions_OptimizeMode FileOptions_OptimizeMode_OptimizeMode_MAX = FileOptions_OptimizeMode_LITE_RUNTIME;
-constexpr int FileOptions_OptimizeMode_OptimizeMode_ARRAYSIZE = FileOptions_OptimizeMode_OptimizeMode_MAX + 1;
-
-PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* FileOptions_OptimizeMode_descriptor();
-template<typename T>
-inline const TProtoStringType& FileOptions_OptimizeMode_Name(T enum_t_value) {
- static_assert(::std::is_same<T, FileOptions_OptimizeMode>::value ||
- ::std::is_integral<T>::value,
- "Incorrect type passed to function FileOptions_OptimizeMode_Name.");
- return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum(
- FileOptions_OptimizeMode_descriptor(), enum_t_value);
-}
-inline bool FileOptions_OptimizeMode_Parse(
- ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, FileOptions_OptimizeMode* value) {
+constexpr FileOptions_OptimizeMode FileOptions_OptimizeMode_OptimizeMode_MIN = static_cast<FileOptions_OptimizeMode>(1);
+constexpr FileOptions_OptimizeMode FileOptions_OptimizeMode_OptimizeMode_MAX = static_cast<FileOptions_OptimizeMode>(3);
+constexpr int FileOptions_OptimizeMode_OptimizeMode_ARRAYSIZE = 3 + 1;
+PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
+FileOptions_OptimizeMode_descriptor();
+template <typename T>
+const TProtoStringType& FileOptions_OptimizeMode_Name(T value) {
+ static_assert(std::is_same<T, FileOptions_OptimizeMode>::value ||
+ std::is_integral<T>::value,
+ "Incorrect type passed to OptimizeMode_Name().");
+ return FileOptions_OptimizeMode_Name(static_cast<FileOptions_OptimizeMode>(value));
+}
+template <>
+inline const TProtoStringType& FileOptions_OptimizeMode_Name(FileOptions_OptimizeMode value) {
+ return ::PROTOBUF_NAMESPACE_ID::internal::NameOfDenseEnum<FileOptions_OptimizeMode_descriptor,
+ 1, 3>(
+ static_cast<int>(value));
+}
+inline bool FileOptions_OptimizeMode_Parse(y_absl::string_view name, FileOptions_OptimizeMode* value) {
return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum<FileOptions_OptimizeMode>(
- FileOptions_OptimizeMode_descriptor(), name, value);
+ FileOptions_OptimizeMode_descriptor(), name, value);
}
enum FieldOptions_CType : int {
FieldOptions_CType_STRING = 0,
FieldOptions_CType_CORD = 1,
- FieldOptions_CType_STRING_PIECE = 2
+ FieldOptions_CType_STRING_PIECE = 2,
};
+
PROTOBUF_EXPORT bool FieldOptions_CType_IsValid(int value);
-constexpr FieldOptions_CType FieldOptions_CType_CType_MIN = FieldOptions_CType_STRING;
-constexpr FieldOptions_CType FieldOptions_CType_CType_MAX = FieldOptions_CType_STRING_PIECE;
-constexpr int FieldOptions_CType_CType_ARRAYSIZE = FieldOptions_CType_CType_MAX + 1;
-
-PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* FieldOptions_CType_descriptor();
-template<typename T>
-inline const TProtoStringType& FieldOptions_CType_Name(T enum_t_value) {
- static_assert(::std::is_same<T, FieldOptions_CType>::value ||
- ::std::is_integral<T>::value,
- "Incorrect type passed to function FieldOptions_CType_Name.");
- return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum(
- FieldOptions_CType_descriptor(), enum_t_value);
-}
-inline bool FieldOptions_CType_Parse(
- ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, FieldOptions_CType* value) {
+constexpr FieldOptions_CType FieldOptions_CType_CType_MIN = static_cast<FieldOptions_CType>(0);
+constexpr FieldOptions_CType FieldOptions_CType_CType_MAX = static_cast<FieldOptions_CType>(2);
+constexpr int FieldOptions_CType_CType_ARRAYSIZE = 2 + 1;
+PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
+FieldOptions_CType_descriptor();
+template <typename T>
+const TProtoStringType& FieldOptions_CType_Name(T value) {
+ static_assert(std::is_same<T, FieldOptions_CType>::value ||
+ std::is_integral<T>::value,
+ "Incorrect type passed to CType_Name().");
+ return FieldOptions_CType_Name(static_cast<FieldOptions_CType>(value));
+}
+template <>
+inline const TProtoStringType& FieldOptions_CType_Name(FieldOptions_CType value) {
+ return ::PROTOBUF_NAMESPACE_ID::internal::NameOfDenseEnum<FieldOptions_CType_descriptor,
+ 0, 2>(
+ static_cast<int>(value));
+}
+inline bool FieldOptions_CType_Parse(y_absl::string_view name, FieldOptions_CType* value) {
return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum<FieldOptions_CType>(
- FieldOptions_CType_descriptor(), name, value);
+ FieldOptions_CType_descriptor(), name, value);
}
enum FieldOptions_JSType : int {
FieldOptions_JSType_JS_NORMAL = 0,
FieldOptions_JSType_JS_STRING = 1,
- FieldOptions_JSType_JS_NUMBER = 2
+ FieldOptions_JSType_JS_NUMBER = 2,
};
+
PROTOBUF_EXPORT bool FieldOptions_JSType_IsValid(int value);
-constexpr FieldOptions_JSType FieldOptions_JSType_JSType_MIN = FieldOptions_JSType_JS_NORMAL;
-constexpr FieldOptions_JSType FieldOptions_JSType_JSType_MAX = FieldOptions_JSType_JS_NUMBER;
-constexpr int FieldOptions_JSType_JSType_ARRAYSIZE = FieldOptions_JSType_JSType_MAX + 1;
-
-PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* FieldOptions_JSType_descriptor();
-template<typename T>
-inline const TProtoStringType& FieldOptions_JSType_Name(T enum_t_value) {
- static_assert(::std::is_same<T, FieldOptions_JSType>::value ||
- ::std::is_integral<T>::value,
- "Incorrect type passed to function FieldOptions_JSType_Name.");
- return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum(
- FieldOptions_JSType_descriptor(), enum_t_value);
-}
-inline bool FieldOptions_JSType_Parse(
- ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, FieldOptions_JSType* value) {
+constexpr FieldOptions_JSType FieldOptions_JSType_JSType_MIN = static_cast<FieldOptions_JSType>(0);
+constexpr FieldOptions_JSType FieldOptions_JSType_JSType_MAX = static_cast<FieldOptions_JSType>(2);
+constexpr int FieldOptions_JSType_JSType_ARRAYSIZE = 2 + 1;
+PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
+FieldOptions_JSType_descriptor();
+template <typename T>
+const TProtoStringType& FieldOptions_JSType_Name(T value) {
+ static_assert(std::is_same<T, FieldOptions_JSType>::value ||
+ std::is_integral<T>::value,
+ "Incorrect type passed to JSType_Name().");
+ return FieldOptions_JSType_Name(static_cast<FieldOptions_JSType>(value));
+}
+template <>
+inline const TProtoStringType& FieldOptions_JSType_Name(FieldOptions_JSType value) {
+ return ::PROTOBUF_NAMESPACE_ID::internal::NameOfDenseEnum<FieldOptions_JSType_descriptor,
+ 0, 2>(
+ static_cast<int>(value));
+}
+inline bool FieldOptions_JSType_Parse(y_absl::string_view name, FieldOptions_JSType* value) {
return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum<FieldOptions_JSType>(
- FieldOptions_JSType_descriptor(), name, value);
+ FieldOptions_JSType_descriptor(), name, value);
+}
+enum FieldOptions_OptionRetention : int {
+ FieldOptions_OptionRetention_RETENTION_UNKNOWN = 0,
+ FieldOptions_OptionRetention_RETENTION_RUNTIME = 1,
+ FieldOptions_OptionRetention_RETENTION_SOURCE = 2,
+};
+
+PROTOBUF_EXPORT bool FieldOptions_OptionRetention_IsValid(int value);
+constexpr FieldOptions_OptionRetention FieldOptions_OptionRetention_OptionRetention_MIN = static_cast<FieldOptions_OptionRetention>(0);
+constexpr FieldOptions_OptionRetention FieldOptions_OptionRetention_OptionRetention_MAX = static_cast<FieldOptions_OptionRetention>(2);
+constexpr int FieldOptions_OptionRetention_OptionRetention_ARRAYSIZE = 2 + 1;
+PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
+FieldOptions_OptionRetention_descriptor();
+template <typename T>
+const TProtoStringType& FieldOptions_OptionRetention_Name(T value) {
+ static_assert(std::is_same<T, FieldOptions_OptionRetention>::value ||
+ std::is_integral<T>::value,
+ "Incorrect type passed to OptionRetention_Name().");
+ return FieldOptions_OptionRetention_Name(static_cast<FieldOptions_OptionRetention>(value));
+}
+template <>
+inline const TProtoStringType& FieldOptions_OptionRetention_Name(FieldOptions_OptionRetention value) {
+ return ::PROTOBUF_NAMESPACE_ID::internal::NameOfDenseEnum<FieldOptions_OptionRetention_descriptor,
+ 0, 2>(
+ static_cast<int>(value));
+}
+inline bool FieldOptions_OptionRetention_Parse(y_absl::string_view name, FieldOptions_OptionRetention* value) {
+ return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum<FieldOptions_OptionRetention>(
+ FieldOptions_OptionRetention_descriptor(), name, value);
+}
+enum FieldOptions_OptionTargetType : int {
+ FieldOptions_OptionTargetType_TARGET_TYPE_UNKNOWN = 0,
+ FieldOptions_OptionTargetType_TARGET_TYPE_FILE = 1,
+ FieldOptions_OptionTargetType_TARGET_TYPE_EXTENSION_RANGE = 2,
+ FieldOptions_OptionTargetType_TARGET_TYPE_MESSAGE = 3,
+ FieldOptions_OptionTargetType_TARGET_TYPE_FIELD = 4,
+ FieldOptions_OptionTargetType_TARGET_TYPE_ONEOF = 5,
+ FieldOptions_OptionTargetType_TARGET_TYPE_ENUM = 6,
+ FieldOptions_OptionTargetType_TARGET_TYPE_ENUM_ENTRY = 7,
+ FieldOptions_OptionTargetType_TARGET_TYPE_SERVICE = 8,
+ FieldOptions_OptionTargetType_TARGET_TYPE_METHOD = 9,
+};
+
+PROTOBUF_EXPORT bool FieldOptions_OptionTargetType_IsValid(int value);
+constexpr FieldOptions_OptionTargetType FieldOptions_OptionTargetType_OptionTargetType_MIN = static_cast<FieldOptions_OptionTargetType>(0);
+constexpr FieldOptions_OptionTargetType FieldOptions_OptionTargetType_OptionTargetType_MAX = static_cast<FieldOptions_OptionTargetType>(9);
+constexpr int FieldOptions_OptionTargetType_OptionTargetType_ARRAYSIZE = 9 + 1;
+PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
+FieldOptions_OptionTargetType_descriptor();
+template <typename T>
+const TProtoStringType& FieldOptions_OptionTargetType_Name(T value) {
+ static_assert(std::is_same<T, FieldOptions_OptionTargetType>::value ||
+ std::is_integral<T>::value,
+ "Incorrect type passed to OptionTargetType_Name().");
+ return FieldOptions_OptionTargetType_Name(static_cast<FieldOptions_OptionTargetType>(value));
+}
+template <>
+inline const TProtoStringType& FieldOptions_OptionTargetType_Name(FieldOptions_OptionTargetType value) {
+ return ::PROTOBUF_NAMESPACE_ID::internal::NameOfDenseEnum<FieldOptions_OptionTargetType_descriptor,
+ 0, 9>(
+ static_cast<int>(value));
+}
+inline bool FieldOptions_OptionTargetType_Parse(y_absl::string_view name, FieldOptions_OptionTargetType* value) {
+ return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum<FieldOptions_OptionTargetType>(
+ FieldOptions_OptionTargetType_descriptor(), name, value);
}
enum MethodOptions_IdempotencyLevel : int {
MethodOptions_IdempotencyLevel_IDEMPOTENCY_UNKNOWN = 0,
MethodOptions_IdempotencyLevel_NO_SIDE_EFFECTS = 1,
- MethodOptions_IdempotencyLevel_IDEMPOTENT = 2
+ MethodOptions_IdempotencyLevel_IDEMPOTENT = 2,
};
+
PROTOBUF_EXPORT bool MethodOptions_IdempotencyLevel_IsValid(int value);
-constexpr MethodOptions_IdempotencyLevel MethodOptions_IdempotencyLevel_IdempotencyLevel_MIN = MethodOptions_IdempotencyLevel_IDEMPOTENCY_UNKNOWN;
-constexpr MethodOptions_IdempotencyLevel MethodOptions_IdempotencyLevel_IdempotencyLevel_MAX = MethodOptions_IdempotencyLevel_IDEMPOTENT;
-constexpr int MethodOptions_IdempotencyLevel_IdempotencyLevel_ARRAYSIZE = MethodOptions_IdempotencyLevel_IdempotencyLevel_MAX + 1;
-
-PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* MethodOptions_IdempotencyLevel_descriptor();
-template<typename T>
-inline const TProtoStringType& MethodOptions_IdempotencyLevel_Name(T enum_t_value) {
- static_assert(::std::is_same<T, MethodOptions_IdempotencyLevel>::value ||
- ::std::is_integral<T>::value,
- "Incorrect type passed to function MethodOptions_IdempotencyLevel_Name.");
- return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum(
- MethodOptions_IdempotencyLevel_descriptor(), enum_t_value);
-}
-inline bool MethodOptions_IdempotencyLevel_Parse(
- ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, MethodOptions_IdempotencyLevel* value) {
+constexpr MethodOptions_IdempotencyLevel MethodOptions_IdempotencyLevel_IdempotencyLevel_MIN = static_cast<MethodOptions_IdempotencyLevel>(0);
+constexpr MethodOptions_IdempotencyLevel MethodOptions_IdempotencyLevel_IdempotencyLevel_MAX = static_cast<MethodOptions_IdempotencyLevel>(2);
+constexpr int MethodOptions_IdempotencyLevel_IdempotencyLevel_ARRAYSIZE = 2 + 1;
+PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
+MethodOptions_IdempotencyLevel_descriptor();
+template <typename T>
+const TProtoStringType& MethodOptions_IdempotencyLevel_Name(T value) {
+ static_assert(std::is_same<T, MethodOptions_IdempotencyLevel>::value ||
+ std::is_integral<T>::value,
+ "Incorrect type passed to IdempotencyLevel_Name().");
+ return MethodOptions_IdempotencyLevel_Name(static_cast<MethodOptions_IdempotencyLevel>(value));
+}
+template <>
+inline const TProtoStringType& MethodOptions_IdempotencyLevel_Name(MethodOptions_IdempotencyLevel value) {
+ return ::PROTOBUF_NAMESPACE_ID::internal::NameOfDenseEnum<MethodOptions_IdempotencyLevel_descriptor,
+ 0, 2>(
+ static_cast<int>(value));
+}
+inline bool MethodOptions_IdempotencyLevel_Parse(y_absl::string_view name, MethodOptions_IdempotencyLevel* value) {
return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum<MethodOptions_IdempotencyLevel>(
- MethodOptions_IdempotencyLevel_descriptor(), name, value);
+ MethodOptions_IdempotencyLevel_descriptor(), name, value);
+}
+enum GeneratedCodeInfo_Annotation_Semantic : int {
+ GeneratedCodeInfo_Annotation_Semantic_NONE = 0,
+ GeneratedCodeInfo_Annotation_Semantic_SET = 1,
+ GeneratedCodeInfo_Annotation_Semantic_ALIAS = 2,
+};
+
+PROTOBUF_EXPORT bool GeneratedCodeInfo_Annotation_Semantic_IsValid(int value);
+constexpr GeneratedCodeInfo_Annotation_Semantic GeneratedCodeInfo_Annotation_Semantic_Semantic_MIN = static_cast<GeneratedCodeInfo_Annotation_Semantic>(0);
+constexpr GeneratedCodeInfo_Annotation_Semantic GeneratedCodeInfo_Annotation_Semantic_Semantic_MAX = static_cast<GeneratedCodeInfo_Annotation_Semantic>(2);
+constexpr int GeneratedCodeInfo_Annotation_Semantic_Semantic_ARRAYSIZE = 2 + 1;
+PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
+GeneratedCodeInfo_Annotation_Semantic_descriptor();
+template <typename T>
+const TProtoStringType& GeneratedCodeInfo_Annotation_Semantic_Name(T value) {
+ static_assert(std::is_same<T, GeneratedCodeInfo_Annotation_Semantic>::value ||
+ std::is_integral<T>::value,
+ "Incorrect type passed to Semantic_Name().");
+ return GeneratedCodeInfo_Annotation_Semantic_Name(static_cast<GeneratedCodeInfo_Annotation_Semantic>(value));
}
+template <>
+inline const TProtoStringType& GeneratedCodeInfo_Annotation_Semantic_Name(GeneratedCodeInfo_Annotation_Semantic value) {
+ return ::PROTOBUF_NAMESPACE_ID::internal::NameOfDenseEnum<GeneratedCodeInfo_Annotation_Semantic_descriptor,
+ 0, 2>(
+ static_cast<int>(value));
+}
+inline bool GeneratedCodeInfo_Annotation_Semantic_Parse(y_absl::string_view name, GeneratedCodeInfo_Annotation_Semantic* value) {
+ return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum<GeneratedCodeInfo_Annotation_Semantic>(
+ GeneratedCodeInfo_Annotation_Semantic_descriptor(), name, value);
+}
+
// ===================================================================
+
+// -------------------------------------------------------------------
+
class PROTOBUF_EXPORT FileDescriptorSet final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorSet) */ {
public:
@@ -395,7 +554,7 @@ class PROTOBUF_EXPORT FileDescriptorSet final :
}
void UnsafeArenaSwap(FileDescriptorSet* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -416,26 +575,25 @@ class PROTOBUF_EXPORT FileDescriptorSet final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(FileDescriptorSet* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.FileDescriptorSet";
}
protected:
- explicit FileDescriptorSet(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit FileDescriptorSet(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -454,8 +612,9 @@ class PROTOBUF_EXPORT FileDescriptorSet final :
int file_size() const;
private:
int _internal_file_size() const;
+
public:
- void clear_file();
+ void clear_file() ;
::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* mutable_file(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto >*
mutable_file();
@@ -467,7 +626,6 @@ class PROTOBUF_EXPORT FileDescriptorSet final :
::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* add_file();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto >&
file() const;
-
// @@protoc_insertion_point(class_scope:google.protobuf.FileDescriptorSet)
private:
class _Internal;
@@ -481,8 +639,7 @@ class PROTOBUF_EXPORT FileDescriptorSet final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT FileDescriptorProto final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorProto) */ {
@@ -559,7 +716,7 @@ class PROTOBUF_EXPORT FileDescriptorProto final :
}
void UnsafeArenaSwap(FileDescriptorProto* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -580,26 +737,25 @@ class PROTOBUF_EXPORT FileDescriptorProto final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(FileDescriptorProto* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.FileDescriptorProto";
}
protected:
- explicit FileDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit FileDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -622,6 +778,7 @@ class PROTOBUF_EXPORT FileDescriptorProto final :
kNameFieldNumber = 1,
kPackageFieldNumber = 2,
kSyntaxFieldNumber = 12,
+ kEditionFieldNumber = 13,
kOptionsFieldNumber = 8,
kSourceCodeInfoFieldNumber = 9,
};
@@ -629,32 +786,37 @@ class PROTOBUF_EXPORT FileDescriptorProto final :
int dependency_size() const;
private:
int _internal_dependency_size() const;
+
public:
- void clear_dependency();
+ void clear_dependency() ;
const TProtoStringType& dependency(int index) const;
TProtoStringType* mutable_dependency(int index);
void set_dependency(int index, const TProtoStringType& value);
void set_dependency(int index, TProtoStringType&& value);
void set_dependency(int index, const char* value);
- void set_dependency(int index, const char* value, size_t size);
+ void set_dependency(int index, const char* value, std::size_t size);
+ void set_dependency(int index, y_absl::string_view value);
TProtoStringType* add_dependency();
void add_dependency(const TProtoStringType& value);
void add_dependency(TProtoStringType&& value);
void add_dependency(const char* value);
- void add_dependency(const char* value, size_t size);
+ void add_dependency(const char* value, std::size_t size);
+ void add_dependency(y_absl::string_view value);
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>& dependency() const;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>* mutable_dependency();
+
private:
const TProtoStringType& _internal_dependency(int index) const;
TProtoStringType* _internal_add_dependency();
- public:
+ public:
// repeated .google.protobuf.DescriptorProto message_type = 4;
int message_type_size() const;
private:
int _internal_message_type_size() const;
+
public:
- void clear_message_type();
+ void clear_message_type() ;
::PROTOBUF_NAMESPACE_ID::DescriptorProto* mutable_message_type(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto >*
mutable_message_type();
@@ -666,13 +828,13 @@ class PROTOBUF_EXPORT FileDescriptorProto final :
::PROTOBUF_NAMESPACE_ID::DescriptorProto* add_message_type();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto >&
message_type() const;
-
// repeated .google.protobuf.EnumDescriptorProto enum_type = 5;
int enum_type_size() const;
private:
int _internal_enum_type_size() const;
+
public:
- void clear_enum_type();
+ void clear_enum_type() ;
::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* mutable_enum_type(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto >*
mutable_enum_type();
@@ -684,13 +846,13 @@ class PROTOBUF_EXPORT FileDescriptorProto final :
::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* add_enum_type();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto >&
enum_type() const;
-
// repeated .google.protobuf.ServiceDescriptorProto service = 6;
int service_size() const;
private:
int _internal_service_size() const;
+
public:
- void clear_service();
+ void clear_service() ;
::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto* mutable_service(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto >*
mutable_service();
@@ -702,13 +864,13 @@ class PROTOBUF_EXPORT FileDescriptorProto final :
::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto* add_service();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto >&
service() const;
-
// repeated .google.protobuf.FieldDescriptorProto extension = 7;
int extension_size() const;
private:
int _internal_extension_size() const;
+
public:
- void clear_extension();
+ void clear_extension() ;
::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* mutable_extension(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto >*
mutable_extension();
@@ -720,111 +882,133 @@ class PROTOBUF_EXPORT FileDescriptorProto final :
::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* add_extension();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto >&
extension() const;
-
// repeated int32 public_dependency = 10;
int public_dependency_size() const;
private:
int _internal_public_dependency_size() const;
+
public:
- void clear_public_dependency();
+ void clear_public_dependency() ;
+ ::arc_i32 public_dependency(int index) const;
+ void set_public_dependency(int index, ::arc_i32 value);
+ void add_public_dependency(::arc_i32 value);
+ const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>& public_dependency() const;
+ ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>* mutable_public_dependency();
+
private:
- arc_i32 _internal_public_dependency(int index) const;
- const ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >&
- _internal_public_dependency() const;
- void _internal_add_public_dependency(arc_i32 value);
- ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >*
- _internal_mutable_public_dependency();
- public:
- arc_i32 public_dependency(int index) const;
- void set_public_dependency(int index, arc_i32 value);
- void add_public_dependency(arc_i32 value);
- const ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >&
- public_dependency() const;
- ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >*
- mutable_public_dependency();
+ ::arc_i32 _internal_public_dependency(int index) const;
+ void _internal_add_public_dependency(::arc_i32 value);
+ const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>& _internal_public_dependency() const;
+ ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>* _internal_mutable_public_dependency();
+ public:
// repeated int32 weak_dependency = 11;
int weak_dependency_size() const;
private:
int _internal_weak_dependency_size() const;
+
public:
- void clear_weak_dependency();
+ void clear_weak_dependency() ;
+ ::arc_i32 weak_dependency(int index) const;
+ void set_weak_dependency(int index, ::arc_i32 value);
+ void add_weak_dependency(::arc_i32 value);
+ const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>& weak_dependency() const;
+ ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>* mutable_weak_dependency();
+
private:
- arc_i32 _internal_weak_dependency(int index) const;
- const ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >&
- _internal_weak_dependency() const;
- void _internal_add_weak_dependency(arc_i32 value);
- ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >*
- _internal_mutable_weak_dependency();
- public:
- arc_i32 weak_dependency(int index) const;
- void set_weak_dependency(int index, arc_i32 value);
- void add_weak_dependency(arc_i32 value);
- const ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >&
- weak_dependency() const;
- ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >*
- mutable_weak_dependency();
+ ::arc_i32 _internal_weak_dependency(int index) const;
+ void _internal_add_weak_dependency(::arc_i32 value);
+ const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>& _internal_weak_dependency() const;
+ ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>* _internal_mutable_weak_dependency();
+ public:
// optional string name = 1;
bool has_name() const;
- private:
- bool _internal_has_name() const;
- public:
- void clear_name();
+ void clear_name() ;
const TProtoStringType& name() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_name(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_name(Arg_&& arg, Args_... args);
TProtoStringType* mutable_name();
PROTOBUF_NODISCARD TProtoStringType* release_name();
- void set_allocated_name(TProtoStringType* name);
+ void set_allocated_name(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_name() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_name();
- public:
+ public:
// optional string package = 2;
bool has_package() const;
- private:
- bool _internal_has_package() const;
- public:
- void clear_package();
+ void clear_package() ;
const TProtoStringType& package() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_package(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_package(Arg_&& arg, Args_... args);
TProtoStringType* mutable_package();
PROTOBUF_NODISCARD TProtoStringType* release_package();
- void set_allocated_package(TProtoStringType* package);
+ void set_allocated_package(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_package() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_package(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_package(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_package();
- public:
+ public:
// optional string syntax = 12;
bool has_syntax() const;
- private:
- bool _internal_has_syntax() const;
- public:
- void clear_syntax();
+ void clear_syntax() ;
const TProtoStringType& syntax() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_syntax(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_syntax(Arg_&& arg, Args_... args);
TProtoStringType* mutable_syntax();
PROTOBUF_NODISCARD TProtoStringType* release_syntax();
- void set_allocated_syntax(TProtoStringType* syntax);
+ void set_allocated_syntax(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_syntax() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_syntax(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_syntax(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_syntax();
+
public:
+ // optional string edition = 13;
+ bool has_edition() const;
+ void clear_edition() ;
+ const TProtoStringType& edition() const;
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_edition(Arg_&& arg, Args_... args);
+ TProtoStringType* mutable_edition();
+ PROTOBUF_NODISCARD TProtoStringType* release_edition();
+ void set_allocated_edition(TProtoStringType* ptr);
- // optional .google.protobuf.FileOptions options = 8;
- bool has_options() const;
private:
- bool _internal_has_options() const;
+ const TProtoStringType& _internal_edition() const;
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_edition(
+ const TProtoStringType& value);
+ TProtoStringType* _internal_mutable_edition();
+
public:
- void clear_options();
+ // optional .google.protobuf.FileOptions options = 8;
+ bool has_options() const;
+ void clear_options() ;
const ::PROTOBUF_NAMESPACE_ID::FileOptions& options() const;
PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::FileOptions* release_options();
::PROTOBUF_NAMESPACE_ID::FileOptions* mutable_options();
@@ -836,13 +1020,9 @@ class PROTOBUF_EXPORT FileDescriptorProto final :
void unsafe_arena_set_allocated_options(
::PROTOBUF_NAMESPACE_ID::FileOptions* options);
::PROTOBUF_NAMESPACE_ID::FileOptions* unsafe_arena_release_options();
-
// optional .google.protobuf.SourceCodeInfo source_code_info = 9;
bool has_source_code_info() const;
- private:
- bool _internal_has_source_code_info() const;
- public:
- void clear_source_code_info();
+ void clear_source_code_info() ;
const ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo& source_code_info() const;
PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* release_source_code_info();
::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* mutable_source_code_info();
@@ -854,7 +1034,6 @@ class PROTOBUF_EXPORT FileDescriptorProto final :
void unsafe_arena_set_allocated_source_code_info(
::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* source_code_info);
::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* unsafe_arena_release_source_code_info();
-
// @@protoc_insertion_point(class_scope:google.protobuf.FileDescriptorProto)
private:
class _Internal;
@@ -870,18 +1049,18 @@ class PROTOBUF_EXPORT FileDescriptorProto final :
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto > enum_type_;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto > service_;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto > extension_;
- ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 > public_dependency_;
- ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 > weak_dependency_;
+ ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32> public_dependency_;
+ ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32> weak_dependency_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr package_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr syntax_;
+ ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr edition_;
::PROTOBUF_NAMESPACE_ID::FileOptions* options_;
::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* source_code_info_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ExtensionRange) */ {
@@ -958,7 +1137,7 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final :
}
void UnsafeArenaSwap(DescriptorProto_ExtensionRange* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -979,26 +1158,25 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(DescriptorProto_ExtensionRange* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.DescriptorProto.ExtensionRange";
}
protected:
- explicit DescriptorProto_ExtensionRange(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit DescriptorProto_ExtensionRange(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -1017,10 +1195,7 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final :
};
// optional .google.protobuf.ExtensionRangeOptions options = 3;
bool has_options() const;
- private:
- bool _internal_has_options() const;
- public:
- void clear_options();
+ void clear_options() ;
const ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions& options() const;
PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* release_options();
::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* mutable_options();
@@ -1032,33 +1207,28 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final :
void unsafe_arena_set_allocated_options(
::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* options);
::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* unsafe_arena_release_options();
-
// optional int32 start = 1;
bool has_start() const;
+ void clear_start() ;
+ ::arc_i32 start() const;
+ void set_start(::arc_i32 value);
+
private:
- bool _internal_has_start() const;
- public:
- void clear_start();
- arc_i32 start() const;
- void set_start(arc_i32 value);
- private:
- arc_i32 _internal_start() const;
- void _internal_set_start(arc_i32 value);
- public:
+ ::arc_i32 _internal_start() const;
+ void _internal_set_start(::arc_i32 value);
+ public:
// optional int32 end = 2;
bool has_end() const;
+ void clear_end() ;
+ ::arc_i32 end() const;
+ void set_end(::arc_i32 value);
+
private:
- bool _internal_has_end() const;
- public:
- void clear_end();
- arc_i32 end() const;
- void set_end(arc_i32 value);
- private:
- arc_i32 _internal_end() const;
- void _internal_set_end(arc_i32 value);
- public:
+ ::arc_i32 _internal_end() const;
+ void _internal_set_end(::arc_i32 value);
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.DescriptorProto.ExtensionRange)
private:
class _Internal;
@@ -1070,13 +1240,12 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final :
::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* options_;
- arc_i32 start_;
- arc_i32 end_;
+ ::arc_i32 start_;
+ ::arc_i32 end_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT DescriptorProto_ReservedRange final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ReservedRange) */ {
@@ -1153,7 +1322,7 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange final :
}
void UnsafeArenaSwap(DescriptorProto_ReservedRange* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -1174,26 +1343,25 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(DescriptorProto_ReservedRange* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.DescriptorProto.ReservedRange";
}
protected:
- explicit DescriptorProto_ReservedRange(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit DescriptorProto_ReservedRange(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -1211,30 +1379,26 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange final :
};
// optional int32 start = 1;
bool has_start() const;
+ void clear_start() ;
+ ::arc_i32 start() const;
+ void set_start(::arc_i32 value);
+
private:
- bool _internal_has_start() const;
- public:
- void clear_start();
- arc_i32 start() const;
- void set_start(arc_i32 value);
- private:
- arc_i32 _internal_start() const;
- void _internal_set_start(arc_i32 value);
- public:
+ ::arc_i32 _internal_start() const;
+ void _internal_set_start(::arc_i32 value);
+ public:
// optional int32 end = 2;
bool has_end() const;
+ void clear_end() ;
+ ::arc_i32 end() const;
+ void set_end(::arc_i32 value);
+
private:
- bool _internal_has_end() const;
- public:
- void clear_end();
- arc_i32 end() const;
- void set_end(arc_i32 value);
- private:
- arc_i32 _internal_end() const;
- void _internal_set_end(arc_i32 value);
- public:
+ ::arc_i32 _internal_end() const;
+ void _internal_set_end(::arc_i32 value);
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.DescriptorProto.ReservedRange)
private:
class _Internal;
@@ -1245,13 +1409,12 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange final :
struct Impl_ {
::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
- arc_i32 start_;
- arc_i32 end_;
+ ::arc_i32 start_;
+ ::arc_i32 end_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT DescriptorProto final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto) */ {
@@ -1328,7 +1491,7 @@ class PROTOBUF_EXPORT DescriptorProto final :
}
void UnsafeArenaSwap(DescriptorProto* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -1349,26 +1512,25 @@ class PROTOBUF_EXPORT DescriptorProto final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(DescriptorProto* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.DescriptorProto";
}
protected:
- explicit DescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit DescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -1399,8 +1561,9 @@ class PROTOBUF_EXPORT DescriptorProto final :
int field_size() const;
private:
int _internal_field_size() const;
+
public:
- void clear_field();
+ void clear_field() ;
::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* mutable_field(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto >*
mutable_field();
@@ -1412,13 +1575,13 @@ class PROTOBUF_EXPORT DescriptorProto final :
::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* add_field();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto >&
field() const;
-
// repeated .google.protobuf.DescriptorProto nested_type = 3;
int nested_type_size() const;
private:
int _internal_nested_type_size() const;
+
public:
- void clear_nested_type();
+ void clear_nested_type() ;
::PROTOBUF_NAMESPACE_ID::DescriptorProto* mutable_nested_type(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto >*
mutable_nested_type();
@@ -1430,13 +1593,13 @@ class PROTOBUF_EXPORT DescriptorProto final :
::PROTOBUF_NAMESPACE_ID::DescriptorProto* add_nested_type();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto >&
nested_type() const;
-
// repeated .google.protobuf.EnumDescriptorProto enum_type = 4;
int enum_type_size() const;
private:
int _internal_enum_type_size() const;
+
public:
- void clear_enum_type();
+ void clear_enum_type() ;
::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* mutable_enum_type(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto >*
mutable_enum_type();
@@ -1448,13 +1611,13 @@ class PROTOBUF_EXPORT DescriptorProto final :
::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* add_enum_type();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto >&
enum_type() const;
-
// repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;
int extension_range_size() const;
private:
int _internal_extension_range_size() const;
+
public:
- void clear_extension_range();
+ void clear_extension_range() ;
::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange* mutable_extension_range(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange >*
mutable_extension_range();
@@ -1466,13 +1629,13 @@ class PROTOBUF_EXPORT DescriptorProto final :
::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange* add_extension_range();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange >&
extension_range() const;
-
// repeated .google.protobuf.FieldDescriptorProto extension = 6;
int extension_size() const;
private:
int _internal_extension_size() const;
+
public:
- void clear_extension();
+ void clear_extension() ;
::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* mutable_extension(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto >*
mutable_extension();
@@ -1484,13 +1647,13 @@ class PROTOBUF_EXPORT DescriptorProto final :
::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* add_extension();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto >&
extension() const;
-
// repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;
int oneof_decl_size() const;
private:
int _internal_oneof_decl_size() const;
+
public:
- void clear_oneof_decl();
+ void clear_oneof_decl() ;
::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto* mutable_oneof_decl(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto >*
mutable_oneof_decl();
@@ -1502,13 +1665,13 @@ class PROTOBUF_EXPORT DescriptorProto final :
::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto* add_oneof_decl();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto >&
oneof_decl() const;
-
// repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;
int reserved_range_size() const;
private:
int _internal_reserved_range_size() const;
+
public:
- void clear_reserved_range();
+ void clear_reserved_range() ;
::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange* mutable_reserved_range(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange >*
mutable_reserved_range();
@@ -1520,55 +1683,58 @@ class PROTOBUF_EXPORT DescriptorProto final :
::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange* add_reserved_range();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange >&
reserved_range() const;
-
// repeated string reserved_name = 10;
int reserved_name_size() const;
private:
int _internal_reserved_name_size() const;
+
public:
- void clear_reserved_name();
+ void clear_reserved_name() ;
const TProtoStringType& reserved_name(int index) const;
TProtoStringType* mutable_reserved_name(int index);
void set_reserved_name(int index, const TProtoStringType& value);
void set_reserved_name(int index, TProtoStringType&& value);
void set_reserved_name(int index, const char* value);
- void set_reserved_name(int index, const char* value, size_t size);
+ void set_reserved_name(int index, const char* value, std::size_t size);
+ void set_reserved_name(int index, y_absl::string_view value);
TProtoStringType* add_reserved_name();
void add_reserved_name(const TProtoStringType& value);
void add_reserved_name(TProtoStringType&& value);
void add_reserved_name(const char* value);
- void add_reserved_name(const char* value, size_t size);
+ void add_reserved_name(const char* value, std::size_t size);
+ void add_reserved_name(y_absl::string_view value);
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>& reserved_name() const;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>* mutable_reserved_name();
+
private:
const TProtoStringType& _internal_reserved_name(int index) const;
TProtoStringType* _internal_add_reserved_name();
- public:
+ public:
// optional string name = 1;
bool has_name() const;
- private:
- bool _internal_has_name() const;
- public:
- void clear_name();
+ void clear_name() ;
const TProtoStringType& name() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_name(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_name(Arg_&& arg, Args_... args);
TProtoStringType* mutable_name();
PROTOBUF_NODISCARD TProtoStringType* release_name();
- void set_allocated_name(TProtoStringType* name);
+ void set_allocated_name(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_name() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_name();
- public:
+ public:
// optional .google.protobuf.MessageOptions options = 7;
bool has_options() const;
- private:
- bool _internal_has_options() const;
- public:
- void clear_options();
+ void clear_options() ;
const ::PROTOBUF_NAMESPACE_ID::MessageOptions& options() const;
PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::MessageOptions* release_options();
::PROTOBUF_NAMESPACE_ID::MessageOptions* mutable_options();
@@ -1580,7 +1746,6 @@ class PROTOBUF_EXPORT DescriptorProto final :
void unsafe_arena_set_allocated_options(
::PROTOBUF_NAMESPACE_ID::MessageOptions* options);
::PROTOBUF_NAMESPACE_ID::MessageOptions* unsafe_arena_release_options();
-
// @@protoc_insertion_point(class_scope:google.protobuf.DescriptorProto)
private:
class _Internal;
@@ -1604,8 +1769,7 @@ class PROTOBUF_EXPORT DescriptorProto final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT ExtensionRangeOptions final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ExtensionRangeOptions) */ {
@@ -1682,7 +1846,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final :
}
void UnsafeArenaSwap(ExtensionRangeOptions* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -1703,26 +1867,25 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(ExtensionRangeOptions* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.ExtensionRangeOptions";
}
protected:
- explicit ExtensionRangeOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit ExtensionRangeOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -1741,8 +1904,9 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final :
int uninterpreted_option_size() const;
private:
int _internal_uninterpreted_option_size() const;
+
public:
- void clear_uninterpreted_option();
+ void clear_uninterpreted_option() ;
::PROTOBUF_NAMESPACE_ID::UninterpretedOption* mutable_uninterpreted_option(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >*
mutable_uninterpreted_option();
@@ -1754,197 +1918,157 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final :
::PROTOBUF_NAMESPACE_ID::UninterpretedOption* add_uninterpreted_option();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >&
uninterpreted_option() const;
-
-
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline bool HasExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ExtensionRangeOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _impl_._extensions_.Has(id.number());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void ClearExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ExtensionRangeOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
_impl_._extensions_.ClearExtension(id.number());
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline int ExtensionSize(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ExtensionRangeOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _impl_._extensions_.ExtensionSize(id.number());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::ConstType GetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
- return _proto_TypeTraits::Get(id.number(), _impl_._extensions_,
- id.default_value());
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ExtensionRangeOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
+ return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, id.default_value());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::MutableType MutableExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
- return _proto_TypeTraits::Mutable(id.number(), _field_type,
- &_impl_._extensions_);
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ExtensionRangeOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ return _proto_TypeTraits::Mutable(id.number(), _field_type, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ExtensionRangeOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::ConstType value) {
_proto_TypeTraits::Set(id.number(), _field_type, value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetAllocatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ExtensionRangeOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::SetAllocated(id.number(), _field_type, value,
&_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void UnsafeArenaSetAllocatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ExtensionRangeOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type,
value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
PROTOBUF_NODISCARD inline
typename _proto_TypeTraits::Singular::MutableType
ReleaseExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
- return _proto_TypeTraits::Release(id.number(), _field_type,
- &_impl_._extensions_);
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ExtensionRangeOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ return _proto_TypeTraits::Release(id.number(), _field_type, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::MutableType
UnsafeArenaReleaseExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ExtensionRangeOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type,
&_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::ConstType GetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ExtensionRangeOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index) const {
-
return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, index);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::MutableType MutableExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ExtensionRangeOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index) {
-
return _proto_TypeTraits::Mutable(id.number(), index, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ExtensionRangeOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index, typename _proto_TypeTraits::Repeated::ConstType value) {
_proto_TypeTraits::Set(id.number(), index, value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::MutableType AddExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ExtensionRangeOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
typename _proto_TypeTraits::Repeated::MutableType to_add =
_proto_TypeTraits::Add(id.number(), _field_type, &_impl_._extensions_);
-
return to_add;
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void AddExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ExtensionRangeOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Repeated::ConstType value) {
_proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value,
&_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline const typename _proto_TypeTraits::Repeated::RepeatedFieldType&
GetRepeatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ExtensionRangeOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _proto_TypeTraits::GetRepeated(id.number(), _impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::RepeatedFieldType*
MutableRepeatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ExtensionRangeOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
return _proto_TypeTraits::MutableRepeated(id.number(), _field_type,
_is_packed, &_impl_._extensions_);
}
-
// @@protoc_insertion_point(class_scope:google.protobuf.ExtensionRangeOptions)
private:
class _Internal;
@@ -1960,8 +2084,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT FieldDescriptorProto final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldDescriptorProto) */ {
@@ -2038,7 +2161,7 @@ class PROTOBUF_EXPORT FieldDescriptorProto final :
}
void UnsafeArenaSwap(FieldDescriptorProto* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -2059,26 +2182,25 @@ class PROTOBUF_EXPORT FieldDescriptorProto final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(FieldDescriptorProto* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.FieldDescriptorProto";
}
protected:
- explicit FieldDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit FieldDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -2088,97 +2210,60 @@ class PROTOBUF_EXPORT FieldDescriptorProto final :
// nested types ----------------------------------------------------
- typedef FieldDescriptorProto_Type Type;
- static constexpr Type TYPE_DOUBLE =
- FieldDescriptorProto_Type_TYPE_DOUBLE;
- static constexpr Type TYPE_FLOAT =
- FieldDescriptorProto_Type_TYPE_FLOAT;
- static constexpr Type TYPE_INT64 =
- FieldDescriptorProto_Type_TYPE_INT64;
- static constexpr Type TYPE_UINT64 =
- FieldDescriptorProto_Type_TYPE_UINT64;
- static constexpr Type TYPE_INT32 =
- FieldDescriptorProto_Type_TYPE_INT32;
- static constexpr Type TYPE_FIXED64 =
- FieldDescriptorProto_Type_TYPE_FIXED64;
- static constexpr Type TYPE_FIXED32 =
- FieldDescriptorProto_Type_TYPE_FIXED32;
- static constexpr Type TYPE_BOOL =
- FieldDescriptorProto_Type_TYPE_BOOL;
- static constexpr Type TYPE_STRING =
- FieldDescriptorProto_Type_TYPE_STRING;
- static constexpr Type TYPE_GROUP =
- FieldDescriptorProto_Type_TYPE_GROUP;
- static constexpr Type TYPE_MESSAGE =
- FieldDescriptorProto_Type_TYPE_MESSAGE;
- static constexpr Type TYPE_BYTES =
- FieldDescriptorProto_Type_TYPE_BYTES;
- static constexpr Type TYPE_UINT32 =
- FieldDescriptorProto_Type_TYPE_UINT32;
- static constexpr Type TYPE_ENUM =
- FieldDescriptorProto_Type_TYPE_ENUM;
- static constexpr Type TYPE_SFIXED32 =
- FieldDescriptorProto_Type_TYPE_SFIXED32;
- static constexpr Type TYPE_SFIXED64 =
- FieldDescriptorProto_Type_TYPE_SFIXED64;
- static constexpr Type TYPE_SINT32 =
- FieldDescriptorProto_Type_TYPE_SINT32;
- static constexpr Type TYPE_SINT64 =
- FieldDescriptorProto_Type_TYPE_SINT64;
+ using Type = FieldDescriptorProto_Type;
+ static constexpr Type TYPE_DOUBLE = FieldDescriptorProto_Type_TYPE_DOUBLE;
+ static constexpr Type TYPE_FLOAT = FieldDescriptorProto_Type_TYPE_FLOAT;
+ static constexpr Type TYPE_INT64 = FieldDescriptorProto_Type_TYPE_INT64;
+ static constexpr Type TYPE_UINT64 = FieldDescriptorProto_Type_TYPE_UINT64;
+ static constexpr Type TYPE_INT32 = FieldDescriptorProto_Type_TYPE_INT32;
+ static constexpr Type TYPE_FIXED64 = FieldDescriptorProto_Type_TYPE_FIXED64;
+ static constexpr Type TYPE_FIXED32 = FieldDescriptorProto_Type_TYPE_FIXED32;
+ static constexpr Type TYPE_BOOL = FieldDescriptorProto_Type_TYPE_BOOL;
+ static constexpr Type TYPE_STRING = FieldDescriptorProto_Type_TYPE_STRING;
+ static constexpr Type TYPE_GROUP = FieldDescriptorProto_Type_TYPE_GROUP;
+ static constexpr Type TYPE_MESSAGE = FieldDescriptorProto_Type_TYPE_MESSAGE;
+ static constexpr Type TYPE_BYTES = FieldDescriptorProto_Type_TYPE_BYTES;
+ static constexpr Type TYPE_UINT32 = FieldDescriptorProto_Type_TYPE_UINT32;
+ static constexpr Type TYPE_ENUM = FieldDescriptorProto_Type_TYPE_ENUM;
+ static constexpr Type TYPE_SFIXED32 = FieldDescriptorProto_Type_TYPE_SFIXED32;
+ static constexpr Type TYPE_SFIXED64 = FieldDescriptorProto_Type_TYPE_SFIXED64;
+ static constexpr Type TYPE_SINT32 = FieldDescriptorProto_Type_TYPE_SINT32;
+ static constexpr Type TYPE_SINT64 = FieldDescriptorProto_Type_TYPE_SINT64;
static inline bool Type_IsValid(int value) {
return FieldDescriptorProto_Type_IsValid(value);
}
- static constexpr Type Type_MIN =
- FieldDescriptorProto_Type_Type_MIN;
- static constexpr Type Type_MAX =
- FieldDescriptorProto_Type_Type_MAX;
- static constexpr int Type_ARRAYSIZE =
- FieldDescriptorProto_Type_Type_ARRAYSIZE;
- static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
- Type_descriptor() {
+ static constexpr Type Type_MIN = FieldDescriptorProto_Type_Type_MIN;
+ static constexpr Type Type_MAX = FieldDescriptorProto_Type_Type_MAX;
+ static constexpr int Type_ARRAYSIZE = FieldDescriptorProto_Type_Type_ARRAYSIZE;
+ static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Type_descriptor() {
return FieldDescriptorProto_Type_descriptor();
}
- template<typename T>
- static inline const TProtoStringType& Type_Name(T enum_t_value) {
- static_assert(::std::is_same<T, Type>::value ||
- ::std::is_integral<T>::value,
- "Incorrect type passed to function Type_Name.");
- return FieldDescriptorProto_Type_Name(enum_t_value);
+ template <typename T>
+ static inline const TProtoStringType& Type_Name(T value) {
+ return FieldDescriptorProto_Type_Name(value);
}
- static inline bool Type_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name,
- Type* value) {
+ static inline bool Type_Parse(y_absl::string_view name, Type* value) {
return FieldDescriptorProto_Type_Parse(name, value);
}
- typedef FieldDescriptorProto_Label Label;
- static constexpr Label LABEL_OPTIONAL =
- FieldDescriptorProto_Label_LABEL_OPTIONAL;
- static constexpr Label LABEL_REQUIRED =
- FieldDescriptorProto_Label_LABEL_REQUIRED;
- static constexpr Label LABEL_REPEATED =
- FieldDescriptorProto_Label_LABEL_REPEATED;
+ using Label = FieldDescriptorProto_Label;
+ static constexpr Label LABEL_OPTIONAL = FieldDescriptorProto_Label_LABEL_OPTIONAL;
+ static constexpr Label LABEL_REQUIRED = FieldDescriptorProto_Label_LABEL_REQUIRED;
+ static constexpr Label LABEL_REPEATED = FieldDescriptorProto_Label_LABEL_REPEATED;
static inline bool Label_IsValid(int value) {
return FieldDescriptorProto_Label_IsValid(value);
}
- static constexpr Label Label_MIN =
- FieldDescriptorProto_Label_Label_MIN;
- static constexpr Label Label_MAX =
- FieldDescriptorProto_Label_Label_MAX;
- static constexpr int Label_ARRAYSIZE =
- FieldDescriptorProto_Label_Label_ARRAYSIZE;
- static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
- Label_descriptor() {
+ static constexpr Label Label_MIN = FieldDescriptorProto_Label_Label_MIN;
+ static constexpr Label Label_MAX = FieldDescriptorProto_Label_Label_MAX;
+ static constexpr int Label_ARRAYSIZE = FieldDescriptorProto_Label_Label_ARRAYSIZE;
+ static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Label_descriptor() {
return FieldDescriptorProto_Label_descriptor();
}
- template<typename T>
- static inline const TProtoStringType& Label_Name(T enum_t_value) {
- static_assert(::std::is_same<T, Label>::value ||
- ::std::is_integral<T>::value,
- "Incorrect type passed to function Label_Name.");
- return FieldDescriptorProto_Label_Name(enum_t_value);
+ template <typename T>
+ static inline const TProtoStringType& Label_Name(T value) {
+ return FieldDescriptorProto_Label_Name(value);
}
- static inline bool Label_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name,
- Label* value) {
+ static inline bool Label_Parse(y_absl::string_view name, Label* value) {
return FieldDescriptorProto_Label_Parse(name, value);
}
@@ -2199,100 +2284,112 @@ class PROTOBUF_EXPORT FieldDescriptorProto final :
};
// optional string name = 1;
bool has_name() const;
- private:
- bool _internal_has_name() const;
- public:
- void clear_name();
+ void clear_name() ;
const TProtoStringType& name() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_name(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_name(Arg_&& arg, Args_... args);
TProtoStringType* mutable_name();
PROTOBUF_NODISCARD TProtoStringType* release_name();
- void set_allocated_name(TProtoStringType* name);
+ void set_allocated_name(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_name() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_name();
- public:
+ public:
// optional string extendee = 2;
bool has_extendee() const;
- private:
- bool _internal_has_extendee() const;
- public:
- void clear_extendee();
+ void clear_extendee() ;
const TProtoStringType& extendee() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_extendee(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_extendee(Arg_&& arg, Args_... args);
TProtoStringType* mutable_extendee();
PROTOBUF_NODISCARD TProtoStringType* release_extendee();
- void set_allocated_extendee(TProtoStringType* extendee);
+ void set_allocated_extendee(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_extendee() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_extendee(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_extendee(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_extendee();
- public:
+ public:
// optional string type_name = 6;
bool has_type_name() const;
- private:
- bool _internal_has_type_name() const;
- public:
- void clear_type_name();
+ void clear_type_name() ;
const TProtoStringType& type_name() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_type_name(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_type_name(Arg_&& arg, Args_... args);
TProtoStringType* mutable_type_name();
PROTOBUF_NODISCARD TProtoStringType* release_type_name();
- void set_allocated_type_name(TProtoStringType* type_name);
+ void set_allocated_type_name(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_type_name() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_type_name(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_type_name(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_type_name();
- public:
+ public:
// optional string default_value = 7;
bool has_default_value() const;
- private:
- bool _internal_has_default_value() const;
- public:
- void clear_default_value();
+ void clear_default_value() ;
const TProtoStringType& default_value() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_default_value(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_default_value(Arg_&& arg, Args_... args);
TProtoStringType* mutable_default_value();
PROTOBUF_NODISCARD TProtoStringType* release_default_value();
- void set_allocated_default_value(TProtoStringType* default_value);
+ void set_allocated_default_value(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_default_value() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_default_value(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_default_value(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_default_value();
- public:
+ public:
// optional string json_name = 10;
bool has_json_name() const;
- private:
- bool _internal_has_json_name() const;
- public:
- void clear_json_name();
+ void clear_json_name() ;
const TProtoStringType& json_name() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_json_name(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_json_name(Arg_&& arg, Args_... args);
TProtoStringType* mutable_json_name();
PROTOBUF_NODISCARD TProtoStringType* release_json_name();
- void set_allocated_json_name(TProtoStringType* json_name);
+ void set_allocated_json_name(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_json_name() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_json_name(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_json_name(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_json_name();
- public:
+ public:
// optional .google.protobuf.FieldOptions options = 8;
bool has_options() const;
- private:
- bool _internal_has_options() const;
- public:
- void clear_options();
+ void clear_options() ;
const ::PROTOBUF_NAMESPACE_ID::FieldOptions& options() const;
PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::FieldOptions* release_options();
::PROTOBUF_NAMESPACE_ID::FieldOptions* mutable_options();
@@ -2304,72 +2401,61 @@ class PROTOBUF_EXPORT FieldDescriptorProto final :
void unsafe_arena_set_allocated_options(
::PROTOBUF_NAMESPACE_ID::FieldOptions* options);
::PROTOBUF_NAMESPACE_ID::FieldOptions* unsafe_arena_release_options();
-
// optional int32 number = 3;
bool has_number() const;
+ void clear_number() ;
+ ::arc_i32 number() const;
+ void set_number(::arc_i32 value);
+
private:
- bool _internal_has_number() const;
- public:
- void clear_number();
- arc_i32 number() const;
- void set_number(arc_i32 value);
- private:
- arc_i32 _internal_number() const;
- void _internal_set_number(arc_i32 value);
- public:
+ ::arc_i32 _internal_number() const;
+ void _internal_set_number(::arc_i32 value);
+ public:
// optional int32 oneof_index = 9;
bool has_oneof_index() const;
+ void clear_oneof_index() ;
+ ::arc_i32 oneof_index() const;
+ void set_oneof_index(::arc_i32 value);
+
private:
- bool _internal_has_oneof_index() const;
- public:
- void clear_oneof_index();
- arc_i32 oneof_index() const;
- void set_oneof_index(arc_i32 value);
- private:
- arc_i32 _internal_oneof_index() const;
- void _internal_set_oneof_index(arc_i32 value);
- public:
+ ::arc_i32 _internal_oneof_index() const;
+ void _internal_set_oneof_index(::arc_i32 value);
+ public:
// optional bool proto3_optional = 17;
bool has_proto3_optional() const;
- private:
- bool _internal_has_proto3_optional() const;
- public:
- void clear_proto3_optional();
+ void clear_proto3_optional() ;
bool proto3_optional() const;
void set_proto3_optional(bool value);
+
private:
bool _internal_proto3_optional() const;
void _internal_set_proto3_optional(bool value);
- public:
+ public:
// optional .google.protobuf.FieldDescriptorProto.Label label = 4;
bool has_label() const;
- private:
- bool _internal_has_label() const;
- public:
- void clear_label();
+ void clear_label() ;
::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label label() const;
void set_label(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label value);
+
private:
::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label _internal_label() const;
void _internal_set_label(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label value);
- public:
+ public:
// optional .google.protobuf.FieldDescriptorProto.Type type = 5;
bool has_type() const;
- private:
- bool _internal_has_type() const;
- public:
- void clear_type();
+ void clear_type() ;
::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type type() const;
void set_type(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type value);
+
private:
::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type _internal_type() const;
void _internal_set_type(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type value);
- public:
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.FieldDescriptorProto)
private:
class _Internal;
@@ -2386,16 +2472,15 @@ class PROTOBUF_EXPORT FieldDescriptorProto final :
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr default_value_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr json_name_;
::PROTOBUF_NAMESPACE_ID::FieldOptions* options_;
- arc_i32 number_;
- arc_i32 oneof_index_;
+ ::arc_i32 number_;
+ ::arc_i32 oneof_index_;
bool proto3_optional_;
int label_;
int type_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT OneofDescriptorProto final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofDescriptorProto) */ {
@@ -2472,7 +2557,7 @@ class PROTOBUF_EXPORT OneofDescriptorProto final :
}
void UnsafeArenaSwap(OneofDescriptorProto* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -2493,26 +2578,25 @@ class PROTOBUF_EXPORT OneofDescriptorProto final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(OneofDescriptorProto* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.OneofDescriptorProto";
}
protected:
- explicit OneofDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit OneofDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -2530,28 +2614,28 @@ class PROTOBUF_EXPORT OneofDescriptorProto final :
};
// optional string name = 1;
bool has_name() const;
- private:
- bool _internal_has_name() const;
- public:
- void clear_name();
+ void clear_name() ;
const TProtoStringType& name() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_name(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_name(Arg_&& arg, Args_... args);
TProtoStringType* mutable_name();
PROTOBUF_NODISCARD TProtoStringType* release_name();
- void set_allocated_name(TProtoStringType* name);
+ void set_allocated_name(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_name() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_name();
- public:
+ public:
// optional .google.protobuf.OneofOptions options = 2;
bool has_options() const;
- private:
- bool _internal_has_options() const;
- public:
- void clear_options();
+ void clear_options() ;
const ::PROTOBUF_NAMESPACE_ID::OneofOptions& options() const;
PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::OneofOptions* release_options();
::PROTOBUF_NAMESPACE_ID::OneofOptions* mutable_options();
@@ -2563,7 +2647,6 @@ class PROTOBUF_EXPORT OneofDescriptorProto final :
void unsafe_arena_set_allocated_options(
::PROTOBUF_NAMESPACE_ID::OneofOptions* options);
::PROTOBUF_NAMESPACE_ID::OneofOptions* unsafe_arena_release_options();
-
// @@protoc_insertion_point(class_scope:google.protobuf.OneofDescriptorProto)
private:
class _Internal;
@@ -2579,8 +2662,7 @@ class PROTOBUF_EXPORT OneofDescriptorProto final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumDescriptorProto.EnumReservedRange) */ {
@@ -2657,7 +2739,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final :
}
void UnsafeArenaSwap(EnumDescriptorProto_EnumReservedRange* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -2678,26 +2760,25 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(EnumDescriptorProto_EnumReservedRange* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.EnumDescriptorProto.EnumReservedRange";
}
protected:
- explicit EnumDescriptorProto_EnumReservedRange(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit EnumDescriptorProto_EnumReservedRange(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -2715,30 +2796,26 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final :
};
// optional int32 start = 1;
bool has_start() const;
+ void clear_start() ;
+ ::arc_i32 start() const;
+ void set_start(::arc_i32 value);
+
private:
- bool _internal_has_start() const;
- public:
- void clear_start();
- arc_i32 start() const;
- void set_start(arc_i32 value);
- private:
- arc_i32 _internal_start() const;
- void _internal_set_start(arc_i32 value);
- public:
+ ::arc_i32 _internal_start() const;
+ void _internal_set_start(::arc_i32 value);
+ public:
// optional int32 end = 2;
bool has_end() const;
+ void clear_end() ;
+ ::arc_i32 end() const;
+ void set_end(::arc_i32 value);
+
private:
- bool _internal_has_end() const;
- public:
- void clear_end();
- arc_i32 end() const;
- void set_end(arc_i32 value);
- private:
- arc_i32 _internal_end() const;
- void _internal_set_end(arc_i32 value);
- public:
+ ::arc_i32 _internal_end() const;
+ void _internal_set_end(::arc_i32 value);
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.EnumDescriptorProto.EnumReservedRange)
private:
class _Internal;
@@ -2749,13 +2826,12 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final :
struct Impl_ {
::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
- arc_i32 start_;
- arc_i32 end_;
+ ::arc_i32 start_;
+ ::arc_i32 end_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT EnumDescriptorProto final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumDescriptorProto) */ {
@@ -2832,7 +2908,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto final :
}
void UnsafeArenaSwap(EnumDescriptorProto* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -2853,26 +2929,25 @@ class PROTOBUF_EXPORT EnumDescriptorProto final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(EnumDescriptorProto* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.EnumDescriptorProto";
}
protected:
- explicit EnumDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit EnumDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -2897,8 +2972,9 @@ class PROTOBUF_EXPORT EnumDescriptorProto final :
int value_size() const;
private:
int _internal_value_size() const;
+
public:
- void clear_value();
+ void clear_value() ;
::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto* mutable_value(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto >*
mutable_value();
@@ -2910,13 +2986,13 @@ class PROTOBUF_EXPORT EnumDescriptorProto final :
::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto* add_value();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto >&
value() const;
-
// repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4;
int reserved_range_size() const;
private:
int _internal_reserved_range_size() const;
+
public:
- void clear_reserved_range();
+ void clear_reserved_range() ;
::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange* mutable_reserved_range(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange >*
mutable_reserved_range();
@@ -2928,55 +3004,58 @@ class PROTOBUF_EXPORT EnumDescriptorProto final :
::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange* add_reserved_range();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange >&
reserved_range() const;
-
// repeated string reserved_name = 5;
int reserved_name_size() const;
private:
int _internal_reserved_name_size() const;
+
public:
- void clear_reserved_name();
+ void clear_reserved_name() ;
const TProtoStringType& reserved_name(int index) const;
TProtoStringType* mutable_reserved_name(int index);
void set_reserved_name(int index, const TProtoStringType& value);
void set_reserved_name(int index, TProtoStringType&& value);
void set_reserved_name(int index, const char* value);
- void set_reserved_name(int index, const char* value, size_t size);
+ void set_reserved_name(int index, const char* value, std::size_t size);
+ void set_reserved_name(int index, y_absl::string_view value);
TProtoStringType* add_reserved_name();
void add_reserved_name(const TProtoStringType& value);
void add_reserved_name(TProtoStringType&& value);
void add_reserved_name(const char* value);
- void add_reserved_name(const char* value, size_t size);
+ void add_reserved_name(const char* value, std::size_t size);
+ void add_reserved_name(y_absl::string_view value);
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>& reserved_name() const;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>* mutable_reserved_name();
+
private:
const TProtoStringType& _internal_reserved_name(int index) const;
TProtoStringType* _internal_add_reserved_name();
- public:
+ public:
// optional string name = 1;
bool has_name() const;
- private:
- bool _internal_has_name() const;
- public:
- void clear_name();
+ void clear_name() ;
const TProtoStringType& name() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_name(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_name(Arg_&& arg, Args_... args);
TProtoStringType* mutable_name();
PROTOBUF_NODISCARD TProtoStringType* release_name();
- void set_allocated_name(TProtoStringType* name);
+ void set_allocated_name(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_name() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_name();
- public:
+ public:
// optional .google.protobuf.EnumOptions options = 3;
bool has_options() const;
- private:
- bool _internal_has_options() const;
- public:
- void clear_options();
+ void clear_options() ;
const ::PROTOBUF_NAMESPACE_ID::EnumOptions& options() const;
PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::EnumOptions* release_options();
::PROTOBUF_NAMESPACE_ID::EnumOptions* mutable_options();
@@ -2988,7 +3067,6 @@ class PROTOBUF_EXPORT EnumDescriptorProto final :
void unsafe_arena_set_allocated_options(
::PROTOBUF_NAMESPACE_ID::EnumOptions* options);
::PROTOBUF_NAMESPACE_ID::EnumOptions* unsafe_arena_release_options();
-
// @@protoc_insertion_point(class_scope:google.protobuf.EnumDescriptorProto)
private:
class _Internal;
@@ -3007,8 +3085,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT EnumValueDescriptorProto final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueDescriptorProto) */ {
@@ -3085,7 +3162,7 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto final :
}
void UnsafeArenaSwap(EnumValueDescriptorProto* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -3106,26 +3183,25 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(EnumValueDescriptorProto* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.EnumValueDescriptorProto";
}
protected:
- explicit EnumValueDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit EnumValueDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -3144,28 +3220,28 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto final :
};
// optional string name = 1;
bool has_name() const;
- private:
- bool _internal_has_name() const;
- public:
- void clear_name();
+ void clear_name() ;
const TProtoStringType& name() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_name(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_name(Arg_&& arg, Args_... args);
TProtoStringType* mutable_name();
PROTOBUF_NODISCARD TProtoStringType* release_name();
- void set_allocated_name(TProtoStringType* name);
+ void set_allocated_name(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_name() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_name();
- public:
+ public:
// optional .google.protobuf.EnumValueOptions options = 3;
bool has_options() const;
- private:
- bool _internal_has_options() const;
- public:
- void clear_options();
+ void clear_options() ;
const ::PROTOBUF_NAMESPACE_ID::EnumValueOptions& options() const;
PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* release_options();
::PROTOBUF_NAMESPACE_ID::EnumValueOptions* mutable_options();
@@ -3177,20 +3253,17 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto final :
void unsafe_arena_set_allocated_options(
::PROTOBUF_NAMESPACE_ID::EnumValueOptions* options);
::PROTOBUF_NAMESPACE_ID::EnumValueOptions* unsafe_arena_release_options();
-
// optional int32 number = 2;
bool has_number() const;
+ void clear_number() ;
+ ::arc_i32 number() const;
+ void set_number(::arc_i32 value);
+
private:
- bool _internal_has_number() const;
- public:
- void clear_number();
- arc_i32 number() const;
- void set_number(arc_i32 value);
- private:
- arc_i32 _internal_number() const;
- void _internal_set_number(arc_i32 value);
- public:
+ ::arc_i32 _internal_number() const;
+ void _internal_set_number(::arc_i32 value);
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.EnumValueDescriptorProto)
private:
class _Internal;
@@ -3203,12 +3276,11 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto final :
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_;
::PROTOBUF_NAMESPACE_ID::EnumValueOptions* options_;
- arc_i32 number_;
+ ::arc_i32 number_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT ServiceDescriptorProto final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceDescriptorProto) */ {
@@ -3285,7 +3357,7 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final :
}
void UnsafeArenaSwap(ServiceDescriptorProto* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -3306,26 +3378,25 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(ServiceDescriptorProto* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.ServiceDescriptorProto";
}
protected:
- explicit ServiceDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit ServiceDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -3346,8 +3417,9 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final :
int method_size() const;
private:
int _internal_method_size() const;
+
public:
- void clear_method();
+ void clear_method() ;
::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto* mutable_method(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto >*
mutable_method();
@@ -3359,31 +3431,30 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final :
::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto* add_method();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto >&
method() const;
-
// optional string name = 1;
bool has_name() const;
- private:
- bool _internal_has_name() const;
- public:
- void clear_name();
+ void clear_name() ;
const TProtoStringType& name() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_name(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_name(Arg_&& arg, Args_... args);
TProtoStringType* mutable_name();
PROTOBUF_NODISCARD TProtoStringType* release_name();
- void set_allocated_name(TProtoStringType* name);
+ void set_allocated_name(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_name() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_name();
- public:
+ public:
// optional .google.protobuf.ServiceOptions options = 3;
bool has_options() const;
- private:
- bool _internal_has_options() const;
- public:
- void clear_options();
+ void clear_options() ;
const ::PROTOBUF_NAMESPACE_ID::ServiceOptions& options() const;
PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::ServiceOptions* release_options();
::PROTOBUF_NAMESPACE_ID::ServiceOptions* mutable_options();
@@ -3395,7 +3466,6 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final :
void unsafe_arena_set_allocated_options(
::PROTOBUF_NAMESPACE_ID::ServiceOptions* options);
::PROTOBUF_NAMESPACE_ID::ServiceOptions* unsafe_arena_release_options();
-
// @@protoc_insertion_point(class_scope:google.protobuf.ServiceDescriptorProto)
private:
class _Internal;
@@ -3412,8 +3482,7 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT MethodDescriptorProto final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodDescriptorProto) */ {
@@ -3490,7 +3559,7 @@ class PROTOBUF_EXPORT MethodDescriptorProto final :
}
void UnsafeArenaSwap(MethodDescriptorProto* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -3511,26 +3580,25 @@ class PROTOBUF_EXPORT MethodDescriptorProto final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(MethodDescriptorProto* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.MethodDescriptorProto";
}
protected:
- explicit MethodDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit MethodDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -3552,64 +3620,70 @@ class PROTOBUF_EXPORT MethodDescriptorProto final :
};
// optional string name = 1;
bool has_name() const;
- private:
- bool _internal_has_name() const;
- public:
- void clear_name();
+ void clear_name() ;
const TProtoStringType& name() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_name(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_name(Arg_&& arg, Args_... args);
TProtoStringType* mutable_name();
PROTOBUF_NODISCARD TProtoStringType* release_name();
- void set_allocated_name(TProtoStringType* name);
+ void set_allocated_name(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_name() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_name();
- public:
+ public:
// optional string input_type = 2;
bool has_input_type() const;
- private:
- bool _internal_has_input_type() const;
- public:
- void clear_input_type();
+ void clear_input_type() ;
const TProtoStringType& input_type() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_input_type(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_input_type(Arg_&& arg, Args_... args);
TProtoStringType* mutable_input_type();
PROTOBUF_NODISCARD TProtoStringType* release_input_type();
- void set_allocated_input_type(TProtoStringType* input_type);
+ void set_allocated_input_type(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_input_type() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_input_type(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_input_type(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_input_type();
- public:
+ public:
// optional string output_type = 3;
bool has_output_type() const;
- private:
- bool _internal_has_output_type() const;
- public:
- void clear_output_type();
+ void clear_output_type() ;
const TProtoStringType& output_type() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_output_type(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_output_type(Arg_&& arg, Args_... args);
TProtoStringType* mutable_output_type();
PROTOBUF_NODISCARD TProtoStringType* release_output_type();
- void set_allocated_output_type(TProtoStringType* output_type);
+ void set_allocated_output_type(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_output_type() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_output_type(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_output_type(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_output_type();
- public:
+ public:
// optional .google.protobuf.MethodOptions options = 4;
bool has_options() const;
- private:
- bool _internal_has_options() const;
- public:
- void clear_options();
+ void clear_options() ;
const ::PROTOBUF_NAMESPACE_ID::MethodOptions& options() const;
PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::MethodOptions* release_options();
::PROTOBUF_NAMESPACE_ID::MethodOptions* mutable_options();
@@ -3621,33 +3695,28 @@ class PROTOBUF_EXPORT MethodDescriptorProto final :
void unsafe_arena_set_allocated_options(
::PROTOBUF_NAMESPACE_ID::MethodOptions* options);
::PROTOBUF_NAMESPACE_ID::MethodOptions* unsafe_arena_release_options();
-
// optional bool client_streaming = 5 [default = false];
bool has_client_streaming() const;
- private:
- bool _internal_has_client_streaming() const;
- public:
- void clear_client_streaming();
+ void clear_client_streaming() ;
bool client_streaming() const;
void set_client_streaming(bool value);
+
private:
bool _internal_client_streaming() const;
void _internal_set_client_streaming(bool value);
- public:
+ public:
// optional bool server_streaming = 6 [default = false];
bool has_server_streaming() const;
- private:
- bool _internal_has_server_streaming() const;
- public:
- void clear_server_streaming();
+ void clear_server_streaming() ;
bool server_streaming() const;
void set_server_streaming(bool value);
+
private:
bool _internal_server_streaming() const;
void _internal_set_server_streaming(bool value);
- public:
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.MethodDescriptorProto)
private:
class _Internal;
@@ -3667,8 +3736,7 @@ class PROTOBUF_EXPORT MethodDescriptorProto final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT FileOptions final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileOptions) */ {
@@ -3745,7 +3813,7 @@ class PROTOBUF_EXPORT FileOptions final :
}
void UnsafeArenaSwap(FileOptions* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -3766,26 +3834,25 @@ class PROTOBUF_EXPORT FileOptions final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(FileOptions* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.FileOptions";
}
protected:
- explicit FileOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit FileOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -3795,35 +3862,24 @@ class PROTOBUF_EXPORT FileOptions final :
// nested types ----------------------------------------------------
- typedef FileOptions_OptimizeMode OptimizeMode;
- static constexpr OptimizeMode SPEED =
- FileOptions_OptimizeMode_SPEED;
- static constexpr OptimizeMode CODE_SIZE =
- FileOptions_OptimizeMode_CODE_SIZE;
- static constexpr OptimizeMode LITE_RUNTIME =
- FileOptions_OptimizeMode_LITE_RUNTIME;
+ using OptimizeMode = FileOptions_OptimizeMode;
+ static constexpr OptimizeMode SPEED = FileOptions_OptimizeMode_SPEED;
+ static constexpr OptimizeMode CODE_SIZE = FileOptions_OptimizeMode_CODE_SIZE;
+ static constexpr OptimizeMode LITE_RUNTIME = FileOptions_OptimizeMode_LITE_RUNTIME;
static inline bool OptimizeMode_IsValid(int value) {
return FileOptions_OptimizeMode_IsValid(value);
}
- static constexpr OptimizeMode OptimizeMode_MIN =
- FileOptions_OptimizeMode_OptimizeMode_MIN;
- static constexpr OptimizeMode OptimizeMode_MAX =
- FileOptions_OptimizeMode_OptimizeMode_MAX;
- static constexpr int OptimizeMode_ARRAYSIZE =
- FileOptions_OptimizeMode_OptimizeMode_ARRAYSIZE;
- static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
- OptimizeMode_descriptor() {
+ static constexpr OptimizeMode OptimizeMode_MIN = FileOptions_OptimizeMode_OptimizeMode_MIN;
+ static constexpr OptimizeMode OptimizeMode_MAX = FileOptions_OptimizeMode_OptimizeMode_MAX;
+ static constexpr int OptimizeMode_ARRAYSIZE = FileOptions_OptimizeMode_OptimizeMode_ARRAYSIZE;
+ static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* OptimizeMode_descriptor() {
return FileOptions_OptimizeMode_descriptor();
}
- template<typename T>
- static inline const TProtoStringType& OptimizeMode_Name(T enum_t_value) {
- static_assert(::std::is_same<T, OptimizeMode>::value ||
- ::std::is_integral<T>::value,
- "Incorrect type passed to function OptimizeMode_Name.");
- return FileOptions_OptimizeMode_Name(enum_t_value);
+ template <typename T>
+ static inline const TProtoStringType& OptimizeMode_Name(T value) {
+ return FileOptions_OptimizeMode_Name(value);
}
- static inline bool OptimizeMode_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name,
- OptimizeMode* value) {
+ static inline bool OptimizeMode_Parse(y_absl::string_view name, OptimizeMode* value) {
return FileOptions_OptimizeMode_Parse(name, value);
}
@@ -3856,8 +3912,9 @@ class PROTOBUF_EXPORT FileOptions final :
int uninterpreted_option_size() const;
private:
int _internal_uninterpreted_option_size() const;
+
public:
- void clear_uninterpreted_option();
+ void clear_uninterpreted_option() ;
::PROTOBUF_NAMESPACE_ID::UninterpretedOption* mutable_uninterpreted_option(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >*
mutable_uninterpreted_option();
@@ -3869,507 +3926,477 @@ class PROTOBUF_EXPORT FileOptions final :
::PROTOBUF_NAMESPACE_ID::UninterpretedOption* add_uninterpreted_option();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >&
uninterpreted_option() const;
-
// optional string java_package = 1;
bool has_java_package() const;
- private:
- bool _internal_has_java_package() const;
- public:
- void clear_java_package();
+ void clear_java_package() ;
const TProtoStringType& java_package() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_java_package(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_java_package(Arg_&& arg, Args_... args);
TProtoStringType* mutable_java_package();
PROTOBUF_NODISCARD TProtoStringType* release_java_package();
- void set_allocated_java_package(TProtoStringType* java_package);
+ void set_allocated_java_package(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_java_package() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_java_package(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_java_package(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_java_package();
- public:
+ public:
// optional string java_outer_classname = 8;
bool has_java_outer_classname() const;
- private:
- bool _internal_has_java_outer_classname() const;
- public:
- void clear_java_outer_classname();
+ void clear_java_outer_classname() ;
const TProtoStringType& java_outer_classname() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_java_outer_classname(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_java_outer_classname(Arg_&& arg, Args_... args);
TProtoStringType* mutable_java_outer_classname();
PROTOBUF_NODISCARD TProtoStringType* release_java_outer_classname();
- void set_allocated_java_outer_classname(TProtoStringType* java_outer_classname);
+ void set_allocated_java_outer_classname(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_java_outer_classname() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_java_outer_classname(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_java_outer_classname(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_java_outer_classname();
- public:
+ public:
// optional string go_package = 11;
bool has_go_package() const;
- private:
- bool _internal_has_go_package() const;
- public:
- void clear_go_package();
+ void clear_go_package() ;
const TProtoStringType& go_package() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_go_package(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_go_package(Arg_&& arg, Args_... args);
TProtoStringType* mutable_go_package();
PROTOBUF_NODISCARD TProtoStringType* release_go_package();
- void set_allocated_go_package(TProtoStringType* go_package);
+ void set_allocated_go_package(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_go_package() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_go_package(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_go_package(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_go_package();
- public:
+ public:
// optional string objc_class_prefix = 36;
bool has_objc_class_prefix() const;
- private:
- bool _internal_has_objc_class_prefix() const;
- public:
- void clear_objc_class_prefix();
+ void clear_objc_class_prefix() ;
const TProtoStringType& objc_class_prefix() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_objc_class_prefix(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_objc_class_prefix(Arg_&& arg, Args_... args);
TProtoStringType* mutable_objc_class_prefix();
PROTOBUF_NODISCARD TProtoStringType* release_objc_class_prefix();
- void set_allocated_objc_class_prefix(TProtoStringType* objc_class_prefix);
+ void set_allocated_objc_class_prefix(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_objc_class_prefix() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_objc_class_prefix(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_objc_class_prefix(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_objc_class_prefix();
- public:
+ public:
// optional string csharp_namespace = 37;
bool has_csharp_namespace() const;
- private:
- bool _internal_has_csharp_namespace() const;
- public:
- void clear_csharp_namespace();
+ void clear_csharp_namespace() ;
const TProtoStringType& csharp_namespace() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_csharp_namespace(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_csharp_namespace(Arg_&& arg, Args_... args);
TProtoStringType* mutable_csharp_namespace();
PROTOBUF_NODISCARD TProtoStringType* release_csharp_namespace();
- void set_allocated_csharp_namespace(TProtoStringType* csharp_namespace);
+ void set_allocated_csharp_namespace(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_csharp_namespace() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_csharp_namespace(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_csharp_namespace(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_csharp_namespace();
- public:
+ public:
// optional string swift_prefix = 39;
bool has_swift_prefix() const;
- private:
- bool _internal_has_swift_prefix() const;
- public:
- void clear_swift_prefix();
+ void clear_swift_prefix() ;
const TProtoStringType& swift_prefix() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_swift_prefix(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_swift_prefix(Arg_&& arg, Args_... args);
TProtoStringType* mutable_swift_prefix();
PROTOBUF_NODISCARD TProtoStringType* release_swift_prefix();
- void set_allocated_swift_prefix(TProtoStringType* swift_prefix);
+ void set_allocated_swift_prefix(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_swift_prefix() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_swift_prefix(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_swift_prefix(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_swift_prefix();
- public:
+ public:
// optional string php_class_prefix = 40;
bool has_php_class_prefix() const;
- private:
- bool _internal_has_php_class_prefix() const;
- public:
- void clear_php_class_prefix();
+ void clear_php_class_prefix() ;
const TProtoStringType& php_class_prefix() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_php_class_prefix(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_php_class_prefix(Arg_&& arg, Args_... args);
TProtoStringType* mutable_php_class_prefix();
PROTOBUF_NODISCARD TProtoStringType* release_php_class_prefix();
- void set_allocated_php_class_prefix(TProtoStringType* php_class_prefix);
+ void set_allocated_php_class_prefix(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_php_class_prefix() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_php_class_prefix(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_php_class_prefix(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_php_class_prefix();
- public:
+ public:
// optional string php_namespace = 41;
bool has_php_namespace() const;
- private:
- bool _internal_has_php_namespace() const;
- public:
- void clear_php_namespace();
+ void clear_php_namespace() ;
const TProtoStringType& php_namespace() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_php_namespace(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_php_namespace(Arg_&& arg, Args_... args);
TProtoStringType* mutable_php_namespace();
PROTOBUF_NODISCARD TProtoStringType* release_php_namespace();
- void set_allocated_php_namespace(TProtoStringType* php_namespace);
+ void set_allocated_php_namespace(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_php_namespace() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_php_namespace(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_php_namespace(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_php_namespace();
- public:
+ public:
// optional string php_metadata_namespace = 44;
bool has_php_metadata_namespace() const;
- private:
- bool _internal_has_php_metadata_namespace() const;
- public:
- void clear_php_metadata_namespace();
+ void clear_php_metadata_namespace() ;
const TProtoStringType& php_metadata_namespace() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_php_metadata_namespace(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_php_metadata_namespace(Arg_&& arg, Args_... args);
TProtoStringType* mutable_php_metadata_namespace();
PROTOBUF_NODISCARD TProtoStringType* release_php_metadata_namespace();
- void set_allocated_php_metadata_namespace(TProtoStringType* php_metadata_namespace);
+ void set_allocated_php_metadata_namespace(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_php_metadata_namespace() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_php_metadata_namespace(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_php_metadata_namespace(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_php_metadata_namespace();
- public:
+ public:
// optional string ruby_package = 45;
bool has_ruby_package() const;
- private:
- bool _internal_has_ruby_package() const;
- public:
- void clear_ruby_package();
+ void clear_ruby_package() ;
const TProtoStringType& ruby_package() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_ruby_package(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_ruby_package(Arg_&& arg, Args_... args);
TProtoStringType* mutable_ruby_package();
PROTOBUF_NODISCARD TProtoStringType* release_ruby_package();
- void set_allocated_ruby_package(TProtoStringType* ruby_package);
+ void set_allocated_ruby_package(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_ruby_package() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_ruby_package(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_ruby_package(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_ruby_package();
- public:
+ public:
// optional bool java_multiple_files = 10 [default = false];
bool has_java_multiple_files() const;
- private:
- bool _internal_has_java_multiple_files() const;
- public:
- void clear_java_multiple_files();
+ void clear_java_multiple_files() ;
bool java_multiple_files() const;
void set_java_multiple_files(bool value);
+
private:
bool _internal_java_multiple_files() const;
void _internal_set_java_multiple_files(bool value);
- public:
- // optional bool java_generate_equals_and_hash = 20 [deprecated = true];
- PROTOBUF_DEPRECATED bool has_java_generate_equals_and_hash() const;
- private:
- bool _internal_has_java_generate_equals_and_hash() const;
public:
- PROTOBUF_DEPRECATED void clear_java_generate_equals_and_hash();
+ // optional bool java_generate_equals_and_hash = 20 [deprecated = true];
+ PROTOBUF_DEPRECATED bool has_java_generate_equals_and_hash() const;
+ PROTOBUF_DEPRECATED void clear_java_generate_equals_and_hash() ;
PROTOBUF_DEPRECATED bool java_generate_equals_and_hash() const;
PROTOBUF_DEPRECATED void set_java_generate_equals_and_hash(bool value);
+
private:
bool _internal_java_generate_equals_and_hash() const;
void _internal_set_java_generate_equals_and_hash(bool value);
- public:
+ public:
// optional bool java_string_check_utf8 = 27 [default = false];
bool has_java_string_check_utf8() const;
- private:
- bool _internal_has_java_string_check_utf8() const;
- public:
- void clear_java_string_check_utf8();
+ void clear_java_string_check_utf8() ;
bool java_string_check_utf8() const;
void set_java_string_check_utf8(bool value);
+
private:
bool _internal_java_string_check_utf8() const;
void _internal_set_java_string_check_utf8(bool value);
- public:
+ public:
// optional bool cc_generic_services = 16 [default = false];
bool has_cc_generic_services() const;
- private:
- bool _internal_has_cc_generic_services() const;
- public:
- void clear_cc_generic_services();
+ void clear_cc_generic_services() ;
bool cc_generic_services() const;
void set_cc_generic_services(bool value);
+
private:
bool _internal_cc_generic_services() const;
void _internal_set_cc_generic_services(bool value);
- public:
+ public:
// optional bool java_generic_services = 17 [default = false];
bool has_java_generic_services() const;
- private:
- bool _internal_has_java_generic_services() const;
- public:
- void clear_java_generic_services();
+ void clear_java_generic_services() ;
bool java_generic_services() const;
void set_java_generic_services(bool value);
+
private:
bool _internal_java_generic_services() const;
void _internal_set_java_generic_services(bool value);
- public:
+ public:
// optional bool py_generic_services = 18 [default = false];
bool has_py_generic_services() const;
- private:
- bool _internal_has_py_generic_services() const;
- public:
- void clear_py_generic_services();
+ void clear_py_generic_services() ;
bool py_generic_services() const;
void set_py_generic_services(bool value);
+
private:
bool _internal_py_generic_services() const;
void _internal_set_py_generic_services(bool value);
- public:
+ public:
// optional bool php_generic_services = 42 [default = false];
bool has_php_generic_services() const;
- private:
- bool _internal_has_php_generic_services() const;
- public:
- void clear_php_generic_services();
+ void clear_php_generic_services() ;
bool php_generic_services() const;
void set_php_generic_services(bool value);
+
private:
bool _internal_php_generic_services() const;
void _internal_set_php_generic_services(bool value);
- public:
+ public:
// optional bool deprecated = 23 [default = false];
bool has_deprecated() const;
- private:
- bool _internal_has_deprecated() const;
- public:
- void clear_deprecated();
+ void clear_deprecated() ;
bool deprecated() const;
void set_deprecated(bool value);
+
private:
bool _internal_deprecated() const;
void _internal_set_deprecated(bool value);
- public:
+ public:
// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
bool has_optimize_for() const;
- private:
- bool _internal_has_optimize_for() const;
- public:
- void clear_optimize_for();
+ void clear_optimize_for() ;
::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode optimize_for() const;
void set_optimize_for(::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode value);
+
private:
::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode _internal_optimize_for() const;
void _internal_set_optimize_for(::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode value);
- public:
+ public:
// optional bool cc_enable_arenas = 31 [default = true];
bool has_cc_enable_arenas() const;
- private:
- bool _internal_has_cc_enable_arenas() const;
- public:
- void clear_cc_enable_arenas();
+ void clear_cc_enable_arenas() ;
bool cc_enable_arenas() const;
void set_cc_enable_arenas(bool value);
+
private:
bool _internal_cc_enable_arenas() const;
void _internal_set_cc_enable_arenas(bool value);
- public:
-
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ public:
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline bool HasExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FileOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _impl_._extensions_.Has(id.number());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void ClearExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FileOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
_impl_._extensions_.ClearExtension(id.number());
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline int ExtensionSize(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FileOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _impl_._extensions_.ExtensionSize(id.number());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::ConstType GetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
- return _proto_TypeTraits::Get(id.number(), _impl_._extensions_,
- id.default_value());
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FileOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
+ return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, id.default_value());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::MutableType MutableExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
- return _proto_TypeTraits::Mutable(id.number(), _field_type,
- &_impl_._extensions_);
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FileOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ return _proto_TypeTraits::Mutable(id.number(), _field_type, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FileOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::ConstType value) {
_proto_TypeTraits::Set(id.number(), _field_type, value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetAllocatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FileOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::SetAllocated(id.number(), _field_type, value,
&_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void UnsafeArenaSetAllocatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FileOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type,
value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
PROTOBUF_NODISCARD inline
typename _proto_TypeTraits::Singular::MutableType
ReleaseExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
- return _proto_TypeTraits::Release(id.number(), _field_type,
- &_impl_._extensions_);
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FileOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ return _proto_TypeTraits::Release(id.number(), _field_type, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::MutableType
UnsafeArenaReleaseExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FileOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type,
&_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::ConstType GetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FileOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index) const {
-
return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, index);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::MutableType MutableExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FileOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index) {
-
return _proto_TypeTraits::Mutable(id.number(), index, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FileOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index, typename _proto_TypeTraits::Repeated::ConstType value) {
_proto_TypeTraits::Set(id.number(), index, value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::MutableType AddExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FileOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
typename _proto_TypeTraits::Repeated::MutableType to_add =
_proto_TypeTraits::Add(id.number(), _field_type, &_impl_._extensions_);
-
return to_add;
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void AddExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FileOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Repeated::ConstType value) {
_proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value,
&_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline const typename _proto_TypeTraits::Repeated::RepeatedFieldType&
GetRepeatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FileOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _proto_TypeTraits::GetRepeated(id.number(), _impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::RepeatedFieldType*
MutableRepeatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FileOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
return _proto_TypeTraits::MutableRepeated(id.number(), _field_type,
_is_packed, &_impl_._extensions_);
}
-
// @@protoc_insertion_point(class_scope:google.protobuf.FileOptions)
private:
class _Internal;
@@ -4406,8 +4433,7 @@ class PROTOBUF_EXPORT FileOptions final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT MessageOptions final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MessageOptions) */ {
@@ -4484,7 +4510,7 @@ class PROTOBUF_EXPORT MessageOptions final :
}
void UnsafeArenaSwap(MessageOptions* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -4505,26 +4531,25 @@ class PROTOBUF_EXPORT MessageOptions final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(MessageOptions* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.MessageOptions";
}
protected:
- explicit MessageOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit MessageOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -4542,13 +4567,15 @@ class PROTOBUF_EXPORT MessageOptions final :
kNoStandardDescriptorAccessorFieldNumber = 2,
kDeprecatedFieldNumber = 3,
kMapEntryFieldNumber = 7,
+ kDeprecatedLegacyJsonFieldConflictsFieldNumber = 11,
};
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
int uninterpreted_option_size() const;
private:
int _internal_uninterpreted_option_size() const;
+
public:
- void clear_uninterpreted_option();
+ void clear_uninterpreted_option() ;
::PROTOBUF_NAMESPACE_ID::UninterpretedOption* mutable_uninterpreted_option(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >*
mutable_uninterpreted_option();
@@ -4560,249 +4587,212 @@ class PROTOBUF_EXPORT MessageOptions final :
::PROTOBUF_NAMESPACE_ID::UninterpretedOption* add_uninterpreted_option();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >&
uninterpreted_option() const;
-
// optional bool message_set_wire_format = 1 [default = false];
bool has_message_set_wire_format() const;
- private:
- bool _internal_has_message_set_wire_format() const;
- public:
- void clear_message_set_wire_format();
+ void clear_message_set_wire_format() ;
bool message_set_wire_format() const;
void set_message_set_wire_format(bool value);
+
private:
bool _internal_message_set_wire_format() const;
void _internal_set_message_set_wire_format(bool value);
- public:
+ public:
// optional bool no_standard_descriptor_accessor = 2 [default = false];
bool has_no_standard_descriptor_accessor() const;
- private:
- bool _internal_has_no_standard_descriptor_accessor() const;
- public:
- void clear_no_standard_descriptor_accessor();
+ void clear_no_standard_descriptor_accessor() ;
bool no_standard_descriptor_accessor() const;
void set_no_standard_descriptor_accessor(bool value);
+
private:
bool _internal_no_standard_descriptor_accessor() const;
void _internal_set_no_standard_descriptor_accessor(bool value);
- public:
+ public:
// optional bool deprecated = 3 [default = false];
bool has_deprecated() const;
- private:
- bool _internal_has_deprecated() const;
- public:
- void clear_deprecated();
+ void clear_deprecated() ;
bool deprecated() const;
void set_deprecated(bool value);
+
private:
bool _internal_deprecated() const;
void _internal_set_deprecated(bool value);
- public:
+ public:
// optional bool map_entry = 7;
bool has_map_entry() const;
- private:
- bool _internal_has_map_entry() const;
- public:
- void clear_map_entry();
+ void clear_map_entry() ;
bool map_entry() const;
void set_map_entry(bool value);
+
private:
bool _internal_map_entry() const;
void _internal_set_map_entry(bool value);
+
public:
+ // optional bool deprecated_legacy_json_field_conflicts = 11 [deprecated = true];
+ PROTOBUF_DEPRECATED bool has_deprecated_legacy_json_field_conflicts() const;
+ PROTOBUF_DEPRECATED void clear_deprecated_legacy_json_field_conflicts() ;
+ PROTOBUF_DEPRECATED bool deprecated_legacy_json_field_conflicts() const;
+ PROTOBUF_DEPRECATED void set_deprecated_legacy_json_field_conflicts(bool value);
+ private:
+ bool _internal_deprecated_legacy_json_field_conflicts() const;
+ void _internal_set_deprecated_legacy_json_field_conflicts(bool value);
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ public:
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline bool HasExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MessageOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _impl_._extensions_.Has(id.number());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void ClearExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MessageOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
_impl_._extensions_.ClearExtension(id.number());
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline int ExtensionSize(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MessageOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _impl_._extensions_.ExtensionSize(id.number());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::ConstType GetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
- return _proto_TypeTraits::Get(id.number(), _impl_._extensions_,
- id.default_value());
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MessageOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
+ return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, id.default_value());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::MutableType MutableExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
- return _proto_TypeTraits::Mutable(id.number(), _field_type,
- &_impl_._extensions_);
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MessageOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ return _proto_TypeTraits::Mutable(id.number(), _field_type, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MessageOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::ConstType value) {
_proto_TypeTraits::Set(id.number(), _field_type, value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetAllocatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MessageOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::SetAllocated(id.number(), _field_type, value,
&_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void UnsafeArenaSetAllocatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MessageOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type,
value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
PROTOBUF_NODISCARD inline
typename _proto_TypeTraits::Singular::MutableType
ReleaseExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
- return _proto_TypeTraits::Release(id.number(), _field_type,
- &_impl_._extensions_);
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MessageOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ return _proto_TypeTraits::Release(id.number(), _field_type, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::MutableType
UnsafeArenaReleaseExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MessageOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type,
&_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::ConstType GetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MessageOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index) const {
-
return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, index);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::MutableType MutableExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MessageOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index) {
-
return _proto_TypeTraits::Mutable(id.number(), index, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MessageOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index, typename _proto_TypeTraits::Repeated::ConstType value) {
_proto_TypeTraits::Set(id.number(), index, value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::MutableType AddExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MessageOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
typename _proto_TypeTraits::Repeated::MutableType to_add =
_proto_TypeTraits::Add(id.number(), _field_type, &_impl_._extensions_);
-
return to_add;
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void AddExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MessageOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Repeated::ConstType value) {
_proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value,
&_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline const typename _proto_TypeTraits::Repeated::RepeatedFieldType&
GetRepeatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MessageOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _proto_TypeTraits::GetRepeated(id.number(), _impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::RepeatedFieldType*
MutableRepeatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MessageOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
return _proto_TypeTraits::MutableRepeated(id.number(), _field_type,
_is_packed, &_impl_._extensions_);
}
-
// @@protoc_insertion_point(class_scope:google.protobuf.MessageOptions)
private:
class _Internal;
@@ -4820,11 +4810,11 @@ class PROTOBUF_EXPORT MessageOptions final :
bool no_standard_descriptor_accessor_;
bool deprecated_;
bool map_entry_;
+ bool deprecated_legacy_json_field_conflicts_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT FieldOptions final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldOptions) */ {
@@ -4901,7 +4891,7 @@ class PROTOBUF_EXPORT FieldOptions final :
}
void UnsafeArenaSwap(FieldOptions* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -4922,26 +4912,25 @@ class PROTOBUF_EXPORT FieldOptions final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(FieldOptions* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.FieldOptions";
}
protected:
- explicit FieldOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit FieldOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -4951,70 +4940,97 @@ class PROTOBUF_EXPORT FieldOptions final :
// nested types ----------------------------------------------------
- typedef FieldOptions_CType CType;
- static constexpr CType STRING =
- FieldOptions_CType_STRING;
- static constexpr CType CORD =
- FieldOptions_CType_CORD;
- static constexpr CType STRING_PIECE =
- FieldOptions_CType_STRING_PIECE;
+ using CType = FieldOptions_CType;
+ static constexpr CType STRING = FieldOptions_CType_STRING;
+ static constexpr CType CORD = FieldOptions_CType_CORD;
+ static constexpr CType STRING_PIECE = FieldOptions_CType_STRING_PIECE;
static inline bool CType_IsValid(int value) {
return FieldOptions_CType_IsValid(value);
}
- static constexpr CType CType_MIN =
- FieldOptions_CType_CType_MIN;
- static constexpr CType CType_MAX =
- FieldOptions_CType_CType_MAX;
- static constexpr int CType_ARRAYSIZE =
- FieldOptions_CType_CType_ARRAYSIZE;
- static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
- CType_descriptor() {
+ static constexpr CType CType_MIN = FieldOptions_CType_CType_MIN;
+ static constexpr CType CType_MAX = FieldOptions_CType_CType_MAX;
+ static constexpr int CType_ARRAYSIZE = FieldOptions_CType_CType_ARRAYSIZE;
+ static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* CType_descriptor() {
return FieldOptions_CType_descriptor();
}
- template<typename T>
- static inline const TProtoStringType& CType_Name(T enum_t_value) {
- static_assert(::std::is_same<T, CType>::value ||
- ::std::is_integral<T>::value,
- "Incorrect type passed to function CType_Name.");
- return FieldOptions_CType_Name(enum_t_value);
+ template <typename T>
+ static inline const TProtoStringType& CType_Name(T value) {
+ return FieldOptions_CType_Name(value);
}
- static inline bool CType_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name,
- CType* value) {
+ static inline bool CType_Parse(y_absl::string_view name, CType* value) {
return FieldOptions_CType_Parse(name, value);
}
- typedef FieldOptions_JSType JSType;
- static constexpr JSType JS_NORMAL =
- FieldOptions_JSType_JS_NORMAL;
- static constexpr JSType JS_STRING =
- FieldOptions_JSType_JS_STRING;
- static constexpr JSType JS_NUMBER =
- FieldOptions_JSType_JS_NUMBER;
+ using JSType = FieldOptions_JSType;
+ static constexpr JSType JS_NORMAL = FieldOptions_JSType_JS_NORMAL;
+ static constexpr JSType JS_STRING = FieldOptions_JSType_JS_STRING;
+ static constexpr JSType JS_NUMBER = FieldOptions_JSType_JS_NUMBER;
static inline bool JSType_IsValid(int value) {
return FieldOptions_JSType_IsValid(value);
}
- static constexpr JSType JSType_MIN =
- FieldOptions_JSType_JSType_MIN;
- static constexpr JSType JSType_MAX =
- FieldOptions_JSType_JSType_MAX;
- static constexpr int JSType_ARRAYSIZE =
- FieldOptions_JSType_JSType_ARRAYSIZE;
- static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
- JSType_descriptor() {
+ static constexpr JSType JSType_MIN = FieldOptions_JSType_JSType_MIN;
+ static constexpr JSType JSType_MAX = FieldOptions_JSType_JSType_MAX;
+ static constexpr int JSType_ARRAYSIZE = FieldOptions_JSType_JSType_ARRAYSIZE;
+ static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* JSType_descriptor() {
return FieldOptions_JSType_descriptor();
}
- template<typename T>
- static inline const TProtoStringType& JSType_Name(T enum_t_value) {
- static_assert(::std::is_same<T, JSType>::value ||
- ::std::is_integral<T>::value,
- "Incorrect type passed to function JSType_Name.");
- return FieldOptions_JSType_Name(enum_t_value);
+ template <typename T>
+ static inline const TProtoStringType& JSType_Name(T value) {
+ return FieldOptions_JSType_Name(value);
}
- static inline bool JSType_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name,
- JSType* value) {
+ static inline bool JSType_Parse(y_absl::string_view name, JSType* value) {
return FieldOptions_JSType_Parse(name, value);
}
+ using OptionRetention = FieldOptions_OptionRetention;
+ static constexpr OptionRetention RETENTION_UNKNOWN = FieldOptions_OptionRetention_RETENTION_UNKNOWN;
+ static constexpr OptionRetention RETENTION_RUNTIME = FieldOptions_OptionRetention_RETENTION_RUNTIME;
+ static constexpr OptionRetention RETENTION_SOURCE = FieldOptions_OptionRetention_RETENTION_SOURCE;
+ static inline bool OptionRetention_IsValid(int value) {
+ return FieldOptions_OptionRetention_IsValid(value);
+ }
+ static constexpr OptionRetention OptionRetention_MIN = FieldOptions_OptionRetention_OptionRetention_MIN;
+ static constexpr OptionRetention OptionRetention_MAX = FieldOptions_OptionRetention_OptionRetention_MAX;
+ static constexpr int OptionRetention_ARRAYSIZE = FieldOptions_OptionRetention_OptionRetention_ARRAYSIZE;
+ static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* OptionRetention_descriptor() {
+ return FieldOptions_OptionRetention_descriptor();
+ }
+ template <typename T>
+ static inline const TProtoStringType& OptionRetention_Name(T value) {
+ return FieldOptions_OptionRetention_Name(value);
+ }
+ static inline bool OptionRetention_Parse(y_absl::string_view name, OptionRetention* value) {
+ return FieldOptions_OptionRetention_Parse(name, value);
+ }
+
+ using OptionTargetType = FieldOptions_OptionTargetType;
+ static constexpr OptionTargetType TARGET_TYPE_UNKNOWN = FieldOptions_OptionTargetType_TARGET_TYPE_UNKNOWN;
+ static constexpr OptionTargetType TARGET_TYPE_FILE = FieldOptions_OptionTargetType_TARGET_TYPE_FILE;
+ static constexpr OptionTargetType TARGET_TYPE_EXTENSION_RANGE = FieldOptions_OptionTargetType_TARGET_TYPE_EXTENSION_RANGE;
+ static constexpr OptionTargetType TARGET_TYPE_MESSAGE = FieldOptions_OptionTargetType_TARGET_TYPE_MESSAGE;
+ static constexpr OptionTargetType TARGET_TYPE_FIELD = FieldOptions_OptionTargetType_TARGET_TYPE_FIELD;
+ static constexpr OptionTargetType TARGET_TYPE_ONEOF = FieldOptions_OptionTargetType_TARGET_TYPE_ONEOF;
+ static constexpr OptionTargetType TARGET_TYPE_ENUM = FieldOptions_OptionTargetType_TARGET_TYPE_ENUM;
+ static constexpr OptionTargetType TARGET_TYPE_ENUM_ENTRY = FieldOptions_OptionTargetType_TARGET_TYPE_ENUM_ENTRY;
+ static constexpr OptionTargetType TARGET_TYPE_SERVICE = FieldOptions_OptionTargetType_TARGET_TYPE_SERVICE;
+ static constexpr OptionTargetType TARGET_TYPE_METHOD = FieldOptions_OptionTargetType_TARGET_TYPE_METHOD;
+ static inline bool OptionTargetType_IsValid(int value) {
+ return FieldOptions_OptionTargetType_IsValid(value);
+ }
+ static constexpr OptionTargetType OptionTargetType_MIN = FieldOptions_OptionTargetType_OptionTargetType_MIN;
+ static constexpr OptionTargetType OptionTargetType_MAX = FieldOptions_OptionTargetType_OptionTargetType_MAX;
+ static constexpr int OptionTargetType_ARRAYSIZE = FieldOptions_OptionTargetType_OptionTargetType_ARRAYSIZE;
+ static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* OptionTargetType_descriptor() {
+ return FieldOptions_OptionTargetType_descriptor();
+ }
+ template <typename T>
+ static inline const TProtoStringType& OptionTargetType_Name(T value) {
+ return FieldOptions_OptionTargetType_Name(value);
+ }
+ static inline bool OptionTargetType_Parse(y_absl::string_view name, OptionTargetType* value) {
+ return FieldOptions_OptionTargetType_Parse(name, value);
+ }
+
// accessors -------------------------------------------------------
enum : int {
@@ -5026,13 +5042,17 @@ class PROTOBUF_EXPORT FieldOptions final :
kUnverifiedLazyFieldNumber = 15,
kDeprecatedFieldNumber = 3,
kWeakFieldNumber = 10,
+ kDebugRedactFieldNumber = 16,
+ kRetentionFieldNumber = 17,
+ kTargetFieldNumber = 18,
};
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
int uninterpreted_option_size() const;
private:
int _internal_uninterpreted_option_size() const;
+
public:
- void clear_uninterpreted_option();
+ void clear_uninterpreted_option() ;
::PROTOBUF_NAMESPACE_ID::UninterpretedOption* mutable_uninterpreted_option(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >*
mutable_uninterpreted_option();
@@ -5044,288 +5064,267 @@ class PROTOBUF_EXPORT FieldOptions final :
::PROTOBUF_NAMESPACE_ID::UninterpretedOption* add_uninterpreted_option();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >&
uninterpreted_option() const;
-
// optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];
bool has_ctype() const;
- private:
- bool _internal_has_ctype() const;
- public:
- void clear_ctype();
+ void clear_ctype() ;
::PROTOBUF_NAMESPACE_ID::FieldOptions_CType ctype() const;
void set_ctype(::PROTOBUF_NAMESPACE_ID::FieldOptions_CType value);
+
private:
::PROTOBUF_NAMESPACE_ID::FieldOptions_CType _internal_ctype() const;
void _internal_set_ctype(::PROTOBUF_NAMESPACE_ID::FieldOptions_CType value);
- public:
+ 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();
+ 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:
+ public:
// optional bool packed = 2;
bool has_packed() const;
- private:
- bool _internal_has_packed() const;
- public:
- void clear_packed();
+ void clear_packed() ;
bool packed() const;
void set_packed(bool value);
+
private:
bool _internal_packed() const;
void _internal_set_packed(bool value);
- public:
+ public:
// optional bool lazy = 5 [default = false];
bool has_lazy() const;
- private:
- bool _internal_has_lazy() const;
- public:
- void clear_lazy();
+ void clear_lazy() ;
bool lazy() const;
void set_lazy(bool value);
+
private:
bool _internal_lazy() const;
void _internal_set_lazy(bool value);
- public:
+ 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();
+ 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:
+ public:
// optional bool deprecated = 3 [default = false];
bool has_deprecated() const;
- private:
- bool _internal_has_deprecated() const;
- public:
- void clear_deprecated();
+ void clear_deprecated() ;
bool deprecated() const;
void set_deprecated(bool value);
+
private:
bool _internal_deprecated() const;
void _internal_set_deprecated(bool value);
- public:
+ public:
// optional bool weak = 10 [default = false];
bool has_weak() const;
- private:
- bool _internal_has_weak() const;
- public:
- void clear_weak();
+ void clear_weak() ;
bool weak() const;
void set_weak(bool value);
+
private:
bool _internal_weak() const;
void _internal_set_weak(bool value);
+
+ public:
+ // optional bool debug_redact = 16 [default = false];
+ bool has_debug_redact() const;
+ void clear_debug_redact() ;
+ bool debug_redact() const;
+ void set_debug_redact(bool value);
+
+ private:
+ bool _internal_debug_redact() const;
+ void _internal_set_debug_redact(bool value);
+
+ public:
+ // optional .google.protobuf.FieldOptions.OptionRetention retention = 17;
+ bool has_retention() const;
+ void clear_retention() ;
+ ::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionRetention retention() const;
+ void set_retention(::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionRetention value);
+
+ private:
+ ::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionRetention _internal_retention() const;
+ void _internal_set_retention(::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionRetention value);
+
public:
+ // optional .google.protobuf.FieldOptions.OptionTargetType target = 18;
+ bool has_target() const;
+ void clear_target() ;
+ ::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionTargetType target() const;
+ void set_target(::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionTargetType value);
+ private:
+ ::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionTargetType _internal_target() const;
+ void _internal_set_target(::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionTargetType value);
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ public:
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline bool HasExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FieldOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _impl_._extensions_.Has(id.number());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void ClearExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FieldOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
_impl_._extensions_.ClearExtension(id.number());
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline int ExtensionSize(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FieldOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _impl_._extensions_.ExtensionSize(id.number());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::ConstType GetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
- return _proto_TypeTraits::Get(id.number(), _impl_._extensions_,
- id.default_value());
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FieldOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
+ return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, id.default_value());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::MutableType MutableExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
- return _proto_TypeTraits::Mutable(id.number(), _field_type,
- &_impl_._extensions_);
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FieldOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ return _proto_TypeTraits::Mutable(id.number(), _field_type, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FieldOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::ConstType value) {
_proto_TypeTraits::Set(id.number(), _field_type, value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetAllocatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FieldOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::SetAllocated(id.number(), _field_type, value,
&_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void UnsafeArenaSetAllocatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FieldOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type,
value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
PROTOBUF_NODISCARD inline
typename _proto_TypeTraits::Singular::MutableType
ReleaseExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
- return _proto_TypeTraits::Release(id.number(), _field_type,
- &_impl_._extensions_);
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FieldOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ return _proto_TypeTraits::Release(id.number(), _field_type, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::MutableType
UnsafeArenaReleaseExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FieldOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type,
&_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::ConstType GetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FieldOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index) const {
-
return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, index);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::MutableType MutableExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FieldOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index) {
-
return _proto_TypeTraits::Mutable(id.number(), index, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FieldOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index, typename _proto_TypeTraits::Repeated::ConstType value) {
_proto_TypeTraits::Set(id.number(), index, value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::MutableType AddExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FieldOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
typename _proto_TypeTraits::Repeated::MutableType to_add =
_proto_TypeTraits::Add(id.number(), _field_type, &_impl_._extensions_);
-
return to_add;
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void AddExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FieldOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Repeated::ConstType value) {
_proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value,
&_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline const typename _proto_TypeTraits::Repeated::RepeatedFieldType&
GetRepeatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FieldOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _proto_TypeTraits::GetRepeated(id.number(), _impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::RepeatedFieldType*
MutableRepeatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<FieldOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
return _proto_TypeTraits::MutableRepeated(id.number(), _field_type,
_is_packed, &_impl_._extensions_);
}
-
// @@protoc_insertion_point(class_scope:google.protobuf.FieldOptions)
private:
class _Internal;
@@ -5346,11 +5345,13 @@ class PROTOBUF_EXPORT FieldOptions final :
bool unverified_lazy_;
bool deprecated_;
bool weak_;
+ bool debug_redact_;
+ int retention_;
+ int target_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT OneofOptions final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofOptions) */ {
@@ -5427,7 +5428,7 @@ class PROTOBUF_EXPORT OneofOptions final :
}
void UnsafeArenaSwap(OneofOptions* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -5448,26 +5449,25 @@ class PROTOBUF_EXPORT OneofOptions final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(OneofOptions* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.OneofOptions";
}
protected:
- explicit OneofOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit OneofOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -5486,8 +5486,9 @@ class PROTOBUF_EXPORT OneofOptions final :
int uninterpreted_option_size() const;
private:
int _internal_uninterpreted_option_size() const;
+
public:
- void clear_uninterpreted_option();
+ void clear_uninterpreted_option() ;
::PROTOBUF_NAMESPACE_ID::UninterpretedOption* mutable_uninterpreted_option(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >*
mutable_uninterpreted_option();
@@ -5499,197 +5500,157 @@ class PROTOBUF_EXPORT OneofOptions final :
::PROTOBUF_NAMESPACE_ID::UninterpretedOption* add_uninterpreted_option();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >&
uninterpreted_option() const;
-
-
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline bool HasExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<OneofOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _impl_._extensions_.Has(id.number());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void ClearExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<OneofOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
_impl_._extensions_.ClearExtension(id.number());
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline int ExtensionSize(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<OneofOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _impl_._extensions_.ExtensionSize(id.number());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::ConstType GetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
- return _proto_TypeTraits::Get(id.number(), _impl_._extensions_,
- id.default_value());
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<OneofOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
+ return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, id.default_value());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::MutableType MutableExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
- return _proto_TypeTraits::Mutable(id.number(), _field_type,
- &_impl_._extensions_);
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<OneofOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ return _proto_TypeTraits::Mutable(id.number(), _field_type, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<OneofOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::ConstType value) {
_proto_TypeTraits::Set(id.number(), _field_type, value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetAllocatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<OneofOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::SetAllocated(id.number(), _field_type, value,
&_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void UnsafeArenaSetAllocatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<OneofOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type,
value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
PROTOBUF_NODISCARD inline
typename _proto_TypeTraits::Singular::MutableType
ReleaseExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
- return _proto_TypeTraits::Release(id.number(), _field_type,
- &_impl_._extensions_);
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<OneofOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ return _proto_TypeTraits::Release(id.number(), _field_type, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::MutableType
UnsafeArenaReleaseExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<OneofOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type,
&_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::ConstType GetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<OneofOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index) const {
-
return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, index);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::MutableType MutableExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<OneofOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index) {
-
return _proto_TypeTraits::Mutable(id.number(), index, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<OneofOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index, typename _proto_TypeTraits::Repeated::ConstType value) {
_proto_TypeTraits::Set(id.number(), index, value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::MutableType AddExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<OneofOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
typename _proto_TypeTraits::Repeated::MutableType to_add =
_proto_TypeTraits::Add(id.number(), _field_type, &_impl_._extensions_);
-
return to_add;
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void AddExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<OneofOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Repeated::ConstType value) {
_proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value,
&_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline const typename _proto_TypeTraits::Repeated::RepeatedFieldType&
GetRepeatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<OneofOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _proto_TypeTraits::GetRepeated(id.number(), _impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::RepeatedFieldType*
MutableRepeatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<OneofOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
return _proto_TypeTraits::MutableRepeated(id.number(), _field_type,
_is_packed, &_impl_._extensions_);
}
-
// @@protoc_insertion_point(class_scope:google.protobuf.OneofOptions)
private:
class _Internal;
@@ -5705,8 +5666,7 @@ class PROTOBUF_EXPORT OneofOptions final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT EnumOptions final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumOptions) */ {
@@ -5783,7 +5743,7 @@ class PROTOBUF_EXPORT EnumOptions final :
}
void UnsafeArenaSwap(EnumOptions* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -5804,26 +5764,25 @@ class PROTOBUF_EXPORT EnumOptions final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(EnumOptions* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.EnumOptions";
}
protected:
- explicit EnumOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit EnumOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -5839,13 +5798,15 @@ class PROTOBUF_EXPORT EnumOptions final :
kUninterpretedOptionFieldNumber = 999,
kAllowAliasFieldNumber = 2,
kDeprecatedFieldNumber = 3,
+ kDeprecatedLegacyJsonFieldConflictsFieldNumber = 6,
};
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
int uninterpreted_option_size() const;
private:
int _internal_uninterpreted_option_size() const;
+
public:
- void clear_uninterpreted_option();
+ void clear_uninterpreted_option() ;
::PROTOBUF_NAMESPACE_ID::UninterpretedOption* mutable_uninterpreted_option(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >*
mutable_uninterpreted_option();
@@ -5857,223 +5818,190 @@ class PROTOBUF_EXPORT EnumOptions final :
::PROTOBUF_NAMESPACE_ID::UninterpretedOption* add_uninterpreted_option();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >&
uninterpreted_option() const;
-
// optional bool allow_alias = 2;
bool has_allow_alias() const;
- private:
- bool _internal_has_allow_alias() const;
- public:
- void clear_allow_alias();
+ void clear_allow_alias() ;
bool allow_alias() const;
void set_allow_alias(bool value);
+
private:
bool _internal_allow_alias() const;
void _internal_set_allow_alias(bool value);
- public:
+ public:
// optional bool deprecated = 3 [default = false];
bool has_deprecated() const;
- private:
- bool _internal_has_deprecated() const;
- public:
- void clear_deprecated();
+ void clear_deprecated() ;
bool deprecated() const;
void set_deprecated(bool value);
+
private:
bool _internal_deprecated() const;
void _internal_set_deprecated(bool value);
+
public:
+ // optional bool deprecated_legacy_json_field_conflicts = 6 [deprecated = true];
+ PROTOBUF_DEPRECATED bool has_deprecated_legacy_json_field_conflicts() const;
+ PROTOBUF_DEPRECATED void clear_deprecated_legacy_json_field_conflicts() ;
+ PROTOBUF_DEPRECATED bool deprecated_legacy_json_field_conflicts() const;
+ PROTOBUF_DEPRECATED void set_deprecated_legacy_json_field_conflicts(bool value);
+ private:
+ bool _internal_deprecated_legacy_json_field_conflicts() const;
+ void _internal_set_deprecated_legacy_json_field_conflicts(bool value);
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ public:
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline bool HasExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _impl_._extensions_.Has(id.number());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void ClearExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
_impl_._extensions_.ClearExtension(id.number());
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline int ExtensionSize(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _impl_._extensions_.ExtensionSize(id.number());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::ConstType GetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
- return _proto_TypeTraits::Get(id.number(), _impl_._extensions_,
- id.default_value());
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
+ return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, id.default_value());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::MutableType MutableExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
- return _proto_TypeTraits::Mutable(id.number(), _field_type,
- &_impl_._extensions_);
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ return _proto_TypeTraits::Mutable(id.number(), _field_type, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::ConstType value) {
_proto_TypeTraits::Set(id.number(), _field_type, value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetAllocatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::SetAllocated(id.number(), _field_type, value,
&_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void UnsafeArenaSetAllocatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type,
value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
PROTOBUF_NODISCARD inline
typename _proto_TypeTraits::Singular::MutableType
ReleaseExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
- return _proto_TypeTraits::Release(id.number(), _field_type,
- &_impl_._extensions_);
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ return _proto_TypeTraits::Release(id.number(), _field_type, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::MutableType
UnsafeArenaReleaseExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type,
&_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::ConstType GetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index) const {
-
return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, index);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::MutableType MutableExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index) {
-
return _proto_TypeTraits::Mutable(id.number(), index, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index, typename _proto_TypeTraits::Repeated::ConstType value) {
_proto_TypeTraits::Set(id.number(), index, value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::MutableType AddExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
typename _proto_TypeTraits::Repeated::MutableType to_add =
_proto_TypeTraits::Add(id.number(), _field_type, &_impl_._extensions_);
-
return to_add;
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void AddExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Repeated::ConstType value) {
_proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value,
&_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline const typename _proto_TypeTraits::Repeated::RepeatedFieldType&
GetRepeatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _proto_TypeTraits::GetRepeated(id.number(), _impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::RepeatedFieldType*
MutableRepeatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
return _proto_TypeTraits::MutableRepeated(id.number(), _field_type,
_is_packed, &_impl_._extensions_);
}
-
// @@protoc_insertion_point(class_scope:google.protobuf.EnumOptions)
private:
class _Internal;
@@ -6089,11 +6017,11 @@ class PROTOBUF_EXPORT EnumOptions final :
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption > uninterpreted_option_;
bool allow_alias_;
bool deprecated_;
+ bool deprecated_legacy_json_field_conflicts_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT EnumValueOptions final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueOptions) */ {
@@ -6170,7 +6098,7 @@ class PROTOBUF_EXPORT EnumValueOptions final :
}
void UnsafeArenaSwap(EnumValueOptions* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -6191,26 +6119,25 @@ class PROTOBUF_EXPORT EnumValueOptions final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(EnumValueOptions* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.EnumValueOptions";
}
protected:
- explicit EnumValueOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit EnumValueOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -6230,8 +6157,9 @@ class PROTOBUF_EXPORT EnumValueOptions final :
int uninterpreted_option_size() const;
private:
int _internal_uninterpreted_option_size() const;
+
public:
- void clear_uninterpreted_option();
+ void clear_uninterpreted_option() ;
::PROTOBUF_NAMESPACE_ID::UninterpretedOption* mutable_uninterpreted_option(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >*
mutable_uninterpreted_option();
@@ -6243,210 +6171,168 @@ class PROTOBUF_EXPORT EnumValueOptions final :
::PROTOBUF_NAMESPACE_ID::UninterpretedOption* add_uninterpreted_option();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >&
uninterpreted_option() const;
-
// optional bool deprecated = 1 [default = false];
bool has_deprecated() const;
- private:
- bool _internal_has_deprecated() const;
- public:
- void clear_deprecated();
+ void clear_deprecated() ;
bool deprecated() const;
void set_deprecated(bool value);
+
private:
bool _internal_deprecated() const;
void _internal_set_deprecated(bool value);
- public:
-
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ public:
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline bool HasExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumValueOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _impl_._extensions_.Has(id.number());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void ClearExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumValueOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
_impl_._extensions_.ClearExtension(id.number());
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline int ExtensionSize(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumValueOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _impl_._extensions_.ExtensionSize(id.number());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::ConstType GetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
- return _proto_TypeTraits::Get(id.number(), _impl_._extensions_,
- id.default_value());
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumValueOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
+ return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, id.default_value());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::MutableType MutableExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
- return _proto_TypeTraits::Mutable(id.number(), _field_type,
- &_impl_._extensions_);
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumValueOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ return _proto_TypeTraits::Mutable(id.number(), _field_type, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumValueOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::ConstType value) {
_proto_TypeTraits::Set(id.number(), _field_type, value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetAllocatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumValueOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::SetAllocated(id.number(), _field_type, value,
&_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void UnsafeArenaSetAllocatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumValueOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type,
value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
PROTOBUF_NODISCARD inline
typename _proto_TypeTraits::Singular::MutableType
ReleaseExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
- return _proto_TypeTraits::Release(id.number(), _field_type,
- &_impl_._extensions_);
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumValueOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ return _proto_TypeTraits::Release(id.number(), _field_type, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::MutableType
UnsafeArenaReleaseExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumValueOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type,
&_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::ConstType GetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumValueOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index) const {
-
return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, index);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::MutableType MutableExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumValueOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index) {
-
return _proto_TypeTraits::Mutable(id.number(), index, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumValueOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index, typename _proto_TypeTraits::Repeated::ConstType value) {
_proto_TypeTraits::Set(id.number(), index, value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::MutableType AddExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumValueOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
typename _proto_TypeTraits::Repeated::MutableType to_add =
_proto_TypeTraits::Add(id.number(), _field_type, &_impl_._extensions_);
-
return to_add;
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void AddExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumValueOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Repeated::ConstType value) {
_proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value,
&_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline const typename _proto_TypeTraits::Repeated::RepeatedFieldType&
GetRepeatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumValueOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _proto_TypeTraits::GetRepeated(id.number(), _impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::RepeatedFieldType*
MutableRepeatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<EnumValueOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
return _proto_TypeTraits::MutableRepeated(id.number(), _field_type,
_is_packed, &_impl_._extensions_);
}
-
// @@protoc_insertion_point(class_scope:google.protobuf.EnumValueOptions)
private:
class _Internal;
@@ -6464,8 +6350,7 @@ class PROTOBUF_EXPORT EnumValueOptions final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT ServiceOptions final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceOptions) */ {
@@ -6542,7 +6427,7 @@ class PROTOBUF_EXPORT ServiceOptions final :
}
void UnsafeArenaSwap(ServiceOptions* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -6563,26 +6448,25 @@ class PROTOBUF_EXPORT ServiceOptions final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(ServiceOptions* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.ServiceOptions";
}
protected:
- explicit ServiceOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit ServiceOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -6602,8 +6486,9 @@ class PROTOBUF_EXPORT ServiceOptions final :
int uninterpreted_option_size() const;
private:
int _internal_uninterpreted_option_size() const;
+
public:
- void clear_uninterpreted_option();
+ void clear_uninterpreted_option() ;
::PROTOBUF_NAMESPACE_ID::UninterpretedOption* mutable_uninterpreted_option(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >*
mutable_uninterpreted_option();
@@ -6615,210 +6500,168 @@ class PROTOBUF_EXPORT ServiceOptions final :
::PROTOBUF_NAMESPACE_ID::UninterpretedOption* add_uninterpreted_option();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >&
uninterpreted_option() const;
-
// optional bool deprecated = 33 [default = false];
bool has_deprecated() const;
- private:
- bool _internal_has_deprecated() const;
- public:
- void clear_deprecated();
+ void clear_deprecated() ;
bool deprecated() const;
void set_deprecated(bool value);
+
private:
bool _internal_deprecated() const;
void _internal_set_deprecated(bool value);
- public:
-
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ public:
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline bool HasExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ServiceOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _impl_._extensions_.Has(id.number());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void ClearExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ServiceOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
_impl_._extensions_.ClearExtension(id.number());
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline int ExtensionSize(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ServiceOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _impl_._extensions_.ExtensionSize(id.number());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::ConstType GetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
- return _proto_TypeTraits::Get(id.number(), _impl_._extensions_,
- id.default_value());
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ServiceOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
+ return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, id.default_value());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::MutableType MutableExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
- return _proto_TypeTraits::Mutable(id.number(), _field_type,
- &_impl_._extensions_);
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ServiceOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ return _proto_TypeTraits::Mutable(id.number(), _field_type, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ServiceOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::ConstType value) {
_proto_TypeTraits::Set(id.number(), _field_type, value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetAllocatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ServiceOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::SetAllocated(id.number(), _field_type, value,
&_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void UnsafeArenaSetAllocatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ServiceOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type,
value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
PROTOBUF_NODISCARD inline
typename _proto_TypeTraits::Singular::MutableType
ReleaseExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
- return _proto_TypeTraits::Release(id.number(), _field_type,
- &_impl_._extensions_);
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ServiceOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ return _proto_TypeTraits::Release(id.number(), _field_type, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::MutableType
UnsafeArenaReleaseExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ServiceOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type,
&_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::ConstType GetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ServiceOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index) const {
-
return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, index);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::MutableType MutableExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ServiceOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index) {
-
return _proto_TypeTraits::Mutable(id.number(), index, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ServiceOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index, typename _proto_TypeTraits::Repeated::ConstType value) {
_proto_TypeTraits::Set(id.number(), index, value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::MutableType AddExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ServiceOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
typename _proto_TypeTraits::Repeated::MutableType to_add =
_proto_TypeTraits::Add(id.number(), _field_type, &_impl_._extensions_);
-
return to_add;
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void AddExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ServiceOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Repeated::ConstType value) {
_proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value,
&_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline const typename _proto_TypeTraits::Repeated::RepeatedFieldType&
GetRepeatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ServiceOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _proto_TypeTraits::GetRepeated(id.number(), _impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::RepeatedFieldType*
MutableRepeatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<ServiceOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
return _proto_TypeTraits::MutableRepeated(id.number(), _field_type,
_is_packed, &_impl_._extensions_);
}
-
// @@protoc_insertion_point(class_scope:google.protobuf.ServiceOptions)
private:
class _Internal;
@@ -6836,8 +6679,7 @@ class PROTOBUF_EXPORT ServiceOptions final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT MethodOptions final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodOptions) */ {
@@ -6914,7 +6756,7 @@ class PROTOBUF_EXPORT MethodOptions final :
}
void UnsafeArenaSwap(MethodOptions* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -6935,26 +6777,25 @@ class PROTOBUF_EXPORT MethodOptions final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(MethodOptions* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.MethodOptions";
}
protected:
- explicit MethodOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit MethodOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -6964,35 +6805,24 @@ class PROTOBUF_EXPORT MethodOptions final :
// nested types ----------------------------------------------------
- typedef MethodOptions_IdempotencyLevel IdempotencyLevel;
- static constexpr IdempotencyLevel IDEMPOTENCY_UNKNOWN =
- MethodOptions_IdempotencyLevel_IDEMPOTENCY_UNKNOWN;
- static constexpr IdempotencyLevel NO_SIDE_EFFECTS =
- MethodOptions_IdempotencyLevel_NO_SIDE_EFFECTS;
- static constexpr IdempotencyLevel IDEMPOTENT =
- MethodOptions_IdempotencyLevel_IDEMPOTENT;
+ using IdempotencyLevel = MethodOptions_IdempotencyLevel;
+ static constexpr IdempotencyLevel IDEMPOTENCY_UNKNOWN = MethodOptions_IdempotencyLevel_IDEMPOTENCY_UNKNOWN;
+ static constexpr IdempotencyLevel NO_SIDE_EFFECTS = MethodOptions_IdempotencyLevel_NO_SIDE_EFFECTS;
+ static constexpr IdempotencyLevel IDEMPOTENT = MethodOptions_IdempotencyLevel_IDEMPOTENT;
static inline bool IdempotencyLevel_IsValid(int value) {
return MethodOptions_IdempotencyLevel_IsValid(value);
}
- static constexpr IdempotencyLevel IdempotencyLevel_MIN =
- MethodOptions_IdempotencyLevel_IdempotencyLevel_MIN;
- static constexpr IdempotencyLevel IdempotencyLevel_MAX =
- MethodOptions_IdempotencyLevel_IdempotencyLevel_MAX;
- static constexpr int IdempotencyLevel_ARRAYSIZE =
- MethodOptions_IdempotencyLevel_IdempotencyLevel_ARRAYSIZE;
- static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
- IdempotencyLevel_descriptor() {
+ static constexpr IdempotencyLevel IdempotencyLevel_MIN = MethodOptions_IdempotencyLevel_IdempotencyLevel_MIN;
+ static constexpr IdempotencyLevel IdempotencyLevel_MAX = MethodOptions_IdempotencyLevel_IdempotencyLevel_MAX;
+ static constexpr int IdempotencyLevel_ARRAYSIZE = MethodOptions_IdempotencyLevel_IdempotencyLevel_ARRAYSIZE;
+ static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* IdempotencyLevel_descriptor() {
return MethodOptions_IdempotencyLevel_descriptor();
}
- template<typename T>
- static inline const TProtoStringType& IdempotencyLevel_Name(T enum_t_value) {
- static_assert(::std::is_same<T, IdempotencyLevel>::value ||
- ::std::is_integral<T>::value,
- "Incorrect type passed to function IdempotencyLevel_Name.");
- return MethodOptions_IdempotencyLevel_Name(enum_t_value);
+ template <typename T>
+ static inline const TProtoStringType& IdempotencyLevel_Name(T value) {
+ return MethodOptions_IdempotencyLevel_Name(value);
}
- static inline bool IdempotencyLevel_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name,
- IdempotencyLevel* value) {
+ static inline bool IdempotencyLevel_Parse(y_absl::string_view name, IdempotencyLevel* value) {
return MethodOptions_IdempotencyLevel_Parse(name, value);
}
@@ -7007,8 +6837,9 @@ class PROTOBUF_EXPORT MethodOptions final :
int uninterpreted_option_size() const;
private:
int _internal_uninterpreted_option_size() const;
+
public:
- void clear_uninterpreted_option();
+ void clear_uninterpreted_option() ;
::PROTOBUF_NAMESPACE_ID::UninterpretedOption* mutable_uninterpreted_option(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >*
mutable_uninterpreted_option();
@@ -7020,223 +6851,179 @@ class PROTOBUF_EXPORT MethodOptions final :
::PROTOBUF_NAMESPACE_ID::UninterpretedOption* add_uninterpreted_option();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >&
uninterpreted_option() const;
-
// optional bool deprecated = 33 [default = false];
bool has_deprecated() const;
- private:
- bool _internal_has_deprecated() const;
- public:
- void clear_deprecated();
+ void clear_deprecated() ;
bool deprecated() const;
void set_deprecated(bool value);
+
private:
bool _internal_deprecated() const;
void _internal_set_deprecated(bool value);
- public:
+ public:
// optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];
bool has_idempotency_level() const;
- private:
- bool _internal_has_idempotency_level() const;
- public:
- void clear_idempotency_level();
+ void clear_idempotency_level() ;
::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel idempotency_level() const;
void set_idempotency_level(::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel value);
+
private:
::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel _internal_idempotency_level() const;
void _internal_set_idempotency_level(::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel value);
- public:
-
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ public:
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline bool HasExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MethodOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _impl_._extensions_.Has(id.number());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void ClearExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MethodOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
_impl_._extensions_.ClearExtension(id.number());
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline int ExtensionSize(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MethodOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _impl_._extensions_.ExtensionSize(id.number());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::ConstType GetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
- return _proto_TypeTraits::Get(id.number(), _impl_._extensions_,
- id.default_value());
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MethodOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
+ return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, id.default_value());
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::MutableType MutableExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
- return _proto_TypeTraits::Mutable(id.number(), _field_type,
- &_impl_._extensions_);
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MethodOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ return _proto_TypeTraits::Mutable(id.number(), _field_type, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MethodOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::ConstType value) {
_proto_TypeTraits::Set(id.number(), _field_type, value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetAllocatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MethodOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::SetAllocated(id.number(), _field_type, value,
&_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void UnsafeArenaSetAllocatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MethodOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type,
value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
PROTOBUF_NODISCARD inline
typename _proto_TypeTraits::Singular::MutableType
ReleaseExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
- return _proto_TypeTraits::Release(id.number(), _field_type,
- &_impl_._extensions_);
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MethodOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ return _proto_TypeTraits::Release(id.number(), _field_type, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::MutableType
UnsafeArenaReleaseExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MethodOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type,
&_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::ConstType GetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MethodOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index) const {
-
return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, index);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::MutableType MutableExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MethodOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index) {
-
return _proto_TypeTraits::Mutable(id.number(), index, &_impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MethodOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
int index, typename _proto_TypeTraits::Repeated::ConstType value) {
_proto_TypeTraits::Set(id.number(), index, value, &_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::MutableType AddExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MethodOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
typename _proto_TypeTraits::Repeated::MutableType to_add =
_proto_TypeTraits::Add(id.number(), _field_type, &_impl_._extensions_);
-
return to_add;
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void AddExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id,
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MethodOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
typename _proto_TypeTraits::Repeated::ConstType value) {
_proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value,
&_impl_._extensions_);
-
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline const typename _proto_TypeTraits::Repeated::RepeatedFieldType&
GetRepeatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MethodOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
return _proto_TypeTraits::GetRepeated(id.number(), _impl_._extensions_);
}
- template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
+ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::RepeatedFieldType*
MutableRepeatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id) {
-
+ const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<MethodOptions, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
return _proto_TypeTraits::MutableRepeated(id.number(), _field_type,
_is_packed, &_impl_._extensions_);
}
-
// @@protoc_insertion_point(class_scope:google.protobuf.MethodOptions)
private:
class _Internal;
@@ -7255,8 +7042,7 @@ class PROTOBUF_EXPORT MethodOptions final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT UninterpretedOption_NamePart final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption.NamePart) */ {
@@ -7333,7 +7119,7 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart final :
}
void UnsafeArenaSwap(UninterpretedOption_NamePart* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -7354,26 +7140,25 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(UninterpretedOption_NamePart* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.UninterpretedOption.NamePart";
}
protected:
- explicit UninterpretedOption_NamePart(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit UninterpretedOption_NamePart(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -7391,41 +7176,42 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart final :
};
// required string name_part = 1;
bool has_name_part() const;
- private:
- bool _internal_has_name_part() const;
- public:
- void clear_name_part();
+ void clear_name_part() ;
const TProtoStringType& name_part() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_name_part(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_name_part(Arg_&& arg, Args_... args);
TProtoStringType* mutable_name_part();
PROTOBUF_NODISCARD TProtoStringType* release_name_part();
- void set_allocated_name_part(TProtoStringType* name_part);
+ void set_allocated_name_part(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_name_part() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_name_part(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_name_part(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_name_part();
- public:
+ public:
// required bool is_extension = 2;
bool has_is_extension() const;
- private:
- bool _internal_has_is_extension() const;
- public:
- void clear_is_extension();
+ void clear_is_extension() ;
bool is_extension() const;
void set_is_extension(bool value);
+
private:
bool _internal_is_extension() const;
void _internal_set_is_extension(bool value);
- public:
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.UninterpretedOption.NamePart)
private:
class _Internal;
// helper for ByteSizeLong()
- size_t RequiredFieldsByteSizeFallback() const;
+ ::size_t RequiredFieldsByteSizeFallback() const;
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
typedef void InternalArenaConstructable_;
@@ -7438,8 +7224,7 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT UninterpretedOption final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption) */ {
@@ -7516,7 +7301,7 @@ class PROTOBUF_EXPORT UninterpretedOption final :
}
void UnsafeArenaSwap(UninterpretedOption* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -7537,26 +7322,25 @@ class PROTOBUF_EXPORT UninterpretedOption final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(UninterpretedOption* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.UninterpretedOption";
}
protected:
- explicit UninterpretedOption(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit UninterpretedOption(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -7583,8 +7367,9 @@ class PROTOBUF_EXPORT UninterpretedOption final :
int name_size() const;
private:
int _internal_name_size() const;
+
public:
- void clear_name();
+ void clear_name() ;
::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart* mutable_name(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart >*
mutable_name();
@@ -7596,100 +7381,102 @@ class PROTOBUF_EXPORT UninterpretedOption final :
::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart* add_name();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart >&
name() const;
-
// optional string identifier_value = 3;
bool has_identifier_value() const;
- private:
- bool _internal_has_identifier_value() const;
- public:
- void clear_identifier_value();
+ void clear_identifier_value() ;
const TProtoStringType& identifier_value() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_identifier_value(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_identifier_value(Arg_&& arg, Args_... args);
TProtoStringType* mutable_identifier_value();
PROTOBUF_NODISCARD TProtoStringType* release_identifier_value();
- void set_allocated_identifier_value(TProtoStringType* identifier_value);
+ void set_allocated_identifier_value(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_identifier_value() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_identifier_value(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_identifier_value(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_identifier_value();
- public:
+ public:
// optional bytes string_value = 7;
bool has_string_value() const;
- private:
- bool _internal_has_string_value() const;
- public:
- void clear_string_value();
+ void clear_string_value() ;
const TProtoStringType& string_value() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_string_value(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_string_value(Arg_&& arg, Args_... args);
TProtoStringType* mutable_string_value();
PROTOBUF_NODISCARD TProtoStringType* release_string_value();
- void set_allocated_string_value(TProtoStringType* string_value);
+ void set_allocated_string_value(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_string_value() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_string_value(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_string_value(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_string_value();
- public:
+ public:
// optional string aggregate_value = 8;
bool has_aggregate_value() const;
- private:
- bool _internal_has_aggregate_value() const;
- public:
- void clear_aggregate_value();
+ void clear_aggregate_value() ;
const TProtoStringType& aggregate_value() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_aggregate_value(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_aggregate_value(Arg_&& arg, Args_... args);
TProtoStringType* mutable_aggregate_value();
PROTOBUF_NODISCARD TProtoStringType* release_aggregate_value();
- void set_allocated_aggregate_value(TProtoStringType* aggregate_value);
+ void set_allocated_aggregate_value(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_aggregate_value() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_aggregate_value(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_aggregate_value(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_aggregate_value();
- public:
+ public:
// optional uint64 positive_int_value = 4;
bool has_positive_int_value() const;
+ void clear_positive_int_value() ;
+ ::arc_ui64 positive_int_value() const;
+ void set_positive_int_value(::arc_ui64 value);
+
private:
- bool _internal_has_positive_int_value() const;
- public:
- void clear_positive_int_value();
- arc_ui64 positive_int_value() const;
- void set_positive_int_value(arc_ui64 value);
- private:
- arc_ui64 _internal_positive_int_value() const;
- void _internal_set_positive_int_value(arc_ui64 value);
- public:
+ ::arc_ui64 _internal_positive_int_value() const;
+ void _internal_set_positive_int_value(::arc_ui64 value);
+ public:
// optional int64 negative_int_value = 5;
bool has_negative_int_value() const;
+ void clear_negative_int_value() ;
+ ::arc_i64 negative_int_value() const;
+ void set_negative_int_value(::arc_i64 value);
+
private:
- bool _internal_has_negative_int_value() const;
- public:
- void clear_negative_int_value();
- arc_i64 negative_int_value() const;
- void set_negative_int_value(arc_i64 value);
- private:
- arc_i64 _internal_negative_int_value() const;
- void _internal_set_negative_int_value(arc_i64 value);
- public:
+ ::arc_i64 _internal_negative_int_value() const;
+ void _internal_set_negative_int_value(::arc_i64 value);
+ public:
// optional double double_value = 6;
bool has_double_value() const;
- private:
- bool _internal_has_double_value() const;
- public:
- void clear_double_value();
+ void clear_double_value() ;
double double_value() const;
void set_double_value(double value);
+
private:
double _internal_double_value() const;
void _internal_set_double_value(double value);
- public:
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.UninterpretedOption)
private:
class _Internal;
@@ -7704,14 +7491,13 @@ class PROTOBUF_EXPORT UninterpretedOption final :
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr identifier_value_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr string_value_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr aggregate_value_;
- arc_ui64 positive_int_value_;
- arc_i64 negative_int_value_;
+ ::arc_ui64 positive_int_value_;
+ ::arc_i64 negative_int_value_;
double double_value_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT SourceCodeInfo_Location final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo.Location) */ {
@@ -7788,7 +7574,7 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location final :
}
void UnsafeArenaSwap(SourceCodeInfo_Location* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -7809,26 +7595,25 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(SourceCodeInfo_Location* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.SourceCodeInfo.Location";
}
protected:
- explicit SourceCodeInfo_Location(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit SourceCodeInfo_Location(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -7851,106 +7636,112 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location final :
int path_size() const;
private:
int _internal_path_size() const;
+
public:
- void clear_path();
+ void clear_path() ;
+ ::arc_i32 path(int index) const;
+ void set_path(int index, ::arc_i32 value);
+ void add_path(::arc_i32 value);
+ const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>& path() const;
+ ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>* mutable_path();
+
private:
- arc_i32 _internal_path(int index) const;
- const ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >&
- _internal_path() const;
- void _internal_add_path(arc_i32 value);
- ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >*
- _internal_mutable_path();
- public:
- arc_i32 path(int index) const;
- void set_path(int index, arc_i32 value);
- void add_path(arc_i32 value);
- const ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >&
- path() const;
- ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >*
- mutable_path();
+ ::arc_i32 _internal_path(int index) const;
+ void _internal_add_path(::arc_i32 value);
+ const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>& _internal_path() const;
+ ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>* _internal_mutable_path();
+ public:
// repeated int32 span = 2 [packed = true];
int span_size() const;
private:
int _internal_span_size() const;
+
public:
- void clear_span();
+ void clear_span() ;
+ ::arc_i32 span(int index) const;
+ void set_span(int index, ::arc_i32 value);
+ void add_span(::arc_i32 value);
+ const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>& span() const;
+ ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>* mutable_span();
+
private:
- arc_i32 _internal_span(int index) const;
- const ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >&
- _internal_span() const;
- void _internal_add_span(arc_i32 value);
- ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >*
- _internal_mutable_span();
- public:
- arc_i32 span(int index) const;
- void set_span(int index, arc_i32 value);
- void add_span(arc_i32 value);
- const ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >&
- span() const;
- ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >*
- mutable_span();
+ ::arc_i32 _internal_span(int index) const;
+ void _internal_add_span(::arc_i32 value);
+ const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>& _internal_span() const;
+ ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>* _internal_mutable_span();
+ public:
// repeated string leading_detached_comments = 6;
int leading_detached_comments_size() const;
private:
int _internal_leading_detached_comments_size() const;
+
public:
- void clear_leading_detached_comments();
+ void clear_leading_detached_comments() ;
const TProtoStringType& leading_detached_comments(int index) const;
TProtoStringType* mutable_leading_detached_comments(int index);
void set_leading_detached_comments(int index, const TProtoStringType& value);
void set_leading_detached_comments(int index, TProtoStringType&& value);
void set_leading_detached_comments(int index, const char* value);
- void set_leading_detached_comments(int index, const char* value, size_t size);
+ void set_leading_detached_comments(int index, const char* value, std::size_t size);
+ void set_leading_detached_comments(int index, y_absl::string_view value);
TProtoStringType* add_leading_detached_comments();
void add_leading_detached_comments(const TProtoStringType& value);
void add_leading_detached_comments(TProtoStringType&& value);
void add_leading_detached_comments(const char* value);
- void add_leading_detached_comments(const char* value, size_t size);
+ void add_leading_detached_comments(const char* value, std::size_t size);
+ void add_leading_detached_comments(y_absl::string_view value);
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>& leading_detached_comments() const;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>* mutable_leading_detached_comments();
+
private:
const TProtoStringType& _internal_leading_detached_comments(int index) const;
TProtoStringType* _internal_add_leading_detached_comments();
- public:
+ public:
// optional string leading_comments = 3;
bool has_leading_comments() const;
- private:
- bool _internal_has_leading_comments() const;
- public:
- void clear_leading_comments();
+ void clear_leading_comments() ;
const TProtoStringType& leading_comments() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_leading_comments(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_leading_comments(Arg_&& arg, Args_... args);
TProtoStringType* mutable_leading_comments();
PROTOBUF_NODISCARD TProtoStringType* release_leading_comments();
- void set_allocated_leading_comments(TProtoStringType* leading_comments);
+ void set_allocated_leading_comments(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_leading_comments() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_leading_comments(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_leading_comments(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_leading_comments();
- public:
+ public:
// optional string trailing_comments = 4;
bool has_trailing_comments() const;
- private:
- bool _internal_has_trailing_comments() const;
- public:
- void clear_trailing_comments();
+ void clear_trailing_comments() ;
const TProtoStringType& trailing_comments() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_trailing_comments(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_trailing_comments(Arg_&& arg, Args_... args);
TProtoStringType* mutable_trailing_comments();
PROTOBUF_NODISCARD TProtoStringType* release_trailing_comments();
- void set_allocated_trailing_comments(TProtoStringType* trailing_comments);
+ void set_allocated_trailing_comments(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_trailing_comments() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_trailing_comments(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_trailing_comments(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_trailing_comments();
- public:
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.SourceCodeInfo.Location)
private:
class _Internal;
@@ -7961,18 +7752,17 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location final :
struct Impl_ {
::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
- ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 > path_;
- mutable std::atomic<int> _path_cached_byte_size_;
- ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 > span_;
- mutable std::atomic<int> _span_cached_byte_size_;
+ ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32> path_;
+ mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _path_cached_byte_size_;
+ ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32> span_;
+ mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _span_cached_byte_size_;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType> leading_detached_comments_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr leading_comments_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr trailing_comments_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT SourceCodeInfo final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo) */ {
@@ -8049,7 +7839,7 @@ class PROTOBUF_EXPORT SourceCodeInfo final :
}
void UnsafeArenaSwap(SourceCodeInfo* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -8070,26 +7860,25 @@ class PROTOBUF_EXPORT SourceCodeInfo final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(SourceCodeInfo* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.SourceCodeInfo";
}
protected:
- explicit SourceCodeInfo(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit SourceCodeInfo(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -8110,8 +7899,9 @@ class PROTOBUF_EXPORT SourceCodeInfo final :
int location_size() const;
private:
int _internal_location_size() const;
+
public:
- void clear_location();
+ void clear_location() ;
::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location* mutable_location(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location >*
mutable_location();
@@ -8123,7 +7913,6 @@ class PROTOBUF_EXPORT SourceCodeInfo final :
::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location* add_location();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location >&
location() const;
-
// @@protoc_insertion_point(class_scope:google.protobuf.SourceCodeInfo)
private:
class _Internal;
@@ -8137,8 +7926,7 @@ class PROTOBUF_EXPORT SourceCodeInfo final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo.Annotation) */ {
@@ -8215,7 +8003,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final :
}
void UnsafeArenaSwap(GeneratedCodeInfo_Annotation* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -8236,26 +8024,25 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(GeneratedCodeInfo_Annotation* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.GeneratedCodeInfo.Annotation";
}
protected:
- explicit GeneratedCodeInfo_Annotation(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit GeneratedCodeInfo_Annotation(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -8265,6 +8052,27 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final :
// nested types ----------------------------------------------------
+ using Semantic = GeneratedCodeInfo_Annotation_Semantic;
+ static constexpr Semantic NONE = GeneratedCodeInfo_Annotation_Semantic_NONE;
+ static constexpr Semantic SET = GeneratedCodeInfo_Annotation_Semantic_SET;
+ static constexpr Semantic ALIAS = GeneratedCodeInfo_Annotation_Semantic_ALIAS;
+ static inline bool Semantic_IsValid(int value) {
+ return GeneratedCodeInfo_Annotation_Semantic_IsValid(value);
+ }
+ static constexpr Semantic Semantic_MIN = GeneratedCodeInfo_Annotation_Semantic_Semantic_MIN;
+ static constexpr Semantic Semantic_MAX = GeneratedCodeInfo_Annotation_Semantic_Semantic_MAX;
+ static constexpr int Semantic_ARRAYSIZE = GeneratedCodeInfo_Annotation_Semantic_Semantic_ARRAYSIZE;
+ static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Semantic_descriptor() {
+ return GeneratedCodeInfo_Annotation_Semantic_descriptor();
+ }
+ template <typename T>
+ static inline const TProtoStringType& Semantic_Name(T value) {
+ return GeneratedCodeInfo_Annotation_Semantic_Name(value);
+ }
+ static inline bool Semantic_Parse(y_absl::string_view name, Semantic* value) {
+ return GeneratedCodeInfo_Annotation_Semantic_Parse(name, value);
+ }
+
// accessors -------------------------------------------------------
enum : int {
@@ -8272,73 +8080,82 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final :
kSourceFileFieldNumber = 2,
kBeginFieldNumber = 3,
kEndFieldNumber = 4,
+ kSemanticFieldNumber = 5,
};
// repeated int32 path = 1 [packed = true];
int path_size() const;
private:
int _internal_path_size() const;
+
public:
- void clear_path();
+ void clear_path() ;
+ ::arc_i32 path(int index) const;
+ void set_path(int index, ::arc_i32 value);
+ void add_path(::arc_i32 value);
+ const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>& path() const;
+ ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>* mutable_path();
+
private:
- arc_i32 _internal_path(int index) const;
- const ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >&
- _internal_path() const;
- void _internal_add_path(arc_i32 value);
- ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >*
- _internal_mutable_path();
- public:
- arc_i32 path(int index) const;
- void set_path(int index, arc_i32 value);
- void add_path(arc_i32 value);
- const ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >&
- path() const;
- ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >*
- mutable_path();
+ ::arc_i32 _internal_path(int index) const;
+ void _internal_add_path(::arc_i32 value);
+ const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>& _internal_path() const;
+ ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>* _internal_mutable_path();
+ public:
// optional string source_file = 2;
bool has_source_file() const;
- private:
- bool _internal_has_source_file() const;
- public:
- void clear_source_file();
+ void clear_source_file() ;
const TProtoStringType& source_file() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_source_file(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_source_file(Arg_&& arg, Args_... args);
TProtoStringType* mutable_source_file();
PROTOBUF_NODISCARD TProtoStringType* release_source_file();
- void set_allocated_source_file(TProtoStringType* source_file);
+ void set_allocated_source_file(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_source_file() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_source_file(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_source_file(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_source_file();
- public:
+ public:
// optional int32 begin = 3;
bool has_begin() const;
+ void clear_begin() ;
+ ::arc_i32 begin() const;
+ void set_begin(::arc_i32 value);
+
private:
- bool _internal_has_begin() const;
- public:
- void clear_begin();
- arc_i32 begin() const;
- void set_begin(arc_i32 value);
- private:
- arc_i32 _internal_begin() const;
- void _internal_set_begin(arc_i32 value);
- public:
+ ::arc_i32 _internal_begin() const;
+ void _internal_set_begin(::arc_i32 value);
+ public:
// optional int32 end = 4;
bool has_end() const;
+ void clear_end() ;
+ ::arc_i32 end() const;
+ void set_end(::arc_i32 value);
+
private:
- bool _internal_has_end() const;
+ ::arc_i32 _internal_end() const;
+ void _internal_set_end(::arc_i32 value);
+
public:
- void clear_end();
- arc_i32 end() const;
- void set_end(arc_i32 value);
+ // optional .google.protobuf.GeneratedCodeInfo.Annotation.Semantic semantic = 5;
+ bool has_semantic() const;
+ void clear_semantic() ;
+ ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation_Semantic semantic() const;
+ void set_semantic(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation_Semantic value);
+
private:
- arc_i32 _internal_end() const;
- void _internal_set_end(arc_i32 value);
- public:
+ ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation_Semantic _internal_semantic() const;
+ void _internal_set_semantic(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation_Semantic value);
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.GeneratedCodeInfo.Annotation)
private:
class _Internal;
@@ -8349,16 +8166,16 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final :
struct Impl_ {
::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
- ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 > path_;
- mutable std::atomic<int> _path_cached_byte_size_;
+ ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32> path_;
+ mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _path_cached_byte_size_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr source_file_;
- arc_i32 begin_;
- arc_i32 end_;
+ ::arc_i32 begin_;
+ ::arc_i32 end_;
+ int semantic_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT GeneratedCodeInfo final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo) */ {
@@ -8435,7 +8252,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final :
}
void UnsafeArenaSwap(GeneratedCodeInfo* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -8456,26 +8273,25 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(GeneratedCodeInfo* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.GeneratedCodeInfo";
}
protected:
- explicit GeneratedCodeInfo(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit GeneratedCodeInfo(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -8496,8 +8312,9 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final :
int annotation_size() const;
private:
int _internal_annotation_size() const;
+
public:
- void clear_annotation();
+ void clear_annotation() ;
::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation* mutable_annotation(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation >*
mutable_annotation();
@@ -8509,7 +8326,6 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final :
::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation* add_annotation();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation >&
annotation() const;
-
// @@protoc_insertion_point(class_scope:google.protobuf.GeneratedCodeInfo)
private:
class _Internal;
@@ -8524,15 +8340,21 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final :
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto;
};
+
// ===================================================================
+
+
// ===================================================================
+
#ifdef __GNUC__
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
+// -------------------------------------------------------------------
+
// FileDescriptorSet
// repeated .google.protobuf.FileDescriptorProto file = 1;
@@ -8580,13 +8402,10 @@ FileDescriptorSet::file() const {
// FileDescriptorProto
// optional string name = 1;
-inline bool FileDescriptorProto::_internal_has_name() const {
+inline bool FileDescriptorProto::has_name() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool FileDescriptorProto::has_name() const {
- return _internal_has_name();
-}
inline void FileDescriptorProto::clear_name() {
_impl_.name_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000001u;
@@ -8595,11 +8414,11 @@ inline const TProtoStringType& FileDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.name)
return _internal_name();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void FileDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void FileDescriptorProto::set_name(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.name_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.name)
}
inline TProtoStringType* FileDescriptorProto::mutable_name() {
@@ -8612,49 +8431,46 @@ inline const TProtoStringType& FileDescriptorProto::_internal_name() const {
}
inline void FileDescriptorProto::_internal_set_name(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000001u;
+
+
_impl_.name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileDescriptorProto::_internal_mutable_name() {
_impl_._has_bits_[0] |= 0x00000001u;
- return _impl_.name_.Mutable(GetArenaForAllocation());
+ return _impl_.name_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* FileDescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.name)
- if (!_internal_has_name()) {
+ if ((_impl_._has_bits_[0] & 0x00000001u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000001u;
- auto* p = _impl_.name_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void FileDescriptorProto::set_allocated_name(TProtoStringType* name) {
- if (name != nullptr) {
+ auto* released = _impl_.name_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void FileDescriptorProto::set_allocated_name(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000001u;
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
- _impl_.name_.SetAllocated(name, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.name_.IsDefault()) {
+ _impl_.name_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.name)
}
// optional string package = 2;
-inline bool FileDescriptorProto::_internal_has_package() const {
+inline bool FileDescriptorProto::has_package() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
return value;
}
-inline bool FileDescriptorProto::has_package() const {
- return _internal_has_package();
-}
inline void FileDescriptorProto::clear_package() {
_impl_.package_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000002u;
@@ -8663,11 +8479,11 @@ inline const TProtoStringType& FileDescriptorProto::package() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.package)
return _internal_package();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void FileDescriptorProto::set_package(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000002u;
- _impl_.package_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void FileDescriptorProto::set_package(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000002u;
+ _impl_.package_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.package)
}
inline TProtoStringType* FileDescriptorProto::mutable_package() {
@@ -8680,38 +8496,38 @@ inline const TProtoStringType& FileDescriptorProto::_internal_package() const {
}
inline void FileDescriptorProto::_internal_set_package(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000002u;
+
+
_impl_.package_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileDescriptorProto::_internal_mutable_package() {
_impl_._has_bits_[0] |= 0x00000002u;
- return _impl_.package_.Mutable(GetArenaForAllocation());
+ return _impl_.package_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* FileDescriptorProto::release_package() {
// @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.package)
- if (!_internal_has_package()) {
+ if ((_impl_._has_bits_[0] & 0x00000002u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000002u;
- auto* p = _impl_.package_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.package_.IsDefault()) {
- _impl_.package_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void FileDescriptorProto::set_allocated_package(TProtoStringType* package) {
- if (package != nullptr) {
+ auto* released = _impl_.package_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.package_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void FileDescriptorProto::set_allocated_package(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000002u;
} else {
_impl_._has_bits_[0] &= ~0x00000002u;
}
- _impl_.package_.SetAllocated(package, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.package_.IsDefault()) {
- _impl_.package_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.package_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.package_.IsDefault()) {
+ _impl_.package_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.package)
}
@@ -8750,18 +8566,20 @@ inline void FileDescriptorProto::set_dependency(int index, TProtoStringType&& va
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency)
}
inline void FileDescriptorProto::set_dependency(int index, const char* value) {
- GOOGLE_DCHECK(value != nullptr);
+ Y_ABSL_DCHECK(value != nullptr);
_impl_.dependency_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.dependency)
}
-inline void FileDescriptorProto::set_dependency(int index, const char* value, size_t size) {
- _impl_.dependency_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
+inline void FileDescriptorProto::set_dependency(int index, const char* value,
+ std::size_t size) {
+ _impl_.dependency_.Mutable(index)->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.dependency)
}
-inline TProtoStringType* FileDescriptorProto::_internal_add_dependency() {
- return _impl_.dependency_.Add();
+inline void FileDescriptorProto::set_dependency(int index, y_absl::string_view value) {
+ _impl_.dependency_.Mutable(index)->assign(value.data(), value.size());
+ // @@protoc_insertion_point(field_set_string_piece:google.protobuf.FileDescriptorProto.dependency)
}
+inline TProtoStringType* FileDescriptorProto::_internal_add_dependency() { return _impl_.dependency_.Add(); }
inline void FileDescriptorProto::add_dependency(const TProtoStringType& value) {
_impl_.dependency_.Add()->assign(value);
// @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency)
@@ -8771,21 +8589,24 @@ inline void FileDescriptorProto::add_dependency(TProtoStringType&& value) {
// @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency)
}
inline void FileDescriptorProto::add_dependency(const char* value) {
- GOOGLE_DCHECK(value != nullptr);
+ Y_ABSL_DCHECK(value != nullptr);
_impl_.dependency_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.FileDescriptorProto.dependency)
}
-inline void FileDescriptorProto::add_dependency(const char* value, size_t size) {
+inline void FileDescriptorProto::add_dependency(const char* value, std::size_t size) {
_impl_.dependency_.Add()->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_add_pointer:google.protobuf.FileDescriptorProto.dependency)
}
+inline void FileDescriptorProto::add_dependency(y_absl::string_view value) {
+ _impl_.dependency_.Add()->assign(value.data(), value.size());
+ // @@protoc_insertion_point(field_add_string_piece:google.protobuf.FileDescriptorProto.dependency)
+}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>&
FileDescriptorProto::dependency() const {
// @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.dependency)
return _impl_.dependency_;
}
-inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>*
-FileDescriptorProto::mutable_dependency() {
+inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>* FileDescriptorProto::mutable_dependency() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.dependency)
return &_impl_.dependency_;
}
@@ -8800,43 +8621,38 @@ inline int FileDescriptorProto::public_dependency_size() const {
inline void FileDescriptorProto::clear_public_dependency() {
_impl_.public_dependency_.Clear();
}
-inline arc_i32 FileDescriptorProto::_internal_public_dependency(int index) const {
- return _impl_.public_dependency_.Get(index);
-}
-inline arc_i32 FileDescriptorProto::public_dependency(int index) const {
+inline ::arc_i32 FileDescriptorProto::public_dependency(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.public_dependency)
return _internal_public_dependency(index);
}
-inline void FileDescriptorProto::set_public_dependency(int index, arc_i32 value) {
+inline void FileDescriptorProto::set_public_dependency(int index, ::arc_i32 value) {
_impl_.public_dependency_.Set(index, value);
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.public_dependency)
}
-inline void FileDescriptorProto::_internal_add_public_dependency(arc_i32 value) {
- _impl_.public_dependency_.Add(value);
-}
-inline void FileDescriptorProto::add_public_dependency(arc_i32 value) {
+inline void FileDescriptorProto::add_public_dependency(::arc_i32 value) {
_internal_add_public_dependency(value);
// @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.public_dependency)
}
-inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >&
-FileDescriptorProto::_internal_public_dependency() const {
- return _impl_.public_dependency_;
-}
-inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >&
-FileDescriptorProto::public_dependency() const {
+inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>& FileDescriptorProto::public_dependency() const {
// @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.public_dependency)
return _internal_public_dependency();
}
-inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >*
-FileDescriptorProto::_internal_mutable_public_dependency() {
- return &_impl_.public_dependency_;
-}
-inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >*
-FileDescriptorProto::mutable_public_dependency() {
+inline ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>* FileDescriptorProto::mutable_public_dependency() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.public_dependency)
return _internal_mutable_public_dependency();
}
+inline ::arc_i32 FileDescriptorProto::_internal_public_dependency(int index) const {
+ return _impl_.public_dependency_.Get(index);
+}
+inline void FileDescriptorProto::_internal_add_public_dependency(::arc_i32 value) { _impl_.public_dependency_.Add(value); }
+inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>& FileDescriptorProto::_internal_public_dependency() const {
+ return _impl_.public_dependency_;
+}
+inline ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>* FileDescriptorProto::_internal_mutable_public_dependency() {
+ return &_impl_.public_dependency_;
+}
+
// repeated int32 weak_dependency = 11;
inline int FileDescriptorProto::_internal_weak_dependency_size() const {
return _impl_.weak_dependency_.size();
@@ -8847,43 +8663,38 @@ inline int FileDescriptorProto::weak_dependency_size() const {
inline void FileDescriptorProto::clear_weak_dependency() {
_impl_.weak_dependency_.Clear();
}
-inline arc_i32 FileDescriptorProto::_internal_weak_dependency(int index) const {
- return _impl_.weak_dependency_.Get(index);
-}
-inline arc_i32 FileDescriptorProto::weak_dependency(int index) const {
+inline ::arc_i32 FileDescriptorProto::weak_dependency(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.weak_dependency)
return _internal_weak_dependency(index);
}
-inline void FileDescriptorProto::set_weak_dependency(int index, arc_i32 value) {
+inline void FileDescriptorProto::set_weak_dependency(int index, ::arc_i32 value) {
_impl_.weak_dependency_.Set(index, value);
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.weak_dependency)
}
-inline void FileDescriptorProto::_internal_add_weak_dependency(arc_i32 value) {
- _impl_.weak_dependency_.Add(value);
-}
-inline void FileDescriptorProto::add_weak_dependency(arc_i32 value) {
+inline void FileDescriptorProto::add_weak_dependency(::arc_i32 value) {
_internal_add_weak_dependency(value);
// @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.weak_dependency)
}
-inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >&
-FileDescriptorProto::_internal_weak_dependency() const {
- return _impl_.weak_dependency_;
-}
-inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >&
-FileDescriptorProto::weak_dependency() const {
+inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>& FileDescriptorProto::weak_dependency() const {
// @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.weak_dependency)
return _internal_weak_dependency();
}
-inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >*
-FileDescriptorProto::_internal_mutable_weak_dependency() {
- return &_impl_.weak_dependency_;
-}
-inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >*
-FileDescriptorProto::mutable_weak_dependency() {
+inline ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>* FileDescriptorProto::mutable_weak_dependency() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.weak_dependency)
return _internal_mutable_weak_dependency();
}
+inline ::arc_i32 FileDescriptorProto::_internal_weak_dependency(int index) const {
+ return _impl_.weak_dependency_.Get(index);
+}
+inline void FileDescriptorProto::_internal_add_weak_dependency(::arc_i32 value) { _impl_.weak_dependency_.Add(value); }
+inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>& FileDescriptorProto::_internal_weak_dependency() const {
+ return _impl_.weak_dependency_;
+}
+inline ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>* FileDescriptorProto::_internal_mutable_weak_dependency() {
+ return &_impl_.weak_dependency_;
+}
+
// repeated .google.protobuf.DescriptorProto message_type = 4;
inline int FileDescriptorProto::_internal_message_type_size() const {
return _impl_.message_type_.size();
@@ -9045,17 +8856,14 @@ FileDescriptorProto::extension() const {
}
// optional .google.protobuf.FileOptions options = 8;
-inline bool FileDescriptorProto::_internal_has_options() const {
- bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0;
+inline bool FileDescriptorProto::has_options() const {
+ bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0;
PROTOBUF_ASSUME(!value || _impl_.options_ != nullptr);
return value;
}
-inline bool FileDescriptorProto::has_options() const {
- return _internal_has_options();
-}
inline void FileDescriptorProto::clear_options() {
if (_impl_.options_ != nullptr) _impl_.options_->Clear();
- _impl_._has_bits_[0] &= ~0x00000008u;
+ _impl_._has_bits_[0] &= ~0x00000010u;
}
inline const ::PROTOBUF_NAMESPACE_ID::FileOptions& FileDescriptorProto::_internal_options() const {
const ::PROTOBUF_NAMESPACE_ID::FileOptions* p = _impl_.options_;
@@ -9073,14 +8881,14 @@ inline void FileDescriptorProto::unsafe_arena_set_allocated_options(
}
_impl_.options_ = options;
if (options) {
- _impl_._has_bits_[0] |= 0x00000008u;
+ _impl_._has_bits_[0] |= 0x00000010u;
} else {
- _impl_._has_bits_[0] &= ~0x00000008u;
+ _impl_._has_bits_[0] &= ~0x00000010u;
}
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileDescriptorProto.options)
}
inline ::PROTOBUF_NAMESPACE_ID::FileOptions* FileDescriptorProto::release_options() {
- _impl_._has_bits_[0] &= ~0x00000008u;
+ _impl_._has_bits_[0] &= ~0x00000010u;
::PROTOBUF_NAMESPACE_ID::FileOptions* temp = _impl_.options_;
_impl_.options_ = nullptr;
#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE
@@ -9096,13 +8904,13 @@ inline ::PROTOBUF_NAMESPACE_ID::FileOptions* FileDescriptorProto::release_option
}
inline ::PROTOBUF_NAMESPACE_ID::FileOptions* FileDescriptorProto::unsafe_arena_release_options() {
// @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.options)
- _impl_._has_bits_[0] &= ~0x00000008u;
+ _impl_._has_bits_[0] &= ~0x00000010u;
::PROTOBUF_NAMESPACE_ID::FileOptions* temp = _impl_.options_;
_impl_.options_ = nullptr;
return temp;
}
inline ::PROTOBUF_NAMESPACE_ID::FileOptions* FileDescriptorProto::_internal_mutable_options() {
- _impl_._has_bits_[0] |= 0x00000008u;
+ _impl_._has_bits_[0] |= 0x00000010u;
if (_impl_.options_ == nullptr) {
auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FileOptions>(GetArenaForAllocation());
_impl_.options_ = p;
@@ -9126,26 +8934,23 @@ inline void FileDescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE_ID::
options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, options, submessage_arena);
}
- _impl_._has_bits_[0] |= 0x00000008u;
+ _impl_._has_bits_[0] |= 0x00000010u;
} else {
- _impl_._has_bits_[0] &= ~0x00000008u;
+ _impl_._has_bits_[0] &= ~0x00000010u;
}
_impl_.options_ = options;
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.options)
}
// optional .google.protobuf.SourceCodeInfo source_code_info = 9;
-inline bool FileDescriptorProto::_internal_has_source_code_info() const {
- bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0;
+inline bool FileDescriptorProto::has_source_code_info() const {
+ bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0;
PROTOBUF_ASSUME(!value || _impl_.source_code_info_ != nullptr);
return value;
}
-inline bool FileDescriptorProto::has_source_code_info() const {
- return _internal_has_source_code_info();
-}
inline void FileDescriptorProto::clear_source_code_info() {
if (_impl_.source_code_info_ != nullptr) _impl_.source_code_info_->Clear();
- _impl_._has_bits_[0] &= ~0x00000010u;
+ _impl_._has_bits_[0] &= ~0x00000020u;
}
inline const ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo& FileDescriptorProto::_internal_source_code_info() const {
const ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* p = _impl_.source_code_info_;
@@ -9163,14 +8968,14 @@ inline void FileDescriptorProto::unsafe_arena_set_allocated_source_code_info(
}
_impl_.source_code_info_ = source_code_info;
if (source_code_info) {
- _impl_._has_bits_[0] |= 0x00000010u;
+ _impl_._has_bits_[0] |= 0x00000020u;
} else {
- _impl_._has_bits_[0] &= ~0x00000010u;
+ _impl_._has_bits_[0] &= ~0x00000020u;
}
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileDescriptorProto.source_code_info)
}
inline ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* FileDescriptorProto::release_source_code_info() {
- _impl_._has_bits_[0] &= ~0x00000010u;
+ _impl_._has_bits_[0] &= ~0x00000020u;
::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* temp = _impl_.source_code_info_;
_impl_.source_code_info_ = nullptr;
#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE
@@ -9186,13 +8991,13 @@ inline ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* FileDescriptorProto::release_sou
}
inline ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* FileDescriptorProto::unsafe_arena_release_source_code_info() {
// @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.source_code_info)
- _impl_._has_bits_[0] &= ~0x00000010u;
+ _impl_._has_bits_[0] &= ~0x00000020u;
::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* temp = _impl_.source_code_info_;
_impl_.source_code_info_ = nullptr;
return temp;
}
inline ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* FileDescriptorProto::_internal_mutable_source_code_info() {
- _impl_._has_bits_[0] |= 0x00000010u;
+ _impl_._has_bits_[0] |= 0x00000020u;
if (_impl_.source_code_info_ == nullptr) {
auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::SourceCodeInfo>(GetArenaForAllocation());
_impl_.source_code_info_ = p;
@@ -9216,22 +9021,19 @@ inline void FileDescriptorProto::set_allocated_source_code_info(::PROTOBUF_NAMES
source_code_info = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, source_code_info, submessage_arena);
}
- _impl_._has_bits_[0] |= 0x00000010u;
+ _impl_._has_bits_[0] |= 0x00000020u;
} else {
- _impl_._has_bits_[0] &= ~0x00000010u;
+ _impl_._has_bits_[0] &= ~0x00000020u;
}
_impl_.source_code_info_ = source_code_info;
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.source_code_info)
}
// optional string syntax = 12;
-inline bool FileDescriptorProto::_internal_has_syntax() const {
+inline bool FileDescriptorProto::has_syntax() const {
bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0;
return value;
}
-inline bool FileDescriptorProto::has_syntax() const {
- return _internal_has_syntax();
-}
inline void FileDescriptorProto::clear_syntax() {
_impl_.syntax_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000004u;
@@ -9240,11 +9042,11 @@ inline const TProtoStringType& FileDescriptorProto::syntax() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.syntax)
return _internal_syntax();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void FileDescriptorProto::set_syntax(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000004u;
- _impl_.syntax_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void FileDescriptorProto::set_syntax(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000004u;
+ _impl_.syntax_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.syntax)
}
inline TProtoStringType* FileDescriptorProto::mutable_syntax() {
@@ -9257,110 +9059,166 @@ inline const TProtoStringType& FileDescriptorProto::_internal_syntax() const {
}
inline void FileDescriptorProto::_internal_set_syntax(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000004u;
+
+
_impl_.syntax_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileDescriptorProto::_internal_mutable_syntax() {
_impl_._has_bits_[0] |= 0x00000004u;
- return _impl_.syntax_.Mutable(GetArenaForAllocation());
+ return _impl_.syntax_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* FileDescriptorProto::release_syntax() {
// @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.syntax)
- if (!_internal_has_syntax()) {
+ if ((_impl_._has_bits_[0] & 0x00000004u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000004u;
- auto* p = _impl_.syntax_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.syntax_.IsDefault()) {
- _impl_.syntax_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void FileDescriptorProto::set_allocated_syntax(TProtoStringType* syntax) {
- if (syntax != nullptr) {
+ auto* released = _impl_.syntax_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.syntax_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void FileDescriptorProto::set_allocated_syntax(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000004u;
} else {
_impl_._has_bits_[0] &= ~0x00000004u;
}
- _impl_.syntax_.SetAllocated(syntax, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.syntax_.IsDefault()) {
- _impl_.syntax_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.syntax_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.syntax_.IsDefault()) {
+ _impl_.syntax_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.syntax)
}
+// optional string edition = 13;
+inline bool FileDescriptorProto::has_edition() const {
+ bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0;
+ return value;
+}
+inline void FileDescriptorProto::clear_edition() {
+ _impl_.edition_.ClearToEmpty();
+ _impl_._has_bits_[0] &= ~0x00000008u;
+}
+inline const TProtoStringType& FileDescriptorProto::edition() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.edition)
+ return _internal_edition();
+}
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void FileDescriptorProto::set_edition(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000008u;
+ _impl_.edition_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
+ // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.edition)
+}
+inline TProtoStringType* FileDescriptorProto::mutable_edition() {
+ TProtoStringType* _s = _internal_mutable_edition();
+ // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.edition)
+ return _s;
+}
+inline const TProtoStringType& FileDescriptorProto::_internal_edition() const {
+ return _impl_.edition_.Get();
+}
+inline void FileDescriptorProto::_internal_set_edition(const TProtoStringType& value) {
+ _impl_._has_bits_[0] |= 0x00000008u;
+
+
+ _impl_.edition_.Set(value, GetArenaForAllocation());
+}
+inline TProtoStringType* FileDescriptorProto::_internal_mutable_edition() {
+ _impl_._has_bits_[0] |= 0x00000008u;
+ return _impl_.edition_.Mutable( GetArenaForAllocation());
+}
+inline TProtoStringType* FileDescriptorProto::release_edition() {
+ // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.edition)
+ if ((_impl_._has_bits_[0] & 0x00000008u) == 0) {
+ return nullptr;
+ }
+ _impl_._has_bits_[0] &= ~0x00000008u;
+ auto* released = _impl_.edition_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.edition_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void FileDescriptorProto::set_allocated_edition(TProtoStringType* value) {
+ if (value != nullptr) {
+ _impl_._has_bits_[0] |= 0x00000008u;
+ } else {
+ _impl_._has_bits_[0] &= ~0x00000008u;
+ }
+ _impl_.edition_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.edition_.IsDefault()) {
+ _impl_.edition_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.edition)
+}
+
// -------------------------------------------------------------------
// DescriptorProto_ExtensionRange
// optional int32 start = 1;
-inline bool DescriptorProto_ExtensionRange::_internal_has_start() const {
+inline bool DescriptorProto_ExtensionRange::has_start() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
return value;
}
-inline bool DescriptorProto_ExtensionRange::has_start() const {
- return _internal_has_start();
-}
inline void DescriptorProto_ExtensionRange::clear_start() {
_impl_.start_ = 0;
_impl_._has_bits_[0] &= ~0x00000002u;
}
-inline arc_i32 DescriptorProto_ExtensionRange::_internal_start() const {
- return _impl_.start_;
-}
-inline arc_i32 DescriptorProto_ExtensionRange::start() const {
+inline ::arc_i32 DescriptorProto_ExtensionRange::start() const {
// @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.start)
return _internal_start();
}
-inline void DescriptorProto_ExtensionRange::_internal_set_start(arc_i32 value) {
- _impl_._has_bits_[0] |= 0x00000002u;
- _impl_.start_ = value;
-}
-inline void DescriptorProto_ExtensionRange::set_start(arc_i32 value) {
+inline void DescriptorProto_ExtensionRange::set_start(::arc_i32 value) {
_internal_set_start(value);
// @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.start)
}
+inline ::arc_i32 DescriptorProto_ExtensionRange::_internal_start() const {
+ return _impl_.start_;
+}
+inline void DescriptorProto_ExtensionRange::_internal_set_start(::arc_i32 value) {
+ _impl_._has_bits_[0] |= 0x00000002u;
+ _impl_.start_ = value;
+}
// optional int32 end = 2;
-inline bool DescriptorProto_ExtensionRange::_internal_has_end() const {
+inline bool DescriptorProto_ExtensionRange::has_end() const {
bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0;
return value;
}
-inline bool DescriptorProto_ExtensionRange::has_end() const {
- return _internal_has_end();
-}
inline void DescriptorProto_ExtensionRange::clear_end() {
_impl_.end_ = 0;
_impl_._has_bits_[0] &= ~0x00000004u;
}
-inline arc_i32 DescriptorProto_ExtensionRange::_internal_end() const {
- return _impl_.end_;
-}
-inline arc_i32 DescriptorProto_ExtensionRange::end() const {
+inline ::arc_i32 DescriptorProto_ExtensionRange::end() const {
// @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.end)
return _internal_end();
}
-inline void DescriptorProto_ExtensionRange::_internal_set_end(arc_i32 value) {
- _impl_._has_bits_[0] |= 0x00000004u;
- _impl_.end_ = value;
-}
-inline void DescriptorProto_ExtensionRange::set_end(arc_i32 value) {
+inline void DescriptorProto_ExtensionRange::set_end(::arc_i32 value) {
_internal_set_end(value);
// @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.end)
}
+inline ::arc_i32 DescriptorProto_ExtensionRange::_internal_end() const {
+ return _impl_.end_;
+}
+inline void DescriptorProto_ExtensionRange::_internal_set_end(::arc_i32 value) {
+ _impl_._has_bits_[0] |= 0x00000004u;
+ _impl_.end_ = value;
+}
// optional .google.protobuf.ExtensionRangeOptions options = 3;
-inline bool DescriptorProto_ExtensionRange::_internal_has_options() const {
+inline bool DescriptorProto_ExtensionRange::has_options() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
PROTOBUF_ASSUME(!value || _impl_.options_ != nullptr);
return value;
}
-inline bool DescriptorProto_ExtensionRange::has_options() const {
- return _internal_has_options();
-}
inline void DescriptorProto_ExtensionRange::clear_options() {
if (_impl_.options_ != nullptr) _impl_.options_->Clear();
_impl_._has_bits_[0] &= ~0x00000001u;
@@ -9447,73 +9305,64 @@ inline void DescriptorProto_ExtensionRange::set_allocated_options(::PROTOBUF_NAM
// DescriptorProto_ReservedRange
// optional int32 start = 1;
-inline bool DescriptorProto_ReservedRange::_internal_has_start() const {
+inline bool DescriptorProto_ReservedRange::has_start() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool DescriptorProto_ReservedRange::has_start() const {
- return _internal_has_start();
-}
inline void DescriptorProto_ReservedRange::clear_start() {
_impl_.start_ = 0;
_impl_._has_bits_[0] &= ~0x00000001u;
}
-inline arc_i32 DescriptorProto_ReservedRange::_internal_start() const {
- return _impl_.start_;
-}
-inline arc_i32 DescriptorProto_ReservedRange::start() const {
+inline ::arc_i32 DescriptorProto_ReservedRange::start() const {
// @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.start)
return _internal_start();
}
-inline void DescriptorProto_ReservedRange::_internal_set_start(arc_i32 value) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.start_ = value;
-}
-inline void DescriptorProto_ReservedRange::set_start(arc_i32 value) {
+inline void DescriptorProto_ReservedRange::set_start(::arc_i32 value) {
_internal_set_start(value);
// @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.start)
}
+inline ::arc_i32 DescriptorProto_ReservedRange::_internal_start() const {
+ return _impl_.start_;
+}
+inline void DescriptorProto_ReservedRange::_internal_set_start(::arc_i32 value) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.start_ = value;
+}
// optional int32 end = 2;
-inline bool DescriptorProto_ReservedRange::_internal_has_end() const {
+inline bool DescriptorProto_ReservedRange::has_end() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
return value;
}
-inline bool DescriptorProto_ReservedRange::has_end() const {
- return _internal_has_end();
-}
inline void DescriptorProto_ReservedRange::clear_end() {
_impl_.end_ = 0;
_impl_._has_bits_[0] &= ~0x00000002u;
}
-inline arc_i32 DescriptorProto_ReservedRange::_internal_end() const {
- return _impl_.end_;
-}
-inline arc_i32 DescriptorProto_ReservedRange::end() const {
+inline ::arc_i32 DescriptorProto_ReservedRange::end() const {
// @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.end)
return _internal_end();
}
-inline void DescriptorProto_ReservedRange::_internal_set_end(arc_i32 value) {
- _impl_._has_bits_[0] |= 0x00000002u;
- _impl_.end_ = value;
-}
-inline void DescriptorProto_ReservedRange::set_end(arc_i32 value) {
+inline void DescriptorProto_ReservedRange::set_end(::arc_i32 value) {
_internal_set_end(value);
// @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.end)
}
+inline ::arc_i32 DescriptorProto_ReservedRange::_internal_end() const {
+ return _impl_.end_;
+}
+inline void DescriptorProto_ReservedRange::_internal_set_end(::arc_i32 value) {
+ _impl_._has_bits_[0] |= 0x00000002u;
+ _impl_.end_ = value;
+}
// -------------------------------------------------------------------
// DescriptorProto
// optional string name = 1;
-inline bool DescriptorProto::_internal_has_name() const {
+inline bool DescriptorProto::has_name() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool DescriptorProto::has_name() const {
- return _internal_has_name();
-}
inline void DescriptorProto::clear_name() {
_impl_.name_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000001u;
@@ -9522,11 +9371,11 @@ inline const TProtoStringType& DescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.name)
return _internal_name();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void DescriptorProto::set_name(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void DescriptorProto::set_name(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.name_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.name)
}
inline TProtoStringType* DescriptorProto::mutable_name() {
@@ -9539,38 +9388,38 @@ inline const TProtoStringType& DescriptorProto::_internal_name() const {
}
inline void DescriptorProto::_internal_set_name(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000001u;
+
+
_impl_.name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* DescriptorProto::_internal_mutable_name() {
_impl_._has_bits_[0] |= 0x00000001u;
- return _impl_.name_.Mutable(GetArenaForAllocation());
+ return _impl_.name_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* DescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.DescriptorProto.name)
- if (!_internal_has_name()) {
+ if ((_impl_._has_bits_[0] & 0x00000001u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000001u;
- auto* p = _impl_.name_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void DescriptorProto::set_allocated_name(TProtoStringType* name) {
- if (name != nullptr) {
+ auto* released = _impl_.name_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void DescriptorProto::set_allocated_name(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000001u;
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
- _impl_.name_.SetAllocated(name, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.name_.IsDefault()) {
+ _impl_.name_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.DescriptorProto.name)
}
@@ -9815,14 +9664,11 @@ DescriptorProto::oneof_decl() const {
}
// optional .google.protobuf.MessageOptions options = 7;
-inline bool DescriptorProto::_internal_has_options() const {
+inline bool DescriptorProto::has_options() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
PROTOBUF_ASSUME(!value || _impl_.options_ != nullptr);
return value;
}
-inline bool DescriptorProto::has_options() const {
- return _internal_has_options();
-}
inline void DescriptorProto::clear_options() {
if (_impl_.options_ != nullptr) _impl_.options_->Clear();
_impl_._has_bits_[0] &= ~0x00000002u;
@@ -9979,18 +9825,20 @@ inline void DescriptorProto::set_reserved_name(int index, TProtoStringType&& val
// @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name)
}
inline void DescriptorProto::set_reserved_name(int index, const char* value) {
- GOOGLE_DCHECK(value != nullptr);
+ Y_ABSL_DCHECK(value != nullptr);
_impl_.reserved_name_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.DescriptorProto.reserved_name)
}
-inline void DescriptorProto::set_reserved_name(int index, const char* value, size_t size) {
- _impl_.reserved_name_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
+inline void DescriptorProto::set_reserved_name(int index, const char* value,
+ std::size_t size) {
+ _impl_.reserved_name_.Mutable(index)->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_set_pointer:google.protobuf.DescriptorProto.reserved_name)
}
-inline TProtoStringType* DescriptorProto::_internal_add_reserved_name() {
- return _impl_.reserved_name_.Add();
+inline void DescriptorProto::set_reserved_name(int index, y_absl::string_view value) {
+ _impl_.reserved_name_.Mutable(index)->assign(value.data(), value.size());
+ // @@protoc_insertion_point(field_set_string_piece:google.protobuf.DescriptorProto.reserved_name)
}
+inline TProtoStringType* DescriptorProto::_internal_add_reserved_name() { return _impl_.reserved_name_.Add(); }
inline void DescriptorProto::add_reserved_name(const TProtoStringType& value) {
_impl_.reserved_name_.Add()->assign(value);
// @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name)
@@ -10000,21 +9848,24 @@ inline void DescriptorProto::add_reserved_name(TProtoStringType&& value) {
// @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name)
}
inline void DescriptorProto::add_reserved_name(const char* value) {
- GOOGLE_DCHECK(value != nullptr);
+ Y_ABSL_DCHECK(value != nullptr);
_impl_.reserved_name_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.DescriptorProto.reserved_name)
}
-inline void DescriptorProto::add_reserved_name(const char* value, size_t size) {
+inline void DescriptorProto::add_reserved_name(const char* value, std::size_t size) {
_impl_.reserved_name_.Add()->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_add_pointer:google.protobuf.DescriptorProto.reserved_name)
}
+inline void DescriptorProto::add_reserved_name(y_absl::string_view value) {
+ _impl_.reserved_name_.Add()->assign(value.data(), value.size());
+ // @@protoc_insertion_point(field_add_string_piece:google.protobuf.DescriptorProto.reserved_name)
+}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>&
DescriptorProto::reserved_name() const {
// @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.reserved_name)
return _impl_.reserved_name_;
}
-inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>*
-DescriptorProto::mutable_reserved_name() {
+inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>* DescriptorProto::mutable_reserved_name() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.reserved_name)
return &_impl_.reserved_name_;
}
@@ -10068,13 +9919,10 @@ ExtensionRangeOptions::uninterpreted_option() const {
// FieldDescriptorProto
// optional string name = 1;
-inline bool FieldDescriptorProto::_internal_has_name() const {
+inline bool FieldDescriptorProto::has_name() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool FieldDescriptorProto::has_name() const {
- return _internal_has_name();
-}
inline void FieldDescriptorProto::clear_name() {
_impl_.name_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000001u;
@@ -10083,11 +9931,11 @@ inline const TProtoStringType& FieldDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.name)
return _internal_name();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void FieldDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void FieldDescriptorProto::set_name(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.name_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.name)
}
inline TProtoStringType* FieldDescriptorProto::mutable_name() {
@@ -10100,135 +9948,123 @@ inline const TProtoStringType& FieldDescriptorProto::_internal_name() const {
}
inline void FieldDescriptorProto::_internal_set_name(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000001u;
+
+
_impl_.name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FieldDescriptorProto::_internal_mutable_name() {
_impl_._has_bits_[0] |= 0x00000001u;
- return _impl_.name_.Mutable(GetArenaForAllocation());
+ return _impl_.name_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* FieldDescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.name)
- if (!_internal_has_name()) {
+ if ((_impl_._has_bits_[0] & 0x00000001u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000001u;
- auto* p = _impl_.name_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void FieldDescriptorProto::set_allocated_name(TProtoStringType* name) {
- if (name != nullptr) {
+ auto* released = _impl_.name_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void FieldDescriptorProto::set_allocated_name(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000001u;
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
- _impl_.name_.SetAllocated(name, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.name_.IsDefault()) {
+ _impl_.name_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.name)
}
// optional int32 number = 3;
-inline bool FieldDescriptorProto::_internal_has_number() const {
+inline bool FieldDescriptorProto::has_number() const {
bool value = (_impl_._has_bits_[0] & 0x00000040u) != 0;
return value;
}
-inline bool FieldDescriptorProto::has_number() const {
- return _internal_has_number();
-}
inline void FieldDescriptorProto::clear_number() {
_impl_.number_ = 0;
_impl_._has_bits_[0] &= ~0x00000040u;
}
-inline arc_i32 FieldDescriptorProto::_internal_number() const {
- return _impl_.number_;
-}
-inline arc_i32 FieldDescriptorProto::number() const {
+inline ::arc_i32 FieldDescriptorProto::number() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.number)
return _internal_number();
}
-inline void FieldDescriptorProto::_internal_set_number(arc_i32 value) {
- _impl_._has_bits_[0] |= 0x00000040u;
- _impl_.number_ = value;
-}
-inline void FieldDescriptorProto::set_number(arc_i32 value) {
+inline void FieldDescriptorProto::set_number(::arc_i32 value) {
_internal_set_number(value);
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.number)
}
+inline ::arc_i32 FieldDescriptorProto::_internal_number() const {
+ return _impl_.number_;
+}
+inline void FieldDescriptorProto::_internal_set_number(::arc_i32 value) {
+ _impl_._has_bits_[0] |= 0x00000040u;
+ _impl_.number_ = value;
+}
// optional .google.protobuf.FieldDescriptorProto.Label label = 4;
-inline bool FieldDescriptorProto::_internal_has_label() const {
+inline bool FieldDescriptorProto::has_label() const {
bool value = (_impl_._has_bits_[0] & 0x00000200u) != 0;
return value;
}
-inline bool FieldDescriptorProto::has_label() const {
- return _internal_has_label();
-}
inline void FieldDescriptorProto::clear_label() {
_impl_.label_ = 1;
_impl_._has_bits_[0] &= ~0x00000200u;
}
-inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label FieldDescriptorProto::_internal_label() const {
- return static_cast< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label >(_impl_.label_);
-}
inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label FieldDescriptorProto::label() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.label)
return _internal_label();
}
+inline void FieldDescriptorProto::set_label(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label value) {
+ _internal_set_label(value);
+ // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.label)
+}
+inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label FieldDescriptorProto::_internal_label() const {
+ return static_cast<::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label>(_impl_.label_);
+}
inline void FieldDescriptorProto::_internal_set_label(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label value) {
assert(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label_IsValid(value));
_impl_._has_bits_[0] |= 0x00000200u;
_impl_.label_ = value;
}
-inline void FieldDescriptorProto::set_label(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label value) {
- _internal_set_label(value);
- // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.label)
-}
// optional .google.protobuf.FieldDescriptorProto.Type type = 5;
-inline bool FieldDescriptorProto::_internal_has_type() const {
+inline bool FieldDescriptorProto::has_type() const {
bool value = (_impl_._has_bits_[0] & 0x00000400u) != 0;
return value;
}
-inline bool FieldDescriptorProto::has_type() const {
- return _internal_has_type();
-}
inline void FieldDescriptorProto::clear_type() {
_impl_.type_ = 1;
_impl_._has_bits_[0] &= ~0x00000400u;
}
-inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type FieldDescriptorProto::_internal_type() const {
- return static_cast< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type >(_impl_.type_);
-}
inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type FieldDescriptorProto::type() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.type)
return _internal_type();
}
+inline void FieldDescriptorProto::set_type(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type value) {
+ _internal_set_type(value);
+ // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type)
+}
+inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type FieldDescriptorProto::_internal_type() const {
+ return static_cast<::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type>(_impl_.type_);
+}
inline void FieldDescriptorProto::_internal_set_type(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type value) {
assert(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type_IsValid(value));
_impl_._has_bits_[0] |= 0x00000400u;
_impl_.type_ = value;
}
-inline void FieldDescriptorProto::set_type(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type value) {
- _internal_set_type(value);
- // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type)
-}
// optional string type_name = 6;
-inline bool FieldDescriptorProto::_internal_has_type_name() const {
+inline bool FieldDescriptorProto::has_type_name() const {
bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0;
return value;
}
-inline bool FieldDescriptorProto::has_type_name() const {
- return _internal_has_type_name();
-}
inline void FieldDescriptorProto::clear_type_name() {
_impl_.type_name_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000004u;
@@ -10237,11 +10073,11 @@ inline const TProtoStringType& FieldDescriptorProto::type_name() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.type_name)
return _internal_type_name();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void FieldDescriptorProto::set_type_name(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000004u;
- _impl_.type_name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void FieldDescriptorProto::set_type_name(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000004u;
+ _impl_.type_name_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type_name)
}
inline TProtoStringType* FieldDescriptorProto::mutable_type_name() {
@@ -10254,49 +10090,46 @@ inline const TProtoStringType& FieldDescriptorProto::_internal_type_name() const
}
inline void FieldDescriptorProto::_internal_set_type_name(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000004u;
+
+
_impl_.type_name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FieldDescriptorProto::_internal_mutable_type_name() {
_impl_._has_bits_[0] |= 0x00000004u;
- return _impl_.type_name_.Mutable(GetArenaForAllocation());
+ return _impl_.type_name_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* FieldDescriptorProto::release_type_name() {
// @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.type_name)
- if (!_internal_has_type_name()) {
+ if ((_impl_._has_bits_[0] & 0x00000004u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000004u;
- auto* p = _impl_.type_name_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.type_name_.IsDefault()) {
- _impl_.type_name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void FieldDescriptorProto::set_allocated_type_name(TProtoStringType* type_name) {
- if (type_name != nullptr) {
+ auto* released = _impl_.type_name_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.type_name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void FieldDescriptorProto::set_allocated_type_name(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000004u;
} else {
_impl_._has_bits_[0] &= ~0x00000004u;
}
- _impl_.type_name_.SetAllocated(type_name, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.type_name_.IsDefault()) {
- _impl_.type_name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.type_name_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.type_name_.IsDefault()) {
+ _impl_.type_name_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.type_name)
}
// optional string extendee = 2;
-inline bool FieldDescriptorProto::_internal_has_extendee() const {
+inline bool FieldDescriptorProto::has_extendee() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
return value;
}
-inline bool FieldDescriptorProto::has_extendee() const {
- return _internal_has_extendee();
-}
inline void FieldDescriptorProto::clear_extendee() {
_impl_.extendee_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000002u;
@@ -10305,11 +10138,11 @@ inline const TProtoStringType& FieldDescriptorProto::extendee() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.extendee)
return _internal_extendee();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void FieldDescriptorProto::set_extendee(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000002u;
- _impl_.extendee_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void FieldDescriptorProto::set_extendee(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000002u;
+ _impl_.extendee_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.extendee)
}
inline TProtoStringType* FieldDescriptorProto::mutable_extendee() {
@@ -10322,49 +10155,46 @@ inline const TProtoStringType& FieldDescriptorProto::_internal_extendee() const
}
inline void FieldDescriptorProto::_internal_set_extendee(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000002u;
+
+
_impl_.extendee_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FieldDescriptorProto::_internal_mutable_extendee() {
_impl_._has_bits_[0] |= 0x00000002u;
- return _impl_.extendee_.Mutable(GetArenaForAllocation());
+ return _impl_.extendee_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* FieldDescriptorProto::release_extendee() {
// @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.extendee)
- if (!_internal_has_extendee()) {
+ if ((_impl_._has_bits_[0] & 0x00000002u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000002u;
- auto* p = _impl_.extendee_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.extendee_.IsDefault()) {
- _impl_.extendee_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void FieldDescriptorProto::set_allocated_extendee(TProtoStringType* extendee) {
- if (extendee != nullptr) {
+ auto* released = _impl_.extendee_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.extendee_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void FieldDescriptorProto::set_allocated_extendee(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000002u;
} else {
_impl_._has_bits_[0] &= ~0x00000002u;
}
- _impl_.extendee_.SetAllocated(extendee, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.extendee_.IsDefault()) {
- _impl_.extendee_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.extendee_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.extendee_.IsDefault()) {
+ _impl_.extendee_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.extendee)
}
// optional string default_value = 7;
-inline bool FieldDescriptorProto::_internal_has_default_value() const {
+inline bool FieldDescriptorProto::has_default_value() const {
bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0;
return value;
}
-inline bool FieldDescriptorProto::has_default_value() const {
- return _internal_has_default_value();
-}
inline void FieldDescriptorProto::clear_default_value() {
_impl_.default_value_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000008u;
@@ -10373,11 +10203,11 @@ inline const TProtoStringType& FieldDescriptorProto::default_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.default_value)
return _internal_default_value();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void FieldDescriptorProto::set_default_value(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000008u;
- _impl_.default_value_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void FieldDescriptorProto::set_default_value(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000008u;
+ _impl_.default_value_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.default_value)
}
inline TProtoStringType* FieldDescriptorProto::mutable_default_value() {
@@ -10390,77 +10220,71 @@ inline const TProtoStringType& FieldDescriptorProto::_internal_default_value() c
}
inline void FieldDescriptorProto::_internal_set_default_value(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000008u;
+
+
_impl_.default_value_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FieldDescriptorProto::_internal_mutable_default_value() {
_impl_._has_bits_[0] |= 0x00000008u;
- return _impl_.default_value_.Mutable(GetArenaForAllocation());
+ return _impl_.default_value_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* FieldDescriptorProto::release_default_value() {
// @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.default_value)
- if (!_internal_has_default_value()) {
+ if ((_impl_._has_bits_[0] & 0x00000008u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000008u;
- auto* p = _impl_.default_value_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.default_value_.IsDefault()) {
- _impl_.default_value_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void FieldDescriptorProto::set_allocated_default_value(TProtoStringType* default_value) {
- if (default_value != nullptr) {
+ auto* released = _impl_.default_value_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.default_value_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void FieldDescriptorProto::set_allocated_default_value(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000008u;
} else {
_impl_._has_bits_[0] &= ~0x00000008u;
}
- _impl_.default_value_.SetAllocated(default_value, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.default_value_.IsDefault()) {
- _impl_.default_value_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.default_value_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.default_value_.IsDefault()) {
+ _impl_.default_value_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.default_value)
}
// optional int32 oneof_index = 9;
-inline bool FieldDescriptorProto::_internal_has_oneof_index() const {
+inline bool FieldDescriptorProto::has_oneof_index() const {
bool value = (_impl_._has_bits_[0] & 0x00000080u) != 0;
return value;
}
-inline bool FieldDescriptorProto::has_oneof_index() const {
- return _internal_has_oneof_index();
-}
inline void FieldDescriptorProto::clear_oneof_index() {
_impl_.oneof_index_ = 0;
_impl_._has_bits_[0] &= ~0x00000080u;
}
-inline arc_i32 FieldDescriptorProto::_internal_oneof_index() const {
- return _impl_.oneof_index_;
-}
-inline arc_i32 FieldDescriptorProto::oneof_index() const {
+inline ::arc_i32 FieldDescriptorProto::oneof_index() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.oneof_index)
return _internal_oneof_index();
}
-inline void FieldDescriptorProto::_internal_set_oneof_index(arc_i32 value) {
- _impl_._has_bits_[0] |= 0x00000080u;
- _impl_.oneof_index_ = value;
-}
-inline void FieldDescriptorProto::set_oneof_index(arc_i32 value) {
+inline void FieldDescriptorProto::set_oneof_index(::arc_i32 value) {
_internal_set_oneof_index(value);
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.oneof_index)
}
+inline ::arc_i32 FieldDescriptorProto::_internal_oneof_index() const {
+ return _impl_.oneof_index_;
+}
+inline void FieldDescriptorProto::_internal_set_oneof_index(::arc_i32 value) {
+ _impl_._has_bits_[0] |= 0x00000080u;
+ _impl_.oneof_index_ = value;
+}
// optional string json_name = 10;
-inline bool FieldDescriptorProto::_internal_has_json_name() const {
+inline bool FieldDescriptorProto::has_json_name() const {
bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0;
return value;
}
-inline bool FieldDescriptorProto::has_json_name() const {
- return _internal_has_json_name();
-}
inline void FieldDescriptorProto::clear_json_name() {
_impl_.json_name_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000010u;
@@ -10469,11 +10293,11 @@ inline const TProtoStringType& FieldDescriptorProto::json_name() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.json_name)
return _internal_json_name();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void FieldDescriptorProto::set_json_name(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000010u;
- _impl_.json_name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void FieldDescriptorProto::set_json_name(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000010u;
+ _impl_.json_name_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.json_name)
}
inline TProtoStringType* FieldDescriptorProto::mutable_json_name() {
@@ -10486,50 +10310,47 @@ inline const TProtoStringType& FieldDescriptorProto::_internal_json_name() const
}
inline void FieldDescriptorProto::_internal_set_json_name(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000010u;
+
+
_impl_.json_name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FieldDescriptorProto::_internal_mutable_json_name() {
_impl_._has_bits_[0] |= 0x00000010u;
- return _impl_.json_name_.Mutable(GetArenaForAllocation());
+ return _impl_.json_name_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* FieldDescriptorProto::release_json_name() {
// @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.json_name)
- if (!_internal_has_json_name()) {
+ if ((_impl_._has_bits_[0] & 0x00000010u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000010u;
- auto* p = _impl_.json_name_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.json_name_.IsDefault()) {
- _impl_.json_name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void FieldDescriptorProto::set_allocated_json_name(TProtoStringType* json_name) {
- if (json_name != nullptr) {
+ auto* released = _impl_.json_name_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.json_name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void FieldDescriptorProto::set_allocated_json_name(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000010u;
} else {
_impl_._has_bits_[0] &= ~0x00000010u;
}
- _impl_.json_name_.SetAllocated(json_name, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.json_name_.IsDefault()) {
- _impl_.json_name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.json_name_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.json_name_.IsDefault()) {
+ _impl_.json_name_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.json_name)
}
// optional .google.protobuf.FieldOptions options = 8;
-inline bool FieldDescriptorProto::_internal_has_options() const {
+inline bool FieldDescriptorProto::has_options() const {
bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0;
PROTOBUF_ASSUME(!value || _impl_.options_ != nullptr);
return value;
}
-inline bool FieldDescriptorProto::has_options() const {
- return _internal_has_options();
-}
inline void FieldDescriptorProto::clear_options() {
if (_impl_.options_ != nullptr) _impl_.options_->Clear();
_impl_._has_bits_[0] &= ~0x00000020u;
@@ -10612,45 +10433,39 @@ inline void FieldDescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE_ID:
}
// optional bool proto3_optional = 17;
-inline bool FieldDescriptorProto::_internal_has_proto3_optional() const {
+inline bool FieldDescriptorProto::has_proto3_optional() const {
bool value = (_impl_._has_bits_[0] & 0x00000100u) != 0;
return value;
}
-inline bool FieldDescriptorProto::has_proto3_optional() const {
- return _internal_has_proto3_optional();
-}
inline void FieldDescriptorProto::clear_proto3_optional() {
_impl_.proto3_optional_ = false;
_impl_._has_bits_[0] &= ~0x00000100u;
}
-inline bool FieldDescriptorProto::_internal_proto3_optional() const {
- return _impl_.proto3_optional_;
-}
inline bool FieldDescriptorProto::proto3_optional() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.proto3_optional)
return _internal_proto3_optional();
}
-inline void FieldDescriptorProto::_internal_set_proto3_optional(bool value) {
- _impl_._has_bits_[0] |= 0x00000100u;
- _impl_.proto3_optional_ = value;
-}
inline void FieldDescriptorProto::set_proto3_optional(bool value) {
_internal_set_proto3_optional(value);
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.proto3_optional)
}
+inline bool FieldDescriptorProto::_internal_proto3_optional() const {
+ return _impl_.proto3_optional_;
+}
+inline void FieldDescriptorProto::_internal_set_proto3_optional(bool value) {
+ _impl_._has_bits_[0] |= 0x00000100u;
+ _impl_.proto3_optional_ = value;
+}
// -------------------------------------------------------------------
// OneofDescriptorProto
// optional string name = 1;
-inline bool OneofDescriptorProto::_internal_has_name() const {
+inline bool OneofDescriptorProto::has_name() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool OneofDescriptorProto::has_name() const {
- return _internal_has_name();
-}
inline void OneofDescriptorProto::clear_name() {
_impl_.name_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000001u;
@@ -10659,11 +10474,11 @@ inline const TProtoStringType& OneofDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.name)
return _internal_name();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void OneofDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void OneofDescriptorProto::set_name(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.name_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.OneofDescriptorProto.name)
}
inline TProtoStringType* OneofDescriptorProto::mutable_name() {
@@ -10676,50 +10491,47 @@ inline const TProtoStringType& OneofDescriptorProto::_internal_name() const {
}
inline void OneofDescriptorProto::_internal_set_name(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000001u;
+
+
_impl_.name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* OneofDescriptorProto::_internal_mutable_name() {
_impl_._has_bits_[0] |= 0x00000001u;
- return _impl_.name_.Mutable(GetArenaForAllocation());
+ return _impl_.name_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* OneofDescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.OneofDescriptorProto.name)
- if (!_internal_has_name()) {
+ if ((_impl_._has_bits_[0] & 0x00000001u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000001u;
- auto* p = _impl_.name_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void OneofDescriptorProto::set_allocated_name(TProtoStringType* name) {
- if (name != nullptr) {
+ auto* released = _impl_.name_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void OneofDescriptorProto::set_allocated_name(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000001u;
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
- _impl_.name_.SetAllocated(name, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.name_.IsDefault()) {
+ _impl_.name_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.OneofDescriptorProto.name)
}
// optional .google.protobuf.OneofOptions options = 2;
-inline bool OneofDescriptorProto::_internal_has_options() const {
+inline bool OneofDescriptorProto::has_options() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
PROTOBUF_ASSUME(!value || _impl_.options_ != nullptr);
return value;
}
-inline bool OneofDescriptorProto::has_options() const {
- return _internal_has_options();
-}
inline void OneofDescriptorProto::clear_options() {
if (_impl_.options_ != nullptr) _impl_.options_->Clear();
_impl_._has_bits_[0] &= ~0x00000002u;
@@ -10806,73 +10618,64 @@ inline void OneofDescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE_ID:
// EnumDescriptorProto_EnumReservedRange
// optional int32 start = 1;
-inline bool EnumDescriptorProto_EnumReservedRange::_internal_has_start() const {
+inline bool EnumDescriptorProto_EnumReservedRange::has_start() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool EnumDescriptorProto_EnumReservedRange::has_start() const {
- return _internal_has_start();
-}
inline void EnumDescriptorProto_EnumReservedRange::clear_start() {
_impl_.start_ = 0;
_impl_._has_bits_[0] &= ~0x00000001u;
}
-inline arc_i32 EnumDescriptorProto_EnumReservedRange::_internal_start() const {
- return _impl_.start_;
-}
-inline arc_i32 EnumDescriptorProto_EnumReservedRange::start() const {
+inline ::arc_i32 EnumDescriptorProto_EnumReservedRange::start() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.EnumReservedRange.start)
return _internal_start();
}
-inline void EnumDescriptorProto_EnumReservedRange::_internal_set_start(arc_i32 value) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.start_ = value;
-}
-inline void EnumDescriptorProto_EnumReservedRange::set_start(arc_i32 value) {
+inline void EnumDescriptorProto_EnumReservedRange::set_start(::arc_i32 value) {
_internal_set_start(value);
// @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.EnumReservedRange.start)
}
+inline ::arc_i32 EnumDescriptorProto_EnumReservedRange::_internal_start() const {
+ return _impl_.start_;
+}
+inline void EnumDescriptorProto_EnumReservedRange::_internal_set_start(::arc_i32 value) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.start_ = value;
+}
// optional int32 end = 2;
-inline bool EnumDescriptorProto_EnumReservedRange::_internal_has_end() const {
+inline bool EnumDescriptorProto_EnumReservedRange::has_end() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
return value;
}
-inline bool EnumDescriptorProto_EnumReservedRange::has_end() const {
- return _internal_has_end();
-}
inline void EnumDescriptorProto_EnumReservedRange::clear_end() {
_impl_.end_ = 0;
_impl_._has_bits_[0] &= ~0x00000002u;
}
-inline arc_i32 EnumDescriptorProto_EnumReservedRange::_internal_end() const {
- return _impl_.end_;
-}
-inline arc_i32 EnumDescriptorProto_EnumReservedRange::end() const {
+inline ::arc_i32 EnumDescriptorProto_EnumReservedRange::end() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.EnumReservedRange.end)
return _internal_end();
}
-inline void EnumDescriptorProto_EnumReservedRange::_internal_set_end(arc_i32 value) {
- _impl_._has_bits_[0] |= 0x00000002u;
- _impl_.end_ = value;
-}
-inline void EnumDescriptorProto_EnumReservedRange::set_end(arc_i32 value) {
+inline void EnumDescriptorProto_EnumReservedRange::set_end(::arc_i32 value) {
_internal_set_end(value);
// @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.EnumReservedRange.end)
}
+inline ::arc_i32 EnumDescriptorProto_EnumReservedRange::_internal_end() const {
+ return _impl_.end_;
+}
+inline void EnumDescriptorProto_EnumReservedRange::_internal_set_end(::arc_i32 value) {
+ _impl_._has_bits_[0] |= 0x00000002u;
+ _impl_.end_ = value;
+}
// -------------------------------------------------------------------
// EnumDescriptorProto
// optional string name = 1;
-inline bool EnumDescriptorProto::_internal_has_name() const {
+inline bool EnumDescriptorProto::has_name() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool EnumDescriptorProto::has_name() const {
- return _internal_has_name();
-}
inline void EnumDescriptorProto::clear_name() {
_impl_.name_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000001u;
@@ -10881,11 +10684,11 @@ inline const TProtoStringType& EnumDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.name)
return _internal_name();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void EnumDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void EnumDescriptorProto::set_name(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.name_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.name)
}
inline TProtoStringType* EnumDescriptorProto::mutable_name() {
@@ -10898,38 +10701,38 @@ inline const TProtoStringType& EnumDescriptorProto::_internal_name() const {
}
inline void EnumDescriptorProto::_internal_set_name(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000001u;
+
+
_impl_.name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* EnumDescriptorProto::_internal_mutable_name() {
_impl_._has_bits_[0] |= 0x00000001u;
- return _impl_.name_.Mutable(GetArenaForAllocation());
+ return _impl_.name_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* EnumDescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.EnumDescriptorProto.name)
- if (!_internal_has_name()) {
+ if ((_impl_._has_bits_[0] & 0x00000001u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000001u;
- auto* p = _impl_.name_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void EnumDescriptorProto::set_allocated_name(TProtoStringType* name) {
- if (name != nullptr) {
+ auto* released = _impl_.name_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void EnumDescriptorProto::set_allocated_name(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000001u;
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
- _impl_.name_.SetAllocated(name, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.name_.IsDefault()) {
+ _impl_.name_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumDescriptorProto.name)
}
@@ -10974,14 +10777,11 @@ EnumDescriptorProto::value() const {
}
// optional .google.protobuf.EnumOptions options = 3;
-inline bool EnumDescriptorProto::_internal_has_options() const {
+inline bool EnumDescriptorProto::has_options() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
PROTOBUF_ASSUME(!value || _impl_.options_ != nullptr);
return value;
}
-inline bool EnumDescriptorProto::has_options() const {
- return _internal_has_options();
-}
inline void EnumDescriptorProto::clear_options() {
if (_impl_.options_ != nullptr) _impl_.options_->Clear();
_impl_._has_bits_[0] &= ~0x00000002u;
@@ -11138,18 +10938,20 @@ inline void EnumDescriptorProto::set_reserved_name(int index, TProtoStringType&&
// @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.reserved_name)
}
inline void EnumDescriptorProto::set_reserved_name(int index, const char* value) {
- GOOGLE_DCHECK(value != nullptr);
+ Y_ABSL_DCHECK(value != nullptr);
_impl_.reserved_name_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.EnumDescriptorProto.reserved_name)
}
-inline void EnumDescriptorProto::set_reserved_name(int index, const char* value, size_t size) {
- _impl_.reserved_name_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
+inline void EnumDescriptorProto::set_reserved_name(int index, const char* value,
+ std::size_t size) {
+ _impl_.reserved_name_.Mutable(index)->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumDescriptorProto.reserved_name)
}
-inline TProtoStringType* EnumDescriptorProto::_internal_add_reserved_name() {
- return _impl_.reserved_name_.Add();
+inline void EnumDescriptorProto::set_reserved_name(int index, y_absl::string_view value) {
+ _impl_.reserved_name_.Mutable(index)->assign(value.data(), value.size());
+ // @@protoc_insertion_point(field_set_string_piece:google.protobuf.EnumDescriptorProto.reserved_name)
}
+inline TProtoStringType* EnumDescriptorProto::_internal_add_reserved_name() { return _impl_.reserved_name_.Add(); }
inline void EnumDescriptorProto::add_reserved_name(const TProtoStringType& value) {
_impl_.reserved_name_.Add()->assign(value);
// @@protoc_insertion_point(field_add:google.protobuf.EnumDescriptorProto.reserved_name)
@@ -11159,21 +10961,24 @@ inline void EnumDescriptorProto::add_reserved_name(TProtoStringType&& value) {
// @@protoc_insertion_point(field_add:google.protobuf.EnumDescriptorProto.reserved_name)
}
inline void EnumDescriptorProto::add_reserved_name(const char* value) {
- GOOGLE_DCHECK(value != nullptr);
+ Y_ABSL_DCHECK(value != nullptr);
_impl_.reserved_name_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.EnumDescriptorProto.reserved_name)
}
-inline void EnumDescriptorProto::add_reserved_name(const char* value, size_t size) {
+inline void EnumDescriptorProto::add_reserved_name(const char* value, std::size_t size) {
_impl_.reserved_name_.Add()->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_add_pointer:google.protobuf.EnumDescriptorProto.reserved_name)
}
+inline void EnumDescriptorProto::add_reserved_name(y_absl::string_view value) {
+ _impl_.reserved_name_.Add()->assign(value.data(), value.size());
+ // @@protoc_insertion_point(field_add_string_piece:google.protobuf.EnumDescriptorProto.reserved_name)
+}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>&
EnumDescriptorProto::reserved_name() const {
// @@protoc_insertion_point(field_list:google.protobuf.EnumDescriptorProto.reserved_name)
return _impl_.reserved_name_;
}
-inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>*
-EnumDescriptorProto::mutable_reserved_name() {
+inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>* EnumDescriptorProto::mutable_reserved_name() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumDescriptorProto.reserved_name)
return &_impl_.reserved_name_;
}
@@ -11183,13 +10988,10 @@ EnumDescriptorProto::mutable_reserved_name() {
// EnumValueDescriptorProto
// optional string name = 1;
-inline bool EnumValueDescriptorProto::_internal_has_name() const {
+inline bool EnumValueDescriptorProto::has_name() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool EnumValueDescriptorProto::has_name() const {
- return _internal_has_name();
-}
inline void EnumValueDescriptorProto::clear_name() {
_impl_.name_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000001u;
@@ -11198,11 +11000,11 @@ inline const TProtoStringType& EnumValueDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.name)
return _internal_name();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void EnumValueDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void EnumValueDescriptorProto::set_name(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.name_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.name)
}
inline TProtoStringType* EnumValueDescriptorProto::mutable_name() {
@@ -11215,78 +11017,72 @@ inline const TProtoStringType& EnumValueDescriptorProto::_internal_name() const
}
inline void EnumValueDescriptorProto::_internal_set_name(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000001u;
+
+
_impl_.name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* EnumValueDescriptorProto::_internal_mutable_name() {
_impl_._has_bits_[0] |= 0x00000001u;
- return _impl_.name_.Mutable(GetArenaForAllocation());
+ return _impl_.name_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* EnumValueDescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.EnumValueDescriptorProto.name)
- if (!_internal_has_name()) {
+ if ((_impl_._has_bits_[0] & 0x00000001u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000001u;
- auto* p = _impl_.name_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void EnumValueDescriptorProto::set_allocated_name(TProtoStringType* name) {
- if (name != nullptr) {
+ auto* released = _impl_.name_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void EnumValueDescriptorProto::set_allocated_name(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000001u;
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
- _impl_.name_.SetAllocated(name, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.name_.IsDefault()) {
+ _impl_.name_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValueDescriptorProto.name)
}
// optional int32 number = 2;
-inline bool EnumValueDescriptorProto::_internal_has_number() const {
+inline bool EnumValueDescriptorProto::has_number() const {
bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0;
return value;
}
-inline bool EnumValueDescriptorProto::has_number() const {
- return _internal_has_number();
-}
inline void EnumValueDescriptorProto::clear_number() {
_impl_.number_ = 0;
_impl_._has_bits_[0] &= ~0x00000004u;
}
-inline arc_i32 EnumValueDescriptorProto::_internal_number() const {
- return _impl_.number_;
-}
-inline arc_i32 EnumValueDescriptorProto::number() const {
+inline ::arc_i32 EnumValueDescriptorProto::number() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.number)
return _internal_number();
}
-inline void EnumValueDescriptorProto::_internal_set_number(arc_i32 value) {
- _impl_._has_bits_[0] |= 0x00000004u;
- _impl_.number_ = value;
-}
-inline void EnumValueDescriptorProto::set_number(arc_i32 value) {
+inline void EnumValueDescriptorProto::set_number(::arc_i32 value) {
_internal_set_number(value);
// @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.number)
}
+inline ::arc_i32 EnumValueDescriptorProto::_internal_number() const {
+ return _impl_.number_;
+}
+inline void EnumValueDescriptorProto::_internal_set_number(::arc_i32 value) {
+ _impl_._has_bits_[0] |= 0x00000004u;
+ _impl_.number_ = value;
+}
// optional .google.protobuf.EnumValueOptions options = 3;
-inline bool EnumValueDescriptorProto::_internal_has_options() const {
+inline bool EnumValueDescriptorProto::has_options() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
PROTOBUF_ASSUME(!value || _impl_.options_ != nullptr);
return value;
}
-inline bool EnumValueDescriptorProto::has_options() const {
- return _internal_has_options();
-}
inline void EnumValueDescriptorProto::clear_options() {
if (_impl_.options_ != nullptr) _impl_.options_->Clear();
_impl_._has_bits_[0] &= ~0x00000002u;
@@ -11373,13 +11169,10 @@ inline void EnumValueDescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE
// ServiceDescriptorProto
// optional string name = 1;
-inline bool ServiceDescriptorProto::_internal_has_name() const {
+inline bool ServiceDescriptorProto::has_name() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool ServiceDescriptorProto::has_name() const {
- return _internal_has_name();
-}
inline void ServiceDescriptorProto::clear_name() {
_impl_.name_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000001u;
@@ -11388,11 +11181,11 @@ inline const TProtoStringType& ServiceDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.name)
return _internal_name();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void ServiceDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void ServiceDescriptorProto::set_name(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.name_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.ServiceDescriptorProto.name)
}
inline TProtoStringType* ServiceDescriptorProto::mutable_name() {
@@ -11405,38 +11198,38 @@ inline const TProtoStringType& ServiceDescriptorProto::_internal_name() const {
}
inline void ServiceDescriptorProto::_internal_set_name(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000001u;
+
+
_impl_.name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* ServiceDescriptorProto::_internal_mutable_name() {
_impl_._has_bits_[0] |= 0x00000001u;
- return _impl_.name_.Mutable(GetArenaForAllocation());
+ return _impl_.name_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* ServiceDescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.ServiceDescriptorProto.name)
- if (!_internal_has_name()) {
+ if ((_impl_._has_bits_[0] & 0x00000001u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000001u;
- auto* p = _impl_.name_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void ServiceDescriptorProto::set_allocated_name(TProtoStringType* name) {
- if (name != nullptr) {
+ auto* released = _impl_.name_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void ServiceDescriptorProto::set_allocated_name(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000001u;
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
- _impl_.name_.SetAllocated(name, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.name_.IsDefault()) {
+ _impl_.name_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.ServiceDescriptorProto.name)
}
@@ -11481,14 +11274,11 @@ ServiceDescriptorProto::method() const {
}
// optional .google.protobuf.ServiceOptions options = 3;
-inline bool ServiceDescriptorProto::_internal_has_options() const {
+inline bool ServiceDescriptorProto::has_options() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
PROTOBUF_ASSUME(!value || _impl_.options_ != nullptr);
return value;
}
-inline bool ServiceDescriptorProto::has_options() const {
- return _internal_has_options();
-}
inline void ServiceDescriptorProto::clear_options() {
if (_impl_.options_ != nullptr) _impl_.options_->Clear();
_impl_._has_bits_[0] &= ~0x00000002u;
@@ -11575,13 +11365,10 @@ inline void ServiceDescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE_I
// MethodDescriptorProto
// optional string name = 1;
-inline bool MethodDescriptorProto::_internal_has_name() const {
+inline bool MethodDescriptorProto::has_name() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool MethodDescriptorProto::has_name() const {
- return _internal_has_name();
-}
inline void MethodDescriptorProto::clear_name() {
_impl_.name_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000001u;
@@ -11590,11 +11377,11 @@ inline const TProtoStringType& MethodDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.name)
return _internal_name();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void MethodDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void MethodDescriptorProto::set_name(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.name_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.name)
}
inline TProtoStringType* MethodDescriptorProto::mutable_name() {
@@ -11607,49 +11394,46 @@ inline const TProtoStringType& MethodDescriptorProto::_internal_name() const {
}
inline void MethodDescriptorProto::_internal_set_name(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000001u;
+
+
_impl_.name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* MethodDescriptorProto::_internal_mutable_name() {
_impl_._has_bits_[0] |= 0x00000001u;
- return _impl_.name_.Mutable(GetArenaForAllocation());
+ return _impl_.name_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* MethodDescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.name)
- if (!_internal_has_name()) {
+ if ((_impl_._has_bits_[0] & 0x00000001u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000001u;
- auto* p = _impl_.name_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void MethodDescriptorProto::set_allocated_name(TProtoStringType* name) {
- if (name != nullptr) {
+ auto* released = _impl_.name_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void MethodDescriptorProto::set_allocated_name(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000001u;
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
- _impl_.name_.SetAllocated(name, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.name_.IsDefault()) {
+ _impl_.name_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.name)
}
// optional string input_type = 2;
-inline bool MethodDescriptorProto::_internal_has_input_type() const {
+inline bool MethodDescriptorProto::has_input_type() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
return value;
}
-inline bool MethodDescriptorProto::has_input_type() const {
- return _internal_has_input_type();
-}
inline void MethodDescriptorProto::clear_input_type() {
_impl_.input_type_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000002u;
@@ -11658,11 +11442,11 @@ inline const TProtoStringType& MethodDescriptorProto::input_type() const {
// @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.input_type)
return _internal_input_type();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void MethodDescriptorProto::set_input_type(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000002u;
- _impl_.input_type_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void MethodDescriptorProto::set_input_type(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000002u;
+ _impl_.input_type_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.input_type)
}
inline TProtoStringType* MethodDescriptorProto::mutable_input_type() {
@@ -11675,49 +11459,46 @@ inline const TProtoStringType& MethodDescriptorProto::_internal_input_type() con
}
inline void MethodDescriptorProto::_internal_set_input_type(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000002u;
+
+
_impl_.input_type_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* MethodDescriptorProto::_internal_mutable_input_type() {
_impl_._has_bits_[0] |= 0x00000002u;
- return _impl_.input_type_.Mutable(GetArenaForAllocation());
+ return _impl_.input_type_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* MethodDescriptorProto::release_input_type() {
// @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.input_type)
- if (!_internal_has_input_type()) {
+ if ((_impl_._has_bits_[0] & 0x00000002u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000002u;
- auto* p = _impl_.input_type_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.input_type_.IsDefault()) {
- _impl_.input_type_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void MethodDescriptorProto::set_allocated_input_type(TProtoStringType* input_type) {
- if (input_type != nullptr) {
+ auto* released = _impl_.input_type_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.input_type_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void MethodDescriptorProto::set_allocated_input_type(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000002u;
} else {
_impl_._has_bits_[0] &= ~0x00000002u;
}
- _impl_.input_type_.SetAllocated(input_type, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.input_type_.IsDefault()) {
- _impl_.input_type_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.input_type_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.input_type_.IsDefault()) {
+ _impl_.input_type_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.input_type)
}
// optional string output_type = 3;
-inline bool MethodDescriptorProto::_internal_has_output_type() const {
+inline bool MethodDescriptorProto::has_output_type() const {
bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0;
return value;
}
-inline bool MethodDescriptorProto::has_output_type() const {
- return _internal_has_output_type();
-}
inline void MethodDescriptorProto::clear_output_type() {
_impl_.output_type_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000004u;
@@ -11726,11 +11507,11 @@ inline const TProtoStringType& MethodDescriptorProto::output_type() const {
// @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.output_type)
return _internal_output_type();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void MethodDescriptorProto::set_output_type(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000004u;
- _impl_.output_type_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void MethodDescriptorProto::set_output_type(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000004u;
+ _impl_.output_type_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.output_type)
}
inline TProtoStringType* MethodDescriptorProto::mutable_output_type() {
@@ -11743,50 +11524,47 @@ inline const TProtoStringType& MethodDescriptorProto::_internal_output_type() co
}
inline void MethodDescriptorProto::_internal_set_output_type(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000004u;
+
+
_impl_.output_type_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* MethodDescriptorProto::_internal_mutable_output_type() {
_impl_._has_bits_[0] |= 0x00000004u;
- return _impl_.output_type_.Mutable(GetArenaForAllocation());
+ return _impl_.output_type_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* MethodDescriptorProto::release_output_type() {
// @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.output_type)
- if (!_internal_has_output_type()) {
+ if ((_impl_._has_bits_[0] & 0x00000004u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000004u;
- auto* p = _impl_.output_type_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.output_type_.IsDefault()) {
- _impl_.output_type_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void MethodDescriptorProto::set_allocated_output_type(TProtoStringType* output_type) {
- if (output_type != nullptr) {
+ auto* released = _impl_.output_type_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.output_type_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void MethodDescriptorProto::set_allocated_output_type(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000004u;
} else {
_impl_._has_bits_[0] &= ~0x00000004u;
}
- _impl_.output_type_.SetAllocated(output_type, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.output_type_.IsDefault()) {
- _impl_.output_type_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.output_type_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.output_type_.IsDefault()) {
+ _impl_.output_type_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.output_type)
}
// optional .google.protobuf.MethodOptions options = 4;
-inline bool MethodDescriptorProto::_internal_has_options() const {
+inline bool MethodDescriptorProto::has_options() const {
bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0;
PROTOBUF_ASSUME(!value || _impl_.options_ != nullptr);
return value;
}
-inline bool MethodDescriptorProto::has_options() const {
- return _internal_has_options();
-}
inline void MethodDescriptorProto::clear_options() {
if (_impl_.options_ != nullptr) _impl_.options_->Clear();
_impl_._has_bits_[0] &= ~0x00000008u;
@@ -11869,73 +11647,64 @@ inline void MethodDescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE_ID
}
// optional bool client_streaming = 5 [default = false];
-inline bool MethodDescriptorProto::_internal_has_client_streaming() const {
+inline bool MethodDescriptorProto::has_client_streaming() const {
bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0;
return value;
}
-inline bool MethodDescriptorProto::has_client_streaming() const {
- return _internal_has_client_streaming();
-}
inline void MethodDescriptorProto::clear_client_streaming() {
_impl_.client_streaming_ = false;
_impl_._has_bits_[0] &= ~0x00000010u;
}
-inline bool MethodDescriptorProto::_internal_client_streaming() const {
- return _impl_.client_streaming_;
-}
inline bool MethodDescriptorProto::client_streaming() const {
// @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.client_streaming)
return _internal_client_streaming();
}
-inline void MethodDescriptorProto::_internal_set_client_streaming(bool value) {
- _impl_._has_bits_[0] |= 0x00000010u;
- _impl_.client_streaming_ = value;
-}
inline void MethodDescriptorProto::set_client_streaming(bool value) {
_internal_set_client_streaming(value);
// @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.client_streaming)
}
+inline bool MethodDescriptorProto::_internal_client_streaming() const {
+ return _impl_.client_streaming_;
+}
+inline void MethodDescriptorProto::_internal_set_client_streaming(bool value) {
+ _impl_._has_bits_[0] |= 0x00000010u;
+ _impl_.client_streaming_ = value;
+}
// optional bool server_streaming = 6 [default = false];
-inline bool MethodDescriptorProto::_internal_has_server_streaming() const {
+inline bool MethodDescriptorProto::has_server_streaming() const {
bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0;
return value;
}
-inline bool MethodDescriptorProto::has_server_streaming() const {
- return _internal_has_server_streaming();
-}
inline void MethodDescriptorProto::clear_server_streaming() {
_impl_.server_streaming_ = false;
_impl_._has_bits_[0] &= ~0x00000020u;
}
-inline bool MethodDescriptorProto::_internal_server_streaming() const {
- return _impl_.server_streaming_;
-}
inline bool MethodDescriptorProto::server_streaming() const {
// @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.server_streaming)
return _internal_server_streaming();
}
-inline void MethodDescriptorProto::_internal_set_server_streaming(bool value) {
- _impl_._has_bits_[0] |= 0x00000020u;
- _impl_.server_streaming_ = value;
-}
inline void MethodDescriptorProto::set_server_streaming(bool value) {
_internal_set_server_streaming(value);
// @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.server_streaming)
}
+inline bool MethodDescriptorProto::_internal_server_streaming() const {
+ return _impl_.server_streaming_;
+}
+inline void MethodDescriptorProto::_internal_set_server_streaming(bool value) {
+ _impl_._has_bits_[0] |= 0x00000020u;
+ _impl_.server_streaming_ = value;
+}
// -------------------------------------------------------------------
// FileOptions
// optional string java_package = 1;
-inline bool FileOptions::_internal_has_java_package() const {
+inline bool FileOptions::has_java_package() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool FileOptions::has_java_package() const {
- return _internal_has_java_package();
-}
inline void FileOptions::clear_java_package() {
_impl_.java_package_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000001u;
@@ -11944,11 +11713,11 @@ inline const TProtoStringType& FileOptions::java_package() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_package)
return _internal_java_package();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void FileOptions::set_java_package(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.java_package_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void FileOptions::set_java_package(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.java_package_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_package)
}
inline TProtoStringType* FileOptions::mutable_java_package() {
@@ -11961,49 +11730,46 @@ inline const TProtoStringType& FileOptions::_internal_java_package() const {
}
inline void FileOptions::_internal_set_java_package(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000001u;
+
+
_impl_.java_package_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::_internal_mutable_java_package() {
_impl_._has_bits_[0] |= 0x00000001u;
- return _impl_.java_package_.Mutable(GetArenaForAllocation());
+ return _impl_.java_package_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::release_java_package() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.java_package)
- if (!_internal_has_java_package()) {
+ if ((_impl_._has_bits_[0] & 0x00000001u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000001u;
- auto* p = _impl_.java_package_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.java_package_.IsDefault()) {
- _impl_.java_package_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void FileOptions::set_allocated_java_package(TProtoStringType* java_package) {
- if (java_package != nullptr) {
+ auto* released = _impl_.java_package_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.java_package_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void FileOptions::set_allocated_java_package(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000001u;
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
- _impl_.java_package_.SetAllocated(java_package, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.java_package_.IsDefault()) {
- _impl_.java_package_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.java_package_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.java_package_.IsDefault()) {
+ _impl_.java_package_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.java_package)
}
// optional string java_outer_classname = 8;
-inline bool FileOptions::_internal_has_java_outer_classname() const {
+inline bool FileOptions::has_java_outer_classname() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
return value;
}
-inline bool FileOptions::has_java_outer_classname() const {
- return _internal_has_java_outer_classname();
-}
inline void FileOptions::clear_java_outer_classname() {
_impl_.java_outer_classname_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000002u;
@@ -12012,11 +11778,11 @@ inline const TProtoStringType& FileOptions::java_outer_classname() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_outer_classname)
return _internal_java_outer_classname();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void FileOptions::set_java_outer_classname(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000002u;
- _impl_.java_outer_classname_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void FileOptions::set_java_outer_classname(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000002u;
+ _impl_.java_outer_classname_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_outer_classname)
}
inline TProtoStringType* FileOptions::mutable_java_outer_classname() {
@@ -12029,162 +11795,147 @@ inline const TProtoStringType& FileOptions::_internal_java_outer_classname() con
}
inline void FileOptions::_internal_set_java_outer_classname(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000002u;
+
+
_impl_.java_outer_classname_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::_internal_mutable_java_outer_classname() {
_impl_._has_bits_[0] |= 0x00000002u;
- return _impl_.java_outer_classname_.Mutable(GetArenaForAllocation());
+ return _impl_.java_outer_classname_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::release_java_outer_classname() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.java_outer_classname)
- if (!_internal_has_java_outer_classname()) {
+ if ((_impl_._has_bits_[0] & 0x00000002u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000002u;
- auto* p = _impl_.java_outer_classname_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.java_outer_classname_.IsDefault()) {
- _impl_.java_outer_classname_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void FileOptions::set_allocated_java_outer_classname(TProtoStringType* java_outer_classname) {
- if (java_outer_classname != nullptr) {
+ auto* released = _impl_.java_outer_classname_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.java_outer_classname_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void FileOptions::set_allocated_java_outer_classname(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000002u;
} else {
_impl_._has_bits_[0] &= ~0x00000002u;
}
- _impl_.java_outer_classname_.SetAllocated(java_outer_classname, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.java_outer_classname_.IsDefault()) {
- _impl_.java_outer_classname_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.java_outer_classname_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.java_outer_classname_.IsDefault()) {
+ _impl_.java_outer_classname_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.java_outer_classname)
}
// optional bool java_multiple_files = 10 [default = false];
-inline bool FileOptions::_internal_has_java_multiple_files() const {
+inline bool FileOptions::has_java_multiple_files() const {
bool value = (_impl_._has_bits_[0] & 0x00000400u) != 0;
return value;
}
-inline bool FileOptions::has_java_multiple_files() const {
- return _internal_has_java_multiple_files();
-}
inline void FileOptions::clear_java_multiple_files() {
_impl_.java_multiple_files_ = false;
_impl_._has_bits_[0] &= ~0x00000400u;
}
-inline bool FileOptions::_internal_java_multiple_files() const {
- return _impl_.java_multiple_files_;
-}
inline bool FileOptions::java_multiple_files() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_multiple_files)
return _internal_java_multiple_files();
}
-inline void FileOptions::_internal_set_java_multiple_files(bool value) {
- _impl_._has_bits_[0] |= 0x00000400u;
- _impl_.java_multiple_files_ = value;
-}
inline void FileOptions::set_java_multiple_files(bool value) {
_internal_set_java_multiple_files(value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_multiple_files)
}
+inline bool FileOptions::_internal_java_multiple_files() const {
+ return _impl_.java_multiple_files_;
+}
+inline void FileOptions::_internal_set_java_multiple_files(bool value) {
+ _impl_._has_bits_[0] |= 0x00000400u;
+ _impl_.java_multiple_files_ = value;
+}
// optional bool java_generate_equals_and_hash = 20 [deprecated = true];
-inline bool FileOptions::_internal_has_java_generate_equals_and_hash() const {
+inline bool FileOptions::has_java_generate_equals_and_hash() const {
bool value = (_impl_._has_bits_[0] & 0x00000800u) != 0;
return value;
}
-inline bool FileOptions::has_java_generate_equals_and_hash() const {
- return _internal_has_java_generate_equals_and_hash();
-}
inline void FileOptions::clear_java_generate_equals_and_hash() {
_impl_.java_generate_equals_and_hash_ = false;
_impl_._has_bits_[0] &= ~0x00000800u;
}
-inline bool FileOptions::_internal_java_generate_equals_and_hash() const {
- return _impl_.java_generate_equals_and_hash_;
-}
inline bool FileOptions::java_generate_equals_and_hash() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_generate_equals_and_hash)
return _internal_java_generate_equals_and_hash();
}
-inline void FileOptions::_internal_set_java_generate_equals_and_hash(bool value) {
- _impl_._has_bits_[0] |= 0x00000800u;
- _impl_.java_generate_equals_and_hash_ = value;
-}
inline void FileOptions::set_java_generate_equals_and_hash(bool value) {
_internal_set_java_generate_equals_and_hash(value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_generate_equals_and_hash)
}
+inline bool FileOptions::_internal_java_generate_equals_and_hash() const {
+ return _impl_.java_generate_equals_and_hash_;
+}
+inline void FileOptions::_internal_set_java_generate_equals_and_hash(bool value) {
+ _impl_._has_bits_[0] |= 0x00000800u;
+ _impl_.java_generate_equals_and_hash_ = value;
+}
// optional bool java_string_check_utf8 = 27 [default = false];
-inline bool FileOptions::_internal_has_java_string_check_utf8() const {
+inline bool FileOptions::has_java_string_check_utf8() const {
bool value = (_impl_._has_bits_[0] & 0x00001000u) != 0;
return value;
}
-inline bool FileOptions::has_java_string_check_utf8() const {
- return _internal_has_java_string_check_utf8();
-}
inline void FileOptions::clear_java_string_check_utf8() {
_impl_.java_string_check_utf8_ = false;
_impl_._has_bits_[0] &= ~0x00001000u;
}
-inline bool FileOptions::_internal_java_string_check_utf8() const {
- return _impl_.java_string_check_utf8_;
-}
inline bool FileOptions::java_string_check_utf8() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_string_check_utf8)
return _internal_java_string_check_utf8();
}
-inline void FileOptions::_internal_set_java_string_check_utf8(bool value) {
- _impl_._has_bits_[0] |= 0x00001000u;
- _impl_.java_string_check_utf8_ = value;
-}
inline void FileOptions::set_java_string_check_utf8(bool value) {
_internal_set_java_string_check_utf8(value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_string_check_utf8)
}
+inline bool FileOptions::_internal_java_string_check_utf8() const {
+ return _impl_.java_string_check_utf8_;
+}
+inline void FileOptions::_internal_set_java_string_check_utf8(bool value) {
+ _impl_._has_bits_[0] |= 0x00001000u;
+ _impl_.java_string_check_utf8_ = value;
+}
// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
-inline bool FileOptions::_internal_has_optimize_for() const {
+inline bool FileOptions::has_optimize_for() const {
bool value = (_impl_._has_bits_[0] & 0x00040000u) != 0;
return value;
}
-inline bool FileOptions::has_optimize_for() const {
- return _internal_has_optimize_for();
-}
inline void FileOptions::clear_optimize_for() {
_impl_.optimize_for_ = 1;
_impl_._has_bits_[0] &= ~0x00040000u;
}
-inline ::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode FileOptions::_internal_optimize_for() const {
- return static_cast< ::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode >(_impl_.optimize_for_);
-}
inline ::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode FileOptions::optimize_for() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.optimize_for)
return _internal_optimize_for();
}
+inline void FileOptions::set_optimize_for(::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode value) {
+ _internal_set_optimize_for(value);
+ // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.optimize_for)
+}
+inline ::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode FileOptions::_internal_optimize_for() const {
+ return static_cast<::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode>(_impl_.optimize_for_);
+}
inline void FileOptions::_internal_set_optimize_for(::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode value) {
assert(::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode_IsValid(value));
_impl_._has_bits_[0] |= 0x00040000u;
_impl_.optimize_for_ = value;
}
-inline void FileOptions::set_optimize_for(::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode value) {
- _internal_set_optimize_for(value);
- // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.optimize_for)
-}
// optional string go_package = 11;
-inline bool FileOptions::_internal_has_go_package() const {
+inline bool FileOptions::has_go_package() const {
bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0;
return value;
}
-inline bool FileOptions::has_go_package() const {
- return _internal_has_go_package();
-}
inline void FileOptions::clear_go_package() {
_impl_.go_package_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000004u;
@@ -12193,11 +11944,11 @@ inline const TProtoStringType& FileOptions::go_package() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.go_package)
return _internal_go_package();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void FileOptions::set_go_package(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000004u;
- _impl_.go_package_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void FileOptions::set_go_package(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000004u;
+ _impl_.go_package_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.go_package)
}
inline TProtoStringType* FileOptions::mutable_go_package() {
@@ -12210,217 +11961,196 @@ inline const TProtoStringType& FileOptions::_internal_go_package() const {
}
inline void FileOptions::_internal_set_go_package(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000004u;
+
+
_impl_.go_package_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::_internal_mutable_go_package() {
_impl_._has_bits_[0] |= 0x00000004u;
- return _impl_.go_package_.Mutable(GetArenaForAllocation());
+ return _impl_.go_package_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::release_go_package() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.go_package)
- if (!_internal_has_go_package()) {
+ if ((_impl_._has_bits_[0] & 0x00000004u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000004u;
- auto* p = _impl_.go_package_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.go_package_.IsDefault()) {
- _impl_.go_package_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void FileOptions::set_allocated_go_package(TProtoStringType* go_package) {
- if (go_package != nullptr) {
+ auto* released = _impl_.go_package_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.go_package_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void FileOptions::set_allocated_go_package(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000004u;
} else {
_impl_._has_bits_[0] &= ~0x00000004u;
}
- _impl_.go_package_.SetAllocated(go_package, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.go_package_.IsDefault()) {
- _impl_.go_package_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.go_package_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.go_package_.IsDefault()) {
+ _impl_.go_package_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.go_package)
}
// optional bool cc_generic_services = 16 [default = false];
-inline bool FileOptions::_internal_has_cc_generic_services() const {
+inline bool FileOptions::has_cc_generic_services() const {
bool value = (_impl_._has_bits_[0] & 0x00002000u) != 0;
return value;
}
-inline bool FileOptions::has_cc_generic_services() const {
- return _internal_has_cc_generic_services();
-}
inline void FileOptions::clear_cc_generic_services() {
_impl_.cc_generic_services_ = false;
_impl_._has_bits_[0] &= ~0x00002000u;
}
-inline bool FileOptions::_internal_cc_generic_services() const {
- return _impl_.cc_generic_services_;
-}
inline bool FileOptions::cc_generic_services() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.cc_generic_services)
return _internal_cc_generic_services();
}
-inline void FileOptions::_internal_set_cc_generic_services(bool value) {
- _impl_._has_bits_[0] |= 0x00002000u;
- _impl_.cc_generic_services_ = value;
-}
inline void FileOptions::set_cc_generic_services(bool value) {
_internal_set_cc_generic_services(value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.cc_generic_services)
}
+inline bool FileOptions::_internal_cc_generic_services() const {
+ return _impl_.cc_generic_services_;
+}
+inline void FileOptions::_internal_set_cc_generic_services(bool value) {
+ _impl_._has_bits_[0] |= 0x00002000u;
+ _impl_.cc_generic_services_ = value;
+}
// optional bool java_generic_services = 17 [default = false];
-inline bool FileOptions::_internal_has_java_generic_services() const {
+inline bool FileOptions::has_java_generic_services() const {
bool value = (_impl_._has_bits_[0] & 0x00004000u) != 0;
return value;
}
-inline bool FileOptions::has_java_generic_services() const {
- return _internal_has_java_generic_services();
-}
inline void FileOptions::clear_java_generic_services() {
_impl_.java_generic_services_ = false;
_impl_._has_bits_[0] &= ~0x00004000u;
}
-inline bool FileOptions::_internal_java_generic_services() const {
- return _impl_.java_generic_services_;
-}
inline bool FileOptions::java_generic_services() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_generic_services)
return _internal_java_generic_services();
}
-inline void FileOptions::_internal_set_java_generic_services(bool value) {
- _impl_._has_bits_[0] |= 0x00004000u;
- _impl_.java_generic_services_ = value;
-}
inline void FileOptions::set_java_generic_services(bool value) {
_internal_set_java_generic_services(value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_generic_services)
}
+inline bool FileOptions::_internal_java_generic_services() const {
+ return _impl_.java_generic_services_;
+}
+inline void FileOptions::_internal_set_java_generic_services(bool value) {
+ _impl_._has_bits_[0] |= 0x00004000u;
+ _impl_.java_generic_services_ = value;
+}
// optional bool py_generic_services = 18 [default = false];
-inline bool FileOptions::_internal_has_py_generic_services() const {
+inline bool FileOptions::has_py_generic_services() const {
bool value = (_impl_._has_bits_[0] & 0x00008000u) != 0;
return value;
}
-inline bool FileOptions::has_py_generic_services() const {
- return _internal_has_py_generic_services();
-}
inline void FileOptions::clear_py_generic_services() {
_impl_.py_generic_services_ = false;
_impl_._has_bits_[0] &= ~0x00008000u;
}
-inline bool FileOptions::_internal_py_generic_services() const {
- return _impl_.py_generic_services_;
-}
inline bool FileOptions::py_generic_services() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.py_generic_services)
return _internal_py_generic_services();
}
-inline void FileOptions::_internal_set_py_generic_services(bool value) {
- _impl_._has_bits_[0] |= 0x00008000u;
- _impl_.py_generic_services_ = value;
-}
inline void FileOptions::set_py_generic_services(bool value) {
_internal_set_py_generic_services(value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.py_generic_services)
}
+inline bool FileOptions::_internal_py_generic_services() const {
+ return _impl_.py_generic_services_;
+}
+inline void FileOptions::_internal_set_py_generic_services(bool value) {
+ _impl_._has_bits_[0] |= 0x00008000u;
+ _impl_.py_generic_services_ = value;
+}
// optional bool php_generic_services = 42 [default = false];
-inline bool FileOptions::_internal_has_php_generic_services() const {
+inline bool FileOptions::has_php_generic_services() const {
bool value = (_impl_._has_bits_[0] & 0x00010000u) != 0;
return value;
}
-inline bool FileOptions::has_php_generic_services() const {
- return _internal_has_php_generic_services();
-}
inline void FileOptions::clear_php_generic_services() {
_impl_.php_generic_services_ = false;
_impl_._has_bits_[0] &= ~0x00010000u;
}
-inline bool FileOptions::_internal_php_generic_services() const {
- return _impl_.php_generic_services_;
-}
inline bool FileOptions::php_generic_services() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_generic_services)
return _internal_php_generic_services();
}
-inline void FileOptions::_internal_set_php_generic_services(bool value) {
- _impl_._has_bits_[0] |= 0x00010000u;
- _impl_.php_generic_services_ = value;
-}
inline void FileOptions::set_php_generic_services(bool value) {
_internal_set_php_generic_services(value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_generic_services)
}
+inline bool FileOptions::_internal_php_generic_services() const {
+ return _impl_.php_generic_services_;
+}
+inline void FileOptions::_internal_set_php_generic_services(bool value) {
+ _impl_._has_bits_[0] |= 0x00010000u;
+ _impl_.php_generic_services_ = value;
+}
// optional bool deprecated = 23 [default = false];
-inline bool FileOptions::_internal_has_deprecated() const {
+inline bool FileOptions::has_deprecated() const {
bool value = (_impl_._has_bits_[0] & 0x00020000u) != 0;
return value;
}
-inline bool FileOptions::has_deprecated() const {
- return _internal_has_deprecated();
-}
inline void FileOptions::clear_deprecated() {
_impl_.deprecated_ = false;
_impl_._has_bits_[0] &= ~0x00020000u;
}
-inline bool FileOptions::_internal_deprecated() const {
- return _impl_.deprecated_;
-}
inline bool FileOptions::deprecated() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.deprecated)
return _internal_deprecated();
}
-inline void FileOptions::_internal_set_deprecated(bool value) {
- _impl_._has_bits_[0] |= 0x00020000u;
- _impl_.deprecated_ = value;
-}
inline void FileOptions::set_deprecated(bool value) {
_internal_set_deprecated(value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.deprecated)
}
+inline bool FileOptions::_internal_deprecated() const {
+ return _impl_.deprecated_;
+}
+inline void FileOptions::_internal_set_deprecated(bool value) {
+ _impl_._has_bits_[0] |= 0x00020000u;
+ _impl_.deprecated_ = value;
+}
// optional bool cc_enable_arenas = 31 [default = true];
-inline bool FileOptions::_internal_has_cc_enable_arenas() const {
+inline bool FileOptions::has_cc_enable_arenas() const {
bool value = (_impl_._has_bits_[0] & 0x00080000u) != 0;
return value;
}
-inline bool FileOptions::has_cc_enable_arenas() const {
- return _internal_has_cc_enable_arenas();
-}
inline void FileOptions::clear_cc_enable_arenas() {
_impl_.cc_enable_arenas_ = true;
_impl_._has_bits_[0] &= ~0x00080000u;
}
-inline bool FileOptions::_internal_cc_enable_arenas() const {
- return _impl_.cc_enable_arenas_;
-}
inline bool FileOptions::cc_enable_arenas() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.cc_enable_arenas)
return _internal_cc_enable_arenas();
}
-inline void FileOptions::_internal_set_cc_enable_arenas(bool value) {
- _impl_._has_bits_[0] |= 0x00080000u;
- _impl_.cc_enable_arenas_ = value;
-}
inline void FileOptions::set_cc_enable_arenas(bool value) {
_internal_set_cc_enable_arenas(value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.cc_enable_arenas)
}
+inline bool FileOptions::_internal_cc_enable_arenas() const {
+ return _impl_.cc_enable_arenas_;
+}
+inline void FileOptions::_internal_set_cc_enable_arenas(bool value) {
+ _impl_._has_bits_[0] |= 0x00080000u;
+ _impl_.cc_enable_arenas_ = value;
+}
// optional string objc_class_prefix = 36;
-inline bool FileOptions::_internal_has_objc_class_prefix() const {
+inline bool FileOptions::has_objc_class_prefix() const {
bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0;
return value;
}
-inline bool FileOptions::has_objc_class_prefix() const {
- return _internal_has_objc_class_prefix();
-}
inline void FileOptions::clear_objc_class_prefix() {
_impl_.objc_class_prefix_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000008u;
@@ -12429,11 +12159,11 @@ inline const TProtoStringType& FileOptions::objc_class_prefix() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.objc_class_prefix)
return _internal_objc_class_prefix();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void FileOptions::set_objc_class_prefix(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000008u;
- _impl_.objc_class_prefix_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void FileOptions::set_objc_class_prefix(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000008u;
+ _impl_.objc_class_prefix_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.objc_class_prefix)
}
inline TProtoStringType* FileOptions::mutable_objc_class_prefix() {
@@ -12446,49 +12176,46 @@ inline const TProtoStringType& FileOptions::_internal_objc_class_prefix() const
}
inline void FileOptions::_internal_set_objc_class_prefix(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000008u;
+
+
_impl_.objc_class_prefix_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::_internal_mutable_objc_class_prefix() {
_impl_._has_bits_[0] |= 0x00000008u;
- return _impl_.objc_class_prefix_.Mutable(GetArenaForAllocation());
+ return _impl_.objc_class_prefix_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::release_objc_class_prefix() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.objc_class_prefix)
- if (!_internal_has_objc_class_prefix()) {
+ if ((_impl_._has_bits_[0] & 0x00000008u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000008u;
- auto* p = _impl_.objc_class_prefix_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.objc_class_prefix_.IsDefault()) {
- _impl_.objc_class_prefix_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void FileOptions::set_allocated_objc_class_prefix(TProtoStringType* objc_class_prefix) {
- if (objc_class_prefix != nullptr) {
+ auto* released = _impl_.objc_class_prefix_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.objc_class_prefix_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void FileOptions::set_allocated_objc_class_prefix(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000008u;
} else {
_impl_._has_bits_[0] &= ~0x00000008u;
}
- _impl_.objc_class_prefix_.SetAllocated(objc_class_prefix, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.objc_class_prefix_.IsDefault()) {
- _impl_.objc_class_prefix_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.objc_class_prefix_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.objc_class_prefix_.IsDefault()) {
+ _impl_.objc_class_prefix_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.objc_class_prefix)
}
// optional string csharp_namespace = 37;
-inline bool FileOptions::_internal_has_csharp_namespace() const {
+inline bool FileOptions::has_csharp_namespace() const {
bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0;
return value;
}
-inline bool FileOptions::has_csharp_namespace() const {
- return _internal_has_csharp_namespace();
-}
inline void FileOptions::clear_csharp_namespace() {
_impl_.csharp_namespace_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000010u;
@@ -12497,11 +12224,11 @@ inline const TProtoStringType& FileOptions::csharp_namespace() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_namespace)
return _internal_csharp_namespace();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void FileOptions::set_csharp_namespace(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000010u;
- _impl_.csharp_namespace_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void FileOptions::set_csharp_namespace(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000010u;
+ _impl_.csharp_namespace_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_namespace)
}
inline TProtoStringType* FileOptions::mutable_csharp_namespace() {
@@ -12514,49 +12241,46 @@ inline const TProtoStringType& FileOptions::_internal_csharp_namespace() const {
}
inline void FileOptions::_internal_set_csharp_namespace(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000010u;
+
+
_impl_.csharp_namespace_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::_internal_mutable_csharp_namespace() {
_impl_._has_bits_[0] |= 0x00000010u;
- return _impl_.csharp_namespace_.Mutable(GetArenaForAllocation());
+ return _impl_.csharp_namespace_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::release_csharp_namespace() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.csharp_namespace)
- if (!_internal_has_csharp_namespace()) {
+ if ((_impl_._has_bits_[0] & 0x00000010u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000010u;
- auto* p = _impl_.csharp_namespace_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.csharp_namespace_.IsDefault()) {
- _impl_.csharp_namespace_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void FileOptions::set_allocated_csharp_namespace(TProtoStringType* csharp_namespace) {
- if (csharp_namespace != nullptr) {
+ auto* released = _impl_.csharp_namespace_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.csharp_namespace_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void FileOptions::set_allocated_csharp_namespace(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000010u;
} else {
_impl_._has_bits_[0] &= ~0x00000010u;
}
- _impl_.csharp_namespace_.SetAllocated(csharp_namespace, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.csharp_namespace_.IsDefault()) {
- _impl_.csharp_namespace_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.csharp_namespace_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.csharp_namespace_.IsDefault()) {
+ _impl_.csharp_namespace_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace)
}
// optional string swift_prefix = 39;
-inline bool FileOptions::_internal_has_swift_prefix() const {
+inline bool FileOptions::has_swift_prefix() const {
bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0;
return value;
}
-inline bool FileOptions::has_swift_prefix() const {
- return _internal_has_swift_prefix();
-}
inline void FileOptions::clear_swift_prefix() {
_impl_.swift_prefix_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000020u;
@@ -12565,11 +12289,11 @@ inline const TProtoStringType& FileOptions::swift_prefix() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.swift_prefix)
return _internal_swift_prefix();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void FileOptions::set_swift_prefix(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000020u;
- _impl_.swift_prefix_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void FileOptions::set_swift_prefix(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000020u;
+ _impl_.swift_prefix_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.swift_prefix)
}
inline TProtoStringType* FileOptions::mutable_swift_prefix() {
@@ -12582,49 +12306,46 @@ inline const TProtoStringType& FileOptions::_internal_swift_prefix() const {
}
inline void FileOptions::_internal_set_swift_prefix(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000020u;
+
+
_impl_.swift_prefix_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::_internal_mutable_swift_prefix() {
_impl_._has_bits_[0] |= 0x00000020u;
- return _impl_.swift_prefix_.Mutable(GetArenaForAllocation());
+ return _impl_.swift_prefix_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::release_swift_prefix() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.swift_prefix)
- if (!_internal_has_swift_prefix()) {
+ if ((_impl_._has_bits_[0] & 0x00000020u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000020u;
- auto* p = _impl_.swift_prefix_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.swift_prefix_.IsDefault()) {
- _impl_.swift_prefix_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void FileOptions::set_allocated_swift_prefix(TProtoStringType* swift_prefix) {
- if (swift_prefix != nullptr) {
+ auto* released = _impl_.swift_prefix_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.swift_prefix_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void FileOptions::set_allocated_swift_prefix(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000020u;
} else {
_impl_._has_bits_[0] &= ~0x00000020u;
}
- _impl_.swift_prefix_.SetAllocated(swift_prefix, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.swift_prefix_.IsDefault()) {
- _impl_.swift_prefix_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.swift_prefix_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.swift_prefix_.IsDefault()) {
+ _impl_.swift_prefix_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.swift_prefix)
}
// optional string php_class_prefix = 40;
-inline bool FileOptions::_internal_has_php_class_prefix() const {
+inline bool FileOptions::has_php_class_prefix() const {
bool value = (_impl_._has_bits_[0] & 0x00000040u) != 0;
return value;
}
-inline bool FileOptions::has_php_class_prefix() const {
- return _internal_has_php_class_prefix();
-}
inline void FileOptions::clear_php_class_prefix() {
_impl_.php_class_prefix_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000040u;
@@ -12633,11 +12354,11 @@ inline const TProtoStringType& FileOptions::php_class_prefix() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_class_prefix)
return _internal_php_class_prefix();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void FileOptions::set_php_class_prefix(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000040u;
- _impl_.php_class_prefix_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void FileOptions::set_php_class_prefix(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000040u;
+ _impl_.php_class_prefix_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_class_prefix)
}
inline TProtoStringType* FileOptions::mutable_php_class_prefix() {
@@ -12650,49 +12371,46 @@ inline const TProtoStringType& FileOptions::_internal_php_class_prefix() const {
}
inline void FileOptions::_internal_set_php_class_prefix(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000040u;
+
+
_impl_.php_class_prefix_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::_internal_mutable_php_class_prefix() {
_impl_._has_bits_[0] |= 0x00000040u;
- return _impl_.php_class_prefix_.Mutable(GetArenaForAllocation());
+ return _impl_.php_class_prefix_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::release_php_class_prefix() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_class_prefix)
- if (!_internal_has_php_class_prefix()) {
+ if ((_impl_._has_bits_[0] & 0x00000040u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000040u;
- auto* p = _impl_.php_class_prefix_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.php_class_prefix_.IsDefault()) {
- _impl_.php_class_prefix_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void FileOptions::set_allocated_php_class_prefix(TProtoStringType* php_class_prefix) {
- if (php_class_prefix != nullptr) {
+ auto* released = _impl_.php_class_prefix_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.php_class_prefix_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void FileOptions::set_allocated_php_class_prefix(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000040u;
} else {
_impl_._has_bits_[0] &= ~0x00000040u;
}
- _impl_.php_class_prefix_.SetAllocated(php_class_prefix, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.php_class_prefix_.IsDefault()) {
- _impl_.php_class_prefix_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.php_class_prefix_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.php_class_prefix_.IsDefault()) {
+ _impl_.php_class_prefix_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_class_prefix)
}
// optional string php_namespace = 41;
-inline bool FileOptions::_internal_has_php_namespace() const {
+inline bool FileOptions::has_php_namespace() const {
bool value = (_impl_._has_bits_[0] & 0x00000080u) != 0;
return value;
}
-inline bool FileOptions::has_php_namespace() const {
- return _internal_has_php_namespace();
-}
inline void FileOptions::clear_php_namespace() {
_impl_.php_namespace_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000080u;
@@ -12701,11 +12419,11 @@ inline const TProtoStringType& FileOptions::php_namespace() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_namespace)
return _internal_php_namespace();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void FileOptions::set_php_namespace(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000080u;
- _impl_.php_namespace_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void FileOptions::set_php_namespace(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000080u;
+ _impl_.php_namespace_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_namespace)
}
inline TProtoStringType* FileOptions::mutable_php_namespace() {
@@ -12718,49 +12436,46 @@ inline const TProtoStringType& FileOptions::_internal_php_namespace() const {
}
inline void FileOptions::_internal_set_php_namespace(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000080u;
+
+
_impl_.php_namespace_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::_internal_mutable_php_namespace() {
_impl_._has_bits_[0] |= 0x00000080u;
- return _impl_.php_namespace_.Mutable(GetArenaForAllocation());
+ return _impl_.php_namespace_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::release_php_namespace() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_namespace)
- if (!_internal_has_php_namespace()) {
+ if ((_impl_._has_bits_[0] & 0x00000080u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000080u;
- auto* p = _impl_.php_namespace_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.php_namespace_.IsDefault()) {
- _impl_.php_namespace_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void FileOptions::set_allocated_php_namespace(TProtoStringType* php_namespace) {
- if (php_namespace != nullptr) {
+ auto* released = _impl_.php_namespace_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.php_namespace_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void FileOptions::set_allocated_php_namespace(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000080u;
} else {
_impl_._has_bits_[0] &= ~0x00000080u;
}
- _impl_.php_namespace_.SetAllocated(php_namespace, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.php_namespace_.IsDefault()) {
- _impl_.php_namespace_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.php_namespace_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.php_namespace_.IsDefault()) {
+ _impl_.php_namespace_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_namespace)
}
// optional string php_metadata_namespace = 44;
-inline bool FileOptions::_internal_has_php_metadata_namespace() const {
+inline bool FileOptions::has_php_metadata_namespace() const {
bool value = (_impl_._has_bits_[0] & 0x00000100u) != 0;
return value;
}
-inline bool FileOptions::has_php_metadata_namespace() const {
- return _internal_has_php_metadata_namespace();
-}
inline void FileOptions::clear_php_metadata_namespace() {
_impl_.php_metadata_namespace_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000100u;
@@ -12769,11 +12484,11 @@ inline const TProtoStringType& FileOptions::php_metadata_namespace() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_metadata_namespace)
return _internal_php_metadata_namespace();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void FileOptions::set_php_metadata_namespace(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000100u;
- _impl_.php_metadata_namespace_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void FileOptions::set_php_metadata_namespace(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000100u;
+ _impl_.php_metadata_namespace_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_metadata_namespace)
}
inline TProtoStringType* FileOptions::mutable_php_metadata_namespace() {
@@ -12786,49 +12501,46 @@ inline const TProtoStringType& FileOptions::_internal_php_metadata_namespace() c
}
inline void FileOptions::_internal_set_php_metadata_namespace(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000100u;
+
+
_impl_.php_metadata_namespace_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::_internal_mutable_php_metadata_namespace() {
_impl_._has_bits_[0] |= 0x00000100u;
- return _impl_.php_metadata_namespace_.Mutable(GetArenaForAllocation());
+ return _impl_.php_metadata_namespace_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::release_php_metadata_namespace() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_metadata_namespace)
- if (!_internal_has_php_metadata_namespace()) {
+ if ((_impl_._has_bits_[0] & 0x00000100u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000100u;
- auto* p = _impl_.php_metadata_namespace_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.php_metadata_namespace_.IsDefault()) {
- _impl_.php_metadata_namespace_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void FileOptions::set_allocated_php_metadata_namespace(TProtoStringType* php_metadata_namespace) {
- if (php_metadata_namespace != nullptr) {
+ auto* released = _impl_.php_metadata_namespace_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.php_metadata_namespace_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void FileOptions::set_allocated_php_metadata_namespace(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000100u;
} else {
_impl_._has_bits_[0] &= ~0x00000100u;
}
- _impl_.php_metadata_namespace_.SetAllocated(php_metadata_namespace, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.php_metadata_namespace_.IsDefault()) {
- _impl_.php_metadata_namespace_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.php_metadata_namespace_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.php_metadata_namespace_.IsDefault()) {
+ _impl_.php_metadata_namespace_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_metadata_namespace)
}
// optional string ruby_package = 45;
-inline bool FileOptions::_internal_has_ruby_package() const {
+inline bool FileOptions::has_ruby_package() const {
bool value = (_impl_._has_bits_[0] & 0x00000200u) != 0;
return value;
}
-inline bool FileOptions::has_ruby_package() const {
- return _internal_has_ruby_package();
-}
inline void FileOptions::clear_ruby_package() {
_impl_.ruby_package_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000200u;
@@ -12837,11 +12549,11 @@ inline const TProtoStringType& FileOptions::ruby_package() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.ruby_package)
return _internal_ruby_package();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void FileOptions::set_ruby_package(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000200u;
- _impl_.ruby_package_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void FileOptions::set_ruby_package(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000200u;
+ _impl_.ruby_package_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.ruby_package)
}
inline TProtoStringType* FileOptions::mutable_ruby_package() {
@@ -12854,38 +12566,38 @@ inline const TProtoStringType& FileOptions::_internal_ruby_package() const {
}
inline void FileOptions::_internal_set_ruby_package(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000200u;
+
+
_impl_.ruby_package_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::_internal_mutable_ruby_package() {
_impl_._has_bits_[0] |= 0x00000200u;
- return _impl_.ruby_package_.Mutable(GetArenaForAllocation());
+ return _impl_.ruby_package_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* FileOptions::release_ruby_package() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.ruby_package)
- if (!_internal_has_ruby_package()) {
+ if ((_impl_._has_bits_[0] & 0x00000200u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000200u;
- auto* p = _impl_.ruby_package_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.ruby_package_.IsDefault()) {
- _impl_.ruby_package_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void FileOptions::set_allocated_ruby_package(TProtoStringType* ruby_package) {
- if (ruby_package != nullptr) {
+ auto* released = _impl_.ruby_package_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.ruby_package_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void FileOptions::set_allocated_ruby_package(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000200u;
} else {
_impl_._has_bits_[0] &= ~0x00000200u;
}
- _impl_.ruby_package_.SetAllocated(ruby_package, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.ruby_package_.IsDefault()) {
- _impl_.ruby_package_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.ruby_package_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.ruby_package_.IsDefault()) {
+ _impl_.ruby_package_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.ruby_package)
}
@@ -12934,115 +12646,128 @@ FileOptions::uninterpreted_option() const {
// MessageOptions
// optional bool message_set_wire_format = 1 [default = false];
-inline bool MessageOptions::_internal_has_message_set_wire_format() const {
+inline bool MessageOptions::has_message_set_wire_format() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool MessageOptions::has_message_set_wire_format() const {
- return _internal_has_message_set_wire_format();
-}
inline void MessageOptions::clear_message_set_wire_format() {
_impl_.message_set_wire_format_ = false;
_impl_._has_bits_[0] &= ~0x00000001u;
}
-inline bool MessageOptions::_internal_message_set_wire_format() const {
- return _impl_.message_set_wire_format_;
-}
inline bool MessageOptions::message_set_wire_format() const {
// @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.message_set_wire_format)
return _internal_message_set_wire_format();
}
-inline void MessageOptions::_internal_set_message_set_wire_format(bool value) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.message_set_wire_format_ = value;
-}
inline void MessageOptions::set_message_set_wire_format(bool value) {
_internal_set_message_set_wire_format(value);
// @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.message_set_wire_format)
}
+inline bool MessageOptions::_internal_message_set_wire_format() const {
+ return _impl_.message_set_wire_format_;
+}
+inline void MessageOptions::_internal_set_message_set_wire_format(bool value) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.message_set_wire_format_ = value;
+}
// optional bool no_standard_descriptor_accessor = 2 [default = false];
-inline bool MessageOptions::_internal_has_no_standard_descriptor_accessor() const {
+inline bool MessageOptions::has_no_standard_descriptor_accessor() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
return value;
}
-inline bool MessageOptions::has_no_standard_descriptor_accessor() const {
- return _internal_has_no_standard_descriptor_accessor();
-}
inline void MessageOptions::clear_no_standard_descriptor_accessor() {
_impl_.no_standard_descriptor_accessor_ = false;
_impl_._has_bits_[0] &= ~0x00000002u;
}
-inline bool MessageOptions::_internal_no_standard_descriptor_accessor() const {
- return _impl_.no_standard_descriptor_accessor_;
-}
inline bool MessageOptions::no_standard_descriptor_accessor() const {
// @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.no_standard_descriptor_accessor)
return _internal_no_standard_descriptor_accessor();
}
-inline void MessageOptions::_internal_set_no_standard_descriptor_accessor(bool value) {
- _impl_._has_bits_[0] |= 0x00000002u;
- _impl_.no_standard_descriptor_accessor_ = value;
-}
inline void MessageOptions::set_no_standard_descriptor_accessor(bool value) {
_internal_set_no_standard_descriptor_accessor(value);
// @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.no_standard_descriptor_accessor)
}
+inline bool MessageOptions::_internal_no_standard_descriptor_accessor() const {
+ return _impl_.no_standard_descriptor_accessor_;
+}
+inline void MessageOptions::_internal_set_no_standard_descriptor_accessor(bool value) {
+ _impl_._has_bits_[0] |= 0x00000002u;
+ _impl_.no_standard_descriptor_accessor_ = value;
+}
// optional bool deprecated = 3 [default = false];
-inline bool MessageOptions::_internal_has_deprecated() const {
+inline bool MessageOptions::has_deprecated() const {
bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0;
return value;
}
-inline bool MessageOptions::has_deprecated() const {
- return _internal_has_deprecated();
-}
inline void MessageOptions::clear_deprecated() {
_impl_.deprecated_ = false;
_impl_._has_bits_[0] &= ~0x00000004u;
}
-inline bool MessageOptions::_internal_deprecated() const {
- return _impl_.deprecated_;
-}
inline bool MessageOptions::deprecated() const {
// @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.deprecated)
return _internal_deprecated();
}
-inline void MessageOptions::_internal_set_deprecated(bool value) {
- _impl_._has_bits_[0] |= 0x00000004u;
- _impl_.deprecated_ = value;
-}
inline void MessageOptions::set_deprecated(bool value) {
_internal_set_deprecated(value);
// @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.deprecated)
}
+inline bool MessageOptions::_internal_deprecated() const {
+ return _impl_.deprecated_;
+}
+inline void MessageOptions::_internal_set_deprecated(bool value) {
+ _impl_._has_bits_[0] |= 0x00000004u;
+ _impl_.deprecated_ = value;
+}
// optional bool map_entry = 7;
-inline bool MessageOptions::_internal_has_map_entry() const {
+inline bool MessageOptions::has_map_entry() const {
bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0;
return value;
}
-inline bool MessageOptions::has_map_entry() const {
- return _internal_has_map_entry();
-}
inline void MessageOptions::clear_map_entry() {
_impl_.map_entry_ = false;
_impl_._has_bits_[0] &= ~0x00000008u;
}
-inline bool MessageOptions::_internal_map_entry() const {
- return _impl_.map_entry_;
-}
inline bool MessageOptions::map_entry() const {
// @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.map_entry)
return _internal_map_entry();
}
+inline void MessageOptions::set_map_entry(bool value) {
+ _internal_set_map_entry(value);
+ // @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.map_entry)
+}
+inline bool MessageOptions::_internal_map_entry() const {
+ return _impl_.map_entry_;
+}
inline void MessageOptions::_internal_set_map_entry(bool value) {
_impl_._has_bits_[0] |= 0x00000008u;
_impl_.map_entry_ = value;
}
-inline void MessageOptions::set_map_entry(bool value) {
- _internal_set_map_entry(value);
- // @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.map_entry)
+
+// optional bool deprecated_legacy_json_field_conflicts = 11 [deprecated = true];
+inline bool MessageOptions::has_deprecated_legacy_json_field_conflicts() const {
+ bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0;
+ return value;
+}
+inline void MessageOptions::clear_deprecated_legacy_json_field_conflicts() {
+ _impl_.deprecated_legacy_json_field_conflicts_ = false;
+ _impl_._has_bits_[0] &= ~0x00000010u;
+}
+inline bool MessageOptions::deprecated_legacy_json_field_conflicts() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.deprecated_legacy_json_field_conflicts)
+ return _internal_deprecated_legacy_json_field_conflicts();
+}
+inline void MessageOptions::set_deprecated_legacy_json_field_conflicts(bool value) {
+ _internal_set_deprecated_legacy_json_field_conflicts(value);
+ // @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.deprecated_legacy_json_field_conflicts)
+}
+inline bool MessageOptions::_internal_deprecated_legacy_json_field_conflicts() const {
+ return _impl_.deprecated_legacy_json_field_conflicts_;
+}
+inline void MessageOptions::_internal_set_deprecated_legacy_json_field_conflicts(bool value) {
+ _impl_._has_bits_[0] |= 0x00000010u;
+ _impl_.deprecated_legacy_json_field_conflicts_ = value;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
@@ -13090,201 +12815,257 @@ MessageOptions::uninterpreted_option() const {
// FieldOptions
// optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];
-inline bool FieldOptions::_internal_has_ctype() const {
+inline bool FieldOptions::has_ctype() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool FieldOptions::has_ctype() const {
- return _internal_has_ctype();
-}
inline void FieldOptions::clear_ctype() {
_impl_.ctype_ = 0;
_impl_._has_bits_[0] &= ~0x00000001u;
}
-inline ::PROTOBUF_NAMESPACE_ID::FieldOptions_CType FieldOptions::_internal_ctype() const {
- return static_cast< ::PROTOBUF_NAMESPACE_ID::FieldOptions_CType >(_impl_.ctype_);
-}
inline ::PROTOBUF_NAMESPACE_ID::FieldOptions_CType FieldOptions::ctype() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.ctype)
return _internal_ctype();
}
+inline void FieldOptions::set_ctype(::PROTOBUF_NAMESPACE_ID::FieldOptions_CType value) {
+ _internal_set_ctype(value);
+ // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.ctype)
+}
+inline ::PROTOBUF_NAMESPACE_ID::FieldOptions_CType FieldOptions::_internal_ctype() const {
+ return static_cast<::PROTOBUF_NAMESPACE_ID::FieldOptions_CType>(_impl_.ctype_);
+}
inline void FieldOptions::_internal_set_ctype(::PROTOBUF_NAMESPACE_ID::FieldOptions_CType value) {
assert(::PROTOBUF_NAMESPACE_ID::FieldOptions_CType_IsValid(value));
_impl_._has_bits_[0] |= 0x00000001u;
_impl_.ctype_ = value;
}
-inline void FieldOptions::set_ctype(::PROTOBUF_NAMESPACE_ID::FieldOptions_CType value) {
- _internal_set_ctype(value);
- // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.ctype)
-}
// optional bool packed = 2;
-inline bool FieldOptions::_internal_has_packed() const {
+inline bool FieldOptions::has_packed() const {
bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0;
return value;
}
-inline bool FieldOptions::has_packed() const {
- return _internal_has_packed();
-}
inline void FieldOptions::clear_packed() {
_impl_.packed_ = false;
_impl_._has_bits_[0] &= ~0x00000004u;
}
-inline bool FieldOptions::_internal_packed() const {
- return _impl_.packed_;
-}
inline bool FieldOptions::packed() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.packed)
return _internal_packed();
}
-inline void FieldOptions::_internal_set_packed(bool value) {
- _impl_._has_bits_[0] |= 0x00000004u;
- _impl_.packed_ = value;
-}
inline void FieldOptions::set_packed(bool value) {
_internal_set_packed(value);
// @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.packed)
}
+inline bool FieldOptions::_internal_packed() const {
+ return _impl_.packed_;
+}
+inline void FieldOptions::_internal_set_packed(bool value) {
+ _impl_._has_bits_[0] |= 0x00000004u;
+ _impl_.packed_ = value;
+}
// optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];
-inline bool FieldOptions::_internal_has_jstype() const {
+inline bool FieldOptions::has_jstype() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
return value;
}
-inline bool FieldOptions::has_jstype() const {
- return _internal_has_jstype();
-}
inline void FieldOptions::clear_jstype() {
_impl_.jstype_ = 0;
_impl_._has_bits_[0] &= ~0x00000002u;
}
-inline ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType FieldOptions::_internal_jstype() const {
- return static_cast< ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType >(_impl_.jstype_);
-}
inline ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType FieldOptions::jstype() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.jstype)
return _internal_jstype();
}
+inline void FieldOptions::set_jstype(::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType value) {
+ _internal_set_jstype(value);
+ // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.jstype)
+}
+inline ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType FieldOptions::_internal_jstype() const {
+ return static_cast<::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType>(_impl_.jstype_);
+}
inline void FieldOptions::_internal_set_jstype(::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType value) {
assert(::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType_IsValid(value));
_impl_._has_bits_[0] |= 0x00000002u;
_impl_.jstype_ = value;
}
-inline void FieldOptions::set_jstype(::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType value) {
- _internal_set_jstype(value);
- // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.jstype)
-}
// optional bool lazy = 5 [default = false];
-inline bool FieldOptions::_internal_has_lazy() const {
+inline bool FieldOptions::has_lazy() const {
bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0;
return value;
}
-inline bool FieldOptions::has_lazy() const {
- return _internal_has_lazy();
-}
inline void FieldOptions::clear_lazy() {
_impl_.lazy_ = false;
_impl_._has_bits_[0] &= ~0x00000008u;
}
-inline bool FieldOptions::_internal_lazy() const {
- return _impl_.lazy_;
-}
inline bool FieldOptions::lazy() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.lazy)
return _internal_lazy();
}
-inline void FieldOptions::_internal_set_lazy(bool value) {
- _impl_._has_bits_[0] |= 0x00000008u;
- _impl_.lazy_ = value;
-}
inline void FieldOptions::set_lazy(bool value) {
_internal_set_lazy(value);
// @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.lazy)
}
+inline bool FieldOptions::_internal_lazy() const {
+ return _impl_.lazy_;
+}
+inline void FieldOptions::_internal_set_lazy(bool value) {
+ _impl_._has_bits_[0] |= 0x00000008u;
+ _impl_.lazy_ = value;
+}
// optional bool unverified_lazy = 15 [default = false];
-inline bool FieldOptions::_internal_has_unverified_lazy() const {
+inline bool FieldOptions::has_unverified_lazy() const {
bool value = (_impl_._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() {
_impl_.unverified_lazy_ = false;
_impl_._has_bits_[0] &= ~0x00000010u;
}
-inline bool FieldOptions::_internal_unverified_lazy() const {
- return _impl_.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) {
- _impl_._has_bits_[0] |= 0x00000010u;
- _impl_.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)
}
+inline bool FieldOptions::_internal_unverified_lazy() const {
+ return _impl_.unverified_lazy_;
+}
+inline void FieldOptions::_internal_set_unverified_lazy(bool value) {
+ _impl_._has_bits_[0] |= 0x00000010u;
+ _impl_.unverified_lazy_ = value;
+}
// optional bool deprecated = 3 [default = false];
-inline bool FieldOptions::_internal_has_deprecated() const {
+inline bool FieldOptions::has_deprecated() const {
bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0;
return value;
}
-inline bool FieldOptions::has_deprecated() const {
- return _internal_has_deprecated();
-}
inline void FieldOptions::clear_deprecated() {
_impl_.deprecated_ = false;
_impl_._has_bits_[0] &= ~0x00000020u;
}
-inline bool FieldOptions::_internal_deprecated() const {
- return _impl_.deprecated_;
-}
inline bool FieldOptions::deprecated() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.deprecated)
return _internal_deprecated();
}
-inline void FieldOptions::_internal_set_deprecated(bool value) {
- _impl_._has_bits_[0] |= 0x00000020u;
- _impl_.deprecated_ = value;
-}
inline void FieldOptions::set_deprecated(bool value) {
_internal_set_deprecated(value);
// @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.deprecated)
}
+inline bool FieldOptions::_internal_deprecated() const {
+ return _impl_.deprecated_;
+}
+inline void FieldOptions::_internal_set_deprecated(bool value) {
+ _impl_._has_bits_[0] |= 0x00000020u;
+ _impl_.deprecated_ = value;
+}
// optional bool weak = 10 [default = false];
-inline bool FieldOptions::_internal_has_weak() const {
+inline bool FieldOptions::has_weak() const {
bool value = (_impl_._has_bits_[0] & 0x00000040u) != 0;
return value;
}
-inline bool FieldOptions::has_weak() const {
- return _internal_has_weak();
-}
inline void FieldOptions::clear_weak() {
_impl_.weak_ = false;
_impl_._has_bits_[0] &= ~0x00000040u;
}
-inline bool FieldOptions::_internal_weak() const {
- return _impl_.weak_;
-}
inline bool FieldOptions::weak() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.weak)
return _internal_weak();
}
+inline void FieldOptions::set_weak(bool value) {
+ _internal_set_weak(value);
+ // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.weak)
+}
+inline bool FieldOptions::_internal_weak() const {
+ return _impl_.weak_;
+}
inline void FieldOptions::_internal_set_weak(bool value) {
_impl_._has_bits_[0] |= 0x00000040u;
_impl_.weak_ = value;
}
-inline void FieldOptions::set_weak(bool value) {
- _internal_set_weak(value);
- // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.weak)
+
+// optional bool debug_redact = 16 [default = false];
+inline bool FieldOptions::has_debug_redact() const {
+ bool value = (_impl_._has_bits_[0] & 0x00000080u) != 0;
+ return value;
+}
+inline void FieldOptions::clear_debug_redact() {
+ _impl_.debug_redact_ = false;
+ _impl_._has_bits_[0] &= ~0x00000080u;
+}
+inline bool FieldOptions::debug_redact() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.debug_redact)
+ return _internal_debug_redact();
+}
+inline void FieldOptions::set_debug_redact(bool value) {
+ _internal_set_debug_redact(value);
+ // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.debug_redact)
+}
+inline bool FieldOptions::_internal_debug_redact() const {
+ return _impl_.debug_redact_;
+}
+inline void FieldOptions::_internal_set_debug_redact(bool value) {
+ _impl_._has_bits_[0] |= 0x00000080u;
+ _impl_.debug_redact_ = value;
+}
+
+// optional .google.protobuf.FieldOptions.OptionRetention retention = 17;
+inline bool FieldOptions::has_retention() const {
+ bool value = (_impl_._has_bits_[0] & 0x00000100u) != 0;
+ return value;
+}
+inline void FieldOptions::clear_retention() {
+ _impl_.retention_ = 0;
+ _impl_._has_bits_[0] &= ~0x00000100u;
+}
+inline ::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionRetention FieldOptions::retention() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.retention)
+ return _internal_retention();
+}
+inline void FieldOptions::set_retention(::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionRetention value) {
+ _internal_set_retention(value);
+ // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.retention)
+}
+inline ::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionRetention FieldOptions::_internal_retention() const {
+ return static_cast<::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionRetention>(_impl_.retention_);
+}
+inline void FieldOptions::_internal_set_retention(::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionRetention value) {
+ assert(::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionRetention_IsValid(value));
+ _impl_._has_bits_[0] |= 0x00000100u;
+ _impl_.retention_ = value;
+}
+
+// optional .google.protobuf.FieldOptions.OptionTargetType target = 18;
+inline bool FieldOptions::has_target() const {
+ bool value = (_impl_._has_bits_[0] & 0x00000200u) != 0;
+ return value;
+}
+inline void FieldOptions::clear_target() {
+ _impl_.target_ = 0;
+ _impl_._has_bits_[0] &= ~0x00000200u;
+}
+inline ::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionTargetType FieldOptions::target() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.target)
+ return _internal_target();
+}
+inline void FieldOptions::set_target(::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionTargetType value) {
+ _internal_set_target(value);
+ // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.target)
+}
+inline ::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionTargetType FieldOptions::_internal_target() const {
+ return static_cast<::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionTargetType>(_impl_.target_);
+}
+inline void FieldOptions::_internal_set_target(::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionTargetType value) {
+ assert(::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionTargetType_IsValid(value));
+ _impl_._has_bits_[0] |= 0x00000200u;
+ _impl_.target_ = value;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
@@ -13376,59 +13157,78 @@ OneofOptions::uninterpreted_option() const {
// EnumOptions
// optional bool allow_alias = 2;
-inline bool EnumOptions::_internal_has_allow_alias() const {
+inline bool EnumOptions::has_allow_alias() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool EnumOptions::has_allow_alias() const {
- return _internal_has_allow_alias();
-}
inline void EnumOptions::clear_allow_alias() {
_impl_.allow_alias_ = false;
_impl_._has_bits_[0] &= ~0x00000001u;
}
-inline bool EnumOptions::_internal_allow_alias() const {
- return _impl_.allow_alias_;
-}
inline bool EnumOptions::allow_alias() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.allow_alias)
return _internal_allow_alias();
}
-inline void EnumOptions::_internal_set_allow_alias(bool value) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.allow_alias_ = value;
-}
inline void EnumOptions::set_allow_alias(bool value) {
_internal_set_allow_alias(value);
// @@protoc_insertion_point(field_set:google.protobuf.EnumOptions.allow_alias)
}
+inline bool EnumOptions::_internal_allow_alias() const {
+ return _impl_.allow_alias_;
+}
+inline void EnumOptions::_internal_set_allow_alias(bool value) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.allow_alias_ = value;
+}
// optional bool deprecated = 3 [default = false];
-inline bool EnumOptions::_internal_has_deprecated() const {
+inline bool EnumOptions::has_deprecated() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
return value;
}
-inline bool EnumOptions::has_deprecated() const {
- return _internal_has_deprecated();
-}
inline void EnumOptions::clear_deprecated() {
_impl_.deprecated_ = false;
_impl_._has_bits_[0] &= ~0x00000002u;
}
-inline bool EnumOptions::_internal_deprecated() const {
- return _impl_.deprecated_;
-}
inline bool EnumOptions::deprecated() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.deprecated)
return _internal_deprecated();
}
+inline void EnumOptions::set_deprecated(bool value) {
+ _internal_set_deprecated(value);
+ // @@protoc_insertion_point(field_set:google.protobuf.EnumOptions.deprecated)
+}
+inline bool EnumOptions::_internal_deprecated() const {
+ return _impl_.deprecated_;
+}
inline void EnumOptions::_internal_set_deprecated(bool value) {
_impl_._has_bits_[0] |= 0x00000002u;
_impl_.deprecated_ = value;
}
-inline void EnumOptions::set_deprecated(bool value) {
- _internal_set_deprecated(value);
- // @@protoc_insertion_point(field_set:google.protobuf.EnumOptions.deprecated)
+
+// optional bool deprecated_legacy_json_field_conflicts = 6 [deprecated = true];
+inline bool EnumOptions::has_deprecated_legacy_json_field_conflicts() const {
+ bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0;
+ return value;
+}
+inline void EnumOptions::clear_deprecated_legacy_json_field_conflicts() {
+ _impl_.deprecated_legacy_json_field_conflicts_ = false;
+ _impl_._has_bits_[0] &= ~0x00000004u;
+}
+inline bool EnumOptions::deprecated_legacy_json_field_conflicts() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.deprecated_legacy_json_field_conflicts)
+ return _internal_deprecated_legacy_json_field_conflicts();
+}
+inline void EnumOptions::set_deprecated_legacy_json_field_conflicts(bool value) {
+ _internal_set_deprecated_legacy_json_field_conflicts(value);
+ // @@protoc_insertion_point(field_set:google.protobuf.EnumOptions.deprecated_legacy_json_field_conflicts)
+}
+inline bool EnumOptions::_internal_deprecated_legacy_json_field_conflicts() const {
+ return _impl_.deprecated_legacy_json_field_conflicts_;
+}
+inline void EnumOptions::_internal_set_deprecated_legacy_json_field_conflicts(bool value) {
+ _impl_._has_bits_[0] |= 0x00000004u;
+ _impl_.deprecated_legacy_json_field_conflicts_ = value;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
@@ -13476,32 +13276,29 @@ EnumOptions::uninterpreted_option() const {
// EnumValueOptions
// optional bool deprecated = 1 [default = false];
-inline bool EnumValueOptions::_internal_has_deprecated() const {
+inline bool EnumValueOptions::has_deprecated() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool EnumValueOptions::has_deprecated() const {
- return _internal_has_deprecated();
-}
inline void EnumValueOptions::clear_deprecated() {
_impl_.deprecated_ = false;
_impl_._has_bits_[0] &= ~0x00000001u;
}
-inline bool EnumValueOptions::_internal_deprecated() const {
- return _impl_.deprecated_;
-}
inline bool EnumValueOptions::deprecated() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumValueOptions.deprecated)
return _internal_deprecated();
}
-inline void EnumValueOptions::_internal_set_deprecated(bool value) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.deprecated_ = value;
-}
inline void EnumValueOptions::set_deprecated(bool value) {
_internal_set_deprecated(value);
// @@protoc_insertion_point(field_set:google.protobuf.EnumValueOptions.deprecated)
}
+inline bool EnumValueOptions::_internal_deprecated() const {
+ return _impl_.deprecated_;
+}
+inline void EnumValueOptions::_internal_set_deprecated(bool value) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.deprecated_ = value;
+}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
inline int EnumValueOptions::_internal_uninterpreted_option_size() const {
@@ -13548,32 +13345,29 @@ EnumValueOptions::uninterpreted_option() const {
// ServiceOptions
// optional bool deprecated = 33 [default = false];
-inline bool ServiceOptions::_internal_has_deprecated() const {
+inline bool ServiceOptions::has_deprecated() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool ServiceOptions::has_deprecated() const {
- return _internal_has_deprecated();
-}
inline void ServiceOptions::clear_deprecated() {
_impl_.deprecated_ = false;
_impl_._has_bits_[0] &= ~0x00000001u;
}
-inline bool ServiceOptions::_internal_deprecated() const {
- return _impl_.deprecated_;
-}
inline bool ServiceOptions::deprecated() const {
// @@protoc_insertion_point(field_get:google.protobuf.ServiceOptions.deprecated)
return _internal_deprecated();
}
-inline void ServiceOptions::_internal_set_deprecated(bool value) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.deprecated_ = value;
-}
inline void ServiceOptions::set_deprecated(bool value) {
_internal_set_deprecated(value);
// @@protoc_insertion_point(field_set:google.protobuf.ServiceOptions.deprecated)
}
+inline bool ServiceOptions::_internal_deprecated() const {
+ return _impl_.deprecated_;
+}
+inline void ServiceOptions::_internal_set_deprecated(bool value) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.deprecated_ = value;
+}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
inline int ServiceOptions::_internal_uninterpreted_option_size() const {
@@ -13620,61 +13414,55 @@ ServiceOptions::uninterpreted_option() const {
// MethodOptions
// optional bool deprecated = 33 [default = false];
-inline bool MethodOptions::_internal_has_deprecated() const {
+inline bool MethodOptions::has_deprecated() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool MethodOptions::has_deprecated() const {
- return _internal_has_deprecated();
-}
inline void MethodOptions::clear_deprecated() {
_impl_.deprecated_ = false;
_impl_._has_bits_[0] &= ~0x00000001u;
}
-inline bool MethodOptions::_internal_deprecated() const {
- return _impl_.deprecated_;
-}
inline bool MethodOptions::deprecated() const {
// @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.deprecated)
return _internal_deprecated();
}
-inline void MethodOptions::_internal_set_deprecated(bool value) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.deprecated_ = value;
-}
inline void MethodOptions::set_deprecated(bool value) {
_internal_set_deprecated(value);
// @@protoc_insertion_point(field_set:google.protobuf.MethodOptions.deprecated)
}
+inline bool MethodOptions::_internal_deprecated() const {
+ return _impl_.deprecated_;
+}
+inline void MethodOptions::_internal_set_deprecated(bool value) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.deprecated_ = value;
+}
// optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];
-inline bool MethodOptions::_internal_has_idempotency_level() const {
+inline bool MethodOptions::has_idempotency_level() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
return value;
}
-inline bool MethodOptions::has_idempotency_level() const {
- return _internal_has_idempotency_level();
-}
inline void MethodOptions::clear_idempotency_level() {
_impl_.idempotency_level_ = 0;
_impl_._has_bits_[0] &= ~0x00000002u;
}
-inline ::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel MethodOptions::_internal_idempotency_level() const {
- return static_cast< ::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel >(_impl_.idempotency_level_);
-}
inline ::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel MethodOptions::idempotency_level() const {
// @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.idempotency_level)
return _internal_idempotency_level();
}
+inline void MethodOptions::set_idempotency_level(::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel value) {
+ _internal_set_idempotency_level(value);
+ // @@protoc_insertion_point(field_set:google.protobuf.MethodOptions.idempotency_level)
+}
+inline ::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel MethodOptions::_internal_idempotency_level() const {
+ return static_cast<::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel>(_impl_.idempotency_level_);
+}
inline void MethodOptions::_internal_set_idempotency_level(::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel value) {
assert(::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel_IsValid(value));
_impl_._has_bits_[0] |= 0x00000002u;
_impl_.idempotency_level_ = value;
}
-inline void MethodOptions::set_idempotency_level(::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel value) {
- _internal_set_idempotency_level(value);
- // @@protoc_insertion_point(field_set:google.protobuf.MethodOptions.idempotency_level)
-}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
inline int MethodOptions::_internal_uninterpreted_option_size() const {
@@ -13721,13 +13509,10 @@ MethodOptions::uninterpreted_option() const {
// UninterpretedOption_NamePart
// required string name_part = 1;
-inline bool UninterpretedOption_NamePart::_internal_has_name_part() const {
+inline bool UninterpretedOption_NamePart::has_name_part() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool UninterpretedOption_NamePart::has_name_part() const {
- return _internal_has_name_part();
-}
inline void UninterpretedOption_NamePart::clear_name_part() {
_impl_.name_part_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000001u;
@@ -13736,11 +13521,11 @@ inline const TProtoStringType& UninterpretedOption_NamePart::name_part() const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.name_part)
return _internal_name_part();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void UninterpretedOption_NamePart::set_name_part(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.name_part_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void UninterpretedOption_NamePart::set_name_part(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.name_part_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.name_part)
}
inline TProtoStringType* UninterpretedOption_NamePart::mutable_name_part() {
@@ -13753,68 +13538,65 @@ inline const TProtoStringType& UninterpretedOption_NamePart::_internal_name_part
}
inline void UninterpretedOption_NamePart::_internal_set_name_part(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000001u;
+
+
_impl_.name_part_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* UninterpretedOption_NamePart::_internal_mutable_name_part() {
_impl_._has_bits_[0] |= 0x00000001u;
- return _impl_.name_part_.Mutable(GetArenaForAllocation());
+ return _impl_.name_part_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* UninterpretedOption_NamePart::release_name_part() {
// @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.NamePart.name_part)
- if (!_internal_has_name_part()) {
+ if ((_impl_._has_bits_[0] & 0x00000001u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000001u;
- auto* p = _impl_.name_part_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_part_.IsDefault()) {
- _impl_.name_part_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void UninterpretedOption_NamePart::set_allocated_name_part(TProtoStringType* name_part) {
- if (name_part != nullptr) {
+ auto* released = _impl_.name_part_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_part_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void UninterpretedOption_NamePart::set_allocated_name_part(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000001u;
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
- _impl_.name_part_.SetAllocated(name_part, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_part_.IsDefault()) {
- _impl_.name_part_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_part_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.name_part_.IsDefault()) {
+ _impl_.name_part_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.NamePart.name_part)
}
// required bool is_extension = 2;
-inline bool UninterpretedOption_NamePart::_internal_has_is_extension() const {
+inline bool UninterpretedOption_NamePart::has_is_extension() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
return value;
}
-inline bool UninterpretedOption_NamePart::has_is_extension() const {
- return _internal_has_is_extension();
-}
inline void UninterpretedOption_NamePart::clear_is_extension() {
_impl_.is_extension_ = false;
_impl_._has_bits_[0] &= ~0x00000002u;
}
-inline bool UninterpretedOption_NamePart::_internal_is_extension() const {
- return _impl_.is_extension_;
-}
inline bool UninterpretedOption_NamePart::is_extension() const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.is_extension)
return _internal_is_extension();
}
-inline void UninterpretedOption_NamePart::_internal_set_is_extension(bool value) {
- _impl_._has_bits_[0] |= 0x00000002u;
- _impl_.is_extension_ = value;
-}
inline void UninterpretedOption_NamePart::set_is_extension(bool value) {
_internal_set_is_extension(value);
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.is_extension)
}
+inline bool UninterpretedOption_NamePart::_internal_is_extension() const {
+ return _impl_.is_extension_;
+}
+inline void UninterpretedOption_NamePart::_internal_set_is_extension(bool value) {
+ _impl_._has_bits_[0] |= 0x00000002u;
+ _impl_.is_extension_ = value;
+}
// -------------------------------------------------------------------
@@ -13861,13 +13643,10 @@ UninterpretedOption::name() const {
}
// optional string identifier_value = 3;
-inline bool UninterpretedOption::_internal_has_identifier_value() const {
+inline bool UninterpretedOption::has_identifier_value() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool UninterpretedOption::has_identifier_value() const {
- return _internal_has_identifier_value();
-}
inline void UninterpretedOption::clear_identifier_value() {
_impl_.identifier_value_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000001u;
@@ -13876,11 +13655,11 @@ inline const TProtoStringType& UninterpretedOption::identifier_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.identifier_value)
return _internal_identifier_value();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void UninterpretedOption::set_identifier_value(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.identifier_value_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void UninterpretedOption::set_identifier_value(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.identifier_value_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.identifier_value)
}
inline TProtoStringType* UninterpretedOption::mutable_identifier_value() {
@@ -13893,133 +13672,121 @@ inline const TProtoStringType& UninterpretedOption::_internal_identifier_value()
}
inline void UninterpretedOption::_internal_set_identifier_value(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000001u;
+
+
_impl_.identifier_value_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* UninterpretedOption::_internal_mutable_identifier_value() {
_impl_._has_bits_[0] |= 0x00000001u;
- return _impl_.identifier_value_.Mutable(GetArenaForAllocation());
+ return _impl_.identifier_value_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* UninterpretedOption::release_identifier_value() {
// @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.identifier_value)
- if (!_internal_has_identifier_value()) {
+ if ((_impl_._has_bits_[0] & 0x00000001u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000001u;
- auto* p = _impl_.identifier_value_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.identifier_value_.IsDefault()) {
- _impl_.identifier_value_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void UninterpretedOption::set_allocated_identifier_value(TProtoStringType* identifier_value) {
- if (identifier_value != nullptr) {
+ auto* released = _impl_.identifier_value_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.identifier_value_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void UninterpretedOption::set_allocated_identifier_value(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000001u;
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
- _impl_.identifier_value_.SetAllocated(identifier_value, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.identifier_value_.IsDefault()) {
- _impl_.identifier_value_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.identifier_value_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.identifier_value_.IsDefault()) {
+ _impl_.identifier_value_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.identifier_value)
}
// optional uint64 positive_int_value = 4;
-inline bool UninterpretedOption::_internal_has_positive_int_value() const {
+inline bool UninterpretedOption::has_positive_int_value() const {
bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0;
return value;
}
-inline bool UninterpretedOption::has_positive_int_value() const {
- return _internal_has_positive_int_value();
-}
inline void UninterpretedOption::clear_positive_int_value() {
- _impl_.positive_int_value_ = arc_ui64{0u};
+ _impl_.positive_int_value_ = ::arc_ui64{0u};
_impl_._has_bits_[0] &= ~0x00000008u;
}
-inline arc_ui64 UninterpretedOption::_internal_positive_int_value() const {
- return _impl_.positive_int_value_;
-}
-inline arc_ui64 UninterpretedOption::positive_int_value() const {
+inline ::arc_ui64 UninterpretedOption::positive_int_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.positive_int_value)
return _internal_positive_int_value();
}
-inline void UninterpretedOption::_internal_set_positive_int_value(arc_ui64 value) {
- _impl_._has_bits_[0] |= 0x00000008u;
- _impl_.positive_int_value_ = value;
-}
-inline void UninterpretedOption::set_positive_int_value(arc_ui64 value) {
+inline void UninterpretedOption::set_positive_int_value(::arc_ui64 value) {
_internal_set_positive_int_value(value);
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.positive_int_value)
}
+inline ::arc_ui64 UninterpretedOption::_internal_positive_int_value() const {
+ return _impl_.positive_int_value_;
+}
+inline void UninterpretedOption::_internal_set_positive_int_value(::arc_ui64 value) {
+ _impl_._has_bits_[0] |= 0x00000008u;
+ _impl_.positive_int_value_ = value;
+}
// optional int64 negative_int_value = 5;
-inline bool UninterpretedOption::_internal_has_negative_int_value() const {
+inline bool UninterpretedOption::has_negative_int_value() const {
bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0;
return value;
}
-inline bool UninterpretedOption::has_negative_int_value() const {
- return _internal_has_negative_int_value();
-}
inline void UninterpretedOption::clear_negative_int_value() {
- _impl_.negative_int_value_ = arc_i64{0};
+ _impl_.negative_int_value_ = ::arc_i64{0};
_impl_._has_bits_[0] &= ~0x00000010u;
}
-inline arc_i64 UninterpretedOption::_internal_negative_int_value() const {
- return _impl_.negative_int_value_;
-}
-inline arc_i64 UninterpretedOption::negative_int_value() const {
+inline ::arc_i64 UninterpretedOption::negative_int_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.negative_int_value)
return _internal_negative_int_value();
}
-inline void UninterpretedOption::_internal_set_negative_int_value(arc_i64 value) {
- _impl_._has_bits_[0] |= 0x00000010u;
- _impl_.negative_int_value_ = value;
-}
-inline void UninterpretedOption::set_negative_int_value(arc_i64 value) {
+inline void UninterpretedOption::set_negative_int_value(::arc_i64 value) {
_internal_set_negative_int_value(value);
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.negative_int_value)
}
+inline ::arc_i64 UninterpretedOption::_internal_negative_int_value() const {
+ return _impl_.negative_int_value_;
+}
+inline void UninterpretedOption::_internal_set_negative_int_value(::arc_i64 value) {
+ _impl_._has_bits_[0] |= 0x00000010u;
+ _impl_.negative_int_value_ = value;
+}
// optional double double_value = 6;
-inline bool UninterpretedOption::_internal_has_double_value() const {
+inline bool UninterpretedOption::has_double_value() const {
bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0;
return value;
}
-inline bool UninterpretedOption::has_double_value() const {
- return _internal_has_double_value();
-}
inline void UninterpretedOption::clear_double_value() {
_impl_.double_value_ = 0;
_impl_._has_bits_[0] &= ~0x00000020u;
}
-inline double UninterpretedOption::_internal_double_value() const {
- return _impl_.double_value_;
-}
inline double UninterpretedOption::double_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.double_value)
return _internal_double_value();
}
-inline void UninterpretedOption::_internal_set_double_value(double value) {
- _impl_._has_bits_[0] |= 0x00000020u;
- _impl_.double_value_ = value;
-}
inline void UninterpretedOption::set_double_value(double value) {
_internal_set_double_value(value);
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.double_value)
}
+inline double UninterpretedOption::_internal_double_value() const {
+ return _impl_.double_value_;
+}
+inline void UninterpretedOption::_internal_set_double_value(double value) {
+ _impl_._has_bits_[0] |= 0x00000020u;
+ _impl_.double_value_ = value;
+}
// optional bytes string_value = 7;
-inline bool UninterpretedOption::_internal_has_string_value() const {
+inline bool UninterpretedOption::has_string_value() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
return value;
}
-inline bool UninterpretedOption::has_string_value() const {
- return _internal_has_string_value();
-}
inline void UninterpretedOption::clear_string_value() {
_impl_.string_value_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000002u;
@@ -14028,11 +13795,11 @@ inline const TProtoStringType& UninterpretedOption::string_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.string_value)
return _internal_string_value();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void UninterpretedOption::set_string_value(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000002u;
- _impl_.string_value_.SetBytes(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void UninterpretedOption::set_string_value(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000002u;
+ _impl_.string_value_.SetBytes(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.string_value)
}
inline TProtoStringType* UninterpretedOption::mutable_string_value() {
@@ -14045,49 +13812,46 @@ inline const TProtoStringType& UninterpretedOption::_internal_string_value() con
}
inline void UninterpretedOption::_internal_set_string_value(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000002u;
+
+
_impl_.string_value_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* UninterpretedOption::_internal_mutable_string_value() {
_impl_._has_bits_[0] |= 0x00000002u;
- return _impl_.string_value_.Mutable(GetArenaForAllocation());
+ return _impl_.string_value_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* UninterpretedOption::release_string_value() {
// @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.string_value)
- if (!_internal_has_string_value()) {
+ if ((_impl_._has_bits_[0] & 0x00000002u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000002u;
- auto* p = _impl_.string_value_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.string_value_.IsDefault()) {
- _impl_.string_value_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void UninterpretedOption::set_allocated_string_value(TProtoStringType* string_value) {
- if (string_value != nullptr) {
+ auto* released = _impl_.string_value_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.string_value_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void UninterpretedOption::set_allocated_string_value(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000002u;
} else {
_impl_._has_bits_[0] &= ~0x00000002u;
}
- _impl_.string_value_.SetAllocated(string_value, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.string_value_.IsDefault()) {
- _impl_.string_value_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.string_value_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.string_value_.IsDefault()) {
+ _impl_.string_value_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.string_value)
}
// optional string aggregate_value = 8;
-inline bool UninterpretedOption::_internal_has_aggregate_value() const {
+inline bool UninterpretedOption::has_aggregate_value() const {
bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0;
return value;
}
-inline bool UninterpretedOption::has_aggregate_value() const {
- return _internal_has_aggregate_value();
-}
inline void UninterpretedOption::clear_aggregate_value() {
_impl_.aggregate_value_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000004u;
@@ -14096,11 +13860,11 @@ inline const TProtoStringType& UninterpretedOption::aggregate_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.aggregate_value)
return _internal_aggregate_value();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void UninterpretedOption::set_aggregate_value(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000004u;
- _impl_.aggregate_value_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void UninterpretedOption::set_aggregate_value(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000004u;
+ _impl_.aggregate_value_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.aggregate_value)
}
inline TProtoStringType* UninterpretedOption::mutable_aggregate_value() {
@@ -14113,38 +13877,38 @@ inline const TProtoStringType& UninterpretedOption::_internal_aggregate_value()
}
inline void UninterpretedOption::_internal_set_aggregate_value(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000004u;
+
+
_impl_.aggregate_value_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* UninterpretedOption::_internal_mutable_aggregate_value() {
_impl_._has_bits_[0] |= 0x00000004u;
- return _impl_.aggregate_value_.Mutable(GetArenaForAllocation());
+ return _impl_.aggregate_value_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* UninterpretedOption::release_aggregate_value() {
// @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.aggregate_value)
- if (!_internal_has_aggregate_value()) {
+ if ((_impl_._has_bits_[0] & 0x00000004u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000004u;
- auto* p = _impl_.aggregate_value_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.aggregate_value_.IsDefault()) {
- _impl_.aggregate_value_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void UninterpretedOption::set_allocated_aggregate_value(TProtoStringType* aggregate_value) {
- if (aggregate_value != nullptr) {
+ auto* released = _impl_.aggregate_value_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.aggregate_value_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void UninterpretedOption::set_allocated_aggregate_value(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000004u;
} else {
_impl_._has_bits_[0] &= ~0x00000004u;
}
- _impl_.aggregate_value_.SetAllocated(aggregate_value, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.aggregate_value_.IsDefault()) {
- _impl_.aggregate_value_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.aggregate_value_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.aggregate_value_.IsDefault()) {
+ _impl_.aggregate_value_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.aggregate_value)
}
@@ -14162,43 +13926,38 @@ inline int SourceCodeInfo_Location::path_size() const {
inline void SourceCodeInfo_Location::clear_path() {
_impl_.path_.Clear();
}
-inline arc_i32 SourceCodeInfo_Location::_internal_path(int index) const {
- return _impl_.path_.Get(index);
-}
-inline arc_i32 SourceCodeInfo_Location::path(int index) const {
+inline ::arc_i32 SourceCodeInfo_Location::path(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.path)
return _internal_path(index);
}
-inline void SourceCodeInfo_Location::set_path(int index, arc_i32 value) {
+inline void SourceCodeInfo_Location::set_path(int index, ::arc_i32 value) {
_impl_.path_.Set(index, value);
// @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.path)
}
-inline void SourceCodeInfo_Location::_internal_add_path(arc_i32 value) {
- _impl_.path_.Add(value);
-}
-inline void SourceCodeInfo_Location::add_path(arc_i32 value) {
+inline void SourceCodeInfo_Location::add_path(::arc_i32 value) {
_internal_add_path(value);
// @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.path)
}
-inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >&
-SourceCodeInfo_Location::_internal_path() const {
- return _impl_.path_;
-}
-inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >&
-SourceCodeInfo_Location::path() const {
+inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>& SourceCodeInfo_Location::path() const {
// @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.Location.path)
return _internal_path();
}
-inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >*
-SourceCodeInfo_Location::_internal_mutable_path() {
- return &_impl_.path_;
-}
-inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >*
-SourceCodeInfo_Location::mutable_path() {
+inline ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>* SourceCodeInfo_Location::mutable_path() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.Location.path)
return _internal_mutable_path();
}
+inline ::arc_i32 SourceCodeInfo_Location::_internal_path(int index) const {
+ return _impl_.path_.Get(index);
+}
+inline void SourceCodeInfo_Location::_internal_add_path(::arc_i32 value) { _impl_.path_.Add(value); }
+inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>& SourceCodeInfo_Location::_internal_path() const {
+ return _impl_.path_;
+}
+inline ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>* SourceCodeInfo_Location::_internal_mutable_path() {
+ return &_impl_.path_;
+}
+
// repeated int32 span = 2 [packed = true];
inline int SourceCodeInfo_Location::_internal_span_size() const {
return _impl_.span_.size();
@@ -14209,51 +13968,43 @@ inline int SourceCodeInfo_Location::span_size() const {
inline void SourceCodeInfo_Location::clear_span() {
_impl_.span_.Clear();
}
-inline arc_i32 SourceCodeInfo_Location::_internal_span(int index) const {
- return _impl_.span_.Get(index);
-}
-inline arc_i32 SourceCodeInfo_Location::span(int index) const {
+inline ::arc_i32 SourceCodeInfo_Location::span(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.span)
return _internal_span(index);
}
-inline void SourceCodeInfo_Location::set_span(int index, arc_i32 value) {
+inline void SourceCodeInfo_Location::set_span(int index, ::arc_i32 value) {
_impl_.span_.Set(index, value);
// @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.span)
}
-inline void SourceCodeInfo_Location::_internal_add_span(arc_i32 value) {
- _impl_.span_.Add(value);
-}
-inline void SourceCodeInfo_Location::add_span(arc_i32 value) {
+inline void SourceCodeInfo_Location::add_span(::arc_i32 value) {
_internal_add_span(value);
// @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.span)
}
-inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >&
-SourceCodeInfo_Location::_internal_span() const {
- return _impl_.span_;
-}
-inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >&
-SourceCodeInfo_Location::span() const {
+inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>& SourceCodeInfo_Location::span() const {
// @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.Location.span)
return _internal_span();
}
-inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >*
-SourceCodeInfo_Location::_internal_mutable_span() {
- return &_impl_.span_;
-}
-inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >*
-SourceCodeInfo_Location::mutable_span() {
+inline ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>* SourceCodeInfo_Location::mutable_span() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.Location.span)
return _internal_mutable_span();
}
+inline ::arc_i32 SourceCodeInfo_Location::_internal_span(int index) const {
+ return _impl_.span_.Get(index);
+}
+inline void SourceCodeInfo_Location::_internal_add_span(::arc_i32 value) { _impl_.span_.Add(value); }
+inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>& SourceCodeInfo_Location::_internal_span() const {
+ return _impl_.span_;
+}
+inline ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>* SourceCodeInfo_Location::_internal_mutable_span() {
+ return &_impl_.span_;
+}
+
// optional string leading_comments = 3;
-inline bool SourceCodeInfo_Location::_internal_has_leading_comments() const {
+inline bool SourceCodeInfo_Location::has_leading_comments() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool SourceCodeInfo_Location::has_leading_comments() const {
- return _internal_has_leading_comments();
-}
inline void SourceCodeInfo_Location::clear_leading_comments() {
_impl_.leading_comments_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000001u;
@@ -14262,11 +14013,11 @@ inline const TProtoStringType& SourceCodeInfo_Location::leading_comments() const
// @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.leading_comments)
return _internal_leading_comments();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void SourceCodeInfo_Location::set_leading_comments(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.leading_comments_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void SourceCodeInfo_Location::set_leading_comments(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.leading_comments_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_comments)
}
inline TProtoStringType* SourceCodeInfo_Location::mutable_leading_comments() {
@@ -14279,49 +14030,46 @@ inline const TProtoStringType& SourceCodeInfo_Location::_internal_leading_commen
}
inline void SourceCodeInfo_Location::_internal_set_leading_comments(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000001u;
+
+
_impl_.leading_comments_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* SourceCodeInfo_Location::_internal_mutable_leading_comments() {
_impl_._has_bits_[0] |= 0x00000001u;
- return _impl_.leading_comments_.Mutable(GetArenaForAllocation());
+ return _impl_.leading_comments_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* SourceCodeInfo_Location::release_leading_comments() {
// @@protoc_insertion_point(field_release:google.protobuf.SourceCodeInfo.Location.leading_comments)
- if (!_internal_has_leading_comments()) {
+ if ((_impl_._has_bits_[0] & 0x00000001u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000001u;
- auto* p = _impl_.leading_comments_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.leading_comments_.IsDefault()) {
- _impl_.leading_comments_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void SourceCodeInfo_Location::set_allocated_leading_comments(TProtoStringType* leading_comments) {
- if (leading_comments != nullptr) {
+ auto* released = _impl_.leading_comments_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.leading_comments_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void SourceCodeInfo_Location::set_allocated_leading_comments(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000001u;
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
- _impl_.leading_comments_.SetAllocated(leading_comments, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.leading_comments_.IsDefault()) {
- _impl_.leading_comments_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.leading_comments_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.leading_comments_.IsDefault()) {
+ _impl_.leading_comments_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceCodeInfo.Location.leading_comments)
}
// optional string trailing_comments = 4;
-inline bool SourceCodeInfo_Location::_internal_has_trailing_comments() const {
+inline bool SourceCodeInfo_Location::has_trailing_comments() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
return value;
}
-inline bool SourceCodeInfo_Location::has_trailing_comments() const {
- return _internal_has_trailing_comments();
-}
inline void SourceCodeInfo_Location::clear_trailing_comments() {
_impl_.trailing_comments_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000002u;
@@ -14330,11 +14078,11 @@ inline const TProtoStringType& SourceCodeInfo_Location::trailing_comments() cons
// @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.trailing_comments)
return _internal_trailing_comments();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void SourceCodeInfo_Location::set_trailing_comments(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000002u;
- _impl_.trailing_comments_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void SourceCodeInfo_Location::set_trailing_comments(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000002u;
+ _impl_.trailing_comments_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.trailing_comments)
}
inline TProtoStringType* SourceCodeInfo_Location::mutable_trailing_comments() {
@@ -14347,38 +14095,38 @@ inline const TProtoStringType& SourceCodeInfo_Location::_internal_trailing_comme
}
inline void SourceCodeInfo_Location::_internal_set_trailing_comments(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000002u;
+
+
_impl_.trailing_comments_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* SourceCodeInfo_Location::_internal_mutable_trailing_comments() {
_impl_._has_bits_[0] |= 0x00000002u;
- return _impl_.trailing_comments_.Mutable(GetArenaForAllocation());
+ return _impl_.trailing_comments_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* SourceCodeInfo_Location::release_trailing_comments() {
// @@protoc_insertion_point(field_release:google.protobuf.SourceCodeInfo.Location.trailing_comments)
- if (!_internal_has_trailing_comments()) {
+ if ((_impl_._has_bits_[0] & 0x00000002u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000002u;
- auto* p = _impl_.trailing_comments_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.trailing_comments_.IsDefault()) {
- _impl_.trailing_comments_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void SourceCodeInfo_Location::set_allocated_trailing_comments(TProtoStringType* trailing_comments) {
- if (trailing_comments != nullptr) {
+ auto* released = _impl_.trailing_comments_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.trailing_comments_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void SourceCodeInfo_Location::set_allocated_trailing_comments(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000002u;
} else {
_impl_._has_bits_[0] &= ~0x00000002u;
}
- _impl_.trailing_comments_.SetAllocated(trailing_comments, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.trailing_comments_.IsDefault()) {
- _impl_.trailing_comments_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.trailing_comments_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.trailing_comments_.IsDefault()) {
+ _impl_.trailing_comments_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceCodeInfo.Location.trailing_comments)
}
@@ -14417,18 +14165,20 @@ inline void SourceCodeInfo_Location::set_leading_detached_comments(int index, TP
// @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
}
inline void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value) {
- GOOGLE_DCHECK(value != nullptr);
+ Y_ABSL_DCHECK(value != nullptr);
_impl_.leading_detached_comments_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
}
-inline void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value, size_t size) {
- _impl_.leading_detached_comments_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
+inline void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value,
+ std::size_t size) {
+ _impl_.leading_detached_comments_.Mutable(index)->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
}
-inline TProtoStringType* SourceCodeInfo_Location::_internal_add_leading_detached_comments() {
- return _impl_.leading_detached_comments_.Add();
+inline void SourceCodeInfo_Location::set_leading_detached_comments(int index, y_absl::string_view value) {
+ _impl_.leading_detached_comments_.Mutable(index)->assign(value.data(), value.size());
+ // @@protoc_insertion_point(field_set_string_piece:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
}
+inline TProtoStringType* SourceCodeInfo_Location::_internal_add_leading_detached_comments() { return _impl_.leading_detached_comments_.Add(); }
inline void SourceCodeInfo_Location::add_leading_detached_comments(const TProtoStringType& value) {
_impl_.leading_detached_comments_.Add()->assign(value);
// @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
@@ -14438,21 +14188,24 @@ inline void SourceCodeInfo_Location::add_leading_detached_comments(TProtoStringT
// @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
}
inline void SourceCodeInfo_Location::add_leading_detached_comments(const char* value) {
- GOOGLE_DCHECK(value != nullptr);
+ Y_ABSL_DCHECK(value != nullptr);
_impl_.leading_detached_comments_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
}
-inline void SourceCodeInfo_Location::add_leading_detached_comments(const char* value, size_t size) {
+inline void SourceCodeInfo_Location::add_leading_detached_comments(const char* value, std::size_t size) {
_impl_.leading_detached_comments_.Add()->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_add_pointer:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
}
+inline void SourceCodeInfo_Location::add_leading_detached_comments(y_absl::string_view value) {
+ _impl_.leading_detached_comments_.Add()->assign(value.data(), value.size());
+ // @@protoc_insertion_point(field_add_string_piece:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
+}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>&
SourceCodeInfo_Location::leading_detached_comments() const {
// @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
return _impl_.leading_detached_comments_;
}
-inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>*
-SourceCodeInfo_Location::mutable_leading_detached_comments() {
+inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>* SourceCodeInfo_Location::mutable_leading_detached_comments() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
return &_impl_.leading_detached_comments_;
}
@@ -14515,51 +14268,43 @@ inline int GeneratedCodeInfo_Annotation::path_size() const {
inline void GeneratedCodeInfo_Annotation::clear_path() {
_impl_.path_.Clear();
}
-inline arc_i32 GeneratedCodeInfo_Annotation::_internal_path(int index) const {
- return _impl_.path_.Get(index);
-}
-inline arc_i32 GeneratedCodeInfo_Annotation::path(int index) const {
+inline ::arc_i32 GeneratedCodeInfo_Annotation::path(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.path)
return _internal_path(index);
}
-inline void GeneratedCodeInfo_Annotation::set_path(int index, arc_i32 value) {
+inline void GeneratedCodeInfo_Annotation::set_path(int index, ::arc_i32 value) {
_impl_.path_.Set(index, value);
// @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.path)
}
-inline void GeneratedCodeInfo_Annotation::_internal_add_path(arc_i32 value) {
- _impl_.path_.Add(value);
-}
-inline void GeneratedCodeInfo_Annotation::add_path(arc_i32 value) {
+inline void GeneratedCodeInfo_Annotation::add_path(::arc_i32 value) {
_internal_add_path(value);
// @@protoc_insertion_point(field_add:google.protobuf.GeneratedCodeInfo.Annotation.path)
}
-inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >&
-GeneratedCodeInfo_Annotation::_internal_path() const {
- return _impl_.path_;
-}
-inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >&
-GeneratedCodeInfo_Annotation::path() const {
+inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>& GeneratedCodeInfo_Annotation::path() const {
// @@protoc_insertion_point(field_list:google.protobuf.GeneratedCodeInfo.Annotation.path)
return _internal_path();
}
-inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >*
-GeneratedCodeInfo_Annotation::_internal_mutable_path() {
- return &_impl_.path_;
-}
-inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< arc_i32 >*
-GeneratedCodeInfo_Annotation::mutable_path() {
+inline ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>* GeneratedCodeInfo_Annotation::mutable_path() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.GeneratedCodeInfo.Annotation.path)
return _internal_mutable_path();
}
+inline ::arc_i32 GeneratedCodeInfo_Annotation::_internal_path(int index) const {
+ return _impl_.path_.Get(index);
+}
+inline void GeneratedCodeInfo_Annotation::_internal_add_path(::arc_i32 value) { _impl_.path_.Add(value); }
+inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>& GeneratedCodeInfo_Annotation::_internal_path() const {
+ return _impl_.path_;
+}
+inline ::PROTOBUF_NAMESPACE_ID::RepeatedField<::arc_i32>* GeneratedCodeInfo_Annotation::_internal_mutable_path() {
+ return &_impl_.path_;
+}
+
// optional string source_file = 2;
-inline bool GeneratedCodeInfo_Annotation::_internal_has_source_file() const {
+inline bool GeneratedCodeInfo_Annotation::has_source_file() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool GeneratedCodeInfo_Annotation::has_source_file() const {
- return _internal_has_source_file();
-}
inline void GeneratedCodeInfo_Annotation::clear_source_file() {
_impl_.source_file_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000001u;
@@ -14568,11 +14313,11 @@ inline const TProtoStringType& GeneratedCodeInfo_Annotation::source_file() const
// @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
return _internal_source_file();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void GeneratedCodeInfo_Annotation::set_source_file(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.source_file_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void GeneratedCodeInfo_Annotation::set_source_file(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.source_file_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
}
inline TProtoStringType* GeneratedCodeInfo_Annotation::mutable_source_file() {
@@ -14585,95 +14330,115 @@ inline const TProtoStringType& GeneratedCodeInfo_Annotation::_internal_source_fi
}
inline void GeneratedCodeInfo_Annotation::_internal_set_source_file(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000001u;
+
+
_impl_.source_file_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* GeneratedCodeInfo_Annotation::_internal_mutable_source_file() {
_impl_._has_bits_[0] |= 0x00000001u;
- return _impl_.source_file_.Mutable(GetArenaForAllocation());
+ return _impl_.source_file_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* GeneratedCodeInfo_Annotation::release_source_file() {
// @@protoc_insertion_point(field_release:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
- if (!_internal_has_source_file()) {
+ if ((_impl_._has_bits_[0] & 0x00000001u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000001u;
- auto* p = _impl_.source_file_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.source_file_.IsDefault()) {
- _impl_.source_file_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void GeneratedCodeInfo_Annotation::set_allocated_source_file(TProtoStringType* source_file) {
- if (source_file != nullptr) {
+ auto* released = _impl_.source_file_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.source_file_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void GeneratedCodeInfo_Annotation::set_allocated_source_file(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000001u;
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
- _impl_.source_file_.SetAllocated(source_file, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.source_file_.IsDefault()) {
- _impl_.source_file_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.source_file_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.source_file_.IsDefault()) {
+ _impl_.source_file_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
}
// optional int32 begin = 3;
-inline bool GeneratedCodeInfo_Annotation::_internal_has_begin() const {
+inline bool GeneratedCodeInfo_Annotation::has_begin() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
return value;
}
-inline bool GeneratedCodeInfo_Annotation::has_begin() const {
- return _internal_has_begin();
-}
inline void GeneratedCodeInfo_Annotation::clear_begin() {
_impl_.begin_ = 0;
_impl_._has_bits_[0] &= ~0x00000002u;
}
-inline arc_i32 GeneratedCodeInfo_Annotation::_internal_begin() const {
- return _impl_.begin_;
-}
-inline arc_i32 GeneratedCodeInfo_Annotation::begin() const {
+inline ::arc_i32 GeneratedCodeInfo_Annotation::begin() const {
// @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.begin)
return _internal_begin();
}
-inline void GeneratedCodeInfo_Annotation::_internal_set_begin(arc_i32 value) {
- _impl_._has_bits_[0] |= 0x00000002u;
- _impl_.begin_ = value;
-}
-inline void GeneratedCodeInfo_Annotation::set_begin(arc_i32 value) {
+inline void GeneratedCodeInfo_Annotation::set_begin(::arc_i32 value) {
_internal_set_begin(value);
// @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.begin)
}
+inline ::arc_i32 GeneratedCodeInfo_Annotation::_internal_begin() const {
+ return _impl_.begin_;
+}
+inline void GeneratedCodeInfo_Annotation::_internal_set_begin(::arc_i32 value) {
+ _impl_._has_bits_[0] |= 0x00000002u;
+ _impl_.begin_ = value;
+}
// optional int32 end = 4;
-inline bool GeneratedCodeInfo_Annotation::_internal_has_end() const {
+inline bool GeneratedCodeInfo_Annotation::has_end() const {
bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0;
return value;
}
-inline bool GeneratedCodeInfo_Annotation::has_end() const {
- return _internal_has_end();
-}
inline void GeneratedCodeInfo_Annotation::clear_end() {
_impl_.end_ = 0;
_impl_._has_bits_[0] &= ~0x00000004u;
}
-inline arc_i32 GeneratedCodeInfo_Annotation::_internal_end() const {
- return _impl_.end_;
-}
-inline arc_i32 GeneratedCodeInfo_Annotation::end() const {
+inline ::arc_i32 GeneratedCodeInfo_Annotation::end() const {
// @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.end)
return _internal_end();
}
-inline void GeneratedCodeInfo_Annotation::_internal_set_end(arc_i32 value) {
+inline void GeneratedCodeInfo_Annotation::set_end(::arc_i32 value) {
+ _internal_set_end(value);
+ // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.end)
+}
+inline ::arc_i32 GeneratedCodeInfo_Annotation::_internal_end() const {
+ return _impl_.end_;
+}
+inline void GeneratedCodeInfo_Annotation::_internal_set_end(::arc_i32 value) {
_impl_._has_bits_[0] |= 0x00000004u;
_impl_.end_ = value;
}
-inline void GeneratedCodeInfo_Annotation::set_end(arc_i32 value) {
- _internal_set_end(value);
- // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.end)
+
+// optional .google.protobuf.GeneratedCodeInfo.Annotation.Semantic semantic = 5;
+inline bool GeneratedCodeInfo_Annotation::has_semantic() const {
+ bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0;
+ return value;
+}
+inline void GeneratedCodeInfo_Annotation::clear_semantic() {
+ _impl_.semantic_ = 0;
+ _impl_._has_bits_[0] &= ~0x00000008u;
+}
+inline ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation_Semantic GeneratedCodeInfo_Annotation::semantic() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.semantic)
+ return _internal_semantic();
+}
+inline void GeneratedCodeInfo_Annotation::set_semantic(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation_Semantic value) {
+ _internal_set_semantic(value);
+ // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.semantic)
+}
+inline ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation_Semantic GeneratedCodeInfo_Annotation::_internal_semantic() const {
+ return static_cast<::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation_Semantic>(_impl_.semantic_);
+}
+inline void GeneratedCodeInfo_Annotation::_internal_set_semantic(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation_Semantic value) {
+ assert(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation_Semantic_IsValid(value));
+ _impl_._has_bits_[0] |= 0x00000008u;
+ _impl_.semantic_ = value;
}
// -------------------------------------------------------------------
@@ -14721,101 +14486,74 @@ GeneratedCodeInfo::annotation() const {
}
#ifdef __GNUC__
- #pragma GCC diagnostic pop
+#pragma GCC diagnostic pop
#endif // __GNUC__
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
// @@protoc_insertion_point(namespace_scope)
-
PROTOBUF_NAMESPACE_CLOSE
+
PROTOBUF_NAMESPACE_OPEN
-template <> struct is_proto_enum< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type> : ::std::true_type {};
template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type>() {
+struct is_proto_enum<::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type> : std::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor<::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type>() {
return ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type_descriptor();
}
-template <> struct is_proto_enum< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label> : ::std::true_type {};
template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label>() {
+struct is_proto_enum<::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label> : std::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor<::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label>() {
return ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label_descriptor();
}
-template <> struct is_proto_enum< ::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode> : ::std::true_type {};
template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode>() {
+struct is_proto_enum<::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode> : std::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor<::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode>() {
return ::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode_descriptor();
}
-template <> struct is_proto_enum< ::PROTOBUF_NAMESPACE_ID::FieldOptions_CType> : ::std::true_type {};
template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::PROTOBUF_NAMESPACE_ID::FieldOptions_CType>() {
+struct is_proto_enum<::PROTOBUF_NAMESPACE_ID::FieldOptions_CType> : std::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor<::PROTOBUF_NAMESPACE_ID::FieldOptions_CType>() {
return ::PROTOBUF_NAMESPACE_ID::FieldOptions_CType_descriptor();
}
-template <> struct is_proto_enum< ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType> : ::std::true_type {};
template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType>() {
+struct is_proto_enum<::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType> : std::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor<::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType>() {
return ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType_descriptor();
}
-template <> struct is_proto_enum< ::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel> : ::std::true_type {};
template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel>() {
+struct is_proto_enum<::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionRetention> : std::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor<::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionRetention>() {
+ return ::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionRetention_descriptor();
+}
+template <>
+struct is_proto_enum<::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionTargetType> : std::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor<::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionTargetType>() {
+ return ::PROTOBUF_NAMESPACE_ID::FieldOptions_OptionTargetType_descriptor();
+}
+template <>
+struct is_proto_enum<::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel> : std::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor<::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel>() {
return ::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel_descriptor();
}
+template <>
+struct is_proto_enum<::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation_Semantic> : std::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor<::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation_Semantic>() {
+ return ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation_Semantic_descriptor();
+}
PROTOBUF_NAMESPACE_CLOSE
// @@protoc_insertion_point(global_scope)
-#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fdescriptor_2eproto
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fdescriptor_2eproto_2epb_2eh
diff --git a/contrib/libs/protobuf/src/google/protobuf/descriptor.proto b/contrib/libs/protobuf/src/google/protobuf/descriptor.proto
index f8eb216cdcc..3b3867543ce 100644
--- a/contrib/libs/protobuf/src/google/protobuf/descriptor.proto
+++ b/contrib/libs/protobuf/src/google/protobuf/descriptor.proto
@@ -36,7 +36,6 @@
// A valid .proto file can be translated directly to a FileDescriptorProto
// without any other information (e.g. without reading its imports).
-
syntax = "proto2";
package google.protobuf;
@@ -86,8 +85,13 @@ message FileDescriptorProto {
optional SourceCodeInfo source_code_info = 9;
// The syntax of the proto file.
- // The supported values are "proto2" and "proto3".
+ // The supported values are "proto2", "proto3", and "editions".
+ //
+ // If `edition` is present, this value must be "editions".
optional string syntax = 12;
+
+ // The edition of the proto file, which is an opaque string.
+ optional string edition = 13;
}
// Describes a message type.
@@ -129,7 +133,6 @@ message ExtensionRangeOptions {
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
-
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
}
@@ -305,7 +308,6 @@ message MethodDescriptorProto {
optional bool server_streaming = 6 [default = false];
}
-
// ===================================================================
// Options
@@ -346,7 +348,6 @@ message FileOptions {
// domain names.
optional string java_package = 1;
-
// Controls the name of the wrapper Java class generated for the .proto file.
// That class will always contain the .proto file's getDescriptor() method as
// well as any top-level extensions defined in the .proto file.
@@ -373,7 +374,6 @@ message FileOptions {
// This option has no effect on when used with the lite runtime.
optional bool java_string_check_utf8 = 27 [default = false];
-
// Generated classes can be optimized for speed or code size.
enum OptimizeMode {
SPEED = 1; // Generate complete code for parsing, serialization,
@@ -390,9 +390,6 @@ message FileOptions {
// - Otherwise, the basename of the .proto file, without extension.
optional string go_package = 11;
-
-
-
// Should generic services be generated in each language? "Generic" services
// are not specific to any particular RPC system. They are generated by the
// main code generators in each language (without additional plugins).
@@ -418,7 +415,6 @@ message FileOptions {
// only to generated classes for C++.
optional bool cc_enable_arenas = 31 [default = true];
-
// Sets the objective c class prefix which is prepended to all objective c
// generated classes from this .proto. There is no default.
optional string objc_class_prefix = 36;
@@ -451,7 +447,6 @@ message FileOptions {
// determining the ruby package.
optional string ruby_package = 45;
-
// The parser stores options it doesn't recognize here.
// See the documentation for the "Options" section above.
repeated UninterpretedOption uninterpreted_option = 999;
@@ -497,6 +492,10 @@ message MessageOptions {
reserved 4, 5, 6;
+ // NOTE: Do not set the option in .proto files. Always use the maps syntax
+ // instead. The option should only be implicitly set by the proto compiler
+ // parser.
+ //
// Whether the message is an automatically generated map entry type for the
// maps field.
//
@@ -514,15 +513,22 @@ message MessageOptions {
// use a native map in the target language to hold the keys and values.
// The reflection APIs in such implementations still need to work as
// if the field is a repeated message field.
- //
- // NOTE: Do not set the option in .proto files. Always use the maps syntax
- // instead. The option should only be implicitly set by the proto compiler
- // parser.
optional bool map_entry = 7;
reserved 8; // javalite_serializable
reserved 9; // javanano_as_lite
+ // Enable the legacy handling of JSON field name conflicts. This lowercases
+ // and strips underscored from the fields before comparison in proto3 only.
+ // The new behavior takes `json_name` into account and applies to proto2 as
+ // well.
+ //
+ // This should only be used as a temporary measure against broken builds due
+ // to the change in behavior for JSON field name conflicts.
+ //
+ // TODO(b/261750190) This is legacy behavior we plan to remove once downstream
+ // teams have had time to migrate.
+ optional bool deprecated_legacy_json_field_conflicts = 11 [deprecated = true];
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
@@ -592,7 +598,6 @@ message FieldOptions {
// call from multiple threads concurrently, while non-const methods continue
// to require exclusive access.
//
- //
// Note that implementations may choose not to check required fields within
// a lazy sub-message. That is, calling IsInitialized() on the outer message
// may return true even if the inner message has missing required fields.
@@ -604,11 +609,8 @@ message FieldOptions {
// 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.
+ // As of May 2022, lazy verifies the contents of the byte stream during
+ // parsing. An invalid byte stream will cause the overall parsing to fail.
optional bool lazy = 5 [default = false];
// unverified_lazy does no correctness checks on the byte stream. This should
@@ -625,6 +627,39 @@ message FieldOptions {
// For Google-internal migration only. Do not use.
optional bool weak = 10 [default = false];
+ // Indicate that the field value should not be printed out when using debug
+ // formats, e.g. when the field contains sensitive credentials.
+ optional bool debug_redact = 16 [default = false];
+
+ // If set to RETENTION_SOURCE, the option will be omitted from the binary.
+ // Note: as of January 2023, support for this is in progress and does not yet
+ // have an effect (b/264593489).
+ enum OptionRetention {
+ RETENTION_UNKNOWN = 0;
+ RETENTION_RUNTIME = 1;
+ RETENTION_SOURCE = 2;
+ }
+
+ optional OptionRetention retention = 17;
+
+ // This indicates the types of entities that the field may apply to when used
+ // as an option. If it is unset, then the field may be freely used as an
+ // option on any kind of entity. Note: as of January 2023, support for this is
+ // in progress and does not yet have an effect (b/264593489).
+ enum OptionTargetType {
+ TARGET_TYPE_UNKNOWN = 0;
+ TARGET_TYPE_FILE = 1;
+ TARGET_TYPE_EXTENSION_RANGE = 2;
+ TARGET_TYPE_MESSAGE = 3;
+ TARGET_TYPE_FIELD = 4;
+ TARGET_TYPE_ONEOF = 5;
+ TARGET_TYPE_ENUM = 6;
+ TARGET_TYPE_ENUM_ENTRY = 7;
+ TARGET_TYPE_SERVICE = 8;
+ TARGET_TYPE_METHOD = 9;
+ }
+
+ optional OptionTargetType target = 18;
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
@@ -657,6 +692,14 @@ message EnumOptions {
reserved 5; // javanano_as_lite
+ // Enable the legacy handling of JSON field name conflicts. This lowercases
+ // and strips underscored from the fields before comparison in proto3 only.
+ // The new behavior takes `json_name` into account and applies to proto2 as
+ // well.
+ // TODO(b/261750190) Remove this legacy behavior once downstream teams have
+ // had time to migrate.
+ optional bool deprecated_legacy_json_field_conflicts = 6 [deprecated = true];
+
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
@@ -729,7 +772,6 @@ message MethodOptions {
extensions 1000 to max;
}
-
// A message representing a option the parser does not recognize. This only
// appears in options protos created by the compiler::Parser class.
// DescriptorPool resolves these when building Descriptor objects. Therefore,
@@ -914,8 +956,20 @@ message GeneratedCodeInfo {
optional int32 begin = 3;
// Identifies the ending offset in bytes in the generated code that
- // relates to the identified offset. The end offset should be one past
+ // relates to the identified object. The end offset should be one past
// the last relevant byte (so the length of the text = end - begin).
optional int32 end = 4;
+
+ // Represents the identified object's effect on the element in the original
+ // .proto file.
+ enum Semantic {
+ // There is no effect or the effect is indescribable.
+ NONE = 0;
+ // The element is set or otherwise mutated.
+ SET = 1;
+ // An alias to the element is returned.
+ ALIAS = 2;
+ }
+ optional Semantic semantic = 5;
}
}
diff --git a/contrib/libs/protobuf/src/google/protobuf/descriptor_database.cc b/contrib/libs/protobuf/src/google/protobuf/descriptor_database.cc
index e221b3c6c9c..275d8c5524e 100644
--- a/contrib/libs/protobuf/src/google/protobuf/descriptor_database.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/descriptor_database.cc
@@ -32,14 +32,19 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/descriptor_database.h>
+#include "google/protobuf/descriptor_database.h"
#include <algorithm>
-#include <set>
+#include <string>
+#include <utility>
+#include <vector>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/stubs/map_util.h>
-#include <google/protobuf/stubs/stl_util.h>
+#include "y_absl/container/btree_set.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/match.h"
+#include "y_absl/strings/str_replace.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/descriptor.pb.h"
namespace google {
@@ -47,12 +52,12 @@ namespace protobuf {
namespace {
void RecordMessageNames(const DescriptorProto& desc_proto,
- const TProtoStringType& prefix,
- std::set<TProtoStringType>* output) {
- GOOGLE_CHECK(desc_proto.has_name());
+ y_absl::string_view prefix,
+ y_absl::btree_set<TProtoStringType>* output) {
+ Y_ABSL_CHECK(desc_proto.has_name());
TProtoStringType full_name = prefix.empty()
? desc_proto.name()
- : StrCat(prefix, ".", desc_proto.name());
+ : y_absl::StrCat(prefix, ".", desc_proto.name());
output->insert(full_name);
for (const auto& d : desc_proto.nested_type()) {
@@ -61,7 +66,7 @@ void RecordMessageNames(const DescriptorProto& desc_proto,
}
void RecordMessageNames(const FileDescriptorProto& file_proto,
- std::set<TProtoStringType>* output) {
+ y_absl::btree_set<TProtoStringType>* output) {
for (const auto& d : file_proto.message_type()) {
RecordMessageNames(d, file_proto.package(), output);
}
@@ -74,12 +79,12 @@ bool ForAllFileProtos(DescriptorDatabase* db, Fn callback,
if (!db->FindAllFileNames(&file_names)) {
return false;
}
- std::set<TProtoStringType> set;
+ y_absl::btree_set<TProtoStringType> set;
FileDescriptorProto file_proto;
for (const auto& f : file_names) {
file_proto.Clear();
if (!db->FindFileByName(f, &file_proto)) {
- GOOGLE_LOG(ERROR) << "File not found in database (unexpected): " << f;
+ Y_ABSL_LOG(ERROR) << "File not found in database (unexpected): " << f;
return false;
}
callback(file_proto, &set);
@@ -89,12 +94,13 @@ bool ForAllFileProtos(DescriptorDatabase* db, Fn callback,
}
} // namespace
-DescriptorDatabase::~DescriptorDatabase() {}
+DescriptorDatabase::~DescriptorDatabase() = default;
bool DescriptorDatabase::FindAllPackageNames(std::vector<TProtoStringType>* output) {
return ForAllFileProtos(
this,
- [](const FileDescriptorProto& file_proto, std::set<TProtoStringType>* set) {
+ [](const FileDescriptorProto& file_proto,
+ y_absl::btree_set<TProtoStringType>* set) {
set->insert(file_proto.package());
},
output);
@@ -103,7 +109,8 @@ bool DescriptorDatabase::FindAllPackageNames(std::vector<TProtoStringType>* outp
bool DescriptorDatabase::FindAllMessageNames(std::vector<TProtoStringType>* output) {
return ForAllFileProtos(
this,
- [](const FileDescriptorProto& file_proto, std::set<TProtoStringType>* set) {
+ [](const FileDescriptorProto& file_proto,
+ y_absl::btree_set<TProtoStringType>* set) {
RecordMessageNames(file_proto, set);
},
output);
@@ -117,8 +124,8 @@ SimpleDescriptorDatabase::~SimpleDescriptorDatabase() {}
template <typename Value>
bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddFile(
const FileDescriptorProto& file, Value value) {
- if (!InsertIfNotPresent(&by_name_, file.name(), value)) {
- GOOGLE_LOG(ERROR) << "File already exists in database: " << file.name();
+ if (!by_name_.emplace(file.name(), value).second) {
+ Y_ABSL_LOG(ERROR) << "File already exists in database: " << file.name();
return false;
}
@@ -151,7 +158,7 @@ namespace {
// Returns true if and only if all characters in the name are alphanumerics,
// underscores, or periods.
-bool ValidateSymbolName(StringPiece name) {
+bool ValidateSymbolName(y_absl::string_view name) {
for (char c : name) {
// I don't trust ctype.h due to locales. :(
if (c != '.' && c != '_' && (c < '0' || c > '9') && (c < 'A' || c > 'Z') &&
@@ -185,9 +192,9 @@ typename Container::const_iterator FindLastLessOrEqual(
// True if either the arguments are equal or super_symbol identifies a
// parent symbol of sub_symbol (e.g. "foo.bar" is a parent of
// "foo.bar.baz", but not a parent of "foo.barbaz").
-bool IsSubSymbol(StringPiece sub_symbol, StringPiece super_symbol) {
+bool IsSubSymbol(y_absl::string_view sub_symbol, y_absl::string_view super_symbol) {
return sub_symbol == super_symbol ||
- (HasPrefixString(super_symbol, sub_symbol) &&
+ (y_absl::StartsWith(super_symbol, sub_symbol) &&
super_symbol[sub_symbol.size()] == '.');
}
@@ -195,14 +202,14 @@ bool IsSubSymbol(StringPiece sub_symbol, StringPiece super_symbol) {
template <typename Value>
bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol(
- const TProtoStringType& name, Value value) {
+ y_absl::string_view name, Value value) {
// We need to make sure not to violate our map invariant.
// If the symbol name is invalid it could break our lookup algorithm (which
// relies on the fact that '.' sorts before all other characters that are
// valid in symbol names).
if (!ValidateSymbolName(name)) {
- GOOGLE_LOG(ERROR) << "Invalid symbol name: " << name;
+ Y_ABSL_LOG(ERROR) << "Invalid symbol name: " << name;
return false;
}
@@ -212,16 +219,15 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol(
if (iter == by_symbol_.end()) {
// Apparently the map is currently empty. Just insert and be done with it.
- by_symbol_.insert(
- typename std::map<TProtoStringType, Value>::value_type(name, value));
+ by_symbol_.try_emplace(name, value);
return true;
}
if (IsSubSymbol(iter->first, name)) {
- GOOGLE_LOG(ERROR) << "Symbol name \"" << name
- << "\" conflicts with the existing "
- "symbol \""
- << iter->first << "\".";
+ Y_ABSL_LOG(ERROR) << "Symbol name \"" << name
+ << "\" conflicts with the existing "
+ "symbol \""
+ << iter->first << "\".";
return false;
}
@@ -233,10 +239,10 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol(
++iter;
if (iter != by_symbol_.end() && IsSubSymbol(name, iter->first)) {
- GOOGLE_LOG(ERROR) << "Symbol name \"" << name
- << "\" conflicts with the existing "
- "symbol \""
- << iter->first << "\".";
+ Y_ABSL_LOG(ERROR) << "Symbol name \"" << name
+ << "\" conflicts with the existing "
+ "symbol \""
+ << iter->first << "\".";
return false;
}
@@ -244,8 +250,7 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol(
// Insert the new symbol using the iterator as a hint, the new entry will
// appear immediately before the one the iterator is pointing at.
- by_symbol_.insert(
- iter, typename std::map<TProtoStringType, Value>::value_type(name, value));
+ by_symbol_.insert(iter, {TProtoStringType(name), value});
return true;
}
@@ -271,14 +276,16 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddExtension(
if (!field.extendee().empty() && field.extendee()[0] == '.') {
// The extension is fully-qualified. We can use it as a lookup key in
// the by_symbol_ table.
- if (!InsertIfNotPresent(
- &by_extension_,
- std::make_pair(field.extendee().substr(1), field.number()),
- value)) {
- GOOGLE_LOG(ERROR) << "Extension conflicts with extension already in database: "
- "extend "
- << field.extendee() << " { " << field.name() << " = "
- << field.number() << " } from:" << filename;
+ if (!by_extension_
+ .emplace(
+ std::make_pair(field.extendee().substr(1), field.number()),
+ value)
+ .second) {
+ Y_ABSL_LOG(ERROR)
+ << "Extension conflicts with extension already in database: "
+ "extend "
+ << field.extendee() << " { " << field.name() << " = "
+ << field.number() << " } from:" << filename;
return false;
}
} else {
@@ -292,7 +299,9 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddExtension(
template <typename Value>
Value SimpleDescriptorDatabase::DescriptorIndex<Value>::FindFile(
const TProtoStringType& filename) {
- return FindWithDefault(by_name_, filename, Value());
+ auto it = by_name_.find(filename);
+ if (it == by_name_.end()) return {};
+ return it->second;
}
template <typename Value>
@@ -308,15 +317,15 @@ Value SimpleDescriptorDatabase::DescriptorIndex<Value>::FindSymbol(
template <typename Value>
Value SimpleDescriptorDatabase::DescriptorIndex<Value>::FindExtension(
const TProtoStringType& containing_type, int field_number) {
- return FindWithDefault(
- by_extension_, std::make_pair(containing_type, field_number), Value());
+ auto it = by_extension_.find({containing_type, field_number});
+ if (it == by_extension_.end()) return {};
+ return it->second;
}
template <typename Value>
bool SimpleDescriptorDatabase::DescriptorIndex<Value>::FindAllExtensionNumbers(
const TProtoStringType& containing_type, std::vector<int>* output) {
- typename std::map<std::pair<TProtoStringType, int>, Value>::const_iterator it =
- by_extension_.lower_bound(std::make_pair(containing_type, 0));
+ auto it = by_extension_.lower_bound(std::make_pair(containing_type, 0));
bool success = false;
for (; it != by_extension_.end() && it->first.first == containing_type;
@@ -352,6 +361,10 @@ bool SimpleDescriptorDatabase::AddAndOwn(const FileDescriptorProto* file) {
return index_.AddFile(*file, file);
}
+bool SimpleDescriptorDatabase::AddUnowned(const FileDescriptorProto* file) {
+ return index_.AddFile(*file, file);
+}
+
bool SimpleDescriptorDatabase::FindFileByName(const TProtoStringType& filename,
FileDescriptorProto* output) {
return MaybeCopy(index_.FindFile(filename), output);
@@ -397,27 +410,27 @@ class EncodedDescriptorDatabase::DescriptorIndex {
template <typename FileProto>
bool AddFile(const FileProto& file, Value value);
- Value FindFile(StringPiece filename);
- Value FindSymbol(StringPiece name);
- Value FindSymbolOnlyFlat(StringPiece name) const;
- Value FindExtension(StringPiece containing_type, int field_number);
- bool FindAllExtensionNumbers(StringPiece containing_type,
+ Value FindFile(y_absl::string_view filename);
+ Value FindSymbol(y_absl::string_view name);
+ Value FindSymbolOnlyFlat(y_absl::string_view name) const;
+ Value FindExtension(y_absl::string_view containing_type, int field_number);
+ bool FindAllExtensionNumbers(y_absl::string_view containing_type,
std::vector<int>* output);
void FindAllFileNames(std::vector<TProtoStringType>* output) const;
private:
friend class EncodedDescriptorDatabase;
- bool AddSymbol(StringPiece symbol);
+ bool AddSymbol(y_absl::string_view symbol);
template <typename DescProto>
- bool AddNestedExtensions(StringPiece filename,
+ bool AddNestedExtensions(y_absl::string_view filename,
const DescProto& message_type);
template <typename FieldProto>
- bool AddExtension(StringPiece filename, const FieldProto& field);
+ bool AddExtension(y_absl::string_view filename, const FieldProto& field);
// All the maps below have two representations:
- // - a std::set<> where we insert initially.
+ // - a y_absl::btree_set<> where we insert initially.
// - a std::vector<> where we flatten the structure on demand.
// The initial tree helps avoid O(N) behavior of inserting into a sorted
// vector, while the vector reduces the heap requirements of the data
@@ -427,8 +440,8 @@ class EncodedDescriptorDatabase::DescriptorIndex {
using String = TProtoStringType;
- String EncodeString(StringPiece str) const { return String(str); }
- StringPiece DecodeString(const String& str, int) const { return str; }
+ String EncodeString(y_absl::string_view str) const { return String(str); }
+ y_absl::string_view DecodeString(const String& str, int) const { return str; }
struct EncodedEntry {
// Do not use `Value` here to avoid the padding of that object.
@@ -445,7 +458,7 @@ class EncodedDescriptorDatabase::DescriptorIndex {
int data_offset;
String encoded_name;
- StringPiece name(const DescriptorIndex& index) const {
+ y_absl::string_view name(const DescriptorIndex& index) const {
return index.DecodeString(encoded_name, data_offset);
}
};
@@ -455,31 +468,31 @@ class EncodedDescriptorDatabase::DescriptorIndex {
bool operator()(const FileEntry& a, const FileEntry& b) const {
return a.name(index) < b.name(index);
}
- bool operator()(const FileEntry& a, StringPiece b) const {
+ bool operator()(const FileEntry& a, y_absl::string_view b) const {
return a.name(index) < b;
}
- bool operator()(StringPiece a, const FileEntry& b) const {
+ bool operator()(y_absl::string_view a, const FileEntry& b) const {
return a < b.name(index);
}
};
- std::set<FileEntry, FileCompare> by_name_{FileCompare{*this}};
+ y_absl::btree_set<FileEntry, FileCompare> by_name_{FileCompare{*this}};
std::vector<FileEntry> by_name_flat_;
struct SymbolEntry {
int data_offset;
String encoded_symbol;
- StringPiece package(const DescriptorIndex& index) const {
+ y_absl::string_view package(const DescriptorIndex& index) const {
return index.DecodeString(index.all_values_[data_offset].encoded_package,
data_offset);
}
- StringPiece symbol(const DescriptorIndex& index) const {
+ y_absl::string_view symbol(const DescriptorIndex& index) const {
return index.DecodeString(encoded_symbol, data_offset);
}
TProtoStringType AsString(const DescriptorIndex& index) const {
auto p = package(index);
- return StrCat(p, p.empty() ? "" : ".", symbol(index));
+ return y_absl::StrCat(p, p.empty() ? "" : ".", symbol(index));
}
};
@@ -489,16 +502,16 @@ class EncodedDescriptorDatabase::DescriptorIndex {
TProtoStringType AsString(const SymbolEntry& entry) const {
return entry.AsString(index);
}
- static StringPiece AsString(StringPiece str) { return str; }
+ static y_absl::string_view AsString(y_absl::string_view str) { return str; }
- std::pair<StringPiece, StringPiece> GetParts(
+ std::pair<y_absl::string_view, y_absl::string_view> GetParts(
const SymbolEntry& entry) const {
auto package = entry.package(index);
- if (package.empty()) return {entry.symbol(index), StringPiece{}};
+ if (package.empty()) return {entry.symbol(index), y_absl::string_view{}};
return {package, entry.symbol(index)};
}
- std::pair<StringPiece, StringPiece> GetParts(
- StringPiece str) const {
+ std::pair<y_absl::string_view, y_absl::string_view> GetParts(
+ y_absl::string_view str) const {
return {str, {}};
}
@@ -519,13 +532,13 @@ class EncodedDescriptorDatabase::DescriptorIndex {
return AsString(lhs) < AsString(rhs);
}
};
- std::set<SymbolEntry, SymbolCompare> by_symbol_{SymbolCompare{*this}};
+ y_absl::btree_set<SymbolEntry, SymbolCompare> by_symbol_{SymbolCompare{*this}};
std::vector<SymbolEntry> by_symbol_flat_;
struct ExtensionEntry {
int data_offset;
String encoded_extendee;
- StringPiece extendee(const DescriptorIndex& index) const {
+ y_absl::string_view extendee(const DescriptorIndex& index) const {
return index.DecodeString(encoded_extendee, data_offset).substr(1);
}
int extension_number;
@@ -538,15 +551,15 @@ class EncodedDescriptorDatabase::DescriptorIndex {
std::make_tuple(b.extendee(index), b.extension_number);
}
bool operator()(const ExtensionEntry& a,
- std::tuple<StringPiece, int> b) const {
+ std::tuple<y_absl::string_view, int> b) const {
return std::make_tuple(a.extendee(index), a.extension_number) < b;
}
- bool operator()(std::tuple<StringPiece, int> a,
+ bool operator()(std::tuple<y_absl::string_view, int> a,
const ExtensionEntry& b) const {
return a < std::make_tuple(b.extendee(index), b.extension_number);
}
};
- std::set<ExtensionEntry, ExtensionCompare> by_extension_{
+ y_absl::btree_set<ExtensionEntry, ExtensionCompare> by_extension_{
ExtensionCompare{*this}};
std::vector<ExtensionEntry> by_extension_flat_;
};
@@ -557,8 +570,8 @@ bool EncodedDescriptorDatabase::Add(const void* encoded_file_descriptor,
if (file.ParseFromArray(encoded_file_descriptor, size)) {
return index_->AddFile(file, std::make_pair(encoded_file_descriptor, size));
} else {
- GOOGLE_LOG(ERROR) << "Invalid file descriptor data passed to "
- "EncodedDescriptorDatabase::Add().";
+ Y_ABSL_LOG(ERROR) << "Invalid file descriptor data passed to "
+ "EncodedDescriptorDatabase::Add().";
return false;
}
}
@@ -629,17 +642,18 @@ bool EncodedDescriptorDatabase::DescriptorIndex::AddFile(const FileProto& file,
all_values_.push_back({value.first, value.second, {}});
if (!ValidateSymbolName(file.package())) {
- GOOGLE_LOG(ERROR) << "Invalid package name: " << file.package();
+ Y_ABSL_LOG(ERROR) << "Invalid package name: " << file.package();
return false;
}
all_values_.back().encoded_package = EncodeString(file.package());
- if (!InsertIfNotPresent(
- &by_name_, FileEntry{static_cast<int>(all_values_.size() - 1),
- EncodeString(file.name())}) ||
+ if (!by_name_
+ .insert({static_cast<int>(all_values_.size() - 1),
+ EncodeString(file.name())})
+ .second ||
std::binary_search(by_name_flat_.begin(), by_name_flat_.end(),
file.name(), by_name_.key_comp())) {
- GOOGLE_LOG(ERROR) << "File already exists in database: " << file.name();
+ Y_ABSL_LOG(ERROR) << "File already exists in database: " << file.name();
return false;
}
@@ -662,13 +676,13 @@ bool EncodedDescriptorDatabase::DescriptorIndex::AddFile(const FileProto& file,
}
template <typename Iter, typename Iter2, typename Index>
-static bool CheckForMutualSubsymbols(StringPiece symbol_name, Iter* iter,
+static bool CheckForMutualSubsymbols(y_absl::string_view symbol_name, Iter* iter,
Iter2 end, const Index& index) {
if (*iter != end) {
if (IsSubSymbol((*iter)->AsString(index), symbol_name)) {
- GOOGLE_LOG(ERROR) << "Symbol name \"" << symbol_name
- << "\" conflicts with the existing symbol \""
- << (*iter)->AsString(index) << "\".";
+ Y_ABSL_LOG(ERROR) << "Symbol name \"" << symbol_name
+ << "\" conflicts with the existing symbol \""
+ << (*iter)->AsString(index) << "\".";
return false;
}
@@ -680,9 +694,9 @@ static bool CheckForMutualSubsymbols(StringPiece symbol_name, Iter* iter,
++*iter;
if (*iter != end && IsSubSymbol(symbol_name, (*iter)->AsString(index))) {
- GOOGLE_LOG(ERROR) << "Symbol name \"" << symbol_name
- << "\" conflicts with the existing symbol \""
- << (*iter)->AsString(index) << "\".";
+ Y_ABSL_LOG(ERROR) << "Symbol name \"" << symbol_name
+ << "\" conflicts with the existing symbol \""
+ << (*iter)->AsString(index) << "\".";
return false;
}
}
@@ -690,7 +704,7 @@ static bool CheckForMutualSubsymbols(StringPiece symbol_name, Iter* iter,
}
bool EncodedDescriptorDatabase::DescriptorIndex::AddSymbol(
- StringPiece symbol) {
+ y_absl::string_view symbol) {
SymbolEntry entry = {static_cast<int>(all_values_.size() - 1),
EncodeString(symbol)};
TProtoStringType entry_as_string = entry.AsString(*this);
@@ -701,7 +715,7 @@ bool EncodedDescriptorDatabase::DescriptorIndex::AddSymbol(
// relies on the fact that '.' sorts before all other characters that are
// valid in symbol names).
if (!ValidateSymbolName(symbol)) {
- GOOGLE_LOG(ERROR) << "Invalid symbol name: " << entry_as_string;
+ Y_ABSL_LOG(ERROR) << "Invalid symbol name: " << entry_as_string;
return false;
}
@@ -730,7 +744,7 @@ bool EncodedDescriptorDatabase::DescriptorIndex::AddSymbol(
template <typename DescProto>
bool EncodedDescriptorDatabase::DescriptorIndex::AddNestedExtensions(
- StringPiece filename, const DescProto& message_type) {
+ y_absl::string_view filename, const DescProto& message_type) {
for (const auto& nested_type : message_type.nested_type()) {
if (!AddNestedExtensions(filename, nested_type)) return false;
}
@@ -742,22 +756,23 @@ bool EncodedDescriptorDatabase::DescriptorIndex::AddNestedExtensions(
template <typename FieldProto>
bool EncodedDescriptorDatabase::DescriptorIndex::AddExtension(
- StringPiece filename, const FieldProto& field) {
+ y_absl::string_view filename, const FieldProto& field) {
if (!field.extendee().empty() && field.extendee()[0] == '.') {
// The extension is fully-qualified. We can use it as a lookup key in
// the by_symbol_ table.
- if (!InsertIfNotPresent(
- &by_extension_,
- ExtensionEntry{static_cast<int>(all_values_.size() - 1),
- EncodeString(field.extendee()), field.number()}) ||
+ if (!by_extension_
+ .insert({static_cast<int>(all_values_.size() - 1),
+ EncodeString(field.extendee()), field.number()})
+ .second ||
std::binary_search(
by_extension_flat_.begin(), by_extension_flat_.end(),
std::make_pair(field.extendee().substr(1), field.number()),
by_extension_.key_comp())) {
- GOOGLE_LOG(ERROR) << "Extension conflicts with extension already in database: "
- "extend "
- << field.extendee() << " { " << field.name() << " = "
- << field.number() << " } from:" << filename;
+ Y_ABSL_LOG(ERROR)
+ << "Extension conflicts with extension already in database: "
+ "extend "
+ << field.extendee() << " { " << field.name() << " = "
+ << field.number() << " } from:" << filename;
return false;
}
} else {
@@ -769,14 +784,14 @@ bool EncodedDescriptorDatabase::DescriptorIndex::AddExtension(
}
std::pair<const void*, int>
-EncodedDescriptorDatabase::DescriptorIndex::FindSymbol(StringPiece name) {
+EncodedDescriptorDatabase::DescriptorIndex::FindSymbol(y_absl::string_view name) {
EnsureFlat();
return FindSymbolOnlyFlat(name);
}
std::pair<const void*, int>
EncodedDescriptorDatabase::DescriptorIndex::FindSymbolOnlyFlat(
- StringPiece name) const {
+ y_absl::string_view name) const {
auto iter =
FindLastLessOrEqual(&by_symbol_flat_, name, by_symbol_.key_comp());
@@ -788,7 +803,7 @@ EncodedDescriptorDatabase::DescriptorIndex::FindSymbolOnlyFlat(
std::pair<const void*, int>
EncodedDescriptorDatabase::DescriptorIndex::FindExtension(
- StringPiece containing_type, int field_number) {
+ y_absl::string_view containing_type, int field_number) {
EnsureFlat();
auto it = std::lower_bound(
@@ -802,7 +817,7 @@ EncodedDescriptorDatabase::DescriptorIndex::FindExtension(
}
template <typename T, typename Less>
-static void MergeIntoFlat(std::set<T, Less>* s, std::vector<T>* flat) {
+static void MergeIntoFlat(y_absl::btree_set<T, Less>* s, std::vector<T>* flat) {
if (s->empty()) return;
std::vector<T> new_flat(s->size() + flat->size());
std::merge(s->begin(), s->end(), flat->begin(), flat->end(), &new_flat[0],
@@ -820,7 +835,7 @@ void EncodedDescriptorDatabase::DescriptorIndex::EnsureFlat() {
}
bool EncodedDescriptorDatabase::DescriptorIndex::FindAllExtensionNumbers(
- StringPiece containing_type, std::vector<int>* output) {
+ y_absl::string_view containing_type, std::vector<int>* output) {
EnsureFlat();
bool success = false;
@@ -853,7 +868,7 @@ void EncodedDescriptorDatabase::DescriptorIndex::FindAllFileNames(
std::pair<const void*, int>
EncodedDescriptorDatabase::DescriptorIndex::FindFile(
- StringPiece filename) {
+ y_absl::string_view filename) {
EnsureFlat();
auto it = std::lower_bound(by_name_flat_.begin(), by_name_flat_.end(),
@@ -1007,15 +1022,15 @@ bool MergedDescriptorDatabase::FindFileContainingExtension(
bool MergedDescriptorDatabase::FindAllExtensionNumbers(
const TProtoStringType& extendee_type, std::vector<int>* output) {
- std::set<int> merged_results;
+ y_absl::btree_set<int> merged_results;
std::vector<int> results;
bool success = false;
for (DescriptorDatabase* source : sources_) {
if (source->FindAllExtensionNumbers(extendee_type, &results)) {
std::copy(results.begin(), results.end(),
- std::insert_iterator<std::set<int> >(merged_results,
- merged_results.begin()));
+ std::insert_iterator<y_absl::btree_set<int> >(
+ merged_results, merged_results.begin()));
success = true;
}
results.clear();
diff --git a/contrib/libs/protobuf/src/google/protobuf/descriptor_database.h b/contrib/libs/protobuf/src/google/protobuf/descriptor_database.h
index a1ff1cc63ff..04164087810 100644
--- a/contrib/libs/protobuf/src/google/protobuf/descriptor_database.h
+++ b/contrib/libs/protobuf/src/google/protobuf/descriptor_database.h
@@ -37,17 +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>
+#include "y_absl/container/btree_map.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/port.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
#ifdef SWIG
#error "You cannot SWIG proto headers"
@@ -74,6 +73,8 @@ class MergedDescriptorDatabase;
class PROTOBUF_EXPORT DescriptorDatabase {
public:
inline DescriptorDatabase() {}
+ DescriptorDatabase(const DescriptorDatabase&) = delete;
+ DescriptorDatabase& operator=(const DescriptorDatabase&) = delete;
virtual ~DescriptorDatabase();
// Find a file by file name. Fills in in *output and returns true if found.
@@ -136,9 +137,6 @@ class PROTOBUF_EXPORT DescriptorDatabase {
// searching all message names, otherwise returns false and leaves output
// unchanged.
bool FindAllMessageNames(std::vector<TProtoStringType>* output);
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DescriptorDatabase);
};
// A DescriptorDatabase into which you can insert files manually.
@@ -165,17 +163,23 @@ class PROTOBUF_EXPORT DescriptorDatabase {
class PROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
public:
SimpleDescriptorDatabase();
+ SimpleDescriptorDatabase(const SimpleDescriptorDatabase&) = delete;
+ SimpleDescriptorDatabase& operator=(const SimpleDescriptorDatabase&) = delete;
~SimpleDescriptorDatabase() override;
// Adds the FileDescriptorProto to the database, making a copy. The object
// can be deleted after Add() returns. Returns false if the file conflicted
// with a file already in the database, in which case an error will have
- // been written to GOOGLE_LOG(ERROR).
+ // been written to Y_ABSL_LOG(ERROR).
bool Add(const FileDescriptorProto& file);
// Adds the FileDescriptorProto to the database and takes ownership of it.
bool AddAndOwn(const FileDescriptorProto* file);
+ // Adds the FileDescriptorProto to the database and not take ownership of it.
+ // The owner must ensure file outlives the SimpleDescriptorDatabase.
+ bool AddUnowned(const FileDescriptorProto* file);
+
// implements DescriptorDatabase -----------------------------------
bool FindFileByName(const TProtoStringType& filename,
FileDescriptorProto* output) override;
@@ -198,7 +202,7 @@ class PROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
// Helpers to recursively add particular descriptors and all their contents
// to the index.
bool AddFile(const FileDescriptorProto& file, Value value);
- bool AddSymbol(const TProtoStringType& name, Value value);
+ bool AddSymbol(y_absl::string_view name, Value value);
bool AddNestedExtensions(const TProtoStringType& filename,
const DescriptorProto& message_type, Value value);
bool AddExtension(const TProtoStringType& filename,
@@ -212,9 +216,9 @@ class PROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
void FindAllFileNames(std::vector<TProtoStringType>* output);
private:
- std::map<TProtoStringType, Value> by_name_;
- std::map<TProtoStringType, Value> by_symbol_;
- std::map<std::pair<TProtoStringType, int>, Value> by_extension_;
+ y_absl::btree_map<TProtoStringType, Value> by_name_;
+ y_absl::btree_map<TProtoStringType, Value> by_symbol_;
+ y_absl::btree_map<std::pair<TProtoStringType, int>, Value> by_extension_;
// Invariant: The by_symbol_ map does not contain any symbols which are
// prefixes of other symbols in the map. For example, "foo.bar" is a
@@ -274,8 +278,6 @@ class PROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
// If file is non-nullptr, copy it into *output and return true, otherwise
// return false.
bool MaybeCopy(const FileDescriptorProto* file, FileDescriptorProto* output);
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SimpleDescriptorDatabase);
};
// Very similar to SimpleDescriptorDatabase, but stores all the descriptors
@@ -286,6 +288,9 @@ class PROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
class PROTOBUF_EXPORT EncodedDescriptorDatabase : public DescriptorDatabase {
public:
EncodedDescriptorDatabase();
+ EncodedDescriptorDatabase(const EncodedDescriptorDatabase&) = delete;
+ EncodedDescriptorDatabase& operator=(const EncodedDescriptorDatabase&) =
+ delete;
~EncodedDescriptorDatabase() override;
// Adds the FileDescriptorProto to the database. The descriptor is provided
@@ -327,14 +332,14 @@ class PROTOBUF_EXPORT EncodedDescriptorDatabase : public DescriptorDatabase {
// return true, otherwise return false.
bool MaybeParse(std::pair<const void*, int> encoded_file,
FileDescriptorProto* output);
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EncodedDescriptorDatabase);
};
// A DescriptorDatabase that fetches files from a given pool.
class PROTOBUF_EXPORT DescriptorPoolDatabase : public DescriptorDatabase {
public:
explicit DescriptorPoolDatabase(const DescriptorPool& pool);
+ DescriptorPoolDatabase(const DescriptorPoolDatabase&) = delete;
+ DescriptorPoolDatabase& operator=(const DescriptorPoolDatabase&) = delete;
~DescriptorPoolDatabase() override;
// implements DescriptorDatabase -----------------------------------
@@ -350,7 +355,6 @@ class PROTOBUF_EXPORT DescriptorPoolDatabase : public DescriptorDatabase {
private:
const DescriptorPool& pool_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DescriptorPoolDatabase);
};
// A DescriptorDatabase that wraps two or more others. It first searches the
@@ -365,6 +369,8 @@ class PROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase {
// DescriptorDatabases need to stick around.
explicit MergedDescriptorDatabase(
const std::vector<DescriptorDatabase*>& sources);
+ MergedDescriptorDatabase(const MergedDescriptorDatabase&) = delete;
+ MergedDescriptorDatabase& operator=(const MergedDescriptorDatabase&) = delete;
~MergedDescriptorDatabase() override;
// implements DescriptorDatabase -----------------------------------
@@ -387,12 +393,11 @@ class PROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase {
private:
std::vector<DescriptorDatabase*> sources_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MergedDescriptorDatabase);
};
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_DESCRIPTOR_DATABASE_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/duration.pb.cc b/contrib/libs/protobuf/src/google/protobuf/duration.pb.cc
index f1c91ffcdae..f94274813e9 100644
--- a/contrib/libs/protobuf/src/google/protobuf/duration.pb.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/duration.pb.cc
@@ -1,122 +1,139 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/duration.proto
-#include <google/protobuf/duration.pb.h>
+#include "google/protobuf/duration.pb.h"
#include <algorithm>
-
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/extension_set.h>
-#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/reflection_ops.h>
-#include <google/protobuf/wire_format.h>
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/extension_set.h"
+#include "google/protobuf/wire_format_lite.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/reflection_ops.h"
+#include "google/protobuf/wire_format.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+// Must be included last.
+#include "google/protobuf/port_def.inc"
PROTOBUF_PRAGMA_INIT_SEG
-
namespace _pb = ::PROTOBUF_NAMESPACE_ID;
-namespace _pbi = _pb::internal;
-
+namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal;
PROTOBUF_NAMESPACE_OPEN
PROTOBUF_CONSTEXPR Duration::Duration(
::_pbi::ConstantInitialized): _impl_{
- /*decltype(_impl_.seconds_)*/arc_i64{0}
- , /*decltype(_impl_.nanos_)*/0
+ /*decltype(_impl_.seconds_)*/ ::arc_i64{0}
+
+ , /*decltype(_impl_.nanos_)*/ 0
+
, /*decltype(_impl_._cached_size_)*/{}} {}
struct DurationDefaultTypeInternal {
- PROTOBUF_CONSTEXPR DurationDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR DurationDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~DurationDefaultTypeInternal() {}
union {
Duration _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DurationDefaultTypeInternal _Duration_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DurationDefaultTypeInternal _Duration_default_instance_;
PROTOBUF_NAMESPACE_CLOSE
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_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Duration, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Duration, _impl_.seconds_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Duration, _impl_.nanos_),
+static constexpr const ::_pb::EnumDescriptor**
+ file_level_enum_descriptors_google_2fprotobuf_2fduration_2eproto = nullptr;
+static constexpr const ::_pb::ServiceDescriptor**
+ 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_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Duration, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Duration, _impl_.seconds_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Duration, _impl_.nanos_),
};
-static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
- { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Duration)},
+
+static const ::_pbi::MigrationSchema
+ schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Duration)},
};
static const ::_pb::Message* const file_default_instances[] = {
- &::PROTOBUF_NAMESPACE_ID::_Duration_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_Duration_default_instance_._instance,
};
-
-const char descriptor_table_protodef_google_2fprotobuf_2fduration_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
- "\n\036google/protobuf/duration.proto\022\017google"
- ".protobuf\"*\n\010Duration\022\017\n\007seconds\030\001 \001(\003\022\r"
- "\n\005nanos\030\002 \001(\005B\203\001\n\023com.google.protobufB\rD"
- "urationProtoP\001Z1google.golang.org/protob"
- "uf/types/known/durationpb\370\001\001\242\002\003GPB\252\002\036Goo"
- "gle.Protobuf.WellKnownTypesb\006proto3"
- ;
-static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fduration_2eproto_once;
+const char descriptor_table_protodef_google_2fprotobuf_2fduration_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ "\n\036google/protobuf/duration.proto\022\017google"
+ ".protobuf\"*\n\010Duration\022\017\n\007seconds\030\001 \001(\003\022\r"
+ "\n\005nanos\030\002 \001(\005B\203\001\n\023com.google.protobufB\rD"
+ "urationProtoP\001Z1google.golang.org/protob"
+ "uf/types/known/durationpb\370\001\001\242\002\003GPB\252\002\036Goo"
+ "gle.Protobuf.WellKnownTypesb\006proto3"
+};
+static ::y_absl::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,
+ 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,
+ &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,
};
+
+// This function exists to be marked as weak.
+// It can significantly speed up compilation by breaking up LLVM's SCC
+// in the .pb.cc translation units. Large translation units see a
+// reduction of more than 35% of walltime for optimized builds. Without
+// the weak attribute all the messages in the file, including all the
+// vtables and everything they use become part of the same SCC through
+// a cycle like:
+// GetMetadata -> descriptor table -> default instances ->
+// 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 ::_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_PRIORITY2 static ::_pbi::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
-
// ===================================================================
class Duration::_Internal {
public:
};
-Duration::Duration(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+Duration::Duration(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Duration)
}
Duration::Duration(const Duration& from)
- : ::PROTOBUF_NAMESPACE_ID::Message() {
- Duration* const _this = this; (void)_this;
- new (&_impl_) Impl_{
- decltype(_impl_.seconds_){}
- , decltype(_impl_.nanos_){}
- , /*decltype(_impl_._cached_size_)*/{}};
-
- _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- ::memcpy(&_impl_.seconds_, &from._impl_.seconds_,
- static_cast<size_t>(reinterpret_cast<char*>(&_impl_.nanos_) -
- reinterpret_cast<char*>(&_impl_.seconds_)) + sizeof(_impl_.nanos_));
+ : ::PROTOBUF_NAMESPACE_ID::Message(), _impl_(from._impl_) {
+ _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(
+ from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:google.protobuf.Duration)
}
-inline void Duration::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void Duration::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
- decltype(_impl_.seconds_){arc_i64{0}}
- , decltype(_impl_.nanos_){0}
+ decltype(_impl_.seconds_) { ::arc_i64{0} }
+
+ , decltype(_impl_.nanos_) { 0 }
+
, /*decltype(_impl_._cached_size_)*/{}
};
}
@@ -131,7 +148,7 @@ Duration::~Duration() {
}
inline void Duration::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
}
void Duration::SetCachedSize(int size) const {
@@ -140,11 +157,11 @@ void Duration::SetCachedSize(int size) const {
void Duration::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Duration)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
- ::memset(&_impl_.seconds_, 0, static_cast<size_t>(
+ ::memset(&_impl_.seconds_, 0, static_cast<::size_t>(
reinterpret_cast<char*>(&_impl_.nanos_) -
reinterpret_cast<char*>(&_impl_.seconds_)) + sizeof(_impl_.nanos_));
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
@@ -153,24 +170,26 @@ void Duration::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// int64 seconds = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) {
_impl_.seconds_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// int32 nanos = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 16)) {
_impl_.nanos_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -195,22 +214,24 @@ failure:
#undef CHK_
}
-uint8_t* Duration::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* Duration::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Duration)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// int64 seconds = 1;
if (this->_internal_seconds() != 0) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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 = ::_pbi::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())) {
@@ -221,22 +242,24 @@ uint8_t* Duration::_InternalSerialize(
return target;
}
-size_t Duration::ByteSizeLong() const {
+::size_t Duration::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Duration)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// int64 seconds = 1;
if (this->_internal_seconds() != 0) {
- total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_seconds());
+ total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(
+ this->_internal_seconds());
}
// int32 nanos = 2;
if (this->_internal_nanos() != 0) {
- total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_nanos());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(
+ this->_internal_nanos());
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -253,8 +276,8 @@ void Duration::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTO
auto* const _this = static_cast<Duration*>(&to_msg);
auto& from = static_cast<const Duration&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Duration)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
if (from._internal_seconds() != 0) {
@@ -293,7 +316,6 @@ void Duration::InternalSwap(Duration* other) {
&descriptor_table_google_2fprotobuf_2fduration_2eproto_getter, &descriptor_table_google_2fprotobuf_2fduration_2eproto_once,
file_level_metadata_google_2fprotobuf_2fduration_2eproto[0]);
}
-
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
@@ -302,6 +324,5 @@ Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Duration >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Duration >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
-
// @@protoc_insertion_point(global_scope)
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protobuf/src/google/protobuf/duration.pb.h b/contrib/libs/protobuf/src/google/protobuf/duration.pb.h
index fd1709ea6e9..ea7cf5dd0e4 100644
--- a/contrib/libs/protobuf/src/google/protobuf/duration.pb.h
+++ b/contrib/libs/protobuf/src/google/protobuf/duration.pb.h
@@ -1,38 +1,43 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/duration.proto
-#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fduration_2eproto
-#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fduration_2eproto
+#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fduration_2eproto_2epb_2eh
+#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fduration_2eproto_2epb_2eh
#include <limits>
#include <string>
-
-#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3021000
-#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 3021003 < 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.
-#endif
-
-#include <google/protobuf/port_undef.inc>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/arena.h>
-#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_util.h>
-#include <google/protobuf/metadata_lite.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h> // IWYU pragma: export
-#include <google/protobuf/extension_set.h> // IWYU pragma: export
-#include <google/protobuf/unknown_field_set.h>
+#include <type_traits>
+
+#include "google/protobuf/port_def.inc"
+#if PROTOBUF_VERSION < 4022000
+#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 // PROTOBUF_VERSION
+
+#if 4022005 < 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."
+#endif // PROTOBUF_MIN_PROTOC_VERSION
+#include "google/protobuf/port_undef.inc"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/arena.h"
+#include "google/protobuf/arenastring.h"
+#include "google/protobuf/generated_message_util.h"
+#include "google/protobuf/metadata_lite.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/repeated_field.h" // IWYU pragma: export
+#include "google/protobuf/extension_set.h" // IWYU pragma: export
+#include "google/protobuf/unknown_field_set.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fduration_2eproto PROTOBUF_EXPORT
+
PROTOBUF_NAMESPACE_OPEN
namespace internal {
class AnyMetadata;
@@ -41,21 +46,25 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fduration_2eproto {
- static const arc_ui32 offsets[];
+ static const ::arc_ui32 offsets[];
};
-PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fduration_2eproto;
+PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable
+ descriptor_table_google_2fprotobuf_2fduration_2eproto;
PROTOBUF_NAMESPACE_OPEN
class Duration;
struct DurationDefaultTypeInternal;
PROTOBUF_EXPORT extern DurationDefaultTypeInternal _Duration_default_instance_;
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Duration* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Duration>(Arena*);
PROTOBUF_NAMESPACE_CLOSE
-PROTOBUF_NAMESPACE_OPEN
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Duration* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Duration>(Arena*);
-PROTOBUF_NAMESPACE_CLOSE
+
PROTOBUF_NAMESPACE_OPEN
// ===================================================================
+
+// -------------------------------------------------------------------
+
class PROTOBUF_EXPORT Duration final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Duration) */ {
public:
@@ -124,7 +133,7 @@ class PROTOBUF_EXPORT Duration final :
}
void UnsafeArenaSwap(Duration* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -145,26 +154,25 @@ class PROTOBUF_EXPORT Duration final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(Duration* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.Duration";
}
protected:
- explicit Duration(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit Duration(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -181,23 +189,25 @@ class PROTOBUF_EXPORT Duration final :
kNanosFieldNumber = 2,
};
// int64 seconds = 1;
- void clear_seconds();
- arc_i64 seconds() const;
- void set_seconds(arc_i64 value);
+ void clear_seconds() ;
+ ::arc_i64 seconds() const;
+ void set_seconds(::arc_i64 value);
+
private:
- arc_i64 _internal_seconds() const;
- void _internal_set_seconds(arc_i64 value);
- public:
+ ::arc_i64 _internal_seconds() const;
+ void _internal_set_seconds(::arc_i64 value);
+ public:
// int32 nanos = 2;
- void clear_nanos();
- arc_i32 nanos() const;
- void set_nanos(arc_i32 value);
+ void clear_nanos() ;
+ ::arc_i32 nanos() const;
+ void set_nanos(::arc_i32 value);
+
private:
- arc_i32 _internal_nanos() const;
- void _internal_set_nanos(arc_i32 value);
- public:
+ ::arc_i32 _internal_nanos() const;
+ void _internal_set_nanos(::arc_i32 value);
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.Duration)
private:
class _Internal;
@@ -206,73 +216,80 @@ class PROTOBUF_EXPORT Duration final :
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
struct Impl_ {
- arc_i64 seconds_;
- arc_i32 nanos_;
+ ::arc_i64 seconds_;
+ ::arc_i32 nanos_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fduration_2eproto;
};
+
// ===================================================================
+
+
// ===================================================================
+
#ifdef __GNUC__
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
+// -------------------------------------------------------------------
+
// Duration
// int64 seconds = 1;
inline void Duration::clear_seconds() {
- _impl_.seconds_ = arc_i64{0};
+ _impl_.seconds_ = ::arc_i64{0};
}
-inline arc_i64 Duration::_internal_seconds() const {
- return _impl_.seconds_;
-}
-inline arc_i64 Duration::seconds() const {
+inline ::arc_i64 Duration::seconds() const {
// @@protoc_insertion_point(field_get:google.protobuf.Duration.seconds)
return _internal_seconds();
}
-inline void Duration::_internal_set_seconds(arc_i64 value) {
-
- _impl_.seconds_ = value;
-}
-inline void Duration::set_seconds(arc_i64 value) {
+inline void Duration::set_seconds(::arc_i64 value) {
_internal_set_seconds(value);
// @@protoc_insertion_point(field_set:google.protobuf.Duration.seconds)
}
+inline ::arc_i64 Duration::_internal_seconds() const {
+ return _impl_.seconds_;
+}
+inline void Duration::_internal_set_seconds(::arc_i64 value) {
+ ;
+ _impl_.seconds_ = value;
+}
// int32 nanos = 2;
inline void Duration::clear_nanos() {
_impl_.nanos_ = 0;
}
-inline arc_i32 Duration::_internal_nanos() const {
- return _impl_.nanos_;
-}
-inline arc_i32 Duration::nanos() const {
+inline ::arc_i32 Duration::nanos() const {
// @@protoc_insertion_point(field_get:google.protobuf.Duration.nanos)
return _internal_nanos();
}
-inline void Duration::_internal_set_nanos(arc_i32 value) {
-
- _impl_.nanos_ = value;
-}
-inline void Duration::set_nanos(arc_i32 value) {
+inline void Duration::set_nanos(::arc_i32 value) {
_internal_set_nanos(value);
// @@protoc_insertion_point(field_set:google.protobuf.Duration.nanos)
}
+inline ::arc_i32 Duration::_internal_nanos() const {
+ return _impl_.nanos_;
+}
+inline void Duration::_internal_set_nanos(::arc_i32 value) {
+ ;
+ _impl_.nanos_ = value;
+}
#ifdef __GNUC__
- #pragma GCC diagnostic pop
+#pragma GCC diagnostic pop
#endif // __GNUC__
// @@protoc_insertion_point(namespace_scope)
-
PROTOBUF_NAMESPACE_CLOSE
+
// @@protoc_insertion_point(global_scope)
-#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fduration_2eproto
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fduration_2eproto_2epb_2eh
diff --git a/contrib/libs/protobuf/src/google/protobuf/duration.proto b/contrib/libs/protobuf/src/google/protobuf/duration.proto
index 81c3e369fd1..41f40c22247 100644
--- a/contrib/libs/protobuf/src/google/protobuf/duration.proto
+++ b/contrib/libs/protobuf/src/google/protobuf/duration.proto
@@ -32,13 +32,13 @@ syntax = "proto3";
package google.protobuf;
-option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option cc_enable_arenas = true;
option go_package = "google.golang.org/protobuf/types/known/durationpb";
option java_package = "com.google.protobuf";
option java_outer_classname = "DurationProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
+option csharp_namespace = "Google.Protobuf.WellKnownTypes";
// A Duration represents a signed, fixed-length span of time represented
// as a count of seconds and fractions of seconds at nanosecond
@@ -99,7 +99,6 @@ option objc_class_prefix = "GPB";
// be expressed in JSON format as "3.000000001s", and 3 seconds and 1
// microsecond should be expressed in JSON format as "3.000001s".
//
-//
message Duration {
// Signed seconds of the span of time. Must be from -315,576,000,000
// to +315,576,000,000 inclusive. Note: these bounds are computed from:
diff --git a/contrib/libs/protobuf/src/google/protobuf/dynamic_message.cc b/contrib/libs/protobuf/src/google/protobuf/dynamic_message.cc
index 0a0f758df20..f87c14d8d7e 100644
--- a/contrib/libs/protobuf/src/google/protobuf/dynamic_message.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/dynamic_message.cc
@@ -62,31 +62,30 @@
// Item 8 of "More Effective C++" discusses this in more detail, though
// I don't have the book on me right now so I'm not sure.
-#include <google/protobuf/dynamic_message.h>
+#include "google/protobuf/dynamic_message.h"
#include <algorithm>
#include <cstddef>
#include <memory>
#include <new>
-#include <unordered_map>
-
-#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>
-#include <google/protobuf/stubs/hash.h>
-#include <google/protobuf/arenastring.h>
-#include <google/protobuf/extension_set.h>
-#include <google/protobuf/map_field.h>
-#include <google/protobuf/map_field_inl.h>
-#include <google/protobuf/map_type_handler.h>
-#include <google/protobuf/reflection_ops.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/wire_format.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"
+#include "google/protobuf/arenastring.h"
+#include "google/protobuf/extension_set.h"
+#include "google/protobuf/map_field.h"
+#include "google/protobuf/map_field_inl.h"
+#include "google/protobuf/map_type_handler.h"
+#include "google/protobuf/reflection_ops.h"
+#include "google/protobuf/repeated_field.h"
+#include "google/protobuf/wire_format.h"
+
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -105,22 +104,6 @@ namespace {
bool IsMapFieldInApi(const FieldDescriptor* field) { return field->is_map(); }
-// Sync with helpers.h.
-inline bool HasHasbit(const FieldDescriptor* field) {
- // This predicate includes proto3 message fields only if they have "optional".
- // Foo submsg1 = 1; // HasHasbit() == false
- // optional Foo submsg2 = 2; // HasHasbit() == true
- // This is slightly odd, as adding "optional" to a singular proto3 field does
- // not change the semantics or API. However whenever any field in a message
- // has a hasbit, it forces reflection to include hasbit offsets for *all*
- // fields, even if almost all of them are set to -1 (no hasbit). So to avoid
- // causing a sudden size regression for ~all proto3 messages, we give proto3
- // message fields a hasbit only if "optional" is present. If the user is
- // explicitly writing "optional", it is likely they are writing it on
- // primitive fields also.
- return (field->has_optional_keyword() || field->is_required()) &&
- !field->options().weak();
-}
inline bool InRealOneof(const FieldDescriptor* field) {
return field->containing_oneof() &&
@@ -195,7 +178,7 @@ int FieldSpaceUsed(const FieldDescriptor* field) {
}
}
- GOOGLE_LOG(DFATAL) << "Can't get here.";
+ Y_ABSL_DLOG(FATAL) << "Can't get here.";
return 0;
}
@@ -224,6 +207,8 @@ class DynamicMessage : public Message {
// This should only be used by GetPrototypeNoLock() to avoid dead lock.
DynamicMessage(DynamicMessageFactory::TypeInfo* type_info, bool lock_factory);
+ DynamicMessage(const DynamicMessage&) = delete;
+ DynamicMessage& operator=(const DynamicMessage&) = delete;
~DynamicMessage() override;
@@ -285,7 +270,6 @@ class DynamicMessage : public Message {
const DynamicMessageFactory::TypeInfo* type_info_;
mutable std::atomic<int> cached_byte_size_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessage);
};
struct DynamicMessageFactory::TypeInfo {
@@ -313,7 +297,21 @@ struct DynamicMessageFactory::TypeInfo {
TypeInfo() : prototype(nullptr) {}
- ~TypeInfo() { delete prototype; }
+ ~TypeInfo() {
+ delete prototype;
+
+ // Scribble the payload to prevent unsanitized opt builds from silently
+ // allowing use-after-free bugs where the factory is destroyed but the
+ // DynamicMessage instances are still used.
+ // This is a common bug with DynamicMessageFactory.
+ // NOTE: This must happen after deleting the prototype.
+ if (offsets != nullptr) {
+ std::fill_n(offsets.get(), type->field_count(), 0xCDCDCDCDu);
+ }
+ if (has_bits_indices != nullptr) {
+ std::fill_n(has_bits_indices.get(), type->field_count(), 0xCDCDCDCDu);
+ }
+ }
};
DynamicMessage::DynamicMessage(const DynamicMessageFactory::TypeInfo* type_info)
@@ -589,7 +587,7 @@ DynamicMessage::~DynamicMessage() {
void DynamicMessage::CrossLinkPrototypes() {
// This should only be called on the prototype message.
- GOOGLE_CHECK(is_prototype());
+ Y_ABSL_CHECK(is_prototype());
DynamicMessageFactory* factory = type_info_->factory;
const Descriptor* descriptor = type_info_->type;
@@ -653,7 +651,7 @@ DynamicMessageFactory::~DynamicMessageFactory() {
}
const Message* DynamicMessageFactory::GetPrototype(const Descriptor* type) {
- MutexLock lock(&prototypes_mutex_);
+ y_absl::MutexLock lock(&prototypes_mutex_);
return GetPrototypeNoLock(type);
}
@@ -705,7 +703,7 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock(
type_info->has_bits_offset = -1;
int max_hasbit = 0;
for (int i = 0; i < type->field_count(); i++) {
- if (HasHasbit(type->field(i))) {
+ if (internal::cpp::HasHasbit(type->field(i))) {
if (type_info->has_bits_offset == -1) {
// At least one field in the message requires a hasbit, so allocate
// hasbits.
@@ -808,8 +806,11 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock(
type_info->oneof_case_offset,
type_info->size,
type_info->weak_field_map_offset,
- nullptr /* inlined_string_indices_ */,
- 0 /* inlined_string_donated_offset_ */};
+ nullptr, // inlined_string_indices_
+ 0, // inlined_string_donated_offset_
+ -1, // split_offset_
+ -1, // sizeof_split_
+ };
type_info->reflection.reset(
new Reflection(type_info->type, schema, type_info->pool, this));
@@ -823,4 +824,4 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock(
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc> // NOLINT
+#include "google/protobuf/port_undef.inc" // NOLINT
diff --git a/contrib/libs/protobuf/src/google/protobuf/dynamic_message.h b/contrib/libs/protobuf/src/google/protobuf/dynamic_message.h
index 8de36810123..7b067c326c8 100644
--- a/contrib/libs/protobuf/src/google/protobuf/dynamic_message.h
+++ b/contrib/libs/protobuf/src/google/protobuf/dynamic_message.h
@@ -38,24 +38,23 @@
#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/stubs/mutex.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/reflection.h>
-#include <google/protobuf/repeated_field.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/synchronization/mutex.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/port.h"
+#include "google/protobuf/reflection.h"
+#include "google/protobuf/repeated_field.h"
#ifdef SWIG
#error "You cannot SWIG proto headers"
#endif
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -81,6 +80,9 @@ class DescriptorPool; // descriptor.h
// encapsulates this "cache". All DynamicMessages of the same type created
// from the same factory will share the same support data. Any Descriptors
// used with a particular factory must outlive the factory.
+//
+// The thread safety for this class is subtle, see comments around GetPrototype
+// for details
class PROTOBUF_EXPORT DynamicMessageFactory : public MessageFactory {
public:
// Construct a DynamicMessageFactory that will search for extensions in
@@ -95,6 +97,8 @@ class PROTOBUF_EXPORT DynamicMessageFactory : public MessageFactory {
// this is almost never what you want to do. Almost all users should use
// the zero-arg constructor.
DynamicMessageFactory(const DescriptorPool* pool);
+ DynamicMessageFactory(const DynamicMessageFactory&) = delete;
+ DynamicMessageFactory& operator=(const DynamicMessageFactory&) = delete;
~DynamicMessageFactory() override;
@@ -132,13 +136,11 @@ class PROTOBUF_EXPORT DynamicMessageFactory : public MessageFactory {
bool delegate_to_generated_factory_;
struct TypeInfo;
- std::unordered_map<const Descriptor*, const TypeInfo*> prototypes_;
- mutable internal::WrappedMutex prototypes_mutex_;
+ y_absl::flat_hash_map<const Descriptor*, const TypeInfo*> prototypes_;
+ mutable y_absl::Mutex prototypes_mutex_;
friend class DynamicMessage;
const Message* GetPrototypeNoLock(const Descriptor* type);
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessageFactory);
};
// Helper for computing a sorted list of map entries via reflection.
@@ -160,9 +162,9 @@ class PROTOBUF_EXPORT DynamicMapSorter {
#ifndef NDEBUG
for (size_t j = 1; j < static_cast<size_t>(map_size); j++) {
if (!comparator(result[j - 1], result[j])) {
- GOOGLE_LOG(ERROR) << (comparator(result[j], result[j - 1])
- ? "internal error in map key sorting"
- : "map keys are not unique");
+ Y_ABSL_LOG(ERROR) << (comparator(result[j], result[j - 1])
+ ? "internal error in map key sorting"
+ : "map keys are not unique");
}
}
#endif
@@ -209,7 +211,7 @@ class PROTOBUF_EXPORT DynamicMapSorter {
return first < second;
}
default:
- GOOGLE_LOG(DFATAL) << "Invalid key for map field.";
+ Y_ABSL_DLOG(FATAL) << "Invalid key for map field.";
return true;
}
}
@@ -222,6 +224,6 @@ class PROTOBUF_EXPORT DynamicMapSorter {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/empty.pb.cc b/contrib/libs/protobuf/src/google/protobuf/empty.pb.cc
index c1848155e14..29bd70d45a4 100644
--- a/contrib/libs/protobuf/src/google/protobuf/empty.pb.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/empty.pb.cc
@@ -1,91 +1,114 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/empty.proto
-#include <google/protobuf/empty.pb.h>
+#include "google/protobuf/empty.pb.h"
#include <algorithm>
-
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/extension_set.h>
-#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/reflection_ops.h>
-#include <google/protobuf/wire_format.h>
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/extension_set.h"
+#include "google/protobuf/wire_format_lite.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/reflection_ops.h"
+#include "google/protobuf/wire_format.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+// Must be included last.
+#include "google/protobuf/port_def.inc"
PROTOBUF_PRAGMA_INIT_SEG
-
namespace _pb = ::PROTOBUF_NAMESPACE_ID;
-namespace _pbi = _pb::internal;
-
+namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal;
PROTOBUF_NAMESPACE_OPEN
PROTOBUF_CONSTEXPR Empty::Empty(
::_pbi::ConstantInitialized) {}
struct EmptyDefaultTypeInternal {
- PROTOBUF_CONSTEXPR EmptyDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR EmptyDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~EmptyDefaultTypeInternal() {}
union {
Empty _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EmptyDefaultTypeInternal _Empty_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EmptyDefaultTypeInternal _Empty_default_instance_;
PROTOBUF_NAMESPACE_CLOSE
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_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Empty, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
+static constexpr const ::_pb::EnumDescriptor**
+ file_level_enum_descriptors_google_2fprotobuf_2fempty_2eproto = nullptr;
+static constexpr const ::_pb::ServiceDescriptor**
+ 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_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Empty, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
};
-static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
- { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Empty)},
+
+static const ::_pbi::MigrationSchema
+ schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Empty)},
};
static const ::_pb::Message* const file_default_instances[] = {
- &::PROTOBUF_NAMESPACE_ID::_Empty_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_Empty_default_instance_._instance,
};
-
-const char descriptor_table_protodef_google_2fprotobuf_2fempty_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
- "\n\033google/protobuf/empty.proto\022\017google.pr"
- "otobuf\"\007\n\005EmptyB}\n\023com.google.protobufB\n"
- "EmptyProtoP\001Z.google.golang.org/protobuf"
- "/types/known/emptypb\370\001\001\242\002\003GPB\252\002\036Google.P"
- "rotobuf.WellKnownTypesb\006proto3"
- ;
-static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fempty_2eproto_once;
+const char descriptor_table_protodef_google_2fprotobuf_2fempty_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ "\n\033google/protobuf/empty.proto\022\017google.pr"
+ "otobuf\"\007\n\005EmptyB}\n\023com.google.protobufB\n"
+ "EmptyProtoP\001Z.google.golang.org/protobuf"
+ "/types/known/emptypb\370\001\001\242\002\003GPB\252\002\036Google.P"
+ "rotobuf.WellKnownTypesb\006proto3"
+};
+static ::y_absl::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,
+ 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,
+ &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,
};
+
+// This function exists to be marked as weak.
+// It can significantly speed up compilation by breaking up LLVM's SCC
+// in the .pb.cc translation units. Large translation units see a
+// reduction of more than 35% of walltime for optimized builds. Without
+// the weak attribute all the messages in the file, including all the
+// vtables and everything they use become part of the same SCC through
+// a cycle like:
+// GetMetadata -> descriptor table -> default instances ->
+// 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 ::_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_PRIORITY2 static ::_pbi::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
-
// ===================================================================
class Empty::_Internal {
public:
};
-Empty::Empty(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase(arena, is_message_owned) {
+Empty::Empty(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase(arena) {
// @@protoc_insertion_point(arena_constructor:google.protobuf.Empty)
}
Empty::Empty(const Empty& from)
@@ -116,7 +139,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Empty::GetClassData() const {
&descriptor_table_google_2fprotobuf_2fempty_2eproto_getter, &descriptor_table_google_2fprotobuf_2fempty_2eproto_once,
file_level_metadata_google_2fprotobuf_2fempty_2eproto[0]);
}
-
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
@@ -125,6 +147,5 @@ Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Empty >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Empty >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
-
// @@protoc_insertion_point(global_scope)
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protobuf/src/google/protobuf/empty.pb.h b/contrib/libs/protobuf/src/google/protobuf/empty.pb.h
index 53f9983cb27..a44e86462fc 100644
--- a/contrib/libs/protobuf/src/google/protobuf/empty.pb.h
+++ b/contrib/libs/protobuf/src/google/protobuf/empty.pb.h
@@ -1,39 +1,44 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/empty.proto
-#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fempty_2eproto
-#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fempty_2eproto
+#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fempty_2eproto_2epb_2eh
+#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fempty_2eproto_2epb_2eh
#include <limits>
#include <string>
-
-#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3021000
-#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 3021003 < 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.
-#endif
-
-#include <google/protobuf/port_undef.inc>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/arena.h>
-#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_bases.h>
-#include <google/protobuf/generated_message_util.h>
-#include <google/protobuf/metadata_lite.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h> // IWYU pragma: export
-#include <google/protobuf/extension_set.h> // IWYU pragma: export
-#include <google/protobuf/unknown_field_set.h>
+#include <type_traits>
+
+#include "google/protobuf/port_def.inc"
+#if PROTOBUF_VERSION < 4022000
+#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 // PROTOBUF_VERSION
+
+#if 4022005 < 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."
+#endif // PROTOBUF_MIN_PROTOC_VERSION
+#include "google/protobuf/port_undef.inc"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/arena.h"
+#include "google/protobuf/arenastring.h"
+#include "google/protobuf/generated_message_bases.h"
+#include "google/protobuf/generated_message_util.h"
+#include "google/protobuf/metadata_lite.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/repeated_field.h" // IWYU pragma: export
+#include "google/protobuf/extension_set.h" // IWYU pragma: export
+#include "google/protobuf/unknown_field_set.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fempty_2eproto PROTOBUF_EXPORT
+
PROTOBUF_NAMESPACE_OPEN
namespace internal {
class AnyMetadata;
@@ -42,21 +47,25 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fempty_2eproto {
- static const arc_ui32 offsets[];
+ static const ::arc_ui32 offsets[];
};
-PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fempty_2eproto;
+PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable
+ descriptor_table_google_2fprotobuf_2fempty_2eproto;
PROTOBUF_NAMESPACE_OPEN
class Empty;
struct EmptyDefaultTypeInternal;
PROTOBUF_EXPORT extern EmptyDefaultTypeInternal _Empty_default_instance_;
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Empty* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Empty>(Arena*);
PROTOBUF_NAMESPACE_CLOSE
-PROTOBUF_NAMESPACE_OPEN
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Empty* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Empty>(Arena*);
-PROTOBUF_NAMESPACE_CLOSE
+
PROTOBUF_NAMESPACE_OPEN
// ===================================================================
+
+// -------------------------------------------------------------------
+
class PROTOBUF_EXPORT Empty final :
public ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase /* @@protoc_insertion_point(class_definition:google.protobuf.Empty) */ {
public:
@@ -124,7 +133,7 @@ class PROTOBUF_EXPORT Empty final :
}
void UnsafeArenaSwap(Empty* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -145,12 +154,11 @@ class PROTOBUF_EXPORT Empty final :
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.Empty";
}
protected:
- explicit Empty(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit Empty(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -173,26 +181,33 @@ class PROTOBUF_EXPORT Empty final :
};
friend struct ::TableStruct_google_2fprotobuf_2fempty_2eproto;
};
+
// ===================================================================
+
+
// ===================================================================
+
#ifdef __GNUC__
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
+// -------------------------------------------------------------------
+
// Empty
#ifdef __GNUC__
- #pragma GCC diagnostic pop
+#pragma GCC diagnostic pop
#endif // __GNUC__
// @@protoc_insertion_point(namespace_scope)
-
PROTOBUF_NAMESPACE_CLOSE
+
// @@protoc_insertion_point(global_scope)
-#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fempty_2eproto
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fempty_2eproto_2epb_2eh
diff --git a/contrib/libs/protobuf/src/google/protobuf/empty.proto b/contrib/libs/protobuf/src/google/protobuf/empty.proto
index 2227462198a..b87c89dcfce 100644
--- a/contrib/libs/protobuf/src/google/protobuf/empty.proto
+++ b/contrib/libs/protobuf/src/google/protobuf/empty.proto
@@ -32,12 +32,12 @@ syntax = "proto3";
package google.protobuf;
-option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option go_package = "google.golang.org/protobuf/types/known/emptypb";
option java_package = "com.google.protobuf";
option java_outer_classname = "EmptyProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
+option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option cc_enable_arenas = true;
// A generic empty message that you can re-use to avoid defining duplicated
diff --git a/contrib/libs/protobuf/src/google/protobuf/endian.h b/contrib/libs/protobuf/src/google/protobuf/endian.h
index ef032c06fb0..34aeb3a1db0 100644
--- a/contrib/libs/protobuf/src/google/protobuf/endian.h
+++ b/contrib/libs/protobuf/src/google/protobuf/endian.h
@@ -38,7 +38,7 @@
#include <cstdint>
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -193,6 +193,6 @@ inline arc_ui64 ToHost(arc_ui64 value) {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_ENDIAN_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/explicitly_constructed.h b/contrib/libs/protobuf/src/google/protobuf/explicitly_constructed.h
index 329b2db2910..0dbeebe3f18 100644
--- a/contrib/libs/protobuf/src/google/protobuf/explicitly_constructed.h
+++ b/contrib/libs/protobuf/src/google/protobuf/explicitly_constructed.h
@@ -33,13 +33,11 @@
#include <stdint.h>
+#include <string>
#include <utility>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-
// clang-format off
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
// clang-format on
namespace google {
@@ -92,6 +90,6 @@ using ExplicitlyConstructedArenaString = ExplicitlyConstructed<TProtoStringType,
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_EXPLICITLY_CONSTRUCTED_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/extension_set.cc b/contrib/libs/protobuf/src/google/protobuf/extension_set.cc
index d41ae5fbd78..f2866927976 100644
--- a/contrib/libs/protobuf/src/google/protobuf/extension_set.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/extension_set.cc
@@ -32,36 +32,35 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/extension_set.h>
+#include "google/protobuf/extension_set.h"
+#include <string>
#include <tuple>
-#include <unordered_set>
+#include <type_traits>
#include <utility>
-#include <google/protobuf/stubs/common.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>
-
-// clang-format off
-#include <google/protobuf/port_def.inc> // must be last.
-// clang-format on
+#include "google/protobuf/stubs/common.h"
+#include "google/protobuf/arena.h"
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/hash/hash.h"
+#include "google/protobuf/extension_set_inl.h"
+#include "google/protobuf/io/coded_stream.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"
+
+// must be last.
+#include "google/protobuf/port_def.inc"
+
namespace google {
namespace protobuf {
namespace internal {
-
namespace {
inline WireFormatLite::FieldType real_type(FieldType type) {
- GOOGLE_DCHECK(type > 0 && type <= WireFormatLite::MAX_FIELD_TYPE);
+ Y_ABSL_DCHECK(type > 0 && type <= WireFormatLite::MAX_FIELD_TYPE);
return static_cast<WireFormatLite::FieldType>(type);
}
@@ -71,8 +70,6 @@ inline WireFormatLite::CppType cpp_type(FieldType type) {
// Registry stuff.
-// Note that we cannot use hetererogeneous lookup for std containers since we
-// need to support C++11.
struct ExtensionEq {
bool operator()(const ExtensionInfo& lhs, const ExtensionInfo& rhs) const {
return lhs.message == rhs.message && lhs.number == rhs.number;
@@ -81,13 +78,12 @@ struct ExtensionEq {
struct ExtensionHasher {
std::size_t operator()(const ExtensionInfo& info) const {
- return std::hash<const MessageLite*>{}(info.message) ^
- std::hash<int>{}(info.number);
+ return y_absl::HashOf(info.message, info.number);
}
};
using ExtensionRegistry =
- std::unordered_set<ExtensionInfo, ExtensionHasher, ExtensionEq>;
+ y_absl::flat_hash_set<ExtensionInfo, ExtensionHasher, ExtensionEq>;
static const ExtensionRegistry* global_registry = nullptr;
@@ -96,10 +92,10 @@ static const ExtensionRegistry* global_registry = nullptr;
void Register(const ExtensionInfo& info) {
static auto local_static_registry = OnShutdownDelete(new ExtensionRegistry);
global_registry = local_static_registry;
- if (!InsertIfNotPresent(local_static_registry, info)) {
- GOOGLE_LOG(FATAL) << "Multiple extension registrations for type \""
- << info.message->GetTypeName() << "\", field number "
- << info.number << ".";
+ if (!local_static_registry->insert(info).second) {
+ Y_ABSL_LOG(FATAL) << "Multiple extension registrations for type \""
+ << info.message->GetTypeName() << "\", field number "
+ << info.number << ".";
}
}
@@ -135,9 +131,9 @@ void ExtensionSet::RegisterExtension(const MessageLite* extendee, int number,
FieldType type, bool is_repeated,
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);
+ Y_ABSL_CHECK_NE(type, WireFormatLite::TYPE_ENUM);
+ Y_ABSL_CHECK_NE(type, WireFormatLite::TYPE_MESSAGE);
+ Y_ABSL_CHECK_NE(type, WireFormatLite::TYPE_GROUP);
ExtensionInfo info(extendee, number, type, is_repeated, is_packed,
verify_func);
Register(info);
@@ -160,7 +156,7 @@ void ExtensionSet::RegisterEnumExtension(const MessageLite* extendee,
int number, FieldType type,
bool is_repeated, bool is_packed,
EnumValidityFunc* is_valid) {
- GOOGLE_CHECK_EQ(type, WireFormatLite::TYPE_ENUM);
+ Y_ABSL_CHECK_EQ(type, WireFormatLite::TYPE_ENUM);
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.
@@ -173,8 +169,8 @@ void ExtensionSet::RegisterMessageExtension(const MessageLite* extendee,
bool is_repeated, bool is_packed,
const MessageLite* prototype,
LazyEagerVerifyFnType verify_func) {
- GOOGLE_CHECK(type == WireFormatLite::TYPE_MESSAGE ||
- type == WireFormatLite::TYPE_GROUP);
+ Y_ABSL_CHECK(type == WireFormatLite::TYPE_MESSAGE ||
+ type == WireFormatLite::TYPE_GROUP);
ExtensionInfo info(extendee, number, type, is_repeated, is_packed,
verify_func);
info.message_info = {prototype};
@@ -224,7 +220,7 @@ void ExtensionSet::DeleteFlatMap(const ExtensionSet::KeyValue* flat,
bool ExtensionSet::Has(int number) const {
const Extension* ext = FindOrNull(number);
if (ext == nullptr) return false;
- GOOGLE_DCHECK(!ext->is_repeated);
+ Y_ABSL_DCHECK(!ext->is_repeated);
return !ext->is_cleared;
}
@@ -250,11 +246,13 @@ int ExtensionSet::ExtensionSize(int number) const {
FieldType ExtensionSet::ExtensionType(int number) const {
const Extension* ext = FindOrNull(number);
if (ext == nullptr) {
- GOOGLE_LOG(DFATAL) << "Don't lookup extension types if they aren't present (1). ";
+ Y_ABSL_DLOG(FATAL)
+ << "Don't lookup extension types if they aren't present (1). ";
return 0;
}
if (ext->is_cleared) {
- GOOGLE_LOG(DFATAL) << "Don't lookup extension types if they aren't present (2). ";
+ Y_ABSL_DLOG(FATAL)
+ << "Don't lookup extension types if they aren't present (2). ";
}
return ext->type;
}
@@ -274,9 +272,10 @@ enum { REPEATED_FIELD, OPTIONAL_FIELD };
} // namespace
-#define GOOGLE_DCHECK_TYPE(EXTENSION, LABEL, CPPTYPE) \
- GOOGLE_DCHECK_EQ((EXTENSION).is_repeated ? REPEATED_FIELD : OPTIONAL_FIELD, LABEL); \
- GOOGLE_DCHECK_EQ(cpp_type((EXTENSION).type), WireFormatLite::CPPTYPE_##CPPTYPE)
+#define Y_ABSL_DCHECK_TYPE(EXTENSION, LABEL, CPPTYPE) \
+ Y_ABSL_DCHECK_EQ((EXTENSION).is_repeated ? REPEATED_FIELD : OPTIONAL_FIELD, \
+ LABEL); \
+ Y_ABSL_DCHECK_EQ(cpp_type((EXTENSION).type), WireFormatLite::CPPTYPE_##CPPTYPE)
// -------------------------------------------------------------------
// Primitives
@@ -289,7 +288,7 @@ enum { REPEATED_FIELD, OPTIONAL_FIELD };
if (extension == nullptr || extension->is_cleared) { \
return default_value; \
} else { \
- GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, UPPERCASE); \
+ Y_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, UPPERCASE); \
return extension->LOWERCASE##_value; \
} \
} \
@@ -300,7 +299,7 @@ enum { REPEATED_FIELD, OPTIONAL_FIELD };
if (extension == nullptr || extension->is_cleared) { \
return default_value; \
} else { \
- GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, UPPERCASE); \
+ Y_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, UPPERCASE); \
return extension->LOWERCASE##_value; \
} \
} \
@@ -311,11 +310,11 @@ enum { REPEATED_FIELD, OPTIONAL_FIELD };
Extension* extension; \
if (MaybeNewExtension(number, descriptor, &extension)) { \
extension->type = type; \
- GOOGLE_DCHECK_EQ(cpp_type(extension->type), \
- WireFormatLite::CPPTYPE_##UPPERCASE); \
+ Y_ABSL_DCHECK_EQ(cpp_type(extension->type), \
+ WireFormatLite::CPPTYPE_##UPPERCASE); \
extension->is_repeated = false; \
} else { \
- GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, UPPERCASE); \
+ Y_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, UPPERCASE); \
} \
extension->is_cleared = false; \
extension->LOWERCASE##_value = value; \
@@ -324,24 +323,27 @@ enum { REPEATED_FIELD, OPTIONAL_FIELD };
LOWERCASE ExtensionSet::GetRepeated##CAMELCASE(int number, int index) \
const { \
const Extension* extension = FindOrNull(number); \
- GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; \
- GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \
+ Y_ABSL_CHECK(extension != nullptr) \
+ << "Index out-of-bounds (field is empty)."; \
+ Y_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \
return extension->repeated_##LOWERCASE##_value->Get(index); \
} \
\
const LOWERCASE& ExtensionSet::GetRefRepeated##CAMELCASE(int number, \
int index) const { \
const Extension* extension = FindOrNull(number); \
- GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; \
- GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \
+ Y_ABSL_CHECK(extension != nullptr) \
+ << "Index out-of-bounds (field is empty)."; \
+ Y_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \
return extension->repeated_##LOWERCASE##_value->Get(index); \
} \
\
void ExtensionSet::SetRepeated##CAMELCASE(int number, int index, \
LOWERCASE value) { \
Extension* extension = FindOrNull(number); \
- GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; \
- GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \
+ Y_ABSL_CHECK(extension != nullptr) \
+ << "Index out-of-bounds (field is empty)."; \
+ Y_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \
extension->repeated_##LOWERCASE##_value->Set(index, value); \
} \
\
@@ -351,15 +353,15 @@ enum { REPEATED_FIELD, OPTIONAL_FIELD };
Extension* extension; \
if (MaybeNewExtension(number, descriptor, &extension)) { \
extension->type = type; \
- GOOGLE_DCHECK_EQ(cpp_type(extension->type), \
- WireFormatLite::CPPTYPE_##UPPERCASE); \
+ Y_ABSL_DCHECK_EQ(cpp_type(extension->type), \
+ WireFormatLite::CPPTYPE_##UPPERCASE); \
extension->is_repeated = true; \
extension->is_packed = packed; \
extension->repeated_##LOWERCASE##_value = \
Arena::CreateMessage<RepeatedField<LOWERCASE>>(arena_); \
} else { \
- GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \
- GOOGLE_DCHECK_EQ(extension->is_packed, packed); \
+ Y_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \
+ Y_ABSL_DCHECK_EQ(extension->is_packed, packed); \
} \
extension->repeated_##LOWERCASE##_value->Add(value); \
}
@@ -448,10 +450,10 @@ void* ExtensionSet::MutableRawRepeatedField(int number, FieldType field_type,
}
// Compatible version using old call signature. Does not create extensions when
-// the don't already exist; instead, just GOOGLE_CHECK-fails.
+// the don't already exist; instead, just Y_ABSL_CHECK-fails.
void* ExtensionSet::MutableRawRepeatedField(int number) {
Extension* extension = FindOrNull(number);
- GOOGLE_CHECK(extension != nullptr) << "Extension not found.";
+ Y_ABSL_CHECK(extension != nullptr) << "Extension not found.";
// We assume that all the RepeatedField<>* pointers have the same
// size and alignment within the anonymous union in Extension.
return extension->repeated_arc_i32_value;
@@ -466,7 +468,7 @@ int ExtensionSet::GetEnum(int number, int default_value) const {
// Not present. Return the default value.
return default_value;
} else {
- GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, ENUM);
+ Y_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, ENUM);
return extension->enum_value;
}
}
@@ -478,7 +480,7 @@ const int& ExtensionSet::GetRefEnum(int number,
// Not present. Return the default value.
return default_value;
} else {
- GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, ENUM);
+ Y_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, ENUM);
return extension->enum_value;
}
}
@@ -488,10 +490,10 @@ void ExtensionSet::SetEnum(int number, FieldType type, int value,
Extension* extension;
if (MaybeNewExtension(number, descriptor, &extension)) {
extension->type = type;
- GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_ENUM);
+ Y_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_ENUM);
extension->is_repeated = false;
} else {
- GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, ENUM);
+ Y_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, ENUM);
}
extension->is_cleared = false;
extension->enum_value = value;
@@ -499,22 +501,22 @@ void ExtensionSet::SetEnum(int number, FieldType type, int value,
int ExtensionSet::GetRepeatedEnum(int number, int index) const {
const Extension* extension = FindOrNull(number);
- GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
- GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM);
+ Y_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
+ Y_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM);
return extension->repeated_enum_value->Get(index);
}
const int& ExtensionSet::GetRefRepeatedEnum(int number, int index) const {
const Extension* extension = FindOrNull(number);
- GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
- GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM);
+ Y_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
+ Y_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM);
return extension->repeated_enum_value->Get(index);
}
void ExtensionSet::SetRepeatedEnum(int number, int index, int value) {
Extension* extension = FindOrNull(number);
- GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
- GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM);
+ Y_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
+ Y_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM);
extension->repeated_enum_value->Set(index, value);
}
@@ -523,14 +525,14 @@ void ExtensionSet::AddEnum(int number, FieldType type, bool packed, int value,
Extension* extension;
if (MaybeNewExtension(number, descriptor, &extension)) {
extension->type = type;
- GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_ENUM);
+ Y_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_ENUM);
extension->is_repeated = true;
extension->is_packed = packed;
extension->repeated_enum_value =
Arena::CreateMessage<RepeatedField<int>>(arena_);
} else {
- GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM);
- GOOGLE_DCHECK_EQ(extension->is_packed, packed);
+ Y_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM);
+ Y_ABSL_DCHECK_EQ(extension->is_packed, packed);
}
extension->repeated_enum_value->Add(value);
}
@@ -545,7 +547,7 @@ const TProtoStringType& ExtensionSet::GetString(
// Not present. Return the default value.
return default_value;
} else {
- GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, STRING);
+ Y_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, STRING);
return *extension->string_value;
}
}
@@ -555,11 +557,11 @@ TProtoStringType* ExtensionSet::MutableString(int number, FieldType type,
Extension* extension;
if (MaybeNewExtension(number, descriptor, &extension)) {
extension->type = type;
- GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_STRING);
+ Y_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_STRING);
extension->is_repeated = false;
extension->string_value = Arena::Create<TProtoStringType>(arena_);
} else {
- GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, STRING);
+ Y_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, STRING);
}
extension->is_cleared = false;
return extension->string_value;
@@ -568,15 +570,15 @@ TProtoStringType* ExtensionSet::MutableString(int number, FieldType type,
const TProtoStringType& ExtensionSet::GetRepeatedString(int number,
int index) const {
const Extension* extension = FindOrNull(number);
- GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
- GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, STRING);
+ Y_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
+ Y_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, STRING);
return extension->repeated_string_value->Get(index);
}
TProtoStringType* ExtensionSet::MutableRepeatedString(int number, int index) {
Extension* extension = FindOrNull(number);
- GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
- GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, STRING);
+ Y_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
+ Y_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, STRING);
return extension->repeated_string_value->Mutable(index);
}
@@ -585,13 +587,13 @@ TProtoStringType* ExtensionSet::AddString(int number, FieldType type,
Extension* extension;
if (MaybeNewExtension(number, descriptor, &extension)) {
extension->type = type;
- GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_STRING);
+ Y_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_STRING);
extension->is_repeated = true;
extension->is_packed = false;
extension->repeated_string_value =
Arena::CreateMessage<RepeatedPtrField<TProtoStringType>>(arena_);
} else {
- GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, STRING);
+ Y_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, STRING);
}
return extension->repeated_string_value->Add();
}
@@ -606,7 +608,7 @@ const MessageLite& ExtensionSet::GetMessage(
// Not present. Return the default value.
return default_value;
} else {
- GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
+ Y_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
if (extension->is_lazy) {
return extension->lazymessage_value->GetMessage(default_value, arena_);
} else {
@@ -626,14 +628,14 @@ MessageLite* ExtensionSet::MutableMessage(int number, FieldType type,
Extension* extension;
if (MaybeNewExtension(number, descriptor, &extension)) {
extension->type = type;
- GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE);
+ Y_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE);
extension->is_repeated = false;
extension->is_lazy = false;
extension->message_value = prototype.New(arena_);
extension->is_cleared = false;
return extension->message_value;
} else {
- GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
+ Y_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
extension->is_cleared = false;
if (extension->is_lazy) {
return extension->lazymessage_value->MutableMessage(prototype, arena_);
@@ -655,13 +657,13 @@ void ExtensionSet::SetAllocatedMessage(int number, FieldType type,
ClearExtension(number);
return;
}
- GOOGLE_DCHECK(message->GetOwningArena() == nullptr ||
- message->GetOwningArena() == arena_);
+ Y_ABSL_DCHECK(message->GetOwningArena() == nullptr ||
+ message->GetOwningArena() == arena_);
Arena* message_arena = message->GetOwningArena();
Extension* extension;
if (MaybeNewExtension(number, descriptor, &extension)) {
extension->type = type;
- GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE);
+ Y_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE);
extension->is_repeated = false;
extension->is_lazy = false;
if (message_arena == arena_) {
@@ -674,7 +676,7 @@ void ExtensionSet::SetAllocatedMessage(int number, FieldType type,
extension->message_value->CheckTypeAndMergeFrom(*message);
}
} else {
- GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
+ Y_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
if (extension->is_lazy) {
extension->lazymessage_value->SetAllocatedMessage(message, arena_);
} else {
@@ -705,12 +707,12 @@ void ExtensionSet::UnsafeArenaSetAllocatedMessage(
Extension* extension;
if (MaybeNewExtension(number, descriptor, &extension)) {
extension->type = type;
- GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE);
+ Y_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE);
extension->is_repeated = false;
extension->is_lazy = false;
extension->message_value = message;
} else {
- GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
+ Y_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
if (extension->is_lazy) {
extension->lazymessage_value->UnsafeArenaSetAllocatedMessage(message,
arena_);
@@ -731,7 +733,7 @@ MessageLite* ExtensionSet::ReleaseMessage(int number,
// Not present. Return nullptr.
return nullptr;
} else {
- GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
+ Y_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
MessageLite* ret = nullptr;
if (extension->is_lazy) {
ret = extension->lazymessage_value->ReleaseMessage(prototype, arena_);
@@ -760,7 +762,7 @@ MessageLite* ExtensionSet::UnsafeArenaReleaseMessage(
// Not present. Return nullptr.
return nullptr;
} else {
- GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
+ Y_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
MessageLite* ret = nullptr;
if (extension->is_lazy) {
ret = extension->lazymessage_value->UnsafeArenaReleaseMessage(prototype,
@@ -783,15 +785,15 @@ MessageLite* ExtensionSet::UnsafeArenaReleaseMessage(
const MessageLite& ExtensionSet::GetRepeatedMessage(int number,
int index) const {
const Extension* extension = FindOrNull(number);
- GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
- GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, MESSAGE);
+ Y_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
+ Y_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, MESSAGE);
return extension->repeated_message_value->Get(index);
}
MessageLite* ExtensionSet::MutableRepeatedMessage(int number, int index) {
Extension* extension = FindOrNull(number);
- GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
- GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, MESSAGE);
+ Y_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
+ Y_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, MESSAGE);
return extension->repeated_message_value->Mutable(index);
}
@@ -801,12 +803,12 @@ MessageLite* ExtensionSet::AddMessage(int number, FieldType type,
Extension* extension;
if (MaybeNewExtension(number, descriptor, &extension)) {
extension->type = type;
- GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE);
+ Y_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE);
extension->is_repeated = true;
extension->repeated_message_value =
Arena::CreateMessage<RepeatedPtrField<MessageLite>>(arena_);
} else {
- GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, MESSAGE);
+ Y_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, MESSAGE);
}
// RepeatedPtrField<MessageLite> does not know how to Add() since it cannot
@@ -826,12 +828,12 @@ MessageLite* ExtensionSet::AddMessage(int number, FieldType type,
// const Descriptor* message_type,
// MessageFactory* factory)
-#undef GOOGLE_DCHECK_TYPE
+#undef Y_ABSL_DCHECK_TYPE
void ExtensionSet::RemoveLast(int number) {
Extension* extension = FindOrNull(number);
- GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
- GOOGLE_DCHECK(extension->is_repeated);
+ Y_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
+ Y_ABSL_DCHECK(extension->is_repeated);
switch (cpp_type(extension->type)) {
case WireFormatLite::CPPTYPE_INT32:
@@ -869,24 +871,24 @@ void ExtensionSet::RemoveLast(int number) {
MessageLite* ExtensionSet::ReleaseLast(int number) {
Extension* extension = FindOrNull(number);
- GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
- GOOGLE_DCHECK(extension->is_repeated);
- GOOGLE_DCHECK(cpp_type(extension->type) == WireFormatLite::CPPTYPE_MESSAGE);
+ Y_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
+ Y_ABSL_DCHECK(extension->is_repeated);
+ Y_ABSL_DCHECK(cpp_type(extension->type) == WireFormatLite::CPPTYPE_MESSAGE);
return extension->repeated_message_value->ReleaseLast();
}
MessageLite* ExtensionSet::UnsafeArenaReleaseLast(int number) {
Extension* extension = FindOrNull(number);
- GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
- GOOGLE_DCHECK(extension->is_repeated);
- GOOGLE_DCHECK(cpp_type(extension->type) == WireFormatLite::CPPTYPE_MESSAGE);
+ Y_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
+ Y_ABSL_DCHECK(extension->is_repeated);
+ Y_ABSL_DCHECK(cpp_type(extension->type) == WireFormatLite::CPPTYPE_MESSAGE);
return extension->repeated_message_value->UnsafeArenaReleaseLast();
}
void ExtensionSet::SwapElements(int number, int index1, int index2) {
Extension* extension = FindOrNull(number);
- GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
- GOOGLE_DCHECK(extension->is_repeated);
+ Y_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
+ Y_ABSL_DCHECK(extension->is_repeated);
switch (cpp_type(extension->type)) {
case WireFormatLite::CPPTYPE_INT32:
@@ -993,9 +995,9 @@ void ExtensionSet::InternalExtensionMergeFrom(const MessageLite* extendee,
extension->is_packed = other_extension.is_packed;
extension->is_repeated = true;
} else {
- GOOGLE_DCHECK_EQ(extension->type, other_extension.type);
- GOOGLE_DCHECK_EQ(extension->is_packed, other_extension.is_packed);
- GOOGLE_DCHECK(extension->is_repeated);
+ Y_ABSL_DCHECK_EQ(extension->type, other_extension.type);
+ Y_ABSL_DCHECK_EQ(extension->is_packed, other_extension.is_packed);
+ Y_ABSL_DCHECK(extension->is_repeated);
}
switch (cpp_type(other_extension.type)) {
@@ -1089,9 +1091,9 @@ void ExtensionSet::InternalExtensionMergeFrom(const MessageLite* extendee,
*other_extension.message_value);
}
} else {
- GOOGLE_DCHECK_EQ(extension->type, other_extension.type);
- GOOGLE_DCHECK_EQ(extension->is_packed, other_extension.is_packed);
- GOOGLE_DCHECK(!extension->is_repeated);
+ Y_ABSL_DCHECK_EQ(extension->type, other_extension.type);
+ Y_ABSL_DCHECK_EQ(extension->is_packed, other_extension.is_packed);
+ Y_ABSL_DCHECK(!extension->is_repeated);
if (other_extension.is_lazy) {
if (extension->is_lazy) {
extension->lazymessage_value->MergeFrom(
@@ -1199,7 +1201,7 @@ void ExtensionSet::UnsafeShallowSwapExtension(ExtensionSet* other, int number) {
if (this_ext == other_ext) return;
- GOOGLE_DCHECK_EQ(GetArena(), other->GetArena());
+ Y_ABSL_DCHECK_EQ(GetArena(), other->GetArena());
if (this_ext != nullptr && other_ext != nullptr) {
std::swap(*this_ext, *other_ext);
@@ -1212,17 +1214,21 @@ void ExtensionSet::UnsafeShallowSwapExtension(ExtensionSet* other, int number) {
}
}
-bool ExtensionSet::IsInitialized() const {
+bool ExtensionSet::IsInitialized(const MessageLite* extendee) const {
// Extensions are never required. However, we need to check that all
// embedded messages are initialized.
if (PROTOBUF_PREDICT_FALSE(is_large())) {
for (const auto& kv : *map_.large) {
- if (!kv.second.IsInitialized()) return false;
+ if (!kv.second.IsInitialized(this, extendee, kv.first, arena_)) {
+ return false;
+ }
}
return true;
}
for (const KeyValue* it = flat_begin(); it != flat_end(); ++it) {
- if (!it->second.IsInitialized()) return false;
+ if (!it->second.IsInitialized(this, extendee, it->first, arena_)) {
+ return false;
+ }
}
return true;
}
@@ -1395,7 +1401,7 @@ size_t ExtensionSet::Extension::ByteSize(int number) const {
case WireFormatLite::TYPE_BYTES:
case WireFormatLite::TYPE_GROUP:
case WireFormatLite::TYPE_MESSAGE:
- GOOGLE_LOG(FATAL) << "Non-primitive types can't be packed.";
+ Y_ABSL_LOG(FATAL) << "Non-primitive types can't be packed.";
break;
}
@@ -1496,7 +1502,7 @@ size_t ExtensionSet::Extension::ByteSize(int number) const {
}
int ExtensionSet::Extension::GetSize() const {
- GOOGLE_DCHECK(is_repeated);
+ Y_ABSL_DCHECK(is_repeated);
switch (cpp_type(type)) {
#define HANDLE_TYPE(UPPERCASE, LOWERCASE) \
case WireFormatLite::CPPTYPE_##UPPERCASE: \
@@ -1515,7 +1521,7 @@ int ExtensionSet::Extension::GetSize() const {
#undef HANDLE_TYPE
}
- GOOGLE_LOG(FATAL) << "Can't get here.";
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
return 0;
}
@@ -1562,25 +1568,29 @@ void ExtensionSet::Extension::Free() {
// Defined in extension_set_heavy.cc.
// int ExtensionSet::Extension::SpaceUsedExcludingSelf() const
-bool ExtensionSet::Extension::IsInitialized() const {
- if (cpp_type(type) == WireFormatLite::CPPTYPE_MESSAGE) {
- if (is_repeated) {
- for (int i = 0; i < repeated_message_value->size(); i++) {
- if (!repeated_message_value->Get(i).IsInitialized()) {
- return false;
- }
- }
- } else {
- if (!is_cleared) {
- if (is_lazy) {
- if (!lazymessage_value->IsInitialized()) return false;
- } else {
- if (!message_value->IsInitialized()) return false;
- }
+bool ExtensionSet::Extension::IsInitialized(const ExtensionSet* ext_set,
+ const MessageLite* extendee,
+ int number, Arena* arena) const {
+ if (cpp_type(type) != WireFormatLite::CPPTYPE_MESSAGE) return true;
+
+ if (is_repeated) {
+ for (int i = 0; i < repeated_message_value->size(); i++) {
+ if (!repeated_message_value->Get(i).IsInitialized()) {
+ return false;
}
}
+ return true;
}
- return true;
+
+ if (is_cleared) return true;
+
+ if (!is_lazy) return message_value->IsInitialized();
+
+ const MessageLite* prototype =
+ ext_set->GetPrototypeForLazyMessage(extendee, number);
+ Y_ABSL_DCHECK_NE(prototype, nullptr)
+ << "extendee: " << extendee->GetTypeName() << "; number: " << number;
+ return lazymessage_value->IsInitialized(prototype, arena);
}
// Dummy key method to avoid weak vtable.
@@ -1664,7 +1674,7 @@ void ExtensionSet::GrowCapacity(size_t minimum_new_capacity) {
hint = new_map.large->insert(hint, {it->first, it->second});
}
flat_size_ = static_cast<uint16_t>(-1);
- GOOGLE_DCHECK(is_large());
+ Y_ABSL_DCHECK(is_large());
} else {
new_map.flat = Arena::CreateArray<KeyValue>(arena_, new_flat_capacity);
std::copy(begin, end, new_map.flat);
@@ -1754,7 +1764,7 @@ uint8_t* ExtensionSet::Extension::InternalSerializeFieldWithCachedSizesToArray(
case WireFormatLite::TYPE_BYTES:
case WireFormatLite::TYPE_GROUP:
case WireFormatLite::TYPE_MESSAGE:
- GOOGLE_LOG(FATAL) << "Non-primitive types can't be packed.";
+ Y_ABSL_LOG(FATAL) << "Non-primitive types can't be packed.";
break;
}
} else {
@@ -1882,7 +1892,7 @@ ExtensionSet::Extension::InternalSerializeMessageSetItemWithCachedSizesToArray(
uint8_t* target, io::EpsCopyOutputStream* stream) const {
if (type != WireFormatLite::TYPE_MESSAGE || is_repeated) {
// Not a valid MessageSet extension, but serialize it the normal way.
- GOOGLE_LOG(WARNING) << "Invalid message set extension.";
+ Y_ABSL_LOG(WARNING) << "Invalid message set extension.";
return InternalSerializeFieldWithCachedSizesToArray(extendee, extension_set,
number, target, stream);
}
@@ -1964,4 +1974,4 @@ LazyEagerVerifyFnType FindExtensionLazyEagerVerifyFn(
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protobuf/src/google/protobuf/extension_set.h b/contrib/libs/protobuf/src/google/protobuf/extension_set.h
index 2067b38169d..c17bf4dc8a6 100644
--- a/contrib/libs/protobuf/src/google/protobuf/extension_set.h
+++ b/contrib/libs/protobuf/src/google/protobuf/extension_set.h
@@ -38,24 +38,24 @@
#ifndef GOOGLE_PROTOBUF_EXTENSION_SET_H__
#define GOOGLE_PROTOBUF_EXTENSION_SET_H__
-
#include <algorithm>
#include <cassert>
-#include <map>
#include <string>
#include <utility>
#include <vector>
-#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/parse_context.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/wire_format_lite.h>
+#include "google/protobuf/stubs/common.h"
+#include "y_absl/container/btree_map.h"
+#include "y_absl/log/absl_check.h"
+#include "google/protobuf/port.h"
+#include "google/protobuf/port.h"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/parse_context.h"
+#include "google/protobuf/repeated_field.h"
+#include "google/protobuf/wire_format_lite.h"
// clang-format off
-#include <google/protobuf/port_def.inc> // Must be last
+#include "google/protobuf/port_def.inc" // Must be last
// clang-format on
#ifdef SWIG
@@ -185,6 +185,8 @@ class PROTOBUF_EXPORT ExtensionSet {
constexpr ExtensionSet();
explicit ExtensionSet(Arena* arena);
ExtensionSet(ArenaInitialized, Arena* arena) : ExtensionSet(arena) {}
+ ExtensionSet(const ExtensionSet&) = delete;
+ ExtensionSet& operator=(const ExtensionSet&) = delete;
~ExtensionSet();
// These are called at startup by protocol-compiler-generated code to
@@ -208,7 +210,8 @@ class PROTOBUF_EXPORT ExtensionSet {
// =================================================================
// Add all fields which are currently present to the given vector. This
- // is useful to implement Reflection::ListFields().
+ // is useful to implement Reflection::ListFields(). Descriptors are appended
+ // in increasing tag order.
void AppendToList(const Descriptor* extendee, const DescriptorPool* pool,
std::vector<const FieldDescriptor*>* output) const;
@@ -318,7 +321,7 @@ class PROTOBUF_EXPORT ExtensionSet {
// This is an overload of MutableRawRepeatedField to maintain compatibility
// with old code using a previous API. This version of
- // MutableRawRepeatedField() will GOOGLE_CHECK-fail on a missing extension.
+ // MutableRawRepeatedField() will Y_ABSL_CHECK-fail on a missing extension.
// (E.g.: borg/clients/internal/proto1/proto2_reflection.cc.)
void* MutableRawRepeatedField(int number);
@@ -384,7 +387,7 @@ class PROTOBUF_EXPORT ExtensionSet {
void SwapExtension(const MessageLite* extendee, ExtensionSet* other,
int number);
void UnsafeShallowSwapExtension(ExtensionSet* other, int number);
- bool IsInitialized() const;
+ bool IsInitialized(const MessageLite* extendee) const;
// Lite parser
const char* ParseField(arc_ui64 tag, const char* ptr,
@@ -537,8 +540,10 @@ class PROTOBUF_EXPORT ExtensionSet {
// Interface of a lazily parsed singular message extension.
class PROTOBUF_EXPORT LazyMessageExtension {
public:
- LazyMessageExtension() {}
- virtual ~LazyMessageExtension() {}
+ LazyMessageExtension() = default;
+ LazyMessageExtension(const LazyMessageExtension&) = delete;
+ LazyMessageExtension& operator=(const LazyMessageExtension&) = delete;
+ virtual ~LazyMessageExtension() = default;
virtual LazyMessageExtension* New(Arena* arena) const = 0;
virtual const MessageLite& GetMessage(const MessageLite& prototype,
@@ -553,7 +558,8 @@ class PROTOBUF_EXPORT ExtensionSet {
virtual MessageLite* UnsafeArenaReleaseMessage(const MessageLite& prototype,
Arena* arena) = 0;
- virtual bool IsInitialized() const = 0;
+ virtual bool IsInitialized(const MessageLite* prototype,
+ Arena* arena) const = 0;
PROTOBUF_DEPRECATED_MSG("Please use ByteSizeLong() instead")
virtual int ByteSize() const { return internal::ToIntSize(ByteSizeLong()); }
@@ -574,8 +580,6 @@ class PROTOBUF_EXPORT ExtensionSet {
private:
virtual void UnusedKeyMethod(); // Dummy key method to avoid weak vtable.
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(LazyMessageExtension);
};
// Give access to function defined below to see LazyMessageExtension.
friend LazyMessageExtension* MaybeCreateLazyExtension(Arena* arena);
@@ -651,7 +655,8 @@ class PROTOBUF_EXPORT ExtensionSet {
int GetSize() const;
void Free();
size_t SpaceUsedExcludingSelfLong() const;
- bool IsInitialized() const;
+ bool IsInitialized(const ExtensionSet* ext_set, const MessageLite* extendee,
+ int number, Arena* arena) const;
};
// The Extension struct is small enough to be passed by value, so we use it
@@ -677,7 +682,7 @@ class PROTOBUF_EXPORT ExtensionSet {
};
};
- typedef std::map<int, Extension> LargeMap;
+ using LargeMap = y_absl::btree_map<int, Extension>;
// Wrapper API that switches between flat-map and LargeMap.
@@ -787,8 +792,8 @@ class PROTOBUF_EXPORT ExtensionSet {
return false;
}
- GOOGLE_DCHECK(extension->type > 0 &&
- extension->type <= WireFormatLite::MAX_FIELD_TYPE);
+ Y_ABSL_DCHECK(extension->type > 0 &&
+ extension->type <= WireFormatLite::MAX_FIELD_TYPE);
auto real_type = static_cast<WireFormatLite::FieldType>(extension->type);
WireFormatLite::WireType expected_wire_type =
@@ -908,8 +913,6 @@ class PROTOBUF_EXPORT ExtensionSet {
} map_;
static void DeleteFlatMap(const KeyValue* flat, uint16_t flat_capacity);
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionSet);
};
constexpr ExtensionSet::ExtensionSet()
@@ -1256,12 +1259,14 @@ class EnumTypeTraits {
}
static inline void Set(int number, FieldType field_type, ConstType value,
ExtensionSet* set) {
- GOOGLE_DCHECK(IsValid(value));
+ Y_ABSL_DCHECK(IsValid(value));
set->SetEnum(number, field_type, value, nullptr);
}
template <typename ExtendeeT>
static void Register(int number, FieldType type, bool is_packed,
LazyEagerVerifyFnType fn) {
+ // Avoid -Wunused-parameter
+ (void)fn;
ExtensionSet::RegisterEnumExtension(&ExtendeeT::default_instance(), number,
type, false, is_packed, IsValid);
}
@@ -1286,12 +1291,12 @@ class RepeatedEnumTypeTraits {
}
static inline void Set(int number, int index, ConstType value,
ExtensionSet* set) {
- GOOGLE_DCHECK(IsValid(value));
+ Y_ABSL_DCHECK(IsValid(value));
set->SetRepeatedEnum(number, index, value);
}
static inline void Add(int number, FieldType field_type, bool is_packed,
ConstType value, ExtensionSet* set) {
- GOOGLE_DCHECK(IsValid(value));
+ Y_ABSL_DCHECK(IsValid(value));
set->AddEnum(number, field_type, is_packed, value, nullptr);
}
static inline const RepeatedField<Type>& GetRepeated(
@@ -1328,6 +1333,8 @@ class RepeatedEnumTypeTraits {
template <typename ExtendeeT>
static void Register(int number, FieldType type, bool is_packed,
LazyEagerVerifyFnType fn) {
+ // Avoid -Wunused-parameter
+ (void)fn;
ExtensionSet::RegisterEnumExtension(&ExtendeeT::default_instance(), number,
type, true, is_packed, IsValid);
}
@@ -1556,6 +1563,5 @@ void LinkExtensionReflection(
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
-
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_EXTENSION_SET_H__
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 95ce1ea964f..808e4870369 100644
--- a/contrib/libs/protobuf/src/google/protobuf/extension_set_heavy.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/extension_set_heavy.cc
@@ -35,24 +35,25 @@
// Contains methods defined in extension_set.h which cannot be part of the
// lite library because they use descriptors or reflection.
-#include <google/protobuf/stubs/casts.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>
+#include <vector>
+
+#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/io/coded_stream.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/message_lite.h"
+#include "google/protobuf/parse_context.h"
+#include "google/protobuf/port.h"
+#include "google/protobuf/repeated_field.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>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -65,8 +66,8 @@ class DescriptorPoolExtensionFinder {
public:
DescriptorPoolExtensionFinder(const DescriptorPool* pool,
MessageFactory* factory,
- const Descriptor* containing_type)
- : pool_(pool), factory_(factory), containing_type_(containing_type) {}
+ const Descriptor* extendee)
+ : pool_(pool), factory_(factory), containing_type_(extendee) {}
bool Find(int number, ExtensionInfo* output);
@@ -77,9 +78,9 @@ class DescriptorPoolExtensionFinder {
};
void ExtensionSet::AppendToList(
- const Descriptor* containing_type, const DescriptorPool* pool,
+ const Descriptor* extendee, const DescriptorPool* pool,
std::vector<const FieldDescriptor*>* output) const {
- ForEach([containing_type, pool, &output](int number, const Extension& ext) {
+ ForEach([extendee, pool, &output](int number, const Extension& ext) {
bool has = false;
if (ext.is_repeated) {
has = ext.GetSize() > 0;
@@ -94,7 +95,7 @@ void ExtensionSet::AppendToList(
// AppendToList() is called.
if (ext.descriptor == nullptr) {
- output->push_back(pool->FindExtensionByNumber(containing_type, number));
+ output->push_back(pool->FindExtensionByNumber(extendee, number));
} else {
output->push_back(ext.descriptor);
}
@@ -103,7 +104,7 @@ void ExtensionSet::AppendToList(
}
inline FieldDescriptor::Type real_type(FieldType type) {
- GOOGLE_DCHECK(type > 0 && type <= FieldDescriptor::MAX_TYPE);
+ Y_ABSL_DCHECK(type > 0 && type <= FieldDescriptor::MAX_TYPE);
return static_cast<FieldDescriptor::Type>(type);
}
@@ -113,15 +114,15 @@ inline FieldDescriptor::CppType cpp_type(FieldType type) {
}
inline WireFormatLite::FieldType field_type(FieldType type) {
- GOOGLE_DCHECK(type > 0 && type <= WireFormatLite::MAX_FIELD_TYPE);
+ Y_ABSL_DCHECK(type > 0 && type <= WireFormatLite::MAX_FIELD_TYPE);
return static_cast<WireFormatLite::FieldType>(type);
}
-#define GOOGLE_DCHECK_TYPE(EXTENSION, LABEL, CPPTYPE) \
- GOOGLE_DCHECK_EQ((EXTENSION).is_repeated ? FieldDescriptor::LABEL_REPEATED \
- : FieldDescriptor::LABEL_OPTIONAL, \
- FieldDescriptor::LABEL_##LABEL); \
- GOOGLE_DCHECK_EQ(cpp_type((EXTENSION).type), FieldDescriptor::CPPTYPE_##CPPTYPE)
+#define Y_ABSL_DCHECK_TYPE(EXTENSION, LABEL, CPPTYPE) \
+ Y_ABSL_DCHECK_EQ((EXTENSION).is_repeated ? FieldDescriptor::LABEL_REPEATED \
+ : FieldDescriptor::LABEL_OPTIONAL, \
+ FieldDescriptor::LABEL_##LABEL); \
+ Y_ABSL_DCHECK_EQ(cpp_type((EXTENSION).type), FieldDescriptor::CPPTYPE_##CPPTYPE)
const MessageLite& ExtensionSet::GetMessage(int number,
const Descriptor* message_type,
@@ -131,7 +132,7 @@ const MessageLite& ExtensionSet::GetMessage(int number,
// Not present. Return the default value.
return *factory->GetPrototype(message_type);
} else {
- GOOGLE_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE);
+ Y_ABSL_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE);
if (extension->is_lazy) {
return extension->lazymessage_value->GetMessage(
*factory->GetPrototype(message_type), arena_);
@@ -146,7 +147,7 @@ MessageLite* ExtensionSet::MutableMessage(const FieldDescriptor* descriptor,
Extension* extension;
if (MaybeNewExtension(descriptor->number(), descriptor, &extension)) {
extension->type = descriptor->type();
- GOOGLE_DCHECK_EQ(cpp_type(extension->type), FieldDescriptor::CPPTYPE_MESSAGE);
+ Y_ABSL_DCHECK_EQ(cpp_type(extension->type), FieldDescriptor::CPPTYPE_MESSAGE);
extension->is_repeated = false;
extension->is_packed = false;
const MessageLite* prototype =
@@ -156,7 +157,7 @@ MessageLite* ExtensionSet::MutableMessage(const FieldDescriptor* descriptor,
extension->is_cleared = false;
return extension->message_value;
} else {
- GOOGLE_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE);
+ Y_ABSL_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE);
extension->is_cleared = false;
if (extension->is_lazy) {
return extension->lazymessage_value->MutableMessage(
@@ -174,7 +175,7 @@ MessageLite* ExtensionSet::ReleaseMessage(const FieldDescriptor* descriptor,
// Not present. Return nullptr.
return nullptr;
} else {
- GOOGLE_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE);
+ Y_ABSL_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE);
MessageLite* ret = nullptr;
if (extension->is_lazy) {
ret = extension->lazymessage_value->ReleaseMessage(
@@ -202,7 +203,7 @@ MessageLite* ExtensionSet::UnsafeArenaReleaseMessage(
// Not present. Return nullptr.
return nullptr;
} else {
- GOOGLE_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE);
+ Y_ABSL_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE);
MessageLite* ret = nullptr;
if (extension->is_lazy) {
ret = extension->lazymessage_value->UnsafeArenaReleaseMessage(
@@ -223,12 +224,12 @@ ExtensionSet::Extension* ExtensionSet::MaybeNewRepeatedExtension(
Extension* extension;
if (MaybeNewExtension(descriptor->number(), descriptor, &extension)) {
extension->type = descriptor->type();
- GOOGLE_DCHECK_EQ(cpp_type(extension->type), FieldDescriptor::CPPTYPE_MESSAGE);
+ Y_ABSL_DCHECK_EQ(cpp_type(extension->type), FieldDescriptor::CPPTYPE_MESSAGE);
extension->is_repeated = true;
extension->repeated_message_value =
Arena::CreateMessage<RepeatedPtrField<MessageLite> >(arena_);
} else {
- GOOGLE_DCHECK_TYPE(*extension, REPEATED, MESSAGE);
+ Y_ABSL_DCHECK_TYPE(*extension, REPEATED, MESSAGE);
}
return extension;
}
@@ -247,7 +248,7 @@ MessageLite* ExtensionSet::AddMessage(const FieldDescriptor* descriptor,
const MessageLite* prototype;
if (extension->repeated_message_value->empty()) {
prototype = factory->GetPrototype(descriptor->message_type());
- GOOGLE_CHECK(prototype != nullptr);
+ Y_ABSL_CHECK(prototype != nullptr);
} else {
prototype = &extension->repeated_message_value->Get(0);
}
@@ -289,7 +290,7 @@ bool DescriptorPoolExtensionFinder::Find(int number, ExtensionInfo* output) {
if (extension->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
output->message_info.prototype =
factory_->GetPrototype(extension->message_type());
- GOOGLE_CHECK(output->message_info.prototype != nullptr)
+ Y_ABSL_CHECK(output->message_info.prototype != nullptr)
<< "Extension factory's GetPrototype() returned nullptr; extension: "
<< extension->full_name();
} else if (extension->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {
@@ -303,19 +304,19 @@ bool DescriptorPoolExtensionFinder::Find(int number, ExtensionInfo* output) {
bool ExtensionSet::FindExtension(int wire_type, arc_ui32 field,
- const Message* containing_type,
+ const Message* extendee,
const internal::ParseContext* ctx,
ExtensionInfo* extension,
bool* was_packed_on_wire) {
if (ctx->data().pool == nullptr) {
- GeneratedExtensionFinder finder(containing_type);
+ GeneratedExtensionFinder finder(extendee);
if (!FindExtensionInfoFromFieldNumber(wire_type, field, &finder, extension,
was_packed_on_wire)) {
return false;
}
} else {
DescriptorPoolExtensionFinder finder(ctx->data().pool, ctx->data().factory,
- containing_type->GetDescriptor());
+ extendee->GetDescriptor());
if (!FindExtensionInfoFromFieldNumber(wire_type, field, &finder, extension,
was_packed_on_wire)) {
return false;
@@ -325,13 +326,13 @@ bool ExtensionSet::FindExtension(int wire_type, arc_ui32 field,
}
const char* ExtensionSet::ParseField(arc_ui64 tag, const char* ptr,
- const Message* containing_type,
+ const Message* extendee,
internal::InternalMetadata* metadata,
internal::ParseContext* ctx) {
int number = tag >> 3;
bool was_packed_on_wire;
ExtensionInfo extension;
- if (!FindExtension(tag & 7, number, containing_type, ctx, &extension,
+ if (!FindExtension(tag & 7, number, extendee, ctx, &extension,
&was_packed_on_wire)) {
return UnknownFieldParse(
tag, metadata->mutable_unknown_fields<UnknownFieldSet>(), ptr, ctx);
@@ -341,15 +342,15 @@ const char* ExtensionSet::ParseField(arc_ui64 tag, const char* ptr,
}
const char* ExtensionSet::ParseFieldMaybeLazily(
- arc_ui64 tag, const char* ptr, const Message* containing_type,
+ arc_ui64 tag, const char* ptr, const Message* extendee,
internal::InternalMetadata* metadata, internal::ParseContext* ctx) {
- return ParseField(tag, ptr, containing_type, metadata, ctx);
+ return ParseField(tag, ptr, extendee, metadata, ctx);
}
const char* ExtensionSet::ParseMessageSetItem(
- const char* ptr, const Message* containing_type,
+ const char* ptr, const Message* extendee,
internal::InternalMetadata* metadata, internal::ParseContext* ctx) {
- return ParseMessageSetItemTmpl<Message, UnknownFieldSet>(ptr, containing_type,
+ return ParseMessageSetItemTmpl<Message, UnknownFieldSet>(ptr, extendee,
metadata, ctx);
}
@@ -413,7 +414,7 @@ size_t ExtensionSet::Extension::SpaceUsedExcludingSelfLong() const {
if (is_lazy) {
total_size += lazymessage_value->SpaceUsedLong();
} else {
- total_size += down_cast<Message*>(message_value)->SpaceUsedLong();
+ total_size += DownCast<Message*>(message_value)->SpaceUsedLong();
}
break;
default:
@@ -437,4 +438,4 @@ uint8_t* ExtensionSet::SerializeMessageSetWithCachedSizesToArray(
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
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 b7bc82eefd1..76e88ab9a99 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/extension_set.h>
-#include <google/protobuf/metadata_lite.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 {
@@ -76,7 +76,7 @@ const char* ExtensionSet::ParseFieldWithExtensionInfo(
case WireFormatLite::TYPE_BYTES:
case WireFormatLite::TYPE_GROUP:
case WireFormatLite::TYPE_MESSAGE:
- GOOGLE_LOG(FATAL) << "Non-primitive types can't be packed.";
+ Y_ABSL_LOG(FATAL) << "Non-primitive types can't be packed.";
break;
}
} else {
@@ -207,15 +207,20 @@ const char* ExtensionSet::ParseMessageSetItemTmpl(
internal::ParseContext* ctx) {
TProtoStringType payload;
arc_ui32 type_id = 0;
- bool payload_read = false;
+ 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 6b869c44239..ba26606a733 100644
--- a/contrib/libs/protobuf/src/google/protobuf/field_mask.pb.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/field_mask.pb.cc
@@ -1,96 +1,119 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/field_mask.proto
-#include <google/protobuf/field_mask.pb.h>
+#include "google/protobuf/field_mask.pb.h"
#include <algorithm>
-
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/extension_set.h>
-#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/reflection_ops.h>
-#include <google/protobuf/wire_format.h>
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/extension_set.h"
+#include "google/protobuf/wire_format_lite.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/reflection_ops.h"
+#include "google/protobuf/wire_format.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+// Must be included last.
+#include "google/protobuf/port_def.inc"
PROTOBUF_PRAGMA_INIT_SEG
-
namespace _pb = ::PROTOBUF_NAMESPACE_ID;
-namespace _pbi = _pb::internal;
-
+namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal;
PROTOBUF_NAMESPACE_OPEN
PROTOBUF_CONSTEXPR FieldMask::FieldMask(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_.paths_)*/{}
, /*decltype(_impl_._cached_size_)*/{}} {}
struct FieldMaskDefaultTypeInternal {
- PROTOBUF_CONSTEXPR FieldMaskDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR FieldMaskDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~FieldMaskDefaultTypeInternal() {}
union {
FieldMask _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldMaskDefaultTypeInternal _FieldMask_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldMaskDefaultTypeInternal _FieldMask_default_instance_;
PROTOBUF_NAMESPACE_CLOSE
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_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldMask, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldMask, _impl_.paths_),
+static constexpr const ::_pb::EnumDescriptor**
+ file_level_enum_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto = nullptr;
+static constexpr const ::_pb::ServiceDescriptor**
+ 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_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldMask, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldMask, _impl_.paths_),
};
-static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
- { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldMask)},
+
+static const ::_pbi::MigrationSchema
+ schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldMask)},
};
static const ::_pb::Message* const file_default_instances[] = {
- &::PROTOBUF_NAMESPACE_ID::_FieldMask_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_FieldMask_default_instance_._instance,
};
-
-const char descriptor_table_protodef_google_2fprotobuf_2ffield_5fmask_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
- "\n google/protobuf/field_mask.proto\022\017goog"
- "le.protobuf\"\032\n\tFieldMask\022\r\n\005paths\030\001 \003(\tB"
- "\205\001\n\023com.google.protobufB\016FieldMaskProtoP"
- "\001Z2google.golang.org/protobuf/types/know"
- "n/fieldmaskpb\370\001\001\242\002\003GPB\252\002\036Google.Protobuf"
- ".WellKnownTypesb\006proto3"
- ;
-static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_once;
+const char descriptor_table_protodef_google_2fprotobuf_2ffield_5fmask_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ "\n google/protobuf/field_mask.proto\022\017goog"
+ "le.protobuf\"\032\n\tFieldMask\022\r\n\005paths\030\001 \003(\tB"
+ "\205\001\n\023com.google.protobufB\016FieldMaskProtoP"
+ "\001Z2google.golang.org/protobuf/types/know"
+ "n/fieldmaskpb\370\001\001\242\002\003GPB\252\002\036Google.Protobuf"
+ ".WellKnownTypesb\006proto3"
+};
+static ::y_absl::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,
+ 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,
+ &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,
};
+
+// This function exists to be marked as weak.
+// It can significantly speed up compilation by breaking up LLVM's SCC
+// in the .pb.cc translation units. Large translation units see a
+// reduction of more than 35% of walltime for optimized builds. Without
+// the weak attribute all the messages in the file, including all the
+// vtables and everything they use become part of the same SCC through
+// a cycle like:
+// GetMetadata -> descriptor table -> default instances ->
+// 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 ::_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_PRIORITY2 static ::_pbi::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
-
// ===================================================================
class FieldMask::_Internal {
public:
};
-FieldMask::FieldMask(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+FieldMask::FieldMask(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.FieldMask)
}
FieldMask::FieldMask(const FieldMask& from)
@@ -104,10 +127,8 @@ FieldMask::FieldMask(const FieldMask& from)
// @@protoc_insertion_point(copy_constructor:google.protobuf.FieldMask)
}
-inline void FieldMask::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void FieldMask::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_.paths_){arena}
, /*decltype(_impl_._cached_size_)*/{}
@@ -124,7 +145,7 @@ FieldMask::~FieldMask() {
}
inline void FieldMask::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.paths_.~RepeatedPtrField();
}
@@ -134,7 +155,7 @@ void FieldMask::SetCachedSize(int size) const {
void FieldMask::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FieldMask)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -145,12 +166,12 @@ void FieldMask::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated string paths = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
ptr -= 1;
do {
ptr += 1;
@@ -160,8 +181,9 @@ const char* FieldMask::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.FieldMask.paths"));
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -186,19 +208,17 @@ failure:
#undef CHK_
}
-uint8_t* FieldMask::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* FieldMask::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldMask)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated string paths = 1;
- for (int i = 0, n = this->_internal_paths_size(); i < n; i++) {
+ for (int i = 0, n = this->_internal_paths_size(); i < n; ++i) {
const auto& s = this->_internal_paths(i);
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
- s.data(), static_cast<int>(s.length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
- "google.protobuf.FieldMask.paths");
+ s.data(), static_cast<int>(s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.FieldMask.paths");
target = stream->WriteString(1, s, target);
}
@@ -210,20 +230,18 @@ uint8_t* FieldMask::_InternalSerialize(
return target;
}
-size_t FieldMask::ByteSizeLong() const {
+::size_t FieldMask::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldMask)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// repeated string paths = 1;
- total_size += 1 *
- ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.paths_.size());
- for (int i = 0, n = _impl_.paths_.size(); i < n; i++) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- _impl_.paths_.Get(i));
+ total_size += 1 * ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.paths_.size());
+ for (int i = 0, n = _impl_.paths_.size(); i < n; ++i) {
+ total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(_impl_.paths_.Get(i));
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -240,8 +258,8 @@ void FieldMask::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROT
auto* const _this = static_cast<FieldMask*>(&to_msg);
auto& from = static_cast<const FieldMask&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldMask)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.paths_.MergeFrom(from._impl_.paths_);
@@ -270,7 +288,6 @@ void FieldMask::InternalSwap(FieldMask* other) {
&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]);
}
-
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
@@ -279,6 +296,5 @@ Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FieldMask >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::FieldMask >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
-
// @@protoc_insertion_point(global_scope)
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
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 27e3e718b7e..79a94df9ec2 100644
--- a/contrib/libs/protobuf/src/google/protobuf/field_mask.pb.h
+++ b/contrib/libs/protobuf/src/google/protobuf/field_mask.pb.h
@@ -1,38 +1,43 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/field_mask.proto
-#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2ffield_5fmask_2eproto
-#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2ffield_5fmask_2eproto
+#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2ffield_5fmask_2eproto_2epb_2eh
+#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2ffield_5fmask_2eproto_2epb_2eh
#include <limits>
#include <string>
-
-#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3021000
-#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 3021003 < 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.
-#endif
-
-#include <google/protobuf/port_undef.inc>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/arena.h>
-#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_util.h>
-#include <google/protobuf/metadata_lite.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h> // IWYU pragma: export
-#include <google/protobuf/extension_set.h> // IWYU pragma: export
-#include <google/protobuf/unknown_field_set.h>
+#include <type_traits>
+
+#include "google/protobuf/port_def.inc"
+#if PROTOBUF_VERSION < 4022000
+#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 // PROTOBUF_VERSION
+
+#if 4022005 < 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."
+#endif // PROTOBUF_MIN_PROTOC_VERSION
+#include "google/protobuf/port_undef.inc"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/arena.h"
+#include "google/protobuf/arenastring.h"
+#include "google/protobuf/generated_message_util.h"
+#include "google/protobuf/metadata_lite.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/repeated_field.h" // IWYU pragma: export
+#include "google/protobuf/extension_set.h" // IWYU pragma: export
+#include "google/protobuf/unknown_field_set.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2ffield_5fmask_2eproto PROTOBUF_EXPORT
+
PROTOBUF_NAMESPACE_OPEN
namespace internal {
class AnyMetadata;
@@ -41,21 +46,25 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto {
- static const arc_ui32 offsets[];
+ static const ::arc_ui32 offsets[];
};
-PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto;
+PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable
+ descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto;
PROTOBUF_NAMESPACE_OPEN
class FieldMask;
struct FieldMaskDefaultTypeInternal;
PROTOBUF_EXPORT extern FieldMaskDefaultTypeInternal _FieldMask_default_instance_;
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FieldMask* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FieldMask>(Arena*);
PROTOBUF_NAMESPACE_CLOSE
-PROTOBUF_NAMESPACE_OPEN
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FieldMask* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FieldMask>(Arena*);
-PROTOBUF_NAMESPACE_CLOSE
+
PROTOBUF_NAMESPACE_OPEN
// ===================================================================
+
+// -------------------------------------------------------------------
+
class PROTOBUF_EXPORT FieldMask final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldMask) */ {
public:
@@ -124,7 +133,7 @@ class PROTOBUF_EXPORT FieldMask final :
}
void UnsafeArenaSwap(FieldMask* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -145,26 +154,25 @@ class PROTOBUF_EXPORT FieldMask final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(FieldMask* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.FieldMask";
}
protected:
- explicit FieldMask(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit FieldMask(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -183,26 +191,30 @@ class PROTOBUF_EXPORT FieldMask final :
int paths_size() const;
private:
int _internal_paths_size() const;
+
public:
- void clear_paths();
+ void clear_paths() ;
const TProtoStringType& paths(int index) const;
TProtoStringType* mutable_paths(int index);
void set_paths(int index, const TProtoStringType& value);
void set_paths(int index, TProtoStringType&& value);
void set_paths(int index, const char* value);
- void set_paths(int index, const char* value, size_t size);
+ void set_paths(int index, const char* value, std::size_t size);
+ void set_paths(int index, y_absl::string_view value);
TProtoStringType* add_paths();
void add_paths(const TProtoStringType& value);
void add_paths(TProtoStringType&& value);
void add_paths(const char* value);
- void add_paths(const char* value, size_t size);
+ void add_paths(const char* value, std::size_t size);
+ void add_paths(y_absl::string_view value);
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>& paths() const;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>* mutable_paths();
+
private:
const TProtoStringType& _internal_paths(int index) const;
TProtoStringType* _internal_add_paths();
- public:
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.FieldMask)
private:
class _Internal;
@@ -217,15 +229,21 @@ class PROTOBUF_EXPORT FieldMask final :
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto;
};
+
// ===================================================================
+
+
// ===================================================================
+
#ifdef __GNUC__
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
+// -------------------------------------------------------------------
+
// FieldMask
// repeated string paths = 1;
@@ -263,18 +281,20 @@ inline void FieldMask::set_paths(int index, TProtoStringType&& value) {
// @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths)
}
inline void FieldMask::set_paths(int index, const char* value) {
- GOOGLE_DCHECK(value != nullptr);
+ Y_ABSL_DCHECK(value != nullptr);
_impl_.paths_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.FieldMask.paths)
}
-inline void FieldMask::set_paths(int index, const char* value, size_t size) {
- _impl_.paths_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
+inline void FieldMask::set_paths(int index, const char* value,
+ std::size_t size) {
+ _impl_.paths_.Mutable(index)->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldMask.paths)
}
-inline TProtoStringType* FieldMask::_internal_add_paths() {
- return _impl_.paths_.Add();
+inline void FieldMask::set_paths(int index, y_absl::string_view value) {
+ _impl_.paths_.Mutable(index)->assign(value.data(), value.size());
+ // @@protoc_insertion_point(field_set_string_piece:google.protobuf.FieldMask.paths)
}
+inline TProtoStringType* FieldMask::_internal_add_paths() { return _impl_.paths_.Add(); }
inline void FieldMask::add_paths(const TProtoStringType& value) {
_impl_.paths_.Add()->assign(value);
// @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths)
@@ -284,34 +304,38 @@ inline void FieldMask::add_paths(TProtoStringType&& value) {
// @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths)
}
inline void FieldMask::add_paths(const char* value) {
- GOOGLE_DCHECK(value != nullptr);
+ Y_ABSL_DCHECK(value != nullptr);
_impl_.paths_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.FieldMask.paths)
}
-inline void FieldMask::add_paths(const char* value, size_t size) {
+inline void FieldMask::add_paths(const char* value, std::size_t size) {
_impl_.paths_.Add()->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_add_pointer:google.protobuf.FieldMask.paths)
}
+inline void FieldMask::add_paths(y_absl::string_view value) {
+ _impl_.paths_.Add()->assign(value.data(), value.size());
+ // @@protoc_insertion_point(field_add_string_piece:google.protobuf.FieldMask.paths)
+}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>&
FieldMask::paths() const {
// @@protoc_insertion_point(field_list:google.protobuf.FieldMask.paths)
return _impl_.paths_;
}
-inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>*
-FieldMask::mutable_paths() {
+inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>* FieldMask::mutable_paths() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.FieldMask.paths)
return &_impl_.paths_;
}
#ifdef __GNUC__
- #pragma GCC diagnostic pop
+#pragma GCC diagnostic pop
#endif // __GNUC__
// @@protoc_insertion_point(namespace_scope)
-
PROTOBUF_NAMESPACE_CLOSE
+
// @@protoc_insertion_point(global_scope)
-#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2ffield_5fmask_2eproto
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2ffield_5fmask_2eproto_2epb_2eh
diff --git a/contrib/libs/protobuf/src/google/protobuf/field_mask.proto b/contrib/libs/protobuf/src/google/protobuf/field_mask.proto
index 6b5104f188a..b28334b9439 100644
--- a/contrib/libs/protobuf/src/google/protobuf/field_mask.proto
+++ b/contrib/libs/protobuf/src/google/protobuf/field_mask.proto
@@ -32,11 +32,11 @@ syntax = "proto3";
package google.protobuf;
-option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option java_package = "com.google.protobuf";
option java_outer_classname = "FieldMaskProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
+option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option go_package = "google.golang.org/protobuf/types/known/fieldmaskpb";
option cc_enable_arenas = true;
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 519ff242c8b..431e57949ee 100644
--- a/contrib/libs/protobuf/src/google/protobuf/generated_enum_reflection.h
+++ b/contrib/libs/protobuf/src/google/protobuf/generated_enum_reflection.h
@@ -39,19 +39,18 @@
#ifndef GOOGLE_PROTOBUF_GENERATED_ENUM_REFLECTION_H__
#define GOOGLE_PROTOBUF_GENERATED_ENUM_REFLECTION_H__
-
#include <string>
-#include <google/protobuf/port.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/generated_enum_util.h>
+#include "google/protobuf/port.h"
+#include "y_absl/strings/string_view.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>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -74,10 +73,10 @@ namespace internal {
// an enum name of the given type, returning true and filling in value on
// success, or returning false and leaving value unchanged on failure.
PROTOBUF_EXPORT bool ParseNamedEnum(const EnumDescriptor* descriptor,
- ConstStringParam name, int* value);
+ y_absl::string_view name, int* value);
template <typename EnumType>
-bool ParseNamedEnum(const EnumDescriptor* descriptor, ConstStringParam name,
+bool ParseNamedEnum(const EnumDescriptor* descriptor, y_absl::string_view name,
EnumType* value) {
int tmp;
if (!ParseNamedEnum(descriptor, name, &tmp)) return false;
@@ -95,6 +94,6 @@ PROTOBUF_EXPORT const TProtoStringType& NameOfEnum(const EnumDescriptor* descrip
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_GENERATED_ENUM_REFLECTION_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/generated_enum_util.cc b/contrib/libs/protobuf/src/google/protobuf/generated_enum_util.cc
index 35939309a5f..f819a37e6d2 100644
--- a/contrib/libs/protobuf/src/google/protobuf/generated_enum_util.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/generated_enum_util.cc
@@ -28,11 +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/generated_enum_util.h>
+#include "google/protobuf/generated_enum_util.h"
#include <algorithm>
-#include <google/protobuf/generated_message_util.h>
+#include "google/protobuf/generated_message_util.h"
namespace google {
namespace protobuf {
@@ -40,7 +40,7 @@ namespace internal {
namespace {
bool EnumCompareByName(const EnumEntry& a, const EnumEntry& b) {
- return StringPiece(a.name) < StringPiece(b.name);
+ return y_absl::string_view(a.name) < y_absl::string_view(b.name);
}
// Gets the numeric value of the EnumEntry at the given index, but returns a
@@ -57,7 +57,7 @@ int GetValue(const EnumEntry* enums, int i, int target) {
} // namespace
bool LookUpEnumValue(const EnumEntry* enums, size_t size,
- StringPiece name, int* value) {
+ y_absl::string_view name, int* value) {
EnumEntry target{name, 0};
auto it = std::lower_bound(enums, enums + size, target, EnumCompareByName);
if (it != enums + size && it->name == name) {
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 cd004478d8b..d3a4406c4bc 100644
--- a/contrib/libs/protobuf/src/google/protobuf/generated_enum_util.h
+++ b/contrib/libs/protobuf/src/google/protobuf/generated_enum_util.h
@@ -31,14 +31,13 @@
#ifndef GOOGLE_PROTOBUF_GENERATED_ENUM_UTIL_H__
#define GOOGLE_PROTOBUF_GENERATED_ENUM_UTIL_H__
-
#include <type_traits>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/message_lite.h>
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/message_lite.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
#ifdef SWIG
#error "You cannot SWIG proto headers"
@@ -58,13 +57,13 @@ namespace internal {
// protos. This struct and the following related functions should only be used
// by protobuf generated code.
struct EnumEntry {
- StringPiece name;
+ y_absl::string_view name;
int value;
};
// Looks up a numeric enum value given the string name.
PROTOBUF_EXPORT bool LookUpEnumValue(const EnumEntry* enums, size_t size,
- StringPiece name, int* value);
+ y_absl::string_view name, int* value);
// Looks up an enum name given the numeric value.
PROTOBUF_EXPORT int LookUpEnumName(const EnumEntry* enums,
@@ -80,6 +79,6 @@ PROTOBUF_EXPORT bool InitializeEnumStrings(
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_GENERATED_ENUM_UTIL_H__
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 3765ac705e4..0308e9348d8 100644
--- a/contrib/libs/protobuf/src/google/protobuf/generated_message_bases.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/generated_message_bases.cc
@@ -28,17 +28,17 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <google/protobuf/generated_message_bases.h>
+#include "google/protobuf/generated_message_bases.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>
+#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"
// Must be last:
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -101,7 +101,7 @@ failure:
void ZeroFieldsBase::MergeImpl(Message& to_param, const Message& from_param) {
auto* to = static_cast<ZeroFieldsBase*>(&to_param);
const auto* from = static_cast<const ZeroFieldsBase*>(&from_param);
- GOOGLE_DCHECK_NE(from, to);
+ Y_ABSL_DCHECK_NE(from, to);
to->_internal_metadata_.MergeFrom<UnknownFieldSet>(from->_internal_metadata_);
}
@@ -121,4 +121,4 @@ void ZeroFieldsBase::InternalSwap(ZeroFieldsBase* other) {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
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 b295218a706..23798cc4c72 100644
--- a/contrib/libs/protobuf/src/google/protobuf/generated_message_bases.h
+++ b/contrib/libs/protobuf/src/google/protobuf/generated_message_bases.h
@@ -35,14 +35,14 @@
#ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_BASES_H__
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_BASES_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>
+#include "google/protobuf/arena.h"
+#include "google/protobuf/generated_message_util.h"
+#include "google/protobuf/io/zero_copy_stream_impl.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/parse_context.h"
// Must come last:
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -63,8 +63,7 @@ class PROTOBUF_EXPORT ZeroFieldsBase : public Message {
protected:
constexpr ZeroFieldsBase() {}
- explicit ZeroFieldsBase(Arena* arena, bool is_message_owned)
- : Message(arena, is_message_owned) {}
+ explicit ZeroFieldsBase(Arena* arena) : Message(arena) {}
ZeroFieldsBase(const ZeroFieldsBase&) = delete;
ZeroFieldsBase& operator=(const ZeroFieldsBase&) = delete;
~ZeroFieldsBase() override;
@@ -82,6 +81,6 @@ class PROTOBUF_EXPORT ZeroFieldsBase : public Message {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_BASES_H__
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 b9aca097308..c0af66629f3 100644
--- a/contrib/libs/protobuf/src/google/protobuf/generated_message_reflection.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/generated_message_reflection.cc
@@ -32,29 +32,37 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/generated_message_reflection.h>
+#include "google/protobuf/generated_message_reflection.h"
#include <algorithm>
-#include <set>
-
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.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/repeated_field.h>
-#include <google/protobuf/unknown_field_set.h>
+#include <atomic>
+#include <cstdint>
+#include <cstring>
+#include <string>
+
+#include "y_absl/base/casts.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/match.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/synchronization/mutex.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/extension_set.h"
+#include "google/protobuf/generated_message_tctable_gen.h"
+#include "google/protobuf/generated_message_tctable_impl.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/repeated_field.h"
+#include "google/protobuf/unknown_field_set.h"
// clang-format off
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
// clang-format on
#define GOOGLE_PROTOBUF_HAS_ONEOF
@@ -73,7 +81,6 @@ using google::protobuf::internal::OnShutdownDelete;
using google::protobuf::internal::ReflectionSchema;
using google::protobuf::internal::RepeatedPtrFieldBase;
using google::protobuf::internal::StringSpaceUsedExcludingSelfLong;
-using google::protobuf::internal::WrappedMutex;
namespace google {
namespace protobuf {
@@ -95,7 +102,7 @@ Message* MaybeForceCopy(Arena* arena, Message* msg) {
namespace internal {
-bool ParseNamedEnum(const EnumDescriptor* descriptor, ConstStringParam name,
+bool ParseNamedEnum(const EnumDescriptor* descriptor, y_absl::string_view name,
int* value) {
const EnumValueDescriptor* d = descriptor->FindValueByName(name);
if (d == nullptr) return false;
@@ -108,6 +115,54 @@ const TProtoStringType& NameOfEnum(const EnumDescriptor* descriptor, int value)
return (d == nullptr ? GetEmptyString() : d->name());
}
+// Internal helper routine for NameOfDenseEnum in the header file.
+// Allocates and fills a simple array of string pointers, based on
+// reflection information about the names of the enums. This routine
+// allocates max_val + 1 entries, under the assumption that all the enums
+// fall in the range [min_val .. max_val].
+const TProtoStringType** MakeDenseEnumCache(const EnumDescriptor* desc, int min_val,
+ int max_val) {
+ auto* str_ptrs =
+ new const TProtoStringType*[static_cast<size_t>(max_val - min_val + 1)]();
+ const int count = desc->value_count();
+ for (int i = 0; i < count; ++i) {
+ const int num = desc->value(i)->number();
+ if (str_ptrs[num - min_val] == nullptr) {
+ // Don't over-write an existing entry, because in case of duplication, the
+ // first one wins.
+ str_ptrs[num - min_val] = &desc->value(i)->name();
+ }
+ }
+ // Change any unfilled entries to point to the empty string.
+ for (int i = 0; i < max_val - min_val + 1; ++i) {
+ if (str_ptrs[i] == nullptr) str_ptrs[i] = &GetEmptyStringAlreadyInited();
+ }
+ return str_ptrs;
+}
+
+PROTOBUF_NOINLINE const TProtoStringType& NameOfDenseEnumSlow(
+ int v, DenseEnumCacheInfo* deci) {
+ if (v < deci->min_val || v > deci->max_val)
+ return GetEmptyStringAlreadyInited();
+
+ const TProtoStringType** new_cache =
+ MakeDenseEnumCache(deci->descriptor_fn(), deci->min_val, deci->max_val);
+ const TProtoStringType** old_cache = nullptr;
+
+ if (deci->cache.compare_exchange_strong(old_cache, new_cache,
+ std::memory_order_release,
+ std::memory_order_acquire)) {
+ // We successfully stored our new cache, and the old value was nullptr.
+ return *new_cache[v - deci->min_val];
+ } else {
+ // In the time it took to create our enum cache, another thread also
+ // created one, and put it into deci->cache. So delete ours, and
+ // use theirs instead.
+ delete[] new_cache;
+ return *old_cache[v - deci->min_val];
+ }
+}
+
} // namespace internal
// ===================================================================
@@ -123,18 +178,18 @@ using internal::GetPointerAtOffset;
void ReportReflectionUsageError(const Descriptor* descriptor,
const FieldDescriptor* field,
const char* method, const char* description) {
- GOOGLE_LOG(FATAL) << "Protocol Buffer reflection usage error:\n"
- " Method : google::protobuf::Reflection::"
- << method
- << "\n"
- " Message type: "
- << descriptor->full_name()
- << "\n"
- " Field : "
- << field->full_name()
- << "\n"
- " Problem : "
- << description;
+ Y_ABSL_LOG(FATAL) << "Protocol Buffer reflection usage error:\n"
+ " Method : google::protobuf::Reflection::"
+ << method
+ << "\n"
+ " Message type: "
+ << descriptor->full_name()
+ << "\n"
+ " Field : "
+ << field->full_name()
+ << "\n"
+ " Problem : "
+ << description;
}
const char* cpptype_names_[FieldDescriptor::MAX_CPPTYPE + 1] = {
@@ -145,7 +200,7 @@ const char* cpptype_names_[FieldDescriptor::MAX_CPPTYPE + 1] = {
static void ReportReflectionUsageTypeError(
const Descriptor* descriptor, const FieldDescriptor* field,
const char* method, FieldDescriptor::CppType expected_type) {
- GOOGLE_LOG(FATAL)
+ Y_ABSL_LOG(FATAL)
<< "Protocol Buffer reflection usage error:\n"
" Method : google::protobuf::Reflection::"
<< method
@@ -167,28 +222,22 @@ static void ReportReflectionUsageTypeError(
static void ReportReflectionUsageEnumTypeError(
const Descriptor* descriptor, const FieldDescriptor* field,
const char* method, const EnumValueDescriptor* value) {
- GOOGLE_LOG(FATAL) << "Protocol Buffer reflection usage error:\n"
- " Method : google::protobuf::Reflection::"
- << method
- << "\n"
- " Message type: "
- << descriptor->full_name()
- << "\n"
- " Field : "
- << field->full_name()
- << "\n"
- " Problem : Enum value did not match field type:\n"
- " Expected : "
- << field->enum_type()->full_name()
- << "\n"
- " Actual : "
- << value->full_name();
-}
-
-inline void CheckInvalidAccess(const internal::ReflectionSchema& schema,
- const FieldDescriptor* field) {
- GOOGLE_CHECK(!schema.IsFieldStripped(field))
- << "invalid access to a stripped field " << field->full_name();
+ Y_ABSL_LOG(FATAL) << "Protocol Buffer reflection usage error:\n"
+ " Method : google::protobuf::Reflection::"
+ << method
+ << "\n"
+ " Message type: "
+ << descriptor->full_name()
+ << "\n"
+ " Field : "
+ << field->full_name()
+ << "\n"
+ " Problem : Enum value did not match field type:\n"
+ " Expected : "
+ << field->enum_type()->full_name()
+ << "\n"
+ " Actual : "
+ << value->full_name();
}
#define USAGE_CHECK(CONDITION, METHOD, ERROR_DESCRIPTION) \
@@ -239,6 +288,12 @@ Reflection::Reflection(const Descriptor* descriptor,
last_non_weak_field_index_ = descriptor_->field_count() - 1;
}
+Reflection::~Reflection() {
+ // No need to use sized delete. This code path is uncommon and it would not be
+ // worth saving or recalculating the size.
+ ::operator delete(const_cast<internal::TcParseTableBase*>(tcparse_table_));
+}
+
const UnknownFieldSet& Reflection::GetUnknownFields(
const Message& message) const {
return GetInternalMetadata(message).unknown_fields<UnknownFieldSet>(
@@ -282,13 +337,6 @@ 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();
}
@@ -394,7 +442,19 @@ size_t Reflection::SpaceUsedLong(const Message& message) const {
}
}
}
+#ifndef PROTOBUF_FUZZ_MESSAGE_SPACE_USED_LONG
return total_size;
+#else
+ // Use both `this` and `dummy` to generate the seed so that the scale factor
+ // is both per-object and non-predictable, but consistent across multiple
+ // calls in the same binary.
+ static bool dummy;
+ uintptr_t seed =
+ reinterpret_cast<uintptr_t>(&dummy) ^ reinterpret_cast<uintptr_t>(this);
+ // Fuzz the size by +/- 50%.
+ double scale = (static_cast<double>(seed % 10000) / 10000) + 0.5;
+ return total_size * scale;
+#endif
}
namespace {
@@ -449,7 +509,7 @@ struct OneofFieldMover {
}
break;
default:
- GOOGLE_LOG(FATAL) << "unimplemented type: " << field->cpp_type();
+ Y_ABSL_LOG(FATAL) << "unimplemented type: " << field->cpp_type();
}
if (unsafe_shallow_swap) {
// Not clearing oneof case after move may cause unwanted "ClearOneof"
@@ -533,7 +593,7 @@ void SwapFieldHelper::SwapInlinedStrings(const Reflection* r, Message* lhs,
auto* lhs_string = r->MutableRaw<InlinedStringField>(lhs, field);
auto* rhs_string = r->MutableRaw<InlinedStringField>(rhs, field);
arc_ui32 index = r->schema_.InlinedStringIndex(field);
- GOOGLE_DCHECK_GT(index, 0);
+ Y_ABSL_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];
@@ -704,7 +764,7 @@ void SwapFieldHelper::SwapNonMessageNonStringField(
SWAP_VALUES(ENUM, int);
#undef SWAP_VALUES
default:
- GOOGLE_LOG(FATAL) << "Unimplemented type: " << field->cpp_type();
+ Y_ABSL_LOG(FATAL) << "Unimplemented type: " << field->cpp_type();
}
}
@@ -740,7 +800,7 @@ void Reflection::SwapField(Message* message1, Message* message2,
break;
default:
- GOOGLE_LOG(FATAL) << "Unimplemented type: " << field->cpp_type();
+ Y_ABSL_LOG(FATAL) << "Unimplemented type: " << field->cpp_type();
}
} else {
switch (field->cpp_type()) {
@@ -803,7 +863,7 @@ void Reflection::UnsafeShallowSwapField(Message* message1, Message* message2,
break;
default:
- GOOGLE_LOG(FATAL) << "Unimplemented type: " << field->cpp_type();
+ Y_ABSL_LOG(FATAL) << "Unimplemented type: " << field->cpp_type();
}
}
@@ -897,7 +957,7 @@ void Reflection::SwapOneofField(Message* lhs, Message* rhs,
const FieldDescriptor* field;
};
- GOOGLE_DCHECK(!oneof_descriptor->is_synthetic());
+ Y_ABSL_DCHECK(!oneof_descriptor->is_synthetic());
arc_ui32 oneof_case_lhs = GetOneofCase(*lhs, oneof_descriptor);
arc_ui32 oneof_case_rhs = GetOneofCase(*rhs, oneof_descriptor);
@@ -938,7 +998,7 @@ void Reflection::Swap(Message* message1, Message* message2) const {
if (message1 == message2) return;
// TODO(kenton): Other Reflection methods should probably check this too.
- GOOGLE_CHECK_EQ(message1->GetReflection(), this)
+ Y_ABSL_CHECK_EQ(message1->GetReflection(), this)
<< "First argument to Swap() (of type \""
<< message1->GetDescriptor()->full_name()
<< "\") is not compatible with this reflection object (which is for type "
@@ -946,7 +1006,7 @@ void Reflection::Swap(Message* message1, Message* message2) const {
<< descriptor_->full_name()
<< "\"). Note that the exact same class is required; not just the same "
"descriptor.";
- GOOGLE_CHECK_EQ(message2->GetReflection(), this)
+ Y_ABSL_CHECK_EQ(message2->GetReflection(), this)
<< "Second argument to Swap() (of type \""
<< message2->GetDescriptor()->full_name()
<< "\") is not compatible with this reflection object (which is for type "
@@ -983,8 +1043,6 @@ void Reflection::Swap(Message* message1, Message* message2) const {
return;
}
- GOOGLE_DCHECK_EQ(message1->GetOwningArena(), message2->GetOwningArena());
-
UnsafeArenaSwap(message1, message2);
}
@@ -995,7 +1053,7 @@ void Reflection::SwapFieldsImpl(
if (message1 == message2) return;
// TODO(kenton): Other Reflection methods should probably check this too.
- GOOGLE_CHECK_EQ(message1->GetReflection(), this)
+ Y_ABSL_CHECK_EQ(message1->GetReflection(), this)
<< "First argument to SwapFields() (of type \""
<< message1->GetDescriptor()->full_name()
<< "\") is not compatible with this reflection object (which is for type "
@@ -1003,7 +1061,7 @@ void Reflection::SwapFieldsImpl(
<< descriptor_->full_name()
<< "\"). Note that the exact same class is required; not just the same "
"descriptor.";
- GOOGLE_CHECK_EQ(message2->GetReflection(), this)
+ Y_ABSL_CHECK_EQ(message2->GetReflection(), this)
<< "Second argument to SwapFields() (of type \""
<< message2->GetDescriptor()->full_name()
<< "\") is not compatible with this reflection object (which is for type "
@@ -1012,15 +1070,11 @@ void Reflection::SwapFieldsImpl(
<< "\"). Note that the exact same class is required; not just the same "
"descriptor.";
- std::set<int> swapped_oneof;
-
- GOOGLE_DCHECK(!unsafe_shallow_swap || message1->GetArenaForAllocation() ==
- message2->GetArenaForAllocation());
+ y_absl::flat_hash_set<int> swapped_oneof;
const Message* prototype =
message_factory_->GetPrototype(message1->GetDescriptor());
for (const auto* field : fields) {
- CheckInvalidAccess(schema_, field);
if (field->is_extension()) {
if (unsafe_shallow_swap) {
MutableExtensionSet(message1)->UnsafeShallowSwapExtension(
@@ -1033,10 +1087,9 @@ void Reflection::SwapFieldsImpl(
if (schema_.InRealOneof(field)) {
int oneof_index = field->containing_oneof()->index();
// Only swap the oneof field once.
- if (swapped_oneof.find(oneof_index) != swapped_oneof.end()) {
+ if (!swapped_oneof.insert(oneof_index).second) {
continue;
}
- swapped_oneof.insert(oneof_index);
SwapOneofField<unsafe_shallow_swap>(message1, message2,
field->containing_oneof());
} else {
@@ -1053,9 +1106,9 @@ void Reflection::SwapFieldsImpl(
SwapBit(message1, message2, field);
if (field->options().ctype() == FieldOptions::STRING &&
IsInlined(field)) {
- GOOGLE_DCHECK(!unsafe_shallow_swap ||
- message1->GetArenaForAllocation() ==
- message2->GetArenaForAllocation());
+ Y_ABSL_DCHECK(!unsafe_shallow_swap ||
+ message1->GetArenaForAllocation() ==
+ message2->GetArenaForAllocation());
SwapInlinedStringDonated(message1, message2, field);
}
}
@@ -1073,13 +1126,16 @@ void Reflection::SwapFields(
void Reflection::UnsafeShallowSwapFields(
Message* message1, Message* message2,
const std::vector<const FieldDescriptor*>& fields) const {
+ Y_ABSL_DCHECK_EQ(message1->GetArenaForAllocation(),
+ message2->GetArenaForAllocation());
+
SwapFieldsImpl<true>(message1, message2, fields);
}
void Reflection::UnsafeArenaSwapFields(
Message* lhs, Message* rhs,
const std::vector<const FieldDescriptor*>& fields) const {
- GOOGLE_DCHECK_EQ(lhs->GetArenaForAllocation(), rhs->GetArenaForAllocation());
+ Y_ABSL_DCHECK_EQ(lhs->GetArenaForAllocation(), rhs->GetArenaForAllocation());
UnsafeShallowSwapFields(lhs, rhs, fields);
}
@@ -1089,7 +1145,6 @@ bool Reflection::HasField(const Message& message,
const FieldDescriptor* field) const {
USAGE_CHECK_MESSAGE_TYPE(HasField);
USAGE_CHECK_SINGULAR(HasField);
- CheckInvalidAccess(schema_, field);
if (field->is_extension()) {
return GetExtensionSet(message).Has(field->number());
@@ -1103,6 +1158,11 @@ bool Reflection::HasField(const Message& message,
}
void Reflection::UnsafeArenaSwap(Message* lhs, Message* rhs) const {
+ Y_ABSL_DCHECK_EQ(lhs->GetOwningArena(), rhs->GetOwningArena());
+ InternalSwap(lhs, rhs);
+}
+
+void Reflection::InternalSwap(Message* lhs, Message* rhs) const {
if (lhs == rhs) return;
MutableInternalMetadata(lhs)->InternalSwap(MutableInternalMetadata(rhs));
@@ -1110,9 +1170,14 @@ void Reflection::UnsafeArenaSwap(Message* lhs, Message* rhs) const {
for (int i = 0; i <= last_non_weak_field_index_; i++) {
const FieldDescriptor* field = descriptor_->field(i);
if (schema_.InRealOneof(field)) continue;
- if (schema_.IsFieldStripped(field)) continue;
+ if (schema_.IsSplit(field)) {
+ continue;
+ }
UnsafeShallowSwapField(lhs, rhs, field);
}
+ if (schema_.IsSplit()) {
+ std::swap(*MutableSplitField(lhs), *MutableSplitField(rhs));
+ }
const int oneof_decl_count = descriptor_->oneof_decl_count();
for (int i = 0; i < oneof_decl_count; i++) {
const OneofDescriptor* oneof = descriptor_->oneof_decl(i);
@@ -1162,8 +1227,8 @@ void Reflection::UnsafeArenaSwap(Message* lhs, Message* rhs) const {
? 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);
+ Y_ABSL_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]);
}
@@ -1178,7 +1243,6 @@ int Reflection::FieldSize(const Message& message,
const FieldDescriptor* field) const {
USAGE_CHECK_MESSAGE_TYPE(FieldSize);
USAGE_CHECK_REPEATED(FieldSize);
- CheckInvalidAccess(schema_, field);
if (field->is_extension()) {
return GetExtensionSet(message).ExtensionSize(field->number());
@@ -1215,7 +1279,7 @@ int Reflection::FieldSize(const Message& message,
}
}
- GOOGLE_LOG(FATAL) << "Can't get here.";
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
return 0;
}
}
@@ -1223,7 +1287,6 @@ int Reflection::FieldSize(const Message& message,
void Reflection::ClearField(Message* message,
const FieldDescriptor* field) const {
USAGE_CHECK_MESSAGE_TYPE(ClearField);
- CheckInvalidAccess(schema_, field);
if (field->is_extension()) {
MutableExtensionSet(message)->ClearExtension(field->number());
@@ -1334,7 +1397,6 @@ void Reflection::RemoveLast(Message* message,
const FieldDescriptor* field) const {
USAGE_CHECK_MESSAGE_TYPE(RemoveLast);
USAGE_CHECK_REPEATED(RemoveLast);
- CheckInvalidAccess(schema_, field);
if (field->is_extension()) {
MutableExtensionSet(message)->RemoveLast(field->number());
@@ -1382,7 +1444,6 @@ void Reflection::RemoveLast(Message* message,
Message* Reflection::ReleaseLast(Message* message,
const FieldDescriptor* field) const {
USAGE_CHECK_ALL(ReleaseLast, REPEATED, MESSAGE);
- CheckInvalidAccess(schema_, field);
Message* released;
if (field->is_extension()) {
@@ -1408,7 +1469,6 @@ Message* Reflection::ReleaseLast(Message* message,
Message* Reflection::UnsafeArenaReleaseLast(
Message* message, const FieldDescriptor* field) const {
USAGE_CHECK_ALL(UnsafeArenaReleaseLast, REPEATED, MESSAGE);
- CheckInvalidAccess(schema_, field);
if (field->is_extension()) {
return static_cast<Message*>(
@@ -1429,7 +1489,6 @@ void Reflection::SwapElements(Message* message, const FieldDescriptor* field,
int index1, int index2) const {
USAGE_CHECK_MESSAGE_TYPE(Swap);
USAGE_CHECK_REPEATED(Swap);
- CheckInvalidAccess(schema_, field);
if (field->is_extension()) {
MutableExtensionSet(message)->SwapElements(field->number(), index1, index2);
@@ -1476,7 +1535,7 @@ struct FieldNumberSorter {
};
bool IsIndexInHasBitSet(const arc_ui32* has_bit_set, arc_ui32 has_bit_index) {
- GOOGLE_DCHECK_NE(has_bit_index, ~0u);
+ Y_ABSL_DCHECK_NE(has_bit_index, ~0u);
return ((has_bit_set[has_bit_index / 32] >> (has_bit_index % 32)) &
static_cast<arc_ui32>(1)) != 0;
}
@@ -1484,6 +1543,13 @@ bool IsIndexInHasBitSet(const arc_ui32* has_bit_set, arc_ui32 has_bit_index) {
bool CreateUnknownEnumValues(const FileDescriptor* file) {
return file->syntax() == FileDescriptor::SYNTAX_PROTO3;
}
+
+void CheckInOrder(const FieldDescriptor* field, arc_ui32* last) {
+ *last = *last <= static_cast<arc_ui32>(field->number())
+ ? static_cast<arc_ui32>(field->number())
+ : UINT32_MAX;
+}
+
} // namespace
namespace internal {
@@ -1494,9 +1560,8 @@ bool CreateUnknownEnumValues(const FieldDescriptor* field) {
} // namespace internal
using internal::CreateUnknownEnumValues;
-void Reflection::ListFieldsMayFailOnStripped(
- const Message& message, bool should_fail,
- std::vector<const FieldDescriptor*>* output) const {
+void Reflection::ListFields(const Message& message,
+ std::vector<const FieldDescriptor*>* output) const {
output->clear();
// Optimization: The default instance never has any fields set.
@@ -1512,14 +1577,17 @@ void Reflection::ListFieldsMayFailOnStripped(
const arc_ui32* const has_bits_indices = schema_.has_bit_indices_;
output->reserve(descriptor_->field_count());
const int last_non_weak_field_index = last_non_weak_field_index_;
+ // Fields in messages are usually added with the increasing tags.
+ arc_ui32 last = 0; // UINT32_MAX if out-of-order
+ auto append_to_output = [&last, &output](const FieldDescriptor* field) {
+ CheckInOrder(field, &last);
+ output->push_back(field);
+ };
for (int i = 0; i <= last_non_weak_field_index; i++) {
const FieldDescriptor* field = descriptor_->field(i);
- if (!should_fail && schema_.IsFieldStripped(field)) {
- continue;
- }
if (field->is_repeated()) {
if (FieldSize(message, field) > 0) {
- output->push_back(field);
+ append_to_output(field);
}
} else {
const OneofDescriptor* containing_oneof = field->containing_oneof();
@@ -1530,36 +1598,43 @@ void Reflection::ListFieldsMayFailOnStripped(
// Equivalent to: HasOneofField(message, field)
if (static_cast<arc_i64>(oneof_case_array[containing_oneof->index()]) ==
field->number()) {
- output->push_back(field);
+ append_to_output(field);
}
} else if (has_bits && has_bits_indices[i] != static_cast<arc_ui32>(-1)) {
- CheckInvalidAccess(schema_, field);
// Equivalent to: HasBit(message, field)
if (IsIndexInHasBitSet(has_bits, has_bits_indices[i])) {
- output->push_back(field);
+ append_to_output(field);
}
} else if (HasBit(message, field)) { // Fall back on proto3-style HasBit.
- output->push_back(field);
+ append_to_output(field);
}
}
}
+ // Descriptors of ExtensionSet are appended in their increasing tag
+ // order and they are usually bigger than the field tags so if all fields are
+ // not sorted, let them be sorted.
+ if (last == UINT32_MAX) {
+ std::sort(output->begin(), output->end(), FieldNumberSorter());
+ last = output->back()->number();
+ }
+ size_t last_size = output->size();
if (schema_.HasExtensionSet()) {
+ // Descriptors of ExtensionSet are appended in their increasing order.
GetExtensionSet(message).AppendToList(descriptor_, descriptor_pool_,
output);
+ Y_ABSL_DCHECK(std::is_sorted(output->begin() + last_size, output->end(),
+ FieldNumberSorter()));
+ if (output->size() != last_size) {
+ CheckInOrder((*output)[last_size], &last);
+ }
+ }
+ if (last != UINT32_MAX) {
+ Y_ABSL_DCHECK(
+ std::is_sorted(output->begin(), output->end(), FieldNumberSorter()));
+ } else {
+ // ListFields() must sort output by field number.
+ std::sort(output->begin(), output->end(), FieldNumberSorter());
}
-
- // ListFields() must sort output by field number.
- std::sort(output->begin(), output->end(), FieldNumberSorter());
-}
-
-void Reflection::ListFields(const Message& message,
- std::vector<const FieldDescriptor*>* output) const {
- ListFieldsMayFailOnStripped(message, true, output);
-}
-
-void Reflection::ListFieldsOmitStripped(
- const Message& message, std::vector<const FieldDescriptor*>* output) const {
- ListFieldsMayFailOnStripped(message, false, output);
}
// -------------------------------------------------------------------
@@ -1697,7 +1772,7 @@ 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);
+ Y_ABSL_DCHECK_GT(index, 0);
arc_ui32* states =
&MutableInlinedStringDonatedArray(message)[index / 32];
arc_ui32 mask = ~(static_cast<arc_ui32>(1) << (index % 32));
@@ -1984,7 +2059,6 @@ const Message& Reflection::GetMessage(const Message& message,
const FieldDescriptor* field,
MessageFactory* factory) const {
USAGE_CHECK_ALL(GetMessage, SINGULAR, MESSAGE);
- CheckInvalidAccess(schema_, field);
if (factory == nullptr) factory = message_factory_;
@@ -2007,7 +2081,6 @@ Message* Reflection::MutableMessage(Message* message,
const FieldDescriptor* field,
MessageFactory* factory) const {
USAGE_CHECK_ALL(MutableMessage, SINGULAR, MESSAGE);
- CheckInvalidAccess(schema_, field);
if (factory == nullptr) factory = message_factory_;
@@ -2043,7 +2116,6 @@ void Reflection::UnsafeArenaSetAllocatedMessage(
Message* message, Message* sub_message,
const FieldDescriptor* field) const {
USAGE_CHECK_ALL(SetAllocatedMessage, SINGULAR, MESSAGE);
- CheckInvalidAccess(schema_, field);
if (field->is_extension()) {
@@ -2076,9 +2148,9 @@ void Reflection::UnsafeArenaSetAllocatedMessage(
void Reflection::SetAllocatedMessage(Message* message, Message* sub_message,
const FieldDescriptor* field) const {
- GOOGLE_DCHECK(sub_message == nullptr || sub_message->GetOwningArena() == nullptr ||
- sub_message->GetOwningArena() == message->GetArenaForAllocation());
- CheckInvalidAccess(schema_, field);
+ Y_ABSL_DCHECK(
+ sub_message == nullptr || sub_message->GetOwningArena() == nullptr ||
+ sub_message->GetOwningArena() == message->GetArenaForAllocation());
// If message and sub-message are in different memory ownership domains
// (different arenas, or one is on heap and one is not), then we may need to
@@ -2109,7 +2181,6 @@ Message* Reflection::UnsafeArenaReleaseMessage(Message* message,
const FieldDescriptor* field,
MessageFactory* factory) const {
USAGE_CHECK_ALL(ReleaseMessage, SINGULAR, MESSAGE);
- CheckInvalidAccess(schema_, field);
if (factory == nullptr) factory = message_factory_;
@@ -2138,8 +2209,6 @@ Message* Reflection::UnsafeArenaReleaseMessage(Message* message,
Message* Reflection::ReleaseMessage(Message* message,
const FieldDescriptor* field,
MessageFactory* factory) const {
- CheckInvalidAccess(schema_, field);
-
Message* released = UnsafeArenaReleaseMessage(message, field, factory);
#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE
released = MaybeForceCopy(message->GetArenaForAllocation(), released);
@@ -2156,7 +2225,6 @@ const Message& Reflection::GetRepeatedMessage(const Message& message,
const FieldDescriptor* field,
int index) const {
USAGE_CHECK_ALL(GetRepeatedMessage, REPEATED, MESSAGE);
- CheckInvalidAccess(schema_, field);
if (field->is_extension()) {
return static_cast<const Message&>(
@@ -2177,7 +2245,6 @@ Message* Reflection::MutableRepeatedMessage(Message* message,
const FieldDescriptor* field,
int index) const {
USAGE_CHECK_ALL(MutableRepeatedMessage, REPEATED, MESSAGE);
- CheckInvalidAccess(schema_, field);
if (field->is_extension()) {
return static_cast<Message*>(
@@ -2198,7 +2265,6 @@ Message* Reflection::MutableRepeatedMessage(Message* message,
Message* Reflection::AddMessage(Message* message, const FieldDescriptor* field,
MessageFactory* factory) const {
USAGE_CHECK_ALL(AddMessage, REPEATED, MESSAGE);
- CheckInvalidAccess(schema_, field);
if (factory == nullptr) factory = message_factory_;
@@ -2241,7 +2307,6 @@ void Reflection::AddAllocatedMessage(Message* message,
const FieldDescriptor* field,
Message* new_entry) const {
USAGE_CHECK_ALL(AddAllocatedMessage, REPEATED, MESSAGE);
- CheckInvalidAccess(schema_, field);
if (field->is_extension()) {
MutableExtensionSet(message)->AddAllocatedMessage(field, new_entry);
@@ -2261,7 +2326,6 @@ void Reflection::UnsafeArenaAddAllocatedMessage(Message* message,
const FieldDescriptor* field,
Message* new_entry) const {
USAGE_CHECK_ALL(UnsafeArenaAddAllocatedMessage, REPEATED, MESSAGE);
- CheckInvalidAccess(schema_, field);
if (field->is_extension()) {
MutableExtensionSet(message)->UnsafeArenaAddAllocatedMessage(field,
@@ -2285,7 +2349,6 @@ void* Reflection::MutableRawRepeatedField(Message* message,
const Descriptor* desc) const {
(void)ctype; // Parameter is used by Google-internal code.
USAGE_CHECK_REPEATED("MutableRawRepeatedField");
- CheckInvalidAccess(schema_, field);
if (field->cpp_type() != cpptype &&
(field->cpp_type() != FieldDescriptor::CPPTYPE_ENUM ||
@@ -2293,7 +2356,7 @@ void* Reflection::MutableRawRepeatedField(Message* message,
ReportReflectionUsageTypeError(descriptor_, field,
"MutableRawRepeatedField", cpptype);
if (desc != nullptr)
- GOOGLE_CHECK_EQ(field->message_type(), desc) << "wrong submessage type";
+ Y_ABSL_CHECK_EQ(field->message_type(), desc) << "wrong submessage type";
if (field->is_extension()) {
return MutableExtensionSet(message)->MutableRawRepeatedField(
field->number(), field->type(), field->is_packed(), field);
@@ -2317,9 +2380,9 @@ const void* Reflection::GetRawRepeatedField(const Message& message,
ReportReflectionUsageTypeError(descriptor_, field, "GetRawRepeatedField",
cpptype);
if (ctype >= 0)
- GOOGLE_CHECK_EQ(field->options().ctype(), ctype) << "subtype mismatch";
+ Y_ABSL_CHECK_EQ(field->options().ctype(), ctype) << "subtype mismatch";
if (desc != nullptr)
- GOOGLE_CHECK_EQ(field->message_type(), desc) << "wrong submessage type";
+ Y_ABSL_CHECK_EQ(field->message_type(), desc) << "wrong submessage type";
if (field->is_extension()) {
// Should use extension_set::GetRawRepeatedField. However, the required
// parameter "default repeated value" is not very easy to get here.
@@ -2410,7 +2473,7 @@ int Reflection::MapSize(const Message& message,
// -----------------------------------------------------------------------------
const FieldDescriptor* Reflection::FindKnownExtensionByName(
- const TProtoStringType& name) const {
+ y_absl::string_view name) const {
if (!schema_.HasExtensionSet()) return nullptr;
return descriptor_pool_->FindExtensionByPrintableName(descriptor_, name);
}
@@ -2434,13 +2497,35 @@ bool Reflection::SupportsUnknownEnumValues() const {
template <class Type>
const Type& Reflection::GetRawNonOneof(const Message& message,
const FieldDescriptor* field) const {
+ if (schema_.IsSplit(field)) {
+ return *GetConstPointerAtOffset<Type>(
+ GetSplitField(&message), schema_.GetFieldOffsetNonOneof(field));
+ }
return GetConstRefAtOffset<Type>(message,
schema_.GetFieldOffsetNonOneof(field));
}
+void Reflection::PrepareSplitMessageForWrite(Message* message) const {
+ Y_ABSL_DCHECK_NE(message, schema_.default_instance_);
+ void** split = MutableSplitField(message);
+ const void* default_split = GetSplitField(schema_.default_instance_);
+ if (*split == default_split) {
+ arc_ui32 size = schema_.SizeofSplit();
+ Arena* arena = message->GetArenaForAllocation();
+ *split = (arena == nullptr) ? ::operator new(size)
+ : arena->AllocateAligned(size);
+ memcpy(*split, default_split, size);
+ }
+}
+
template <class Type>
Type* Reflection::MutableRawNonOneof(Message* message,
const FieldDescriptor* field) const {
+ if (schema_.IsSplit(field)) {
+ PrepareSplitMessageForWrite(message);
+ return GetPointerAtOffset<Type>(*MutableSplitField(message),
+ schema_.GetFieldOffsetNonOneof(field));
+ }
return GetPointerAtOffset<Type>(message,
schema_.GetFieldOffsetNonOneof(field));
}
@@ -2448,22 +2533,27 @@ Type* Reflection::MutableRawNonOneof(Message* message,
template <typename Type>
Type* Reflection::MutableRaw(Message* message,
const FieldDescriptor* field) const {
+ if (schema_.IsSplit(field)) {
+ PrepareSplitMessageForWrite(message);
+ return GetPointerAtOffset<Type>(*MutableSplitField(message),
+ schema_.GetFieldOffset(field));
+ }
return GetPointerAtOffset<Type>(message, schema_.GetFieldOffset(field));
}
const arc_ui32* Reflection::GetHasBits(const Message& message) const {
- GOOGLE_DCHECK(schema_.HasHasbits());
+ Y_ABSL_DCHECK(schema_.HasHasbits());
return &GetConstRefAtOffset<arc_ui32>(message, schema_.HasBitsOffset());
}
arc_ui32* Reflection::MutableHasBits(Message* message) const {
- GOOGLE_DCHECK(schema_.HasHasbits());
+ Y_ABSL_DCHECK(schema_.HasHasbits());
return GetPointerAtOffset<arc_ui32>(message, schema_.HasBitsOffset());
}
arc_ui32* Reflection::MutableOneofCase(
Message* message, const OneofDescriptor* oneof_descriptor) const {
- GOOGLE_DCHECK(!oneof_descriptor->is_synthetic());
+ Y_ABSL_DCHECK(!oneof_descriptor->is_synthetic());
return GetPointerAtOffset<arc_ui32>(
message, schema_.GetOneofCaseOffset(oneof_descriptor));
}
@@ -2491,13 +2581,13 @@ InternalMetadata* Reflection::MutableInternalMetadata(Message* message) const {
const arc_ui32* Reflection::GetInlinedStringDonatedArray(
const Message& message) const {
- GOOGLE_DCHECK(schema_.HasInlinedString());
+ Y_ABSL_DCHECK(schema_.HasInlinedString());
return &GetConstRefAtOffset<arc_ui32>(message,
schema_.InlinedStringDonatedOffset());
}
arc_ui32* Reflection::MutableInlinedStringDonatedArray(Message* message) const {
- GOOGLE_DCHECK(schema_.HasInlinedString());
+ Y_ABSL_DCHECK(schema_.HasInlinedString());
return GetPointerAtOffset<arc_ui32>(message,
schema_.InlinedStringDonatedOffset());
}
@@ -2506,7 +2596,7 @@ arc_ui32* Reflection::MutableInlinedStringDonatedArray(Message* message) const {
bool Reflection::IsInlinedStringDonated(const Message& message,
const FieldDescriptor* field) const {
arc_ui32 index = schema_.InlinedStringIndex(field);
- GOOGLE_DCHECK_GT(index, 0);
+ Y_ABSL_DCHECK_GT(index, 0);
return IsIndexInHasBitSet(GetInlinedStringDonatedArray(message), index);
}
@@ -2535,11 +2625,11 @@ void Reflection::SwapInlinedStringDonated(Message* lhs, Message* rhs,
// 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);
+ Y_ABSL_CHECK_EQ(lhs_array[0] & 0x1u, 0u);
+ Y_ABSL_CHECK_EQ(rhs_array[0] & 0x1u, 0u);
// Swap donation status bit.
arc_ui32 index = schema_.InlinedStringIndex(field);
- GOOGLE_DCHECK_GT(index, 0);
+ Y_ABSL_DCHECK_GT(index, 0);
if (rhs_donated) {
SetInlinedStringDonated(index, lhs_array);
ClearInlinedStringDonated(index, rhs_array);
@@ -2552,14 +2642,11 @@ void Reflection::SwapInlinedStringDonated(Message* lhs, Message* rhs,
// Simple accessors for manipulating has_bits_.
bool Reflection::HasBit(const Message& message,
const FieldDescriptor* field) const {
- GOOGLE_DCHECK(!field->options().weak());
+ Y_ABSL_DCHECK(!field->options().weak());
if (schema_.HasBitIndex(field) != static_cast<arc_ui32>(-1)) {
return IsIndexInHasBitSet(GetHasBits(message), schema_.HasBitIndex(field));
}
- // Intentionally check here because HasBitIndex(field) != -1 means valid.
- CheckInvalidAccess(schema_, field);
-
// proto3: no has-bits. All fields present except messages, which are
// present only if their message-field pointer is non-null.
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
@@ -2614,13 +2701,13 @@ bool Reflection::HasBit(const Message& message,
// handled above; avoid warning
break;
}
- GOOGLE_LOG(FATAL) << "Reached impossible case in HasBit().";
+ Y_ABSL_LOG(FATAL) << "Reached impossible case in HasBit().";
return false;
}
}
void Reflection::SetBit(Message* message, const FieldDescriptor* field) const {
- GOOGLE_DCHECK(!field->options().weak());
+ Y_ABSL_DCHECK(!field->options().weak());
const arc_ui32 index = schema_.HasBitIndex(field);
if (index == static_cast<arc_ui32>(-1)) return;
MutableHasBits(message)[index / 32] |=
@@ -2629,7 +2716,7 @@ void Reflection::SetBit(Message* message, const FieldDescriptor* field) const {
void Reflection::ClearBit(Message* message,
const FieldDescriptor* field) const {
- GOOGLE_DCHECK(!field->options().weak());
+ Y_ABSL_DCHECK(!field->options().weak());
const arc_ui32 index = schema_.HasBitIndex(field);
if (index == static_cast<arc_ui32>(-1)) return;
MutableHasBits(message)[index / 32] &=
@@ -2638,7 +2725,7 @@ void Reflection::ClearBit(Message* message,
void Reflection::SwapBit(Message* message1, Message* message2,
const FieldDescriptor* field) const {
- GOOGLE_DCHECK(!field->options().weak());
+ Y_ABSL_DCHECK(!field->options().weak());
if (!schema_.HasHasbits()) {
return;
}
@@ -2832,15 +2919,15 @@ void* Reflection::RepeatedFieldData(Message* message,
const FieldDescriptor* field,
FieldDescriptor::CppType cpp_type,
const Descriptor* message_type) const {
- GOOGLE_CHECK(field->is_repeated());
- GOOGLE_CHECK(field->cpp_type() == cpp_type ||
- (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM &&
- cpp_type == FieldDescriptor::CPPTYPE_INT32))
+ Y_ABSL_CHECK(field->is_repeated());
+ Y_ABSL_CHECK(field->cpp_type() == cpp_type ||
+ (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM &&
+ cpp_type == FieldDescriptor::CPPTYPE_INT32))
<< "The type parameter T in RepeatedFieldRef<T> API doesn't match "
<< "the actual field type (for enums T should be the generated enum "
<< "type or arc_i32).";
if (message_type != nullptr) {
- GOOGLE_CHECK_EQ(message_type, field->message_type());
+ Y_ABSL_CHECK_EQ(message_type, field->message_type());
}
if (field->is_extension()) {
return MutableExtensionSet(message)->MutableRawRepeatedField(
@@ -2864,6 +2951,378 @@ const MapFieldBase* Reflection::GetMapData(const Message& message,
return &(GetRaw<MapFieldBase>(message, field));
}
+template <typename T>
+static arc_ui32 AlignTo(arc_ui32 v) {
+ return (v + alignof(T) - 1) & ~(alignof(T) - 1);
+}
+
+static internal::TailCallParseFunc GetFastParseFunction(
+ y_absl::string_view name) {
+ // This list must be synchronized with TcParser.
+ // Missing entries are replaced with MiniParse in opt mode to avoid runtime
+ // failures. It check-fails in debug mode.
+ static const auto* const map =
+ new y_absl::flat_hash_map<y_absl::string_view, internal::TailCallParseFunc>{
+ {"::_pbi::TcParser::FastF32S1", internal::TcParser::FastF32S1},
+ {"::_pbi::TcParser::FastF32S2", internal::TcParser::FastF32S2},
+ {"::_pbi::TcParser::FastF32R1", internal::TcParser::FastF32R1},
+ {"::_pbi::TcParser::FastF32R2", internal::TcParser::FastF32R2},
+ {"::_pbi::TcParser::FastF32P1", internal::TcParser::FastF32P1},
+ {"::_pbi::TcParser::FastF32P2", internal::TcParser::FastF32P2},
+ {"::_pbi::TcParser::FastF64S1", internal::TcParser::FastF64S1},
+ {"::_pbi::TcParser::FastF64S2", internal::TcParser::FastF64S2},
+ {"::_pbi::TcParser::FastF64R1", internal::TcParser::FastF64R1},
+ {"::_pbi::TcParser::FastF64R2", internal::TcParser::FastF64R2},
+ {"::_pbi::TcParser::FastF64P1", internal::TcParser::FastF64P1},
+ {"::_pbi::TcParser::FastF64P2", internal::TcParser::FastF64P2},
+ {"::_pbi::TcParser::FastV8S1", internal::TcParser::FastV8S1},
+ {"::_pbi::TcParser::FastV8S2", internal::TcParser::FastV8S2},
+ {"::_pbi::TcParser::FastV8R1", internal::TcParser::FastV8R1},
+ {"::_pbi::TcParser::FastV8R2", internal::TcParser::FastV8R2},
+ {"::_pbi::TcParser::FastV8P1", internal::TcParser::FastV8P1},
+ {"::_pbi::TcParser::FastV8P2", internal::TcParser::FastV8P2},
+ {"::_pbi::TcParser::FastV32S1", internal::TcParser::FastV32S1},
+ {"::_pbi::TcParser::FastV32S2", internal::TcParser::FastV32S2},
+ {"::_pbi::TcParser::FastV32R1", internal::TcParser::FastV32R1},
+ {"::_pbi::TcParser::FastV32R2", internal::TcParser::FastV32R2},
+ {"::_pbi::TcParser::FastV32P1", internal::TcParser::FastV32P1},
+ {"::_pbi::TcParser::FastV32P2", internal::TcParser::FastV32P2},
+ {"::_pbi::TcParser::FastV64S1", internal::TcParser::FastV64S1},
+ {"::_pbi::TcParser::FastV64S2", internal::TcParser::FastV64S2},
+ {"::_pbi::TcParser::FastV64R1", internal::TcParser::FastV64R1},
+ {"::_pbi::TcParser::FastV64R2", internal::TcParser::FastV64R2},
+ {"::_pbi::TcParser::FastV64P1", internal::TcParser::FastV64P1},
+ {"::_pbi::TcParser::FastV64P2", internal::TcParser::FastV64P2},
+ {"::_pbi::TcParser::FastZ32S1", internal::TcParser::FastZ32S1},
+ {"::_pbi::TcParser::FastZ32S2", internal::TcParser::FastZ32S2},
+ {"::_pbi::TcParser::FastZ32R1", internal::TcParser::FastZ32R1},
+ {"::_pbi::TcParser::FastZ32R2", internal::TcParser::FastZ32R2},
+ {"::_pbi::TcParser::FastZ32P1", internal::TcParser::FastZ32P1},
+ {"::_pbi::TcParser::FastZ32P2", internal::TcParser::FastZ32P2},
+ {"::_pbi::TcParser::FastZ64S1", internal::TcParser::FastZ64S1},
+ {"::_pbi::TcParser::FastZ64S2", internal::TcParser::FastZ64S2},
+ {"::_pbi::TcParser::FastZ64R1", internal::TcParser::FastZ64R1},
+ {"::_pbi::TcParser::FastZ64R2", internal::TcParser::FastZ64R2},
+ {"::_pbi::TcParser::FastZ64P1", internal::TcParser::FastZ64P1},
+ {"::_pbi::TcParser::FastZ64P2", internal::TcParser::FastZ64P2},
+ {"::_pbi::TcParser::FastErS1", internal::TcParser::FastErS1},
+ {"::_pbi::TcParser::FastErS2", internal::TcParser::FastErS2},
+ {"::_pbi::TcParser::FastErR1", internal::TcParser::FastErR1},
+ {"::_pbi::TcParser::FastErR2", internal::TcParser::FastErR2},
+ {"::_pbi::TcParser::FastErP1", internal::TcParser::FastErP1},
+ {"::_pbi::TcParser::FastErP2", internal::TcParser::FastErP2},
+ {"::_pbi::TcParser::FastEr0S1", internal::TcParser::FastEr0S1},
+ {"::_pbi::TcParser::FastEr0S2", internal::TcParser::FastEr0S2},
+ {"::_pbi::TcParser::FastEr0R1", internal::TcParser::FastEr0R1},
+ {"::_pbi::TcParser::FastEr0R2", internal::TcParser::FastEr0R2},
+ {"::_pbi::TcParser::FastEr0P1", internal::TcParser::FastEr0P1},
+ {"::_pbi::TcParser::FastEr0P2", internal::TcParser::FastEr0P2},
+ {"::_pbi::TcParser::FastEr1S1", internal::TcParser::FastEr1S1},
+ {"::_pbi::TcParser::FastEr1S2", internal::TcParser::FastEr1S2},
+ {"::_pbi::TcParser::FastEr1R1", internal::TcParser::FastEr1R1},
+ {"::_pbi::TcParser::FastEr1R2", internal::TcParser::FastEr1R2},
+ {"::_pbi::TcParser::FastEr1P1", internal::TcParser::FastEr1P1},
+ {"::_pbi::TcParser::FastEr1P2", internal::TcParser::FastEr1P2},
+ {"::_pbi::TcParser::FastEvS1", internal::TcParser::FastEvS1},
+ {"::_pbi::TcParser::FastEvS2", internal::TcParser::FastEvS2},
+ {"::_pbi::TcParser::FastEvR1", internal::TcParser::FastEvR1},
+ {"::_pbi::TcParser::FastEvR2", internal::TcParser::FastEvR2},
+ {"::_pbi::TcParser::FastEvP1", internal::TcParser::FastEvP1},
+ {"::_pbi::TcParser::FastEvP2", internal::TcParser::FastEvP2},
+ {"::_pbi::TcParser::FastBS1", internal::TcParser::FastBS1},
+ {"::_pbi::TcParser::FastBS2", internal::TcParser::FastBS2},
+ {"::_pbi::TcParser::FastBR1", internal::TcParser::FastBR1},
+ {"::_pbi::TcParser::FastBR2", internal::TcParser::FastBR2},
+ {"::_pbi::TcParser::FastSS1", internal::TcParser::FastSS1},
+ {"::_pbi::TcParser::FastSS2", internal::TcParser::FastSS2},
+ {"::_pbi::TcParser::FastSR1", internal::TcParser::FastSR1},
+ {"::_pbi::TcParser::FastSR2", internal::TcParser::FastSR2},
+ {"::_pbi::TcParser::FastUS1", internal::TcParser::FastUS1},
+ {"::_pbi::TcParser::FastUS2", internal::TcParser::FastUS2},
+ {"::_pbi::TcParser::FastUR1", internal::TcParser::FastUR1},
+ {"::_pbi::TcParser::FastUR2", internal::TcParser::FastUR2},
+ {"::_pbi::TcParser::FastBiS1", internal::TcParser::FastBiS1},
+ {"::_pbi::TcParser::FastBiS2", internal::TcParser::FastBiS2},
+ {"::_pbi::TcParser::FastSiS1", internal::TcParser::FastSiS1},
+ {"::_pbi::TcParser::FastSiS2", internal::TcParser::FastSiS2},
+ {"::_pbi::TcParser::FastUiS1", internal::TcParser::FastUiS1},
+ {"::_pbi::TcParser::FastUiS2", internal::TcParser::FastUiS2},
+ {"::_pbi::TcParser::FastBcS1", internal::TcParser::FastBcS1},
+ {"::_pbi::TcParser::FastBcS2", internal::TcParser::FastBcS2},
+ {"::_pbi::TcParser::FastScS1", internal::TcParser::FastScS1},
+ {"::_pbi::TcParser::FastScS2", internal::TcParser::FastScS2},
+ {"::_pbi::TcParser::FastUcS1", internal::TcParser::FastUcS1},
+ {"::_pbi::TcParser::FastUcS2", internal::TcParser::FastUcS2},
+ {"::_pbi::TcParser::FastMdS1", internal::TcParser::FastMdS1},
+ {"::_pbi::TcParser::FastMdS2", internal::TcParser::FastMdS2},
+ {"::_pbi::TcParser::FastGdS1", internal::TcParser::FastGdS1},
+ {"::_pbi::TcParser::FastGdS2", internal::TcParser::FastGdS2},
+ {"::_pbi::TcParser::FastMtS1", internal::TcParser::FastMtS1},
+ {"::_pbi::TcParser::FastMtS2", internal::TcParser::FastMtS2},
+ {"::_pbi::TcParser::FastGtS1", internal::TcParser::FastGtS1},
+ {"::_pbi::TcParser::FastGtS2", internal::TcParser::FastGtS2},
+ {"::_pbi::TcParser::FastMdR1", internal::TcParser::FastMdR1},
+ {"::_pbi::TcParser::FastMdR2", internal::TcParser::FastMdR2},
+ {"::_pbi::TcParser::FastGdR1", internal::TcParser::FastGdR1},
+ {"::_pbi::TcParser::FastGdR2", internal::TcParser::FastGdR2},
+ {"::_pbi::TcParser::FastMtR1", internal::TcParser::FastMtR1},
+ {"::_pbi::TcParser::FastMtR2", internal::TcParser::FastMtR2},
+ {"::_pbi::TcParser::FastGtR1", internal::TcParser::FastGtR1},
+ {"::_pbi::TcParser::FastGtR2", internal::TcParser::FastGtR2},
+ {"::_pbi::TcParser::FastEndG1", internal::TcParser::FastEndG1},
+ {"::_pbi::TcParser::FastEndG2", internal::TcParser::FastEndG2},
+ };
+ auto it = map->find(name);
+ if (it == map->end()) {
+ Y_ABSL_DLOG(FATAL) << "Failed to find function: " << name;
+ // Let's not crash in opt, just in case.
+ // MiniParse is always a valid parser.
+ return &internal::TcParser::MiniParse;
+ }
+ return it->second;
+}
+
+const internal::TcParseTableBase* Reflection::CreateTcParseTableForMessageSet()
+ const {
+ // ParseLoop can't parse message set wire format.
+ // Create a dummy table that only exists to make TcParser::ParseLoop jump
+ // into the reflective parse loop.
+
+ using Table = internal::TcParseTable<0, 0, 0, 0, 1>;
+ // We use `operator new` here because the destruction will be done with
+ // `operator delete` unconditionally.
+ void* p = ::operator new(sizeof(Table));
+ auto* full_table = ::new (p) Table{
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, schema_.default_instance_, nullptr},
+ {{{&internal::TcParser::ReflectionParseLoop, {}}}}};
+ Y_ABSL_DCHECK_EQ(static_cast<void*>(&full_table->header),
+ static_cast<void*>(full_table));
+ return &full_table->header;
+}
+
+void Reflection::PopulateTcParseFastEntries(
+ const internal::TailCallTableInfo& table_info,
+ TcParseTableBase::FastFieldEntry* fast_entries) const {
+ for (const auto& fast_field : table_info.fast_path_fields) {
+ if (fast_field.field == nullptr) {
+ if (fast_field.func_name.empty()) {
+ // No fast entry here. Use mini parser.
+ *fast_entries++ = {internal::TcParser::MiniParse, {}};
+ } else {
+ // No field, but still a special entry.
+ *fast_entries++ = {GetFastParseFunction(fast_field.func_name),
+ {fast_field.coded_tag, fast_field.nonfield_info}};
+ }
+ } else if (fast_field.func_name.find("TcParser::FastEv") !=
+ fast_field.func_name.npos) {
+ // We can't use fast parsing for these entries because we can't specify
+ // the validator. Use the reflection based parser called from MiniParse.
+ // TODO(b/239592582): Implement a fast parser for these enums.
+ *fast_entries++ = {internal::TcParser::MiniParse, {}};
+ } else {
+ *fast_entries++ = {
+ GetFastParseFunction(fast_field.func_name),
+ {fast_field.coded_tag, fast_field.hasbit_idx, fast_field.aux_idx,
+ static_cast<uint16_t>(schema_.GetFieldOffset(fast_field.field))}};
+ }
+ }
+}
+
+static void PopulateTcParseLookupTable(
+ const internal::TailCallTableInfo& table_info, uint16_t* lookup_table) {
+ for (const auto& entry_block : table_info.num_to_entry_table.blocks) {
+ *lookup_table++ = entry_block.first_fnum & 0xFFFF;
+ *lookup_table++ = entry_block.first_fnum >> 16;
+ *lookup_table++ = entry_block.entries.size();
+ for (auto se16 : entry_block.entries) {
+ *lookup_table++ = se16.skipmap;
+ *lookup_table++ = se16.field_entry_offset;
+ }
+ }
+ *lookup_table++ = 0xFFFF;
+ *lookup_table++ = 0xFFFF;
+}
+
+void Reflection::PopulateTcParseEntries(
+ internal::TailCallTableInfo& table_info,
+ TcParseTableBase::FieldEntry* entries) const {
+ for (const auto& entry : table_info.field_entries) {
+ const FieldDescriptor* field = entry.field;
+ if (field->options().weak()) {
+ // Weak fields are handled by the generated fallback function.
+ // (These are handled by legacy Google-internal logic.)
+ *entries = {};
+ } else if (field->type() == field->TYPE_ENUM &&
+ table_info.aux_entries[entry.aux_idx].type ==
+ internal::TailCallTableInfo::kEnumValidator) {
+ // Mini parse can't handle it. Fallback to reflection.
+ *entries = {};
+ table_info.aux_entries[entry.aux_idx] = {};
+ } else {
+ const OneofDescriptor* oneof = field->real_containing_oneof();
+ entries->offset = schema_.GetFieldOffset(field);
+ if (oneof != nullptr) {
+ entries->has_idx = schema_.oneof_case_offset_ + 4 * oneof->index();
+ } else if (schema_.HasHasbits()) {
+ entries->has_idx =
+ static_cast<int>(8 * schema_.HasBitsOffset() + entry.hasbit_idx);
+ } else {
+ entries->has_idx = 0;
+ }
+ entries->aux_idx = entry.aux_idx;
+ entries->type_card = entry.type_card;
+ }
+
+ ++entries;
+ }
+}
+
+void Reflection::PopulateTcParseFieldAux(
+ const internal::TailCallTableInfo& table_info,
+ TcParseTableBase::FieldAux* field_aux) const {
+ for (const auto& aux_entry : table_info.aux_entries) {
+ switch (aux_entry.type) {
+ case internal::TailCallTableInfo::kNothing:
+ *field_aux++ = {};
+ break;
+ case internal::TailCallTableInfo::kInlinedStringDonatedOffset:
+ field_aux++->offset =
+ static_cast<arc_ui32>(schema_.inlined_string_donated_offset_);
+ break;
+ case internal::TailCallTableInfo::kSplitOffset:
+ field_aux++->offset = schema_.SplitOffset();
+ break;
+ case internal::TailCallTableInfo::kSplitSizeof:
+ field_aux++->offset = schema_.SizeofSplit();
+ break;
+ case internal::TailCallTableInfo::kSubTable:
+ case internal::TailCallTableInfo::kSubMessageWeak:
+ Y_ABSL_LOG(FATAL) << "Not supported";
+ break;
+ case internal::TailCallTableInfo::kSubMessage:
+ field_aux++->message_default_p =
+ GetDefaultMessageInstance(aux_entry.field);
+ break;
+ case internal::TailCallTableInfo::kEnumRange:
+ field_aux++->enum_range = {aux_entry.enum_range.start,
+ aux_entry.enum_range.size};
+ break;
+ case internal::TailCallTableInfo::kEnumValidator:
+ Y_ABSL_LOG(FATAL) << "Not supported.";
+ break;
+ case internal::TailCallTableInfo::kNumericOffset:
+ field_aux++->offset = aux_entry.offset;
+ break;
+ }
+ }
+}
+
+const internal::TcParseTableBase* Reflection::CreateTcParseTable() const {
+ using TcParseTableBase = internal::TcParseTableBase;
+
+ if (descriptor_->options().message_set_wire_format()) {
+ return CreateTcParseTableForMessageSet();
+ }
+
+ std::vector<const FieldDescriptor*> fields;
+ constexpr int kNoHasbit = -1;
+ std::vector<int> has_bit_indices(
+ static_cast<size_t>(descriptor_->field_count()), kNoHasbit);
+ std::vector<int> inlined_string_indices = has_bit_indices;
+ for (int i = 0; i < descriptor_->field_count(); ++i) {
+ auto* field = descriptor_->field(i);
+ fields.push_back(field);
+ has_bit_indices[static_cast<size_t>(field->index())] =
+ static_cast<int>(schema_.HasBitIndex(field));
+
+ if (IsInlined(field)) {
+ inlined_string_indices[static_cast<size_t>(field->index())] =
+ schema_.InlinedStringIndex(field);
+ }
+ }
+ std::sort(fields.begin(), fields.end(),
+ [](const FieldDescriptor* a, const FieldDescriptor* b) {
+ return a->number() < b->number();
+ });
+
+ class ReflectionOptionProvider final
+ : public internal::TailCallTableInfo::OptionProvider {
+ public:
+ explicit ReflectionOptionProvider(const Reflection& ref) : ref_(ref) {}
+ internal::TailCallTableInfo::PerFieldOptions GetForField(
+ const FieldDescriptor* field) const final {
+ return {ref_.IsLazyField(field), //
+ ref_.IsInlined(field), //
+
+ // Only LITE can be implicitly weak.
+ /* is_implicitly_weak */ false,
+
+ // We could change this to use direct table.
+ // Might be easier to do when all messages support TDP.
+ /* use_direct_tcparser_table */ false,
+
+ /* is_lite */ false, //
+ ref_.schema_.IsSplit(field)};
+ }
+
+ private:
+ const Reflection& ref_;
+ };
+ internal::TailCallTableInfo table_info(
+ descriptor_, fields, ReflectionOptionProvider(*this), has_bit_indices,
+ inlined_string_indices);
+
+ const size_t fast_entries_count = table_info.fast_path_fields.size();
+ Y_ABSL_CHECK_EQ(fast_entries_count, 1 << table_info.table_size_log2);
+ const uint16_t lookup_table_offset = AlignTo<uint16_t>(
+ sizeof(TcParseTableBase) +
+ fast_entries_count * sizeof(TcParseTableBase::FastFieldEntry));
+ const arc_ui32 field_entry_offset = AlignTo<TcParseTableBase::FieldEntry>(
+ lookup_table_offset +
+ sizeof(uint16_t) * table_info.num_to_entry_table.size16());
+ const arc_ui32 aux_offset = AlignTo<TcParseTableBase::FieldAux>(
+ field_entry_offset +
+ sizeof(TcParseTableBase::FieldEntry) * fields.size());
+
+ int byte_size =
+ aux_offset +
+ sizeof(TcParseTableBase::FieldAux) * table_info.aux_entries.size() +
+ sizeof(char) * table_info.field_name_data.size();
+
+ void* p = ::operator new(byte_size);
+ auto* res = ::new (p) TcParseTableBase{
+ static_cast<uint16_t>(schema_.HasHasbits() ? schema_.HasBitsOffset() : 0),
+ // extensions handled through reflection.
+ 0, 0, 0,
+ static_cast<arc_ui32>(fields.empty() ? 0 : fields.back()->number()),
+ static_cast<uint8_t>((fast_entries_count - 1) << 3), lookup_table_offset,
+ table_info.num_to_entry_table.skipmap32, field_entry_offset,
+ static_cast<uint16_t>(fields.size()),
+ static_cast<uint16_t>(table_info.aux_entries.size()), aux_offset,
+ schema_.default_instance_, &internal::TcParser::ReflectionFallback};
+
+ // Now copy the rest of the payloads
+ PopulateTcParseFastEntries(table_info, res->fast_entry(0));
+
+ PopulateTcParseLookupTable(table_info, res->field_lookup_begin());
+
+ PopulateTcParseEntries(table_info, res->field_entries_begin());
+
+ PopulateTcParseFieldAux(table_info, res->field_aux(0u));
+
+ // Copy the name data.
+ if (!table_info.field_name_data.empty()) {
+ memcpy(res->name_data(), table_info.field_name_data.data(),
+ table_info.field_name_data.size());
+ }
+ // Validation to make sure we used all the bytes correctly.
+ Y_ABSL_CHECK_EQ(res->name_data() + table_info.field_name_data.size() -
+ reinterpret_cast<char*>(res),
+ byte_size);
+
+ return res;
+}
+
namespace {
// Helper function to transform migration schema into reflection schema.
@@ -2872,9 +3331,11 @@ ReflectionSchema MigrationToReflectionSchema(
MigrationSchema migration_schema) {
ReflectionSchema result;
result.default_instance_ = *default_instance;
- // First 7 offsets are offsets to the special fields. The following offsets
+ // First 9 offsets are offsets to the special fields. The following offsets
// are the proto fields.
- result.offsets_ = offsets + migration_schema.offsets_index + 6;
+ //
+ // TODO(congliu): Find a way to not encode sizeof_split_ in offsets.
+ result.offsets_ = offsets + migration_schema.offsets_index + 8;
result.has_bit_indices_ = offsets + migration_schema.has_bit_indices_index;
result.has_bits_offset_ = offsets[migration_schema.offsets_index + 0];
result.metadata_offset_ = offsets[migration_schema.offsets_index + 1];
@@ -2884,6 +3345,8 @@ ReflectionSchema MigrationToReflectionSchema(
result.weak_field_map_offset_ = offsets[migration_schema.offsets_index + 4];
result.inlined_string_donated_offset_ =
offsets[migration_schema.offsets_index + 5];
+ result.split_offset_ = offsets[migration_schema.offsets_index + 6];
+ result.sizeof_split_ = offsets[migration_schema.offsets_index + 7];
result.inlined_string_indices_ =
offsets + migration_schema.inlined_string_indices_index;
return result;
@@ -2970,7 +3433,7 @@ struct MetadataOwner {
private:
MetadataOwner() = default; // private because singleton
- WrappedMutex mu_;
+ y_absl::Mutex mu_;
std::vector<std::pair<const Metadata*, const Metadata*> > metadata_arrays_;
};
@@ -2981,7 +3444,7 @@ void AssignDescriptorsImpl(const DescriptorTable* table, bool eager) {
{
// This only happens once per proto file. So a global mutex to serialize
// calls to AddDescriptors.
- static WrappedMutex mu{GOOGLE_PROTOBUF_LINKER_INITIALIZED};
+ static y_absl::Mutex mu{y_absl::kConstInit};
mu.Lock();
AddDescriptors(table);
mu.Unlock();
@@ -3009,7 +3472,7 @@ void AssignDescriptorsImpl(const DescriptorTable* table, bool eager) {
const FileDescriptor* file =
DescriptorPool::internal_generated_pool()->FindFileByName(
table->filename);
- GOOGLE_CHECK(file != nullptr);
+ Y_ABSL_CHECK(file != nullptr);
MessageFactory* factory = MessageFactory::generated_factory();
@@ -3076,9 +3539,8 @@ void RegisterAllTypesInternal(const Metadata* file_level_metadata, int size) {
namespace internal {
Metadata AssignDescriptors(const DescriptorTable* (*table)(),
- internal::once_flag* once,
- const Metadata& metadata) {
- call_once(*once, [=] {
+ y_absl::once_flag* once, const Metadata& metadata) {
+ y_absl::call_once(*once, [=] {
auto* t = table();
AssignDescriptorsImpl(t, t->is_eager);
});
@@ -3088,7 +3550,7 @@ Metadata AssignDescriptors(const DescriptorTable* (*table)(),
void AssignDescriptors(const DescriptorTable* table, bool eager) {
if (!eager) eager = table->is_eager;
- call_once(*table->once, AssignDescriptorsImpl, table, eager);
+ y_absl::call_once(*table->once, AssignDescriptorsImpl, table, eager);
}
AddDescriptorsRunner::AddDescriptorsRunner(const DescriptorTable* table) {
@@ -3114,7 +3576,7 @@ void UnknownFieldSetSerializer(const uint8_t* base, arc_ui32 offset,
bool IsDescendant(Message& root, const Message& message) {
const Reflection* reflection = root.GetReflection();
std::vector<const FieldDescriptor*> fields;
- reflection->ListFieldsOmitStripped(root, &fields);
+ reflection->ListFields(root, &fields);
for (const auto* field : fields) {
// Skip non-message fields.
@@ -3165,4 +3627,4 @@ bool IsDescendant(Message& root, const Message& message) {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
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 dfab838ee48..66c31010a2f 100644
--- a/contrib/libs/protobuf/src/google/protobuf/generated_message_reflection.h
+++ b/contrib/libs/protobuf/src/google/protobuf/generated_message_reflection.h
@@ -38,17 +38,19 @@
#ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_REFLECTION_H__
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_REFLECTION_H__
-#include <google/protobuf/stubs/casts.h>
-#include <google/protobuf/stubs/common.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>
+#include <string>
+#include "google/protobuf/stubs/common.h"
+#include "y_absl/base/call_once.h"
+#include "y_absl/base/casts.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/generated_enum_reflection.h"
+#include "google/protobuf/port.h"
+#include "google/protobuf/unknown_field_set.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
#ifdef SWIG
#error "You cannot SWIG proto headers"
@@ -72,6 +74,16 @@ class DefaultEmptyOneof;
class ExtensionSet; // extension_set.h
class WeakFieldMap; // weak_field_map.h
+// Tag used on offsets for fields that don't have a real offset.
+// For example, weak message fields go into the WeakFieldMap and not in an
+// actual field.
+constexpr arc_ui32 kInvalidFieldOffsetTag = 0x40000000u;
+
+// Mask used on offsets for split fields.
+constexpr arc_ui32 kSplitFieldOffsetMask = 0x80000000u;
+constexpr arc_ui32 kLazyMask = 0x1u;
+constexpr arc_ui32 kInlinedMask = 0x1u;
+
// This struct describes the internal layout of the message, hence this is
// used to act on the message reflectively.
// default_instance: The default instance of the message. This is only
@@ -128,7 +140,7 @@ struct ReflectionSchema {
// Offset of a non-oneof field. Getting a field offset is slightly more
// efficient when we know statically that it is not a oneof field.
arc_ui32 GetFieldOffsetNonOneof(const FieldDescriptor* field) const {
- GOOGLE_DCHECK(!InRealOneof(field));
+ Y_ABSL_DCHECK(!InRealOneof(field));
return OffsetValue(offsets_[field->index()], field->type());
}
@@ -160,13 +172,13 @@ struct ReflectionSchema {
// Bit index within the bit array of hasbits. Bit order is low-to-high.
arc_ui32 HasBitIndex(const FieldDescriptor* field) const {
if (has_bits_offset_ == -1) return static_cast<arc_ui32>(-1);
- GOOGLE_DCHECK(HasHasbits());
+ Y_ABSL_DCHECK(HasHasbits());
return has_bit_indices_[field->index()];
}
// Byte offset of the hasbits array.
arc_ui32 HasBitsOffset() const {
- GOOGLE_DCHECK(HasHasbits());
+ Y_ABSL_DCHECK(HasHasbits());
return static_cast<arc_ui32>(has_bits_offset_);
}
@@ -175,13 +187,13 @@ struct ReflectionSchema {
// Bit index within the bit array of _inlined_string_donated_. Bit order is
// low-to-high.
arc_ui32 InlinedStringIndex(const FieldDescriptor* field) const {
- GOOGLE_DCHECK(HasInlinedString());
+ Y_ABSL_DCHECK(HasInlinedString());
return inlined_string_indices_[field->index()];
}
// Byte offset of the _inlined_string_donated_ array.
arc_ui32 InlinedStringDonatedOffset() const {
- GOOGLE_DCHECK(HasInlinedString());
+ Y_ABSL_DCHECK(HasInlinedString());
return static_cast<arc_ui32>(inlined_string_donated_offset_);
}
@@ -198,7 +210,7 @@ struct ReflectionSchema {
// The offset of the ExtensionSet in this message.
arc_ui32 GetExtensionSetOffset() const {
- GOOGLE_DCHECK(HasExtensionSet());
+ Y_ABSL_DCHECK(HasExtensionSet());
return static_cast<arc_ui32>(extensions_offset_);
}
@@ -219,19 +231,27 @@ struct ReflectionSchema {
// Returns true if the field is implicitly backed by LazyField.
bool IsEagerlyVerifiedLazyField(const FieldDescriptor* field) const {
- GOOGLE_DCHECK_EQ(field->type(), FieldDescriptor::TYPE_MESSAGE);
+ Y_ABSL_DCHECK_EQ(field->type(), FieldDescriptor::TYPE_MESSAGE);
(void)field;
return false;
}
- bool IsFieldStripped(const FieldDescriptor* field) const {
- (void)field;
- return false;
+ bool IsSplit() const { return split_offset_ != -1; }
+
+ bool IsSplit(const FieldDescriptor* field) const {
+ return split_offset_ != -1 &&
+ (offsets_[field->index()] & kSplitFieldOffsetMask) != 0;
}
- bool IsMessageStripped(const Descriptor* descriptor) const {
- (void)descriptor;
- return false;
+ // Byte offset of _split_.
+ arc_ui32 SplitOffset() const {
+ Y_ABSL_DCHECK(IsSplit());
+ return static_cast<arc_ui32>(split_offset_);
+ }
+
+ arc_ui32 SizeofSplit() const {
+ Y_ABSL_DCHECK(IsSplit());
+ return static_cast<arc_ui32>(sizeof_split_);
}
@@ -254,6 +274,8 @@ struct ReflectionSchema {
int weak_field_map_offset_;
const arc_ui32* inlined_string_indices_;
int inlined_string_donated_offset_;
+ int split_offset_;
+ int sizeof_split_;
// We tag offset values to provide additional data about fields (such as
// "unused" or "lazy" or "inlined").
@@ -261,15 +283,15 @@ struct ReflectionSchema {
if (type == FieldDescriptor::TYPE_MESSAGE ||
type == FieldDescriptor::TYPE_STRING ||
type == FieldDescriptor::TYPE_BYTES) {
- return v & 0xFFFFFFFEu;
+ return v & (~kSplitFieldOffsetMask) & (~kInlinedMask) & (~kLazyMask);
}
- return v;
+ return v & (~kSplitFieldOffsetMask);
}
static bool Inlined(arc_ui32 v, FieldDescriptor::Type type) {
if (type == FieldDescriptor::TYPE_STRING ||
type == FieldDescriptor::TYPE_BYTES) {
- return (v & 1u) != 0u;
+ return (v & kInlinedMask) != 0u;
} else {
// Non string/byte fields are not inlined.
return false;
@@ -299,7 +321,7 @@ struct PROTOBUF_EXPORT DescriptorTable {
int size; // of serialized descriptor
const char* descriptor;
const char* filename;
- once_flag* once;
+ y_absl::once_flag* once;
const DescriptorTable* const* deps;
int num_deps;
int num_messages;
@@ -312,13 +334,6 @@ struct PROTOBUF_EXPORT DescriptorTable {
const ServiceDescriptor** file_level_service_descriptors;
};
-enum {
- // Tag used on offsets for fields that don't have a real offset.
- // For example, weak message fields go into the WeakFieldMap and not in an
- // actual field.
- kInvalidFieldOffsetTag = 0x40000000u,
-};
-
// AssignDescriptors() pulls the compiled FileDescriptor from the DescriptorPool
// and uses it to populate all of the global variables which store pointers to
// the descriptor objects. It also constructs the reflection objects. It is
@@ -332,7 +347,7 @@ void PROTOBUF_EXPORT AssignDescriptors(const DescriptorTable* table,
// It takes a `Metadata` and returns it to allow for tail calls and reduce
// binary size.
Metadata PROTOBUF_EXPORT AssignDescriptors(const DescriptorTable* (*table)(),
- internal::once_flag* once,
+ y_absl::once_flag* once,
const Metadata& metadata);
// These cannot be in lite so we put them in the reflection.
@@ -345,10 +360,38 @@ struct PROTOBUF_EXPORT AddDescriptorsRunner {
explicit AddDescriptorsRunner(const DescriptorTable* table);
};
+struct DenseEnumCacheInfo {
+ std::atomic<const TProtoStringType**> cache;
+ int min_val;
+ int max_val;
+ const EnumDescriptor* (*descriptor_fn)();
+};
+PROTOBUF_EXPORT const TProtoStringType& NameOfDenseEnumSlow(int v,
+ DenseEnumCacheInfo*);
+
+// Similar to the routine NameOfEnum, this routine returns the name of an enum.
+// Unlike that routine, it allocates, on-demand, a block of pointers to the
+// TProtoStringType objects allocated by reflection to store the enum names. This
+// way, as long as the enum values are fairly dense, looking them up can be
+// very fast. This assumes all the enums fall in the range [min_val .. max_val].
+template <const EnumDescriptor* (*descriptor_fn)(), int min_val, int max_val>
+const TProtoStringType& NameOfDenseEnum(int v) {
+ static_assert(max_val - min_val >= 0, "Too many enums between min and max.");
+ static DenseEnumCacheInfo deci = {/* atomic ptr */ {}, min_val, max_val,
+ descriptor_fn};
+ const TProtoStringType** cache = deci.cache.load(std::memory_order_acquire );
+ if (PROTOBUF_PREDICT_TRUE(cache != nullptr)) {
+ if (PROTOBUF_PREDICT_TRUE(v >= min_val && v <= max_val)) {
+ return *cache[v - min_val];
+ }
+ }
+ return NameOfDenseEnumSlow(v, &deci);
+}
+
} // namespace internal
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_REFLECTION_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 bb42f6fdefd..1e97d073205 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
@@ -36,15 +36,16 @@
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_TCTABLE_DECL_H__
#include <array>
+#include <atomic>
#include <cstddef>
#include <cstdint>
#include <type_traits>
-#include <google/protobuf/message_lite.h>
-#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>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -85,6 +86,27 @@ struct TcFieldData {
uint8_t aux_idx() const { return static_cast<uint8_t>(data >> 24); }
uint16_t offset() const { return static_cast<uint16_t>(data >> 48); }
+ // Constructor for special entries that do not represent a field.
+ // - End group: `nonfield_info` is the decoded tag.
+ constexpr TcFieldData(uint16_t coded_tag, uint16_t nonfield_info)
+ : data(arc_ui64{nonfield_info} << 16 | //
+ arc_ui64{coded_tag}) {}
+
+ // Fields used in non-field entries
+ //
+ // Bit:
+ // +-----------+-------------------+
+ // |63 .. 32|31 .. 0|
+ // +---------------+---------------+
+ // : . : . : . 16|=======| [16] coded_tag()
+ // : . : . 32|=======| . : [16] decoded_tag()
+ // :---.---:---.---: . : . : [32] (unused)
+ // +-----------+-------------------+
+ // |63 .. 32|31 .. 0|
+ // +---------------+---------------+
+
+ uint16_t decoded_tag() const { return static_cast<uint16_t>(data >> 16); }
+
// Fields used in mini table parsing:
//
// Bit:
@@ -120,6 +142,8 @@ struct Offset {
#pragma warning(disable : 4324)
#endif
+struct FieldAuxDefaultMessage {};
+
// Base class for message-level table with info for the tail-call parser.
struct alignas(arc_ui64) TcParseTableBase {
// Common attributes for message layout:
@@ -173,25 +197,58 @@ struct alignas(arc_ui64) TcParseTableBase {
// Table entry for fast-path tailcall dispatch handling.
struct FastFieldEntry {
// Target function for dispatch:
- TailCallParseFunc target;
+ mutable std::atomic<TailCallParseFunc> target_atomic;
+
// Field data used during parse:
TcFieldData bits;
+
+ // Default initializes this instance with undefined values.
+ FastFieldEntry() = default;
+
+ // Constant initializes this instance
+ constexpr FastFieldEntry(TailCallParseFunc func, TcFieldData bits)
+ : target_atomic(func), bits(bits) {}
+
+ // FastFieldEntry is copy-able and assignable, which is intended
+ // mainly for testing and debugging purposes.
+ FastFieldEntry(const FastFieldEntry& rhs) noexcept
+ : FastFieldEntry(rhs.target(), rhs.bits) {}
+ FastFieldEntry& operator=(const FastFieldEntry& rhs) noexcept {
+ SetTarget(rhs.target());
+ bits = rhs.bits;
+ return *this;
+ }
+
+ // Protocol buffer code should use these relaxed accessors.
+ TailCallParseFunc target() const {
+ return target_atomic.load(std::memory_order_relaxed);
+ }
+ void SetTarget(TailCallParseFunc func) const {
+ return target_atomic.store(func, std::memory_order_relaxed);
+ }
};
// There is always at least one table entry.
const FastFieldEntry* fast_entry(size_t idx) const {
return reinterpret_cast<const FastFieldEntry*>(this + 1) + idx;
}
+ FastFieldEntry* fast_entry(size_t idx) {
+ return reinterpret_cast<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);
}
+ uint16_t* field_lookup_begin() {
+ return reinterpret_cast<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
+ arc_i32 has_idx; // has-bit index, relative to the message object
uint16_t aux_idx; // index for `field_aux`.
uint16_t type_card; // `FieldType` and `Cardinality` (see _impl.h)
};
@@ -201,29 +258,49 @@ struct alignas(arc_ui64) TcParseTableBase {
return reinterpret_cast<const FieldEntry*>(
reinterpret_cast<uintptr_t>(this) + field_entries_offset);
}
+ FieldEntry* field_entries_begin() {
+ return reinterpret_cast<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() : message_default_p(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) {}
+ constexpr FieldAux(const MessageLite* msg) : message_default_p(msg) {}
+ constexpr FieldAux(FieldAuxDefaultMessage, const void* msg)
+ : message_default_p(msg) {}
+ constexpr FieldAux(const TcParseTableBase* table) : table(table) {}
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 void* message_default_p;
+ const TcParseTableBase* table;
+
+ const MessageLite* message_default() const {
+ return static_cast<const MessageLite*>(message_default_p);
+ }
+ const MessageLite* message_default_weak() const {
+ return *static_cast<const MessageLite* const*>(message_default_p);
+ }
};
const FieldAux* field_aux(arc_ui32 idx) const {
return reinterpret_cast<const FieldAux*>(reinterpret_cast<uintptr_t>(this) +
aux_offset) +
idx;
}
+ FieldAux* field_aux(arc_ui32 idx) {
+ return reinterpret_cast<FieldAux*>(reinterpret_cast<uintptr_t>(this) +
+ aux_offset) +
+ idx;
+ }
const FieldAux* field_aux(const FieldEntry* entry) const {
return field_aux(entry->aux_idx);
}
@@ -234,6 +311,11 @@ struct alignas(arc_ui64) TcParseTableBase {
aux_offset +
num_aux_entries * sizeof(FieldAux));
}
+ char* name_data() {
+ return reinterpret_cast<char*>(reinterpret_cast<uintptr_t>(this) +
+ aux_offset +
+ num_aux_entries * sizeof(FieldAux));
+ }
};
#if defined(_MSC_VER) && !defined(_WIN64)
@@ -265,7 +347,7 @@ struct TcParseTable {
// Entries for all fields:
std::array<TcParseTableBase::FieldEntry, kNumFieldEntries> field_entries;
std::array<TcParseTableBase::FieldAux, kNumFieldAux> aux_entries;
- std::array<char, kNameTableSize> field_names;
+ std::array<char, kNameTableSize == 0 ? 1 : kNameTableSize> field_names;
};
// Partial specialization: if there are no aux entries, there will be no array.
@@ -281,7 +363,7 @@ struct TcParseTable<kFastTableSizeLog2, kNumFieldEntries, 0, kNameTableSize,
fast_entries;
std::array<uint16_t, kFieldLookupSize> field_lookup_table;
std::array<TcParseTableBase::FieldEntry, kNumFieldEntries> field_entries;
- std::array<char, kNameTableSize> field_names;
+ std::array<char, kNameTableSize == 0 ? 1 : kNameTableSize> field_names;
};
// Partial specialization: if there are no fields at all, then we can save space
@@ -293,7 +375,7 @@ struct TcParseTable<0, 0, 0, kNameTableSize, kFieldLookupSize> {
// 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;
+ std::array<char, kNameTableSize == 0 ? 1 : kNameTableSize> field_names;
};
static_assert(std::is_standard_layout<TcParseTable<1>>::value,
@@ -307,6 +389,6 @@ static_assert(offsetof(TcParseTable<1>, fast_entries) ==
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_TCTABLE_DECL_H__
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 b77bb8d8e33..96cf9dd2d8e 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,24 +30,65 @@
#include <cstdint>
-#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>
+#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/port.h"
+#include "google/protobuf/unknown_field_set.h"
+#include "google/protobuf/wire_format.h"
-// clang-format off
-#include <google/protobuf/port_def.inc>
-// clang-format on
+// must be last
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
namespace internal {
+using ::google::protobuf::internal::DownCast;
const char* TcParser::GenericFallback(PROTOBUF_TC_PARAM_DECL) {
return GenericFallbackImpl<Message, UnknownFieldSet>(PROTOBUF_TC_PARAM_PASS);
}
+const char* TcParser::ReflectionFallback(PROTOBUF_TC_PARAM_DECL) {
+ if (PROTOBUF_PREDICT_FALSE(MustFallbackToGeneric(PROTOBUF_TC_PARAM_PASS))) {
+ PROTOBUF_MUSTTAIL return GenericFallback(PROTOBUF_TC_PARAM_PASS);
+ }
+
+ SyncHasbits(msg, hasbits, table);
+ arc_ui32 tag = data.tag();
+ if (tag == 0 || (tag & 7) == WireFormatLite::WIRETYPE_END_GROUP) {
+ ctx->SetLastTag(tag);
+ return ptr;
+ }
+
+ auto* full_msg = DownCast<Message*>(msg);
+ auto* descriptor = full_msg->GetDescriptor();
+ auto* reflection = full_msg->GetReflection();
+ int field_number = WireFormatLite::GetTagFieldNumber(tag);
+ const FieldDescriptor* field = descriptor->FindFieldByNumber(field_number);
+
+ // If that failed, check if the field is an extension.
+ if (field == nullptr && descriptor->IsExtensionNumber(field_number)) {
+ if (ctx->data().pool == nullptr) {
+ field = reflection->FindKnownExtensionByNumber(field_number);
+ } else {
+ field = ctx->data().pool->FindExtensionByNumber(descriptor, field_number);
+ }
+ }
+
+ return WireFormat::_InternalParseAndMergeField(full_msg, ptr, ctx, tag,
+ reflection, field);
+}
+
+const char* TcParser::ReflectionParseLoop(PROTOBUF_TC_PARAM_DECL) {
+ (void)data;
+ (void)table;
+ (void)hasbits;
+ // Call into the wire format reflective parse loop.
+ return WireFormat::_InternalParse(DownCast<Message*>(msg), ptr, ctx);
+}
+
} // namespace internal
} // namespace protobuf
} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_gen.cc b/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_gen.cc
new file mode 100644
index 00000000000..78712020e5e
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_gen.cc
@@ -0,0 +1,835 @@
+// 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_tctable_gen.h"
+
+#include <algorithm>
+#include <limits>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/generated_message_tctable_decl.h"
+#include "google/protobuf/generated_message_tctable_impl.h"
+#include "google/protobuf/wire_format.h"
+
+// Must come last:
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace internal {
+
+namespace {
+
+bool GetEnumValidationRange(const EnumDescriptor* enum_type, int16_t& start,
+ uint16_t& size) {
+ Y_ABSL_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 = static_cast<int>(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 (std::numeric_limits<int16_t>::min() <= enum_values[0] &&
+ enum_values[0] <= std::numeric_limits<int16_t>::max() &&
+ enum_values.size() <= std::numeric_limits<uint16_t>::max() &&
+ static_cast<int>(enum_values[0] + enum_values.size() - 1) ==
+ enum_values.back()) {
+ start = static_cast<int16_t>(enum_values[0]);
+ size = static_cast<uint16_t>(enum_values.size());
+ return true;
+ } else {
+ return false;
+ }
+}
+
+void PopulateFastFieldEntry(const TailCallTableInfo::FieldEntryInfo& entry,
+ const TailCallTableInfo::PerFieldOptions& options,
+ TailCallTableInfo::FastFieldInfo& info) {
+ const FieldDescriptor* field = entry.field;
+ TProtoStringType name = "::_pbi::TcParser::Fast";
+ uint8_t aux_idx = static_cast<uint8_t>(entry.aux_idx);
+
+ static const char* kPrefix[] = {
+ nullptr, // 0
+ "F64", // TYPE_DOUBLE = 1,
+ "F32", // TYPE_FLOAT = 2,
+ "V64", // TYPE_INT64 = 3,
+ "V64", // TYPE_UINT64 = 4,
+ "V32", // TYPE_INT32 = 5,
+ "F64", // TYPE_FIXED64 = 6,
+ "F32", // TYPE_FIXED32 = 7,
+ "V8", // TYPE_BOOL = 8,
+ "", // TYPE_STRING = 9,
+ "G", // TYPE_GROUP = 10,
+ "M", // TYPE_MESSAGE = 11,
+ "B", // TYPE_BYTES = 12,
+ "V32", // TYPE_UINT32 = 13,
+ "", // TYPE_ENUM = 14,
+ "F32", // TYPE_SFIXED32 = 15,
+ "F64", // TYPE_SFIXED64 = 16,
+ "Z32", // TYPE_SINT32 = 17,
+ "Z64", // TYPE_SINT64 = 18,
+ };
+ name.append(kPrefix[field->type()]);
+
+ if (field->type() == field->TYPE_ENUM) {
+ // Enums are handled as:
+ // - V32 for open enums
+ // - Er (and Er0/Er1) for sequential enums
+ // - Ev for the rest
+ if (cpp::HasPreservingUnknownEnumSemantics(field)) {
+ name.append("V32");
+ } else {
+ int16_t start;
+ uint16_t size;
+ if (GetEnumValidationRange(field->enum_type(), start, size)) {
+ name.append("Er");
+ int max_value = start + size - 1;
+ if (max_value <= 127 && (start == 0 || start == 1)) {
+ name.append(1, '0' + start);
+ aux_idx = max_value;
+ }
+ } else {
+ name.append("Ev");
+ }
+ }
+ }
+ if (field->type() == field->TYPE_STRING) {
+ switch (internal::cpp::GetUtf8CheckMode(field, options.is_lite)) {
+ case internal::cpp::Utf8CheckMode::kStrict:
+ name.append("U");
+ break;
+ case internal::cpp::Utf8CheckMode::kVerify:
+ name.append("S");
+ break;
+ case internal::cpp::Utf8CheckMode::kNone:
+ name.append("B");
+ break;
+ }
+ }
+ if (field->type() == field->TYPE_STRING ||
+ field->type() == field->TYPE_BYTES) {
+ if (field->options().ctype() == FieldOptions::CORD) {
+ name.append("c");
+ } else if (options.is_string_inlined) {
+ name.append("i");
+ Y_ABSL_CHECK(!field->is_repeated());
+ aux_idx = static_cast<uint8_t>(entry.inlined_string_idx);
+ }
+ }
+ if (field->type() == field->TYPE_MESSAGE ||
+ field->type() == field->TYPE_GROUP) {
+ name.append(options.use_direct_tcparser_table ? "t" : "d");
+ }
+
+ // 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");
+
+ // Append the tag length. Fast parsing only handles 1- or 2-byte tags.
+ name.append(field->number() < 16 ? "1" : "2");
+
+ info.func_name = std::move(name);
+ info.aux_idx = aux_idx;
+}
+
+bool IsFieldEligibleForFastParsing(
+ const TailCallTableInfo::FieldEntryInfo& entry,
+ const TailCallTableInfo::OptionProvider& option_provider) {
+ const auto* field = entry.field;
+ const auto options = option_provider.GetForField(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() || options.is_implicitly_weak ||
+ options.is_lazy || options.should_split) {
+ return false;
+ }
+
+ // 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;
+
+ switch (field->type()) {
+ // Some bytes fields can be handled on fast path.
+ case FieldDescriptor::TYPE_STRING:
+ case FieldDescriptor::TYPE_BYTES:
+ if (field->options().ctype() == FieldOptions::STRING) {
+ // strings are fine...
+ } else if (field->options().ctype() == FieldOptions::CORD) {
+ // Cords are worth putting into the fast table, if they're not repeated
+ if (field->is_repeated()) return false;
+ } else {
+ return false;
+ }
+ if (options.is_string_inlined) {
+ Y_ABSL_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;
+
+ default:
+ break;
+ }
+
+ if (cpp::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.
+ Y_ABSL_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;
+}
+
+y_absl::optional<arc_ui32> GetEndGroupTag(const Descriptor* descriptor) {
+ auto* parent = descriptor->containing_type();
+ if (parent == nullptr) return y_absl::nullopt;
+ for (int i = 0; i < parent->field_count(); ++i) {
+ auto* field = parent->field(i);
+ if (field->type() == field->TYPE_GROUP &&
+ field->message_type() == descriptor) {
+ return WireFormatLite::MakeTag(field->number(),
+ WireFormatLite::WIRETYPE_END_GROUP);
+ }
+ }
+ return y_absl::nullopt;
+}
+
+arc_ui32 RecodeTagForFastParsing(arc_ui32 tag) {
+ Y_ABSL_DCHECK_LE(tag, 0x3FFF);
+ // 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) {
+ // hi = tag & ~0x7F
+ // lo = tag & 0x7F
+ // This shifts hi to the left by 1 to the next byte and sets the
+ // continuation bit.
+ tag = tag + hibits + 128;
+ }
+ return tag;
+}
+
+std::vector<TailCallTableInfo::FastFieldInfo> SplitFastFieldsForSize(
+ y_absl::optional<arc_ui32> end_group_tag,
+ const std::vector<TailCallTableInfo::FieldEntryInfo>& field_entries,
+ int table_size_log2,
+ const TailCallTableInfo::OptionProvider& option_provider) {
+ std::vector<TailCallTableInfo::FastFieldInfo> result(1 << table_size_log2);
+ const arc_ui32 idx_mask = static_cast<arc_ui32>(result.size() - 1);
+ const auto tag_to_idx = [&](arc_ui32 tag) {
+ // 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
+ // 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.
+ return (tag >> 3) & idx_mask;
+ };
+
+ if (end_group_tag.has_value() && (*end_group_tag >> 14) == 0) {
+ // Fits in 1 or 2 varint bytes.
+ const arc_ui32 tag = RecodeTagForFastParsing(*end_group_tag);
+ const arc_ui32 fast_idx = tag_to_idx(tag);
+
+ TailCallTableInfo::FastFieldInfo& info = result[fast_idx];
+ info.func_name = "::_pbi::TcParser::FastEndG";
+ info.func_name.append(*end_group_tag < 128 ? "1" : "2");
+ info.coded_tag = tag;
+ info.nonfield_info = *end_group_tag;
+ }
+
+ for (const auto& entry : field_entries) {
+ if (!IsFieldEligibleForFastParsing(entry, option_provider)) {
+ continue;
+ }
+
+ const auto* field = entry.field;
+ const auto options = option_provider.GetForField(field);
+ const arc_ui32 tag = RecodeTagForFastParsing(WireFormat::MakeTag(field));
+ const arc_ui32 fast_idx = tag_to_idx(tag);
+
+ TailCallTableInfo::FastFieldInfo& info = result[fast_idx];
+ if (!info.func_name.empty()) {
+ // This field entry is already filled.
+ continue;
+ }
+
+ // Fill in this field's entry:
+ Y_ABSL_CHECK(info.func_name.empty()) << info.func_name;
+ PopulateFastFieldEntry(entry, options, info);
+ 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 = cpp::HasHasbit(field) ? entry.hasbit_idx : 63;
+ }
+ return result;
+}
+
+// Filter out fields that will be handled by mini parsing.
+std::vector<const FieldDescriptor*> FilterMiniParsedFields(
+ const std::vector<const FieldDescriptor*>& fields,
+ const TailCallTableInfo::OptionProvider& option_provider
+) {
+ std::vector<const FieldDescriptor*> generated_fallback_fields;
+
+ for (const auto* field : fields) {
+ auto options = option_provider.GetForField(field);
+
+ bool handled = false;
+ switch (field->type()) {
+ case FieldDescriptor::TYPE_DOUBLE:
+ case FieldDescriptor::TYPE_FLOAT:
+ 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_SINT64:
+ case FieldDescriptor::TYPE_INT64:
+ case FieldDescriptor::TYPE_ENUM:
+ case FieldDescriptor::TYPE_BYTES:
+ case FieldDescriptor::TYPE_STRING:
+ // These are handled by MiniParse, so we don't need any generated
+ // fallback code.
+ handled = true;
+ break;
+
+
+ case FieldDescriptor::TYPE_MESSAGE:
+ case FieldDescriptor::TYPE_GROUP:
+ // TODO(b/210762816): support remaining field types.
+ if (field->is_map() || field->options().weak() || options.is_lazy) {
+ handled = false;
+ } else {
+ handled = true;
+ }
+ break;
+
+ default:
+ handled = false;
+ break;
+ }
+ if (!handled) generated_fallback_fields.push_back(field);
+ }
+
+ return generated_fallback_fields;
+}
+
+// We only need field names for reporting UTF-8 parsing errors, so we only
+// emit them for string fields with Utf8 transform specified.
+y_absl::string_view FieldNameForTable(
+ const TailCallTableInfo::FieldEntryInfo& entry) {
+ const auto* field = entry.field;
+ if (field->type() == FieldDescriptor::TYPE_STRING) {
+ const uint16_t xform_val = entry.type_card & field_layout::kTvMask;
+
+ switch (xform_val) {
+ case field_layout::kTvUtf8:
+ case field_layout::kTvUtf8Debug:
+ return field->name();
+ }
+ }
+ return "";
+}
+
+std::vector<uint8_t> GenerateFieldNames(
+ const Descriptor* descriptor,
+ const std::vector<TailCallTableInfo::FieldEntryInfo>& entries) {
+ static constexpr int kMaxNameLength = 255;
+ std::vector<uint8_t> out;
+
+ bool found_needed_name = false;
+ for (const auto& entry : entries) {
+ if (!FieldNameForTable(entry).empty()) {
+ found_needed_name = true;
+ break;
+ }
+ }
+
+ // No names needed. Omit the whole table.
+ if (!found_needed_name) {
+ return out;
+ }
+
+ // First, we output the size of each string, as an unsigned byte. The first
+ // string is the message name.
+ int count = 1;
+ out.push_back(std::min(static_cast<int>(descriptor->full_name().size()),
+ kMaxNameLength));
+ for (const auto& entry : entries) {
+ out.push_back(FieldNameForTable(entry).size());
+ ++count;
+ }
+ while (count & 7) { // align to an 8-byte boundary
+ out.push_back(0);
+ ++count;
+ }
+ // The message name is stored at the beginning of the string
+ std::string message_name = descriptor->full_name();
+ if (message_name.size() > kMaxNameLength) {
+ static constexpr int kNameHalfLength = (kMaxNameLength - 3) / 2;
+ message_name = y_absl::StrCat(
+ message_name.substr(0, kNameHalfLength), "...",
+ message_name.substr(message_name.size() - kNameHalfLength));
+ }
+ out.insert(out.end(), message_name.begin(), message_name.end());
+ // Then we output the actual field names
+ for (const auto& entry : entries) {
+ const auto& field_name = FieldNameForTable(entry);
+ out.insert(out.end(), field_name.begin(), field_name.end());
+ }
+
+ return out;
+}
+
+TailCallTableInfo::NumToEntryTable MakeNumToEntryTable(
+ const std::vector<const FieldDescriptor*>& field_descriptors) {
+ TailCallTableInfo::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;
+
+ TailCallTableInfo::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 = static_cast<arc_ui32>(field_descriptor->number());
+ Y_ABSL_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({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;
+}
+
+uint16_t MakeTypeCardForField(
+ const FieldDescriptor* field,
+ const TailCallTableInfo::PerFieldOptions& options) {
+ uint16_t type_card;
+ namespace fl = internal::field_layout;
+ if (internal::cpp::HasHasbit(field)) {
+ type_card = fl::kFcOptional;
+ } else if (field->is_repeated()) {
+ type_card = fl::kFcRepeated;
+ } else if (field->real_containing_oneof()) {
+ type_card = fl::kFcOneof;
+ } else {
+ type_card = fl::kFcSingular;
+ }
+
+ // The rest of the type uses convenience aliases:
+ switch (field->type()) {
+ case FieldDescriptor::TYPE_DOUBLE:
+ type_card |= field->is_repeated() && field->is_packed()
+ ? fl::kPackedDouble
+ : fl::kDouble;
+ break;
+ case FieldDescriptor::TYPE_FLOAT:
+ type_card |= field->is_repeated() && field->is_packed() ? fl::kPackedFloat
+ : fl::kFloat;
+ break;
+ case FieldDescriptor::TYPE_FIXED32:
+ type_card |= field->is_repeated() && field->is_packed()
+ ? fl::kPackedFixed32
+ : fl::kFixed32;
+ break;
+ case FieldDescriptor::TYPE_SFIXED32:
+ type_card |= field->is_repeated() && field->is_packed()
+ ? fl::kPackedSFixed32
+ : fl::kSFixed32;
+ break;
+ case FieldDescriptor::TYPE_FIXED64:
+ type_card |= field->is_repeated() && field->is_packed()
+ ? fl::kPackedFixed64
+ : fl::kFixed64;
+ break;
+ case FieldDescriptor::TYPE_SFIXED64:
+ type_card |= field->is_repeated() && field->is_packed()
+ ? fl::kPackedSFixed64
+ : fl::kSFixed64;
+ break;
+ case FieldDescriptor::TYPE_BOOL:
+ type_card |= field->is_repeated() && field->is_packed() ? fl::kPackedBool
+ : fl::kBool;
+ break;
+ case FieldDescriptor::TYPE_ENUM:
+ if (internal::cpp::HasPreservingUnknownEnumSemantics(field)) {
+ // No validation is required.
+ type_card |= field->is_repeated() && field->is_packed()
+ ? fl::kPackedOpenEnum
+ : fl::kOpenEnum;
+ } else {
+ int16_t start;
+ uint16_t size;
+ if (GetEnumValidationRange(field->enum_type(), start, size)) {
+ // Validation is done by range check (start/length in FieldAux).
+ type_card |= field->is_repeated() && field->is_packed()
+ ? fl::kPackedEnumRange
+ : fl::kEnumRange;
+ } else {
+ // Validation uses the generated _IsValid function.
+ type_card |= field->is_repeated() && field->is_packed()
+ ? fl::kPackedEnum
+ : fl::kEnum;
+ }
+ }
+ break;
+ case FieldDescriptor::TYPE_UINT32:
+ type_card |= field->is_repeated() && field->is_packed()
+ ? fl::kPackedUInt32
+ : fl::kUInt32;
+ break;
+ case FieldDescriptor::TYPE_SINT32:
+ type_card |= field->is_repeated() && field->is_packed()
+ ? fl::kPackedSInt32
+ : fl::kSInt32;
+ break;
+ case FieldDescriptor::TYPE_INT32:
+ type_card |= field->is_repeated() && field->is_packed() ? fl::kPackedInt32
+ : fl::kInt32;
+ break;
+ case FieldDescriptor::TYPE_UINT64:
+ type_card |= field->is_repeated() && field->is_packed()
+ ? fl::kPackedUInt64
+ : fl::kUInt64;
+ break;
+ case FieldDescriptor::TYPE_SINT64:
+ type_card |= field->is_repeated() && field->is_packed()
+ ? fl::kPackedSInt64
+ : fl::kSInt64;
+ break;
+ case FieldDescriptor::TYPE_INT64:
+ type_card |= field->is_repeated() && field->is_packed() ? fl::kPackedInt64
+ : fl::kInt64;
+ break;
+
+ case FieldDescriptor::TYPE_BYTES:
+ type_card |= fl::kBytes;
+ break;
+ case FieldDescriptor::TYPE_STRING: {
+ switch (internal::cpp::GetUtf8CheckMode(field, options.is_lite)) {
+ case internal::cpp::Utf8CheckMode::kStrict:
+ type_card |= fl::kUtf8String;
+ break;
+ case internal::cpp::Utf8CheckMode::kVerify:
+ type_card |= fl::kRawString;
+ break;
+ case internal::cpp::Utf8CheckMode::kNone:
+ type_card |= fl::kBytes;
+ break;
+ }
+ break;
+ }
+
+ case FieldDescriptor::TYPE_GROUP:
+ type_card |= 0 | fl::kMessage | fl::kRepGroup;
+ if (options.is_implicitly_weak) {
+ type_card |= fl::kTvWeakPtr;
+ } else if (options.use_direct_tcparser_table) {
+ type_card |= fl::kTvTable;
+ } else {
+ type_card |= fl::kTvDefault;
+ }
+ break;
+ case FieldDescriptor::TYPE_MESSAGE:
+ if (field->is_map()) {
+ type_card |= fl::kMap;
+ } else {
+ type_card |= fl::kMessage;
+ if (options.is_lazy) {
+ type_card |= fl::kRepLazy;
+ }
+
+ if (options.is_implicitly_weak) {
+ type_card |= fl::kTvWeakPtr;
+ } else if (options.use_direct_tcparser_table) {
+ type_card |= fl::kTvTable;
+ } else {
+ type_card |= fl::kTvDefault;
+ }
+ }
+ 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()) {
+ type_card |= fl::kRepSString;
+ } else {
+ type_card |= fl::kRepAString;
+ }
+ }
+
+ if (options.should_split) {
+ type_card |= fl::kSplitTrue;
+ }
+
+ return type_card;
+}
+
+} // namespace
+
+TailCallTableInfo::TailCallTableInfo(
+ const Descriptor* descriptor,
+ const std::vector<const FieldDescriptor*>& ordered_fields,
+ const OptionProvider& option_provider,
+ const std::vector<int>& has_bit_indices,
+ const std::vector<int>& inlined_string_indices) {
+ // If this message has any inlined string fields, store the donation state
+ // offset in the first auxiliary entry, which is kInlinedStringAuxIdx.
+ if (!inlined_string_indices.empty()) {
+ aux_entries.resize(kInlinedStringAuxIdx + 1); // Allocate our slot
+ aux_entries[kInlinedStringAuxIdx] = {kInlinedStringDonatedOffset};
+ }
+
+ // If this message is split, store the split pointer offset in the second
+ // and third auxiliary entries, which are kSplitOffsetAuxIdx and
+ // kSplitSizeAuxIdx.
+ for (auto* field : ordered_fields) {
+ if (option_provider.GetForField(field).should_split) {
+ static_assert(kSplitOffsetAuxIdx + 1 == kSplitSizeAuxIdx, "");
+ aux_entries.resize(kSplitSizeAuxIdx + 1); // Allocate our 2 slots
+ aux_entries[kSplitOffsetAuxIdx] = {kSplitOffset};
+ aux_entries[kSplitSizeAuxIdx] = {kSplitSizeof};
+ break;
+ }
+ }
+
+ // Fill in mini table entries.
+ for (const FieldDescriptor* field : ordered_fields) {
+ auto options = option_provider.GetForField(field);
+ field_entries.push_back(
+ {field, internal::cpp ::HasHasbit(field)
+ ? has_bit_indices[static_cast<size_t>(field->index())]
+ : -1});
+ auto& entry = field_entries.back();
+ entry.type_card = MakeTypeCardForField(field, options);
+
+ 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 (field->options().weak()) {
+ // Don't generate anything for weak fields. They are handled by the
+ // generated fallback.
+ } else if (options.is_lazy) {
+ // Lazy fields are handled by the generated fallback function.
+ } else {
+ field_entries.back().aux_idx = aux_entries.size();
+ aux_entries.push_back({options.is_implicitly_weak ? kSubMessageWeak
+ : options.use_direct_tcparser_table
+ ? kSubTable
+ : kSubMessage,
+ {field}});
+ }
+ } else if (field->type() == FieldDescriptor::TYPE_ENUM &&
+ !cpp::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();
+ aux_entries.push_back({});
+ auto& aux_entry = aux_entries.back();
+
+ if (GetEnumValidationRange(field->enum_type(), aux_entry.enum_range.start,
+ aux_entry.enum_range.size)) {
+ aux_entry.type = kEnumRange;
+ } else {
+ aux_entry.type = kEnumValidator;
+ aux_entry.field = field;
+ }
+
+ } else if ((field->type() == FieldDescriptor::TYPE_STRING ||
+ field->type() == FieldDescriptor::TYPE_BYTES) &&
+ options.is_string_inlined) {
+ Y_ABSL_CHECK(!field->is_repeated());
+ // Inlined strings have an extra marker to represent their donation state.
+ int idx = inlined_string_indices[static_cast<size_t>(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({kNumericOffset});
+ aux_entries.back().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;
+ }
+ }
+
+ table_size_log2 = 0; // fallback value
+ int num_fast_fields = -1;
+ auto end_group_tag = GetEndGroupTag(descriptor);
+ for (int try_size_log2 : {0, 1, 2, 3, 4, 5}) {
+ size_t try_size = 1 << try_size_log2;
+ auto split_fields = SplitFastFieldsForSize(end_group_tag, field_entries,
+ try_size_log2, option_provider);
+ Y_ABSL_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 (end_group_tag.has_value()) {
+ // If this message uses group encoding, the tables are sometimes very
+ // sparse because the fields in the group avoid using the same field
+ // numbering as the parent message (even though currently, the proto
+ // compiler allows the overlap, and there is no possible conflict.)
+ // As such, this test produces a false negative as far as whether the
+ // large table will be worth it. So we disable the test in this case.
+ } else {
+ if (try_size > ordered_fields.size()) {
+ break;
+ }
+ }
+ }
+
+ // 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, option_provider
+ );
+
+ num_to_entry_table = MakeNumToEntryTable(ordered_fields);
+ Y_ABSL_CHECK_EQ(field_entries.size(), ordered_fields.size());
+ field_name_data = GenerateFieldNames(descriptor, field_entries);
+
+ // 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.
+ use_generated_fallback =
+ !fallback_fields.empty() || descriptor->extension_range_count() > 1;
+}
+
+} // namespace internal
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_gen.h b/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_gen.h
new file mode 100644
index 00000000000..062793bfc82
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/generated_message_tctable_gen.h
@@ -0,0 +1,164 @@
+// 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.
+
+// This file contains routines to generate tail-call table parsing tables.
+// Everything in this file is for internal use only.
+
+#ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_TCTABLE_GEN_H__
+#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_TCTABLE_GEN_H__
+
+#include <cstdint>
+#include <functional>
+#include <string>
+#include <vector>
+
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/generated_message_tctable_decl.h"
+
+// Must come last:
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace internal {
+
+// Helper class for generating tailcall parsing functions.
+struct PROTOBUF_EXPORT TailCallTableInfo {
+ struct PerFieldOptions {
+ bool is_lazy;
+ bool is_string_inlined;
+ bool is_implicitly_weak;
+ bool use_direct_tcparser_table;
+ bool is_lite;
+ bool should_split;
+ };
+ class OptionProvider {
+ public:
+ virtual PerFieldOptions GetForField(const FieldDescriptor*) const = 0;
+
+ protected:
+ ~OptionProvider() = default;
+ };
+
+ TailCallTableInfo(const Descriptor* descriptor,
+ const std::vector<const FieldDescriptor*>& ordered_fields,
+ const OptionProvider& option_provider,
+ const std::vector<int>& has_bit_indices,
+ const std::vector<int>& inlined_string_indices);
+
+ // 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;
+ uint16_t nonfield_info;
+ };
+ 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;
+ uint16_t type_card;
+ };
+ std::vector<FieldEntryInfo> field_entries;
+
+ enum AuxType {
+ kNothing = 0,
+ kInlinedStringDonatedOffset,
+ kSplitOffset,
+ kSplitSizeof,
+ kSubMessage,
+ kSubTable,
+ kSubMessageWeak,
+ kEnumRange,
+ kEnumValidator,
+ kNumericOffset,
+ };
+ struct AuxEntry {
+ AuxType type;
+ struct EnumRange {
+ int16_t start;
+ uint16_t size;
+ };
+ union {
+ const FieldDescriptor* field;
+ arc_ui32 offset;
+ EnumRange enum_range;
+ };
+ };
+ std::vector<AuxEntry> aux_entries;
+
+ // Fields parsed by generated fallback function.
+ std::vector<const FieldDescriptor*> fallback_fields;
+
+ 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 += static_cast<int>(3 + block.entries.size() * 2);
+ }
+ return size;
+ }
+ };
+ NumToEntryTable num_to_entry_table;
+
+ std::vector<uint8_t> field_name_data;
+
+ // Table size.
+ int table_size_log2;
+ // True if a generated fallback function is required instead of generic.
+ bool use_generated_fallback;
+};
+
+} // namespace internal
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_TCTABLE_GEN_H__
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 0f95846ccdf..708302648d4 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
@@ -32,18 +32,20 @@
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_TCTABLE_IMPL_H__
#include <cstdint>
+#include <cstdlib>
+#include <string>
#include <type_traits>
+#include <utility>
-#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/parse_context.h>
-#include <google/protobuf/wire_format_lite.h>
+#include "google/protobuf/port.h"
+#include "google/protobuf/extension_set.h"
+#include "google/protobuf/generated_message_tctable_decl.h"
+#include "google/protobuf/metadata_lite.h"
+#include "google/protobuf/parse_context.h"
+#include "google/protobuf/wire_format_lite.h"
// Must come last:
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -53,6 +55,12 @@ class UnknownFieldSet;
namespace internal {
+enum {
+ kInlinedStringAuxIdx = 0,
+ kSplitOffsetAuxIdx = 1,
+ kSplitSizeAuxIdx = 2,
+};
+
// Field layout enums.
//
// Structural information about fields is packed into a 16-bit value. The enum
@@ -64,10 +72,11 @@ namespace internal {
// |15 .. 8|7 .. 0|
// +-----------------------+-----------------------+
// : . : . : . : . : . : . : 3|========| [3] FieldType
-// : : : : : : 5|=====| : : [2] FieldCardinality
-// : . : . : . : . 8|========| : . : . : [3] FieldRep
-// : : : 10|=====| : : : : [2] TransformValidation
-// : . : .12|=====| . : . : . : . : . : [2] FormatDiscriminator
+// : : : : : : . 4|==| : : [1] FieldSplit
+// : : : : : 6|=====| . : : [2] FieldCardinality
+// : . : . : . : 9|========| . : . : . : [3] FieldRep
+// : : :11|=====| : : : : : [2] TransformValidation
+// : . :13|=====| : . : . : . : . : . : [2] FormatDiscriminator
// +-----------------------+-----------------------+
// |15 .. 8|7 .. 0|
// +-----------------------+-----------------------+
@@ -95,11 +104,21 @@ enum FieldKind : uint16_t {
static_assert(kFkMap < (1 << kFkBits), "too many types");
+// Split (1 bit):
+enum FieldSplit : uint16_t {
+ kSplitShift = kFkShift+ kFkBits,
+ kSplitBits = 1,
+ kSplitMask = ((1 << kSplitBits) - 1) << kSplitShift,
+
+ kSplitFalse = 0,
+ kSplitTrue = 1 << kSplitShift,
+};
+
// 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,
+ kFcShift = kSplitShift+ kSplitBits,
kFcBits = 2,
kFcMask = ((1 << kFcBits) - 1) << kFcShift,
@@ -123,14 +142,13 @@ enum FieldRep : uint16_t {
// String types:
kRepAString = 0, // ArenaStringPtr
kRepIString = 1 << kRepShift, // InlinedString
- kRepCord = 2 << kRepShift, // absl::Cord
+ kRepCord = 2 << kRepShift, // y_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):
@@ -147,6 +165,11 @@ enum TransformValidation : uint16_t {
// String fields:
kTvUtf8Debug = 1 << kTvShift, // proto2
kTvUtf8 = 2 << kTvShift, // proto3
+
+ // Message fields:
+ kTvDefault = 1 << kTvShift, // Aux has default_instance*
+ kTvTable = 2 << kTvShift, // Aux has TcParseTableBase*
+ kTvWeakPtr = 3 << kTvShift, // Aux has default_instance** (for weak)
};
static_assert((kTvEnum & kTvRange) != 0,
@@ -175,7 +198,7 @@ enum FormatDiscriminator : uint16_t {
};
// Update this assertion (and comments above) when adding or removing bits:
-static_assert(kFmtShift + kFmtBits == 12, "number of bits changed");
+static_assert(kFmtShift + kFmtBits == 13, "number of bits changed");
// This assertion should not change unless the storage width changes:
static_assert(kFmtShift + kFmtBits <= 16, "too many bits");
@@ -183,48 +206,48 @@ 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,
+ kBool = 0 | kFkVarint | kRep8Bits,
+
+ kFixed32 = 0 | kFkFixed | kRep32Bits | kFmtUnsigned,
+ kUInt32 = 0 | kFkVarint | kRep32Bits | kFmtUnsigned,
+ kSFixed32 = 0 | kFkFixed | kRep32Bits | kFmtSigned,
+ kInt32 = 0 | kFkVarint | kRep32Bits | kFmtSigned,
+ kSInt32 = 0 | kFkVarint | kRep32Bits | kFmtSigned | kTvZigZag,
+ kFloat = 0 | kFkFixed | kRep32Bits | kFmtFloating,
+ kEnum = 0 | kFkVarint | kRep32Bits | kFmtEnum | kTvEnum,
+ kEnumRange = 0 | kFkVarint | kRep32Bits | kFmtEnum | kTvRange,
+ kOpenEnum = 0 | kFkVarint | kRep32Bits | kFmtEnum,
+
+ kFixed64 = 0 | kFkFixed | kRep64Bits | kFmtUnsigned,
+ kUInt64 = 0 | kFkVarint | kRep64Bits | kFmtUnsigned,
+ kSFixed64 = 0 | kFkFixed | kRep64Bits | kFmtSigned,
+ kInt64 = 0 | kFkVarint | kRep64Bits | kFmtSigned,
+ kSInt64 = 0 | kFkVarint | kRep64Bits | kFmtSigned | kTvZigZag,
+ kDouble = 0 | kFkFixed | kRep64Bits | kFmtFloating,
+
+ kPackedBool = 0 | kFkPackedVarint | kRep8Bits,
+
+ kPackedFixed32 = 0 | kFkPackedFixed | kRep32Bits | kFmtUnsigned,
+ kPackedUInt32 = 0 | kFkPackedVarint | kRep32Bits | kFmtUnsigned,
+ kPackedSFixed32 = 0 | kFkPackedFixed | kRep32Bits | kFmtSigned,
+ kPackedInt32 = 0 | kFkPackedVarint | kRep32Bits | kFmtSigned,
+ kPackedSInt32 = 0 | kFkPackedVarint | kRep32Bits | kFmtSigned | kTvZigZag,
+ kPackedFloat = 0 | kFkPackedFixed | kRep32Bits | kFmtFloating,
+ kPackedEnum = 0 | kFkPackedVarint | kRep32Bits | kFmtEnum | kTvEnum,
+ kPackedEnumRange = 0 | kFkPackedVarint | kRep32Bits | kFmtEnum | kTvRange,
+ kPackedOpenEnum = 0 | kFkPackedVarint | kRep32Bits | kFmtEnum,
+
+ kPackedFixed64 = 0 | kFkPackedFixed | kRep64Bits | kFmtUnsigned,
+ kPackedUInt64 = 0 | kFkPackedVarint | kRep64Bits | kFmtUnsigned,
+ kPackedSFixed64 = 0 | kFkPackedFixed | kRep64Bits | kFmtSigned,
+ kPackedInt64 = 0 | kFkPackedVarint | kRep64Bits | kFmtSigned,
+ kPackedSInt64 = 0 | kFkPackedVarint | kRep64Bits | kFmtSigned | kTvZigZag,
+ kPackedDouble = 0 | kFkPackedFixed | kRep64Bits | kFmtFloating,
// String types:
- kBytes = kFkString | kFmtArray,
- kRawString = kFkString | kFmtUtf8 | kTvUtf8Debug,
- kUtf8String = kFkString | kFmtUtf8 | kTvUtf8,
+ kBytes = 0 | kFkString | kFmtArray,
+ kRawString = 0 | kFkString | kFmtUtf8 | kTvUtf8Debug,
+ kUtf8String = 0 | kFkString | kFmtUtf8 | kTvUtf8,
// Message types:
kMessage = kFkMessage,
@@ -232,38 +255,51 @@ enum FieldType : uint16_t {
// 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.
-//
-// Note that this is performance sensitive: changing the parameters will change
-// the registers used by the ABI calling convention, which subsequently affects
-// register selection logic inside the function.
-
-// PROTOBUF_TC_PARAM_PASS passes values to match PROTOBUF_TC_PARAM_DECL.
-#define PROTOBUF_TC_PARAM_PASS msg, ptr, ctx, table, hasbits, data
-
#ifndef NDEBUG
-template <size_t align>
-#ifndef _MSC_VER
-[[noreturn]]
-#endif
-void AlignFail(uintptr_t address) {
- GOOGLE_LOG(FATAL) << "Unaligned (" << align << ") access at " << address;
-}
-
-extern template void AlignFail<4>(uintptr_t);
-extern template void AlignFail<8>(uintptr_t);
+PROTOBUF_EXPORT void AlignFail(std::integral_constant<size_t, 4>,
+ std::uintptr_t address);
+PROTOBUF_EXPORT void AlignFail(std::integral_constant<size_t, 8>,
+ std::uintptr_t address);
+inline void AlignFail(std::integral_constant<size_t, 1>,
+ std::uintptr_t address) {}
#endif
// TcParser implements most of the parsing logic for tailcall tables.
class PROTOBUF_EXPORT TcParser final {
public:
+ template <typename T>
+ static constexpr const TcParseTableBase* GetTable() {
+ return &T::_table_.header;
+ }
+
+ // == ABI of the tail call functions ==
+ // All the tail call functions have the same signature as required by clang's
+ // `musttail` attribute. However, their ABIs are different.
+ // See TcFieldData's comments for details on the layouts.
+ // The ABIs are as follow:
+ //
+ // - The following functions ignore `data`:
+ // ToTagDispatch, TagDispatch, MiniParse, ToParseLoop, Error,
+ // FastUnknownEnumFallback.
+ // - FastXXX functions expect `data` with a fast table entry ABI.
+ // - FastEndGX functions expect `data` with a non-field entry ABI.
+ // - MpXXX functions expect `data` with a mini table ABI.
+ // - The fallback functions (both GenericFallbackXXX and the codegen ones)
+ // expect only the tag in `data`. In addition, if a null `ptr` is passed,
+ // the function is used as a way to get a UnknownFieldOps vtable, returned
+ // via the `const char*` return type. See `GetUnknownFieldOps()`
+
+ static bool MustFallbackToGeneric(PROTOBUF_TC_PARAM_DECL) {
+ return ptr == nullptr;
+ }
+
static const char* GenericFallback(PROTOBUF_TC_PARAM_DECL);
static const char* GenericFallbackLite(PROTOBUF_TC_PARAM_DECL);
+ static const char* ReflectionFallback(PROTOBUF_TC_PARAM_DECL);
+ static const char* ReflectionParseLoop(PROTOBUF_TC_PARAM_DECL);
static const char* ParseLoop(MessageLite* msg, const char* ptr,
ParseContext* ctx,
@@ -323,19 +359,73 @@ class PROTOBUF_EXPORT TcParser final {
static const char* FastZ64P1(PROTOBUF_TC_PARAM_DECL);
static const char* FastZ64P2(PROTOBUF_TC_PARAM_DECL);
+ // Manually unrolled and specialized Varint parsing.
+ template <typename FieldType, int data_offset, int hasbit_idx>
+ static const char* FastTV32S1(PROTOBUF_TC_PARAM_DECL);
+ template <typename FieldType, int data_offset, int hasbit_idx>
+ static const char* FastTV64S1(PROTOBUF_TC_PARAM_DECL);
+ template <int data_offset, int hasbit_idx>
+ static const char* FastTV8S1(PROTOBUF_TC_PARAM_DECL);
+
+ template <typename FieldType, int data_offset, int hasbit_idx>
+ static constexpr TailCallParseFunc SingularVarintNoZag1() {
+ if (sizeof(FieldType) == 1) {
+ if (data_offset < 100) {
+ return &FastTV8S1<data_offset, hasbit_idx>;
+ } else {
+ return &FastV8S1;
+ }
+ }
+ if (sizeof(FieldType) == 4) {
+ if (data_offset < 100) {
+ return &FastTV32S1<FieldType, data_offset, hasbit_idx>;
+ } else { //
+ return &FastV32S1;
+ }
+ }
+ if (sizeof(FieldType) == 8) {
+ if (data_offset < 128) {
+ return &FastTV64S1<FieldType, data_offset, hasbit_idx>;
+ } else {
+ return &FastV64S1;
+ }
+ }
+ static_assert(sizeof(FieldType) == 1 || sizeof(FieldType) == 4 ||
+ sizeof(FieldType) == 8,
+ "");
+ Y_ABSL_LOG(FATAL) << "This should be unreachable";
+ }
+
// 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
+ // S: singular R: repeated P: packed
// 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* FastErP1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastErP2(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);
+ static const char* FastEvP1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastEvP2(PROTOBUF_TC_PARAM_DECL);
+
+ static const char* FastEr0S1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastEr0S2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastEr0R1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastEr0R2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastEr0P1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastEr0P2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastEr1S1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastEr1S2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastEr1R1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastEr1R2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastEr1P1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastEr1P2(PROTOBUF_TC_PARAM_DECL);
// Functions referenced by generated fast tables (string types):
// B: bytes S: string U: UTF-8 string
@@ -362,18 +452,35 @@ class PROTOBUF_EXPORT TcParser final {
static const char* FastUiS1(PROTOBUF_TC_PARAM_DECL);
static const char* FastUiS2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastBcS1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastBcS2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastScS1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastScS2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastUcS1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastUcS2(PROTOBUF_TC_PARAM_DECL);
+
// Functions referenced by generated fast tables (message types):
// M: message G: group
+ // d: default* t: TcParseTable* (the contents of aux)
// 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);
+ static const char* FastMdS1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastMdS2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastGdS1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastGdS2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastMtS1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastMtS2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastGtS1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastGtS2(PROTOBUF_TC_PARAM_DECL);
+
+ static const char* FastMdR1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastMdR2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastGdR1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastGdR2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastMtR1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastMtR2(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastGtR1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastGtR2(PROTOBUF_TC_PARAM_DECL);
template <typename T>
static inline T& RefAt(void* x, size_t offset) {
@@ -381,7 +488,10 @@ class PROTOBUF_EXPORT TcParser final {
#ifndef NDEBUG
if (PROTOBUF_PREDICT_FALSE(
reinterpret_cast<uintptr_t>(target) % alignof(T) != 0)) {
- AlignFail<alignof(T)>(reinterpret_cast<uintptr_t>(target));
+ AlignFail(std::integral_constant<size_t, alignof(T)>(),
+ reinterpret_cast<uintptr_t>(target));
+ // Explicit abort to let compilers know this code-path does not return
+ abort();
}
#endif
return *target;
@@ -394,7 +504,10 @@ class PROTOBUF_EXPORT TcParser final {
#ifndef NDEBUG
if (PROTOBUF_PREDICT_FALSE(
reinterpret_cast<uintptr_t>(target) % alignof(T) != 0)) {
- AlignFail<alignof(T)>(reinterpret_cast<uintptr_t>(target));
+ AlignFail(std::integral_constant<size_t, alignof(T)>(),
+ reinterpret_cast<uintptr_t>(target));
+ // Explicit abort to let compilers know this code-path does not return
+ abort();
}
#endif
return *target;
@@ -418,21 +531,41 @@ class PROTOBUF_EXPORT TcParser final {
// parsing.
static const char* MiniParse(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastEndG1(PROTOBUF_TC_PARAM_DECL);
+ static const char* FastEndG2(PROTOBUF_TC_PARAM_DECL);
+
private:
friend class GeneratedTcTableLiteTest;
+ static void* MaybeGetSplitBase(MessageLite* msg, const bool is_split,
+ const TcParseTableBase* table);
+
+ // Test only access to verify that the right function is being called via
+ // MiniParse.
+ struct TestMiniParseResult {
+ TailCallParseFunc called_func;
+ arc_ui32 tag;
+ const TcParseTableBase::FieldEntry* found_entry;
+ const char* ptr;
+ };
+ static TestMiniParseResult TestMiniParse(PROTOBUF_TC_PARAM_DECL);
+ template <bool export_called_function>
+ static const char* MiniParse(PROTOBUF_TC_PARAM_DECL);
- template <typename TagType, bool group_coding>
+ template <typename TagType, bool group_coding, bool aux_is_table>
static inline const char* SingularParseMessageAuxImpl(PROTOBUF_TC_PARAM_DECL);
- template <typename TagType, bool group_coding>
+ template <typename TagType, bool group_coding, bool aux_is_table>
static inline const char* RepeatedParseMessageAuxImpl(PROTOBUF_TC_PARAM_DECL);
+ template <typename TagType>
+ static const char* FastEndGroupImpl(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;
if (has_bits_offset) {
// Only the first 32 has-bits are updated. Nothing above those is stored,
// but e.g. messages without has-bits update the upper bits.
- RefAt<arc_ui32>(msg, has_bits_offset) = static_cast<arc_ui32>(hasbits);
+ RefAt<arc_ui32>(msg, has_bits_offset) |= static_cast<arc_ui32>(hasbits);
}
}
@@ -445,18 +578,46 @@ class PROTOBUF_EXPORT TcParser final {
class ScopedArenaSwap;
+ struct UnknownFieldOps {
+ void (*write_varint)(MessageLite* msg, int number, int value);
+ void (*write_length_delimited)(MessageLite* msg, int number,
+ y_absl::string_view value);
+ };
+
+ static const UnknownFieldOps& GetUnknownFieldOps(
+ const TcParseTableBase* table);
+
+ template <typename UnknownFieldsT>
+ static void WriteVarintToUnknown(MessageLite* msg, int number, int value) {
+ internal::WriteVarint(
+ number, value,
+ msg->_internal_metadata_.mutable_unknown_fields<UnknownFieldsT>());
+ }
+ template <typename UnknownFieldsT>
+ static void WriteLengthDelimitedToUnknown(MessageLite* msg, int number,
+ y_absl::string_view value) {
+ internal::WriteLengthDelimited(
+ number, value,
+ msg->_internal_metadata_.mutable_unknown_fields<UnknownFieldsT>());
+ }
+
template <class MessageBaseT, class UnknownFieldsT>
static const char* GenericFallbackImpl(PROTOBUF_TC_PARAM_DECL) {
-#define CHK_(x) \
- if (PROTOBUF_PREDICT_FALSE(!(x))) return nullptr /* NOLINT */
+ if (PROTOBUF_PREDICT_FALSE(ptr == nullptr)) {
+ // This is the ABI used by GetUnknownFieldOps(). Return the vtable.
+ static constexpr UnknownFieldOps kOps = {
+ WriteVarintToUnknown<UnknownFieldsT>,
+ WriteLengthDelimitedToUnknown<UnknownFieldsT>};
+ return reinterpret_cast<const char*>(&kOps);
+ }
SyncHasbits(msg, hasbits, table);
- CHK_(ptr);
arc_ui32 tag = data.tag();
if ((tag & 7) == WireFormatLite::WIRETYPE_END_GROUP || tag == 0) {
ctx->SetLastTag(tag);
return ptr;
}
+
arc_ui32 num = tag >> 3;
if (table->extension_range_low <= num &&
num <= table->extension_range_high) {
@@ -465,10 +626,10 @@ class PROTOBUF_EXPORT TcParser final {
static_cast<const MessageBaseT*>(table->default_instance),
&msg->_internal_metadata_, ctx);
}
+
return UnknownFieldParse(
tag, msg->_internal_metadata_.mutable_unknown_fields<UnknownFieldsT>(),
ptr, ctx);
-#undef CHK_
}
// Note: `inline` is needed on template function declarations below to avoid
@@ -497,21 +658,36 @@ class PROTOBUF_EXPORT TcParser final {
// 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, uint8_t min>
+ static inline const char* SingularEnumSmallRange(PROTOBUF_TC_PARAM_DECL);
template <typename TagType, uint16_t xform_val>
static inline const char* RepeatedEnum(PROTOBUF_TC_PARAM_DECL);
+ template <typename TagType, uint16_t xform_val>
+ static inline const char* PackedEnum(PROTOBUF_TC_PARAM_DECL);
+ template <typename TagType, uint8_t min>
+ static inline const char* RepeatedEnumSmallRange(PROTOBUF_TC_PARAM_DECL);
+ template <typename TagType, uint8_t min>
+ static inline const char* PackedEnumSmallRange(PROTOBUF_TC_PARAM_DECL);
// Implementations for fast string field parsing functions:
enum Utf8Type { kNoUtf8 = 0, kUtf8 = 1, kUtf8ValidateOnly = 2 };
- template <typename TagType, Utf8Type utf8>
+ template <typename TagType, typename FieldType, Utf8Type utf8>
static inline const char* SingularString(PROTOBUF_TC_PARAM_DECL);
- template <typename TagType, Utf8Type utf8>
+ template <typename TagType, typename FieldType, Utf8Type utf8>
static inline const char* RepeatedString(PROTOBUF_TC_PARAM_DECL);
+ static inline const char* ParseRepeatedStringOnce(
+ const char* ptr, Arena* arena, SerialArena* serial_arena,
+ ParseContext* ctx, RepeatedPtrField<TProtoStringType>& field);
+
+ static void UnknownPackedEnum(MessageLite* msg, const TcParseTableBase* table,
+ arc_ui32 tag, arc_i32 enum_value);
+
// 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,
+ static y_absl::string_view MessageName(const TcParseTableBase* table);
+ static y_absl::string_view FieldName(const TcParseTableBase* table,
const TcParseTableBase::FieldEntry*);
static bool ChangeOneof(const TcParseTableBase* table,
const TcParseTableBase::FieldEntry& entry,
@@ -521,33 +697,330 @@ class PROTOBUF_EXPORT TcParser final {
// UTF-8 validation:
static void ReportFastUtf8Error(arc_ui32 decoded_tag,
const TcParseTableBase* table);
- static bool MpVerifyUtf8(StringPiece wire_bytes,
+ static bool MpVerifyUtf8(y_absl::string_view wire_bytes,
const TcParseTableBase* table,
const TcParseTableBase::FieldEntry& entry,
uint16_t xform_val);
// For FindFieldEntry tests:
friend class FindFieldEntryTest;
+ friend struct ParseFunctionGeneratorTestPeer;
+ friend struct FuzzPeer;
static constexpr const arc_ui32 kMtSmallScanSize = 4;
// Mini parsing:
+ template <bool is_split>
static const char* MpVarint(PROTOBUF_TC_PARAM_DECL);
static const char* MpRepeatedVarint(PROTOBUF_TC_PARAM_DECL);
static const char* MpPackedVarint(PROTOBUF_TC_PARAM_DECL);
+ template <bool is_split>
static const char* MpFixed(PROTOBUF_TC_PARAM_DECL);
static const char* MpRepeatedFixed(PROTOBUF_TC_PARAM_DECL);
static const char* MpPackedFixed(PROTOBUF_TC_PARAM_DECL);
+ template <bool is_split>
static const char* MpString(PROTOBUF_TC_PARAM_DECL);
static const char* MpRepeatedString(PROTOBUF_TC_PARAM_DECL);
+ template <bool is_split>
static const char* MpMessage(PROTOBUF_TC_PARAM_DECL);
static const char* MpRepeatedMessage(PROTOBUF_TC_PARAM_DECL);
- static const char* MpMap(PROTOBUF_TC_PARAM_DECL);
+ static const char* MpFallback(PROTOBUF_TC_PARAM_DECL);
};
+// Shift "byte" left by n * 7 bits, filling vacated bits with ones.
+template <int n>
+inline PROTOBUF_ALWAYS_INLINE arc_i64 shift_left_fill_with_ones(arc_ui64 byte,
+ arc_ui64 ones) {
+ return static_cast<arc_i64>((byte << (n * 7)) | (ones >> (64 - (n * 7))));
+}
+
+// Shift "byte" left by n * 7 bits, filling vacated bits with ones, and
+// put the new value in res. Return whether the result was negative.
+template <int n>
+inline PROTOBUF_ALWAYS_INLINE bool shift_left_fill_with_ones_was_negative(
+ arc_ui64 byte, arc_ui64 ones, arc_i64& res) {
+#if defined(__GCC_ASM_FLAG_OUTPUTS__) && defined(__x86_64__)
+ // For the first two rounds (ptr[1] and ptr[2]), micro benchmarks show a
+ // substantial improvement from capturing the sign from the condition code
+ // register on x86-64.
+ bool sign_bit;
+ asm("shldq %3, %2, %1"
+ : "=@ccs"(sign_bit), "+r"(byte)
+ : "r"(ones), "i"(n * 7));
+ res = static_cast<arc_i64>(byte);
+ return sign_bit;
+#else
+ // Generic fallback:
+ res = shift_left_fill_with_ones<n>(byte, ones);
+ return res < 0;
+#endif
+}
+
+template <class VarintType>
+inline PROTOBUF_ALWAYS_INLINE std::pair<const char*, VarintType>
+ParseFallbackPair(const char* p, arc_i64 res1) {
+ constexpr bool kIs64BitVarint = std::is_same<VarintType, arc_ui64>::value;
+ constexpr bool kIs32BitVarint = std::is_same<VarintType, arc_ui32>::value;
+ static_assert(kIs64BitVarint || kIs32BitVarint,
+ "Only 32 or 64 bit varints are supported");
+ auto ptr = reinterpret_cast<const int8_t*>(p);
+
+ // The algorithm relies on sign extension for each byte to set all high bits
+ // when the varint continues. It also relies on asserting all of the lower
+ // bits for each successive byte read. This allows the result to be aggregated
+ // using a bitwise AND. For example:
+ //
+ // 8 1 64 57 ... 24 17 16 9 8 1
+ // ptr[0] = 1aaa aaaa ; res1 = 1111 1111 ... 1111 1111 1111 1111 1aaa aaaa
+ // ptr[1] = 1bbb bbbb ; res2 = 1111 1111 ... 1111 1111 11bb bbbb b111 1111
+ // ptr[2] = 1ccc cccc ; res3 = 0000 0000 ... 000c cccc cc11 1111 1111 1111
+ // ---------------------------------------------
+ // res1 & res2 & res3 = 0000 0000 ... 000c cccc ccbb bbbb baaa aaaa
+ //
+ // On x86-64, a shld from a single register filled with enough 1s in the high
+ // bits can accomplish all this in one instruction. It so happens that res1
+ // has 57 high bits of ones, which is enough for the largest shift done.
+ //
+ // Just as importantly, by keeping results in res1, res2, and res3, we take
+ // advantage of the superscalar abilities of the CPU.
+ Y_ABSL_DCHECK_EQ(res1 >> 7, -1);
+ arc_ui64 ones = res1; // save the high 1 bits from res1 (input to SHLD)
+ arc_i64 res2, res3; // accumulated result chunks
+
+ if (!shift_left_fill_with_ones_was_negative<1>(ptr[1], ones, res2))
+ goto done2;
+ if (!shift_left_fill_with_ones_was_negative<2>(ptr[2], ones, res3))
+ goto done3;
+
+ // For the remainder of the chunks, check the sign of the AND result.
+ res2 &= shift_left_fill_with_ones<3>(ptr[3], ones);
+ if (res2 >= 0) goto done4;
+ res1 &= shift_left_fill_with_ones<4>(ptr[4], ones);
+ if (res1 >= 0) goto done5;
+ if (kIs64BitVarint) {
+ res2 &= shift_left_fill_with_ones<5>(ptr[5], ones);
+ if (res2 >= 0) goto done6;
+ res3 &= shift_left_fill_with_ones<6>(ptr[6], ones);
+ if (res3 >= 0) goto done7;
+ res1 &= shift_left_fill_with_ones<7>(ptr[7], ones);
+ if (res1 >= 0) goto done8;
+ res3 &= shift_left_fill_with_ones<8>(ptr[8], ones);
+ if (res3 >= 0) goto done9;
+ } else if (kIs32BitVarint) {
+ if (PROTOBUF_PREDICT_TRUE(!(ptr[5] & 0x80))) goto done6;
+ if (PROTOBUF_PREDICT_TRUE(!(ptr[6] & 0x80))) goto done7;
+ if (PROTOBUF_PREDICT_TRUE(!(ptr[7] & 0x80))) goto done8;
+ if (PROTOBUF_PREDICT_TRUE(!(ptr[8] & 0x80))) goto done9;
+ }
+
+ // For valid 64bit varints, the 10th byte/ptr[9] should be exactly 1. In this
+ // case, the continuation bit of ptr[8] already set the top bit of res3
+ // correctly, so all we have to do is check that the expected case is true.
+ if (PROTOBUF_PREDICT_TRUE(kIs64BitVarint && ptr[9] == 1)) goto done10;
+
+ if (PROTOBUF_PREDICT_FALSE(ptr[9] & 0x80)) {
+ // If the continue bit is set, it is an unterminated varint.
+ return {nullptr, 0};
+ }
+
+ // A zero value of the first bit of the 10th byte represents an
+ // over-serialized varint. This case should not happen, but if does (say, due
+ // to a nonconforming serializer), deassert the continuation bit that came
+ // from ptr[8].
+ if (kIs64BitVarint && (ptr[9] & 1) == 0) {
+#if defined(__GCC_ASM_FLAG_OUTPUTS__) && defined(__x86_64__)
+ // Use a small instruction since this is an uncommon code path.
+ asm("btcq $63,%0" : "+r"(res3));
+#else
+ res3 ^= static_cast<arc_ui64>(1) << 63;
+#endif
+ }
+ goto done10;
+
+done2:
+ return {p + 2, res1 & res2};
+done3:
+ return {p + 3, res1 & res2 & res3};
+done4:
+ return {p + 4, res1 & res2 & res3};
+done5:
+ return {p + 5, res1 & res2 & res3};
+done6:
+ return {p + 6, res1 & res2 & res3};
+done7:
+ return {p + 7, res1 & res2 & res3};
+done8:
+ return {p + 8, res1 & res2 & res3};
+done9:
+ return {p + 9, res1 & res2 & res3};
+done10:
+ return {p + 10, res1 & res2 & res3};
+}
+
+// Notes:
+// 1) if data_offset is negative, it's read from data.offset()
+// 2) if hasbit_idx is negative, it's read from data.hasbit_idx()
+template <int data_offset, int hasbit_idx>
+PROTOBUF_NOINLINE const char* TcParser::FastTV8S1(PROTOBUF_TC_PARAM_DECL) {
+ using TagType = uint8_t;
+
+ // Special case for a varint bool field with a tag of 1 byte:
+ // The coded_tag() field will actually contain the value too and we can check
+ // both at the same time.
+ auto coded_tag = data.coded_tag<uint16_t>();
+ if (PROTOBUF_PREDICT_TRUE(coded_tag == 0x0000 || coded_tag == 0x0100)) {
+ auto& field =
+ RefAt<bool>(msg, data_offset >= 0 ? data_offset : data.offset());
+ // Note: we use `data.data` because Clang generates suboptimal code when
+ // using coded_tag.
+ // In x86_64 this uses the CH register to read the second byte out of
+ // `data`.
+ uint8_t value = data.data >> 8;
+ // The assume allows using a mov instead of test+setne.
+ PROTOBUF_ASSUME(value <= 1);
+ field = static_cast<bool>(value);
+
+ ptr += sizeof(TagType) + 1; // Consume the tag and the value.
+ if (hasbit_idx < 0) {
+ hasbits |= (arc_ui64{1} << data.hasbit_idx());
+ } else {
+ if (hasbit_idx < 32) {
+ // `& 31` avoids a compiler warning when hasbit_idx is negative.
+ hasbits |= (arc_ui64{1} << (hasbit_idx & 31));
+ } else {
+ static_assert(hasbit_idx == 63 || (hasbit_idx < 32),
+ "hard-coded hasbit_idx should be 0-31, or the special"
+ "value 63, which indicates the field has no has-bit.");
+ // TODO(jorg): investigate whether higher hasbit indices are worth
+ // supporting. Something like:
+ // auto& hasblock = TcParser::RefAt<arc_ui32>(msg, hasbit_idx / 32 * 4);
+ // hasblock |= arc_ui32{1} << (hasbit_idx % 32);
+ }
+ }
+
+ PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
+ }
+
+ // If it didn't match above either the tag is wrong, or the value is encoded
+ // non-canonically.
+ // Jump to MiniParse as wrong tag is the most probable reason.
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+}
+
+template <typename FieldType, int data_offset, int hasbit_idx>
+PROTOBUF_NOINLINE const char* TcParser::FastTV64S1(PROTOBUF_TC_PARAM_DECL) {
+ using TagType = uint8_t;
+ // super-early success test...
+ if (PROTOBUF_PREDICT_TRUE(((data.data) & 0x80FF) == 0)) {
+ ptr += sizeof(TagType); // Consume tag
+ if (hasbit_idx < 32) {
+ hasbits |= (arc_ui64{1} << hasbit_idx);
+ }
+ uint8_t value = data.data >> 8;
+ RefAt<FieldType>(msg, data_offset) = value;
+ ptr += 1;
+ PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
+ }
+ if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+ }
+ ptr += sizeof(TagType); // Consume tag
+ if (hasbit_idx < 32) {
+ hasbits |= (arc_ui64{1} << hasbit_idx);
+ }
+
+ auto tmp =
+ ParseFallbackPair<arc_ui64>(ptr, static_cast<int8_t>(data.data >> 8));
+ data.data = 0; // Indicate to the compiler that we don't need this anymore.
+ ptr = tmp.first;
+ if (PROTOBUF_PREDICT_FALSE(ptr == nullptr)) {
+ return Error(PROTOBUF_TC_PARAM_PASS);
+ }
+
+ RefAt<FieldType>(msg, data_offset) = static_cast<FieldType>(tmp.second);
+ PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
+}
+
+template <typename FieldType, int data_offset, int hasbit_idx>
+PROTOBUF_NOINLINE const char* TcParser::FastTV32S1(PROTOBUF_TC_PARAM_DECL) {
+ using TagType = uint8_t;
+ // super-early success test...
+ if (PROTOBUF_PREDICT_TRUE(((data.data) & 0x80FF) == 0)) {
+ ptr += sizeof(TagType); // Consume tag
+ if (hasbit_idx < 32) {
+ hasbits |= (arc_ui64{1} << hasbit_idx);
+ }
+ uint8_t value = data.data >> 8;
+ RefAt<FieldType>(msg, data_offset) = value;
+ ptr += 1;
+ PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
+ }
+ if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+ }
+ ptr += sizeof(TagType); // Consume tag
+ if (hasbit_idx < 32) {
+ hasbits |= (arc_ui64{1} << hasbit_idx);
+ }
+
+ auto tmp =
+ ParseFallbackPair<arc_ui32>(ptr, static_cast<int8_t>(data.data >> 8));
+ data.data = 0; // Indicate to the compiler that we don't need this anymore.
+ ptr = tmp.first;
+ if (PROTOBUF_PREDICT_FALSE(ptr == nullptr)) {
+ return Error(PROTOBUF_TC_PARAM_PASS);
+ }
+
+ RefAt<FieldType>(msg, data_offset) = static_cast<FieldType>(tmp.second);
+ PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
+}
+
+// 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;
+}
+
} // namespace internal
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_TCTABLE_IMPL_H__
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 23266c60d67..364b18d3b80 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
@@ -30,17 +30,21 @@
#include <cstdint>
#include <numeric>
+#include <string>
+#include <type_traits>
+#include <utility>
+
+#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"
+#include "utf8_validity.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
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
// clang-format on
namespace google {
@@ -54,8 +58,18 @@ using FieldEntry = TcParseTableBase::FieldEntry;
//////////////////////////////////////////////////////////////////////////////
#ifndef NDEBUG
-template void AlignFail<4>(uintptr_t);
-template void AlignFail<8>(uintptr_t);
+void AlignFail(std::integral_constant<size_t, 4>, std::uintptr_t address) {
+ Y_ABSL_LOG(FATAL) << "Unaligned (4) access at " << address;
+
+ // Explicit abort to let compilers know this function does not return
+ abort();
+}
+void AlignFail(std::integral_constant<size_t, 8>, std::uintptr_t address) {
+ Y_ABSL_LOG(FATAL) << "Unaligned (8) access at " << address;
+
+ // Explicit abort to let compilers know this function does not return
+ abort();
+}
#endif
const char* TcParser::GenericFallbackLite(PROTOBUF_TC_PARAM_DECL) {
@@ -66,78 +80,31 @@ const char* TcParser::GenericFallbackLite(PROTOBUF_TC_PARAM_DECL) {
// 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);
+ // Note: TagDispatch uses a dispatch table at "&table->fast_entries".
+ // For fast dispatch, we'd like to have a pointer to that, but if we use
+ // that expression, there's no easy way to get back to "table", which we also
+ // need during dispatch. It turns out that "table + 1" points exactly to
+ // fast_entries, so we just increment table by 1 here, to get the register
+ // holding the value we want.
+ table += 1;
while (!ctx->Done(&ptr)) {
- // Unconditionally read has bits, even if we don't have has bits.
- // has_bits_offset will be 0 and we will just read something valid.
- arc_ui64 hasbits = ReadAt<arc_ui32>(msg, table->has_bits_offset);
- ptr = TagDispatch(msg, ptr, ctx, table, hasbits, {});
+#if defined(__GNUC__)
+ // Note: this asm prevents the compiler (clang, specifically) from
+ // believing (thanks to CSE) that it needs to dedicate a registeer both
+ // to "table" and "&table->fast_entries".
+ // TODO(b/64614992): remove this asm
+ asm("" : "+r"(table));
+#endif
+ ptr = TagDispatch(msg, ptr, ctx, {}, table - 1, 0);
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;
@@ -271,7 +238,7 @@ const TcParseTableBase::FieldEntry* TcParser::FindFieldEntry(
// 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,
+static y_absl::string_view 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
@@ -287,11 +254,11 @@ static StringPiece FindName(const char* name_data, size_t entries,
return {start, size};
}
-StringPiece TcParser::MessageName(const TcParseTableBase* table) {
+y_absl::string_view TcParser::MessageName(const TcParseTableBase* table) {
return FindName(table->name_data(), table->num_field_entries + 1, 0);
}
-StringPiece TcParser::FieldName(const TcParseTableBase* table,
+y_absl::string_view 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);
@@ -299,13 +266,25 @@ StringPiece TcParser::FieldName(const TcParseTableBase* table,
field_index + 1);
}
-const char* TcParser::MiniParse(PROTOBUF_TC_PARAM_DECL) {
+template <bool export_called_function>
+inline PROTOBUF_ALWAYS_INLINE const char* TcParser::MiniParse(
+ PROTOBUF_TC_PARAM_DECL) {
+ TestMiniParseResult* test_out;
+ if (export_called_function) {
+ test_out = reinterpret_cast<TestMiniParseResult*>(
+ static_cast<uintptr_t>(data.data));
+ }
+
arc_ui32 tag;
ptr = ReadTagInlined(ptr, &tag);
- if (PROTOBUF_PREDICT_FALSE(ptr == nullptr)) return nullptr;
+ if (PROTOBUF_PREDICT_FALSE(ptr == nullptr)) {
+ if (export_called_function) *test_out = {Error};
+ return Error(PROTOBUF_TC_PARAM_PASS);
+ }
auto* entry = FindFieldEntry(table, tag >> 3);
if (entry == nullptr) {
+ if (export_called_function) *test_out = {table->fallback, tag};
data.data = tag;
PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
}
@@ -318,36 +297,94 @@ const char* TcParser::MiniParse(PROTOBUF_TC_PARAM_DECL) {
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);
- }
+ auto field_type =
+ entry->type_card & (+field_layout::kSplitMask | FieldKind::kFkMask);
+
+ static constexpr TailCallParseFunc kMiniParseTable[] = {
+ &MpFallback, // FieldKind::kFkNone
+ &MpVarint<false>, // FieldKind::kFkVarint
+ &MpPackedVarint, // FieldKind::kFkPackedVarint
+ &MpFixed<false>, // FieldKind::kFkFixed
+ &MpPackedFixed, // FieldKind::kFkPackedFixed
+ &MpString<false>, // FieldKind::kFkString
+ &MpMessage<false>, // FieldKind::kFkMessage
+ &MpFallback, // FieldKind::kFkMap
+ &Error, // kSplitMask | FieldKind::kFkNone
+ &MpVarint<true>, // kSplitMask | FieldKind::kFkVarint
+ &Error, // kSplitMask | FieldKind::kFkPackedVarint
+ &MpFixed<true>, // kSplitMask | FieldKind::kFkFixed
+ &Error, // kSplitMask | FieldKind::kFkPackedFixed
+ &MpString<true>, // kSplitMask | FieldKind::kFkString
+ &MpMessage<true>, // kSplitMask | FieldKind::kFkMessage
+ &Error, // kSplitMask | FieldKind::kFkMap
+ };
+ // Just to be sure we got the order right, above.
+ static_assert(0 == FieldKind::kFkNone, "Invalid table order");
+ static_assert(1 == FieldKind::kFkVarint, "Invalid table order");
+ static_assert(2 == FieldKind::kFkPackedVarint, "Invalid table order");
+ static_assert(3 == FieldKind::kFkFixed, "Invalid table order");
+ static_assert(4 == FieldKind::kFkPackedFixed, "Invalid table order");
+ static_assert(5 == FieldKind::kFkString, "Invalid table order");
+ static_assert(6 == FieldKind::kFkMessage, "Invalid table order");
+ static_assert(7 == FieldKind::kFkMap, "Invalid table order");
+
+ static_assert(8 == (+field_layout::kSplitMask | FieldKind::kFkNone),
+ "Invalid table order");
+ static_assert(9 == (+field_layout::kSplitMask | FieldKind::kFkVarint),
+ "Invalid table order");
+ static_assert(10 == (+field_layout::kSplitMask | FieldKind::kFkPackedVarint),
+ "Invalid table order");
+ static_assert(11 == (+field_layout::kSplitMask | FieldKind::kFkFixed),
+ "Invalid table order");
+ static_assert(12 == (+field_layout::kSplitMask | FieldKind::kFkPackedFixed),
+ "Invalid table order");
+ static_assert(13 == (+field_layout::kSplitMask | FieldKind::kFkString),
+ "Invalid table order");
+ static_assert(14 == (+field_layout::kSplitMask | FieldKind::kFkMessage),
+ "Invalid table order");
+ static_assert(15 == (+field_layout::kSplitMask | FieldKind::kFkMap),
+ "Invalid table order");
+
+ TailCallParseFunc parse_fn = kMiniParseTable[field_type];
+ if (export_called_function) *test_out = {parse_fn, tag, entry};
+
+ PROTOBUF_MUSTTAIL return parse_fn(PROTOBUF_TC_PARAM_PASS);
+}
+
+PROTOBUF_NOINLINE const char* TcParser::MiniParse(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return MiniParse<false>(PROTOBUF_TC_PARAM_PASS);
+}
+PROTOBUF_NOINLINE TcParser::TestMiniParseResult TcParser::TestMiniParse(
+ PROTOBUF_TC_PARAM_DECL) {
+ TestMiniParseResult result = {};
+ data.data = reinterpret_cast<uintptr_t>(&result);
+ result.ptr = MiniParse<true>(PROTOBUF_TC_PARAM_PASS);
+ return result;
}
-namespace {
+const char* TcParser::MpFallback(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
+}
-// Offset returns the address `offset` bytes after `base`.
-inline void* Offset(void* base, arc_ui32 offset) {
- return static_cast<uint8_t*>(base) + offset;
+template <typename TagType>
+const char* TcParser::FastEndGroupImpl(PROTOBUF_TC_PARAM_DECL) {
+ if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+ }
+ ctx->SetLastTag(data.decoded_tag());
+ ptr += sizeof(TagType);
+ PROTOBUF_MUSTTAIL return ToParseLoop(PROTOBUF_TC_PARAM_PASS);
}
+PROTOBUF_NOINLINE const char* TcParser::FastEndG1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return FastEndGroupImpl<uint8_t>(PROTOBUF_TC_PARAM_PASS);
+}
+PROTOBUF_NOINLINE const char* TcParser::FastEndG2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return FastEndGroupImpl<uint16_t>(PROTOBUF_TC_PARAM_PASS);
+}
+
+namespace {
+
// InvertPacked changes tag bits from the given wire type to length
// delimited. This is the difference expected between packed and non-packed
// repeated fields.
@@ -362,9 +399,9 @@ inline PROTOBUF_ALWAYS_INLINE void InvertPacked(TcFieldData& data) {
// Message fields
//////////////////////////////////////////////////////////////////////////////
-template <typename TagType, bool group_coding>
-inline PROTOBUF_ALWAYS_INLINE
-const char* TcParser::SingularParseMessageAuxImpl(PROTOBUF_TC_PARAM_DECL) {
+template <typename TagType, bool group_coding, bool aux_is_table>
+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);
}
@@ -373,74 +410,145 @@ const char* TcParser::SingularParseMessageAuxImpl(PROTOBUF_TC_PARAM_DECL) {
hasbits |= (arc_ui64{1} << data.hasbit_idx());
SyncHasbits(msg, hasbits, table);
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);
- }
- if (group_coding) {
- return ctx->ParseGroup(field, ptr, FastDecodeTag(saved_tag));
+
+ if (aux_is_table) {
+ const auto* inner_table = table->field_aux(data.aux_idx())->table;
+ if (field == nullptr) {
+ field = inner_table->default_instance->New(msg->GetArenaForAllocation());
+ }
+ if (group_coding) {
+ return ctx->ParseGroup<TcParser>(field, ptr, FastDecodeTag(saved_tag),
+ inner_table);
+ }
+ return ctx->ParseMessage<TcParser>(field, ptr, inner_table);
+ } else {
+ if (field == nullptr) {
+ const MessageLite* default_instance =
+ table->field_aux(data.aux_idx())->message_default();
+ field = default_instance->New(msg->GetArenaForAllocation());
+ }
+ if (group_coding) {
+ return ctx->ParseGroup(field, ptr, FastDecodeTag(saved_tag));
+ }
+ return ctx->ParseMessage(field, ptr);
}
- return ctx->ParseMessage(field, ptr);
}
-const char* TcParser::FastMS1(PROTOBUF_TC_PARAM_DECL) {
- PROTOBUF_MUSTTAIL return SingularParseMessageAuxImpl<uint8_t, false>(
+PROTOBUF_NOINLINE const char* TcParser::FastMdS1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularParseMessageAuxImpl<uint8_t, false, false>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+PROTOBUF_NOINLINE const char* TcParser::FastMdS2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularParseMessageAuxImpl<uint16_t, false, false>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+PROTOBUF_NOINLINE const char* TcParser::FastGdS1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularParseMessageAuxImpl<uint8_t, true, false>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+PROTOBUF_NOINLINE const char* TcParser::FastGdS2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularParseMessageAuxImpl<uint16_t, true, false>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+PROTOBUF_NOINLINE const char* TcParser::FastMtS1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularParseMessageAuxImpl<uint8_t, false, true>(
PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastMS2(PROTOBUF_TC_PARAM_DECL) {
- PROTOBUF_MUSTTAIL return SingularParseMessageAuxImpl<uint16_t, false>(
+PROTOBUF_NOINLINE const char* TcParser::FastMtS2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularParseMessageAuxImpl<uint16_t, false, true>(
PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastGS1(PROTOBUF_TC_PARAM_DECL) {
- PROTOBUF_MUSTTAIL return SingularParseMessageAuxImpl<uint8_t, true>(
+PROTOBUF_NOINLINE const char* TcParser::FastGtS1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularParseMessageAuxImpl<uint8_t, true, true>(
PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastGS2(PROTOBUF_TC_PARAM_DECL) {
- PROTOBUF_MUSTTAIL return SingularParseMessageAuxImpl<uint16_t, true>(
+PROTOBUF_NOINLINE const char* TcParser::FastGtS2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularParseMessageAuxImpl<uint16_t, true, true>(
PROTOBUF_TC_PARAM_PASS);
}
-template <typename TagType, bool group_coding>
-inline PROTOBUF_ALWAYS_INLINE
-const char* TcParser::RepeatedParseMessageAuxImpl(PROTOBUF_TC_PARAM_DECL) {
+template <typename TagType, bool group_coding, bool aux_is_table>
+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;
+ const auto expected_tag = UnalignedLoad<TagType>(ptr);
+ const auto aux = *table->field_aux(data.aux_idx());
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);
+ do {
+ ptr += sizeof(TagType);
+ MessageLite* submsg = field.Add<GenericTypeHandler<MessageLite>>(
+ aux_is_table ? aux.table->default_instance : aux.message_default());
+ if (aux_is_table) {
+ if (group_coding) {
+ ptr = ctx->ParseGroup<TcParser>(submsg, ptr,
+ FastDecodeTag(expected_tag), aux.table);
+ } else {
+ ptr = ctx->ParseMessage<TcParser>(submsg, ptr, aux.table);
+ }
+ } else {
+ if (group_coding) {
+ ptr = ctx->ParseGroup(submsg, ptr, FastDecodeTag(expected_tag));
+ } else {
+ ptr = ctx->ParseMessage(submsg, ptr);
+ }
+ }
+ if (PROTOBUF_PREDICT_FALSE(ptr == nullptr)) {
+ PROTOBUF_MUSTTAIL return Error(PROTOBUF_TC_PARAM_PASS);
+ }
+ if (PROTOBUF_PREDICT_FALSE(!ctx->DataAvailable(ptr))) {
+ PROTOBUF_MUSTTAIL return ToParseLoop(PROTOBUF_TC_PARAM_PASS);
+ }
+ } while (UnalignedLoad<TagType>(ptr) == expected_tag);
+
+ PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
+}
+
+PROTOBUF_NOINLINE const char* TcParser::FastMdR1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedParseMessageAuxImpl<uint8_t, false, false>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+PROTOBUF_NOINLINE const char* TcParser::FastMdR2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedParseMessageAuxImpl<uint16_t, false, false>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+PROTOBUF_NOINLINE const char* TcParser::FastGdR1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedParseMessageAuxImpl<uint8_t, true, false>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+PROTOBUF_NOINLINE const char* TcParser::FastGdR2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedParseMessageAuxImpl<uint16_t, true, false>(
+ PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastMR1(PROTOBUF_TC_PARAM_DECL) {
- PROTOBUF_MUSTTAIL return RepeatedParseMessageAuxImpl<uint8_t, false>(
+PROTOBUF_NOINLINE const char* TcParser::FastMtR1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedParseMessageAuxImpl<uint8_t, false, true>(
PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastMR2(PROTOBUF_TC_PARAM_DECL) {
- PROTOBUF_MUSTTAIL return RepeatedParseMessageAuxImpl<uint16_t, false>(
+PROTOBUF_NOINLINE const char* TcParser::FastMtR2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedParseMessageAuxImpl<uint16_t, false, true>(
PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastGR1(PROTOBUF_TC_PARAM_DECL) {
- PROTOBUF_MUSTTAIL return RepeatedParseMessageAuxImpl<uint8_t, true>(
+PROTOBUF_NOINLINE const char* TcParser::FastGtR1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedParseMessageAuxImpl<uint8_t, true, true>(
PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastGR2(PROTOBUF_TC_PARAM_DECL) {
- PROTOBUF_MUSTTAIL return RepeatedParseMessageAuxImpl<uint16_t, true>(
+PROTOBUF_NOINLINE const char* TcParser::FastGtR2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedParseMessageAuxImpl<uint16_t, true, true>(
PROTOBUF_TC_PARAM_PASS);
}
@@ -461,19 +569,19 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularFixed(
PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastF32S1(PROTOBUF_TC_PARAM_DECL) {
+PROTOBUF_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE const char* TcParser::FastF64S2(PROTOBUF_TC_PARAM_DECL) {
PROTOBUF_MUSTTAIL return SingularFixed<arc_ui64, uint16_t>(
PROTOBUF_TC_PARAM_PASS);
}
@@ -494,35 +602,27 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::RepeatedFixed(
}
}
auto& field = RefAt<RepeatedField<LayoutType>>(msg, data.offset());
- int idx = field.size();
- auto elem = field.Add();
- int space = field.Capacity() - idx;
- idx = 0;
- auto expected_tag = UnalignedLoad<TagType>(ptr);
+ const auto tag = UnalignedLoad<TagType>(ptr);
do {
- ptr += sizeof(TagType);
- elem[idx++] = UnalignedLoad<LayoutType>(ptr);
- ptr += sizeof(LayoutType);
- if (idx >= space) break;
- if (!ctx->DataAvailable(ptr)) break;
- } while (UnalignedLoad<TagType>(ptr) == expected_tag);
- field.AddNAlreadyReserved(idx - 1);
+ field.Add(UnalignedLoad<LayoutType>(ptr + sizeof(TagType)));
+ ptr += sizeof(TagType) + sizeof(LayoutType);
+ } while (ctx->DataAvailable(ptr) && UnalignedLoad<TagType>(ptr) == tag);
return ToParseLoop(PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastF32R1(PROTOBUF_TC_PARAM_DECL) {
+PROTOBUF_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE const char* TcParser::FastF64R2(PROTOBUF_TC_PARAM_DECL) {
PROTOBUF_MUSTTAIL return RepeatedFixed<arc_ui64, uint16_t>(
PROTOBUF_TC_PARAM_PASS);
}
@@ -557,19 +657,19 @@ const char* TcParser::PackedFixed(PROTOBUF_TC_PARAM_DECL) {
static_cast<RepeatedField<LayoutType>*>(&field));
}
-const char* TcParser::FastF32P1(PROTOBUF_TC_PARAM_DECL) {
+PROTOBUF_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE const char* TcParser::FastF64P2(PROTOBUF_TC_PARAM_DECL) {
PROTOBUF_MUSTTAIL return PackedFixed<arc_ui64, uint16_t>(
PROTOBUF_TC_PARAM_PASS);
}
@@ -580,144 +680,100 @@ const char* TcParser::FastF64P2(PROTOBUF_TC_PARAM_DECL) {
namespace {
-// Shift "byte" left by n * 7 bits, filling vacated bits with ones.
-template <int n>
-inline PROTOBUF_ALWAYS_INLINE arc_ui64
-shift_left_fill_with_ones(arc_ui64 byte, arc_ui64 ones) {
- return (byte << (n * 7)) | (ones >> (64 - (n * 7)));
-}
-
-// Shift "byte" left by n * 7 bits, filling vacated bits with ones, and
-// put the new value in res. Return whether the result was negative.
-template <int n>
-inline PROTOBUF_ALWAYS_INLINE bool shift_left_fill_with_ones_was_negative(
- arc_ui64 byte, arc_ui64 ones, arc_i64& res) {
-#if defined(__GCC_ASM_FLAG_OUTPUTS__) && defined(__x86_64__)
- // For the first two rounds (ptr[1] and ptr[2]), micro benchmarks show a
- // substantial improvement from capturing the sign from the condition code
- // register on x86-64.
- bool sign_bit;
- asm("shldq %3, %2, %1"
- : "=@ccs"(sign_bit), "+r"(byte)
- : "r"(ones), "i"(n * 7));
- res = byte;
- return sign_bit;
-#else
- // Generic fallback:
- res = (byte << (n * 7)) | (ones >> (64 - (n * 7)));
- return static_cast<arc_i64>(res) < 0;
-#endif
-}
-
-inline PROTOBUF_ALWAYS_INLINE std::pair<const char*, arc_ui64>
-Parse64FallbackPair(const char* p, arc_i64 res1) {
- auto ptr = reinterpret_cast<const int8_t*>(p);
-
- // The algorithm relies on sign extension for each byte to set all high bits
- // when the varint continues. It also relies on asserting all of the lower
- // bits for each successive byte read. This allows the result to be aggregated
- // using a bitwise AND. For example:
- //
- // 8 1 64 57 ... 24 17 16 9 8 1
- // ptr[0] = 1aaa aaaa ; res1 = 1111 1111 ... 1111 1111 1111 1111 1aaa aaaa
- // ptr[1] = 1bbb bbbb ; res2 = 1111 1111 ... 1111 1111 11bb bbbb b111 1111
- // ptr[2] = 1ccc cccc ; res3 = 0000 0000 ... 000c cccc cc11 1111 1111 1111
- // ---------------------------------------------
- // res1 & res2 & res3 = 0000 0000 ... 000c cccc ccbb bbbb baaa aaaa
- //
- // On x86-64, a shld from a single register filled with enough 1s in the high
- // bits can accomplish all this in one instruction. It so happens that res1
- // has 57 high bits of ones, which is enough for the largest shift done.
- GOOGLE_DCHECK_EQ(res1 >> 7, -1);
- arc_ui64 ones = res1; // save the high 1 bits from res1 (input to SHLD)
- arc_i64 res2, res3; // accumulated result chunks
-
- if (!shift_left_fill_with_ones_was_negative<1>(ptr[1], ones, res2))
- goto done2;
- if (!shift_left_fill_with_ones_was_negative<2>(ptr[2], ones, res3))
- goto done3;
-
- // For the remainder of the chunks, check the sign of the AND result.
- res1 &= shift_left_fill_with_ones<3>(ptr[3], ones);
- if (res1 >= 0) goto done4;
- res2 &= shift_left_fill_with_ones<4>(ptr[4], ones);
- if (res2 >= 0) goto done5;
- res3 &= shift_left_fill_with_ones<5>(ptr[5], ones);
- if (res3 >= 0) goto done6;
- res1 &= shift_left_fill_with_ones<6>(ptr[6], ones);
- if (res1 >= 0) goto done7;
- res2 &= shift_left_fill_with_ones<7>(ptr[7], ones);
- if (res2 >= 0) goto done8;
- res3 &= shift_left_fill_with_ones<8>(ptr[8], ones);
- if (res3 >= 0) goto done9;
-
- // For valid 64bit varints, the 10th byte/ptr[9] should be exactly 1. In this
- // case, the continuation bit of ptr[8] already set the top bit of res3
- // correctly, so all we have to do is check that the expected case is true.
- if (PROTOBUF_PREDICT_TRUE(ptr[9] == 1)) goto done10;
-
- // A value of 0, however, represents an over-serialized varint. This case
- // should not happen, but if does (say, due to a nonconforming serializer),
- // deassert the continuation bit that came from ptr[8].
- if (ptr[9] == 0) {
-#if defined(__GCC_ASM_FLAG_OUTPUTS__) && defined(__x86_64__)
- // Use a small instruction since this is an uncommon code path.
- asm("btcq $63,%0" : "+r"(res3));
-#else
- res3 ^= static_cast<arc_ui64>(1) << 63;
-#endif
- goto done10;
- }
-
- // If the 10th byte/ptr[9] itself has any other value, then it is too big to
- // fit in 64 bits. If the continue bit is set, it is an unterminated varint.
- return {nullptr, 0};
-
-done2:
- return {p + 2, res1 & res2};
-done3:
- return {p + 3, res1 & res2 & res3};
-done4:
- return {p + 4, res1 & res2 & res3};
-done5:
- return {p + 5, res1 & res2 & res3};
-done6:
- return {p + 6, res1 & res2 & res3};
-done7:
- return {p + 7, res1 & res2 & res3};
-done8:
- return {p + 8, res1 & res2 & res3};
-done9:
- return {p + 9, res1 & res2 & res3};
-done10:
- return {p + 10, res1 & res2 & res3};
-}
-
+template <typename Type>
inline PROTOBUF_ALWAYS_INLINE const char* ParseVarint(const char* p,
- arc_ui64* value) {
+ Type* value) {
+ static_assert(sizeof(Type) == 4 || sizeof(Type) == 8,
+ "Only [u]arc_i32 and [u]arc_i64 please");
+#ifdef __aarch64__
+ // The VarintParse parser has a faster implementation on ARM.
+ y_absl::conditional_t<sizeof(Type) == 4, arc_ui32, arc_ui64> tmp;
+ p = VarintParse(p, &tmp);
+ if (p != nullptr) {
+ *value = tmp;
+ }
+ return p;
+#endif
arc_i64 byte = static_cast<int8_t>(*p);
if (PROTOBUF_PREDICT_TRUE(byte >= 0)) {
*value = byte;
return p + 1;
} else {
- auto tmp = Parse64FallbackPair(p, byte);
- if (PROTOBUF_PREDICT_TRUE(tmp.first)) *value = tmp.second;
+ auto tmp = ParseFallbackPair<std::make_unsigned_t<Type>>(p, byte);
+ if (PROTOBUF_PREDICT_TRUE(tmp.first)) {
+ *value = static_cast<Type>(tmp.second);
+ }
return tmp.first;
}
}
+// This overload is specifically for handling bool, because bools have very
+// different requirements and performance opportunities than ints.
+inline PROTOBUF_ALWAYS_INLINE const char* ParseVarint(const char* p,
+ bool* value) {
+ unsigned char byte = static_cast<unsigned char>(*p++);
+ if (PROTOBUF_PREDICT_TRUE(byte == 0 || byte == 1)) {
+ // This is the code path almost always taken,
+ // so we take care to make it very efficient.
+ if (sizeof(byte) == sizeof(*value)) {
+ memcpy(value, &byte, 1);
+ } else {
+ // The C++ standard does not specify that a `bool` takes only one byte
+ *value = byte;
+ }
+ return p;
+ }
+ // This part, we just care about code size.
+ // Although it's almost never used, we have to support it because we guarantee
+ // compatibility for users who change a field from an int32 or int64 to a bool
+ if (PROTOBUF_PREDICT_FALSE(byte & 0x80)) {
+ byte = (byte - 0x80) | *p++;
+ if (PROTOBUF_PREDICT_FALSE(byte & 0x80)) {
+ byte = (byte - 0x80) | *p++;
+ if (PROTOBUF_PREDICT_FALSE(byte & 0x80)) {
+ byte = (byte - 0x80) | *p++;
+ if (PROTOBUF_PREDICT_FALSE(byte & 0x80)) {
+ byte = (byte - 0x80) | *p++;
+ if (PROTOBUF_PREDICT_FALSE(byte & 0x80)) {
+ byte = (byte - 0x80) | *p++;
+ if (PROTOBUF_PREDICT_FALSE(byte & 0x80)) {
+ byte = (byte - 0x80) | *p++;
+ if (PROTOBUF_PREDICT_FALSE(byte & 0x80)) {
+ byte = (byte - 0x80) | *p++;
+ if (PROTOBUF_PREDICT_FALSE(byte & 0x80)) {
+ byte = (byte - 0x80) | *p++;
+ if (PROTOBUF_PREDICT_FALSE(byte & 0x80)) {
+ // We only care about the continuation bit and the first bit
+ // of the 10th byte.
+ byte = (byte - 0x80) | (*p++ & 0x81);
+ if (PROTOBUF_PREDICT_FALSE(byte & 0x80)) {
+ return nullptr;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ *value = byte;
+ return p;
+}
+
template <typename FieldType, bool zigzag = false>
-inline FieldType ZigZagDecodeHelper(arc_ui64 value) {
+inline FieldType ZigZagDecodeHelper(FieldType value) {
return static_cast<FieldType>(value);
}
template <>
-inline arc_i32 ZigZagDecodeHelper<arc_i32, true>(arc_ui64 value) {
+inline arc_i32 ZigZagDecodeHelper<arc_i32, true>(arc_i32 value) {
return WireFormatLite::ZigZagDecode32(value);
}
template <>
-inline arc_i64 ZigZagDecodeHelper<arc_i64, true>(arc_ui64 value) {
+inline arc_i64 ZigZagDecodeHelper<arc_i64, true>(arc_i64 value) {
return WireFormatLite::ZigZagDecode64(value);
}
@@ -768,9 +824,15 @@ PROTOBUF_NOINLINE const char* TcParser::SingularVarBigint(
const ::google::protobuf::internal::TcParseTableBase* table;
arc_ui64 hasbits;
};
- volatile Spill spill = {data.data, msg, table, hasbits};
+ Spill spill = {data.data, msg, table, hasbits};
+#if defined(__GNUC__)
+ // This empty asm block convinces the compiler that the contents of spill may
+ // have changed, and thus can't be cached in registers. It's similar to, but
+ // more optimal than, the effect of declaring it "volatile".
+ asm("" : "+m"(spill));
+#endif
- arc_ui64 tmp;
+ FieldType tmp;
PROTOBUF_ASSUME(static_cast<int8_t>(*ptr) < 0);
ptr = ParseVarint(ptr, &tmp);
@@ -787,44 +849,43 @@ PROTOBUF_NOINLINE const char* TcParser::SingularVarBigint(
PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastV8S1(PROTOBUF_TC_PARAM_DECL) {
- PROTOBUF_MUSTTAIL return SingularVarint<bool, uint8_t>(
- PROTOBUF_TC_PARAM_PASS);
+PROTOBUF_NOINLINE const char* TcParser::FastV8S1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return FastTV8S1<-1, -1>(PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastV8S2(PROTOBUF_TC_PARAM_DECL) {
+PROTOBUF_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE const char* TcParser::FastZ64S2(PROTOBUF_TC_PARAM_DECL) {
PROTOBUF_MUSTTAIL return SingularVarint<arc_i64, uint16_t, true>(
PROTOBUF_TC_PARAM_PASS);
}
@@ -842,10 +903,10 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::RepeatedVarint(
}
}
auto& field = RefAt<RepeatedField<FieldType>>(msg, data.offset());
- auto expected_tag = UnalignedLoad<TagType>(ptr);
+ const auto expected_tag = UnalignedLoad<TagType>(ptr);
do {
ptr += sizeof(TagType);
- arc_ui64 tmp;
+ FieldType tmp;
ptr = ParseVarint(ptr, &tmp);
if (ptr == nullptr) {
return Error(PROTOBUF_TC_PARAM_PASS);
@@ -858,44 +919,44 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::RepeatedVarint(
return ToParseLoop(PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastV8R1(PROTOBUF_TC_PARAM_DECL) {
+PROTOBUF_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE const char* TcParser::FastZ64R2(PROTOBUF_TC_PARAM_DECL) {
PROTOBUF_MUSTTAIL return RepeatedVarint<arc_i64, uint16_t, true>(
PROTOBUF_TC_PARAM_PASS);
}
@@ -931,42 +992,42 @@ const char* TcParser::PackedVarint(PROTOBUF_TC_PARAM_DECL) {
});
}
-const char* TcParser::FastV8P1(PROTOBUF_TC_PARAM_DECL) {
+PROTOBUF_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE const char* TcParser::FastZ64P2(PROTOBUF_TC_PARAM_DECL) {
PROTOBUF_MUSTTAIL return PackedVarint<arc_i64, uint16_t, true>(
PROTOBUF_TC_PARAM_PASS);
}
@@ -977,10 +1038,6 @@ const char* TcParser::FastZ64P2(PROTOBUF_TC_PARAM_DECL) {
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.
@@ -1017,37 +1074,36 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularEnum(
PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastErS1(PROTOBUF_TC_PARAM_DECL) {
+PROTOBUF_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE 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) {
+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);
+ PROTOBUF_MUSTTAIL return PackedEnum<TagType, xform_val>(
+ 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 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
@@ -1072,30 +1128,222 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::RepeatedEnum(
return ToParseLoop(PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastErR1(PROTOBUF_TC_PARAM_DECL) {
+const TcParser::UnknownFieldOps& TcParser::GetUnknownFieldOps(
+ const TcParseTableBase* table) {
+ // Call the fallback function in a special mode to only act as a
+ // way to return the ops.
+ // Hiding the unknown fields vtable behind the fallback function avoids adding
+ // more pointers in TcParseTableBase, and the extra runtime jumps are not
+ // relevant because unknown fields are rare.
+ const char* ptr = table->fallback(nullptr, nullptr, nullptr, {}, nullptr, 0);
+ return *reinterpret_cast<const UnknownFieldOps*>(ptr);
+}
+
+PROTOBUF_NOINLINE void TcParser::UnknownPackedEnum(
+ MessageLite* msg, const TcParseTableBase* table, arc_ui32 tag,
+ arc_i32 enum_value) {
+ GetUnknownFieldOps(table).write_varint(msg, tag >> 3, enum_value);
+}
+
+template <typename TagType, uint16_t xform_val>
+const char* TcParser::PackedEnum(PROTOBUF_TC_PARAM_DECL) {
+ if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
+ InvertPacked<WireFormatLite::WIRETYPE_VARINT>(data);
+ if (data.coded_tag<TagType>() == 0) {
+ PROTOBUF_MUSTTAIL return RepeatedEnum<TagType, xform_val>(
+ PROTOBUF_TC_PARAM_PASS);
+ } else {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+ }
+ }
+ const auto saved_tag = UnalignedLoad<TagType>(ptr);
+ ptr += sizeof(TagType);
+ // Since ctx->ReadPackedVarint does not use TailCall or Return, sync any
+ // pending hasbits now:
+ SyncHasbits(msg, hasbits, table);
+ auto* field = &RefAt<RepeatedField<arc_i32>>(msg, data.offset());
+ const TcParseTableBase::FieldAux aux = *table->field_aux(data.aux_idx());
+ return ctx->ReadPackedVarint(ptr, [=](arc_i32 value) {
+ if (!EnumIsValidAux(value, xform_val, aux)) {
+ UnknownPackedEnum(msg, table, FastDecodeTag(saved_tag), value);
+ } else {
+ field->Add(value);
+ }
+ });
+}
+
+PROTOBUF_NOINLINE 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_NOINLINE 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_NOINLINE 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_NOINLINE const char* TcParser::FastEvR2(PROTOBUF_TC_PARAM_DECL) {
PROTOBUF_MUSTTAIL return RepeatedEnum<uint16_t, field_layout::kTvEnum>(
PROTOBUF_TC_PARAM_PASS);
}
+PROTOBUF_NOINLINE const char* TcParser::FastErP1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return PackedEnum<uint8_t, field_layout::kTvRange>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+PROTOBUF_NOINLINE const char* TcParser::FastErP2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return PackedEnum<uint16_t, field_layout::kTvRange>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+PROTOBUF_NOINLINE const char* TcParser::FastEvP1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return PackedEnum<uint8_t, field_layout::kTvEnum>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+PROTOBUF_NOINLINE const char* TcParser::FastEvP2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return PackedEnum<uint16_t, field_layout::kTvEnum>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+template <typename TagType, uint8_t min>
+PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularEnumSmallRange(
+ PROTOBUF_TC_PARAM_DECL) {
+ if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+ }
+
+ uint8_t v = ptr[sizeof(TagType)];
+ if (PROTOBUF_PREDICT_FALSE(min > v || v > data.aux_idx())) {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+ }
+
+ RefAt<arc_i32>(msg, data.offset()) = v;
+ ptr += sizeof(TagType) + 1;
+ hasbits |= (arc_ui64{1} << data.hasbit_idx());
+ PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
+}
+
+PROTOBUF_NOINLINE const char* TcParser::FastEr0S1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularEnumSmallRange<uint8_t, 0>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+PROTOBUF_NOINLINE const char* TcParser::FastEr0S2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularEnumSmallRange<uint16_t, 0>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+PROTOBUF_NOINLINE const char* TcParser::FastEr1S1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularEnumSmallRange<uint8_t, 1>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+PROTOBUF_NOINLINE const char* TcParser::FastEr1S2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularEnumSmallRange<uint16_t, 1>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+template <typename TagType, uint8_t min>
+const char* TcParser::RepeatedEnumSmallRange(PROTOBUF_TC_PARAM_DECL) {
+ if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
+ InvertPacked<WireFormatLite::WIRETYPE_VARINT>(data);
+ if (data.coded_tag<TagType>() == 0) {
+ PROTOBUF_MUSTTAIL return PackedEnumSmallRange<TagType, min>(
+ 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 uint8_t max = data.aux_idx();
+ do {
+ uint8_t v = ptr[sizeof(TagType)];
+ if (PROTOBUF_PREDICT_FALSE(min > v || v > max)) {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+ }
+ field.Add(static_cast<arc_i32>(v));
+ ptr += sizeof(TagType) + 1;
+ if (PROTOBUF_PREDICT_FALSE(!ctx->DataAvailable(ptr))) break;
+ } while (UnalignedLoad<TagType>(ptr) == expected_tag);
+
+ PROTOBUF_MUSTTAIL return ToParseLoop(PROTOBUF_TC_PARAM_PASS);
+}
+
+PROTOBUF_NOINLINE const char* TcParser::FastEr0R1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedEnumSmallRange<uint8_t, 0>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+PROTOBUF_NOINLINE const char* TcParser::FastEr0R2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedEnumSmallRange<uint16_t, 0>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+PROTOBUF_NOINLINE const char* TcParser::FastEr1R1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedEnumSmallRange<uint8_t, 1>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+PROTOBUF_NOINLINE const char* TcParser::FastEr1R2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedEnumSmallRange<uint16_t, 1>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+template <typename TagType, uint8_t min>
+const char* TcParser::PackedEnumSmallRange(PROTOBUF_TC_PARAM_DECL) {
+ if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
+ InvertPacked<WireFormatLite::WIRETYPE_VARINT>(data);
+ if (data.coded_tag<TagType>() == 0) {
+ PROTOBUF_MUSTTAIL return RepeatedEnumSmallRange<TagType, min>(
+ PROTOBUF_TC_PARAM_PASS);
+ } else {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+ }
+ }
+
+ // Since ctx->ReadPackedVarint does not use TailCall or Return, sync any
+ // pending hasbits now:
+ SyncHasbits(msg, hasbits, table);
+
+ const auto saved_tag = UnalignedLoad<TagType>(ptr);
+ ptr += sizeof(TagType);
+ auto* field = &RefAt<RepeatedField<arc_i32>>(msg, data.offset());
+ const uint8_t max = data.aux_idx();
+
+ return ctx->ReadPackedVarint(ptr, [=](arc_i32 v) {
+ if (PROTOBUF_PREDICT_FALSE(min > v || v > max)) {
+ UnknownPackedEnum(msg, table, FastDecodeTag(saved_tag), v);
+ } else {
+ field->Add(v);
+ }
+ });
+}
+
+PROTOBUF_NOINLINE const char* TcParser::FastEr0P1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return PackedEnumSmallRange<uint8_t, 0>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+PROTOBUF_NOINLINE const char* TcParser::FastEr0P2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return PackedEnumSmallRange<uint16_t, 0>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
+PROTOBUF_NOINLINE const char* TcParser::FastEr1P1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return PackedEnumSmallRange<uint8_t, 1>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+PROTOBUF_NOINLINE const char* TcParser::FastEr1P2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return PackedEnumSmallRange<uint16_t, 1>(
+ PROTOBUF_TC_PARAM_PASS);
+}
+
//////////////////////////////////////////////////////////////////////////////
// String/bytes fields
//////////////////////////////////////////////////////////////////////////////
// Defined in wire_format_lite.cc
-void PrintUTF8ErrorLog(StringPiece message_name,
- StringPiece field_name, const char* operation_str,
+void PrintUTF8ErrorLog(y_absl::string_view message_name,
+ y_absl::string_view field_name, const char* operation_str,
bool emit_stacktrace);
void TcParser::ReportFastUtf8Error(arc_ui32 decoded_tag,
@@ -1108,17 +1356,34 @@ void TcParser::ReportFastUtf8Error(arc_ui32 decoded_tag,
namespace {
+// Here are overloads of ReadStringIntoArena, ReadStringNoArena and IsValidUTF8
+// for every string class for which we provide fast-table parser support.
+
+PROTOBUF_ALWAYS_INLINE inline const char* ReadStringIntoArena(
+ MessageLite* /*msg*/, const char* ptr, ParseContext* ctx,
+ arc_ui32 /*aux_idx*/, const TcParseTableBase* /*table*/,
+ ArenaStringPtr& field, Arena* arena) {
+ return ctx->ReadArenaString(ptr, &field, arena);
+}
+
PROTOBUF_NOINLINE
-const char* SingularStringParserFallback(ArenaStringPtr* s, const char* ptr,
- EpsCopyInputStream* stream) {
+const char* ReadStringNoArena(MessageLite* /*msg*/, const char* ptr,
+ ParseContext* ctx, arc_ui32 /*aux_idx*/,
+ const TcParseTableBase* /*table*/,
+ ArenaStringPtr& field) {
int size = ReadSize(&ptr);
if (!ptr) return nullptr;
- return stream->ReadString(ptr, size, s->MutableNoCopy(nullptr));
+ return ctx->ReadString(ptr, size, field.MutableNoCopy(nullptr));
+}
+
+PROTOBUF_ALWAYS_INLINE inline bool IsValidUTF8(ArenaStringPtr& field) {
+ return utf8_range::IsStructurallyValid(field.Get());
}
+
} // namespace
-template <typename TagType, TcParser::Utf8Type utf8>
+template <typename TagType, typename FieldType, TcParser::Utf8Type utf8>
PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularString(
PROTOBUF_TC_PARAM_DECL) {
if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
@@ -1127,12 +1392,13 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularString(
auto saved_tag = UnalignedLoad<TagType>(ptr);
ptr += sizeof(TagType);
hasbits |= (arc_ui64{1} << data.hasbit_idx());
- auto& field = RefAt<ArenaStringPtr>(msg, data.offset());
- auto arena = ctx->data().arena;
+ auto& field = RefAt<FieldType>(msg, data.offset());
+ auto arena = msg->GetArenaForAllocation();
if (arena) {
- ptr = ctx->ReadArenaString(ptr, &field, arena);
+ ptr =
+ ReadStringIntoArena(msg, ptr, ctx, data.aux_idx(), table, field, arena);
} else {
- ptr = SingularStringParserFallback(&field, ptr, ctx);
+ ptr = ReadStringNoArena(msg, ptr, ctx, data.aux_idx(), table, field);
}
if (ptr == nullptr) return Error(PROTOBUF_TC_PARAM_PASS);
switch (utf8) {
@@ -1142,7 +1408,7 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularString(
#endif
return ToParseLoop(PROTOBUF_TC_PARAM_PASS);
default:
- if (PROTOBUF_PREDICT_TRUE(IsStructurallyValidUTF8(field.Get()))) {
+ if (PROTOBUF_PREDICT_TRUE(IsValidUTF8(field))) {
return ToParseLoop(PROTOBUF_TC_PARAM_PASS);
}
ReportFastUtf8Error(FastDecodeTag(saved_tag), table);
@@ -1151,28 +1417,30 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularString(
}
}
-const char* TcParser::FastBS1(PROTOBUF_TC_PARAM_DECL) {
- PROTOBUF_MUSTTAIL return SingularString<uint8_t, kNoUtf8>(
+PROTOBUF_NOINLINE const char* TcParser::FastBS1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularString<uint8_t, ArenaStringPtr, kNoUtf8>(
PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastBS2(PROTOBUF_TC_PARAM_DECL) {
- PROTOBUF_MUSTTAIL return SingularString<uint16_t, kNoUtf8>(
+PROTOBUF_NOINLINE const char* TcParser::FastBS2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularString<uint16_t, ArenaStringPtr, kNoUtf8>(
PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastSS1(PROTOBUF_TC_PARAM_DECL) {
- PROTOBUF_MUSTTAIL return SingularString<uint8_t, kUtf8ValidateOnly>(
+PROTOBUF_NOINLINE const char* TcParser::FastSS1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularString<uint8_t, ArenaStringPtr,
+ kUtf8ValidateOnly>(
PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastSS2(PROTOBUF_TC_PARAM_DECL) {
- PROTOBUF_MUSTTAIL return SingularString<uint16_t, kUtf8ValidateOnly>(
+PROTOBUF_NOINLINE const char* TcParser::FastSS2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularString<uint16_t, ArenaStringPtr,
+ kUtf8ValidateOnly>(
PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastUS1(PROTOBUF_TC_PARAM_DECL) {
- PROTOBUF_MUSTTAIL return SingularString<uint8_t, kUtf8>(
+PROTOBUF_NOINLINE const char* TcParser::FastUS1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularString<uint8_t, ArenaStringPtr, kUtf8>(
PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastUS2(PROTOBUF_TC_PARAM_DECL) {
- PROTOBUF_MUSTTAIL return SingularString<uint16_t, kUtf8>(
+PROTOBUF_NOINLINE const char* TcParser::FastUS2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return SingularString<uint16_t, ArenaStringPtr, kUtf8>(
PROTOBUF_TC_PARAM_PASS);
}
@@ -1197,62 +1465,107 @@ const char* TcParser::FastUiS2(PROTOBUF_TC_PARAM_DECL) {
PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
}
-template <typename TagType, TcParser::Utf8Type utf8>
+// Corded string variants:
+const char* TcParser::FastBcS1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastBcS2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastScS1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastScS2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastUcS1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+}
+const char* TcParser::FastUcS2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
+}
+
+template <typename TagType, typename FieldType, TcParser::Utf8Type utf8>
PROTOBUF_ALWAYS_INLINE const char* TcParser::RepeatedString(
PROTOBUF_TC_PARAM_DECL) {
if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS);
}
- auto expected_tag = UnalignedLoad<TagType>(ptr);
- auto& field = RefAt<RepeatedPtrField<TProtoStringType>>(msg, data.offset());
- do {
- ptr += sizeof(TagType);
- TProtoStringType* str = field.Add();
- ptr = InlineGreedyStringParser(str, ptr, ctx);
- if (ptr == nullptr) {
- return Error(PROTOBUF_TC_PARAM_PASS);
- }
+ const auto expected_tag = UnalignedLoad<TagType>(ptr);
+ auto& field = RefAt<FieldType>(msg, data.offset());
+
+ const auto validate_last_string = [expected_tag, table, &field] {
switch (utf8) {
case kNoUtf8:
#ifdef NDEBUG
case kUtf8ValidateOnly:
#endif
- break;
+ return true;
default:
- if (PROTOBUF_PREDICT_TRUE(IsStructurallyValidUTF8(*str))) {
- break;
+ if (PROTOBUF_PREDICT_TRUE(
+ utf8_range::IsStructurallyValid(field[field.size() - 1]))) {
+ return true;
}
ReportFastUtf8Error(FastDecodeTag(expected_tag), table);
- if (utf8 == kUtf8) return Error(PROTOBUF_TC_PARAM_PASS);
- break;
+ if (utf8 == kUtf8) return false;
+ return true;
}
- if (!ctx->DataAvailable(ptr)) break;
- } while (UnalignedLoad<TagType>(ptr) == expected_tag);
+ };
+
+ auto* arena = field.GetOwningArena();
+ SerialArena* serial_arena;
+ if (PROTOBUF_PREDICT_TRUE(arena != nullptr &&
+ arena->impl_.GetSerialArenaFast(&serial_arena) &&
+ field.PrepareForParse())) {
+ do {
+ ptr += sizeof(TagType);
+ ptr = ParseRepeatedStringOnce(ptr, arena, serial_arena, ctx, field);
+
+ if (PROTOBUF_PREDICT_FALSE(ptr == nullptr || !validate_last_string())) {
+ return Error(PROTOBUF_TC_PARAM_PASS);
+ }
+ if (!ctx->DataAvailable(ptr)) break;
+ } while (UnalignedLoad<TagType>(ptr) == expected_tag);
+ } else {
+ do {
+ ptr += sizeof(TagType);
+ TProtoStringType* str = field.Add();
+ ptr = InlineGreedyStringParser(str, ptr, ctx);
+ if (PROTOBUF_PREDICT_FALSE(ptr == nullptr || !validate_last_string())) {
+ return Error(PROTOBUF_TC_PARAM_PASS);
+ }
+ if (!ctx->DataAvailable(ptr)) break;
+ } while (UnalignedLoad<TagType>(ptr) == expected_tag);
+ }
return ToParseLoop(PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastBR1(PROTOBUF_TC_PARAM_DECL) {
- PROTOBUF_MUSTTAIL return RepeatedString<uint8_t, kNoUtf8>(
- PROTOBUF_TC_PARAM_PASS);
+PROTOBUF_NOINLINE const char* TcParser::FastBR1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedString<
+ uint8_t, RepeatedPtrField<TProtoStringType>, kNoUtf8>(PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastBR2(PROTOBUF_TC_PARAM_DECL) {
- PROTOBUF_MUSTTAIL return RepeatedString<uint16_t, kNoUtf8>(
- PROTOBUF_TC_PARAM_PASS);
+PROTOBUF_NOINLINE const char* TcParser::FastBR2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedString<
+ uint16_t, RepeatedPtrField<TProtoStringType>, kNoUtf8>(PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastSR1(PROTOBUF_TC_PARAM_DECL) {
- PROTOBUF_MUSTTAIL return RepeatedString<uint8_t, kUtf8ValidateOnly>(
+PROTOBUF_NOINLINE const char* TcParser::FastSR1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedString<
+ uint8_t, RepeatedPtrField<TProtoStringType>, kUtf8ValidateOnly>(
PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastSR2(PROTOBUF_TC_PARAM_DECL) {
- PROTOBUF_MUSTTAIL return RepeatedString<uint16_t, kUtf8ValidateOnly>(
+PROTOBUF_NOINLINE const char* TcParser::FastSR2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedString<
+ uint16_t, RepeatedPtrField<TProtoStringType>, kUtf8ValidateOnly>(
PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastUR1(PROTOBUF_TC_PARAM_DECL) {
- PROTOBUF_MUSTTAIL return RepeatedString<uint8_t, kUtf8>(
+PROTOBUF_NOINLINE const char* TcParser::FastUR1(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedString<uint8_t,
+ RepeatedPtrField<TProtoStringType>, kUtf8>(
PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::FastUR2(PROTOBUF_TC_PARAM_DECL) {
- PROTOBUF_MUSTTAIL return RepeatedString<uint16_t, kUtf8>(
+PROTOBUF_NOINLINE const char* TcParser::FastUR2(PROTOBUF_TC_PARAM_DECL) {
+ PROTOBUF_MUSTTAIL return RepeatedString<uint16_t,
+ RepeatedPtrField<TProtoStringType>, kUtf8>(
PROTOBUF_TC_PARAM_PASS);
}
@@ -1261,20 +1574,14 @@ const char* TcParser::FastUR2(PROTOBUF_TC_PARAM_DECL) {
//////////////////////////////////////////////////////////////////////////////
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);
+inline void SetHas(const FieldEntry& entry, MessageLite* msg) {
+ auto has_idx = static_cast<arc_ui32>(entry.has_idx);
#if defined(__x86_64__) && defined(__GNUC__)
- asm("bts %1, %0\n" : "+m"(*hasblocks) : "r"(has_idx));
+ asm("bts %1, %0\n" : "+m"(*msg) : "r"(has_idx));
#else
- auto& hasblock = hasblocks[has_idx / 32];
- hasblock |= arc_ui32{1} << (has_idx % 32);
+ auto& hasblock = TcParser::RefAt<arc_ui32>(msg, has_idx / 32 * 4);
+ hasblock |= arc_ui32{1} << (has_idx % 32);
#endif
- }
}
} // namespace
@@ -1285,11 +1592,8 @@ 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;
+ // The _oneof_case_ value offset is stored in the has-bit index.
+ arc_ui32* oneof_case = &TcParser::RefAt<arc_ui32>(msg, entry.has_idx);
arc_ui32 current_case = *oneof_case;
*oneof_case = field_num;
@@ -1316,31 +1620,62 @@ bool TcParser::ChangeOneof(const TcParseTableBase* table,
case field_layout::kRepSString:
case field_layout::kRepIString:
default:
- GOOGLE_LOG(DFATAL) << "string rep not handled: "
- << (current_rep >> field_layout::kRepShift);
+ Y_ABSL_DLOG(FATAL) << "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: {
+ case field_layout::kRepGroup: {
auto& field = RefAt<MessageLite*>(msg, current_entry->offset);
- if (!ctx->data().arena) {
+ if (!msg->GetArenaForAllocation()) {
delete field;
}
break;
}
default:
- GOOGLE_LOG(DFATAL) << "message rep not handled: "
- << (current_rep >> field_layout::kRepShift);
+ Y_ABSL_DLOG(FATAL) << "message rep not handled: "
+ << (current_rep >> field_layout::kRepShift);
break;
}
}
return true;
}
-const char* TcParser::MpFixed(PROTOBUF_TC_PARAM_DECL) {
+namespace {
+arc_ui32 GetSplitOffset(const TcParseTableBase* table) {
+ return table->field_aux(kSplitOffsetAuxIdx)->offset;
+}
+
+arc_ui32 GetSizeofSplit(const TcParseTableBase* table) {
+ return table->field_aux(kSplitSizeAuxIdx)->offset;
+}
+} // namespace
+
+void* TcParser::MaybeGetSplitBase(MessageLite* msg, const bool is_split,
+ const TcParseTableBase* table) {
+ void* out = msg;
+ if (is_split) {
+ const arc_ui32 split_offset = GetSplitOffset(table);
+ void* default_split =
+ TcParser::RefAt<void*>(table->default_instance, split_offset);
+ void*& split = TcParser::RefAt<void*>(msg, split_offset);
+ if (split == default_split) {
+ // Allocate split instance when needed.
+ arc_ui32 size = GetSizeofSplit(table);
+ Arena* arena = msg->GetArenaForAllocation();
+ split = (arena == nullptr) ? ::operator new(size)
+ : arena->AllocateAligned(size);
+ memcpy(split, default_split, size);
+ }
+ out = split;
+ }
+ return out;
+}
+
+template <bool is_split>
+PROTOBUF_NOINLINE 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;
@@ -1357,29 +1692,31 @@ const char* TcParser::MpFixed(PROTOBUF_TC_PARAM_DECL) {
PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
}
} else {
- GOOGLE_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep32Bits));
+ Y_ABSL_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);
+ SetHas(entry, msg);
} else if (card == field_layout::kFcOneof) {
ChangeOneof(table, entry, data.tag() >> 3, ctx, msg);
}
+ void* const base = MaybeGetSplitBase(msg, is_split, table);
// Copy the value:
if (rep == field_layout::kRep64Bits) {
- RefAt<arc_ui64>(msg, entry.offset) = UnalignedLoad<arc_ui64>(ptr);
+ RefAt<arc_ui64>(base, entry.offset) = UnalignedLoad<arc_ui64>(ptr);
ptr += sizeof(arc_ui64);
} else {
- RefAt<arc_ui32>(msg, entry.offset) = UnalignedLoad<arc_ui32>(ptr);
+ RefAt<arc_ui32>(base, entry.offset) = UnalignedLoad<arc_ui32>(ptr);
ptr += sizeof(arc_ui32);
}
PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::MpRepeatedFixed(PROTOBUF_TC_PARAM_DECL) {
+PROTOBUF_NOINLINE 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;
@@ -1407,7 +1744,7 @@ const char* TcParser::MpRepeatedFixed(PROTOBUF_TC_PARAM_DECL) {
ptr2 = ReadTag(ptr, &next_tag);
} while (next_tag == decoded_tag);
} else {
- GOOGLE_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep32Bits));
+ Y_ABSL_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);
}
@@ -1427,7 +1764,7 @@ const char* TcParser::MpRepeatedFixed(PROTOBUF_TC_PARAM_DECL) {
PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::MpPackedFixed(PROTOBUF_TC_PARAM_DECL) {
+PROTOBUF_NOINLINE 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;
@@ -1447,7 +1784,7 @@ const char* TcParser::MpPackedFixed(PROTOBUF_TC_PARAM_DECL) {
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));
+ Y_ABSL_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);
}
@@ -1458,7 +1795,8 @@ const char* TcParser::MpPackedFixed(PROTOBUF_TC_PARAM_DECL) {
PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::MpVarint(PROTOBUF_TC_PARAM_DECL) {
+template <bool is_split>
+PROTOBUF_NOINLINE 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;
@@ -1501,24 +1839,26 @@ const char* TcParser::MpVarint(PROTOBUF_TC_PARAM_DECL) {
// Mark the field as present:
const bool is_oneof = card == field_layout::kFcOneof;
if (card == field_layout::kFcOptional) {
- SetHas(table, entry, msg, hasbits);
+ SetHas(entry, msg);
} else if (is_oneof) {
ChangeOneof(table, entry, data.tag() >> 3, ctx, msg);
}
+ void* const base = MaybeGetSplitBase(msg, is_split, table);
if (rep == field_layout::kRep64Bits) {
- RefAt<arc_ui64>(msg, entry.offset) = tmp;
+ RefAt<arc_ui64>(base, entry.offset) = tmp;
} else if (rep == field_layout::kRep32Bits) {
- RefAt<arc_ui32>(msg, entry.offset) = static_cast<arc_ui32>(tmp);
+ RefAt<arc_ui32>(base, 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);
+ Y_ABSL_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep8Bits));
+ RefAt<bool>(base, entry.offset) = static_cast<bool>(tmp);
}
PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::MpRepeatedVarint(PROTOBUF_TC_PARAM_DECL) {
+PROTOBUF_NOINLINE 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();
@@ -1548,6 +1888,7 @@ const char* TcParser::MpRepeatedVarint(PROTOBUF_TC_PARAM_DECL) {
field.Add(is_zigzag ? WireFormatLite::ZigZagDecode64(tmp) : tmp);
if (!ctx->DataAvailable(ptr)) break;
ptr2 = ReadTag(ptr, &next_tag);
+ if (ptr2 == nullptr) return Error(PROTOBUF_TC_PARAM_PASS);
} while (next_tag == decoded_tag);
} else if (rep == field_layout::kRep32Bits) {
auto& field = RefAt<RepeatedField<arc_ui32>>(msg, entry.offset);
@@ -1568,9 +1909,10 @@ const char* TcParser::MpRepeatedVarint(PROTOBUF_TC_PARAM_DECL) {
field.Add(tmp);
if (!ctx->DataAvailable(ptr)) break;
ptr2 = ReadTag(ptr, &next_tag);
+ if (ptr2 == nullptr) return Error(PROTOBUF_TC_PARAM_PASS);
} while (next_tag == decoded_tag);
} else {
- GOOGLE_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep8Bits));
+ Y_ABSL_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;
@@ -1581,13 +1923,14 @@ const char* TcParser::MpRepeatedVarint(PROTOBUF_TC_PARAM_DECL) {
field.Add(static_cast<bool>(tmp));
if (!ctx->DataAvailable(ptr)) break;
ptr2 = ReadTag(ptr, &next_tag);
+ if (ptr2 == nullptr) return Error(PROTOBUF_TC_PARAM_PASS);
} while (next_tag == decoded_tag);
}
PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::MpPackedVarint(PROTOBUF_TC_PARAM_DECL) {
+PROTOBUF_NOINLINE 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;
@@ -1596,13 +1939,9 @@ const char* TcParser::MpPackedVarint(PROTOBUF_TC_PARAM_DECL) {
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 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:
@@ -1616,13 +1955,24 @@ const char* TcParser::MpPackedVarint(PROTOBUF_TC_PARAM_DECL) {
});
} 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);
- });
+ if (is_validated_enum) {
+ const TcParseTableBase::FieldAux aux = *table->field_aux(entry.aux_idx);
+ return ctx->ReadPackedVarint(ptr, [=](arc_i32 value) {
+ if (!EnumIsValidAux(value, xform_val, aux)) {
+ UnknownPackedEnum(msg, table, data.tag(), value);
+ } else {
+ field->Add(value);
+ }
+ });
+ } else {
+ 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));
+ Y_ABSL_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); });
@@ -1631,11 +1981,11 @@ const char* TcParser::MpPackedVarint(PROTOBUF_TC_PARAM_DECL) {
return Error(PROTOBUF_TC_PARAM_PASS);
}
-bool TcParser::MpVerifyUtf8(StringPiece wire_bytes,
+bool TcParser::MpVerifyUtf8(y_absl::string_view wire_bytes,
const TcParseTableBase* table,
const FieldEntry& entry, uint16_t xform_val) {
if (xform_val == field_layout::kTvUtf8) {
- if (!IsStructurallyValidUTF8(wire_bytes)) {
+ if (!utf8_range::IsStructurallyValid(wire_bytes)) {
PrintUTF8ErrorLog(MessageName(table), FieldName(table, &entry), "parsing",
false);
return false;
@@ -1644,7 +1994,7 @@ bool TcParser::MpVerifyUtf8(StringPiece wire_bytes,
}
#ifndef NDEBUG
if (xform_val == field_layout::kTvUtf8Debug) {
- if (!IsStructurallyValidUTF8(wire_bytes)) {
+ if (!utf8_range::IsStructurallyValid(wire_bytes)) {
PrintUTF8ErrorLog(MessageName(table), FieldName(table, &entry), "parsing",
false);
}
@@ -1653,7 +2003,8 @@ bool TcParser::MpVerifyUtf8(StringPiece wire_bytes,
return true;
}
-const char* TcParser::MpString(PROTOBUF_TC_PARAM_DECL) {
+template <bool is_split>
+PROTOBUF_NOINLINE 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;
@@ -1676,17 +2027,18 @@ const char* TcParser::MpString(PROTOBUF_TC_PARAM_DECL) {
const bool is_oneof = card == field_layout::kFcOneof;
bool need_init = false;
if (card == field_layout::kFcOptional) {
- SetHas(table, entry, msg, hasbits);
+ SetHas(entry, msg);
} else if (is_oneof) {
need_init = ChangeOneof(table, entry, data.tag() >> 3, ctx, msg);
}
bool is_valid = false;
- Arena* arena = ctx->data().arena;
+ void* const base = MaybeGetSplitBase(msg, is_split, table);
switch (rep) {
case field_layout::kRepAString: {
- auto& field = RefAt<ArenaStringPtr>(msg, entry.offset);
+ auto& field = RefAt<ArenaStringPtr>(base, entry.offset);
if (need_init) field.InitDefault();
+ Arena* arena = msg->GetArenaForAllocation();
if (arena) {
ptr = ctx->ReadArenaString(ptr, &field, arena);
} else {
@@ -1709,7 +2061,21 @@ const char* TcParser::MpString(PROTOBUF_TC_PARAM_DECL) {
return ToParseLoop(PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::MpRepeatedString(PROTOBUF_TC_PARAM_DECL) {
+PROTOBUF_ALWAYS_INLINE const char* TcParser::ParseRepeatedStringOnce(
+ const char* ptr, Arena* arena, SerialArena* serial_arena, ParseContext* ctx,
+ RepeatedPtrField<TProtoStringType>& field) {
+ int size = ReadSize(&ptr);
+ if (PROTOBUF_PREDICT_FALSE(!ptr)) return {};
+ auto* str = Arena::Create<TProtoStringType>(arena);
+ field.AddAllocatedForParse(str);
+ ptr = ctx->ReadString(ptr, size, str);
+ if (PROTOBUF_PREDICT_FALSE(!ptr)) return {};
+ PROTOBUF_ASSUME(ptr != nullptr);
+ return ptr;
+}
+
+PROTOBUF_NOINLINE 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();
@@ -1726,24 +2092,45 @@ const char* TcParser::MpRepeatedString(PROTOBUF_TC_PARAM_DECL) {
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);
+
+ auto* arena = field.GetOwningArena();
+ SerialArena* serial_arena;
+ if (PROTOBUF_PREDICT_TRUE(
+ arena != nullptr &&
+ arena->impl_.GetSerialArenaFast(&serial_arena) &&
+ field.PrepareForParse())) {
+ do {
+ ptr = ptr2;
+ ptr = ParseRepeatedStringOnce(ptr, arena, serial_arena, ctx, field);
+ if (PROTOBUF_PREDICT_FALSE(ptr == nullptr ||
+ !MpVerifyUtf8(field[field.size() - 1],
+ 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);
+ } else {
+ 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;
+ Y_ABSL_LOG(FATAL) << "Unsupported repeated string rep: " << rep;
break;
#endif
}
@@ -1751,7 +2138,8 @@ const char* TcParser::MpRepeatedString(PROTOBUF_TC_PARAM_DECL) {
return ToParseLoop(PROTOBUF_TC_PARAM_PASS);
}
-const char* TcParser::MpMessage(PROTOBUF_TC_PARAM_DECL) {
+template <bool is_split>
+PROTOBUF_NOINLINE 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;
@@ -1789,28 +2177,47 @@ const char* TcParser::MpMessage(PROTOBUF_TC_PARAM_DECL) {
const bool is_oneof = card == field_layout::kFcOneof;
bool need_init = false;
if (card == field_layout::kFcOptional) {
- SetHas(table, entry, msg, hasbits);
+ SetHas(entry, msg);
} 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);
- }
+
+ void* const base = MaybeGetSplitBase(msg, is_split, table);
SyncHasbits(msg, hasbits, table);
- if (is_group) {
- return ctx->ParseGroup(field, ptr, decoded_tag);
+ MessageLite*& field = RefAt<MessageLite*>(base, entry.offset);
+ if ((type_card & field_layout::kTvMask) == field_layout::kTvTable) {
+ auto* inner_table = table->field_aux(&entry)->table;
+ if (need_init || field == nullptr) {
+ field = inner_table->default_instance->New(msg->GetArenaForAllocation());
+ }
+ if (is_group) {
+ return ctx->ParseGroup<TcParser>(field, ptr, decoded_tag, inner_table);
+ }
+ return ctx->ParseMessage<TcParser>(field, ptr, inner_table);
+ } else {
+ if (need_init || field == nullptr) {
+ const MessageLite* def;
+ if ((type_card & field_layout::kTvMask) == field_layout::kTvDefault) {
+ def = table->field_aux(&entry)->message_default();
+ } else {
+ Y_ABSL_DCHECK_EQ(type_card & field_layout::kTvMask,
+ +field_layout::kTvWeakPtr);
+ def = table->field_aux(&entry)->message_default_weak();
+ }
+ field = def->New(msg->GetArenaForAllocation());
+ }
+ if (is_group) {
+ return ctx->ParseGroup(field, ptr, decoded_tag);
+ }
+ return ctx->ParseMessage(field, ptr);
}
- 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));
+ Y_ABSL_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;
@@ -1837,21 +2244,31 @@ const char* TcParser::MpRepeatedMessage(PROTOBUF_TC_PARAM_DECL) {
}
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);
+ const auto aux = *table->field_aux(&entry);
+ if ((type_card & field_layout::kTvMask) == field_layout::kTvTable) {
+ auto* inner_table = aux.table;
+ MessageLite* value = field.Add<GenericTypeHandler<MessageLite>>(
+ inner_table->default_instance);
+ if (is_group) {
+ return ctx->ParseGroup<TcParser>(value, ptr, decoded_tag, inner_table);
+ }
+ return ctx->ParseMessage<TcParser>(value, ptr, inner_table);
+ } else {
+ const MessageLite* def;
+ if ((type_card & field_layout::kTvMask) == field_layout::kTvDefault) {
+ def = aux.message_default();
+ } else {
+ Y_ABSL_DCHECK_EQ(type_card & field_layout::kTvMask,
+ +field_layout::kTvWeakPtr);
+ def = aux.message_default_weak();
+ }
+ MessageLite* value = field.Add<GenericTypeHandler<MessageLite>>(def);
+ if (is_group) {
+ return ctx->ParseGroup(value, ptr, decoded_tag);
+ }
+ return ctx->ParseMessage(value, ptr);
}
- 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
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 3062860a993..b476bd7e433 100644
--- a/contrib/libs/protobuf/src/google/protobuf/generated_message_util.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/generated_message_util.cc
@@ -32,23 +32,23 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/generated_message_util.h>
+#include "google/protobuf/generated_message_util.h"
#include <atomic>
#include <limits>
#include <vector>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
-#include <google/protobuf/arenastring.h>
-#include <google/protobuf/extension_set.h>
-#include <google/protobuf/message_lite.h>
-#include <google/protobuf/metadata_lite.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/wire_format_lite.h>
+#include "google/protobuf/arenastring.h"
+#include "google/protobuf/extension_set.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/metadata_lite.h"
+#include "google/protobuf/repeated_field.h"
+#include "google/protobuf/wire_format_lite.h"
// Must be included last
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
PROTOBUF_PRAGMA_INIT_SEG
@@ -317,7 +317,7 @@ class AccessorHelper {
};
void SerializeNotImplemented(int field) {
- GOOGLE_LOG(FATAL) << "Not implemented field number " << field;
+ Y_ABSL_LOG(FATAL) << "Not implemented field number " << field;
}
// When switching to c++11 we should make these constexpr functions
@@ -389,9 +389,9 @@ void GenericSwap(MessageLite* m1, MessageLite* m2) {
MessageLite* GetOwnedMessageInternal(Arena* message_arena,
MessageLite* submessage,
Arena* submessage_arena) {
- GOOGLE_DCHECK(Arena::InternalGetOwningArena(submessage) == submessage_arena);
- GOOGLE_DCHECK(message_arena != submessage_arena);
- GOOGLE_DCHECK_EQ(submessage_arena, nullptr);
+ Y_ABSL_DCHECK(Arena::InternalGetOwningArena(submessage) == submessage_arena);
+ Y_ABSL_DCHECK(message_arena != submessage_arena);
+ Y_ABSL_DCHECK_EQ(submessage_arena, nullptr);
if (message_arena != nullptr && submessage_arena == nullptr) {
message_arena->Own(submessage);
return submessage;
@@ -406,4 +406,4 @@ MessageLite* GetOwnedMessageInternal(Arena* message_arena,
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
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 db579798297..f56d87dc233 100644
--- a/contrib/libs/protobuf/src/google/protobuf/generated_message_util.h
+++ b/contrib/libs/protobuf/src/google/protobuf/generated_message_util.h
@@ -43,22 +43,24 @@
#include <atomic>
#include <climits>
#include <string>
+#include <type_traits>
#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/repeated_field.h>
-#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/stubs/casts.h>
+#include "google/protobuf/stubs/common.h"
+#include "y_absl/base/call_once.h"
+#include "y_absl/base/casts.h"
+#include "y_absl/strings/string_view.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/port.h"
+#include "google/protobuf/repeated_field.h"
+#include "google/protobuf/wire_format_lite.h"
+
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
#ifdef SWIG
#error "You cannot SWIG proto headers"
@@ -76,15 +78,6 @@ class CodedInputStream;
namespace internal {
-template <typename To, typename From>
-inline To DownCast(From* f) {
- return PROTOBUF_NAMESPACE_ID::internal::down_cast<To>(f);
-}
-template <typename To, typename From>
-inline To DownCast(From& f) {
- return PROTOBUF_NAMESPACE_ID::internal::down_cast<To>(f);
-}
-
// This fastpath inlines a single branch instead of having to make the
// InitProtobufDefaults function call.
@@ -185,13 +178,58 @@ T* GetOwnedMessage(Arena* message_arena, T* submessage,
// Hide atomic from the public header and allow easy change to regular int
// on platforms where the atomic might have a perf impact.
+//
+// CachedSize is like std::atomic<int> but with some important changes:
+//
+// 1) CachedSize uses Get / Set rather than load / store.
+// 2) CachedSize always uses relaxed ordering.
+// 3) CachedSize is assignable and copy-constructible.
+// 4) CachedSize has a constexpr default constructor, and a constexpr
+// constructor that takes an int argument.
+// 5) If the compiler supports the __atomic_load_n / __atomic_store_n builtins,
+// then CachedSize is trivially copyable.
+//
+// Developed at https://godbolt.org/z/vYcx7zYs1 ; supports gcc, clang, MSVC.
class PROTOBUF_EXPORT CachedSize {
+ private:
+ using Scalar = int;
+
public:
- int Get() const { return size_.load(std::memory_order_relaxed); }
- void Set(int size) { size_.store(size, std::memory_order_relaxed); }
+ constexpr CachedSize() noexcept : atom_(Scalar{}) {}
+ // NOLINTNEXTLINE(google-explicit-constructor)
+ constexpr CachedSize(Scalar desired) noexcept : atom_(desired) {}
+#if PROTOBUF_BUILTIN_ATOMIC
+ constexpr CachedSize(const CachedSize& other) = default;
+
+ Scalar Get() const noexcept {
+ return __atomic_load_n(&atom_, __ATOMIC_RELAXED);
+ }
+
+ void Set(Scalar desired) noexcept {
+ __atomic_store_n(&atom_, desired, __ATOMIC_RELAXED);
+ }
+#else
+ CachedSize(const CachedSize& other) noexcept : atom_(other.Get()) {}
+ CachedSize& operator=(const CachedSize& other) noexcept {
+ Set(other.Get());
+ return *this;
+ }
+
+ Scalar Get() const noexcept { //
+ return atom_.load(std::memory_order_relaxed);
+ }
+
+ void Set(Scalar desired) noexcept {
+ atom_.store(desired, std::memory_order_relaxed);
+ }
+#endif
private:
- std::atomic<int> size_{0};
+#if PROTOBUF_BUILTIN_ATOMIC
+ Scalar atom_;
+#else
+ std::atomic<Scalar> atom_;
+#endif
};
PROTOBUF_EXPORT void DestroyMessage(const void* message);
@@ -209,6 +247,6 @@ inline void OnShutdownDestroyString(const TProtoStringType* ptr) {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_UTIL_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/has_bits.h b/contrib/libs/protobuf/src/google/protobuf/has_bits.h
index 6185d04e009..147f18ed4ce 100644
--- a/contrib/libs/protobuf/src/google/protobuf/has_bits.h
+++ b/contrib/libs/protobuf/src/google/protobuf/has_bits.h
@@ -31,11 +31,11 @@
#ifndef GOOGLE_PROTOBUF_HAS_BITS_H__
#define GOOGLE_PROTOBUF_HAS_BITS_H__
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/port.h>
+#include "google/protobuf/stubs/common.h"
+#include "google/protobuf/port.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
#ifdef SWIG
#error "You cannot SWIG proto headers"
@@ -112,6 +112,6 @@ inline bool HasBits<doublewords>::empty() const {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_HAS_BITS_H__
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 27ed6b65d24..5fac836d0ab 100644
--- a/contrib/libs/protobuf/src/google/protobuf/implicit_weak_message.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/implicit_weak_message.cc
@@ -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.
-#include <google/protobuf/implicit_weak_message.h>
+#include "google/protobuf/implicit_weak_message.h"
-#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
-#include <google/protobuf/parse_context.h>
-#include <google/protobuf/wire_format_lite.h>
+#include "google/protobuf/io/zero_copy_stream_impl_lite.h"
+#include "google/protobuf/parse_context.h"
+#include "google/protobuf/wire_format_lite.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
PROTOBUF_PRAGMA_INIT_SEG
@@ -69,4 +69,4 @@ const ImplicitWeakMessage* ImplicitWeakMessage::default_instance() {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
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 393cc136eda..c2d39507bb0 100644
--- a/contrib/libs/protobuf/src/google/protobuf/implicit_weak_message.h
+++ b/contrib/libs/protobuf/src/google/protobuf/implicit_weak_message.h
@@ -33,17 +33,17 @@
#include <string>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/arena.h>
-#include <google/protobuf/message_lite.h>
-#include <google/protobuf/repeated_field.h>
+#include "google/protobuf/arena.h"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/message_lite.h"
+#include "google/protobuf/repeated_field.h"
#ifdef SWIG
#error "You cannot SWIG proto headers"
#endif
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
// This file is logically internal-only and should only be used by protobuf
// generated code.
@@ -62,6 +62,8 @@ class PROTOBUF_EXPORT ImplicitWeakMessage : public MessageLite {
: data_(nullptr) {}
explicit ImplicitWeakMessage(Arena* arena)
: MessageLite(arena), data_(new TProtoStringType) {}
+ ImplicitWeakMessage(const ImplicitWeakMessage&) = delete;
+ ImplicitWeakMessage& operator=(const ImplicitWeakMessage&) = delete;
~ImplicitWeakMessage() override {
// data_ will be null in the default instance, but we can safely call delete
@@ -115,7 +117,6 @@ class PROTOBUF_EXPORT ImplicitWeakMessage : public MessageLite {
// 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;
@@ -208,6 +209,6 @@ struct WeakRepeatedPtrField {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_IMPLICIT_WEAK_MESSAGE_H__
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 93e9fb9e908..a2dfdcf138f 100644
--- a/contrib/libs/protobuf/src/google/protobuf/inlined_string_field.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/inlined_string_field.cc
@@ -28,16 +28,18 @@
// (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/inlined_string_field.h>
+#include "google/protobuf/inlined_string_field.h"
+
+#include "google/protobuf/arena.h"
+#include "y_absl/strings/internal/resize_uninitialized.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"
-#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>
+#include "google/protobuf/port_def.inc"
// clang-format on
namespace google {
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 1a7baafdb70..18040e11a75 100644
--- a/contrib/libs/protobuf/src/google/protobuf/inlined_string_field.h
+++ b/contrib/libs/protobuf/src/google/protobuf/inlined_string_field.h
@@ -34,15 +34,14 @@
#include <string>
#include <utility>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/port.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/arenastring.h>
-#include <google/protobuf/message_lite.h>
+#include "google/protobuf/port.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/arenastring.h"
+#include "google/protobuf/message_lite.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
#ifdef SWIG
#error "You cannot SWIG proto headers"
@@ -130,7 +129,7 @@ class PROTOBUF_EXPORT InlinedStringField {
// `donated == ((donating_states & ~mask) != 0)`
//
// This method never changes the `donating_states`.
- void Set(ConstStringParam value, Arena* arena, bool donated,
+ void Set(y_absl::string_view 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
@@ -149,7 +148,7 @@ class PROTOBUF_EXPORT InlinedStringField {
::google::protobuf::Arena* arena, bool donated, arc_ui32* donating_states,
arc_ui32 mask, MessageLite* msg);
- void SetBytes(ConstStringParam value, Arena* arena, bool donated,
+ void SetBytes(y_absl::string_view value, Arena* arena, bool donated,
arc_ui32* donating_states, arc_ui32 mask, MessageLite* msg);
void SetBytes(TProtoStringType&& value, Arena* arena, bool donated,
@@ -167,7 +166,7 @@ class PROTOBUF_EXPORT InlinedStringField {
::google::protobuf::Arena* arena, bool donated, arc_ui32* donating_states,
arc_ui32 mask, MessageLite* msg);
- PROTOBUF_NDEBUG_INLINE void SetNoArena(StringPiece value);
+ PROTOBUF_NDEBUG_INLINE void SetNoArena(y_absl::string_view value);
PROTOBUF_NDEBUG_INLINE void SetNoArena(TProtoStringType&& value);
// Basic accessors.
@@ -228,7 +227,7 @@ class PROTOBUF_EXPORT InlinedStringField {
return Release();
}
- void Set(const TProtoStringType*, ConstStringParam value, Arena* arena,
+ void Set(const TProtoStringType*, y_absl::string_view value, Arena* arena,
bool donated, arc_ui32* donating_states, arc_ui32 mask,
MessageLite* msg) {
Set(value, arena, donated, donating_states, mask, msg);
@@ -261,7 +260,7 @@ class PROTOBUF_EXPORT InlinedStringField {
Set(const_string_ref, arena, donated, donating_states, mask, msg);
}
- void SetBytes(const TProtoStringType*, ConstStringParam value, Arena* arena,
+ void SetBytes(const TProtoStringType*, y_absl::string_view value, Arena* arena,
bool donated, arc_ui32* donating_states, arc_ui32 mask,
MessageLite* msg) {
Set(value, arena, donated, donating_states, mask, msg);
@@ -297,7 +296,7 @@ class PROTOBUF_EXPORT InlinedStringField {
msg);
}
- void SetNoArena(const TProtoStringType*, StringPiece value) {
+ void SetNoArena(const TProtoStringType*, y_absl::string_view value) {
SetNoArena(value);
}
void SetNoArena(const TProtoStringType*, TProtoStringType&& value) {
@@ -413,7 +412,7 @@ inline void InlinedStringField::DestroyNoArena(const TProtoStringType*) {
this->~InlinedStringField();
}
-inline void InlinedStringField::SetNoArena(StringPiece value) {
+inline void InlinedStringField::SetNoArena(y_absl::string_view value) {
get_mutable()->assign(value.data(), value.length());
}
@@ -427,7 +426,7 @@ inline PROTOBUF_NDEBUG_INLINE void InlinedStringField::InternalSwap(
MessageLite* lhs_msg, //
InlinedStringField* rhs, Arena* rhs_arena, bool rhs_arena_dtor_registered,
MessageLite* rhs_msg) {
-#if GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE
+#ifdef GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE
lhs->get_mutable()->swap(*rhs->get_mutable());
if (!lhs_arena_dtor_registered && rhs_arena_dtor_registered) {
lhs_msg->OnDemandRegisterArenaDtor(lhs_arena);
@@ -445,7 +444,7 @@ inline PROTOBUF_NDEBUG_INLINE void InlinedStringField::InternalSwap(
#endif
}
-inline void InlinedStringField::Set(ConstStringParam value, Arena* arena,
+inline void InlinedStringField::Set(y_absl::string_view value, Arena* arena,
bool donated, arc_ui32* /*donating_states*/,
arc_ui32 /*mask*/, MessageLite* /*msg*/) {
(void)arena;
@@ -456,17 +455,17 @@ inline void InlinedStringField::Set(ConstStringParam value, Arena* arena,
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);
+ Set(y_absl::string_view(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);
+ Set(y_absl::string_view{str, size}, arena, donated, donating_states, mask, msg);
}
-inline void InlinedStringField::SetBytes(ConstStringParam value, Arena* arena,
+inline void InlinedStringField::SetBytes(y_absl::string_view value, Arena* arena,
bool donated,
arc_ui32* donating_states,
arc_ui32 mask, MessageLite* msg) {
@@ -527,6 +526,6 @@ inline TProtoStringType* InlinedStringField::MutableNoCopy(std::nullptr_t) {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_INLINED_STRING_FIELD_H__
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 926e9394515..fe251ceb11d 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/coded_stream.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/io/coded_stream.cc
@@ -38,24 +38,29 @@
// will not cross the end of the buffer, since we can avoid a lot
// of branching in this case.
-#include <google/protobuf/io/coded_stream.h>
+#include "google/protobuf/io/coded_stream.h"
#include <limits.h>
#include <algorithm>
+#include <cstddef>
+#include <cstdint>
#include <cstring>
#include <utility>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/arena.h>
-#include <google/protobuf/io/zero_copy_stream.h>
-#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
-#include <google/protobuf/stubs/stl_util.h>
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/cord.h"
+#include "y_absl/strings/internal/resize_uninitialized.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/arena.h"
+#include "google/protobuf/io/zero_copy_stream.h"
+#include "google/protobuf/io/zero_copy_stream_impl_lite.h"
+#include "google/protobuf/port.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -66,6 +71,9 @@ namespace {
static const int kMaxVarintBytes = 10;
static const int kMaxVarint32Bytes = 5;
+// When reading / writing Cords, if we have fewer than this many bytes we
+// won't bother trying to avoid coping the contents.
+static const int kMaxCordBytesToCopy = 512;
inline bool NextNonEmpty(ZeroCopyInputStream* input, const void** data,
int* size) {
@@ -76,6 +84,14 @@ inline bool NextNonEmpty(ZeroCopyInputStream* input, const void** data,
return success;
}
+inline uint8_t* CopyCordToArray(const y_absl::Cord& cord, uint8_t* target) {
+ for (y_absl::string_view sv : cord.Chunks()) {
+ memcpy(target, sv.data(), sv.size());
+ target += sv.size();
+ }
+ return target;
+}
+
} // namespace
// CodedInputStream ==================================================
@@ -159,7 +175,7 @@ CodedInputStream::Limit CodedInputStream::ReadLengthAndPushLimit() {
bool CodedInputStream::DecrementRecursionDepthAndPopLimit(Limit limit) {
bool result = ConsumedEntireMessage();
PopLimit(limit);
- GOOGLE_DCHECK_LT(recursion_budget_, recursion_limit_);
+ Y_ABSL_DCHECK_LT(recursion_budget_, recursion_limit_);
++recursion_budget_;
return result;
}
@@ -191,13 +207,12 @@ int CodedInputStream::BytesUntilTotalBytesLimit() const {
}
void CodedInputStream::PrintTotalBytesLimitError() {
- GOOGLE_LOG(ERROR)
- << "A protocol message was rejected because it was too "
- "big (more than "
- << total_bytes_limit_
- << " bytes). To increase the limit (or to disable these "
- "warnings), see CodedInputStream::SetTotalBytesLimit() "
- "in third_party/protobuf/io/coded_stream.h.";
+ Y_ABSL_LOG(ERROR) << "A protocol message was rejected because it was too "
+ "big (more than "
+ << total_bytes_limit_
+ << " bytes). To increase the limit (or to disable these "
+ "warnings), see CodedInputStream::SetTotalBytesLimit() "
+ "in third_party/protobuf/io/coded_stream.h.";
}
bool CodedInputStream::SkipFallback(int count, int original_buffer_size) {
@@ -260,12 +275,12 @@ bool CodedInputStream::ReadString(TProtoStringType* buffer, int size) {
if (size < 0) return false; // security: size is often user-supplied
if (BufferSize() >= size) {
- STLStringResizeUninitialized(buffer, size);
+ y_absl::strings_internal::STLStringResizeUninitialized(buffer, size);
std::pair<char*, bool> z = as_string_data(buffer);
if (z.second) {
// Oddly enough, memcpy() requires its first two args to be non-NULL even
// if we copy 0 bytes. So, we have ensured that z.first is non-NULL here.
- GOOGLE_DCHECK(z.first != NULL);
+ Y_ABSL_DCHECK(z.first != NULL);
memcpy(z.first, buffer_, size);
Advance(size);
}
@@ -308,6 +323,46 @@ bool CodedInputStream::ReadStringFallback(TProtoStringType* buffer, int size) {
return true;
}
+bool CodedInputStream::ReadCord(y_absl::Cord* output, int size) {
+ Y_ABSL_DCHECK_NE(output, nullptr);
+
+ // security: size is often user-supplied
+ if (size < 0) {
+ output->Clear();
+ return false; // security: size is often user-supplied
+ }
+
+ // Grab whatever is in the current output if `size` is relatively small,
+ // or if we are not sourcing data from an input stream.
+ if (input_ == nullptr || size < kMaxCordBytesToCopy) {
+ // Just copy the current buffer into the output rather than backing up.
+ y_absl::string_view buffer(reinterpret_cast<const char*>(buffer_),
+ static_cast<size_t>(std::min(size, BufferSize())));
+ *output = buffer;
+ Advance(static_cast<int>(buffer.size()));
+ size -= static_cast<int>(buffer.size());
+ if (size == 0) return true;
+ if (input_ == nullptr || buffer_size_after_limit_ + overflow_bytes_ > 0) {
+ // We hit a limit.
+ return false;
+ }
+ } else {
+ output->Clear();
+ BackUpInputToCurrentPosition();
+ }
+
+ // Make sure to not cross a limit set by PushLimit() or SetTotalBytesLimit().
+ const int closest_limit = std::min(current_limit_, total_bytes_limit_);
+ const int available = closest_limit - total_bytes_read_;
+ if (PROTOBUF_PREDICT_FALSE(size > available)) {
+ total_bytes_read_ = closest_limit;
+ input_->ReadCord(output, available);
+ return false;
+ }
+ total_bytes_read_ += size;
+ return input_->ReadCord(output, size);
+}
+
bool CodedInputStream::ReadLittleEndian32Fallback(arc_ui32* value) {
uint8_t bytes[sizeof(*value)];
@@ -350,7 +405,7 @@ namespace {
// subtracting 0x80 at each iteration, it subtracts properly shifted mask once.
template <size_t N>
const uint8_t* DecodeVarint64KnownSize(const uint8_t* buffer, arc_ui64* value) {
- GOOGLE_DCHECK_GT(N, 0);
+ Y_ABSL_DCHECK_GT(N, 0);
arc_ui64 result = static_cast<arc_ui64>(buffer[N - 1]) << (7 * (N - 1));
for (size_t i = 0, offset = 0; i < N - 1; i++, offset += 7) {
result += static_cast<arc_ui64>(buffer[i] - 0x80) << offset;
@@ -371,8 +426,8 @@ inline ::std::pair<bool, const uint8_t*> ReadVarint32FromArray(
arc_ui32 first_byte, const uint8_t* buffer, arc_ui32* value) {
// Fast path: We have enough bytes left in the buffer to guarantee that
// this read won't cross the end, so we can skip the checks.
- GOOGLE_DCHECK_EQ(*buffer, first_byte);
- GOOGLE_DCHECK_EQ(first_byte & 0x80, 0x80) << first_byte;
+ Y_ABSL_DCHECK_EQ(*buffer, first_byte);
+ Y_ABSL_DCHECK_EQ(first_byte & 0x80, 0x80) << first_byte;
const uint8_t* ptr = buffer;
arc_ui32 b;
arc_ui32 result = first_byte - 0x80;
@@ -415,7 +470,7 @@ PROTOBUF_ALWAYS_INLINE::std::pair<bool, const uint8_t*> ReadVarint64FromArray(
inline ::std::pair<bool, const uint8_t*> ReadVarint64FromArray(
const uint8_t* buffer, arc_ui64* value) {
// Assumes varint64 is at least 2 bytes.
- GOOGLE_DCHECK_GE(buffer[0], 128);
+ Y_ABSL_DCHECK_GE(buffer[0], 128);
const uint8_t* next;
if (buffer[1] < 128) {
@@ -460,7 +515,7 @@ arc_i64 CodedInputStream::ReadVarint32Fallback(arc_ui32 first_byte_or_zero) {
// Optimization: We're also safe if the buffer is non-empty and it ends
// with a byte that would terminate a varint.
(buffer_end_ > buffer_ && !(buffer_end_[-1] & 0x80))) {
- GOOGLE_DCHECK_NE(first_byte_or_zero, 0)
+ Y_ABSL_DCHECK_NE(first_byte_or_zero, 0)
<< "Caller should provide us with *buffer_ when buffer is non-empty";
arc_ui32 temp;
::std::pair<bool, const uint8_t*> p =
@@ -535,7 +590,7 @@ arc_ui32 CodedInputStream::ReadTagFallback(arc_ui32 first_byte_or_zero) {
// Optimization: We're also safe if the buffer is non-empty and it ends
// with a byte that would terminate a varint.
(buf_size > 0 && !(buffer_end_[-1] & 0x80))) {
- GOOGLE_DCHECK_EQ(first_byte_or_zero, buffer_[0]);
+ Y_ABSL_DCHECK_EQ(first_byte_or_zero, buffer_[0]);
if (first_byte_or_zero == 0) {
++buffer_;
return 0;
@@ -615,7 +670,7 @@ std::pair<arc_ui64, bool> CodedInputStream::ReadVarint64Fallback() {
}
bool CodedInputStream::Refresh() {
- GOOGLE_DCHECK_EQ(0, BufferSize());
+ Y_ABSL_DCHECK_EQ(0, BufferSize());
if (buffer_size_after_limit_ > 0 || overflow_bytes_ > 0 ||
total_bytes_read_ == current_limit_) {
@@ -636,7 +691,7 @@ bool CodedInputStream::Refresh() {
if (NextNonEmpty(input_, &void_buffer, &buffer_size)) {
buffer_ = reinterpret_cast<const uint8_t*>(void_buffer);
buffer_end_ = buffer_ + buffer_size;
- GOOGLE_CHECK_GE(buffer_size, 0);
+ Y_ABSL_CHECK_GE(buffer_size, 0);
if (total_bytes_read_ <= INT_MAX - buffer_size) {
total_bytes_read_ += buffer_size;
@@ -683,8 +738,8 @@ int64_t EpsCopyOutputStream::ByteCount(uint8_t* ptr) const {
int EpsCopyOutputStream::Flush(uint8_t* ptr) {
while (buffer_end_ && ptr > end_) {
int overrun = ptr - end_;
- GOOGLE_DCHECK(!had_error_);
- GOOGLE_DCHECK(overrun <= kSlopBytes); // NOLINT
+ Y_ABSL_DCHECK(!had_error_);
+ Y_ABSL_DCHECK(overrun <= kSlopBytes); // NOLINT
ptr = Next() + overrun;
if (had_error_) return 0;
}
@@ -698,7 +753,7 @@ int EpsCopyOutputStream::Flush(uint8_t* ptr) {
s = end_ + kSlopBytes - ptr;
buffer_end_ = ptr;
}
- GOOGLE_DCHECK(s >= 0); // NOLINT
+ Y_ABSL_DCHECK(s >= 0); // NOLINT
return s;
}
@@ -786,7 +841,7 @@ uint8_t* EpsCopyOutputStream::GetDirectBufferForNBytesAndAdvance(int size,
}
uint8_t* EpsCopyOutputStream::Next() {
- GOOGLE_DCHECK(!had_error_); // NOLINT
+ Y_ABSL_DCHECK(!had_error_); // NOLINT
if (PROTOBUF_PREDICT_FALSE(stream_ == nullptr)) return Error();
if (buffer_end_) {
// We're in the patch buffer and need to fill up the previous buffer.
@@ -808,7 +863,7 @@ uint8_t* EpsCopyOutputStream::Next() {
buffer_end_ = nullptr;
return ptr;
} else {
- GOOGLE_DCHECK(size > 0); // NOLINT
+ Y_ABSL_DCHECK(size > 0); // NOLINT
// Buffer to small
std::memmove(buffer_, end_, kSlopBytes);
buffer_end_ = ptr;
@@ -827,11 +882,11 @@ uint8_t* EpsCopyOutputStream::EnsureSpaceFallback(uint8_t* ptr) {
do {
if (PROTOBUF_PREDICT_FALSE(had_error_)) return buffer_;
int overrun = ptr - end_;
- GOOGLE_DCHECK(overrun >= 0); // NOLINT
- GOOGLE_DCHECK(overrun <= kSlopBytes); // NOLINT
+ Y_ABSL_DCHECK(overrun >= 0); // NOLINT
+ Y_ABSL_DCHECK(overrun <= kSlopBytes); // NOLINT
ptr = Next() + overrun;
} while (ptr >= end_);
- GOOGLE_DCHECK(ptr < end_); // NOLINT
+ Y_ABSL_DCHECK(ptr < end_); // NOLINT
return ptr;
}
@@ -909,6 +964,26 @@ uint8_t* EpsCopyOutputStream::WriteRawLittleEndian64(const void* data, int size,
}
#endif
+uint8_t* EpsCopyOutputStream::WriteCord(const y_absl::Cord& cord, uint8_t* ptr) {
+ int s = GetSize(ptr);
+ if (stream_ == nullptr) {
+ if (static_cast<arc_i64>(cord.size()) <= s) {
+ // Just copy it to the current buffer.
+ return CopyCordToArray(cord, ptr);
+ } else {
+ return Error();
+ }
+ } else if (static_cast<arc_i64>(cord.size()) <= s &&
+ static_cast<arc_i64>(cord.size()) < kMaxCordBytesToCopy) {
+ // Just copy it to the current buffer.
+ return CopyCordToArray(cord, ptr);
+ } else {
+ // Back up to the position where the Cord should start.
+ ptr = Trim(ptr);
+ if (!stream_->WriteCord(cord)) return Error();
+ return ptr;
+ }
+}
uint8_t* EpsCopyOutputStream::WriteStringMaybeAliasedOutline(arc_ui32 num,
const TProtoStringType& s,
@@ -927,41 +1002,40 @@ uint8_t* EpsCopyOutputStream::WriteStringOutline(arc_ui32 num, const TProtoStrin
return WriteRaw(s.data(), size, ptr);
}
+uint8_t* EpsCopyOutputStream::WriteStringOutline(arc_ui32 num, y_absl::string_view s,
+ uint8_t* ptr) {
+ ptr = EnsureSpace(ptr);
+ arc_ui32 size = s.size();
+ ptr = WriteLengthDelim(num, size, ptr);
+ return WriteRaw(s.data(), size, ptr);
+}
+
+uint8_t* EpsCopyOutputStream::WriteCordOutline(const y_absl::Cord& c, uint8_t* ptr) {
+ arc_ui32 size = c.size();
+ ptr = UnsafeWriteSize(size, ptr);
+ return WriteCord(c, ptr);
+}
+
std::atomic<bool> CodedOutputStream::default_serialization_deterministic_{
false};
CodedOutputStream::~CodedOutputStream() { Trim(); }
+uint8_t* CodedOutputStream::WriteCordToArray(const y_absl::Cord& cord,
+ uint8_t* target) {
+ return CopyCordToArray(cord, target);
+}
+
uint8_t* CodedOutputStream::WriteStringWithSizeToArray(const TProtoStringType& str,
uint8_t* target) {
- GOOGLE_DCHECK_LE(str.size(), std::numeric_limits<arc_ui32>::max());
+ Y_ABSL_DCHECK_LE(str.size(), std::numeric_limits<arc_ui32>::max());
target = WriteVarint32ToArray(str.size(), target);
return WriteStringToArray(str, target);
}
-uint8_t* CodedOutputStream::WriteVarint32ToArrayOutOfLineHelper(arc_ui32 value,
- uint8_t* target) {
- GOOGLE_DCHECK_GE(value, 0x80);
- target[0] |= static_cast<uint8_t>(0x80);
- value >>= 7;
- target[1] = static_cast<uint8_t>(value);
- if (value < 0x80) {
- return target + 2;
- }
- target += 2;
- do {
- // Turn on continuation bit in the byte we just wrote.
- target[-1] |= static_cast<uint8_t>(0x80);
- value >>= 7;
- *target = static_cast<uint8_t>(value);
- ++target;
- } while (value >= 0x80);
- return target;
-}
-
} // namespace io
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
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 e8bde19d853..e0a86f0e32d 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/coded_stream.h
+++ b/contrib/libs/protobuf/src/google/protobuf/io/coded_stream.h
@@ -109,7 +109,6 @@
#ifndef GOOGLE_PROTOBUF_IO_CODED_STREAM_H__
#define GOOGLE_PROTOBUF_IO_CODED_STREAM_H__
-
#include <assert.h>
#include <atomic>
@@ -128,15 +127,17 @@
#endif
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/port.h>
-#include <google/protobuf/stubs/port.h>
+#include "google/protobuf/stubs/common.h"
+#include "y_absl/base/attributes.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/numeric/bits.h"
+#include "y_absl/strings/cord.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/port.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -178,6 +179,8 @@ class PROTOBUF_EXPORT CodedInputStream {
// faster than using an ArrayInputStream. PushLimit(size) is implied by
// this constructor.
explicit CodedInputStream(const uint8_t* buffer, int size);
+ CodedInputStream(const CodedInputStream&) = delete;
+ CodedInputStream& operator=(const CodedInputStream&) = delete;
// Destroy the CodedInputStream and position the underlying
// ZeroCopyInputStream at the first unread byte. If an error occurred while
@@ -214,6 +217,9 @@ class PROTOBUF_EXPORT CodedInputStream {
// Like ReadRaw, but reads into a string.
bool ReadString(TProtoStringType* buffer, int size);
+ // Like ReadString(), but reads to a Cord.
+ bool ReadCord(y_absl::Cord* output, int size);
+
// Read a 32-bit little-endian integer.
bool ReadLittleEndian32(arc_ui32* value);
@@ -518,8 +524,6 @@ class PROTOBUF_EXPORT CodedInputStream {
MessageFactory* GetExtensionFactory();
private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CodedInputStream);
-
const uint8_t* buffer_;
const uint8_t* buffer_end_; // pointer to the end of the buffer.
ZeroCopyInputStream* input_;
@@ -681,7 +685,7 @@ class PROTOBUF_EXPORT EpsCopyOutputStream {
if (PROTOBUF_PREDICT_FALSE(end_ - ptr < size)) {
return WriteRawFallback(data, size, ptr);
}
- std::memcpy(ptr, data, size);
+ std::memcpy(ptr, data, static_cast<unsigned int>(size));
return ptr + size;
}
// Writes the buffer specified by data, size to the stream. Possibly by
@@ -699,6 +703,7 @@ class PROTOBUF_EXPORT EpsCopyOutputStream {
}
}
+ uint8_t* WriteCord(const y_absl::Cord& cord, uint8_t* ptr);
#ifndef NDEBUG
PROTOBUF_NOINLINE
@@ -733,6 +738,13 @@ class PROTOBUF_EXPORT EpsCopyOutputStream {
std::memcpy(ptr, s.data(), size);
return ptr + size;
}
+
+ uint8_t* WriteString(arc_ui32 num, const y_absl::Cord& s, uint8_t* ptr) {
+ ptr = EnsureSpace(ptr);
+ ptr = WriteTag(num, 2, ptr);
+ return WriteCordOutline(s, ptr);
+ }
+
template <typename T>
#ifndef NDEBUG
PROTOBUF_NOINLINE
@@ -832,7 +844,7 @@ class PROTOBUF_EXPORT EpsCopyOutputStream {
inline uint8_t* Next();
int Flush(uint8_t* ptr);
std::ptrdiff_t GetSize(uint8_t* ptr) const {
- GOOGLE_DCHECK(ptr <= end_ + kSlopBytes); // NOLINT
+ Y_ABSL_DCHECK(ptr <= end_ + kSlopBytes); // NOLINT
return end_ + kSlopBytes - ptr;
}
@@ -853,7 +865,7 @@ class PROTOBUF_EXPORT EpsCopyOutputStream {
PROTOBUF_ALWAYS_INLINE uint8_t* WriteTag(arc_ui32 num, arc_ui32 wt,
uint8_t* ptr) {
- GOOGLE_DCHECK(ptr < end_); // NOLINT
+ Y_ABSL_DCHECK(ptr < end_); // NOLINT
return UnsafeVarint((num << 3) | wt, ptr);
}
@@ -870,6 +882,8 @@ class PROTOBUF_EXPORT EpsCopyOutputStream {
uint8_t* WriteStringMaybeAliasedOutline(arc_ui32 num, const TProtoStringType& s,
uint8_t* ptr);
uint8_t* WriteStringOutline(arc_ui32 num, const TProtoStringType& s, uint8_t* ptr);
+ uint8_t* WriteStringOutline(arc_ui32 num, y_absl::string_view s, uint8_t* ptr);
+ uint8_t* WriteCordOutline(const y_absl::Cord& c, uint8_t* ptr);
template <typename T, typename E>
PROTOBUF_ALWAYS_INLINE uint8_t* WriteVarintPacked(int num, const T& r,
@@ -899,25 +913,12 @@ class PROTOBUF_EXPORT EpsCopyOutputStream {
PROTOBUF_ALWAYS_INLINE static uint8_t* UnsafeVarint(T value, uint8_t* ptr) {
static_assert(std::is_unsigned<T>::value,
"Varint serialization must be unsigned");
- ptr[0] = static_cast<uint8_t>(value);
- if (value < 0x80) {
- return ptr + 1;
- }
- // Turn on continuation bit in the byte we just wrote.
- ptr[0] |= static_cast<uint8_t>(0x80);
- value >>= 7;
- ptr[1] = static_cast<uint8_t>(value);
- if (value < 0x80) {
- return ptr + 2;
- }
- ptr += 2;
- do {
- // Turn on continuation bit in the byte we just wrote.
- ptr[-1] |= static_cast<uint8_t>(0x80);
+ while (PROTOBUF_PREDICT_FALSE(value >= 0x80)) {
+ *ptr = static_cast<uint8_t>(value | 0x80);
value >>= 7;
- *ptr = static_cast<uint8_t>(value);
++ptr;
- } while (value >= 0x80);
+ }
+ *ptr++ = static_cast<uint8_t>(value);
return ptr;
}
@@ -1061,6 +1062,8 @@ class PROTOBUF_EXPORT CodedOutputStream {
template <class Stream, class = typename std::enable_if<std::is_base_of<
ZeroCopyOutputStream, Stream>::value>::type>
CodedOutputStream(Stream* stream, bool eager_init);
+ CodedOutputStream(const CodedOutputStream&) = delete;
+ CodedOutputStream& operator=(const CodedOutputStream&) = delete;
// Destroy the CodedOutputStream and position the underlying
// ZeroCopyOutputStream immediately after the last byte written.
@@ -1071,7 +1074,7 @@ class PROTOBUF_EXPORT CodedOutputStream {
// errors.
bool HadError() {
cur_ = impl_.FlushAndResetBuffer(cur_);
- GOOGLE_DCHECK(cur_);
+ Y_ABSL_DCHECK(cur_);
return impl_.HadError();
}
@@ -1136,6 +1139,12 @@ class PROTOBUF_EXPORT CodedOutputStream {
static uint8_t* WriteStringWithSizeToArray(const TProtoStringType& str,
uint8_t* target);
+ // Like WriteString() but writes a Cord.
+ void WriteCord(const y_absl::Cord& cord) { cur_ = impl_.WriteCord(cord, cur_); }
+
+ // Like WriteCord() but writing directly to the target array.
+ static uint8_t* WriteCordToArray(const y_absl::Cord& cord, uint8_t* target);
+
// Write a 32-bit little-endian integer.
void WriteLittleEndian32(arc_ui32 value) {
@@ -1158,10 +1167,12 @@ class PROTOBUF_EXPORT CodedOutputStream {
void WriteVarint32(arc_ui32 value);
// Like WriteVarint32() but writing directly to the target array.
static uint8_t* WriteVarint32ToArray(arc_ui32 value, uint8_t* target);
- // Like WriteVarint32() but writing directly to the target array, and with
- // the less common-case paths being out of line rather than inlined.
+ // Like WriteVarint32ToArray()
+ PROTOBUF_DEPRECATED_MSG("Please use WriteVarint32ToArray() instead")
static uint8_t* WriteVarint32ToArrayOutOfLine(arc_ui32 value,
- uint8_t* target);
+ uint8_t* target) {
+ return WriteVarint32ToArray(value, target);
+ }
// Write an unsigned integer with Varint encoding.
void WriteVarint64(arc_ui64 value);
// Like WriteVarint64() but writing directly to the target array.
@@ -1281,14 +1292,10 @@ class PROTOBUF_EXPORT CodedOutputStream {
// that wants deterministic serialization by default needs to call
// SetDefaultSerializationDeterministic() or ensure on its own that another
// thread has done so.
- friend void internal::MapTestForceDeterministic();
+ friend void google::protobuf::internal::MapTestForceDeterministic();
static void SetDefaultSerializationDeterministic() {
default_serialization_deterministic_.store(true, std::memory_order_relaxed);
}
- // REQUIRES: value >= 0x80, and that (value & 7f) has been written to *target.
- static uint8_t* WriteVarint32ToArrayOutOfLineHelper(arc_ui32 value,
- uint8_t* target);
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CodedOutputStream);
};
// inline methods ====================================================
@@ -1647,16 +1654,6 @@ inline uint8_t* CodedOutputStream::WriteVarint32ToArray(arc_ui32 value,
return EpsCopyOutputStream::UnsafeVarint(value, target);
}
-inline uint8_t* CodedOutputStream::WriteVarint32ToArrayOutOfLine(
- arc_ui32 value, uint8_t* target) {
- target[0] = static_cast<uint8_t>(value);
- if (value < 0x80) {
- return target + 1;
- } else {
- return WriteVarint32ToArrayOutOfLineHelper(value, target);
- }
-}
-
inline uint8_t* CodedOutputStream::WriteVarint64ToArray(arc_ui64 value,
uint8_t* target) {
return EpsCopyOutputStream::UnsafeVarint(value, target);
@@ -1729,15 +1726,16 @@ inline size_t CodedOutputStream::VarintSize32(arc_ui32 value) {
// This computes value == 0 ? 1 : floor(log2(value)) / 7 + 1
// Use an explicit multiplication to implement the divide of
// a number in the 1..31 range.
- // Explicit OR 0x1 to avoid calling Bits::Log2FloorNonZero(0), which is
- // undefined.
- arc_ui32 log2value = Bits::Log2FloorNonZero(value | 0x1);
+ //
+ // Explicit OR 0x1 to avoid calling y_absl::countl_zero(0), which
+ // requires a branch to check for on many platforms.
+ arc_ui32 log2value = 31 - y_absl::countl_zero(value | 0x1);
return static_cast<size_t>((log2value * 9 + 73) / 64);
}
inline size_t CodedOutputStream::VarintSize32PlusOne(arc_ui32 value) {
// Same as above, but one more.
- arc_ui32 log2value = Bits::Log2FloorNonZero(value | 0x1);
+ arc_ui32 log2value = 31 - y_absl::countl_zero(value | 0x1);
return static_cast<size_t>((log2value * 9 + 73 + 64) / 64);
}
@@ -1745,15 +1743,16 @@ inline size_t CodedOutputStream::VarintSize64(arc_ui64 value) {
// This computes value == 0 ? 1 : floor(log2(value)) / 7 + 1
// Use an explicit multiplication to implement the divide of
// a number in the 1..63 range.
- // Explicit OR 0x1 to avoid calling Bits::Log2FloorNonZero(0), which is
- // undefined.
- arc_ui32 log2value = Bits::Log2FloorNonZero64(value | 0x1);
+ //
+ // Explicit OR 0x1 to avoid calling y_absl::countl_zero(0), which
+ // requires a branch to check for on many platforms.
+ arc_ui32 log2value = 63 - y_absl::countl_zero(value | 0x1);
return static_cast<size_t>((log2value * 9 + 73) / 64);
}
inline size_t CodedOutputStream::VarintSize64PlusOne(arc_ui64 value) {
// Same as above, but one more.
- arc_ui32 log2value = Bits::Log2FloorNonZero64(value | 0x1);
+ arc_ui32 log2value = 63 - y_absl::countl_zero(value | 0x1);
return static_cast<size_t>((log2value * 9 + 73 + 64) / 64);
}
@@ -1777,7 +1776,7 @@ inline void CodedOutputStream::WriteRawMaybeAliased(const void* data,
inline uint8_t* CodedOutputStream::WriteRawToArray(const void* data, int size,
uint8_t* target) {
- memcpy(target, data, size);
+ memcpy(target, data, static_cast<unsigned int>(size));
return target + size;
}
@@ -1794,6 +1793,6 @@ inline uint8_t* CodedOutputStream::WriteStringToArray(const TProtoStringType& st
#pragma runtime_checks("c", restore)
#endif // _MSC_VER && !defined(__INTEL_COMPILER)
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_IO_CODED_STREAM_H__
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 4b491dd0246..b61a9e3f878 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/gzip_stream.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/io/gzip_stream.cc
@@ -35,11 +35,12 @@
#if HAVE_ZLIB
-#include <google/protobuf/io/gzip_stream.h>
-#include <google/protobuf/port.h>
+#include "google/protobuf/io/gzip_stream.h"
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/logging.h>
+#include "google/protobuf/stubs/common.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "google/protobuf/port.h"
namespace google {
namespace protobuf {
@@ -65,7 +66,7 @@ GzipInputStream::GzipInputStream(ZeroCopyInputStream* sub_stream, Format format,
output_buffer_length_ = buffer_size;
}
output_buffer_ = operator new(output_buffer_length_);
- GOOGLE_CHECK(output_buffer_ != NULL);
+ Y_ABSL_CHECK(output_buffer_ != NULL);
zcontext_.next_out = static_cast<Bytef*>(output_buffer_);
zcontext_.avail_out = output_buffer_length_;
output_position_ = output_buffer_;
@@ -220,7 +221,7 @@ void GzipOutputStream::Init(ZeroCopyOutputStream* sub_stream,
input_buffer_length_ = options.buffer_size;
input_buffer_ = operator new(input_buffer_length_);
- GOOGLE_CHECK(input_buffer_ != NULL);
+ Y_ABSL_CHECK(input_buffer_ != NULL);
zcontext_.zalloc = Z_NULL;
zcontext_.zfree = Z_NULL;
@@ -259,7 +260,7 @@ int GzipOutputStream::Deflate(int flush) {
sub_data_size_ = 0;
return Z_BUF_ERROR;
}
- GOOGLE_CHECK_GT(sub_data_size_, 0);
+ Y_ABSL_CHECK_GT(sub_data_size_, 0);
zcontext_.next_out = static_cast<Bytef*>(sub_data_);
zcontext_.avail_out = sub_data_size_;
}
@@ -294,12 +295,12 @@ bool GzipOutputStream::Next(void** data, int* size) {
*size = input_buffer_length_;
} else {
// The loop in Deflate should consume all avail_in
- GOOGLE_LOG(DFATAL) << "Deflate left bytes unconsumed";
+ Y_ABSL_DLOG(FATAL) << "Deflate left bytes unconsumed";
}
return true;
}
void GzipOutputStream::BackUp(int count) {
- GOOGLE_CHECK_GE(zcontext_.avail_in, static_cast<uInt>(count));
+ Y_ABSL_CHECK_GE(zcontext_.avail_in, static_cast<uInt>(count));
zcontext_.avail_in -= count;
}
int64_t GzipOutputStream::ByteCount() const {
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 170ba709291..5f81868e184 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/gzip_stream.h
+++ b/contrib/libs/protobuf/src/google/protobuf/io/gzip_stream.h
@@ -43,22 +43,20 @@
#ifndef GOOGLE_PROTOBUF_IO_GZIP_STREAM_H__
#define GOOGLE_PROTOBUF_IO_GZIP_STREAM_H__
-
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/io/zero_copy_stream.h>
-#include <google/protobuf/port.h>
+#include "google/protobuf/stubs/common.h"
+#include "google/protobuf/io/zero_copy_stream.h"
+#include "google/protobuf/port.h"
#include "zlib.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
namespace io {
// A ZeroCopyInputStream that reads compressed data through zlib
-class PROTOBUF_EXPORT GzipInputStream PROTOBUF_FUTURE_FINAL
- : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT GzipInputStream final : public ZeroCopyInputStream {
public:
// Format key for constructor
enum Format {
@@ -75,7 +73,9 @@ class PROTOBUF_EXPORT GzipInputStream PROTOBUF_FUTURE_FINAL
// buffer_size and format may be -1 for default of 64kB and GZIP format
explicit GzipInputStream(ZeroCopyInputStream* sub_stream,
Format format = AUTO, int buffer_size = -1);
- virtual ~GzipInputStream();
+ GzipInputStream(const GzipInputStream&) = delete;
+ GzipInputStream& operator=(const GzipInputStream&) = delete;
+ ~GzipInputStream() override;
// Return last error message or NULL if no error.
inline const char* ZlibErrorMessage() const { return zcontext_.msg; }
@@ -102,12 +102,9 @@ class PROTOBUF_EXPORT GzipInputStream PROTOBUF_FUTURE_FINAL
int Inflate(int flush);
void DoNextOutput(const void** data, int* size);
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GzipInputStream);
};
-class PROTOBUF_EXPORT GzipOutputStream PROTOBUF_FUTURE_FINAL
- : public ZeroCopyOutputStream {
+class PROTOBUF_EXPORT GzipOutputStream final : public ZeroCopyOutputStream {
public:
// Format key for constructor
enum Format {
@@ -142,8 +139,10 @@ class PROTOBUF_EXPORT GzipOutputStream PROTOBUF_FUTURE_FINAL
// Create a GzipOutputStream with the given options.
GzipOutputStream(ZeroCopyOutputStream* sub_stream, const Options& options);
+ GzipOutputStream(const GzipOutputStream&) = delete;
+ GzipOutputStream& operator=(const GzipOutputStream&) = delete;
- virtual ~GzipOutputStream();
+ ~GzipOutputStream() override;
// Return last error message or NULL if no error.
inline const char* ZlibErrorMessage() const { return zcontext_.msg; }
@@ -192,14 +191,12 @@ class PROTOBUF_EXPORT GzipOutputStream PROTOBUF_FUTURE_FINAL
// Takes zlib flush mode.
// Returns zlib error code.
int Deflate(int flush);
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GzipOutputStream);
};
} // namespace io
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_IO_GZIP_STREAM_H__
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 e29ac4952e4..0036bbd3980 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/io_win32.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/io/io_win32.cc
@@ -49,7 +49,7 @@
// debug failing tests if that's caused by the long path support.
#define SUPPORT_LONGPATHS
-#include <google/protobuf/io/io_win32.h>
+#include "google/protobuf/io/io_win32.h"
#include <ctype.h>
#include <direct.h>
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 37572ef0681..7528cd979d4 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/io_win32.h
+++ b/contrib/libs/protobuf/src/google/protobuf/io/io_win32.h
@@ -53,10 +53,10 @@
#include <string>
#include <google/protobuf/stubs/port.h>
-#include <google/protobuf/port.h>
+#include "google/protobuf/port.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
// Compilers on Windows other than MSVC (e.g. Cygwin, MinGW32) define the
// following functions already, except for mkdir.
@@ -135,7 +135,7 @@ PROTOBUF_EXPORT bool wcs_to_utf8(const wchar_t* input, TProtoStringType* out);
#define STDOUT_FILENO 1
#endif
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // defined(_WIN32)
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/printer.cc b/contrib/libs/protobuf/src/google/protobuf/io/printer.cc
index e174a49133e..7be5e3d0b5a 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/printer.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/io/printer.cc
@@ -32,195 +32,371 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/io/printer.h>
-
-#include <cctype>
-
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/io/zero_copy_stream.h>
+#include "google/protobuf/io/printer.h"
+
+#include <stdlib.h>
+
+#include <cstddef>
+#include <functional>
+#include <string>
+#include <type_traits>
+#include <utility>
+#include <vector>
+
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/escaping.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/str_split.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/strings/strip.h"
+#include "y_absl/types/optional.h"
+#include "y_absl/types/span.h"
+#include "y_absl/types/variant.h"
namespace google {
namespace protobuf {
namespace io {
-
-Printer::Printer(ZeroCopyOutputStream* output, char variable_delimiter)
- : variable_delimiter_(variable_delimiter),
- output_(output),
- buffer_(NULL),
- buffer_size_(0),
- offset_(0),
- at_start_of_line_(true),
- failed_(false),
- annotation_collector_(NULL) {}
-
-Printer::Printer(ZeroCopyOutputStream* output, char variable_delimiter,
- AnnotationCollector* annotation_collector)
- : variable_delimiter_(variable_delimiter),
- output_(output),
- buffer_(NULL),
- buffer_size_(0),
- offset_(0),
- at_start_of_line_(true),
- failed_(false),
- annotation_collector_(annotation_collector) {}
-
-Printer::~Printer() {
- // 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_);
+namespace {
+template <typename T>
+y_absl::optional<T> LookupInFrameStack(
+ y_absl::string_view var,
+ y_absl::Span<std::function<y_absl::optional<T>(y_absl::string_view)>> frames) {
+ for (size_t i = frames.size(); i >= 1; --i) {
+ auto val = frames[i - 1](var);
+ if (val.has_value()) {
+ return val;
+ }
}
+ return y_absl::nullopt;
}
+} // namespace
+
+struct Printer::Format {
+ struct Chunk {
+ // The chunk's text; if this is a variable, it does not include the $...$.
+ y_absl::string_view text;
+
+ // Whether or not this is a variable name, i.e., a $...$.
+ bool is_var;
+ };
+
+ struct Line {
+ // Chunks to emit, split along $ and annotates as to whether it is a
+ // variable name.
+ std::vector<Chunk> chunks;
+
+ // The indentation for this chunk.
+ size_t indent;
+ };
+
+ std::vector<Line> lines;
+
+ // Whether this is a multiline raw string, according to internal heuristics.
+ bool is_raw_string = false;
+};
+
+Printer::Format Printer::TokenizeFormat(y_absl::string_view format_string,
+ const PrintOptions& options) {
+ Format format;
+ size_t raw_string_indent = 0;
+ if (options.strip_raw_string_indentation) {
+ // We are processing a call that looks like
+ //
+ // p->Emit(R"cc(
+ // class Foo {
+ // int x, y, z;
+ // };
+ // )cc");
+ //
+ // or
+ //
+ // p->Emit(R"cc(
+ //
+ // class Foo {
+ // int x, y, z;
+ // };
+ // )cc");
+ //
+ // To compute the indent, we need:
+ // 1. Iterate over each line.
+ // 2. Find the first line that contains non-whitespace characters.
+ // 3. Count the number of leading spaces on that line.
+ //
+ // The following pairs of loops assume the current line is the first line
+ // with non-whitespace characters; if we consume all the spaces and
+ // then immediately hit a newline, this means this wasn't the right line and
+ // we should start over.
+ //
+ // Note that the very first character *must* be a newline; that is how we
+ // detect that this is a multi-line raw string template, and as such this is
+ // a while loop, not a do/while loop.
+
+ y_absl::string_view orig = format_string;
+ while (y_absl::ConsumePrefix(&format_string, "\n")) {
+ raw_string_indent = 0;
+ format.is_raw_string = true;
+ while (y_absl::ConsumePrefix(&format_string, " ")) {
+ ++raw_string_indent;
+ }
+ }
-bool Printer::GetSubstitutionRange(const char* varname,
- std::pair<size_t, size_t>* range) {
- std::map<TProtoStringType, std::pair<size_t, size_t> >::const_iterator iter =
- substitutions_.find(varname);
- if (iter == substitutions_.end()) {
- GOOGLE_LOG(DFATAL) << " Undefined variable in annotation: " << varname;
- return false;
+ // If we consume the entire string, this probably wasn't a raw string and
+ // was probably something like a couple of explicit newlines.
+ if (format_string.empty()) {
+ format_string = orig;
+ format.is_raw_string = false;
+ raw_string_indent = 0;
+ }
}
- if (iter->second.first > iter->second.second) {
- GOOGLE_LOG(DFATAL) << " Variable used for annotation used multiple times: "
- << varname;
- return false;
+
+ // We now split the remaining format string into lines and discard:
+ // 1. A trailing Printer-discarded comment, if this is a raw string.
+ //
+ // 2. All leading spaces to compute that line's indent.
+ // We do not do this for the first line, so that Emit(" ") works
+ // correctly. We do this *regardless* of whether we are processing
+ // a raw string, because existing non-raw-string calls to cpp::Formatter
+ // rely on this. There is a test that validates this behavior.
+ //
+ // 3. Set the indent for that line to max(0, line_indent -
+ // raw_string_indent), if this is not a raw string.
+ //
+ // 4. Trailing empty lines, if we know this is a raw string, except for
+ // a single extra newline at the end.
+ //
+ // Each line is itself split into chunks along the variable delimiters, e.g.
+ // $...$.
+ bool is_first = true;
+ for (y_absl::string_view line_text : y_absl::StrSplit(format_string, '\n')) {
+ if (format.is_raw_string) {
+ size_t comment_index = line_text.find(options_.ignored_comment_start);
+ line_text = line_text.substr(0, comment_index);
+ }
+
+ size_t line_indent = 0;
+ while (!is_first && y_absl::ConsumePrefix(&line_text, " ")) {
+ ++line_indent;
+ }
+ is_first = false;
+
+ format.lines.emplace_back();
+ auto& line = format.lines.back();
+ line.indent =
+ line_indent > raw_string_indent ? line_indent - raw_string_indent : 0;
+
+ bool is_var = false;
+ size_t total_len = 0;
+ for (y_absl::string_view chunk :
+ y_absl::StrSplit(line_text, options_.variable_delimiter)) {
+ // The special _start and _end variables should actually glom the next
+ // chunk into themselves, so as to be of the form _start$foo and _end$foo.
+ if (!line.chunks.empty() && !is_var) {
+ auto& prev = line.chunks.back();
+ if (prev.text == "_start" || prev.text == "_end") {
+ // The +1 below is to account for the $ in between them.
+ // This string is safe, because prev.text and chunk are contiguous
+ // by construction.
+ prev.text = y_absl::string_view(prev.text.data(),
+ prev.text.size() + 1 + chunk.size());
+
+ // Account for the foo$ part of $_start$foo$.
+ total_len += chunk.size() + 1;
+ continue;
+ }
+ }
+
+ if (is_var || !chunk.empty()) {
+ line.chunks.push_back(Format::Chunk{chunk, is_var});
+ }
+
+ total_len += chunk.size();
+ if (is_var) {
+ // This accounts for the $s around a variable.
+ total_len += 2;
+ }
+
+ is_var = !is_var;
+ }
+
+ // To ensure there are no unclosed $...$, we check that the computed length
+ // above equals the actual length of the string. If it's off, that means
+ // that there are missing or extra $ characters.
+ Validate(total_len == line_text.size(), options, [&line] {
+ if (line.chunks.empty()) {
+ return TProtoStringType("wrong number of variable delimiters");
+ }
+
+ return y_absl::StrFormat("unclosed variable name: `%s`",
+ y_absl::CHexEscape(line.chunks.back().text));
+ });
+
+ // Trim any empty, non-variable chunks.
+ while (!line.chunks.empty()) {
+ auto& last = line.chunks.back();
+ if (last.is_var || !last.text.empty()) {
+ break;
+ }
+
+ line.chunks.pop_back();
+ }
}
- *range = iter->second;
- return true;
-}
-void Printer::Annotate(const char* begin_varname, const char* end_varname,
- const TProtoStringType& file_path,
- const std::vector<int>& path) {
- if (annotation_collector_ == NULL) {
- // Can't generate signatures with this Printer.
- return;
+ // Discard any trailing newlines (i.e., lines which contain no chunks.)
+ if (format.is_raw_string) {
+ while (!format.lines.empty() && format.lines.back().chunks.empty()) {
+ format.lines.pop_back();
+ }
}
- std::pair<size_t, size_t> begin, end;
- if (!GetSubstitutionRange(begin_varname, &begin) ||
- !GetSubstitutionRange(end_varname, &end)) {
- return;
+
+#if 0 // Use this to aid debugging tokenization.
+ LOG(INFO) << "--- " << format.lines.size() << " lines";
+ for (size_t i = 0; i < format.lines.size(); ++i) {
+ const auto& line = format.lines[i];
+
+ auto log_line = y_absl::StrFormat("[\" \" x %d]", line.indent);
+ for (const auto& chunk : line.chunks) {
+ y_absl::StrAppendFormat(&log_line, " %s\"%s\"", chunk.is_var ? "$" : "",
+ y_absl::CHexEscape(chunk.text));
+ }
+ LOG(INFO) << log_line;
}
- if (begin.first > end.second) {
- GOOGLE_LOG(DFATAL) << " Annotation has negative length from " << begin_varname
- << " to " << end_varname;
- } else {
- annotation_collector_->AddAnnotation(begin.first, end.second, file_path,
- path);
+ LOG(INFO) << "---";
+#endif
+
+ return format;
+}
+
+constexpr y_absl::string_view Printer::kProtocCodegenTrace;
+
+Printer::Printer(ZeroCopyOutputStream* output, Options options)
+ : sink_(output), options_(options) {
+ if (!options_.enable_codegen_trace.has_value()) {
+ // Trace-by-default is threaded through via an env var, rather than a
+ // global, so that child processes can pick it up as well. The flag
+ // --enable_codegen_trace setenv()'s this in protoc's startup code.
+ static const bool kEnableCodegenTrace =
+ ::getenv(kProtocCodegenTrace.data()) != nullptr;
+ options_.enable_codegen_trace = kEnableCodegenTrace;
}
}
-void Printer::Print(const std::map<TProtoStringType, TProtoStringType>& variables,
- const char* text) {
- int size = strlen(text);
- int pos = 0; // The number of bytes we've written so far.
- substitutions_.clear();
- line_start_variables_.clear();
+y_absl::string_view Printer::LookupVar(y_absl::string_view var) {
+ auto result = LookupInFrameStack(var, y_absl::MakeSpan(var_lookups_));
+ Y_ABSL_CHECK(result.has_value()) << "could not find " << var;
- for (int i = 0; i < size; i++) {
- if (text[i] == '\n') {
- // Saw newline. If there is more text, we may need to insert an indent
- // here. So, write what we have so far, including the '\n'.
- WriteRaw(text + pos, i - pos + 1);
- pos = i + 1;
-
- // Setting this true will cause the next WriteRaw() to insert an indent
- // first.
- at_start_of_line_ = true;
- line_start_variables_.clear();
-
- } else if (text[i] == variable_delimiter_) {
- // Saw the start of a variable name.
-
- // Write what we have so far.
- WriteRaw(text + pos, i - pos);
- pos = i + 1;
-
- // Find closing delimiter.
- const char* end = strchr(text + pos, variable_delimiter_);
- if (end == NULL) {
- GOOGLE_LOG(DFATAL) << " Unclosed variable name.";
- end = text + pos;
- }
- int endpos = end - text;
+ auto* view = result->AsString();
+ Y_ABSL_CHECK(view != nullptr)
+ << "could not find " << var << "; found callback instead";
- TProtoStringType varname(text + pos, endpos - pos);
- if (varname.empty()) {
- // Two delimiters in a row reduce to a literal delimiter character.
- WriteRaw(&variable_delimiter_, 1);
- } else {
- // Replace with the variable's value.
- std::map<TProtoStringType, TProtoStringType>::const_iterator iter =
- variables.find(varname);
- if (iter == variables.end()) {
- GOOGLE_LOG(DFATAL) << " Undefined variable: " << varname;
- } else {
- if (at_start_of_line_ && iter->second.empty()) {
- line_start_variables_.push_back(varname);
- }
- WriteRaw(iter->second.data(), iter->second.size());
- std::pair<std::map<TProtoStringType, std::pair<size_t, size_t> >::iterator,
- bool>
- inserted = substitutions_.insert(std::make_pair(
- varname,
- std::make_pair(offset_ - iter->second.size(), offset_)));
- if (!inserted.second) {
- // This variable was used multiple times. Make its span have
- // negative length so we can detect it if it gets used in an
- // annotation.
- inserted.first->second = std::make_pair(1, 0);
- }
- }
- }
+ return *view;
+}
- // Advance past this variable.
- i = endpos;
- pos = endpos + 1;
+bool Printer::Validate(bool cond, Printer::PrintOptions opts,
+ y_absl::FunctionRef<TProtoStringType()> message) {
+ if (!cond) {
+ if (opts.checks_are_debug_only) {
+ Y_ABSL_DLOG(FATAL) << message();
+ } else {
+ Y_ABSL_LOG(FATAL) << message();
}
}
-
- // Write the rest.
- WriteRaw(text + pos, size - pos);
+ return cond;
}
-void Printer::Indent() { indent_ += " "; }
+bool Printer::Validate(bool cond, Printer::PrintOptions opts,
+ y_absl::string_view message) {
+ return Validate(cond, opts, [=] { return TProtoStringType(message); });
+}
+// This function is outlined to isolate the use of
+// Y_ABSL_CHECK into the .cc file.
void Printer::Outdent() {
- if (indent_.empty()) {
- GOOGLE_LOG(DFATAL) << " Outdent() without matching Indent().";
+ PrintOptions opts;
+ opts.checks_are_debug_only = true;
+ if (!Validate(indent_ >= options_.spaces_per_indent, opts,
+ "Outdent() without matching Indent()")) {
return;
}
+ indent_ -= options_.spaces_per_indent;
+}
- indent_.resize(indent_.size() - 2);
+void Printer::Emit(y_absl::Span<const Sub> vars, y_absl::string_view format,
+ SourceLocation loc) {
+ PrintOptions opts;
+ opts.strip_raw_string_indentation = true;
+ opts.loc = loc;
+
+ auto defs = WithDefs(vars, /*allow_callbacks=*/true);
+
+ PrintImpl(format, {}, opts);
}
-void Printer::PrintRaw(const TProtoStringType& data) {
- WriteRaw(data.data(), data.size());
+y_absl::optional<std::pair<size_t, size_t>> Printer::GetSubstitutionRange(
+ y_absl::string_view varname, PrintOptions opts) {
+ auto it = substitutions_.find(varname);
+ if (!Validate(it != substitutions_.end(), opts, [varname] {
+ return y_absl::StrCat("undefined variable in annotation: ", varname);
+ })) {
+ return y_absl::nullopt;
+ }
+
+ std::pair<size_t, size_t> range = it->second;
+ if (!Validate(range.first <= range.second, opts, [range, varname] {
+ return y_absl::StrFormat(
+ "variable used for annotation used multiple times: %s (%d..%d)",
+ varname, range.first, range.second);
+ })) {
+ return y_absl::nullopt;
+ }
+
+ return range;
}
-void Printer::PrintRaw(const char* data) {
- if (failed_) return;
- WriteRaw(data, strlen(data));
+void Printer::Annotate(y_absl::string_view begin_varname,
+ y_absl::string_view end_varname,
+ y_absl::string_view file_path,
+ const std::vector<int>& path) {
+ if (options_.annotation_collector == nullptr) {
+ return;
+ }
+
+ PrintOptions opts;
+ opts.checks_are_debug_only = true;
+ auto begin = GetSubstitutionRange(begin_varname, opts);
+ auto end = GetSubstitutionRange(end_varname, opts);
+ if (!begin.has_value() || !end.has_value()) {
+ return;
+ }
+ if (begin->first > end->second) {
+ Y_ABSL_DLOG(FATAL) << "annotation has negative length from " << begin_varname
+ << " to " << end_varname;
+ return;
+ }
+ options_.annotation_collector->AddAnnotation(begin->first, end->second,
+ TProtoStringType(file_path), path);
}
-void Printer::WriteRaw(const char* data, int size) {
- if (failed_) return;
- if (size == 0) return;
+void Printer::WriteRaw(const char* data, size_t size) {
+ if (failed_ || size == 0) {
+ return;
+ }
+
+ if (at_start_of_line_ && data[0] != '\n') {
+ IndentIfAtStart();
+ if (failed_) {
+ return;
+ }
- if (at_start_of_line_ && (size > 0) && (data[0] != '\n')) {
- // Insert an indent.
- at_start_of_line_ = false;
- CopyToBuffer(indent_.data(), indent_.size());
- if (failed_) return;
// Fix up empty variables (e.g., "{") that should be annotated as
// coming after the indent.
- for (std::vector<TProtoStringType>::iterator i = line_start_variables_.begin();
- i != line_start_variables_.end(); ++i) {
- substitutions_[*i].first += indent_.size();
- substitutions_[*i].second += indent_.size();
+ for (const TProtoStringType& var : line_start_variables_) {
+ auto& pair = substitutions_[var];
+ pair.first += indent_;
+ pair.second += indent_;
}
}
@@ -229,175 +405,376 @@ void Printer::WriteRaw(const char* data, int size) {
// the current line.
line_start_variables_.clear();
- CopyToBuffer(data, size);
+ sink_.Append(data, size);
+ failed_ |= sink_.failed();
}
-bool Printer::Next() {
- do {
- void* void_buffer;
- if (!output_->Next(&void_buffer, &buffer_size_)) {
- failed_ = true;
- return false;
- }
- buffer_ = reinterpret_cast<char*>(void_buffer);
- } while (buffer_size_ == 0);
- return true;
-}
-
-void Printer::CopyToBuffer(const char* data, int size) {
- if (failed_) return;
- if (size == 0) return;
-
- while (size > buffer_size_) {
- // Data exceeds space in the buffer. Copy what we can and request a
- // new buffer.
- if (buffer_size_ > 0) {
- memcpy(buffer_, data, buffer_size_);
- offset_ += buffer_size_;
- data += buffer_size_;
- size -= buffer_size_;
- }
- void* void_buffer;
- failed_ = !output_->Next(&void_buffer, &buffer_size_);
- if (failed_) return;
- buffer_ = reinterpret_cast<char*>(void_buffer);
+void Printer::IndentIfAtStart() {
+ if (!at_start_of_line_) {
+ return;
}
- // Buffer is big enough to receive the data; copy it.
- memcpy(buffer_, data, size);
- buffer_ += size;
- buffer_size_ -= size;
- offset_ += size;
-}
-
-void Printer::IndentIfAtStart() {
- if (at_start_of_line_) {
- CopyToBuffer(indent_.data(), indent_.size());
- at_start_of_line_ = false;
+ for (size_t i = 0; i < indent_; ++i) {
+ sink_.Write(" ");
}
+ at_start_of_line_ = false;
}
-void Printer::FormatInternal(const std::vector<TProtoStringType>& args,
- const std::map<TProtoStringType, TProtoStringType>& vars,
- const char* format) {
- auto save = format;
- int arg_index = 0;
- std::vector<AnnotationCollector::Annotation> annotations;
- while (*format) {
- char c = *format++;
- switch (c) {
- case '$':
- format = WriteVariable(args, vars, format, &arg_index, &annotations);
- continue;
- case '\n':
- at_start_of_line_ = true;
- line_start_variables_.clear();
- break;
- default:
- IndentIfAtStart();
- break;
- }
- push_back(c);
- }
- if (arg_index != static_cast<int>(args.size())) {
- GOOGLE_LOG(FATAL) << " Unused arguments. " << save;
+void Printer::PrintCodegenTrace(y_absl::optional<SourceLocation> loc) {
+ if (!options_.enable_codegen_trace.value_or(false) || !loc.has_value()) {
+ return;
}
- if (!annotations.empty()) {
- GOOGLE_LOG(FATAL) << " Annotation range is not-closed, expect $}$. " << save;
+
+ if (!at_start_of_line_) {
+ at_start_of_line_ = true;
+ line_start_variables_.clear();
+ sink_.Write("\n");
}
+
+ PrintRaw(y_absl::StrFormat("%s @%s:%d\n", options_.comment_start,
+ loc->file_name(), loc->line()));
+ at_start_of_line_ = true;
}
-const char* Printer::WriteVariable(
- const std::vector<TProtoStringType>& args,
- const std::map<TProtoStringType, TProtoStringType>& vars, const char* format,
- int* arg_index, std::vector<AnnotationCollector::Annotation>* annotations) {
- auto start = format;
- auto end = strchr(format, '$');
- if (!end) {
- GOOGLE_LOG(FATAL) << " Unclosed variable name.";
- }
- format = end + 1;
- if (end == start) {
- // "$$" is an escape for just '$'
- IndentIfAtStart();
- push_back('$');
- return format;
+bool Printer::ValidateIndexLookupInBounds(size_t index,
+ size_t current_arg_index,
+ size_t args_len, PrintOptions opts) {
+ if (!Validate(index < args_len, opts, [this, index] {
+ return y_absl::StrFormat("annotation %c{%d%c is out of bounds",
+ options_.variable_delimiter, index + 1,
+ options_.variable_delimiter);
+ })) {
+ return false;
}
- if (*start == '{') {
- GOOGLE_CHECK(std::isdigit(start[1]));
- GOOGLE_CHECK_EQ(end - start, 2);
- int idx = start[1] - '1';
- if (idx < 0 || static_cast<size_t>(idx) >= args.size()) {
- GOOGLE_LOG(FATAL) << "Annotation ${" << idx + 1 << "$ is out of bounds.";
- }
- if (idx > *arg_index) {
- GOOGLE_LOG(FATAL) << "Annotation arg must be in correct order as given. Expected"
- << " ${" << (*arg_index) + 1 << "$ got ${" << idx + 1 << "$.";
- } else if (idx == *arg_index) {
- (*arg_index)++;
- }
- IndentIfAtStart();
- annotations->push_back({{offset_, 0}, args[idx]});
- return format;
- } else if (*start == '}') {
- GOOGLE_CHECK(annotations);
- if (annotations->empty()) {
- GOOGLE_LOG(FATAL) << "Unexpected end of annotation found.";
- }
- auto& a = annotations->back();
- a.first.second = offset_;
- if (annotation_collector_) annotation_collector_->AddAnnotationNew(a);
- annotations->pop_back();
- return format;
+ if (!Validate(
+ index <= current_arg_index, opts, [this, index, current_arg_index] {
+ return y_absl::StrFormat(
+ "annotation arg must be in correct order as given; expected "
+ "%c{%d%c but got %c{%d%c",
+ options_.variable_delimiter, current_arg_index + 1,
+ options_.variable_delimiter, options_.variable_delimiter,
+ index + 1, options_.variable_delimiter);
+ })) {
+ return false;
}
- auto start_var = start;
- while (start_var < end && *start_var == ' ') start_var++;
- if (start_var == end) {
- GOOGLE_LOG(FATAL) << " Empty variable.";
+ return true;
+}
+
+void Printer::PrintImpl(y_absl::string_view format,
+ y_absl::Span<const TProtoStringType> args, PrintOptions opts) {
+ // Inside of this function, we set indentation as we print new lines from
+ // the format string. No matter how we exit this function, we should fix up
+ // the indent to what it was before we entered; a cleanup makes it easy to
+ // avoid this mistake.
+ size_t original_indent = indent_;
+ auto unindent =
+ y_absl::MakeCleanup([this, original_indent] { indent_ = original_indent; });
+
+ y_absl::string_view original = format;
+
+ line_start_variables_.clear();
+
+ if (opts.use_substitution_map) {
+ substitutions_.clear();
}
- auto end_var = end;
- while (start_var < end_var && *(end_var - 1) == ' ') end_var--;
- TProtoStringType var_name{
- start_var, static_cast<TProtoStringType::size_type>(end_var - start_var)};
- TProtoStringType sub;
- if (std::isdigit(var_name[0])) {
- GOOGLE_CHECK_EQ(var_name.size(), 1U); // No need for multi-digits
- int idx = var_name[0] - '1'; // Start counting at 1
- GOOGLE_CHECK_GE(idx, 0);
- if (static_cast<size_t>(idx) >= args.size()) {
- GOOGLE_LOG(FATAL) << "Argument $" << idx + 1 << "$ is out of bounds.";
- }
- if (idx > *arg_index) {
- GOOGLE_LOG(FATAL) << "Arguments must be used in same order as given. Expected $"
- << (*arg_index) + 1 << "$ got $" << idx + 1 << "$.";
- } else if (idx == *arg_index) {
- (*arg_index)++;
- }
- sub = args[idx];
- } else {
- auto it = vars.find(var_name);
- if (it == vars.end()) {
- GOOGLE_LOG(FATAL) << " Unknown variable: " << var_name << ".";
+
+ auto fmt = TokenizeFormat(format, opts);
+ PrintCodegenTrace(opts.loc);
+
+ size_t arg_index = 0;
+ bool skip_next_newline = false;
+ std::vector<AnnotationCollector::Annotation> annot_stack;
+ std::vector<std::pair<y_absl::string_view, size_t>> annot_records;
+ for (size_t line_idx = 0; line_idx < fmt.lines.size(); ++line_idx) {
+ const auto& line = fmt.lines[line_idx];
+
+ // We only print a newline for lines that follow the first; a loop iteration
+ // can also hint that we should not emit another newline through the
+ // `skip_next_newline` variable.
+ //
+ // We also assume that double newlines are undesirable, so we
+ // do not emit a newline if we are at the beginning of a line, *unless* the
+ // previous format line is actually empty. This behavior is specific to
+ // raw strings.
+ if (line_idx > 0) {
+ bool prev_was_empty = fmt.lines[line_idx - 1].chunks.empty();
+ bool should_skip_newline =
+ skip_next_newline ||
+ (fmt.is_raw_string && (at_start_of_line_ && !prev_was_empty));
+ if (!should_skip_newline) {
+ line_start_variables_.clear();
+ sink_.Write("\n");
+ at_start_of_line_ = true;
+ }
}
- sub = it->second;
- }
+ skip_next_newline = false;
- // By returning here in case of empty we also skip possible spaces inside
- // the $...$, i.e. "void$ dllexpor$ f();" -> "void f();" in the empty case.
- if (sub.empty()) return format;
+ indent_ = original_indent + line.indent;
- // We're going to write something non-empty so we need a possible indent.
- IndentIfAtStart();
+ for (size_t chunk_idx = 0; chunk_idx < line.chunks.size(); ++chunk_idx) {
+ auto chunk = line.chunks[chunk_idx];
- // Write the possible spaces in front.
- CopyToBuffer(start, start_var - start);
- // Write a non-empty substituted variable.
- CopyToBuffer(sub.c_str(), sub.size());
- // Finish off with writing possible trailing spaces.
- CopyToBuffer(end_var, end - end_var);
- return format;
-}
+ if (!chunk.is_var) {
+ PrintRaw(chunk.text);
+ continue;
+ }
+
+ if (chunk.text.empty()) {
+ // `$$` is an escape for just `$`.
+ WriteRaw(&options_.variable_delimiter, 1);
+ continue;
+ }
+
+ // If we get this far, we can conclude the chunk is a substitution
+ // variable; we rename the `chunk` variable to make this clear below.
+ y_absl::string_view var = chunk.text;
+ if (opts.use_curly_brace_substitutions &&
+ y_absl::ConsumePrefix(&var, "{")) {
+ if (!Validate(var.size() == 1u, opts,
+ "expected single-digit variable")) {
+ continue;
+ }
+
+ if (!Validate(y_absl::ascii_isdigit(var[0]), opts,
+ "expected digit after {")) {
+ continue;
+ }
+
+ size_t idx = var[0] - '1';
+ if (!ValidateIndexLookupInBounds(idx, arg_index, args.size(), opts)) {
+ continue;
+ }
+
+ if (idx == arg_index) {
+ ++arg_index;
+ }
+
+ IndentIfAtStart();
+ annot_stack.push_back({{sink_.bytes_written(), 0}, args[idx]});
+ continue;
+ }
+
+ if (opts.use_curly_brace_substitutions &&
+ y_absl::ConsumePrefix(&var, "}")) {
+ // The rest of var is actually ignored, and this is apparently
+ // public API now. Oops?
+ if (!Validate(!annot_stack.empty(), opts,
+ "unexpected end of annotation")) {
+ continue;
+ }
+ annot_stack.back().first.second = sink_.bytes_written();
+ if (options_.annotation_collector != nullptr) {
+ options_.annotation_collector->AddAnnotationNew(annot_stack.back());
+ }
+ annot_stack.pop_back();
+ continue;
+ }
+
+ y_absl::string_view prefix, suffix;
+ if (opts.strip_spaces_around_vars) {
+ var = y_absl::StripLeadingAsciiWhitespace(var);
+ prefix = chunk.text.substr(0, chunk.text.size() - var.size());
+ var = y_absl::StripTrailingAsciiWhitespace(var);
+ suffix = chunk.text.substr(prefix.size() + var.size());
+ }
+
+ if (!Validate(!var.empty(), opts, "unexpected empty variable")) {
+ continue;
+ }
+
+ bool is_start = y_absl::ConsumePrefix(&var, "_start$");
+ bool is_end = y_absl::ConsumePrefix(&var, "_end$");
+ if (opts.use_annotation_frames && (is_start || is_end)) {
+ if (is_start) {
+ IndentIfAtStart();
+ annot_records.push_back({var, sink_.bytes_written()});
+
+ // Skip all whitespace immediately after a _start.
+ ++chunk_idx;
+ if (chunk_idx < line.chunks.size()) {
+ y_absl::string_view text = line.chunks[chunk_idx].text;
+ while (y_absl::ConsumePrefix(&text, " ")) {
+ }
+ PrintRaw(text);
+ }
+ } else {
+ // If a line consisted *only* of an _end, this will likely result in
+ // a blank line if we do not zap the newline after it, so we do that
+ // here.
+ if (line.chunks.size() == 1) {
+ skip_next_newline = true;
+ }
+
+ auto record_var = annot_records.back();
+ annot_records.pop_back();
+
+ if (!Validate(record_var.first == var, opts, [record_var, var] {
+ return y_absl::StrFormat(
+ "_start and _end variables must match, but got %s and %s, "
+ "respectively",
+ record_var.first, var);
+ })) {
+ continue;
+ }
+
+ y_absl::optional<AnnotationRecord> record =
+ LookupInFrameStack(var, y_absl::MakeSpan(annotation_lookups_));
+
+ if (!Validate(record.has_value(), opts, [var] {
+ return y_absl::StrCat("undefined annotation variable: \"",
+ y_absl::CHexEscape(var), "\"");
+ })) {
+ continue;
+ }
+
+ if (options_.annotation_collector != nullptr) {
+ options_.annotation_collector->AddAnnotation(
+ record_var.second, sink_.bytes_written(), record->file_path,
+ record->path, record->semantic);
+ }
+ }
+
+ continue;
+ }
+
+ y_absl::optional<ValueView> sub;
+ y_absl::optional<AnnotationRecord> same_name_record;
+ if (opts.allow_digit_substitutions && y_absl::ascii_isdigit(var[0])) {
+ if (!Validate(var.size() == 1u, opts,
+ "expected single-digit variable")) {
+ continue;
+ }
+
+ size_t idx = var[0] - '1';
+ if (!ValidateIndexLookupInBounds(idx, arg_index, args.size(), opts)) {
+ continue;
+ }
+ if (idx == arg_index) {
+ ++arg_index;
+ }
+ sub = args[idx];
+ } else {
+ sub = LookupInFrameStack(var, y_absl::MakeSpan(var_lookups_));
+
+ if (opts.use_annotation_frames) {
+ same_name_record =
+ LookupInFrameStack(var, y_absl::MakeSpan(annotation_lookups_));
+ }
+ }
+
+ // By returning here in case of empty we also skip possible spaces inside
+ // the $...$, i.e. "void$ dllexpor$ f();" -> "void f();" in the empty
+ // case.
+ if (!Validate(sub.has_value(), opts, [var] {
+ return y_absl::StrCat("undefined variable: \"", y_absl::CHexEscape(var),
+ "\"");
+ })) {
+ continue;
+ }
+
+ size_t range_start = sink_.bytes_written();
+ size_t range_end = sink_.bytes_written();
+
+ if (const y_absl::string_view* str = sub->AsString()) {
+ if (at_start_of_line_ && str->empty()) {
+ line_start_variables_.emplace_back(var);
+ }
+
+ if (!str->empty()) {
+ // If `sub` is empty, we do not print the spaces around it.
+ PrintRaw(prefix);
+ PrintRaw(*str);
+ range_end = sink_.bytes_written();
+ range_start = range_end - str->size();
+ PrintRaw(suffix);
+ }
+ } else {
+ const ValueView::Callback* fnc = sub->AsCallback();
+ Y_ABSL_CHECK(fnc != nullptr);
+
+ Validate(
+ prefix.empty() && suffix.empty(), opts,
+ "substitution that resolves to callback cannot contain whitespace");
+
+ range_start = sink_.bytes_written();
+ Y_ABSL_CHECK((*fnc)())
+ << "recursive call encountered while evaluating \"" << var << "\"";
+ range_end = sink_.bytes_written();
+ }
+
+ // If we just evaluated a value which specifies end-of-line consume-after
+ // characters, and we're at the start of a line, that means we finished
+ // with a newline.
+ //
+ // We trim a single end-of-line `consume_after` character in this case.
+ //
+ // This helps callback formatting "work as expected" with respect to forms
+ // like
+ //
+ // class Foo {
+ // $methods$;
+ // };
+ //
+ // Without this post-processing, it would turn into
+ //
+ // class Foo {
+ // void Bar() {};
+ // };
+ //
+ // in many cases. Without the `;`, clang-format may format the template
+ // incorrectly.
+ auto next_idx = chunk_idx + 1;
+ if (!sub->consume_after.empty() && next_idx < line.chunks.size() &&
+ !line.chunks[next_idx].is_var) {
+ chunk_idx = next_idx;
+
+ y_absl::string_view text = line.chunks[chunk_idx].text;
+ for (char c : sub->consume_after) {
+ if (y_absl::ConsumePrefix(&text, y_absl::string_view(&c, 1))) {
+ break;
+ }
+ }
+
+ PrintRaw(text);
+ }
+
+ if (same_name_record.has_value() &&
+ options_.annotation_collector != nullptr) {
+ options_.annotation_collector->AddAnnotation(
+ range_start, range_end, same_name_record->file_path,
+ same_name_record->path, same_name_record->semantic);
+ }
+
+ if (opts.use_substitution_map) {
+ auto insertion =
+ substitutions_.emplace(var, std::make_pair(range_start, range_end));
+
+ if (!insertion.second) {
+ // This variable was used multiple times.
+ // Make its span have negative length so
+ // we can detect it if it gets used in an
+ // annotation.
+ insertion.first->second = {1, 0};
+ }
+ }
+ }
+ }
+
+ Validate(arg_index == args.size(), opts,
+ [original] { return y_absl::StrCat("unused args: ", original); });
+ Validate(annot_stack.empty(), opts, [this, original] {
+ return y_absl::StrFormat(
+ "annotation range was not closed; expected %c}%c: %s",
+ options_.variable_delimiter, options_.variable_delimiter, original);
+ });
+
+ // For multiline raw strings, we always make sure to end on a newline.
+ if (fmt.is_raw_string && !at_start_of_line_) {
+ PrintRaw("\n");
+ at_start_of_line_ = true;
+ }
+}
} // namespace io
} // namespace protobuf
} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/printer.h b/contrib/libs/protobuf/src/google/protobuf/io/printer.h
index f1137fc689f..8a2055ede00 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/printer.h
+++ b/contrib/libs/protobuf/src/google/protobuf/io/printer.h
@@ -37,27 +37,51 @@
#ifndef GOOGLE_PROTOBUF_IO_PRINTER_H__
#define GOOGLE_PROTOBUF_IO_PRINTER_H__
-
-#include <map>
+#include <cstddef>
+#include <functional>
+#include <initializer_list>
#include <string>
+#include <type_traits>
+#include <utility>
#include <vector>
-#include <google/protobuf/stubs/common.h>
+#include "y_absl/cleanup/cleanup.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/functional/function_ref.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/meta/type_traits.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/types/optional.h"
+#include "y_absl/types/variant.h"
+#include "google/protobuf/io/zero_copy_sink.h"
+
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
namespace io {
-class ZeroCopyOutputStream; // zero_copy_stream.h
-
// Records annotations about a Printer's output.
class PROTOBUF_EXPORT AnnotationCollector {
public:
- // Annotation is a offset range and a payload pair.
- typedef std::pair<std::pair<size_t, size_t>, TProtoStringType> Annotation;
+ // Annotation is a offset range and a payload pair. This payload's layout is
+ // specific to derived types of AnnotationCollector.
+ using Annotation = std::pair<std::pair<size_t, size_t>, TProtoStringType>;
+
+ // The semantic meaning of an annotation. This enum mirrors
+ // google.protobuf.GeneratedCodeInfo.Annotation.Semantic, and the enumerator values
+ // should match it.
+ enum Semantic {
+ kNone = 0,
+ kSet = 1,
+ kAlias = 2,
+ };
+
+ virtual ~AnnotationCollector() = default;
// Records that the bytes in file_path beginning with begin_offset and ending
// before end_offset are associated with the SourceCodeInfo-style path.
@@ -65,38 +89,75 @@ class PROTOBUF_EXPORT AnnotationCollector {
const TProtoStringType& file_path,
const std::vector<int>& path) = 0;
+ virtual void AddAnnotation(size_t begin_offset, size_t end_offset,
+ const TProtoStringType& file_path,
+ const std::vector<int>& path,
+ y_absl::optional<Semantic> semantic) {
+ AddAnnotation(begin_offset, end_offset, file_path, path);
+ }
+
// TODO(gerbens) I don't see why we need virtuals here. Just a vector of
// range, payload pairs stored in a context should suffice.
- virtual void AddAnnotationNew(Annotation& /* a */) {}
-
- virtual ~AnnotationCollector() {}
+ virtual void AddAnnotationNew(Annotation&) {}
};
-// Records annotations about a Printer's output to the given protocol buffer,
-// assuming that the buffer has an ::Annotation message exposing path,
-// source_file, begin and end fields.
+// Records annotations about a Printer's output to a Protobuf message,
+// assuming that it has a repeated submessage field named `annotation` with
+// fields matching
+//
+// message ??? {
+// repeated int32 path = 1;
+// optional string source_file = 2;
+// optional int32 begin = 3;
+// optional int32 end = 4;
+// optional int32 semantic = 5;
+// }
template <typename AnnotationProto>
class AnnotationProtoCollector : public AnnotationCollector {
+ private:
+ // Some users of this type use it with a proto that does not have a
+ // "semantic" field. Therefore, we need to detect it with SFINAE.
+
+ // go/ranked-overloads
+ struct Rank0 {};
+ struct Rank1 : Rank0 {};
+
+ template <typename Proto>
+ static auto SetSemantic(Proto* p, int semantic, Rank1)
+ -> decltype(p->set_semantic(
+ static_cast<typename Proto::Semantic>(semantic))) {
+ return p->set_semantic(static_cast<typename Proto::Semantic>(semantic));
+ }
+
+ template <typename Proto>
+ static void SetSemantic(Proto*, int, Rank0) {}
+
public:
- // annotation_proto is the protocol buffer to which new Annotations should be
- // added. It is not owned by the AnnotationProtoCollector.
explicit AnnotationProtoCollector(AnnotationProto* annotation_proto)
: annotation_proto_(annotation_proto) {}
- // Override for AnnotationCollector::AddAnnotation.
void AddAnnotation(size_t begin_offset, size_t end_offset,
const TProtoStringType& file_path,
const std::vector<int>& path) override {
- typename AnnotationProto::Annotation* annotation =
- annotation_proto_->add_annotation();
+ AddAnnotation(begin_offset, end_offset, file_path, path, y_absl::nullopt);
+ }
+
+ void AddAnnotation(size_t begin_offset, size_t end_offset,
+ const TProtoStringType& file_path, const std::vector<int>& path,
+ y_absl::optional<Semantic> semantic) override {
+ auto* annotation = annotation_proto_->add_annotation();
for (int i = 0; i < path.size(); ++i) {
annotation->add_path(path[i]);
}
annotation->set_source_file(file_path);
annotation->set_begin(begin_offset);
annotation->set_end(end_offset);
+
+ if (semantic.has_value()) {
+ SetSemantic(annotation, *semantic, Rank1{});
+ }
}
- // Override for AnnotationCollector::AddAnnotation.
+
void AddAnnotationNew(Annotation& a) override {
auto* annotation = annotation_proto_->add_annotation();
annotation->ParseFromString(a.second);
@@ -105,10 +166,233 @@ class AnnotationProtoCollector : public AnnotationCollector {
}
private:
- // The protocol buffer to which new annotations should be added.
- AnnotationProto* const annotation_proto_;
+ AnnotationProto* annotation_proto_;
};
+// A source code printer for assisting in code generation.
+//
+// This type implements a simple templating language for substiting variables
+// into static, user-provided strings, and also tracks indentation
+// automatically.
+//
+// The main entry-point for this type is the Emit function, which can be used
+// thus:
+//
+// Printer p(output);
+// p.Emit({{"class", my_class_name}}, R"cc(
+// class $class$ {
+// public:
+// $class$(int x) : x_(x) {}
+// private:
+// int x_;
+// };
+// )cc");
+//
+// Substitutions are of the form $var$, which is looked up in the map passed in
+// as the first argument. The variable delimiter character, $, can be chosen to
+// be something convenient for the target language. For example, in PHP, which
+// makes heavy use of $, it can be made into something like # instead.
+//
+// A literal $ can be emitted by writing $$.
+//
+// Substitutions may contain spaces around the name of the variable, which will
+// be ignored for the purposes of looking up the variable to substitute in, but
+// which will be reproduced in the output:
+//
+// p.Emit({{"foo", "bar"}}, "$ foo $");
+//
+// emits the string " bar ". If the substituted-in variable is the empty string,
+// then the surrounding spaces are *not* printed:
+//
+// p.Emit({{"xzy", xyz}}, "$xyz $Thing");
+//
+// If xyz is "Foo", this will become "Foo Thing", but if it is "", this becomes
+// "Thing", rather than " Thing". This helps minimize awkward whitespace in the
+// output.
+//
+// The value may be any type that can be stringified with `y_absl::StrCat`:
+//
+// p.Emit({{"num", 5}}, "x = $num$;");
+//
+// If a variable is referenced in the format string that is missing, the program
+// will crash. Callers must statically know that every variable reference is
+// valid, and MUST NOT pass user-provided strings directly into Emit().
+//
+// Substitutions can be configured to "chomp" a single character after them, to
+// help make indentation work out. This can be configured by passing a
+// two-argument io::Printer::Value into Emit's substitution map:
+//
+// p.Emit({{"var", io::Printer::Value{var_decl, ";"}}}, R"cc(
+// class $class$ {
+// public:
+// $var$;
+// };
+// )cc");
+//
+// This will delete the ; after $var$, regardless of whether it was an empty
+// declaration or not. It will also intelligently attempt to clean up
+// empty lines that follow, if it was on an empty line; this promotes cleaner
+// formatting of the output.
+//
+// Any number of different characters can be potentially skipped, but only one
+// will actually be skipped. For example, callback substitutions (see below) use
+// ";," by default as their "chomping set".
+//
+// # Callback Substitution
+//
+// Instead of passing a string into Emit(), it is possible to pass in a callback
+// as a variable mapping. This will take indentation into account, which allows
+// factoring out parts of a formatting string while ensuring braces are
+// balanced:
+//
+// p.Emit(
+// {{"methods", [&] {
+// p.Emit(R"cc(
+// int Bar() {
+// return 42;
+// }
+// )cc");
+// }}},
+// R"cc(
+// class Foo {
+// public:
+// $methods$;
+// };
+// )cc"
+// );
+//
+// This emits
+//
+// class Foo {
+// public:
+// int Bar() {
+// return 42;
+// }
+// };
+//
+// # Comments
+//
+// It may be desirable to place comments in a raw string that are stripped out
+// before printing. The prefix for Printer-ignored comments can be configured
+// in Options. By default, this is `//~`.
+//
+// p.Emit(R"cc(
+// // Will be printed in the output.
+// //~ Won't be.
+// )cc");
+//
+// # Lookup Frames
+//
+// If many calls to Emit() use the same set of variables, they can be stored
+// in a *variable lookup frame*, like so:
+//
+// auto vars = p.WithVars({{"class_name", my_class_name}});
+// p.Emit(R"cc(
+// class $class_name$ {
+// public:
+// $class_name$(int x);
+// // Etc.
+// };
+// )cc");
+//
+// WithVars() returns an RAII object that will "pop" the lookup frame on scope
+// exit, ensuring that the variables remain local. There are a few different
+// overloads of WithVars(); it accepts a map type, like y_absl::flat_hash_map,
+// either by-value (which will cause the Printer to store a copy), or by
+// pointer (which will cause the Printer to store a pointer, potentially
+// avoiding a copy.)
+//
+// p.Emit(vars, "..."); is effectively syntax sugar for
+//
+// { auto v = p.WithVars(vars); p.Emit("..."); }
+//
+// NOTE: callbacks are *not* allowed with WithVars; callbacks should be local
+// to a specific Emit() call.
+//
+// # Annotations
+//
+// If Printer is given an AnnotationCollector, it will use it to record which
+// spans of generated code correspond to user-indicated descriptors. There are
+// a few different ways of indicating when to emit annotations.
+//
+// The WithAnnotations() function is like WithVars(), but accepts maps with
+// string keys and descriptor values. It adds an annotation variable frame and
+// returns an RAII object that pops the frame.
+//
+// There are two different ways to annotate code. In the first, when
+// substituting a variable, if there is an annotation with the same name, then
+// the resulting expanded value's span will be annotated with that annotation.
+// For example:
+//
+// auto v = p.WithVars({{"class_name", my_class_name}});
+// auto a = p.WithAnnotations({{"class_name", message_descriptor}});
+// p.Emit(R"cc(
+// class $class_name$ {
+// public:
+// $class_name$(int x);
+// // Etc.
+// };
+// )cc");
+//
+// The span corresponding to whatever $class_name$ expands to will be annotated
+// as having come from message_descriptor.
+//
+// For convenience, this can be done with a single WithVars(), using the special
+// three-argument form:
+//
+// auto v = p.WithVars({{"class_name", my_class_name, message_descriptor}});
+// p.Emit(R"cc(
+// class $class_name$ {
+// public:
+// $class_name$(int x);
+// // Etc.
+// };
+// )cc");
+//
+//
+// Alternatively, a range may be given explicitly:
+//
+// auto a = p.WithAnnotations({{"my_desc", message_descriptor}});
+// p.Emit(R"cc(
+// $_start$my_desc$
+// class Foo {
+// // Etc.
+// };
+// $_end$my_desc$
+// )cc");
+//
+// The special $_start$ and $_end$ variables indicate the start and end of an
+// annotated span, which is annotated with the variable that follows. This
+// form can produce somewhat unreadable format strings and is not recommended.
+//
+// Note that whitespace after a $_start$ and before an $_end$ is not printed.
+//
+// # Indentation
+//
+// Printer tracks an indentation amount to add to each new line, independent
+// from indentation in an Emit() call's literal. The amount of indentation to
+// add is controlled by the WithIndent() function:
+//
+// p.Emit("class $class_name$ {");
+// {
+// auto indent = p.WithIndent();
+// p.Emit(R"cc(
+// public:
+// $class_name$(int x);
+// )cc");
+// }
+// p.Emit("};");
+//
+// This will automatically add one level of indentation to all code in scope of
+// `indent`, which is an RAII object much like the return value of `WithVars()`.
+//
+// # Old API
+// TODO(b/242326974): Delete this documentation.
+//
+// Printer supports an older-style API that is in the process of being
+// re-written. The old documentation is reproduced here until all use-cases are
+// handled.
+//
// This simple utility class assists in code generation. It basically
// allows the caller to define a set of variables and then output some
// text with variable substitutions. Example usage:
@@ -180,26 +464,172 @@ class AnnotationProtoCollector : public AnnotationCollector {
//
// This code associates the span covering "call(bar,bar)" in the output with the
// call_ descriptor.
-
class PROTOBUF_EXPORT Printer {
+ private:
+ // This type exists to work around an absl type that has not yet been
+ // released.
+ struct SourceLocation {
+ static SourceLocation current() { return {}; }
+ y_absl::string_view file_name() { return "<unknown>"; }
+ int line() { return 0; }
+ };
+
+ struct AnnotationRecord;
+
public:
- // Create a printer that writes text to the given output stream. Use the
- // given character as the delimiter for variables.
- Printer(ZeroCopyOutputStream* output, char variable_delimiter);
-
- // Create a printer that writes text to the given output stream. Use the
- // given character as the delimiter for variables. If annotation_collector
- // is not null, Printer will provide it with annotations about code written
- // to the stream. annotation_collector is not owned by Printer.
+ static constexpr char kDefaultVariableDelimiter = '$';
+ static constexpr y_absl::string_view kProtocCodegenTrace =
+ "PROTOC_CODEGEN_TRACE";
+
+ // Sink type for constructing substitutions to pass to WithVars() and Emit().
+ class Sub;
+
+ // Options for controlling how the output of a Printer is formatted.
+ struct Options {
+ Options() = default;
+ Options(const Options&) = default;
+ Options(Options&&) = default;
+ Options(char variable_delimiter, AnnotationCollector* annotation_collector)
+ : variable_delimiter(variable_delimiter),
+ annotation_collector(annotation_collector) {}
+
+ // The delimiter for variable substitutions, e.g. $foo$.
+ char variable_delimiter = kDefaultVariableDelimiter;
+ // An optional listener the Printer calls whenever it emits a source
+ // annotation; may be null.
+ AnnotationCollector* annotation_collector = nullptr;
+ // The "comment start" token for the language being generated. This is used
+ // to allow the Printer to emit debugging annotations in the source code
+ // output.
+ y_absl::string_view comment_start = "//";
+ // The token for beginning comments that are discarded by Printer's internal
+ // formatter.
+ y_absl::string_view ignored_comment_start = "//~";
+ // The number of spaces that a single level of indentation adds by default;
+ // this is the amount that WithIndent() increases indentation by.
+ size_t spaces_per_indent = 2;
+ // Whether to emit a "codegen trace" for calls to Emit(). If true, each call
+ // to Emit() will print a comment indicating where in the source of the
+ // compiler the Emit() call occurred.
+ //
+ // If disengaged, defaults to whether or not the environment variable
+ // `PROTOC_CODEGEN_TRACE` is set.
+ y_absl::optional<bool> enable_codegen_trace = y_absl::nullopt;
+ };
+
+ // Constructs a new Printer with the default options to output to
+ // `output`.
+ explicit Printer(ZeroCopyOutputStream* output) : Printer(output, Options{}) {}
+
+ // Constructs a new printer with the given set of options to output to
+ // `output`.
+ Printer(ZeroCopyOutputStream* output, Options options);
+
+ // Old-style constructor. Avoid in preference to the two constructors above.
+ //
+ // Will eventually be marked as deprecated.
Printer(ZeroCopyOutputStream* output, char variable_delimiter,
- AnnotationCollector* annotation_collector);
+ AnnotationCollector* annotation_collector = nullptr)
+ : Printer(output, Options{variable_delimiter, annotation_collector}) {}
+
+ Printer(const Printer&) = delete;
+ Printer& operator=(const Printer&) = delete;
+
+ // Pushes a new variable lookup frame that stores `vars` by reference.
+ //
+ // Returns an RAII object that pops the lookup frame.
+ template <typename Map>
+ auto WithVars(const Map* vars);
+
+ // Pushes a new variable lookup frame that stores `vars` by value.
+ //
+ // Returns an RAII object that pops the lookup frame.
+ template <typename Map = y_absl::flat_hash_map<TProtoStringType, TProtoStringType>,
+ typename = std::enable_if_t<!std::is_pointer<Map>::value>,
+ // Prefer the more specific span impl if this could be turned into
+ // a span.
+ typename = std::enable_if_t<
+ !std::is_convertible<Map, y_absl::Span<const Sub>>::value>>
+ auto WithVars(Map&& vars);
+
+ // Pushes a new variable lookup frame that stores `vars` by value.
+ //
+ // Returns an RAII object that pops the lookup frame.
+ auto WithVars(y_absl::Span<const Sub> vars);
+
+ // Looks up a variable set with WithVars().
+ //
+ // Will crash if:
+ // - `var` is not present in the lookup frame table.
+ // - `var` is a callback, rather than a string.
+ y_absl::string_view LookupVar(y_absl::string_view var);
+
+ // Pushes a new annotation lookup frame that stores `vars` by reference.
+ //
+ // Returns an RAII object that pops the lookup frame.
+ template <typename Map>
+ auto WithAnnotations(const Map* vars);
+
+ // Pushes a new variable lookup frame that stores `vars` by value.
+ //
+ // When writing `WithAnnotations({...})`, this is the overload that will be
+ // called, and it will synthesize an `y_absl::flat_hash_map`.
+ //
+ // Returns an RAII object that pops the lookup frame.
+ template <typename Map = y_absl::flat_hash_map<TProtoStringType, AnnotationRecord>>
+ auto WithAnnotations(Map&& vars);
+
+ // Increases the indentation by `indent` spaces; when nullopt, increments
+ // indentation by the configured default spaces_per_indent.
+ //
+ // Returns an RAII object that removes this indentation.
+ auto WithIndent(y_absl::optional<size_t> indent = y_absl::nullopt) {
+ size_t delta = indent.value_or(options_.spaces_per_indent);
+ indent_ += delta;
+ return y_absl::MakeCleanup([this, delta] { indent_ -= delta; });
+ }
+
+ // Emits formatted source code to the underlying output. See the class
+ // documentation for more details.
+ //
+ // `format` MUST be a string constant.
+ void Emit(y_absl::string_view format,
+ SourceLocation loc = SourceLocation::current());
+
+ // Emits formatted source code to the underlying output, injecting
+ // additional variables as a lookup frame for just this call. See the class
+ // documentation for more details.
+ //
+ // `format` MUST be a string constant.
+ void Emit(y_absl::Span<const Sub> vars, y_absl::string_view format,
+ SourceLocation loc = SourceLocation::current());
+
+ // Write a string directly to the underlying output, performing no formatting
+ // of any sort.
+ void PrintRaw(y_absl::string_view data) { WriteRaw(data.data(), data.size()); }
+
+ // Write a string directly to the underlying output, performing no formatting
+ // of any sort.
+ void WriteRaw(const char* data, size_t size);
+
+ // True if any write to the underlying stream failed. (We don't just
+ // crash in this case because this is an I/O failure, not a programming
+ // error.)
+ bool failed() const { return failed_; }
+
+ // -- Old-style API below; to be deprecated and removed. --
+ // TODO(b/242326974): Deprecate these APIs.
- ~Printer();
+ template <typename Map = y_absl::flat_hash_map<TProtoStringType, TProtoStringType>>
+ void Print(const Map& vars, y_absl::string_view text);
+
+ template <typename... Args>
+ void Print(y_absl::string_view text, const Args&... args);
// Link a substitution variable emitted by the last call to Print to the
// object described by descriptor.
template <typename SomeDescriptor>
- void Annotate(const char* varname, const SomeDescriptor* descriptor) {
+ void Annotate(y_absl::string_view varname, const SomeDescriptor* descriptor) {
Annotate(varname, varname, descriptor);
}
@@ -207,22 +637,13 @@ class PROTOBUF_EXPORT Printer {
// the last call to Print to the object described by descriptor. The range
// begins at begin_varname's value and ends after the last character of the
// value substituted for end_varname.
- template <typename SomeDescriptor>
- void Annotate(const char* begin_varname, const char* end_varname,
- const SomeDescriptor* descriptor) {
- if (annotation_collector_ == NULL) {
- // Annotations aren't turned on for this Printer, so don't pay the cost
- // of building the location path.
- return;
- }
- std::vector<int> path;
- descriptor->GetLocationPath(&path);
- Annotate(begin_varname, end_varname, descriptor->file()->name(), path);
- }
+ template <typename Desc>
+ void Annotate(y_absl::string_view begin_varname, y_absl::string_view end_varname,
+ const Desc* descriptor);
// Link a substitution variable emitted by the last call to Print to the file
// with path file_name.
- void Annotate(const char* varname, const TProtoStringType& file_name) {
+ void Annotate(y_absl::string_view varname, y_absl::string_view file_name) {
Annotate(varname, varname, file_name);
}
@@ -230,158 +651,505 @@ class PROTOBUF_EXPORT Printer {
// the last call to Print to the file with path file_name. The range begins
// at begin_varname's value and ends after the last character of the value
// substituted for end_varname.
- void Annotate(const char* begin_varname, const char* end_varname,
- const TProtoStringType& file_name) {
- if (annotation_collector_ == NULL) {
- // Annotations aren't turned on for this Printer.
+ void Annotate(y_absl::string_view begin_varname, y_absl::string_view end_varname,
+ y_absl::string_view file_name) {
+ if (options_.annotation_collector == nullptr) {
return;
}
- std::vector<int> empty_path;
- Annotate(begin_varname, end_varname, file_name, empty_path);
- }
-
- // Print some text after applying variable substitutions. If a particular
- // variable in the text is not defined, this will crash. Variables to be
- // substituted are identified by their names surrounded by delimiter
- // characters (as given to the constructor). The variable bindings are
- // defined by the given map.
- void Print(const std::map<TProtoStringType, TProtoStringType>& variables,
- const char* text);
- // Like the first Print(), except the substitutions are given as parameters.
- template <typename... Args>
- void Print(const char* text, const Args&... args) {
- std::map<TProtoStringType, TProtoStringType> vars;
- PrintInternal(&vars, text, args...);
+ Annotate(begin_varname, end_varname, file_name, {});
}
- // Indent text by two spaces. After calling Indent(), two spaces will be
- // inserted at the beginning of each line of text. Indent() may be called
- // multiple times to produce deeper indents.
- void Indent();
+ // Indent text by `options.spaces_per_indent`; undone by Outdent().
+ void Indent() { indent_ += options_.spaces_per_indent; }
- // Reduces the current indent level by two spaces, or crashes if the indent
- // level is zero.
+ // Undoes a call to Indent().
void Outdent();
- // Write a string to the output buffer.
- // This method does not look for newlines to add indentation.
- void PrintRaw(const TProtoStringType& data);
+ // FormatInternal is a helper function not meant to use directly, use
+ // compiler::cpp::Formatter instead.
+ template <typename Map = y_absl::flat_hash_map<TProtoStringType, TProtoStringType>>
+ void FormatInternal(y_absl::Span<const TProtoStringType> args, const Map& vars,
+ y_absl::string_view format);
+
+ private:
+ struct PrintOptions;
+ struct Format;
- // Write a zero-delimited string to output buffer.
- // This method does not look for newlines to add indentation.
- void PrintRaw(const char* data);
+ // Helper type for wrapping a variable substitution expansion result.
+ template <bool owned>
+ struct ValueImpl;
- // Write some bytes to the output buffer.
- // This method does not look for newlines to add indentation.
- void WriteRaw(const char* data, int size);
+ using ValueView = ValueImpl</*owned=*/false>;
+ using Value = ValueImpl</*owned=*/true>;
- // FormatInternal is a helper function not meant to use directly, use
- // compiler::cpp::Formatter instead. This function is meant to support
- // formatting text using named variables (eq. "$foo$) from a lookup map (vars)
- // and variables directly supplied by arguments (eq "$1$" meaning first
- // argument which is the zero index element of args).
- void FormatInternal(const std::vector<TProtoStringType>& args,
- const std::map<TProtoStringType, TProtoStringType>& vars,
- const char* format);
+ // Provide a helper to use heterogeneous lookup when it's available.
+ template <typename...>
+ using Void = void;
- // True if any write to the underlying stream failed. (We don't just
- // crash in this case because this is an I/O failure, not a programming
- // error.)
- bool failed() const { return failed_; }
+ template <typename Map, typename = void>
+ struct HasHeteroLookup : std::false_type {};
+ template <typename Map>
+ struct HasHeteroLookup<Map, Void<decltype(std::declval<Map>().find(
+ std::declval<y_absl::string_view>()))>>
+ : std::true_type {};
- private:
- // Link the output range defined by the substitution variables as emitted by
- // the last call to Print to the object found at the SourceCodeInfo-style path
- // in a file with path file_path. The range begins at the start of
- // begin_varname's value and ends after the last character of the value
- // substituted for end_varname. Note that begin_varname and end_varname
- // may refer to the same variable.
- void Annotate(const char* begin_varname, const char* end_varname,
- const TProtoStringType& file_path, const std::vector<int>& path);
-
- // Base case
- void PrintInternal(std::map<TProtoStringType, TProtoStringType>* vars,
- const char* text) {
- Print(*vars, text);
+ template <typename Map,
+ typename = std::enable_if_t<HasHeteroLookup<Map>::value>>
+ static y_absl::string_view ToStringKey(y_absl::string_view x) {
+ return x;
}
- template <typename... Args>
- void PrintInternal(std::map<TProtoStringType, TProtoStringType>* vars, const char* text,
- const char* key, const TProtoStringType& value,
- const Args&... args) {
- (*vars)[key] = value;
- PrintInternal(vars, text, args...);
+ template <typename Map,
+ typename = std::enable_if_t<!HasHeteroLookup<Map>::value>>
+ static TProtoStringType ToStringKey(y_absl::string_view x) {
+ return TProtoStringType(x);
}
- // Copy size worth of bytes from data to buffer_.
- void CopyToBuffer(const char* data, int size);
+ Format TokenizeFormat(y_absl::string_view format_string,
+ const PrintOptions& options);
- void push_back(char c) {
- if (failed_) return;
- if (buffer_size_ == 0) {
- if (!Next()) return;
- }
- *buffer_++ = c;
- buffer_size_--;
- offset_++;
- }
+ // Emit an annotation for the range defined by the given substitution
+ // variables, as set by the most recent call to PrintImpl() that set
+ // `use_substitution_map` to true.
+ //
+ // The range begins at the start of `begin_varname`'s value and ends after the
+ // last byte of `end_varname`'s value.
+ //
+ // `begin_varname` and `end_varname may` refer to the same variable.
+ void Annotate(y_absl::string_view begin_varname, y_absl::string_view end_varname,
+ y_absl::string_view file_path, const std::vector<int>& path);
+
+ // The core printing implementation. There are three public entry points,
+ // which enable different slices of functionality that are controlled by the
+ // `opts` argument.
+ void PrintImpl(y_absl::string_view format, y_absl::Span<const TProtoStringType> args,
+ PrintOptions opts);
+
+ // This is a private function only so that it can see PrintOptions.
+ static bool Validate(bool cond, PrintOptions opts,
+ y_absl::FunctionRef<TProtoStringType()> message);
+ static bool Validate(bool cond, PrintOptions opts, y_absl::string_view message);
- bool Next();
+ // Performs calls to `Validate()` to check that `index < current_arg_index`
+ // and `index < args_len`, producing appropriate log lines if the checks fail,
+ // and crashing if necessary.
+ bool ValidateIndexLookupInBounds(size_t index, size_t current_arg_index,
+ size_t args_len, PrintOptions opts);
- inline void IndentIfAtStart();
- const char* WriteVariable(
- const std::vector<TProtoStringType>& args,
- const std::map<TProtoStringType, TProtoStringType>& vars, const char* format,
- int* arg_index,
- std::vector<AnnotationCollector::Annotation>* annotations);
+ // Prints indentation if `at_start_of_line_` is true.
+ void IndentIfAtStart();
- const char variable_delimiter_;
+ // Prints a codegen trace, for the given location in the compiler's source.
+ void PrintCodegenTrace(y_absl::optional<SourceLocation> loc);
- ZeroCopyOutputStream* const output_;
- char* buffer_;
- int buffer_size_;
- // The current position, in bytes, in the output stream. This is equivalent
- // to the total number of bytes that have been written so far. This value is
- // used to calculate annotation ranges in the substitutions_ map below.
- size_t offset_;
+ // The core implementation for "fully-elaborated" variable definitions.
+ auto WithDefs(y_absl::Span<const Sub> vars, bool allow_callbacks);
- TProtoStringType indent_;
- bool at_start_of_line_;
- bool failed_;
+ // Returns the start and end of the value that was substituted in place of
+ // the variable `varname` in the last call to PrintImpl() (with
+ // `use_substitution_map` set), if such a variable was substituted exactly
+ // once.
+ y_absl::optional<std::pair<size_t, size_t>> GetSubstitutionRange(
+ y_absl::string_view varname, PrintOptions opts);
+
+ google::protobuf::io::zc_sink_internal::ZeroCopyStreamByteSink sink_;
+ Options options_;
+ size_t indent_ = 0;
+ bool at_start_of_line_ = true;
+ bool failed_ = false;
+
+ std::vector<std::function<y_absl::optional<ValueView>(y_absl::string_view)>>
+ var_lookups_;
+
+ std::vector<
+ std::function<y_absl::optional<AnnotationRecord>(y_absl::string_view)>>
+ annotation_lookups_;
// A map from variable name to [start, end) offsets in the output buffer.
- // These refer to the offsets used for a variable after the last call to
- // Print. If a variable was used more than once, the entry used in
- // this map is set to a negative-length span. For singly-used variables, the
- // start offset is the beginning of the substitution; the end offset is the
- // last byte of the substitution plus one (such that (end - start) is the
- // length of the substituted string).
- std::map<TProtoStringType, std::pair<size_t, size_t> > substitutions_;
-
- // Keeps track of the keys in substitutions_ that need to be updated when
+ //
+ // This stores the data looked up by GetSubstitutionRange().
+ y_absl::flat_hash_map<TProtoStringType, std::pair<size_t, size_t>> substitutions_;
+ // Keeps track of the keys in `substitutions_` that need to be updated when
// indents are inserted. These are keys that refer to the beginning of the
// current line.
std::vector<TProtoStringType> line_start_variables_;
+};
+
+// Options for PrintImpl().
+struct Printer::PrintOptions {
+ // The callsite of the public entry-point. Only Emit() sets this.
+ y_absl::optional<SourceLocation> loc;
+ // If set, Validate() calls will not crash the program.
+ bool checks_are_debug_only = false;
+ // If set, the `substitutions_` map will be populated as variables are
+ // substituted.
+ bool use_substitution_map = false;
+ // If set, the ${1$ and $}$ forms will be substituted. These are used for
+ // a slightly janky annotation-insertion mechanism in FormatInternal, that
+ // requires that passed-in substitution variables be serialized protos.
+ bool use_curly_brace_substitutions = false;
+ // If set, the $n$ forms will be substituted, pulling from the `args`
+ // argument to PrintImpl().
+ bool allow_digit_substitutions = true;
+ // If set, when a variable substitution with spaces in it, such as $ var$,
+ // is encountered, the spaces are stripped, so that it is as if it was
+ // $var$. If $var$ substitutes to a non-empty string, the removed spaces are
+ // printed around the substituted value.
+ //
+ // See the class documentation for more information on this behavior.
+ bool strip_spaces_around_vars = true;
+ // If set, leading whitespace will be stripped from the format string to
+ // determine the "extraneous indentation" that is produced when the format
+ // string is a C++ raw string. This is used to remove leading spaces from
+ // a raw string that would otherwise result in erratic indentation in the
+ // output.
+ bool strip_raw_string_indentation = false;
+ // If set, the annotation lookup frames are searched, per the annotation
+ // semantics of Emit() described in the class documentation.
+ bool use_annotation_frames = true;
+};
+
+// Helper type for wrapping a variable substitution expansion result.
+template <bool owned>
+struct Printer::ValueImpl {
+ private:
+ template <typename T>
+ struct IsSubImpl : std::false_type {};
+ template <bool a>
+ struct IsSubImpl<ValueImpl<a>> : std::true_type {};
+
+ public:
+ using StringType = std::conditional_t<owned, TProtoStringType, y_absl::string_view>;
+ // These callbacks return false if this is a recursive call.
+ using Callback = std::function<bool()>;
+ using StringOrCallback = y_absl::variant<StringType, Callback>;
+
+ ValueImpl() = default;
+
+ // This is a template to avoid colliding with the copy constructor below.
+ template <typename Value,
+ typename = std::enable_if_t<
+ !IsSubImpl<y_absl::remove_cvref_t<Value>>::value>>
+ ValueImpl(Value&& value) // NOLINT
+ : value(ToStringOrCallback(std::forward<Value>(value), Rank2{})) {
+ if (y_absl::holds_alternative<Callback>(this->value)) {
+ consume_after = ";,";
+ }
+ }
+
+ // Copy ctor/assign allow interconversion of the two template parameters.
+ template <bool that_owned>
+ ValueImpl(const ValueImpl<that_owned>& that) { // NOLINT
+ *this = that;
+ }
- // Returns true and sets range to the substitution range in the output for
- // varname if varname was used once in the last call to Print. If varname
- // was not used, or if it was used multiple times, returns false (and
- // fails a debug assertion).
- bool GetSubstitutionRange(const char* varname,
- std::pair<size_t, size_t>* range);
+ template <bool that_owned>
+ ValueImpl& operator=(const ValueImpl<that_owned>& that);
- // If non-null, annotation_collector_ is used to store annotations about
- // generated code.
- AnnotationCollector* const annotation_collector_;
+ const StringType* AsString() const {
+ return y_absl::get_if<StringType>(&value);
+ }
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Printer);
+ const Callback* AsCallback() const { return y_absl::get_if<Callback>(&value); }
+
+ StringOrCallback value;
+ TProtoStringType consume_after;
+
+ private:
+ // go/ranked-overloads
+ struct Rank0 {};
+ struct Rank1 : Rank0 {};
+ struct Rank2 : Rank1 {};
+
+ // Dummy template for delayed instantiation, which is required for the
+ // static assert below to kick in only when this function is called when it
+ // shouldn't.
+ //
+ // This is done to produce a better error message than the "candidate does
+ // not match" SFINAE errors.
+ template <typename Cb, typename = decltype(std::declval<Cb&&>()())>
+ StringOrCallback ToStringOrCallback(Cb&& cb, Rank2);
+
+ // Separate from the AlphaNum overload to avoid copies when taking strings
+ // by value when in `owned` mode.
+ StringOrCallback ToStringOrCallback(StringType s, Rank1) { return s; }
+
+ StringOrCallback ToStringOrCallback(const y_absl::AlphaNum& s, Rank0) {
+ return StringType(s.Piece());
+ }
};
+template <bool owned>
+template <bool that_owned>
+Printer::ValueImpl<owned>& Printer::ValueImpl<owned>::operator=(
+ const ValueImpl<that_owned>& that) {
+ // Cast to void* is required, since this and that may potentially be of
+ // different types (due to the `that_owned` parameter).
+ if (static_cast<const void*>(this) == static_cast<const void*>(&that)) {
+ return *this;
+ }
+
+ using ThatStringType = typename ValueImpl<that_owned>::StringType;
+
+ if (auto* str = y_absl::get_if<ThatStringType>(&that.value)) {
+ value = StringType(*str);
+ } else {
+ value = y_absl::get<Callback>(that.value);
+ }
+
+ consume_after = that.consume_after;
+ return *this;
+}
+
+template <bool owned>
+template <typename Cb, typename /*Sfinae*/>
+auto Printer::ValueImpl<owned>::ToStringOrCallback(Cb&& cb, Rank2)
+ -> StringOrCallback {
+ return Callback(
+ [cb = std::forward<Cb>(cb), is_called = false]() mutable -> bool {
+ if (is_called) {
+ // Catch whether or not this function is being called recursively.
+ return false;
+ }
+ is_called = true;
+ cb();
+ is_called = false;
+ return true;
+ });
+}
+
+struct Printer::AnnotationRecord {
+ std::vector<int> path;
+ TProtoStringType file_path;
+ y_absl::optional<AnnotationCollector::Semantic> semantic;
+
+ // AnnotationRecord's constructors are *not* marked as explicit,
+ // specifically so that it is possible to construct a
+ // map<string, AnnotationRecord> by writing
+ //
+ // {{"foo", my_cool_descriptor}, {"bar", "file.proto"}}
+
+ template <
+ typename String,
+ std::enable_if_t<std::is_convertible<const String&, TProtoStringType>::value,
+ int> = 0>
+ AnnotationRecord( // NOLINT(google-explicit-constructor)
+ const String& file_path,
+ y_absl::optional<AnnotationCollector::Semantic> semantic = y_absl::nullopt)
+ : file_path(file_path), semantic(semantic) {}
+
+ template <typename Desc,
+ // This SFINAE clause excludes char* from matching this
+ // constructor.
+ std::enable_if_t<std::is_class<Desc>::value, int> = 0>
+ AnnotationRecord( // NOLINT(google-explicit-constructor)
+ const Desc* desc,
+ y_absl::optional<AnnotationCollector::Semantic> semantic = y_absl::nullopt)
+ : file_path(desc->file()->name()), semantic(semantic) {
+ desc->GetLocationPath(&path);
+ }
+};
+
+class Printer::Sub {
+ public:
+ template <typename Value>
+ Sub(TProtoStringType key, Value&& value)
+ : key_(std::move(key)),
+ value_(std::forward<Value>(value)),
+ annotation_(y_absl::nullopt) {}
+
+ Sub AnnotatedAs(AnnotationRecord annotation) && {
+ annotation_ = std::move(annotation);
+ return std::move(*this);
+ }
+
+ Sub WithSuffix(TProtoStringType sub_suffix) && {
+ value_.consume_after = std::move(sub_suffix);
+ return std::move(*this);
+ }
+
+ y_absl::string_view key() const { return key_; }
+
+ y_absl::string_view value() const {
+ const auto* str = value_.AsString();
+ Y_ABSL_CHECK(str != nullptr)
+ << "could not find " << key() << "; found callback instead";
+ return *str;
+ }
+
+ private:
+ friend class Printer;
+
+ TProtoStringType key_;
+ Value value_;
+ y_absl::optional<AnnotationRecord> annotation_;
+};
+
+template <typename Map>
+auto Printer::WithVars(const Map* vars) {
+ var_lookups_.emplace_back(
+ [vars](y_absl::string_view var) -> y_absl::optional<ValueView> {
+ auto it = vars->find(ToStringKey<Map>(var));
+ if (it == vars->end()) {
+ return y_absl::nullopt;
+ }
+ return ValueView(it->second);
+ });
+ return y_absl::MakeCleanup([this] { var_lookups_.pop_back(); });
+}
+
+template <typename Map, typename, typename /*Sfinae*/>
+auto Printer::WithVars(Map&& vars) {
+ var_lookups_.emplace_back(
+ [vars = std::forward<Map>(vars)](
+ y_absl::string_view var) -> y_absl::optional<ValueView> {
+ auto it = vars.find(ToStringKey<Map>(var));
+ if (it == vars.end()) {
+ return y_absl::nullopt;
+ }
+ return ValueView(it->second);
+ });
+ return y_absl::MakeCleanup([this] { var_lookups_.pop_back(); });
+}
+
+template <typename Map>
+auto Printer::WithAnnotations(const Map* vars) {
+ annotation_lookups_.emplace_back(
+ [vars](y_absl::string_view var) -> y_absl::optional<AnnotationRecord> {
+ auto it = vars->find(ToStringKey<Map>(var));
+ if (it == vars->end()) {
+ return y_absl::nullopt;
+ }
+ return AnnotationRecord(it->second);
+ });
+ return y_absl::MakeCleanup([this] { annotation_lookups_.pop_back(); });
+}
+
+template <typename Map>
+auto Printer::WithAnnotations(Map&& vars) {
+ annotation_lookups_.emplace_back(
+ [vars = std::forward<Map>(vars)](
+ y_absl::string_view var) -> y_absl::optional<AnnotationRecord> {
+ auto it = vars.find(ToStringKey<Map>(var));
+ if (it == vars.end()) {
+ return y_absl::nullopt;
+ }
+ return AnnotationRecord(it->second);
+ });
+ return y_absl::MakeCleanup([this] { annotation_lookups_.pop_back(); });
+}
+
+inline void Printer::Emit(y_absl::string_view format, SourceLocation loc) {
+ Emit({}, format, loc);
+}
+
+template <typename Map>
+void Printer::Print(const Map& vars, y_absl::string_view text) {
+ PrintOptions opts;
+ opts.checks_are_debug_only = true;
+ opts.use_substitution_map = true;
+ opts.allow_digit_substitutions = false;
+
+ auto pop = WithVars(&vars);
+ PrintImpl(text, {}, opts);
+}
+
+template <typename... Args>
+void Printer::Print(y_absl::string_view text, const Args&... args) {
+ static_assert(sizeof...(args) % 2 == 0, "");
+
+ // Include an extra arg, since a zero-length array is ill-formed, and
+ // MSVC complains.
+ y_absl::string_view vars[] = {args..., ""};
+ y_absl::flat_hash_map<y_absl::string_view, y_absl::string_view> map;
+ map.reserve(sizeof...(args) / 2);
+ for (size_t i = 0; i < sizeof...(args); i += 2) {
+ map.emplace(vars[i], vars[i + 1]);
+ }
+
+ Print(map, text);
+}
+
+template <typename Desc>
+void Printer::Annotate(y_absl::string_view begin_varname,
+ y_absl::string_view end_varname, const Desc* descriptor) {
+ if (options_.annotation_collector == nullptr) {
+ return;
+ }
+
+ std::vector<int> path;
+ descriptor->GetLocationPath(&path);
+ Annotate(begin_varname, end_varname, descriptor->file()->name(), path);
+}
+
+template <typename Map>
+void Printer::FormatInternal(y_absl::Span<const TProtoStringType> args,
+ const Map& vars, y_absl::string_view format) {
+ PrintOptions opts;
+ opts.use_curly_brace_substitutions = true;
+ opts.strip_spaces_around_vars = true;
+
+ auto pop = WithVars(&vars);
+ PrintImpl(format, args, opts);
+}
+
+inline auto Printer::WithDefs(y_absl::Span<const Sub> vars,
+ bool allow_callbacks) {
+ y_absl::flat_hash_map<TProtoStringType, Value> var_map;
+ var_map.reserve(vars.size());
+
+ y_absl::flat_hash_map<TProtoStringType, AnnotationRecord> annotation_map;
+
+ for (const auto& var : vars) {
+ Y_ABSL_CHECK(allow_callbacks || var.value_.AsCallback() == nullptr)
+ << "callback arguments are not permitted in this position";
+ auto result = var_map.insert({var.key_, var.value_});
+ Y_ABSL_CHECK(result.second)
+ << "repeated variable in Emit() or WithVars() call: \"" << var.key_
+ << "\"";
+ if (var.annotation_.has_value()) {
+ annotation_map.insert({var.key_, *var.annotation_});
+ }
+ }
+
+ var_lookups_.emplace_back([map = std::move(var_map)](y_absl::string_view var)
+ -> y_absl::optional<ValueView> {
+ auto it = map.find(var);
+ if (it == map.end()) {
+ return y_absl::nullopt;
+ }
+ return ValueView(it->second);
+ });
+
+ bool has_annotations = !annotation_map.empty();
+ if (has_annotations) {
+ annotation_lookups_.emplace_back(
+ [map = std::move(annotation_map)](
+ y_absl::string_view var) -> y_absl::optional<AnnotationRecord> {
+ auto it = map.find(var);
+ if (it == map.end()) {
+ return y_absl::nullopt;
+ }
+ return it->second;
+ });
+ }
+
+ return y_absl::MakeCleanup([this, has_annotations] {
+ var_lookups_.pop_back();
+ if (has_annotations) {
+ annotation_lookups_.pop_back();
+ }
+ });
+}
+
+inline auto Printer::WithVars(y_absl::Span<const Sub> vars) {
+ return WithDefs(vars, /*allow_callbacks=*/false);
+}
} // namespace io
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_IO_PRINTER_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/strtod.cc b/contrib/libs/protobuf/src/google/protobuf/io/strtod.cc
index 03acb5b294a..f7c8950b52e 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/strtod.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/io/strtod.cc
@@ -28,17 +28,22 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <google/protobuf/io/strtod.h>
+#include "google/protobuf/io/strtod.h"
+#include <float.h> // FLT_DIG and DBL_DIG
+
+#include <cmath>
#include <cstdio>
+#include <cstdlib>
#include <cstring>
#include <limits>
#include <string>
+#include <system_error> // NOLINT(build/c++11)
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-
-#include <google/protobuf/stubs/strutil.h>
+#include "y_absl/log/absl_check.h"
+#include "y_absl/strings/charconv.h"
+#include "y_absl/strings/numbers.h"
+#include "y_absl/strings/str_format.h"
namespace google {
namespace protobuf {
@@ -46,7 +51,7 @@ namespace io {
// This approximately 0x1.ffffffp127, but we don't use 0x1.ffffffp127 because
// it won't compile in MSVC.
-const double MAX_FLOAT_AS_DOUBLE_ROUNDED = 3.4028235677973366e+38;
+constexpr double MAX_FLOAT_AS_DOUBLE_ROUNDED = 3.4028235677973366e+38;
float SafeDoubleToFloat(double value) {
// static_cast<float> on a number larger than float can result in illegal
@@ -73,8 +78,204 @@ float SafeDoubleToFloat(double value) {
}
}
-double NoLocaleStrtod(const char* str, char** endptr) {
- return google::protobuf::internal::NoLocaleStrtod(str, endptr);
+double NoLocaleStrtod(const char *str, char **endptr) {
+ double ret = 0.0;
+ // This isn't ideal, but the existing function interface does not provide any
+ // bounds.
+ const char *end = strchr(str, 0);
+ auto result = y_absl::from_chars(str, end, ret);
+ // from_chars() with DR 3081's current wording will return max() on
+ // overflow. SimpleAtod returns infinity instead.
+ if (result.ec == std::errc::result_out_of_range) {
+ if (ret > 1.0) {
+ ret = std::numeric_limits<double>::infinity();
+ } else if (ret < -1.0) {
+ ret = -std::numeric_limits<double>::infinity();
+ }
+ }
+ if (endptr) {
+ *endptr = const_cast<char *>(result.ptr);
+ }
+ return ret;
+}
+
+// ----------------------------------------------------------------------
+// SimpleDtoa()
+// SimpleFtoa()
+// We want to print the value without losing precision, but we also do
+// not want to print more digits than necessary. This turns out to be
+// trickier than it sounds. Numbers like 0.2 cannot be represented
+// exactly in binary. If we print 0.2 with a very large precision,
+// e.g. "%.50g", we get "0.2000000000000000111022302462515654042363167".
+// On the other hand, if we set the precision too low, we lose
+// significant digits when printing numbers that actually need them.
+// It turns out there is no precision value that does the right thing
+// for all numbers.
+//
+// Our strategy is to first try printing with a precision that is never
+// over-precise, then parse the result with strtod() to see if it
+// matches. If not, we print again with a precision that will always
+// give a precise result, but may use more digits than necessary.
+//
+// An arguably better strategy would be to use the algorithm described
+// in "How to Print Floating-Point Numbers Accurately" by Steele &
+// White, e.g. as implemented by David M. Gay's dtoa(). It turns out,
+// however, that the following implementation is about as fast as
+// DMG's code. Furthermore, DMG's code locks mutexes, which means it
+// will not scale well on multi-core machines. DMG's code is slightly
+// more accurate (in that it will never use more digits than
+// necessary), but this is probably irrelevant for most users.
+//
+// Rob Pike and Ken Thompson also have an implementation of dtoa() in
+// third_party/fmt/fltfmt.cc. Their implementation is similar to this
+// one in that it makes guesses and then uses strtod() to check them.
+// Their implementation is faster because they use their own code to
+// generate the digits in the first place rather than use snprintf(),
+// thus avoiding format string parsing overhead. However, this makes
+// it considerably more complicated than the following implementation,
+// and it is embedded in a larger library. If speed turns out to be
+// an issue, we could re-implement this in terms of their
+// implementation.
+// ----------------------------------------------------------------------
+
+namespace {
+// In practice, doubles should never need more than 24 bytes and floats
+// should never need more than 14 (including null terminators), but we
+// overestimate to be safe.
+constexpr int kDoubleToBufferSize = 32;
+constexpr int kFloatToBufferSize = 24;
+
+inline bool IsValidFloatChar(char c) {
+ return ('0' <= c && c <= '9') || c == 'e' || c == 'E' || c == '+' || c == '-';
+}
+
+void DelocalizeRadix(char *buffer) {
+ // Fast check: if the buffer has a normal decimal point, assume no
+ // translation is needed.
+ if (strchr(buffer, '.') != nullptr) return;
+
+ // Find the first unknown character.
+ while (IsValidFloatChar(*buffer)) ++buffer;
+
+ if (*buffer == '\0') {
+ // No radix character found.
+ return;
+ }
+
+ // We are now pointing at the locale-specific radix character. Replace it
+ // with '.'.
+ *buffer = '.';
+ ++buffer;
+
+ if (!IsValidFloatChar(*buffer) && *buffer != '\0') {
+ // It appears the radix was a multi-byte character. We need to remove the
+ // extra bytes.
+ char *target = buffer;
+ do {
+ ++buffer;
+ } while (!IsValidFloatChar(*buffer) && *buffer != '\0');
+ memmove(target, buffer, strlen(buffer) + 1);
+ }
+}
+
+bool safe_strtof(const char *str, float *value) {
+ char *endptr;
+ errno = 0; // errno only gets set on errors
+ *value = strtof(str, &endptr);
+ return *str != 0 && *endptr == 0 && errno == 0;
+}
+
+char *FloatToBuffer(float value, char *buffer) {
+ // FLT_DIG is 6 for IEEE-754 floats, which are used on almost all
+ // platforms these days. Just in case some system exists where FLT_DIG
+ // is significantly larger -- and risks overflowing our buffer -- we have
+ // this assert.
+ static_assert(FLT_DIG < 10, "FLT_DIG_is_too_big");
+
+ if (value == std::numeric_limits<double>::infinity()) {
+ y_absl::SNPrintF(buffer, kFloatToBufferSize, "inf");
+ return buffer;
+ } else if (value == -std::numeric_limits<double>::infinity()) {
+ y_absl::SNPrintF(buffer, kFloatToBufferSize, "-inf");
+ return buffer;
+ } else if (std::isnan(value)) {
+ y_absl::SNPrintF(buffer, kFloatToBufferSize, "nan");
+ return buffer;
+ }
+
+ int snprintf_result =
+ y_absl::SNPrintF(buffer, kFloatToBufferSize, "%.*g", FLT_DIG, value);
+
+ // The snprintf should never overflow because the buffer is significantly
+ // larger than the precision we asked for.
+ Y_ABSL_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize);
+
+ float parsed_value;
+ if (!safe_strtof(buffer, &parsed_value) || parsed_value != value) {
+ snprintf_result =
+ y_absl::SNPrintF(buffer, kFloatToBufferSize, "%.*g", FLT_DIG + 3, value);
+
+ // Should never overflow; see above.
+ Y_ABSL_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize);
+ }
+
+ DelocalizeRadix(buffer);
+ return buffer;
+}
+
+char *DoubleToBuffer(double value, char *buffer) {
+ // DBL_DIG is 15 for IEEE-754 doubles, which are used on almost all
+ // platforms these days. Just in case some system exists where DBL_DIG
+ // is significantly larger -- and risks overflowing our buffer -- we have
+ // this assert.
+ static_assert(DBL_DIG < 20, "DBL_DIG_is_too_big");
+
+ if (value == std::numeric_limits<double>::infinity()) {
+ y_absl::SNPrintF(buffer, kDoubleToBufferSize, "inf");
+ return buffer;
+ } else if (value == -std::numeric_limits<double>::infinity()) {
+ y_absl::SNPrintF(buffer, kDoubleToBufferSize, "-inf");
+ return buffer;
+ } else if (std::isnan(value)) {
+ y_absl::SNPrintF(buffer, kDoubleToBufferSize, "nan");
+ return buffer;
+ }
+
+ int snprintf_result =
+ y_absl::SNPrintF(buffer, kDoubleToBufferSize, "%.*g", DBL_DIG, value);
+
+ // The snprintf should never overflow because the buffer is significantly
+ // larger than the precision we asked for.
+ Y_ABSL_DCHECK(snprintf_result > 0 && snprintf_result < kDoubleToBufferSize);
+
+ // We need to make parsed_value volatile in order to force the compiler to
+ // write it out to the stack. Otherwise, it may keep the value in a
+ // register, and if it does that, it may keep it as a long double instead
+ // of a double. This long double may have extra bits that make it compare
+ // unequal to "value" even though it would be exactly equal if it were
+ // truncated to a double.
+ volatile double parsed_value = NoLocaleStrtod(buffer, nullptr);
+ if (parsed_value != value) {
+ snprintf_result =
+ y_absl::SNPrintF(buffer, kDoubleToBufferSize, "%.*g", DBL_DIG + 2, value);
+
+ // Should never overflow; see above.
+ Y_ABSL_DCHECK(snprintf_result > 0 && snprintf_result < kDoubleToBufferSize);
+ }
+
+ DelocalizeRadix(buffer);
+ return buffer;
+}
+} // namespace
+
+TProtoStringType SimpleDtoa(double value) {
+ char buffer[kDoubleToBufferSize];
+ return DoubleToBuffer(value, buffer);
+}
+
+TProtoStringType SimpleFtoa(float value) {
+ char buffer[kFloatToBufferSize];
+ return FloatToBuffer(value, buffer);
}
} // namespace io
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/strtod.h b/contrib/libs/protobuf/src/google/protobuf/io/strtod.h
index 38f544af34c..2172d15a1c3 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/strtod.h
+++ b/contrib/libs/protobuf/src/google/protobuf/io/strtod.h
@@ -35,10 +35,31 @@
#ifndef GOOGLE_PROTOBUF_IO_STRTOD_H__
#define GOOGLE_PROTOBUF_IO_STRTOD_H__
+#include <util/generic/string.h>
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+using TProtoStringType = TString;
+
namespace google {
namespace protobuf {
namespace io {
+// ----------------------------------------------------------------------
+// SimpleDtoa()
+// SimpleFtoa()
+// Description: converts a double or float to a string which, if
+// passed to NoLocaleStrtod(), will produce the exact same original double
+// (except in case of NaN; all NaNs are considered the same value).
+// We try to keep the string short but it's not guaranteed to be as
+// short as possible.
+//
+// Return value: string
+// ----------------------------------------------------------------------
+PROTOBUF_EXPORT TProtoStringType SimpleDtoa(double value);
+PROTOBUF_EXPORT TProtoStringType SimpleFtoa(float value);
+
// A locale-independent version of the standard strtod(), which always
// uses a dot as the decimal separator.
double NoLocaleStrtod(const char* str, char** endptr);
@@ -52,4 +73,6 @@ float SafeDoubleToFloat(double value);
} // namespace protobuf
} // namespace google
+#include "google/protobuf/port_undef.inc"
+
#endif // GOOGLE_PROTOBUF_IO_STRTOD_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/tokenizer.cc b/contrib/libs/protobuf/src/google/protobuf/io/tokenizer.cc
index 56cf5d8917c..66594cae875 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/tokenizer.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/io/tokenizer.cc
@@ -88,18 +88,18 @@
// I'd love to hear about other alternatives, though, as this code isn't
// exactly pretty.
-#include <google/protobuf/io/tokenizer.h>
+#include "google/protobuf/io/tokenizer.h"
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/logging.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>
+#include "google/protobuf/stubs/common.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/escaping.h"
+#include "y_absl/strings/str_format.h"
+#include "google/protobuf/io/strtod.h"
+#include "google/protobuf/io/zero_copy_stream.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -406,7 +406,7 @@ void Tokenizer::ConsumeString(char delimiter) {
case '\n': {
if (!allow_multiline_strings_) {
- AddError("String literals cannot cross line boundaries.");
+ AddError("Multiline strings are not allowed. Did you miss a \"?.");
return;
}
NextChar();
@@ -422,7 +422,7 @@ void Tokenizer::ConsumeString(char delimiter) {
// Possibly followed by two more octal digits, but these will
// just be consumed by the main loop anyway so we don't need
// to do so explicitly here.
- } else if (TryConsume('x')) {
+ } else if (TryConsume('x') || TryConsume('X')) {
if (!TryConsumeOne<HexDigit>()) {
AddError("Expected hex digits for escape sequence.");
}
@@ -568,8 +568,8 @@ void Tokenizer::ConsumeBlockComment(TProtoStringType* content) {
"\"/*\" inside block comment. Block comments cannot be nested.");
} else if (current_char_ == '\0') {
AddError("End-of-file inside block comment.");
- error_collector_->AddError(start_line, start_column,
- " Comment started here.");
+ error_collector_->RecordError(start_line, start_column,
+ " Comment started here.");
if (content != NULL) StopRecording();
break;
}
@@ -687,7 +687,7 @@ bool Tokenizer::Next() {
current_.line == previous_.line &&
current_.column == previous_.end_column) {
// We don't accept syntax like "blah.123".
- error_collector_->AddError(
+ error_collector_->RecordError(
line_, column_ - 2,
"Need space between identifier and decimal point.");
}
@@ -746,6 +746,8 @@ class CommentCollector {
: prev_trailing_comments_(prev_trailing_comments),
detached_comments_(detached_comments),
next_leading_comments_(next_leading_comments),
+ num_comments_(0),
+ has_trailing_comment_(false),
has_comment_(false),
is_line_comment_(false),
can_attach_to_prev_(true) {
@@ -797,6 +799,7 @@ class CommentCollector {
if (prev_trailing_comments_ != NULL) {
prev_trailing_comments_->append(comment_buffer_);
}
+ has_trailing_comment_ = true;
can_attach_to_prev_ = false;
} else {
if (detached_comments_ != NULL) {
@@ -804,17 +807,39 @@ class CommentCollector {
}
}
ClearBuffer();
+ num_comments_++;
}
}
void DetachFromPrev() { can_attach_to_prev_ = false; }
+ void MaybeDetachComment() {
+ int count = num_comments_;
+ if (has_comment_) count++;
+
+ // If there's one comment, make sure it is detached.
+ if (count == 1) {
+ if (has_trailing_comment_ && prev_trailing_comments_ != NULL) {
+ TProtoStringType trail = *prev_trailing_comments_;
+ if (detached_comments_ != NULL) {
+ // push trailing comment to front of detached
+ detached_comments_->insert(detached_comments_->begin(), 1, trail);
+ }
+ prev_trailing_comments_->clear();
+ }
+ // flush pending comment so it's detached instead of leading
+ Flush();
+ }
+ }
+
private:
TProtoStringType* prev_trailing_comments_;
std::vector<TProtoStringType>* detached_comments_;
TProtoStringType* next_leading_comments_;
TProtoStringType comment_buffer_;
+ int num_comments_;
+ bool has_trailing_comment_;
// True if any comments were read into comment_buffer_. This can be true even
// if comment_buffer_ is empty, namely if the comment was "/**/".
@@ -836,6 +861,9 @@ bool Tokenizer::NextWithComments(TProtoStringType* prev_trailing_comments,
CommentCollector collector(prev_trailing_comments, detached_comments,
next_leading_comments);
+ int prev_line = line_;
+ int trailing_comment_end_line = -1;
+
if (current_.type == TYPE_START) {
// Ignore unicode byte order mark(BOM) if it appears at the file
// beginning. Only UTF-8 BOM (0xEF 0xBB 0xBF) is accepted.
@@ -849,12 +877,14 @@ bool Tokenizer::NextWithComments(TProtoStringType* prev_trailing_comments,
}
}
collector.DetachFromPrev();
+ prev_line = -1;
} else {
// A comment appearing on the same line must be attached to the previous
// declaration.
ConsumeZeroOrMore<WhitespaceNoNewline>();
switch (TryConsumeCommentStart()) {
case LINE_COMMENT:
+ trailing_comment_end_line = line_;
ConsumeLineComment(collector.GetBufferForLineComment());
// Don't allow comments on subsequent lines to be attached to a trailing
@@ -863,14 +893,8 @@ bool Tokenizer::NextWithComments(TProtoStringType* prev_trailing_comments,
break;
case BLOCK_COMMENT:
ConsumeBlockComment(collector.GetBufferForBlockComment());
-
+ trailing_comment_end_line = line_;
ConsumeZeroOrMore<WhitespaceNoNewline>();
- if (!TryConsume('\n')) {
- // Oops, the next token is on the same line. If we recorded a comment
- // we really have no idea which token it should be attached to.
- collector.ClearBuffer();
- return Next();
- }
// Don't allow comments on subsequent lines to be attached to a trailing
// comment.
@@ -918,6 +942,14 @@ bool Tokenizer::NextWithComments(TProtoStringType* prev_trailing_comments,
// makes no sense to attach a comment to the following token.
collector.Flush();
}
+ if (result &&
+ (prev_line == line_ || trailing_comment_end_line == line_)) {
+ // When previous token and this one are on the same line, or
+ // even if a multi-line trailing comment ends on the same line
+ // as this token, it's unclear to what token the comment
+ // should be attached. So we detach it.
+ collector.MaybeDetachComment();
+ }
return result;
}
break;
@@ -1002,9 +1034,20 @@ bool Tokenizer::ParseInteger(const TProtoStringType& text, arc_ui64 max_value,
}
double Tokenizer::ParseFloat(const TProtoStringType& text) {
+ double result = 0;
+ if (!TryParseFloat(text, &result)) {
+ Y_ABSL_DLOG(FATAL)
+ << " Tokenizer::ParseFloat() passed text that could not have been"
+ " tokenized as a float: "
+ << y_absl::CEscape(text);
+ }
+ return result;
+}
+
+bool Tokenizer::TryParseFloat(const TProtoStringType& text, double* result) {
const char* start = text.c_str();
char* end;
- double result = NoLocaleStrtod(start, &end);
+ *result = NoLocaleStrtod(start, &end);
// "1e" is not a valid float, but if the tokenizer reads it, it will
// report an error but still return it as a valid token. We need to
@@ -1020,12 +1063,7 @@ double Tokenizer::ParseFloat(const TProtoStringType& text) {
++end;
}
- GOOGLE_LOG_IF(DFATAL,
- static_cast<size_t>(end - start) != text.size() || *start == '-')
- << " Tokenizer::ParseFloat() passed text that could not have been"
- " tokenized as a float: "
- << CEscape(text);
- return result;
+ return static_cast<size_t>(end - start) == text.size() && *start != '-';
}
// Helper to append a Unicode code point to a string as UTF8, without bringing
@@ -1052,7 +1090,7 @@ static void AppendUTF8(arc_ui32 code_point, TProtoStringType* output) {
// Unicode code points end at 0x10FFFF, so this is out-of-range.
// ConsumeString permits hex values up to 0x1FFFFF, and FetchUnicodePoint
// doesn't perform a range check.
- StringAppendF(output, "\\U%08x", code_point);
+ y_absl::StrAppendFormat(output, "\\U%08x", code_point);
return;
}
tmp = ghtonl(tmp);
@@ -1093,8 +1131,8 @@ static inline bool IsTrailSurrogate(arc_ui32 code_point) {
// Combine a head and trail surrogate into a single Unicode code point.
static arc_ui32 AssembleUTF16(arc_ui32 head_surrogate,
arc_ui32 trail_surrogate) {
- GOOGLE_DCHECK(IsHeadSurrogate(head_surrogate));
- GOOGLE_DCHECK(IsTrailSurrogate(trail_surrogate));
+ Y_ABSL_DCHECK(IsHeadSurrogate(head_surrogate));
+ Y_ABSL_DCHECK(IsTrailSurrogate(trail_surrogate));
return 0x10000 + (((head_surrogate - kMinHeadSurrogate) << 10) |
(trail_surrogate - kMinTrailSurrogate));
}
@@ -1143,9 +1181,10 @@ void Tokenizer::ParseStringAppend(const TProtoStringType& text,
// empty, it's invalid, so we'll just return).
const size_t text_size = text.size();
if (text_size == 0) {
- GOOGLE_LOG(DFATAL) << " Tokenizer::ParseStringAppend() passed text that could not"
- " have been tokenized as a string: "
- << CEscape(text);
+ Y_ABSL_DLOG(FATAL)
+ << " Tokenizer::ParseStringAppend() passed text that could not"
+ " have been tokenized as a string: "
+ << y_absl::CEscape(text);
return;
}
@@ -1179,7 +1218,7 @@ void Tokenizer::ParseStringAppend(const TProtoStringType& text,
}
output->push_back(static_cast<char>(code));
- } else if (*ptr == 'x') {
+ } else if (*ptr == 'x' || *ptr == 'X') {
// A hex escape. May zero, one, or two digits. (The zero case
// will have been caught as an error earlier.)
int code = 0;
@@ -1236,4 +1275,4 @@ bool Tokenizer::IsIdentifier(const TProtoStringType& text) {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/tokenizer.h b/contrib/libs/protobuf/src/google/protobuf/io/tokenizer.h
index 984004e696d..0a649ad5455 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/tokenizer.h
+++ b/contrib/libs/protobuf/src/google/protobuf/io/tokenizer.h
@@ -37,15 +37,16 @@
#ifndef GOOGLE_PROTOBUF_IO_TOKENIZER_H__
#define GOOGLE_PROTOBUF_IO_TOKENIZER_H__
-
#include <string>
#include <vector>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/logging.h>
+#include "google/protobuf/stubs/common.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/port.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -69,22 +70,40 @@ typedef int ColumnNumber;
class PROTOBUF_EXPORT ErrorCollector {
public:
inline ErrorCollector() {}
+ ErrorCollector(const ErrorCollector&) = delete;
+ ErrorCollector& operator=(const ErrorCollector&) = delete;
virtual ~ErrorCollector();
// Indicates that there was an error in the input at the given line and
// column numbers. The numbers are zero-based, so you may want to add
// 1 to each before printing them.
- virtual void AddError(int line, ColumnNumber column,
- const TProtoStringType& message) = 0;
+ virtual void RecordError(int line, ColumnNumber column,
+ y_absl::string_view message) {
+ PROTOBUF_IGNORE_DEPRECATION_START
+ AddError(line, column, TProtoStringType(message));
+ PROTOBUF_IGNORE_DEPRECATION_STOP
+ }
// Indicates that there was a warning in the input at the given line and
// column numbers. The numbers are zero-based, so you may want to add
// 1 to each before printing them.
- virtual void AddWarning(int /* line */, ColumnNumber /* column */,
- const TProtoStringType& /* message */) {}
+ virtual void RecordWarning(int line, ColumnNumber column,
+ y_absl::string_view message) {
+ PROTOBUF_IGNORE_DEPRECATION_START
+ AddWarning(line, column, TProtoStringType(message));
+ PROTOBUF_IGNORE_DEPRECATION_STOP
+ }
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ErrorCollector);
+ // These should never be called directly, but if a legacy class overrides
+ // them they'll get routed to by the Record* methods.
+
+ virtual void AddError(int line, ColumnNumber column,
+ const TProtoStringType& message) {
+ Y_ABSL_LOG(FATAL) << "AddError or RecordError must be implemented.";
+ }
+
+ virtual void AddWarning(int line, ColumnNumber column,
+ const TProtoStringType& message) {}
};
// This class converts a stream of raw text into a stream of tokens for
@@ -99,6 +118,8 @@ class PROTOBUF_EXPORT Tokenizer {
// input stream and writes errors to the given error_collector.
// The caller keeps ownership of input and error_collector.
Tokenizer(ZeroCopyInputStream* input, ErrorCollector* error_collector);
+ Tokenizer(const Tokenizer&) = delete;
+ Tokenizer& operator=(const Tokenizer&) = delete;
~Tokenizer();
enum TokenType {
@@ -149,11 +170,11 @@ class PROTOBUF_EXPORT Tokenizer {
// Get the current token. This is updated when Next() is called. Before
// the first call to Next(), current() has type TYPE_START and no contents.
- const Token& current();
+ const Token& current() const;
// Return the previous token -- i.e. what current() returned before the
// previous call to Next().
- const Token& previous();
+ const Token& previous() const;
// Advance to the next token. Returns false if the end of the input is
// reached.
@@ -213,6 +234,10 @@ class PROTOBUF_EXPORT Tokenizer {
// result is undefined (possibly an assert failure).
static double ParseFloat(const TProtoStringType& text);
+ // Parses given text as if it were a TYPE_FLOAT token. Returns false if the
+ // given text is not actually a valid float literal.
+ static bool TryParseFloat(const TProtoStringType& text, double* result);
+
// Parses a TYPE_STRING token. This never fails, so long as the text actually
// comes from a TYPE_STRING token parsed by Tokenizer. If it doesn't, the
// result is undefined (possibly an assert failure).
@@ -276,8 +301,6 @@ class PROTOBUF_EXPORT Tokenizer {
// -----------------------------------------------------------------
private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Tokenizer);
-
Token current_; // Returned by current().
Token previous_; // Returned by previous().
@@ -336,7 +359,7 @@ class PROTOBUF_EXPORT Tokenizer {
// Convenience method to add an error at the current line and column.
void AddError(const TProtoStringType& message) {
- error_collector_->AddError(line_, column_, message);
+ error_collector_->RecordError(line_, column_, message);
}
// -----------------------------------------------------------------
@@ -423,9 +446,9 @@ class PROTOBUF_EXPORT Tokenizer {
};
// inline methods ====================================================
-inline const Tokenizer::Token& Tokenizer::current() { return current_; }
+inline const Tokenizer::Token& Tokenizer::current() const { return current_; }
-inline const Tokenizer::Token& Tokenizer::previous() { return previous_; }
+inline const Tokenizer::Token& Tokenizer::previous() const { return previous_; }
inline void Tokenizer::ParseString(const TProtoStringType& text,
TProtoStringType* output) {
@@ -437,6 +460,6 @@ inline void Tokenizer::ParseString(const TProtoStringType& text,
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_IO_TOKENIZER_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_sink.cc b/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_sink.cc
new file mode 100644
index 00000000000..70456485c77
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_sink.cc
@@ -0,0 +1,68 @@
+// 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/io/zero_copy_sink.h"
+
+#include <algorithm>
+#include <cstddef>
+
+namespace google {
+namespace protobuf {
+namespace io {
+namespace zc_sink_internal {
+void ZeroCopyStreamByteSink::Append(const char* bytes, size_t len) {
+ while (!failed_ && len > 0) {
+ if (buffer_size_ == 0) {
+ int size;
+ if (!stream_->Next(&buffer_, &size)) {
+ // There isn't a way for ByteSink to report errors.
+ buffer_size_ = 0;
+ failed_ = true;
+ return;
+ }
+ buffer_size_ = static_cast<unsigned int>(size);
+ }
+
+ auto to_write = std::min(len, buffer_size_);
+ memcpy(buffer_, bytes, to_write);
+
+ buffer_ = static_cast<char*>(buffer_) + to_write;
+ buffer_size_ -= to_write;
+
+ bytes += to_write;
+ len -= to_write;
+
+ bytes_written_ += to_write;
+ }
+}
+} // namespace zc_sink_internal
+} // namespace io
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_sink.h b/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_sink.h
new file mode 100644
index 00000000000..2b44061f0d9
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_sink.h
@@ -0,0 +1,80 @@
+// 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_UTIL_ZERO_COPY_SINK_H__
+#define GOOGLE_PROTOBUF_UTIL_ZERO_COPY_SINK_H__
+
+#include <cstddef>
+
+#include "google/protobuf/io/zero_copy_stream.h"
+#include "google/protobuf/port.h"
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace io {
+namespace zc_sink_internal {
+
+// Internal helper class, for turning a ZeroCopyOutputStream into a sink.
+class PROTOBUF_EXPORT ZeroCopyStreamByteSink {
+ public:
+ explicit ZeroCopyStreamByteSink(io::ZeroCopyOutputStream* stream)
+ : stream_(stream) {}
+ ZeroCopyStreamByteSink(const ZeroCopyStreamByteSink&) = delete;
+ ZeroCopyStreamByteSink& operator=(const ZeroCopyStreamByteSink&) = delete;
+
+ ~ZeroCopyStreamByteSink() {
+ if (buffer_size_ > 0) {
+ stream_->BackUp(buffer_size_);
+ }
+ }
+
+ void Append(const char* bytes, size_t len);
+ void Write(y_absl::string_view str) { Append(str.data(), str.size()); }
+
+ size_t bytes_written() { return bytes_written_; }
+ bool failed() { return failed_; }
+
+ private:
+ io::ZeroCopyOutputStream* stream_;
+ void* buffer_ = nullptr;
+ size_t buffer_size_ = 0;
+ size_t bytes_written_ = 0;
+ bool failed_ = false;
+};
+} // namespace zc_sink_internal
+} // namespace io
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
+#endif // GOOGLE_PROTOBUF_UTIL_ZERO_COPY_SINK_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream.cc b/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream.cc
index f81555e5549..6622c620c1a 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream.cc
@@ -32,21 +32,110 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/io/zero_copy_stream.h>
+#include "google/protobuf/io/zero_copy_stream.h"
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
+#include <cstring>
+#include <utility>
+
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/cord.h"
+#include "y_absl/strings/cord_buffer.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/types/span.h"
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
namespace io {
+bool ZeroCopyInputStream::ReadCord(y_absl::Cord* cord, int count) {
+ if (count <= 0) return true;
+
+ y_absl::CordBuffer cord_buffer = cord->GetAppendBuffer(count);
+ y_absl::Span<char> out = cord_buffer.available_up_to(count);
+
+ auto FetchNextChunk = [&]() -> y_absl::Span<const char> {
+ const void* buffer;
+ int size;
+ if (!Next(&buffer, &size)) return {};
+
+ if (size > count) {
+ BackUp(size - count);
+ size = count;
+ }
+ return y_absl::MakeConstSpan(static_cast<const char*>(buffer), size);
+ };
+
+ auto AppendFullBuffer = [&]() -> y_absl::Span<char> {
+ cord->Append(std::move(cord_buffer));
+ cord_buffer = y_absl::CordBuffer::CreateWithDefaultLimit(count);
+ return cord_buffer.available_up_to(count);
+ };
+
+ auto CopyBytes = [&](y_absl::Span<char>& dst, y_absl::Span<const char>& src,
+ size_t bytes) {
+ memcpy(dst.data(), src.data(), bytes);
+ dst.remove_prefix(bytes);
+ src.remove_prefix(bytes);
+ count -= bytes;
+ cord_buffer.IncreaseLengthBy(bytes);
+ };
+
+ do {
+ y_absl::Span<const char> in = FetchNextChunk();
+ if (in.empty()) {
+ // Append whatever we have pending so far.
+ cord->Append(std::move(cord_buffer));
+ return false;
+ }
+
+ if (out.empty()) out = AppendFullBuffer();
+
+ while (in.size() > out.size()) {
+ CopyBytes(out, in, out.size());
+ out = AppendFullBuffer();
+ }
+
+ CopyBytes(out, in, in.size());
+ } while (count > 0);
+
+ cord->Append(std::move(cord_buffer));
+ return true;
+}
+
+bool ZeroCopyOutputStream::WriteCord(const y_absl::Cord& cord) {
+ if (cord.empty()) return true;
+
+ void* buffer;
+ int buffer_size = 0;
+ if (!Next(&buffer, &buffer_size)) return false;
+
+ for (y_absl::string_view fragment : cord.Chunks()) {
+ while (fragment.size() > static_cast<size_t>(buffer_size)) {
+ std::memcpy(buffer, fragment.data(), buffer_size);
+
+ fragment.remove_prefix(buffer_size);
+
+ if (!Next(&buffer, &buffer_size)) return false;
+ }
+ std::memcpy(buffer, fragment.data(), fragment.size());
+
+ // Advance the buffer.
+ buffer = static_cast<char*>(buffer) + fragment.size();
+ buffer_size -= static_cast<int>(fragment.size());
+ }
+ BackUp(buffer_size);
+ return true;
+}
+
bool ZeroCopyOutputStream::WriteAliasedRaw(const void* /* data */,
int /* size */) {
- GOOGLE_LOG(FATAL) << "This ZeroCopyOutputStream doesn't support aliasing. "
- "Reaching here usually means a ZeroCopyOutputStream "
- "implementation bug.";
+ Y_ABSL_LOG(FATAL) << "This ZeroCopyOutputStream doesn't support aliasing. "
+ "Reaching here usually means a ZeroCopyOutputStream "
+ "implementation bug.";
return false;
}
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 2041cbf648f..52538760ae0 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
@@ -107,12 +107,13 @@
#ifndef GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_H__
#define GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_H__
-
-#include <google/protobuf/stubs/common.h>
+#include "google/protobuf/stubs/common.h"
+#include "y_absl/strings/cord.h"
+#include "google/protobuf/port.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -127,6 +128,8 @@ class ZeroCopyOutputStream;
class PROTOBUF_EXPORT ZeroCopyInputStream {
public:
ZeroCopyInputStream() {}
+ ZeroCopyInputStream(const ZeroCopyInputStream&) = delete;
+ ZeroCopyInputStream& operator=(const ZeroCopyInputStream&) = delete;
virtual ~ZeroCopyInputStream() {}
// Obtains a chunk of data from the stream.
@@ -154,13 +157,6 @@ 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
@@ -172,18 +168,31 @@ class PROTOBUF_EXPORT ZeroCopyInputStream {
// the same data again before producing new data.
virtual void BackUp(int count) = 0;
- // Skips a number of bytes. Returns false if the end of the stream is
- // reached or some input error occurred. In the end-of-stream case, the
- // stream is advanced to the end of the stream (so ByteCount() will return
- // the total size of the stream).
+ // Skips `count` number of bytes.
+ // Returns true on success, or false if some input error occurred, or `count`
+ // exceeds the end of the stream. This function may skip up to `count - 1`
+ // bytes in case of failure.
+ //
+ // Preconditions:
+ // * `count` is non-negative.
+ //
virtual bool Skip(int count) = 0;
// Returns the total number of bytes read since this object was created.
virtual int64_t ByteCount() const = 0;
+ // Read the next `count` bytes and append it to the given Cord.
+ //
+ // In the case of a read error, the method reads as much data as possible into
+ // the cord before returning false. The default implementation iterates over
+ // the buffers and appends up to `count` bytes of data into `cord` using the
+ // `y_absl::CordBuffer` API.
+ //
+ // Some streams may implement this in a way that avoids copying by sharing or
+ // reference counting existing data managed by the stream implementation.
+ //
+ virtual bool ReadCord(y_absl::Cord* cord, int count);
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ZeroCopyInputStream);
};
// Abstract interface similar to an output stream but designed to minimize
@@ -191,6 +200,8 @@ class PROTOBUF_EXPORT ZeroCopyInputStream {
class PROTOBUF_EXPORT ZeroCopyOutputStream {
public:
ZeroCopyOutputStream() {}
+ ZeroCopyOutputStream(const ZeroCopyOutputStream&) = delete;
+ ZeroCopyOutputStream& operator=(const ZeroCopyOutputStream&) = delete;
virtual ~ZeroCopyOutputStream() {}
// Obtains a buffer into which data can be written. Any data written
@@ -221,6 +232,13 @@ class PROTOBUF_EXPORT ZeroCopyOutputStream {
// than you needed. You don't want to write a bunch of garbage after the
// end of your data, so you use BackUp() to back up.
//
+ // 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
@@ -238,7 +256,7 @@ class PROTOBUF_EXPORT ZeroCopyOutputStream {
// Write a given chunk of data to the output. Some output streams may
// implement this in a way that avoids copying. Check AllowsAliasing() before
- // calling WriteAliasedRaw(). It will GOOGLE_CHECK fail if WriteAliasedRaw() is
+ // calling WriteAliasedRaw(). It will Y_ABSL_CHECK fail if WriteAliasedRaw() is
// called on a stream that does not allow aliasing.
//
// NOTE: It is caller's responsibility to ensure that the chunk of memory
@@ -246,15 +264,21 @@ class PROTOBUF_EXPORT ZeroCopyOutputStream {
virtual bool WriteAliasedRaw(const void* data, int size);
virtual bool AllowsAliasing() const { return false; }
+ // Writes the given Cord to the output.
+ //
+ // The default implementation iterates over all Cord chunks copying all cord
+ // data into the buffer(s) returned by the stream's `Next()` method.
+ //
+ // Some streams may implement this in a way that avoids copying the cord
+ // data by copying and managing a copy of the provided cord instead.
+ virtual bool WriteCord(const y_absl::Cord& cord);
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ZeroCopyOutputStream);
};
} // namespace io
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc b/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc
index 7439a70d611..ecd23808070 100644
--- a/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc
@@ -43,11 +43,11 @@
#include <algorithm>
#include <iostream>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/io/io_win32.h>
-#include <google/protobuf/io/zero_copy_stream_impl.h>
-#include <google/protobuf/stubs/stl_util.h>
+#include "google/protobuf/stubs/common.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "google/protobuf/io/io_win32.h"
+#include "google/protobuf/io/zero_copy_stream_impl.h"
namespace google {
@@ -114,13 +114,13 @@ FileInputStream::CopyingFileInputStream::CopyingFileInputStream(
FileInputStream::CopyingFileInputStream::~CopyingFileInputStream() {
if (close_on_delete_) {
if (!Close()) {
- GOOGLE_LOG(ERROR) << "close() failed: " << strerror(errno_);
+ Y_ABSL_LOG(ERROR) << "close() failed: " << strerror(errno_);
}
}
}
bool FileInputStream::CopyingFileInputStream::Close() {
- GOOGLE_CHECK(!is_closed_);
+ Y_ABSL_CHECK(!is_closed_);
is_closed_ = true;
if (close_no_eintr(file_) != 0) {
@@ -135,7 +135,7 @@ bool FileInputStream::CopyingFileInputStream::Close() {
}
int FileInputStream::CopyingFileInputStream::Read(void* buffer, int size) {
- GOOGLE_CHECK(!is_closed_);
+ Y_ABSL_CHECK(!is_closed_);
int result;
do {
@@ -151,7 +151,7 @@ int FileInputStream::CopyingFileInputStream::Read(void* buffer, int size) {
}
int FileInputStream::CopyingFileInputStream::Skip(int count) {
- GOOGLE_CHECK(!is_closed_);
+ Y_ABSL_CHECK(!is_closed_);
if (!previous_seek_failed_ && lseek(file_, count, SEEK_CUR) != (off_t)-1) {
// Seek succeeded.
@@ -170,8 +170,8 @@ int FileInputStream::CopyingFileInputStream::Skip(int count) {
// ===================================================================
-FileOutputStream::FileOutputStream(int file_descriptor, int /*block_size*/)
- : CopyingOutputStreamAdaptor(&copying_output_),
+FileOutputStream::FileOutputStream(int file_descriptor, int block_size)
+ : CopyingOutputStreamAdaptor(&copying_output_, block_size),
copying_output_(file_descriptor) {}
bool FileOutputStream::Close() {
@@ -191,13 +191,13 @@ FileOutputStream::~FileOutputStream() { Flush(); }
FileOutputStream::CopyingFileOutputStream::~CopyingFileOutputStream() {
if (close_on_delete_) {
if (!Close()) {
- GOOGLE_LOG(ERROR) << "close() failed: " << strerror(errno_);
+ Y_ABSL_LOG(ERROR) << "close() failed: " << strerror(errno_);
}
}
}
bool FileOutputStream::CopyingFileOutputStream::Close() {
- GOOGLE_CHECK(!is_closed_);
+ Y_ABSL_CHECK(!is_closed_);
is_closed_ = true;
if (close_no_eintr(file_) != 0) {
@@ -213,7 +213,7 @@ bool FileOutputStream::CopyingFileOutputStream::Close() {
bool FileOutputStream::CopyingFileOutputStream::Write(const void* buffer,
int size) {
- GOOGLE_CHECK(!is_closed_);
+ Y_ABSL_CHECK(!is_closed_);
int total_written = 0;
const uint8_t* buffer_base = reinterpret_cast<const uint8_t*>(buffer);
@@ -330,7 +330,7 @@ void ConcatenatingInputStream::BackUp(int count) {
if (stream_count_ > 0) {
streams_[0]->BackUp(count);
} else {
- GOOGLE_LOG(DFATAL) << "Can't BackUp() after failed Next().";
+ Y_ABSL_DLOG(FATAL) << "Can't BackUp() after failed Next().";
}
}
@@ -344,7 +344,7 @@ bool ConcatenatingInputStream::Skip(int count) {
// Hit the end of the stream. Figure out how many more bytes we still have
// to skip.
arc_i64 final_byte_count = streams_[0]->ByteCount();
- GOOGLE_DCHECK_LT(final_byte_count, target_byte_count);
+ Y_ABSL_DCHECK_LT(final_byte_count, target_byte_count);
count = target_byte_count - final_byte_count;
// That stream is done. Advance to the next one.
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 6ec43b2ee2a..5fed05de1c4 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
@@ -40,16 +40,15 @@
#ifndef GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_H__
#define GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_H__
-
#include <iosfwd>
#include <string>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/io/zero_copy_stream.h>
-#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
+#include "google/protobuf/stubs/common.h"
+#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>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -63,14 +62,15 @@ 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 PROTOBUF_FUTURE_FINAL
- : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT FileInputStream 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
// should be read and returned with each call to Next(). Otherwise,
// a reasonable default is used.
explicit FileInputStream(int file_descriptor, int block_size = -1);
+ FileInputStream(const FileInputStream&) = delete;
+ FileInputStream& operator=(const FileInputStream&) = delete;
// Flushes any buffers and closes the underlying file. Returns false if
// an error occurs during the process; use GetErrno() to examine the error.
@@ -97,10 +97,12 @@ class PROTOBUF_EXPORT FileInputStream PROTOBUF_FUTURE_FINAL
int64_t ByteCount() const override;
private:
- class PROTOBUF_EXPORT CopyingFileInputStream PROTOBUF_FUTURE_FINAL
+ class PROTOBUF_EXPORT CopyingFileInputStream final
: public CopyingInputStream {
public:
CopyingFileInputStream(int file_descriptor);
+ CopyingFileInputStream(const CopyingFileInputStream&) = delete;
+ CopyingFileInputStream& operator=(const CopyingFileInputStream&) = delete;
~CopyingFileInputStream() override;
bool Close();
@@ -123,14 +125,10 @@ class PROTOBUF_EXPORT FileInputStream PROTOBUF_FUTURE_FINAL
// Did we try to seek once and fail? If so, we assume this file descriptor
// doesn't support seeking and won't try again.
bool previous_seek_failed_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingFileInputStream);
};
CopyingFileInputStream copying_input_;
CopyingInputStreamAdaptor impl_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileInputStream);
};
// ===================================================================
@@ -142,7 +140,7 @@ class PROTOBUF_EXPORT FileInputStream PROTOBUF_FUTURE_FINAL
// 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 PROTOBUF_FUTURE_FINAL
+class PROTOBUF_EXPORT FileOutputStream final
: public CopyingOutputStreamAdaptor {
public:
// Creates a stream that writes to the given Unix file descriptor.
@@ -150,6 +148,8 @@ class PROTOBUF_EXPORT FileOutputStream PROTOBUF_FUTURE_FINAL
// that should be returned by Next(). Otherwise, a reasonable default
// is used.
explicit FileOutputStream(int file_descriptor, int block_size = -1);
+ FileOutputStream(const FileOutputStream&) = delete;
+ FileOutputStream& operator=(const FileOutputStream&) = delete;
~FileOutputStream() override;
@@ -172,10 +172,12 @@ class PROTOBUF_EXPORT FileOutputStream PROTOBUF_FUTURE_FINAL
int GetErrno() const { return copying_output_.GetErrno(); }
private:
- class PROTOBUF_EXPORT CopyingFileOutputStream PROTOBUF_FUTURE_FINAL
+ class PROTOBUF_EXPORT CopyingFileOutputStream final
: public CopyingOutputStream {
public:
CopyingFileOutputStream(int file_descriptor);
+ CopyingFileOutputStream(const CopyingFileOutputStream&) = delete;
+ CopyingFileOutputStream& operator=(const CopyingFileOutputStream&) = delete;
~CopyingFileOutputStream() override;
bool Close();
@@ -193,13 +195,9 @@ class PROTOBUF_EXPORT FileOutputStream PROTOBUF_FUTURE_FINAL
// The errno of the I/O error, if one has occurred. Otherwise, zero.
int errno_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingFileOutputStream);
};
CopyingFileOutputStream copying_output_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileOutputStream);
};
// ===================================================================
@@ -208,14 +206,15 @@ class PROTOBUF_EXPORT FileOutputStream PROTOBUF_FUTURE_FINAL
//
// Note that for reading files (or anything represented by a file descriptor),
// FileInputStream is more efficient.
-class PROTOBUF_EXPORT IstreamInputStream PROTOBUF_FUTURE_FINAL
- : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT IstreamInputStream 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
// should be read and returned with each call to Next(). Otherwise,
// a reasonable default is used.
explicit IstreamInputStream(std::istream* stream, int block_size = -1);
+ IstreamInputStream(const IstreamInputStream&) = delete;
+ IstreamInputStream& operator=(const IstreamInputStream&) = delete;
// implements ZeroCopyInputStream ----------------------------------
bool Next(const void** data, int* size) override;
@@ -224,10 +223,13 @@ class PROTOBUF_EXPORT IstreamInputStream PROTOBUF_FUTURE_FINAL
int64_t ByteCount() const override;
private:
- class PROTOBUF_EXPORT CopyingIstreamInputStream PROTOBUF_FUTURE_FINAL
+ class PROTOBUF_EXPORT CopyingIstreamInputStream final
: public CopyingInputStream {
public:
CopyingIstreamInputStream(std::istream* input);
+ CopyingIstreamInputStream(const CopyingIstreamInputStream&) = delete;
+ CopyingIstreamInputStream& operator=(const CopyingIstreamInputStream&) =
+ delete;
~CopyingIstreamInputStream() override;
// implements CopyingInputStream ---------------------------------
@@ -237,14 +239,10 @@ class PROTOBUF_EXPORT IstreamInputStream PROTOBUF_FUTURE_FINAL
private:
// The stream.
std::istream* input_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingIstreamInputStream);
};
CopyingIstreamInputStream copying_input_;
CopyingInputStreamAdaptor impl_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(IstreamInputStream);
};
// ===================================================================
@@ -253,14 +251,15 @@ class PROTOBUF_EXPORT IstreamInputStream PROTOBUF_FUTURE_FINAL
//
// Note that for writing files (or anything represented by a file descriptor),
// FileOutputStream is more efficient.
-class PROTOBUF_EXPORT OstreamOutputStream PROTOBUF_FUTURE_FINAL
- : public ZeroCopyOutputStream {
+class PROTOBUF_EXPORT OstreamOutputStream 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
// that should be returned by Next(). Otherwise, a reasonable default
// is used.
explicit OstreamOutputStream(std::ostream* stream, int block_size = -1);
+ OstreamOutputStream(const OstreamOutputStream&) = delete;
+ OstreamOutputStream& operator=(const OstreamOutputStream&) = delete;
~OstreamOutputStream() override;
// implements ZeroCopyOutputStream ---------------------------------
@@ -269,10 +268,13 @@ class PROTOBUF_EXPORT OstreamOutputStream PROTOBUF_FUTURE_FINAL
int64_t ByteCount() const override;
private:
- class PROTOBUF_EXPORT CopyingOstreamOutputStream PROTOBUF_FUTURE_FINAL
+ class PROTOBUF_EXPORT CopyingOstreamOutputStream final
: public CopyingOutputStream {
public:
CopyingOstreamOutputStream(std::ostream* output);
+ CopyingOstreamOutputStream(const CopyingOstreamOutputStream&) = delete;
+ CopyingOstreamOutputStream& operator=(const CopyingOstreamOutputStream&) =
+ delete;
~CopyingOstreamOutputStream() override;
// implements CopyingOutputStream --------------------------------
@@ -281,14 +283,10 @@ class PROTOBUF_EXPORT OstreamOutputStream PROTOBUF_FUTURE_FINAL
private:
// The stream.
std::ostream* output_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingOstreamOutputStream);
};
CopyingOstreamOutputStream copying_output_;
CopyingOutputStreamAdaptor impl_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(OstreamOutputStream);
};
// ===================================================================
@@ -300,12 +298,14 @@ class PROTOBUF_EXPORT OstreamOutputStream PROTOBUF_FUTURE_FINAL
// 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 PROTOBUF_FUTURE_FINAL
+class PROTOBUF_EXPORT ConcatenatingInputStream final
: public ZeroCopyInputStream {
public:
// All streams passed in as well as the array itself must remain valid
// until the ConcatenatingInputStream is destroyed.
ConcatenatingInputStream(ZeroCopyInputStream* const streams[], int count);
+ ConcatenatingInputStream(const ConcatenatingInputStream&) = delete;
+ ConcatenatingInputStream& operator=(const ConcatenatingInputStream&) = delete;
~ConcatenatingInputStream() override = default;
// implements ZeroCopyInputStream ----------------------------------
@@ -321,8 +321,6 @@ class PROTOBUF_EXPORT ConcatenatingInputStream PROTOBUF_FUTURE_FINAL
ZeroCopyInputStream* const* streams_;
int stream_count_;
arc_i64 bytes_retired_; // Bytes read from previous streams.
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ConcatenatingInputStream);
};
// ===================================================================
@@ -331,6 +329,6 @@ class PROTOBUF_EXPORT ConcatenatingInputStream PROTOBUF_FUTURE_FINAL
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_H__
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 29cb50807cb..6d7263af5a2 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
@@ -32,15 +32,20 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
+#include "google/protobuf/io/zero_copy_stream_impl_lite.h"
#include <algorithm>
#include <limits>
+#include <utility>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/casts.h>
-#include <google/protobuf/stubs/stl_util.h>
+#include "google/protobuf/stubs/common.h"
+#include "y_absl/base/casts.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/strings/cord.h"
+#include "y_absl/strings/internal/resize_uninitialized.h"
+
+// Must be included last
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -77,16 +82,16 @@ bool ArrayInputStream::Next(const void** data, int* size) {
}
void ArrayInputStream::BackUp(int count) {
- GOOGLE_CHECK_GT(last_returned_size_, 0)
+ Y_ABSL_CHECK_GT(last_returned_size_, 0)
<< "BackUp() can only be called after a successful Next().";
- GOOGLE_CHECK_LE(count, last_returned_size_);
- GOOGLE_CHECK_GE(count, 0);
+ Y_ABSL_CHECK_LE(count, last_returned_size_);
+ Y_ABSL_CHECK_GE(count, 0);
position_ -= count;
last_returned_size_ = 0; // Don't let caller back up further.
}
bool ArrayInputStream::Skip(int count) {
- GOOGLE_CHECK_GE(count, 0);
+ Y_ABSL_CHECK_GE(count, 0);
last_returned_size_ = 0; // Don't let caller back up.
if (count > size_ - position_) {
position_ = size_;
@@ -124,9 +129,9 @@ bool ArrayOutputStream::Next(void** data, int* size) {
}
void ArrayOutputStream::BackUp(int count) {
- GOOGLE_CHECK_LE(count, last_returned_size_)
+ Y_ABSL_CHECK_LE(count, last_returned_size_)
<< "BackUp() can not exceed the size of the last Next() call.";
- GOOGLE_CHECK_GE(count, 0);
+ Y_ABSL_CHECK_GE(count, 0);
position_ -= count;
last_returned_size_ -= count;
}
@@ -138,7 +143,7 @@ int64_t ArrayOutputStream::ByteCount() const { return position_; }
StringOutputStream::StringOutputStream(TProtoStringType* target) : target_(target) {}
bool StringOutputStream::Next(void** data, int* size) {
- GOOGLE_CHECK(target_ != NULL);
+ Y_ABSL_CHECK(target_ != NULL);
size_t old_size = target_->size();
// Grow the string.
@@ -154,7 +159,7 @@ bool StringOutputStream::Next(void** data, int* size) {
// Avoid integer overflow in returned '*size'.
new_size = std::min(new_size, old_size + std::numeric_limits<int>::max());
// Increase the size, also make sure that it is at least kMinimumSize.
- STLStringResizeUninitialized(
+ y_absl::strings_internal::STLStringResizeUninitialized(
target_,
std::max(new_size,
kMinimumSize + 0)); // "+ 0" works around GCC4 weirdness.
@@ -165,14 +170,14 @@ bool StringOutputStream::Next(void** data, int* size) {
}
void StringOutputStream::BackUp(int count) {
- GOOGLE_CHECK_GE(count, 0);
- GOOGLE_CHECK(target_ != NULL);
- GOOGLE_CHECK_LE(static_cast<size_t>(count), target_->size());
+ Y_ABSL_CHECK_GE(count, 0);
+ Y_ABSL_CHECK(target_ != NULL);
+ Y_ABSL_CHECK_LE(static_cast<size_t>(count), target_->size());
target_->resize(target_->size() - count);
}
int64_t StringOutputStream::ByteCount() const {
- GOOGLE_CHECK(target_ != NULL);
+ Y_ABSL_CHECK(target_ != NULL);
return target_->size();
}
@@ -183,7 +188,7 @@ int CopyingInputStream::Skip(int count) {
int skipped = 0;
while (skipped < count) {
int bytes = Read(junk, std::min(count - skipped,
- implicit_cast<int>(sizeof(junk))));
+ y_absl::implicit_cast<int>(sizeof(junk))));
if (bytes <= 0) {
// EOF or read error.
return skipped;
@@ -244,18 +249,18 @@ bool CopyingInputStreamAdaptor::Next(const void** data, int* size) {
}
void CopyingInputStreamAdaptor::BackUp(int count) {
- GOOGLE_CHECK(backup_bytes_ == 0 && buffer_.get() != NULL)
+ Y_ABSL_CHECK(backup_bytes_ == 0 && buffer_.get() != NULL)
<< " BackUp() can only be called after Next().";
- GOOGLE_CHECK_LE(count, buffer_used_)
+ Y_ABSL_CHECK_LE(count, buffer_used_)
<< " Can't back up over more bytes than were returned by the last call"
" to Next().";
- GOOGLE_CHECK_GE(count, 0) << " Parameter to BackUp() can't be negative.";
+ Y_ABSL_CHECK_GE(count, 0) << " Parameter to BackUp() can't be negative.";
backup_bytes_ = count;
}
bool CopyingInputStreamAdaptor::Skip(int count) {
- GOOGLE_CHECK_GE(count, 0);
+ Y_ABSL_CHECK_GE(count, 0);
if (failed_) {
// Already failed on a previous read.
@@ -288,7 +293,7 @@ void CopyingInputStreamAdaptor::AllocateBufferIfNeeded() {
}
void CopyingInputStreamAdaptor::FreeBuffer() {
- GOOGLE_CHECK_EQ(backup_bytes_, 0);
+ Y_ABSL_CHECK_EQ(backup_bytes_, 0);
buffer_used_ = 0;
buffer_.reset();
}
@@ -331,10 +336,10 @@ void CopyingOutputStreamAdaptor::BackUp(int count) {
Flush();
return;
}
- GOOGLE_CHECK_GE(count, 0);
- GOOGLE_CHECK_EQ(buffer_used_, buffer_size_)
+ Y_ABSL_CHECK_GE(count, 0);
+ Y_ABSL_CHECK_EQ(buffer_used_, buffer_size_)
<< " BackUp() can only be called after Next().";
- GOOGLE_CHECK_LE(count, buffer_used_)
+ Y_ABSL_CHECK_LE(count, buffer_used_)
<< " Can't back up over more bytes than were returned by the last call"
" to Next().";
@@ -350,7 +355,7 @@ bool CopyingOutputStreamAdaptor::WriteAliasedRaw(const void* data, int size) {
if (!Flush() || !copying_stream_->Write(data, size)) {
return false;
}
- GOOGLE_DCHECK_EQ(buffer_used_, 0);
+ Y_ABSL_DCHECK_EQ(buffer_used_, 0);
position_ += size;
return true;
}
@@ -375,6 +380,14 @@ bool CopyingOutputStreamAdaptor::WriteAliasedRaw(const void* data, int size) {
return true;
}
+bool CopyingOutputStreamAdaptor::WriteCord(const y_absl::Cord& cord) {
+ for (y_absl::string_view chunk : cord.Chunks()) {
+ if (!WriteAliasedRaw(chunk.data(), chunk.size())) {
+ return false;
+ }
+ }
+ return true;
+}
bool CopyingOutputStreamAdaptor::WriteBuffer() {
if (failed_) {
@@ -462,8 +475,233 @@ int64_t LimitingInputStream::ByteCount() const {
}
}
+bool LimitingInputStream::ReadCord(y_absl::Cord* cord, int count) {
+ if (count <= 0) return true;
+ if (count <= limit_) {
+ if (!input_->ReadCord(cord, count)) return false;
+ limit_ -= count;
+ return true;
+ }
+ input_->ReadCord(cord, limit_);
+ limit_ = 0;
+ return false;
+}
+
// ===================================================================
+CordInputStream::CordInputStream(const y_absl::Cord* cord)
+ : it_(cord->char_begin()),
+ length_(cord->size()),
+ bytes_remaining_(length_) {
+ LoadChunkData();
+}
+
+bool CordInputStream::LoadChunkData() {
+ if (bytes_remaining_ != 0) {
+ y_absl::string_view sv = y_absl::Cord::ChunkRemaining(it_);
+ data_ = sv.data();
+ size_ = available_ = sv.size();
+ return true;
+ }
+ size_ = available_ = 0;
+ return false;
+}
+
+bool CordInputStream::NextChunk(size_t skip) {
+ // `size_ == 0` indicates we're at EOF.
+ if (size_ == 0) return false;
+
+ // The caller consumed 'size_ - available_' bytes that are not yet accounted
+ // for in the iterator position to get to the start of the next chunk.
+ const size_t distance = size_ - available_ + skip;
+ y_absl::Cord::Advance(&it_, distance);
+ bytes_remaining_ -= skip;
+
+ return LoadChunkData();
+}
+
+bool CordInputStream::Next(const void** data, int* size) {
+ if (available_ > 0 || NextChunk(0)) {
+ *data = data_ + size_ - available_;
+ *size = available_;
+ bytes_remaining_ -= available_;
+ available_ = 0;
+ return true;
+ }
+ return false;
+}
+
+void CordInputStream::BackUp(int count) {
+ // Backup is only allowed on last returned chunk from `Next()`.
+ Y_ABSL_CHECK_LE(static_cast<size_t>(count), size_ - available_);
+
+ available_ += count;
+ bytes_remaining_ += count;
+}
+
+bool CordInputStream::Skip(int count) {
+ // Short circuit if we stay inside the current chunk.
+ if (static_cast<size_t>(count) <= available_) {
+ available_ -= count;
+ bytes_remaining_ -= count;
+ return true;
+ }
+
+ // Sanity check the skip count.
+ if (static_cast<size_t>(count) <= bytes_remaining_) {
+ // Skip to end: do not return EOF condition: skipping into EOF is ok.
+ NextChunk(count);
+ return true;
+ }
+ NextChunk(bytes_remaining_);
+ return false;
+}
+
+int64_t CordInputStream::ByteCount() const {
+ return length_ - bytes_remaining_;
+}
+
+bool CordInputStream::ReadCord(y_absl::Cord* cord, int count) {
+ // Advance the iterator to the current position
+ const size_t used = size_ - available_;
+ y_absl::Cord::Advance(&it_, used);
+
+ // Read the cord, adjusting the iterator position.
+ // Make sure to cap at available bytes to avoid hard crashes.
+ const size_t n = std::min(static_cast<size_t>(count), bytes_remaining_);
+ cord->Append(y_absl::Cord::AdvanceAndRead(&it_, n));
+
+ // Update current chunk data.
+ bytes_remaining_ -= n;
+ LoadChunkData();
+
+ return n == static_cast<size_t>(count);
+}
+
+
+CordOutputStream::CordOutputStream(size_t size_hint) : size_hint_(size_hint) {}
+
+CordOutputStream::CordOutputStream(y_absl::Cord cord, size_t size_hint)
+ : cord_(std::move(cord)),
+ size_hint_(size_hint),
+ state_(cord_.empty() ? State::kEmpty : State::kSteal) {}
+
+CordOutputStream::CordOutputStream(y_absl::CordBuffer buffer, size_t size_hint)
+ : size_hint_(size_hint),
+ state_(buffer.length() < buffer.capacity() ? State::kPartial
+ : State::kFull),
+ buffer_(std::move(buffer)) {}
+
+CordOutputStream::CordOutputStream(y_absl::Cord cord, y_absl::CordBuffer buffer,
+ size_t size_hint)
+ : cord_(std::move(cord)),
+ size_hint_(size_hint),
+ state_(buffer.length() < buffer.capacity() ? State::kPartial
+ : State::kFull),
+ buffer_(std::move(buffer)) {}
+
+bool CordOutputStream::Next(void** data, int* size) {
+ // Use 128 bytes as a minimum buffer size if we don't have any application
+ // provided size hints. This number is picked somewhat arbitrary as 'small
+ // enough to avoid excessive waste on small data, and large enough to not
+ // waste CPU and memory on tiny buffer overhead'.
+ // It is worth noting that absent size hints, we pick 'current size' as
+ // the default buffer size (capped at max flat size), which means we quickly
+ // double the buffer size. This is in contrast to `Cord::Append()` functions
+ // accepting strings which use a conservative 10% growth.
+ static const size_t kMinBlockSize = 128;
+
+ size_t desired_size, max_size;
+ const size_t cord_size = cord_.size() + buffer_.length();
+ if (size_hint_ > cord_size) {
+ // Try to hit size_hint_ exactly so the caller doesn't receive a larger
+ // buffer than indicated, requiring a non-zero call to BackUp() to undo
+ // the buffer capacity we returned beyond the indicated size hint.
+ desired_size = size_hint_ - cord_size;
+ max_size = desired_size;
+ } else {
+ // We're past the size hint or don't have a size hint. Try to allocate a
+ // block as large as what we have so far, or at least kMinBlockSize bytes.
+ // CordBuffer will truncate this to an appropriate size if it is too large.
+ desired_size = std::max(cord_size, kMinBlockSize);
+ max_size = std::numeric_limits<size_t>::max();
+ }
+
+ switch (state_) {
+ case State::kSteal:
+ // Steal last buffer from Cord if available.
+ assert(buffer_.length() == 0);
+ buffer_ = cord_.GetAppendBuffer(desired_size);
+ break;
+ case State::kPartial:
+ // Use existing capacity in 'buffer_`
+ assert(buffer_.length() < buffer_.capacity());
+ break;
+ case State::kFull:
+ assert(buffer_.length() > 0);
+ cord_.Append(std::move(buffer_));
+ PROTOBUF_FALLTHROUGH_INTENDED;
+ case State::kEmpty:
+ assert(buffer_.length() == 0);
+ buffer_ = y_absl::CordBuffer::CreateWithDefaultLimit(desired_size);
+ break;
+ }
+
+ // Get all available capacity from the buffer.
+ y_absl::Span<char> span = buffer_.available();
+ assert(!span.empty());
+ *data = span.data();
+
+ // Only hand out up to 'max_size', which is limited if there is a size hint
+ // specified, and we have more available than the size hint.
+ if (span.size() > max_size) {
+ *size = static_cast<int>(max_size);
+ buffer_.IncreaseLengthBy(max_size);
+ state_ = State::kPartial;
+ } else {
+ *size = static_cast<int>(span.size());
+ buffer_.IncreaseLengthBy(span.size());
+ state_ = State::kFull;
+ }
+
+ return true;
+}
+
+void CordOutputStream::BackUp(int count) {
+ // Check if something to do, else state remains unchanged.
+ assert(0 <= count && count <= ByteCount());
+ if (count == 0) return;
+
+ // Backup() is not supposed to backup beyond last Next() call
+ const int buffer_length = static_cast<int>(buffer_.length());
+ assert(count <= buffer_length);
+ if (count <= buffer_length) {
+ buffer_.SetLength(static_cast<size_t>(buffer_length - count));
+ state_ = State::kPartial;
+ } else {
+ buffer_ = {};
+ cord_.RemoveSuffix(static_cast<size_t>(count));
+ state_ = State::kSteal;
+ }
+}
+
+int64_t CordOutputStream::ByteCount() const {
+ return static_cast<arc_i64>(cord_.size() + buffer_.length());
+}
+
+bool CordOutputStream::WriteCord(const y_absl::Cord& cord) {
+ cord_.Append(std::move(buffer_));
+ cord_.Append(cord);
+ state_ = State::kSteal; // Attempt to utilize existing capacity in `cord'
+ return true;
+}
+
+y_absl::Cord CordOutputStream::Consume() {
+ cord_.Append(std::move(buffer_));
+ state_ = State::kEmpty;
+ return std::move(cord_);
+}
+
} // namespace io
} // namespace protobuf
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 aff4c5c603d..bbdebf92473 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
@@ -44,19 +44,22 @@
#ifndef GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__
#define GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__
-
#include <iosfwd>
#include <memory>
#include <string>
+#include <utility>
-#include <google/protobuf/stubs/callback.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/io/zero_copy_stream.h>
-#include <google/protobuf/stubs/stl_util.h>
+#include "google/protobuf/stubs/callback.h"
+#include "google/protobuf/stubs/common.h"
+#include "y_absl/base/attributes.h"
+#include "y_absl/strings/cord.h"
+#include "y_absl/strings/cord_buffer.h"
+#include "google/protobuf/io/zero_copy_stream.h"
+#include "google/protobuf/port.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -65,8 +68,7 @@ namespace io {
// ===================================================================
// A ZeroCopyInputStream backed by an in-memory array of bytes.
-class PROTOBUF_EXPORT ArrayInputStream PROTOBUF_FUTURE_FINAL
- : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT ArrayInputStream 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
@@ -78,6 +80,10 @@ class PROTOBUF_EXPORT ArrayInputStream PROTOBUF_FUTURE_FINAL
ArrayInputStream(const void* data, int size, int block_size = -1);
~ArrayInputStream() override = default;
+ // `ArrayInputStream` is neither copiable nor assignable
+ ArrayInputStream(const ArrayInputStream&) = delete;
+ ArrayInputStream& operator=(const ArrayInputStream&) = delete;
+
// implements ZeroCopyInputStream ----------------------------------
bool Next(const void** data, int* size) override;
void BackUp(int count) override;
@@ -93,15 +99,12 @@ class PROTOBUF_EXPORT ArrayInputStream PROTOBUF_FUTURE_FINAL
int position_;
int last_returned_size_; // How many bytes we returned last time Next()
// was called (used for error checking only).
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ArrayInputStream);
};
// ===================================================================
// A ZeroCopyOutputStream backed by an in-memory array of bytes.
-class PROTOBUF_EXPORT ArrayOutputStream PROTOBUF_FUTURE_FINAL
- : public ZeroCopyOutputStream {
+class PROTOBUF_EXPORT ArrayOutputStream 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
@@ -113,6 +116,10 @@ class PROTOBUF_EXPORT ArrayOutputStream PROTOBUF_FUTURE_FINAL
ArrayOutputStream(void* data, int size, int block_size = -1);
~ArrayOutputStream() override = default;
+ // `ArrayOutputStream` is neither copiable nor assignable
+ ArrayOutputStream(const ArrayOutputStream&) = delete;
+ ArrayOutputStream& operator=(const ArrayOutputStream&) = delete;
+
// implements ZeroCopyOutputStream ---------------------------------
bool Next(void** data, int* size) override;
void BackUp(int count) override;
@@ -126,15 +133,12 @@ class PROTOBUF_EXPORT ArrayOutputStream PROTOBUF_FUTURE_FINAL
int position_;
int last_returned_size_; // How many bytes we returned last time Next()
// was called (used for error checking only).
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ArrayOutputStream);
};
// ===================================================================
// A ZeroCopyOutputStream which appends bytes to a string.
-class PROTOBUF_EXPORT StringOutputStream PROTOBUF_FUTURE_FINAL
- : public ZeroCopyOutputStream {
+class PROTOBUF_EXPORT StringOutputStream 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
@@ -148,6 +152,10 @@ class PROTOBUF_EXPORT StringOutputStream PROTOBUF_FUTURE_FINAL
explicit StringOutputStream(TProtoStringType* target);
~StringOutputStream() override = default;
+ // `StringOutputStream` is neither copiable nor assignable
+ StringOutputStream(const StringOutputStream&) = delete;
+ StringOutputStream& operator=(const StringOutputStream&) = delete;
+
// implements ZeroCopyOutputStream ---------------------------------
bool Next(void** data, int* size) override;
void BackUp(int count) override;
@@ -157,8 +165,6 @@ class PROTOBUF_EXPORT StringOutputStream PROTOBUF_FUTURE_FINAL
static constexpr size_t kMinimumSize = 16;
TProtoStringType* target_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringOutputStream);
};
// Note: There is no StringInputStream. Instead, just create an
@@ -215,6 +221,10 @@ class PROTOBUF_EXPORT CopyingInputStreamAdaptor : public ZeroCopyInputStream {
int block_size = -1);
~CopyingInputStreamAdaptor() override;
+ // `CopyingInputStreamAdaptor` is neither copiable nor assignable
+ CopyingInputStreamAdaptor(const CopyingInputStreamAdaptor&) = delete;
+ CopyingInputStreamAdaptor& operator=(const CopyingInputStreamAdaptor&) = delete;
+
// Call SetOwnsCopyingStream(true) to tell the CopyingInputStreamAdaptor to
// delete the underlying CopyingInputStream when it is destroyed.
void SetOwnsCopyingStream(bool value) { owns_copying_stream_ = value; }
@@ -255,8 +265,6 @@ class PROTOBUF_EXPORT CopyingInputStreamAdaptor : public ZeroCopyInputStream {
// BackUp(). These need to be returned again.
// 0 <= backup_bytes_ <= buffer_used_
int backup_bytes_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingInputStreamAdaptor);
};
// ===================================================================
@@ -298,6 +306,10 @@ class PROTOBUF_EXPORT CopyingOutputStreamAdaptor : public ZeroCopyOutputStream {
int block_size = -1);
~CopyingOutputStreamAdaptor() override;
+ // `CopyingOutputStreamAdaptor` is neither copiable nor assignable
+ CopyingOutputStreamAdaptor(const CopyingOutputStreamAdaptor&) = delete;
+ CopyingOutputStreamAdaptor& operator=(const CopyingOutputStreamAdaptor&) = delete;
+
// Writes all pending data to the underlying stream. Returns false if a
// write error occurred on the underlying stream. (The underlying
// stream itself is not necessarily flushed.)
@@ -313,6 +325,7 @@ class PROTOBUF_EXPORT CopyingOutputStreamAdaptor : public ZeroCopyOutputStream {
int64_t ByteCount() const override;
bool WriteAliasedRaw(const void* data, int size) override;
bool AllowsAliasing() const override { return true; }
+ bool WriteCord(const y_absl::Cord& cord) override;
private:
// Write the current buffer, if it is present.
@@ -342,56 +355,170 @@ class PROTOBUF_EXPORT CopyingOutputStreamAdaptor : public ZeroCopyOutputStream {
// returned by Next()). When BackUp() is called, we just reduce this.
// 0 <= buffer_used_ <= buffer_size_.
int buffer_used_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingOutputStreamAdaptor);
};
// ===================================================================
// A ZeroCopyInputStream which wraps some other stream and limits it to
// a particular byte count.
-class PROTOBUF_EXPORT LimitingInputStream PROTOBUF_FUTURE_FINAL
- : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT LimitingInputStream final : public ZeroCopyInputStream {
public:
LimitingInputStream(ZeroCopyInputStream* input, arc_i64 limit);
~LimitingInputStream() override;
+ // `LimitingInputStream` is neither copiable nor assignable
+ LimitingInputStream(const LimitingInputStream&) = delete;
+ LimitingInputStream& operator=(const LimitingInputStream&) = delete;
+
// implements ZeroCopyInputStream ----------------------------------
bool Next(const void** data, int* size) override;
void BackUp(int count) override;
bool Skip(int count) override;
int64_t ByteCount() const override;
+ bool ReadCord(y_absl::Cord* cord, int count) override;
private:
ZeroCopyInputStream* input_;
arc_i64 limit_; // Decreases as we go, becomes negative if we overshoot.
arc_i64 prior_bytes_read_; // Bytes read on underlying stream at construction
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(LimitingInputStream);
};
+// ===================================================================
+
+// A ZeroCopyInputStream backed by a Cord. This stream implements ReadCord()
+// in a way that can share memory between the source and destination cords
+// rather than copying.
+class PROTOBUF_EXPORT CordInputStream final : public ZeroCopyInputStream {
+ public:
+ // Creates an InputStream that reads from the given Cord. `cord` must
+ // not be null and must outlive this CordInputStream instance. `cord` must
+ // not be modified while this instance is actively being used: any change
+ // to `cord` will lead to undefined behavior on any subsequent call into
+ // this instance.
+ explicit CordInputStream(
+ const y_absl::Cord* cord Y_ABSL_ATTRIBUTE_LIFETIME_BOUND);
+
+
+ // `CordInputStream` is neither copiable nor assignable
+ CordInputStream(const CordInputStream&) = delete;
+ CordInputStream& operator=(const CordInputStream&) = delete;
+
+ // implements ZeroCopyInputStream ----------------------------------
+ bool Next(const void** data, int* size) override;
+ void BackUp(int count) override;
+ bool Skip(int count) override;
+ int64_t ByteCount() const override;
+ bool ReadCord(y_absl::Cord* cord, int count) override;
+
+
+ private:
+ // Moves `it_` to the next available chunk skipping `skip` extra bytes
+ // and updates the chunk data pointers.
+ bool NextChunk(size_t skip);
+
+ // Updates the current chunk data context `data_`, `size_` and `available_`.
+ // If `bytes_remaining_` is zero, sets `size_` and `available_` to zero.
+ // Returns true if more data is available, false otherwise.
+ bool LoadChunkData();
+
+ y_absl::Cord::CharIterator it_;
+ size_t length_;
+ size_t bytes_remaining_;
+ const char* data_;
+ size_t size_;
+ size_t available_;
+};
// ===================================================================
-// mutable_string_data() and as_string_data() are workarounds to improve
-// the performance of writing new data to an existing string. Unfortunately
-// the methods provided by the string class are suboptimal, and using memcpy()
-// is mildly annoying because it requires its pointer args to be non-NULL even
-// if we ask it to copy 0 bytes. Furthermore, string_as_array() has the
-// property that it always returns NULL if its arg is the empty string, exactly
-// what we want to avoid if we're using it in conjunction with memcpy()!
-// With C++11, the desired memcpy() boils down to memcpy(..., &(*s)[0], size),
-// where s is a string*. Without C++11, &(*s)[0] is not guaranteed to be safe,
-// so we use string_as_array(), and live with the extra logic that tests whether
-// *s is empty.
+// A ZeroCopyOutputStream that writes to a Cord. This stream implements
+// WriteCord() in a way that can share memory between the source and
+// destination cords rather than copying.
+class PROTOBUF_EXPORT CordOutputStream final : public ZeroCopyOutputStream {
+ public:
+ // Creates an OutputStream streaming serialized data into a Cord. `size_hint`,
+ // if given, is the expected total size of the resulting Cord. This is a hint
+ // only, used for optimization. Callers can obtain the generated Cord value by
+ // invoking `Consume()`.
+ explicit CordOutputStream(size_t size_hint = 0);
+
+ // Creates an OutputStream with an initial Cord value. This constructor can be
+ // used by applications wanting to directly append serialization data to a
+ // given cord. In such cases, donating the existing value as in:
+ //
+ // CordOutputStream stream(std::move(cord));
+ // message.SerializeToZeroCopyStream(&stream);
+ // cord = std::move(stream.Consume());
+ //
+ // is more efficient then appending the serialized cord in application code:
+ //
+ // CordOutputStream stream;
+ // message.SerializeToZeroCopyStream(&stream);
+ // cord.Append(stream.Consume());
+ //
+ // The former allows `CordOutputStream` to utilize pre-existing privately
+ // owned Cord buffers from the donated cord where the latter does not, which
+ // may lead to more memory usage when serialuzing data into existing cords.
+ explicit CordOutputStream(y_absl::Cord cord, size_t size_hint = 0);
+
+ // Creates an OutputStream with an initial Cord value and initial buffer.
+ // This donates both the preexisting cord in `cord`, as well as any
+ // pre-existing data and additional capacity in `buffer`.
+ // This function is mainly intended to be used in internal serialization logic
+ // using eager buffer initialization in EpsCopyOutputStream.
+ // The donated buffer can be empty, partially empty or full: the outputstream
+ // will DTRT in all cases and preserve any pre-existing data.
+ explicit CordOutputStream(y_absl::Cord cord, y_absl::CordBuffer buffer,
+ size_t size_hint = 0);
+
+ // Creates an OutputStream with an initial buffer.
+ // This method is logically identical to, but more efficient than:
+ // `CordOutputStream(y_absl::Cord(), std::move(buffer), size_hint)`
+ explicit CordOutputStream(y_absl::CordBuffer buffer, size_t size_hint = 0);
+
+ // `CordOutputStream` is neither copiable nor assignable
+ CordOutputStream(const CordOutputStream&) = delete;
+ CordOutputStream& operator=(const CordOutputStream&) = delete;
+
+ // implements `ZeroCopyOutputStream` ---------------------------------
+ bool Next(void** data, int* size) final;
+ void BackUp(int count) final;
+ int64_t ByteCount() const final;
+ bool WriteCord(const y_absl::Cord& cord) final;
+
+ // Consumes the serialized data as a cord value. `Consume()` internally
+ // flushes any pending state 'as if' BackUp(0) was called. While a final call
+ // to BackUp() is generally required by the `ZeroCopyOutputStream` contract,
+ // applications using `CordOutputStream` directly can call `Consume()` without
+ // a preceding call to `BackUp()`.
+ //
+ // While it will rarely be useful in practice (and especially in the presence
+ // of size hints) an instance is safe to be used after a call to `Consume()`.
+ // The only logical change in state is that all serialized data is extracted,
+ // and any new serialization calls will serialize into new cord data.
+ y_absl::Cord Consume();
+
+ private:
+ // State of `buffer_` and 'cord_. As a default CordBuffer instance always has
+ // inlined capacity, we track state explicitly to avoid returning 'existing
+ // capacity' from the default or 'moved from' CordBuffer. 'kSteal' indicates
+ // we should (attempt to) steal the next buffer from the cord.
+ enum class State { kEmpty, kFull, kPartial, kSteal };
+
+ y_absl::Cord cord_;
+ size_t size_hint_;
+ State state_ = State::kEmpty;
+ y_absl::CordBuffer buffer_;
+};
+
+
+// ===================================================================
// Return a pointer to mutable characters underlying the given string. The
// return value is valid until the next time the string is resized. We
// trust the caller to treat the return value as an array of length s->size().
inline char* mutable_string_data(TProtoStringType* s) {
- // This should be simpler & faster than string_as_array() because the latter
- // is guaranteed to return NULL when *s is empty, so it has to check for that.
return &(*s)[0];
}
@@ -408,6 +535,6 @@ inline std::pair<char*, bool> as_string_data(TProtoStringType* s) {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/json/internal/descriptor_traits.h b/contrib/libs/protobuf/src/google/protobuf/json/internal/descriptor_traits.h
new file mode 100644
index 00000000000..a43aa14d9aa
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/json/internal/descriptor_traits.h
@@ -0,0 +1,536 @@
+// 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_JSON_INTERNAL_DESCRIPTOR_TRAITS_H__
+#define GOOGLE_PROTOBUF_JSON_INTERNAL_DESCRIPTOR_TRAITS_H__
+
+#include <array>
+#include <cfloat>
+#include <cmath>
+#include <cstdint>
+#include <cstring>
+#include <limits>
+#include <string>
+#include <utility>
+
+#include "google/protobuf/type.pb.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/dynamic_message.h"
+#include "google/protobuf/message.h"
+#include "y_absl/algorithm/container.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/status/status.h"
+#include "y_absl/status/statusor.h"
+#include "y_absl/strings/match.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/types/optional.h"
+#include "google/protobuf/json/internal/lexer.h"
+#include "google/protobuf/json/internal/untyped_message.h"
+#include "google/protobuf/stubs/status_macros.h"
+
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+// Traits for working with descriptor.proto and type.proto generically.
+
+namespace google {
+namespace protobuf {
+namespace json_internal {
+enum class MessageType {
+ kNotWellKnown,
+ kAny,
+ kWrapper,
+ kStruct,
+ kList,
+ kValue,
+ kNull,
+ kTimestamp,
+ kDuration,
+ kFieldMask,
+};
+
+inline MessageType ClassifyMessage(y_absl::string_view name) {
+ constexpr y_absl::string_view kWellKnownPkg = "google.protobuf.";
+ if (!y_absl::StartsWith(name, kWellKnownPkg)) {
+ return MessageType::kNotWellKnown;
+ }
+ name = name.substr(kWellKnownPkg.size());
+
+ switch (name.size()) {
+ case 3:
+ if (name == "Any") {
+ return MessageType::kAny;
+ }
+ break;
+ case 5:
+ if (name == "Value") {
+ return MessageType::kValue;
+ }
+ break;
+ case 6:
+ if (name == "Struct") {
+ return MessageType::kStruct;
+ }
+ break;
+ case 8:
+ if (name == "Duration") {
+ return MessageType::kDuration;
+ }
+ break;
+ case 9:
+ if (name == "BoolValue") {
+ return MessageType::kWrapper;
+ }
+ if (name == "NullValue") {
+ return MessageType::kNull;
+ }
+ if (name == "ListValue") {
+ return MessageType::kList;
+ }
+ if (name == "Timestamp") {
+ return MessageType::kTimestamp;
+ }
+ if (name == "FieldMask") {
+ return MessageType::kFieldMask;
+ }
+ break;
+ case 10:
+ if (name == "BytesValue" || name == "FloatValue" ||
+ name == "Int32Value" || name == "Int64Value") {
+ return MessageType::kWrapper;
+ }
+ break;
+ case 11:
+ if (name == "DoubleValue" || name == "StringValue" ||
+ name == "UInt32Value" || name == "UInt64Value") {
+ return MessageType::kWrapper;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return MessageType::kNotWellKnown;
+}
+
+// Helper alias templates to avoid needing to write `typename` in function
+// signatures.
+template <typename Traits>
+using Field = typename Traits::Field;
+template <typename Traits>
+using Desc = typename Traits::Desc;
+
+// Traits for proto2-ish descriptors.
+struct Proto2Descriptor {
+ // A descriptor for introspecting the fields of a message type.
+ //
+ // Desc<Traits> needs to be handled through a const Desc& in most (but not
+ // all, in the case of ResolverTraits) cases, so we do not include the const*
+ // annotation on this type.
+ using Desc = Descriptor;
+
+ // A field descriptor for introspecting a single field.
+ //
+ // Field<Traits> is always copyable, so this can be a pointer directly.
+ using Field = const FieldDescriptor*;
+
+ /// Functions for working with descriptors. ///
+
+ static y_absl::string_view TypeName(const Desc& d) { return d.full_name(); }
+
+ static y_absl::optional<Field> FieldByNumber(const Desc& d, arc_i32 number) {
+ if (const auto* field = d.FindFieldByNumber(number)) {
+ return field;
+ }
+ return y_absl::nullopt;
+ }
+
+ static Field MustHaveField(const Desc& d, arc_i32 number,
+ JsonLocation::SourceLocation loc =
+ JsonLocation::SourceLocation::current()) {
+ auto f = FieldByNumber(d, number);
+ if (!f.has_value()) {
+ Y_ABSL_LOG(FATAL)
+ << y_absl::StrFormat(
+ "%s has, by definition, a field numbered %d, but it could not "
+ "be "
+ "looked up; this is a bug",
+ TypeName(d), number);
+ }
+ return *f;
+ }
+
+ static y_absl::optional<Field> FieldByName(const Desc& d,
+ y_absl::string_view name) {
+ if (const auto* field = d.FindFieldByCamelcaseName(name)) {
+ return field;
+ }
+
+ if (const auto* field = d.FindFieldByName(name)) {
+ return field;
+ }
+
+ for (int i = 0; i < d.field_count(); ++i) {
+ const auto* field = d.field(i);
+ if (field->has_json_name() && field->json_name() == name) {
+ return field;
+ }
+ }
+
+ return y_absl::nullopt;
+ }
+
+ static Field KeyField(const Desc& d) { return d.map_key(); }
+
+ static Field ValueField(const Desc& d) { return d.map_value(); }
+
+ static size_t FieldCount(const Desc& d) { return d.field_count(); }
+
+ static Field FieldByIndex(const Desc& d, size_t idx) { return d.field(idx); }
+
+ static y_absl::optional<Field> ExtensionByName(const Desc& d,
+ y_absl::string_view name) {
+ auto* field = d.file()->pool()->FindExtensionByName(name);
+ if (field == nullptr) {
+ return y_absl::nullopt;
+ }
+ return field;
+ }
+
+ /// Functions for introspecting fields. ///
+
+ static y_absl::string_view FieldName(Field f) { return f->name(); }
+ static y_absl::string_view FieldJsonName(Field f) {
+ return f->has_json_name() ? f->json_name() : f->camelcase_name();
+ }
+ static bool HasJsonName(Field f) {
+ return f->has_json_name();
+ }
+ static y_absl::string_view FieldFullName(Field f) { return f->full_name(); }
+
+ static y_absl::string_view FieldTypeName(Field f) {
+ if (f->type() == FieldDescriptor::TYPE_MESSAGE) {
+ return f->message_type()->full_name();
+ }
+ if (f->type() == FieldDescriptor::TYPE_ENUM) {
+ return f->enum_type()->full_name();
+ }
+ return "";
+ }
+
+ static FieldDescriptor::Type FieldType(Field f) { return f->type(); }
+
+ static arc_i32 FieldNumber(Field f) { return f->number(); }
+
+ static bool Is32Bit(Field f) {
+ switch (f->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_UINT32:
+ case FieldDescriptor::CPPTYPE_INT32:
+ case FieldDescriptor::CPPTYPE_ENUM:
+ case FieldDescriptor::CPPTYPE_FLOAT:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ static const Desc& ContainingType(Field f) { return *f->containing_type(); }
+
+ static bool IsMap(Field f) { return f->is_map(); }
+
+ static bool IsRepeated(Field f) { return f->is_repeated(); }
+
+ static bool IsOptional(Field f) { return f->has_presence(); }
+
+ static bool IsImplicitPresence(Field f) {
+ return !f->is_repeated() && !f->has_presence();
+ }
+
+ static bool IsExtension(Field f) { return f->is_extension(); }
+
+ static bool IsOneof(Field f) { return f->containing_oneof() != nullptr; }
+
+ static y_absl::StatusOr<arc_i32> EnumNumberByName(Field f,
+ y_absl::string_view name,
+ bool case_insensitive) {
+ if (case_insensitive) {
+ for (int i = 0; i < f->enum_type()->value_count(); ++i) {
+ const auto* ev = f->enum_type()->value(i);
+ if (y_absl::EqualsIgnoreCase(name, ev->name())) {
+ return ev->number();
+ }
+ }
+ return y_absl::InvalidArgumentError(
+ y_absl::StrFormat("unknown enum value: '%s'", name));
+ }
+
+ if (const auto* ev = f->enum_type()->FindValueByName(name)) {
+ return ev->number();
+ }
+
+ return y_absl::InvalidArgumentError(
+ y_absl::StrFormat("unknown enum value: '%s'", name));
+ }
+
+ static y_absl::StatusOr<TProtoStringType> EnumNameByNumber(Field f, arc_i32 number) {
+ if (const auto* ev = f->enum_type()->FindValueByNumber(number)) {
+ return ev->name();
+ }
+ return y_absl::InvalidArgumentError(
+ y_absl::StrFormat("unknown enum number: '%d'", number));
+ }
+
+ // Looks up the corresponding Desc for `f`'s type, if there is one, and
+ // calls `body` with it.
+ //
+ // This needs to have this funny callback API since whether or not the
+ // Descriptor equivalent is an owning type depends on the trait.
+ template <typename F>
+ static y_absl::Status WithFieldType(Field f, F body) {
+ return body(*f->message_type());
+ }
+
+ // Like WithFieldType, but using dynamic lookup by type URL.
+ template <typename F>
+ static y_absl::Status WithDynamicType(const Desc& desc,
+ const TProtoStringType& type_url, F body) {
+ size_t slash = type_url.rfind('/');
+ if (slash == y_absl::string_view::npos || slash == 0) {
+ return y_absl::InvalidArgumentError(y_absl::StrCat(
+ "@type must contain at least one / and a nonempty host; got: ",
+ type_url));
+ }
+ y_absl::string_view type_name(type_url);
+ type_name = type_name.substr(slash + 1);
+
+ const Descriptor* dyn_desc =
+ desc.file()->pool()->FindMessageTypeByName(type_name);
+ if (dyn_desc == nullptr) {
+ return y_absl::InvalidArgumentError(
+ y_absl::StrFormat("could not find @type '%s'", type_url));
+ }
+
+ return body(*dyn_desc);
+ }
+};
+
+// Traits for proto3-ish deserialization.
+//
+// See Proto2Descriptor for API docs.
+struct Proto3Type {
+ using Desc = ResolverPool::Message;
+ using Field = const ResolverPool::Field*;
+
+ /// Functions for working with descriptors. ///
+ static y_absl::string_view TypeName(const Desc& d) { return d.proto().name(); }
+
+ static y_absl::optional<Field> FieldByNumber(const Desc& d, arc_i32 number) {
+ const auto* f = d.FindField(number);
+ return f == nullptr ? y_absl::nullopt : y_absl::make_optional(f);
+ }
+
+ static Field MustHaveField(const Desc& d, arc_i32 number,
+ JsonLocation::SourceLocation loc =
+ JsonLocation::SourceLocation::current()) {
+ auto f = FieldByNumber(d, number);
+ if (!f.has_value()) {
+ Y_ABSL_LOG(FATAL)
+ << y_absl::StrFormat(
+ "%s has, by definition, a field numbered %d, but it could not "
+ "be "
+ "looked up; this is a bug",
+ TypeName(d), number);
+ }
+ return *f;
+ }
+
+ static y_absl::optional<Field> FieldByName(const Desc& d,
+ y_absl::string_view name) {
+ const auto* f = d.FindField(name);
+ return f == nullptr ? y_absl::nullopt : y_absl::make_optional(f);
+ }
+
+ static Field KeyField(const Desc& d) { return &d.FieldsByIndex()[0]; }
+
+ static Field ValueField(const Desc& d) { return &d.FieldsByIndex()[1]; }
+
+ static size_t FieldCount(const Desc& d) { return d.proto().fields_size(); }
+
+ static Field FieldByIndex(const Desc& d, size_t idx) {
+ return &d.FieldsByIndex()[idx];
+ }
+
+ static y_absl::optional<Field> ExtensionByName(const Desc& d,
+ y_absl::string_view name) {
+ // type.proto cannot represent extensions, so this function always
+ // fails.
+ return y_absl::nullopt;
+ }
+
+ /// Functions for introspecting fields. ///
+
+ static y_absl::string_view FieldName(Field f) { return f->proto().name(); }
+ static y_absl::string_view FieldJsonName(Field f) {
+ return f->proto().json_name();
+ }
+ static bool HasJsonName(Field f) {
+ return true;
+ }
+ static y_absl::string_view FieldFullName(Field f) { return f->proto().name(); }
+
+ static y_absl::string_view FieldTypeName(Field f) {
+ y_absl::string_view url = f->proto().type_url();
+
+ // If there is no slash, `slash` is string_view::npos, which is guaranteed
+ // to be -1.
+ size_t slash = url.rfind('/');
+ return url.substr(slash + 1);
+ }
+
+ static FieldDescriptor::Type FieldType(Field f) {
+ // The descriptor.proto and type.proto field type enums are required to be
+ // the same, so we leverage this.
+ return static_cast<FieldDescriptor::Type>(f->proto().kind());
+ }
+
+ static arc_i32 FieldNumber(Field f) { return f->proto().number(); }
+
+ static bool Is32Bit(Field f) {
+ switch (f->proto().kind()) {
+ case google::protobuf::Field::TYPE_INT32:
+ case google::protobuf::Field::TYPE_SINT32:
+ case google::protobuf::Field::TYPE_UINT32:
+ case google::protobuf::Field::TYPE_FIXED32:
+ case google::protobuf::Field::TYPE_SFIXED32:
+ case google::protobuf::Field::TYPE_FLOAT:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ static const Desc& ContainingType(Field f) { return f->parent(); }
+ static bool IsMap(Field f) {
+ if (f->proto().kind() != google::protobuf::Field::TYPE_MESSAGE) {
+ return false;
+ }
+
+ bool value = false;
+ (void)WithFieldType(f, [&value](const Desc& desc) {
+ value = y_absl::c_any_of(desc.proto().options(), [&](auto& option) {
+ return option.name() == "map_entry";
+ });
+ return y_absl::OkStatus();
+ });
+ return value;
+ }
+
+ static bool IsRepeated(Field f) {
+ return f->proto().cardinality() ==
+ google::protobuf::Field::CARDINALITY_REPEATED;
+ }
+
+ static bool IsOptional(Field f) {
+ // Implicit presence requires this weird check: in proto3, everything is
+ // implicit presence, except for things that are members of oneofs,
+ // which is how proto3 optional is represented.
+ if (f->parent().proto().syntax() == google::protobuf::SYNTAX_PROTO3) {
+ return f->proto().oneof_index() != 0;
+ }
+
+ return f->proto().cardinality() ==
+ google::protobuf::Field::CARDINALITY_OPTIONAL ||
+ google::protobuf::Field::CARDINALITY_REQUIRED;
+ }
+
+ static bool IsImplicitPresence(Field f) {
+ return !IsRepeated(f) && !IsOptional(f);
+ }
+
+ static bool IsExtension(Field f) { return false; }
+
+ static bool IsOneof(Field f) { return f->proto().oneof_index() != 0; }
+
+ static y_absl::StatusOr<arc_i32> EnumNumberByName(Field f,
+ y_absl::string_view name,
+ bool case_insensitive) {
+ auto e = f->EnumType();
+ RETURN_IF_ERROR(e.status());
+
+ for (const auto& ev : (**e).proto().enumvalue()) {
+ if (case_insensitive) {
+ // Two ifs to avoid doing operator== twice if the names are not equal.
+ if (y_absl::EqualsIgnoreCase(ev.name(), name)) {
+ return ev.number();
+ }
+ } else if (ev.name() == name) {
+ return ev.number();
+ }
+ }
+ return y_absl::InvalidArgumentError(
+ y_absl::StrFormat("unknown enum value: '%s'", name));
+ }
+
+ static y_absl::StatusOr<TProtoStringType> EnumNameByNumber(Field f, arc_i32 number) {
+ auto e = f->EnumType();
+ RETURN_IF_ERROR(e.status());
+
+ for (const auto& ev : (**e).proto().enumvalue()) {
+ if (ev.number() == number) {
+ return ev.name();
+ }
+ }
+ return y_absl::InvalidArgumentError(
+ y_absl::StrFormat("unknown enum number: '%d'", number));
+ }
+
+ template <typename F>
+ static y_absl::Status WithFieldType(Field f, F body) {
+ auto m = f->MessageType();
+ RETURN_IF_ERROR(m.status());
+ return body(**m);
+ }
+
+ template <typename F>
+ static y_absl::Status WithDynamicType(const Desc& desc,
+ const TProtoStringType& type_url, F body) {
+ auto dyn_desc = desc.pool()->FindMessage(type_url);
+ RETURN_IF_ERROR(dyn_desc.status());
+ return body(**dyn_desc);
+ }
+};
+} // namespace json_internal
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
+#endif // GOOGLE_PROTOBUF_JSON_INTERNAL_DESCRIPTOR_TRAITS_INTERNAL_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/json/internal/lexer.cc b/contrib/libs/protobuf/src/google/protobuf/json/internal/lexer.cc
new file mode 100644
index 00000000000..7f52a861fee
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/json/internal/lexer.cc
@@ -0,0 +1,540 @@
+// 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/json/internal/lexer.h"
+
+#include <sys/types.h>
+
+#include <atomic>
+#include <cfloat>
+#include <cmath>
+#include <cstdint>
+#include <iostream>
+#include <limits>
+#include <ostream>
+#include <string>
+#include <utility>
+
+#include "y_absl/algorithm/container.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/numeric/bits.h"
+#include "y_absl/status/status.h"
+#include "y_absl/status/statusor.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/numbers.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/stubs/status_macros.h"
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace json_internal {
+namespace {
+// Randomly inserts bonus whitespace of a few different kinds into a string.
+//
+// This utility is intended to make error messages hostile to machine
+// interpretation as a Hyrum's Law countermeasure, without potentially confusing
+// human readers.
+void HardenAgainstHyrumsLaw(y_absl::string_view to_obfuscate, TProtoStringType& out) {
+ // Get some simple randomness from ASLR, which is enabled in most
+ // environments. Our goal is to be annoying, not secure.
+ static const void* const kAslrSeed = &kAslrSeed;
+ // Per-call randomness from a relaxed atomic.
+ static std::atomic<uintptr_t> kCounterSeed{0};
+
+ constexpr arc_ui64 kA = 0x5851f42d4c957f2dull;
+ constexpr arc_ui64 kB = 0x14057b7ef767814full;
+
+ arc_ui64 state = y_absl::bit_cast<uintptr_t>(kAslrSeed) + kB +
+ kCounterSeed.fetch_add(1, std::memory_order_relaxed);
+ auto rng = [&state, &kA, &kB] {
+ state = state * kA + kB;
+ return y_absl::rotr(static_cast<arc_ui32>(((state >> 18) ^ state) >> 27),
+ state >> 59);
+ };
+ (void)rng(); // Advance state once.
+
+ out.reserve(to_obfuscate.size() + y_absl::c_count(to_obfuscate, ' '));
+ for (char c : to_obfuscate) {
+ out.push_back(c);
+ if (c != ' ' || rng() % 3 != 0) {
+ continue;
+ }
+
+ size_t count = rng() % 2 + 1;
+ for (size_t i = 0; i < count; ++i) {
+ out.push_back(' ');
+ }
+ }
+}
+} // namespace
+
+constexpr size_t ParseOptions::kDefaultDepth;
+
+y_absl::Status JsonLocation::Invalid(y_absl::string_view message,
+ SourceLocation sl) const {
+ // NOTE: we intentionally do not harden the "invalid JSON" part, so that
+ // people have a hope of grepping for it in logs. That part is easy to
+ // commit to, as stability goes.
+ //
+ // This copies the error twice. Because this is the "unhappy" path, this
+ // function is cold and can afford the waste.
+ TProtoStringType status_message = "invalid JSON";
+ TProtoStringType to_obfuscate;
+ if (path != nullptr) {
+ y_absl::StrAppend(&to_obfuscate, " in ");
+ path->Describe(to_obfuscate);
+ to_obfuscate.push_back(',');
+ }
+ y_absl::StrAppendFormat(&to_obfuscate, " near %zu:%zu (offset %zu): %s",
+ line + 1, col + 1, offset, message);
+ HardenAgainstHyrumsLaw(to_obfuscate, status_message);
+
+ return y_absl::InvalidArgumentError(std::move(status_message));
+}
+
+y_absl::StatusOr<JsonLexer::Kind> JsonLexer::PeekKind() {
+ RETURN_IF_ERROR(SkipToToken());
+ char c = stream_.PeekChar();
+ switch (c) {
+ case '{':
+ return JsonLexer::kObj;
+ case '[':
+ return JsonLexer::kArr;
+ case '"':
+ case '\'':
+ return JsonLexer::kStr;
+ case '-':
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ return JsonLexer::kNum;
+ case 't':
+ return JsonLexer::kTrue;
+ case 'f':
+ return JsonLexer::kFalse;
+ case 'n':
+ return JsonLexer::kNull;
+ default:
+ return Invalid(y_absl::StrFormat("unexpected character: '%c'", c));
+ }
+}
+
+y_absl::Status JsonLexer::SkipValue() {
+ y_absl::StatusOr<Kind> kind = PeekKind();
+ RETURN_IF_ERROR(kind.status());
+
+ switch (*kind) {
+ case JsonLexer::kObj:
+ return VisitObject(
+ [this](LocationWith<MaybeOwnedString>&) { return SkipValue(); });
+ case JsonLexer::kArr:
+ return VisitArray([this] { return SkipValue(); });
+ case JsonLexer::kStr:
+ return ParseUtf8().status();
+ case JsonLexer::kNum:
+ return ParseNumber().status();
+ case JsonLexer::kTrue:
+ return Expect("true");
+ case JsonLexer::kFalse:
+ return Expect("false");
+ case JsonLexer::kNull:
+ return Expect("null");
+ default:
+ break;
+ }
+ // Some compilers seem to fail to realize this is a basic block
+ // terminator and incorrectly believe this function is missing
+ // a return.
+ Y_ABSL_CHECK(false) << "unreachable";
+ return y_absl::OkStatus();
+}
+
+y_absl::StatusOr<uint16_t> JsonLexer::ParseU16HexCodepoint() {
+ y_absl::StatusOr<LocationWith<MaybeOwnedString>> escape = Take(4);
+ RETURN_IF_ERROR(escape.status());
+
+ uint16_t u16 = 0;
+ for (char c : escape->value.AsView()) {
+ if (c >= '0' && c <= '9') {
+ c -= '0';
+ } else if (c >= 'a' && c <= 'f') {
+ c = c - 'a' + 10;
+ } else if (c >= 'A' && c <= 'F') {
+ c = c - 'A' + 10;
+ } else {
+ return Invalid("invalid Unicode escape");
+ }
+ u16 <<= 4;
+ u16 |= c;
+ }
+
+ return u16;
+}
+
+y_absl::Status JsonLexer::SkipToToken() {
+ while (true) {
+ RETURN_IF_ERROR(stream_.BufferAtLeast(1).status());
+ switch (stream_.PeekChar()) {
+ case '\n':
+ RETURN_IF_ERROR(Advance(1));
+ ++json_loc_.line;
+ json_loc_.col = 0;
+ break;
+ case '\r':
+ case '\t':
+ case ' ':
+ RETURN_IF_ERROR(Advance(1));
+ break;
+ default:
+ return y_absl::OkStatus();
+ }
+ }
+}
+
+y_absl::StatusOr<LocationWith<MaybeOwnedString>> JsonLexer::ParseRawNumber() {
+ RETURN_IF_ERROR(SkipToToken());
+
+ enum { kInt, kFraction, kExponent } state = kInt;
+ char prev_var = 0;
+ auto number = TakeWhile([state, prev_var](size_t index, char c) mutable {
+ char prev = prev_var;
+ prev_var = c;
+ if (y_absl::ascii_isdigit(c)) {
+ return true;
+ }
+
+ bool last_was_int = y_absl::ascii_isdigit(prev);
+ // These checks handle transitions between the integer, fractional, and
+ // exponent part of a number. This will cut off at the first syntax error.
+ // Because all numbers must be followed by `,`, `]`, or `}`, we can let
+ // that catch what's left behind.
+ if (state == kInt && c == '-') {
+ return !last_was_int;
+ }
+ if (state == kInt && last_was_int && c == '.') {
+ state = kFraction;
+ return true;
+ }
+ if (state != kExponent && last_was_int && (c == 'e' || c == 'E')) {
+ state = kExponent;
+ return true;
+ }
+ if ((prev == 'e' || prev == 'E') && (c == '-' || c == '+')) {
+ return true;
+ }
+
+ return false;
+ });
+
+ RETURN_IF_ERROR(number.status());
+ y_absl::string_view number_text = number->value.AsView();
+
+ if (number_text.empty() || number_text == "-") {
+ return number->loc.Invalid("expected a number");
+ }
+
+ auto without_minus =
+ number_text[0] == '-' ? number_text.substr(1) : number_text;
+ if (without_minus.size() > 1 && without_minus[0] == '0' &&
+ y_absl::ascii_isdigit(without_minus[1])) {
+ return number->loc.Invalid("number cannot have extraneous leading zero");
+ }
+
+ if (number_text.back() == '.') {
+ return number->loc.Invalid("number cannot have trailing period");
+ }
+
+ double d;
+ if (!y_absl::SimpleAtod(number_text, &d) || !std::isfinite(d)) {
+ return number->loc.Invalid(
+ y_absl::StrFormat("invalid number: '%s'", number_text));
+ }
+
+ // Find the next token, to make sure we didn't leave something behind we
+ // shouldn't have.
+ if (!stream_.AtEof()) {
+ RETURN_IF_ERROR(SkipToToken());
+ switch (stream_.PeekChar()) {
+ case ',':
+ case ']':
+ case '}':
+ break;
+ default:
+ return Invalid(
+ y_absl::StrFormat("unexpected character: '%c'", stream_.PeekChar()));
+ }
+ }
+
+ return number;
+}
+
+y_absl::StatusOr<LocationWith<double>> JsonLexer::ParseNumber() {
+ auto number = ParseRawNumber();
+ RETURN_IF_ERROR(number.status());
+
+ double d;
+ if (!y_absl::SimpleAtod(number->value.AsView(), &d) || !std::isfinite(d)) {
+ return number->loc.Invalid(
+ y_absl::StrFormat("invalid number: '%s'", number->value.AsView()));
+ }
+
+ return LocationWith<double>{d, number->loc};
+}
+
+y_absl::StatusOr<size_t> JsonLexer::ParseUnicodeEscape(char out_utf8[4]) {
+ auto hex = ParseU16HexCodepoint();
+ RETURN_IF_ERROR(hex.status());
+
+ arc_ui32 rune = *hex;
+ if (rune >= 0xd800 && rune <= 0xdbff) {
+ // Surrogate pair: two 16-bit codepoints become a 32-bit codepoint.
+ arc_ui32 high = rune;
+
+ RETURN_IF_ERROR(Expect("\\u"));
+ auto hex = ParseU16HexCodepoint();
+ RETURN_IF_ERROR(hex.status());
+
+ arc_ui32 low = *hex;
+ if (low < 0xdc00 || low > 0xdfff) {
+ return Invalid("invalid low surrogate");
+ }
+
+ rune = (high & 0x3ff) << 10;
+ rune |= (low & 0x3ff);
+ rune += 0x10000;
+ } else if (rune >= 0xdc00 && rune <= 0xdfff) {
+ return Invalid("unpaired low surrogate");
+ }
+
+ // Write as UTF-8.
+ if (rune <= 0x7f) {
+ out_utf8[0] = rune;
+ return 1;
+ } else if (rune <= 0x07ff) {
+ out_utf8[0] = ((rune >> 6) & 0x1f) | 0xc0;
+ out_utf8[1] = ((rune >> 0) & 0x3f) | 0x80;
+ return 2;
+ } else if (rune <= 0xffff) {
+ out_utf8[0] = ((rune >> 12) & 0x0f) | 0xe0;
+ out_utf8[1] = ((rune >> 6) & 0x3f) | 0x80;
+ out_utf8[2] = ((rune >> 0) & 0x3f) | 0x80;
+ return 3;
+ } else if (rune < 0x10ffff) {
+ out_utf8[0] = ((rune >> 18) & 0x07) | 0xF0;
+ out_utf8[1] = ((rune >> 12) & 0x3f) | 0x80;
+ out_utf8[2] = ((rune >> 6) & 0x3f) | 0x80;
+ out_utf8[3] = ((rune >> 0) & 0x3f) | 0x80;
+ return 4;
+ } else {
+ return Invalid("invalid codepoint");
+ }
+}
+
+static char ParseSimpleEscape(char c, bool allow_legacy_syntax) {
+ switch (c) {
+ case '"':
+ return '"';
+ case '\\':
+ return '\\';
+ case '/':
+ return '/';
+ case 'b':
+ return '\b';
+ case 'f':
+ return '\f';
+ case 'n':
+ return '\n';
+ case 'r':
+ return '\r';
+ case 't':
+ return '\t';
+ case '\'':
+ if (allow_legacy_syntax) {
+ return '\'';
+ }
+ Y_ABSL_FALLTHROUGH_INTENDED;
+ default:
+ return 0;
+ }
+}
+
+y_absl::StatusOr<LocationWith<MaybeOwnedString>> JsonLexer::ParseUtf8() {
+ RETURN_IF_ERROR(SkipToToken());
+ // This is a non-standard extension accepted by the ESF parser that we will
+ // need to accept for backwards-compat.
+ bool is_single_quote = stream_.PeekChar() == '\'';
+ if (!options_.allow_legacy_syntax && is_single_quote) {
+ return Invalid("expected '\"'");
+ }
+
+ JsonLocation loc = json_loc_;
+ RETURN_IF_ERROR(Expect(is_single_quote ? "'" : "\""));
+
+ // on_heap is empty if we do not need to heap-allocate the string.
+ TProtoStringType on_heap;
+ LocationWith<Mark> mark = BeginMark();
+ while (true) {
+ RETURN_IF_ERROR(stream_.BufferAtLeast(1).status());
+
+ char c = stream_.PeekChar();
+ RETURN_IF_ERROR(Advance(1));
+ switch (c) {
+ case '"':
+ case '\'': {
+ if (c != (is_single_quote ? '\'' : '"')) {
+ goto normal_character;
+ }
+
+ if (!on_heap.empty()) {
+ return LocationWith<MaybeOwnedString>{
+ MaybeOwnedString(std::move(on_heap)), loc};
+ }
+ // NOTE: the 1 below clips off the " from the end of the string.
+ return LocationWith<MaybeOwnedString>{mark.value.UpToUnread(1), loc};
+ }
+ case '\\': {
+ if (on_heap.empty()) {
+ // The 1 skips over the `\`.
+ on_heap = TProtoStringType(mark.value.UpToUnread(1).AsView());
+ // Clang-tidy incorrectly notes this as being moved-from multiple
+ // times, but it can only occur in one loop iteration. The mark is
+ // destroyed only if we need to handle an escape when on_heap is
+ // empty. Because this branch unconditionally pushes to on_heap, this
+ // condition can never be reached in any iteration that follows it.
+ // This, at most one move every actually occurs.
+ std::move(mark).value.Discard();
+ }
+ RETURN_IF_ERROR(stream_.BufferAtLeast(1).status());
+
+ char c = stream_.PeekChar();
+ RETURN_IF_ERROR(Advance(1));
+ if (c == 'u' || (c == 'U' && options_.allow_legacy_syntax)) {
+ // Ensure there is actual space to scribble the UTF-8 onto.
+ on_heap.resize(on_heap.size() + 4);
+ auto written = ParseUnicodeEscape(&on_heap[on_heap.size() - 4]);
+ RETURN_IF_ERROR(written.status());
+ on_heap.resize(on_heap.size() - 4 + *written);
+ } else {
+ char escape = ParseSimpleEscape(c, options_.allow_legacy_syntax);
+ if (escape == 0) {
+ return Invalid(y_absl::StrFormat("invalid escape char: '%c'", c));
+ }
+ on_heap.push_back(escape);
+ }
+ break;
+ }
+ normal_character:
+ default: {
+ uint8_t uc = static_cast<uint8_t>(c);
+ // If people have newlines in their strings, that's their problem; it
+ // is too difficult to support correctly in our location tracking, and
+ // is out of spec, so users will get slightly wrong locations in errors.
+ if ((uc < 0x20 || uc == 0xff) && !options_.allow_legacy_syntax) {
+ return Invalid(y_absl::StrFormat(
+ "invalid control character 0x%02x in string", uc));
+ }
+
+ // Verify this is valid UTF-8. UTF-8 is a varint encoding satisfying
+ // one of the following (big-endian) patterns:
+ //
+ // 0b0xxxxxxx
+ // 0b110xxxxx'10xxxxxx
+ // 0b1110xxxx'10xxxxxx'10xxxxxx
+ // 0b11110xxx'10xxxxxx'10xxxxxx'10xxxxxx
+ //
+ // We don't need to decode it; just validate it.
+ size_t lookahead = 0;
+ switch (y_absl::countl_one(uc)) {
+ case 0:
+ break;
+ case 2:
+ lookahead = 1;
+ break;
+ case 3:
+ lookahead = 2;
+ break;
+ case 4:
+ lookahead = 3;
+ break;
+ default:
+ return Invalid("invalid UTF-8 in string");
+ }
+
+ if (!on_heap.empty()) {
+ on_heap.push_back(c);
+ }
+ for (int i = 0; i < lookahead; ++i) {
+ RETURN_IF_ERROR(stream_.BufferAtLeast(1).status());
+ uint8_t uc = static_cast<uint8_t>(stream_.PeekChar());
+ if ((uc >> 6) != 2) {
+ return Invalid("invalid UTF-8 in string");
+ }
+ if (!on_heap.empty()) {
+ on_heap.push_back(stream_.PeekChar());
+ }
+ RETURN_IF_ERROR(Advance(1));
+ }
+ break;
+ }
+ }
+ }
+
+ return Invalid("EOF inside string");
+}
+
+y_absl::StatusOr<LocationWith<MaybeOwnedString>> JsonLexer::ParseBareWord() {
+ RETURN_IF_ERROR(SkipToToken());
+ auto ident = TakeWhile(
+ [](size_t, char c) { return c == '_' || y_absl::ascii_isalnum(c); });
+ RETURN_IF_ERROR(ident.status());
+ y_absl::string_view text = ident->value.AsView();
+
+ if (text.empty() || y_absl::ascii_isdigit(text[0]) || text == "null" ||
+ text == "true" || text == "false") {
+ return ident->loc.Invalid("expected bare word");
+ }
+ return ident;
+}
+
+} // namespace json_internal
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/json/internal/lexer.h b/contrib/libs/protobuf/src/google/protobuf/json/internal/lexer.h
new file mode 100644
index 00000000000..bf257aca7cf
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/json/internal/lexer.h
@@ -0,0 +1,359 @@
+// 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.
+
+// Internal JSON tokenization utilities; not public API.
+#ifndef GOOGLE_PROTOBUF_JSON_INTERNAL_LEXER_H__
+#define GOOGLE_PROTOBUF_JSON_INTERNAL_LEXER_H__
+
+#include <array>
+#include <cfloat>
+#include <cmath>
+#include <cstdint>
+#include <iostream>
+#include <limits>
+#include <ostream>
+#include <string>
+#include <utility>
+
+#include "google/protobuf/descriptor.h"
+#include "y_absl/status/status.h"
+#include "y_absl/status/statusor.h"
+#include "y_absl/strings/match.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/io/zero_copy_stream.h"
+#include "google/protobuf/json/internal/message_path.h"
+#include "google/protobuf/json/internal/zero_copy_buffered_stream.h"
+#include "google/protobuf/stubs/status_macros.h"
+
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace json_internal {
+// This is a duplicate of JsonParseOptions from json_util.h; it must be
+// re-defined here so that :json_lexer does not need to depend on :json_util.
+struct ParseOptions {
+ bool ignore_unknown_fields = false;
+ bool case_insensitive_enum_parsing = false;
+
+ static constexpr size_t kDefaultDepth = 100;
+
+ // The number of times we may recurse before bailing out on the grounds of
+ // avoiding pathological input.
+ int recursion_depth = kDefaultDepth;
+
+ // The original parser used by json_util2 accepted a number of non-standard
+ // options. Setting this flag enables them.
+ //
+ // What those extensions were is explicitly not documented, beyond what exists
+ // in the unit tests; we intend to remove this setting eventually. See
+ // b/234868512.
+ bool allow_legacy_syntax = false;
+};
+
+// A position in JSON input, for error context.
+struct JsonLocation {
+ // This type exists to work around an absl type that has not yet been
+ // released.
+ struct SourceLocation {
+ static SourceLocation current() { return {}; }
+ };
+
+ // Line and column are both zero-indexed in-memory.
+ size_t offset = 0;
+ size_t line = 0;
+ size_t col = 0;
+ const MessagePath* path = nullptr;
+
+ // Creates an y_absl::InvalidArgumentError with line/column information.
+ y_absl::Status Invalid(y_absl::string_view message,
+ SourceLocation sl = SourceLocation::current()) const;
+};
+
+template <typename T>
+struct LocationWith {
+ T value;
+ JsonLocation loc;
+};
+
+class JsonLexer {
+ public:
+ // A kind of token that PeekKind() can detect.
+ enum Kind {
+ kObj,
+ kArr,
+ kStr,
+ kNum,
+ kTrue,
+ kFalse,
+ kNull,
+ };
+
+ using SourceLocation = JsonLocation::SourceLocation;
+
+ JsonLexer(io::ZeroCopyInputStream* stream, const ParseOptions& options,
+ MessagePath* path = nullptr, JsonLocation start = {})
+ : stream_(stream), options_(options), json_loc_(start), path_(path) {
+ json_loc_.path = path_;
+ }
+
+ const ParseOptions& options() const { return options_; }
+
+ const MessagePath& path() const { return *path_; }
+ MessagePath& path() { return *path_; }
+
+ // Creates an y_absl::InvalidArgumentError with line/column information.
+ y_absl::Status Invalid(y_absl::string_view message,
+ SourceLocation sl = SourceLocation::current()) {
+ return json_loc_.Invalid(message, sl);
+ }
+
+ // Expects the next bytes to be parsed (after consuming whitespace) to be
+ // exactly `literal`. If they are, consumes them; otherwise returns an error.
+ y_absl::Status Expect(y_absl::string_view literal,
+ SourceLocation sl = SourceLocation::current()) {
+ RETURN_IF_ERROR(SkipToToken());
+ auto buffering = stream_.BufferAtLeast(literal.size());
+ RETURN_IF_ERROR(buffering.status());
+
+ if (!y_absl::StartsWith(stream_.Unread(), literal)) {
+ return Invalid(
+ y_absl::StrFormat("unexpected character: '%c'; expected '%s'",
+ stream_.PeekChar(), literal),
+ sl);
+ }
+
+ return Advance(literal.size());
+ }
+
+ // Like Expect(), but returns a boolean. This makes it clear that the
+ // lookahead is failible.
+ bool Peek(y_absl::string_view literal) {
+ // Suppress the error; this can only fail on EOF in which case we would
+ // return false regardless.
+ (void)SkipToToken();
+ auto ignored = stream_.BufferAtLeast(literal.size());
+ if (!y_absl::StartsWith(stream_.Unread(), literal)) {
+ return false;
+ }
+
+ // We just ensured we had enough buffered so we can suppress this error.
+ (void)Advance(literal.size());
+ return true;
+ }
+
+ // Like Peek(string), but returns true if and only if a token of the given
+ // kind can be lexed next. Returns false on EOF, just like Peek(string).
+ bool Peek(Kind needle) {
+ auto kind = PeekKind();
+ return kind.ok() && *kind == needle;
+ }
+
+ // Consumes all whitespace and other ignored characters until the next
+ // token.
+ //
+ // This function returns an error on EOF, so PeekChar() can be safely
+ // called if it returns ok.
+ y_absl::Status SkipToToken();
+
+ // Returns which kind of value token (i.e., something that can occur after
+ // a `:`) is next up to be parsed.
+ y_absl::StatusOr<Kind> PeekKind();
+
+ // Parses a JSON number.
+ y_absl::StatusOr<LocationWith<double>> ParseNumber();
+
+ // Parses a number as a string, without turning it into an integer.
+ y_absl::StatusOr<LocationWith<MaybeOwnedString>> ParseRawNumber();
+
+ // Parses a UTF-8 string. If the contents of the string happen to actually be
+ // UTF-8, it will return a zero-copy view; otherwise it will allocate.
+ y_absl::StatusOr<LocationWith<MaybeOwnedString>> ParseUtf8();
+
+ // Walks over an array, calling `f` each time an element is reached.
+ //
+ // `f` should have type `() -> y_absl::Status`.
+ template <typename F>
+ y_absl::Status VisitArray(F f);
+
+ // Walks over an object, calling `f` just after parsing each `:`.
+ //
+ // `f` should have type `(y_absl::string_view) -> y_absl::Status`.
+ template <typename F>
+ y_absl::Status VisitObject(F f);
+
+ // Parses a single value and discards it.
+ y_absl::Status SkipValue();
+
+ // Forwards of functions from ZeroCopyBufferedStream.
+
+ bool AtEof() {
+ // Ignore whitespace for the purposes of finding the EOF. This will return
+ // an error if we hit EOF, so we discard it.
+ (void)SkipToToken();
+ return stream_.AtEof();
+ }
+
+ y_absl::StatusOr<LocationWith<MaybeOwnedString>> Take(size_t len) {
+ JsonLocation loc = json_loc_;
+ auto taken = stream_.Take(len);
+ RETURN_IF_ERROR(taken.status());
+ return LocationWith<MaybeOwnedString>{*std::move(taken), loc};
+ }
+
+ template <typename Pred>
+ y_absl::StatusOr<LocationWith<MaybeOwnedString>> TakeWhile(Pred p) {
+ JsonLocation loc = json_loc_;
+ auto taken = stream_.TakeWhile(std::move(p));
+ RETURN_IF_ERROR(taken.status());
+ return LocationWith<MaybeOwnedString>{*std::move(taken), loc};
+ }
+
+ LocationWith<Mark> BeginMark() { return {stream_.BeginMark(), json_loc_}; }
+
+ private:
+ friend BufferingGuard;
+ friend Mark;
+ friend MaybeOwnedString;
+
+ y_absl::Status Push() {
+ if (options_.recursion_depth == 0) {
+ return Invalid("JSON content was too deeply nested");
+ }
+ --options_.recursion_depth;
+ return y_absl::OkStatus();
+ }
+
+ void Pop() { ++options_.recursion_depth; }
+
+ // Parses the next four bytes as a 16-bit hex numeral.
+ y_absl::StatusOr<uint16_t> ParseU16HexCodepoint();
+
+ // Parses a Unicode escape (\uXXXX); this may be a surrogate pair, so it may
+ // consume the character that follows. Both are encoded as utf8 into
+ // `out_utf8`; returns the number of bytes written.
+ y_absl::StatusOr<size_t> ParseUnicodeEscape(char out_utf8[4]);
+
+ // Parses an alphanumeric "identifier", for use with the non-standard
+ // "unquoted keys" extension.
+ y_absl::StatusOr<LocationWith<MaybeOwnedString>> ParseBareWord();
+
+ y_absl::Status Advance(size_t bytes) {
+ RETURN_IF_ERROR(stream_.Advance(bytes));
+ json_loc_.offset += static_cast<int>(bytes);
+ json_loc_.col += static_cast<int>(bytes);
+ return y_absl::OkStatus();
+ }
+
+ ZeroCopyBufferedStream stream_;
+
+ ParseOptions options_;
+ JsonLocation json_loc_;
+ MessagePath* path_;
+};
+
+template <typename F>
+y_absl::Status JsonLexer::VisitArray(F f) {
+ RETURN_IF_ERROR(Expect("["));
+ RETURN_IF_ERROR(Push());
+
+ if (Peek("]")) {
+ Pop();
+ return y_absl::OkStatus();
+ }
+
+ bool has_comma = true;
+ do {
+ if (!has_comma) {
+ return Invalid("expected ','");
+ }
+ RETURN_IF_ERROR(f());
+ has_comma = Peek(",");
+ } while (!Peek("]"));
+
+ if (!options_.allow_legacy_syntax && has_comma) {
+ return Invalid("expected ']'");
+ }
+
+ Pop();
+ return y_absl::OkStatus();
+}
+
+// Walks over an object, calling `f` just after parsing each `:`.
+//
+// `f` should have type `(MaybeOwnedString&) -> y_absl::Status`.
+template <typename F>
+y_absl::Status JsonLexer::VisitObject(F f) {
+ RETURN_IF_ERROR(Expect("{"));
+ RETURN_IF_ERROR(Push());
+
+ if (Peek("}")) {
+ Pop();
+ return y_absl::OkStatus();
+ }
+
+ bool has_comma = true;
+ do {
+ if (!has_comma) {
+ return Invalid("expected ','");
+ }
+ RETURN_IF_ERROR(SkipToToken());
+
+ y_absl::StatusOr<LocationWith<MaybeOwnedString>> key;
+ if (stream_.PeekChar() == '"' || stream_.PeekChar() == '\'') {
+ key = ParseUtf8();
+ } else if (options_.allow_legacy_syntax) {
+ key = ParseBareWord();
+ } else {
+ return Invalid("expected '\"'");
+ }
+
+ RETURN_IF_ERROR(key.status());
+ RETURN_IF_ERROR(Expect(":"));
+ RETURN_IF_ERROR(f(*key));
+ has_comma = Peek(",");
+ } while (!Peek("}"));
+ Pop();
+
+ if (!options_.allow_legacy_syntax && has_comma) {
+ return Invalid("expected '}'");
+ }
+
+ return y_absl::OkStatus();
+}
+} // namespace json_internal
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
+#endif // GOOGLE_PROTOBUF_JSON_INTERNAL_LEXER_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/location_tracker.h b/contrib/libs/protobuf/src/google/protobuf/json/internal/message_path.cc
index 2a67a82a0d5..1ab7050199f 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/location_tracker.h
+++ b/contrib/libs/protobuf/src/google/protobuf/json/internal/message_path.cc
@@ -28,43 +28,40 @@
// (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_LOCATION_TRACKER_H__
-#define GOOGLE_PROTOBUF_UTIL_INTERNAL_LOCATION_TRACKER_H__
+#include "google/protobuf/json/internal/message_path.h"
#include <string>
-#include <google/protobuf/stubs/common.h>
+#include "y_absl/strings/str_cat.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
-namespace util {
-namespace converter {
+namespace json_internal {
+void MessagePath::Describe(TProtoStringType& out) const {
+ y_absl::StrAppend(&out, components_.front().type_name);
+ if (components_.size() == 1) {
+ return;
+ }
-// LocationTrackerInterface is an interface for classes that track
-// the location information for the purpose of error reporting.
-class PROTOBUF_EXPORT LocationTrackerInterface {
- public:
- virtual ~LocationTrackerInterface() {}
+ y_absl::StrAppend(&out, " @ ");
+ for (size_t i = 1; i < components_.size(); ++i) {
+ y_absl::StrAppend(&out, i == 1 ? "" : ".", components_[i].field_name);
+ if (components_[i].repeated_index >= 0) {
+ y_absl::StrAppend(&out, "[", components_[i].repeated_index, "]");
+ }
+ }
+ y_absl::string_view kind_name =
+ FieldDescriptor::TypeName(components_.back().type);
+ y_absl::StrAppend(&out, ": ", kind_name);
- // Returns the object location as human readable string.
- virtual TProtoStringType ToString() const = 0;
-
- protected:
- LocationTrackerInterface() {}
-
- private:
- // Please do not add any data members to this class.
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(LocationTrackerInterface);
-};
-
-} // namespace converter
-} // namespace util
+ y_absl::string_view type_name = components_.back().type_name;
+ if (!type_name.empty()) {
+ y_absl::StrAppend(&out, " ", type_name);
+ }
+}
+} // namespace json_internal
} // namespace protobuf
} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_LOCATION_TRACKER_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/json/internal/message_path.h b/contrib/libs/protobuf/src/google/protobuf/json/internal/message_path.h
new file mode 100644
index 00000000000..056425f1fdb
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/json/internal/message_path.h
@@ -0,0 +1,84 @@
+// 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_JSON_INTERNAL_MESSAGE_PATH_H__
+#define GOOGLE_PROTOBUF_JSON_INTERNAL_MESSAGE_PATH_H__
+
+#include <string>
+#include <vector>
+
+#include "y_absl/cleanup/cleanup.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/descriptor.h"
+
+namespace google {
+namespace protobuf {
+namespace json_internal {
+// A path in a Protobuf message, annotated specifically for producing nice
+// errors.
+class MessagePath {
+ public:
+ explicit MessagePath(y_absl::string_view message_root)
+ : components_(
+ {Component{FieldDescriptor::TYPE_MESSAGE, message_root, "", -1}}) {}
+
+ // Pushes a new field name, along with an optional type name if it is
+ // a message or enum.
+ //
+ // Returns an RAII object that will pop the field component on scope exit.
+ auto Push(y_absl::string_view field_name, FieldDescriptor::Type type,
+ y_absl::string_view type_name = "") {
+ // -1 makes it so the first call to NextRepeated makes the index 0.
+ components_.push_back(Component{type, type_name, field_name, -1});
+ return y_absl::MakeCleanup([this] { components_.pop_back(); });
+ }
+
+ // Increments the index of this field, indicating it is a repeated field.
+ //
+ // The first time this is called, the field will be marked as repeated and
+ // the index will become 0.
+ void NextRepeated() { ++components_.back().repeated_index; }
+
+ // Appends a description of the current state of the path to `out`.
+ void Describe(TProtoStringType& out) const;
+
+ private:
+ struct Component {
+ FieldDescriptor::Type type;
+ y_absl::string_view type_name, field_name;
+ arc_i32 repeated_index;
+ };
+ std::vector<Component> components_;
+};
+} // namespace json_internal
+} // namespace protobuf
+} // namespace google
+
+#endif // GOOGLE_PROTOBUF_JSON_INTERNAL_MESSAGE_PATH_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/json/internal/parser.cc b/contrib/libs/protobuf/src/google/protobuf/json/internal/parser.cc
new file mode 100644
index 00000000000..0da57a1f056
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/json/internal/parser.cc
@@ -0,0 +1,1409 @@
+// 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/json/internal/parser.h"
+
+#include <cfloat>
+#include <cmath>
+#include <cstdint>
+#include <cstring>
+#include <limits>
+#include <memory>
+#include <string>
+#include <utility>
+
+#include "google/protobuf/type.pb.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/dynamic_message.h"
+#include "google/protobuf/message.h"
+#include "y_absl/base/attributes.h"
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/status/status.h"
+#include "y_absl/status/statusor.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/escaping.h"
+#include "y_absl/strings/match.h"
+#include "y_absl/strings/numbers.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/str_split.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/types/optional.h"
+#include "y_absl/types/span.h"
+#include "google/protobuf/io/zero_copy_sink.h"
+#include "google/protobuf/io/zero_copy_stream.h"
+#include "google/protobuf/io/zero_copy_stream_impl_lite.h"
+#include "google/protobuf/json/internal/descriptor_traits.h"
+#include "google/protobuf/json/internal/lexer.h"
+#include "google/protobuf/json/internal/parser_traits.h"
+#include "google/protobuf/util/type_resolver.h"
+#include "google/protobuf/stubs/status_macros.h"
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace json_internal {
+namespace {
+// This file contains code that drives a JsonLexer to visit a JSON document and
+// convert it into some form of proto.
+//
+// This semantic layer is duplicated: proto2-ish code can deserialize directly
+// into a message, whereas proto3-ish code deserializes into a byte stream,
+// using TypeResolvers instead of Descriptors.
+//
+// The parsing code is templated over which of these two reflection + output
+// combinations is used. The traits types that collect the per-instantiation
+// functionality can be found in json_util2_parser_traits-inl.h.
+
+// This table maps an unsigned `char` value, interpreted as an ASCII character,
+// to a corresponding value in the base64 alphabet (both traditional and
+// "web-safe" characters are included).
+//
+// If a character is not valid base64, it maps to -1; this is used by the bit
+// operations that assemble a base64-encoded word to determine if an error
+// occurred, by checking the sign bit.
+constexpr signed char kBase64Table[256] = {
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, 62 /*+*/, -1, 62 /*-*/, -1, 63 /*/ */, 52 /*0*/,
+ 53 /*1*/, 54 /*2*/, 55 /*3*/, 56 /*4*/, 57 /*5*/, 58 /*6*/, 59 /*7*/,
+ 60 /*8*/, 61 /*9*/, -1, -1, -1, -1, -1,
+ -1, -1, 0 /*A*/, 1 /*B*/, 2 /*C*/, 3 /*D*/, 4 /*E*/,
+ 5 /*F*/, 6 /*G*/, 07 /*H*/, 8 /*I*/, 9 /*J*/, 10 /*K*/, 11 /*L*/,
+ 12 /*M*/, 13 /*N*/, 14 /*O*/, 15 /*P*/, 16 /*Q*/, 17 /*R*/, 18 /*S*/,
+ 19 /*T*/, 20 /*U*/, 21 /*V*/, 22 /*W*/, 23 /*X*/, 24 /*Y*/, 25 /*Z*/,
+ -1, -1, -1, -1, 63 /*_*/, -1, 26 /*a*/,
+ 27 /*b*/, 28 /*c*/, 29 /*d*/, 30 /*e*/, 31 /*f*/, 32 /*g*/, 33 /*h*/,
+ 34 /*i*/, 35 /*j*/, 36 /*k*/, 37 /*l*/, 38 /*m*/, 39 /*n*/, 40 /*o*/,
+ 41 /*p*/, 42 /*q*/, 43 /*r*/, 44 /*s*/, 45 /*t*/, 46 /*u*/, 47 /*v*/,
+ 48 /*w*/, 49 /*x*/, 50 /*y*/, 51 /*z*/, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1};
+
+arc_ui32 Base64Lookup(char c) {
+ // Sign-extend return value so high bit will be set on any unexpected char.
+ return static_cast<arc_ui32>(kBase64Table[static_cast<uint8_t>(c)]);
+}
+
+// Decodes `base64` in-place, shrinking the length as appropriate.
+y_absl::StatusOr<y_absl::Span<char>> DecodeBase64InPlace(y_absl::Span<char> base64) {
+ // We decode in place. This is safe because this is a new buffer (not
+ // aliasing the input) and because base64 decoding shrinks 4 bytes into 3.
+ char* out = base64.data();
+ const char* ptr = base64.data();
+ const char* end = ptr + base64.size();
+ const char* end4 = ptr + (base64.size() & ~3u);
+
+ for (; ptr < end4; ptr += 4, out += 3) {
+ auto val = Base64Lookup(ptr[0]) << 18 | Base64Lookup(ptr[1]) << 12 |
+ Base64Lookup(ptr[2]) << 6 | Base64Lookup(ptr[3]) << 0;
+
+ if (static_cast<arc_i32>(val) < 0) {
+ // Junk chars or padding. Remove trailing padding, if any.
+ if (end - ptr == 4 && ptr[3] == '=') {
+ if (ptr[2] == '=') {
+ end -= 2;
+ } else {
+ end -= 1;
+ }
+ }
+ break;
+ }
+
+ out[0] = val >> 16;
+ out[1] = (val >> 8) & 0xff;
+ out[2] = val & 0xff;
+ }
+
+ if (ptr < end) {
+ arc_ui32 val = ~0u;
+ switch (end - ptr) {
+ case 2:
+ val = Base64Lookup(ptr[0]) << 18 | Base64Lookup(ptr[1]) << 12;
+ out[0] = val >> 16;
+ out += 1;
+ break;
+ case 3:
+ val = Base64Lookup(ptr[0]) << 18 | Base64Lookup(ptr[1]) << 12 |
+ Base64Lookup(ptr[2]) << 6;
+ out[0] = val >> 16;
+ out[1] = (val >> 8) & 0xff;
+ out += 2;
+ break;
+ }
+
+ if (static_cast<arc_i32>(val) < 0) {
+ return y_absl::InvalidArgumentError("corrupt base64");
+ }
+ }
+
+ return y_absl::Span<char>(base64.data(),
+ static_cast<size_t>(out - base64.data()));
+}
+
+template <typename T>
+y_absl::StatusOr<LocationWith<T>> ParseIntInner(JsonLexer& lex, double lo,
+ double hi) {
+ y_absl::StatusOr<JsonLexer::Kind> kind = lex.PeekKind();
+ RETURN_IF_ERROR(kind.status());
+
+ LocationWith<T> n;
+ switch (*kind) {
+ case JsonLexer::kNum: {
+ y_absl::StatusOr<LocationWith<MaybeOwnedString>> x = lex.ParseRawNumber();
+ RETURN_IF_ERROR(x.status());
+ n.loc = x->loc;
+ if (y_absl::SimpleAtoi(x->value.AsView(), &n.value)) {
+ break;
+ }
+
+ double d;
+ if (!y_absl::SimpleAtod(x->value.AsView(), &d) || !std::isfinite(d)) {
+ return x->loc.Invalid(
+ y_absl::StrFormat("invalid number: '%s'", x->value.AsView()));
+ }
+
+ // Conversion overflow here would be UB.
+ if (lo > d || d > hi) {
+ return lex.Invalid("JSON number out of range for int");
+ }
+ n.value = static_cast<T>(d);
+ if (d - static_cast<double>(n.value) != 0) {
+ return lex.Invalid(
+ "expected integer, but JSON number had fractional part");
+ }
+ break;
+ }
+ case JsonLexer::kStr: {
+ y_absl::StatusOr<LocationWith<MaybeOwnedString>> str = lex.ParseUtf8();
+ RETURN_IF_ERROR(str.status());
+ // SimpleAtoi will ignore leading and trailing whitespace, so we need
+ // to check for it ourselves.
+ for (char c : str->value.AsView()) {
+ if (y_absl::ascii_isspace(c)) {
+ return lex.Invalid("non-number characters in quoted number");
+ }
+ }
+ if (!y_absl::SimpleAtoi(str->value.AsView(), &n.value)) {
+ return str->loc.Invalid("non-number characters in quoted number");
+ }
+ n.loc = str->loc;
+ break;
+ }
+ default:
+ return lex.Invalid("expected number or string");
+ }
+
+ return n;
+}
+
+template <typename Traits>
+y_absl::StatusOr<arc_i64> ParseInt(JsonLexer& lex, Field<Traits> field) {
+ y_absl::StatusOr<LocationWith<arc_i64>> n =
+ ParseIntInner<arc_i64>(lex, -9007199254740992.0, 9007199254740992.0);
+ RETURN_IF_ERROR(n.status());
+
+ if (Traits::Is32Bit(field)) {
+ if (std::numeric_limits<arc_i32>::min() > n->value ||
+ n->value > std::numeric_limits<arc_i32>::max()) {
+ return n->loc.Invalid("integer out of range");
+ }
+ }
+
+ return n->value;
+}
+
+template <typename Traits>
+y_absl::StatusOr<arc_ui64> ParseUInt(JsonLexer& lex, Field<Traits> field) {
+ y_absl::StatusOr<LocationWith<arc_ui64>> n =
+ ParseIntInner<arc_ui64>(lex, 0, 18014398509481984.0);
+ RETURN_IF_ERROR(n.status());
+
+ if (Traits::Is32Bit(field)) {
+ if (n->value > std::numeric_limits<arc_ui32>::max()) {
+ return n->loc.Invalid("integer out of range");
+ }
+ }
+
+ return n->value;
+}
+
+template <typename Traits>
+y_absl::StatusOr<double> ParseFp(JsonLexer& lex, Field<Traits> field) {
+ y_absl::StatusOr<JsonLexer::Kind> kind = lex.PeekKind();
+ RETURN_IF_ERROR(kind.status());
+
+ double n;
+ switch (*kind) {
+ case JsonLexer::kNum: {
+ y_absl::StatusOr<LocationWith<double>> d = lex.ParseNumber();
+ RETURN_IF_ERROR(d.status());
+ n = d->value;
+ break;
+ }
+ case JsonLexer::kStr: {
+ y_absl::StatusOr<LocationWith<MaybeOwnedString>> str = lex.ParseUtf8();
+ RETURN_IF_ERROR(str.status());
+
+ if (str->value == "NaN") {
+ n = NAN;
+ } else if (str->value == "Infinity") {
+ n = INFINITY;
+ } else if (str->value == "-Infinity") {
+ n = -INFINITY;
+ } else if (!y_absl::SimpleAtod(str->value.AsView(), &n)) {
+ return str->loc.Invalid("non-number characters in quoted number");
+ }
+ break;
+ }
+ default:
+ return lex.Invalid("expected number or string");
+ }
+
+ if (Traits::Is32Bit(field)) {
+ // Detect out-of-range 32-bit floats by seeing whether the conversion result
+ // is still finite. Finite extreme values may have textual representations
+ // that parse to 64-bit values outside the 32-bit range, but which are
+ // closer to the 32-bit extreme than to the "next value with the same
+ // precision".
+ if (std::isfinite(n) && !std::isfinite(static_cast<float>(n))) {
+ return lex.Invalid("float out of range");
+ }
+ }
+
+ return n;
+}
+
+template <typename Traits>
+y_absl::StatusOr<TProtoStringType> ParseStrOrBytes(JsonLexer& lex,
+ Field<Traits> field) {
+ y_absl::StatusOr<LocationWith<MaybeOwnedString>> str = lex.ParseUtf8();
+ RETURN_IF_ERROR(str.status());
+
+ if (Traits::FieldType(field) == FieldDescriptor::TYPE_BYTES) {
+ TProtoStringType& b64 = str->value.ToString();
+ y_absl::StatusOr<y_absl::Span<char>> decoded =
+ DecodeBase64InPlace(y_absl::MakeSpan(&b64[0], b64.size()));
+ if (!decoded.ok()) {
+ return str->loc.Invalid(decoded.status().message());
+ }
+ b64.resize(decoded->size());
+ }
+
+ return std::move(str->value.ToString());
+}
+
+template <typename Traits>
+y_absl::StatusOr<y_absl::optional<arc_i32>> ParseEnumFromStr(JsonLexer& lex,
+ MaybeOwnedString& str,
+ Field<Traits> field) {
+ y_absl::StatusOr<arc_i32> value = Traits::EnumNumberByName(
+ field, str.AsView(), lex.options().case_insensitive_enum_parsing);
+ if (value.ok()) {
+ return y_absl::optional<arc_i32>(*value);
+ }
+
+ arc_i32 i;
+ if (y_absl::SimpleAtoi(str.AsView(), &i)) {
+ return y_absl::optional<arc_i32>(i);
+ } else if (lex.options().ignore_unknown_fields) {
+ return {y_absl::nullopt};
+ }
+
+ return value.status();
+}
+
+// Parses an enum; can return nullopt if a quoted enumerator that we don't
+// know about is received and `ignore_unknown_fields` is set.
+template <typename Traits>
+y_absl::StatusOr<y_absl::optional<arc_i32>> ParseEnum(JsonLexer& lex,
+ Field<Traits> field) {
+ y_absl::StatusOr<JsonLexer::Kind> kind = lex.PeekKind();
+ RETURN_IF_ERROR(kind.status());
+
+ arc_i32 n = 0;
+ switch (*kind) {
+ case JsonLexer::kStr: {
+ y_absl::StatusOr<LocationWith<MaybeOwnedString>> str = lex.ParseUtf8();
+ RETURN_IF_ERROR(str.status());
+
+ auto e = ParseEnumFromStr<Traits>(lex, str->value, field);
+ RETURN_IF_ERROR(e.status());
+ if (!e->has_value()) {
+ return {y_absl::nullopt};
+ }
+ n = **e;
+ break;
+ }
+ case JsonLexer::kNum:
+ return ParseInt<Traits>(lex, field);
+ default:
+ return lex.Invalid("expected number or string");
+ }
+
+ return n;
+}
+
+// Mutually recursive with functions that follow.
+template <typename Traits>
+y_absl::Status ParseMessage(JsonLexer& lex, const Desc<Traits>& desc,
+ Msg<Traits>& msg, bool any_reparse);
+template <typename Traits>
+y_absl::Status ParseField(JsonLexer& lex, const Desc<Traits>& desc,
+ y_absl::string_view name, Msg<Traits>& msg);
+
+template <typename Traits>
+y_absl::Status ParseSingular(JsonLexer& lex, Field<Traits> field,
+ Msg<Traits>& msg) {
+ auto field_type = Traits::FieldType(field);
+ if (lex.Peek(JsonLexer::kNull)) {
+ auto message_type = ClassifyMessage(Traits::FieldTypeName(field));
+ switch (field_type) {
+ case FieldDescriptor::TYPE_ENUM:
+ if (message_type == MessageType::kNull) {
+ Traits::SetEnum(field, msg, 0);
+ }
+ break;
+ case FieldDescriptor::TYPE_MESSAGE: {
+ if (message_type == MessageType::kValue) {
+ return Traits::NewMsg(
+ field, msg,
+ [&](const Desc<Traits>& type, Msg<Traits>& msg) -> y_absl::Status {
+ auto field = Traits::FieldByNumber(type, 1);
+ Y_ABSL_DCHECK(field.has_value());
+ RETURN_IF_ERROR(lex.Expect("null"));
+ Traits::SetEnum(Traits::MustHaveField(type, 1), msg, 0);
+ return y_absl::OkStatus();
+ });
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ return lex.Expect("null");
+ }
+
+ switch (field_type) {
+ case FieldDescriptor::TYPE_FLOAT: {
+ auto x = ParseFp<Traits>(lex, field);
+ RETURN_IF_ERROR(x.status());
+ Traits::SetFloat(field, msg, *x);
+ break;
+ }
+ case FieldDescriptor::TYPE_DOUBLE: {
+ auto x = ParseFp<Traits>(lex, field);
+ RETURN_IF_ERROR(x.status());
+ Traits::SetDouble(field, msg, *x);
+ break;
+ }
+
+ case FieldDescriptor::TYPE_SFIXED64:
+ case FieldDescriptor::TYPE_SINT64:
+ case FieldDescriptor::TYPE_INT64: {
+ auto x = ParseInt<Traits>(lex, field);
+ RETURN_IF_ERROR(x.status());
+ Traits::SetInt64(field, msg, *x);
+ break;
+ }
+ case FieldDescriptor::TYPE_FIXED64:
+ case FieldDescriptor::TYPE_UINT64: {
+ auto x = ParseUInt<Traits>(lex, field);
+ RETURN_IF_ERROR(x.status());
+ Traits::SetUInt64(field, msg, *x);
+ break;
+ }
+
+ case FieldDescriptor::TYPE_SFIXED32:
+ case FieldDescriptor::TYPE_SINT32:
+ case FieldDescriptor::TYPE_INT32: {
+ auto x = ParseInt<Traits>(lex, field);
+ RETURN_IF_ERROR(x.status());
+ Traits::SetInt32(field, msg, static_cast<arc_i32>(*x));
+ break;
+ }
+ case FieldDescriptor::TYPE_FIXED32:
+ case FieldDescriptor::TYPE_UINT32: {
+ auto x = ParseUInt<Traits>(lex, field);
+ RETURN_IF_ERROR(x.status());
+ Traits::SetUInt32(field, msg, static_cast<arc_ui32>(*x));
+ break;
+ }
+ case FieldDescriptor::TYPE_BOOL: {
+ y_absl::StatusOr<JsonLexer::Kind> kind = lex.PeekKind();
+ RETURN_IF_ERROR(kind.status());
+
+ switch (*kind) {
+ case JsonLexer::kTrue:
+ RETURN_IF_ERROR(lex.Expect("true"));
+ Traits::SetBool(field, msg, true);
+ break;
+ case JsonLexer::kFalse:
+ RETURN_IF_ERROR(lex.Expect("false"));
+ Traits::SetBool(field, msg, false);
+ break;
+ case JsonLexer::kStr: {
+ if (!lex.options().allow_legacy_syntax) {
+ goto bad;
+ }
+
+ auto x = lex.ParseUtf8();
+ RETURN_IF_ERROR(x.status());
+
+ bool flag;
+ if (!y_absl::SimpleAtob(x->value, &flag)) {
+ // Is this error a lie? Do we accept things otyher than "true" and
+ // "false" because SimpleAtob does? Absolutely!
+ return x->loc.Invalid("expected 'true' or 'false'");
+ }
+ Traits::SetBool(field, msg, flag);
+
+ break;
+ }
+ bad:
+ default:
+ return lex.Invalid("expected 'true' or 'false'");
+ }
+ break;
+ }
+ case FieldDescriptor::TYPE_STRING:
+ case FieldDescriptor::TYPE_BYTES: {
+ auto x = ParseStrOrBytes<Traits>(lex, field);
+ RETURN_IF_ERROR(x.status());
+ Traits::SetString(field, msg, *x);
+ break;
+ }
+ case FieldDescriptor::TYPE_ENUM: {
+ y_absl::StatusOr<y_absl::optional<arc_i32>> x = ParseEnum<Traits>(lex, field);
+ RETURN_IF_ERROR(x.status());
+
+ if (x->has_value() || Traits::IsImplicitPresence(field)) {
+ Traits::SetEnum(field, msg, x->value_or(0));
+ }
+ break;
+ }
+ case FieldDescriptor::TYPE_MESSAGE:
+ case FieldDescriptor::TYPE_GROUP: {
+ return Traits::NewMsg(
+ field, msg,
+ [&](const Desc<Traits>& type, Msg<Traits>& msg) -> y_absl::Status {
+ return ParseMessage<Traits>(lex, type, msg,
+ /*any_reparse=*/false);
+ });
+ }
+ default:
+ return lex.Invalid(
+ y_absl::StrCat("unsupported field type: ", Traits::FieldType(field)));
+ }
+
+ return y_absl::OkStatus();
+}
+
+template <typename Traits>
+y_absl::Status EmitNull(JsonLexer& lex, Field<Traits> field, Msg<Traits>& msg) {
+ switch (Traits::FieldType(field)) {
+ case FieldDescriptor::TYPE_FLOAT:
+ Traits::SetFloat(field, msg, 0);
+ break;
+ case FieldDescriptor::TYPE_DOUBLE:
+ Traits::SetDouble(field, msg, 0);
+ break;
+ case FieldDescriptor::TYPE_SFIXED64:
+ case FieldDescriptor::TYPE_SINT64:
+ case FieldDescriptor::TYPE_INT64:
+ Traits::SetInt64(field, msg, 0);
+ break;
+ case FieldDescriptor::TYPE_FIXED64:
+ case FieldDescriptor::TYPE_UINT64:
+ Traits::SetUInt64(field, msg, 0);
+ break;
+ case FieldDescriptor::TYPE_SFIXED32:
+ case FieldDescriptor::TYPE_SINT32:
+ case FieldDescriptor::TYPE_INT32:
+ Traits::SetInt32(field, msg, 0);
+ break;
+ case FieldDescriptor::TYPE_FIXED32:
+ case FieldDescriptor::TYPE_UINT32:
+ Traits::SetUInt32(field, msg, 0);
+ break;
+ case FieldDescriptor::TYPE_BOOL:
+ Traits::SetBool(field, msg, false);
+ break;
+ case FieldDescriptor::TYPE_STRING:
+ case FieldDescriptor::TYPE_BYTES:
+ Traits::SetString(field, msg, "");
+ break;
+ case FieldDescriptor::TYPE_ENUM:
+ Traits::SetEnum(field, msg, 0);
+ break;
+ case FieldDescriptor::TYPE_MESSAGE:
+ case FieldDescriptor::TYPE_GROUP:
+ return Traits::NewMsg(field, msg,
+ [](const auto&, const auto&) -> y_absl::Status {
+ return y_absl::OkStatus();
+ });
+ default:
+ return lex.Invalid(
+ y_absl::StrCat("unsupported field type: ", Traits::FieldType(field)));
+ }
+ return y_absl::OkStatus();
+}
+
+template <typename Traits>
+y_absl::Status ParseArray(JsonLexer& lex, Field<Traits> field, Msg<Traits>& msg) {
+ if (lex.Peek(JsonLexer::kNull)) {
+ return lex.Expect("null");
+ }
+
+ return lex.VisitArray([&]() -> y_absl::Status {
+ lex.path().NextRepeated();
+ MessageType type = ClassifyMessage(Traits::FieldTypeName(field));
+
+ if (lex.Peek(JsonLexer::kNull)) {
+ if (type == MessageType::kValue) {
+ return ParseSingular<Traits>(lex, field, msg);
+ }
+ if (type == MessageType::kNull) {
+ return ParseSingular<Traits>(lex, field, msg);
+ }
+
+ if (lex.options().allow_legacy_syntax) {
+ RETURN_IF_ERROR(lex.Expect("null"));
+ return EmitNull<Traits>(lex, field, msg);
+ }
+ return lex.Invalid("null cannot occur inside of repeated fields");
+ }
+
+ // Note that this is sufficient to catch when we are inside of a ListValue,
+ // because a ListValue's sole field is of type Value. Thus, we only need to
+ // classify cases in which we are inside of an array and parsing messages
+ // that like looking like arrays.
+ //
+ // This will also correctly handle e.g. writing out a ListValue with the
+ // legacy syntax of `{"values": [[0], [1], [2]]}`, which does not go through
+ // the custom parser handler.
+ bool can_flatten =
+ type != MessageType::kValue && type != MessageType::kList;
+ if (can_flatten && lex.options().allow_legacy_syntax &&
+ lex.Peek(JsonLexer::kArr)) {
+ // You read that right. In legacy mode, if we encounter an array within
+ // an array, we just flatten it as part of the current array!
+ //
+ // This DOES NOT apply when parsing a google.protobuf.Value or a
+ // google.protobuf.ListValue!
+ return ParseArray<Traits>(lex, field, msg);
+ }
+ return ParseSingular<Traits>(lex, field, msg);
+ });
+}
+
+template <typename Traits>
+y_absl::Status ParseMap(JsonLexer& lex, Field<Traits> field, Msg<Traits>& msg) {
+ if (lex.Peek(JsonLexer::kNull)) {
+ return lex.Expect("null");
+ }
+
+ y_absl::flat_hash_set<TProtoStringType> keys_seen;
+ return lex.VisitObject(
+ [&](LocationWith<MaybeOwnedString>& key) -> y_absl::Status {
+ lex.path().NextRepeated();
+ auto insert_result = keys_seen.emplace(key.value.AsView());
+ if (!insert_result.second) {
+ return key.loc.Invalid(y_absl::StrFormat(
+ "got unexpectedly-repeated repeated map key: '%s'",
+ key.value.AsView()));
+ }
+ return Traits::NewMsg(
+ field, msg,
+ [&](const Desc<Traits>& type, Msg<Traits>& entry) -> y_absl::Status {
+ auto key_field = Traits::KeyField(type);
+ switch (Traits::FieldType(key_field)) {
+ case FieldDescriptor::TYPE_INT64:
+ case FieldDescriptor::TYPE_SINT64:
+ case FieldDescriptor::TYPE_SFIXED64: {
+ arc_i64 n;
+ if (!y_absl::SimpleAtoi(key.value.AsView(), &n)) {
+ return key.loc.Invalid(
+ "non-number characters in quoted number");
+ }
+ Traits::SetInt64(key_field, entry, n);
+ break;
+ }
+ case FieldDescriptor::TYPE_UINT64:
+ case FieldDescriptor::TYPE_FIXED64: {
+ arc_ui64 n;
+ if (!y_absl::SimpleAtoi(key.value.AsView(), &n)) {
+ return key.loc.Invalid(
+ "non-number characters in quoted number");
+ }
+ Traits::SetUInt64(key_field, entry, n);
+ break;
+ }
+ case FieldDescriptor::TYPE_INT32:
+ case FieldDescriptor::TYPE_SINT32:
+ case FieldDescriptor::TYPE_SFIXED32: {
+ arc_i32 n;
+ if (!y_absl::SimpleAtoi(key.value.AsView(), &n)) {
+ return key.loc.Invalid(
+ "non-number characters in quoted number");
+ }
+ Traits::SetInt32(key_field, entry, n);
+ break;
+ }
+ case FieldDescriptor::TYPE_UINT32:
+ case FieldDescriptor::TYPE_FIXED32: {
+ arc_ui32 n;
+ if (!y_absl::SimpleAtoi(key.value.AsView(), &n)) {
+ return key.loc.Invalid(
+ "non-number characters in quoted number");
+ }
+ Traits::SetUInt32(key_field, entry, n);
+ break;
+ }
+ case FieldDescriptor::TYPE_BOOL: {
+ if (key.value == "true") {
+ Traits::SetBool(key_field, entry, true);
+ } else if (key.value == "false") {
+ Traits::SetBool(key_field, entry, false);
+ } else {
+ return key.loc.Invalid(y_absl::StrFormat(
+ "expected bool string, got '%s'", key.value.AsView()));
+ }
+ break;
+ }
+ case FieldDescriptor::TYPE_ENUM: {
+ MaybeOwnedString key_str = key.value;
+ auto e = ParseEnumFromStr<Traits>(lex, key_str, field);
+ RETURN_IF_ERROR(e.status());
+ Traits::SetEnum(key_field, entry, e->value_or(0));
+ break;
+ }
+ case FieldDescriptor::TYPE_STRING: {
+ Traits::SetString(key_field, entry,
+ std::move(key.value.ToString()));
+ break;
+ }
+ default:
+ return lex.Invalid("unsupported map key type");
+ }
+
+ return ParseSingular<Traits>(lex, Traits::ValueField(type),
+ entry);
+ });
+ });
+}
+
+y_absl::optional<arc_ui32> TakeTimeDigitsWithSuffixAndAdvance(
+ y_absl::string_view& data, int max_digits, y_absl::string_view end) {
+ Y_ABSL_DCHECK_LE(max_digits, 9);
+
+ arc_ui32 val = 0;
+ int limit = max_digits;
+ while (!data.empty()) {
+ if (limit-- < 0) {
+ return y_absl::nullopt;
+ }
+ arc_ui32 digit = data[0] - '0';
+ if (digit >= 10) {
+ break;
+ }
+
+ val *= 10;
+ val += digit;
+ data = data.substr(1);
+ }
+ if (!y_absl::StartsWith(data, end)) {
+ return y_absl::nullopt;
+ }
+
+ data = data.substr(end.size());
+ return val;
+}
+
+y_absl::optional<arc_i32> TakeNanosAndAdvance(y_absl::string_view& data) {
+ arc_i32 frac_secs = 0;
+ size_t frac_digits = 0;
+ if (y_absl::StartsWith(data, ".")) {
+ for (char c : data.substr(1)) {
+ if (!y_absl::ascii_isdigit(c)) {
+ break;
+ }
+ ++frac_digits;
+ }
+ auto digits = data.substr(1, frac_digits);
+ if (frac_digits == 0 || frac_digits > 9 ||
+ !y_absl::SimpleAtoi(digits, &frac_secs)) {
+ return y_absl::nullopt;
+ }
+ data = data.substr(frac_digits + 1);
+ }
+ for (int i = 0; i < 9 - frac_digits; ++i) {
+ frac_secs *= 10;
+ }
+ return frac_secs;
+}
+
+template <typename Traits>
+y_absl::Status ParseTimestamp(JsonLexer& lex, const Desc<Traits>& desc,
+ Msg<Traits>& msg) {
+ if (lex.Peek(JsonLexer::kNull)) {
+ return lex.Expect("null");
+ }
+
+ y_absl::StatusOr<LocationWith<MaybeOwnedString>> str = lex.ParseUtf8();
+ RETURN_IF_ERROR(str.status());
+
+ y_absl::string_view data = str->value.AsView();
+ if (data.size() < 20) {
+ return str->loc.Invalid("timestamp string too short");
+ }
+
+ arc_i64 secs;
+ {
+ /* 1972-01-01T01:00:00 */
+ auto year = TakeTimeDigitsWithSuffixAndAdvance(data, 4, "-");
+ if (!year.has_value() || *year == 0) {
+ return str->loc.Invalid("bad year in timestamp");
+ }
+ auto mon = TakeTimeDigitsWithSuffixAndAdvance(data, 2, "-");
+ if (!mon.has_value() || *mon == 0) {
+ return str->loc.Invalid("bad month in timestamp");
+ }
+ auto day = TakeTimeDigitsWithSuffixAndAdvance(data, 2, "T");
+ if (!day.has_value() || *day == 0) {
+ return str->loc.Invalid("bad day in timestamp");
+ }
+ auto hour = TakeTimeDigitsWithSuffixAndAdvance(data, 2, ":");
+ if (!hour.has_value()) {
+ return str->loc.Invalid("bad hours in timestamp");
+ }
+ auto min = TakeTimeDigitsWithSuffixAndAdvance(data, 2, ":");
+ if (!min.has_value()) {
+ return str->loc.Invalid("bad minutes in timestamp");
+ }
+ auto sec = TakeTimeDigitsWithSuffixAndAdvance(data, 2, "");
+ if (!sec.has_value()) {
+ return str->loc.Invalid("bad seconds in timestamp");
+ }
+
+ arc_ui32 m_adj = *mon - 3; // March-based month.
+ arc_ui32 carry = m_adj > *mon ? 1 : 0;
+
+ arc_ui32 year_base = 4800; // Before min year, multiple of 400.
+ arc_ui32 y_adj = *year + year_base - carry;
+
+ arc_ui32 month_days = ((m_adj + carry * 12) * 62719 + 769) / 2048;
+ arc_ui32 leap_days = y_adj / 4 - y_adj / 100 + y_adj / 400;
+ arc_i32 epoch_days =
+ y_adj * 365 + leap_days + month_days + (*day - 1) - 2472632;
+
+ secs = arc_i64{epoch_days} * 86400 + *hour * 3600 + *min * 60 + *sec;
+ }
+
+ auto nanos = TakeNanosAndAdvance(data);
+ if (!nanos.has_value()) {
+ return str->loc.Invalid("timestamp had bad nanoseconds");
+ }
+
+ if (data.empty()) {
+ return str->loc.Invalid("timestamp missing timezone offset");
+ }
+
+ {
+ // [+-]hh:mm or Z
+ bool neg = false;
+ switch (data[0]) {
+ case '-':
+ neg = true;
+ Y_ABSL_FALLTHROUGH_INTENDED;
+ case '+': {
+ if (data.size() != 6) {
+ return str->loc.Invalid("timestamp offset of wrong size.");
+ }
+
+ data = data.substr(1);
+ auto hour = TakeTimeDigitsWithSuffixAndAdvance(data, 2, ":");
+ auto mins = TakeTimeDigitsWithSuffixAndAdvance(data, 2, "");
+ if (!hour.has_value() || !mins.has_value()) {
+ return str->loc.Invalid("timestamp offset has bad hours and minutes");
+ }
+
+ arc_i64 offset = (*hour * 60 + *mins) * 60;
+ secs += (neg ? offset : -offset);
+ break;
+ }
+ // Lowercase z is not accepted, per the spec.
+ case 'Z':
+ if (data.size() == 1) {
+ break;
+ }
+ Y_ABSL_FALLTHROUGH_INTENDED;
+ default:
+ return str->loc.Invalid("bad timezone offset");
+ }
+ }
+
+ Traits::SetInt64(Traits::MustHaveField(desc, 1), msg, secs);
+ Traits::SetInt32(Traits::MustHaveField(desc, 2), msg, *nanos);
+
+ return y_absl::OkStatus();
+}
+
+template <typename Traits>
+y_absl::Status ParseDuration(JsonLexer& lex, const Desc<Traits>& desc,
+ Msg<Traits>& msg) {
+ if (lex.Peek(JsonLexer::kNull)) {
+ return lex.Expect("null");
+ }
+
+ constexpr arc_i64 kMaxSeconds = arc_i64{3652500} * 86400;
+
+ y_absl::StatusOr<LocationWith<MaybeOwnedString>> str = lex.ParseUtf8();
+ RETURN_IF_ERROR(str.status());
+
+ size_t int_part_end = 0;
+ for (char c : str->value.AsView()) {
+ if (!y_absl::ascii_isdigit(c) && c != '-') {
+ break;
+ }
+ ++int_part_end;
+ }
+ if (int_part_end == 0) {
+ return str->loc.Invalid("duration must start with an integer");
+ }
+
+ y_absl::string_view sec_digits = str->value.AsView().substr(0, int_part_end);
+ arc_i64 secs;
+ if (!y_absl::SimpleAtoi(sec_digits, &secs)) {
+ return str->loc.Invalid("duration had bad seconds");
+ }
+
+ if (secs > kMaxSeconds || secs < -kMaxSeconds) {
+ return str->loc.Invalid("duration out of range");
+ }
+
+ y_absl::string_view rest = str->value.AsView().substr(int_part_end);
+ auto nanos = TakeNanosAndAdvance(rest);
+ if (!nanos.has_value()) {
+ return str->loc.Invalid("duration had bad nanoseconds");
+ }
+
+ bool isNegative = (secs < 0) || y_absl::StartsWith(sec_digits, "-");
+ if (isNegative) {
+ *nanos *= -1;
+ }
+
+ if (rest != "s") {
+ return str->loc.Invalid("duration must end with a single 's'");
+ }
+
+ Traits::SetInt64(Traits::MustHaveField(desc, 1), msg, secs);
+ Traits::SetInt32(Traits::MustHaveField(desc, 2), msg, *nanos);
+
+ return y_absl::OkStatus();
+}
+
+template <typename Traits>
+y_absl::Status ParseFieldMask(JsonLexer& lex, const Desc<Traits>& desc,
+ Msg<Traits>& msg) {
+ y_absl::StatusOr<LocationWith<MaybeOwnedString>> str = lex.ParseUtf8();
+ RETURN_IF_ERROR(str.status());
+ auto paths = str->value.AsView();
+
+ // The special case of the empty string is not handled correctly below,
+ // because StrSplit("", ',') is [""], not [].
+ if (paths.empty()) {
+ return y_absl::OkStatus();
+ }
+
+ // google.protobuf.FieldMask has a single field with number 1.
+ auto paths_field = Traits::MustHaveField(desc, 1);
+ for (y_absl::string_view path : y_absl::StrSplit(paths, ',')) {
+ TProtoStringType snake_path;
+ // Assume approximately six-letter words, so add one extra space for an
+ // underscore for every six bytes.
+ snake_path.reserve(path.size() * 7 / 6);
+
+ // Port from protobuf 21.x for entity/ugc (TODO remove?).
+ bool is_quoted = false;
+ bool is_escaping = false;
+
+ for (char c : path) {
+ // Outputs quoted string as-is.
+ if (is_quoted) {
+ snake_path.push_back(c);
+ if (is_escaping) {
+ is_escaping = false;
+ } else if (c == '\\') {
+ is_escaping = true;
+ } else if (c == '\"') {
+ is_quoted = false;
+ }
+ continue;
+ }
+ if (y_absl::ascii_isdigit(c) || y_absl::ascii_islower(c) || c == '.') {
+ snake_path.push_back(c);
+ } else if (y_absl::ascii_isupper(c)) {
+ snake_path.push_back('_');
+ snake_path.push_back(y_absl::ascii_tolower(c));
+ } else if (lex.options().allow_legacy_syntax) {
+ is_quoted = c == '\"';
+ snake_path.push_back(c);
+ } else {
+ return str->loc.Invalid("unexpected character in FieldMask");
+ }
+ }
+ Traits::SetString(paths_field, msg, snake_path);
+ }
+
+ return y_absl::OkStatus();
+}
+
+template <typename Traits>
+y_absl::Status ParseAny(JsonLexer& lex, const Desc<Traits>& desc,
+ Msg<Traits>& msg) {
+ // Buffer an entire object. Because @type can occur anywhere, we're forced
+ // to do this.
+ RETURN_IF_ERROR(lex.SkipToToken());
+ auto mark = lex.BeginMark();
+
+ // Search for @type, buffering the entire object along the way so we can
+ // reparse it.
+ y_absl::optional<MaybeOwnedString> type_url;
+ RETURN_IF_ERROR(lex.VisitObject(
+ [&](const LocationWith<MaybeOwnedString>& key) -> y_absl::Status {
+ if (key.value == "@type") {
+ if (type_url.has_value()) {
+ return key.loc.Invalid("repeated @type in Any");
+ }
+
+ y_absl::StatusOr<LocationWith<MaybeOwnedString>> maybe_url =
+ lex.ParseUtf8();
+ RETURN_IF_ERROR(maybe_url.status());
+ type_url = std::move(maybe_url)->value;
+ return y_absl::OkStatus();
+ }
+ return lex.SkipValue();
+ }));
+
+ // Build a new lexer over the skipped object.
+ y_absl::string_view any_text = mark.value.UpToUnread();
+ io::ArrayInputStream in(any_text.data(), any_text.size());
+ // Copying lex.options() is important; it inherits the recursion
+ // limit.
+ JsonLexer any_lex(&in, lex.options(), &lex.path(), mark.loc);
+
+ if (!type_url.has_value() && !lex.options().allow_legacy_syntax) {
+ return mark.loc.Invalid("missing @type in Any");
+ }
+
+ if (type_url.has_value()) {
+ Traits::SetString(Traits::MustHaveField(desc, 1), msg, type_url->AsView());
+ return Traits::NewDynamic(
+ Traits::MustHaveField(desc, 2), type_url->ToString(), msg,
+ [&](const Desc<Traits>& desc, Msg<Traits>& msg) {
+ auto pop = any_lex.path().Push("<any>", FieldDescriptor::TYPE_MESSAGE,
+ Traits::TypeName(desc));
+ return ParseMessage<Traits>(any_lex, desc, msg,
+ /*any_reparse=*/true);
+ });
+ } else {
+ // Empty {} is accepted in legacy mode.
+ Y_ABSL_DCHECK(lex.options().allow_legacy_syntax);
+ RETURN_IF_ERROR(any_lex.VisitObject([&](auto&) {
+ return mark.loc.Invalid(
+ "in legacy mode, missing @type in Any is only allowed for an empty "
+ "object");
+ }));
+ return y_absl::OkStatus();
+ }
+}
+
+// These are mutually recursive with ParseValue.
+template <typename Traits>
+y_absl::Status ParseStructValue(JsonLexer& lex, const Desc<Traits>& desc,
+ Msg<Traits>& msg);
+template <typename Traits>
+y_absl::Status ParseListValue(JsonLexer& lex, const Desc<Traits>& desc,
+ Msg<Traits>& msg);
+
+template <typename Traits>
+y_absl::Status ParseValue(JsonLexer& lex, const Desc<Traits>& desc,
+ Msg<Traits>& msg) {
+ auto kind = lex.PeekKind();
+ RETURN_IF_ERROR(kind.status());
+ // NOTE: The field numbers 1 through 6 are the numbers of the oneof fields
+ // in google.protobuf.Value. Conformance tests verify the correctness of
+ // these numbers.
+ switch (*kind) {
+ case JsonLexer::kNull: {
+ auto field = Traits::MustHaveField(desc, 1);
+ auto pop =
+ lex.path().Push(Traits::FieldName(field), Traits::FieldType(field),
+ Traits::FieldTypeName(field));
+
+ RETURN_IF_ERROR(lex.Expect("null"));
+ Traits::SetEnum(field, msg, 0);
+ break;
+ }
+ case JsonLexer::kNum: {
+ auto field = Traits::MustHaveField(desc, 2);
+ auto pop =
+ lex.path().Push(Traits::FieldName(field), Traits::FieldType(field),
+ Traits::FieldTypeName(field));
+
+ auto number = lex.ParseNumber();
+ RETURN_IF_ERROR(number.status());
+ Traits::SetDouble(field, msg, number->value);
+ break;
+ }
+ case JsonLexer::kStr: {
+ auto field = Traits::MustHaveField(desc, 3);
+ auto pop =
+ lex.path().Push(Traits::FieldName(field), Traits::FieldType(field),
+ Traits::FieldTypeName(field));
+
+ auto str = lex.ParseUtf8();
+ RETURN_IF_ERROR(str.status());
+ Traits::SetString(field, msg, std::move(str->value.ToString()));
+ break;
+ }
+ case JsonLexer::kFalse:
+ case JsonLexer::kTrue: {
+ auto field = Traits::MustHaveField(desc, 4);
+ auto pop =
+ lex.path().Push(Traits::FieldName(field), Traits::FieldType(field),
+ Traits::FieldTypeName(field));
+
+ // "Quoted" bools, including non-standard Abseil Atob bools, are not
+ // supported, because all strings are treated as genuine JSON strings.
+ if (*kind == JsonLexer::kTrue) {
+ RETURN_IF_ERROR(lex.Expect("true"));
+ Traits::SetBool(field, msg, true);
+ } else {
+ RETURN_IF_ERROR(lex.Expect("false"));
+ Traits::SetBool(field, msg, false);
+ }
+ break;
+ }
+ case JsonLexer::kObj: {
+ auto field = Traits::MustHaveField(desc, 5);
+ auto pop =
+ lex.path().Push(Traits::FieldName(field), Traits::FieldType(field),
+ Traits::FieldTypeName(field));
+
+ return Traits::NewMsg(field, msg, [&](auto& desc, auto& msg) {
+ return ParseStructValue<Traits>(lex, desc, msg);
+ });
+ }
+ case JsonLexer::kArr: {
+ auto field = Traits::MustHaveField(desc, 6);
+ auto pop =
+ lex.path().Push(Traits::FieldName(field), Traits::FieldType(field),
+ Traits::FieldTypeName(field));
+
+ return Traits::NewMsg(field, msg, [&](auto& desc, auto& msg) {
+ return ParseListValue<Traits>(lex, desc, msg);
+ });
+ }
+ }
+
+ return y_absl::OkStatus();
+}
+
+template <typename Traits>
+y_absl::Status ParseStructValue(JsonLexer& lex, const Desc<Traits>& desc,
+ Msg<Traits>& msg) {
+ auto entry_field = Traits::MustHaveField(desc, 1);
+ auto pop = lex.path().Push("<struct>", FieldDescriptor::TYPE_MESSAGE,
+ Traits::FieldTypeName(entry_field));
+
+ // Structs are always cleared even if set to {}.
+ Traits::RecordAsSeen(entry_field, msg);
+
+ // Parsing a map does the right thing: Struct has a single map<string,
+ // Value> field; keys are correctly parsed as strings, and the values
+ // recurse into ParseMessage, which will be routed into ParseValue. This
+ // results in some extra overhead, but performance is not what we're going
+ // for here.
+ return ParseMap<Traits>(lex, entry_field, msg);
+}
+
+template <typename Traits>
+y_absl::Status ParseListValue(JsonLexer& lex, const Desc<Traits>& desc,
+ Msg<Traits>& msg) {
+ auto entry_field = Traits::MustHaveField(desc, 1);
+ auto pop = lex.path().Push("<list>", FieldDescriptor::TYPE_MESSAGE,
+ Traits::FieldTypeName(entry_field));
+
+ // ListValues are always cleared even if set to [].
+ Traits::RecordAsSeen(entry_field, msg);
+ // Parsing an array does the right thing: see the analogous comment in
+ // ParseStructValue.
+ return ParseArray<Traits>(lex, entry_field, msg);
+}
+
+template <typename Traits>
+y_absl::Status ParseField(JsonLexer& lex, const Desc<Traits>& desc,
+ y_absl::string_view name, Msg<Traits>& msg) {
+ y_absl::optional<Field<Traits>> field;
+ if (y_absl::StartsWith(name, "[") && y_absl::EndsWith(name, "]")) {
+ y_absl::string_view extn_name = name.substr(1, name.size() - 2);
+ field = Traits::ExtensionByName(desc, extn_name);
+
+ if (field.has_value()) {
+ // The check for whether this is an invalid field occurs below, since it
+ // is combined for both extension and non-extension fields.
+ auto correct_type_name = Traits::TypeName(desc);
+ if (Traits::TypeName(Traits::ContainingType(*field)) !=
+ correct_type_name) {
+ return lex.Invalid(y_absl::StrFormat(
+ "'%s' is a known extension name, but is not an extension "
+ "of '%s' as expected",
+ extn_name, correct_type_name));
+ }
+ }
+ } else {
+ field = Traits::FieldByName(desc, name);
+ }
+
+ if (!field.has_value()) {
+ if (!lex.options().ignore_unknown_fields) {
+ return lex.Invalid(y_absl::StrFormat("no such field: '%s'", name));
+ }
+ return lex.SkipValue();
+ }
+
+ auto pop = lex.path().Push(name, Traits::FieldType(*field),
+ Traits::FieldTypeName(*field));
+
+ if (Traits::HasParsed(
+ *field, msg,
+ /*allow_repeated_non_oneof=*/lex.options().allow_legacy_syntax) &&
+ !lex.Peek(JsonLexer::kNull)) {
+ return lex.Invalid(y_absl::StrFormat(
+ "'%s' has already been set (either directly or as part of a oneof)",
+ name));
+ }
+
+ if (Traits::IsMap(*field)) {
+ return ParseMap<Traits>(lex, *field, msg);
+ }
+
+ if (Traits::IsRepeated(*field)) {
+ if (lex.options().allow_legacy_syntax && !lex.Peek(JsonLexer::kArr)) {
+ // The original ESF parser permits a single element in place of an array
+ // thereof.
+ return ParseSingular<Traits>(lex, *field, msg);
+ }
+ return ParseArray<Traits>(lex, *field, msg);
+ }
+
+ return ParseSingular<Traits>(lex, *field, msg);
+}
+
+template <typename Traits>
+y_absl::Status ParseMessage(JsonLexer& lex, const Desc<Traits>& desc,
+ Msg<Traits>& msg, bool any_reparse) {
+ MessageType type = ClassifyMessage(Traits::TypeName(desc));
+ if (!any_reparse) {
+ switch (type) {
+ case MessageType::kAny:
+ return ParseAny<Traits>(lex, desc, msg);
+ case MessageType::kValue:
+ return ParseValue<Traits>(lex, desc, msg);
+ case MessageType::kStruct:
+ return ParseStructValue<Traits>(lex, desc, msg);
+ default:
+ break;
+ }
+ // For some types, the ESF parser permits parsing the "non-special" version.
+ // It is not clear if this counts as out-of-spec, but we're treating it as
+ // such.
+ bool is_upcoming_object = lex.Peek(JsonLexer::kObj);
+ if (!(is_upcoming_object && lex.options().allow_legacy_syntax)) {
+ switch (type) {
+ case MessageType::kList:
+ return ParseListValue<Traits>(lex, desc, msg);
+ case MessageType::kWrapper: {
+ return ParseSingular<Traits>(lex, Traits::MustHaveField(desc, 1),
+ msg);
+ }
+ case MessageType::kTimestamp:
+ return ParseTimestamp<Traits>(lex, desc, msg);
+ case MessageType::kDuration:
+ return ParseDuration<Traits>(lex, desc, msg);
+ case MessageType::kFieldMask:
+ return ParseFieldMask<Traits>(lex, desc, msg);
+ default:
+ break;
+ }
+ }
+ }
+
+ return lex.VisitObject(
+ [&](LocationWith<MaybeOwnedString>& name) -> y_absl::Status {
+ // If this is a well-known type, we expect its contents to be inside
+ // of a JSON field named "value".
+ if (any_reparse) {
+ if (name.value == "@type") {
+ RETURN_IF_ERROR(lex.SkipValue());
+ return y_absl::OkStatus();
+ }
+ if (type != MessageType::kNotWellKnown) {
+ if (name.value != "value") {
+ return lex.Invalid(
+ "fields in a well-known-typed Any must be @type or value");
+ }
+ // Parse the upcoming value as the message itself. This is *not*
+ // an Any reparse because we do not expect to see @type in the
+ // upcoming value.
+ return ParseMessage<Traits>(lex, desc, msg,
+ /*any_reparse=*/false);
+ }
+ }
+
+ return ParseField<Traits>(lex, desc, name.value.AsView(), msg);
+ });
+}
+} // namespace
+
+y_absl::Status JsonStringToMessage(y_absl::string_view input, Message* message,
+ json_internal::ParseOptions options) {
+ MessagePath path(message->GetDescriptor()->full_name());
+ PROTOBUF_DLOG(INFO) << "json2/input: " << y_absl::CHexEscape(input);
+ io::ArrayInputStream in(input.data(), input.size());
+ JsonLexer lex(&in, options, &path);
+
+ ParseProto2Descriptor::Msg msg(message);
+ y_absl::Status s =
+ ParseMessage<ParseProto2Descriptor>(lex, *message->GetDescriptor(), msg,
+ /*any_reparse=*/false);
+ if (s.ok() && !lex.AtEof()) {
+ s = y_absl::InvalidArgumentError(
+ "extraneous characters after end of JSON object");
+ }
+ if (s.ok() && !message->IsInitialized()) {
+ s = y_absl::InvalidArgumentError("Not all fileds are sets");
+ }
+
+ PROTOBUF_DLOG(INFO) << "json2/status: " << s;
+ PROTOBUF_DLOG(INFO) << "json2/output: " << message->DebugString();
+
+ return s;
+}
+
+y_absl::Status JsonToBinaryStream(google::protobuf::util::TypeResolver* resolver,
+ const TProtoStringType& type_url,
+ io::ZeroCopyInputStream* json_input,
+ io::ZeroCopyOutputStream* binary_output,
+ json_internal::ParseOptions options) {
+ // NOTE: Most of the contortions in this function are to allow for capture of
+ // input and output of the parser in Y_ABSL_DLOG mode. Destruction order is very
+ // critical in this function, because io::ZeroCopy*Stream types usually only
+ // flush on destruction.
+
+ // For Y_ABSL_DLOG, we would like to print out the input and output, which
+ // requires buffering both instead of doing "zero copy". This block, and the
+ // one at the end of the function, set up and tear down interception of the
+ // input and output streams.
+ TProtoStringType copy;
+ TProtoStringType out;
+ y_absl::optional<io::ArrayInputStream> tee_input;
+ y_absl::optional<io::StringOutputStream> tee_output;
+ if (PROTOBUF_DEBUG) {
+ const void* data;
+ int len;
+ while (json_input->Next(&data, &len)) {
+ copy.resize(copy.size() + len);
+ std::memcpy(&copy[copy.size() - len], data, len);
+ }
+ tee_input.emplace(copy.data(), copy.size());
+ tee_output.emplace(&out);
+ }
+
+ PROTOBUF_DLOG(INFO) << "json2/input: " << y_absl::CHexEscape(copy);
+
+ // This scope forces the CodedOutputStream inside of `msg` to flush before we
+ // possibly handle logging the binary protobuf output.
+ y_absl::Status s;
+ {
+ MessagePath path(type_url);
+ JsonLexer lex(tee_input.has_value() ? &*tee_input : json_input, options,
+ &path);
+ Msg<ParseProto3Type> msg(tee_output.has_value() ? &*tee_output
+ : binary_output);
+
+ ResolverPool pool(resolver);
+ auto desc = pool.FindMessage(type_url);
+ RETURN_IF_ERROR(desc.status());
+
+ s = ParseMessage<ParseProto3Type>(lex, **desc, msg, /*any_reparse=*/false);
+ if (s.ok() && !lex.AtEof()) {
+ s = y_absl::InvalidArgumentError(
+ "extraneous characters after end of JSON object");
+ }
+ }
+
+ if (PROTOBUF_DEBUG) {
+ tee_output.reset(); // Flush the output stream.
+ io::zc_sink_internal::ZeroCopyStreamByteSink(binary_output)
+ .Append(out.data(), out.size());
+ }
+
+ PROTOBUF_DLOG(INFO) << "json2/status: " << s;
+ PROTOBUF_DLOG(INFO) << "json2/output: " << y_absl::BytesToHexString(out);
+ return s;
+}
+} // namespace json_internal
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/json/internal/parser.h b/contrib/libs/protobuf/src/google/protobuf/json/internal/parser.h
new file mode 100644
index 00000000000..346dc28be8a
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/json/internal/parser.h
@@ -0,0 +1,59 @@
+// 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_JSON_INTERNAL_PARSER_H__
+#define GOOGLE_PROTOBUF_JSON_INTERNAL_PARSER_H__
+
+#include <string>
+
+#include "google/protobuf/message.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/json/internal/lexer.h"
+#include "google/protobuf/util/type_resolver.h"
+
+namespace google {
+namespace protobuf {
+namespace json_internal {
+// Internal version of google::protobuf::util::JsonStringToMessage; see json_util.h for
+// details.
+y_absl::Status JsonStringToMessage(y_absl::string_view input, Message* message,
+ json_internal::ParseOptions options);
+// Internal version of google::protobuf::util::JsonToBinaryStream; see json_util.h for
+// details.
+y_absl::Status JsonToBinaryStream(google::protobuf::util::TypeResolver* resolver,
+ const TProtoStringType& type_url,
+ io::ZeroCopyInputStream* json_input,
+ io::ZeroCopyOutputStream* binary_output,
+ json_internal::ParseOptions options);
+} // namespace json_internal
+} // namespace protobuf
+} // namespace google
+
+#endif // GOOGLE_PROTOBUF_JSON_INTERNAL_PARSER_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/json/internal/parser_traits.h b/contrib/libs/protobuf/src/google/protobuf/json/internal/parser_traits.h
new file mode 100644
index 00000000000..1d3e68e8968
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/json/internal/parser_traits.h
@@ -0,0 +1,423 @@
+// 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_JSON_INTERNAL_PARSER_TRAITS_H__
+#define GOOGLE_PROTOBUF_JSON_INTERNAL_PARSER_TRAITS_H__
+
+#include <cfloat>
+#include <cmath>
+#include <cstdint>
+#include <limits>
+#include <memory>
+#include <string>
+#include <utility>
+
+#include "google/protobuf/type.pb.h"
+#include "y_absl/base/attributes.h"
+#include "y_absl/base/casts.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/status/status.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/string_view.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/json/internal/descriptor_traits.h"
+#include "google/protobuf/wire_format_lite.h"
+#include "google/protobuf/stubs/status_macros.h"
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace json_internal {
+using ::google::protobuf::internal::WireFormatLite;
+
+// See the comment in json_util2_parser.cc for more information.
+//
+// The type traits in this file describe how to parse to a protobuf
+// representation used by the JSON API, either via proto reflection or by
+// emitting wire format to an output stream.
+
+// Helper alias templates to avoid needing to write `typename` in function
+// signatures.
+template <typename Traits>
+using Msg = typename Traits::Msg;
+
+struct ParseProto2Descriptor : Proto2Descriptor {
+ // A message value that fields can be written to, but not read from.
+ class Msg {
+ public:
+ explicit Msg(Message* msg) : msg_(msg) {}
+
+ private:
+ friend ParseProto2Descriptor;
+ Message* msg_;
+ // Because `msg` might already have oneofs set, we need to track which were
+ // set *during* the parse separately.
+ y_absl::flat_hash_set<int> parsed_oneofs_indices_;
+ y_absl::flat_hash_set<int> parsed_fields_;
+ };
+
+ static bool HasParsed(Field f, const Msg& msg,
+ bool allow_repeated_non_oneof) {
+ if (f->real_containing_oneof()) {
+ return msg.parsed_oneofs_indices_.contains(
+ f->real_containing_oneof()->index());
+ }
+ if (allow_repeated_non_oneof) {
+ return false;
+ }
+ return msg.parsed_fields_.contains(f->number());
+ }
+
+ /// Functions for writing fields. ///
+
+ // Marks a field as having been "seen". This will clear the field if it is
+ // the first occurrence thereof.
+ //
+ // All setters call this function automatically, but it may also be called
+ // eagerly to clear a pre-existing value that might not be overwritten, such
+ // as when parsing a repeated field.
+ static void RecordAsSeen(Field f, Msg& msg) {
+ bool inserted = msg.parsed_fields_.insert(f->number()).second;
+ if (inserted) {
+ msg.msg_->GetReflection()->ClearField(msg.msg_, f);
+ }
+
+ if (f->real_containing_oneof() != nullptr) {
+ msg.parsed_oneofs_indices_.insert(f->real_containing_oneof()->index());
+ }
+ }
+
+ // Adds a new message and calls body on it.
+ //
+ // Body should have a signature `y_absl::Status(const Desc&, Msg&)`.
+ template <typename F>
+ static y_absl::Status NewMsg(Field f, Msg& msg, F body) {
+ RecordAsSeen(f, msg);
+
+ Message* new_msg;
+ if (f->is_repeated()) {
+ new_msg = msg.msg_->GetReflection()->AddMessage(msg.msg_, f);
+ } else {
+ new_msg = msg.msg_->GetReflection()->MutableMessage(msg.msg_, f);
+ }
+ Msg wrapper(new_msg);
+ return body(*f->message_type(), wrapper);
+ }
+
+ // Adds a new dynamic message with the given type name and calls body on it.
+ //
+ // Body should have a signature `y_absl::Status(const Desc&, Msg&)`.
+ template <typename F>
+ static y_absl::Status NewDynamic(Field f, const TProtoStringType& type_url, Msg& msg,
+ F body) {
+ RecordAsSeen(f, msg);
+ return WithDynamicType(
+ *f->containing_type(), type_url, [&](const Desc& desc) -> y_absl::Status {
+ DynamicMessageFactory factory;
+ std::unique_ptr<Message> dynamic(factory.GetPrototype(&desc)->New());
+ Msg wrapper(dynamic.get());
+ RETURN_IF_ERROR(body(desc, wrapper));
+
+ if (f->is_repeated()) {
+ msg.msg_->GetReflection()->AddString(
+ msg.msg_, f, dynamic->SerializePartialAsString());
+ } else {
+ msg.msg_->GetReflection()->SetString(
+ msg.msg_, f, dynamic->SerializePartialAsString());
+ }
+ return y_absl::OkStatus();
+ });
+ }
+
+ static void SetFloat(Field f, Msg& msg, float x) {
+ RecordAsSeen(f, msg);
+ if (f->is_repeated()) {
+ msg.msg_->GetReflection()->AddFloat(msg.msg_, f, x);
+ } else {
+ msg.msg_->GetReflection()->SetFloat(msg.msg_, f, x);
+ }
+ }
+
+ static void SetDouble(Field f, Msg& msg, double x) {
+ if (f->is_repeated()) {
+ msg.msg_->GetReflection()->AddDouble(msg.msg_, f, x);
+ } else {
+ msg.msg_->GetReflection()->SetDouble(msg.msg_, f, x);
+ }
+ }
+
+ static void SetInt64(Field f, Msg& msg, arc_i64 x) {
+ RecordAsSeen(f, msg);
+ if (f->is_repeated()) {
+ msg.msg_->GetReflection()->AddInt64(msg.msg_, f, x);
+ } else {
+ msg.msg_->GetReflection()->SetInt64(msg.msg_, f, x);
+ }
+ }
+
+ static void SetUInt64(Field f, Msg& msg, arc_ui64 x) {
+ RecordAsSeen(f, msg);
+ if (f->is_repeated()) {
+ msg.msg_->GetReflection()->AddUInt64(msg.msg_, f, x);
+ } else {
+ msg.msg_->GetReflection()->SetUInt64(msg.msg_, f, x);
+ }
+ }
+
+ static void SetInt32(Field f, Msg& msg, int32 x) {
+ RecordAsSeen(f, msg);
+ if (f->is_repeated()) {
+ msg.msg_->GetReflection()->AddInt32(msg.msg_, f, x);
+ } else {
+ msg.msg_->GetReflection()->SetInt32(msg.msg_, f, x);
+ }
+ }
+
+ static void SetUInt32(Field f, Msg& msg, uint32 x) {
+ RecordAsSeen(f, msg);
+ if (f->is_repeated()) {
+ msg.msg_->GetReflection()->AddUInt32(msg.msg_, f, x);
+ } else {
+ msg.msg_->GetReflection()->SetUInt32(msg.msg_, f, x);
+ }
+ }
+
+ static void SetBool(Field f, Msg& msg, bool x) {
+ RecordAsSeen(f, msg);
+ if (f->is_repeated()) {
+ msg.msg_->GetReflection()->AddBool(msg.msg_, f, x);
+ } else {
+ msg.msg_->GetReflection()->SetBool(msg.msg_, f, x);
+ }
+ }
+
+ static void SetString(Field f, Msg& msg, y_absl::string_view x) {
+ RecordAsSeen(f, msg);
+ if (f->is_repeated()) {
+ msg.msg_->GetReflection()->AddString(msg.msg_, f, TProtoStringType(x));
+ } else {
+ msg.msg_->GetReflection()->SetString(msg.msg_, f, TProtoStringType(x));
+ }
+ }
+
+ static void SetEnum(Field f, Msg& msg, arc_i32 x) {
+ RecordAsSeen(f, msg);
+ if (f->is_repeated()) {
+ msg.msg_->GetReflection()->AddEnumValue(msg.msg_, f, x);
+ } else {
+ msg.msg_->GetReflection()->SetEnumValue(msg.msg_, f, x);
+ }
+ }
+};
+
+// Traits for proto3-ish deserialization.
+//
+// This includes a rudimentary proto serializer, since message fields are
+// written directly instead of being reflectively written to a proto field.
+//
+// See MessageTraits for API docs.
+struct ParseProto3Type : Proto3Type {
+ class Msg {
+ public:
+ explicit Msg(io::ZeroCopyOutputStream* stream) : stream_(stream) {}
+
+ private:
+ friend ParseProto3Type;
+ io::CodedOutputStream stream_;
+ y_absl::flat_hash_set<arc_i32> parsed_oneofs_indices_;
+ y_absl::flat_hash_set<arc_i32> parsed_fields_;
+ };
+
+ static bool HasParsed(Field f, const Msg& msg,
+ bool allow_repeated_non_oneof) {
+ if (f->proto().oneof_index() != 0) {
+ return msg.parsed_oneofs_indices_.contains(f->proto().oneof_index());
+ }
+ if (allow_repeated_non_oneof) {
+ return false;
+ }
+ return msg.parsed_fields_.contains(f->proto().number());
+ }
+
+ /// Functions for writing fields. ///
+
+ static void RecordAsSeen(Field f, Msg& msg) {
+ msg.parsed_fields_.insert(f->proto().number());
+ if (f->proto().oneof_index() != 0) {
+ msg.parsed_oneofs_indices_.insert(f->proto().oneof_index());
+ }
+ }
+
+ template <typename F>
+ static y_absl::Status NewMsg(Field f, Msg& msg, F body) {
+ return NewDynamic(f, f->proto().type_url(), msg, body);
+ }
+
+ template <typename F>
+ static y_absl::Status NewDynamic(Field f, const TProtoStringType& type_url, Msg& msg,
+ F body) {
+ RecordAsSeen(f, msg);
+ return WithDynamicType(
+ f->parent(), type_url, [&](const Desc& desc) -> y_absl::Status {
+ if (f->proto().kind() == google::protobuf::Field::TYPE_GROUP) {
+ msg.stream_.WriteTag(f->proto().number() << 3 |
+ WireFormatLite::WIRETYPE_START_GROUP);
+ RETURN_IF_ERROR(body(desc, msg));
+ msg.stream_.WriteTag(f->proto().number() << 3 |
+ WireFormatLite::WIRETYPE_END_GROUP);
+ return y_absl::OkStatus();
+ }
+
+ TProtoStringType out;
+ io::StringOutputStream stream(&out);
+ Msg new_msg(&stream);
+ RETURN_IF_ERROR(body(desc, new_msg));
+
+ new_msg.stream_.Trim(); // Should probably be called "Flush()".
+ y_absl::string_view written(
+ out.data(), static_cast<size_t>(new_msg.stream_.ByteCount()));
+ SetString(f, msg, written);
+ return y_absl::OkStatus();
+ });
+ }
+
+ static void SetFloat(Field f, Msg& msg, float x) {
+ RecordAsSeen(f, msg);
+ msg.stream_.WriteTag(f->proto().number() << 3 |
+ WireFormatLite::WIRETYPE_FIXED32);
+ msg.stream_.WriteLittleEndian32(y_absl::bit_cast<arc_ui32>(x));
+ }
+
+ static void SetDouble(Field f, Msg& msg, double x) {
+ RecordAsSeen(f, msg);
+ msg.stream_.WriteTag(f->proto().number() << 3 |
+ WireFormatLite::WIRETYPE_FIXED64);
+ msg.stream_.WriteLittleEndian64(y_absl::bit_cast<arc_ui64>(x));
+ }
+
+ static void SetInt64(Field f, Msg& msg, arc_i64 x) {
+ SetInt<arc_i64, google::protobuf::Field::TYPE_INT64,
+ google::protobuf::Field::TYPE_SFIXED64,
+ google::protobuf::Field::TYPE_SINT64>(f, msg, x);
+ }
+
+ static void SetUInt64(Field f, Msg& msg, arc_ui64 x) {
+ SetInt<arc_ui64, google::protobuf::Field::TYPE_UINT64,
+ google::protobuf::Field::TYPE_FIXED64,
+ google::protobuf::Field::TYPE_UNKNOWN>(f, msg, x);
+ }
+
+ static void SetInt32(Field f, Msg& msg, arc_i32 x) {
+ SetInt<arc_i32, google::protobuf::Field::TYPE_INT32,
+ google::protobuf::Field::TYPE_SFIXED32,
+ google::protobuf::Field::TYPE_SINT32>(f, msg, x);
+ }
+
+ static void SetUInt32(Field f, Msg& msg, arc_ui32 x) {
+ SetInt<arc_ui32, google::protobuf::Field::TYPE_UINT32,
+ google::protobuf::Field::TYPE_FIXED32,
+ google::protobuf::Field::TYPE_UNKNOWN>(f, msg, x);
+ }
+
+ static void SetBool(Field f, Msg& msg, bool x) {
+ RecordAsSeen(f, msg);
+ msg.stream_.WriteTag(f->proto().number() << 3);
+ char b = x ? 0x01 : 0x00;
+ msg.stream_.WriteRaw(&b, 1);
+ }
+
+ static void SetString(Field f, Msg& msg, y_absl::string_view x) {
+ RecordAsSeen(f, msg);
+ msg.stream_.WriteTag(f->proto().number() << 3 |
+ WireFormatLite::WIRETYPE_LENGTH_DELIMITED);
+ msg.stream_.WriteVarint64(static_cast<arc_ui64>(x.size()));
+ msg.stream_.WriteRaw(x.data(), x.size());
+ }
+
+ static void SetEnum(Field f, Msg& msg, arc_i32 x) {
+ RecordAsSeen(f, msg);
+ msg.stream_.WriteTag(f->proto().number() << 3);
+ // Sign extension is deliberate here.
+ msg.stream_.WriteVarint32(x);
+ }
+
+ private:
+ using Kind = google::protobuf::Field::Kind;
+ // Sets a field of *some* integer type, with the given kinds for the possible
+ // encodings. This avoids quadruplicating this code in the helpers for the
+ // four major integer types.
+ template <typename Int, Kind varint, Kind fixed, Kind zigzag>
+ static void SetInt(Field f, Msg& msg, Int x) {
+ RecordAsSeen(f, msg);
+ switch (f->proto().kind()) {
+ case zigzag:
+ // Regardless of the integer type, ZigZag64 will do the right thing,
+ // because ZigZag is not dependent on the width of the integer: it is
+ // always `2 * abs(n) + (n < 0)`.
+ x = static_cast<Int>(
+ internal::WireFormatLite::ZigZagEncode64(static_cast<arc_i64>(x)));
+ Y_ABSL_FALLTHROUGH_INTENDED;
+ case varint:
+ msg.stream_.WriteTag(f->proto().number() << 3 |
+ WireFormatLite::WIRETYPE_VARINT);
+ if (sizeof(Int) == 4) {
+ msg.stream_.WriteVarint32(static_cast<arc_ui32>(x));
+ } else {
+ msg.stream_.WriteVarint64(static_cast<arc_ui64>(x));
+ }
+ break;
+ case fixed: {
+ if (sizeof(Int) == 4) {
+ msg.stream_.WriteTag(f->proto().number() << 3 |
+ WireFormatLite::WIRETYPE_FIXED32);
+ msg.stream_.WriteLittleEndian32(static_cast<arc_ui32>(x));
+ } else {
+ msg.stream_.WriteTag(f->proto().number() << 3 |
+ WireFormatLite::WIRETYPE_FIXED64);
+ msg.stream_.WriteLittleEndian64(static_cast<arc_ui64>(x));
+ }
+ break;
+ }
+ default: { // Unreachable.
+ }
+ }
+ }
+};
+} // namespace json_internal
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
+#endif // GOOGLE_PROTOBUF_JSON_INTERNAL_PARSER_TRAITS_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/json/internal/unparser.cc b/contrib/libs/protobuf/src/google/protobuf/json/internal/unparser.cc
new file mode 100644
index 00000000000..80ccf0da584
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/json/internal/unparser.cc
@@ -0,0 +1,892 @@
+// 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/json/internal/unparser.h"
+
+#include <cfloat>
+#include <complex>
+#include <cstdint>
+#include <cstring>
+#include <limits>
+#include <memory>
+#include <sstream>
+#include <string>
+#include <utility>
+
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/dynamic_message.h"
+#include "google/protobuf/message.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/status/status.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/escaping.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/types/optional.h"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/io/zero_copy_stream.h"
+#include "google/protobuf/json/internal/descriptor_traits.h"
+#include "google/protobuf/json/internal/unparser_traits.h"
+#include "google/protobuf/json/internal/writer.h"
+#include "google/protobuf/stubs/status_macros.h"
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace json_internal {
+namespace {
+template <typename Traits>
+bool IsEmpty(const Msg<Traits>& msg, const Desc<Traits>& desc) {
+ size_t count = Traits::FieldCount(desc);
+ for (size_t i = 0; i < count; ++i) {
+ if (Traits::GetSize(Traits::FieldByIndex(desc, i), msg) > 0) {
+ return false;
+ }
+ }
+ return true;
+}
+
+enum class IntegerEnumStyle {
+ kQuoted,
+ kUnquoted,
+};
+
+template <typename Traits>
+void WriteEnum(JsonWriter& writer, Field<Traits> field, arc_i32 value,
+ IntegerEnumStyle int_style = IntegerEnumStyle::kUnquoted) {
+ if (ClassifyMessage(Traits::FieldTypeName(field)) == MessageType::kNull) {
+ writer.Write("null");
+ return;
+ }
+
+ if (!writer.options().always_print_enums_as_ints) {
+ auto name = Traits::EnumNameByNumber(field, value);
+ if (name.ok()) {
+ writer.Write("\"", *name, "\"");
+ return;
+ }
+ }
+
+ if (int_style == IntegerEnumStyle::kQuoted) {
+ writer.Write("\"", value, "\"");
+ } else {
+ writer.Write(value);
+ }
+}
+
+// Mutually recursive with functions that follow.
+template <typename Traits>
+y_absl::Status WriteMessage(JsonWriter& writer, const Msg<Traits>& msg,
+ const Desc<Traits>& desc, bool is_top_level = false);
+
+// This is templatized so that defaults, singular, and repeated fields can both
+// use the same enormous switch-case.
+template <typename Traits, typename... Args>
+y_absl::Status WriteSingular(JsonWriter& writer, Field<Traits> field,
+ Args&&... args) {
+ // When the pack `args` is empty, the caller has requested printing the
+ // default value.
+ bool is_default = sizeof...(Args) == 0;
+ switch (Traits::FieldType(field)) {
+ case FieldDescriptor::TYPE_FLOAT: {
+ auto x = Traits::GetFloat(field, std::forward<Args>(args)...);
+ RETURN_IF_ERROR(x.status());
+ if (writer.options().allow_legacy_syntax && is_default &&
+ !std::isfinite(*x)) {
+ *x = 0;
+ }
+ writer.Write(*x);
+ break;
+ }
+ case FieldDescriptor::TYPE_DOUBLE: {
+ auto x = Traits::GetDouble(field, std::forward<Args>(args)...);
+ RETURN_IF_ERROR(x.status());
+ if (writer.options().allow_legacy_syntax && is_default &&
+ !std::isfinite(*x)) {
+ *x = 0;
+ }
+ writer.Write(*x);
+ break;
+ }
+ case FieldDescriptor::TYPE_SFIXED64:
+ case FieldDescriptor::TYPE_SINT64:
+ case FieldDescriptor::TYPE_INT64: {
+ auto x = Traits::GetInt64(field, std::forward<Args>(args)...);
+ RETURN_IF_ERROR(x.status());
+ writer.Write(MakeQuoted(*x));
+ break;
+ }
+ case FieldDescriptor::TYPE_FIXED64:
+ case FieldDescriptor::TYPE_UINT64: {
+ auto x = Traits::GetUInt64(field, std::forward<Args>(args)...);
+ RETURN_IF_ERROR(x.status());
+ writer.Write(MakeQuoted(*x));
+ break;
+ }
+ case FieldDescriptor::TYPE_SFIXED32:
+ case FieldDescriptor::TYPE_SINT32:
+ case FieldDescriptor::TYPE_INT32: {
+ auto x = Traits::GetInt32(field, std::forward<Args>(args)...);
+ RETURN_IF_ERROR(x.status());
+ writer.Write(*x);
+ break;
+ }
+ case FieldDescriptor::TYPE_FIXED32:
+ case FieldDescriptor::TYPE_UINT32: {
+ auto x = Traits::GetUInt32(field, std::forward<Args>(args)...);
+ RETURN_IF_ERROR(x.status());
+ writer.Write(*x);
+ break;
+ }
+ case FieldDescriptor::TYPE_BOOL: {
+ auto x = Traits::GetBool(field, std::forward<Args>(args)...);
+ RETURN_IF_ERROR(x.status());
+ writer.Write(*x ? "true" : "false");
+ break;
+ }
+ case FieldDescriptor::TYPE_STRING: {
+ auto x = Traits::GetString(field, writer.ScratchBuf(),
+ std::forward<Args>(args)...);
+ RETURN_IF_ERROR(x.status());
+ writer.Write(MakeQuoted(*x));
+ break;
+ }
+ case FieldDescriptor::TYPE_BYTES: {
+ auto x = Traits::GetString(field, writer.ScratchBuf(),
+ std::forward<Args>(args)...);
+ RETURN_IF_ERROR(x.status());
+ if (writer.options().allow_legacy_syntax && is_default) {
+ // Although difficult to verify, it appears that the original ESF parser
+ // fails to unescape the contents of a
+ // google.protobuf.Field.default_value, which may potentially be
+ // escaped if it is for a `bytes` field (note that default_value is a
+ // `string` regardless of what type the field is).
+ //
+ // However, our parser's type.proto guts actually know to do this
+ // correctly, so this bug must be manually re-introduced.
+ writer.WriteBase64(y_absl::CEscape(*x));
+ } else {
+ writer.WriteBase64(*x);
+ }
+ break;
+ }
+ case FieldDescriptor::TYPE_ENUM: {
+ auto x = Traits::GetEnumValue(field, std::forward<Args>(args)...);
+ RETURN_IF_ERROR(x.status());
+ WriteEnum<Traits>(writer, field, *x);
+ break;
+ }
+ case FieldDescriptor::TYPE_MESSAGE:
+ case FieldDescriptor::TYPE_GROUP: {
+ auto x = Traits::GetMessage(field, std::forward<Args>(args)...);
+ RETURN_IF_ERROR(x.status());
+ return WriteMessage<Traits>(writer, **x, Traits::GetDesc(**x));
+ }
+ default:
+ return y_absl::InvalidArgumentError(
+ y_absl::StrCat("unsupported field type: ", Traits::FieldType(field)));
+ }
+
+ return y_absl::OkStatus();
+}
+
+template <typename Traits>
+y_absl::Status WriteRepeated(JsonWriter& writer, const Msg<Traits>& msg,
+ Field<Traits> field) {
+ writer.Write("[");
+ writer.Push();
+
+ size_t count = Traits::GetSize(field, msg);
+ bool first = true;
+ for (size_t i = 0; i < count; ++i) {
+ if (ClassifyMessage(Traits::FieldTypeName(field)) == MessageType::kValue) {
+ bool empty = false;
+ RETURN_IF_ERROR(Traits::WithFieldType(
+ field, [&](const Desc<Traits>& desc) -> y_absl::Status {
+ auto inner = Traits::GetMessage(field, msg, i);
+ RETURN_IF_ERROR(inner.status());
+ empty = IsEmpty<Traits>(**inner, desc);
+ return y_absl::OkStatus();
+ }));
+
+ // Empty google.protobuf.Values are silently discarded.
+ if (empty) {
+ continue;
+ }
+ }
+ writer.WriteComma(first);
+ writer.NewLine();
+ RETURN_IF_ERROR(WriteSingular<Traits>(writer, field, msg, i));
+ }
+
+ writer.Pop();
+ if (!first) {
+ writer.NewLine();
+ }
+ writer.Write("]");
+ return y_absl::OkStatus();
+}
+
+template <typename Traits>
+y_absl::Status WriteMapKey(JsonWriter& writer, const Msg<Traits>& entry,
+ Field<Traits> field) {
+ switch (Traits::FieldType(field)) {
+ case FieldDescriptor::TYPE_SFIXED64:
+ case FieldDescriptor::TYPE_SINT64:
+ case FieldDescriptor::TYPE_INT64: {
+ auto x = Traits::GetInt64(field, entry);
+ RETURN_IF_ERROR(x.status());
+ writer.Write(MakeQuoted(*x));
+ break;
+ }
+ case FieldDescriptor::TYPE_FIXED64:
+ case FieldDescriptor::TYPE_UINT64: {
+ auto x = Traits::GetUInt64(field, entry);
+ RETURN_IF_ERROR(x.status());
+ writer.Write(MakeQuoted(*x));
+ break;
+ }
+ case FieldDescriptor::TYPE_SFIXED32:
+ case FieldDescriptor::TYPE_SINT32:
+ case FieldDescriptor::TYPE_INT32: {
+ auto x = Traits::GetInt32(field, entry);
+ RETURN_IF_ERROR(x.status());
+ writer.Write(MakeQuoted(*x));
+ break;
+ }
+ case FieldDescriptor::TYPE_FIXED32:
+ case FieldDescriptor::TYPE_UINT32: {
+ auto x = Traits::GetUInt32(field, entry);
+ RETURN_IF_ERROR(x.status());
+ writer.Write(MakeQuoted(*x));
+ break;
+ }
+ case FieldDescriptor::TYPE_BOOL: {
+ auto x = Traits::GetBool(field, entry);
+ RETURN_IF_ERROR(x.status());
+ writer.Write(MakeQuoted(*x ? "true" : "false"));
+ break;
+ }
+ case FieldDescriptor::TYPE_STRING: {
+ auto x = Traits::GetString(field, writer.ScratchBuf(), entry);
+ RETURN_IF_ERROR(x.status());
+ writer.Write(MakeQuoted(*x));
+ break;
+ }
+ case FieldDescriptor::TYPE_ENUM: {
+ auto x = Traits::GetEnumValue(field, entry);
+ RETURN_IF_ERROR(x.status());
+ WriteEnum<Traits>(writer, field, *x, IntegerEnumStyle::kQuoted);
+ break;
+ }
+ default:
+ return y_absl::InvalidArgumentError(
+ y_absl::StrCat("unsupported map key type: ", Traits::FieldType(field)));
+ }
+ return y_absl::OkStatus();
+}
+
+template <typename Traits>
+y_absl::StatusOr<bool> IsEmptyValue(const Msg<Traits>& msg, Field<Traits> field) {
+ if (ClassifyMessage(Traits::FieldTypeName(field)) != MessageType::kValue) {
+ return false;
+ }
+ bool empty = false;
+ RETURN_IF_ERROR(Traits::WithFieldType(
+ field, [&](const Desc<Traits>& desc) -> y_absl::Status {
+ auto inner = Traits::GetMessage(field, msg);
+ RETURN_IF_ERROR(inner.status());
+ empty = IsEmpty<Traits>(**inner, desc);
+ return y_absl::OkStatus();
+ }));
+ return empty;
+}
+
+template <typename Traits>
+y_absl::Status WriteMap(JsonWriter& writer, const Msg<Traits>& msg,
+ Field<Traits> field) {
+ writer.Write("{");
+ writer.Push();
+
+ size_t count = Traits::GetSize(field, msg);
+ bool first = true;
+ for (size_t i = 0; i < count; ++i) {
+ y_absl::StatusOr<const Msg<Traits>*> entry =
+ Traits::GetMessage(field, msg, i);
+ RETURN_IF_ERROR(entry.status());
+ const Desc<Traits>& type = Traits::GetDesc(**entry);
+
+ auto is_empty = IsEmptyValue<Traits>(**entry, Traits::ValueField(type));
+ RETURN_IF_ERROR(is_empty.status());
+ if (*is_empty) {
+ // Empty google.protobuf.Values are silently discarded.
+ continue;
+ }
+
+ writer.WriteComma(first);
+ writer.NewLine();
+ RETURN_IF_ERROR(
+ WriteMapKey<Traits>(writer, **entry, Traits::KeyField(type)));
+ writer.Write(":");
+ writer.Whitespace(" ");
+ RETURN_IF_ERROR(
+ WriteSingular<Traits>(writer, Traits::ValueField(type), **entry));
+ }
+
+ writer.Pop();
+ if (!first) {
+ writer.NewLine();
+ }
+ writer.Write("}");
+ return y_absl::OkStatus();
+}
+
+template <typename Traits>
+y_absl::Status WriteField(JsonWriter& writer, const Msg<Traits>& msg,
+ Field<Traits> field, bool& first) {
+ if (!Traits::IsRepeated(field)) { // Repeated case is handled in
+ // WriteRepeated.
+ auto is_empty = IsEmptyValue<Traits>(msg, field);
+ RETURN_IF_ERROR(is_empty.status());
+ if (*is_empty) {
+ // Empty google.protobuf.Values are silently discarded.
+ return y_absl::OkStatus();
+ }
+ }
+
+ writer.WriteComma(first);
+ writer.NewLine();
+
+ if (Traits::IsExtension(field)) {
+ writer.Write(MakeQuoted("[", Traits::FieldFullName(field), "]"), ":");
+ } else if (writer.options().preserve_proto_field_names) {
+ writer.Write(MakeQuoted(Traits::FieldName(field)), ":");
+ } else {
+ // The generator for type.proto and the internals of descriptor.cc disagree
+ // on what the json name of a PascalCase field is supposed to be; type.proto
+ // seems to (incorrectly?) capitalize the first letter, which is the
+ // behavior ESF defaults to. To fix this, if the original field name starts
+ // with an uppercase letter, and the Json name does not, we uppercase it.
+ y_absl::string_view original_name = Traits::FieldName(field);
+ y_absl::string_view json_name = Traits::FieldJsonName(field);
+ if (writer.options().allow_legacy_syntax && !Traits::HasJsonName(field) &&
+ y_absl::ascii_isupper(original_name[0]) &&
+ !y_absl::ascii_isupper(json_name[0])) {
+ writer.Write(MakeQuoted(y_absl::ascii_toupper(original_name[0]),
+ original_name.substr(1)),
+ ":");
+ } else {
+ writer.Write(MakeQuoted(json_name), ":");
+ }
+ }
+ writer.Whitespace(" ");
+
+ if (Traits::IsMap(field)) {
+ return WriteMap<Traits>(writer, msg, field);
+ } else if (Traits::IsRepeated(field)) {
+ return WriteRepeated<Traits>(writer, msg, field);
+ } else if (Traits::GetSize(field, msg) == 0) {
+ // We can only get here if always_print_primitive_fields is true.
+ Y_ABSL_DCHECK(writer.options().always_print_primitive_fields);
+
+ if (Traits::FieldType(field) == FieldDescriptor::TYPE_GROUP) {
+ // We do not yet have full group support, but this is required so that we
+ // pass the same tests as the ESF parser.
+ writer.Write("null");
+ return y_absl::OkStatus();
+ }
+ return WriteSingular<Traits>(writer, field);
+ }
+
+ return WriteSingular<Traits>(writer, field, msg);
+}
+
+template <typename Traits>
+y_absl::Status WriteFields(JsonWriter& writer, const Msg<Traits>& msg,
+ const Desc<Traits>& desc, bool& first) {
+ std::vector<Field<Traits>> fields;
+ size_t total = Traits::FieldCount(desc);
+ fields.reserve(total);
+ for (size_t i = 0; i < total; ++i) {
+ Field<Traits> field = Traits::FieldByIndex(desc, i);
+
+ bool has = Traits::GetSize(field, msg) > 0;
+ if (writer.options().always_print_primitive_fields) {
+ bool is_singular_message =
+ !Traits::IsRepeated(field) &&
+ Traits::FieldType(field) == FieldDescriptor::TYPE_MESSAGE;
+ has |= !is_singular_message && !Traits::IsOneof(field);
+ }
+
+ if (has) {
+ fields.push_back(field);
+ }
+ }
+
+ // Add extensions *before* sorting.
+ Traits::FindAndAppendExtensions(msg, fields);
+
+ // Fields are guaranteed to be serialized in field number order.
+ y_absl::c_sort(fields, [](const auto& a, const auto& b) {
+ return Traits::FieldNumber(a) < Traits::FieldNumber(b);
+ });
+
+ for (auto field : fields) {
+ RETURN_IF_ERROR(WriteField<Traits>(writer, msg, field, first));
+ }
+
+ return y_absl::OkStatus();
+}
+
+template <typename Traits>
+y_absl::Status WriteStructValue(JsonWriter& writer, const Msg<Traits>& msg,
+ const Desc<Traits>& desc);
+template <typename Traits>
+y_absl::Status WriteListValue(JsonWriter& writer, const Msg<Traits>& msg,
+ const Desc<Traits>& desc);
+
+template <typename Traits>
+y_absl::Status WriteValue(JsonWriter& writer, const Msg<Traits>& msg,
+ const Desc<Traits>& desc, bool is_top_level) {
+ // NOTE: The field numbers 1 through 6 are the numbers of the oneof fields in
+ // google.protobuf.Value. Conformance tests verify the correctness of these
+ // numbers.
+ if (Traits::GetSize(Traits::MustHaveField(desc, 1), msg) > 0) {
+ writer.Write("null");
+ return y_absl::OkStatus();
+ }
+
+ auto number_field = Traits::MustHaveField(desc, 2);
+ if (Traits::GetSize(number_field, msg) > 0) {
+ auto x = Traits::GetDouble(number_field, msg);
+ RETURN_IF_ERROR(x.status());
+ if (std::isnan(*x)) {
+ return y_absl::InvalidArgumentError(
+ "google.protobuf.Value cannot encode double values for nan, "
+ "because it would be parsed as a string");
+ }
+ if (*x == std::numeric_limits<double>::infinity() ||
+ *x == -std::numeric_limits<double>::infinity()) {
+ return y_absl::InvalidArgumentError(
+ "google.protobuf.Value cannot encode double values for "
+ "infinity, because it would be parsed as a string");
+ }
+ writer.Write(*x);
+ return y_absl::OkStatus();
+ }
+
+ auto string_field = Traits::MustHaveField(desc, 3);
+ if (Traits::GetSize(string_field, msg) > 0) {
+ auto x = Traits::GetString(string_field, writer.ScratchBuf(), msg);
+ RETURN_IF_ERROR(x.status());
+ writer.Write(MakeQuoted(*x));
+ return y_absl::OkStatus();
+ }
+
+ auto bool_field = Traits::MustHaveField(desc, 4);
+ if (Traits::GetSize(bool_field, msg) > 0) {
+ auto x = Traits::GetBool(bool_field, msg);
+ RETURN_IF_ERROR(x.status());
+ writer.Write(*x ? "true" : "false");
+ return y_absl::OkStatus();
+ }
+
+ auto struct_field = Traits::MustHaveField(desc, 5);
+ if (Traits::GetSize(struct_field, msg) > 0) {
+ auto x = Traits::GetMessage(struct_field, msg);
+ RETURN_IF_ERROR(x.status());
+ return Traits::WithFieldType(struct_field, [&](const Desc<Traits>& type) {
+ return WriteStructValue<Traits>(writer, **x, type);
+ });
+ }
+
+ auto list_field = Traits::MustHaveField(desc, 6);
+ if (Traits::GetSize(list_field, msg) > 0) {
+ auto x = Traits::GetMessage(list_field, msg);
+ RETURN_IF_ERROR(x.status());
+ return Traits::WithFieldType(list_field, [&](const Desc<Traits>& type) {
+ return WriteListValue<Traits>(writer, **x, type);
+ });
+ }
+
+ Y_ABSL_CHECK(is_top_level)
+ << "empty, non-top-level Value must be handled one layer "
+ "up, since it prints an empty string; reaching this "
+ "statement is always a bug";
+ return y_absl::OkStatus();
+}
+
+template <typename Traits>
+y_absl::Status WriteStructValue(JsonWriter& writer, const Msg<Traits>& msg,
+ const Desc<Traits>& desc) {
+ return WriteMap<Traits>(writer, msg, Traits::MustHaveField(desc, 1));
+}
+
+template <typename Traits>
+y_absl::Status WriteListValue(JsonWriter& writer, const Msg<Traits>& msg,
+ const Desc<Traits>& desc) {
+ return WriteRepeated<Traits>(writer, msg, Traits::MustHaveField(desc, 1));
+}
+
+template <typename Traits>
+y_absl::Status WriteTimestamp(JsonWriter& writer, const Msg<Traits>& msg,
+ const Desc<Traits>& desc) {
+ auto secs_field = Traits::MustHaveField(desc, 1);
+ auto secs = Traits::GetSize(secs_field, msg) > 0
+ ? Traits::GetInt64(secs_field, msg)
+ : 0;
+ RETURN_IF_ERROR(secs.status());
+
+ if (*secs < -62135596800) {
+ return y_absl::InvalidArgumentError(
+ "minimum acceptable time value is 0001-01-01T00:00:00Z");
+ } else if (*secs > 253402300799) {
+ return y_absl::InvalidArgumentError(
+ "maximum acceptable time value is 9999-12-31T23:59:59Z");
+ }
+
+ // Ensure seconds is positive.
+ *secs += 62135596800;
+
+ auto nanos_field = Traits::MustHaveField(desc, 2);
+ auto nanos = Traits::GetSize(nanos_field, msg) > 0
+ ? Traits::GetInt32(nanos_field, msg)
+ : 0;
+ RETURN_IF_ERROR(nanos.status());
+
+ // Julian Day -> Y/M/D, Algorithm from:
+ // Fliegel, H. F., and Van Flandern, T. C., "A Machine Algorithm for
+ // Processing Calendar Dates," Communications of the Association of
+ // Computing Machines, vol. 11 (1968), p. 657.
+ arc_i32 L, N, I, J, K;
+ L = static_cast<arc_i32>(*secs / 86400) - 719162 + 68569 + 2440588;
+ N = 4 * L / 146097;
+ L = L - (146097 * N + 3) / 4;
+ I = 4000 * (L + 1) / 1461001;
+ L = L - 1461 * I / 4 + 31;
+ J = 80 * L / 2447;
+ K = L - 2447 * J / 80;
+ L = J / 11;
+ J = J + 2 - 12 * L;
+ I = 100 * (N - 49) + I + L;
+
+ arc_i32 sec = *secs % 60;
+ arc_i32 min = (*secs / 60) % 60;
+ arc_i32 hour = (*secs / 3600) % 24;
+
+ if (*nanos == 0) {
+ writer.Write(y_absl::StrFormat(R"("%04d-%02d-%02dT%02d:%02d:%02dZ")", I, J, K,
+ hour, min, sec));
+ return y_absl::OkStatus();
+ }
+
+ size_t digits = 9;
+ arc_ui32 frac_seconds = std::abs(*nanos);
+ while (frac_seconds % 1000 == 0) {
+ frac_seconds /= 1000;
+ digits -= 3;
+ }
+
+ writer.Write(y_absl::StrFormat(R"("%04d-%02d-%02dT%02d:%02d:%02d.%.*dZ")", I, J,
+ K, hour, min, sec, digits, frac_seconds));
+ return y_absl::OkStatus();
+}
+
+template <typename Traits>
+y_absl::Status WriteDuration(JsonWriter& writer, const Msg<Traits>& msg,
+ const Desc<Traits>& desc) {
+ constexpr arc_i64 kMaxSeconds = arc_i64{3652500} * 86400;
+ constexpr arc_i64 kMaxNanos = 999999999;
+
+ auto secs_field = Traits::MustHaveField(desc, 1);
+ auto secs = Traits::GetSize(secs_field, msg) > 0
+ ? Traits::GetInt64(secs_field, msg)
+ : 0;
+ RETURN_IF_ERROR(secs.status());
+
+ if (*secs > kMaxSeconds || *secs < -kMaxSeconds) {
+ return y_absl::InvalidArgumentError("duration out of range");
+ }
+
+ auto nanos_field = Traits::MustHaveField(desc, 2);
+ auto nanos = Traits::GetSize(nanos_field, msg) > 0
+ ? Traits::GetInt32(nanos_field, msg)
+ : 0;
+ RETURN_IF_ERROR(nanos.status());
+
+ if (*nanos > kMaxNanos || *nanos < -kMaxNanos) {
+ return y_absl::InvalidArgumentError("duration out of range");
+ }
+ if ((*secs != 0) && (*nanos != 0) && ((*secs < 0) != (*nanos < 0))) {
+ return y_absl::InvalidArgumentError("nanos and seconds signs do not match");
+ }
+
+ if (*nanos == 0) {
+ writer.Write(y_absl::StrFormat(R"("%ds")", *secs));
+ return y_absl::OkStatus();
+ }
+
+ size_t digits = 9;
+ arc_ui32 frac_seconds = std::abs(*nanos);
+ while (frac_seconds % 1000 == 0) {
+ frac_seconds /= 1000;
+ digits -= 3;
+ }
+
+ y_absl::string_view sign = ((*secs < 0) || (*nanos < 0)) ? "-" : "";
+ writer.Write(y_absl::StrFormat(R"("%s%d.%.*ds")", sign, std::abs(*secs), digits,
+ frac_seconds));
+ return y_absl::OkStatus();
+}
+
+template <typename Traits>
+y_absl::Status WriteFieldMask(JsonWriter& writer, const Msg<Traits>& msg,
+ const Desc<Traits>& desc) {
+ // google.protobuf.FieldMask has a single field with number 1.
+ auto paths_field = Traits::MustHaveField(desc, 1);
+ size_t paths = Traits::GetSize(paths_field, msg);
+ writer.Write('"');
+
+ bool first = true;
+ for (size_t i = 0; i < paths; ++i) {
+ writer.WriteComma(first);
+ auto path = Traits::GetString(paths_field, writer.ScratchBuf(), msg, i);
+ RETURN_IF_ERROR(path.status());
+ bool saw_under = false;
+ for (char c : *path) {
+ if (y_absl::ascii_islower(c) && saw_under) {
+ writer.Write(y_absl::ascii_toupper(c));
+ } else if (y_absl::ascii_isdigit(c) || y_absl::ascii_islower(c) || c == '.') {
+ writer.Write(c);
+ } else if (c == '_' &&
+ (!saw_under || writer.options().allow_legacy_syntax)) {
+ saw_under = true;
+ continue;
+ } else if (!writer.options().allow_legacy_syntax) {
+ return y_absl::InvalidArgumentError("unexpected character in FieldMask");
+ } else {
+ if (saw_under) {
+ writer.Write('_');
+ }
+ writer.Write(c);
+ }
+ saw_under = false;
+ }
+ }
+ writer.Write('"');
+
+ return y_absl::OkStatus();
+}
+
+template <typename Traits>
+y_absl::Status WriteAny(JsonWriter& writer, const Msg<Traits>& msg,
+ const Desc<Traits>& desc) {
+ auto type_url_field = Traits::MustHaveField(desc, 1);
+ auto value_field = Traits::MustHaveField(desc, 2);
+
+ bool has_type_url = Traits::GetSize(type_url_field, msg) > 0;
+ bool has_value = Traits::GetSize(value_field, msg) > 0;
+ if (!has_type_url && !has_value) {
+ writer.Write("{}");
+ return y_absl::OkStatus();
+ } else if (!has_type_url) {
+ return y_absl::InvalidArgumentError("broken Any: missing type URL");
+ } else if (!has_value && !writer.options().allow_legacy_syntax) {
+ return y_absl::InvalidArgumentError("broken Any: missing value");
+ }
+
+ writer.Write("{");
+ writer.Push();
+
+ auto type_url = Traits::GetString(type_url_field, writer.ScratchBuf(), msg);
+ RETURN_IF_ERROR(type_url.status());
+ writer.NewLine();
+ writer.Write("\"@type\":");
+ writer.Whitespace(" ");
+ writer.Write(MakeQuoted(*type_url));
+
+ return Traits::WithDynamicType(
+ desc, TProtoStringType(*type_url),
+ [&](const Desc<Traits>& any_desc) -> y_absl::Status {
+ y_absl::string_view any_bytes;
+ if (has_value) {
+ y_absl::StatusOr<y_absl::string_view> bytes =
+ Traits::GetString(value_field, writer.ScratchBuf(), msg);
+ RETURN_IF_ERROR(bytes.status());
+ any_bytes = *bytes;
+ }
+
+ return Traits::WithDecodedMessage(
+ any_desc, any_bytes,
+ [&](const Msg<Traits>& unerased) -> y_absl::Status {
+ bool first = false;
+ if (ClassifyMessage(Traits::TypeName(any_desc)) !=
+ MessageType::kNotWellKnown) {
+ writer.WriteComma(first);
+ writer.NewLine();
+ writer.Write("\"value\":");
+ writer.Whitespace(" ");
+ RETURN_IF_ERROR(
+ WriteMessage<Traits>(writer, unerased, any_desc));
+ } else {
+ RETURN_IF_ERROR(
+ WriteFields<Traits>(writer, unerased, any_desc, first));
+ }
+ writer.Pop();
+ if (!first) {
+ writer.NewLine();
+ }
+ writer.Write("}");
+ return y_absl::OkStatus();
+ });
+ });
+}
+
+template <typename Traits>
+y_absl::Status WriteMessage(JsonWriter& writer, const Msg<Traits>& msg,
+ const Desc<Traits>& desc, bool is_top_level) {
+ switch (ClassifyMessage(Traits::TypeName(desc))) {
+ case MessageType::kAny:
+ return WriteAny<Traits>(writer, msg, desc);
+ case MessageType::kWrapper: {
+ auto field = Traits::MustHaveField(desc, 1);
+ if (Traits::GetSize(field, msg) == 0) {
+ return WriteSingular<Traits>(writer, field);
+ }
+ return WriteSingular<Traits>(writer, field, msg);
+ }
+ case MessageType::kValue:
+ return WriteValue<Traits>(writer, msg, desc, is_top_level);
+ case MessageType::kStruct:
+ return WriteStructValue<Traits>(writer, msg, desc);
+ case MessageType::kList:
+ return WriteListValue<Traits>(writer, msg, desc);
+ case MessageType::kTimestamp:
+ return WriteTimestamp<Traits>(writer, msg, desc);
+ case MessageType::kDuration:
+ return WriteDuration<Traits>(writer, msg, desc);
+ case MessageType::kFieldMask:
+ return WriteFieldMask<Traits>(writer, msg, desc);
+ default: {
+ writer.Write("{");
+ writer.Push();
+ bool first = true;
+ RETURN_IF_ERROR(WriteFields<Traits>(writer, msg, desc, first));
+ writer.Pop();
+ if (!first) {
+ writer.NewLine();
+ }
+ writer.Write("}");
+ return y_absl::OkStatus();
+ }
+ }
+}
+} // namespace
+
+y_absl::Status MessageToJsonString(const Message& message, TProtoStringType* output,
+ json_internal::WriterOptions options) {
+ PROTOBUF_DLOG(INFO) << "json2/input: " << message.DebugString();
+ io::StringOutputStream out(output);
+ JsonWriter writer(&out, options);
+ y_absl::Status s = WriteMessage<UnparseProto2Descriptor>(
+ writer, message, *message.GetDescriptor(), /*is_top_level=*/true);
+ PROTOBUF_DLOG(INFO) << "json2/status: " << s;
+ RETURN_IF_ERROR(s);
+
+ writer.NewLine();
+ PROTOBUF_DLOG(INFO) << "json2/output: " << y_absl::CHexEscape(*output);
+ return y_absl::OkStatus();
+}
+
+y_absl::Status BinaryToJsonStream(google::protobuf::util::TypeResolver* resolver,
+ const TProtoStringType& type_url,
+ io::ZeroCopyInputStream* binary_input,
+ io::ZeroCopyOutputStream* json_output,
+ json_internal::WriterOptions options) {
+ // NOTE: Most of the contortions in this function are to allow for capture of
+ // input and output of the parser in Y_ABSL_DLOG mode. Destruction order is very
+ // critical in this function, because io::ZeroCopy*Stream types usually only
+ // flush on destruction.
+
+ // For Y_ABSL_DLOG, we would like to print out the input and output, which
+ // requires buffering both instead of doing "zero copy". This block, and the
+ // one at the end of the function, set up and tear down interception of the
+ // input and output streams.
+ TProtoStringType copy;
+ TProtoStringType out;
+ y_absl::optional<io::ArrayInputStream> tee_input;
+ y_absl::optional<io::StringOutputStream> tee_output;
+ if (PROTOBUF_DEBUG) {
+ const void* data;
+ int len;
+ while (binary_input->Next(&data, &len)) {
+ copy.resize(copy.size() + len);
+ std::memcpy(&copy[copy.size() - len], data, len);
+ }
+ tee_input.emplace(copy.data(), copy.size());
+ tee_output.emplace(&out);
+ }
+
+ PROTOBUF_DLOG(INFO) << "json2/input: " << y_absl::BytesToHexString(copy);
+
+ ResolverPool pool(resolver);
+ auto desc = pool.FindMessage(type_url);
+ RETURN_IF_ERROR(desc.status());
+
+ io::CodedInputStream stream(tee_input.has_value() ? &*tee_input
+ : binary_input);
+ auto msg = UntypedMessage::ParseFromStream(*desc, stream);
+ RETURN_IF_ERROR(msg.status());
+
+ JsonWriter writer(tee_output.has_value() ? &*tee_output : json_output,
+ options);
+ y_absl::Status s = WriteMessage<UnparseProto3Type>(
+ writer, *msg, UnparseProto3Type::GetDesc(*msg),
+ /*is_top_level=*/true);
+ PROTOBUF_DLOG(INFO) << "json2/status: " << s;
+ RETURN_IF_ERROR(s);
+
+ if (PROTOBUF_DEBUG) {
+ tee_output.reset(); // Flush the output stream.
+ io::zc_sink_internal::ZeroCopyStreamByteSink(json_output)
+ .Append(out.data(), out.size());
+ }
+
+ PROTOBUF_DLOG(INFO) << "json2/output: " << y_absl::CHexEscape(out);
+
+ writer.NewLine();
+ return y_absl::OkStatus();
+}
+} // namespace json_internal
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/json/internal/unparser.h b/contrib/libs/protobuf/src/google/protobuf/json/internal/unparser.h
new file mode 100644
index 00000000000..5d1bc950e85
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/json/internal/unparser.h
@@ -0,0 +1,59 @@
+// 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_JSON_INTERNAL_UNPARSER_H__
+#define GOOGLE_PROTOBUF_JSON_INTERNAL_UNPARSER_H__
+
+#include <string>
+
+#include "google/protobuf/message.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/json/internal/writer.h"
+#include "google/protobuf/util/type_resolver.h"
+
+namespace google {
+namespace protobuf {
+namespace json_internal {
+// Internal version of google::protobuf::util::MessageToJsonString; see json_util.h for
+// details.
+y_absl::Status MessageToJsonString(const Message& message, TProtoStringType* output,
+ json_internal::WriterOptions options);
+// Internal version of google::protobuf::util::BinaryToJsonStream; see json_util.h for
+// details.
+y_absl::Status BinaryToJsonStream(google::protobuf::util::TypeResolver* resolver,
+ const TProtoStringType& type_url,
+ io::ZeroCopyInputStream* binary_input,
+ io::ZeroCopyOutputStream* json_output,
+ json_internal::WriterOptions options);
+} // namespace json_internal
+} // namespace protobuf
+} // namespace google
+
+#endif // GOOGLE_PROTOBUF_JSON_INTERNAL_UNPARSER_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/json/internal/unparser_traits.h b/contrib/libs/protobuf/src/google/protobuf/json/internal/unparser_traits.h
new file mode 100644
index 00000000000..2f3c9dd24ad
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/json/internal/unparser_traits.h
@@ -0,0 +1,438 @@
+// 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_JSON_INTERNAL_UNPARSER_TRAITS_H__
+#define GOOGLE_PROTOBUF_JSON_INTERNAL_UNPARSER_TRAITS_H__
+
+#include <algorithm>
+#include <cfloat>
+#include <cstdint>
+#include <memory>
+#include <sstream>
+#include <string>
+#include <type_traits>
+#include <utility>
+#include <vector>
+
+#include "google/protobuf/type.pb.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/status/status.h"
+#include "y_absl/strings/escaping.h"
+#include "y_absl/strings/numbers.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/types/optional.h"
+#include "y_absl/types/variant.h"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/json/internal/descriptor_traits.h"
+#include "google/protobuf/stubs/status_macros.h"
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace json_internal {
+// The type traits in this file provide describe how to read from protobuf
+// representation used by the JSON API, either via proto reflection or via
+// something ad-hoc for type.proto.
+
+// Helper alias templates to avoid needing to write `typename` in function
+// signatures.
+template <typename Traits>
+using Msg = typename Traits::Msg;
+
+// Traits for proto2-ish deserialization.
+struct UnparseProto2Descriptor : Proto2Descriptor {
+ // A message value that fields can be read from.
+ using Msg = Message;
+
+ static const Desc& GetDesc(const Msg& msg) { return *msg.GetDescriptor(); }
+
+ // Appends extension fields to `fields`.
+ static void FindAndAppendExtensions(const Msg& msg,
+ std::vector<Field>& fields) {
+ // Note that it is *not* correct to use ListFields for getting a list of
+ // fields to write, because the way that JSON decides to print non-extension
+ // fields is slightly subtle. That logic is handled elsewhere; we're only
+ // here to get extensions.
+ std::vector<Field> all_fields;
+ msg.GetReflection()->ListFields(msg, &all_fields);
+
+ for (Field field : all_fields) {
+ if (field->is_extension()) {
+ fields.push_back(field);
+ }
+ }
+ }
+
+ static size_t GetSize(Field f, const Msg& msg) {
+ if (f->is_repeated()) {
+ return msg.GetReflection()->FieldSize(msg, f);
+ } else {
+ return msg.GetReflection()->HasField(msg, f) ? 1 : 0;
+ }
+ }
+
+ static y_absl::StatusOr<float> GetFloat(Field f) {
+ return f->default_value_float();
+ }
+
+ static y_absl::StatusOr<double> GetDouble(Field f) {
+ return f->default_value_double();
+ }
+
+ static y_absl::StatusOr<arc_i32> GetInt32(Field f) {
+ return f->default_value_int32();
+ }
+
+ static y_absl::StatusOr<arc_ui32> GetUInt32(Field f) {
+ return f->default_value_uint32();
+ }
+
+ static y_absl::StatusOr<arc_i64> GetInt64(Field f) {
+ return f->default_value_int64();
+ }
+
+ static y_absl::StatusOr<arc_ui64> GetUInt64(Field f) {
+ return f->default_value_uint64();
+ }
+
+ static y_absl::StatusOr<bool> GetBool(Field f) {
+ return f->default_value_bool();
+ }
+
+ static y_absl::StatusOr<arc_i32> GetEnumValue(Field f) {
+ return f->default_value_enum()->number();
+ }
+
+ static y_absl::StatusOr<y_absl::string_view> GetString(Field f,
+ TProtoStringType& scratch) {
+ return f->default_value_string();
+ }
+
+ static y_absl::StatusOr<const Msg*> GetMessage(Field f) {
+ return y_absl::InternalError("message fields cannot have defaults");
+ }
+
+ static y_absl::StatusOr<float> GetFloat(Field f, const Msg& msg) {
+ return msg.GetReflection()->GetFloat(msg, f);
+ }
+
+ static y_absl::StatusOr<double> GetDouble(Field f, const Msg& msg) {
+ return msg.GetReflection()->GetDouble(msg, f);
+ }
+
+ static y_absl::StatusOr<arc_i32> GetInt32(Field f, const Msg& msg) {
+ return msg.GetReflection()->GetInt32(msg, f);
+ }
+
+ static y_absl::StatusOr<arc_ui32> GetUInt32(Field f, const Msg& msg) {
+ return msg.GetReflection()->GetUInt32(msg, f);
+ }
+
+ static y_absl::StatusOr<arc_i64> GetInt64(Field f, const Msg& msg) {
+ return msg.GetReflection()->GetInt64(msg, f);
+ }
+
+ static y_absl::StatusOr<arc_ui64> GetUInt64(Field f, const Msg& msg) {
+ return msg.GetReflection()->GetUInt64(msg, f);
+ }
+
+ static y_absl::StatusOr<bool> GetBool(Field f, const Msg& msg) {
+ return msg.GetReflection()->GetBool(msg, f);
+ }
+
+ static y_absl::StatusOr<arc_i32> GetEnumValue(Field f, const Msg& msg) {
+ return msg.GetReflection()->GetEnumValue(msg, f);
+ }
+
+ static y_absl::StatusOr<y_absl::string_view> GetString(Field f,
+ TProtoStringType& scratch,
+ const Msg& msg) {
+ return msg.GetReflection()->GetStringReference(msg, f, &scratch);
+ }
+
+ static y_absl::StatusOr<const Msg*> GetMessage(Field f, const Msg& msg) {
+ return &msg.GetReflection()->GetMessage(msg, f);
+ }
+
+ static y_absl::StatusOr<float> GetFloat(Field f, const Msg& msg, size_t idx) {
+ return msg.GetReflection()->GetRepeatedFloat(msg, f, idx);
+ }
+
+ static y_absl::StatusOr<double> GetDouble(Field f, const Msg& msg, size_t idx) {
+ return msg.GetReflection()->GetRepeatedDouble(msg, f, idx);
+ }
+
+ static y_absl::StatusOr<arc_i32> GetInt32(Field f, const Msg& msg, size_t idx) {
+ return msg.GetReflection()->GetRepeatedInt32(msg, f, idx);
+ }
+
+ static y_absl::StatusOr<arc_ui32> GetUInt32(Field f, const Msg& msg,
+ size_t idx) {
+ return msg.GetReflection()->GetRepeatedUInt32(msg, f, idx);
+ }
+
+ static y_absl::StatusOr<arc_i64> GetInt64(Field f, const Msg& msg, size_t idx) {
+ return msg.GetReflection()->GetRepeatedInt64(msg, f, idx);
+ }
+
+ static y_absl::StatusOr<arc_ui64> GetUInt64(Field f, const Msg& msg,
+ size_t idx) {
+ return msg.GetReflection()->GetRepeatedUInt64(msg, f, idx);
+ }
+
+ static y_absl::StatusOr<bool> GetBool(Field f, const Msg& msg, size_t idx) {
+ return msg.GetReflection()->GetRepeatedBool(msg, f, idx);
+ }
+
+ static y_absl::StatusOr<arc_i32> GetEnumValue(Field f, const Msg& msg,
+ size_t idx) {
+ return msg.GetReflection()->GetRepeatedEnumValue(msg, f, idx);
+ }
+
+ static y_absl::StatusOr<y_absl::string_view> GetString(Field f,
+ TProtoStringType& scratch,
+ const Msg& msg,
+ size_t idx) {
+ return msg.GetReflection()->GetRepeatedStringReference(msg, f, idx,
+ &scratch);
+ }
+
+ static y_absl::StatusOr<const Msg*> GetMessage(Field f, const Msg& msg,
+ size_t idx) {
+ return &msg.GetReflection()->GetRepeatedMessage(msg, f, idx);
+ }
+
+ template <typename F>
+ static y_absl::Status WithDecodedMessage(const Desc& desc,
+ y_absl::string_view data, F body) {
+ DynamicMessageFactory factory;
+ std::unique_ptr<Message> unerased(factory.GetPrototype(&desc)->New());
+ unerased->ParsePartialFromString(data);
+
+ // Explicitly create a const reference, so that we do not accidentally pass
+ // a mutable reference to `body`.
+ const Msg& ref = *unerased;
+ return body(ref);
+ }
+};
+
+struct UnparseProto3Type : Proto3Type {
+ using Msg = UntypedMessage;
+
+ static const Desc& GetDesc(const Msg& msg) { return msg.desc(); }
+
+ static void FindAndAppendExtensions(const Msg&, std::vector<Field>&) {
+ // type.proto does not support extensions.
+ }
+
+ static size_t GetSize(Field f, const Msg& msg) {
+ return msg.Count(f->proto().number());
+ }
+
+ static y_absl::StatusOr<float> GetFloat(Field f) {
+ if (f->proto().default_value().empty()) {
+ return 0.0;
+ }
+ float x;
+ if (!y_absl::SimpleAtof(f->proto().default_value(), &x)) {
+ return y_absl::InternalError(y_absl::StrCat(
+ "bad default value in type.proto: ", f->parent().proto().name()));
+ }
+ return x;
+ }
+
+ static y_absl::StatusOr<double> GetDouble(Field f) {
+ if (f->proto().default_value().empty()) {
+ return 0.0;
+ }
+ double x;
+ if (!y_absl::SimpleAtod(f->proto().default_value(), &x)) {
+ return y_absl::InternalError(y_absl::StrCat(
+ "bad default value in type.proto: ", f->parent().proto().name()));
+ }
+ return x;
+ }
+
+ static y_absl::StatusOr<arc_i32> GetInt32(Field f) {
+ if (f->proto().default_value().empty()) {
+ return 0;
+ }
+ arc_i32 x;
+ if (!y_absl::SimpleAtoi(f->proto().default_value(), &x)) {
+ return y_absl::InternalError(y_absl::StrCat(
+ "bad default value in type.proto: ", f->parent().proto().name()));
+ }
+ return x;
+ }
+
+ static y_absl::StatusOr<arc_ui32> GetUInt32(Field f) {
+ if (f->proto().default_value().empty()) {
+ return 0;
+ }
+ arc_ui32 x;
+ if (!y_absl::SimpleAtoi(f->proto().default_value(), &x)) {
+ return y_absl::InternalError(y_absl::StrCat(
+ "bad default value in type.proto: ", f->parent().proto().name()));
+ }
+ return x;
+ }
+
+ static y_absl::StatusOr<arc_i64> GetInt64(Field f) {
+ if (f->proto().default_value().empty()) {
+ return 0;
+ }
+ arc_i64 x;
+ if (!y_absl::SimpleAtoi(f->proto().default_value(), &x)) {
+ return y_absl::InternalError(y_absl::StrCat(
+ "bad default value in type.proto: ", f->parent().proto().name()));
+ }
+ return x;
+ }
+
+ static y_absl::StatusOr<arc_ui64> GetUInt64(Field f) {
+ if (f->proto().default_value().empty()) {
+ return 0;
+ }
+ arc_ui64 x;
+ if (!y_absl::SimpleAtoi(f->proto().default_value(), &x)) {
+ return y_absl::InternalError(y_absl::StrCat(
+ "bad default value in type.proto: ", f->parent().proto().name()));
+ }
+ return x;
+ }
+
+ static y_absl::StatusOr<bool> GetBool(Field f) {
+ if (f->proto().default_value().empty()) {
+ return false;
+ } else if (f->proto().default_value() == "false") {
+ return false;
+ } else if (f->proto().default_value() == "true") {
+ return true;
+ } else {
+ return y_absl::InternalError(y_absl::StrCat(
+ "bad default value in type.proto: ", f->parent().proto().name()));
+ }
+ }
+
+ static y_absl::StatusOr<arc_i32> GetEnumValue(Field f) {
+ if (f->proto().default_value().empty()) {
+ auto e = f->EnumType();
+ RETURN_IF_ERROR(e.status());
+
+ return (**e).proto().enumvalue(0).number();
+ }
+ return EnumNumberByName(f, f->proto().default_value(),
+ /*case_insensitive=*/false);
+ }
+
+ static y_absl::StatusOr<y_absl::string_view> GetString(Field f,
+ TProtoStringType& scratch) {
+ y_absl::CUnescape(f->proto().default_value(), &scratch);
+ return scratch;
+ }
+
+ static y_absl::StatusOr<const Msg*> GetMessage(Field f) {
+ return y_absl::InternalError("message fields cannot have defaults");
+ }
+
+ static y_absl::StatusOr<float> GetFloat(Field f, const Msg& msg,
+ size_t idx = 0) {
+ return msg.Get<float>(f->proto().number())[idx];
+ }
+
+ static y_absl::StatusOr<double> GetDouble(Field f, const Msg& msg,
+ size_t idx = 0) {
+ return msg.Get<double>(f->proto().number())[idx];
+ }
+
+ static y_absl::StatusOr<arc_i32> GetInt32(Field f, const Msg& msg,
+ size_t idx = 0) {
+ return msg.Get<arc_i32>(f->proto().number())[idx];
+ }
+
+ static y_absl::StatusOr<arc_ui32> GetUInt32(Field f, const Msg& msg,
+ size_t idx = 0) {
+ return msg.Get<arc_ui32>(f->proto().number())[idx];
+ }
+
+ static y_absl::StatusOr<arc_i64> GetInt64(Field f, const Msg& msg,
+ size_t idx = 0) {
+ return msg.Get<arc_i64>(f->proto().number())[idx];
+ }
+
+ static y_absl::StatusOr<arc_ui64> GetUInt64(Field f, const Msg& msg,
+ size_t idx = 0) {
+ return msg.Get<arc_ui64>(f->proto().number())[idx];
+ }
+
+ static y_absl::StatusOr<bool> GetBool(Field f, const Msg& msg, size_t idx = 0) {
+ return msg.Get<Msg::Bool>(f->proto().number())[idx] == Msg::kTrue;
+ }
+
+ static y_absl::StatusOr<arc_i32> GetEnumValue(Field f, const Msg& msg,
+ size_t idx = 0) {
+ return msg.Get<arc_i32>(f->proto().number())[idx];
+ }
+
+ static y_absl::StatusOr<y_absl::string_view> GetString(Field f,
+ TProtoStringType& scratch,
+ const Msg& msg,
+ size_t idx = 0) {
+ return msg.Get<TProtoStringType>(f->proto().number())[idx];
+ }
+
+ static y_absl::StatusOr<const Msg*> GetMessage(Field f, const Msg& msg,
+ size_t idx = 0) {
+ return &msg.Get<Msg>(f->proto().number())[idx];
+ }
+
+ template <typename F>
+ static y_absl::Status WithDecodedMessage(const Desc& desc,
+ y_absl::string_view data, F body) {
+ io::CodedInputStream stream(reinterpret_cast<const uint8_t*>(data.data()),
+ data.size());
+ auto unerased = Msg::ParseFromStream(&desc, stream);
+ RETURN_IF_ERROR(unerased.status());
+
+ // Explicitly create a const reference, so that we do not accidentally pass
+ // a mutable reference to `body`.
+ const Msg& ref = *unerased;
+ return body(ref);
+ }
+};
+} // namespace json_internal
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
+#endif // GOOGLE_PROTOBUF_JSON_INTERNAL_UNPARSER_TRAITS_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/json/internal/untyped_message.cc b/contrib/libs/protobuf/src/google/protobuf/json/internal/untyped_message.cc
new file mode 100644
index 00000000000..37c2d38d42b
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/json/internal/untyped_message.cc
@@ -0,0 +1,553 @@
+// 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/json/internal/untyped_message.h"
+
+#include <algorithm>
+#include <cfloat>
+#include <cstdint>
+#include <memory>
+#include <sstream>
+#include <string>
+#include <type_traits>
+#include <utility>
+#include <vector>
+
+#include "google/protobuf/type.pb.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/status/status.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/types/optional.h"
+#include "y_absl/types/span.h"
+#include "y_absl/types/variant.h"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/port.h"
+#include "google/protobuf/util/type_resolver.h"
+#include "google/protobuf/wire_format_lite.h"
+#include "utf8_validity.h"
+#include "google/protobuf/stubs/status_macros.h"
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace json_internal {
+using ::google::protobuf::Field;
+using ::google::protobuf::internal::WireFormatLite;
+
+y_absl::StatusOr<const ResolverPool::Message*> ResolverPool::Field::MessageType()
+ const {
+ Y_ABSL_CHECK(proto().kind() == google::protobuf::Field::TYPE_MESSAGE ||
+ proto().kind() == google::protobuf::Field::TYPE_GROUP)
+ << proto().kind();
+ if (type_ == nullptr) {
+ auto type = pool_->FindMessage(proto().type_url());
+ RETURN_IF_ERROR(type.status());
+ type_ = *type;
+ }
+ return reinterpret_cast<const Message*>(type_);
+}
+
+y_absl::StatusOr<const ResolverPool::Enum*> ResolverPool::Field::EnumType()
+ const {
+ Y_ABSL_CHECK(proto().kind() == google::protobuf::Field::TYPE_ENUM)
+ << proto().kind();
+ if (type_ == nullptr) {
+ auto type = pool_->FindEnum(proto().type_url());
+ RETURN_IF_ERROR(type.status());
+ type_ = *type;
+ }
+ return reinterpret_cast<const Enum*>(type_);
+}
+
+y_absl::Span<const ResolverPool::Field> ResolverPool::Message::FieldsByIndex()
+ const {
+ if (raw_.fields_size() > 0 && fields_ == nullptr) {
+ fields_ = std::unique_ptr<Field[]>(new Field[raw_.fields_size()]);
+ for (size_t i = 0; i < raw_.fields_size(); ++i) {
+ fields_[i].pool_ = pool_;
+ fields_[i].raw_ = &raw_.fields(i);
+ fields_[i].parent_ = this;
+ }
+ }
+
+ return y_absl::MakeSpan(fields_.get(), proto().fields_size());
+}
+
+const ResolverPool::Field* ResolverPool::Message::FindField(
+ y_absl::string_view name) const {
+ if (raw_.fields_size() == 0) {
+ return nullptr;
+ }
+
+ if (fields_by_name_.empty()) {
+ const Field* found = nullptr;
+ for (auto& field : FieldsByIndex()) {
+ if (field.proto().name() == name || field.proto().json_name() == name) {
+ found = &field;
+ }
+ fields_by_name_.try_emplace(field.proto().name(), &field);
+ fields_by_name_.try_emplace(field.proto().json_name(), &field);
+ }
+ return found;
+ }
+
+ auto it = fields_by_name_.find(name);
+ return it == fields_by_name_.end() ? nullptr : it->second;
+}
+
+const ResolverPool::Field* ResolverPool::Message::FindField(
+ arc_i32 number) const {
+ if (raw_.fields_size() == 0) {
+ return nullptr;
+ }
+
+ bool is_small = raw_.fields_size() < 8;
+ if (is_small || fields_by_number_.empty()) {
+ const Field* found = nullptr;
+ for (auto& field : FieldsByIndex()) {
+ if (field.proto().number() == number) {
+ found = &field;
+ }
+ if (!is_small) {
+ fields_by_number_.try_emplace(field.proto().number(), &field);
+ }
+ }
+ return found;
+ }
+
+ auto it = fields_by_number_.find(number);
+ return it == fields_by_number_.end() ? nullptr : it->second;
+}
+
+y_absl::StatusOr<const ResolverPool::Message*> ResolverPool::FindMessage(
+ y_absl::string_view url) {
+ auto it = messages_.find(url);
+ if (it != messages_.end()) {
+ return it->second.get();
+ }
+
+ auto msg = y_absl::WrapUnique(new Message(this));
+ TProtoStringType url_buf(url);
+ RETURN_IF_ERROR(resolver_->ResolveMessageType(url_buf, &msg->raw_));
+
+ return messages_.try_emplace(std::move(url_buf), std::move(msg))
+ .first->second.get();
+}
+
+y_absl::StatusOr<const ResolverPool::Enum*> ResolverPool::FindEnum(
+ y_absl::string_view url) {
+ auto it = enums_.find(url);
+ if (it != enums_.end()) {
+ return it->second.get();
+ }
+
+ auto enoom = y_absl::WrapUnique(new Enum(this));
+ TProtoStringType url_buf(url);
+ RETURN_IF_ERROR(resolver_->ResolveEnumType(url_buf, &enoom->raw_));
+
+ return enums_.try_emplace(std::move(url_buf), std::move(enoom))
+ .first->second.get();
+}
+
+y_absl::Status UntypedMessage::Decode(io::CodedInputStream& stream,
+ y_absl::optional<arc_i32> current_group) {
+ while (true) {
+ std::vector<arc_i32> group_stack;
+ arc_ui32 tag = stream.ReadTag();
+ if (tag == 0) {
+ return y_absl::OkStatus();
+ }
+
+ arc_i32 field_number = tag >> 3;
+ arc_i32 wire_type = tag & 7;
+
+ // EGROUP markers can show up as "unknown fields", so we need to handle them
+ // before we even do field lookup. Being inside of a group behaves as if a
+ // special field has been added to the message.
+ if (wire_type == WireFormatLite::WIRETYPE_END_GROUP) {
+ if (!current_group.has_value()) {
+ return y_absl::InvalidArgumentError(y_absl::StrFormat(
+ "attempted to close group %d before SGROUP tag", field_number));
+ }
+ if (field_number != *current_group) {
+ return y_absl::InvalidArgumentError(
+ y_absl::StrFormat("attempted to close group %d while inside group %d",
+ field_number, *current_group));
+ }
+ return y_absl::OkStatus();
+ }
+
+ const auto* field = desc_->FindField(field_number);
+ if (!group_stack.empty() || field == nullptr) {
+ // Skip unknown field. If the group-stack is non-empty, we are in the
+ // process of working through an unknown group.
+ switch (wire_type) {
+ case WireFormatLite::WIRETYPE_VARINT: {
+ arc_ui64 x;
+ if (!stream.ReadVarint64(&x)) {
+ return y_absl::InvalidArgumentError("unexpected EOF");
+ }
+ continue;
+ }
+ case WireFormatLite::WIRETYPE_FIXED64: {
+ arc_ui64 x;
+ if (!stream.ReadLittleEndian64(&x)) {
+ return y_absl::InvalidArgumentError("unexpected EOF");
+ }
+ continue;
+ }
+ case WireFormatLite::WIRETYPE_FIXED32: {
+ arc_ui32 x;
+ if (!stream.ReadLittleEndian32(&x)) {
+ return y_absl::InvalidArgumentError("unexpected EOF");
+ }
+ continue;
+ }
+ case WireFormatLite::WIRETYPE_LENGTH_DELIMITED: {
+ arc_ui32 x;
+ if (!stream.ReadVarint32(&x)) {
+ return y_absl::InvalidArgumentError("unexpected EOF");
+ }
+ stream.Skip(x);
+ continue;
+ }
+ case WireFormatLite::WIRETYPE_START_GROUP: {
+ group_stack.push_back(field_number);
+ continue;
+ }
+ case WireFormatLite::WIRETYPE_END_GROUP: {
+ if (group_stack.empty()) {
+ return y_absl::InvalidArgumentError(y_absl::StrFormat(
+ "attempted to close group %d before SGROUP tag", field_number));
+ }
+ if (field_number != group_stack.back()) {
+ return y_absl::InvalidArgumentError(y_absl::StrFormat(
+ "attempted to close group %d while inside group %d",
+ field_number, *current_group));
+ }
+ group_stack.pop_back();
+ continue;
+ }
+ default:
+ return y_absl::InvalidArgumentError(
+ y_absl::StrCat("unknown wire type: ", wire_type));
+ }
+ }
+ switch (wire_type) {
+ case WireFormatLite::WIRETYPE_VARINT:
+ RETURN_IF_ERROR(DecodeVarint(stream, *field));
+ break;
+ case WireFormatLite::WIRETYPE_FIXED64:
+ RETURN_IF_ERROR(Decode64Bit(stream, *field));
+ break;
+ case WireFormatLite::WIRETYPE_FIXED32:
+ RETURN_IF_ERROR(Decode32Bit(stream, *field));
+ break;
+ case WireFormatLite::WIRETYPE_LENGTH_DELIMITED:
+ RETURN_IF_ERROR(DecodeDelimited(stream, *field));
+ break;
+ case WireFormatLite::WIRETYPE_START_GROUP: {
+ if (field->proto().kind() != Field::TYPE_GROUP) {
+ return y_absl::InvalidArgumentError(y_absl::StrFormat(
+ "field number %d is not a group", field->proto().number()));
+ }
+ auto group_desc = field->MessageType();
+ RETURN_IF_ERROR(group_desc.status());
+
+ UntypedMessage group(*group_desc);
+ RETURN_IF_ERROR(group.Decode(stream, field_number));
+ RETURN_IF_ERROR(InsertField<UntypedMessage>(*field, std::move(group)));
+ break;
+ }
+ case WireFormatLite::WIRETYPE_END_GROUP:
+ Y_ABSL_CHECK(false) << "unreachable";
+ break;
+ default:
+ return y_absl::InvalidArgumentError(
+ y_absl::StrCat("unknown wire type: ", wire_type));
+ }
+ }
+
+ return y_absl::OkStatus();
+}
+
+y_absl::Status UntypedMessage::DecodeVarint(io::CodedInputStream& stream,
+ const ResolverPool::Field& field) {
+ switch (field.proto().kind()) {
+ case Field::TYPE_BOOL: {
+ char byte;
+ if (!stream.ReadRaw(&byte, 1)) {
+ return y_absl::InvalidArgumentError("unexpected EOF");
+ }
+ switch (byte) {
+ case 0:
+ RETURN_IF_ERROR(InsertField(field, kFalse));
+ break;
+ case 1:
+ RETURN_IF_ERROR(InsertField(field, kTrue));
+ break;
+ default:
+ return y_absl::InvalidArgumentError(
+ y_absl::StrFormat("bad value for bool: \\x%02x", byte));
+ }
+ break;
+ }
+ case Field::TYPE_INT32:
+ case Field::TYPE_SINT32:
+ case Field::TYPE_UINT32:
+ case Field::TYPE_ENUM: {
+ arc_ui32 x;
+ if (!stream.ReadVarint32(&x)) {
+ return y_absl::InvalidArgumentError("unexpected EOF");
+ }
+ if (field.proto().kind() == Field::TYPE_UINT32) {
+ RETURN_IF_ERROR(InsertField(field, x));
+ break;
+ }
+ if (field.proto().kind() == Field::TYPE_SINT32) {
+ x = WireFormatLite::ZigZagDecode32(x);
+ }
+ RETURN_IF_ERROR(InsertField(field, static_cast<arc_i32>(x)));
+ break;
+ }
+ case Field::TYPE_INT64:
+ case Field::TYPE_SINT64:
+ case Field::TYPE_UINT64: {
+ arc_ui64 x;
+ if (!stream.ReadVarint64(&x)) {
+ return y_absl::InvalidArgumentError("unexpected EOF");
+ }
+ if (field.proto().kind() == Field::TYPE_UINT64) {
+ RETURN_IF_ERROR(InsertField(field, x));
+ break;
+ }
+ if (field.proto().kind() == Field::TYPE_SINT64) {
+ x = WireFormatLite::ZigZagDecode64(x);
+ }
+ RETURN_IF_ERROR(InsertField(field, static_cast<arc_i64>(x)));
+ break;
+ }
+ default:
+ return y_absl::InvalidArgumentError(y_absl::StrFormat(
+ "field type %d (number %d) does not support varint fields",
+ field.proto().kind(), field.proto().number()));
+ }
+ return y_absl::OkStatus();
+}
+
+y_absl::Status UntypedMessage::Decode64Bit(io::CodedInputStream& stream,
+ const ResolverPool::Field& field) {
+ switch (field.proto().kind()) {
+ case Field::TYPE_FIXED64: {
+ arc_ui64 x;
+ if (!stream.ReadLittleEndian64(&x)) {
+ return y_absl::InvalidArgumentError("unexpected EOF");
+ }
+ RETURN_IF_ERROR(InsertField(field, x));
+ break;
+ }
+ case Field::TYPE_SFIXED64: {
+ arc_ui64 x;
+ if (!stream.ReadLittleEndian64(&x)) {
+ return y_absl::InvalidArgumentError("unexpected EOF");
+ }
+ RETURN_IF_ERROR(InsertField(field, static_cast<arc_i64>(x)));
+ break;
+ }
+ case Field::TYPE_DOUBLE: {
+ arc_ui64 x;
+ if (!stream.ReadLittleEndian64(&x)) {
+ return y_absl::InvalidArgumentError("unexpected EOF");
+ }
+ RETURN_IF_ERROR(InsertField(field, y_absl::bit_cast<double>(x)));
+ break;
+ }
+ default:
+ return y_absl::InvalidArgumentError(
+ y_absl::StrFormat("field type %d (number %d) does not support "
+ "type 64-bit fields",
+ field.proto().kind(), field.proto().number()));
+ }
+ return y_absl::OkStatus();
+}
+
+y_absl::Status UntypedMessage::Decode32Bit(io::CodedInputStream& stream,
+ const ResolverPool::Field& field) {
+ switch (field.proto().kind()) {
+ case Field::TYPE_FIXED32: {
+ arc_ui32 x;
+ if (!stream.ReadLittleEndian32(&x)) {
+ return y_absl::InvalidArgumentError("unexpected EOF");
+ }
+ RETURN_IF_ERROR(InsertField(field, x));
+ break;
+ }
+ case Field::TYPE_SFIXED32: {
+ arc_ui32 x;
+ if (!stream.ReadLittleEndian32(&x)) {
+ return y_absl::InvalidArgumentError("unexpected EOF");
+ }
+ RETURN_IF_ERROR(InsertField(field, static_cast<arc_i32>(x)));
+ break;
+ }
+ case Field::TYPE_FLOAT: {
+ arc_ui32 x;
+ if (!stream.ReadLittleEndian32(&x)) {
+ return y_absl::InvalidArgumentError("unexpected EOF");
+ }
+ RETURN_IF_ERROR(InsertField(field, y_absl::bit_cast<float>(x)));
+ break;
+ }
+ default:
+ return y_absl::InvalidArgumentError(y_absl::StrFormat(
+ "field type %d (number %d) does not support 32-bit fields",
+ field.proto().kind(), field.proto().number()));
+ }
+ return y_absl::OkStatus();
+}
+
+y_absl::Status UntypedMessage::DecodeDelimited(io::CodedInputStream& stream,
+ const ResolverPool::Field& field) {
+ auto limit = stream.ReadLengthAndPushLimit();
+ if (limit == 0) {
+ return y_absl::InvalidArgumentError("unexpected EOF");
+ }
+
+ switch (field.proto().kind()) {
+ case Field::TYPE_STRING:
+ case Field::TYPE_BYTES: {
+ TProtoStringType buf;
+ if (!stream.ReadString(&buf, stream.BytesUntilLimit())) {
+ return y_absl::InvalidArgumentError("unexpected EOF");
+ }
+ if (field.proto().kind() == Field::TYPE_STRING) {
+ if (desc_->proto().syntax() == google::protobuf::SYNTAX_PROTO3 &&
+ utf8_range::IsStructurallyValid(buf)) {
+ return y_absl::InvalidArgumentError("proto3 strings must be UTF-8");
+ }
+ }
+
+ RETURN_IF_ERROR(InsertField<TProtoStringType>(field, std::move(buf)));
+ break;
+ }
+ case Field::TYPE_MESSAGE: {
+ auto inner_desc = field.MessageType();
+ RETURN_IF_ERROR(inner_desc.status());
+
+ auto inner = ParseFromStream(*inner_desc, stream);
+ RETURN_IF_ERROR(inner.status());
+ RETURN_IF_ERROR(InsertField<UntypedMessage>(field, std::move(*inner)));
+ break;
+ }
+ default: {
+ // This is definitely a packed field.
+ while (stream.BytesUntilLimit() > 0) {
+ switch (field.proto().kind()) {
+ case Field::TYPE_BOOL:
+ case Field::TYPE_INT32:
+ case Field::TYPE_SINT32:
+ case Field::TYPE_UINT32:
+ case Field::TYPE_ENUM:
+ case Field::TYPE_INT64:
+ case Field::TYPE_SINT64:
+ case Field::TYPE_UINT64:
+ RETURN_IF_ERROR(DecodeVarint(stream, field));
+ break;
+ case Field::TYPE_FIXED64:
+ case Field::TYPE_SFIXED64:
+ case Field::TYPE_DOUBLE:
+ RETURN_IF_ERROR(Decode64Bit(stream, field));
+ break;
+ case Field::TYPE_FIXED32:
+ case Field::TYPE_SFIXED32:
+ case Field::TYPE_FLOAT:
+ RETURN_IF_ERROR(Decode32Bit(stream, field));
+ break;
+ default:
+ return y_absl::InvalidArgumentError(y_absl::StrFormat(
+ "field type %d (number %d) does not support type 2 records",
+ field.proto().kind(), field.proto().number()));
+ }
+ }
+ break;
+ }
+ }
+ stream.PopLimit(limit);
+ return y_absl::OkStatus();
+}
+
+template <typename T>
+y_absl::Status UntypedMessage::InsertField(const ResolverPool::Field& field,
+ T value) {
+ arc_i32 number = field.proto().number();
+ auto emplace_result = fields_.try_emplace(number, std::move(value));
+ if (emplace_result.second) {
+ return y_absl::OkStatus();
+ }
+
+ if (field.proto().cardinality() !=
+ google::protobuf::Field::CARDINALITY_REPEATED) {
+ return y_absl::InvalidArgumentError(
+ y_absl::StrCat("repeated entries for singular field number ", number));
+ }
+
+ Value& slot = emplace_result.first->second;
+ if (auto* extant = y_absl::get_if<T>(&slot)) {
+ std::vector<T> repeated;
+ repeated.push_back(std::move(*extant));
+ repeated.push_back(std::move(value));
+
+ slot = std::move(repeated);
+ } else if (auto* extant = y_absl::get_if<std::vector<T>>(&slot)) {
+ extant->push_back(std::move(value));
+ } else {
+ y_absl::optional<y_absl::string_view> name =
+ google::protobuf::internal::RttiTypeName<T>();
+ if (!name.has_value()) {
+ name = "<unknown>";
+ }
+
+ return y_absl::InvalidArgumentError(
+ y_absl::StrFormat("inconsistent types for field number %d: tried to "
+ "insert '%s', but index was %d",
+ number, *name, slot.index()));
+ }
+
+ return y_absl::OkStatus();
+}
+
+} // namespace json_internal
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/json/internal/untyped_message.h b/contrib/libs/protobuf/src/google/protobuf/json/internal/untyped_message.h
new file mode 100644
index 00000000000..caeaaf03112
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/json/internal/untyped_message.h
@@ -0,0 +1,260 @@
+#include "y_absl/log/absl_check.h"
+// 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_UITL_UNTYPED_MESSAGE_H__
+#define GOOGLE_PROTOBUF_UITL_UNTYPED_MESSAGE_H__
+
+#include <cstddef>
+#include <cstdint>
+#include <memory>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "google/protobuf/type.pb.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/dynamic_message.h"
+#include "google/protobuf/message.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/status/status.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/types/optional.h"
+#include "y_absl/types/span.h"
+#include "y_absl/types/variant.h"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/util/type_resolver.h"
+#include "google/protobuf/wire_format.h"
+#include "google/protobuf/wire_format_lite.h"
+#include "google/protobuf/stubs/status_macros.h"
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace json_internal {
+struct SizeVisitor {
+ template <typename T>
+ size_t operator()(const std::vector<T>& x) {
+ return x.size();
+ }
+
+ template <typename T>
+ size_t operator()(const T& x) {
+ return 1;
+ }
+};
+
+// A DescriptorPool-like type for caching lookups from a TypeResolver.
+//
+// This type and all of its nested types are thread-hostile.
+class ResolverPool {
+ public:
+ class Message;
+ class Enum;
+ class Field {
+ public:
+ Field(const Field&) = delete;
+ Field& operator=(const Field&) = delete;
+
+ y_absl::StatusOr<const Message*> MessageType() const;
+ y_absl::StatusOr<const Enum*> EnumType() const;
+
+ const Message& parent() const { return *parent_; }
+ const google::protobuf::Field& proto() const { return *raw_; }
+
+ private:
+ friend class ResolverPool;
+
+ Field() = default;
+
+ ResolverPool* pool_ = nullptr;
+ const google::protobuf::Field* raw_ = nullptr;
+ const Message* parent_ = nullptr;
+ mutable const void* type_ = nullptr;
+ };
+
+ class Message {
+ public:
+ Message(const Message&) = delete;
+ Message& operator=(const Message&) = delete;
+
+ y_absl::Span<const Field> FieldsByIndex() const;
+ const Field* FindField(y_absl::string_view name) const;
+ const Field* FindField(arc_i32 number) const;
+
+ const google::protobuf::Type& proto() const { return raw_; }
+ ResolverPool* pool() const { return pool_; }
+
+ private:
+ friend class ResolverPool;
+
+ explicit Message(ResolverPool* pool) : pool_(pool) {}
+
+ ResolverPool* pool_;
+ google::protobuf::Type raw_;
+ mutable std::unique_ptr<Field[]> fields_;
+ mutable y_absl::flat_hash_map<y_absl::string_view, const Field*>
+ fields_by_name_;
+ mutable y_absl::flat_hash_map<arc_i32, const Field*> fields_by_number_;
+ };
+
+ class Enum {
+ public:
+ Enum(const Enum&) = delete;
+ Enum& operator=(const Enum&) = delete;
+
+ const google::protobuf::Enum& proto() const { return raw_; }
+ ResolverPool* pool() const { return pool_; }
+
+ private:
+ friend class ResolverPool;
+
+ explicit Enum(ResolverPool* pool) : pool_(pool) {}
+
+ ResolverPool* pool_;
+ google::protobuf::Enum raw_;
+ mutable y_absl::flat_hash_map<y_absl::string_view, google::protobuf::EnumValue*>
+ values_;
+ };
+
+ explicit ResolverPool(google::protobuf::util::TypeResolver* resolver)
+ : resolver_(resolver) {}
+
+ ResolverPool(const ResolverPool&) = delete;
+ ResolverPool& operator=(const ResolverPool&) = delete;
+
+ y_absl::StatusOr<const Message*> FindMessage(y_absl::string_view url);
+ y_absl::StatusOr<const Enum*> FindEnum(y_absl::string_view url);
+
+ private:
+ y_absl::flat_hash_map<TProtoStringType, std::unique_ptr<Message>> messages_;
+ y_absl::flat_hash_map<TProtoStringType, std::unique_ptr<Enum>> enums_;
+ google::protobuf::util::TypeResolver* resolver_;
+};
+
+// A parsed wire-format proto that uses TypeReslover for parsing.
+//
+// This type is an implementation detail of the JSON parser.
+class UntypedMessage final {
+ public:
+ // New nominal type instead of `bool` to avoid vector<bool> shenanigans.
+ enum Bool : unsigned char { kTrue, kFalse };
+ using Value = y_absl::variant<Bool, arc_i32, arc_ui32, arc_i64, arc_ui64, float,
+ double, TProtoStringType, UntypedMessage,
+ //
+ std::vector<Bool>, std::vector<arc_i32>,
+ std::vector<arc_ui32>, std::vector<arc_i64>,
+ std::vector<arc_ui64>, std::vector<float>,
+ std::vector<double>, std::vector<TProtoStringType>,
+ std::vector<UntypedMessage>>;
+
+ UntypedMessage(const UntypedMessage&) = delete;
+ UntypedMessage& operator=(const UntypedMessage&) = delete;
+ UntypedMessage(UntypedMessage&&) = default;
+ UntypedMessage& operator=(UntypedMessage&&) = default;
+
+ // Tries to parse a proto with the given descriptor from an input stream.
+ static y_absl::StatusOr<UntypedMessage> ParseFromStream(
+ const ResolverPool::Message* desc, io::CodedInputStream& stream) {
+ UntypedMessage msg(std::move(desc));
+ RETURN_IF_ERROR(msg.Decode(stream));
+ return std::move(msg);
+ }
+
+ // Returns the number of elements in a field by number.
+ //
+ // Optional fields are treated like repeated fields with one or zero elements.
+ size_t Count(arc_i32 field_number) const {
+ auto it = fields_.find(field_number);
+ if (it == fields_.end()) {
+ return 0;
+ }
+
+ return y_absl::visit(SizeVisitor{}, it->second);
+ }
+
+ // Returns the contents of a field by number.
+ //
+ // Optional fields are treated like repeated fields with one or zero elements.
+ // If the field is not set, returns an empty span.
+ //
+ // If `T` is the wrong type, this function crashes.
+ template <typename T>
+ y_absl::Span<const T> Get(arc_i32 field_number) const {
+ auto it = fields_.find(field_number);
+ if (it == fields_.end()) {
+ return {};
+ }
+
+ if (auto* val = y_absl::get_if<T>(&it->second)) {
+ return y_absl::Span<const T>(val, 1);
+ } else if (auto* vec = y_absl::get_if<std::vector<T>>(&it->second)) {
+ return *vec;
+ } else {
+ Y_ABSL_CHECK(false) << "wrong type for UntypedMessage::Get(" << field_number
+ << ")";
+ return {}; // avoid compiler warning.
+ }
+ }
+
+ const ResolverPool::Message& desc() const { return *desc_; }
+
+ private:
+ enum Cardinality { kSingular, kRepeated };
+
+ explicit UntypedMessage(const ResolverPool::Message* desc) : desc_(desc) {}
+
+ y_absl::Status Decode(io::CodedInputStream& stream,
+ y_absl::optional<arc_i32> current_group = y_absl::nullopt);
+
+ y_absl::Status DecodeVarint(io::CodedInputStream& stream,
+ const ResolverPool::Field& field);
+ y_absl::Status Decode64Bit(io::CodedInputStream& stream,
+ const ResolverPool::Field& field);
+ y_absl::Status Decode32Bit(io::CodedInputStream& stream,
+ const ResolverPool::Field& field);
+ y_absl::Status DecodeDelimited(io::CodedInputStream& stream,
+ const ResolverPool::Field& field);
+
+ template <typename T>
+ y_absl::Status InsertField(const ResolverPool::Field& field, T value);
+
+ const ResolverPool::Message* desc_;
+ y_absl::flat_hash_map<arc_i32, Value> fields_;
+};
+} // namespace json_internal
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
+#endif // GOOGLE_PROTOBUF_UITL_UNTYPED_MESSAGE_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/json/internal/writer.cc b/contrib/libs/protobuf/src/google/protobuf/json/internal/writer.cc
new file mode 100644
index 00000000000..5dcc390238c
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/json/internal/writer.cc
@@ -0,0 +1,328 @@
+// 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/json/internal/writer.h"
+
+#include <cstdint>
+#include <initializer_list>
+#include <limits>
+#include <utility>
+
+#include "y_absl/algorithm/container.h"
+#include "y_absl/log/absl_check.h"
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace json_internal {
+
+// Tries to write a non-finite double if necessary; returns false if
+// nothing was written.
+bool JsonWriter::MaybeWriteSpecialFp(double val) {
+ if (val == std::numeric_limits<double>::infinity()) {
+ Write("\"Infinity\"");
+ } else if (val == -std::numeric_limits<double>::infinity()) {
+ Write("\"-Infinity\"");
+ } else if (std::isnan(val)) {
+ Write("\"NaN\"");
+ } else {
+ return false;
+ }
+ return true;
+}
+
+void JsonWriter::WriteBase64(y_absl::string_view str) {
+ // This is the regular base64, not the "web-safe" version.
+ constexpr y_absl::string_view kBase64 =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ const char* ptr = str.data();
+ const char* end = ptr + str.size();
+
+ // Reads the `n`th character off of `ptr` while gracefully avoiding
+ // sign extension due to implicit conversions
+ auto read = [&](size_t n) {
+ return static_cast<size_t>(static_cast<uint8_t>(ptr[n]));
+ };
+
+ char buf[4];
+ y_absl::string_view view(buf, sizeof(buf));
+ Write("\"");
+
+ while (end - ptr >= 3) {
+ buf[0] = kBase64[read(0) >> 2];
+ buf[1] = kBase64[((read(0) & 0x3) << 4) | (read(1) >> 4)];
+ buf[2] = kBase64[((read(1) & 0xf) << 2) | (read(2) >> 6)];
+ buf[3] = kBase64[read(2) & 0x3f];
+ Write(view);
+ ptr += 3;
+ }
+
+ switch (end - ptr) {
+ case 2:
+ buf[0] = kBase64[read(0) >> 2];
+ buf[1] = kBase64[((read(0) & 0x3) << 4) | (read(1) >> 4)];
+ buf[2] = kBase64[(read(1) & 0xf) << 2];
+ buf[3] = '=';
+ Write(view);
+ break;
+ case 1:
+ buf[0] = kBase64[read(0) >> 2];
+ buf[1] = kBase64[((read(0) & 0x3) << 4)];
+ buf[2] = '=';
+ buf[3] = '=';
+ Write(view);
+ break;
+ }
+
+ Write("\"");
+}
+
+// The minimum value of a unicode high-surrogate code unit in the utf-16
+// encoding. A high-surrogate is also known as a leading-surrogate.
+// See http://www.unicode.org/glossary/#high_surrogate_code_unit
+static constexpr uint16_t kMinHighSurrogate = 0xd800;
+
+// The minimum value of a unicode low-surrogate code unit in the utf-16
+// encoding. A low-surrogate is also known as a trailing-surrogate.
+// See http://www.unicode.org/glossary/#low_surrogate_code_unit
+static constexpr uint16_t kMinLowSurrogate = 0xdc00;
+
+// The maximum value of a unicode low-surrogate code unit in the utf-16
+// encoding. A low-surrogate is also known as a trailing surrogate.
+// See http://www.unicode.org/glossary/#low_surrogate_code_unit
+static constexpr uint16_t kMaxLowSurrogate = 0xdfff;
+
+// The minimum value of a unicode supplementary code point.
+// See http://www.unicode.org/glossary/#supplementary_code_point
+static constexpr arc_ui32 kMinSupplementaryCodePoint = 0x010000;
+
+// The maximum value of a unicode code point.
+// See http://www.unicode.org/glossary/#code_point
+static constexpr arc_ui32 kMaxCodePoint = 0x10ffff;
+
+// Indicates decoding failure; not a valid Unicode scalar.
+static constexpr arc_ui32 kErrorSentinel = 0xaaaaaaaa;
+
+// A Unicode Scalar encoded two ways.
+struct Utf8Scalar {
+ // The Unicode scalar value as a 32-bit integer. If decoding failed, this
+ // is equal to kErrorSentinel.
+ arc_ui32 u32;
+ // The Unicode scalar value encoded as UTF-8 bytes. May not reflect the
+ // contents of `u32` if it is kErrorSentinel.
+ y_absl::string_view utf8;
+};
+
+// Parses a single UTF-8-encoded Unicode scalar from `str`. Returns a pair of
+// the scalar and the UTF-8-encoded content corresponding to it from `str`.
+//
+// Returns U+FFFD on failure, and consumes an unspecified number of bytes in
+// doing so.
+static Utf8Scalar ConsumeUtf8Scalar(y_absl::string_view& str) {
+ Y_ABSL_DCHECK(!str.empty());
+ arc_ui32 scalar = static_cast<uint8_t>(str[0]);
+ const char* start = str.data();
+ size_t len = 1;
+
+ str = str.substr(1);
+
+ // Verify this is valid UTF-8. UTF-8 is a varint encoding satisfying
+ // one of the following (big-endian) patterns:
+ //
+ // 0b0xxxxxxx
+ // 0b110xxxxx'10xxxxxx
+ // 0b1110xxxx'10xxxxxx'10xxxxxx
+ // 0b11110xxx'10xxxxxx'10xxxxxx'10xxxxxx
+ //
+ // We don't need to decode it; just validate it.
+ int lookahead = 0;
+ switch (y_absl::countl_one(static_cast<uint8_t>(scalar))) {
+ case 0:
+ break;
+ case 2:
+ lookahead = 1;
+ scalar &= (1 << 5) - 1;
+ break;
+ case 3:
+ lookahead = 2;
+ scalar &= (1 << 4) - 1;
+ break;
+ case 4:
+ lookahead = 3;
+ scalar &= (1 << 3) - 1;
+ break;
+ default:
+ scalar = kErrorSentinel;
+ break;
+ }
+
+ for (int i = 0; i < lookahead; ++i) {
+ if (str.empty()) {
+ scalar = kErrorSentinel;
+ break;
+ }
+
+ uint8_t next = str[0];
+ str = str.substr(1);
+ ++len;
+
+ // Looking for top 2 bits are 0b10.
+ if (next >> 6 != 2) {
+ scalar = kErrorSentinel;
+ break;
+ }
+ next &= (1 << 6) - 1;
+ scalar <<= 6;
+ scalar |= next;
+ }
+
+ if (scalar > kMaxCodePoint) {
+ scalar = kErrorSentinel;
+ }
+
+ return {scalar, y_absl::string_view(start, len)};
+}
+
+// Decides whether we must escape `scalar`.
+//
+// If the given Unicode scalar would not use a \u escape, `custom_escape` will
+// be set to a non-empty string.
+static bool MustEscape(arc_ui32 scalar, y_absl::string_view& custom_escape) {
+ switch (scalar) {
+ // These escapes are defined by the JSON spec. We do not escape /.
+ case '\n':
+ custom_escape = R"(\n)";
+ return true;
+ case '\r':
+ custom_escape = R"(\r)";
+ return true;
+ case '\t':
+ custom_escape = R"(\t)";
+ return true;
+ case '\"':
+ custom_escape = R"(\")";
+ return true;
+ case '\f':
+ custom_escape = R"(\f)";
+ return true;
+ case '\b':
+ custom_escape = R"(\b)";
+ return true;
+ case '\\':
+ custom_escape = R"(\\)";
+ return true;
+
+ case kErrorSentinel:
+ // Decoding failure turns into spaces, *not* replacement characters. We
+ // handle this separately from "normal" spaces so that it follows the
+ // escaping code-path.
+ //
+ // Note that literal replacement characters in the input string DO NOT
+ // get turned into spaces; this is only for decoding failures!
+ custom_escape = " ";
+ return true;
+
+ // These are not required by the JSON spec, but help
+ // to prevent security bugs in JavaScript.
+ //
+ // These were originally present in the ESF parser, so they are kept for
+ // legacy compatibility (and because escaping most of these is in good
+ // taste, regardless).
+ case '<':
+ case '>':
+ case 0xfeff: // Zero width no-break space.
+ case 0xfff9: // Interlinear annotation anchor.
+ case 0xfffa: // Interlinear annotation separator.
+ case 0xfffb: // Interlinear annotation terminator.
+ case 0x00ad: // Soft-hyphen.
+ case 0x06dd: // Arabic end of ayah.
+ case 0x070f: // Syriac abbreviation mark.
+ case 0x17b4: // Khmer vowel inherent Aq.
+ case 0x17b5: // Khmer vowel inherent Aa.
+ case 0x000e0001: // Language tag.
+ return true;
+ default:
+ static constexpr std::pair<arc_ui32, arc_ui32> kEscapedRanges[] = {
+ {0x0000, 0x001f}, // ASCII control.
+ {0x007f, 0x009f}, // High ASCII bytes.
+ {0x0600, 0x0603}, // Arabic signs.
+ {0x200b, 0x200f}, // Zero width etc.
+ {0x2028, 0x202e}, // Separators etc.
+ {0x2060, 0x2064}, // Invisible etc.
+ {0x206a, 0x206f}, // Shaping etc.
+ {0x0001d173, 0x0001d17a}, // Music formatting.
+ {0x000e0020, 0x000e007f}, // TAG symbols.
+ };
+
+ return y_absl::c_any_of(kEscapedRanges, [scalar](auto range) {
+ return range.first <= scalar && scalar <= range.second;
+ });
+ }
+}
+
+void JsonWriter::WriteEscapedUtf8(y_absl::string_view str) {
+ while (!str.empty()) {
+ auto scalar = ConsumeUtf8Scalar(str);
+ y_absl::string_view custom_escape;
+
+ if (!MustEscape(scalar.u32, custom_escape)) {
+ Write(scalar.utf8);
+ continue;
+ }
+
+ if (!custom_escape.empty()) {
+ Write(custom_escape);
+ continue;
+ }
+
+ if (scalar.u32 < 0x10000) {
+ WriteUEscape(scalar.u32);
+ continue;
+ }
+
+ uint16_t lo =
+ (scalar.u32 & (kMaxLowSurrogate - kMinLowSurrogate)) + kMinLowSurrogate;
+ uint16_t hi = (scalar.u32 >> 10) +
+ (kMinHighSurrogate - (kMinSupplementaryCodePoint >> 10));
+ WriteUEscape(hi);
+ WriteUEscape(lo);
+ }
+}
+
+void JsonWriter::WriteUEscape(uint16_t val) {
+ char hex[7];
+ int len = y_absl::SNPrintF(hex, sizeof(hex), R"(\u%04x)", val);
+ Write(y_absl::string_view(hex, static_cast<size_t>(len)));
+}
+} // namespace json_internal
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/json/internal/writer.h b/contrib/libs/protobuf/src/google/protobuf/json/internal/writer.h
new file mode 100644
index 00000000000..2da3af95fdc
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/json/internal/writer.h
@@ -0,0 +1,241 @@
+// 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_JSON_INTERNAL_WRITER_H__
+#define GOOGLE_PROTOBUF_JSON_INTERNAL_WRITER_H__
+
+#include <cfloat>
+#include <cmath>
+#include <cstdint>
+#include <iostream>
+#include <limits>
+#include <ostream>
+#include <string>
+#include <tuple>
+#include <type_traits>
+#include <utility>
+
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/io/strtod.h"
+#include "google/protobuf/io/zero_copy_sink.h"
+#include "google/protobuf/io/zero_copy_stream.h"
+#include "google/protobuf/stubs/status_macros.h"
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace json_internal {
+struct WriterOptions {
+ // Whether to add spaces, line breaks and indentation to make the JSON output
+ // easy to read.
+ bool add_whitespace = false;
+ // Whether to always print primitive fields. By default proto3 primitive
+ // fields with default values will be omitted in JSON output. For example, an
+ // int32 field set to 0 will be omitted. Set this flag to true will override
+ // the default behavior and print primitive fields regardless of their values.
+ bool always_print_primitive_fields = false;
+ // Whether to always print enums as ints. By default they are rendered as
+ // strings.
+ bool always_print_enums_as_ints = false;
+ // Whether to preserve proto field names
+ bool preserve_proto_field_names = false;
+ // The original parser used by json_util2 accepted a number of non-standard
+ // options. Setting this flag enables them.
+ //
+ // What those extensions were is explicitly not documented, beyond what exists
+ // in the unit tests; we intend to remove this setting eventually. See
+ // b/234868512.
+ bool allow_legacy_syntax = false;
+};
+
+template <typename Tuple, typename F, size_t... i>
+void EachInner(const Tuple& value, F f, std::index_sequence<i...>) {
+ int ignored[] = {
+ (f(std::get<i>(value)), 0)...}; // NOLINT(readability/braces)
+ (void)ignored;
+}
+
+// Executes f on each element of value.
+template <typename Tuple, typename F>
+void Each(const Tuple& value, F f) {
+ EachInner(value, f,
+ std::make_index_sequence<std::tuple_size<Tuple>::value>());
+}
+
+// See JsonWriter::Write().
+template <typename... T>
+struct Quoted {
+ std::tuple<T...> value;
+};
+
+// Because this is not C++17 yet, we cannot add a deduction guide.
+template <typename... T>
+static Quoted<T...> MakeQuoted(T... t) {
+ return Quoted<T...>{std::make_tuple(t...)};
+}
+
+class JsonWriter {
+ public:
+ JsonWriter(io::ZeroCopyOutputStream* out, WriterOptions options)
+ : sink_(out), options_(options) {}
+
+ const WriterOptions& options() const { return options_; }
+
+ void Push() { ++indent_; }
+ void Pop() { --indent_; }
+
+ // The many overloads of Write() will write a value to the underlying stream.
+ // Some values may want to be quoted; the Quoted<> type will automatically add
+ // quotes and escape sequences.
+ //
+ // Note that Write() is not implemented for 64-bit integers, since they
+ // cannot be crisply represented without quotes; use MakeQuoted for that.
+
+ void Write(y_absl::string_view str) { sink_.Append(str.data(), str.size()); }
+
+ void Write(char c) { sink_.Append(&c, 1); }
+
+ // The precision on this and the following function are completely made-up,
+ // in an attempt to match the behavior of the ESF parser.
+ void Write(double val) {
+ if (!MaybeWriteSpecialFp(val)) {
+ Write(io::SimpleDtoa(val));
+ }
+ }
+
+ void Write(float val) {
+ if (!MaybeWriteSpecialFp(val)) {
+ Write(io::SimpleFtoa(val));
+ }
+ }
+
+ void Write(arc_i32 val) {
+ char buf[22];
+ int len = y_absl::SNPrintF(buf, sizeof(buf), "%d", val);
+ y_absl::string_view view(buf, static_cast<size_t>(len));
+ Write(view);
+ }
+
+ void Write(arc_ui32 val) {
+ char buf[22];
+ int len = y_absl::SNPrintF(buf, sizeof(buf), "%d", val);
+ y_absl::string_view view(buf, static_cast<size_t>(len));
+ Write(view);
+ }
+
+ void Write(arc_i64) = delete;
+ void Write(arc_ui64) = delete;
+
+ template <typename... Ts>
+ void Write(Quoted<Ts...> val) {
+ Write('"');
+ Each(val.value, [this](auto x) { this->WriteQuoted(x); });
+ Write('"');
+ }
+
+ template <typename... Ts>
+ auto Write(Ts... args) ->
+ // This bit of SFINAE avoids this function being called with one argument,
+ // so the other overloads of Write() can be picked up instead.
+ typename std::enable_if<sizeof...(Ts) != 1, void>::type {
+ Each(std::make_tuple(args...), [this](auto x) { this->Write(x); });
+ }
+
+ void Whitespace(y_absl::string_view ws) {
+ if (options_.add_whitespace) {
+ Write(ws);
+ }
+ }
+
+ void NewLine() {
+ Whitespace("\n");
+ for (int i = 0; i < indent_; ++i) {
+ Whitespace(" ");
+ }
+ }
+
+ void WriteComma(bool& is_first) {
+ if (is_first) {
+ is_first = false;
+ return;
+ }
+ Write(",");
+ }
+
+ void WriteBase64(y_absl::string_view str);
+
+ // Returns a buffer that can be re-used throughout a writing session as
+ // variable-length scratch space.
+ TProtoStringType& ScratchBuf() { return scratch_buf_; }
+
+ private:
+ template <typename T>
+ void WriteQuoted(T val) {
+ Write(val);
+ }
+
+ void WriteQuoted(y_absl::string_view val) { WriteEscapedUtf8(val); }
+
+ void WriteQuoted(arc_i64 val) {
+ char buf[22];
+ int len = y_absl::SNPrintF(buf, sizeof(buf), "%d", val);
+ y_absl::string_view view(buf, static_cast<size_t>(len));
+ Write(view);
+ }
+
+ void WriteQuoted(arc_ui64 val) {
+ char buf[22];
+ int len = y_absl::SNPrintF(buf, sizeof(buf), "%d", val);
+ y_absl::string_view view(buf, static_cast<size_t>(len));
+ Write(view);
+ }
+
+ // Tries to write a non-finite double if necessary; returns false if
+ // nothing was written.
+ bool MaybeWriteSpecialFp(double val);
+
+ void WriteEscapedUtf8(y_absl::string_view str);
+ void WriteUEscape(uint16_t val);
+
+ io::zc_sink_internal::ZeroCopyStreamByteSink sink_;
+ WriterOptions options_;
+ int indent_ = 0;
+
+ TProtoStringType scratch_buf_;
+};
+} // namespace json_internal
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
+#endif // GOOGLE_PROTOBUF_JSON_INTERNAL_WRITER_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/json/internal/zero_copy_buffered_stream.cc b/contrib/libs/protobuf/src/google/protobuf/json/internal/zero_copy_buffered_stream.cc
new file mode 100644
index 00000000000..462ae247394
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/json/internal/zero_copy_buffered_stream.cc
@@ -0,0 +1,148 @@
+// 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/json/internal/zero_copy_buffered_stream.h"
+
+#include <algorithm>
+#include <iterator>
+#include <string>
+#include <utility>
+
+#include "y_absl/algorithm/container.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/stubs/status_macros.h"
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace json_internal {
+y_absl::Status ZeroCopyBufferedStream::Advance(size_t bytes) {
+ while (bytes != 0) {
+ if (Unread().empty() && !ReadChunk()) {
+ return y_absl::InvalidArgumentError("unexpected EOF");
+ }
+ size_t to_skip = std::min(bytes, Unread().size());
+ cursor_ += to_skip;
+ bytes -= to_skip;
+ }
+
+ if (using_buf_) {
+ Y_ABSL_DCHECK_LE(cursor_, buffer_start_ + buf_.size());
+ } else {
+ Y_ABSL_DCHECK_LE(cursor_, last_chunk_.size());
+ }
+
+ return y_absl::OkStatus();
+}
+
+y_absl::StatusOr<BufferingGuard> ZeroCopyBufferedStream::BufferAtLeast(
+ size_t bytes) {
+ // This MUST be an empty guard before the first call to ReadChunk();
+ // otherwise we risk unconditional buffering.
+ BufferingGuard guard;
+ while (Unread().size() < bytes) {
+ if (!Unread().empty()) {
+ // We must buffer before reading if Unread() is nonempty; otherwise we
+ // risk discarding part of the unread buffer. However, we must NOT
+ // buffer before calling ReadChunk if it *is* empty, because then we
+ // would buffer unconditionally.
+ //
+ // There are tests to verify both of these cases.
+ guard = BufferingGuard(this);
+ }
+ if (!ReadChunk()) {
+ return y_absl::InvalidArgumentError("unexpected EOF");
+ }
+ guard = BufferingGuard(this);
+ }
+ Y_ABSL_DCHECK_GE(Unread().size(), bytes);
+ return BufferingGuard(this);
+}
+
+void ZeroCopyBufferedStream::DownRefBuffer() {
+ Y_ABSL_DCHECK_GT(outstanding_buffer_borrows_, 0);
+
+ --outstanding_buffer_borrows_;
+ if (outstanding_buffer_borrows_ > 0 || !using_buf_) {
+ return;
+ }
+
+ // The "virtual length" is the size of the buffer cursor_ indexes into, which
+ // is bigger than buf_.
+ size_t virtual_buf_len = buf_.size() + buffer_start_;
+ size_t last_chunk_in_buf = virtual_buf_len - last_chunk_.size();
+ // If we are inside of `last_chunk_`, set the cursor there; otherwise, we have
+ // a dangling reference somewhere.
+ Y_ABSL_DCHECK_LE(last_chunk_in_buf, virtual_buf_len) << y_absl::StrFormat(
+ "%d, %d, %d", buf_.size(), last_chunk_.size(), buffer_start_);
+ if (cursor_ <= last_chunk_in_buf) {
+ cursor_ = 0;
+ } else {
+ cursor_ -= last_chunk_in_buf;
+ }
+ buf_.clear();
+ using_buf_ = false;
+}
+
+bool ZeroCopyBufferedStream::ReadChunk() {
+ if (eof_) {
+ return false;
+ }
+ // We are buffering a second chunk, so we need to put the current chunk
+ // into the buffer.
+ if (outstanding_buffer_borrows_ > 0 && !using_buf_) {
+ y_absl::c_copy(RawBuffer(buffer_start_), std::back_inserter(buf_));
+ using_buf_ = true;
+ }
+
+ const void* data;
+ int len;
+ if (!stream_->Next(&data, &len)) {
+ eof_ = true;
+ return false;
+ }
+
+ last_chunk_ = y_absl::string_view(static_cast<const char*>(data),
+ static_cast<size_t>(len));
+ if (using_buf_) {
+ y_absl::c_copy(last_chunk_, std::back_inserter(buf_));
+ // Cursor does not need to move, because it is still inside of `buf_`.
+ } else {
+ cursor_ = 0;
+ buffer_start_ = 0;
+ }
+ return true;
+}
+} // namespace json_internal
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/json/internal/zero_copy_buffered_stream.h b/contrib/libs/protobuf/src/google/protobuf/json/internal/zero_copy_buffered_stream.h
new file mode 100644
index 00000000000..d714a40da4f
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/json/internal/zero_copy_buffered_stream.h
@@ -0,0 +1,355 @@
+// 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_JSON_INTERNAL_ZERO_COPY_BUFFERED_STREAM_H__
+#define GOOGLE_PROTOBUF_JSON_INTERNAL_ZERO_COPY_BUFFERED_STREAM_H__
+
+#include <algorithm>
+#include <cstdint>
+#include <iostream>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/status/status.h"
+#include "y_absl/status/statusor.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/io/zero_copy_stream.h"
+#include "google/protobuf/stubs/status_macros.h"
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+// Utilities for parsing contiguous buffers out of ZeroCopyInputStreams.
+
+namespace google {
+namespace protobuf {
+namespace json_internal {
+// Forward decl. for use by helper types below.
+class ZeroCopyBufferedStream;
+
+// An RAII type that represents holding a reference into the backing buffer
+// of a ZeroCopyBufferedStream. This allows for automatic management of the
+// backing buffer.
+class BufferingGuard {
+ public:
+ explicit BufferingGuard(ZeroCopyBufferedStream* owner = nullptr);
+ ~BufferingGuard();
+
+ BufferingGuard(const BufferingGuard& other) : BufferingGuard(other.owner_) {}
+ BufferingGuard& operator=(const BufferingGuard& other) {
+ this->~BufferingGuard();
+ new (this) BufferingGuard(other);
+ return *this;
+ }
+
+ private:
+ friend class Mark;
+ ZeroCopyBufferedStream* owner_ = nullptr;
+};
+
+// A string that may own its contents, or live inside of a buffer owned by
+// a ZeroCopyBufferedStream.
+//
+// Note that this type holds onto a reference to the owning
+// ZeroCopyBufferedStream; this allows it to be durable against strings being
+// moved around for buffering puroses.
+class MaybeOwnedString {
+ public:
+ explicit MaybeOwnedString(TProtoStringType value) : data_(std::move(value)) {}
+ MaybeOwnedString(ZeroCopyBufferedStream* stream, size_t start, size_t len,
+ BufferingGuard token)
+ : data_(StreamOwned{stream, start, len}), token_(token) {}
+
+ // Returns the string as a view, regardless of whether it is owned or not.
+ y_absl::string_view AsView() const {
+ if (auto* unowned = y_absl::get_if<StreamOwned>(&data_)) {
+ return unowned->AsView();
+ }
+
+ return y_absl::get<TProtoStringType>(data_);
+ }
+
+ operator y_absl::string_view() const { return AsView(); } // NOLINT
+
+ // Returns a reference to an owned string; if the wrapped string is not
+ // owned, this function will perform a copy and make it owned.
+ TProtoStringType& ToString() {
+ if (auto* unowned = y_absl::get_if<StreamOwned>(&data_)) {
+ data_ = TProtoStringType(unowned->AsView());
+ token_ = BufferingGuard{};
+ }
+
+ return y_absl::get<TProtoStringType>(data_);
+ }
+
+ template <typename String>
+ friend bool operator==(const MaybeOwnedString& lhs, const String& rhs) {
+ return lhs.AsView() == rhs;
+ }
+ template <typename String>
+ friend bool operator!=(const MaybeOwnedString& lhs, const String& rhs) {
+ return !(lhs == rhs);
+ }
+
+ private:
+ struct StreamOwned {
+ ZeroCopyBufferedStream* stream;
+ size_t start, len;
+ y_absl::string_view AsView() const;
+ };
+ y_absl::variant<TProtoStringType, StreamOwned> data_;
+ BufferingGuard token_;
+};
+
+// A mark in a stream. See ZeroCopyBufferedStream::Mark().
+class Mark {
+ public:
+ // Returns a maybe-owned string up to the unread bytes boundary, except for
+ // the last `clip` bytes.
+ MaybeOwnedString UpToUnread(size_t clip = 0) const;
+
+ // Discards this mark and its hold on the buffer.
+ void Discard() && { guard_ = BufferingGuard(); }
+
+ private:
+ friend ZeroCopyBufferedStream;
+ Mark(size_t offset, BufferingGuard guard) : offset_(offset), guard_(guard) {}
+
+ size_t offset_;
+ BufferingGuard guard_;
+};
+
+// A wrapper over a ZeroCopyInputStream that allows doing as-needed buffer for
+// obtaining contiguous chunks larger than those the underlying stream might
+// provide, while minimizing the amount of actual copying.
+class ZeroCopyBufferedStream {
+ public:
+ explicit ZeroCopyBufferedStream(io::ZeroCopyInputStream* stream)
+ : stream_(stream) {}
+
+ // Returns whether the stream is currently at eof.
+ //
+ // This function will buffer at least one character to verify whether it
+ // actually *is* at EOF.
+ bool AtEof() {
+ (void)BufferAtLeast(1);
+ return eof_;
+ }
+
+ // Takes exactly n characters from a string.
+ y_absl::StatusOr<MaybeOwnedString> Take(size_t len) {
+ auto buffering = BufferAtLeast(len);
+ RETURN_IF_ERROR(buffering.status());
+
+ size_t start = cursor_;
+ RETURN_IF_ERROR(Advance(len));
+ return MaybeOwnedString(this, start, len, *buffering);
+ }
+
+ // Takes characters to form a string, according to the given predicate. Stops
+ // early if an EOF is hit.
+ //
+ // The predicate must have type `(int, char) -> bool`; the first argument
+ // is the index of the character.
+ template <typename Pred>
+ y_absl::StatusOr<MaybeOwnedString> TakeWhile(Pred p);
+
+ // Places a mark in the stream, ensuring that all characters consumed after
+ // the mark are buffered. This can be used to parse some characters and then
+ // recover everything that follows as a contiguous string_view so that it may
+ // be processed a second time.
+ //
+ // The returned value is an RAII type that ensure the buffer sticks around
+ // long enough.
+ Mark BeginMark() { return Mark(cursor_, BufferingGuard(this)); }
+
+ // Peeks the next character in the stream.
+ //
+ // This function will not enable buffering on its own, and will read past the
+ // end of the buffer if at EOF; BufferAtLeast() should be called before
+ // calling this function.
+ char PeekChar() {
+ Y_ABSL_DCHECK(!Unread().empty());
+ return Unread()[0];
+ }
+
+ // Advances the cursor by the given number of bytes.
+ y_absl::Status Advance(size_t bytes);
+
+ // Returns a view of the current buffer, which may be either the owned
+ // `buf_` or the stream-owned `last_chunk_`.
+ //
+ // The returned view is unstable: calling any function may invalidate it,
+ // because there will not be a `BufferingGuard` to guard it.
+ y_absl::string_view RawBuffer(size_t start,
+ size_t len = y_absl::string_view::npos) const;
+
+ // Returns a view of RawBuffer, unread bytes; this will not be the entirety
+ // of the underlying stream.
+ y_absl::string_view Unread() const { return RawBuffer(cursor_); }
+
+ bool IsBuffering() const { return using_buf_; }
+
+ // Buffers at least `bytes` bytes ahead of the current cursor position,
+ // possibly enabling buffering.
+ //
+ // Returns an error if that many bytes could not be RawBuffer.
+ y_absl::StatusOr<BufferingGuard> BufferAtLeast(size_t bytes);
+
+ private:
+ friend BufferingGuard;
+ friend Mark;
+ friend MaybeOwnedString;
+
+ // Increments the buffering refcount; this will also update `buffer_start_` if
+ // necessary.
+ void UpRefBuffer() {
+ if (outstanding_buffer_borrows_++ == 0) {
+ buffer_start_ = cursor_;
+ }
+ }
+
+ // Decrements the buffering refcount; calling this function if the refcount is
+ // zero is undefined behavior.
+ //
+ // This function should not be called directly; it is called automatically
+ // by the destructor of `BufferingGuard`.
+ void DownRefBuffer();
+
+ // Obtains a new chunk from the underlying stream; returns whether there is
+ // still more data to read.
+ bool ReadChunk();
+
+ // The streamer implements a buffering stream on top of the given stream, by
+ // the following mechanism:
+ // - `cursor_` is an offset into either `last_chunk_` or `buf_`, which can
+ // be obtained via RawBuffer() and Unread():
+ // - If `using_buf_` is true, it is an offset into `buf_`.
+ // - Otherwise it is an offset into `last_chunk_`.
+ // - If `outstanding_buffer_borrows_ > 0`, someone needs the buffer to stick
+ // around. MaybeUnownedString::StreamOwned is implemented such that it does
+ // not hold onto `last_chunk_` directly, so we can freely copy it into
+ // `buf_` as needed arises.
+ // - Note that we can copy only part if we update `buffer_start_`; see
+ // RawBuffer().
+ // - If we would read more data and `outstanding_buffer_borrows_ > 0`, instead
+ // of trashing `last_chunk_`, we copy it into `buf_` and append to `buf_`
+ // each time we read.
+ // - If `outstanding_buffer_borrows_ == 0`, we can trash `buf_` and go back to
+ // using `last_chunk_` directly. See `DownRefBuffer()`.
+ io::ZeroCopyInputStream* stream_;
+ y_absl::string_view last_chunk_;
+ std::vector<char> buf_;
+ bool using_buf_ = false;
+ size_t cursor_ = 0;
+ // Invariant: this always refers to the earliest point at which we requested
+ // buffering, since the last time outstanding_buffer_borrows_ was zero.
+ size_t buffer_start_ = 0;
+ bool eof_ = false;
+ int outstanding_buffer_borrows_ = 0;
+};
+
+// These functions all rely on the definition of ZeroCopyBufferedStream, so must
+// come after it.
+inline BufferingGuard::BufferingGuard(ZeroCopyBufferedStream* owner)
+ : owner_(owner) {
+ if (owner_ != nullptr) {
+ owner_->UpRefBuffer();
+ }
+}
+
+inline BufferingGuard::~BufferingGuard() {
+ if (owner_ != nullptr) {
+ owner_->DownRefBuffer();
+ owner_ = nullptr;
+ }
+}
+
+inline y_absl::string_view MaybeOwnedString::StreamOwned::AsView() const {
+ return stream->RawBuffer(start, len);
+}
+
+inline MaybeOwnedString Mark::UpToUnread(size_t clip) const {
+ return MaybeOwnedString(guard_.owner_, offset_,
+ guard_.owner_->cursor_ - offset_ - clip, guard_);
+}
+
+template <typename Pred>
+y_absl::StatusOr<MaybeOwnedString> ZeroCopyBufferedStream::TakeWhile(Pred p) {
+ size_t start = cursor_;
+ BufferingGuard guard(this);
+ while (true) {
+ if (!BufferAtLeast(1).ok()) {
+ // We treat EOF as ending the take, rather than being an error.
+ break;
+ }
+ if (!p(cursor_ - start, PeekChar())) {
+ break;
+ }
+ RETURN_IF_ERROR(Advance(1));
+ }
+
+ return MaybeOwnedString(this, start, cursor_ - start, guard);
+}
+
+inline y_absl::string_view ZeroCopyBufferedStream::RawBuffer(size_t start,
+ size_t len) const {
+ y_absl::string_view view = last_chunk_;
+ if (using_buf_) {
+ Y_ABSL_DCHECK_LE(buffer_start_, start);
+ start -= buffer_start_;
+ view = y_absl::string_view(buf_.data(), buf_.size());
+ }
+#if 0
+ // This print statement is especially useful for trouble-shooting low-level
+ // bugs in the buffering logic.
+ Y_ABSL_LOG(INFO) << y_absl::StreamFormat("%s(\"%s\")[%d:%d]/%d:%d @ %p",
+ using_buf_ ? "buf_" : "last_chunk_",
+ view, start, static_cast<int>(len),
+ buffer_start_, cursor_, this);
+#endif
+ Y_ABSL_DCHECK_LE(start, view.size());
+ if (len == y_absl::string_view::npos) {
+ return view.substr(start);
+ }
+
+ Y_ABSL_DCHECK_LE(start + len, view.size());
+ return view.substr(start, len);
+}
+} // namespace json_internal
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
+#endif // GOOGLE_PROTOBUF_JSON_INTERNAL_ZERO_COPY_BUFFERED_STREAM_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/json/json.cc b/contrib/libs/protobuf/src/google/protobuf/json/json.cc
new file mode 100644
index 00000000000..b647d471cfc
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/json/json.cc
@@ -0,0 +1,133 @@
+// 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/json/json.h"
+
+#include <string>
+
+#include "y_absl/status/status.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/io/zero_copy_stream.h"
+#include "google/protobuf/json/internal/parser.h"
+#include "google/protobuf/json/internal/unparser.h"
+#include "google/protobuf/util/type_resolver.h"
+#include "google/protobuf/stubs/status_macros.h"
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace json {
+
+y_absl::Status BinaryToJsonStream(google::protobuf::util::TypeResolver* resolver,
+ const TProtoStringType& type_url,
+ io::ZeroCopyInputStream* binary_input,
+ io::ZeroCopyOutputStream* json_output,
+ const PrintOptions& options) {
+ google::protobuf::json_internal::WriterOptions opts;
+ opts.add_whitespace = options.add_whitespace;
+ opts.preserve_proto_field_names = options.preserve_proto_field_names;
+ opts.always_print_enums_as_ints = options.always_print_enums_as_ints;
+ opts.always_print_primitive_fields = options.always_print_primitive_fields;
+
+ // TODO(b/234868512): Drop this setting.
+ opts.allow_legacy_syntax = true;
+
+ return google::protobuf::json_internal::BinaryToJsonStream(
+ resolver, type_url, binary_input, json_output, opts);
+}
+
+y_absl::Status BinaryToJsonString(google::protobuf::util::TypeResolver* resolver,
+ const TProtoStringType& type_url,
+ const TProtoStringType& binary_input,
+ TProtoStringType* json_output,
+ const PrintOptions& options) {
+ io::ArrayInputStream input_stream(binary_input.data(), binary_input.size());
+ io::StringOutputStream output_stream(json_output);
+ return BinaryToJsonStream(resolver, type_url, &input_stream, &output_stream,
+ options);
+}
+
+y_absl::Status JsonToBinaryStream(google::protobuf::util::TypeResolver* resolver,
+ const TProtoStringType& type_url,
+ io::ZeroCopyInputStream* json_input,
+ io::ZeroCopyOutputStream* binary_output,
+ const ParseOptions& options) {
+ google::protobuf::json_internal::ParseOptions opts;
+ opts.ignore_unknown_fields = options.ignore_unknown_fields;
+ opts.case_insensitive_enum_parsing = options.case_insensitive_enum_parsing;
+
+ // TODO(b/234868512): Drop this setting.
+ opts.allow_legacy_syntax = true;
+
+ return google::protobuf::json_internal::JsonToBinaryStream(
+ resolver, type_url, json_input, binary_output, opts);
+}
+
+y_absl::Status JsonToBinaryString(google::protobuf::util::TypeResolver* resolver,
+ const TProtoStringType& type_url,
+ y_absl::string_view json_input,
+ TProtoStringType* binary_output,
+ const ParseOptions& options) {
+ io::ArrayInputStream input_stream(json_input.data(), json_input.size());
+ io::StringOutputStream output_stream(binary_output);
+ return JsonToBinaryStream(resolver, type_url, &input_stream, &output_stream,
+ options);
+}
+
+y_absl::Status MessageToJsonString(const Message& message, TProtoStringType* output,
+ const PrintOptions& options) {
+ google::protobuf::json_internal::WriterOptions opts;
+ opts.add_whitespace = options.add_whitespace;
+ opts.preserve_proto_field_names = options.preserve_proto_field_names;
+ opts.always_print_enums_as_ints = options.always_print_enums_as_ints;
+ opts.always_print_primitive_fields = options.always_print_primitive_fields;
+
+ // TODO(b/234868512): Drop this setting.
+ opts.allow_legacy_syntax = true;
+
+ return google::protobuf::json_internal::MessageToJsonString(message, output, opts);
+}
+
+y_absl::Status JsonStringToMessage(y_absl::string_view input, Message* message,
+ const ParseOptions& options) {
+ google::protobuf::json_internal::ParseOptions opts;
+ opts.ignore_unknown_fields = options.ignore_unknown_fields;
+ opts.case_insensitive_enum_parsing = options.case_insensitive_enum_parsing;
+
+ // TODO(b/234868512): Drop this setting.
+ opts.allow_legacy_syntax = true;
+
+ return google::protobuf::json_internal::JsonStringToMessage(input, message, opts);
+}
+} // namespace json
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/json/json.h b/contrib/libs/protobuf/src/google/protobuf/json/json.h
new file mode 100644
index 00000000000..6a67616b41d
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/json/json.h
@@ -0,0 +1,200 @@
+// 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.
+
+// Utility functions to convert between protobuf binary format and proto3 JSON
+// format.
+#ifndef GOOGLE_PROTOBUF_JSON_JSON_H__
+#define GOOGLE_PROTOBUF_JSON_JSON_H__
+
+#include <string>
+
+#include "y_absl/status/status.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/util/type_resolver.h"
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+#ifdef USE_DEPRECATED_NAMESPACE
+namespace util {
+#else
+namespace json {
+#endif
+struct ParseOptions {
+ // Whether to ignore unknown JSON fields during parsing
+ bool ignore_unknown_fields = false;
+
+ // If true, when a lowercase enum value fails to parse, try convert it to
+ // UPPER_CASE and see if it matches a valid enum.
+ // WARNING: This option exists only to preserve legacy behavior. Avoid using
+ // this option. If your enum needs to support different casing, consider using
+ // allow_alias instead.
+ bool case_insensitive_enum_parsing = false;
+
+ ParseOptions()
+ : ignore_unknown_fields(false), case_insensitive_enum_parsing(false) {}
+};
+
+struct PrintOptions {
+ // Whether to add spaces, line breaks and indentation to make the JSON output
+ // easy to read.
+ bool add_whitespace = false;
+ // Whether to always print primitive fields. By default proto3 primitive
+ // fields with default values will be omitted in JSON output. For example, an
+ // int32 field set to 0 will be omitted. Set this flag to true will override
+ // the default behavior and print primitive fields regardless of their values.
+ bool always_print_primitive_fields = false;
+ // Whether to always print enums as ints. By default they are rendered as
+ // strings.
+ bool always_print_enums_as_ints = false;
+ // Whether to preserve proto field names
+ bool preserve_proto_field_names = false;
+
+ PrintOptions()
+ : add_whitespace(false),
+ always_print_primitive_fields(false),
+ always_print_enums_as_ints(false),
+ preserve_proto_field_names(false) {}
+};
+
+#ifdef USE_DEPRECATED_NAMESPACE
+using JsonParseOptions = ParseOptions;
+using JsonPrintOptions = PrintOptions;
+using JsonOptions = PrintOptions;
+#endif
+
+// Converts from protobuf message to JSON and appends it to |output|. This is a
+// simple wrapper of BinaryToJsonString(). It will use the DescriptorPool of the
+// passed-in message to resolve Any types.
+//
+// Please note that non-OK statuses are not a stable output of this API and
+// subject to change without notice.
+PROTOBUF_EXPORT y_absl::Status MessageToJsonString(const Message& message,
+ TProtoStringType* output,
+ const PrintOptions& options);
+
+inline y_absl::Status MessageToJsonString(const Message& message,
+ TProtoStringType* output) {
+ return MessageToJsonString(message, output, PrintOptions());
+}
+
+// Converts from JSON to protobuf message. This is a simple wrapper of
+// JsonStringToBinary(). It will use the DescriptorPool of the passed-in
+// message to resolve Any types.
+//
+// Please note that non-OK statuses are not a stable output of this API and
+// subject to change without notice.
+PROTOBUF_EXPORT y_absl::Status JsonStringToMessage(y_absl::string_view input,
+ Message* message,
+ const ParseOptions& options);
+
+inline y_absl::Status JsonStringToMessage(y_absl::string_view input,
+ Message* message) {
+ return JsonStringToMessage(input, message, ParseOptions());
+}
+
+// Converts protobuf binary data to JSON.
+// The conversion will fail if:
+// 1. TypeResolver fails to resolve a type.
+// 2. input is not valid protobuf wire format, or conflicts with the type
+// information returned by TypeResolver.
+// Note that unknown fields will be discarded silently.
+//
+// Please note that non-OK statuses are not a stable output of this API and
+// subject to change without notice.
+PROTOBUF_EXPORT y_absl::Status BinaryToJsonStream(
+ google::protobuf::util::TypeResolver* resolver, const TProtoStringType& type_url,
+ io::ZeroCopyInputStream* binary_input,
+ io::ZeroCopyOutputStream* json_output, const PrintOptions& options);
+
+inline y_absl::Status BinaryToJsonStream(google::protobuf::util::TypeResolver* resolver,
+ const TProtoStringType& type_url,
+ io::ZeroCopyInputStream* binary_input,
+ io::ZeroCopyOutputStream* json_output) {
+ return BinaryToJsonStream(resolver, type_url, binary_input, json_output,
+ PrintOptions());
+}
+
+PROTOBUF_EXPORT y_absl::Status BinaryToJsonString(
+ google::protobuf::util::TypeResolver* resolver, const TProtoStringType& type_url,
+ const TProtoStringType& binary_input, TProtoStringType* json_output,
+ const PrintOptions& options);
+
+inline y_absl::Status BinaryToJsonString(google::protobuf::util::TypeResolver* resolver,
+ const TProtoStringType& type_url,
+ const TProtoStringType& binary_input,
+ TProtoStringType* json_output) {
+ return BinaryToJsonString(resolver, type_url, binary_input, json_output,
+ PrintOptions());
+}
+
+// Converts JSON data to protobuf binary format.
+// The conversion will fail if:
+// 1. TypeResolver fails to resolve a type.
+// 2. input is not valid JSON format, or conflicts with the type
+// information returned by TypeResolver.
+//
+// Please note that non-OK statuses are not a stable output of this API and
+// subject to change without notice.
+PROTOBUF_EXPORT y_absl::Status JsonToBinaryStream(
+ google::protobuf::util::TypeResolver* resolver, const TProtoStringType& type_url,
+ io::ZeroCopyInputStream* json_input,
+ io::ZeroCopyOutputStream* binary_output, const ParseOptions& options);
+
+inline y_absl::Status JsonToBinaryStream(
+ google::protobuf::util::TypeResolver* resolver, const TProtoStringType& type_url,
+ io::ZeroCopyInputStream* json_input,
+ io::ZeroCopyOutputStream* binary_output) {
+ return JsonToBinaryStream(resolver, type_url, json_input, binary_output,
+ ParseOptions());
+}
+
+PROTOBUF_EXPORT y_absl::Status JsonToBinaryString(
+ google::protobuf::util::TypeResolver* resolver, const TProtoStringType& type_url,
+ y_absl::string_view json_input, TProtoStringType* binary_output,
+ const ParseOptions& options);
+
+inline y_absl::Status JsonToBinaryString(google::protobuf::util::TypeResolver* resolver,
+ const TProtoStringType& type_url,
+ y_absl::string_view json_input,
+ TProtoStringType* binary_output) {
+ return JsonToBinaryString(resolver, type_url, json_input, binary_output,
+ ParseOptions());
+}
+} // namespace json
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_JSON_JSON_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/json/old_json.cc b/contrib/libs/protobuf/src/google/protobuf/json/old_json.cc
new file mode 100644
index 00000000000..cdf0c7727e2
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/json/old_json.cc
@@ -0,0 +1,134 @@
+// 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.
+
+#define USE_DEPRECATED_NAMESPACE 1
+#include "google/protobuf/json/json.h"
+
+#include <string>
+
+#include "y_absl/status/status.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/io/zero_copy_stream.h"
+#include "google/protobuf/json/internal/parser.h"
+#include "google/protobuf/json/internal/unparser.h"
+#include "google/protobuf/util/type_resolver.h"
+#include "google/protobuf/stubs/status_macros.h"
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace util {
+
+y_absl::Status BinaryToJsonStream(google::protobuf::util::TypeResolver* resolver,
+ const TProtoStringType& type_url,
+ io::ZeroCopyInputStream* binary_input,
+ io::ZeroCopyOutputStream* json_output,
+ const PrintOptions& options) {
+ google::protobuf::json_internal::WriterOptions opts;
+ opts.add_whitespace = options.add_whitespace;
+ opts.preserve_proto_field_names = options.preserve_proto_field_names;
+ opts.always_print_enums_as_ints = options.always_print_enums_as_ints;
+ opts.always_print_primitive_fields = options.always_print_primitive_fields;
+
+ // TODO(b/234868512): Drop this setting.
+ opts.allow_legacy_syntax = true;
+
+ return google::protobuf::json_internal::BinaryToJsonStream(
+ resolver, type_url, binary_input, json_output, opts);
+}
+
+y_absl::Status BinaryToJsonString(google::protobuf::util::TypeResolver* resolver,
+ const TProtoStringType& type_url,
+ const TProtoStringType& binary_input,
+ TProtoStringType* json_output,
+ const PrintOptions& options) {
+ io::ArrayInputStream input_stream(binary_input.data(), binary_input.size());
+ io::StringOutputStream output_stream(json_output);
+ return BinaryToJsonStream(resolver, type_url, &input_stream, &output_stream,
+ options);
+}
+
+y_absl::Status JsonToBinaryStream(google::protobuf::util::TypeResolver* resolver,
+ const TProtoStringType& type_url,
+ io::ZeroCopyInputStream* json_input,
+ io::ZeroCopyOutputStream* binary_output,
+ const ParseOptions& options) {
+ google::protobuf::json_internal::ParseOptions opts;
+ opts.ignore_unknown_fields = options.ignore_unknown_fields;
+ opts.case_insensitive_enum_parsing = options.case_insensitive_enum_parsing;
+
+ // TODO(b/234868512): Drop this setting.
+ opts.allow_legacy_syntax = true;
+
+ return google::protobuf::json_internal::JsonToBinaryStream(
+ resolver, type_url, json_input, binary_output, opts);
+}
+
+y_absl::Status JsonToBinaryString(google::protobuf::util::TypeResolver* resolver,
+ const TProtoStringType& type_url,
+ y_absl::string_view json_input,
+ TProtoStringType* binary_output,
+ const ParseOptions& options) {
+ io::ArrayInputStream input_stream(json_input.data(), json_input.size());
+ io::StringOutputStream output_stream(binary_output);
+ return JsonToBinaryStream(resolver, type_url, &input_stream, &output_stream,
+ options);
+}
+
+y_absl::Status MessageToJsonString(const Message& message, TProtoStringType* output,
+ const PrintOptions& options) {
+ google::protobuf::json_internal::WriterOptions opts;
+ opts.add_whitespace = options.add_whitespace;
+ opts.preserve_proto_field_names = options.preserve_proto_field_names;
+ opts.always_print_enums_as_ints = options.always_print_enums_as_ints;
+ opts.always_print_primitive_fields = options.always_print_primitive_fields;
+
+ // TODO(b/234868512): Drop this setting.
+ opts.allow_legacy_syntax = true;
+
+ return google::protobuf::json_internal::MessageToJsonString(message, output, opts);
+}
+
+y_absl::Status JsonStringToMessage(y_absl::string_view input, Message* message,
+ const ParseOptions& options) {
+ google::protobuf::json_internal::ParseOptions opts;
+ opts.ignore_unknown_fields = options.ignore_unknown_fields;
+ opts.case_insensitive_enum_parsing = options.case_insensitive_enum_parsing;
+
+ // TODO(b/234868512): Drop this setting.
+ opts.allow_legacy_syntax = true;
+
+ return google::protobuf::json_internal::JsonStringToMessage(input, message, opts);
+}
+} // namespace util
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/map.cc b/contrib/libs/protobuf/src/google/protobuf/map.cc
index d60a9a285cc..3490fcae20f 100644
--- a/contrib/libs/protobuf/src/google/protobuf/map.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/map.cc
@@ -28,13 +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.
-#include <google/protobuf/map.h>
+#include "google/protobuf/map.h"
namespace google {
namespace protobuf {
namespace internal {
-void* const kGlobalEmptyTable[kGlobalEmptyTableSize] = {nullptr};
+const TableEntryPtr kGlobalEmptyTable[kGlobalEmptyTableSize] = {};
} // namespace internal
} // namespace protobuf
diff --git a/contrib/libs/protobuf/src/google/protobuf/map.h b/contrib/libs/protobuf/src/google/protobuf/map.h
index e0da73ea361..d586715e7e4 100644
--- a/contrib/libs/protobuf/src/google/protobuf/map.h
+++ b/contrib/libs/protobuf/src/google/protobuf/map.h
@@ -37,38 +37,37 @@
#ifndef GOOGLE_PROTOBUF_MAP_H__
#define GOOGLE_PROTOBUF_MAP_H__
-
+#include <algorithm>
#include <functional>
#include <initializer_list>
#include <iterator>
#include <limits> // To support Visual Studio 2008
-#include <map>
#include <string>
#include <type_traits>
#include <utility>
-#if defined(__cpp_lib_string_view)
-#include <string_view>
-#endif // defined(__cpp_lib_string_view)
-
#if !defined(GOOGLE_PROTOBUF_NO_RDTSC) && defined(__APPLE__)
#define GOOGLE_PROTOBUF_NO_RDTSC 1
//#include <mach/mach_time.h>
#endif
-#include <google/protobuf/stubs/common.h>
-#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>
+#include "google/protobuf/stubs/common.h"
+#include "y_absl/container/btree_map.h"
+#include "y_absl/hash/hash.h"
+#include "y_absl/meta/type_traits.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/arena.h"
+#include "google/protobuf/generated_enum_util.h"
+#include "google/protobuf/map_type_handler.h"
+#include "google/protobuf/port.h"
+
#ifdef SWIG
#error "You cannot SWIG proto headers"
#endif
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -99,6 +98,14 @@ class DynamicMapField;
class GeneratedMessageReflection;
+// Internal type traits that can be used to define custom key/value types. These
+// are only be specialized by protobuf internals, and never by users.
+template <typename T, typename VoidT = void>
+struct is_internal_map_key_type : std::false_type {};
+
+template <typename T, typename VoidT = void>
+struct is_internal_map_value_type : std::false_type {};
+
// re-implement std::allocator to use arena allocator for memory allocation.
// Used for Map implementation. Users should not use this class
// directly.
@@ -193,10 +200,19 @@ class MapAllocator {
Arena* arena_;
};
+// To save on binary size and simplify generic uses of the map types we collapse
+// signed/unsigned versions of the same sized integer to the unsigned version.
+template <typename T, typename = void>
+struct KeyForBaseImpl {
+ using type = T;
+};
template <typename T>
-using KeyForTree =
- typename std::conditional<std::is_scalar<T>::value, T,
- std::reference_wrapper<const T>>::type;
+struct KeyForBaseImpl<T, std::enable_if_t<std::is_integral<T>::value &&
+ std::is_signed<T>::value>> {
+ using type = std::make_unsigned_t<T>;
+};
+template <typename T>
+using KeyForBase = typename KeyForBaseImpl<T>::type;
// Default case: Not transparent.
// We use std::hash<key_type>/std::less<key_type> and all the lookup functions
@@ -212,69 +228,149 @@ struct TransparentSupport {
using key_arg = key_type;
};
-#if defined(__cpp_lib_string_view)
-// If std::string_view is available, we add transparent support for TProtoStringType
-// keys. We use std::hash<std::string_view> as it supports the input types we
-// care about. The lookup functions accept arbitrary `K`. This will include any
-// key type that is convertible to std::string_view.
+// We add transparent support for TProtoStringType keys. We use
+// std::hash<y_absl::string_view> as it supports the input types we care about.
+// The lookup functions accept arbitrary `K`. This will include any key type
+// that is convertible to y_absl::string_view.
template <>
struct TransparentSupport<TProtoStringType> {
- static std::string_view ImplicitConvert(std::string_view str) { return str; }
- // If the element is not convertible to std::string_view, try to convert to
- // TProtoStringType first.
- // The template makes this overload lose resolution when both have the same
- // rank otherwise.
- template <typename = void>
- static std::string_view ImplicitConvert(const TProtoStringType& str) {
- return str;
+ // If the element is not convertible to y_absl::string_view, try to convert to
+ // TProtoStringType first, and then fallback to support for converting from
+ // std::string_view. The ranked overload pattern is used to specify our
+ // order of preference.
+ struct Rank0 {};
+ struct Rank1 : Rank0 {};
+ struct Rank2 : Rank1 {};
+ template <typename T, typename = std::enable_if_t<
+ std::is_convertible<T, y_absl::string_view>::value>>
+ static y_absl::string_view ImplicitConvertImpl(T&& str, Rank2) {
+ y_absl::string_view ref = str;
+ return ref;
+ }
+ template <typename T, typename = std::enable_if_t<
+ std::is_convertible<T, const TProtoStringType&>::value>>
+ static y_absl::string_view ImplicitConvertImpl(T&& str, Rank1) {
+ const TProtoStringType& ref = str;
+ return ref;
+ }
+ template <typename T>
+ static y_absl::string_view ImplicitConvertImpl(T&& str, Rank0) {
+ return {str.data(), str.size()};
+ }
+
+ template <typename T>
+ static y_absl::string_view ImplicitConvert(T&& str) {
+ return ImplicitConvertImpl(std::forward<T>(str), Rank2{});
}
- struct hash : private std::hash<std::string_view> {
+ struct hash : public y_absl::Hash<y_absl::string_view> {
using is_transparent = void;
template <typename T>
- size_t operator()(const T& str) const {
- return base()(ImplicitConvert(str));
+ size_t operator()(T&& str) const {
+ return y_absl::Hash<y_absl::string_view>::operator()(
+ ImplicitConvert(std::forward<T>(str)));
}
-
- private:
- const std::hash<std::string_view>& base() const { return *this; }
};
struct less {
using is_transparent = void;
template <typename T, typename U>
- bool operator()(const T& t, const U& u) const {
- return ImplicitConvert(t) < ImplicitConvert(u);
+ bool operator()(T&& t, U&& u) const {
+ return ImplicitConvert(std::forward<T>(t)) <
+ ImplicitConvert(std::forward<U>(u));
}
};
template <typename T, typename U>
- static bool Equals(const T& t, const U& u) {
- return ImplicitConvert(t) == ImplicitConvert(u);
+ static bool Equals(T&& t, U&& u) {
+ return ImplicitConvert(std::forward<T>(t)) ==
+ ImplicitConvert(std::forward<U>(u));
}
template <typename K>
using key_arg = K;
};
-#endif // defined(__cpp_lib_string_view)
+
+struct NodeBase {
+ // Align the node to allow KeyNode to predict the location of the key.
+ // This way sizeof(NodeBase) contains any possible padding it was going to
+ // have between NodeBase and the key.
+ alignas(kMaxMessageAlignment) NodeBase* next;
+};
+
+inline NodeBase* EraseFromLinkedList(NodeBase* item, NodeBase* head) {
+ if (head == item) {
+ return head->next;
+ } else {
+ head->next = EraseFromLinkedList(item, head->next);
+ return head;
+ }
+}
+
+inline bool TableEntryIsTooLong(NodeBase* node) {
+ const size_t kMaxLength = 8;
+ size_t count = 0;
+ do {
+ ++count;
+ node = node->next;
+ } while (node != nullptr);
+ // Invariant: no linked list ever is more than kMaxLength in length.
+ Y_ABSL_DCHECK_LE(count, kMaxLength);
+ return count >= kMaxLength;
+}
+
+template <typename T>
+using KeyForTree = std::conditional_t<std::is_integral<T>::value, arc_ui64,
+ std::reference_wrapper<const T>>;
+
+template <typename T>
+using LessForTree = typename TransparentSupport<
+ std::conditional_t<std::is_integral<T>::value, arc_ui64, T>>::less;
template <typename Key>
using TreeForMap =
- std::map<KeyForTree<Key>, void*, typename TransparentSupport<Key>::less,
- MapAllocator<std::pair<const KeyForTree<Key>, void*>>>;
-
-inline bool TableEntryIsEmpty(void* const* table, size_t b) {
- return table[b] == nullptr;
+ y_absl::btree_map<KeyForTree<Key>, NodeBase*, LessForTree<Key>,
+ MapAllocator<std::pair<const KeyForTree<Key>, NodeBase*>>>;
+
+// Type safe tagged pointer.
+// We convert to/from nodes and trees using the operations below.
+// They ensure that the tags are used correctly.
+// There are three states:
+// - x == 0: the entry is empty
+// - x != 0 && (x&1) == 0: the entry is a node list
+// - x != 0 && (x&1) == 1: the entry is a tree
+enum class TableEntryPtr : uintptr_t;
+
+inline bool TableEntryIsEmpty(TableEntryPtr entry) {
+ return entry == TableEntryPtr{};
+}
+inline bool TableEntryIsTree(TableEntryPtr entry) {
+ return (static_cast<uintptr_t>(entry) & 1) == 1;
+}
+inline bool TableEntryIsList(TableEntryPtr entry) {
+ return !TableEntryIsTree(entry);
+}
+inline bool TableEntryIsNonEmptyList(TableEntryPtr entry) {
+ return !TableEntryIsEmpty(entry) && TableEntryIsList(entry);
}
-inline bool TableEntryIsNonEmptyList(void* const* table, size_t b) {
- return table[b] != nullptr && table[b] != table[b ^ 1];
+inline NodeBase* TableEntryToNode(TableEntryPtr entry) {
+ Y_ABSL_DCHECK(TableEntryIsList(entry));
+ return reinterpret_cast<NodeBase*>(static_cast<uintptr_t>(entry));
}
-inline bool TableEntryIsTree(void* const* table, size_t b) {
- return !TableEntryIsEmpty(table, b) && !TableEntryIsNonEmptyList(table, b);
+inline TableEntryPtr NodeToTableEntry(NodeBase* node) {
+ Y_ABSL_DCHECK((reinterpret_cast<uintptr_t>(node) & 1) == 0);
+ return static_cast<TableEntryPtr>(reinterpret_cast<uintptr_t>(node));
}
-inline bool TableEntryIsList(void* const* table, size_t b) {
- return !TableEntryIsTree(table, b);
+template <typename Tree>
+Tree* TableEntryToTree(TableEntryPtr entry) {
+ Y_ABSL_DCHECK(TableEntryIsTree(entry));
+ return reinterpret_cast<Tree*>(static_cast<uintptr_t>(entry) - 1);
+}
+template <typename Tree>
+TableEntryPtr TreeToTableEntry(Tree* node) {
+ Y_ABSL_DCHECK((reinterpret_cast<uintptr_t>(node) & 1) == 0);
+ return static_cast<TableEntryPtr>(reinterpret_cast<uintptr_t>(node) | 1);
}
// This captures all numeric types.
@@ -289,12 +385,14 @@ size_t MapValueSpaceUsedExcludingSelfLong(const T& message) {
}
constexpr size_t kGlobalEmptyTableSize = 1;
-PROTOBUF_EXPORT extern void* const kGlobalEmptyTable[kGlobalEmptyTableSize];
+PROTOBUF_EXPORT extern const TableEntryPtr
+ kGlobalEmptyTable[kGlobalEmptyTableSize];
// Space used for the table, trees, and nodes.
// Does not include the indirect space used. Eg the data of a TProtoStringType.
template <typename Key>
-PROTOBUF_NOINLINE size_t SpaceUsedInTable(void** table, size_t num_buckets,
+PROTOBUF_NOINLINE size_t SpaceUsedInTable(TableEntryPtr* table,
+ size_t num_buckets,
size_t num_elements,
size_t sizeof_node) {
size_t size = 0;
@@ -304,10 +402,10 @@ PROTOBUF_NOINLINE size_t SpaceUsedInTable(void** table, size_t num_buckets,
size += sizeof_node * num_elements;
// For each tree, count the overhead of the those nodes.
// Two buckets at a time because we only care about trees.
- for (size_t b = 0; b < num_buckets; b += 2) {
- if (internal::TableEntryIsTree(table, b)) {
+ for (size_t b = 0; b < num_buckets; ++b) {
+ if (internal::TableEntryIsTree(table[b])) {
using Tree = TreeForMap<Key>;
- Tree* tree = static_cast<Tree*>(table[b]);
+ Tree* tree = TableEntryToTree<Tree>(table[b]);
// Estimated cost of the red-black tree nodes, 3 pointers plus a
// bool (plus alignment, so 4 pointers).
size += tree->size() *
@@ -332,858 +430,692 @@ size_t SpaceUsedInValues(const Map* map) {
inline size_t SpaceUsedInValues(const void*) { return 0; }
-} // namespace internal
-
-// This is the class for Map's internal value_type. Instead of using
-// std::pair as value_type, we use this class which provides us more control of
-// its process of construction and destruction.
-template <typename Key, typename T>
-struct PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG MapPair {
- using first_type = const Key;
- using second_type = T;
-
- MapPair(const Key& other_first, const T& other_second)
- : first(other_first), second(other_second) {}
- explicit MapPair(const Key& other_first) : first(other_first), second() {}
- explicit MapPair(Key&& other_first)
- : first(std::move(other_first)), second() {}
- MapPair(const MapPair& other) : first(other.first), second(other.second) {}
+// Base class for all Map instantiations.
+// This class holds all the data and provides the basic functionality shared
+// among all instantiations.
+// Having an untyped base class helps generic consumers (like the table-driven
+// parser) by having non-template code that can handle all instantiations.
+class PROTOBUF_EXPORT UntypedMapBase {
+ using Allocator = internal::MapAllocator<void*>;
- ~MapPair() {}
+ public:
+ using size_type = size_t;
- // Implicitly convertible to std::pair of compatible types.
- template <typename T1, typename T2>
- operator std::pair<T1, T2>() const { // NOLINT(runtime/explicit)
- return std::pair<T1, T2>(first, second);
- }
+ explicit constexpr UntypedMapBase(Arena* arena)
+ : num_elements_(0),
+ num_buckets_(internal::kGlobalEmptyTableSize),
+ seed_(0),
+ index_of_first_non_null_(internal::kGlobalEmptyTableSize),
+ table_(const_cast<TableEntryPtr*>(internal::kGlobalEmptyTable)),
+ alloc_(arena) {}
- const Key first;
- T second;
+ UntypedMapBase(const UntypedMapBase&) = delete;
+ UntypedMapBase& operator=(const UntypedMapBase&) = delete;
- private:
- friend class Arena;
- friend class Map<Key, T>;
-};
+ protected:
+ enum { kMinTableSize = 8 };
-// Map is an associative container type used to store protobuf map
-// fields. Each Map instance may or may not use a different hash function, a
-// different iteration order, and so on. E.g., please don't examine
-// implementation details to decide if the following would work:
-// Map<int, int> m0, m1;
-// m0[0] = m1[0] = m0[1] = m1[1] = 0;
-// assert(m0.begin()->first == m1.begin()->first); // Bug!
-//
-// Map's interface is similar to std::unordered_map, except that Map is not
-// designed to play well with exceptions.
-template <typename Key, typename T>
-class Map {
public:
- using key_type = Key;
- using mapped_type = T;
- using value_type = MapPair<Key, T>;
+ Arena* arena() const { return this->alloc_.arena(); }
+
+ void Swap(UntypedMapBase* other) {
+ std::swap(num_elements_, other->num_elements_);
+ std::swap(num_buckets_, other->num_buckets_);
+ std::swap(seed_, other->seed_);
+ std::swap(index_of_first_non_null_, other->index_of_first_non_null_);
+ std::swap(table_, other->table_);
+ std::swap(alloc_, other->alloc_);
+ }
- using pointer = value_type*;
- using const_pointer = const value_type*;
- using reference = value_type&;
- using const_reference = const value_type&;
+ static size_type max_size() {
+ return static_cast<size_type>(1) << (sizeof(void**) >= 8 ? 60 : 28);
+ }
+ size_type size() const { return num_elements_; }
+ bool empty() const { return size() == 0; }
- using size_type = size_t;
- using hasher = typename internal::TransparentSupport<Key>::hash;
+ protected:
+ friend class TcParser;
- constexpr Map() : elements_(nullptr) {}
- explicit Map(Arena* arena) : elements_(arena) {}
+ struct NodeAndBucket {
+ NodeBase* node;
+ size_type bucket;
+ };
- Map(const Map& other) : Map() { insert(other.begin(), other.end()); }
+ // Returns whether we should insert after the head of the list. For
+ // non-optimized builds, we randomly decide whether to insert right at the
+ // head of the list or just after the head. This helps add a little bit of
+ // non-determinism to the map ordering.
+ bool ShouldInsertAfterHead(void* node) {
+#ifdef NDEBUG
+ (void)node;
+ return false;
+#else
+ // Doing modulo with a prime mixes the bits more.
+ return (reinterpret_cast<uintptr_t>(node) ^ seed_) % 13 > 6;
+#endif
+ }
- Map(Map&& other) noexcept : Map() {
- if (other.arena() != nullptr) {
- *this = other;
+ // Helper for InsertUnique. Handles the case where bucket b is a
+ // not-too-long linked list.
+ void InsertUniqueInList(size_type b, NodeBase* node) {
+ if (!TableEntryIsEmpty(b) && ShouldInsertAfterHead(node)) {
+ auto* first = TableEntryToNode(table_[b]);
+ node->next = first->next;
+ first->next = node;
} else {
- swap(other);
+ node->next = TableEntryToNode(table_[b]);
+ table_[b] = NodeToTableEntry(node);
}
}
- Map& operator=(Map&& other) noexcept {
- if (this != &other) {
- if (arena() != other.arena()) {
- *this = other;
- } else {
- swap(other);
- }
- }
- return *this;
+ bool TableEntryIsEmpty(size_type b) const {
+ return internal::TableEntryIsEmpty(table_[b]);
}
-
- template <class InputIt>
- Map(const InputIt& first, const InputIt& last) : Map() {
- insert(first, last);
+ bool TableEntryIsNonEmptyList(size_type b) const {
+ return internal::TableEntryIsNonEmptyList(table_[b]);
+ }
+ bool TableEntryIsTree(size_type b) const {
+ return internal::TableEntryIsTree(table_[b]);
+ }
+ bool TableEntryIsList(size_type b) const {
+ return internal::TableEntryIsList(table_[b]);
}
- ~Map() {}
-
- private:
- using Allocator = internal::MapAllocator<void*>;
-
- // InnerMap is a generic hash-based map. It doesn't contain any
- // protocol-buffer-specific logic. It is a chaining hash map with the
- // additional feature that some buckets can be converted to use an ordered
- // container. This ensures O(lg n) bounds on find, insert, and erase, while
- // avoiding the overheads of ordered containers most of the time.
- //
- // The implementation doesn't need the full generality of unordered_map,
- // and it doesn't have it. More bells and whistles can be added as needed.
- // Some implementation details:
- // 1. The hash function has type hasher and the equality function
- // equal_to<Key>. We inherit from hasher to save space
- // (empty-base-class optimization).
- // 2. The number of buckets is a power of two.
- // 3. Buckets are converted to trees in pairs: if we convert bucket b then
- // buckets b and b^1 will share a tree. Invariant: buckets b and b^1 have
- // the same non-null value iff they are sharing a tree. (An alternative
- // implementation strategy would be to have a tag bit per bucket.)
- // 4. As is typical for hash_map and such, the Keys and Values are always
- // stored in linked list nodes. Pointers to elements are never invalidated
- // until the element is deleted.
- // 5. The trees' payload type is pointer to linked-list node. Tree-converting
- // a bucket doesn't copy Key-Value pairs.
- // 6. Once we've tree-converted a bucket, it is never converted back. However,
- // the items a tree contains may wind up assigned to trees or lists upon a
- // rehash.
- // 7. The code requires no C++ features from C++14 or later.
- // 8. Mutations to a map do not invalidate the map's iterators, pointers to
- // elements, or references to elements.
- // 9. Except for erase(iterator), any non-const method can reorder iterators.
- // 10. InnerMap uses KeyForTree<Key> when using the Tree representation, which
- // is either `Key`, if Key is a scalar, or `reference_wrapper<const Key>`
- // otherwise. This avoids unnecessary copies of string keys, for example.
- class InnerMap : private hasher {
- public:
- explicit constexpr InnerMap(Arena* arena)
- : hasher(),
- num_elements_(0),
- num_buckets_(internal::kGlobalEmptyTableSize),
- seed_(0),
- index_of_first_non_null_(internal::kGlobalEmptyTableSize),
- table_(const_cast<void**>(internal::kGlobalEmptyTable)),
- alloc_(arena) {}
-
- ~InnerMap() {
- if (alloc_.arena() == nullptr &&
- num_buckets_ != internal::kGlobalEmptyTableSize) {
- clear();
- Dealloc<void*>(table_, num_buckets_);
- }
- }
-
- private:
- enum { kMinTableSize = 8 };
-
- // Linked-list nodes, as one would expect for a chaining hash table.
- struct Node {
- value_type kv;
- Node* next;
- };
-
- // Trees. The payload type is a copy of Key, so that we can query the tree
- // with Keys that are not in any particular data structure.
- // The value is a void* pointing to Node. We use void* instead of Node* to
- // avoid code bloat. That way there is only one instantiation of the tree
- // class per key type.
- using Tree = internal::TreeForMap<Key>;
- using TreeIterator = typename Tree::iterator;
-
- static Node* NodeFromTreeIterator(TreeIterator it) {
- return static_cast<Node*>(it->second);
- }
-
- // iterator and const_iterator are instantiations of iterator_base.
- template <typename KeyValueType>
- class iterator_base {
- public:
- using reference = KeyValueType&;
- using pointer = KeyValueType*;
-
- // Invariants:
- // node_ is always correct. This is handy because the most common
- // operations are operator* and operator-> and they only use node_.
- // When node_ is set to a non-null value, all the other non-const fields
- // are updated to be correct also, but those fields can become stale
- // if the underlying map is modified. When those fields are needed they
- // are rechecked, and updated if necessary.
- iterator_base() : node_(nullptr), m_(nullptr), bucket_index_(0) {}
-
- explicit iterator_base(const InnerMap* m) : m_(m) {
- SearchFrom(m->index_of_first_non_null_);
- }
-
- // Any iterator_base can convert to any other. This is overkill, and we
- // rely on the enclosing class to use it wisely. The standard "iterator
- // can convert to const_iterator" is OK but the reverse direction is not.
- template <typename U>
- explicit iterator_base(const iterator_base<U>& it)
- : node_(it.node_), m_(it.m_), bucket_index_(it.bucket_index_) {}
-
- iterator_base(Node* n, const InnerMap* m, size_type index)
- : node_(n), m_(m), bucket_index_(index) {}
-
- iterator_base(TreeIterator tree_it, const InnerMap* m, size_type index)
- : node_(NodeFromTreeIterator(tree_it)), m_(m), bucket_index_(index) {
- // Invariant: iterators that use buckets with trees have an even
- // bucket_index_.
- GOOGLE_DCHECK_EQ(bucket_index_ % 2, 0u);
- }
+ // Return whether table_[b] is a linked list that seems awfully long.
+ // Requires table_[b] to point to a non-empty linked list.
+ bool TableEntryIsTooLong(size_type b) {
+ return internal::TableEntryIsTooLong(TableEntryToNode(table_[b]));
+ }
- // Advance through buckets, looking for the first that isn't empty.
- // If nothing non-empty is found then leave node_ == nullptr.
- void SearchFrom(size_type start_bucket) {
- GOOGLE_DCHECK(m_->index_of_first_non_null_ == m_->num_buckets_ ||
- m_->table_[m_->index_of_first_non_null_] != nullptr);
- node_ = nullptr;
- for (bucket_index_ = start_bucket; bucket_index_ < m_->num_buckets_;
- bucket_index_++) {
- if (m_->TableEntryIsNonEmptyList(bucket_index_)) {
- node_ = static_cast<Node*>(m_->table_[bucket_index_]);
- break;
- } else if (m_->TableEntryIsTree(bucket_index_)) {
- Tree* tree = static_cast<Tree*>(m_->table_[bucket_index_]);
- GOOGLE_DCHECK(!tree->empty());
- node_ = NodeFromTreeIterator(tree->begin());
- break;
- }
- }
- }
+ // Return a power of two no less than max(kMinTableSize, n).
+ // Assumes either n < kMinTableSize or n is a power of two.
+ size_type TableSize(size_type n) {
+ return n < static_cast<size_type>(kMinTableSize)
+ ? static_cast<size_type>(kMinTableSize)
+ : n;
+ }
- reference operator*() const { return node_->kv; }
- pointer operator->() const { return &(operator*()); }
+ template <typename T>
+ using AllocFor = y_absl::allocator_traits<Allocator>::template rebind_alloc<T>;
- friend bool operator==(const iterator_base& a, const iterator_base& b) {
- return a.node_ == b.node_;
- }
- friend bool operator!=(const iterator_base& a, const iterator_base& b) {
- return a.node_ != b.node_;
- }
+ // Alignment of the nodes is the same as alignment of NodeBase.
+ NodeBase* AllocNode(size_t node_size) {
+ PROTOBUF_ASSUME(node_size % sizeof(NodeBase) == 0);
+ return AllocFor<NodeBase>(alloc_).allocate(node_size / sizeof(NodeBase));
+ }
- iterator_base& operator++() {
- if (node_->next == nullptr) {
- TreeIterator tree_it;
- const bool is_list = revalidate_if_necessary(&tree_it);
- if (is_list) {
- SearchFrom(bucket_index_ + 1);
- } else {
- GOOGLE_DCHECK_EQ(bucket_index_ & 1, 0u);
- Tree* tree = static_cast<Tree*>(m_->table_[bucket_index_]);
- if (++tree_it == tree->end()) {
- SearchFrom(bucket_index_ + 2);
- } else {
- node_ = NodeFromTreeIterator(tree_it);
- }
- }
- } else {
- node_ = node_->next;
- }
- return *this;
- }
+ void DeallocNode(NodeBase* node, size_t node_size) {
+ PROTOBUF_ASSUME(node_size % sizeof(NodeBase) == 0);
+ AllocFor<NodeBase>(alloc_).deallocate(node, node_size / sizeof(NodeBase));
+ }
- iterator_base operator++(int /* unused */) {
- iterator_base tmp = *this;
- ++*this;
- return tmp;
- }
+ void DeleteTable(TableEntryPtr* table, size_type n) {
+ AllocFor<TableEntryPtr>(alloc_).deallocate(table, n);
+ }
- // Assumes node_ and m_ are correct and non-null, but other fields may be
- // stale. Fix them as needed. Then return true iff node_ points to a
- // Node in a list. If false is returned then *it is modified to be
- // a valid iterator for node_.
- bool revalidate_if_necessary(TreeIterator* it) {
- GOOGLE_DCHECK(node_ != nullptr && m_ != nullptr);
- // Force bucket_index_ to be in range.
- bucket_index_ &= (m_->num_buckets_ - 1);
- // Common case: the bucket we think is relevant points to node_.
- if (m_->table_[bucket_index_] == static_cast<void*>(node_)) return true;
- // Less common: the bucket is a linked list with node_ somewhere in it,
- // but not at the head.
- if (m_->TableEntryIsNonEmptyList(bucket_index_)) {
- Node* l = static_cast<Node*>(m_->table_[bucket_index_]);
- while ((l = l->next) != nullptr) {
- if (l == node_) {
- return true;
- }
- }
- }
- // Well, bucket_index_ still might be correct, but probably
- // not. Revalidate just to be sure. This case is rare enough that we
- // don't worry about potential optimizations, such as having a custom
- // find-like method that compares Node* instead of the key.
- iterator_base i(m_->find(node_->kv.first, it));
- bucket_index_ = i.bucket_index_;
- return m_->TableEntryIsList(bucket_index_);
- }
+ TableEntryPtr* CreateEmptyTable(size_type n) {
+ Y_ABSL_DCHECK_GE(n, size_type{kMinTableSize});
+ Y_ABSL_DCHECK_EQ(n & (n - 1), 0u);
+ TableEntryPtr* result = AllocFor<TableEntryPtr>(alloc_).allocate(n);
+ memset(result, 0, n * sizeof(result[0]));
+ return result;
+ }
- Node* node_;
- const InnerMap* m_;
- size_type bucket_index_;
- };
+ // Return a randomish value.
+ size_type Seed() const {
+ // We get a little bit of randomness from the address of the map. The
+ // lower bits are not very random, due to alignment, so we discard them
+ // and shift the higher bits into their place.
+ size_type s = reinterpret_cast<uintptr_t>(this) >> 4;
+#if !defined(GOOGLE_PROTOBUF_NO_RDTSC)
+#if defined(__APPLE__)
+ // Use a commpage-based fast time function on Apple environments (MacOS,
+ // iOS, tvOS, watchOS, etc).
+ s += mach_absolute_time();
+#elif defined(__x86_64__) && defined(__GNUC__)
+ arc_ui32 hi, lo;
+ asm volatile("rdtsc" : "=a"(lo), "=d"(hi));
+ s += ((static_cast<arc_ui64>(hi) << 32) | lo);
+#elif defined(__aarch64__) && defined(__GNUC__)
+ // There is no rdtsc on ARMv8. CNTVCT_EL0 is the virtual counter of the
+ // system timer. It runs at a different frequency than the CPU's, but is
+ // the best source of time-based entropy we get.
+ arc_ui64 virtual_timer_value;
+ asm volatile("mrs %0, cntvct_el0" : "=r"(virtual_timer_value));
+ s += virtual_timer_value;
+#endif
+#endif // !defined(GOOGLE_PROTOBUF_NO_RDTSC)
+ return s;
+ }
- public:
- using iterator = iterator_base<value_type>;
- using const_iterator = iterator_base<const value_type>;
-
- Arena* arena() const { return alloc_.arena(); }
-
- void Swap(InnerMap* other) {
- std::swap(num_elements_, other->num_elements_);
- std::swap(num_buckets_, other->num_buckets_);
- std::swap(seed_, other->seed_);
- std::swap(index_of_first_non_null_, other->index_of_first_non_null_);
- std::swap(table_, other->table_);
- std::swap(alloc_, other->alloc_);
- }
+ size_type num_elements_;
+ size_type num_buckets_;
+ size_type seed_;
+ size_type index_of_first_non_null_;
+ TableEntryPtr* table_; // an array with num_buckets_ entries
+ Allocator alloc_;
+};
- iterator begin() { return iterator(this); }
- iterator end() { return iterator(); }
- const_iterator begin() const { return const_iterator(this); }
- const_iterator end() const { return const_iterator(); }
-
- void clear() {
- for (size_type b = 0; b < num_buckets_; b++) {
- if (TableEntryIsNonEmptyList(b)) {
- Node* node = static_cast<Node*>(table_[b]);
- table_[b] = nullptr;
- do {
- Node* next = node->next;
- DestroyNode(node);
- node = next;
- } while (node != nullptr);
- } else if (TableEntryIsTree(b)) {
- Tree* tree = static_cast<Tree*>(table_[b]);
- GOOGLE_DCHECK(table_[b] == table_[b + 1] && (b & 1) == 0);
- table_[b] = table_[b + 1] = nullptr;
- typename Tree::iterator tree_it = tree->begin();
- do {
- Node* node = NodeFromTreeIterator(tree_it);
- typename Tree::iterator next = tree_it;
- ++next;
- tree->erase(tree_it);
- DestroyNode(node);
- tree_it = next;
- } while (tree_it != tree->end());
- DestroyTree(tree);
- b++;
- }
- }
- num_elements_ = 0;
- index_of_first_non_null_ = num_buckets_;
- }
+// The value might be of different signedness, so use memcpy to extract it.
+template <typename T, std::enable_if_t<std::is_integral<T>::value, int> = 0>
+T ReadKey(const void* ptr) {
+ T out;
+ memcpy(&out, ptr, sizeof(T));
+ return out;
+}
- const hasher& hash_function() const { return *this; }
+template <typename T, std::enable_if_t<!std::is_integral<T>::value, int> = 0>
+const T& ReadKey(const void* ptr) {
+ return *reinterpret_cast<const T*>(ptr);
+}
- static size_type max_size() {
- return static_cast<size_type>(1) << (sizeof(void**) >= 8 ? 60 : 28);
- }
- size_type size() const { return num_elements_; }
- bool empty() const { return size() == 0; }
+// KeyMapBase is a chaining hash map with the additional feature that some
+// buckets can be converted to use an ordered container. This ensures O(lg n)
+// bounds on find, insert, and erase, while avoiding the overheads of ordered
+// containers most of the time.
+//
+// The implementation doesn't need the full generality of unordered_map,
+// and it doesn't have it. More bells and whistles can be added as needed.
+// Some implementation details:
+// 1. The number of buckets is a power of two.
+// 2. As is typical for hash_map and such, the Keys and Values are always
+// stored in linked list nodes. Pointers to elements are never invalidated
+// until the element is deleted.
+// 3. The trees' payload type is pointer to linked-list node. Tree-converting
+// a bucket doesn't copy Key-Value pairs.
+// 4. Once we've tree-converted a bucket, it is never converted back unless the
+// bucket is completely emptied out. Note that the items a tree contains may
+// wind up assigned to trees or lists upon a rehash.
+// 5. Mutations to a map do not invalidate the map's iterators, pointers to
+// elements, or references to elements.
+// 6. Except for erase(iterator), any non-const method can reorder iterators.
+// 7. Uses KeyForTree<Key> when using the Tree representation, which
+// is either `arc_ui64` if `Key` is an integer, or
+// `reference_wrapper<const Key>` otherwise. This avoids unnecessary copies
+// of string keys, for example.
- template <typename K>
- iterator find(const K& k) {
- return iterator(FindHelper(k).first);
- }
+template <typename Key>
+class KeyMapBase : public UntypedMapBase {
+ static_assert(!std::is_signed<Key>::value || !std::is_integral<Key>::value,
+ "");
- template <typename K>
- const_iterator find(const K& k) const {
- return FindHelper(k).first;
- }
+ public:
+ using hasher = typename TransparentSupport<Key>::hash;
- // Inserts a new element into the container if there is no element with the
- // key in the container.
- // The new element is:
- // (1) Constructed in-place with the given args, if mapped_type is not
- // arena constructible.
- // (2) Constructed in-place with the arena and then assigned with a
- // mapped_type temporary constructed with the given args, otherwise.
- template <typename K, typename... Args>
- std::pair<iterator, bool> try_emplace(K&& k, Args&&... args) {
- return ArenaAwareTryEmplace(Arena::is_arena_constructable<mapped_type>(),
- std::forward<K>(k),
- std::forward<Args>(args)...);
- }
+ using UntypedMapBase::UntypedMapBase;
- // Inserts the key into the map, if not present. In that case, the value
- // will be value initialized.
- template <typename K>
- std::pair<iterator, bool> insert(K&& k) {
- return try_emplace(std::forward<K>(k));
+ protected:
+ struct KeyNode : NodeBase {
+ static constexpr size_t kOffset = sizeof(NodeBase);
+ decltype(auto) key() const {
+ return ReadKey<Key>(reinterpret_cast<const char*>(this) + kOffset);
}
+ };
- template <typename K>
- value_type& operator[](K&& k) {
- return *try_emplace(std::forward<K>(k)).first;
- }
+ // Trees. The payload type is a copy of Key, so that we can query the tree
+ // with Keys that are not in any particular data structure.
+ // The value is a void* pointing to Node. We use void* instead of Node* to
+ // avoid code bloat. That way there is only one instantiation of the tree
+ // class per key type.
+ using Tree = internal::TreeForMap<Key>;
+ using TreeIterator = typename Tree::iterator;
- void erase(iterator it) {
- GOOGLE_DCHECK_EQ(it.m_, this);
- typename Tree::iterator tree_it;
- const bool is_list = it.revalidate_if_necessary(&tree_it);
- size_type b = it.bucket_index_;
- Node* const item = it.node_;
- if (is_list) {
- GOOGLE_DCHECK(TableEntryIsNonEmptyList(b));
- Node* head = static_cast<Node*>(table_[b]);
- head = EraseFromLinkedList(item, head);
- table_[b] = static_cast<void*>(head);
- } else {
- GOOGLE_DCHECK(TableEntryIsTree(b));
- Tree* tree = static_cast<Tree*>(table_[b]);
- tree->erase(tree_it);
- if (tree->empty()) {
- // Force b to be the minimum of b and b ^ 1. This is important
- // only because we want index_of_first_non_null_ to be correct.
- b &= ~static_cast<size_type>(1);
- DestroyTree(tree);
- table_[b] = table_[b + 1] = nullptr;
- }
- }
- DestroyNode(item);
- --num_elements_;
- if (PROTOBUF_PREDICT_FALSE(b == index_of_first_non_null_)) {
- while (index_of_first_non_null_ < num_buckets_ &&
- table_[index_of_first_non_null_] == nullptr) {
- ++index_of_first_non_null_;
+ class KeyIteratorBase {
+ public:
+ // Invariants:
+ // node_ is always correct. This is handy because the most common
+ // operations are operator* and operator-> and they only use node_.
+ // When node_ is set to a non-null value, all the other non-const fields
+ // are updated to be correct also, but those fields can become stale
+ // if the underlying map is modified. When those fields are needed they
+ // are rechecked, and updated if necessary.
+ KeyIteratorBase() : node_(nullptr), m_(nullptr), bucket_index_(0) {}
+
+ explicit KeyIteratorBase(const KeyMapBase* m) : m_(m) {
+ SearchFrom(m->index_of_first_non_null_);
+ }
+
+ KeyIteratorBase(KeyNode* n, const KeyMapBase* m, size_type index)
+ : node_(n), m_(m), bucket_index_(index) {}
+
+ KeyIteratorBase(TreeIterator tree_it, const KeyMapBase* m, size_type index)
+ : node_(NodeFromTreeIterator(tree_it)), m_(m), bucket_index_(index) {}
+
+ // Advance through buckets, looking for the first that isn't empty.
+ // If nothing non-empty is found then leave node_ == nullptr.
+ void SearchFrom(size_type start_bucket) {
+ Y_ABSL_DCHECK(m_->index_of_first_non_null_ == m_->num_buckets_ ||
+ !m_->TableEntryIsEmpty(m_->index_of_first_non_null_));
+ for (size_type i = start_bucket; i < m_->num_buckets_; ++i) {
+ TableEntryPtr entry = m_->table_[i];
+ if (entry == TableEntryPtr{}) continue;
+ bucket_index_ = i;
+ if (PROTOBUF_PREDICT_TRUE(internal::TableEntryIsList(entry))) {
+ node_ = static_cast<KeyNode*>(TableEntryToNode(entry));
+ } else {
+ Tree* tree = TableEntryToTree<Tree>(entry);
+ Y_ABSL_DCHECK(!tree->empty());
+ node_ = static_cast<KeyNode*>(tree->begin()->second);
}
+ return;
}
+ node_ = nullptr;
+ bucket_index_ = 0;
}
- size_t SpaceUsedInternal() const {
- return internal::SpaceUsedInTable<Key>(table_, num_buckets_,
- num_elements_, sizeof(Node));
+ // The definition of operator== is handled by the derived type. If we were
+ // to do it in this class it would allow comparing iterators of different
+ // map types.
+ bool Equals(const KeyIteratorBase& other) const {
+ return node_ == other.node_;
}
- private:
- template <typename K, typename... Args>
- std::pair<iterator, bool> TryEmplaceInternal(K&& k, Args&&... args) {
- std::pair<const_iterator, size_type> p = FindHelper(k);
- // Case 1: key was already present.
- if (p.first.node_ != nullptr)
- return std::make_pair(iterator(p.first), false);
- // Case 2: insert.
- if (ResizeIfLoadIsOutOfRange(num_elements_ + 1)) {
- p = FindHelper(k);
+ // The definition of operator++ is handled in the derived type. We would not
+ // be able to return the right type from here.
+ void PlusPlus() {
+ if (node_->next == nullptr) {
+ SearchFrom(bucket_index_ + 1);
+ } else {
+ node_ = static_cast<KeyNode*>(node_->next);
}
- const size_type b = p.second; // bucket number
- // If K is not key_type, make the conversion to key_type explicit.
- using TypeToInit = typename std::conditional<
- std::is_same<typename std::decay<K>::type, key_type>::value, K&&,
- key_type>::type;
- Node* node = Alloc<Node>(1);
- // Even when arena is nullptr, CreateInArenaStorage is still used to
- // ensure the arena of submessage will be consistent. Otherwise,
- // submessage may have its own arena when message-owned arena is enabled.
- // Note: This only works if `Key` is not arena constructible.
- Arena::CreateInArenaStorage(const_cast<Key*>(&node->kv.first),
- alloc_.arena(),
- static_cast<TypeToInit>(std::forward<K>(k)));
- // Note: if `T` is arena constructible, `Args` needs to be empty.
- Arena::CreateInArenaStorage(&node->kv.second, alloc_.arena(),
- std::forward<Args>(args)...);
-
- iterator result = InsertUnique(b, node);
- ++num_elements_;
- return std::make_pair(result, true);
}
- // A helper function to perform an assignment of `mapped_type`.
- // If the first argument is true, then it is a regular assignment.
- // Otherwise, we first create a temporary and then perform an assignment.
- template <typename V>
- static void AssignMapped(std::true_type, mapped_type& mapped, V&& v) {
- mapped = std::forward<V>(v);
- }
- template <typename... Args>
- static void AssignMapped(std::false_type, mapped_type& mapped,
- Args&&... args) {
- mapped = mapped_type(std::forward<Args>(args)...);
- }
+ KeyNode* node_;
+ const KeyMapBase* m_;
+ size_type bucket_index_;
+ };
- // Case 1: `mapped_type` is arena constructible. A temporary object is
- // created and then (if `Args` are not empty) assigned to a mapped value
- // that was created with the arena.
- template <typename K>
- std::pair<iterator, bool> ArenaAwareTryEmplace(std::true_type, K&& k) {
- // case 1.1: "default" constructed (e.g. from arena only).
- return TryEmplaceInternal(std::forward<K>(k));
- }
- template <typename K, typename... Args>
- std::pair<iterator, bool> ArenaAwareTryEmplace(std::true_type, K&& k,
- Args&&... args) {
- // case 1.2: "default" constructed + copy/move assignment
- auto p = TryEmplaceInternal(std::forward<K>(k));
- if (p.second) {
- AssignMapped(std::is_same<void(typename std::decay<Args>::type...),
- void(mapped_type)>(),
- p.first->second, std::forward<Args>(args)...);
+ public:
+ hasher hash_function() const { return {}; }
+
+ protected:
+ PROTOBUF_NOINLINE void erase_no_destroy(size_type b, KeyNode* node) {
+ TreeIterator tree_it;
+ const bool is_list = revalidate_if_necessary(b, node, &tree_it);
+ if (is_list) {
+ Y_ABSL_DCHECK(TableEntryIsNonEmptyList(b));
+ auto* head = TableEntryToNode(table_[b]);
+ head = EraseFromLinkedList(node, head);
+ table_[b] = NodeToTableEntry(head);
+ } else {
+ Y_ABSL_DCHECK(this->TableEntryIsTree(b));
+ Tree* tree = internal::TableEntryToTree<Tree>(this->table_[b]);
+ if (tree_it != tree->begin()) {
+ auto* prev = std::prev(tree_it)->second;
+ prev->next = prev->next->next;
+ }
+ tree->erase(tree_it);
+ if (tree->empty()) {
+ this->DestroyTree(tree);
+ this->table_[b] = TableEntryPtr{};
}
- return p;
- }
- // Case 2: `mapped_type` is not arena constructible. Using in-place
- // construction.
- template <typename... Args>
- std::pair<iterator, bool> ArenaAwareTryEmplace(std::false_type,
- Args&&... args) {
- return TryEmplaceInternal(std::forward<Args>(args)...);
- }
-
- const_iterator find(const Key& k, TreeIterator* it) const {
- return FindHelper(k, it).first;
- }
- template <typename K>
- std::pair<const_iterator, size_type> FindHelper(const K& k) const {
- return FindHelper(k, nullptr);
}
- template <typename K>
- std::pair<const_iterator, size_type> FindHelper(const K& k,
- TreeIterator* it) const {
- size_type b = BucketNumber(k);
- if (TableEntryIsNonEmptyList(b)) {
- Node* node = static_cast<Node*>(table_[b]);
- do {
- if (internal::TransparentSupport<Key>::Equals(node->kv.first, k)) {
- return std::make_pair(const_iterator(node, this, b), b);
- } else {
- node = node->next;
- }
- } while (node != nullptr);
- } else if (TableEntryIsTree(b)) {
- GOOGLE_DCHECK_EQ(table_[b], table_[b ^ 1]);
- b &= ~static_cast<size_t>(1);
- Tree* tree = static_cast<Tree*>(table_[b]);
- auto tree_it = tree->find(k);
- if (tree_it != tree->end()) {
- if (it != nullptr) *it = tree_it;
- return std::make_pair(const_iterator(tree_it, this, b), b);
- }
+ --num_elements_;
+ if (PROTOBUF_PREDICT_FALSE(b == index_of_first_non_null_)) {
+ while (index_of_first_non_null_ < num_buckets_ &&
+ TableEntryIsEmpty(index_of_first_non_null_)) {
+ ++index_of_first_non_null_;
}
- return std::make_pair(end(), b);
}
+ }
- // Insert the given Node in bucket b. If that would make bucket b too big,
- // and bucket b is not a tree, create a tree for buckets b and b^1 to share.
- // Requires count(*KeyPtrFromNodePtr(node)) == 0 and that b is the correct
- // bucket. num_elements_ is not modified.
- iterator InsertUnique(size_type b, Node* node) {
- GOOGLE_DCHECK(index_of_first_non_null_ == num_buckets_ ||
- table_[index_of_first_non_null_] != nullptr);
- // In practice, the code that led to this point may have already
- // determined whether we are inserting into an empty list, a short list,
- // or whatever. But it's probably cheap enough to recompute that here;
- // it's likely that we're inserting into an empty or short list.
- iterator result;
- GOOGLE_DCHECK(find(node->kv.first) == end());
- if (TableEntryIsEmpty(b)) {
- result = InsertUniqueInList(b, node);
- } else if (TableEntryIsNonEmptyList(b)) {
- if (PROTOBUF_PREDICT_FALSE(TableEntryIsTooLong(b))) {
- TreeConvert(b);
- result = InsertUniqueInTree(b, node);
- GOOGLE_DCHECK_EQ(result.bucket_index_, b & ~static_cast<size_type>(1));
+ // TODO(sbenza): We can reduce duplication by coercing `K` to a common type.
+ // Eg, for string keys we can coerce to string_view. Otherwise, we instantiate
+ // this with all the different `char[N]` of the caller.
+ template <typename K>
+ NodeAndBucket FindHelper(const K& k, TreeIterator* it = nullptr) const {
+ size_type b = BucketNumber(k);
+ if (TableEntryIsNonEmptyList(b)) {
+ auto* node = internal::TableEntryToNode(table_[b]);
+ do {
+ if (internal::TransparentSupport<Key>::Equals(
+ static_cast<KeyNode*>(node)->key(), k)) {
+ return {node, b};
} else {
- // Insert into a pre-existing list. This case cannot modify
- // index_of_first_non_null_, so we skip the code to update it.
- return InsertUniqueInList(b, node);
+ node = node->next;
}
- } else {
- // Insert into a pre-existing tree. This case cannot modify
- // index_of_first_non_null_, so we skip the code to update it.
- return InsertUniqueInTree(b, node);
+ } while (node != nullptr);
+ } else if (TableEntryIsTree(b)) {
+ Tree* tree = internal::TableEntryToTree<Tree>(table_[b]);
+ auto tree_it = tree->find(k);
+ if (it != nullptr) *it = tree_it;
+ if (tree_it != tree->end()) {
+ return {tree_it->second, b};
}
- // parentheses around (std::min) prevents macro expansion of min(...)
- index_of_first_non_null_ =
- (std::min)(index_of_first_non_null_, result.bucket_index_);
- return result;
- }
-
- // Returns whether we should insert after the head of the list. For
- // non-optimized builds, we randomly decide whether to insert right at the
- // head of the list or just after the head. This helps add a little bit of
- // non-determinism to the map ordering.
- bool ShouldInsertAfterHead(void* node) {
-#ifdef NDEBUG
- (void)node;
- return false;
-#else
- // Doing modulo with a prime mixes the bits more.
- return (reinterpret_cast<uintptr_t>(node) ^ seed_) % 13 > 6;
-#endif
}
+ return {nullptr, b};
+ }
- // Helper for InsertUnique. Handles the case where bucket b is a
- // not-too-long linked list.
- iterator InsertUniqueInList(size_type b, Node* node) {
- if (table_[b] != nullptr && ShouldInsertAfterHead(node)) {
- Node* first = static_cast<Node*>(table_[b]);
- node->next = first->next;
- first->next = node;
- return iterator(node, this, b);
+ // Insert the given Node in bucket b. If that would make bucket b too big,
+ // and bucket b is not a tree, create a tree for buckets b.
+ // Requires count(*KeyPtrFromNodePtr(node)) == 0 and that b is the correct
+ // bucket. num_elements_ is not modified.
+ void InsertUnique(size_type b, KeyNode* node) {
+ Y_ABSL_DCHECK(index_of_first_non_null_ == num_buckets_ ||
+ !TableEntryIsEmpty(index_of_first_non_null_));
+ // In practice, the code that led to this point may have already
+ // determined whether we are inserting into an empty list, a short list,
+ // or whatever. But it's probably cheap enough to recompute that here;
+ // it's likely that we're inserting into an empty or short list.
+ Y_ABSL_DCHECK(FindHelper(node->key()).node == nullptr);
+ if (TableEntryIsEmpty(b)) {
+ InsertUniqueInList(b, node);
+ index_of_first_non_null_ = (std::min)(index_of_first_non_null_, b);
+ } else if (TableEntryIsNonEmptyList(b) && !TableEntryIsTooLong(b)) {
+ InsertUniqueInList(b, node);
+ } else {
+ if (TableEntryIsNonEmptyList(b)) {
+ TreeConvert(b);
}
-
- node->next = static_cast<Node*>(table_[b]);
- table_[b] = static_cast<void*>(node);
- return iterator(node, this, b);
+ Y_ABSL_DCHECK(TableEntryIsTree(b))
+ << (void*)table_[b] << " " << (uintptr_t)table_[b];
+ InsertUniqueInTree(b, node);
+ index_of_first_non_null_ = (std::min)(index_of_first_non_null_, b);
}
+ }
- // Helper for InsertUnique. Handles the case where bucket b points to a
- // Tree.
- iterator InsertUniqueInTree(size_type b, Node* node) {
- GOOGLE_DCHECK_EQ(table_[b], table_[b ^ 1]);
- // Maintain the invariant that node->next is null for all Nodes in Trees.
- node->next = nullptr;
- return iterator(
- static_cast<Tree*>(table_[b])->insert({node->kv.first, node}).first,
- this, b & ~static_cast<size_t>(1));
- }
+ // Helper for InsertUnique. Handles the case where bucket b points to a
+ // Tree.
+ void InsertUniqueInTree(size_type b, KeyNode* node) {
+ auto* tree = TableEntryToTree<Tree>(table_[b]);
+ auto it = tree->insert({node->key(), node}).first;
+ // Maintain the linked list of the nodes in the tree.
+ // For simplicity, they are in the same order as the tree iteration.
+ if (it != tree->begin()) {
+ auto* prev = std::prev(it)->second;
+ prev->next = node;
+ }
+ auto next = std::next(it);
+ node->next = next != tree->end() ? next->second : nullptr;
+ }
- // Returns whether it did resize. Currently this is only used when
- // num_elements_ increases, though it could be used in other situations.
- // It checks for load too low as well as load too high: because any number
- // of erases can occur between inserts, the load could be as low as 0 here.
- // Resizing to a lower size is not always helpful, but failing to do so can
- // destroy the expected big-O bounds for some operations. By having the
- // policy that sometimes we resize down as well as up, clients can easily
- // keep O(size()) = O(number of buckets) if they want that.
- bool ResizeIfLoadIsOutOfRange(size_type new_size) {
- const size_type kMaxMapLoadTimes16 = 12; // controls RAM vs CPU tradeoff
- const size_type hi_cutoff = num_buckets_ * kMaxMapLoadTimes16 / 16;
- const size_type lo_cutoff = hi_cutoff / 4;
- // We don't care how many elements are in trees. If a lot are,
- // we may resize even though there are many empty buckets. In
- // practice, this seems fine.
- if (PROTOBUF_PREDICT_FALSE(new_size >= hi_cutoff)) {
- if (num_buckets_ <= max_size() / 2) {
- Resize(num_buckets_ * 2);
- return true;
- }
- } else if (PROTOBUF_PREDICT_FALSE(new_size <= lo_cutoff &&
- num_buckets_ > kMinTableSize)) {
- size_type lg2_of_size_reduction_factor = 1;
- // It's possible we want to shrink a lot here... size() could even be 0.
- // So, estimate how much to shrink by making sure we don't shrink so
- // much that we would need to grow the table after a few inserts.
- const size_type hypothetical_size = new_size * 5 / 4 + 1;
- while ((hypothetical_size << lg2_of_size_reduction_factor) <
- hi_cutoff) {
- ++lg2_of_size_reduction_factor;
- }
- size_type new_num_buckets = std::max<size_type>(
- kMinTableSize, num_buckets_ >> lg2_of_size_reduction_factor);
- if (new_num_buckets != num_buckets_) {
- Resize(new_num_buckets);
- return true;
- }
+ // Returns whether it did resize. Currently this is only used when
+ // num_elements_ increases, though it could be used in other situations.
+ // It checks for load too low as well as load too high: because any number
+ // of erases can occur between inserts, the load could be as low as 0 here.
+ // Resizing to a lower size is not always helpful, but failing to do so can
+ // destroy the expected big-O bounds for some operations. By having the
+ // policy that sometimes we resize down as well as up, clients can easily
+ // keep O(size()) = O(number of buckets) if they want that.
+ bool ResizeIfLoadIsOutOfRange(size_type new_size) {
+ const size_type kMaxMapLoadTimes16 = 12; // controls RAM vs CPU tradeoff
+ const size_type hi_cutoff = num_buckets_ * kMaxMapLoadTimes16 / 16;
+ const size_type lo_cutoff = hi_cutoff / 4;
+ // We don't care how many elements are in trees. If a lot are,
+ // we may resize even though there are many empty buckets. In
+ // practice, this seems fine.
+ if (PROTOBUF_PREDICT_FALSE(new_size >= hi_cutoff)) {
+ if (num_buckets_ <= max_size() / 2) {
+ Resize(num_buckets_ * 2);
+ return true;
}
- return false;
- }
-
- // Resize to the given number of buckets.
- void Resize(size_t new_num_buckets) {
- if (num_buckets_ == internal::kGlobalEmptyTableSize) {
- // This is the global empty array.
- // Just overwrite with a new one. No need to transfer or free anything.
- num_buckets_ = index_of_first_non_null_ = kMinTableSize;
- table_ = CreateEmptyTable(num_buckets_);
- seed_ = Seed();
- return;
+ } else if (PROTOBUF_PREDICT_FALSE(new_size <= lo_cutoff &&
+ num_buckets_ > kMinTableSize)) {
+ size_type lg2_of_size_reduction_factor = 1;
+ // It's possible we want to shrink a lot here... size() could even be 0.
+ // So, estimate how much to shrink by making sure we don't shrink so
+ // much that we would need to grow the table after a few inserts.
+ const size_type hypothetical_size = new_size * 5 / 4 + 1;
+ while ((hypothetical_size << lg2_of_size_reduction_factor) < hi_cutoff) {
+ ++lg2_of_size_reduction_factor;
+ }
+ size_type new_num_buckets = std::max<size_type>(
+ kMinTableSize, num_buckets_ >> lg2_of_size_reduction_factor);
+ if (new_num_buckets != num_buckets_) {
+ Resize(new_num_buckets);
+ return true;
}
+ }
+ return false;
+ }
- GOOGLE_DCHECK_GE(new_num_buckets, kMinTableSize);
- void** const old_table = table_;
- const size_type old_table_size = num_buckets_;
- num_buckets_ = new_num_buckets;
+ // Resize to the given number of buckets.
+ void Resize(size_t new_num_buckets) {
+ if (num_buckets_ == kGlobalEmptyTableSize) {
+ // This is the global empty array.
+ // Just overwrite with a new one. No need to transfer or free anything.
+ num_buckets_ = index_of_first_non_null_ = kMinTableSize;
table_ = CreateEmptyTable(num_buckets_);
- const size_type start = index_of_first_non_null_;
- index_of_first_non_null_ = num_buckets_;
- for (size_type i = start; i < old_table_size; i++) {
- if (internal::TableEntryIsNonEmptyList(old_table, i)) {
- TransferList(old_table, i);
- } else if (internal::TableEntryIsTree(old_table, i)) {
- TransferTree(old_table, i++);
- }
+ seed_ = Seed();
+ return;
+ }
+
+ Y_ABSL_DCHECK_GE(new_num_buckets, kMinTableSize);
+ const auto old_table = table_;
+ const size_type old_table_size = num_buckets_;
+ num_buckets_ = new_num_buckets;
+ table_ = CreateEmptyTable(num_buckets_);
+ const size_type start = index_of_first_non_null_;
+ index_of_first_non_null_ = num_buckets_;
+ for (size_type i = start; i < old_table_size; ++i) {
+ if (internal::TableEntryIsNonEmptyList(old_table[i])) {
+ TransferList(static_cast<KeyNode*>(TableEntryToNode(old_table[i])));
+ } else if (internal::TableEntryIsTree(old_table[i])) {
+ TransferTree(TableEntryToTree<Tree>(old_table[i]));
}
- Dealloc<void*>(old_table, old_table_size);
}
+ DeleteTable(old_table, old_table_size);
+ }
- void TransferList(void* const* table, size_type index) {
- Node* node = static_cast<Node*>(table[index]);
- do {
- Node* next = node->next;
- InsertUnique(BucketNumber(node->kv.first), node);
- node = next;
- } while (node != nullptr);
- }
+ // Transfer all nodes in the list `node` into `this`.
+ void TransferList(KeyNode* node) {
+ do {
+ auto* next = static_cast<KeyNode*>(node->next);
+ InsertUnique(BucketNumber(node->key()), node);
+ node = next;
+ } while (node != nullptr);
+ }
- void TransferTree(void* const* table, size_type index) {
- Tree* tree = static_cast<Tree*>(table[index]);
- typename Tree::iterator tree_it = tree->begin();
- do {
- InsertUnique(BucketNumber(std::cref(tree_it->first).get()),
- NodeFromTreeIterator(tree_it));
- } while (++tree_it != tree->end());
- DestroyTree(tree);
- }
+ // Transfer all nodes in the tree `tree` into `this` and destroy the tree.
+ void TransferTree(Tree* tree) {
+ auto* node = tree->begin()->second;
+ DestroyTree(tree);
+ TransferList(static_cast<KeyNode*>(node));
+ }
- Node* EraseFromLinkedList(Node* item, Node* head) {
- if (head == item) {
- return head->next;
- } else {
- head->next = EraseFromLinkedList(item, head->next);
- return head;
- }
- }
+ void TreeConvert(size_type b) {
+ Y_ABSL_DCHECK(!TableEntryIsTree(b));
+ Tree* tree =
+ Arena::Create<Tree>(alloc_.arena(), typename Tree::key_compare(),
+ typename Tree::allocator_type(alloc_));
+ size_type count = CopyListToTree(b, tree);
+ Y_ABSL_DCHECK_EQ(count, tree->size());
+ table_[b] = TreeToTableEntry(tree);
+ // Relink the nodes.
+ NodeBase* next = nullptr;
+ auto it = tree->end();
+ do {
+ auto* node = (--it)->second;
+ node->next = next;
+ next = node;
+ } while (it != tree->begin());
+ }
- bool TableEntryIsEmpty(size_type b) const {
- return internal::TableEntryIsEmpty(table_, b);
- }
- bool TableEntryIsNonEmptyList(size_type b) const {
- return internal::TableEntryIsNonEmptyList(table_, b);
- }
- bool TableEntryIsTree(size_type b) const {
- return internal::TableEntryIsTree(table_, b);
- }
- bool TableEntryIsList(size_type b) const {
- return internal::TableEntryIsList(table_, b);
+ // Copy a linked list in the given bucket to a tree.
+ // Returns the number of things it copied.
+ size_type CopyListToTree(size_type b, Tree* tree) {
+ size_type count = 0;
+ auto* node = TableEntryToNode(table_[b]);
+ while (node != nullptr) {
+ tree->insert({static_cast<KeyNode*>(node)->key(), node});
+ ++count;
+ auto* next = node->next;
+ node->next = nullptr;
+ node = next;
}
+ return count;
+ }
- void TreeConvert(size_type b) {
- GOOGLE_DCHECK(!TableEntryIsTree(b) && !TableEntryIsTree(b ^ 1));
- Tree* tree =
- Arena::Create<Tree>(alloc_.arena(), typename Tree::key_compare(),
- typename Tree::allocator_type(alloc_));
- size_type count = CopyListToTree(b, tree) + CopyListToTree(b ^ 1, tree);
- GOOGLE_DCHECK_EQ(count, tree->size());
- table_[b] = table_[b ^ 1] = static_cast<void*>(tree);
+ template <typename K>
+ size_type BucketNumber(const K& k) const {
+ // We xor the hash value against the random seed so that we effectively
+ // have a random hash function.
+ arc_ui64 h = hash_function()(k) ^ seed_;
+
+ // We use the multiplication method to determine the bucket number from
+ // the hash value. The constant kPhi (suggested by Knuth) is roughly
+ // (sqrt(5) - 1) / 2 * 2^64.
+ constexpr arc_ui64 kPhi = arc_ui64{0x9e3779b97f4a7c15};
+ return ((kPhi * h) >> 32) & (num_buckets_ - 1);
+ }
+
+ void DestroyTree(Tree* tree) {
+ if (alloc_.arena() == nullptr) {
+ delete tree;
}
+ }
- // Copy a linked list in the given bucket to a tree.
- // Returns the number of things it copied.
- size_type CopyListToTree(size_type b, Tree* tree) {
- size_type count = 0;
- Node* node = static_cast<Node*>(table_[b]);
- while (node != nullptr) {
- tree->insert({node->kv.first, node});
- ++count;
- Node* next = node->next;
- node->next = nullptr;
- node = next;
+ // Assumes node_ and m_ are correct and non-null, but other fields may be
+ // stale. Fix them as needed. Then return true iff node_ points to a
+ // Node in a list. If false is returned then *it is modified to be
+ // a valid iterator for node_.
+ bool revalidate_if_necessary(size_t& bucket_index, KeyNode* node,
+ TreeIterator* it) const {
+ // Force bucket_index to be in range.
+ bucket_index &= (num_buckets_ - 1);
+ // Common case: the bucket we think is relevant points to `node`.
+ if (table_[bucket_index] == NodeToTableEntry(node)) return true;
+ // Less common: the bucket is a linked list with node_ somewhere in it,
+ // but not at the head.
+ if (TableEntryIsNonEmptyList(bucket_index)) {
+ auto* l = TableEntryToNode(table_[bucket_index]);
+ while ((l = l->next) != nullptr) {
+ if (l == node) {
+ return true;
+ }
}
- return count;
}
+ // Well, bucket_index_ still might be correct, but probably
+ // not. Revalidate just to be sure. This case is rare enough that we
+ // don't worry about potential optimizations, such as having a custom
+ // find-like method that compares Node* instead of the key.
+ auto res = FindHelper(node->key(), it);
+ bucket_index = res.bucket;
+ return TableEntryIsList(bucket_index);
+ }
+};
- // Return whether table_[b] is a linked list that seems awfully long.
- // Requires table_[b] to point to a non-empty linked list.
- bool TableEntryIsTooLong(size_type b) {
- const size_type kMaxLength = 8;
- size_type count = 0;
- Node* node = static_cast<Node*>(table_[b]);
- do {
- ++count;
- node = node->next;
- } while (node != nullptr);
- // Invariant: no linked list ever is more than kMaxLength in length.
- GOOGLE_DCHECK_LE(count, kMaxLength);
- return count >= kMaxLength;
- }
+} // namespace internal
- template <typename K>
- size_type BucketNumber(const K& k) const {
- // We xor the hash value against the random seed so that we effectively
- // have a random hash function.
- arc_ui64 h = hash_function()(k) ^ seed_;
-
- // We use the multiplication method to determine the bucket number from
- // the hash value. The constant kPhi (suggested by Knuth) is roughly
- // (sqrt(5) - 1) / 2 * 2^64.
- constexpr arc_ui64 kPhi = arc_ui64{0x9e3779b97f4a7c15};
- return ((kPhi * h) >> 32) & (num_buckets_ - 1);
- }
+// This is the class for Map's internal value_type.
+template <typename Key, typename T>
+using MapPair = std::pair<const Key, T>;
- // Return a power of two no less than max(kMinTableSize, n).
- // Assumes either n < kMinTableSize or n is a power of two.
- size_type TableSize(size_type n) {
- return n < static_cast<size_type>(kMinTableSize)
- ? static_cast<size_type>(kMinTableSize)
- : n;
- }
+// Map is an associative container type used to store protobuf map
+// fields. Each Map instance may or may not use a different hash function, a
+// different iteration order, and so on. E.g., please don't examine
+// implementation details to decide if the following would work:
+// Map<int, int> m0, m1;
+// m0[0] = m1[0] = m0[1] = m1[1] = 0;
+// assert(m0.begin()->first == m1.begin()->first); // Bug!
+//
+// Map's interface is similar to std::unordered_map, except that Map is not
+// designed to play well with exceptions.
+template <typename Key, typename T>
+class Map : private internal::KeyMapBase<internal::KeyForBase<Key>> {
+ using Base = typename Map::KeyMapBase;
- // Use alloc_ to allocate an array of n objects of type U.
- template <typename U>
- U* Alloc(size_type n) {
- using alloc_type = typename Allocator::template rebind<U>::other;
- return alloc_type(alloc_).allocate(n);
- }
+ public:
+ using key_type = Key;
+ using mapped_type = T;
+ using init_type = std::pair<Key, T>;
+ using value_type = MapPair<Key, T>;
- // Use alloc_ to deallocate an array of n objects of type U.
- template <typename U>
- void Dealloc(U* t, size_type n) {
- using alloc_type = typename Allocator::template rebind<U>::other;
- alloc_type(alloc_).deallocate(t, n);
- }
+ using pointer = value_type*;
+ using const_pointer = const value_type*;
+ using reference = value_type&;
+ using const_reference = const value_type&;
- void DestroyNode(Node* node) {
- if (alloc_.arena() == nullptr) {
- delete node;
- }
+ using size_type = size_t;
+ using hasher = typename internal::TransparentSupport<Key>::hash;
+
+ constexpr Map() : Base(nullptr) { StaticValidityCheck(); }
+ explicit Map(Arena* arena) : Base(arena) { StaticValidityCheck(); }
+
+ Map(const Map& other) : Map() { insert(other.begin(), other.end()); }
+
+ Map(Map&& other) noexcept : Map() {
+ if (other.arena() != nullptr) {
+ *this = other;
+ } else {
+ swap(other);
}
+ }
- void DestroyTree(Tree* tree) {
- if (alloc_.arena() == nullptr) {
- delete tree;
+ Map& operator=(Map&& other) noexcept {
+ if (this != &other) {
+ if (arena() != other.arena()) {
+ *this = other;
+ } else {
+ swap(other);
}
}
+ return *this;
+ }
- void** CreateEmptyTable(size_type n) {
- GOOGLE_DCHECK(n >= kMinTableSize);
- GOOGLE_DCHECK_EQ(n & (n - 1), 0u);
- void** result = Alloc<void*>(n);
- memset(result, 0, n * sizeof(result[0]));
- return result;
- }
+ template <class InputIt>
+ Map(const InputIt& first, const InputIt& last) : Map() {
+ insert(first, last);
+ }
- // Return a randomish value.
- size_type Seed() const {
- // We get a little bit of randomness from the address of the map. The
- // lower bits are not very random, due to alignment, so we discard them
- // and shift the higher bits into their place.
- size_type s = reinterpret_cast<uintptr_t>(this) >> 4;
-#if !defined(GOOGLE_PROTOBUF_NO_RDTSC)
-#if defined(__APPLE__)
- // Use a commpage-based fast time function on Apple environments (MacOS,
- // iOS, tvOS, watchOS, etc).
- s += mach_absolute_time();
-#elif defined(__x86_64__) && defined(__GNUC__)
- arc_ui32 hi, lo;
- asm volatile("rdtsc" : "=a"(lo), "=d"(hi));
- s += ((static_cast<arc_ui64>(hi) << 32) | lo);
-#elif defined(__aarch64__) && defined(__GNUC__)
- // There is no rdtsc on ARMv8. CNTVCT_EL0 is the virtual counter of the
- // system timer. It runs at a different frequency than the CPU's, but is
- // the best source of time-based entropy we get.
- arc_ui64 virtual_timer_value;
- asm volatile("mrs %0, cntvct_el0" : "=r"(virtual_timer_value));
- s += virtual_timer_value;
-#endif
-#endif // !defined(GOOGLE_PROTOBUF_NO_RDTSC)
- return s;
+ ~Map() {
+ // Fail-safe in case we miss calling this in a constructor. Note: this one
+ // won't trigger for leaked maps that never get destructed.
+ StaticValidityCheck();
+
+ if (this->alloc_.arena() == nullptr &&
+ this->num_buckets_ != internal::kGlobalEmptyTableSize) {
+ clear();
+ this->DeleteTable(this->table_, this->num_buckets_);
}
+ }
- friend class Arena;
- using InternalArenaConstructable_ = void;
- using DestructorSkippable_ = void;
+ private:
+ static_assert(!std::is_const<mapped_type>::value &&
+ !std::is_const<key_type>::value,
+ "We do not support const types.");
+ static_assert(!std::is_volatile<mapped_type>::value &&
+ !std::is_volatile<key_type>::value,
+ "We do not support volatile types.");
+ static_assert(!std::is_pointer<mapped_type>::value &&
+ !std::is_pointer<key_type>::value,
+ "We do not support pointer types.");
+ static_assert(!std::is_reference<mapped_type>::value &&
+ !std::is_reference<key_type>::value,
+ "We do not support reference types.");
+ static constexpr PROTOBUF_ALWAYS_INLINE void StaticValidityCheck() {
+ static_assert(alignof(internal::NodeBase) >= alignof(mapped_type),
+ "Alignment of mapped type is too high.");
+ static_assert(
+ y_absl::disjunction<internal::is_supported_integral_type<key_type>,
+ internal::is_supported_string_type<key_type>,
+ internal::is_internal_map_key_type<key_type>>::value,
+ "We only support integer, string, or designated internal key "
+ "types.");
+ static_assert(y_absl::disjunction<
+ internal::is_supported_scalar_type<mapped_type>,
+ is_proto_enum<mapped_type>,
+ internal::is_supported_message_type<mapped_type>,
+ internal::is_internal_map_value_type<mapped_type>>::value,
+ "We only support scalar, Message, and designated internal "
+ "mapped types.");
+ }
- size_type num_elements_;
- size_type num_buckets_;
- size_type seed_;
- size_type index_of_first_non_null_;
- void** table_; // an array with num_buckets_ entries
- Allocator alloc_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(InnerMap);
- }; // end of class InnerMap
+ template <typename P>
+ struct SameAsElementReference
+ : std::is_same<typename std::remove_cv<
+ typename std::remove_reference<reference>::type>::type,
+ typename std::remove_cv<
+ typename std::remove_reference<P>::type>::type> {};
+
+ template <class P>
+ using RequiresInsertable =
+ typename std::enable_if<std::is_convertible<P, init_type>::value ||
+ SameAsElementReference<P>::value,
+ int>::type;
+ template <class P>
+ using RequiresNotInit =
+ typename std::enable_if<!std::is_same<P, init_type>::value, int>::type;
template <typename LookupKey>
using key_arg = typename internal::TransparentSupport<
@@ -1191,8 +1123,8 @@ class Map {
public:
// Iterators
- class const_iterator {
- using InnerIt = typename InnerMap::const_iterator;
+ class const_iterator : private Base::KeyIteratorBase {
+ using BaseIt = typename Base::KeyIteratorBase;
public:
using iterator_category = std::forward_iterator_tag;
@@ -1202,30 +1134,37 @@ class Map {
using reference = const value_type&;
const_iterator() {}
- explicit const_iterator(const InnerIt& it) : it_(it) {}
+ const_iterator(const const_iterator&) = default;
+ const_iterator& operator=(const const_iterator&) = default;
- const_reference operator*() const { return *it_; }
- const_pointer operator->() const { return &(operator*()); }
+ reference operator*() const { return static_cast<Node*>(this->node_)->kv; }
+ pointer operator->() const { return &(operator*()); }
const_iterator& operator++() {
- ++it_;
+ this->PlusPlus();
return *this;
}
- const_iterator operator++(int) { return const_iterator(it_++); }
+ const_iterator operator++(int) {
+ auto copy = *this;
+ this->PlusPlus();
+ return copy;
+ }
friend bool operator==(const const_iterator& a, const const_iterator& b) {
- return a.it_ == b.it_;
+ return a.Equals(b);
}
friend bool operator!=(const const_iterator& a, const const_iterator& b) {
- return !(a == b);
+ return !a.Equals(b);
}
private:
- InnerIt it_;
+ using BaseIt::BaseIt;
+ explicit const_iterator(const BaseIt& base) : BaseIt(base) {}
+ friend class Map;
};
- class iterator {
- using InnerIt = typename InnerMap::iterator;
+ class iterator : private Base::KeyIteratorBase {
+ using BaseIt = typename Base::KeyIteratorBase;
public:
using iterator_category = std::forward_iterator_tag;
@@ -1235,70 +1174,73 @@ class Map {
using reference = value_type&;
iterator() {}
- explicit iterator(const InnerIt& it) : it_(it) {}
+ iterator(const iterator&) = default;
+ iterator& operator=(const iterator&) = default;
- reference operator*() const { return *it_; }
+ reference operator*() const { return static_cast<Node*>(this->node_)->kv; }
pointer operator->() const { return &(operator*()); }
iterator& operator++() {
- ++it_;
+ this->PlusPlus();
return *this;
}
- iterator operator++(int) { return iterator(it_++); }
+ iterator operator++(int) {
+ auto copy = *this;
+ this->PlusPlus();
+ return copy;
+ }
// Allow implicit conversion to const_iterator.
operator const_iterator() const { // NOLINT(runtime/explicit)
- return const_iterator(typename InnerMap::const_iterator(it_));
+ return const_iterator(static_cast<const BaseIt&>(*this));
}
friend bool operator==(const iterator& a, const iterator& b) {
- return a.it_ == b.it_;
+ return a.Equals(b);
}
friend bool operator!=(const iterator& a, const iterator& b) {
- return !(a == b);
+ return !a.Equals(b);
}
private:
+ using BaseIt::BaseIt;
friend class Map;
-
- InnerIt it_;
};
- iterator begin() { return iterator(elements_.begin()); }
- iterator end() { return iterator(elements_.end()); }
- const_iterator begin() const { return const_iterator(elements_.begin()); }
- const_iterator end() const { return const_iterator(elements_.end()); }
+ iterator begin() { return iterator(this); }
+ iterator end() { return iterator(); }
+ const_iterator begin() const { return const_iterator(this); }
+ const_iterator end() const { return const_iterator(); }
const_iterator cbegin() const { return begin(); }
const_iterator cend() const { return end(); }
- // Capacity
- size_type size() const { return elements_.size(); }
- bool empty() const { return size() == 0; }
+ using Base::empty;
+ using Base::size;
// Element access
template <typename K = key_type>
T& operator[](const key_arg<K>& key) {
- return elements_[key].second;
+ return try_emplace(key).first->second;
}
template <
typename K = key_type,
// Disable for integral types to reduce code bloat.
typename = typename std::enable_if<!std::is_integral<K>::value>::type>
T& operator[](key_arg<K>&& key) {
- return elements_[std::forward<K>(key)].second;
+ return try_emplace(std::forward<K>(key)).first->second;
}
template <typename K = key_type>
const T& at(const key_arg<K>& key) const {
const_iterator it = find(key);
- GOOGLE_CHECK(it != end()) << "key not found: " << static_cast<Key>(key);
+ Y_ABSL_CHECK(it != end()) << "key not found: " << static_cast<Key>(key);
return it->second;
}
template <typename K = key_type>
T& at(const key_arg<K>& key) {
iterator it = find(key);
- GOOGLE_CHECK(it != end()) << "key not found: " << static_cast<Key>(key);
+ Y_ABSL_CHECK(it != end()) << "key not found: " << static_cast<Key>(key);
return it->second;
}
@@ -1310,11 +1252,12 @@ class Map {
template <typename K = key_type>
const_iterator find(const key_arg<K>& key) const {
- return const_iterator(elements_.find(key));
+ return const_cast<Map*>(this)->find(key);
}
template <typename K = key_type>
iterator find(const key_arg<K>& key) {
- return iterator(elements_.find(key));
+ auto res = this->FindHelper(key);
+ return iterator(static_cast<Node*>(res.node), this, res.bucket);
}
template <typename K = key_type>
@@ -1348,27 +1291,42 @@ class Map {
// insert
template <typename K, typename... Args>
std::pair<iterator, bool> try_emplace(K&& k, Args&&... args) {
- auto p =
- elements_.try_emplace(std::forward<K>(k), std::forward<Args>(args)...);
- return std::pair<iterator, bool>(iterator(p.first), p.second);
+ // Inserts a new element into the container if there is no element with the
+ // key in the container.
+ // The new element is:
+ // (1) Constructed in-place with the given args, if mapped_type is not
+ // arena constructible.
+ // (2) Constructed in-place with the arena and then assigned with a
+ // mapped_type temporary constructed with the given args, otherwise.
+ return ArenaAwareTryEmplace(Arena::is_arena_constructable<mapped_type>(),
+ std::forward<K>(k),
+ std::forward<Args>(args)...);
}
- std::pair<iterator, bool> insert(const value_type& value) {
- return try_emplace(value.first, value.second);
+ std::pair<iterator, bool> insert(init_type&& value) {
+ return try_emplace(std::move(value.first), std::move(value.second));
}
- std::pair<iterator, bool> insert(value_type&& value) {
- return try_emplace(value.first, std::move(value.second));
+ template <typename P, RequiresInsertable<P> = 0>
+ std::pair<iterator, bool> insert(P&& value) {
+ return try_emplace(std::forward<P>(value).first,
+ std::forward<P>(value).second);
}
template <typename... Args>
std::pair<iterator, bool> emplace(Args&&... args) {
- return insert(value_type(std::forward<Args>(args)...));
+ return EmplaceInternal(Rank0{}, std::forward<Args>(args)...);
}
template <class InputIt>
void insert(InputIt first, InputIt last) {
for (; first != last; ++first) {
- try_emplace(first->first, first->second);
+ auto&& pair = *first;
+ try_emplace(pair.first, pair.second);
}
}
- void insert(std::initializer_list<value_type> values) {
+ void insert(std::initializer_list<init_type> values) {
+ insert(values.begin(), values.end());
+ }
+ template <typename P, RequiresNotInit<P> = 0,
+ RequiresInsertable<const P&> = 0>
+ void insert(std::initializer_list<P> values) {
insert(values.begin(), values.end());
}
@@ -1383,17 +1341,45 @@ class Map {
return 1;
}
}
+
iterator erase(iterator pos) {
- iterator i = pos++;
- elements_.erase(i.it_);
- return pos;
+ auto next = std::next(pos);
+ Y_ABSL_DCHECK_EQ(pos.m_, static_cast<Base*>(this));
+ auto* node = static_cast<Node*>(pos.node_);
+ this->erase_no_destroy(pos.bucket_index_, node);
+ DestroyNode(node);
+ return next;
}
+
void erase(iterator first, iterator last) {
while (first != last) {
first = erase(first);
}
}
- void clear() { elements_.clear(); }
+
+ void clear() {
+ for (size_type b = 0; b < this->num_buckets_; b++) {
+ internal::NodeBase* node;
+ if (this->TableEntryIsNonEmptyList(b)) {
+ node = internal::TableEntryToNode(this->table_[b]);
+ this->table_[b] = TableEntryPtr{};
+ } else if (this->TableEntryIsTree(b)) {
+ Tree* tree = internal::TableEntryToTree<Tree>(this->table_[b]);
+ this->table_[b] = TableEntryPtr{};
+ node = NodeFromTreeIterator(tree->begin());
+ this->DestroyTree(tree);
+ } else {
+ continue;
+ }
+ do {
+ auto* next = node->next;
+ DestroyNode(static_cast<Node*>(node));
+ node = next;
+ } while (node != nullptr);
+ }
+ this->num_elements_ = 0;
+ this->index_of_first_non_null_ = this->num_buckets_;
+ }
// Assign
Map& operator=(const Map& other) {
@@ -1406,7 +1392,7 @@ class Map {
void swap(Map& other) {
if (arena() == other.arena()) {
- InternalSwap(other);
+ InternalSwap(&other);
} else {
// TODO(zuguang): optimize this. The temporary copy can be allocated
// in the same arena as the other message, and the "other = copy" can
@@ -1417,22 +1403,141 @@ class Map {
}
}
- void InternalSwap(Map& other) { elements_.Swap(&other.elements_); }
+ void InternalSwap(Map* other) { this->Swap(other); }
- // Access to hasher. Currently this returns a copy, but it may
- // be modified to return a const reference in the future.
- hasher hash_function() const { return elements_.hash_function(); }
+ hasher hash_function() const { return {}; }
size_t SpaceUsedExcludingSelfLong() const {
if (empty()) return 0;
- return elements_.SpaceUsedInternal() + internal::SpaceUsedInValues(this);
+ return SpaceUsedInternal() + internal::SpaceUsedInValues(this);
}
private:
- Arena* arena() const { return elements_.arena(); }
- InnerMap elements_;
+ struct Rank1 {};
+ struct Rank0 : Rank1 {};
+
+ // Linked-list nodes, as one would expect for a chaining hash table.
+ struct Node : Base::KeyNode {
+ value_type kv;
+ };
+
+ using Tree = internal::TreeForMap<Key>;
+ using TreeIterator = typename Tree::iterator;
+ using TableEntryPtr = internal::TableEntryPtr;
+
+ static Node* NodeFromTreeIterator(TreeIterator it) {
+ static_assert(
+ PROTOBUF_FIELD_OFFSET(Node, kv.first) == Base::KeyNode::kOffset, "");
+ static_assert(alignof(Node) == alignof(internal::NodeBase), "");
+ return static_cast<Node*>(it->second);
+ }
+
+ void DestroyNode(Node* node) {
+ if (this->alloc_.arena() == nullptr) {
+ node->kv.first.~key_type();
+ node->kv.second.~mapped_type();
+ this->DeallocNode(node, sizeof(Node));
+ }
+ }
+
+ size_t SpaceUsedInternal() const {
+ return internal::SpaceUsedInTable<Key>(this->table_, this->num_buckets_,
+ this->num_elements_, sizeof(Node));
+ }
+
+ // We try to construct `init_type` from `Args` with a fall back to
+ // `value_type`. The latter is less desired as it unconditionally makes a copy
+ // of `value_type::first`.
+ template <typename... Args>
+ auto EmplaceInternal(Rank0, Args&&... args) ->
+ typename std::enable_if<std::is_constructible<init_type, Args...>::value,
+ std::pair<iterator, bool>>::type {
+ return insert(init_type(std::forward<Args>(args)...));
+ }
+ template <typename... Args>
+ std::pair<iterator, bool> EmplaceInternal(Rank1, Args&&... args) {
+ return insert(value_type(std::forward<Args>(args)...));
+ }
+
+ template <typename K, typename... Args>
+ std::pair<iterator, bool> TryEmplaceInternal(K&& k, Args&&... args) {
+ auto p = this->FindHelper(k);
+ // Case 1: key was already present.
+ if (p.node != nullptr)
+ return std::make_pair(
+ iterator(static_cast<Node*>(p.node), this, p.bucket), false);
+ // Case 2: insert.
+ if (this->ResizeIfLoadIsOutOfRange(this->num_elements_ + 1)) {
+ p = this->FindHelper(k);
+ }
+ const size_type b = p.bucket; // bucket number
+ // If K is not key_type, make the conversion to key_type explicit.
+ using TypeToInit = typename std::conditional<
+ std::is_same<typename std::decay<K>::type, key_type>::value, K&&,
+ key_type>::type;
+ Node* node = static_cast<Node*>(this->AllocNode(sizeof(Node)));
+ // Even when arena is nullptr, CreateInArenaStorage is still used to
+ // ensure the arena of submessage will be consistent. Otherwise,
+ // submessage may have its own arena when message-owned arena is enabled.
+ // Note: This only works if `Key` is not arena constructible.
+ Arena::CreateInArenaStorage(const_cast<Key*>(&node->kv.first),
+ this->alloc_.arena(),
+ static_cast<TypeToInit>(std::forward<K>(k)));
+ // Note: if `T` is arena constructible, `Args` needs to be empty.
+ Arena::CreateInArenaStorage(&node->kv.second, this->alloc_.arena(),
+ std::forward<Args>(args)...);
+
+ this->InsertUnique(b, node);
+ ++this->num_elements_;
+ return std::make_pair(iterator(node, this, b), true);
+ }
+
+ // A helper function to perform an assignment of `mapped_type`.
+ // If the first argument is true, then it is a regular assignment.
+ // Otherwise, we first create a temporary and then perform an assignment.
+ template <typename V>
+ static void AssignMapped(std::true_type, mapped_type& mapped, V&& v) {
+ mapped = std::forward<V>(v);
+ }
+ template <typename... Args>
+ static void AssignMapped(std::false_type, mapped_type& mapped,
+ Args&&... args) {
+ mapped = mapped_type(std::forward<Args>(args)...);
+ }
+
+ // Case 1: `mapped_type` is arena constructible. A temporary object is
+ // created and then (if `Args` are not empty) assigned to a mapped value
+ // that was created with the arena.
+ template <typename K>
+ std::pair<iterator, bool> ArenaAwareTryEmplace(std::true_type, K&& k) {
+ // case 1.1: "default" constructed (e.g. from arena only).
+ return TryEmplaceInternal(std::forward<K>(k));
+ }
+ template <typename K, typename... Args>
+ std::pair<iterator, bool> ArenaAwareTryEmplace(std::true_type, K&& k,
+ Args&&... args) {
+ // case 1.2: "default" constructed + copy/move assignment
+ auto p = TryEmplaceInternal(std::forward<K>(k));
+ if (p.second) {
+ AssignMapped(std::is_same<void(typename std::decay<Args>::type...),
+ void(mapped_type)>(),
+ p.first->second, std::forward<Args>(args)...);
+ }
+ return p;
+ }
+ // Case 2: `mapped_type` is not arena constructible. Using in-place
+ // construction.
+ template <typename... Args>
+ std::pair<iterator, bool> ArenaAwareTryEmplace(std::false_type,
+ Args&&... args) {
+ return TryEmplaceInternal(std::forward<Args>(args)...);
+ }
+
+ using Base::arena;
friend class Arena;
+ template <typename, typename>
+ friend class internal::TypeDefinedMapFieldBase;
using InternalArenaConstructable_ = void;
using DestructorSkippable_ = void;
template <typename Derived, typename K, typename V,
@@ -1441,9 +1546,18 @@ class Map {
friend class internal::MapFieldLite;
};
+namespace internal {
+template <typename... T>
+PROTOBUF_NOINLINE void MapMergeFrom(Map<T...>& dest, const Map<T...>& src) {
+ for (const auto& elem : src) {
+ dest[elem.first] = elem.second;
+ }
+}
+} // namespace internal
+
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_MAP_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/map_entry.h b/contrib/libs/protobuf/src/google/protobuf/map_entry.h
index 021a56000ce..96b51990ed5 100644
--- a/contrib/libs/protobuf/src/google/protobuf/map_entry.h
+++ b/contrib/libs/protobuf/src/google/protobuf/map_entry.h
@@ -31,16 +31,16 @@
#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/reflection_ops.h>
-#include <google/protobuf/unknown_field_set.h>
-#include <google/protobuf/wire_format_lite.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/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>
+#include "google/protobuf/port_def.inc"
#ifdef SWIG
#error "You cannot SWIG proto headers"
@@ -98,6 +98,8 @@ class MapEntry : public MapEntryImpl<Derived, Message, Key, Value,
explicit MapEntry(Arena* arena)
: MapEntryImpl<Derived, Message, Key, Value, kKeyFieldType,
kValueFieldType>(arena) {}
+ MapEntry(const MapEntry&) = delete;
+ MapEntry& operator=(const MapEntry&) = delete;
~MapEntry() override {
Message::_internal_metadata_.template Delete<UnknownFieldSet>();
}
@@ -121,14 +123,12 @@ class MapEntry : public MapEntryImpl<Derived, Message, Key, Value,
template <typename C, typename K, typename V,
WireFormatLite::FieldType k_wire_type, WireFormatLite::FieldType>
friend class internal::MapField;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapEntry);
};
} // namespace internal
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_MAP_ENTRY_H__
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 692f42b912f..feba03aec47 100644
--- a/contrib/libs/protobuf/src/google/protobuf/map_entry_lite.h
+++ b/contrib/libs/protobuf/src/google/protobuf/map_entry_lite.h
@@ -37,19 +37,20 @@
#include <string>
#include <utility>
-#include <google/protobuf/stubs/casts.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/parse_context.h>
-#include <google/protobuf/wire_format_lite.h>
+#include "google/protobuf/arena.h"
+#include "y_absl/base/casts.h"
+#include "google/protobuf/arenastring.h"
+#include "google/protobuf/generated_message_util.h"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/map.h"
+#include "google/protobuf/map_type_handler.h"
+#include "google/protobuf/parse_context.h"
+#include "google/protobuf/port.h"
+#include "google/protobuf/wire_format_lite.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
+
#ifdef SWIG
#error "You cannot SWIG proto headers"
#endif
@@ -102,7 +103,7 @@ struct MoveHelper<false, false, true, T> { // strings and similar
};
// MapEntryImpl is used to implement parsing and serialization of map entries.
-// It uses Curious Recursive Template Pattern (CRTP) to provide the type of
+// It uses Curiously Recurring Template Pattern (CRTP) to provide the type of
// the eventual code to the template code.
template <typename Derived, typename Base, typename Key, typename Value,
WireFormatLite::FieldType kKeyFieldType,
@@ -159,6 +160,9 @@ class MapEntryImpl : public Base {
value_(ValueTypeHandler::Constinit()),
_has_bits_{} {}
+ MapEntryImpl(const MapEntryImpl&) = delete;
+ MapEntryImpl& operator=(const MapEntryImpl&) = delete;
+
~MapEntryImpl() override {
if (Base::GetArenaForAllocation() != nullptr) return;
KeyTypeHandler::DeleteNoArena(key_);
@@ -167,10 +171,10 @@ class MapEntryImpl : public Base {
// accessors ======================================================
- virtual inline const KeyMapEntryAccessorType& key() const {
+ inline const KeyMapEntryAccessorType& key() const {
return KeyTypeHandler::GetExternalReference(key_);
}
- virtual inline const ValueMapEntryAccessorType& value() const {
+ inline const ValueMapEntryAccessorType& value() const {
return ValueTypeHandler::DefaultIfNotInitialized(value_);
}
inline KeyMapEntryAccessorType* mutable_key() {
@@ -425,12 +429,14 @@ class MapEntryImpl : public Base {
typedef void DestructorSkippable_;
template <typename C, typename K, typename V, WireFormatLite::FieldType,
WireFormatLite::FieldType>
- friend class internal::MapEntry;
+ friend class ::PROTOBUF_NAMESPACE_ID::internal::MapEntry;
template <typename C, typename K, typename V, WireFormatLite::FieldType,
WireFormatLite::FieldType>
- friend class internal::MapFieldLite;
+ friend class ::PROTOBUF_NAMESPACE_ID::internal::MapFieldLite;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapEntryImpl);
+ template <typename DerivedT, typename KeyT, typename TT,
+ WireFormatLite::FieldType, WireFormatLite::FieldType>
+ friend class ::PROTOBUF_NAMESPACE_ID::internal::MapField;
};
template <typename T, typename Key, typename Value,
@@ -443,14 +449,13 @@ class MapEntryLite : public MapEntryImpl<T, MessageLite, Key, Value,
kValueFieldType>
SuperType;
constexpr MapEntryLite() {}
+ MapEntryLite(const MapEntryLite&) = delete;
+ MapEntryLite& operator=(const MapEntryLite&) = delete;
explicit MapEntryLite(Arena* arena) : SuperType(arena) {}
~MapEntryLite() override {
MessageLite::_internal_metadata_.template Delete<TProtoStringType>();
}
void MergeFrom(const MapEntryLite& other) { MergeFromInternal(other); }
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapEntryLite);
};
// Helpers for deterministic serialization =============================
@@ -558,6 +563,6 @@ class MapSorterPtr {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_MAP_ENTRY_LITE_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/map_field.cc b/contrib/libs/protobuf/src/google/protobuf/map_field.cc
index 34df16989fd..21e428743e1 100644
--- a/contrib/libs/protobuf/src/google/protobuf/map_field.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/map_field.cc
@@ -28,18 +28,20 @@
// (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/map_field.h>
+#include "google/protobuf/map_field.h"
#include <vector>
-#include <google/protobuf/map_field_inl.h>
+#include "google/protobuf/port.h"
+#include "google/protobuf/map_field_inl.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
namespace internal {
+using ::google::protobuf::internal::DownCast;
void MapFieldBase::Destruct() {
if (arena_ == nullptr) {
@@ -72,8 +74,8 @@ void MapFieldBase::SwapState(MapFieldBase* other) {
void SwapRepeatedPtrToNull(RepeatedPtrField<Message>** from,
RepeatedPtrField<Message>** to, Arena* from_arena,
Arena* to_arena) {
- GOOGLE_DCHECK(*from != nullptr);
- GOOGLE_DCHECK(*to == nullptr);
+ Y_ABSL_DCHECK(*from != nullptr);
+ Y_ABSL_DCHECK(*to == nullptr);
*to = Arena::CreateMessage<RepeatedPtrField<Message> >(to_arena);
**to = std::move(**from);
if (from_arena == nullptr) {
@@ -102,7 +104,7 @@ void MapFieldBase::Swap(MapFieldBase* other) {
}
void MapFieldBase::UnsafeShallowSwap(MapFieldBase* other) {
- GOOGLE_DCHECK_EQ(arena_, other->arena_);
+ Y_ABSL_DCHECK_EQ(arena_, other->arena_);
InternalSwap(other);
}
@@ -361,7 +363,7 @@ void DynamicMapField::SetMapIteratorValue(MapIterator* map_iter) const {
}
void DynamicMapField::MergeFrom(const MapFieldBase& other) {
- GOOGLE_DCHECK(IsMapValid() && other.IsMapValid());
+ Y_ABSL_DCHECK(IsMapValid() && other.IsMapValid());
Map<MapKey, MapValueRef>* map = MutableMap();
const DynamicMapField& other_field =
reinterpret_cast<const DynamicMapField&>(other);
@@ -427,7 +429,7 @@ void DynamicMapField::MergeFrom(const MapFieldBase& other) {
}
void DynamicMapField::Swap(MapFieldBase* other) {
- DynamicMapField* other_field = down_cast<DynamicMapField*>(other);
+ DynamicMapField* other_field = DownCast<DynamicMapField*>(other);
std::swap(this->MapFieldBase::repeated_field_, other_field->repeated_field_);
map_.swap(other_field->map_);
// a relaxed swap of the atomic
@@ -476,7 +478,7 @@ void DynamicMapField::SyncRepeatedFieldWithMapNoLock() const {
case FieldDescriptor::CPPTYPE_FLOAT:
case FieldDescriptor::CPPTYPE_ENUM:
case FieldDescriptor::CPPTYPE_MESSAGE:
- GOOGLE_LOG(FATAL) << "Can't get here.";
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
break;
}
const MapValueRef& map_val = it->second;
@@ -559,7 +561,7 @@ void DynamicMapField::SyncMapWithRepeatedFieldNoLock() const {
case FieldDescriptor::CPPTYPE_FLOAT:
case FieldDescriptor::CPPTYPE_ENUM:
case FieldDescriptor::CPPTYPE_MESSAGE:
- GOOGLE_LOG(FATAL) << "Can't get here.";
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
break;
}
@@ -651,4 +653,4 @@ size_t DynamicMapField::SpaceUsedExcludingSelfNoLock() const {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protobuf/src/google/protobuf/map_field.h b/contrib/libs/protobuf/src/google/protobuf/map_field.h
index 088388382d3..30eee618dec 100644
--- a/contrib/libs/protobuf/src/google/protobuf/map_field.h
+++ b/contrib/libs/protobuf/src/google/protobuf/map_field.h
@@ -33,24 +33,25 @@
#include <atomic>
#include <functional>
+#include <type_traits>
-#include <google/protobuf/arena.h>
-#include <google/protobuf/stubs/mutex.h>
+#include "google/protobuf/arena.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>
-#include <google/protobuf/map_entry.h>
-#include <google/protobuf/map_field_lite.h>
-#include <google/protobuf/map_type_handler.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/unknown_field_set.h>
+#include "google/protobuf/port.h"
+#include "y_absl/synchronization/mutex.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/generated_message_util.h"
+#include "google/protobuf/map_entry.h"
+#include "google/protobuf/map_field_lite.h"
+#include "google/protobuf/map_type_handler.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/repeated_field.h"
+#include "google/protobuf/unknown_field_set.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
#ifdef SWIG
#error "You cannot SWIG proto headers"
@@ -68,13 +69,14 @@ class MapIterator;
#pragma warning(disable : 4265)
#endif // _MSC_VER
-#define TYPE_CHECK(EXPECTEDTYPE, METHOD) \
- if (type() != EXPECTEDTYPE) { \
- GOOGLE_LOG(FATAL) << "Protocol Buffer map usage error:\n" \
- << METHOD << " type does not match\n" \
- << " Expected : " \
- << FieldDescriptor::CppTypeName(EXPECTEDTYPE) << "\n" \
- << " Actual : " << FieldDescriptor::CppTypeName(type()); \
+#define TYPE_CHECK(EXPECTEDTYPE, METHOD) \
+ if (type() != EXPECTEDTYPE) { \
+ Y_ABSL_LOG(FATAL) << "Protocol Buffer map usage error:\n" \
+ << METHOD << " type does not match\n" \
+ << " Expected : " \
+ << FieldDescriptor::CppTypeName(EXPECTEDTYPE) << "\n" \
+ << " Actual : " \
+ << FieldDescriptor::CppTypeName(type()); \
}
// MapKey is an union type for representing any possible
@@ -97,9 +99,9 @@ class PROTOBUF_EXPORT MapKey {
FieldDescriptor::CppType type() const {
if (type_ == FieldDescriptor::CppType()) {
- GOOGLE_LOG(FATAL) << "Protocol Buffer map usage error:\n"
- << "MapKey::type MapKey is not initialized. "
- << "Call set methods to initialize MapKey.";
+ Y_ABSL_LOG(FATAL) << "Protocol Buffer map usage error:\n"
+ << "MapKey::type MapKey is not initialized. "
+ << "Call set methods to initialize MapKey.";
}
return type_;
}
@@ -158,14 +160,14 @@ class PROTOBUF_EXPORT MapKey {
if (type_ != other.type_) {
// We could define a total order that handles this case, but
// there currently no need. So, for now, fail.
- GOOGLE_LOG(FATAL) << "Unsupported: type mismatch";
+ Y_ABSL_LOG(FATAL) << "Unsupported: type mismatch";
}
switch (type()) {
case FieldDescriptor::CPPTYPE_DOUBLE:
case FieldDescriptor::CPPTYPE_FLOAT:
case FieldDescriptor::CPPTYPE_ENUM:
case FieldDescriptor::CPPTYPE_MESSAGE:
- GOOGLE_LOG(FATAL) << "Unsupported";
+ Y_ABSL_LOG(FATAL) << "Unsupported";
return false;
case FieldDescriptor::CPPTYPE_STRING:
return val_.string_value_.get() < other.val_.string_value_.get();
@@ -186,14 +188,14 @@ class PROTOBUF_EXPORT MapKey {
bool operator==(const MapKey& other) const {
if (type_ != other.type_) {
// To be consistent with operator<, we don't allow this either.
- GOOGLE_LOG(FATAL) << "Unsupported: type mismatch";
+ Y_ABSL_LOG(FATAL) << "Unsupported: type mismatch";
}
switch (type()) {
case FieldDescriptor::CPPTYPE_DOUBLE:
case FieldDescriptor::CPPTYPE_FLOAT:
case FieldDescriptor::CPPTYPE_ENUM:
case FieldDescriptor::CPPTYPE_MESSAGE:
- GOOGLE_LOG(FATAL) << "Unsupported";
+ Y_ABSL_LOG(FATAL) << "Unsupported";
break;
case FieldDescriptor::CPPTYPE_STRING:
return val_.string_value_.get() == other.val_.string_value_.get();
@@ -208,7 +210,7 @@ class PROTOBUF_EXPORT MapKey {
case FieldDescriptor::CPPTYPE_BOOL:
return val_.bool_value_ == other.val_.bool_value_;
}
- GOOGLE_LOG(FATAL) << "Can't get here.";
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
return false;
}
@@ -219,7 +221,7 @@ class PROTOBUF_EXPORT MapKey {
case FieldDescriptor::CPPTYPE_FLOAT:
case FieldDescriptor::CPPTYPE_ENUM:
case FieldDescriptor::CPPTYPE_MESSAGE:
- GOOGLE_LOG(FATAL) << "Unsupported";
+ Y_ABSL_LOG(FATAL) << "Unsupported";
break;
case FieldDescriptor::CPPTYPE_STRING:
*val_.string_value_.get_mutable() = other.val_.string_value_.get();
@@ -274,6 +276,11 @@ class PROTOBUF_EXPORT MapKey {
FieldDescriptor::CppType type_;
};
+namespace internal {
+template <>
+struct is_internal_map_key_type<MapKey> : std::true_type {};
+} // namespace internal
+
} // namespace protobuf
} // namespace google
namespace std {
@@ -285,7 +292,7 @@ struct hash<::PROTOBUF_NAMESPACE_ID::MapKey> {
case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_FLOAT:
case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_ENUM:
case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_MESSAGE:
- GOOGLE_LOG(FATAL) << "Unsupported";
+ Y_ABSL_LOG(FATAL) << "Unsupported";
break;
case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_STRING:
return hash<TProtoStringType>()(map_key.GetStringValue());
@@ -309,7 +316,7 @@ struct hash<::PROTOBUF_NAMESPACE_ID::MapKey> {
return hash<bool>()(map_key.GetBoolValue());
}
}
- GOOGLE_LOG(FATAL) << "Can't get here.";
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
return 0;
}
bool operator()(const ::PROTOBUF_NAMESPACE_ID::MapKey& map_key1,
@@ -343,14 +350,16 @@ class PROTOBUF_EXPORT MapFieldBase {
constexpr MapFieldBase(ConstantInitialized)
: arena_(nullptr),
repeated_field_(nullptr),
- mutex_(GOOGLE_PROTOBUF_LINKER_INITIALIZED),
+ mutex_(y_absl::kConstInit),
state_(STATE_MODIFIED_MAP) {}
explicit MapFieldBase(Arena* arena)
: arena_(arena), repeated_field_(nullptr), state_(STATE_MODIFIED_MAP) {}
+ MapFieldBase(const MapFieldBase&) = delete;
+ MapFieldBase& operator=(const MapFieldBase&) = delete;
protected:
~MapFieldBase() { // "protected" stops users from deleting a `MapFieldBase *`
- GOOGLE_DCHECK(repeated_field_ == nullptr);
+ Y_ABSL_DCHECK(repeated_field_ == nullptr);
}
void Destruct();
@@ -426,7 +435,7 @@ class PROTOBUF_EXPORT MapFieldBase {
// MapFieldBase-derived object, and there is no synchronization going
// on between them, tsan will alert.
#if defined(__SANITIZE_THREAD__) || defined(THREAD_SANITIZER)
- void ConstAccess() const { GOOGLE_CHECK_EQ(seq1_, seq2_); }
+ void ConstAccess() const { Y_ABSL_CHECK_EQ(seq1_, seq2_); }
void MutableAccess() {
if (seq1_ & 1) {
seq2_ = ++seq1_;
@@ -450,9 +459,8 @@ class PROTOBUF_EXPORT MapFieldBase {
Arena* arena_;
mutable RepeatedPtrField<Message>* repeated_field_;
- mutable internal::WrappedMutex
- mutex_; // The thread to synchronize map and repeated field
- // needs to get lock first;
+ mutable y_absl::Mutex mutex_; // The thread to synchronize map and repeated
+ // field needs to get lock first;
mutable std::atomic<State> state_;
private:
@@ -485,8 +493,6 @@ class PROTOBUF_EXPORT MapFieldBase {
// Swaps state_ with another MapFieldBase
void SwapState(MapFieldBase* other);
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapFieldBase);
};
// This class provides common Map Reflection implementations for generated
@@ -495,6 +501,8 @@ template <typename Key, typename T>
class TypeDefinedMapFieldBase : public MapFieldBase {
public:
TypeDefinedMapFieldBase() {}
+ TypeDefinedMapFieldBase(const TypeDefinedMapFieldBase&) = delete;
+ TypeDefinedMapFieldBase& operator=(const TypeDefinedMapFieldBase&) = delete;
// This constructor is for constant initialized global instances.
// It uses a linker initialized mutex, so it is not compatible with regular
@@ -530,7 +538,6 @@ class TypeDefinedMapFieldBase : public MapFieldBase {
void IncreaseIterator(MapIterator* map_iter) const override;
virtual void SetMapIteratorValue(MapIterator* map_iter) const = 0;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeDefinedMapFieldBase);
};
// This class provides access to map field using generated api. It is used for
@@ -563,6 +570,8 @@ class MapField : public TypeDefinedMapFieldBase<Key, T> {
typedef Map<Key, T> MapType;
MapField() : impl_() {}
+ MapField(const MapField&) = delete;
+ MapField& operator=(const MapField&) = delete;
virtual ~MapField() {} // Destruct() must already have been called!
void Destruct() {
impl_.Destruct();
@@ -636,7 +645,6 @@ class MapField : public TypeDefinedMapFieldBase<Key, T> {
friend class ::PROTOBUF_NAMESPACE_ID::Arena;
friend class MapFieldStateTest; // For testing, it needs raw access to impl_
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapField);
};
template <typename Derived, typename Key, typename T,
@@ -665,6 +673,8 @@ class PROTOBUF_EXPORT DynamicMapField
public:
explicit DynamicMapField(const Message* default_entry);
DynamicMapField(const Message* default_entry, Arena* arena);
+ DynamicMapField(const DynamicMapField&) = delete;
+ DynamicMapField& operator=(const DynamicMapField&) = delete;
virtual ~DynamicMapField();
// Implement MapFieldBase
@@ -695,7 +705,6 @@ class PROTOBUF_EXPORT DynamicMapField
void SyncMapWithRepeatedFieldNoLock() const override;
size_t SpaceUsedExcludingSelfNoLock() const override;
void SetMapIteratorValue(MapIterator* map_iter) const override;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMapField);
};
} // namespace internal
@@ -766,7 +775,7 @@ class PROTOBUF_EXPORT MapValueConstRef {
FieldDescriptor::CppType type() const {
if (type_ == FieldDescriptor::CppType() || data_ == nullptr) {
- GOOGLE_LOG(FATAL)
+ Y_ABSL_LOG(FATAL)
<< "Protocol Buffer map usage error:\n"
<< "MapValueConstRef::type MapValueConstRef is not initialized.";
}
@@ -935,6 +944,13 @@ class PROTOBUF_EXPORT MapIterator {
MapValueRef value_;
};
+namespace internal {
+template <>
+struct is_internal_map_value_type<class MapValueConstRef> : std::true_type {};
+template <>
+struct is_internal_map_value_type<class MapValueRef> : std::true_type {};
+} // namespace internal
+
} // namespace protobuf
} // namespace google
@@ -942,6 +958,6 @@ class PROTOBUF_EXPORT MapIterator {
#pragma warning(pop) // restore warning C4265
#endif // _MSC_VER
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_MAP_FIELD_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/map_field_inl.h b/contrib/libs/protobuf/src/google/protobuf/map_field_inl.h
index 4d4abd2224d..908374a6aeb 100644
--- a/contrib/libs/protobuf/src/google/protobuf/map_field_inl.h
+++ b/contrib/libs/protobuf/src/google/protobuf/map_field_inl.h
@@ -33,10 +33,14 @@
#include <memory>
-#include <google/protobuf/stubs/casts.h>
-#include <google/protobuf/map.h>
-#include <google/protobuf/map_field.h>
-#include <google/protobuf/map_type_handler.h>
+#include "y_absl/base/casts.h"
+#include "google/protobuf/map.h"
+#include "google/protobuf/map_field.h"
+#include "google/protobuf/map_type_handler.h"
+#include "google/protobuf/port.h"
+
+// must be last
+#include "google/protobuf/port_def.inc"
#ifdef SWIG
#error "You cannot SWIG proto headers"
@@ -138,7 +142,7 @@ template <typename Key, typename T>
void TypeDefinedMapFieldBase<Key, T>::InitializeIterator(
MapIterator* map_iter) const {
map_iter->iter_ = new typename Map<Key, T>::const_iterator;
- GOOGLE_CHECK(map_iter->iter_ != nullptr);
+ Y_ABSL_CHECK(map_iter->iter_ != nullptr);
}
template <typename Key, typename T>
@@ -278,7 +282,7 @@ template <typename Derived, typename Key, typename T,
void MapField<Derived, Key, T, kKeyFieldType, kValueFieldType>::Swap(
MapFieldBase* other) {
MapFieldBase::Swap(other);
- MapField* other_field = down_cast<MapField*>(other);
+ MapField* other_field = DownCast<MapField*>(other);
impl_.Swap(&other_field->impl_);
}
@@ -287,7 +291,7 @@ template <typename Derived, typename Key, typename T,
WireFormatLite::FieldType kValueFieldType>
void MapField<Derived, Key, T, kKeyFieldType,
kValueFieldType>::UnsafeShallowSwap(MapFieldBase* other) {
- InternalSwap(down_cast<MapField*>(other));
+ InternalSwap(DownCast<MapField*>(other));
}
template <typename Derived, typename Key, typename T,
@@ -325,7 +329,7 @@ void MapField<Derived, Key, T, kKeyFieldType,
for (typename Map<Key, T>::const_iterator it = map.begin(); it != map.end();
++it) {
EntryType* new_entry =
- down_cast<EntryType*>(default_entry->New(this->MapFieldBase::arena_));
+ DownCast<EntryType*>(default_entry->New(this->MapFieldBase::arena_));
repeated_field->AddAllocated(new_entry);
(*new_entry->mutable_key()) = it->first;
(*new_entry->mutable_value()) = it->second;
@@ -341,7 +345,7 @@ void MapField<Derived, Key, T, kKeyFieldType,
RepeatedPtrField<EntryType>* repeated_field =
reinterpret_cast<RepeatedPtrField<EntryType>*>(
this->MapFieldBase::repeated_field_);
- GOOGLE_CHECK(this->MapFieldBase::repeated_field_ != nullptr);
+ Y_ABSL_CHECK(this->MapFieldBase::repeated_field_ != nullptr);
map->clear();
for (typename RepeatedPtrField<EntryType>::iterator it =
repeated_field->begin();
@@ -372,4 +376,6 @@ size_t MapField<Derived, Key, T, kKeyFieldType,
} // namespace protobuf
} // namespace google
+#include "google/protobuf/port_undef.inc"
+
#endif // GOOGLE_PROTOBUF_MAP_FIELD_INL_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 6aa08030f29..654196ee1cc 100644
--- a/contrib/libs/protobuf/src/google/protobuf/map_field_lite.h
+++ b/contrib/libs/protobuf/src/google/protobuf/map_field_lite.h
@@ -33,15 +33,15 @@
#include <type_traits>
-#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/parse_context.h>
-#include <google/protobuf/wire_format_lite.h>
+#include "google/protobuf/port.h"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/map.h"
+#include "google/protobuf/map_entry_lite.h"
+#include "google/protobuf/parse_context.h"
+#include "google/protobuf/wire_format_lite.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
#ifdef SWIG
#error "You cannot SWIG proto headers"
@@ -83,7 +83,7 @@ class MapFieldLite {
// 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);
+ map_.InternalSwap(&swapped_map);
}
~MapFieldLite() {
if (map_.arena() == nullptr && !map_.empty()) {
@@ -99,13 +99,10 @@ class MapFieldLite {
int size() const { return static_cast<int>(map_.size()); }
void Clear() { return map_.clear(); }
void MergeFrom(const MapFieldLite& other) {
- for (typename Map<Key, T>::const_iterator it = other.map_.begin();
- it != other.map_.end(); ++it) {
- map_[it->first] = it->second;
- }
+ internal::MapMergeFrom(map_, other.map_);
}
void Swap(MapFieldLite* other) { map_.swap(other->map_); }
- void InternalSwap(MapFieldLite* other) { map_.InternalSwap(other->map_); }
+ void InternalSwap(MapFieldLite* other) { map_.InternalSwap(&other->map_); }
// Used in the implementation of parsing. Caller should take the ownership iff
// arena_ is nullptr.
@@ -196,7 +193,7 @@ struct MapEntryToMapField<
#ifndef NDEBUG
inline PROTOBUF_NOINLINE void MapFieldLiteNotDestructed(void* map_field_lite) {
bool proper_destruct = false;
- GOOGLE_CHECK(proper_destruct) << map_field_lite;
+ Y_ABSL_CHECK(proper_destruct) << map_field_lite;
}
#endif
@@ -204,6 +201,6 @@ inline PROTOBUF_NOINLINE void MapFieldLiteNotDestructed(void* map_field_lite) {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_MAP_FIELD_LITE_H__
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 3cc189416bb..282afbf2ee5 100644
--- a/contrib/libs/protobuf/src/google/protobuf/map_type_handler.h
+++ b/contrib/libs/protobuf/src/google/protobuf/map_type_handler.h
@@ -31,11 +31,11 @@
#ifndef GOOGLE_PROTOBUF_MAP_TYPE_HANDLER_H__
#define GOOGLE_PROTOBUF_MAP_TYPE_HANDLER_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>
+#include "google/protobuf/arena.h"
+#include "google/protobuf/arenastring.h"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/parse_context.h"
+#include "google/protobuf/wire_format_lite.h"
#ifdef SWIG
#error "You cannot SWIG proto headers"
@@ -434,7 +434,7 @@ inline const char* ReadENUM(const char* ptr, E* value) {
return ptr;
}
inline const char* ReadBOOL(const char* ptr, bool* value) {
- *value = static_cast<bool>(ReadVarint32(&ptr));
+ *value = static_cast<bool>(ReadVarint64(&ptr));
return ptr;
}
diff --git a/contrib/libs/protobuf/src/google/protobuf/message.cc b/contrib/libs/protobuf/src/google/protobuf/message.cc
index faaa0b06262..ea8905ab65c 100644
--- a/contrib/libs/protobuf/src/google/protobuf/message.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/message.cc
@@ -32,40 +32,41 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/message.h>
+#include "google/protobuf/message.h"
#include <iostream>
#include <stack>
-#include <unordered_map>
-
-#include <google/protobuf/stubs/casts.h>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.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/map_util.h>
-#include <google/protobuf/stubs/stl_util.h>
-#include <google/protobuf/stubs/hash.h>
+
+#include "y_absl/base/casts.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/str_join.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/synchronization/mutex.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/generated_message_tctable_impl.h"
+#include "google/protobuf/generated_message_util.h"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/io/zero_copy_stream_impl.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"
+
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
-
namespace internal {
// TODO(gerbens) make this factorized better. This should not have to hop
@@ -75,6 +76,7 @@ void RegisterFileLevelMetadata(const DescriptorTable* descriptor_table);
} // namespace internal
+using internal::DownCast;
using internal::ReflectionOps;
using internal::WireFormat;
using internal::WireFormatLite;
@@ -92,7 +94,7 @@ void Message::MergeFrom(const Message& from) {
}
void Message::CheckTypeAndMergeFrom(const MessageLite& other) {
- MergeFrom(*down_cast<const Message*>(&other));
+ MergeFrom(*DownCast<const Message*>(&other));
}
void Message::CopyFrom(const Message& from) {
@@ -104,7 +106,7 @@ void Message::CopyFrom(const Message& from) {
if (class_to == nullptr || class_to != class_from) {
const Descriptor* descriptor = GetDescriptor();
- GOOGLE_CHECK_EQ(from.GetDescriptor(), descriptor)
+ Y_ABSL_CHECK_EQ(from.GetDescriptor(), descriptor)
<< ": Tried to copy from a message with a different type. "
"to: "
<< descriptor->full_name()
@@ -119,22 +121,14 @@ void Message::CopyFrom(const Message& from) {
}
void Message::CopyWithSourceCheck(Message& to, const Message& from) {
-#ifndef NDEBUG
- FailIfCopyFromDescendant(to, from);
-#endif
+ // Fail if "from" is a descendant of "to" as such copy is not allowed.
+ Y_ABSL_DCHECK(!internal::IsDescendant(to, from))
+ << "Source of CopyFrom cannot be a descendant of the target.";
+
to.Clear();
to.GetClassData()->merge_to_from(to, from);
}
-void Message::FailIfCopyFromDescendant(Message& to, const Message& from) {
- auto* arena = to.GetArenaForAllocation();
- bool same_message_owned_arena = to.GetOwningArena() == nullptr &&
- arena != nullptr &&
- arena == from.GetOwningArena();
- GOOGLE_CHECK(!same_message_owned_arena && !internal::IsDescendant(to, from))
- << "Source of CopyFrom cannot be a descendant of the target.";
-}
-
TProtoStringType Message::GetTypeName() const {
return GetDescriptor()->full_name();
}
@@ -152,13 +146,13 @@ void Message::FindInitializationErrors(std::vector<TProtoStringType>* errors) co
TProtoStringType Message::InitializationErrorString() const {
std::vector<TProtoStringType> errors;
FindInitializationErrors(&errors);
- return Join(errors, ", ");
+ return y_absl::StrJoin(errors, ", ");
}
void Message::CheckInitialized() const {
- GOOGLE_CHECK(IsInitialized()) << "Message of type \"" << GetDescriptor()->full_name()
- << "\" is missing required fields: "
- << InitializationErrorString();
+ Y_ABSL_CHECK(IsInitialized())
+ << "Message of type \"" << GetDescriptor()->full_name()
+ << "\" is missing required fields: " << InitializationErrorString();
}
void Message::DiscardUnknownFields() {
@@ -167,7 +161,15 @@ void Message::DiscardUnknownFields() {
const char* Message::_InternalParse(const char* ptr,
internal::ParseContext* ctx) {
+#if defined(PROTOBUF_USE_TABLE_PARSER_ON_REFLECTION)
+ auto meta = GetMetadata();
+ ptr = internal::TcParser::ParseLoop(this, ptr, ctx,
+ meta.reflection->GetTcParseTable());
+
+ return ptr;
+#else
return WireFormat::_InternalParse(this, ptr, ctx);
+#endif
}
uint8_t* Message::_InternalSerialize(uint8_t* target,
@@ -228,9 +230,9 @@ size_t Message::ByteSizeLong() const {
}
void Message::SetCachedSize(int /* size */) const {
- GOOGLE_LOG(FATAL) << "Message class \"" << GetDescriptor()->full_name()
- << "\" implements neither SetCachedSize() nor ByteSize(). "
- "Must implement one or the other.";
+ Y_ABSL_LOG(FATAL) << "Message class \"" << GetDescriptor()->full_name()
+ << "\" implements neither SetCachedSize() nor ByteSize(). "
+ "Must implement one or the other.";
}
size_t Message::ComputeUnknownFieldsSize(
@@ -259,6 +261,18 @@ arc_ui64 Message::GetInvariantPerBuild(arc_ui64 salt) {
return salt;
}
+namespace internal {
+void* CreateSplitMessageGeneric(Arena* arena, const void* default_split,
+ size_t size, const void* message,
+ const void* default_message) {
+ Y_ABSL_DCHECK_NE(message, default_message);
+ void* split =
+ (arena == nullptr) ? ::operator new(size) : arena->AllocateAligned(size);
+ memcpy(split, default_split, size);
+ return split;
+}
+} // namespace internal
+
// =============================================================================
// MessageFactory
@@ -266,11 +280,6 @@ MessageFactory::~MessageFactory() {}
namespace {
-
-#define HASH_MAP std::unordered_map
-#define STR_HASH_FXN hash<::google::protobuf::StringPiece>
-
-
class GeneratedMessageFactory final : public MessageFactory {
public:
static GeneratedMessageFactory* singleton();
@@ -282,14 +291,58 @@ class GeneratedMessageFactory final : public MessageFactory {
const Message* GetPrototype(const Descriptor* type) override;
private:
+ const Message* FindInTypeMap(const Descriptor* type)
+ Y_ABSL_SHARED_LOCKS_REQUIRED(mutex_)
+ {
+ auto it = type_map_.find(type);
+ if (it == type_map_.end()) return nullptr;
+ return it->second;
+ }
+
+ const google::protobuf::internal::DescriptorTable* FindInFileMap(
+ y_absl::string_view name) {
+ auto it = files_.find(name);
+ if (it == files_.end()) return nullptr;
+ return *it;
+ }
+
+ struct DescriptorByNameHash {
+ using is_transparent = void;
+ size_t operator()(const google::protobuf::internal::DescriptorTable* t) const {
+ return y_absl::HashOf(y_absl::string_view{t->filename});
+ }
+
+ size_t operator()(y_absl::string_view name) const {
+ return y_absl::HashOf(name);
+ }
+ };
+ struct DescriptorByNameEq {
+ using is_transparent = void;
+ bool operator()(const google::protobuf::internal::DescriptorTable* lhs,
+ const google::protobuf::internal::DescriptorTable* rhs) const {
+ return lhs == rhs || (*this)(lhs->filename, rhs->filename);
+ }
+ bool operator()(y_absl::string_view lhs,
+ const google::protobuf::internal::DescriptorTable* rhs) const {
+ return (*this)(lhs, rhs->filename);
+ }
+ bool operator()(const google::protobuf::internal::DescriptorTable* lhs,
+ y_absl::string_view rhs) const {
+ return (*this)(lhs->filename, rhs);
+ }
+ bool operator()(y_absl::string_view lhs, y_absl::string_view rhs) const {
+ return lhs == rhs;
+ }
+ };
+
// Only written at static init time, so does not require locking.
- HASH_MAP<StringPiece, const google::protobuf::internal::DescriptorTable*,
- STR_HASH_FXN>
- file_map_;
+ y_absl::flat_hash_set<const google::protobuf::internal::DescriptorTable*,
+ DescriptorByNameHash, DescriptorByNameEq>
+ files_;
- internal::WrappedMutex mutex_;
- // Initialized lazily, so requires locking.
- std::unordered_map<const Descriptor*, const Message*> type_map_;
+ y_absl::Mutex mutex_;
+ y_absl::flat_hash_map<const Descriptor*, const Message*> type_map_
+ Y_ABSL_GUARDED_BY(mutex_);
};
GeneratedMessageFactory* GeneratedMessageFactory::singleton() {
@@ -300,14 +353,14 @@ GeneratedMessageFactory* GeneratedMessageFactory::singleton() {
void GeneratedMessageFactory::RegisterFile(
const google::protobuf::internal::DescriptorTable* table) {
- if (!InsertIfNotPresent(&file_map_, table->filename, table)) {
- GOOGLE_LOG(FATAL) << "File is already registered: " << table->filename;
+ if (!files_.insert(table).second) {
+ Y_ABSL_LOG(FATAL) << "File is already registered: " << table->filename;
}
}
void GeneratedMessageFactory::RegisterType(const Descriptor* descriptor,
const Message* prototype) {
- GOOGLE_DCHECK_EQ(descriptor->file()->pool(), DescriptorPool::generated_pool())
+ Y_ABSL_DCHECK_EQ(descriptor->file()->pool(), DescriptorPool::generated_pool())
<< "Tried to register a non-generated type with the generated "
"type registry.";
@@ -315,16 +368,17 @@ void GeneratedMessageFactory::RegisterType(const Descriptor* descriptor,
// function during GetPrototype(), in which case we already have locked
// the mutex.
mutex_.AssertHeld();
- if (!InsertIfNotPresent(&type_map_, descriptor, prototype)) {
- GOOGLE_LOG(DFATAL) << "Type is already registered: " << descriptor->full_name();
+ if (!type_map_.try_emplace(descriptor, prototype).second) {
+ Y_ABSL_DLOG(FATAL) << "Type is already registered: "
+ << descriptor->full_name();
}
}
const Message* GeneratedMessageFactory::GetPrototype(const Descriptor* type) {
{
- ReaderMutexLock lock(&mutex_);
- const Message* result = FindPtrOrNull(type_map_, type);
+ y_absl::ReaderMutexLock lock(&mutex_);
+ const Message* result = FindInTypeMap(type);
if (result != nullptr) return result;
}
@@ -334,28 +388,28 @@ const Message* GeneratedMessageFactory::GetPrototype(const Descriptor* type) {
// Apparently the file hasn't been registered yet. Let's do that now.
const internal::DescriptorTable* registration_data =
- FindPtrOrNull(file_map_, type->file()->name().c_str());
+ FindInFileMap(type->file()->name());
if (registration_data == nullptr) {
- GOOGLE_LOG(DFATAL) << "File appears to be in generated pool but wasn't "
- "registered: "
- << type->file()->name();
+ Y_ABSL_DLOG(FATAL) << "File appears to be in generated pool but wasn't "
+ "registered: "
+ << type->file()->name();
return nullptr;
}
- WriterMutexLock lock(&mutex_);
+ y_absl::WriterMutexLock lock(&mutex_);
// Check if another thread preempted us.
- const Message* result = FindPtrOrNull(type_map_, type);
+ const Message* result = FindInTypeMap(type);
if (result == nullptr) {
// Nope. OK, register everything.
internal::RegisterFileLevelMetadata(registration_data);
// Should be here now.
- result = FindPtrOrNull(type_map_, type);
+ result = FindInTypeMap(type);
}
if (result == nullptr) {
- GOOGLE_LOG(DFATAL) << "Type appears to be in generated pool but wasn't "
- << "registered: " << type->full_name();
+ Y_ABSL_DLOG(FATAL) << "Type appears to be in generated pool but wasn't "
+ << "registered: " << type->full_name();
}
return result;
@@ -388,7 +442,7 @@ T* GetSingleton() {
const internal::RepeatedFieldAccessor* Reflection::RepeatedFieldAccessor(
const FieldDescriptor* field) const {
- GOOGLE_CHECK(field->is_repeated());
+ Y_ABSL_CHECK(field->is_repeated());
switch (field->cpp_type()) {
#define HANDLE_PRIMITIVE_TYPE(TYPE, type) \
case FieldDescriptor::CPPTYPE_##TYPE: \
@@ -416,7 +470,7 @@ const internal::RepeatedFieldAccessor* Reflection::RepeatedFieldAccessor(
return GetSingleton<internal::RepeatedPtrFieldMessageAccessor>();
}
}
- GOOGLE_LOG(FATAL) << "Should not reach here.";
+ Y_ABSL_LOG(FATAL) << "Should not reach here.";
return nullptr;
}
@@ -442,9 +496,18 @@ PROTOBUF_NOINLINE
GenericTypeHandler<Message>::GetOwningArena(Message* value) {
return value->GetOwningArena();
}
+
+template void InternalMetadata::DoClear<UnknownFieldSet>();
+template void InternalMetadata::DoMergeFrom<UnknownFieldSet>(
+ const UnknownFieldSet& other);
+template void InternalMetadata::DoSwap<UnknownFieldSet>(UnknownFieldSet* other);
+template Arena* InternalMetadata::DeleteOutOfLineHelper<UnknownFieldSet>();
+template UnknownFieldSet*
+InternalMetadata::mutable_unknown_fields_slow<UnknownFieldSet>();
+
} // namespace internal
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protobuf/src/google/protobuf/message.h b/contrib/libs/protobuf/src/google/protobuf/message.h
index 8dacc5eb58a..b49218704b5 100644
--- a/contrib/libs/protobuf/src/google/protobuf/message.h
+++ b/contrib/libs/protobuf/src/google/protobuf/message.h
@@ -110,27 +110,31 @@
#ifndef GOOGLE_PROTOBUF_MESSAGE_H__
#define GOOGLE_PROTOBUF_MESSAGE_H__
-
#include <iosfwd>
#include <string>
#include <type_traits>
#include <vector>
-#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/stubs/common.h"
+#include "google/protobuf/arena.h"
+#include "google/protobuf/port.h"
+#include "y_absl/base/call_once.h"
+#include "y_absl/base/casts.h"
+#include "y_absl/functional/function_ref.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/generated_message_tctable_decl.h"
+#include "google/protobuf/generated_message_util.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/map.h" // TODO(b/211442718): cleanup
+#include "google/protobuf/message_lite.h"
+#include "google/protobuf/port.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
#ifdef SWIG
#error "You cannot SWIG proto headers"
@@ -155,10 +159,12 @@ class MapIterator;
class MapReflectionTester;
namespace internal {
+struct FuzzPeer;
struct DescriptorTable;
class MapFieldBase;
class SwapFieldHelper;
class CachedSize;
+struct TailCallTableInfo;
} // namespace internal
class UnknownFieldSet; // unknown_field_set.h
namespace io {
@@ -177,7 +183,10 @@ class CelMapReflectionFriend; // field_backed_map_impl.cc
namespace internal {
class MapFieldPrinterHelper; // text_format.cc
-}
+void PerformAbslStringify(
+ const Message& message,
+ y_absl::FunctionRef<void(y_absl::string_view)> append); // text_format.cc
+} // namespace internal
namespace util {
class MessageDifferencer;
}
@@ -205,12 +214,12 @@ struct Metadata {
namespace internal {
template <class To>
-inline To* GetPointerAtOffset(Message* message, arc_ui32 offset) {
+inline To* GetPointerAtOffset(void* message, arc_ui32 offset) {
return reinterpret_cast<To*>(reinterpret_cast<char*>(message) + offset);
}
template <class To>
-const To* GetConstPointerAtOffset(const Message* message, arc_ui32 offset) {
+const To* GetConstPointerAtOffset(const void* message, arc_ui32 offset) {
return reinterpret_cast<const To*>(reinterpret_cast<const char*>(message) +
offset);
}
@@ -242,6 +251,8 @@ PROTOBUF_EXPORT bool IsDescendant(Message& root, const Message& message);
class PROTOBUF_EXPORT Message : public MessageLite {
public:
constexpr Message() {}
+ Message(const Message&) = delete;
+ Message& operator=(const Message&) = delete;
// Basic Operations ------------------------------------------------
@@ -266,8 +277,8 @@ class PROTOBUF_EXPORT Message : public MessageLite {
// exact same class).
virtual void MergeFrom(const Message& from);
- // Verifies that IsInitialized() returns true. GOOGLE_CHECK-fails otherwise, with
- // a nice error message.
+ // Verifies that IsInitialized() returns true. Y_ABSL_CHECK-fails otherwise,
+ // with a nice error message.
void CheckInitialized() const;
// Slowly build a list of all required fields that are not set.
@@ -300,6 +311,10 @@ class PROTOBUF_EXPORT Message : public MessageLite {
// using reflection (rather than the generated code implementation for
// ByteSize()). Like ByteSize(), its CPU time is linear in the number of
// fields defined for the proto.
+ //
+ // Note: The precise value of this method should never be depended on, and can
+ // change substantially due to internal details. In debug builds, this will
+ // include a random fuzz factor to prevent these dependencies.
virtual size_t SpaceUsedLong() const;
PROTOBUF_DEPRECATED_MSG("Please use SpaceUsedLong() instead")
@@ -320,6 +335,15 @@ class PROTOBUF_EXPORT Message : public MessageLite {
// Convenience function useful in GDB. Prints DebugString() to stdout.
void PrintDebugString() const;
+ // Implementation of the `AbslStringify` interface. This adds something
+ // similar to either `ShortDebugString()` or `DebugString()` to the sink.
+ // Do not rely on exact format.
+ template <typename Sink>
+ friend void AbslStringify(Sink& sink, const google::protobuf::Message& message) {
+ internal::PerformAbslStringify(
+ message, [&](y_absl::string_view content) { sink.Append(content); });
+ }
+
// Reflection-based methods ----------------------------------------
// These methods are pure-virtual in MessageLite, but Message provides
// reflection-based default implementations.
@@ -410,11 +434,7 @@ class PROTOBUF_EXPORT Message : public MessageLite {
// type, and thus uses GetClassData().
static void CopyWithSourceCheck(Message& to, const Message& from);
- // Fail if "from" is a descendant of "to" as such copy is not allowed.
- static void FailIfCopyFromDescendant(Message& to, const Message& from);
-
- inline explicit Message(Arena* arena, bool is_message_owned = false)
- : MessageLite(arena, is_message_owned) {}
+ inline explicit Message(Arena* arena) : MessageLite(arena) {}
size_t ComputeUnknownFieldsSize(size_t total_size,
internal::CachedSize* cached_size) const;
size_t MaybeComputeUnknownFieldsSize(size_t total_size,
@@ -423,12 +443,14 @@ class PROTOBUF_EXPORT Message : public MessageLite {
protected:
static arc_ui64 GetInvariantPerBuild(arc_ui64 salt);
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Message);
};
namespace internal {
+// Creates and returns an allocation for a split message.
+void* CreateSplitMessageGeneric(Arena* arena, const void* default_split,
+ size_t size, const void* message,
+ const void* default_message);
+
// Forward-declare interfaces used to implement RepeatedFieldRef.
// These are protobuf internals that users shouldn't care about.
class RepeatedFieldAccessor;
@@ -482,6 +504,10 @@ class MutableRepeatedFieldRef;
// memory leaks. So, instead we ended up with this flat interface.
class PROTOBUF_EXPORT Reflection final {
public:
+ Reflection(const Reflection&) = delete;
+ Reflection& operator=(const Reflection&) = delete;
+ ~Reflection();
+
// Get the UnknownFieldSet for the message. This contains fields which
// were seen when the Message was parsed but were not recognized according
// to the Message's definition.
@@ -499,6 +525,11 @@ class PROTOBUF_EXPORT Reflection final {
return internal::ToIntSize(SpaceUsedLong(message));
}
+ // Returns true if the given message is a default message instance.
+ bool IsDefaultInstance(const Message& message) const {
+ return schema_.IsDefaultInstance(message);
+ }
+
// Check if the given non-repeated field is set.
bool HasField(const Message& message, const FieldDescriptor* field) const;
@@ -796,6 +827,7 @@ class PROTOBUF_EXPORT Reflection final {
TProtoStringType value) const;
void AddEnum(Message* message, const FieldDescriptor* field,
const EnumValueDescriptor* value) const;
+
// Add an integer value to a repeated enum field rather than
// EnumValueDescriptor. For proto3 this is just setting the enum field to the
// value specified, for proto2 it's more complicated. If value is a known enum
@@ -915,8 +947,7 @@ class PROTOBUF_EXPORT Reflection final {
// Try to find an extension of this message type by fully-qualified field
// name. Returns nullptr if no extension is known for this name or number.
- const FieldDescriptor* FindKnownExtensionByName(
- const TProtoStringType& name) const;
+ const FieldDescriptor* FindKnownExtensionByName(y_absl::string_view name) const;
// Try to find an extension of this message type by field number.
// Returns nullptr if no extension is known for this name or number.
@@ -929,7 +960,7 @@ class PROTOBUF_EXPORT Reflection final {
// take arbitrary integer values, and the legacy GetEnum() getter will
// dynamically create an EnumValueDescriptor for any integer value without
// one. If |false|, setting an unknown enum value via the integer-based
- // setters results in undefined behavior (in practice, GOOGLE_DCHECK-fails).
+ // setters results in undefined behavior (in practice, Y_ABSL_DCHECK-fails).
//
// Generic code that uses reflection to handle messages with enum fields
// should check this flag before using the integer-based setter, and either
@@ -978,6 +1009,7 @@ class PROTOBUF_EXPORT Reflection final {
template <typename T>
RepeatedPtrField<T>* MutableRepeatedPtrFieldInternal(
Message* message, const FieldDescriptor* field) const;
+
// Obtain a pointer to a Repeated Field Structure and do some type checking:
// on field->cpp_type(),
// on field->field_option().ctype() (if ctype >= 0)
@@ -1015,22 +1047,6 @@ class PROTOBUF_EXPORT Reflection final {
const internal::RepeatedFieldAccessor* RepeatedFieldAccessor(
const FieldDescriptor* field) const;
- // Lists all fields of the message which are currently set, except for unknown
- // fields and stripped fields. See ListFields for details.
- void ListFieldsOmitStripped(
- const Message& message,
- std::vector<const FieldDescriptor*>* output) const;
-
- bool IsMessageStripped(const Descriptor* descriptor) const {
- return schema_.IsMessageStripped(descriptor);
- }
-
- friend class TextFormat;
-
- void ListFieldsMayFailOnStripped(
- const Message& message, bool should_fail,
- std::vector<const FieldDescriptor*>* output) const;
-
// Returns true if the message field is backed by a LazyField.
//
// A message field may be backed by a LazyField without the user annotation
@@ -1052,6 +1068,11 @@ class PROTOBUF_EXPORT Reflection final {
bool IsLazilyVerifiedLazyField(const FieldDescriptor* field) const;
bool IsEagerlyVerifiedLazyField(const FieldDescriptor* field) const;
+ bool IsSplit(const FieldDescriptor* field) const {
+ return schema_.IsSplit(field);
+ }
+
+ friend class FastReflectionBase;
friend class FastReflectionMessageMutator;
friend bool internal::IsDescendant(Message& root, const Message& message);
@@ -1065,10 +1086,34 @@ class PROTOBUF_EXPORT Reflection final {
// contain weak fields, then this field equals descriptor_->field_count().
int last_non_weak_field_index_;
+ // The table-driven parser table.
+ // This table is generated on demand for Message types that did not override
+ // _InternalParse. It uses the reflection information to do so.
+ mutable y_absl::once_flag tcparse_table_once_;
+ using TcParseTableBase = internal::TcParseTableBase;
+ mutable const TcParseTableBase* tcparse_table_ = nullptr;
+
+ const TcParseTableBase* GetTcParseTable() const {
+ y_absl::call_once(tcparse_table_once_,
+ [&] { tcparse_table_ = CreateTcParseTable(); });
+ return tcparse_table_;
+ }
+
+ const TcParseTableBase* CreateTcParseTable() const;
+ const TcParseTableBase* CreateTcParseTableForMessageSet() const;
+ void PopulateTcParseFastEntries(
+ const internal::TailCallTableInfo& table_info,
+ TcParseTableBase::FastFieldEntry* fast_entries) const;
+ void PopulateTcParseEntries(internal::TailCallTableInfo& table_info,
+ TcParseTableBase::FieldEntry* entries) const;
+ void PopulateTcParseFieldAux(const internal::TailCallTableInfo& table_info,
+ TcParseTableBase::FieldAux* field_aux) const;
+
template <typename T, typename Enable>
friend class RepeatedFieldRef;
template <typename T, typename Enable>
friend class MutableRepeatedFieldRef;
+ friend class Message;
friend class ::PROTOBUF_NAMESPACE_ID::MessageLayoutInspector;
friend class ::PROTOBUF_NAMESPACE_ID::AssignDescriptorsHelper;
friend class DynamicMessageFactory;
@@ -1083,6 +1128,7 @@ class PROTOBUF_EXPORT Reflection final {
friend class internal::WireFormat;
friend class internal::ReflectionOps;
friend class internal::SwapFieldHelper;
+ friend struct internal::FuzzPeer;
// Needed for implementing text format for map.
friend class internal::MapFieldPrinterHelper;
@@ -1197,6 +1243,14 @@ class PROTOBUF_EXPORT Reflection final {
inline void SwapInlinedStringDonated(Message* lhs, Message* rhs,
const FieldDescriptor* field) const;
+ // Returns the `_split_` pointer. Requires: IsSplit() == true.
+ inline const void* GetSplitField(const Message* message) const;
+ // Returns the address of the `_split_` pointer. Requires: IsSplit() == true.
+ inline void** MutableSplitField(Message* message) const;
+
+ // Allocate the split instance if needed.
+ void PrepareSplitMessageForWrite(Message* message) const;
+
// Shallow-swap fields listed in fields vector of two messages. It is the
// caller's responsibility to make sure shallow swap is safe.
void UnsafeShallowSwapFields(
@@ -1220,6 +1274,8 @@ class PROTOBUF_EXPORT Reflection final {
void SwapOneofField(Message* lhs, Message* rhs,
const OneofDescriptor* oneof_descriptor) const;
+ void InternalSwap(Message* lhs, Message* rhs) const;
+
inline bool HasOneofField(const Message& message,
const FieldDescriptor* field) const;
inline void SetOneofCase(Message* message,
@@ -1283,14 +1339,17 @@ class PROTOBUF_EXPORT Reflection final {
const Reflection* reflection,
const char* ptr,
internal::ParseContext* ctx);
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Reflection);
};
// Abstract interface for a factory for message objects.
+//
+// The thread safety for this class is implementation dependent, see comments
+// around GetPrototype for details
class PROTOBUF_EXPORT MessageFactory {
public:
inline MessageFactory() {}
+ MessageFactory(const MessageFactory&) = delete;
+ MessageFactory& operator=(const MessageFactory&) = delete;
virtual ~MessageFactory();
// Given a Descriptor, gets or constructs the default (prototype) Message
@@ -1346,9 +1405,6 @@ class PROTOBUF_EXPORT MessageFactory {
static void InternalRegisterGeneratedMessage(const Descriptor* descriptor,
const Message* prototype);
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFactory);
};
#define DECLARE_GET_REPEATED_FIELD(TYPE) \
@@ -1395,7 +1451,7 @@ const T* DynamicCastToGenerated(const Message* from) {
#else
bool ok = from != nullptr &&
T::default_instance().GetReflection() == from->GetReflection();
- return ok ? down_cast<const T*>(from) : nullptr;
+ return ok ? internal::DownCast<const T*>(from) : nullptr;
#endif
}
@@ -1493,7 +1549,7 @@ const Type& Reflection::DefaultRaw(const FieldDescriptor* field) const {
arc_ui32 Reflection::GetOneofCase(
const Message& message, const OneofDescriptor* oneof_descriptor) const {
- GOOGLE_DCHECK(!oneof_descriptor->is_synthetic());
+ Y_ABSL_DCHECK(!oneof_descriptor->is_synthetic());
return internal::GetConstRefAtOffset<arc_ui32>(
message, schema_.GetOneofCaseOffset(oneof_descriptor));
}
@@ -1504,17 +1560,32 @@ bool Reflection::HasOneofField(const Message& message,
static_cast<arc_ui32>(field->number()));
}
+const void* Reflection::GetSplitField(const Message* message) const {
+ Y_ABSL_DCHECK(schema_.IsSplit());
+ return *internal::GetConstPointerAtOffset<void*>(message,
+ schema_.SplitOffset());
+}
+
+void** Reflection::MutableSplitField(Message* message) const {
+ Y_ABSL_DCHECK(schema_.IsSplit());
+ return internal::GetPointerAtOffset<void*>(message, schema_.SplitOffset());
+}
+
template <typename Type>
const Type& Reflection::GetRaw(const Message& message,
const FieldDescriptor* field) const {
- GOOGLE_DCHECK(!schema_.InRealOneof(field) || HasOneofField(message, field))
+ Y_ABSL_DCHECK(!schema_.InRealOneof(field) || HasOneofField(message, field))
<< "Field = " << field->full_name();
+ if (schema_.IsSplit(field)) {
+ return *internal::GetConstPointerAtOffset<Type>(
+ GetSplitField(&message), schema_.GetFieldOffset(field));
+ }
return internal::GetConstRefAtOffset<Type>(message,
schema_.GetFieldOffset(field));
}
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_MESSAGE_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/message_lite.cc b/contrib/libs/protobuf/src/google/protobuf/message_lite.cc
index c0ff5cc201d..52f0f797585 100644
--- a/contrib/libs/protobuf/src/google/protobuf/message_lite.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/message_lite.cc
@@ -33,28 +33,36 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/message_lite.h>
+#include "google/protobuf/message_lite.h"
#include <climits>
+#include <cstddef>
#include <cstdint>
+#include <istream>
+#include <ostream>
#include <string>
+#include <utility>
+
+#include "google/protobuf/arena.h"
+#include "y_absl/base/dynamic_annotations.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/cord.h"
+#include "y_absl/strings/cord_buffer.h"
+#include "y_absl/strings/internal/resize_uninitialized.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/synchronization/mutex.h"
+#include "y_absl/types/optional.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/parse_context.h"
-#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/arena.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/generated_message_util.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/stubs/stl_util.h>
-#include <google/protobuf/stubs/mutex.h>
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -64,8 +72,7 @@ TProtoStringType MessageLite::InitializationErrorString() const {
}
TProtoStringType MessageLite::DebugString() const {
- std::uintptr_t address = reinterpret_cast<std::uintptr_t>(this);
- return StrCat("MessageLite at 0x", strings::Hex(address));
+ return y_absl::StrCat("MessageLite at 0x", y_absl::Hex(this));
}
namespace {
@@ -80,47 +87,34 @@ void ByteSizeConsistencyError(size_t byte_size_before_serialization,
size_t byte_size_after_serialization,
size_t bytes_produced_by_serialization,
const MessageLite& message) {
- GOOGLE_CHECK_EQ(byte_size_before_serialization, byte_size_after_serialization)
+ Y_ABSL_CHECK_EQ(byte_size_before_serialization, byte_size_after_serialization)
<< message.GetTypeName()
<< " was modified concurrently during serialization.";
- GOOGLE_CHECK_EQ(bytes_produced_by_serialization, byte_size_before_serialization)
+ Y_ABSL_CHECK_EQ(bytes_produced_by_serialization, byte_size_before_serialization)
<< "Byte size calculation and serialization were inconsistent. This "
"may indicate a bug in protocol buffers or it may be caused by "
"concurrent modification of "
<< message.GetTypeName() << ".";
- GOOGLE_LOG(FATAL) << "This shouldn't be called if all the sizes are equal.";
+ Y_ABSL_LOG(FATAL) << "This shouldn't be called if all the sizes are equal.";
}
} // anonymous namespace
-TProtoStringType InitializationErrorMessage(const char* action,
+TProtoStringType InitializationErrorMessage(y_absl::string_view action,
const MessageLite& message) {
- // Note: We want to avoid depending on strutil in the lite library, otherwise
- // we'd use:
- //
- // return strings::Substitute(
- // "Can't $0 message of type \"$1\" because it is missing required "
- // "fields: $2",
- // action, message.GetTypeName(),
- // message.InitializationErrorString());
-
- TProtoStringType result;
- result += "Can't ";
- result += action;
- result += " message of type \"";
- result += message.GetTypeName();
- result += "\" because it is missing required fields: ";
- result += message.InitializationErrorString();
- return result;
+ return y_absl::StrCat("Can't ", action, " message of type \"",
+ message.GetTypeName(),
+ "\" because it is missing required fields: ",
+ message.InitializationErrorString());
}
namespace {
-inline StringPiece as_string_view(const void* data, int size) {
- return StringPiece(static_cast<const char*>(data), size);
+inline y_absl::string_view as_string_view(const void* data, int size) {
+ return y_absl::string_view(static_cast<const char*>(data), size);
}
-// Returns true of all required fields are present / have values.
+// Returns true if all required fields are present / have values.
inline bool CheckFieldPresence(const internal::ParseContext& ctx,
const MessageLite& msg,
MessageLite::ParseFlags parse_flags) {
@@ -134,13 +128,13 @@ inline bool CheckFieldPresence(const internal::ParseContext& ctx,
} // namespace
void MessageLite::LogInitializationErrorMessage() const {
- GOOGLE_LOG(ERROR) << InitializationErrorMessage("parse", *this);
+ Y_ABSL_LOG(ERROR) << InitializationErrorMessage("parse", *this);
}
namespace internal {
template <bool aliasing>
-bool MergeFromImpl(StringPiece input, MessageLite* msg,
+bool MergeFromImpl(y_absl::string_view input, MessageLite* msg,
MessageLite::ParseFlags parse_flags) {
const char* ptr;
internal::ParseContext ctx(io::CodedInputStream::GetDefaultRecursionLimit(),
@@ -182,9 +176,9 @@ bool MergeFromImpl(BoundedZCIS input, MessageLite* msg,
return false;
}
-template bool MergeFromImpl<false>(StringPiece input, MessageLite* msg,
+template bool MergeFromImpl<false>(y_absl::string_view input, MessageLite* msg,
MessageLite::ParseFlags parse_flags);
-template bool MergeFromImpl<true>(StringPiece input, MessageLite* msg,
+template bool MergeFromImpl<true>(y_absl::string_view input, MessageLite* msg,
MessageLite::ParseFlags parse_flags);
template bool MergeFromImpl<false>(io::ZeroCopyInputStream* input,
MessageLite* msg,
@@ -201,7 +195,7 @@ template bool MergeFromImpl<true>(BoundedZCIS input, MessageLite* msg,
class ZeroCopyCodedInputStream : public io::ZeroCopyInputStream {
public:
- ZeroCopyCodedInputStream(io::CodedInputStream* cis) : cis_(cis) {}
+ explicit ZeroCopyCodedInputStream(io::CodedInputStream* cis) : cis_(cis) {}
bool Next(const void** data, int* size) final {
if (!cis_->GetDirectBufferPointer(data, size)) return false;
cis_->Skip(*size);
@@ -213,6 +207,16 @@ class ZeroCopyCodedInputStream : public io::ZeroCopyInputStream {
bool aliasing_enabled() { return cis_->aliasing_enabled_; }
+ bool ReadCord(y_absl::Cord* cord, int count) final {
+ // Fast path: tail call into ReadCord reading new value.
+ if (PROTOBUF_PREDICT_TRUE(cord->empty())) {
+ return cis_->ReadCord(cord, count);
+ }
+ y_absl::Cord tmp;
+ bool res = cis_->ReadCord(&tmp, count);
+ cord->Append(std::move(tmp));
+ return res;
+ }
private:
io::CodedInputStream* cis_;
};
@@ -233,7 +237,7 @@ bool MessageLite::MergeFromImpl(io::CodedInputStream* input,
if (PROTOBUF_PREDICT_FALSE(!ptr)) return false;
ctx.BackUp(ptr);
if (!ctx.EndedAtEndOfStream()) {
- GOOGLE_DCHECK_NE(ctx.LastTag(), 1); // We can't end on a pushed limit.
+ Y_ABSL_DCHECK_NE(ctx.LastTag(), 1); // We can't end on a pushed limit.
if (ctx.IsExceedingLimit(ptr)) return false;
input->SetLastTag(ctx.LastTag());
} else {
@@ -309,11 +313,11 @@ bool MessageLite::ParsePartialFromBoundedZeroCopyStream(
return ParseFrom<kParsePartial>(internal::BoundedZCIS{input, size});
}
-bool MessageLite::ParseFromString(ConstStringParam data) {
+bool MessageLite::ParseFromString(y_absl::string_view data) {
return ParseFrom<kParse>(data);
}
-bool MessageLite::ParsePartialFromString(ConstStringParam data) {
+bool MessageLite::ParsePartialFromString(y_absl::string_view data) {
return ParseFrom<kParsePartial>(data);
}
@@ -325,10 +329,74 @@ bool MessageLite::ParsePartialFromArray(const void* data, int size) {
return ParseFrom<kParsePartial>(as_string_view(data, size));
}
-bool MessageLite::MergeFromString(ConstStringParam data) {
+bool MessageLite::MergeFromString(y_absl::string_view data) {
return ParseFrom<kMerge>(data);
}
+#if PROTOBUF_USE_EXCEPTIONS && defined(__cpp_lib_string_view)
+void MessageLite::ParseFromStringOrThrow(std::string_view s) {
+ const bool isOk = ParseFromArray(s.data(), s.size());
+ if (!isOk) {
+ throw FatalException("message_lite.cc", __LINE__, "Failed to parse protobuf message " + GetTypeName());
+ }
+}
+#endif
+
+#if PROTOBUF_USE_EXCEPTIONS
+TProtoStringType NProtoBuf::MessageLite::SerializeAsStringOrThrow() const {
+ TProtoStringType s;
+ if (!IsInitialized()) {
+ //NOTE: SerializeToString (called inside SerializeAsString too) does not perform this check in release build
+ // so SerializeToString in release build return false only if result size is greater than 2gb
+ // but in debug build not properly inited message (without required filds) will lead to an exception
+ // different control flow in debug and build release look like a bug
+ throw FatalException("message_lite.cc", __LINE__, "Some required fileds are not set in message " + GetTypeName());
+ }
+ const bool isOk = SerializeToString(&s);
+ if (!isOk) {
+ throw FatalException("message_lite.cc", __LINE__, "Failed to serialize protobuf message " + GetTypeName());
+ }
+ return s;
+}
+#endif
+
+
+namespace internal {
+
+template <>
+struct SourceWrapper<y_absl::Cord> {
+ explicit SourceWrapper(const y_absl::Cord* c) : cord(c) {}
+ template <bool alias>
+ bool MergeInto(MessageLite* msg, MessageLite::ParseFlags parse_flags) const {
+ y_absl::optional<y_absl::string_view> flat = cord->TryFlat();
+ if (flat && flat->size() <= ParseContext::kMaxCordBytesToCopy) {
+ return MergeFromImpl<alias>(*flat, msg, parse_flags);
+ } else {
+ io::CordInputStream input(cord);
+ return MergeFromImpl<alias>(&input, msg, parse_flags);
+ }
+ }
+
+ const y_absl::Cord* const cord;
+};
+
+} // namespace internal
+
+bool MessageLite::MergeFromCord(const y_absl::Cord& cord) {
+ return ParseFrom<kMerge>(internal::SourceWrapper<y_absl::Cord>(&cord));
+}
+
+bool MessageLite::MergePartialFromCord(const y_absl::Cord& cord) {
+ return ParseFrom<kMergePartial>(internal::SourceWrapper<y_absl::Cord>(&cord));
+}
+
+bool MessageLite::ParseFromCord(const y_absl::Cord& cord) {
+ return ParseFrom<kParse>(internal::SourceWrapper<y_absl::Cord>(&cord));
+}
+
+bool MessageLite::ParsePartialFromCord(const y_absl::Cord& cord) {
+ return ParseFrom<kParsePartial>(internal::SourceWrapper<y_absl::Cord>(&cord));
+}
// ===================================================================
@@ -346,14 +414,14 @@ inline uint8_t* SerializeToArrayImpl(const MessageLite& msg, uint8_t* target,
&ptr);
ptr = msg._InternalSerialize(ptr, &out);
out.Trim(ptr);
- GOOGLE_DCHECK(!out.HadError() && stream.ByteCount() == size);
+ Y_ABSL_DCHECK(!out.HadError() && stream.ByteCount() == size);
return target + size;
} else {
io::EpsCopyOutputStream out(
target, size,
io::CodedOutputStream::IsDefaultSerializationDeterministic());
- auto res = msg._InternalSerialize(target, &out);
- GOOGLE_DCHECK(target + size == res);
+ uint8_t* res = msg._InternalSerialize(target, &out);
+ Y_ABSL_DCHECK(target + size == res);
return res;
}
}
@@ -365,7 +433,8 @@ uint8_t* MessageLite::SerializeWithCachedSizesToArray(uint8_t* target) const {
}
bool MessageLite::SerializeToCodedStream(io::CodedOutputStream* output) const {
- GOOGLE_DCHECK(IsInitialized()) << InitializationErrorMessage("serialize", *this);
+ Y_ABSL_DCHECK(IsInitialized())
+ << InitializationErrorMessage("serialize", *this);
return SerializePartialToCodedStream(output);
}
@@ -373,8 +442,8 @@ bool MessageLite::SerializePartialToCodedStream(
io::CodedOutputStream* output) const {
const size_t size = ByteSizeLong(); // Force size to be cached.
if (size > INT_MAX) {
- GOOGLE_LOG(ERROR) << GetTypeName()
- << " exceeded maximum protobuf size of 2GB: " << size;
+ Y_ABSL_LOG(ERROR) << GetTypeName()
+ << " exceeded maximum protobuf size of 2GB: " << size;
return false;
}
@@ -395,7 +464,8 @@ bool MessageLite::SerializePartialToCodedStream(
bool MessageLite::SerializeToZeroCopyStream(
io::ZeroCopyOutputStream* output) const {
- GOOGLE_DCHECK(IsInitialized()) << InitializationErrorMessage("serialize", *this);
+ Y_ABSL_DCHECK(IsInitialized())
+ << InitializationErrorMessage("serialize", *this);
return SerializePartialToZeroCopyStream(output);
}
@@ -403,8 +473,8 @@ bool MessageLite::SerializePartialToZeroCopyStream(
io::ZeroCopyOutputStream* output) const {
const size_t size = ByteSizeLong(); // Force size to be cached.
if (size > INT_MAX) {
- GOOGLE_LOG(ERROR) << GetTypeName()
- << " exceeded maximum protobuf size of 2GB: " << size;
+ Y_ABSL_LOG(ERROR) << GetTypeName()
+ << " exceeded maximum protobuf size of 2GB: " << size;
return false;
}
@@ -442,7 +512,8 @@ bool MessageLite::SerializePartialToOstream(std::ostream* output) const {
}
bool MessageLite::AppendToString(TProtoStringType* output) const {
- GOOGLE_DCHECK(IsInitialized()) << InitializationErrorMessage("serialize", *this);
+ Y_ABSL_DCHECK(IsInitialized())
+ << InitializationErrorMessage("serialize", *this);
return AppendPartialToString(output);
}
@@ -450,12 +521,13 @@ bool MessageLite::AppendPartialToString(TProtoStringType* output) const {
size_t old_size = output->size();
size_t byte_size = ByteSizeLong();
if (byte_size > INT_MAX) {
- GOOGLE_LOG(ERROR) << GetTypeName()
- << " exceeded maximum protobuf size of 2GB: " << byte_size;
+ Y_ABSL_LOG(ERROR) << GetTypeName()
+ << " exceeded maximum protobuf size of 2GB: " << byte_size;
return false;
}
- STLStringResizeUninitializedAmortized(output, old_size + byte_size);
+ y_absl::strings_internal::STLStringResizeUninitializedAmortized(
+ output, old_size + byte_size);
uint8_t* start =
reinterpret_cast<uint8_t*>(io::mutable_string_data(output) + old_size);
SerializeToArrayImpl(*this, start, byte_size);
@@ -473,15 +545,16 @@ bool MessageLite::SerializePartialToString(TProtoStringType* output) const {
}
bool MessageLite::SerializeToArray(void* data, int size) const {
- GOOGLE_DCHECK(IsInitialized()) << InitializationErrorMessage("serialize", *this);
+ Y_ABSL_DCHECK(IsInitialized())
+ << InitializationErrorMessage("serialize", *this);
return SerializePartialToArray(data, size);
}
bool MessageLite::SerializePartialToArray(void* data, int size) const {
const size_t byte_size = ByteSizeLong();
if (byte_size > INT_MAX) {
- GOOGLE_LOG(ERROR) << GetTypeName()
- << " exceeded maximum protobuf size of 2GB: " << byte_size;
+ Y_ABSL_LOG(ERROR) << GetTypeName()
+ << " exceeded maximum protobuf size of 2GB: " << byte_size;
return false;
}
if (size < static_cast<arc_i64>(byte_size)) return false;
@@ -506,33 +579,78 @@ TProtoStringType MessageLite::SerializePartialAsString() const {
return output;
}
-#if PROTOBUF_USE_EXCEPTIONS && defined(__cpp_lib_string_view)
-void MessageLite::ParseFromStringOrThrow(std::string_view s) {
- const bool isOk = ParseFromArray(s.data(), s.size());
- if (!isOk) {
- throw FatalException("message_lite.cc", __LINE__, "Failed to parse protobuf message " + GetTypeName());
- }
+bool MessageLite::AppendToCord(y_absl::Cord* output) const {
+ Y_ABSL_DCHECK(IsInitialized())
+ << InitializationErrorMessage("serialize", *this);
+ return AppendPartialToCord(output);
}
-#endif
-#if PROTOBUF_USE_EXCEPTIONS
-TProtoStringType NProtoBuf::MessageLite::SerializeAsStringOrThrow() const {
- TProtoStringType s;
- if (!IsInitialized()) {
- //NOTE: SerializeToString (called inside SerializeAsString too) does not perform this check in release build
- // so SerializeToString in release build return false only if result size is greater than 2gb
- // but in debug build not properly inited message (without required filds) will lead to an exception
- // different control flow in debug and build release look like a bug
- throw FatalException("message_lite.cc", __LINE__, "Some required fileds are not set in message " + GetTypeName());
+bool MessageLite::AppendPartialToCord(y_absl::Cord* output) const {
+ // For efficiency, we'd like to pass a size hint to CordOutputStream with
+ // the exact total size expected.
+ const size_t size = ByteSizeLong();
+ const size_t total_size = size + output->size();
+ if (size > INT_MAX) {
+ Y_ABSL_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB.";
+ return false;
}
- const bool isOk = SerializeToString(&s);
- if (!isOk) {
- throw FatalException("message_lite.cc", __LINE__, "Failed to serialize protobuf message " + GetTypeName());
+
+
+ // Allocate a CordBuffer (which may utilize private capacity in 'output').
+ y_absl::CordBuffer buffer = output->GetAppendBuffer(size);
+ y_absl::Span<char> available = buffer.available();
+ auto target = reinterpret_cast<uint8_t*>(available.data());
+ if (available.size() >= size) {
+ // Use EpsCopyOutputStream with full available capacity, as serialization
+ // may in the future use the extra slop bytes if available.
+ io::EpsCopyOutputStream out(
+ target, static_cast<int>(available.size()),
+ io::CodedOutputStream::IsDefaultSerializationDeterministic());
+ auto res = _InternalSerialize(target, &out);
+ Y_ABSL_DCHECK_EQ(res, target + size);
+ buffer.IncreaseLengthBy(size);
+ output->Append(std::move(buffer));
+ Y_ABSL_DCHECK_EQ(output->size(), total_size);
+ return true;
}
- return s;
+
+ // Donate the buffer to the CordOutputStream with length := capacity.
+ // This follows the eager `EpsCopyOutputStream` initialization logic.
+ buffer.SetLength(buffer.capacity());
+ io::CordOutputStream output_stream(std::move(*output), std::move(buffer),
+ total_size);
+ io::EpsCopyOutputStream out(
+ target, static_cast<int>(available.size()), &output_stream,
+ io::CodedOutputStream::IsDefaultSerializationDeterministic(), &target);
+ target = _InternalSerialize(target, &out);
+ out.Trim(target);
+ if (out.HadError()) return false;
+ *output = output_stream.Consume();
+ Y_ABSL_DCHECK_EQ(output->size(), total_size);
+ return true;
+}
+
+bool MessageLite::SerializeToCord(y_absl::Cord* output) const {
+ output->Clear();
+ return AppendToCord(output);
+}
+
+bool MessageLite::SerializePartialToCord(y_absl::Cord* output) const {
+ output->Clear();
+ return AppendPartialToCord(output);
}
-#endif
+y_absl::Cord MessageLite::SerializeAsCord() const {
+ y_absl::Cord output;
+ if (!AppendToCord(&output)) output.Clear();
+ return output;
+}
+
+y_absl::Cord MessageLite::SerializePartialAsCord() const {
+ y_absl::Cord output;
+ if (!AppendPartialToCord(&output)) output.Clear();
+ return output;
+}
namespace internal {
@@ -551,15 +669,6 @@ void GenericTypeHandler<TProtoStringType>::Merge(const TProtoStringType& from,
*to = from;
}
-// Non-inline implementations of InternalMetadata destructor
-// This is moved out of the header because the GOOGLE_DCHECK produces a lot of code.
-void InternalMetadata::CheckedDestruct() {
- if (HasMessageOwnedArenaTag()) {
- GOOGLE_DCHECK(!HasUnknownFieldsTag());
- delete reinterpret_cast<Arena*>(ptr_ - kMessageOwnedArenaTagMask);
- }
-}
-
// Non-inline variants of TProtoStringType specializations for
// various InternalMetadata routines.
template <>
@@ -597,7 +706,7 @@ struct ShutdownData {
}
std::vector<std::pair<void (*)(const void*), const void*>> functions;
- Mutex mutex;
+ y_absl::Mutex mutex;
};
static void RunZeroArgFunc(const void* arg) {
@@ -611,7 +720,7 @@ void OnShutdown(void (*func)()) {
void OnShutdownRun(void (*f)(const void*), const void* arg) {
auto shutdown_data = ShutdownData::get();
- MutexLock lock(&shutdown_data->mutex);
+ y_absl::MutexLock lock(&shutdown_data->mutex);
shutdown_data->functions.push_back(std::make_pair(f, arg));
}
@@ -630,4 +739,4 @@ void ShutdownProtobufLibrary() {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protobuf/src/google/protobuf/message_lite.h b/contrib/libs/protobuf/src/google/protobuf/message_lite.h
index 1a510e2a524..d160a5aefaa 100644
--- a/contrib/libs/protobuf/src/google/protobuf/message_lite.h
+++ b/contrib/libs/protobuf/src/google/protobuf/message_lite.h
@@ -46,21 +46,24 @@
#endif
#include <climits>
+#include <iosfwd>
#include <string>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/arena.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
+#include "google/protobuf/stubs/common.h"
+#include "google/protobuf/arena.h"
+#include "google/protobuf/port.h"
+#include "y_absl/base/call_once.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/strings/cord.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/explicitly_constructed.h"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/metadata_lite.h"
+#include "google/protobuf/port.h"
+
// clang-format off
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
// clang-format on
#ifdef SWIG
@@ -106,7 +109,7 @@ class GenericTypeHandler; // defined in repeated_field.h
// computed size to a cached size. Since we don't proceed with serialization
// if the total size was > INT_MAX, it is not important what this function
// returns for inputs > INT_MAX. However this case should not error or
-// GOOGLE_CHECK-fail, because the full size_t resolution is still returned from
+// Y_ABSL_CHECK-fail, because the full size_t resolution is still returned from
// ByteSizeLong() and checked against INT_MAX; we can catch the overflow
// there.
inline int ToCachedSize(size_t size) { return static_cast<int>(size); }
@@ -121,11 +124,11 @@ inline size_t FromIntSize(int size) {
return static_cast<unsigned int>(size);
}
-// For cases where a legacy function returns an integer size. We GOOGLE_DCHECK()
+// For cases where a legacy function returns an integer size. We Y_ABSL_DCHECK()
// that the conversion will fit within an integer; if this is false then we
// are losing information.
inline int ToIntSize(size_t size) {
- GOOGLE_DCHECK_LE(size, static_cast<size_t>(INT_MAX));
+ Y_ABSL_DCHECK_LE(size, static_cast<size_t>(INT_MAX));
return static_cast<int>(size);
}
@@ -173,6 +176,8 @@ PROTOBUF_EXPORT size_t StringSpaceUsedExcludingSelfLong(const TProtoStringType&
class PROTOBUF_EXPORT MessageLite {
public:
constexpr MessageLite() {}
+ MessageLite(const MessageLite&) = delete;
+ MessageLite& operator=(const MessageLite&) = delete;
virtual ~MessageLite() = default;
// Basic Operations ------------------------------------------------
@@ -188,8 +193,7 @@ class PROTOBUF_EXPORT MessageLite {
// if arena is a nullptr.
virtual MessageLite* New(Arena* arena) const = 0;
- // Returns user-owned arena; nullptr if it's message owned.
- Arena* GetArena() const { return _internal_metadata_.user_arena(); }
+ Arena* GetArena() const { return _internal_metadata_.arena(); }
// Clear all fields of the message and set them to their default values.
// Clear() assumes that any memory allocated to hold parts of the message
@@ -224,6 +228,13 @@ class PROTOBUF_EXPORT MessageLite {
// with Message.
TProtoStringType Utf8DebugString() const { return DebugString(); }
+ // Implementation of the `AbslStringify` interface. This adds `DebugString()`
+ // to the sink. Do not rely on exact format.
+ template <typename Sink>
+ friend void AbslStringify(Sink& sink, const google::protobuf::MessageLite& msg) {
+ sink.Append(msg.DebugString());
+ }
+
// Parsing ---------------------------------------------------------
// Methods for parsing in protocol buffer format. Most of these are
// just simple wrappers around MergeFromCodedStream(). Clear() will be
@@ -282,11 +293,11 @@ class PROTOBUF_EXPORT MessageLite {
// format, matching the encoding output by MessageLite::SerializeToString().
// If you'd like to convert a human-readable string into a protocol buffer
// object, see google::protobuf::TextFormat::ParseFromString().
- PROTOBUF_ATTRIBUTE_REINITIALIZES PROTOBUF_MUST_USE_RESULT bool ParseFromString(ConstStringParam data);
+ PROTOBUF_ATTRIBUTE_REINITIALIZES PROTOBUF_MUST_USE_RESULT bool ParseFromString(y_absl::string_view data);
// Like ParseFromString(), but accepts messages that are missing
// required fields.
PROTOBUF_ATTRIBUTE_REINITIALIZES PROTOBUF_MUST_USE_RESULT bool ParsePartialFromString(
- ConstStringParam data);
+ y_absl::string_view data);
// Parse a protocol buffer contained in an array of bytes.
PROTOBUF_ATTRIBUTE_REINITIALIZES PROTOBUF_MUST_USE_RESULT bool ParseFromArray(const void* data,
int size);
@@ -317,7 +328,7 @@ class PROTOBUF_EXPORT MessageLite {
PROTOBUF_MUST_USE_RESULT bool MergePartialFromCodedStream(io::CodedInputStream* input);
// Merge a protocol buffer contained in a string.
- PROTOBUF_MUST_USE_RESULT bool MergeFromString(ConstStringParam data);
+ PROTOBUF_MUST_USE_RESULT bool MergeFromString(y_absl::string_view data);
// Serialization ---------------------------------------------------
@@ -326,7 +337,7 @@ class PROTOBUF_EXPORT MessageLite {
// Write a protocol buffer of this message to the given output. Returns
// false on a write error. If the message is missing required fields,
- // this may GOOGLE_CHECK-fail.
+ // this may Y_ABSL_CHECK-fail.
PROTOBUF_MUST_USE_RESULT bool SerializeToCodedStream(io::CodedOutputStream* output) const;
// Like SerializeToCodedStream(), but allows missing required fields.
PROTOBUF_MUST_USE_RESULT bool SerializePartialToCodedStream(io::CodedOutputStream* output) const;
@@ -373,6 +384,36 @@ class PROTOBUF_EXPORT MessageLite {
// Like AppendToString(), but allows missing required fields.
PROTOBUF_MUST_USE_RESULT bool AppendPartialToString(TProtoStringType* output) const;
+ // Reads a protocol buffer from a Cord and merges it into this message.
+ PROTOBUF_MUST_USE_RESULT bool MergeFromCord(const y_absl::Cord& cord);
+ // Like MergeFromCord(), but accepts messages that are missing
+ // required fields.
+ PROTOBUF_MUST_USE_RESULT bool MergePartialFromCord(const y_absl::Cord& cord);
+ // Parse a protocol buffer contained in a Cord.
+ PROTOBUF_ATTRIBUTE_REINITIALIZES PROTOBUF_MUST_USE_RESULT bool ParseFromCord(const y_absl::Cord& cord);
+ // Like ParseFromCord(), but accepts messages that are missing
+ // required fields.
+ PROTOBUF_ATTRIBUTE_REINITIALIZES PROTOBUF_MUST_USE_RESULT bool ParsePartialFromCord(
+ const y_absl::Cord& cord);
+
+ // Serialize the message and store it in the given Cord. All required
+ // fields must be set.
+ PROTOBUF_MUST_USE_RESULT bool SerializeToCord(y_absl::Cord* output) const;
+ // Like SerializeToCord(), but allows missing required fields.
+ PROTOBUF_MUST_USE_RESULT bool SerializePartialToCord(y_absl::Cord* output) const;
+
+ // Make a Cord encoding the message. Is equivalent to calling
+ // SerializeToCord() on a Cord and using that. Returns an empty
+ // Cord if SerializeToCord() would have returned an error.
+ y_absl::Cord SerializeAsCord() const;
+ // Like SerializeAsCord(), but allows missing required fields.
+ y_absl::Cord SerializePartialAsCord() const;
+
+ // Like SerializeToCord(), but appends to the data to the Cord's existing
+ // contents. All required fields must be set.
+ PROTOBUF_MUST_USE_RESULT bool AppendToCord(y_absl::Cord* output) const;
+ // Like AppendToCord(), but allows missing required fields.
+ PROTOBUF_MUST_USE_RESULT bool AppendPartialToCord(y_absl::Cord* output) const;
// Computes the serialized size of the message. This recursively calls
// ByteSizeLong() on all embedded messages.
@@ -430,24 +471,19 @@ class PROTOBUF_EXPORT MessageLite {
return Arena::CreateMaybeMessage<T>(arena);
}
- inline explicit MessageLite(Arena* arena, bool is_message_owned = false)
- : _internal_metadata_(arena, is_message_owned) {}
+ inline explicit MessageLite(Arena* arena) : _internal_metadata_(arena) {}
// Returns the arena, if any, that directly owns this message and its internal
// memory (Arena::Own is different in that the arena doesn't directly own the
// internal memory). This method is used in proto's implementation for
// swapping, moving and setting allocated, for deciding whether the ownership
// of this message or its internal memory could be changed.
- Arena* GetOwningArena() const { return _internal_metadata_.owning_arena(); }
+ Arena* GetOwningArena() const { return _internal_metadata_.arena(); }
// Returns the arena, used for allocating internal objects(e.g., child
// messages, etc), or owning incoming objects (e.g., set allocated).
Arena* GetArenaForAllocation() const { return _internal_metadata_.arena(); }
- // Returns true if this message is enabled for message-owned arena (MOA)
- // trials. No lite messages are eligible for MOA.
- static bool InMoaTrial() { return false; }
-
internal::InternalMetadata _internal_metadata_;
public:
@@ -505,19 +541,17 @@ class PROTOBUF_EXPORT MessageLite {
void LogInitializationErrorMessage() const;
PROTOBUF_MUST_USE_RESULT bool MergeFromImpl(io::CodedInputStream* input, ParseFlags parse_flags);
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageLite);
};
namespace internal {
template <bool alias>
-PROTOBUF_MUST_USE_RESULT bool MergeFromImpl(StringPiece input, MessageLite* msg,
+PROTOBUF_MUST_USE_RESULT bool MergeFromImpl(y_absl::string_view input, MessageLite* msg,
MessageLite::ParseFlags parse_flags);
-extern template PROTOBUF_MUST_USE_RESULT bool MergeFromImpl<false>(StringPiece input,
+extern template PROTOBUF_MUST_USE_RESULT bool MergeFromImpl<false>(y_absl::string_view input,
MessageLite* msg,
MessageLite::ParseFlags parse_flags);
-extern template PROTOBUF_MUST_USE_RESULT bool MergeFromImpl<true>(StringPiece input,
+extern template PROTOBUF_MUST_USE_RESULT bool MergeFromImpl<true>(y_absl::string_view input,
MessageLite* msg,
MessageLite::ParseFlags parse_flags);
@@ -599,6 +633,6 @@ T* OnShutdownDelete(T* p) {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_MESSAGE_LITE_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/messagext.cc b/contrib/libs/protobuf/src/google/protobuf/messagext.cc
index 1923205598e..8b08544d924 100644
--- a/contrib/libs/protobuf/src/google/protobuf/messagext.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/messagext.cc
@@ -14,7 +14,7 @@ namespace {
namespace google::protobuf {
//defined in message_lite.cc
-TProtoStringType InitializationErrorMessage(const char* action, const MessageLite& message);
+TProtoStringType InitializationErrorMessage(y_absl::string_view action, const MessageLite& message);
} // namespace google::protobuf
@@ -64,7 +64,7 @@ bool SerializePartialToCodedStreamSeq(const Message* msg, io::CodedOutputStream*
}
bool SerializeToCodedStreamSeq(const Message* msg, io::CodedOutputStream* output) {
- GOOGLE_DCHECK(msg->IsInitialized()) << InitializationErrorMessage("serialize", *msg);
+ Y_ABSL_DCHECK(msg->IsInitialized()) << InitializationErrorMessage("serialize", *msg);
return SerializePartialToCodedStreamSeq(msg, output);
}
@@ -78,9 +78,9 @@ int TInputStreamProxy::Read(void* buffer, int size) {
try {
return (int)mSlave->Read(buffer, (size_t)size);
} catch (const yexception& e) {
- GOOGLE_LOG(ERROR) << e.what();
+ Y_ABSL_LOG(ERROR) << e.what();
} catch (...) {
- GOOGLE_LOG(ERROR) << "unknown exception caught";
+ Y_ABSL_LOG(ERROR) << "unknown exception caught";
}
TErrorState::SetError();
return -1;
@@ -92,9 +92,9 @@ bool TOutputStreamProxy::Write(const void* buffer, int size) {
mSlave->Write(buffer, (size_t)size);
return true;
} catch (const yexception& e) {
- GOOGLE_LOG(ERROR) << e.what();
+ Y_ABSL_LOG(ERROR) << e.what();
} catch (...) {
- GOOGLE_LOG(ERROR) << "unknown exception caught";
+ Y_ABSL_LOG(ERROR) << "unknown exception caught";
}
TErrorState::SetError();
return false;
diff --git a/contrib/libs/protobuf/src/google/protobuf/metadata_lite.h b/contrib/libs/protobuf/src/google/protobuf/metadata_lite.h
index eb004422ee0..6c98e1d9eb6 100644
--- a/contrib/libs/protobuf/src/google/protobuf/metadata_lite.h
+++ b/contrib/libs/protobuf/src/google/protobuf/metadata_lite.h
@@ -32,12 +32,13 @@
#define GOOGLE_PROTOBUF_METADATA_LITE_H__
#include <string>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/arena.h>
-#include <google/protobuf/port.h>
+
+#include "google/protobuf/arena.h"
+#include "google/protobuf/port.h"
+#include "google/protobuf/port.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
#ifdef SWIG
#error "You cannot SWIG proto headers"
@@ -45,6 +46,9 @@
namespace google {
namespace protobuf {
+
+class UnknownFieldSet;
+
namespace internal {
// This is the representation for messages that support arena allocation. It
@@ -63,29 +67,8 @@ namespace internal {
class PROTOBUF_EXPORT InternalMetadata {
public:
constexpr InternalMetadata() : ptr_(0) {}
- explicit InternalMetadata(Arena* arena, bool is_message_owned = false) {
- SetArena(arena, is_message_owned);
- }
-
- void SetArena(Arena* arena, bool is_message_owned) {
- ptr_ = is_message_owned
- ? reinterpret_cast<intptr_t>(arena) | kMessageOwnedArenaTagMask
- : reinterpret_cast<intptr_t>(arena);
- GOOGLE_DCHECK(!is_message_owned || arena != nullptr);
- }
-
- // To keep the ABI identical between debug and non-debug builds,
- // the destructor is always defined here even though it may delegate
- // to a non-inline private method.
- // (see https://github.com/protocolbuffers/protobuf/issues/9947)
- ~InternalMetadata() {
-#if defined(NDEBUG) || defined(_MSC_VER)
- if (HasMessageOwnedArenaTag()) {
- delete reinterpret_cast<Arena*>(ptr_ - kMessageOwnedArenaTagMask);
- }
-#else
- CheckedDestruct();
-#endif
+ explicit InternalMetadata(Arena* arena) {
+ ptr_ = reinterpret_cast<intptr_t>(arena);
}
template <typename T>
@@ -112,15 +95,6 @@ class PROTOBUF_EXPORT InternalMetadata {
}
}
- 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;
@@ -192,18 +166,13 @@ class PROTOBUF_EXPORT InternalMetadata {
// Tagged pointer implementation.
static constexpr intptr_t kUnknownFieldsTagMask = 1;
- static constexpr intptr_t kMessageOwnedArenaTagMask = 2;
- static constexpr intptr_t kPtrTagMask =
- kUnknownFieldsTagMask | kMessageOwnedArenaTagMask;
+ static constexpr intptr_t kPtrTagMask = kUnknownFieldsTagMask;
static constexpr intptr_t kPtrValueMask = ~kPtrTagMask;
// Accessors for pointer tag and pointer value.
PROTOBUF_ALWAYS_INLINE bool HasUnknownFieldsTag() const {
return ptr_ & kUnknownFieldsTagMask;
}
- PROTOBUF_ALWAYS_INLINE bool HasMessageOwnedArenaTag() const {
- return ptr_ & kMessageOwnedArenaTagMask;
- }
template <typename U>
U* PtrValue() const {
@@ -223,11 +192,7 @@ class PROTOBUF_EXPORT InternalMetadata {
template <typename T>
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;
+ ptr_ = reinterpret_cast<intptr_t>(a);
return a;
} else {
delete PtrValue<Container<T>>();
@@ -240,11 +205,10 @@ class PROTOBUF_EXPORT InternalMetadata {
PROTOBUF_NOINLINE T* mutable_unknown_fields_slow() {
Arena* my_arena = arena();
Container<T>* container = Arena::Create<Container<T>>(my_arena);
- intptr_t message_owned_arena_tag = ptr_ & kMessageOwnedArenaTagMask;
// Two-step assignment works around a bug in clang's static analyzer:
// https://bugs.llvm.org/show_bug.cgi?id=34198.
ptr_ = reinterpret_cast<intptr_t>(container);
- ptr_ |= kUnknownFieldsTagMask | message_owned_arena_tag;
+ ptr_ |= kUnknownFieldsTagMask;
container->arena = my_arena;
return &(container->unknown_fields);
}
@@ -280,6 +244,19 @@ PROTOBUF_EXPORT void InternalMetadata::DoMergeFrom<TProtoStringType>(
template <>
PROTOBUF_EXPORT void InternalMetadata::DoSwap<TProtoStringType>(TProtoStringType* other);
+// Instantiated once in message.cc (where the definition of UnknownFieldSet is
+// known) to prevent much duplication across translation units of a large build.
+extern template PROTOBUF_EXPORT void
+InternalMetadata::DoClear<UnknownFieldSet>();
+extern template PROTOBUF_EXPORT void
+InternalMetadata::DoMergeFrom<UnknownFieldSet>(const UnknownFieldSet& other);
+extern template PROTOBUF_EXPORT void
+InternalMetadata::DoSwap<UnknownFieldSet>(UnknownFieldSet* other);
+extern template PROTOBUF_EXPORT Arena*
+InternalMetadata::DeleteOutOfLineHelper<UnknownFieldSet>();
+extern template PROTOBUF_EXPORT UnknownFieldSet*
+InternalMetadata::mutable_unknown_fields_slow<UnknownFieldSet>();
+
// This helper RAII class is needed to efficiently parse unknown fields. We
// should only call mutable_unknown_fields if there are actual unknown fields.
// The obvious thing to just use a stack string and swap it at the end of
@@ -311,6 +288,6 @@ class PROTOBUF_EXPORT LiteUnknownFieldSetter {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_METADATA_LITE_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/parse_context.cc b/contrib/libs/protobuf/src/google/protobuf/parse_context.cc
index 6c07eb15531..9aa438fdc0e 100644
--- a/contrib/libs/protobuf/src/google/protobuf/parse_context.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/parse_context.cc
@@ -28,31 +28,32 @@
// (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/parse_context.h>
+#include "google/protobuf/parse_context.h"
+
+#include <algorithm>
+#include <cstring>
+
+#include "y_absl/strings/cord.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/message_lite.h"
+#include "google/protobuf/repeated_field.h"
+#include "google/protobuf/wire_format_lite.h"
+#include "utf8_validity.h"
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/zero_copy_stream.h>
-#include <google/protobuf/arenastring.h>
-#include <google/protobuf/endian.h>
-#include <google/protobuf/message_lite.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/wire_format_lite.h>
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
namespace internal {
-namespace {
-
// Only call if at start of tag.
-bool ParseEndsInSlopRegion(const char* begin, int overrun, int depth) {
+bool EpsCopyInputStream::ParseEndsInSlopRegion(const char* begin, int overrun,
+ int depth) {
constexpr int kSlopBytes = EpsCopyInputStream::kSlopBytes;
- GOOGLE_DCHECK_GE(overrun, 0);
- GOOGLE_DCHECK_LE(overrun, kSlopBytes);
+ Y_ABSL_DCHECK_GE(overrun, 0);
+ Y_ABSL_DCHECK_LE(overrun, kSlopBytes);
auto ptr = begin + overrun;
auto end = begin + kSlopBytes;
while (ptr < end) {
@@ -98,44 +99,42 @@ bool ParseEndsInSlopRegion(const char* begin, int overrun, int depth) {
return false;
}
-} // namespace
-
const char* EpsCopyInputStream::NextBuffer(int overrun, int depth) {
if (next_chunk_ == nullptr) return nullptr; // We've reached end of stream.
- if (next_chunk_ != buffer_) {
- GOOGLE_DCHECK(size_ > kSlopBytes);
+ if (next_chunk_ != patch_buffer_) {
+ Y_ABSL_DCHECK(size_ > kSlopBytes);
// The chunk is large enough to be used directly
buffer_end_ = next_chunk_ + size_ - kSlopBytes;
auto res = next_chunk_;
- next_chunk_ = buffer_;
+ next_chunk_ = patch_buffer_;
if (aliasing_ == kOnPatch) aliasing_ = kNoDelta;
return res;
}
// Move the slop bytes of previous buffer to start of the patch buffer.
// Note we must use memmove because the previous buffer could be part of
- // buffer_.
- std::memmove(buffer_, buffer_end_, kSlopBytes);
+ // patch_buffer_.
+ std::memmove(patch_buffer_, buffer_end_, kSlopBytes);
if (overall_limit_ > 0 &&
- (depth < 0 || !ParseEndsInSlopRegion(buffer_, overrun, depth))) {
+ (depth < 0 || !ParseEndsInSlopRegion(patch_buffer_, overrun, depth))) {
const void* data;
// ZeroCopyInputStream indicates Next may return 0 size buffers. Hence
// we loop.
while (StreamNext(&data)) {
if (size_ > kSlopBytes) {
// We got a large chunk
- std::memcpy(buffer_ + kSlopBytes, data, kSlopBytes);
+ std::memcpy(patch_buffer_ + kSlopBytes, data, kSlopBytes);
next_chunk_ = static_cast<const char*>(data);
- buffer_end_ = buffer_ + kSlopBytes;
+ buffer_end_ = patch_buffer_ + kSlopBytes;
if (aliasing_ >= kNoDelta) aliasing_ = kOnPatch;
- return buffer_;
+ return patch_buffer_;
} else if (size_ > 0) {
- std::memcpy(buffer_ + kSlopBytes, data, size_);
- next_chunk_ = buffer_;
- buffer_end_ = buffer_ + size_;
+ std::memcpy(patch_buffer_ + kSlopBytes, data, size_);
+ next_chunk_ = patch_buffer_;
+ buffer_end_ = patch_buffer_ + size_;
if (aliasing_ >= kNoDelta) aliasing_ = kOnPatch;
- return buffer_;
+ return patch_buffer_;
}
- GOOGLE_DCHECK(size_ == 0) << size_;
+ Y_ABSL_DCHECK(size_ == 0) << size_;
}
overall_limit_ = 0; // Next failed, no more needs for next
}
@@ -147,16 +146,16 @@ const char* EpsCopyInputStream::NextBuffer(int overrun, int depth) {
// array. This guarantees string_view's are always aliased if parsed from
// an array.
aliasing_ = reinterpret_cast<std::uintptr_t>(buffer_end_) -
- reinterpret_cast<std::uintptr_t>(buffer_);
+ reinterpret_cast<std::uintptr_t>(patch_buffer_);
}
next_chunk_ = nullptr;
- buffer_end_ = buffer_ + kSlopBytes;
+ buffer_end_ = patch_buffer_ + kSlopBytes;
size_ = 0;
- return buffer_;
+ return patch_buffer_;
}
const char* EpsCopyInputStream::Next() {
- GOOGLE_DCHECK(limit_ > kSlopBytes);
+ Y_ABSL_DCHECK(limit_ > kSlopBytes);
auto p = NextBuffer(0 /* immaterial */, -1);
if (p == nullptr) {
limit_end_ = buffer_end_;
@@ -173,25 +172,25 @@ std::pair<const char*, bool> EpsCopyInputStream::DoneFallback(int overrun,
int depth) {
// Did we exceeded the limit (parse error).
if (PROTOBUF_PREDICT_FALSE(overrun > limit_)) return {nullptr, true};
- GOOGLE_DCHECK(overrun != limit_); // Guaranteed by caller.
- GOOGLE_DCHECK(overrun < limit_); // Follows from above
+ Y_ABSL_DCHECK(overrun != limit_); // Guaranteed by caller.
+ Y_ABSL_DCHECK(overrun < limit_); // Follows from above
// TODO(gerbens) Instead of this dcheck we could just assign, and remove
// updating the limit_end from PopLimit, ie.
// limit_end_ = buffer_end_ + (std::min)(0, limit_);
// if (ptr < limit_end_) return {ptr, false};
- GOOGLE_DCHECK(limit_end_ == buffer_end_ + (std::min)(0, limit_));
+ Y_ABSL_DCHECK(limit_end_ == buffer_end_ + (std::min)(0, limit_));
// At this point we know the following assertion holds.
- GOOGLE_DCHECK_GT(limit_, 0);
- GOOGLE_DCHECK(limit_end_ == buffer_end_); // because limit_ > 0
+ Y_ABSL_DCHECK_GT(limit_, 0);
+ Y_ABSL_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_GE(overrun, 0);
+ Y_ABSL_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_GT(limit_, 0);
+ Y_ABSL_DCHECK_GT(limit_, 0);
limit_end_ = buffer_end_;
// Distinguish ending on a pushed limit or ending on end-of-stream.
SetEndOfStream();
@@ -234,6 +233,61 @@ const char* EpsCopyInputStream::AppendStringFallback(const char* ptr, int size,
[str](const char* p, int s) { str->append(p, s); });
}
+const char* EpsCopyInputStream::ReadCordFallback(const char* ptr, int size,
+ y_absl::Cord* cord) {
+ if (zcis_ == nullptr) {
+ int bytes_from_buffer = buffer_end_ - ptr + kSlopBytes;
+ if (size <= bytes_from_buffer) {
+ *cord = y_absl::string_view(ptr, size);
+ return ptr + size;
+ }
+ return AppendSize(ptr, size, [cord](const char* p, int s) {
+ cord->Append(y_absl::string_view(p, s));
+ });
+ }
+ int new_limit = buffer_end_ - ptr + limit_;
+ if (size > new_limit) return nullptr;
+ new_limit -= size;
+ int bytes_from_buffer = buffer_end_ - ptr + kSlopBytes;
+ const bool in_patch_buf = reinterpret_cast<uintptr_t>(ptr) -
+ reinterpret_cast<uintptr_t>(patch_buffer_) <=
+ kPatchBufferSize;
+ if (bytes_from_buffer > kPatchBufferSize || !in_patch_buf) {
+ cord->Clear();
+ StreamBackUp(bytes_from_buffer);
+ } else if (bytes_from_buffer == kSlopBytes && next_chunk_ != nullptr &&
+ // Only backup if next_chunk_ points to a valid buffer returned by
+ // ZeroCopyInputStream. This happens when NextStream() returns a
+ // chunk that's smaller than or equal to kSlopBytes.
+ next_chunk_ != patch_buffer_) {
+ cord->Clear();
+ StreamBackUp(size_);
+ } else {
+ size -= bytes_from_buffer;
+ Y_ABSL_DCHECK_GT(size, 0);
+ *cord = y_absl::string_view(ptr, bytes_from_buffer);
+ if (next_chunk_ == patch_buffer_) {
+ // We have read to end of the last buffer returned by
+ // ZeroCopyInputStream. So the stream is in the right position.
+ } else if (next_chunk_ == nullptr) {
+ // There is no remaining chunks. We can't read size.
+ SetEndOfStream();
+ return nullptr;
+ } else {
+ // Next chunk is already loaded
+ Y_ABSL_DCHECK(size_ > kSlopBytes);
+ StreamBackUp(size_ - kSlopBytes);
+ }
+ }
+ if (size > overall_limit_) return nullptr;
+ overall_limit_ -= size;
+ if (!zcis_->ReadCord(cord, size)) return nullptr;
+ ptr = InitFrom(zcis_);
+ limit_ = new_limit - static_cast<int>(buffer_end_ - ptr);
+ limit_end_ = buffer_end_ + (std::min)(0, limit_);
+ return ptr;
+}
+
const char* EpsCopyInputStream::InitFrom(io::ZeroCopyInputStream* zcis) {
zcis_ = zcis;
@@ -246,13 +300,13 @@ const char* EpsCopyInputStream::InitFrom(io::ZeroCopyInputStream* zcis) {
auto ptr = static_cast<const char*>(data);
limit_ -= size - kSlopBytes;
limit_end_ = buffer_end_ = ptr + size - kSlopBytes;
- next_chunk_ = buffer_;
+ next_chunk_ = patch_buffer_;
if (aliasing_ == kOnPatch) aliasing_ = kNoDelta;
return ptr;
} else {
- limit_end_ = buffer_end_ = buffer_ + kSlopBytes;
- next_chunk_ = buffer_;
- auto ptr = buffer_ + 2 * kSlopBytes - size;
+ limit_end_ = buffer_end_ = patch_buffer_ + kSlopBytes;
+ next_chunk_ = patch_buffer_;
+ auto ptr = patch_buffer_ + kPatchBufferSize - size;
std::memcpy(ptr, data, size);
return ptr;
}
@@ -260,26 +314,29 @@ const char* EpsCopyInputStream::InitFrom(io::ZeroCopyInputStream* zcis) {
overall_limit_ = 0;
next_chunk_ = nullptr;
size_ = 0;
- limit_end_ = buffer_end_ = buffer_;
- return buffer_;
+ limit_end_ = buffer_end_ = patch_buffer_;
+ return patch_buffer_;
}
const char* ParseContext::ReadSizeAndPushLimitAndDepth(const char* ptr,
int* old_limit) {
int size = ReadSize(&ptr);
- if (PROTOBUF_PREDICT_FALSE(!ptr)) {
+ if (PROTOBUF_PREDICT_FALSE(!ptr) || depth_ <= 0) {
*old_limit = 0; // Make sure this isn't uninitialized even on error return
return nullptr;
}
*old_limit = PushLimit(ptr, size);
- if (--depth_ < 0) return nullptr;
+ --depth_;
return ptr;
}
const char* ParseContext::ParseMessage(MessageLite* msg, const char* ptr) {
int old;
ptr = ReadSizeAndPushLimitAndDepth(ptr, &old);
- ptr = ptr ? msg->_InternalParse(ptr, this) : nullptr;
+ if (ptr == nullptr) return ptr;
+ auto old_depth = depth_;
+ ptr = msg->_InternalParse(ptr, this);
+ if (ptr != nullptr) Y_ABSL_DCHECK_EQ(old_depth, depth_);
depth_++;
if (!PopLimit(old)) return nullptr;
return ptr;
@@ -299,7 +356,7 @@ void WriteVarint(arc_ui32 num, arc_ui64 val, TProtoStringType* s) {
WriteVarint(val, s);
}
-void WriteLengthDelimited(arc_ui32 num, StringPiece val, TProtoStringType* s) {
+void WriteLengthDelimited(arc_ui32 num, y_absl::string_view val, TProtoStringType* s) {
WriteVarint((num << 3) + 2, s);
WriteVarint(val.size(), s);
s->append(val.data(), val.size());
@@ -307,7 +364,7 @@ void WriteLengthDelimited(arc_ui32 num, StringPiece val, TProtoStringType* s) {
std::pair<const char*, arc_ui32> VarintParseSlow32(const char* p,
arc_ui32 res) {
- for (arc_ui32 i = 2; i < 5; i++) {
+ for (arc_ui32 i = 1; i < 5; i++) {
arc_ui32 byte = static_cast<uint8_t>(p[i]);
res += (byte - 1) << (7 * i);
if (PROTOBUF_PREDICT_TRUE(byte < 128)) {
@@ -327,7 +384,7 @@ std::pair<const char*, arc_ui32> VarintParseSlow32(const char* p,
std::pair<const char*, arc_ui64> VarintParseSlow64(const char* p,
arc_ui32 res32) {
arc_ui64 res = res32;
- for (arc_ui32 i = 2; i < 10; i++) {
+ for (arc_ui32 i = 1; i < 10; i++) {
arc_ui64 byte = static_cast<uint8_t>(p[i]);
res += (byte - 1) << (7 * i);
if (PROTOBUF_PREDICT_TRUE(byte < 128)) {
@@ -376,12 +433,12 @@ const char* StringParser(const char* begin, const char* end, void* object,
}
// Defined in wire_format_lite.cc
-void PrintUTF8ErrorLog(StringPiece message_name,
- StringPiece field_name, const char* operation_str,
+void PrintUTF8ErrorLog(y_absl::string_view message_name,
+ y_absl::string_view field_name, const char* operation_str,
bool emit_stacktrace);
-bool VerifyUTF8(StringPiece str, const char* field_name) {
- if (!IsStructurallyValidUTF8(str)) {
+bool VerifyUTF8(y_absl::string_view str, const char* field_name) {
+ if (!utf8_range::IsStructurallyValid(str)) {
PrintUTF8ErrorLog("", field_name, "parsing", false);
return false;
}
@@ -541,8 +598,208 @@ const char* UnknownFieldParse(arc_ui32 tag, TProtoStringType* unknown,
return FieldParser(tag, field_parser, ptr, ctx);
}
+#ifdef __aarch64__
+// Generally, speaking, the ARM-optimized Varint decode algorithm is to extract
+// and concatenate all potentially valid data bits, compute the actual length
+// of the Varint, and mask off the data bits which are not actually part of the
+// result. More detail on the two main parts is shown below.
+//
+// 1) Extract and concatenate all potentially valid data bits.
+// Two ARM-specific features help significantly:
+// a) Efficient and non-destructive bit extraction (UBFX)
+// b) A single instruction can perform both an OR with a shifted
+// second operand in one cycle. E.g., the following two lines do the same
+// thing
+// ```result = operand_1 | (operand2 << 7);```
+// ```ORR %[result], %[operand_1], %[operand_2], LSL #7```
+// The figure below shows the implementation for handling four chunks.
+//
+// Bits 32 31-24 23 22-16 15 14-8 7 6-0
+// +----+---------+----+---------+----+---------+----+---------+
+// |CB 3| Chunk 3 |CB 2| Chunk 2 |CB 1| Chunk 1 |CB 0| Chunk 0 |
+// +----+---------+----+---------+----+---------+----+---------+
+// | | | |
+// UBFX UBFX UBFX UBFX -- cycle 1
+// | | | |
+// V V V V
+// Combined LSL #7 and ORR Combined LSL #7 and ORR -- cycle 2
+// | |
+// V V
+// Combined LSL #14 and ORR -- cycle 3
+// |
+// V
+// Parsed bits 0-27
+//
+//
+// 2) Calculate the index of the cleared continuation bit in order to determine
+// where the encoded Varint ends and the size of the decoded value. The
+// easiest way to do this is mask off all data bits, leaving just the
+// continuation bits. We actually need to do the masking on an inverted
+// copy of the data, which leaves a 1 in all continuation bits which were
+// originally clear. The number of trailing zeroes in this value indicates
+// the size of the Varint.
+//
+// AND 0x80 0x80 0x80 0x80 0x80 0x80 0x80 0x80
+//
+// Bits 63 55 47 39 31 23 15 7
+// +----+--+----+--+----+--+----+--+----+--+----+--+----+--+----+--+
+// ~ |CB 7| |CB 6| |CB 5| |CB 4| |CB 3| |CB 2| |CB 1| |CB 0| |
+// +----+--+----+--+----+--+----+--+----+--+----+--+----+--+----+--+
+// | | | | | | | |
+// V V V V V V V V
+// Bits 63 55 47 39 31 23 15 7
+// +----+--+----+--+----+--+----+--+----+--+----+--+----+--+----+--+
+// |~CB 7|0|~CB 6|0|~CB 5|0|~CB 4|0|~CB 3|0|~CB 2|0|~CB 1|0|~CB 0|0|
+// +----+--+----+--+----+--+----+--+----+--+----+--+----+--+----+--+
+// |
+// CTZ
+// V
+// Index of first cleared continuation bit
+//
+//
+// While this is implemented in C++ significant care has been taken to ensure
+// the compiler emits the best instruction sequence. In some cases we use the
+// following two functions to manipulate the compiler's scheduling decisions.
+//
+// Controls compiler scheduling by telling it that the first value is modified
+// by the second value the callsite. This is useful if non-critical path
+// instructions are too aggressively scheduled, resulting in a slowdown of the
+// actual critical path due to opportunity costs. An example usage is shown
+// where a false dependence of num_bits on result is added to prevent checking
+// for a very unlikely error until all critical path instructions have been
+// fetched.
+//
+// ```
+// num_bits = <multiple operations to calculate new num_bits value>
+// result = <multiple operations to calculate result>
+// num_bits = ValueBarrier(num_bits, result);
+// if (num_bits == 63) {
+// Y_ABSL_LOG(FATAL) << "Invalid num_bits value";
+// }
+// ```
+PROTOBUF_ALWAYS_INLINE inline arc_ui64 ExtractAndMergeTwoChunks(
+ arc_ui64 data, arc_ui64 first_byte) {
+ Y_ABSL_DCHECK_LE(first_byte, 6);
+ arc_ui64 first = Ubfx7(data, first_byte * 8);
+ arc_ui64 second = Ubfx7(data, (first_byte + 1) * 8);
+ return ValueBarrier(first | (second << 7));
+}
+
+struct SlowPathEncodedInfo {
+ const char* p;
+ arc_ui64 last8;
+ arc_ui64 valid_bits;
+ arc_ui64 valid_chunk_bits;
+ arc_ui64 masked_cont_bits;
+};
+
+// Performs multiple actions which are identical between 32 and 64 bit Varints
+// in order to compute the length of the encoded Varint and compute the new
+// of p.
+PROTOBUF_ALWAYS_INLINE inline SlowPathEncodedInfo ComputeLengthAndUpdateP(
+ const char* p) {
+ SlowPathEncodedInfo result;
+ // Load the last two bytes of the encoded Varint.
+ std::memcpy(&result.last8, p + 2, sizeof(result.last8));
+ arc_ui64 mask = ValueBarrier(0x8080808080808080);
+ // Only set continuation bits remain
+ result.masked_cont_bits = ValueBarrier(mask & (~result.last8));
+ // The first cleared continuation bit is the most significant 1 in the
+ // reversed value. Result is undefined for an input of 0 and we handle that
+ // case below.
+ result.valid_bits = y_absl::countr_zero(result.masked_cont_bits);
+ // Calculates the number of chunks in the encoded Varint. This value is low
+ // by three as neither the cleared continuation chunk nor the first two chunks
+ // are counted.
+ arc_ui64 set_continuation_bits = result.valid_bits >> 3;
+ // Update p to point past the encoded Varint.
+ result.p = p + set_continuation_bits + 3;
+ // Calculate number of valid data bits in the decoded value so invalid bits
+ // can be masked off. Value is too low by 14 but we account for that when
+ // calculating the mask.
+ result.valid_chunk_bits = result.valid_bits - set_continuation_bits;
+ return result;
+}
+
+constexpr arc_ui64 kResultMaskUnshifted = 0xffffffffffffc000ULL;
+constexpr arc_ui64 kFirstResultBitChunk1 = 1 * 7;
+constexpr arc_ui64 kFirstResultBitChunk2 = 2 * 7;
+constexpr arc_ui64 kFirstResultBitChunk3 = 3 * 7;
+constexpr arc_ui64 kFirstResultBitChunk4 = 4 * 7;
+constexpr arc_ui64 kFirstResultBitChunk6 = 6 * 7;
+constexpr arc_ui64 kFirstResultBitChunk8 = 8 * 7;
+constexpr arc_ui64 kValidBitsForInvalidVarint = 0x60;
+
+PROTOBUF_NOINLINE const char* VarintParseSlowArm64(const char* p, arc_ui64* out,
+ arc_ui64 first8) {
+ SlowPathEncodedInfo info = ComputeLengthAndUpdateP(p);
+ // Extract data bits from the low six chunks. This includes chunks zero and
+ // one which we already know are valid.
+ arc_ui64 merged_01 = ExtractAndMergeTwoChunks(first8, /*first_chunk=*/0);
+ arc_ui64 merged_23 = ExtractAndMergeTwoChunks(first8, /*first_chunk=*/2);
+ arc_ui64 merged_45 = ExtractAndMergeTwoChunks(first8, /*first_chunk=*/4);
+ // Low 42 bits of decoded value.
+ arc_ui64 result = merged_01 | merged_23 << kFirstResultBitChunk2 |
+ merged_45 << kFirstResultBitChunk4;
+ // This immediate ends in 14 zeroes since valid_chunk_bits is too low by 14.
+ arc_ui64 result_mask = kResultMaskUnshifted << info.valid_chunk_bits;
+ // masked_cont_bits is 0 iff the Varint is invalid.
+ if (PROTOBUF_PREDICT_FALSE(!info.masked_cont_bits)) {
+ *out = 0;
+ return nullptr;
+ }
+ // Test for early exit if Varint does not exceed 6 chunks. Branching on one
+ // bit is faster on ARM than via a compare and branch.
+ if (PROTOBUF_PREDICT_FALSE((info.valid_bits & 0x20) != 0)) {
+ // Extract data bits from high four chunks.
+ arc_ui64 merged_67 = ExtractAndMergeTwoChunks(first8, /*first_chunk=*/6);
+ // Last two chunks come from last two bytes of info.last8.
+ arc_ui64 merged_89 =
+ ExtractAndMergeTwoChunks(info.last8, /*first_chunk=*/6);
+ result |= merged_67 << kFirstResultBitChunk6;
+ result |= merged_89 << kFirstResultBitChunk8;
+ // Handle an invalid Varint with all 10 continuation bits set.
+ }
+ // Mask off invalid data bytes.
+ result &= ~result_mask;
+ *out = result;
+ return info.p;
+}
+
+// See comments in VarintParseSlowArm64 for a description of the algorithm.
+// Differences in the 32 bit version are noted below.
+PROTOBUF_NOINLINE const char* VarintParseSlowArm32(const char* p, arc_ui32* out,
+ arc_ui64 first8) {
+ // This also skips the slop bytes.
+ SlowPathEncodedInfo info = ComputeLengthAndUpdateP(p);
+ // Extract data bits from chunks 1-4. Chunk zero is merged in below.
+ arc_ui64 merged_12 = ExtractAndMergeTwoChunks(first8, /*first_chunk=*/1);
+ arc_ui64 merged_34 = ExtractAndMergeTwoChunks(first8, /*first_chunk=*/3);
+ first8 = ValueBarrier(first8, p);
+ arc_ui64 result = Ubfx7(first8, /*start=*/0);
+ result = ValueBarrier(result | merged_12 << kFirstResultBitChunk1);
+ result = ValueBarrier(result | merged_34 << kFirstResultBitChunk3);
+ arc_ui64 result_mask = kResultMaskUnshifted << info.valid_chunk_bits;
+ result &= ~result_mask;
+ // It is extremely unlikely that a Varint is invalid so checking that
+ // condition isn't on the critical path. Here we make sure that we don't do so
+ // until result has been computed.
+ info.masked_cont_bits = ValueBarrier(info.masked_cont_bits, result);
+ if (PROTOBUF_PREDICT_FALSE(info.masked_cont_bits == 0)) {
+ // Makes the compiler think out was modified here. This ensures it won't
+ // predicate this extremely predictable branch.
+ out = ValueBarrier(out);
+ *out = 0;
+ return nullptr;
+ }
+ *out = result;
+ return info.p;
+}
+
+#endif // __aarch64__
+
} // namespace internal
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protobuf/src/google/protobuf/parse_context.h b/contrib/libs/protobuf/src/google/protobuf/parse_context.h
index eb76cde8a05..d42811ff0a2 100644
--- a/contrib/libs/protobuf/src/google/protobuf/parse_context.h
+++ b/contrib/libs/protobuf/src/google/protobuf/parse_context.h
@@ -36,21 +36,26 @@
#include <string>
#include <type_traits>
-#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/endian.h>
-#include <google/protobuf/implicit_weak_message.h>
-#include <google/protobuf/inlined_string_field.h>
-#include <google/protobuf/metadata_lite.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/wire_format_lite.h>
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/cord.h"
+#include "y_absl/strings/internal/resize_uninitialized.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/arena.h"
+#include "google/protobuf/arenastring.h"
+#include "google/protobuf/endian.h"
+#include "google/protobuf/implicit_weak_message.h"
+#include "google/protobuf/inlined_string_field.h"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/io/zero_copy_stream.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"
+
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
@@ -64,11 +69,11 @@ namespace internal {
// Template code below needs to know about the existence of these functions.
PROTOBUF_EXPORT void WriteVarint(arc_ui32 num, arc_ui64 val, TProtoStringType* s);
-PROTOBUF_EXPORT void WriteLengthDelimited(arc_ui32 num, StringPiece val,
+PROTOBUF_EXPORT void WriteLengthDelimited(arc_ui32 num, y_absl::string_view val,
TProtoStringType* s);
// Inline because it is just forwarding to s->WriteVarint
inline void WriteVarint(arc_ui32 num, arc_ui64 val, UnknownFieldSet* s);
-inline void WriteLengthDelimited(arc_ui32 num, StringPiece val,
+inline void WriteLengthDelimited(arc_ui32 num, y_absl::string_view val,
UnknownFieldSet* s);
@@ -111,15 +116,14 @@ inline void WriteLengthDelimited(arc_ui32 num, StringPiece val,
class PROTOBUF_EXPORT EpsCopyInputStream {
public:
- enum { kSlopBytes = 16, kMaxCordBytesToCopy = 512 };
-
+ enum { kMaxCordBytesToCopy = 512 };
explicit EpsCopyInputStream(bool enable_aliasing)
: aliasing_(enable_aliasing ? kOnPatch : kNoAliasing) {}
void BackUp(const char* ptr) {
- GOOGLE_DCHECK(ptr <= buffer_end_ + kSlopBytes);
+ Y_ABSL_DCHECK(ptr <= buffer_end_ + kSlopBytes);
int count;
- if (next_chunk_ == buffer_) {
+ if (next_chunk_ == patch_buffer_) {
count = static_cast<int>(buffer_end_ + kSlopBytes - ptr);
} else {
count = size_ + static_cast<int>(buffer_end_ - ptr);
@@ -129,7 +133,7 @@ class PROTOBUF_EXPORT EpsCopyInputStream {
// If return value is negative it's an error
PROTOBUF_NODISCARD int PushLimit(const char* ptr, int limit) {
- GOOGLE_DCHECK(limit >= 0 && limit <= INT_MAX - kSlopBytes);
+ Y_ABSL_DCHECK(limit >= 0 && limit <= INT_MAX - kSlopBytes);
// This add is safe due to the invariant above, because
// ptr - buffer_end_ <= kSlopBytes.
limit += static_cast<int>(ptr - buffer_end_);
@@ -157,7 +161,13 @@ class PROTOBUF_EXPORT EpsCopyInputStream {
PROTOBUF_NODISCARD const char* ReadString(const char* ptr, int size,
TProtoStringType* s) {
if (size <= buffer_end_ + kSlopBytes - ptr) {
- s->assign(ptr, size);
+ // Fundamentally we just want to do assign to the string.
+ // However micro-benchmarks regress on string reading cases. So we copy
+ // the same logic from the old CodedInputStream ReadString. Note: as of
+ // Apr 2021, this is still a significant win over `assign()`.
+ y_absl::strings_internal::STLStringResizeUninitialized(s, size);
+ char* z = &(*s)[0];
+ memcpy(z, ptr, size);
return ptr + size;
}
return ReadStringFallback(ptr, size, s);
@@ -175,6 +185,17 @@ class PROTOBUF_EXPORT EpsCopyInputStream {
ArenaStringPtr* s,
Arena* arena);
+ PROTOBUF_NODISCARD const char* ReadCord(const char* ptr, int size,
+ ::y_absl::Cord* cord) {
+ if (size <= std::min<int>(static_cast<int>(buffer_end_ + kSlopBytes - ptr),
+ kMaxCordBytesToCopy)) {
+ *cord = y_absl::string_view(ptr, size);
+ return ptr + size;
+ }
+ return ReadCordFallback(ptr, size, cord);
+ }
+
+
template <typename Tag, typename T>
PROTOBUF_NODISCARD const char* ReadRepeatedFixed(const char* ptr,
Tag expected_tag,
@@ -204,6 +225,10 @@ class PROTOBUF_EXPORT EpsCopyInputStream {
int BytesUntilLimit(const char* ptr) const {
return limit_ + static_cast<int>(buffer_end_ - ptr);
}
+ // Maximum number of sequential bytes that can be read starting from `ptr`.
+ int MaximumReadSize(const char* ptr) const {
+ return static_cast<int>(limit_end_ - ptr) + kSlopBytes;
+ }
// Returns true if more data is available, if false is returned one has to
// call Done for further checks.
bool DataAvailable(const char* ptr) { return ptr < limit_end_; }
@@ -213,10 +238,10 @@ class PROTOBUF_EXPORT EpsCopyInputStream {
// reached. It aligns *ptr across buffer seams.
// If limit is exceeded it returns true and ptr is set to null.
bool DoneWithCheck(const char** ptr, int d) {
- GOOGLE_DCHECK(*ptr);
+ Y_ABSL_DCHECK(*ptr);
if (PROTOBUF_PREDICT_TRUE(*ptr < limit_end_)) return false;
int overrun = static_cast<int>(*ptr - buffer_end_);
- GOOGLE_DCHECK_LE(overrun, kSlopBytes); // Guaranteed by parse loop.
+ Y_ABSL_DCHECK_LE(overrun, kSlopBytes); // Guaranteed by parse loop.
if (overrun ==
limit_) { // No need to flip buffers if we ended on a limit.
// If we actually overrun the buffer and next_chunk_ is null. It means
@@ -229,26 +254,26 @@ class PROTOBUF_EXPORT EpsCopyInputStream {
return res.second;
}
- const char* InitFrom(StringPiece flat) {
+ const char* InitFrom(y_absl::string_view flat) {
overall_limit_ = 0;
if (flat.size() > kSlopBytes) {
limit_ = kSlopBytes;
limit_end_ = buffer_end_ = flat.data() + flat.size() - kSlopBytes;
- next_chunk_ = buffer_;
+ next_chunk_ = patch_buffer_;
if (aliasing_ == kOnPatch) aliasing_ = kNoDelta;
return flat.data();
} else {
if (!flat.empty()) {
- std::memcpy(buffer_, flat.data(), flat.size());
+ std::memcpy(patch_buffer_, flat.data(), flat.size());
}
limit_ = 0;
- limit_end_ = buffer_end_ = buffer_ + flat.size();
+ limit_end_ = buffer_end_ = patch_buffer_ + flat.size();
next_chunk_ = nullptr;
if (aliasing_ == kOnPatch) {
aliasing_ = reinterpret_cast<std::uintptr_t>(flat.data()) -
- reinterpret_cast<std::uintptr_t>(buffer_);
+ reinterpret_cast<std::uintptr_t>(patch_buffer_);
}
- return buffer_;
+ return patch_buffer_;
}
}
@@ -264,13 +289,19 @@ class PROTOBUF_EXPORT EpsCopyInputStream {
}
private:
+ enum { kSlopBytes = 16, kPatchBufferSize = 32 };
+ static_assert(kPatchBufferSize >= kSlopBytes * 2,
+ "Patch buffer needs to be at least large enough to hold all "
+ "the slop bytes from the previous buffer, plus the first "
+ "kSlopBytes from the next buffer.");
+
const char* limit_end_; // buffer_end_ + min(limit_, 0)
const char* buffer_end_;
const char* next_chunk_;
int size_;
int limit_; // relative to buffer_end_;
io::ZeroCopyInputStream* zcis_ = nullptr;
- char buffer_[2 * kSlopBytes] = {};
+ char patch_buffer_[kPatchBufferSize] = {};
enum { kNoAliasing = 0, kOnPatch = 1, kNoDelta = 2 };
std::uintptr_t aliasing_ = kNoAliasing;
// This variable is used to communicate how the parse ended, in order to
@@ -315,6 +346,8 @@ class PROTOBUF_EXPORT EpsCopyInputStream {
const char* SkipFallback(const char* ptr, int size);
const char* AppendStringFallback(const char* ptr, int size, TProtoStringType* str);
const char* ReadStringFallback(const char* ptr, int size, TProtoStringType* str);
+ const char* ReadCordFallback(const char* ptr, int size, y_absl::Cord* cord);
+ static bool ParseEndsInSlopRegion(const char* begin, int overrun, int depth);
bool StreamNext(const void** data) {
bool res = zcis_->Next(data, &size_);
if (res) overall_limit_ -= size_;
@@ -327,9 +360,9 @@ class PROTOBUF_EXPORT EpsCopyInputStream {
template <typename A>
const char* AppendSize(const char* ptr, int size, const A& append) {
- int chunk_size = buffer_end_ + kSlopBytes - ptr;
+ int chunk_size = static_cast<int>(buffer_end_ + kSlopBytes - ptr);
do {
- GOOGLE_DCHECK(size > chunk_size);
+ Y_ABSL_DCHECK(size > chunk_size);
if (next_chunk_ == nullptr) return nullptr;
append(ptr, chunk_size);
ptr += chunk_size;
@@ -341,7 +374,7 @@ class PROTOBUF_EXPORT EpsCopyInputStream {
ptr = Next();
if (ptr == nullptr) return nullptr; // passed the limit
ptr += kSlopBytes;
- chunk_size = buffer_end_ + kSlopBytes - ptr;
+ chunk_size = static_cast<int>(buffer_end_ + kSlopBytes - ptr);
} while (size > chunk_size);
append(ptr, size);
return ptr + size;
@@ -363,7 +396,7 @@ class PROTOBUF_EXPORT EpsCopyInputStream {
ptr += kSlopBytes;
}
auto end = buffer_end_ + limit_;
- GOOGLE_DCHECK(end >= ptr);
+ Y_ABSL_DCHECK(end >= ptr);
append(ptr, end - ptr);
return end;
}
@@ -374,6 +407,10 @@ class PROTOBUF_EXPORT EpsCopyInputStream {
ptr, [str](const char* p, ptrdiff_t s) { str->append(p, s); });
}
friend class ImplicitWeakMessage;
+
+ // Needs access to kSlopBytes.
+ friend PROTOBUF_EXPORT std::pair<const char*, arc_i32> ReadSizeFallback(
+ const char* p, arc_ui32 res);
};
using LazyEagerVerifyFnType = const char* (*)(const char* ptr,
@@ -389,7 +426,6 @@ class PROTOBUF_EXPORT ParseContext : public EpsCopyInputStream {
struct Data {
const DescriptorPool* pool = nullptr;
MessageFactory* factory = nullptr;
- Arena* arena = nullptr;
};
template <typename... T>
@@ -400,6 +436,8 @@ class PROTOBUF_EXPORT ParseContext : public EpsCopyInputStream {
void TrackCorrectEnding() { group_depth_ = 0; }
+ // Done should only be called when the parsing pointer is pointing to the
+ // beginning of field data - that is, at a tag. Or if it is NULL.
bool Done(const char** ptr) { return DoneWithCheck(ptr, group_depth_); }
int depth() const { return depth_; }
@@ -429,12 +467,49 @@ class PROTOBUF_EXPORT ParseContext : public EpsCopyInputStream {
bool>::type = true>
PROTOBUF_NODISCARD const char* ParseMessage(T* msg, const char* ptr);
+ template <typename TcParser, typename Table>
+ PROTOBUF_NODISCARD PROTOBUF_ALWAYS_INLINE const char* ParseMessage(
+ MessageLite* msg, const char* ptr, const Table* table) {
+ int old;
+ ptr = ReadSizeAndPushLimitAndDepthInlined(ptr, &old);
+ auto old_depth = depth_;
+ ptr = ptr ? TcParser::ParseLoop(msg, ptr, this, table) : nullptr;
+ if (ptr != nullptr) Y_ABSL_DCHECK_EQ(old_depth, depth_);
+ depth_++;
+ if (!PopLimit(old)) return nullptr;
+ return ptr;
+ }
+
template <typename T>
PROTOBUF_NODISCARD PROTOBUF_NDEBUG_INLINE const char* ParseGroup(
T* msg, const char* ptr, arc_ui32 tag) {
if (--depth_ < 0) return nullptr;
group_depth_++;
+ auto old_depth = depth_;
+ auto old_group_depth = group_depth_;
ptr = msg->_InternalParse(ptr, this);
+ if (ptr != nullptr) {
+ Y_ABSL_DCHECK_EQ(old_depth, depth_);
+ Y_ABSL_DCHECK_EQ(old_group_depth, group_depth_);
+ }
+ group_depth_--;
+ depth_++;
+ if (PROTOBUF_PREDICT_FALSE(!ConsumeEndGroup(tag))) return nullptr;
+ return ptr;
+ }
+
+ template <typename TcParser, typename Table>
+ PROTOBUF_NODISCARD PROTOBUF_ALWAYS_INLINE const char* ParseGroup(
+ MessageLite* msg, const char* ptr, arc_ui32 tag, const Table* table) {
+ if (--depth_ < 0) return nullptr;
+ group_depth_++;
+ auto old_depth = depth_;
+ auto old_group_depth = group_depth_;
+ ptr = TcParser::ParseLoop(msg, ptr, this, table);
+ if (ptr != nullptr) {
+ Y_ABSL_DCHECK_EQ(old_depth, depth_);
+ Y_ABSL_DCHECK_EQ(old_group_depth, group_depth_);
+ }
group_depth_--;
depth_++;
if (PROTOBUF_PREDICT_FALSE(!ConsumeEndGroup(tag))) return nullptr;
@@ -453,6 +528,11 @@ class PROTOBUF_EXPORT ParseContext : public EpsCopyInputStream {
PROTOBUF_NODISCARD const char* ReadSizeAndPushLimitAndDepth(const char* ptr,
int* old_limit);
+ // As above, but fully inlined for the cases where we care about performance
+ // more than size. eg TcParser.
+ PROTOBUF_NODISCARD PROTOBUF_ALWAYS_INLINE const char*
+ ReadSizeAndPushLimitAndDepthInlined(const char* ptr, int* old_limit);
+
// The context keeps an internal stack to keep track of the recursive
// part of the parse state.
// Current depth of the active parser, depth counts down.
@@ -536,21 +616,74 @@ inline const char* VarintParseSlow(const char* p, arc_ui32 res, arc_ui64* out) {
return tmp.first;
}
+#ifdef __aarch64__
+PROTOBUF_EXPORT
+const char* VarintParseSlowArm64(const char* p, arc_ui64* out, arc_ui64 first8);
+PROTOBUF_EXPORT
+const char* VarintParseSlowArm32(const char* p, arc_ui32* out, arc_ui64 first8);
+
+inline const char* VarintParseSlowArm(const char* p, arc_ui32* out,
+ arc_ui64 first8) {
+ return VarintParseSlowArm32(p, out, first8);
+}
+
+inline const char* VarintParseSlowArm(const char* p, arc_ui64* out,
+ arc_ui64 first8) {
+ return VarintParseSlowArm64(p, out, first8);
+}
+
+// Falsely indicate that the specific value is modified at this location. This
+// prevents code which depends on this value from being scheduled earlier.
+template <typename V1Type>
+PROTOBUF_ALWAYS_INLINE inline V1Type ValueBarrier(V1Type value1) {
+ asm("" : "+r"(value1));
+ return value1;
+}
+
+template <typename V1Type, typename V2Type>
+PROTOBUF_ALWAYS_INLINE inline V1Type ValueBarrier(V1Type value1,
+ V2Type value2) {
+ asm("" : "+r"(value1) : "r"(value2));
+ return value1;
+}
+
+// Performs a 7 bit UBFX (Unsigned Bit Extract) starting at the indicated bit.
+static PROTOBUF_ALWAYS_INLINE inline arc_ui64 Ubfx7(arc_ui64 data,
+ arc_ui64 start) {
+ return ValueBarrier((data >> start) & 0x7f);
+}
+
+#endif // __aarch64__
+
template <typename T>
PROTOBUF_NODISCARD const char* VarintParse(const char* p, T* out) {
+#if defined(__aarch64__) && defined(PROTOBUF_LITTLE_ENDIAN)
+ // This optimization is not supported in big endian mode
+ arc_ui64 first8;
+ std::memcpy(&first8, p, sizeof(first8));
+ if (PROTOBUF_PREDICT_TRUE((first8 & 0x80) == 0)) {
+ *out = static_cast<uint8_t>(first8);
+ return p + 1;
+ }
+ if (PROTOBUF_PREDICT_TRUE((first8 & 0x8000) == 0)) {
+ arc_ui64 chunk1;
+ arc_ui64 chunk2;
+ // Extracting the two chunks this way gives a speedup for this path.
+ chunk1 = Ubfx7(first8, 0);
+ chunk2 = Ubfx7(first8, 8);
+ *out = chunk1 | (chunk2 << 7);
+ return p + 2;
+ }
+ return VarintParseSlowArm(p, out, first8);
+#else // __aarch64__
auto ptr = reinterpret_cast<const uint8_t*>(p);
arc_ui32 res = ptr[0];
- if (!(res & 0x80)) {
+ if ((res & 0x80) == 0) {
*out = res;
return p + 1;
}
- arc_ui32 byte = ptr[1];
- res += (byte - 1) << 7;
- if (!(byte & 0x80)) {
- *out = res;
- return p + 2;
- }
return VarintParseSlow(p, res, out);
+#endif // __aarch64__
}
// Used for tags, could read up to 5 bytes which must be available.
@@ -592,6 +725,7 @@ PROTOBUF_NODISCARD PROTOBUF_ALWAYS_INLINE constexpr T RotateLeft(
PROTOBUF_NODISCARD inline PROTOBUF_ALWAYS_INLINE arc_ui64
RotRight7AndReplaceLowByte(arc_ui64 res, const char& byte) {
+ // TODO(b/239808098): remove the inline assembly
#if defined(__x86_64__) && defined(__GNUC__)
// This will only use one register for `res`.
// `byte` comes as a reference to allow the compiler to generate code like:
@@ -751,12 +885,28 @@ PROTOBUF_NODISCARD const char* ParseContext::ParseMessage(T* msg,
const char* ptr) {
int old;
ptr = ReadSizeAndPushLimitAndDepth(ptr, &old);
- ptr = ptr ? msg->_InternalParse(ptr, this) : nullptr;
+ if (ptr == nullptr) return ptr;
+ auto old_depth = depth_;
+ ptr = msg->_InternalParse(ptr, this);
+ if (ptr != nullptr) Y_ABSL_DCHECK_EQ(old_depth, depth_);
depth_++;
if (!PopLimit(old)) return nullptr;
return ptr;
}
+inline const char* ParseContext::ReadSizeAndPushLimitAndDepthInlined(
+ const char* ptr, int* old_limit) {
+ int size = ReadSize(&ptr);
+ if (PROTOBUF_PREDICT_FALSE(!ptr)) {
+ // Make sure this isn't uninitialized even on error return
+ *old_limit = 0;
+ return nullptr;
+ }
+ *old_limit = PushLimit(ptr, size);
+ if (--depth_ < 0) return nullptr;
+ return ptr;
+}
+
template <typename Tag, typename T>
const char* EpsCopyInputStream::ReadRepeatedFixed(const char* ptr,
Tag expected_tag,
@@ -774,7 +924,7 @@ const char* EpsCopyInputStream::ReadRepeatedFixed(const char* ptr,
#define GOOGLE_PROTOBUF_ASSERT_RETURN(predicate, ret) \
if (!(predicate)) { \
/* ::raise(SIGINT); */ \
- /* GOOGLE_LOG(ERROR) << "Parse failure"; */ \
+ /* Y_ABSL_LOG(ERROR) << "Parse failure"; */ \
return ret; \
}
@@ -785,7 +935,7 @@ template <typename T>
const char* EpsCopyInputStream::ReadPackedFixed(const char* ptr, int size,
RepeatedField<T>* out) {
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- int nbytes = buffer_end_ + kSlopBytes - ptr;
+ int nbytes = static_cast<int>(buffer_end_ + kSlopBytes - ptr);
while (size > nbytes) {
int num = nbytes / sizeof(T);
int old_entries = out->size();
@@ -803,14 +953,16 @@ const char* EpsCopyInputStream::ReadPackedFixed(const char* ptr, int size,
ptr = Next();
if (ptr == nullptr) return nullptr;
ptr += kSlopBytes - (nbytes - block_size);
- nbytes = buffer_end_ + kSlopBytes - ptr;
+ nbytes = static_cast<int>(buffer_end_ + kSlopBytes - ptr);
}
int num = size / sizeof(T);
+ int block_size = num * sizeof(T);
+ if (num == 0) return size == block_size ? ptr : nullptr;
int old_entries = out->size();
out->Reserve(old_entries + num);
- int block_size = num * sizeof(T);
auto dst = out->AddNAlreadyReserved(num);
#ifdef PROTOBUF_LITTLE_ENDIAN
+ Y_ABSL_CHECK(dst != nullptr) << out << "," << num;
std::memcpy(dst, ptr, block_size);
#else
for (int i = 0; i < num; i++) dst[i] = UnalignedLoad<T>(ptr + i * sizeof(T));
@@ -835,32 +987,32 @@ template <typename Add>
const char* EpsCopyInputStream::ReadPackedVarint(const char* ptr, Add add) {
int size = ReadSize(&ptr);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
- int chunk_size = buffer_end_ - ptr;
+ int chunk_size = static_cast<int>(buffer_end_ - ptr);
while (size > chunk_size) {
ptr = ReadPackedVarintArray(ptr, buffer_end_, add);
if (ptr == nullptr) return nullptr;
- int overrun = ptr - buffer_end_;
- GOOGLE_DCHECK(overrun >= 0 && overrun <= kSlopBytes);
+ int overrun = static_cast<int>(ptr - buffer_end_);
+ Y_ABSL_DCHECK(overrun >= 0 && overrun <= kSlopBytes);
if (size - chunk_size <= kSlopBytes) {
// The current buffer contains all the information needed, we don't need
// to flip buffers. However we must parse from a buffer with enough space
// so we are not prone to a buffer overflow.
char buf[kSlopBytes + 10] = {};
std::memcpy(buf, buffer_end_, kSlopBytes);
- GOOGLE_CHECK_LE(size - chunk_size, kSlopBytes);
+ Y_ABSL_CHECK_LE(size - chunk_size, kSlopBytes);
auto end = buf + (size - chunk_size);
auto res = ReadPackedVarintArray(buf + overrun, end, add);
if (res == nullptr || res != end) return nullptr;
return buffer_end_ + (res - buf);
}
size -= overrun + chunk_size;
- GOOGLE_DCHECK_GT(size, 0);
+ Y_ABSL_DCHECK_GT(size, 0);
// We must flip buffers
if (limit_ <= kSlopBytes) return nullptr;
ptr = Next();
if (ptr == nullptr) return nullptr;
ptr += overrun;
- chunk_size = buffer_end_ - ptr;
+ chunk_size = static_cast<int>(buffer_end_ - ptr);
}
auto end = ptr + size;
ptr = ReadPackedVarintArray(ptr, end, add);
@@ -869,7 +1021,7 @@ const char* EpsCopyInputStream::ReadPackedVarint(const char* ptr, Add add) {
// Helper for verification of utf8
PROTOBUF_EXPORT
-bool VerifyUTF8(StringPiece s, const char* field_name);
+bool VerifyUTF8(y_absl::string_view s, const char* field_name);
inline bool VerifyUTF8(const TProtoStringType* s, const char* field_name) {
return VerifyUTF8(*s, field_name);
@@ -911,7 +1063,7 @@ PROTOBUF_NODISCARD const char* FieldParser(arc_ui64 tag, T& field_parser,
break;
}
case WireType::WIRETYPE_END_GROUP: {
- GOOGLE_LOG(FATAL) << "Can't happen";
+ Y_ABSL_LOG(FATAL) << "Can't happen";
break;
}
case WireType::WIRETYPE_FIXED32: {
@@ -1022,6 +1174,6 @@ PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* UnknownFieldParse(
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_PARSE_CONTEXT_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/port.h b/contrib/libs/protobuf/src/google/protobuf/port.h
index 09e82c46ec1..d4eb4f1eb34 100644
--- a/contrib/libs/protobuf/src/google/protobuf/port.h
+++ b/contrib/libs/protobuf/src/google/protobuf/port.h
@@ -36,13 +36,83 @@
#ifndef GOOGLE_PROTOBUF_PORT_H__
#define GOOGLE_PROTOBUF_PORT_H__
+#include <cassert>
#include <cstddef>
+#include <cstdint>
#include <new>
+#include <util/generic/string.h>
+#include <type_traits>
+#if PROTOBUF_RTTI
+#include <typeinfo>
+#endif
+
+
+#include "y_absl/meta/type_traits.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/types/optional.h"
+
+// must be last
+#include "google/protobuf/port_def.inc"
+
+using TProtoStringType = TString;
namespace google {
namespace protobuf {
+
+class MessageLite;
+
namespace internal {
+
+
+// See comments on `AllocateAtLeast` for information on size returning new.
+struct SizedPtr {
+ void* p;
+ size_t n;
+};
+
+// Debug hook allowing setting up test scenarios for AllocateAtLeast usage.
+using AllocateAtLeastHookFn = SizedPtr (*)(size_t, void*);
+
+// `AllocAtLeastHook` API
+constexpr bool HaveAllocateAtLeastHook();
+void SetAllocateAtLeastHook(AllocateAtLeastHookFn fn, void* context = nullptr);
+
+#if !defined(NDEBUG) && defined(Y_ABSL_HAVE_THREAD_LOCAL) && \
+ defined(__cpp_inline_variables)
+
+// Hook data for current thread. These vars must not be accessed directly, use
+// the 'HaveAllocateAtLeastHook()` and `SetAllocateAtLeastHook()` API instead.
+inline thread_local AllocateAtLeastHookFn allocate_at_least_hook = nullptr;
+inline thread_local void* allocate_at_least_hook_context = nullptr;
+
+constexpr bool HaveAllocateAtLeastHook() { return true; }
+inline void SetAllocateAtLeastHook(AllocateAtLeastHookFn fn, void* context) {
+ allocate_at_least_hook = fn;
+ allocate_at_least_hook_context = context;
+}
+
+#else // !NDEBUG && Y_ABSL_HAVE_THREAD_LOCAL && __cpp_inline_variables
+
+constexpr bool HaveAllocateAtLeastHook() { return false; }
+inline void SetAllocateAtLeastHook(AllocateAtLeastHookFn fn, void* context) {}
+
+#endif // !NDEBUG && Y_ABSL_HAVE_THREAD_LOCAL && __cpp_inline_variables
+
+// Allocates at least `size` bytes. This function follows the c++ language
+// proposal from D0901R10 (http://wg21.link/D0901R10) and will be implemented
+// in terms of the new operator new semantics when available. The allocated
+// memory should be released by a call to `SizedDelete` or `::operator delete`.
+inline SizedPtr AllocateAtLeast(size_t size) {
+#if !defined(NDEBUG) && defined(Y_ABSL_HAVE_THREAD_LOCAL) && \
+ defined(__cpp_inline_variables)
+ if (allocate_at_least_hook != nullptr) {
+ return allocate_at_least_hook(size, allocate_at_least_hook_context);
+ }
+#endif // !NDEBUG && Y_ABSL_HAVE_THREAD_LOCAL && __cpp_inline_variables
+ return {::operator new(size), size};
+}
+
inline void SizedDelete(void* p, size_t size) {
#if defined(__cpp_sized_deallocation)
::operator delete(p, size);
@@ -77,8 +147,82 @@ struct ArenaInitialized {
explicit ArenaInitialized() = default;
};
+template <typename To, typename From>
+inline To DownCast(From* f) {
+ static_assert(
+ std::is_base_of<From, typename std::remove_pointer<To>::type>::value,
+ "illegal DownCast");
+
+#if PROTOBUF_RTTI
+ // RTTI: debug mode only!
+ assert(f == nullptr || dynamic_cast<To>(f) != nullptr);
+#endif
+ return static_cast<To>(f);
+}
+
+template <typename ToRef, typename From>
+inline ToRef DownCast(From& f) {
+ using To = typename std::remove_reference<ToRef>::type;
+ static_assert(std::is_base_of<From, To>::value, "illegal DownCast");
+
+#if PROTOBUF_RTTI
+ // RTTI: debug mode only!
+ assert(dynamic_cast<To*>(&f) != nullptr);
+#endif
+ return *static_cast<To*>(&f);
+}
+
+// Looks up the name of `T` via RTTI, if RTTI is available.
+template <typename T>
+inline y_absl::optional<y_absl::string_view> RttiTypeName() {
+#if PROTOBUF_RTTI
+ return typeid(T).name();
+#else
+ return y_absl::nullopt;
+#endif
+}
+
+// Helpers for identifying our supported types.
+template <typename T>
+struct is_supported_integral_type
+ : y_absl::disjunction<std::is_same<T, arc_i32>, std::is_same<T, arc_ui32>,
+ std::is_same<T, arc_i64>, std::is_same<T, arc_ui64>,
+ std::is_same<T, bool>> {};
+
+template <typename T>
+struct is_supported_floating_point_type
+ : y_absl::disjunction<std::is_same<T, float>, std::is_same<T, double>> {};
+
+template <typename T>
+struct is_supported_string_type
+ : y_absl::disjunction<std::is_same<T, TProtoStringType>> {};
+
+template <typename T>
+struct is_supported_scalar_type
+ : y_absl::disjunction<is_supported_integral_type<T>,
+ is_supported_floating_point_type<T>,
+ is_supported_string_type<T>> {};
+
+template <typename T>
+struct is_supported_message_type
+ : y_absl::disjunction<std::is_base_of<MessageLite, T>> {
+ static constexpr auto force_complete_type = sizeof(T);
+};
+
+// To prevent sharing cache lines between threads
+#ifdef __cpp_aligned_new
+enum { kCacheAlignment = 64 };
+#else
+enum { kCacheAlignment = alignof(max_align_t) }; // do the best we can
+#endif
+
+// The maximum byte alignment we support.
+enum { kMaxMessageAlignment = 8 };
+
} // namespace internal
} // namespace protobuf
} // namespace google
+#include "google/protobuf/port_undef.inc"
+
#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 b4d7fbe2787..09f108a2f98 100644
--- a/contrib/libs/protobuf/src/google/protobuf/port_def.inc
+++ b/contrib/libs/protobuf/src/google/protobuf/port_def.inc
@@ -1,3 +1,4 @@
+// -*- c++ -*-
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
@@ -118,6 +119,15 @@
#define PROTOBUF_has_builtin_DEFINED_
#endif
+#ifdef ADDRESS_SANITIZER
+#include <sanitizer/asan_interface.h>
+#define PROTOBUF_POISON_MEMORY_REGION(p, n) ASAN_POISON_MEMORY_REGION(p, n)
+#define PROTOBUF_UNPOISON_MEMORY_REGION(p, n) ASAN_UNPOISON_MEMORY_REGION(p, n)
+#else // ADDRESS_SANITIZER
+#define PROTOBUF_POISON_MEMORY_REGION(p, n)
+#define PROTOBUF_UNPOISON_MEMORY_REGION(p, n)
+#endif // ADDRESS_SANITIZER
+
// Portable PROTOBUF_BUILTIN_BSWAPxx definitions
// Code must check for availability, e.g.: `defined(PROTOBUF_BUILTIN_BSWAP32)`
#ifdef PROTOBUF_BUILTIN_BSWAP16
@@ -139,16 +149,28 @@
#define PROTOBUF_BUILTIN_BSWAP64(x) __builtin_bswap64(x)
#endif
+// Portable check for gcc-style atomic built-ins
+#if __has_builtin(__atomic_load_n)
+#define PROTOBUF_BUILTIN_ATOMIC 1
+#endif
+
// Portable check for GCC minimum version:
// https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
#if defined(__GNUC__) && defined(__GNUC_MINOR__) \
&& defined(__GNUC_PATCHLEVEL__)
# define PROTOBUF_GNUC_MIN(x, y) \
- (__GNUC__ > (x) || __GNUC__ == (x) && __GNUC_MINOR__ >= (y))
+ (__GNUC__ > (x) || (__GNUC__ == (x) && __GNUC_MINOR__ >= (y)))
#else
# define PROTOBUF_GNUC_MIN(x, y) 0
#endif
+#if defined(__clang__) && defined(__clang_major__) && defined(__clang_minor__)
+#define PROTOBUF_CLANG_MIN(x, y) \
+ (__clang_major__ > (x) || (__clang_major__ == (x) && __clang_minor__ >= (y)))
+#else
+#define PROTOBUF_CLANG_MIN(x, y) 0
+#endif
+
// Portable check for MSVC minimum version:
// https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros
#if defined(_MSC_VER)
@@ -166,29 +188,47 @@
#define PROTOBUF_CPLUSPLUS_MIN(x) (_MSVC_LANG >= x)
#endif
+// Check minimum Protobuf support defined at:
+// https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md
+#ifdef __clang__
+static_assert(PROTOBUF_CLANG_MIN(6, 0), "Protobuf only supports Clang 6.0 and newer.");
+#elif defined(__GNUC__)
+static_assert(PROTOBUF_GNUC_MIN(7, 3), "Protobuf only supports GCC 7.3 and newer.");
+#elif defined(_MSVC_LANG)
+static_assert(PROTOBUF_MSC_VER_MIN(1910), "Protobuf only supports MSVC 2017 and newer.");
+#endif
+static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and newer.");
+
// 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_FUTURE_BREAKING_CHANGES
+
+// Used to remove the manipulation of cleared elements in RepeatedPtrField.
+// Owner: mkruskal@
+#define PROTOBUF_FUTURE_REMOVE_CLEARED_API 1
+
+// Used for descriptor proto extension declarations.
+// Owner: shaod@, gberg@
+#define PROTOBUF_FUTURE_DESCRIPTOR_EXTENSION_DECL 1
+
+#endif
#ifdef PROTOBUF_VERSION
#error PROTOBUF_VERSION was previously defined
#endif
-#define PROTOBUF_VERSION 3021003
+#define PROTOBUF_VERSION 4022005
#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 3021000
+#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 4022000
#ifdef PROTOBUF_MIN_PROTOC_VERSION
#error PROTOBUF_MIN_PROTOC_VERSION was previously defined
#endif
-#define PROTOBUF_MIN_PROTOC_VERSION 3021000
+#define PROTOBUF_MIN_PROTOC_VERSION 4022000
#ifdef PROTOBUF_VERSION_SUFFIX
#error PROTOBUF_VERSION_SUFFIX was previously defined
@@ -213,7 +253,7 @@
// For functions we want to force inline.
#if defined(PROTOBUF_NO_INLINE)
# define PROTOBUF_ALWAYS_INLINE
-#elif PROTOBUF_GNUC_MIN(3, 1)
+#elif defined(__GNUC__)
# define PROTOBUF_ALWAYS_INLINE __attribute__((always_inline))
#elif defined(_MSC_VER)
# define PROTOBUF_ALWAYS_INLINE __forceinline
@@ -241,7 +281,7 @@
#ifdef PROTOBUF_NOINLINE
#error PROTOBUF_NOINLINE was previously defined
#endif
-#if PROTOBUF_GNUC_MIN(3, 1)
+#if defined(__GNUC__)
# define PROTOBUF_NOINLINE __attribute__((noinline))
#elif defined(_MSC_VER)
// Seems to have been around since at least Visual Studio 2005
@@ -254,9 +294,9 @@
#ifdef PROTOBUF_TAILCALL
#error PROTOBUF_TAILCALL was previously defined
#endif
-#if __has_cpp_attribute(clang::musttail) && !defined(__arm__) && \
- !defined(_ARCH_PPC) && !defined(__wasm__) && \
- !(defined(_MSC_VER) && defined(_M_IX86)) && \
+#if __has_cpp_attribute(clang::musttail) && !defined(__arm__) && \
+ !defined(_ARCH_PPC) && !defined(__wasm__) && \
+ !(defined(_MSC_VER) && defined(_M_IX86)) && !defined(__i386__) && \
!(defined(__NDK_MAJOR__) && __NDK_MAJOR <= 24)
# ifndef PROTO2_OPENSOURCE
// Compilation fails on ARM32: b/195943306
@@ -313,7 +353,7 @@
#ifdef PROTOBUF_COLD
#error PROTOBUF_COLD was previously defined
#endif
-#if __has_attribute(cold) || PROTOBUF_GNUC_MIN(4, 3)
+#if __has_attribute(cold) || defined(__GNUC__)
# define PROTOBUF_COLD __attribute__((cold))
#else
# define PROTOBUF_COLD
@@ -343,19 +383,38 @@
#endif
# define PROTOBUF_DEPRECATED_ENUM
-#ifdef PROTOBUF_FUNC_ALIGN
-#error PROTOBUF_FUNC_ALIGN was previously defined
+// External libs can define New macro, but absl will broke...
+#ifdef New
+#undef New
+#endif
+#ifdef Poison
+#undef Poison
#endif
-#if __has_attribute(aligned) || PROTOBUF_GNUC_MIN(4, 3)
-#define PROTOBUF_FUNC_ALIGN(bytes) __attribute__((aligned(bytes)))
+#ifdef rename
+#undef rename
+#endif
+
+#if defined(__clang__)
+#define PROTOBUF_IGNORE_DEPRECATION_START \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
+#define PROTOBUF_IGNORE_DEPRECATION_STOP \
+ _Pragma("clang diagnostic pop")
+#elif defined(__GNUC__)
+#define PROTOBUF_IGNORE_DEPRECATION_START \
+ _Pragma("GCC diagnostic push") \
+ _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
+#define PROTOBUF_IGNORE_DEPRECATION_STOP \
+ _Pragma("GCC diagnostic pop")
#else
-#define PROTOBUF_FUNC_ALIGN(bytes)
+#define PROTOBUF_IGNORE_DEPRECATION_START
+#define PROTOBUF_IGNORE_DEPRECATION_STOP
#endif
#ifdef PROTOBUF_RETURNS_NONNULL
#error PROTOBUF_RETURNS_NONNULL was previously defined
#endif
-#if __has_attribute(returns_nonnull) || PROTOBUF_GNUC_MIN(4, 9)
+#if __has_attribute(returns_nonnull) || defined(__GNUC__)
#define PROTOBUF_RETURNS_NONNULL __attribute__((returns_nonnull))
#else
#define PROTOBUF_RETURNS_NONNULL
@@ -372,7 +431,7 @@
// The minimum library version which works with the current version of the
// headers.
-#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3021000
+#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 4022000
#ifdef PROTOBUF_RTTI
#error PROTOBUF_RTTI was previously defined
@@ -416,7 +475,7 @@
_Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
__builtin_offsetof(TYPE, FIELD) \
_Pragma("clang diagnostic pop")
-#elif PROTOBUF_GNUC_MIN(4, 8)
+#elif defined(__GNUC__)
#define PROTOBUF_FIELD_OFFSET(TYPE, FIELD) __builtin_offsetof(TYPE, FIELD)
#else // defined(__clang__)
// Note that we calculate relative to the pointer value 16 here since if we
@@ -472,7 +531,7 @@
#if defined(PROTOBUF_PREDICT_TRUE) || defined(PROTOBUF_PREDICT_FALSE)
#error PROTOBUF_PREDICT_(TRUE|FALSE) was previously defined
#endif
-#if PROTOBUF_GNUC_MIN(3, 0)
+#if defined(__GNUC__)
# define PROTOBUF_PREDICT_TRUE(x) (__builtin_expect(false || (x), true))
# define PROTOBUF_PREDICT_FALSE(x) (__builtin_expect(false || (x), false))
#else
@@ -485,18 +544,20 @@
#endif
#if __has_cpp_attribute(nodiscard) && PROTOBUF_CPLUSPLUS_MIN(201703L)
#define PROTOBUF_NODISCARD [[nodiscard]]
-#elif __has_attribute(warn_unused_result) || PROTOBUF_GNUC_MIN(4, 8)
+#elif __has_attribute(warn_unused_result) || defined(__GNUC__)
#define PROTOBUF_NODISCARD __attribute__((warn_unused_result))
#else
#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_RESTRICT
+#error PROTOBUF_RESTRICT was previously defined
+#endif
+#if defined( __clang__) || defined(__GNUC__)
+#define PROTOBUF_RESTRICT __restrict
+#else
+#define PROTOBUF_RESTRICT
+#endif
#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE
#error PROTOBUF_FORCE_COPY_IN_RELEASE was previously defined
@@ -514,12 +575,20 @@
#error PROTOBUF_FORCE_RESET_IN_CLEAR was previously defined
#endif
+#ifdef PROTOBUF_FUZZ_MESSAGE_SPACE_USED_LONG
+#error PROTOBUF_FUZZ_MESSAGE_SPACE_USED_LONG was previously defined
+#endif
+
// Force copy the default string to a string field so that non-optimized builds
// have harder-to-rely-on address stability.
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
#error PROTOBUF_FORCE_COPY_DEFAULT_STRING was previously defined
#endif
+#ifdef PROTOBUF_FORCE_ALLOCATION_ON_CONSTRUCTION
+#error PROTOBUF_FORCE_ALLOCATION_ON_CONSTRUCTION was previously defined
+#endif
+
#ifdef PROTOBUF_FALLTHROUGH_INTENDED
#error PROTOBUF_FALLTHROUGH_INTENDED was previously defined
#endif
@@ -527,14 +596,14 @@
#define PROTOBUF_FALLTHROUGH_INTENDED [[fallthrough]]
#elif __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
#define PROTOBUF_FALLTHROUGH_INTENDED [[clang::fallthrough]]
-#elif PROTOBUF_GNUC_MIN(7, 0)
+#elif defined(__GNUC__)
#define PROTOBUF_FALLTHROUGH_INTENDED [[gnu::fallthrough]]
#else
#define PROTOBUF_FALLTHROUGH_INTENDED
#endif
// PROTOBUF_ASSUME(pred) tells the compiler that it can assume pred is true. To
-// be safe, we also validate the assumption with a GOOGLE_DCHECK in unoptimized
+// be safe, we also validate the assumption with a Y_ABSL_DCHECK in unoptimized
// builds. The macro does not do anything useful if the compiler does not
// support __builtin_assume.
#ifdef PROTOBUF_ASSUME
@@ -542,10 +611,10 @@
#endif
#if __has_builtin(__builtin_assume)
#define PROTOBUF_ASSUME(pred) \
- GOOGLE_DCHECK(pred); \
+ Y_ABSL_DCHECK(pred); \
__builtin_assume(pred)
#else
-#define PROTOBUF_ASSUME(pred) GOOGLE_DCHECK(pred)
+#define PROTOBUF_ASSUME(pred) Y_ABSL_DCHECK(pred)
#endif
// Specify memory alignment for structs, classes, etc.
@@ -574,7 +643,7 @@
#endif
#if defined(_MSC_VER)
#define PROTOBUF_ALIGNAS(byte_alignment) __declspec(align(byte_alignment))
-#elif PROTOBUF_GNUC_MIN(3, 0)
+#elif defined(__GNUC__)
#define PROTOBUF_ALIGNAS(byte_alignment) \
__attribute__((aligned(byte_alignment)))
#else
@@ -611,41 +680,38 @@
#error "endian detection failed for current compiler"
#endif
-// For enabling message owned arena, one major blocker is semantic change from
-// moving to copying when there is ownership transfer (e.g., move ctor, swap,
-// set allocated, release). This change not only causes performance regression
-// but also breaks users code (e.g., dangling reference). For top-level
-// messages, since it owns the arena, we can mitigate the issue by transferring
-// ownership of arena. However, we cannot do that for nested messages. In order
-// to tell how many usages of nested messages affected by message owned arena,
-// we need to simulate the arena ownership.
-// This experiment is purely for the purpose of gathering data. All code guarded
-// by this flag is supposed to be removed after this experiment.
-#define PROTOBUF_MESSAGE_OWNED_ARENA_EXPERIMENT
#ifdef PROTOBUF_CONSTINIT
#error PROTOBUF_CONSTINIT was previously defined
#endif
-#if defined(__cpp_constinit) && !defined(_MSC_VER)
-#define PROTOBUF_CONSTINIT constinit
-#define PROTOBUF_CONSTEXPR constexpr
+
+// Lexan sets both MSV_VER and clang, so handle it with the clang path.
+#if defined(_MSC_VER) && !defined(__clang__)
+// MSVC 17 currently seems to raise an error about constant-initialized pointers.
+# if PROTOBUF_MSC_VER_MIN(1930)
+# define PROTOBUF_CONSTINIT
+# define PROTOBUF_CONSTEXPR constexpr
+# endif
+#else
+# if defined(__cpp_constinit) && !defined(__CYGWIN__)
+# define PROTOBUF_CONSTINIT constinit
+# 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.
-// Clang-cl on Windows raises error also.
-#elif !defined(_MSC_VER) && __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, 2)
-#define PROTOBUF_CONSTINIT __constinit
-#define PROTOBUF_CONSTEXPR constexpr
-// MSVC 17 currently seems to raise an error about constant-initialized pointers.
-#elif defined(_MSC_VER) && _MSC_VER >= 1930
-#define PROTOBUF_CONSTINIT
-#define PROTOBUF_CONSTEXPR constexpr
-#else
+# elif !defined(__CYGWIN__) && \
+ __has_cpp_attribute(clang::require_constant_initialization) && \
+ ((defined(__APPLE__) && PROTOBUF_CLANG_MIN(13, 0)) || \
+ (!defined(__APPLE__) && PROTOBUF_CLANG_MIN(12, 0)))
+# define PROTOBUF_CONSTINIT [[clang::require_constant_initialization]]
+# define PROTOBUF_CONSTEXPR constexpr
+# elif PROTOBUF_GNUC_MIN(12, 2)
+# define PROTOBUF_CONSTINIT __constinit
+# define PROTOBUF_CONSTEXPR constexpr
+# endif
+#endif
+
+#ifndef PROTOBUF_CONSTINIT
#define PROTOBUF_CONSTINIT
#define PROTOBUF_CONSTEXPR
#endif
@@ -691,7 +757,7 @@
#ifdef PROTOBUF_ATTRIBUTE_INIT_PRIORITY2
#error PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 was previously defined
#endif
-#if PROTOBUF_GNUC_MIN(3, 0) && (!defined(__APPLE__) || defined(__clang__)) && \
+#if defined(__GNUC__) && (!defined(__APPLE__) || defined(__clang__)) && \
!((defined(sun) || defined(__sun)) && \
(defined(__SVR4) || defined(__svr4__)))
#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 __attribute__((init_priority((101))))
@@ -744,7 +810,7 @@
# if __has_feature(memory_sanitizer)
# define PROTOBUF_MSAN 1
# endif
-#elif PROTOBUF_GNUC_MIN(3, 0)
+#elif defined(__GNUC__)
// Double-guard is needed for -Wundef:
# ifdef __SANITIZE_ADDRESS__
# if __SANITIZE_ADDRESS__
@@ -758,21 +824,35 @@
# endif
#endif
-// Tail call table-driven parsing can be enabled by defining
-// PROTOBUF_EXPERIMENTAL_USE_TAIL_CALL_TABLE_PARSER at compilation time. Note
-// that this macro is for small-scale testing only, and is not supported.
+// Tail call table-driven parsing is enabled by default.
#ifdef PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED
#error PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED was previously declared
#endif
-#if defined(PROTOBUF_EXPERIMENTAL_USE_TAIL_CALL_TABLE_PARSER)
#define PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED 1
+
+#ifdef PROTOBUF_USE_TABLE_PARSER_ON_REFLECTION
+#error PROTOBUF_USE_TABLE_PARSER_ON_REFLECTION was previously defined
#endif
+#if !defined(PROTOBUF_TEMPORARY_DISABLE_TABLE_PARSER_ON_REFLECTION)
+#define PROTOBUF_USE_TABLE_PARSER_ON_REFLECTION 1
+#endif // PROTOBUF_ENABLE_FORCE_ALLOCATION_ON_CONSTRUCTION
-#define PROTOBUF_TC_PARAM_DECL \
- ::google::protobuf::MessageLite *msg, const char *ptr, \
- ::google::protobuf::internal::ParseContext *ctx, \
- const ::google::protobuf::internal::TcParseTableBase *table, \
- arc_ui64 hasbits, ::google::protobuf::internal::TcFieldData data
+// Note that this is performance sensitive: changing the parameters will change
+// the registers used by the ABI calling convention, which subsequently affects
+// register selection logic inside the function.
+// Arguments `msg`, `ptr` and `ctx` are the 1st/2nd/3rd argument to match the
+// signature of ParseLoop.
+//
+// Note for x86_64: `data` must be the third or fourth argument for performance
+// reasons. In order to efficiently read the second byte of `data` we need it to
+// be passed in RDX or RCX.
+#define PROTOBUF_TC_PARAM_DECL \
+ ::google::protobuf::MessageLite *msg, const char *ptr, \
+ ::google::protobuf::internal::ParseContext *ctx, \
+ ::google::protobuf::internal::TcFieldData data, \
+ const ::google::protobuf::internal::TcParseTableBase *table, arc_ui64 hasbits
+// PROTOBUF_TC_PARAM_PASS passes values to match PROTOBUF_TC_PARAM_DECL.
+#define PROTOBUF_TC_PARAM_PASS msg, ptr, ctx, data, table, hasbits
#ifdef PROTOBUF_UNUSED
#error PROTOBUF_UNUSED was previously defined
@@ -780,7 +860,7 @@
#if __has_cpp_attribute(maybe_unused) || \
(PROTOBUF_MSC_VER_MIN(1911) && PROTOBUF_CPLUSPLUS_MIN(201703L))
#define PROTOBUF_UNUSED [[maybe_unused]]
-#elif __has_attribute(unused) || PROTOBUF_GNUC_MIN(3, 0)
+#elif __has_attribute(unused) || defined(__GNUC__)
#define PROTOBUF_UNUSED __attribute__((__unused__))
#else
#define PROTOBUF_UNUSED
@@ -788,13 +868,36 @@
// ThreadSafeArenaz is turned off completely in opensource builds.
+// autoheader defines this in some circumstances
+#ifdef PACKAGE
+#define PROTOBUF_DID_UNDEF_PACKAGE
+#pragma push_macro("PACKAGE")
+#undef PACKAGE
+#endif
+
+// autoheader defines this in some circumstances
+#ifdef PACKAGE
+#define PROTOBUF_DID_UNDEF_PACKAGE
+#pragma push_macro("PACKAGE")
+#undef PACKAGE
+#endif
+
+// linux is a legacy MACRO defined in most popular C++ standards.
+#ifdef linux
+#pragma push_macro("linux")
+#undef linux
+#define PROTOBUF_DID_UNDEF_LINUX
+#endif
+
// Windows declares several inconvenient macro names. We #undef them and then
// restore them in port_undef.inc.
-#ifdef _MSC_VER
+#ifdef _WIN32
#pragma push_macro("CREATE_NEW")
#undef CREATE_NEW
#pragma push_macro("DELETE")
#undef DELETE
+#pragma push_macro("DOMAIN")
+#undef DOMAIN
#pragma push_macro("DOUBLE_CLICK")
#undef DOUBLE_CLICK
#pragma push_macro("ERROR")
@@ -807,6 +910,8 @@
#undef ERROR_NOT_FOUND
#pragma push_macro("GetClassName")
#undef GetClassName
+#pragma push_macro("GetCurrentTime")
+#undef GetCurrentTime
#pragma push_macro("GetMessage")
#undef GetMessage
#pragma push_macro("GetObject")
@@ -843,7 +948,11 @@
#undef STRICT
#pragma push_macro("timezone")
#undef timezone
-#endif // _MSC_VER
+#pragma push_macro("TRUE")
+#undef TRUE
+#pragma push_macro("FALSE")
+#undef FALSE
+#endif // _WIN32
#ifdef __APPLE__
// Inconvenient macro names from usr/include/math.h in some macOS SDKs.
@@ -857,32 +966,73 @@
// Inconvenient macro names from usr/include/sys/syslimits.h in some macOS SDKs.
#pragma push_macro("UID_MAX")
#undef UID_MAX
+#pragma push_macro("GID_MAX")
+#undef GID_MAX
+// TYPE_BOOL is defined in the MacOS's ConditionalMacros.h.
+#pragma push_macro("TYPE_BOOL")
+#undef TYPE_BOOL
#endif // __APPLE__
-#if defined(__clang__) || PROTOBUF_GNUC_MIN(3, 0) || defined(_MSC_VER)
+#if defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER)
// Don't let Objective-C Macros interfere with proto identifiers with the same
// name.
#pragma push_macro("DEBUG")
#undef DEBUG
-#endif // defined(__clang__) || PROTOBUF_GNUC_MIN(3, 0) || defined(_MSC_VER)
+#endif // defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER)
-#if defined(__clang__)
+// Protobuf does not support building with a number of warnings that are noisy
+// (and of variable quality across compiler versions) or impossible to implement
+// effectively but which people turn on anyways.
+#ifdef __clang__
#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wunused-parameter"
+// -Wshorten-64-to-32 is a typical pain where we diff pointers.
+// char* p = strchr(s, '\n');
+// return p ? p - s : -1;
#pragma clang diagnostic ignored "-Wshorten-64-to-32"
-#endif // defined(__clang__)
-#if PROTOBUF_GNUC_MIN(3, 0)
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#pragma GCC diagnostic ignored "-Wshorten-64-to-32"
-#endif // PROTOBUF_GNUC_MIN(3, 0)
-
-#if PROTOBUF_GNUC_MIN(3, 0)
+// Turn on -Wdeprecated-enum-enum-conversion. This deprecation comes in C++20
+// via http://wg21.link/p1120r0.
+// #pragma clang diagnostic error "-Wdeprecated-enum-enum-conversion"
+// This error has been generally flaky, but we need to disable it specifically
+// to fix https://github.com/protocolbuffers/protobuf/issues/12313
+#pragma clang diagnostic ignored "-Wunused-parameter"
+#pragma clang diagnostic ignored "-Wswitch-enum"
+#endif
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+// Some of the warnings below only exist in some GCC versions; those version
+// ranges are poorly documented.
+#pragma GCC diagnostic ignored "-Wpragmas"
// 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"
+// Some versions of GCC seem to think that
+// [this] { Foo(); }
+// leaves `this` unused, even though `Foo();` is a member function of the
+// captured `this`.
+// https://bugzilla.mozilla.org/show_bug.cgi?id=1373625
+#pragma GCC diagnostic ignored "-Wunused-lambda-capture"
+// -Wsign-conversion causes a lot of warnings on mostly code like:
+// int index = ...
+// int value = vec[index];
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+// This error has been generally flaky, but we need to disable it specifically
+// to fix https://github.com/protocolbuffers/protobuf/issues/12313
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#ifndef __clang__
+// This causes spurious warnings in GCC 13.
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+// This causes spurious warnings in GCC 13.
+#pragma GCC diagnostic ignored "-Wself-move"
+#endif
+#if __GNUC__ == 12 && __GNUC_MINOR__ < 4
+// Wrong warning emitted when assigning a single char c-string to a TProtoStringType
+// in c++20 mode and optimization on.
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105329
+// Planned to be fixed by 12.3 but widen window to 12.4.
+#pragma GCC diagnostic ignored "-Wrestrict"
#endif
+#endif // __GNUC__
// Silence some MSVC warnings in all our code.
#ifdef _MSC_VER
@@ -900,6 +1050,27 @@
#pragma warning(disable: 4125)
#endif
+#if PROTOBUF_ENABLE_DEBUG_LOGGING_MAY_LEAK_PII
+#define PROTOBUF_DEBUG true
+#else
+#define PROTOBUF_DEBUG false
+#endif
+
+// This `for` allows us to condition the `Y_ABSL_LOG` on the define above, so that
+// code can write `PROTOBUF_DLOG(INFO) << ...;` and have it turned off when
+// debug logging is off.
+//
+// This is a `for`, not and `if`, to avoid it accidentally chaining with an
+// `else` below it.
+#define PROTOBUF_DLOG(x) \
+ for (bool b = PROTOBUF_DEBUG; b; b = false) Y_ABSL_LOG(x)
+
+#define PROTO2_IS_OSS true
+
+#ifdef PROTOBUF_NO_THREADLOCAL
+#error PROTOBUF_NO_THREADLOCAL was previously defined
+#endif
+
// We don't want code outside port_def doing complex testing, so
// remove our portable condition test macros to nudge folks away from
// using it themselves.
diff --git a/contrib/libs/protobuf/src/google/protobuf/port_undef.inc b/contrib/libs/protobuf/src/google/protobuf/port_undef.inc
index 042a75a7d3b..a0a5f648df4 100644
--- a/contrib/libs/protobuf/src/google/protobuf/port_undef.inc
+++ b/contrib/libs/protobuf/src/google/protobuf/port_undef.inc
@@ -1,3 +1,4 @@
+// -*- c++ -*-
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
@@ -35,10 +36,14 @@
#error "port_undef.inc must be included after port_def.inc"
#endif
+#undef PROTOBUF_POISON_MEMORY_REGION
+#undef PROTOBUF_UNPOISON_MEMORY_REGION
#undef PROTOBUF_BUILTIN_BSWAP16
#undef PROTOBUF_BUILTIN_BSWAP32
#undef PROTOBUF_BUILTIN_BSWAP64
+#undef PROTOBUF_BUILTIN_ATOMIC
#undef PROTOBUF_GNUC_MIN
+#undef PROTOBUF_CLANG_MIN
#undef PROTOBUF_MSC_VER_MIN
#undef PROTOBUF_CPLUSPLUS_MIN
#undef PROTOBUF_NAMESPACE
@@ -53,7 +58,8 @@
#undef PROTOBUF_DEPRECATED
#undef PROTOBUF_DEPRECATED_ENUM
#undef PROTOBUF_DEPRECATED_MSG
-#undef PROTOBUF_FUNC_ALIGN
+#undef PROTOBUF_IGNORE_DEPRECATION_START
+#undef PROTOBUF_IGNORE_DEPRECATION_STOP
#undef PROTOBUF_RETURNS_NONNULL
#undef PROTOBUF_ATTRIBUTE_REINITIALIZES
#undef PROTOBUF_RTTI
@@ -68,11 +74,14 @@
#undef PROTOBUF_EXPORT
#undef PROTOC_EXPORT
#undef PROTOBUF_NODISCARD
+#undef PROTOBUF_RESTRICT
#undef PROTOBUF_FORCE_COPY_IN_RELEASE
#undef PROTOBUF_FORCE_COPY_IN_SWAP
#undef PROTOBUF_FORCE_COPY_IN_MOVE
#undef PROTOBUF_FORCE_RESET_IN_CLEAR
+#undef PROTOBUF_FUZZ_MESSAGE_SPACE_USED_LONG
#undef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+#undef PROTOBUF_FORCE_ALLOCATION_ON_CONSTRUCTION
#undef PROTOBUF_NAMESPACE_OPEN
#undef PROTOBUF_NAMESPACE_CLOSE
#undef PROTOBUF_UNUSED
@@ -81,11 +90,9 @@
#undef PROTOBUF_EXPORT_TEMPLATE_DEFINE
#undef PROTOBUF_ALIGNAS
#undef PROTOBUF_FINAL
-#undef PROTOBUF_FUTURE_FINAL
#undef PROTOBUF_THREAD_LOCAL
#undef PROTOBUF_LITTLE_ENDIAN
#undef PROTOBUF_BIG_ENDIAN
-#undef PROTOBUF_MESSAGE_OWNED_ARENA_EXPERIMENT
#undef PROTOBUF_CONSTINIT
#undef PROTOBUF_CONSTEXPR
#undef PROTOBUF_ATTRIBUTE_WEAK
@@ -99,26 +106,45 @@
#undef PROTOBUF_MSAN
#undef PROTOBUF_TSAN
#undef PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED
+#undef PROTOBUF_USE_TABLE_PARSER_ON_REFLECTION
#undef PROTOBUF_TC_PARAM_DECL
#undef PROTOBUF_EXCLUSIVE_LOCKS_REQUIRED
#undef PROTOBUF_LOCKS_EXCLUDED
#undef PROTOBUF_NO_THREAD_SAFETY_ANALYSIS
#undef PROTOBUF_GUARDED_BY
+#undef PROTOBUF_DEBUG
+#undef PROTOBUF_DLOG
+#undef PROTO2_IS_OSS
+#undef PROTOBUF_NO_THREADLOCAL
#ifdef PROTOBUF_FUTURE_BREAKING_CHANGES
#undef PROTOBUF_FUTURE_BREAKING_CHANGES
+#undef PROTOBUF_FUTURE_REMOVE_CLEARED_API
+#undef PROTOBUF_FUTURE_DESCRIPTOR_EXTENSION_DECL
#endif
-// Restore macro that may have been #undef'd in port_def.inc.
-#ifdef _MSC_VER
+// Restore macros that may have been #undef'd in port_def.inc.
+
+#ifdef PROTOBUF_DID_UNDEF_PACKAGE
+#pragma pop_macro("PACKAGE")
+#undef PROTOBUF_DID_UNDEF_PACKAGE
+#endif
+
+#ifdef PROTOBUF_DID_UNDEF_LINUX
+#pragma pop_macro("linux")
+#endif
+
+#ifdef _WIN32
#pragma pop_macro("CREATE_NEW")
#pragma pop_macro("DELETE")
+#pragma pop_macro("DOMAIN")
#pragma pop_macro("DOUBLE_CLICK")
#pragma pop_macro("ERROR")
#pragma pop_macro("ERROR_BUSY")
#pragma pop_macro("ERROR_INSTALL_FAILED")
#pragma pop_macro("ERROR_NOT_FOUND")
#pragma pop_macro("GetClassName")
+#pragma pop_macro("GetCurrentTime")
#pragma pop_macro("GetMessage")
#pragma pop_macro("GetObject")
#pragma pop_macro("IGNORE")
@@ -137,6 +163,8 @@
#pragma pop_macro("STRICT")
#pragma pop_macro("STATUS_PENDING")
#pragma pop_macro("timezone")
+#pragma pop_macro("TRUE")
+#pragma pop_macro("FALSE")
#endif
#ifdef __APPLE__
@@ -144,6 +172,8 @@
#pragma pop_macro("TRUE")
#pragma pop_macro("FALSE")
#pragma pop_macro("UID_MAX")
+#pragma pop_macro("GID_MAX")
+#pragma pop_macro("TYPE_BOOL")
#endif // __APPLE__
#if defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER)
@@ -154,7 +184,7 @@
#pragma GCC diagnostic pop
#endif
-#if defined(__clang__)
+#ifdef __clang__
#pragma clang diagnostic pop
#endif
diff --git a/contrib/libs/protobuf/src/google/protobuf/reflection.h b/contrib/libs/protobuf/src/google/protobuf/reflection.h
index fa141b8a661..d974d1f54f0 100644
--- a/contrib/libs/protobuf/src/google/protobuf/reflection.h
+++ b/contrib/libs/protobuf/src/google/protobuf/reflection.h
@@ -33,18 +33,17 @@
#ifndef GOOGLE_PROTOBUF_REFLECTION_H__
#define GOOGLE_PROTOBUF_REFLECTION_H__
-
#include <memory>
-#include <google/protobuf/message.h>
-#include <google/protobuf/generated_enum_util.h>
+#include "google/protobuf/message.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>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -565,6 +564,6 @@ struct RefTypeTraits<
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_REFLECTION_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/reflection_internal.h b/contrib/libs/protobuf/src/google/protobuf/reflection_internal.h
index 0035db23a54..bbceb2adb5e 100644
--- a/contrib/libs/protobuf/src/google/protobuf/reflection_internal.h
+++ b/contrib/libs/protobuf/src/google/protobuf/reflection_internal.h
@@ -31,9 +31,10 @@
#ifndef GOOGLE_PROTOBUF_REFLECTION_INTERNAL_H__
#define GOOGLE_PROTOBUF_REFLECTION_INTERNAL_H__
-#include <google/protobuf/map_field.h>
-#include <google/protobuf/reflection.h>
-#include <google/protobuf/repeated_field.h>
+#include "y_absl/strings/cord.h"
+#include "google/protobuf/map_field.h"
+#include "google/protobuf/reflection.h"
+#include "google/protobuf/repeated_field.h"
namespace google {
namespace protobuf {
@@ -233,7 +234,7 @@ class MapFieldAccessor final : public RandomAccessRepeatedFieldAccessor {
}
void Swap(Field* data, const internal::RepeatedFieldAccessor* other_mutator,
Field* other_data) const override {
- GOOGLE_CHECK(this == other_mutator);
+ Y_ABSL_CHECK(this == other_mutator);
MutableRepeatedField(data)->Swap(MutableRepeatedField(other_data));
}
@@ -277,7 +278,7 @@ class RepeatedFieldPrimitiveAccessor final : public RepeatedFieldWrapper<T> {
// Currently RepeatedFieldPrimitiveAccessor is the only implementation of
// RepeatedFieldAccessor for primitive types. As we are using singletons
// for these accessors, here "other_mutator" must be "this".
- GOOGLE_CHECK(this == other_mutator);
+ Y_ABSL_CHECK(this == other_mutator);
MutableRepeatedField(data)->Swap(MutableRepeatedField(other_data));
}
@@ -341,7 +342,7 @@ class RepeatedPtrFieldMessageAccessor final
RepeatedPtrFieldMessageAccessor() {}
void Swap(Field* data, const internal::RepeatedFieldAccessor* other_mutator,
Field* other_data) const override {
- GOOGLE_CHECK(this == other_mutator);
+ Y_ABSL_CHECK(this == other_mutator);
MutableRepeatedField(data)->Swap(MutableRepeatedField(other_data));
}
diff --git a/contrib/libs/protobuf/src/google/protobuf/reflection_ops.cc b/contrib/libs/protobuf/src/google/protobuf/reflection_ops.cc
index 566dfaa86fe..a2c3e4dde89 100644
--- a/contrib/libs/protobuf/src/google/protobuf/reflection_ops.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/reflection_ops.cc
@@ -31,21 +31,22 @@
// Author: [email protected] (Kenton Varda)
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/reflection_ops.h>
+#include "google/protobuf/reflection_ops.h"
#include <string>
#include <vector>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.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>
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/str_cat.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>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -57,7 +58,8 @@ static const Reflection* GetReflectionOrDie(const Message& m) {
const Descriptor* d = m.GetDescriptor();
const TProtoStringType& mtype = d ? d->name() : "unknown";
// RawMessage is one known type for which GetReflection() returns nullptr.
- GOOGLE_LOG(FATAL) << "Message does not support reflection (type " << mtype << ").";
+ Y_ABSL_LOG(FATAL) << "Message does not support reflection (type " << mtype
+ << ").";
}
return r;
}
@@ -69,10 +71,10 @@ void ReflectionOps::Copy(const Message& from, Message* to) {
}
void ReflectionOps::Merge(const Message& from, Message* to) {
- GOOGLE_CHECK_NE(&from, to);
+ Y_ABSL_CHECK_NE(&from, to);
const Descriptor* descriptor = from.GetDescriptor();
- GOOGLE_CHECK_EQ(to->GetDescriptor(), descriptor)
+ Y_ABSL_CHECK_EQ(to->GetDescriptor(), descriptor)
<< "Tried to merge messages of different types "
<< "(merge " << descriptor->full_name() << " to "
<< to->GetDescriptor()->full_name() << ")";
@@ -85,7 +87,7 @@ void ReflectionOps::Merge(const Message& from, Message* to) {
google::protobuf::MessageFactory::generated_factory());
std::vector<const FieldDescriptor*> fields;
- from_reflection->ListFieldsOmitStripped(from, &fields);
+ from_reflection->ListFields(from, &fields);
for (const FieldDescriptor* field : fields) {
if (field->is_repeated()) {
// Use map reflection if both are in map status and have the
@@ -180,7 +182,7 @@ void ReflectionOps::Clear(Message* message) {
const Reflection* reflection = GetReflectionOrDie(*message);
std::vector<const FieldDescriptor*> fields;
- reflection->ListFieldsOmitStripped(*message, &fields);
+ reflection->ListFields(*message, &fields);
for (const FieldDescriptor* field : fields) {
reflection->ClearField(message, field);
}
@@ -197,7 +199,7 @@ bool ReflectionOps::IsInitialized(const Message& message, bool check_fields,
if (const int field_count = descriptor->field_count()) {
const FieldDescriptor* begin = descriptor->field(0);
const FieldDescriptor* end = begin + field_count;
- GOOGLE_DCHECK_EQ(descriptor->field(field_count - 1), end - 1);
+ Y_ABSL_DCHECK_EQ(descriptor->field(field_count - 1), end - 1);
if (check_fields) {
// Check required fields of this message.
@@ -245,9 +247,20 @@ bool ReflectionOps::IsInitialized(const Message& message, bool check_fields,
}
}
}
- if (check_descendants && reflection->HasExtensionSet(message) &&
- !reflection->GetExtensionSet(message).IsInitialized()) {
- return false;
+ if (check_descendants && reflection->HasExtensionSet(message)) {
+ // Note that "extendee" is only referenced if the extension is lazily parsed
+ // (e.g. LazyMessageExtensionImpl), which requires a verification function
+ // to be generated.
+ //
+ // Dynamic messages would get null prototype from the generated message
+ // factory but their verification functions are not generated. Therefore, it
+ // it will always be eagerly parsed and "extendee" here will not be
+ // referenced.
+ const Message* extendee =
+ MessageFactory::generated_factory()->GetPrototype(descriptor);
+ if (!reflection->GetExtensionSet(message).IsInitialized(extendee)) {
+ return false;
+ }
}
return true;
}
@@ -272,7 +285,7 @@ bool ReflectionOps::IsInitialized(const Message& message) {
std::vector<const FieldDescriptor*> fields;
// Should be safe to skip stripped fields because required fields are not
// stripped.
- reflection->ListFieldsOmitStripped(message, &fields);
+ reflection->ListFields(message, &fields);
for (const FieldDescriptor* field : fields) {
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
@@ -374,7 +387,7 @@ static TProtoStringType SubMessagePrefix(const TProtoStringType& prefix,
}
if (index != -1) {
result.append("[");
- result.append(StrCat(index));
+ result.append(y_absl::StrCat(index));
result.append("]");
}
result.append(".");
@@ -401,7 +414,7 @@ void ReflectionOps::FindInitializationErrors(const Message& message,
// Check sub-messages.
std::vector<const FieldDescriptor*> fields;
- reflection->ListFieldsOmitStripped(message, &fields);
+ reflection->ListFields(message, &fields);
for (const FieldDescriptor* field : fields) {
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
@@ -425,10 +438,10 @@ void ReflectionOps::FindInitializationErrors(const Message& message,
void GenericSwap(Message* lhs, Message* rhs) {
#ifndef PROTOBUF_FORCE_COPY_IN_SWAP
- GOOGLE_DCHECK(Arena::InternalGetOwningArena(lhs) !=
- Arena::InternalGetOwningArena(rhs));
- GOOGLE_DCHECK(Arena::InternalGetOwningArena(lhs) != nullptr ||
- Arena::InternalGetOwningArena(rhs) != nullptr);
+ Y_ABSL_DCHECK(Arena::InternalGetOwningArena(lhs) !=
+ Arena::InternalGetOwningArena(rhs));
+ Y_ABSL_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::InternalGetOwningArena(rhs);
@@ -456,4 +469,4 @@ void GenericSwap(Message* lhs, Message* rhs) {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protobuf/src/google/protobuf/reflection_ops.h b/contrib/libs/protobuf/src/google/protobuf/reflection_ops.h
index 32f95cffb0a..1ed7133590b 100644
--- a/contrib/libs/protobuf/src/google/protobuf/reflection_ops.h
+++ b/contrib/libs/protobuf/src/google/protobuf/reflection_ops.h
@@ -38,15 +38,15 @@
#ifndef GOOGLE_PROTOBUF_REFLECTION_OPS_H__
#define GOOGLE_PROTOBUF_REFLECTION_OPS_H__
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/message.h>
+#include "google/protobuf/message.h"
+#include "google/protobuf/port.h"
#ifdef SWIG
#error "You cannot SWIG proto headers"
#endif
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -63,6 +63,8 @@ namespace internal {
// This class is really a namespace that contains only static methods.
class PROTOBUF_EXPORT ReflectionOps {
public:
+ ReflectionOps() = delete;
+
static void Copy(const Message& from, Message* to);
static void Merge(const Message& from, Message* to);
static void Clear(Message* message);
@@ -77,16 +79,12 @@ class PROTOBUF_EXPORT ReflectionOps {
static void FindInitializationErrors(const Message& message,
const TProtoStringType& prefix,
std::vector<TProtoStringType>* errors);
-
- private:
- // All methods are static. No need to construct.
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ReflectionOps);
};
} // namespace internal
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_REFLECTION_OPS_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/repeated_field.cc b/contrib/libs/protobuf/src/google/protobuf/repeated_field.cc
index 9e467ab1480..a38c4b690f9 100644
--- a/contrib/libs/protobuf/src/google/protobuf/repeated_field.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/repeated_field.cc
@@ -32,40 +32,35 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/repeated_field.h>
+#include "google/protobuf/repeated_field.h"
#include <algorithm>
+#include <string>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/cord.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<bool>;
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<arc_i32>;
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<arc_ui32>;
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<arc_i64>;
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<arc_ui64>;
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<float>;
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<double>;
-template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedPtrField<TProtoStringType>;
+template <>
+PROTOBUF_EXPORT_TEMPLATE_DEFINE size_t
+RepeatedField<y_absl::Cord>::SpaceUsedExcludingSelfLong() const {
+ size_t result = current_size_ * sizeof(y_absl::Cord);
+ for (int i = 0; i < current_size_; i++) {
+ // Estimate only.
+ result += Get(i).size();
+ }
+ return result;
+}
-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
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protobuf/src/google/protobuf/repeated_field.h b/contrib/libs/protobuf/src/google/protobuf/repeated_field.h
index 171cd065b29..c188fd0dc66 100644
--- a/contrib/libs/protobuf/src/google/protobuf/repeated_field.h
+++ b/contrib/libs/protobuf/src/google/protobuf/repeated_field.h
@@ -44,24 +44,28 @@
#ifndef GOOGLE_PROTOBUF_REPEATED_FIELD_H__
#define GOOGLE_PROTOBUF_REPEATED_FIELD_H__
-
#include <algorithm>
#include <iterator>
#include <limits>
+#include <memory>
#include <string>
#include <type_traits>
#include <utility>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/arena.h>
-#include <google/protobuf/port.h>
-#include <google/protobuf/message_lite.h>
-#include <google/protobuf/repeated_ptr_field.h>
+#include "google/protobuf/arena.h"
+#include "google/protobuf/port.h"
+#include "y_absl/base/dynamic_annotations.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/meta/type_traits.h"
+#include "y_absl/strings/cord.h"
+#include "google/protobuf/generated_enum_util.h"
+#include "google/protobuf/message_lite.h"
+#include "google/protobuf/port.h"
+#include "google/protobuf/repeated_ptr_field.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
#ifdef SWIG
#error "You cannot SWIG proto headers"
@@ -94,60 +98,41 @@ constexpr int RepeatedFieldLowerClampLimit() {
constexpr int kRepeatedFieldUpperClampLimit =
(std::numeric_limits<int>::max() / 2) + 1;
-template <typename Iter>
-inline int CalculateReserve(Iter begin, Iter end, std::forward_iterator_tag) {
- return static_cast<int>(std::distance(begin, end));
-}
-
-template <typename Iter>
-inline int CalculateReserve(Iter /*begin*/, Iter /*end*/,
- std::input_iterator_tag /*unused*/) {
- return -1;
-}
-
-template <typename Iter>
-inline int CalculateReserve(Iter begin, Iter end) {
- typedef typename std::iterator_traits<Iter>::iterator_category Category;
- return CalculateReserve(begin, end, Category());
-}
-
-// Swaps two blocks of memory of size sizeof(T).
-template <typename T>
-inline void SwapBlock(char* p, char* q) {
- T tmp;
- memcpy(&tmp, p, sizeof(T));
- memcpy(p, q, sizeof(T));
- memcpy(q, &tmp, sizeof(T));
-}
-
// Swaps two blocks of memory of size kSize:
-// template <int kSize> void memswap(char* p, char* q);
-template <int kSize>
-inline typename std::enable_if<(kSize == 0), void>::type memswap(char*, char*) {
-}
-
-#define PROTO_MEMSWAP_DEF_SIZE(reg_type, max_size) \
- template <int kSize> \
- typename std::enable_if<(kSize >= sizeof(reg_type) && kSize < (max_size)), \
- void>::type \
- memswap(char* p, char* q) { \
- SwapBlock<reg_type>(p, q); \
- memswap<kSize - sizeof(reg_type)>(p + sizeof(reg_type), \
- q + sizeof(reg_type)); \
- }
-
-PROTO_MEMSWAP_DEF_SIZE(uint8_t, 2)
-PROTO_MEMSWAP_DEF_SIZE(uint16_t, 4)
-PROTO_MEMSWAP_DEF_SIZE(arc_ui32, 8)
-
-#ifdef __SIZEOF_INT128__
-PROTO_MEMSWAP_DEF_SIZE(arc_ui64, 16)
-PROTO_MEMSWAP_DEF_SIZE(__uint128_t, (1u << 31))
+template <size_t kSize>
+void memswap(char* a, char* b) {
+#if __SIZEOF_INT128__
+ using Buffer = __uint128_t;
#else
-PROTO_MEMSWAP_DEF_SIZE(arc_ui64, (1u << 31))
+ using Buffer = arc_ui64;
#endif
-#undef PROTO_MEMSWAP_DEF_SIZE
+ constexpr size_t kBlockSize = sizeof(Buffer);
+ Buffer buf;
+ for (size_t i = 0; i < kSize / kBlockSize; ++i) {
+ memcpy(&buf, a, kBlockSize);
+ memcpy(a, b, kBlockSize);
+ memcpy(b, &buf, kBlockSize);
+ a += kBlockSize;
+ b += kBlockSize;
+ }
+
+#if defined(__GNUC__) && !defined(__clang__)
+ // Workaround GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpragmas"
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+#endif // __GNUC__
+
+ // Swap the leftover bytes, could be zero.
+ memcpy(&buf, a, kSize % kBlockSize);
+ memcpy(a, b, kSize % kBlockSize);
+ memcpy(b, &buf, kSize % kBlockSize);
+
+#if defined(__GNUC__) && !defined(__clang__)
+#pragma GCC diagnostic pop
+#endif // GCC
+}
template <typename Element>
class RepeatedIterator;
@@ -158,17 +143,37 @@ class RepeatedIterator;
// other words, everything except strings and nested Messages). Most users will
// not ever use a RepeatedField directly; they will use the get-by-index,
// set-by-index, and add accessors that are generated for all repeated fields.
+// Actually, in addition to primitive types, we use RepeatedField for repeated
+// Cords, because the Cord class is in fact just a reference-counted pointer.
+// We have to specialize several methods in the Cord case to get the memory
+// management right; e.g. swapping when appropriate, etc.
template <typename Element>
class RepeatedField {
static_assert(
alignof(Arena) >= alignof(Element),
"We only support types that have an alignment smaller than Arena");
+ static_assert(!std::is_const<Element>::value,
+ "We do not support const value types.");
+ static_assert(!std::is_volatile<Element>::value,
+ "We do not support volatile value types.");
+ static_assert(!std::is_pointer<Element>::value,
+ "We do not support pointer value types.");
+ static_assert(!std::is_reference<Element>::value,
+ "We do not support reference value types.");
+ static constexpr PROTOBUF_ALWAYS_INLINE void StaticValidityCheck() {
+ static_assert(
+ y_absl::disjunction<internal::is_supported_integral_type<Element>,
+ internal::is_supported_floating_point_type<Element>,
+ std::is_same<y_absl::Cord, Element>,
+ is_proto_enum<Element>>::value,
+ "We only support non-string scalars in RepeatedField.");
+ }
public:
constexpr RepeatedField();
explicit RepeatedField(Arena* arena);
- RepeatedField(const RepeatedField& other);
+ RepeatedField(const RepeatedField& rhs);
template <typename Iter,
typename = typename std::enable_if<std::is_constructible<
@@ -195,7 +200,8 @@ class RepeatedField {
Element& at(int index);
void Set(int index, const Element& value);
- void Add(const Element& value);
+ void Add(Element value);
+
// Appends a new element and returns a pointer to it.
// The new element is uninitialized if |Element| is a POD type.
Element* Add();
@@ -226,16 +232,17 @@ class RepeatedField {
void Reserve(int new_size);
// Resizes the RepeatedField to a new, smaller size. This is O(1).
+ // Except for RepeatedField<Cord>, for which it is O(size-new_size).
void Truncate(int new_size);
- void AddAlreadyReserved(const Element& value);
- // Appends a new element and return a pointer to it.
- // The new element is uninitialized if |Element| is a POD type.
- // Should be called only if Capacity() > Size().
- Element* AddAlreadyReserved();
- Element* AddNAlreadyReserved(int elements);
+ void AddAlreadyReserved(Element value);
int Capacity() const;
+ // Adds `n` elements to this instance asserting there is enough capacity.
+ // The added elements are uninitialized if `Element` is trivial.
+ Element* AddAlreadyReserved();
+ Element* AddNAlreadyReserved(int n);
+
// Like STL resize. Uses value to fill appended elements.
// Like Truncate() if new_size <= size(), otherwise this is
// O(new_size - size()).
@@ -246,16 +253,10 @@ class RepeatedField {
Element* mutable_data();
const Element* data() const;
- // Swaps entire contents with "other". If they are separate arenas then,
+ // Swaps entire contents with "other". If they are separate arenas, then
// copies data between each other.
void Swap(RepeatedField* other);
- // 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);
-
// Swaps two elements.
void SwapElements(int index1, int index2);
@@ -313,9 +314,9 @@ class RepeatedField {
iterator erase(const_iterator first, const_iterator last);
// Gets the Arena on which this RepeatedField stores its elements.
- inline Arena* GetArena() const {
- return GetOwningArena();
- }
+ // Note: this can be inaccurate for split default fields so we make this
+ // function non-const.
+ inline Arena* GetArena() { return GetOwningArena(); }
// For internal use only.
//
@@ -331,6 +332,44 @@ class RepeatedField {
: rep()->arena;
}
+ // 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
+ // Y_ABSL_DCHECK (see API docs for details).
+ void UnsafeArenaSwap(RepeatedField* other);
+
+ // Copy constructs `n` instances in place into the array `dst`.
+ // This function is identical to `std::uninitialized_copy_n(src, n, dst)`
+ // except that we explicit declare the memory to not be aliased, which will
+ // result in `memcpy` code generation instead of `memmove` for trivial types.
+ static inline void UninitializedCopyN(const Element* PROTOBUF_RESTRICT src,
+ int n, Element* PROTOBUF_RESTRICT dst) {
+ std::uninitialized_copy_n(src, n, dst);
+ }
+
+ // Copy constructs `[begin, end)` instances in place into the array `dst`.
+ // See above `UninitializedCopyN()` function comments for more information.
+ template <typename Iter>
+ static inline void UninitializedCopy(Iter begin, Iter end,
+ Element* PROTOBUF_RESTRICT dst) {
+ std::uninitialized_copy(begin, end, dst);
+ }
+
+ template <typename Iter>
+ void AddForwardIterator(Iter begin, Iter end);
+
+ template <typename Iter>
+ void AddInputIterator(Iter begin, Iter end);
+
+ // 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.
+ // If `annotate_size` is true (the default), then this function will annotate
+ // the old container from `current_size` to `total_size_` (unpoison memory)
+ // directly before it is being released, and annotate the new container from
+ // `total_size_` to `current_size` (poison unused memory).
+ void Grow(int current_size, int new_size);
+ void GrowNoAnnotate(int current_size, int new_size);
+
static constexpr int kInitialSize = 0;
// A note on the representation here (see also comment below for
// RepeatedPtrFieldBase's struct Rep):
@@ -344,6 +383,36 @@ class RepeatedField {
// RepeatedField class to avoid costly cache misses due to the indirection.
int current_size_;
int total_size_;
+
+ // Annotates a change in size of this instance. This function should be called
+ // with (total_size, current_size) after new memory has been allocated and
+ // filled from previous memory), and called with (current_size, total_size)
+ // right before (previously annotated) memory is released.
+ void AnnotateSize(int old_size, int new_size) const {
+ return;
+ if (old_size != new_size) {
+ Y_ABSL_ANNOTATE_CONTIGUOUS_CONTAINER(
+ unsafe_elements(), unsafe_elements() + total_size_,
+ unsafe_elements() + old_size, unsafe_elements() + new_size);
+ if (new_size < old_size) {
+ Y_ABSL_ANNOTATE_MEMORY_IS_UNINITIALIZED(
+ unsafe_elements() + new_size,
+ (old_size - new_size) * sizeof(Element));
+ }
+ }
+ }
+
+ // Replaces current_size_ with new_size and returns the previous value of
+ // current_size_. This function is intended to be the only place where
+ // current_size_ is modified, with the exception of `AddInputIterator()`
+ // where the size of added items is not known in advance.
+ inline int ExchangeCurrentSize(int new_size) {
+ const int prev_size = current_size_;
+ AnnotateSize(prev_size, new_size);
+ current_size_ = new_size;
+ return prev_size;
+ }
+
// Pad the Rep after arena allow for power-of-two byte sizes when
// sizeof(Element) > sizeof(Arena*). eg for 16-byte objects.
static PROTOBUF_CONSTEXPR const size_t kRepHeaderSize =
@@ -364,7 +433,7 @@ class RepeatedField {
// Returns a pointer to elements array.
// pre-condition: the array must have been allocated.
Element* elements() const {
- GOOGLE_DCHECK_GT(total_size_, 0);
+ Y_ABSL_DCHECK_GT(total_size_, 0);
// Because of above pre-condition this cast is safe.
return unsafe_elements();
}
@@ -386,152 +455,50 @@ class RepeatedField {
friend class Arena;
typedef void InternalArenaConstructable_;
- // 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);
-
- // 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, bool in_destructor) {
- if (rep != nullptr) {
- Element* e = &rep->elements()[0];
- if (!std::is_trivial<Element>::value) {
- Element* limit = &rep->elements()[size];
- for (; e < limit; e++) {
- e->~Element();
- }
- }
- const size_t bytes = size * sizeof(*e) + kRepHeaderSize;
- if (rep->arena == nullptr) {
- 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);
- }
+ // Destroys all elements in [begin, end).
+ // This function does nothing if `Element` is trivial.
+ static void Destroy(const Element* begin, const Element* end) {
+ if (!std::is_trivial<Element>::value) {
+ std::for_each(begin, end, [&](const Element& e) { e.~Element(); });
}
}
- // This class is a performance wrapper around RepeatedField::Add(const T&)
- // function. In general unless a RepeatedField is a local stack variable LLVM
- // has a hard time optimizing Add. The machine code tends to be
- // loop:
- // mov %size, dword ptr [%repeated_field] // load
- // cmp %size, dword ptr [%repeated_field + 4]
- // jae fallback
- // mov %buffer, qword ptr [%repeated_field + 8]
- // mov dword [%buffer + %size * 4], %value
- // inc %size // increment
- // mov dword ptr [%repeated_field], %size // store
- // jmp loop
- //
- // This puts a load/store in each iteration of the important loop variable
- // size. It's a pretty bad compile that happens even in simple cases, but
- // 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 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
- //
- // void AddSequence(const int* begin, const int* end, RepeatedField<int>* out)
- // {
- // RepeatedFieldAdder<int> adder(out); // Take ownership of out
- // for (auto it = begin; it != end; ++it) {
- // adder.Add(*it);
- // }
- // }
- //
- // 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 executes at only 1 or 2 cycles.
- template <int = 0, bool = std::is_trivial<Element>::value>
- class FastAdderImpl {
- public:
- explicit FastAdderImpl(RepeatedField* rf) : repeated_field_(rf) {
- index_ = repeated_field_->current_size_;
- capacity_ = repeated_field_->total_size_;
- buffer_ = repeated_field_->unsafe_elements();
- }
- ~FastAdderImpl() { repeated_field_->current_size_ = index_; }
-
- void Add(Element val) {
- if (index_ == capacity_) {
- repeated_field_->current_size_ = index_;
- repeated_field_->Reserve(index_ + 1);
- capacity_ = repeated_field_->total_size_;
- buffer_ = repeated_field_->unsafe_elements();
- }
- buffer_[index_++] = val;
+ // Internal helper to delete all elements and deallocate the storage.
+ template <bool in_destructor = false>
+ void InternalDeallocate() {
+ const size_t bytes = total_size_ * sizeof(Element) + kRepHeaderSize;
+ if (rep()->arena == nullptr) {
+ 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);
}
-
- private:
- RepeatedField* repeated_field_;
- int index_;
- int capacity_;
- Element* buffer_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FastAdderImpl);
- };
-
- // FastAdder is a wrapper for adding fields. The specialization above handles
- // POD types more efficiently than RepeatedField.
- template <int I>
- class FastAdderImpl<I, false> {
- public:
- explicit FastAdderImpl(RepeatedField* rf) : repeated_field_(rf) {}
- void Add(const Element& val) { repeated_field_->Add(val); }
-
- private:
- RepeatedField* repeated_field_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FastAdderImpl);
- };
-
- using FastAdder = FastAdderImpl<>;
-
- friend class TestRepeatedFieldHelper;
- friend class ::google::protobuf::internal::ParseContext;
-};
-
-namespace internal {
-
-// This is a helper template to copy an array of elements efficiently when they
-// have a trivial copy constructor, and correctly otherwise. This really
-// shouldn't be necessary, but our compiler doesn't optimize std::copy very
-// effectively.
-template <typename Element,
- bool HasTrivialCopy = std::is_trivial<Element>::value>
-struct ElementCopier {
- void operator()(Element* to, const Element* from, int array_size);
+ }
};
-} // namespace internal
-
// implementation ====================================================
template <typename Element>
constexpr RepeatedField<Element>::RepeatedField()
- : current_size_(0), total_size_(0), arena_or_elements_(nullptr) {}
+ : current_size_(0), total_size_(0), arena_or_elements_(nullptr) {
+ StaticValidityCheck();
+}
template <typename Element>
inline RepeatedField<Element>::RepeatedField(Arena* arena)
- : current_size_(0), total_size_(0), arena_or_elements_(arena) {}
+ : current_size_(0), total_size_(0), arena_or_elements_(arena) {
+ StaticValidityCheck();
+}
template <typename Element>
-inline RepeatedField<Element>::RepeatedField(const RepeatedField& other)
+inline RepeatedField<Element>::RepeatedField(const RepeatedField& rhs)
: current_size_(0), total_size_(0), arena_or_elements_(nullptr) {
- if (other.current_size_ != 0) {
- Reserve(other.size());
- AddNAlreadyReserved(other.size());
- CopyArray(Mutable(0), &other.Get(0), other.size());
+ StaticValidityCheck();
+ if (auto size = rhs.current_size_) {
+ Grow(0, size);
+ ExchangeCurrentSize(size);
+ UninitializedCopyN(rhs.elements(), size, unsafe_elements());
}
}
@@ -539,11 +506,13 @@ template <typename Element>
template <typename Iter, typename>
RepeatedField<Element>::RepeatedField(Iter begin, Iter end)
: current_size_(0), total_size_(0), arena_or_elements_(nullptr) {
+ StaticValidityCheck();
Add(begin, end);
}
template <typename Element>
RepeatedField<Element>::~RepeatedField() {
+ StaticValidityCheck();
#ifndef NDEBUG
// Try to trigger segfault / asan failure in non-opt builds if arena_
// lifetime has ended before the destructor.
@@ -551,7 +520,8 @@ RepeatedField<Element>::~RepeatedField() {
if (arena) (void)arena->SpaceAllocated();
#endif
if (total_size_ > 0) {
- InternalDeallocate(rep(), total_size_, true);
+ Destroy(unsafe_elements(), unsafe_elements() + current_size_);
+ InternalDeallocate<true>();
}
}
@@ -614,135 +584,175 @@ inline int RepeatedField<Element>::Capacity() const {
}
template <typename Element>
-inline void RepeatedField<Element>::AddAlreadyReserved(const Element& value) {
- GOOGLE_DCHECK_LT(current_size_, total_size_);
- elements()[current_size_++] = value;
+inline void RepeatedField<Element>::AddAlreadyReserved(Element value) {
+ Y_ABSL_DCHECK_LT(current_size_, total_size_);
+ void* p = elements() + ExchangeCurrentSize(current_size_ + 1);
+ ::new (p) Element(std::move(value));
}
template <typename Element>
inline Element* RepeatedField<Element>::AddAlreadyReserved() {
- GOOGLE_DCHECK_LT(current_size_, total_size_);
- return &elements()[current_size_++];
+ Y_ABSL_DCHECK_LT(current_size_, total_size_);
+ // new (p) <TrivialType> compiles into nothing: this is intentional as this
+ // function is documented to return uninitialized data for trivial types.
+ void* p = elements() + ExchangeCurrentSize(current_size_ + 1);
+ return ::new (p) Element;
}
template <typename Element>
-inline Element* RepeatedField<Element>::AddNAlreadyReserved(int elements) {
- GOOGLE_DCHECK_GE(total_size_ - current_size_, elements)
+inline Element* RepeatedField<Element>::AddNAlreadyReserved(int n) {
+ Y_ABSL_DCHECK_GE(total_size_ - current_size_, n)
<< total_size_ << ", " << current_size_;
- // 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_ += elements;
- return ret;
+ Element* p = unsafe_elements() + ExchangeCurrentSize(current_size_ + n);
+ for (Element *begin = p, *end = p + n; begin != end; ++begin) {
+ new (static_cast<void*>(begin)) Element;
+ }
+ return p;
}
template <typename Element>
inline void RepeatedField<Element>::Resize(int new_size, const Element& value) {
- GOOGLE_DCHECK_GE(new_size, 0);
+ Y_ABSL_DCHECK_GE(new_size, 0);
if (new_size > current_size_) {
- Reserve(new_size);
- std::fill(&elements()[current_size_], &elements()[new_size], value);
+ if (new_size > total_size_) Grow(current_size_, new_size);
+ Element* first = elements() + ExchangeCurrentSize(new_size);
+ std::uninitialized_fill(first, elements() + current_size_, value);
+ } else if (new_size < current_size_) {
+ Destroy(unsafe_elements() + new_size, unsafe_elements() + current_size_);
+ ExchangeCurrentSize(new_size);
}
- current_size_ = new_size;
}
template <typename Element>
inline const Element& RepeatedField<Element>::Get(int index) const {
- GOOGLE_DCHECK_GE(index, 0);
- GOOGLE_DCHECK_LT(index, current_size_);
+ Y_ABSL_DCHECK_GE(index, 0);
+ Y_ABSL_DCHECK_LT(index, current_size_);
return elements()[index];
}
template <typename Element>
inline const Element& RepeatedField<Element>::at(int index) const {
- GOOGLE_CHECK_GE(index, 0);
- GOOGLE_CHECK_LT(index, current_size_);
+ Y_ABSL_CHECK_GE(index, 0);
+ Y_ABSL_CHECK_LT(index, current_size_);
return elements()[index];
}
template <typename Element>
inline Element& RepeatedField<Element>::at(int index) {
- GOOGLE_CHECK_GE(index, 0);
- GOOGLE_CHECK_LT(index, current_size_);
+ Y_ABSL_CHECK_GE(index, 0);
+ Y_ABSL_CHECK_LT(index, current_size_);
return elements()[index];
}
template <typename Element>
inline Element* RepeatedField<Element>::Mutable(int index) {
- GOOGLE_DCHECK_GE(index, 0);
- GOOGLE_DCHECK_LT(index, current_size_);
+ Y_ABSL_DCHECK_GE(index, 0);
+ Y_ABSL_DCHECK_LT(index, current_size_);
return &elements()[index];
}
template <typename Element>
inline void RepeatedField<Element>::Set(int index, const Element& value) {
- GOOGLE_DCHECK_GE(index, 0);
- GOOGLE_DCHECK_LT(index, current_size_);
+ Y_ABSL_DCHECK_GE(index, 0);
+ Y_ABSL_DCHECK_LT(index, current_size_);
elements()[index] = value;
}
template <typename Element>
-inline void RepeatedField<Element>::Add(const Element& value) {
- arc_ui32 size = current_size_;
- if (static_cast<int>(size) == total_size_) {
- // value could reference an element of the array. Reserving new space will
- // invalidate the reference. So we must make a copy first.
- auto tmp = value;
- Reserve(total_size_ + 1);
- elements()[size] = std::move(tmp);
- } else {
- elements()[size] = value;
+inline void RepeatedField<Element>::Add(Element value) {
+ int total_size = total_size_;
+ Element* elem = unsafe_elements();
+ if (Y_ABSL_PREDICT_FALSE(current_size_ == total_size)) {
+ Grow(current_size_, current_size_ + 1);
+ total_size = total_size_;
+ elem = unsafe_elements();
}
- current_size_ = size + 1;
+ int new_size = current_size_ + 1;
+ void* p = elem + ExchangeCurrentSize(new_size);
+ ::new (p) Element(std::move(value));
+
+ // The below helps the compiler optimize dense loops.
+ Y_ABSL_ASSUME(new_size == current_size_);
+ Y_ABSL_ASSUME(elem == arena_or_elements_);
+ Y_ABSL_ASSUME(total_size == total_size_);
}
template <typename Element>
inline Element* RepeatedField<Element>::Add() {
- arc_ui32 size = current_size_;
- if (static_cast<int>(size) == total_size_) Reserve(total_size_ + 1);
- auto ptr = &elements()[size];
- current_size_ = size + 1;
- return ptr;
+ if (Y_ABSL_PREDICT_FALSE(current_size_ == total_size_)) {
+ Grow(current_size_, current_size_ + 1);
+ }
+ void* p = unsafe_elements() + ExchangeCurrentSize(current_size_ + 1);
+ return ::new (p) Element;
}
template <typename Element>
template <typename Iter>
-inline void RepeatedField<Element>::Add(Iter begin, Iter end) {
- int reserve = internal::CalculateReserve(begin, end);
- if (reserve != -1) {
- if (reserve == 0) {
- return;
+inline void RepeatedField<Element>::AddForwardIterator(Iter begin, Iter end) {
+ int total_size = total_size_;
+ Element* elem = unsafe_elements();
+ int new_size = current_size_ + static_cast<int>(std::distance(begin, end));
+ if (Y_ABSL_PREDICT_FALSE(new_size > total_size)) {
+ Grow(current_size_, new_size);
+ elem = unsafe_elements();
+ total_size = total_size_;
+ }
+ UninitializedCopy(begin, end, elem + ExchangeCurrentSize(new_size));
+
+ // The below helps the compiler optimize dense loops.
+ Y_ABSL_ASSUME(new_size == current_size_);
+ Y_ABSL_ASSUME(elem == arena_or_elements_);
+ Y_ABSL_ASSUME(total_size == total_size_);
+}
+
+template <typename Element>
+template <typename Iter>
+inline void RepeatedField<Element>::AddInputIterator(Iter begin, Iter end) {
+ Element* first = unsafe_elements() + current_size_;
+ Element* last = unsafe_elements() + total_size_;
+ AnnotateSize(current_size_, total_size_);
+
+ while (begin != end) {
+ if (Y_ABSL_PREDICT_FALSE(first == last)) {
+ int current_size = first - unsafe_elements();
+ GrowNoAnnotate(current_size, current_size + 1);
+ first = unsafe_elements() + current_size;
+ last = unsafe_elements() + total_size_;
}
+ ::new (static_cast<void*>(first)) Element(*begin);
+ ++begin;
+ ++first;
+ }
+
+ current_size_ = first - unsafe_elements();
+ AnnotateSize(total_size_, current_size_);
+}
- Reserve(reserve + size());
- // TODO(ckennelly): The compiler loses track of the buffer freshly
- // allocated by Reserve() by the time we call elements, so it cannot
- // guarantee that elements does not alias [begin(), end()).
- //
- // If restrict is available, annotating the pointer obtained from elements()
- // causes this to lower to memcpy instead of memmove.
- std::copy(begin, end, elements() + size());
- current_size_ = reserve + size();
+template <typename Element>
+template <typename Iter>
+inline void RepeatedField<Element>::Add(Iter begin, Iter end) {
+ if (std::is_base_of<
+ std::forward_iterator_tag,
+ typename std::iterator_traits<Iter>::iterator_category>::value) {
+ AddForwardIterator(begin, end);
} else {
- FastAdder fast_adder(this);
- for (; begin != end; ++begin) fast_adder.Add(*begin);
+ AddInputIterator(begin, end);
}
}
template <typename Element>
inline void RepeatedField<Element>::RemoveLast() {
- GOOGLE_DCHECK_GT(current_size_, 0);
- current_size_--;
+ Y_ABSL_DCHECK_GT(current_size_, 0);
+ elements()[current_size_ - 1].~Element();
+ ExchangeCurrentSize(current_size_ - 1);
}
template <typename Element>
void RepeatedField<Element>::ExtractSubrange(int start, int num,
Element* elements) {
- GOOGLE_DCHECK_GE(start, 0);
- GOOGLE_DCHECK_GE(num, 0);
- GOOGLE_DCHECK_LE(start + num, this->current_size_);
+ Y_ABSL_DCHECK_GE(start, 0);
+ Y_ABSL_DCHECK_GE(num, 0);
+ Y_ABSL_DCHECK_LE(start + num, this->current_size_);
// Save the values of the removed elements if requested.
if (elements != nullptr) {
@@ -759,17 +769,17 @@ void RepeatedField<Element>::ExtractSubrange(int start, int num,
template <typename Element>
inline void RepeatedField<Element>::Clear() {
- current_size_ = 0;
+ Destroy(unsafe_elements(), unsafe_elements() + current_size_);
+ ExchangeCurrentSize(0);
}
template <typename Element>
-inline void RepeatedField<Element>::MergeFrom(const RepeatedField& other) {
- GOOGLE_DCHECK_NE(&other, this);
- if (other.current_size_ != 0) {
- int existing_size = size();
- Reserve(existing_size + other.size());
- AddNAlreadyReserved(other.size());
- CopyArray(Mutable(existing_size), &other.Get(0), other.size());
+inline void RepeatedField<Element>::MergeFrom(const RepeatedField& rhs) {
+ Y_ABSL_DCHECK_NE(&rhs, this);
+ if (auto size = rhs.current_size_) {
+ Reserve(current_size_ + size);
+ Element* dst = elements() + ExchangeCurrentSize(current_size_ + size);
+ UninitializedCopyN(rhs.elements(), size, dst);
}
}
@@ -815,7 +825,7 @@ inline const Element* RepeatedField<Element>::data() const {
template <typename Element>
inline void RepeatedField<Element>::InternalSwap(RepeatedField* other) {
- GOOGLE_DCHECK(this != other);
+ Y_ABSL_DCHECK(this != other);
// Swap all fields at once.
static_assert(std::is_standard_layout<RepeatedField<Element>>::value,
@@ -848,7 +858,7 @@ void RepeatedField<Element>::Swap(RepeatedField* other) {
template <typename Element>
void RepeatedField<Element>::UnsafeArenaSwap(RepeatedField* other) {
if (this == other) return;
- GOOGLE_DCHECK_EQ(GetOwningArena(), other->GetOwningArena());
+ Y_ABSL_DCHECK_EQ(GetOwningArena(), other->GetOwningArena());
InternalSwap(other);
}
@@ -922,97 +932,90 @@ inline int CalculateReserveSize(int total_size, int new_size) {
}
} // namespace internal
+template <typename Element>
+void RepeatedField<Element>::Reserve(int new_size) {
+ if (Y_ABSL_PREDICT_FALSE(new_size > total_size_)) {
+ Grow(current_size_, new_size);
+ }
+}
+
// Avoid inlining of Reserve(): new, copy, and delete[] lead to a significant
// amount of code bloat.
template <typename Element>
-void RepeatedField<Element>::Reserve(int new_size) {
- if (total_size_ >= new_size) return;
- Rep* old_rep = total_size_ > 0 ? rep() : nullptr;
+PROTOBUF_NOINLINE void RepeatedField<Element>::GrowNoAnnotate(int current_size,
+ int new_size) {
+ Y_ABSL_DCHECK_GT(new_size, total_size_);
Rep* new_rep;
Arena* arena = GetOwningArena();
new_size = internal::CalculateReserveSize<Element, kRepHeaderSize>(
total_size_, new_size);
- GOOGLE_DCHECK_LE(
+ Y_ABSL_DCHECK_LE(
static_cast<size_t>(new_size),
(std::numeric_limits<size_t>::max() - kRepHeaderSize) / sizeof(Element))
<< "Requested size is too large to fit into size_t.";
size_t bytes =
kRepHeaderSize + sizeof(Element) * static_cast<size_t>(new_size);
if (arena == nullptr) {
- new_rep = static_cast<Rep*>(::operator new(bytes));
+ Y_ABSL_DCHECK_LE((bytes - kRepHeaderSize) / sizeof(Element),
+ static_cast<size_t>(std::numeric_limits<int>::max()))
+ << "Requested size is too large to fit element count into int.";
+ internal::SizedPtr res = internal::AllocateAtLeast(bytes);
+ size_t num_available =
+ std::min((res.n - kRepHeaderSize) / sizeof(Element),
+ static_cast<size_t>(std::numeric_limits<int>::max()));
+ new_size = static_cast<int>(num_available);
+ new_rep = static_cast<Rep*>(res.p);
} else {
new_rep = reinterpret_cast<Rep*>(Arena::CreateArray<char>(arena, bytes));
}
new_rep->arena = arena;
- int old_total_size = total_size_;
- // Already known: new_size >= internal::kMinRepeatedFieldAllocationSize
- // Maintain invariant:
- // total_size_ == 0 ||
- // total_size_ >= internal::kMinRepeatedFieldAllocationSize
- total_size_ = new_size;
- 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
- // RepeatedField with non-POD types, relying on constructor invocation. If
- // Element has a trivial constructor (e.g., arc_i32), gcc (tested with -O2)
- // completely removes this loop because the loop body is empty, so this has no
- // effect unless its side-effects are required for correctness.
- // Note that we do this before MoveArray() below because Element's copy
- // assignment implementation will want an initialized instance first.
- Element* e = &elements()[0];
- Element* limit = e + total_size_;
- for (; e < limit; e++) {
- new (e) Element;
- }
- if (current_size_ > 0) {
- MoveArray(&elements()[0], old_rep->elements(), current_size_);
- }
- // Likewise, we need to invoke destructors on the old array.
- InternalDeallocate(old_rep, old_total_size, false);
-
-}
-
-template <typename Element>
-inline void RepeatedField<Element>::Truncate(int new_size) {
- GOOGLE_DCHECK_LE(new_size, current_size_);
- if (current_size_ > 0) {
- current_size_ = new_size;
+ if (total_size_ > 0) {
+ if (current_size > 0) {
+ Element* pnew = new_rep->elements();
+ Element* pold = elements();
+ // TODO(b/263791665): add y_absl::is_trivially_relocatable<Element>
+ if (std::is_trivial<Element>::value) {
+ memcpy(static_cast<void*>(pnew), pold, current_size * sizeof(Element));
+ } else {
+ for (Element* end = pnew + current_size; pnew != end; ++pnew, ++pold) {
+ ::new (static_cast<void*>(pnew)) Element(std::move(*pold));
+ pold->~Element();
+ }
+ }
+ }
+ InternalDeallocate();
}
-}
-template <typename Element>
-inline void RepeatedField<Element>::MoveArray(Element* to, Element* from,
- int array_size) {
- CopyArray(to, from, array_size);
+ total_size_ = new_size;
+ arena_or_elements_ = new_rep->elements();
}
+// TODO(b/266411038): we should really be able to make this:
+// template <bool annotate_size = true>
+// void Grow();
template <typename Element>
-inline void RepeatedField<Element>::CopyArray(Element* to, const Element* from,
- int array_size) {
- internal::ElementCopier<Element>()(to, from, array_size);
-}
-
-namespace internal {
-
-template <typename Element, bool HasTrivialCopy>
-void ElementCopier<Element, HasTrivialCopy>::operator()(Element* to,
- const Element* from,
- int array_size) {
- std::copy(from, from + array_size, to);
+PROTOBUF_NOINLINE void RepeatedField<Element>::Grow(int current_size,
+ int new_size) {
+ AnnotateSize(current_size, total_size_);
+ GrowNoAnnotate(current_size, new_size);
+ AnnotateSize(total_size_, current_size);
}
template <typename Element>
-struct ElementCopier<Element, true> {
- void operator()(Element* to, const Element* from, int array_size) {
- memcpy(to, from, static_cast<size_t>(array_size) * sizeof(Element));
+inline void RepeatedField<Element>::Truncate(int new_size) {
+ Y_ABSL_DCHECK_LE(new_size, current_size_);
+ if (new_size < current_size_) {
+ Destroy(unsafe_elements() + new_size, unsafe_elements() + current_size_);
+ ExchangeCurrentSize(new_size);
}
-};
+}
-} // namespace internal
+template <>
+PROTOBUF_EXPORT size_t
+RepeatedField<y_absl::Cord>::SpaceUsedExcludingSelfLong() const;
// -------------------------------------------------------------------
@@ -1192,32 +1195,10 @@ internal::RepeatedFieldBackInsertIterator<T> RepeatedFieldBackInserter(
return internal::RepeatedFieldBackInsertIterator<T>(mutable_field);
}
-// Extern declarations of common instantiations to reduce library bloat.
-extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<bool>;
-extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<arc_i32>;
-extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<arc_ui32>;
-extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<arc_i64>;
-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
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_REPEATED_FIELD_H__
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 7886494a3db..808f4a638dd 100644
--- a/contrib/libs/protobuf/src/google/protobuf/repeated_ptr_field.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/repeated_ptr_field.cc
@@ -34,14 +34,13 @@
#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>
+#include "y_absl/log/absl_check.h"
+#include "google/protobuf/implicit_weak_message.h"
+#include "google/protobuf/port.h"
+#include "google/protobuf/repeated_field.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -59,14 +58,16 @@ void** RepeatedPtrFieldBase::InternalExtend(int extend_amount) {
Arena* arena = GetOwningArena();
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) /
- sizeof(old_rep->elements[0])))
+ Y_ABSL_CHECK_LE(static_cast<arc_i64>(new_size),
+ static_cast<arc_i64>(
+ (std::numeric_limits<size_t>::max() - kRepHeaderSize) /
+ sizeof(old_rep->elements[0])))
<< "Requested size is too large to fit into size_t.";
size_t bytes = kRepHeaderSize + sizeof(old_rep->elements[0]) * new_size;
if (arena == nullptr) {
- rep_ = reinterpret_cast<Rep*>(::operator new(bytes));
+ internal::SizedPtr res = internal::AllocateAtLeast(bytes);
+ new_size = (res.n - kRepHeaderSize) / sizeof(old_rep->elements[0]);
+ rep_ = reinterpret_cast<Rep*>(res.p);
} else {
rep_ = reinterpret_cast<Rep*>(Arena::CreateArray<char>(arena, bytes));
}
@@ -99,8 +100,8 @@ void RepeatedPtrFieldBase::Reserve(int new_size) {
}
void RepeatedPtrFieldBase::DestroyProtos() {
- GOOGLE_DCHECK(rep_);
- GOOGLE_DCHECK(arena_ == nullptr);
+ Y_ABSL_DCHECK(rep_);
+ Y_ABSL_DCHECK(arena_ == nullptr);
int n = rep_->allocated_size;
void* const* elements = rep_->elements;
for (int i = 0; i < n; i++) {
@@ -116,7 +117,7 @@ void* RepeatedPtrFieldBase::AddOutOfLineHelper(void* obj) {
InternalExtend(1); // Equivalent to "Reserve(total_size_ + 1)"
}
++rep_->allocated_size;
- rep_->elements[current_size_++] = obj;
+ rep_->elements[ExchangeCurrentSize(current_size_ + 1)] = obj;
return obj;
}
@@ -125,13 +126,14 @@ void RepeatedPtrFieldBase::CloseGap(int start, int num) {
// Close up a gap of "num" elements starting at offset "start".
for (int i = start + num; i < rep_->allocated_size; ++i)
rep_->elements[i - num] = rep_->elements[i];
- current_size_ -= num;
+ ExchangeCurrentSize(current_size_ - num);
rep_->allocated_size -= num;
}
MessageLite* RepeatedPtrFieldBase::AddWeak(const MessageLite* prototype) {
if (rep_ != nullptr && current_size_ < rep_->allocated_size) {
- return reinterpret_cast<MessageLite*>(rep_->elements[current_size_++]);
+ return reinterpret_cast<MessageLite*>(
+ rep_->elements[ExchangeCurrentSize(current_size_ + 1)]);
}
if (!rep_ || rep_->allocated_size == total_size_) {
Reserve(total_size_ + 1);
@@ -140,7 +142,7 @@ MessageLite* RepeatedPtrFieldBase::AddWeak(const MessageLite* prototype) {
MessageLite* result = prototype
? prototype->New(arena_)
: Arena::CreateMessage<ImplicitWeakMessage>(arena_);
- rep_->elements[current_size_++] = result;
+ rep_->elements[ExchangeCurrentSize(current_size_ + 1)] = result;
return result;
}
@@ -149,4 +151,4 @@ MessageLite* RepeatedPtrFieldBase::AddWeak(const MessageLite* prototype) {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
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 70776f74895..fe7ac9d4fea 100644
--- a/contrib/libs/protobuf/src/google/protobuf/repeated_ptr_field.h
+++ b/contrib/libs/protobuf/src/google/protobuf/repeated_ptr_field.h
@@ -41,8 +41,6 @@
//
// 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__
@@ -58,15 +56,15 @@
#include <string>
#include <type_traits>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/arena.h>
-#include <google/protobuf/port.h>
-#include <google/protobuf/message_lite.h>
+#include "google/protobuf/arena.h"
+#include "google/protobuf/port.h"
+#include "y_absl/log/absl_check.h"
+#include "google/protobuf/message_lite.h"
+#include "google/protobuf/port.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
#ifdef SWIG
#error "You cannot SWIG proto headers"
@@ -187,22 +185,22 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
template <typename TypeHandler>
const typename TypeHandler::Type& at(int index) const {
- GOOGLE_CHECK_GE(index, 0);
- GOOGLE_CHECK_LT(index, current_size_);
+ Y_ABSL_CHECK_GE(index, 0);
+ Y_ABSL_CHECK_LT(index, current_size_);
return *cast<TypeHandler>(rep_->elements[index]);
}
template <typename TypeHandler>
typename TypeHandler::Type& at(int index) {
- GOOGLE_CHECK_GE(index, 0);
- GOOGLE_CHECK_LT(index, current_size_);
+ Y_ABSL_CHECK_GE(index, 0);
+ Y_ABSL_CHECK_LT(index, current_size_);
return *cast<TypeHandler>(rep_->elements[index]);
}
template <typename TypeHandler>
typename TypeHandler::Type* Mutable(int index) {
- GOOGLE_DCHECK_GE(index, 0);
- GOOGLE_DCHECK_LT(index, current_size_);
+ Y_ABSL_DCHECK_GE(index, 0);
+ Y_ABSL_DCHECK_LT(index, current_size_);
return cast<TypeHandler>(rep_->elements[index]);
}
@@ -210,7 +208,8 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
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_++]);
+ return cast<TypeHandler>(
+ rep_->elements[ExchangeCurrentSize(current_size_ + 1)]);
}
typename TypeHandler::Type* result =
TypeHandler::NewFromPrototype(prototype, arena_);
@@ -223,7 +222,9 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
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);
+ *cast<TypeHandler>(
+ rep_->elements[ExchangeCurrentSize(current_size_ + 1)]) =
+ std::move(value);
return;
}
if (!rep_ || rep_->allocated_size == total_size_) {
@@ -232,13 +233,13 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
++rep_->allocated_size;
typename TypeHandler::Type* result =
TypeHandler::New(arena_, std::move(value));
- rep_->elements[current_size_++] = result;
+ rep_->elements[ExchangeCurrentSize(current_size_ + 1)] = result;
}
template <typename TypeHandler>
void Delete(int index) {
- GOOGLE_DCHECK_GE(index, 0);
- GOOGLE_DCHECK_LT(index, current_size_);
+ Y_ABSL_DCHECK_GE(index, 0);
+ Y_ABSL_DCHECK_LT(index, current_size_);
TypeHandler::Delete(cast<TypeHandler>(rep_->elements[index]), arena_);
}
@@ -267,8 +268,8 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
template <typename TypeHandler>
const typename TypeHandler::Type& Get(int index) const {
- GOOGLE_DCHECK_GE(index, 0);
- GOOGLE_DCHECK_LT(index, current_size_);
+ Y_ABSL_DCHECK_GE(index, 0);
+ Y_ABSL_DCHECK_LT(index, current_size_);
return *cast<TypeHandler>(rep_->elements[index]);
}
@@ -281,14 +282,9 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
template <typename TypeHandler>
void Clear() {
const int n = current_size_;
- GOOGLE_DCHECK_GE(n, 0);
+ Y_ABSL_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;
+ ClearNonEmpty<TypeHandler>();
}
}
@@ -300,14 +296,14 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
// 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);
+ Y_ABSL_DCHECK_NE(&other, this);
if (other.current_size_ == 0) return;
MergeFromInternal(other,
&RepeatedPtrFieldBase::MergeFromInnerLoop<TypeHandler>);
}
inline void InternalSwap(RepeatedPtrFieldBase* rhs) {
- GOOGLE_DCHECK(this != rhs);
+ Y_ABSL_DCHECK(this != rhs);
// Swap all fields at once.
auto temp = std::make_tuple(rhs->arena_, rhs->current_size_,
@@ -317,11 +313,40 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
std::tie(arena_, current_size_, total_size_, rep_) = temp;
}
+ // Prepares the container for adding elements via `AddAllocatedForParse`.
+ // It ensures some invariants to avoid checking then in the Add loop:
+ // - rep_ is not null.
+ // - there are no preallocated elements.
+ // Returns true if the invariants hold and `AddAllocatedForParse` can be
+ // used.
+ bool PrepareForParse() {
+ if (current_size_ == total_size_) {
+ InternalExtend(1);
+ }
+ return rep_->allocated_size == current_size_;
+ }
+
+ // Similar to `AddAllocated` but faster.
+ // Can only be invoked after a call to `PrepareForParse` that returned `true`,
+ // or other calls to `AddAllocatedForParse`.
+ template <typename TypeHandler>
+ void AddAllocatedForParse(typename TypeHandler::Type* value) {
+ PROTOBUF_ASSUME(rep_ != nullptr);
+ PROTOBUF_ASSUME(current_size_ == rep_->allocated_size);
+ if (current_size_ == total_size_) {
+ // The array is completely full with no cleared objects, so grow it.
+ InternalExtend(1);
+ }
+ rep_->elements[current_size_++] = value;
+ ++rep_->allocated_size;
+ }
+
protected:
template <typename TypeHandler>
void RemoveLast() {
- GOOGLE_DCHECK_GT(current_size_, 0);
- TypeHandler::Clear(cast<TypeHandler>(rep_->elements[--current_size_]));
+ Y_ABSL_DCHECK_GT(current_size_, 0);
+ ExchangeCurrentSize(current_size_ - 1);
+ TypeHandler::Clear(cast<TypeHandler>(rep_->elements[current_size_]));
}
template <typename TypeHandler>
@@ -337,7 +362,7 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
template<typename TypeHandler>
void Truncate(int new_size) {
- GOOGLE_DCHECK_LE(new_size, current_size_);
+ Y_ABSL_DCHECK_LE(new_size, current_size_);
for (int i = new_size; i < current_size_; i++) {
TypeHandler::Clear(cast<TypeHandler>(rep_->elements[i]));
}
@@ -412,7 +437,8 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
template <typename TypeHandler>
typename TypeHandler::Type* AddFromCleared() {
if (rep_ != nullptr && current_size_ < rep_->allocated_size) {
- return cast<TypeHandler>(rep_->elements[current_size_++]);
+ return cast<TypeHandler>(
+ rep_->elements[ExchangeCurrentSize(current_size_ + 1)]);
} else {
return nullptr;
}
@@ -448,7 +474,7 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
++rep_->allocated_size;
}
- rep_->elements[current_size_++] = value;
+ rep_->elements[ExchangeCurrentSize(current_size_ + 1)] = value;
}
template <typename TypeHandler>
@@ -462,9 +488,10 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
// arena.
template <typename TypeHandler>
typename TypeHandler::Type* UnsafeArenaReleaseLast() {
- GOOGLE_DCHECK_GT(current_size_, 0);
+ Y_ABSL_DCHECK_GT(current_size_, 0);
+ ExchangeCurrentSize(current_size_ - 1);
typename TypeHandler::Type* result =
- cast<TypeHandler>(rep_->elements[--current_size_]);
+ 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
@@ -480,9 +507,10 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
template <typename TypeHandler>
void AddCleared(typename TypeHandler::Type* value) {
- GOOGLE_DCHECK(GetOwningArena() == nullptr) << "AddCleared() can only be used on a "
- "RepeatedPtrField not on an arena.";
- GOOGLE_DCHECK(TypeHandler::GetOwningArena(value) == nullptr)
+ Y_ABSL_DCHECK(GetOwningArena() == nullptr)
+ << "AddCleared() can only be used on a "
+ "RepeatedPtrField not on an arena.";
+ Y_ABSL_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);
@@ -492,12 +520,11 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
template <typename TypeHandler>
PROTOBUF_NODISCARD typename TypeHandler::Type* ReleaseCleared() {
- GOOGLE_DCHECK(GetOwningArena() == nullptr)
+ Y_ABSL_DCHECK(GetOwningArena() == nullptr)
<< "ReleaseCleared() can only be used on a RepeatedPtrField not on "
<< "an arena.";
- GOOGLE_DCHECK(GetOwningArena() == nullptr);
- GOOGLE_DCHECK(rep_ != nullptr);
- GOOGLE_DCHECK_GT(rep_->allocated_size, current_size_);
+ Y_ABSL_DCHECK(rep_ != nullptr);
+ Y_ABSL_DCHECK_GT(rep_->allocated_size, current_size_);
return cast<TypeHandler>(rep_->elements[--rep_->allocated_size]);
}
@@ -517,8 +544,7 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
// allocated list.
elems[rep_->allocated_size] = elems[current_size_];
}
- elems[current_size_] = value;
- current_size_ = current_size_ + 1;
+ elems[ExchangeCurrentSize(current_size_ + 1)] = value;
rep_->allocated_size = rep_->allocated_size + 1;
} else {
AddAllocatedSlowWithCopy<TypeHandler>(value, element_arena, arena);
@@ -540,8 +566,7 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
// allocated list.
elems[rep_->allocated_size] = elems[current_size_];
}
- elems[current_size_] = value;
- current_size_ = current_size_ + 1;
+ elems[ExchangeCurrentSize(current_size_ + 1)] = value;
++rep_->allocated_size;
} else {
UnsafeArenaAddAllocated<TypeHandler>(value);
@@ -591,10 +616,10 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
template <typename TypeHandler>
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(GetOwningArena() == nullptr)
+ // this is the same as UnsafeArenaReleaseLast(). Note that we
+ // Y_ABSL_DCHECK-fail if we're on an arena, since the user really should
+ // implement the copy operation in this case.
+ Y_ABSL_DCHECK(GetOwningArena() == 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.";
@@ -604,10 +629,10 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
template <typename TypeHandler>
PROTOBUF_NOINLINE void SwapFallback(RepeatedPtrFieldBase* other) {
#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
- GOOGLE_DCHECK(GetOwningArena() == nullptr ||
- other->GetOwningArena() != GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == nullptr ||
+ other->GetOwningArena() != GetOwningArena());
#else // PROTOBUF_FORCE_COPY_IN_SWAP
- GOOGLE_DCHECK(other->GetOwningArena() != GetOwningArena());
+ Y_ABSL_DCHECK(other->GetOwningArena() != GetOwningArena());
#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
// Copy semantics in this case. We try to improve efficiency by placing the
@@ -621,7 +646,8 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
temp.Destroy<TypeHandler>(); // Frees rep_ if `other` had no arena.
}
- inline Arena* GetArena() const { return arena_; }
+ // Gets the Arena on which this RepeatedPtrField stores its elements.
+ inline Arena* GetArena() const { return GetOwningArena(); }
protected:
inline Arena* GetOwningArena() const { return arena_; }
@@ -644,6 +670,16 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
Arena* arena_;
int current_size_;
int total_size_;
+
+ // Replaces current_size_ with new_size and returns the previous value of
+ // current_size_. This function is intended to be the only place where
+ // current_size_ is modified.
+ inline int ExchangeCurrentSize(int new_size) {
+ int prev_size = current_size_;
+ current_size_ = new_size;
+ return prev_size;
+ }
+
struct Rep {
int allocated_size;
// Here we declare a huge array as a way of approximating C's "flexible
@@ -663,12 +699,27 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
return reinterpret_cast<const typename TypeHandler::Type*>(element);
}
+ // Out-of-line helper routine for Clear() once the inlined check has
+ // determined the container is non-empty
+ template <typename TypeHandler>
+ PROTOBUF_NOINLINE void ClearNonEmpty() {
+ const int n = current_size_;
+ void* const* elements = rep_->elements;
+ int i = 0;
+ Y_ABSL_DCHECK_GT(
+ n,
+ 0); // do/while loop to avoid initial test because we know n > 0
+ do {
+ TypeHandler::Clear(cast<TypeHandler>(elements[i++]));
+ } while (i < n);
+ ExchangeCurrentSize(0);
+ }
+
// Non-templated inner function to avoid code duplication. Takes a function
// pointer to the type-specific (templated) inner allocate/merge loop.
- void MergeFromInternal(const RepeatedPtrFieldBase& other,
- void (RepeatedPtrFieldBase::*inner_loop)(void**,
- void**, int,
- int)) {
+ PROTOBUF_NOINLINE void 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;
@@ -676,7 +727,7 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
int allocated_elems = rep_->allocated_size - current_size_;
(this->*inner_loop)(new_elements, other_elements, other_size,
allocated_elems);
- current_size_ += other_size;
+ ExchangeCurrentSize(current_size_ + other_size);
if (rep_->allocated_size < current_size_) {
rep_->allocated_size = current_size_;
}
@@ -771,7 +822,7 @@ class GenericTypeHandler {
}
}
static inline Arena* GetOwningArena(GenericType* value) {
- return Arena::GetOwningArena<Type>(value);
+ return Arena::InternalGetOwningArena(value);
}
static inline void Clear(GenericType* value) { value->Clear(); }
@@ -829,10 +880,10 @@ class StringTypeHandler {
typedef TProtoStringType Type;
using Movable = IsMovable<Type>;
- static inline TProtoStringType* New(Arena* arena) {
+ static PROTOBUF_NOINLINE TProtoStringType* New(Arena* arena) {
return Arena::Create<TProtoStringType>(arena);
}
- static inline TProtoStringType* New(Arena* arena, TProtoStringType&& value) {
+ static PROTOBUF_NOINLINE TProtoStringType* New(Arena* arena, TProtoStringType&& value) {
return Arena::Create<TProtoStringType>(arena, std::move(value));
}
static inline TProtoStringType* NewFromPrototype(const TProtoStringType*,
@@ -860,6 +911,21 @@ class StringTypeHandler {
// Messages.
template <typename Element>
class RepeatedPtrField : private internal::RepeatedPtrFieldBase {
+ static_assert(!std::is_const<Element>::value,
+ "We do not support const value types.");
+ static_assert(!std::is_volatile<Element>::value,
+ "We do not support volatile value types.");
+ static_assert(!std::is_pointer<Element>::value,
+ "We do not support pointer value types.");
+ static_assert(!std::is_reference<Element>::value,
+ "We do not support reference value types.");
+ static constexpr PROTOBUF_ALWAYS_INLINE void StaticValidityCheck() {
+ static_assert(
+ y_absl::disjunction<
+ internal::is_supported_string_type<Element>,
+ internal::is_supported_message_type<Element>>::value,
+ "We only support string and Message types in RepeatedPtrField.");
+ }
public:
constexpr RepeatedPtrField();
@@ -947,10 +1013,6 @@ 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;
@@ -961,7 +1023,7 @@ class RepeatedPtrField : private internal::RepeatedPtrFieldBase {
// 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.
+ // Y_ABSL_DCHECK.
void UnsafeArenaSwap(RepeatedPtrField* other);
// Swaps two elements.
@@ -1095,23 +1157,28 @@ class RepeatedPtrField : private internal::RepeatedPtrFieldBase {
// Gets the number of cleared objects that are currently being kept
// around for reuse.
+
int ClearedCount() const;
-#ifndef PROTOBUF_FUTURE_BREAKING_CHANGES
+
+#ifndef PROTOBUF_FUTURE_REMOVE_CLEARED_API
// 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 either the repeated field or |value| is
- // on an arena; both cases will trigger a GOOGLE_DCHECK-failure.
+ // on an arena; both cases will trigger a Y_ABSL_DCHECK-failure.
+
void AddCleared(Element* value);
// 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();
-#endif // !PROTOBUF_FUTURE_BREAKING_CHANGES
+ // so will trigger a Y_ABSL_DCHECK-failure.
+ PROTOBUF_NODISCARD
+
+ Element* ReleaseCleared();
+#endif // !PROTOBUF_FUTURE_REMOVE_CLEARED_API
// Removes the element referenced by position.
//
@@ -1129,6 +1196,9 @@ class RepeatedPtrField : private internal::RepeatedPtrFieldBase {
iterator erase(const_iterator first, const_iterator last);
// Gets the arena on which this RepeatedPtrField stores its elements.
+ inline Arena* GetArena();
+
+
inline Arena* GetArena() const;
// For internal use only.
@@ -1154,7 +1224,12 @@ class RepeatedPtrField : private internal::RepeatedPtrFieldBase {
void ExtractSubrangeInternal(int start, int num, Element** elements,
std::false_type);
+ void AddAllocatedForParse(Element* p) {
+ return RepeatedPtrFieldBase::AddAllocatedForParse<TypeHandler>(p);
+ }
+
friend class Arena;
+ friend class internal::TcParser;
template <typename T>
friend struct WeakRepeatedPtrField;
@@ -1175,27 +1250,34 @@ class RepeatedPtrField<TProtoStringType>::TypeHandler
template <typename Element>
constexpr RepeatedPtrField<Element>::RepeatedPtrField()
- : RepeatedPtrFieldBase() {}
+ : RepeatedPtrFieldBase() {
+ StaticValidityCheck();
+}
template <typename Element>
inline RepeatedPtrField<Element>::RepeatedPtrField(Arena* arena)
- : RepeatedPtrFieldBase(arena) {}
+ : RepeatedPtrFieldBase(arena) {
+ StaticValidityCheck();
+}
template <typename Element>
inline RepeatedPtrField<Element>::RepeatedPtrField(
const RepeatedPtrField& other)
: RepeatedPtrFieldBase() {
+ StaticValidityCheck();
MergeFrom(other);
}
template <typename Element>
template <typename Iter, typename>
inline RepeatedPtrField<Element>::RepeatedPtrField(Iter begin, Iter end) {
+ StaticValidityCheck();
Add(begin, end);
}
template <typename Element>
RepeatedPtrField<Element>::~RepeatedPtrField() {
+ StaticValidityCheck();
#ifdef __cpp_if_constexpr
if constexpr (std::is_base_of<MessageLite, Element>::value) {
#else
@@ -1283,7 +1365,7 @@ inline Element* RepeatedPtrField<Element>::Mutable(int index) {
}
template <typename Element>
-inline Element* RepeatedPtrField<Element>::Add() {
+PROTOBUF_NOINLINE Element* RepeatedPtrField<Element>::Add() {
return RepeatedPtrFieldBase::Add<TypeHandler>();
}
@@ -1298,7 +1380,7 @@ inline void RepeatedPtrField<Element>::Add(Iter begin, Iter end) {
if (std::is_base_of<
std::forward_iterator_tag,
typename std::iterator_traits<Iter>::iterator_category>::value) {
- int reserve = std::distance(begin, end);
+ int reserve = static_cast<int>(std::distance(begin, end));
Reserve(size() + reserve);
}
for (; begin != end; ++begin) {
@@ -1313,9 +1395,9 @@ inline void RepeatedPtrField<Element>::RemoveLast() {
template <typename Element>
inline void RepeatedPtrField<Element>::DeleteSubrange(int start, int num) {
- GOOGLE_DCHECK_GE(start, 0);
- GOOGLE_DCHECK_GE(num, 0);
- GOOGLE_DCHECK_LE(start + num, size());
+ Y_ABSL_DCHECK_GE(start, 0);
+ Y_ABSL_DCHECK_GE(num, 0);
+ Y_ABSL_DCHECK_LE(start + num, size());
for (int i = 0; i < num; ++i) {
RepeatedPtrFieldBase::Delete<TypeHandler>(start + i);
}
@@ -1335,13 +1417,13 @@ inline void RepeatedPtrField<Element>::ExtractSubrange(int start, int num,
template <typename Element>
inline void RepeatedPtrField<Element>::ExtractSubrangeInternal(
int start, int num, Element** elements, std::true_type) {
- GOOGLE_DCHECK_GE(start, 0);
- GOOGLE_DCHECK_GE(num, 0);
- GOOGLE_DCHECK_LE(start + num, size());
+ Y_ABSL_DCHECK_GE(start, 0);
+ Y_ABSL_DCHECK_GE(num, 0);
+ Y_ABSL_DCHECK_LE(start + num, size());
if (num == 0) return;
- GOOGLE_DCHECK_NE(elements, nullptr)
+ Y_ABSL_DCHECK_NE(elements, nullptr)
<< "Releasing elements without transferring ownership is an unsafe "
"operation. Use UnsafeArenaExtractSubrange.";
if (elements == nullptr) {
@@ -1385,9 +1467,9 @@ inline void RepeatedPtrField<Element>::ExtractSubrangeInternal(
int start, int num, Element** elements, std::false_type) {
// This case is identical to UnsafeArenaExtractSubrange(). However, since
// ExtractSubrange() must return heap-allocated objects by contract, and we
- // cannot fulfill this contract if we are an on arena, we must GOOGLE_DCHECK() that
- // we are not on an arena.
- GOOGLE_DCHECK(GetOwningArena() == nullptr)
+ // cannot fulfill this contract if we are an on arena, we must Y_ABSL_DCHECK()
+ // that we are not on an arena.
+ Y_ABSL_DCHECK(GetOwningArena() == nullptr)
<< "ExtractSubrange() when arena is non-nullptr is only supported when "
<< "the Element type supplies a MergeFrom() operation to make copies.";
UnsafeArenaExtractSubrange(start, num, elements);
@@ -1396,9 +1478,9 @@ inline void RepeatedPtrField<Element>::ExtractSubrangeInternal(
template <typename Element>
inline void RepeatedPtrField<Element>::UnsafeArenaExtractSubrange(
int start, int num, Element** elements) {
- GOOGLE_DCHECK_GE(start, 0);
- GOOGLE_DCHECK_GE(num, 0);
- GOOGLE_DCHECK_LE(start + num, size());
+ Y_ABSL_DCHECK_GE(start, 0);
+ Y_ABSL_DCHECK_GE(num, 0);
+ Y_ABSL_DCHECK_LE(start + num, size());
if (num > 0) {
// Save the values of the removed elements if requested.
@@ -1443,8 +1525,8 @@ RepeatedPtrField<Element>::erase(const_iterator position) {
template <typename Element>
inline typename RepeatedPtrField<Element>::iterator
RepeatedPtrField<Element>::erase(const_iterator first, const_iterator last) {
- size_type pos_offset = std::distance(cbegin(), first);
- size_type last_offset = std::distance(cbegin(), last);
+ size_type pos_offset = static_cast<size_type>(std::distance(cbegin(), first));
+ size_type last_offset = static_cast<size_type>(std::distance(cbegin(), last));
DeleteSubrange(pos_offset, last_offset - pos_offset);
return begin() + pos_offset;
}
@@ -1469,7 +1551,7 @@ template <typename Element>
inline void RepeatedPtrField<Element>::UnsafeArenaSwap(
RepeatedPtrField* other) {
if (this == other) return;
- GOOGLE_DCHECK_EQ(GetOwningArena(), other->GetOwningArena());
+ Y_ABSL_DCHECK_EQ(GetOwningArena(), other->GetOwningArena());
RepeatedPtrFieldBase::InternalSwap(other);
}
@@ -1479,6 +1561,11 @@ inline void RepeatedPtrField<Element>::SwapElements(int index1, int index2) {
}
template <typename Element>
+inline Arena* RepeatedPtrField<Element>::GetArena() {
+ return RepeatedPtrFieldBase::GetArena();
+}
+
+template <typename Element>
inline Arena* RepeatedPtrField<Element>::GetArena() const {
return RepeatedPtrFieldBase::GetArena();
}
@@ -1518,7 +1605,7 @@ inline int RepeatedPtrField<Element>::ClearedCount() const {
return RepeatedPtrFieldBase::ClearedCount();
}
-#ifndef PROTOBUF_FUTURE_BREAKING_CHANGES
+#ifndef PROTOBUF_FUTURE_REMOVE_CLEARED_API
template <typename Element>
inline void RepeatedPtrField<Element>::AddCleared(Element* value) {
return RepeatedPtrFieldBase::AddCleared<TypeHandler>(value);
@@ -1528,7 +1615,7 @@ template <typename Element>
inline Element* RepeatedPtrField<Element>::ReleaseCleared() {
return RepeatedPtrFieldBase::ReleaseCleared<TypeHandler>();
}
-#endif // !PROTOBUF_FUTURE_BREAKING_CHANGES
+#endif // !PROTOBUF_FUTURE_REMOVE_CLEARED_API
template <typename Element>
inline void RepeatedPtrField<Element>::Reserve(int new_size) {
@@ -1989,12 +2076,9 @@ UnsafeArenaAllocatedRepeatedPtrFieldBackInserter(
mutable_field);
}
-extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE
- RepeatedPtrField<TProtoStringType>;
-
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_REPEATED_PTR_FIELD_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/serial_arena.h b/contrib/libs/protobuf/src/google/protobuf/serial_arena.h
new file mode 100644
index 00000000000..b4e5091df2a
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/serial_arena.h
@@ -0,0 +1,434 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2022 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.
+//
+// This file defines the internal class SerialArena
+
+#ifndef GOOGLE_PROTOBUF_SERIAL_ARENA_H__
+#define GOOGLE_PROTOBUF_SERIAL_ARENA_H__
+
+#include <algorithm>
+#include <atomic>
+#include <string>
+#include <type_traits>
+#include <typeinfo>
+#include <utility>
+
+#include "google/protobuf/stubs/common.h"
+#include "y_absl/base/attributes.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/numeric/bits.h"
+#include "google/protobuf/arena_align.h"
+#include "google/protobuf/arena_cleanup.h"
+#include "google/protobuf/arena_config.h"
+#include "google/protobuf/arenaz_sampler.h"
+#include "google/protobuf/port.h"
+#include "google/protobuf/string_block.h"
+
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace internal {
+
+// Arena blocks are variable length malloc-ed objects. The following structure
+// describes the common header for all blocks.
+struct ArenaBlock {
+ // For the sentry block with zero-size where ptr_, limit_, cleanup_nodes all
+ // point to "this".
+ constexpr ArenaBlock()
+ : next(nullptr), cleanup_nodes(this), size(0) {}
+
+ ArenaBlock(ArenaBlock* next, size_t size)
+ : next(next), cleanup_nodes(nullptr), size(size) {
+ Y_ABSL_DCHECK_GT(size, sizeof(ArenaBlock));
+ }
+
+ char* Pointer(size_t n) {
+ Y_ABSL_DCHECK_LE(n, size);
+ return reinterpret_cast<char*>(this) + n;
+ }
+ char* Limit() { return Pointer(size & static_cast<size_t>(-8)); }
+
+ bool IsSentry() const { return size == 0; }
+
+ ArenaBlock* const next;
+ void* cleanup_nodes;
+ const size_t size;
+ // data follows
+};
+
+enum class AllocationClient { kDefault, kArray };
+
+class ThreadSafeArena;
+
+// Tag type used to invoke the constructor of the first SerialArena.
+struct FirstSerialArena {
+ explicit FirstSerialArena() = default;
+};
+
+// 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
+// for ThreadSafeArena, which provides a thread-safe arena allocator.
+//
+// This class manages
+// 1) Arena bump allocation + owning memory blocks.
+// 2) Maintaining a cleanup list.
+// It delegates the actual memory allocation back to ThreadSafeArena, which
+// contains the information on block growth policy and backing memory allocation
+// used.
+class PROTOBUF_EXPORT SerialArena {
+ public:
+ void CleanupList();
+ size_t FreeStringBlocks() {
+ // On the active block delete all strings skipping the unused instances.
+ size_t unused_bytes = string_block_unused_.load(std::memory_order_relaxed);
+ if (string_block_ != nullptr) {
+ return FreeStringBlocks(string_block_, unused_bytes);
+ }
+ return 0;
+ }
+ arc_ui64 SpaceAllocated() const {
+ return space_allocated_.load(std::memory_order_relaxed);
+ }
+ arc_ui64 SpaceUsed() const;
+
+ 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 = y_absl::bit_width(size - 1) - 4;
+
+ if (index >= cached_block_length_) return nullptr;
+ auto& cached_head = cached_blocks_[index];
+ if (cached_head == nullptr) return nullptr;
+
+ void* ret = cached_head;
+ PROTOBUF_UNPOISON_MEMORY_REGION(ret, size);
+ 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) {
+ Y_ABSL_DCHECK(internal::ArenaAlignDefault::IsAligned(n));
+ Y_ABSL_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);
+ }
+ return AllocateFromExisting(n);
+ }
+
+ private:
+ static inline PROTOBUF_ALWAYS_INLINE constexpr size_t AlignUpTo(size_t n,
+ size_t a) {
+ // 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 a <= 8 ? ArenaAlignDefault::Ceil(n) : ArenaAlignAs(a).Padded(n);
+ }
+
+ static inline PROTOBUF_ALWAYS_INLINE void* AlignTo(void* p, size_t a) {
+ return (a <= ArenaAlignDefault::align)
+ ? ArenaAlignDefault::CeilDefaultAligned(p)
+ : ArenaAlignAs(a).CeilDefaultAligned(p);
+ }
+
+ void* AllocateFromExisting(size_t n) {
+ PROTOBUF_UNPOISON_MEMORY_REGION(ptr(), n);
+ void* ret = ptr();
+ set_ptr(static_cast<char*>(ret) + n);
+ 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 {
+ PROTOBUF_ASSUME(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 = y_absl::bit_width(size) - 5;
+
+ 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);
+
+ // We need to unpoison this memory before filling it in case it has been
+ // poisoned by another santizer client.
+ PROTOBUF_UNPOISON_MEMORY_REGION(
+ new_list + cached_block_length_,
+ (new_size - cached_block_length_) * sizeof(CachedBlock*));
+
+ 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;
+ PROTOBUF_POISON_MEMORY_REGION(p, size);
+ }
+
+ public:
+ // Allocate space if the current region provides enough space.
+ bool MaybeAllocateAligned(size_t n, void** out) {
+ Y_ABSL_DCHECK(internal::ArenaAlignDefault::IsAligned(n));
+ Y_ABSL_DCHECK_GE(limit_, ptr());
+ if (PROTOBUF_PREDICT_FALSE(!HasSpace(n))) return false;
+ *out = AllocateFromExisting(n);
+ return true;
+ }
+
+ // If there is enough space in the current block, allocate space for one `T`
+ // object and register for destruction. The object has not been constructed
+ // and the memory returned is uninitialized.
+ template <typename T>
+ PROTOBUF_ALWAYS_INLINE void* MaybeAllocateWithCleanup() {
+ Y_ABSL_DCHECK_GE(limit_, ptr());
+ static_assert(!std::is_trivially_destructible<T>::value,
+ "This function is only for non-trivial types.");
+
+ constexpr int aligned_size = ArenaAlignDefault::Ceil(sizeof(T));
+ constexpr auto destructor = cleanup::arena_destruct_object<T>;
+ size_t required = aligned_size + cleanup::Size(destructor);
+ if (PROTOBUF_PREDICT_FALSE(!HasSpace(required))) {
+ return nullptr;
+ }
+ void* ptr = AllocateFromExistingWithCleanupFallback(aligned_size,
+ alignof(T), destructor);
+ PROTOBUF_ASSUME(ptr != nullptr);
+ return ptr;
+ }
+
+ PROTOBUF_ALWAYS_INLINE
+ void* AllocateAlignedWithCleanup(size_t n, size_t align,
+ void (*destructor)(void*)) {
+ size_t required = AlignUpTo(n, align) + cleanup::Size(destructor);
+ if (PROTOBUF_PREDICT_FALSE(!HasSpace(required))) {
+ return AllocateAlignedWithCleanupFallback(n, align, destructor);
+ }
+ return AllocateFromExistingWithCleanupFallback(n, align, destructor);
+ }
+
+ PROTOBUF_ALWAYS_INLINE
+ void AddCleanup(void* elem, void (*destructor)(void*)) {
+ size_t required = cleanup::Size(destructor);
+ if (PROTOBUF_PREDICT_FALSE(!HasSpace(required))) {
+ return AddCleanupFallback(elem, destructor);
+ }
+ AddCleanupFromExisting(elem, destructor);
+ }
+
+ Y_ABSL_ATTRIBUTE_RETURNS_NONNULL void* AllocateFromStringBlock();
+
+ private:
+ bool MaybeAllocateString(void*& p);
+ Y_ABSL_ATTRIBUTE_RETURNS_NONNULL void* AllocateFromStringBlockFallback();
+
+ void* AllocateFromExistingWithCleanupFallback(size_t n, size_t align,
+ void (*destructor)(void*)) {
+ n = AlignUpTo(n, align);
+ PROTOBUF_UNPOISON_MEMORY_REGION(ptr(), n);
+ void* ret = ArenaAlignAs(align).CeilDefaultAligned(ptr());
+ set_ptr(ptr() + n);
+ Y_ABSL_DCHECK_GE(limit_, ptr());
+ AddCleanupFromExisting(ret, destructor);
+ return ret;
+ }
+
+ PROTOBUF_ALWAYS_INLINE
+ void AddCleanupFromExisting(void* elem, void (*destructor)(void*)) {
+ cleanup::Tag tag = cleanup::Type(destructor);
+ size_t n = cleanup::Size(tag);
+
+ PROTOBUF_UNPOISON_MEMORY_REGION(limit_ - n, n);
+ limit_ -= n;
+ Y_ABSL_DCHECK_GE(limit_, ptr());
+ cleanup::CreateNode(tag, limit_, elem, destructor);
+ }
+
+ private:
+ friend class ThreadSafeArena;
+
+ // Creates a new SerialArena inside mem using the remaining memory as for
+ // future allocations.
+ // The `parent` arena must outlive the serial arena, which is guaranteed
+ // because the parent manages the lifetime of the serial arenas.
+ static SerialArena* New(SizedPtr mem, ThreadSafeArena& parent);
+ // Free SerialArena returning the memory passed in to New
+ template <typename Deallocator>
+ SizedPtr Free(Deallocator deallocator);
+
+ static size_t FreeStringBlocks(StringBlock* string_block, size_t unused);
+
+ // Members are declared here to track sizeof(SerialArena) and hotness
+ // centrally. They are (roughly) laid out in descending order of hotness.
+
+ // Next pointer to allocate from. Always 8-byte aligned. Points inside
+ // head_ (and head_->pos will always be non-canonical). We keep these
+ // here to reduce indirection.
+ std::atomic<char*> ptr_{nullptr};
+ // Limiting address up to which memory can be allocated from the head block.
+ char* limit_ = nullptr;
+
+ // The active string block.
+ StringBlock* string_block_ = nullptr;
+
+ // The number of unused bytes in string_block_.
+ // We allocate from `effective_size()` down to 0 inside `string_block_`.
+ // `unused == 0` means that `string_block_` is exhausted. (or null).
+ std::atomic<size_t> string_block_unused_{0};
+
+ std::atomic<ArenaBlock*> head_{nullptr}; // Head of linked list of blocks.
+ std::atomic<size_t> space_used_{0}; // Necessary for metrics.
+ std::atomic<size_t> space_allocated_{0};
+ ThreadSafeArena& parent_;
+
+ // 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;
+
+ // Helper getters/setters to handle relaxed operations on atomic variables.
+ ArenaBlock* head() { return head_.load(std::memory_order_relaxed); }
+ const ArenaBlock* head() const {
+ return head_.load(std::memory_order_relaxed);
+ }
+
+ char* ptr() { return ptr_.load(std::memory_order_relaxed); }
+ const char* ptr() const { return ptr_.load(std::memory_order_relaxed); }
+ void set_ptr(char* ptr) { return ptr_.store(ptr, std::memory_order_relaxed); }
+
+ // Constructor is private as only New() should be used.
+ inline SerialArena(ArenaBlock* b, ThreadSafeArena& parent);
+
+ // Constructors to handle the first SerialArena.
+ inline explicit SerialArena(ThreadSafeArena& parent);
+ inline SerialArena(FirstSerialArena, ArenaBlock* b, ThreadSafeArena& parent);
+
+ void* AllocateAlignedFallback(size_t n);
+ void* AllocateAlignedWithCleanupFallback(size_t n, size_t align,
+ void (*destructor)(void*));
+ void AddCleanupFallback(void* elem, void (*destructor)(void*));
+ inline void AllocateNewBlock(size_t n);
+ inline void Init(ArenaBlock* b, size_t offset);
+
+ public:
+ static constexpr size_t kBlockHeaderSize =
+ ArenaAlignDefault::Ceil(sizeof(ArenaBlock));
+};
+
+inline PROTOBUF_ALWAYS_INLINE bool SerialArena::MaybeAllocateString(void*& p) {
+ // Check how many unused instances are in the current block.
+ size_t unused_bytes = string_block_unused_.load(std::memory_order_relaxed);
+ if (PROTOBUF_PREDICT_TRUE(unused_bytes != 0)) {
+ unused_bytes -= sizeof(TProtoStringType);
+ string_block_unused_.store(unused_bytes, std::memory_order_relaxed);
+ p = string_block_->AtOffset(unused_bytes);
+ return true;
+ }
+ return false;
+}
+
+template <>
+inline PROTOBUF_ALWAYS_INLINE void*
+SerialArena::MaybeAllocateWithCleanup<TProtoStringType>() {
+ void* p;
+ return MaybeAllocateString(p) ? p : nullptr;
+}
+
+Y_ABSL_ATTRIBUTE_RETURNS_NONNULL inline PROTOBUF_ALWAYS_INLINE void*
+SerialArena::AllocateFromStringBlock() {
+ void* p;
+ if (Y_ABSL_PREDICT_TRUE(MaybeAllocateString(p))) return p;
+ return AllocateFromStringBlockFallback();
+}
+
+} // namespace internal
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_SERIAL_ARENA_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/service.cc b/contrib/libs/protobuf/src/google/protobuf/service.cc
index 53945684cb9..da1ae780e71 100644
--- a/contrib/libs/protobuf/src/google/protobuf/service.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/service.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/service.h>
+#include "google/protobuf/service.h"
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protobuf/src/google/protobuf/service.h b/contrib/libs/protobuf/src/google/protobuf/service.h
index c25f672baab..ab89ce3cbc5 100644
--- a/contrib/libs/protobuf/src/google/protobuf/service.h
+++ b/contrib/libs/protobuf/src/google/protobuf/service.h
@@ -100,17 +100,18 @@
#ifndef GOOGLE_PROTOBUF_SERVICE_H__
#define GOOGLE_PROTOBUF_SERVICE_H__
-
#include <string>
-#include <google/protobuf/stubs/callback.h>
-#include <google/protobuf/stubs/common.h>
+
+#include "google/protobuf/stubs/callback.h"
+#include "google/protobuf/stubs/common.h"
+#include "google/protobuf/port.h"
#ifdef SWIG
#error "You cannot SWIG proto headers"
#endif
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -134,6 +135,8 @@ class Message; // message.h
class PROTOBUF_EXPORT Service {
public:
inline Service() {}
+ Service(const Service&) = delete;
+ Service& operator=(const Service&) = delete;
virtual ~Service();
// When constructing a stub, you may pass STUB_OWNS_CHANNEL as the second
@@ -190,9 +193,6 @@ class PROTOBUF_EXPORT Service {
const MethodDescriptor* method) const = 0;
virtual const Message& GetResponsePrototype(
const MethodDescriptor* method) const = 0;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Service);
};
// An RpcController mediates a single method call. The primary purpose of
@@ -206,6 +206,8 @@ class PROTOBUF_EXPORT Service {
class PROTOBUF_EXPORT RpcController {
public:
inline RpcController() {}
+ RpcController(const RpcController&) = delete;
+ RpcController& operator=(const RpcController&) = delete;
virtual ~RpcController();
// Client-side methods ---------------------------------------------
@@ -256,9 +258,6 @@ class PROTOBUF_EXPORT RpcController {
//
// NotifyOnCancel() must be called no more than once per request.
virtual void NotifyOnCancel(Closure* callback) = 0;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RpcController);
};
// Abstract interface for an RPC channel. An RpcChannel represents a
@@ -272,6 +271,8 @@ class PROTOBUF_EXPORT RpcController {
class PROTOBUF_EXPORT RpcChannel {
public:
inline RpcChannel() {}
+ RpcChannel(const RpcChannel&) = delete;
+ RpcChannel& operator=(const RpcChannel&) = delete;
virtual ~RpcChannel();
// Call the given method of the remote service. The signature of this
@@ -282,14 +283,11 @@ class PROTOBUF_EXPORT RpcChannel {
virtual void CallMethod(const MethodDescriptor* method,
RpcController* controller, const Message* request,
Message* response, Closure* done) = 0;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RpcChannel);
};
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_SERVICE_H__
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 498a5478e02..d3e784ebd29 100644
--- a/contrib/libs/protobuf/src/google/protobuf/source_context.pb.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/source_context.pb.cc
@@ -1,129 +1,154 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/source_context.proto
-#include <google/protobuf/source_context.pb.h>
+#include "google/protobuf/source_context.pb.h"
#include <algorithm>
-
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/extension_set.h>
-#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/reflection_ops.h>
-#include <google/protobuf/wire_format.h>
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/extension_set.h"
+#include "google/protobuf/wire_format_lite.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/reflection_ops.h"
+#include "google/protobuf/wire_format.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+// Must be included last.
+#include "google/protobuf/port_def.inc"
PROTOBUF_PRAGMA_INIT_SEG
-
namespace _pb = ::PROTOBUF_NAMESPACE_ID;
-namespace _pbi = _pb::internal;
-
+namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal;
PROTOBUF_NAMESPACE_OPEN
PROTOBUF_CONSTEXPR SourceContext::SourceContext(
::_pbi::ConstantInitialized): _impl_{
- /*decltype(_impl_.file_name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
+ /*decltype(_impl_.file_name_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
, /*decltype(_impl_._cached_size_)*/{}} {}
struct SourceContextDefaultTypeInternal {
- PROTOBUF_CONSTEXPR SourceContextDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR SourceContextDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~SourceContextDefaultTypeInternal() {}
union {
SourceContext _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceContextDefaultTypeInternal _SourceContext_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceContextDefaultTypeInternal _SourceContext_default_instance_;
PROTOBUF_NAMESPACE_CLOSE
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_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceContext, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceContext, _impl_.file_name_),
+static constexpr const ::_pb::EnumDescriptor**
+ file_level_enum_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto = nullptr;
+static constexpr const ::_pb::ServiceDescriptor**
+ 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_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceContext, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceContext, _impl_.file_name_),
};
-static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
- { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceContext)},
+
+static const ::_pbi::MigrationSchema
+ schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceContext)},
};
static const ::_pb::Message* const file_default_instances[] = {
- &::PROTOBUF_NAMESPACE_ID::_SourceContext_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_SourceContext_default_instance_._instance,
};
-
-const char descriptor_table_protodef_google_2fprotobuf_2fsource_5fcontext_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
- "\n$google/protobuf/source_context.proto\022\017"
- "google.protobuf\"\"\n\rSourceContext\022\021\n\tfile"
- "_name\030\001 \001(\tB\212\001\n\023com.google.protobufB\022Sou"
- "rceContextProtoP\001Z6google.golang.org/pro"
- "tobuf/types/known/sourcecontextpb\242\002\003GPB\252"
- "\002\036Google.Protobuf.WellKnownTypesb\006proto3"
- ;
-static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_once;
+const char descriptor_table_protodef_google_2fprotobuf_2fsource_5fcontext_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ "\n$google/protobuf/source_context.proto\022\017"
+ "google.protobuf\"\"\n\rSourceContext\022\021\n\tfile"
+ "_name\030\001 \001(\tB\212\001\n\023com.google.protobufB\022Sou"
+ "rceContextProtoP\001Z6google.golang.org/pro"
+ "tobuf/types/known/sourcecontextpb\242\002\003GPB\252"
+ "\002\036Google.Protobuf.WellKnownTypesb\006proto3"
+};
+static ::y_absl::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,
+ 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,
+ &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,
};
+
+// This function exists to be marked as weak.
+// It can significantly speed up compilation by breaking up LLVM's SCC
+// in the .pb.cc translation units. Large translation units see a
+// reduction of more than 35% of walltime for optimized builds. Without
+// the weak attribute all the messages in the file, including all the
+// vtables and everything they use become part of the same SCC through
+// a cycle like:
+// GetMetadata -> descriptor table -> default instances ->
+// 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 ::_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_PRIORITY2 static ::_pbi::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
-
// ===================================================================
class SourceContext::_Internal {
public:
};
-SourceContext::SourceContext(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+SourceContext::SourceContext(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.SourceContext)
}
SourceContext::SourceContext(const SourceContext& from)
: ::PROTOBUF_NAMESPACE_ID::Message() {
SourceContext* const _this = this; (void)_this;
new (&_impl_) Impl_{
- decltype(_impl_.file_name_){}
+ decltype(_impl_.file_name_) {}
+
, /*decltype(_impl_._cached_size_)*/{}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.file_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.file_name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.file_name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_file_name().empty()) {
- _this->_impl_.file_name_.Set(from._internal_file_name(),
- _this->GetArenaForAllocation());
+ _this->_impl_.file_name_.Set(from._internal_file_name(), _this->GetArenaForAllocation());
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.SourceContext)
}
-inline void SourceContext::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void SourceContext::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
- decltype(_impl_.file_name_){}
+ decltype(_impl_.file_name_) {}
+
, /*decltype(_impl_._cached_size_)*/{}
};
_impl_.file_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.file_name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.file_name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
SourceContext::~SourceContext() {
@@ -136,7 +161,7 @@ SourceContext::~SourceContext() {
}
inline void SourceContext::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.file_name_.Destroy();
}
@@ -146,7 +171,7 @@ void SourceContext::SetCachedSize(int size) const {
void SourceContext::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.SourceContext)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -157,18 +182,19 @@ void SourceContext::Clear() {
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;
+ ::arc_ui32 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)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_file_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.SourceContext.file_name"));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -193,20 +219,18 @@ failure:
#undef CHK_
}
-uint8_t* SourceContext::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* SourceContext::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceContext)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// string file_name = 1;
if (!this->_internal_file_name().empty()) {
+ const TProtoStringType& _s = this->_internal_file_name();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
- this->_internal_file_name().data(), static_cast<int>(this->_internal_file_name().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
- "google.protobuf.SourceContext.file_name");
- target = stream->WriteStringMaybeAliased(
- 1, this->_internal_file_name(), target);
+ _s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.SourceContext.file_name");
+ target = stream->WriteStringMaybeAliased(1, _s, target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
@@ -217,19 +241,18 @@ uint8_t* SourceContext::_InternalSerialize(
return target;
}
-size_t SourceContext::ByteSizeLong() const {
+::size_t SourceContext::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceContext)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// string file_name = 1;
if (!this->_internal_file_name().empty()) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_file_name());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_file_name());
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -246,8 +269,8 @@ void SourceContext::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::
auto* const _this = static_cast<SourceContext*>(&to_msg);
auto& from = static_cast<const SourceContext&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceContext)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
if (!from._internal_file_name().empty()) {
@@ -272,10 +295,8 @@ void SourceContext::InternalSwap(SourceContext* other) {
auto* lhs_arena = GetArenaForAllocation();
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.file_name_, lhs_arena,
- &other->_impl_.file_name_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.file_name_, lhs_arena,
+ &other->_impl_.file_name_, rhs_arena);
}
::PROTOBUF_NAMESPACE_ID::Metadata SourceContext::GetMetadata() const {
@@ -283,7 +304,6 @@ void SourceContext::InternalSwap(SourceContext* other) {
&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]);
}
-
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
@@ -292,6 +312,5 @@ Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::SourceContext >(Arena* arena
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::SourceContext >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
-
// @@protoc_insertion_point(global_scope)
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
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 f4ac68863f6..cfe0fe4e8d3 100644
--- a/contrib/libs/protobuf/src/google/protobuf/source_context.pb.h
+++ b/contrib/libs/protobuf/src/google/protobuf/source_context.pb.h
@@ -1,38 +1,43 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/source_context.proto
-#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fsource_5fcontext_2eproto
-#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fsource_5fcontext_2eproto
+#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fsource_5fcontext_2eproto_2epb_2eh
+#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fsource_5fcontext_2eproto_2epb_2eh
#include <limits>
#include <string>
-
-#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3021000
-#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 3021003 < 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.
-#endif
-
-#include <google/protobuf/port_undef.inc>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/arena.h>
-#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_util.h>
-#include <google/protobuf/metadata_lite.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h> // IWYU pragma: export
-#include <google/protobuf/extension_set.h> // IWYU pragma: export
-#include <google/protobuf/unknown_field_set.h>
+#include <type_traits>
+
+#include "google/protobuf/port_def.inc"
+#if PROTOBUF_VERSION < 4022000
+#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 // PROTOBUF_VERSION
+
+#if 4022005 < 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."
+#endif // PROTOBUF_MIN_PROTOC_VERSION
+#include "google/protobuf/port_undef.inc"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/arena.h"
+#include "google/protobuf/arenastring.h"
+#include "google/protobuf/generated_message_util.h"
+#include "google/protobuf/metadata_lite.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/repeated_field.h" // IWYU pragma: export
+#include "google/protobuf/extension_set.h" // IWYU pragma: export
+#include "google/protobuf/unknown_field_set.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fsource_5fcontext_2eproto PROTOBUF_EXPORT
+
PROTOBUF_NAMESPACE_OPEN
namespace internal {
class AnyMetadata;
@@ -41,21 +46,25 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto {
- static const arc_ui32 offsets[];
+ static const ::arc_ui32 offsets[];
};
-PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto;
+PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable
+ descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto;
PROTOBUF_NAMESPACE_OPEN
class SourceContext;
struct SourceContextDefaultTypeInternal;
PROTOBUF_EXPORT extern SourceContextDefaultTypeInternal _SourceContext_default_instance_;
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::SourceContext* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::SourceContext>(Arena*);
PROTOBUF_NAMESPACE_CLOSE
-PROTOBUF_NAMESPACE_OPEN
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::SourceContext* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::SourceContext>(Arena*);
-PROTOBUF_NAMESPACE_CLOSE
+
PROTOBUF_NAMESPACE_OPEN
// ===================================================================
+
+// -------------------------------------------------------------------
+
class PROTOBUF_EXPORT SourceContext final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceContext) */ {
public:
@@ -124,7 +133,7 @@ class PROTOBUF_EXPORT SourceContext final :
}
void UnsafeArenaSwap(SourceContext* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -145,26 +154,25 @@ class PROTOBUF_EXPORT SourceContext final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(SourceContext* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.SourceContext";
}
protected:
- explicit SourceContext(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit SourceContext(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -180,19 +188,25 @@ class PROTOBUF_EXPORT SourceContext final :
kFileNameFieldNumber = 1,
};
// string file_name = 1;
- void clear_file_name();
+ void clear_file_name() ;
const TProtoStringType& file_name() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_file_name(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_file_name(Arg_&& arg, Args_... args);
TProtoStringType* mutable_file_name();
PROTOBUF_NODISCARD TProtoStringType* release_file_name();
- void set_allocated_file_name(TProtoStringType* file_name);
+ void set_allocated_file_name(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_file_name() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_file_name(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_file_name(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_file_name();
- public:
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.SourceContext)
private:
class _Internal;
@@ -207,15 +221,21 @@ class PROTOBUF_EXPORT SourceContext final :
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto;
};
+
// ===================================================================
+
+
// ===================================================================
+
#ifdef __GNUC__
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
+// -------------------------------------------------------------------
+
// SourceContext
// string file_name = 1;
@@ -226,11 +246,11 @@ inline const TProtoStringType& SourceContext::file_name() const {
// @@protoc_insertion_point(field_get:google.protobuf.SourceContext.file_name)
return _internal_file_name();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void SourceContext::set_file_name(ArgT0&& arg0, ArgT... args) {
-
- _impl_.file_name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void SourceContext::set_file_name(Arg_&& arg,
+ Args_... args) {
+ ;
+ _impl_.file_name_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name)
}
inline TProtoStringType* SourceContext::mutable_file_name() {
@@ -242,41 +262,39 @@ inline const TProtoStringType& SourceContext::_internal_file_name() const {
return _impl_.file_name_.Get();
}
inline void SourceContext::_internal_set_file_name(const TProtoStringType& value) {
-
+ ;
+
+
_impl_.file_name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* SourceContext::_internal_mutable_file_name() {
-
- return _impl_.file_name_.Mutable(GetArenaForAllocation());
+ ;
+ return _impl_.file_name_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* SourceContext::release_file_name() {
// @@protoc_insertion_point(field_release:google.protobuf.SourceContext.file_name)
return _impl_.file_name_.Release();
}
-inline void SourceContext::set_allocated_file_name(TProtoStringType* file_name) {
- if (file_name != nullptr) {
-
- } else {
-
- }
- _impl_.file_name_.SetAllocated(file_name, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.file_name_.IsDefault()) {
- _impl_.file_name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+inline void SourceContext::set_allocated_file_name(TProtoStringType* value) {
+ _impl_.file_name_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.file_name_.IsDefault()) {
+ _impl_.file_name_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name)
}
#ifdef __GNUC__
- #pragma GCC diagnostic pop
+#pragma GCC diagnostic pop
#endif // __GNUC__
// @@protoc_insertion_point(namespace_scope)
-
PROTOBUF_NAMESPACE_CLOSE
+
// @@protoc_insertion_point(global_scope)
-#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fsource_5fcontext_2eproto
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fsource_5fcontext_2eproto_2epb_2eh
diff --git a/contrib/libs/protobuf/src/google/protobuf/source_context.proto b/contrib/libs/protobuf/src/google/protobuf/source_context.proto
index 06bfc43a78e..135f50fea51 100644
--- a/contrib/libs/protobuf/src/google/protobuf/source_context.proto
+++ b/contrib/libs/protobuf/src/google/protobuf/source_context.proto
@@ -32,11 +32,11 @@ syntax = "proto3";
package google.protobuf;
-option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option java_package = "com.google.protobuf";
option java_outer_classname = "SourceContextProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
+option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option go_package = "google.golang.org/protobuf/types/known/sourcecontextpb";
// `SourceContext` represents information about the source of a
diff --git a/contrib/libs/protobuf/src/google/protobuf/string_block.h b/contrib/libs/protobuf/src/google/protobuf/string_block.h
new file mode 100644
index 00000000000..a59d922dc19
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/string_block.h
@@ -0,0 +1,164 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2023 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.
+//
+// This file defines the internal StringBlock class
+
+#ifndef GOOGLE_PROTOBUF_STRING_BLOCK_H__
+#define GOOGLE_PROTOBUF_STRING_BLOCK_H__
+
+#include <algorithm>
+#include <cstddef>
+#include <cstdint>
+#include <string>
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/log/absl_check.h"
+#include "google/protobuf/arena_align.h"
+#include "google/protobuf/port.h"
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace internal {
+
+// StringBlock provides heap allocated, dynamically sized blocks (mini arenas)
+// for allocating TProtoStringType instances. StringBlocks are allocated through
+// the `New` function, and must be freed using the `Delete` function.
+// StringBlocks are automatically sized from 256B to 8KB depending on the
+// `next` instance provided in the `New` function to keep the average maximum
+// unused space limited to 25%, or up to 4KB.
+class alignas(TProtoStringType) StringBlock {
+ public:
+ StringBlock() = delete;
+ StringBlock(const StringBlock&) = delete;
+ StringBlock& operator=(const StringBlock&) = delete;
+
+ // Allocates a new StringBlock pointing to `next`, which can be null.
+ // The size of the returned block depends on the allocated size of `next`.
+ static StringBlock* New(StringBlock* next);
+
+ // Deletes `block`. `block` must not be null.
+ static size_t Delete(StringBlock* block);
+
+ StringBlock* next() const;
+
+ // Returns the string instance at offset `offset`.
+ // `offset` must be a multiple of sizeof(TProtoStringType), and be less than or
+ // equal to `effective_size()`. `AtOffset(effective_size())` returns the
+ // end of the allocated string instances and must not be de-referenced.
+ Y_ABSL_ATTRIBUTE_RETURNS_NONNULL TProtoStringType* AtOffset(size_t offset);
+
+ // Returns a pointer to the first string instance in this block.
+ Y_ABSL_ATTRIBUTE_RETURNS_NONNULL TProtoStringType* begin();
+
+ // Returns a pointer directly beyond the last string instance in this block.
+ Y_ABSL_ATTRIBUTE_RETURNS_NONNULL TProtoStringType* end();
+
+ // Returns the total allocation size of this instance.
+ size_t allocated_size() const { return allocated_size_; }
+
+ // Returns the effective size available for allocation string instances.
+ // This value is guaranteed to be a multiple of sizeof(TProtoStringType), and
+ // guaranteed to never be zero.
+ size_t effective_size() const;
+
+ private:
+ static_assert(alignof(TProtoStringType) <= sizeof(void*), "");
+ static_assert(alignof(TProtoStringType) <= ArenaAlignDefault::align, "");
+
+ ~StringBlock() = default;
+
+ explicit StringBlock(StringBlock* next, arc_ui32 size,
+ arc_ui32 next_size) noexcept
+ : next_(next), allocated_size_(size), next_size_(next_size) {}
+
+ static constexpr arc_ui32 min_size() { return size_t{256}; }
+ static constexpr arc_ui32 max_size() { return size_t{8192}; }
+
+ // Returns the size of the next block.
+ size_t next_size() const { return next_size_; }
+
+ StringBlock* const next_;
+ const arc_ui32 allocated_size_;
+ const arc_ui32 next_size_;
+};
+
+inline StringBlock* StringBlock::New(StringBlock* next) {
+ // Compute required size, rounding down to a multiple of sizeof(std:string)
+ // so that we can optimize the allocation path. I.e., we incur a (constant
+ // size) MOD() operation cost here to avoid any MUL() later on.
+ arc_ui32 size = min_size();
+ arc_ui32 next_size = min_size();
+ if (next) {
+ size = next->next_size_;
+ next_size = std::min(size * 2, max_size());
+ }
+ size -= (size - sizeof(StringBlock)) % sizeof(TProtoStringType);
+ void* p = ::operator new(size);
+ return new (p) StringBlock(next, size, next_size);
+}
+
+inline size_t StringBlock::Delete(StringBlock* block) {
+ Y_ABSL_DCHECK(block != nullptr);
+ size_t size = block->allocated_size();
+ internal::SizedDelete(block, size);
+ return size;
+}
+
+inline StringBlock* StringBlock::next() const { return next_; }
+
+inline size_t StringBlock::effective_size() const {
+ return allocated_size_ - sizeof(StringBlock);
+}
+
+Y_ABSL_ATTRIBUTE_RETURNS_NONNULL inline TProtoStringType* StringBlock::AtOffset(
+ size_t offset) {
+ Y_ABSL_DCHECK_LE(offset, effective_size());
+ return reinterpret_cast<TProtoStringType*>(reinterpret_cast<char*>(this + 1) +
+ offset);
+}
+
+Y_ABSL_ATTRIBUTE_RETURNS_NONNULL inline TProtoStringType* StringBlock::begin() {
+ return AtOffset(0);
+}
+
+Y_ABSL_ATTRIBUTE_RETURNS_NONNULL inline TProtoStringType* StringBlock::end() {
+ return AtOffset(effective_size());
+}
+
+} // namespace internal
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_STRING_BLOCK_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/struct.pb.cc b/contrib/libs/protobuf/src/google/protobuf/struct.pb.cc
index cdd74ec1eea..fa4413fc98c 100644
--- a/contrib/libs/protobuf/src/google/protobuf/struct.pb.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/struct.pb.cc
@@ -1,168 +1,201 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/struct.proto
-#include <google/protobuf/struct.pb.h>
+#include "google/protobuf/struct.pb.h"
#include <algorithm>
-
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/extension_set.h>
-#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/reflection_ops.h>
-#include <google/protobuf/wire_format.h>
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/extension_set.h"
+#include "google/protobuf/wire_format_lite.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/reflection_ops.h"
+#include "google/protobuf/wire_format.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+// Must be included last.
+#include "google/protobuf/port_def.inc"
PROTOBUF_PRAGMA_INIT_SEG
-
namespace _pb = ::PROTOBUF_NAMESPACE_ID;
-namespace _pbi = _pb::internal;
-
+namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal;
PROTOBUF_NAMESPACE_OPEN
PROTOBUF_CONSTEXPR Struct_FieldsEntry_DoNotUse::Struct_FieldsEntry_DoNotUse(
::_pbi::ConstantInitialized) {}
struct Struct_FieldsEntry_DoNotUseDefaultTypeInternal {
- PROTOBUF_CONSTEXPR Struct_FieldsEntry_DoNotUseDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR Struct_FieldsEntry_DoNotUseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~Struct_FieldsEntry_DoNotUseDefaultTypeInternal() {}
union {
Struct_FieldsEntry_DoNotUse _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 Struct_FieldsEntry_DoNotUseDefaultTypeInternal _Struct_FieldsEntry_DoNotUse_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 Struct_FieldsEntry_DoNotUseDefaultTypeInternal _Struct_FieldsEntry_DoNotUse_default_instance_;
PROTOBUF_CONSTEXPR Struct::Struct(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_.fields_)*/{::_pbi::ConstantInitialized()}
, /*decltype(_impl_._cached_size_)*/{}} {}
struct StructDefaultTypeInternal {
- PROTOBUF_CONSTEXPR StructDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR StructDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~StructDefaultTypeInternal() {}
union {
Struct _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 StructDefaultTypeInternal _Struct_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 StructDefaultTypeInternal _Struct_default_instance_;
PROTOBUF_CONSTEXPR Value::Value(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_.kind_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
, /*decltype(_impl_._oneof_case_)*/{}} {}
struct ValueDefaultTypeInternal {
- PROTOBUF_CONSTEXPR ValueDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR ValueDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~ValueDefaultTypeInternal() {}
union {
Value _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ValueDefaultTypeInternal _Value_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ValueDefaultTypeInternal _Value_default_instance_;
PROTOBUF_CONSTEXPR ListValue::ListValue(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_.values_)*/{}
, /*decltype(_impl_._cached_size_)*/{}} {}
struct ListValueDefaultTypeInternal {
- PROTOBUF_CONSTEXPR ListValueDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR ListValueDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~ListValueDefaultTypeInternal() {}
union {
ListValue _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ListValueDefaultTypeInternal _ListValue_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ListValueDefaultTypeInternal _ListValue_default_instance_;
PROTOBUF_NAMESPACE_CLOSE
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_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse, key_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse, value_),
- 0,
- 1,
- ~0u, // no _has_bits_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Struct, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Struct, _impl_.fields_),
- ~0u, // no _has_bits_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Value, _internal_metadata_),
- ~0u, // no _extensions_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Value, _impl_._oneof_case_[0]),
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- ::_pbi::kInvalidFieldOffsetTag,
- ::_pbi::kInvalidFieldOffsetTag,
- ::_pbi::kInvalidFieldOffsetTag,
- ::_pbi::kInvalidFieldOffsetTag,
- ::_pbi::kInvalidFieldOffsetTag,
- ::_pbi::kInvalidFieldOffsetTag,
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Value, _impl_.kind_),
- ~0u, // no _has_bits_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ListValue, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ListValue, _impl_.values_),
+static constexpr const ::_pb::ServiceDescriptor**
+ 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_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse, key_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse, value_),
+ 0,
+ 1,
+ ~0u, // no _has_bits_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Struct, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Struct, _impl_.fields_),
+ ~0u, // no _has_bits_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Value, _internal_metadata_),
+ ~0u, // no _extensions_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Value, _impl_._oneof_case_[0]),
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ ::_pbi::kInvalidFieldOffsetTag,
+ ::_pbi::kInvalidFieldOffsetTag,
+ ::_pbi::kInvalidFieldOffsetTag,
+ ::_pbi::kInvalidFieldOffsetTag,
+ ::_pbi::kInvalidFieldOffsetTag,
+ ::_pbi::kInvalidFieldOffsetTag,
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Value, _impl_.kind_),
+ ~0u, // no _has_bits_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ListValue, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ListValue, _impl_.values_),
};
-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 const ::_pbi::MigrationSchema
+ schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ { 0, 10, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse)},
+ { 12, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Struct)},
+ { 21, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Value)},
+ { 36, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ListValue)},
};
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,
+ &::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) =
- "\n\034google/protobuf/struct.proto\022\017google.p"
- "rotobuf\"\204\001\n\006Struct\0223\n\006fields\030\001 \003(\0132#.goo"
- "gle.protobuf.Struct.FieldsEntry\032E\n\013Field"
- "sEntry\022\013\n\003key\030\001 \001(\t\022%\n\005value\030\002 \001(\0132\026.goo"
- "gle.protobuf.Value:\0028\001\"\352\001\n\005Value\0220\n\nnull"
- "_value\030\001 \001(\0162\032.google.protobuf.NullValue"
- "H\000\022\026\n\014number_value\030\002 \001(\001H\000\022\026\n\014string_val"
- "ue\030\003 \001(\tH\000\022\024\n\nbool_value\030\004 \001(\010H\000\022/\n\014stru"
- "ct_value\030\005 \001(\0132\027.google.protobuf.StructH"
- "\000\0220\n\nlist_value\030\006 \001(\0132\032.google.protobuf."
- "ListValueH\000B\006\n\004kind\"3\n\tListValue\022&\n\006valu"
- "es\030\001 \003(\0132\026.google.protobuf.Value*\033\n\tNull"
- "Value\022\016\n\nNULL_VALUE\020\000B\177\n\023com.google.prot"
- "obufB\013StructProtoP\001Z/google.golang.org/p"
- "rotobuf/types/known/structpb\370\001\001\242\002\003GPB\252\002\036"
- "Google.Protobuf.WellKnownTypesb\006proto3"
- ;
-static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fstruct_2eproto_once;
+const char descriptor_table_protodef_google_2fprotobuf_2fstruct_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ "\n\034google/protobuf/struct.proto\022\017google.p"
+ "rotobuf\"\204\001\n\006Struct\0223\n\006fields\030\001 \003(\0132#.goo"
+ "gle.protobuf.Struct.FieldsEntry\032E\n\013Field"
+ "sEntry\022\013\n\003key\030\001 \001(\t\022%\n\005value\030\002 \001(\0132\026.goo"
+ "gle.protobuf.Value:\0028\001\"\352\001\n\005Value\0220\n\nnull"
+ "_value\030\001 \001(\0162\032.google.protobuf.NullValue"
+ "H\000\022\026\n\014number_value\030\002 \001(\001H\000\022\026\n\014string_val"
+ "ue\030\003 \001(\tH\000\022\024\n\nbool_value\030\004 \001(\010H\000\022/\n\014stru"
+ "ct_value\030\005 \001(\0132\027.google.protobuf.StructH"
+ "\000\0220\n\nlist_value\030\006 \001(\0132\032.google.protobuf."
+ "ListValueH\000B\006\n\004kind\"3\n\tListValue\022&\n\006valu"
+ "es\030\001 \003(\0132\026.google.protobuf.Value*\033\n\tNull"
+ "Value\022\016\n\nNULL_VALUE\020\000B\177\n\023com.google.prot"
+ "obufB\013StructProtoP\001Z/google.golang.org/p"
+ "rotobuf/types/known/structpb\370\001\001\242\002\003GPB\252\002\036"
+ "Google.Protobuf.WellKnownTypesb\006proto3"
+};
+static ::y_absl::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,
+ 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,
+ &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,
};
+
+// This function exists to be marked as weak.
+// It can significantly speed up compilation by breaking up LLVM's SCC
+// in the .pb.cc translation units. Large translation units see a
+// reduction of more than 35% of walltime for optimized builds. Without
+// the weak attribute all the messages in the file, including all the
+// vtables and everything they use become part of the same SCC through
+// a cycle like:
+// GetMetadata -> descriptor table -> default instances ->
+// 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 ::_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_PRIORITY2 static ::_pbi::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);
@@ -176,8 +209,6 @@ bool NullValue_IsValid(int value) {
return false;
}
}
-
-
// ===================================================================
Struct_FieldsEntry_DoNotUse::Struct_FieldsEntry_DoNotUse() {}
@@ -191,18 +222,16 @@ void Struct_FieldsEntry_DoNotUse::MergeFrom(const Struct_FieldsEntry_DoNotUse& o
&descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter, &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once,
file_level_metadata_google_2fprotobuf_2fstruct_2eproto[0]);
}
-
// ===================================================================
class Struct::_Internal {
public:
};
-Struct::Struct(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
- if (arena != nullptr && !is_message_owned) {
+Struct::Struct(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
+ if (arena != nullptr) {
arena->OwnCustomDestructor(this, &Struct::ArenaDtor);
}
// @@protoc_insertion_point(arena_constructor:google.protobuf.Struct)
@@ -219,10 +248,8 @@ Struct::Struct(const Struct& from)
// @@protoc_insertion_point(copy_constructor:google.protobuf.Struct)
}
-inline void Struct::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void Struct::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
/*decltype(_impl_.fields_)*/{::_pbi::ArenaInitialized(), arena}
, /*decltype(_impl_._cached_size_)*/{}
@@ -240,7 +267,7 @@ Struct::~Struct() {
}
inline void Struct::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.fields_.Destruct();
_impl_.fields_.~MapField();
}
@@ -255,7 +282,7 @@ void Struct::SetCachedSize(int size) const {
void Struct::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Struct)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -266,12 +293,12 @@ void Struct::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// map<string, .google.protobuf.Value> fields = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
ptr -= 1;
do {
ptr += 1;
@@ -279,8 +306,9 @@ const char* Struct::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -305,10 +333,10 @@ failure:
#undef CHK_
}
-uint8_t* Struct::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* Struct::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Struct)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// map<string, .google.protobuf.Value> fields = 1;
@@ -319,9 +347,8 @@ uint8_t* Struct::_InternalSerialize(
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");
+ entry.first.data(), static_cast<int>(entry.first.length()),
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Struct.fields");
};
if (stream->IsSerializationDeterministic() && map_field.size() > 1) {
@@ -345,11 +372,11 @@ uint8_t* Struct::_InternalSerialize(
return target;
}
-size_t Struct::ByteSizeLong() const {
+::size_t Struct::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Struct)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -376,8 +403,8 @@ void Struct::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBU
auto* const _this = static_cast<Struct*>(&to_msg);
auto& from = static_cast<const Struct&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Struct)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.fields_.MergeFrom(from._impl_.fields_);
@@ -406,11 +433,12 @@ void Struct::InternalSwap(Struct* other) {
&descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter, &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once,
file_level_metadata_google_2fprotobuf_2fstruct_2eproto[1]);
}
-
// ===================================================================
class Value::_Internal {
public:
+ static constexpr ::arc_i32 kOneofCaseOffset =
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Value, _impl_._oneof_case_);
static const ::PROTOBUF_NAMESPACE_ID::Struct& struct_value(const Value* msg);
static const ::PROTOBUF_NAMESPACE_ID::ListValue& list_value(const Value* msg);
};
@@ -453,10 +481,9 @@ void Value::set_allocated_list_value(::PROTOBUF_NAMESPACE_ID::ListValue* list_va
}
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.list_value)
}
-Value::Value(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+Value::Value(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Value)
}
Value::Value(const Value& from)
@@ -503,10 +530,8 @@ Value::Value(const Value& from)
// @@protoc_insertion_point(copy_constructor:google.protobuf.Value)
}
-inline void Value::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void Value::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_.kind_){}
, /*decltype(_impl_._cached_size_)*/{}
@@ -525,7 +550,7 @@ Value::~Value() {
}
inline void Value::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
if (has_kind()) {
clear_kind();
}
@@ -576,7 +601,7 @@ void Value::clear_kind() {
void Value::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Value)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -587,59 +612,65 @@ void Value::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// .google.protobuf.NullValue null_value = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
- arc_ui64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) {
+ ::arc_ui32 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
_internal_set_null_value(static_cast<::PROTOBUF_NAMESPACE_ID::NullValue>(val));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// double number_value = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 17)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 17)) {
_internal_set_number_value(::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<double>(ptr));
ptr += sizeof(double);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// string string_value = 3;
case 3:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 26)) {
auto str = _internal_mutable_string_value();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Value.string_value"));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// bool bool_value = 4;
case 4:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 32)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 32)) {
_internal_set_bool_value(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr));
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// .google.protobuf.Struct struct_value = 5;
case 5:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 42)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 42)) {
ptr = ctx->ParseMessage(_internal_mutable_struct_value(), ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// .google.protobuf.ListValue list_value = 6;
case 6:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 50)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 50)) {
ptr = ctx->ParseMessage(_internal_mutable_list_value(), ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -664,50 +695,50 @@ failure:
#undef CHK_
}
-uint8_t* Value::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* Value::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Value)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// .google.protobuf.NullValue null_value = 1;
- if (_internal_has_null_value()) {
+ if (kind_case() == kNullValue) {
target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::WriteEnumToArray(
- 1, this->_internal_null_value(), target);
+ 1, this->_internal_null_value(), target);
}
// double number_value = 2;
- if (_internal_has_number_value()) {
+ if (kind_case() == kNumberValue) {
target = stream->EnsureSpace(target);
- target = ::_pbi::WireFormatLite::WriteDoubleToArray(2, this->_internal_number_value(), target);
+ target = ::_pbi::WireFormatLite::WriteDoubleToArray(
+ 2, this->_internal_number_value(), target);
}
// string string_value = 3;
- if (_internal_has_string_value()) {
+ if (kind_case() == kStringValue) {
+ const TProtoStringType& _s = this->_internal_string_value();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
- this->_internal_string_value().data(), static_cast<int>(this->_internal_string_value().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
- "google.protobuf.Value.string_value");
- target = stream->WriteStringMaybeAliased(
- 3, this->_internal_string_value(), target);
+ _s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Value.string_value");
+ target = stream->WriteStringMaybeAliased(3, _s, target);
}
// bool bool_value = 4;
- if (_internal_has_bool_value()) {
+ if (kind_case() == kBoolValue) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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()) {
+ if (kind_case() == kStructValue) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(5, _Internal::struct_value(this),
_Internal::struct_value(this).GetCachedSize(), target, stream);
}
// .google.protobuf.ListValue list_value = 6;
- if (_internal_has_list_value()) {
+ if (kind_case() == kListValue) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(6, _Internal::list_value(this),
_Internal::list_value(this).GetCachedSize(), target, stream);
@@ -721,11 +752,11 @@ uint8_t* Value::_InternalSerialize(
return target;
}
-size_t Value::ByteSizeLong() const {
+::size_t Value::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Value)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -733,24 +764,23 @@ size_t Value::ByteSizeLong() const {
// .google.protobuf.NullValue null_value = 1;
case kNullValue: {
total_size += 1 +
- ::_pbi::WireFormatLite::EnumSize(this->_internal_null_value());
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_null_value());
break;
}
// double number_value = 2;
case kNumberValue: {
- total_size += 1 + 8;
+ total_size += 9;
break;
}
// string string_value = 3;
case kStringValue: {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_string_value());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_string_value());
break;
}
// bool bool_value = 4;
case kBoolValue: {
- total_size += 1 + 1;
+ total_size += 2;
break;
}
// .google.protobuf.Struct struct_value = 5;
@@ -785,8 +815,8 @@ void Value::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF
auto* const _this = static_cast<Value*>(&to_msg);
auto& from = static_cast<const Value&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Value)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
switch (from.kind_case()) {
@@ -846,17 +876,15 @@ void Value::InternalSwap(Value* other) {
&descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter, &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once,
file_level_metadata_google_2fprotobuf_2fstruct_2eproto[2]);
}
-
// ===================================================================
class ListValue::_Internal {
public:
};
-ListValue::ListValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+ListValue::ListValue(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.ListValue)
}
ListValue::ListValue(const ListValue& from)
@@ -870,10 +898,8 @@ ListValue::ListValue(const ListValue& from)
// @@protoc_insertion_point(copy_constructor:google.protobuf.ListValue)
}
-inline void ListValue::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void ListValue::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_.values_){arena}
, /*decltype(_impl_._cached_size_)*/{}
@@ -890,7 +916,7 @@ ListValue::~ListValue() {
}
inline void ListValue::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.values_.~RepeatedPtrField();
}
@@ -900,7 +926,7 @@ void ListValue::SetCachedSize(int size) const {
void ListValue::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.ListValue)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -911,12 +937,12 @@ void ListValue::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated .google.protobuf.Value values = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
ptr -= 1;
do {
ptr += 1;
@@ -924,8 +950,9 @@ const char* ListValue::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -950,10 +977,10 @@ failure:
#undef CHK_
}
-uint8_t* ListValue::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* ListValue::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.ListValue)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .google.protobuf.Value values = 1;
@@ -972,11 +999,11 @@ uint8_t* ListValue::_InternalSerialize(
return target;
}
-size_t ListValue::ByteSizeLong() const {
+::size_t ListValue::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.ListValue)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -1001,8 +1028,8 @@ void ListValue::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROT
auto* const _this = static_cast<ListValue*>(&to_msg);
auto& from = static_cast<const ListValue&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ListValue)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.values_.MergeFrom(from._impl_.values_);
@@ -1031,7 +1058,6 @@ void ListValue::InternalSwap(ListValue* other) {
&descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter, &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once,
file_level_metadata_google_2fprotobuf_2fstruct_2eproto[3]);
}
-
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
@@ -1052,6 +1078,5 @@ Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::ListValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::ListValue >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
-
// @@protoc_insertion_point(global_scope)
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protobuf/src/google/protobuf/struct.pb.h b/contrib/libs/protobuf/src/google/protobuf/struct.pb.h
index b5d353e1a51..04e346b5772 100644
--- a/contrib/libs/protobuf/src/google/protobuf/struct.pb.h
+++ b/contrib/libs/protobuf/src/google/protobuf/struct.pb.h
@@ -1,42 +1,47 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/struct.proto
-#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fstruct_2eproto
-#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fstruct_2eproto
+#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fstruct_2eproto_2epb_2eh
+#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fstruct_2eproto_2epb_2eh
#include <limits>
#include <string>
-
-#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3021000
-#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 3021003 < 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.
-#endif
-
-#include <google/protobuf/port_undef.inc>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/arena.h>
-#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_util.h>
-#include <google/protobuf/metadata_lite.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h> // IWYU pragma: export
-#include <google/protobuf/extension_set.h> // IWYU pragma: export
-#include <google/protobuf/map.h> // IWYU pragma: export
-#include <google/protobuf/map_entry.h>
-#include <google/protobuf/map_field_inl.h>
-#include <google/protobuf/generated_enum_reflection.h>
-#include <google/protobuf/unknown_field_set.h>
+#include <type_traits>
+
+#include "google/protobuf/port_def.inc"
+#if PROTOBUF_VERSION < 4022000
+#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 // PROTOBUF_VERSION
+
+#if 4022005 < 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."
+#endif // PROTOBUF_MIN_PROTOC_VERSION
+#include "google/protobuf/port_undef.inc"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/arena.h"
+#include "google/protobuf/arenastring.h"
+#include "google/protobuf/generated_message_util.h"
+#include "google/protobuf/metadata_lite.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/repeated_field.h" // IWYU pragma: export
+#include "google/protobuf/extension_set.h" // IWYU pragma: export
+#include "google/protobuf/map.h" // IWYU pragma: export
+#include "google/protobuf/map_entry.h"
+#include "google/protobuf/map_field_inl.h"
+#include "google/protobuf/generated_enum_reflection.h"
+#include "google/protobuf/unknown_field_set.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fstruct_2eproto PROTOBUF_EXPORT
+
PROTOBUF_NAMESPACE_OPEN
namespace internal {
class AnyMetadata;
@@ -45,9 +50,10 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fstruct_2eproto {
- static const arc_ui32 offsets[];
+ static const ::arc_ui32 offsets[];
};
-PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fstruct_2eproto;
+PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable
+ descriptor_table_google_2fprotobuf_2fstruct_2eproto;
PROTOBUF_NAMESPACE_OPEN
class ListValue;
struct ListValueDefaultTypeInternal;
@@ -61,42 +67,55 @@ PROTOBUF_EXPORT extern Struct_FieldsEntry_DoNotUseDefaultTypeInternal _Struct_Fi
class Value;
struct ValueDefaultTypeInternal;
PROTOBUF_EXPORT extern ValueDefaultTypeInternal _Value_default_instance_;
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::ListValue* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::ListValue>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Struct* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Struct>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Value* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Value>(Arena*);
PROTOBUF_NAMESPACE_CLOSE
-PROTOBUF_NAMESPACE_OPEN
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::ListValue* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::ListValue>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Struct* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Struct>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Value* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Value>(Arena*);
-PROTOBUF_NAMESPACE_CLOSE
-PROTOBUF_NAMESPACE_OPEN
+PROTOBUF_NAMESPACE_OPEN
enum NullValue : int {
NULL_VALUE = 0,
- NullValue_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits<arc_i32>::min(),
- NullValue_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits<arc_i32>::max()
+ NullValue_INT_MIN_SENTINEL_DO_NOT_USE_ =
+ std::numeric_limits<::arc_i32>::min(),
+ NullValue_INT_MAX_SENTINEL_DO_NOT_USE_ =
+ std::numeric_limits<::arc_i32>::max(),
};
+
PROTOBUF_EXPORT bool NullValue_IsValid(int value);
-constexpr NullValue NullValue_MIN = NULL_VALUE;
-constexpr NullValue NullValue_MAX = NULL_VALUE;
-constexpr int NullValue_ARRAYSIZE = NullValue_MAX + 1;
-
-PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* NullValue_descriptor();
-template<typename T>
-inline const TProtoStringType& NullValue_Name(T enum_t_value) {
- static_assert(::std::is_same<T, NullValue>::value ||
- ::std::is_integral<T>::value,
- "Incorrect type passed to function NullValue_Name.");
- return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum(
- NullValue_descriptor(), enum_t_value);
-}
-inline bool NullValue_Parse(
- ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, NullValue* value) {
+constexpr NullValue NullValue_MIN = static_cast<NullValue>(0);
+constexpr NullValue NullValue_MAX = static_cast<NullValue>(0);
+constexpr int NullValue_ARRAYSIZE = 0 + 1;
+PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
+NullValue_descriptor();
+template <typename T>
+const TProtoStringType& NullValue_Name(T value) {
+ static_assert(std::is_same<T, NullValue>::value ||
+ std::is_integral<T>::value,
+ "Incorrect type passed to NullValue_Name().");
+ return NullValue_Name(static_cast<NullValue>(value));
+}
+template <>
+inline const TProtoStringType& NullValue_Name(NullValue value) {
+ return ::PROTOBUF_NAMESPACE_ID::internal::NameOfDenseEnum<NullValue_descriptor,
+ 0, 0>(
+ static_cast<int>(value));
+}
+inline bool NullValue_Parse(y_absl::string_view name, NullValue* value) {
return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum<NullValue>(
- NullValue_descriptor(), name, value);
+ NullValue_descriptor(), name, value);
}
+
// ===================================================================
-class Struct_FieldsEntry_DoNotUse : public ::PROTOBUF_NAMESPACE_ID::internal::MapEntry<Struct_FieldsEntry_DoNotUse,
+
+// -------------------------------------------------------------------
+
+class Struct_FieldsEntry_DoNotUse final : public ::PROTOBUF_NAMESPACE_ID::internal::MapEntry<Struct_FieldsEntry_DoNotUse,
TProtoStringType, ::PROTOBUF_NAMESPACE_ID::Value,
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING,
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_MESSAGE> {
@@ -119,7 +138,6 @@ public:
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
friend struct ::TableStruct_google_2fprotobuf_2fstruct_2eproto;
};
-
// -------------------------------------------------------------------
class PROTOBUF_EXPORT Struct final :
@@ -190,7 +208,7 @@ class PROTOBUF_EXPORT Struct final :
}
void UnsafeArenaSwap(Struct* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -211,26 +229,25 @@ class PROTOBUF_EXPORT Struct final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(Struct* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.Struct";
}
protected:
- explicit Struct(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit Struct(::PROTOBUF_NAMESPACE_ID::Arena* arena);
private:
static void ArenaDtor(void* object);
public:
@@ -252,8 +269,9 @@ class PROTOBUF_EXPORT Struct final :
int fields_size() const;
private:
int _internal_fields_size() const;
+
public:
- void clear_fields();
+ void clear_fields() ;
private:
const ::PROTOBUF_NAMESPACE_ID::Map< TProtoStringType, ::PROTOBUF_NAMESPACE_ID::Value >&
_internal_fields() const;
@@ -264,7 +282,6 @@ class PROTOBUF_EXPORT Struct final :
fields() const;
::PROTOBUF_NAMESPACE_ID::Map< TProtoStringType, ::PROTOBUF_NAMESPACE_ID::Value >*
mutable_fields();
-
// @@protoc_insertion_point(class_scope:google.protobuf.Struct)
private:
class _Internal;
@@ -282,8 +299,7 @@ class PROTOBUF_EXPORT Struct final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fstruct_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT Value final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Value) */ {
@@ -363,7 +379,7 @@ class PROTOBUF_EXPORT Value final :
}
void UnsafeArenaSwap(Value* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -384,26 +400,25 @@ class PROTOBUF_EXPORT Value final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(Value* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.Value";
}
protected:
- explicit Value(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit Value(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -425,67 +440,65 @@ class PROTOBUF_EXPORT Value final :
};
// .google.protobuf.NullValue null_value = 1;
bool has_null_value() const;
- private:
- bool _internal_has_null_value() const;
- public:
- void clear_null_value();
+ void clear_null_value() ;
::PROTOBUF_NAMESPACE_ID::NullValue null_value() const;
void set_null_value(::PROTOBUF_NAMESPACE_ID::NullValue value);
+
private:
::PROTOBUF_NAMESPACE_ID::NullValue _internal_null_value() const;
void _internal_set_null_value(::PROTOBUF_NAMESPACE_ID::NullValue value);
- public:
+ public:
// double number_value = 2;
bool has_number_value() const;
- private:
- bool _internal_has_number_value() const;
- public:
- void clear_number_value();
+ void clear_number_value() ;
double number_value() const;
void set_number_value(double value);
+
private:
double _internal_number_value() const;
void _internal_set_number_value(double value);
- public:
+ public:
// string string_value = 3;
bool has_string_value() const;
- private:
- bool _internal_has_string_value() const;
- public:
- void clear_string_value();
+ void clear_string_value() ;
const TProtoStringType& string_value() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_string_value(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_string_value(Arg_&& arg, Args_... args);
TProtoStringType* mutable_string_value();
PROTOBUF_NODISCARD TProtoStringType* release_string_value();
- void set_allocated_string_value(TProtoStringType* string_value);
+ void set_allocated_string_value(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_string_value() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_string_value(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_string_value(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_string_value();
- public:
+ public:
// bool bool_value = 4;
bool has_bool_value() const;
- private:
- bool _internal_has_bool_value() const;
- public:
- void clear_bool_value();
+ void clear_bool_value() ;
bool bool_value() const;
void set_bool_value(bool value);
+
private:
bool _internal_bool_value() const;
void _internal_set_bool_value(bool value);
- public:
+ public:
// .google.protobuf.Struct struct_value = 5;
bool has_struct_value() const;
private:
bool _internal_has_struct_value() const;
+
public:
- void clear_struct_value();
+ void clear_struct_value() ;
const ::PROTOBUF_NAMESPACE_ID::Struct& struct_value() const;
PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::Struct* release_struct_value();
::PROTOBUF_NAMESPACE_ID::Struct* mutable_struct_value();
@@ -497,13 +510,13 @@ class PROTOBUF_EXPORT Value final :
void unsafe_arena_set_allocated_struct_value(
::PROTOBUF_NAMESPACE_ID::Struct* struct_value);
::PROTOBUF_NAMESPACE_ID::Struct* unsafe_arena_release_struct_value();
-
// .google.protobuf.ListValue list_value = 6;
bool has_list_value() const;
private:
bool _internal_has_list_value() const;
+
public:
- void clear_list_value();
+ void clear_list_value() ;
const ::PROTOBUF_NAMESPACE_ID::ListValue& list_value() const;
PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::ListValue* release_list_value();
::PROTOBUF_NAMESPACE_ID::ListValue* mutable_list_value();
@@ -515,7 +528,6 @@ class PROTOBUF_EXPORT Value final :
void unsafe_arena_set_allocated_list_value(
::PROTOBUF_NAMESPACE_ID::ListValue* list_value);
::PROTOBUF_NAMESPACE_ID::ListValue* unsafe_arena_release_list_value();
-
void clear_kind();
KindCase kind_case() const;
// @@protoc_insertion_point(class_scope:google.protobuf.Value)
@@ -546,13 +558,12 @@ class PROTOBUF_EXPORT Value final :
::PROTOBUF_NAMESPACE_ID::ListValue* list_value_;
} kind_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
- arc_ui32 _oneof_case_[1];
+ ::arc_ui32 _oneof_case_[1];
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fstruct_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT ListValue final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ListValue) */ {
@@ -622,7 +633,7 @@ class PROTOBUF_EXPORT ListValue final :
}
void UnsafeArenaSwap(ListValue* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -643,26 +654,25 @@ class PROTOBUF_EXPORT ListValue final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(ListValue* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.ListValue";
}
protected:
- explicit ListValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit ListValue(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -681,8 +691,9 @@ class PROTOBUF_EXPORT ListValue final :
int values_size() const;
private:
int _internal_values_size() const;
+
public:
- void clear_values();
+ void clear_values() ;
::PROTOBUF_NAMESPACE_ID::Value* mutable_values(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Value >*
mutable_values();
@@ -694,7 +705,6 @@ class PROTOBUF_EXPORT ListValue final :
::PROTOBUF_NAMESPACE_ID::Value* add_values();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Value >&
values() const;
-
// @@protoc_insertion_point(class_scope:google.protobuf.ListValue)
private:
class _Internal;
@@ -709,17 +719,23 @@ class PROTOBUF_EXPORT ListValue final :
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fstruct_2eproto;
};
+
// ===================================================================
+
+
// ===================================================================
+
#ifdef __GNUC__
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
// -------------------------------------------------------------------
+// -------------------------------------------------------------------
+
// Struct
// map<string, .google.protobuf.Value> fields = 1;
@@ -756,93 +772,84 @@ Struct::mutable_fields() {
// Value
// .google.protobuf.NullValue null_value = 1;
-inline bool Value::_internal_has_null_value() const {
- return kind_case() == kNullValue;
-}
inline bool Value::has_null_value() const {
- return _internal_has_null_value();
+ return kind_case() == kNullValue;
}
inline void Value::set_has_null_value() {
_impl_._oneof_case_[0] = kNullValue;
}
inline void Value::clear_null_value() {
- if (_internal_has_null_value()) {
+ if (kind_case() == kNullValue) {
_impl_.kind_.null_value_ = 0;
clear_has_kind();
}
}
-inline ::PROTOBUF_NAMESPACE_ID::NullValue Value::_internal_null_value() const {
- if (_internal_has_null_value()) {
- return static_cast< ::PROTOBUF_NAMESPACE_ID::NullValue >(_impl_.kind_.null_value_);
- }
- return static_cast< ::PROTOBUF_NAMESPACE_ID::NullValue >(0);
-}
inline ::PROTOBUF_NAMESPACE_ID::NullValue Value::null_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.Value.null_value)
return _internal_null_value();
}
+inline void Value::set_null_value(::PROTOBUF_NAMESPACE_ID::NullValue value) {
+ _internal_set_null_value(value);
+ // @@protoc_insertion_point(field_set:google.protobuf.Value.null_value)
+}
+inline ::PROTOBUF_NAMESPACE_ID::NullValue Value::_internal_null_value() const {
+ if (kind_case() == kNullValue) {
+ return static_cast<::PROTOBUF_NAMESPACE_ID::NullValue>(_impl_.kind_.null_value_);
+ }
+ return static_cast<::PROTOBUF_NAMESPACE_ID::NullValue>(0);
+}
inline void Value::_internal_set_null_value(::PROTOBUF_NAMESPACE_ID::NullValue value) {
- if (!_internal_has_null_value()) {
+ if (kind_case() != kNullValue) {
clear_kind();
set_has_null_value();
}
_impl_.kind_.null_value_ = value;
}
-inline void Value::set_null_value(::PROTOBUF_NAMESPACE_ID::NullValue value) {
- _internal_set_null_value(value);
- // @@protoc_insertion_point(field_set:google.protobuf.Value.null_value)
-}
// double number_value = 2;
-inline bool Value::_internal_has_number_value() const {
- return kind_case() == kNumberValue;
-}
inline bool Value::has_number_value() const {
- return _internal_has_number_value();
+ return kind_case() == kNumberValue;
}
inline void Value::set_has_number_value() {
_impl_._oneof_case_[0] = kNumberValue;
}
inline void Value::clear_number_value() {
- if (_internal_has_number_value()) {
+ if (kind_case() == kNumberValue) {
_impl_.kind_.number_value_ = 0;
clear_has_kind();
}
}
+inline double Value::number_value() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.Value.number_value)
+ return _internal_number_value();
+}
+inline void Value::set_number_value(double value) {
+ _internal_set_number_value(value);
+ // @@protoc_insertion_point(field_set:google.protobuf.Value.number_value)
+}
inline double Value::_internal_number_value() const {
- if (_internal_has_number_value()) {
+ if (kind_case() == kNumberValue) {
return _impl_.kind_.number_value_;
}
return 0;
}
inline void Value::_internal_set_number_value(double value) {
- if (!_internal_has_number_value()) {
+ if (kind_case() != kNumberValue) {
clear_kind();
set_has_number_value();
}
_impl_.kind_.number_value_ = value;
}
-inline double Value::number_value() const {
- // @@protoc_insertion_point(field_get:google.protobuf.Value.number_value)
- return _internal_number_value();
-}
-inline void Value::set_number_value(double value) {
- _internal_set_number_value(value);
- // @@protoc_insertion_point(field_set:google.protobuf.Value.number_value)
-}
// string string_value = 3;
-inline bool Value::_internal_has_string_value() const {
- return kind_case() == kStringValue;
-}
inline bool Value::has_string_value() const {
- return _internal_has_string_value();
+ return kind_case() == kStringValue;
}
inline void Value::set_has_string_value() {
_impl_._oneof_case_[0] = kStringValue;
}
inline void Value::clear_string_value() {
- if (_internal_has_string_value()) {
+ if (kind_case() == kStringValue) {
_impl_.kind_.string_value_.Destroy();
clear_has_kind();
}
@@ -851,14 +858,16 @@ inline const TProtoStringType& Value::string_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.Value.string_value)
return _internal_string_value();
}
-template <typename ArgT0, typename... ArgT>
-inline void Value::set_string_value(ArgT0&& arg0, ArgT... args) {
- if (!_internal_has_string_value()) {
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void Value::set_string_value(Arg_&& arg,
+ Args_... args) {
+ if (kind_case() != kStringValue) {
clear_kind();
+
set_has_string_value();
_impl_.kind_.string_value_.InitDefault();
}
- _impl_.kind_.string_value_.Set( static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ _impl_.kind_.string_value_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Value.string_value)
}
inline TProtoStringType* Value::mutable_string_value() {
@@ -867,97 +876,97 @@ inline TProtoStringType* Value::mutable_string_value() {
return _s;
}
inline const TProtoStringType& Value::_internal_string_value() const {
- if (_internal_has_string_value()) {
- return _impl_.kind_.string_value_.Get();
+ if (kind_case() != kStringValue) {
+ return ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited();
}
- return ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited();
+ return _impl_.kind_.string_value_.Get();
}
inline void Value::_internal_set_string_value(const TProtoStringType& value) {
- if (!_internal_has_string_value()) {
+ if (kind_case() != kStringValue) {
clear_kind();
+
set_has_string_value();
_impl_.kind_.string_value_.InitDefault();
}
+
+
_impl_.kind_.string_value_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Value::_internal_mutable_string_value() {
- if (!_internal_has_string_value()) {
+ if (kind_case() != kStringValue) {
clear_kind();
+
set_has_string_value();
_impl_.kind_.string_value_.InitDefault();
}
- return _impl_.kind_.string_value_.Mutable( GetArenaForAllocation());
+ return _impl_.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 _impl_.kind_.string_value_.Release();
- } else {
+ if (kind_case() != kStringValue) {
return nullptr;
}
+ clear_has_kind();
+ return _impl_.kind_.string_value_.Release();
}
-inline void Value::set_allocated_string_value(TProtoStringType* string_value) {
+inline void Value::set_allocated_string_value(TProtoStringType* value) {
if (has_kind()) {
clear_kind();
}
- if (string_value != nullptr) {
+ if (value != nullptr) {
set_has_string_value();
- _impl_.kind_.string_value_.InitAllocated(string_value, GetArenaForAllocation());
+ _impl_.kind_.string_value_.InitAllocated(value, GetArenaForAllocation());
}
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.string_value)
}
// bool bool_value = 4;
-inline bool Value::_internal_has_bool_value() const {
- return kind_case() == kBoolValue;
-}
inline bool Value::has_bool_value() const {
- return _internal_has_bool_value();
+ return kind_case() == kBoolValue;
}
inline void Value::set_has_bool_value() {
_impl_._oneof_case_[0] = kBoolValue;
}
inline void Value::clear_bool_value() {
- if (_internal_has_bool_value()) {
+ if (kind_case() == kBoolValue) {
_impl_.kind_.bool_value_ = false;
clear_has_kind();
}
}
+inline bool Value::bool_value() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.Value.bool_value)
+ return _internal_bool_value();
+}
+inline void Value::set_bool_value(bool value) {
+ _internal_set_bool_value(value);
+ // @@protoc_insertion_point(field_set:google.protobuf.Value.bool_value)
+}
inline bool Value::_internal_bool_value() const {
- if (_internal_has_bool_value()) {
+ if (kind_case() == kBoolValue) {
return _impl_.kind_.bool_value_;
}
return false;
}
inline void Value::_internal_set_bool_value(bool value) {
- if (!_internal_has_bool_value()) {
+ if (kind_case() != kBoolValue) {
clear_kind();
set_has_bool_value();
}
_impl_.kind_.bool_value_ = value;
}
-inline bool Value::bool_value() const {
- // @@protoc_insertion_point(field_get:google.protobuf.Value.bool_value)
- return _internal_bool_value();
-}
-inline void Value::set_bool_value(bool value) {
- _internal_set_bool_value(value);
- // @@protoc_insertion_point(field_set:google.protobuf.Value.bool_value)
-}
// .google.protobuf.Struct struct_value = 5;
-inline bool Value::_internal_has_struct_value() const {
+inline bool Value::has_struct_value() const {
return kind_case() == kStructValue;
}
-inline bool Value::has_struct_value() const {
- return _internal_has_struct_value();
+inline bool Value::_internal_has_struct_value() const {
+ return kind_case() == kStructValue;
}
inline void Value::set_has_struct_value() {
_impl_._oneof_case_[0] = kStructValue;
}
inline void Value::clear_struct_value() {
- if (_internal_has_struct_value()) {
+ if (kind_case() == kStructValue) {
if (GetArenaForAllocation() == nullptr) {
delete _impl_.kind_.struct_value_;
}
@@ -966,7 +975,7 @@ inline void Value::clear_struct_value() {
}
inline ::PROTOBUF_NAMESPACE_ID::Struct* Value::release_struct_value() {
// @@protoc_insertion_point(field_release:google.protobuf.Value.struct_value)
- if (_internal_has_struct_value()) {
+ if (kind_case() == kStructValue) {
clear_has_kind();
::PROTOBUF_NAMESPACE_ID::Struct* temp = _impl_.kind_.struct_value_;
if (GetArenaForAllocation() != nullptr) {
@@ -979,7 +988,7 @@ inline ::PROTOBUF_NAMESPACE_ID::Struct* Value::release_struct_value() {
}
}
inline const ::PROTOBUF_NAMESPACE_ID::Struct& Value::_internal_struct_value() const {
- return _internal_has_struct_value()
+ return kind_case() == kStructValue
? *_impl_.kind_.struct_value_
: reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::Struct&>(::PROTOBUF_NAMESPACE_ID::_Struct_default_instance_);
}
@@ -989,7 +998,7 @@ inline const ::PROTOBUF_NAMESPACE_ID::Struct& Value::struct_value() const {
}
inline ::PROTOBUF_NAMESPACE_ID::Struct* Value::unsafe_arena_release_struct_value() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Value.struct_value)
- if (_internal_has_struct_value()) {
+ if (kind_case() == kStructValue) {
clear_has_kind();
::PROTOBUF_NAMESPACE_ID::Struct* temp = _impl_.kind_.struct_value_;
_impl_.kind_.struct_value_ = nullptr;
@@ -1007,7 +1016,7 @@ inline void Value::unsafe_arena_set_allocated_struct_value(::PROTOBUF_NAMESPACE_
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.struct_value)
}
inline ::PROTOBUF_NAMESPACE_ID::Struct* Value::_internal_mutable_struct_value() {
- if (!_internal_has_struct_value()) {
+ if (kind_case() != kStructValue) {
clear_kind();
set_has_struct_value();
_impl_.kind_.struct_value_ = CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Struct >(GetArenaForAllocation());
@@ -1021,17 +1030,17 @@ inline ::PROTOBUF_NAMESPACE_ID::Struct* Value::mutable_struct_value() {
}
// .google.protobuf.ListValue list_value = 6;
-inline bool Value::_internal_has_list_value() const {
+inline bool Value::has_list_value() const {
return kind_case() == kListValue;
}
-inline bool Value::has_list_value() const {
- return _internal_has_list_value();
+inline bool Value::_internal_has_list_value() const {
+ return kind_case() == kListValue;
}
inline void Value::set_has_list_value() {
_impl_._oneof_case_[0] = kListValue;
}
inline void Value::clear_list_value() {
- if (_internal_has_list_value()) {
+ if (kind_case() == kListValue) {
if (GetArenaForAllocation() == nullptr) {
delete _impl_.kind_.list_value_;
}
@@ -1040,7 +1049,7 @@ inline void Value::clear_list_value() {
}
inline ::PROTOBUF_NAMESPACE_ID::ListValue* Value::release_list_value() {
// @@protoc_insertion_point(field_release:google.protobuf.Value.list_value)
- if (_internal_has_list_value()) {
+ if (kind_case() == kListValue) {
clear_has_kind();
::PROTOBUF_NAMESPACE_ID::ListValue* temp = _impl_.kind_.list_value_;
if (GetArenaForAllocation() != nullptr) {
@@ -1053,7 +1062,7 @@ inline ::PROTOBUF_NAMESPACE_ID::ListValue* Value::release_list_value() {
}
}
inline const ::PROTOBUF_NAMESPACE_ID::ListValue& Value::_internal_list_value() const {
- return _internal_has_list_value()
+ return kind_case() == kListValue
? *_impl_.kind_.list_value_
: reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::ListValue&>(::PROTOBUF_NAMESPACE_ID::_ListValue_default_instance_);
}
@@ -1063,7 +1072,7 @@ inline const ::PROTOBUF_NAMESPACE_ID::ListValue& Value::list_value() const {
}
inline ::PROTOBUF_NAMESPACE_ID::ListValue* Value::unsafe_arena_release_list_value() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Value.list_value)
- if (_internal_has_list_value()) {
+ if (kind_case() == kListValue) {
clear_has_kind();
::PROTOBUF_NAMESPACE_ID::ListValue* temp = _impl_.kind_.list_value_;
_impl_.kind_.list_value_ = nullptr;
@@ -1081,7 +1090,7 @@ inline void Value::unsafe_arena_set_allocated_list_value(::PROTOBUF_NAMESPACE_ID
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.list_value)
}
inline ::PROTOBUF_NAMESPACE_ID::ListValue* Value::_internal_mutable_list_value() {
- if (!_internal_has_list_value()) {
+ if (kind_case() != kListValue) {
clear_kind();
set_has_list_value();
_impl_.kind_.list_value_ = CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::ListValue >(GetArenaForAllocation());
@@ -1148,24 +1157,19 @@ ListValue::values() const {
}
#ifdef __GNUC__
- #pragma GCC diagnostic pop
+#pragma GCC diagnostic pop
#endif // __GNUC__
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
// @@protoc_insertion_point(namespace_scope)
-
PROTOBUF_NAMESPACE_CLOSE
+
PROTOBUF_NAMESPACE_OPEN
-template <> struct is_proto_enum< ::PROTOBUF_NAMESPACE_ID::NullValue> : ::std::true_type {};
template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::PROTOBUF_NAMESPACE_ID::NullValue>() {
+struct is_proto_enum<::PROTOBUF_NAMESPACE_ID::NullValue> : std::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor<::PROTOBUF_NAMESPACE_ID::NullValue>() {
return ::PROTOBUF_NAMESPACE_ID::NullValue_descriptor();
}
@@ -1173,5 +1177,6 @@ PROTOBUF_NAMESPACE_CLOSE
// @@protoc_insertion_point(global_scope)
-#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fstruct_2eproto
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fstruct_2eproto_2epb_2eh
diff --git a/contrib/libs/protobuf/src/google/protobuf/struct.proto b/contrib/libs/protobuf/src/google/protobuf/struct.proto
index 0ac843ca08f..c4ea6453eae 100644
--- a/contrib/libs/protobuf/src/google/protobuf/struct.proto
+++ b/contrib/libs/protobuf/src/google/protobuf/struct.proto
@@ -32,13 +32,13 @@ syntax = "proto3";
package google.protobuf;
-option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option cc_enable_arenas = true;
option go_package = "google.golang.org/protobuf/types/known/structpb";
option java_package = "com.google.protobuf";
option java_outer_classname = "StructProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
+option csharp_namespace = "Google.Protobuf.WellKnownTypes";
// `Struct` represents a structured data value, consisting of fields
// which map to dynamically typed values. In some languages, `Struct`
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/bytestream.cc b/contrib/libs/protobuf/src/google/protobuf/stubs/bytestream.cc
deleted file mode 100644
index 980d6f6cfc5..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/bytestream.cc
+++ /dev/null
@@ -1,194 +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/stubs/bytestream.h>
-
-#include <string.h>
-#include <algorithm>
-
-#include <google/protobuf/stubs/logging.h>
-
-namespace google {
-namespace protobuf {
-namespace strings {
-
-void ByteSource::CopyTo(ByteSink* sink, size_t n) {
- while (n > 0) {
- StringPiece fragment = Peek();
- if (fragment.empty()) {
- GOOGLE_LOG(DFATAL) << "ByteSource::CopyTo() overran input.";
- break;
- }
- std::size_t fragment_size = std::min<std::size_t>(n, fragment.size());
- sink->Append(fragment.data(), fragment_size);
- Skip(fragment_size);
- n -= fragment_size;
- }
-}
-
-void ByteSink::Flush() {}
-
-void UncheckedArrayByteSink::Append(const char* data, size_t n) {
- if (data != dest_) {
- // Catch cases where the pointer returned by GetAppendBuffer() was modified.
- GOOGLE_DCHECK(!(dest_ <= data && data < (dest_ + n)))
- << "Append() data[] overlaps with dest_[]";
- memcpy(dest_, data, n);
- }
- dest_ += n;
-}
-
-CheckedArrayByteSink::CheckedArrayByteSink(char* outbuf, size_t capacity)
- : outbuf_(outbuf), capacity_(capacity), size_(0), overflowed_(false) {
-}
-
-void CheckedArrayByteSink::Append(const char* bytes, size_t n) {
- size_t available = capacity_ - size_;
- if (n > available) {
- n = available;
- overflowed_ = true;
- }
- if (n > 0 && bytes != (outbuf_ + size_)) {
- // Catch cases where the pointer returned by GetAppendBuffer() was modified.
- GOOGLE_DCHECK(!(outbuf_ <= bytes && bytes < (outbuf_ + capacity_)))
- << "Append() bytes[] overlaps with outbuf_[]";
- memcpy(outbuf_ + size_, bytes, n);
- }
- size_ += n;
-}
-
-GrowingArrayByteSink::GrowingArrayByteSink(size_t estimated_size)
- : capacity_(estimated_size),
- buf_(new char[estimated_size]),
- size_(0) {
-}
-
-GrowingArrayByteSink::~GrowingArrayByteSink() {
- delete[] buf_; // Just in case the user didn't call GetBuffer.
-}
-
-void GrowingArrayByteSink::Append(const char* bytes, size_t n) {
- size_t available = capacity_ - size_;
- if (bytes != (buf_ + size_)) {
- // Catch cases where the pointer returned by GetAppendBuffer() was modified.
- // We need to test for this before calling Expand() which may reallocate.
- GOOGLE_DCHECK(!(buf_ <= bytes && bytes < (buf_ + capacity_)))
- << "Append() bytes[] overlaps with buf_[]";
- }
- if (n > available) {
- Expand(n - available);
- }
- if (n > 0 && bytes != (buf_ + size_)) {
- memcpy(buf_ + size_, bytes, n);
- }
- size_ += n;
-}
-
-char* GrowingArrayByteSink::GetBuffer(size_t* nbytes) {
- ShrinkToFit();
- char* b = buf_;
- *nbytes = size_;
- buf_ = nullptr;
- size_ = capacity_ = 0;
- return b;
-}
-
-void GrowingArrayByteSink::Expand(size_t amount) { // Expand by at least 50%.
- size_t new_capacity = std::max(capacity_ + amount, (3 * capacity_) / 2);
- char* bigger = new char[new_capacity];
- memcpy(bigger, buf_, size_);
- delete[] buf_;
- buf_ = bigger;
- capacity_ = new_capacity;
-}
-
-void GrowingArrayByteSink::ShrinkToFit() {
- // Shrink only if the buffer is large and size_ is less than 3/4
- // of capacity_.
- if (capacity_ > 256 && size_ < (3 * capacity_) / 4) {
- char* just_enough = new char[size_];
- memcpy(just_enough, buf_, size_);
- delete[] buf_;
- buf_ = just_enough;
- capacity_ = size_;
- }
-}
-
-void StringByteSink::Append(const char* data, size_t n) {
- dest_->append(data, n);
-}
-
-size_t ArrayByteSource::Available() const {
- return input_.size();
-}
-
-StringPiece ArrayByteSource::Peek() {
- return input_;
-}
-
-void ArrayByteSource::Skip(size_t n) {
- GOOGLE_DCHECK_LE(n, input_.size());
- input_.remove_prefix(n);
-}
-
-LimitByteSource::LimitByteSource(ByteSource *source, size_t limit)
- : source_(source),
- limit_(limit) {
-}
-
-size_t LimitByteSource::Available() const {
- size_t available = source_->Available();
- if (available > limit_) {
- available = limit_;
- }
-
- return available;
-}
-
-StringPiece LimitByteSource::Peek() {
- StringPiece piece = source_->Peek();
- return StringPiece(piece.data(), std::min(piece.size(), limit_));
-}
-
-void LimitByteSource::Skip(size_t n) {
- GOOGLE_DCHECK_LE(n, limit_);
- source_->Skip(n);
- limit_ -= n;
-}
-
-void LimitByteSource::CopyTo(ByteSink *sink, size_t n) {
- GOOGLE_DCHECK_LE(n, limit_);
- source_->CopyTo(sink, n);
- limit_ -= n;
-}
-
-} // namespace strings
-} // namespace protobuf
-} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/bytestream.h b/contrib/libs/protobuf/src/google/protobuf/stubs/bytestream.h
deleted file mode 100644
index 05d69ab89fc..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/bytestream.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.
-
-// This file declares the ByteSink and ByteSource abstract interfaces. These
-// interfaces represent objects that consume (ByteSink) or produce (ByteSource)
-// a sequence of bytes. Using these abstract interfaces in your APIs can help
-// make your code work with a variety of input and output types.
-//
-// This file also declares the following commonly used implementations of these
-// interfaces.
-//
-// ByteSink:
-// UncheckedArrayByteSink Writes to an array, without bounds checking
-// CheckedArrayByteSink Writes to an array, with bounds checking
-// GrowingArrayByteSink Allocates and writes to a growable buffer
-// StringByteSink Writes to an STL string
-// NullByteSink Consumes a never-ending stream of bytes
-//
-// ByteSource:
-// ArrayByteSource Reads from an array or string/StringPiece
-// LimitedByteSource Limits the number of bytes read from an
-
-#ifndef GOOGLE_PROTOBUF_STUBS_BYTESTREAM_H_
-#define GOOGLE_PROTOBUF_STUBS_BYTESTREAM_H_
-
-#include <stddef.h>
-#include <string>
-
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/stringpiece.h>
-
-#include <google/protobuf/port_def.inc>
-
-class CordByteSink;
-
-namespace google {
-namespace protobuf {
-namespace strings {
-
-// An abstract interface for an object that consumes a sequence of bytes. This
-// interface offers a way to append data as well as a Flush() function.
-//
-// Example:
-//
-// string my_data;
-// ...
-// ByteSink* sink = ...
-// sink->Append(my_data.data(), my_data.size());
-// sink->Flush();
-//
-class PROTOBUF_EXPORT ByteSink {
- public:
- ByteSink() {}
- virtual ~ByteSink() {}
-
- // Appends the "n" bytes starting at "bytes".
- virtual void Append(const char* bytes, size_t n) = 0;
-
- // Flushes internal buffers. The default implementation does nothing. ByteSink
- // subclasses may use internal buffers that require calling Flush() at the end
- // of the stream.
- virtual void Flush();
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ByteSink);
-};
-
-// An abstract interface for an object that produces a fixed-size sequence of
-// bytes.
-//
-// Example:
-//
-// ByteSource* source = ...
-// while (source->Available() > 0) {
-// StringPiece data = source->Peek();
-// ... do something with "data" ...
-// source->Skip(data.length());
-// }
-//
-class PROTOBUF_EXPORT ByteSource {
- public:
- ByteSource() {}
- virtual ~ByteSource() {}
-
- // Returns the number of bytes left to read from the source. Available()
- // should decrease by N each time Skip(N) is called. Available() may not
- // increase. Available() returning 0 indicates that the ByteSource is
- // exhausted.
- //
- // Note: Size() may have been a more appropriate name as it's more
- // indicative of the fixed-size nature of a ByteSource.
- virtual size_t Available() const = 0;
-
- // Returns a StringPiece of the next contiguous region of the source. Does not
- // reposition the source. The returned region is empty iff Available() == 0.
- //
- // The returned region is valid until the next call to Skip() or until this
- // object is destroyed, whichever occurs first.
- //
- // The length of the returned StringPiece will be <= Available().
- virtual StringPiece Peek() = 0;
-
- // Skips the next n bytes. Invalidates any StringPiece returned by a previous
- // call to Peek().
- //
- // REQUIRES: Available() >= n
- virtual void Skip(size_t n) = 0;
-
- // Writes the next n bytes in this ByteSource to the given ByteSink, and
- // advances this ByteSource past the copied bytes. The default implementation
- // of this method just copies the bytes normally, but subclasses might
- // override CopyTo to optimize certain cases.
- //
- // REQUIRES: Available() >= n
- virtual void CopyTo(ByteSink* sink, size_t n);
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ByteSource);
-};
-
-//
-// Some commonly used implementations of ByteSink
-//
-
-// Implementation of ByteSink that writes to an unsized byte array. No
-// bounds-checking is performed--it is the caller's responsibility to ensure
-// that the destination array is large enough.
-//
-// Example:
-//
-// char buf[10];
-// UncheckedArrayByteSink sink(buf);
-// sink.Append("hi", 2); // OK
-// sink.Append(data, 100); // WOOPS! Overflows buf[10].
-//
-class PROTOBUF_EXPORT UncheckedArrayByteSink : public ByteSink {
- public:
- explicit UncheckedArrayByteSink(char* dest) : dest_(dest) {}
- virtual void Append(const char* data, size_t n) override;
-
- // Returns the current output pointer so that a caller can see how many bytes
- // were produced.
- //
- // Note: this method is not part of the ByteSink interface.
- char* CurrentDestination() const { return dest_; }
-
- private:
- char* dest_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(UncheckedArrayByteSink);
-};
-
-// Implementation of ByteSink that writes to a sized byte array. This sink will
-// not write more than "capacity" bytes to outbuf. Once "capacity" bytes are
-// appended, subsequent bytes will be ignored and Overflowed() will return true.
-// Overflowed() does not cause a runtime error (i.e., it does not CHECK fail).
-//
-// Example:
-//
-// char buf[10];
-// CheckedArrayByteSink sink(buf, 10);
-// sink.Append("hi", 2); // OK
-// sink.Append(data, 100); // Will only write 8 more bytes
-//
-class PROTOBUF_EXPORT CheckedArrayByteSink : public ByteSink {
- public:
- CheckedArrayByteSink(char* outbuf, size_t capacity);
- virtual void Append(const char* bytes, size_t n) override;
-
- // Returns the number of bytes actually written to the sink.
- size_t NumberOfBytesWritten() const { return size_; }
-
- // Returns true if any bytes were discarded, i.e., if there was an
- // attempt to write more than 'capacity' bytes.
- bool Overflowed() const { return overflowed_; }
-
- private:
- char* outbuf_;
- const size_t capacity_;
- size_t size_;
- bool overflowed_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CheckedArrayByteSink);
-};
-
-// Implementation of ByteSink that allocates an internal buffer (a char array)
-// and expands it as needed to accommodate appended data (similar to a string),
-// and allows the caller to take ownership of the internal buffer via the
-// GetBuffer() method. The buffer returned from GetBuffer() must be deleted by
-// the caller with delete[]. GetBuffer() also sets the internal buffer to be
-// empty, and subsequent appends to the sink will create a new buffer. The
-// destructor will free the internal buffer if GetBuffer() was not called.
-//
-// Example:
-//
-// GrowingArrayByteSink sink(10);
-// sink.Append("hi", 2);
-// sink.Append(data, n);
-// const char* buf = sink.GetBuffer(); // Ownership transferred
-// delete[] buf;
-//
-class PROTOBUF_EXPORT GrowingArrayByteSink : public strings::ByteSink {
- public:
- explicit GrowingArrayByteSink(size_t estimated_size);
- virtual ~GrowingArrayByteSink();
- virtual void Append(const char* bytes, size_t n) override;
-
- // Returns the allocated buffer, and sets nbytes to its size. The caller takes
- // ownership of the buffer and must delete it with delete[].
- char* GetBuffer(size_t* nbytes);
-
- private:
- void Expand(size_t amount);
- void ShrinkToFit();
-
- size_t capacity_;
- char* buf_;
- size_t size_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GrowingArrayByteSink);
-};
-
-// Implementation of ByteSink that appends to the given string.
-// Existing contents of "dest" are not modified; new data is appended.
-//
-// Example:
-//
-// string dest = "Hello ";
-// StringByteSink sink(&dest);
-// sink.Append("World", 5);
-// assert(dest == "Hello World");
-//
-class PROTOBUF_EXPORT StringByteSink : public ByteSink {
- public:
- explicit StringByteSink(TProtoStringType* dest) : dest_(dest) {}
- virtual void Append(const char* data, size_t n) override;
-
- private:
- TProtoStringType* dest_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringByteSink);
-};
-
-// Implementation of ByteSink that discards all data.
-//
-// Example:
-//
-// NullByteSink sink;
-// sink.Append(data, data.size()); // All data ignored.
-//
-class PROTOBUF_EXPORT NullByteSink : public ByteSink {
- public:
- NullByteSink() {}
- void Append(const char* /*data*/, size_t /*n*/) override {}
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(NullByteSink);
-};
-
-//
-// Some commonly used implementations of ByteSource
-//
-
-// Implementation of ByteSource that reads from a StringPiece.
-//
-// Example:
-//
-// string data = "Hello";
-// ArrayByteSource source(data);
-// assert(source.Available() == 5);
-// assert(source.Peek() == "Hello");
-//
-class PROTOBUF_EXPORT ArrayByteSource : public ByteSource {
- public:
- explicit ArrayByteSource(StringPiece s) : input_(s) {}
-
- virtual size_t Available() const override;
- virtual StringPiece Peek() override;
- virtual void Skip(size_t n) override;
-
- private:
- StringPiece input_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ArrayByteSource);
-};
-
-// Implementation of ByteSource that wraps another ByteSource, limiting the
-// number of bytes returned.
-//
-// The caller maintains ownership of the underlying source, and may not use the
-// underlying source while using the LimitByteSource object. The underlying
-// source's pointer is advanced by n bytes every time this LimitByteSource
-// object is advanced by n.
-//
-// Example:
-//
-// string data = "Hello World";
-// ArrayByteSource abs(data);
-// assert(abs.Available() == data.size());
-//
-// LimitByteSource limit(abs, 5);
-// assert(limit.Available() == 5);
-// assert(limit.Peek() == "Hello");
-//
-class PROTOBUF_EXPORT LimitByteSource : public ByteSource {
- public:
- // Returns at most "limit" bytes from "source".
- LimitByteSource(ByteSource* source, size_t limit);
-
- virtual size_t Available() const override;
- virtual StringPiece Peek() override;
- virtual void Skip(size_t n) override;
-
- // We override CopyTo so that we can forward to the underlying source, in
- // case it has an efficient implementation of CopyTo.
- virtual void CopyTo(ByteSink* sink, size_t n) override;
-
- private:
- ByteSource* source_;
- size_t limit_;
-};
-
-} // namespace strings
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#endif // GOOGLE_PROTOBUF_STUBS_BYTESTREAM_H_
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/callback.h b/contrib/libs/protobuf/src/google/protobuf/stubs/callback.h
index 6e0f62dcd77..13e9047b94a 100644
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/callback.h
+++ b/contrib/libs/protobuf/src/google/protobuf/stubs/callback.h
@@ -1,11 +1,39 @@
+// 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_STUBS_CALLBACK_H_
#define GOOGLE_PROTOBUF_STUBS_CALLBACK_H_
#include <type_traits>
-#include <google/protobuf/stubs/macros.h>
-
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
// ===================================================================
// emulates google3/base/callback.h
@@ -73,48 +101,44 @@ namespace protobuf {
class PROTOBUF_EXPORT Closure {
public:
Closure() {}
+ Closure(const Closure&) = delete;
+ Closure& operator=(const Closure&) = delete;
virtual ~Closure();
virtual void Run() = 0;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Closure);
};
template<typename R>
class ResultCallback {
public:
ResultCallback() {}
+ ResultCallback(const ResultCallback&) = delete;
+ ResultCallback& operator=(const ResultCallback&) = delete;
virtual ~ResultCallback() {}
virtual R Run() = 0;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ResultCallback);
};
template <typename R, typename A1>
class PROTOBUF_EXPORT ResultCallback1 {
public:
ResultCallback1() {}
+ ResultCallback1(const ResultCallback1&) = delete;
+ ResultCallback1& operator=(const ResultCallback1&) = delete;
virtual ~ResultCallback1() {}
virtual R Run(A1) = 0;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ResultCallback1);
};
template <typename R, typename A1, typename A2>
class PROTOBUF_EXPORT ResultCallback2 {
public:
ResultCallback2() {}
+ ResultCallback2(const ResultCallback2&) = delete;
+ ResultCallback2& operator=(const ResultCallback2&) = delete;
virtual ~ResultCallback2() {}
virtual R Run(A1,A2) = 0;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ResultCallback2);
};
namespace internal {
@@ -578,6 +602,6 @@ void PROTOBUF_EXPORT DoNothing();
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_STUBS_CALLBACK_H_
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/casts.h b/contrib/libs/protobuf/src/google/protobuf/stubs/casts.h
deleted file mode 100644
index ad29dac1f87..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/casts.h
+++ /dev/null
@@ -1,138 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2014 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_CASTS_H__
-#define GOOGLE_PROTOBUF_CASTS_H__
-
-#include <google/protobuf/stubs/common.h>
-
-#include <google/protobuf/port_def.inc>
-#include <type_traits>
-
-namespace google {
-namespace protobuf {
-namespace internal {
-
-// Use implicit_cast as a safe version of static_cast or const_cast
-// for upcasting in the type hierarchy (i.e. casting a pointer to Foo
-// to a pointer to SuperclassOfFoo or casting a pointer to Foo to
-// a const pointer to Foo).
-// When you use implicit_cast, the compiler checks that the cast is safe.
-// Such explicit implicit_casts are necessary in surprisingly many
-// situations where C++ demands an exact type match instead of an
-// argument type convertible to a target type.
-//
-// The From type can be inferred, so the preferred syntax for using
-// implicit_cast is the same as for static_cast etc.:
-//
-// implicit_cast<ToType>(expr)
-//
-// implicit_cast would have been part of the C++ standard library,
-// but the proposal was submitted too late. It will probably make
-// its way into the language in the future.
-template<typename To, typename From>
-inline To implicit_cast(From const &f) {
- return f;
-}
-
-// When you upcast (that is, cast a pointer from type Foo to type
-// SuperclassOfFoo), it's fine to use implicit_cast<>, since upcasts
-// always succeed. When you downcast (that is, cast a pointer from
-// type Foo to type SubclassOfFoo), static_cast<> isn't safe, because
-// how do you know the pointer is really of type SubclassOfFoo? It
-// could be a bare Foo, or of type DifferentSubclassOfFoo. Thus,
-// when you downcast, you should use this macro. In debug mode, we
-// use dynamic_cast<> to double-check the downcast is legal (we die
-// if it's not). In normal mode, we do the efficient static_cast<>
-// instead. Thus, it's important to test in debug mode to make sure
-// the cast is legal!
-// This is the only place in the code we should use dynamic_cast<>.
-// In particular, you SHOULDN'T be using dynamic_cast<> in order to
-// do RTTI (eg code like this:
-// if (dynamic_cast<Subclass1>(foo)) HandleASubclass1Object(foo);
-// if (dynamic_cast<Subclass2>(foo)) HandleASubclass2Object(foo);
-// You should design the code some other way not to need this.
-
-template<typename To, typename From> // use like this: down_cast<T*>(foo);
-inline To down_cast(From* f) { // so we only accept pointers
- // Ensures that To is a sub-type of From *. This test is here only
- // for compile-time type checking, and has no overhead in an
- // optimized build at run-time, as it will be optimized away
- // completely.
- if (false) {
- implicit_cast<From*, To>(0);
- }
-
-#if !defined(NDEBUG) && PROTOBUF_RTTI
- assert(f == nullptr || dynamic_cast<To>(f) != nullptr); // RTTI: debug mode only!
-#endif
- return static_cast<To>(f);
-}
-
-template<typename To, typename From> // use like this: down_cast<T&>(foo);
-inline To down_cast(From& f) {
- typedef typename std::remove_reference<To>::type* ToAsPointer;
- // Ensures that To is a sub-type of From *. This test is here only
- // for compile-time type checking, and has no overhead in an
- // optimized build at run-time, as it will be optimized away
- // completely.
- if (false) {
- implicit_cast<From*, ToAsPointer>(0);
- }
-
-#if !defined(NDEBUG) && PROTOBUF_RTTI
- // RTTI: debug mode only!
- assert(dynamic_cast<ToAsPointer>(&f) != nullptr);
-#endif
- return *static_cast<ToAsPointer>(&f);
-}
-
-template<typename To, typename From>
-inline To bit_cast(const From& from) {
- static_assert(sizeof(From) == sizeof(To), "bit_cast_with_different_sizes");
- To dest;
- memcpy(&dest, &from, sizeof(dest));
- return dest;
-}
-
-} // namespace internal
-
-// We made these internal so that they would show up as such in the docs,
-// but we don't want to stick "internal::" in front of them everywhere.
-using internal::implicit_cast;
-using internal::down_cast;
-using internal::bit_cast;
-
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#endif // GOOGLE_PROTOBUF_CASTS_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/common.cc b/contrib/libs/protobuf/src/google/protobuf/stubs/common.cc
index b2efa1b0549..9cfb19e5d2e 100644
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/common.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/stubs/common.cc
@@ -30,12 +30,13 @@
// Author: [email protected] (Kenton Varda)
-#include <google/protobuf/stubs/common.h>
+#include "google/protobuf/stubs/common.h"
-#include <atomic>
#include <errno.h>
-#include <sstream>
#include <stdio.h>
+
+#include <atomic>
+#include <sstream>
#include <vector>
#ifdef _WIN32
@@ -49,15 +50,14 @@
#include <android/log.h>
#endif
-#include <google/protobuf/stubs/callback.h>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/once.h>
-#include <google/protobuf/stubs/status.h>
-#include <google/protobuf/stubs/stringpiece.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/int128.h>
+#include "y_absl/log/absl_log.h"
+#include "y_absl/status/status.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/stubs/callback.h"
-#include <google/protobuf/port_def.inc>
+// Must be last.
+#include "google/protobuf/port_def.inc" // NOLINT
namespace google {
namespace protobuf {
@@ -69,26 +69,32 @@ void VerifyVersion(int headerVersion,
const char* filename) {
if (GOOGLE_PROTOBUF_VERSION < minLibraryVersion) {
// Library is too old for headers.
- GOOGLE_LOG(FATAL)
- << "This program requires version " << VersionString(minLibraryVersion)
- << " of the Protocol Buffer runtime library, but the installed version "
- "is " << VersionString(GOOGLE_PROTOBUF_VERSION) << ". Please update "
- "your library. If you compiled the program yourself, make sure that "
- "your headers are from the same version of Protocol Buffers as your "
- "link-time library. (Version verification failed in \""
- << filename << "\".)";
+ Y_ABSL_LOG(FATAL)
+ << "This program requires version " << VersionString(minLibraryVersion)
+ << " of the Protocol Buffer runtime library, but the installed version "
+ "is "
+ << VersionString(GOOGLE_PROTOBUF_VERSION)
+ << ". Please update "
+ "your library. If you compiled the program yourself, make sure "
+ "that "
+ "your headers are from the same version of Protocol Buffers as your "
+ "link-time library. (Version verification failed in \""
+ << filename << "\".)";
}
if (headerVersion < kMinHeaderVersionForLibrary) {
// Headers are too old for library.
- GOOGLE_LOG(FATAL)
- << "This program was compiled against version "
- << VersionString(headerVersion) << " of the Protocol Buffer runtime "
- "library, which is not compatible with the installed version ("
- << VersionString(GOOGLE_PROTOBUF_VERSION) << "). Contact the program "
- "author for an update. If you compiled the program yourself, make "
- "sure that your headers are from the same version of Protocol Buffers "
- "as your link-time library. (Version verification failed in \""
- << filename << "\".)";
+ Y_ABSL_LOG(FATAL)
+ << "This program was compiled against version "
+ << VersionString(headerVersion)
+ << " of the Protocol Buffer runtime "
+ "library, which is not compatible with the installed version ("
+ << VersionString(GOOGLE_PROTOBUF_VERSION)
+ << "). Contact the program "
+ "author for an update. If you compiled the program yourself, make "
+ "sure that your headers are from the same version of Protocol "
+ "Buffers "
+ "as your link-time library. (Version verification failed in \""
+ << filename << "\".)";
}
}
@@ -108,180 +114,23 @@ TProtoStringType VersionString(int version) {
return buffer;
}
-} // namespace internal
-
-// ===================================================================
-// emulates google3/base/logging.cc
-
-// If the minimum logging level is not set, we default to logging messages for
-// all levels.
-#ifndef GOOGLE_PROTOBUF_MIN_LOG_LEVEL
-#define GOOGLE_PROTOBUF_MIN_LOG_LEVEL LOGLEVEL_INFO
-#endif
-
-namespace internal {
-
-#if defined(__ANDROID__)
-inline void DefaultLogHandler(LogLevel level, const char* filename, int line,
- const TProtoStringType& message) {
- if (level < GOOGLE_PROTOBUF_MIN_LOG_LEVEL) {
- return;
- }
- static const char* level_names[] = {"INFO", "WARNING", "ERROR", "FATAL"};
-
- static const int android_log_levels[] = {
- ANDROID_LOG_INFO, // LOG(INFO),
- ANDROID_LOG_WARN, // LOG(WARNING)
- ANDROID_LOG_ERROR, // LOG(ERROR)
- ANDROID_LOG_FATAL, // LOG(FATAL)
- };
-
- // Bound the logging level.
- const int android_log_level = android_log_levels[level];
- ::std::ostringstream ostr;
- ostr << "[libprotobuf " << level_names[level] << " " << filename << ":"
- << line << "] " << message.c_str();
-
- // Output the log string the Android log at the appropriate level.
- __android_log_write(android_log_level, "libprotobuf-native",
- ostr.str().c_str());
- // Also output to std::cerr.
- fprintf(stderr, "%s", ostr.str().c_str());
- fflush(stderr);
-
- // Indicate termination if needed.
- if (android_log_level == ANDROID_LOG_FATAL) {
- __android_log_write(ANDROID_LOG_FATAL, "libprotobuf-native",
- "terminating.\n");
- }
-}
-
-#else
-void DefaultLogHandler(LogLevel level, const char* filename, int line,
- const TProtoStringType& message) {
- if (level < GOOGLE_PROTOBUF_MIN_LOG_LEVEL) {
- return;
- }
- static const char* level_names[] = { "INFO", "WARNING", "ERROR", "FATAL" };
-
- // We use fprintf() instead of cerr because we want this to work at static
- // initialization time.
- fprintf(stderr, "[libprotobuf %s %s:%d] %s\n",
- level_names[level], filename, line, message.c_str());
- fflush(stderr); // Needed on MSVC.
-}
-#endif
-
-void NullLogHandler(LogLevel /* level */, const char* /* filename */,
- int /* line */, const TProtoStringType& /* message */) {
- // Nothing.
-}
-
-static LogHandler* log_handler_ = &DefaultLogHandler;
-static std::atomic<int> log_silencer_count_ = ATOMIC_VAR_INIT(0);
-
-LogMessage& LogMessage::operator<<(const TProtoStringType& value) {
- message_ += value;
- return *this;
-}
-
-LogMessage& LogMessage::operator<<(const char* value) {
- message_ += value;
- return *this;
-}
-
-LogMessage& LogMessage::operator<<(const StringPiece& value) {
- message_ += value.ToString();
- return *this;
-}
-
-LogMessage& LogMessage::operator<<(const util::Status& status) {
- message_ += status.ToString();
- return *this;
-}
-
-LogMessage& LogMessage::operator<<(const uint128& value) {
- std::ostringstream str;
- str << value;
- message_ += str.str();
- return *this;
-}
-
-LogMessage& LogMessage::operator<<(char value) {
- return *this << StringPiece(&value, 1);
-}
-
-LogMessage& LogMessage::operator<<(void* value) {
- StrAppend(&message_, strings::Hex(reinterpret_cast<uintptr_t>(value)));
- return *this;
-}
-
-#undef DECLARE_STREAM_OPERATOR
-#define DECLARE_STREAM_OPERATOR(TYPE) \
- LogMessage& LogMessage::operator<<(TYPE value) { \
- StrAppend(&message_, value); \
- return *this; \
- }
-
-DECLARE_STREAM_OPERATOR(int)
-DECLARE_STREAM_OPERATOR(unsigned int)
-DECLARE_STREAM_OPERATOR(long) // NOLINT(runtime/int)
-DECLARE_STREAM_OPERATOR(unsigned long) // NOLINT(runtime/int)
-DECLARE_STREAM_OPERATOR(double)
-DECLARE_STREAM_OPERATOR(long long) // NOLINT(runtime/int)
-DECLARE_STREAM_OPERATOR(unsigned long long) // NOLINT(runtime/int)
-#undef DECLARE_STREAM_OPERATOR
-
-LogMessage::LogMessage(LogLevel level, const char* filename, int line)
- : level_(level), filename_(filename), line_(line) {}
-LogMessage::~LogMessage() {}
-
-void LogMessage::Finish() {
- bool suppress = false;
-
- if (level_ != LOGLEVEL_FATAL) {
- suppress = log_silencer_count_ > 0;
- }
+TProtoStringType ProtocVersionString(int version) {
+ int minor = (version / 1000) % 1000;
+ int micro = version % 1000;
- if (!suppress) {
- log_handler_(level_, filename_, line_, message_);
- }
+ // 128 bytes should always be enough, but we use snprintf() anyway to be
+ // safe.
+ char buffer[128];
+ snprintf(buffer, sizeof(buffer), "%d.%d", minor, micro);
- if (level_ == LOGLEVEL_FATAL) {
-#if PROTOBUF_USE_EXCEPTIONS
- throw FatalException(filename_, line_, message_);
-#else
- abort();
-#endif
- }
-}
+ // Guard against broken MSVC snprintf().
+ buffer[sizeof(buffer) - 1] = '\0';
-void LogFinisher::operator=(LogMessage& other) {
- other.Finish();
+ return buffer;
}
} // namespace internal
-LogHandler* SetLogHandler(LogHandler* new_func) {
- LogHandler* old = internal::log_handler_;
- if (old == &internal::NullLogHandler) {
- old = nullptr;
- }
- if (new_func == nullptr) {
- internal::log_handler_ = &internal::NullLogHandler;
- } else {
- internal::log_handler_ = new_func;
- }
- return old;
-}
-
-LogSilencer::LogSilencer() {
- ++internal::log_silencer_count_;
-};
-
-LogSilencer::~LogSilencer() {
- --internal::log_silencer_count_;
-};
// ===================================================================
// emulates google3/base/callback.cc
@@ -321,4 +170,4 @@ const char* FatalException::what() const throw() {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc" // NOLINT
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/common.h b/contrib/libs/protobuf/src/google/protobuf/stubs/common.h
index 7bdcef8b8b0..b5a595429c0 100644
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/common.h
+++ b/contrib/libs/protobuf/src/google/protobuf/stubs/common.h
@@ -37,16 +37,13 @@
#include <algorithm>
#include <iostream>
-#include <map>
#include <memory>
-#include <set>
#include <string>
#include <vector>
-#include <google/protobuf/stubs/macros.h>
-#include <google/protobuf/stubs/platform_macros.h>
-#include <google/protobuf/stubs/port.h>
-#include <google/protobuf/stubs/stringpiece.h>
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/stubs/platform_macros.h"
+#include "google/protobuf/stubs/port.h"
#ifndef PROTOBUF_USE_EXCEPTIONS
#if defined(_MSC_VER) && defined(_CPPUNWIND)
@@ -60,9 +57,6 @@
#define Y_PROTOBUF_SUPPRESS_NODISCARD [[maybe_unused]] bool Y_GENERATE_UNIQUE_ID(pb_checker)=
-#if PROTOBUF_USE_EXCEPTIONS
-#include <exception>
-#endif
#if defined(__APPLE__)
#include <TargetConditionals.h> // for TARGET_OS_IPHONE
#endif
@@ -71,7 +65,7 @@
#include <pthread.h>
#endif
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace std {}
@@ -84,7 +78,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 3021003
+#define GOOGLE_PROTOBUF_VERSION 4022005
// A suffix string for alpha, beta or rc releases. Empty for stable releases.
#define GOOGLE_PROTOBUF_VERSION_SUFFIX ""
@@ -92,15 +86,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 = 3021000;
+static const int kMinHeaderVersionForLibrary = 4022000;
// The minimum protoc version which works with the current version of the
// headers.
-#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3021000
+#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 4022000
// The minimum header version which works with the current version of
// protoc. This constant should only be used in VerifyVersion().
-static const int kMinHeaderVersionForProtoc = 3021000;
+static const int kMinHeaderVersionForProtoc = 4022000;
// Verifies that the headers and libraries are compatible. Use the macro
// below to call this.
@@ -108,10 +102,35 @@ void PROTOBUF_EXPORT VerifyVersion(int headerVersion, int minLibraryVersion,
const char* filename);
// Converts a numeric version number to a string.
-TProtoStringType PROTOBUF_EXPORT VersionString(int version);
+TProtoStringType PROTOBUF_EXPORT
+VersionString(int version); // NOLINT(runtime/string)
+
+// Prints the protoc compiler version (no major version)
+TProtoStringType PROTOBUF_EXPORT
+ProtocVersionString(int version); // NOLINT(runtime/string)
} // namespace internal
+#if PROTOBUF_USE_EXCEPTIONS
+class FatalException : public std::exception {
+ public:
+ FatalException(const char* filename, int line, const TProtoStringType& message)
+ : filename_(filename), line_(line), message_(message) {}
+ virtual ~FatalException() throw();
+
+ const char* what() const throw() override;
+
+ const char* filename() const { return filename_; }
+ int line() const { return line_; }
+ const TProtoStringType& message() const { return message_; }
+
+ private:
+ const char* filename_;
+ const int line_;
+ const TProtoStringType message_;
+};
+#endif
+
// Place this macro in your main() function (or somewhere before you attempt
// to use the protobuf library) to verify that the version you link against
// matches the headers you compiled against. If a version mismatch is
@@ -122,45 +141,14 @@ TProtoStringType PROTOBUF_EXPORT VersionString(int version);
__FILE__)
-// ===================================================================
-// from google3/util/utf8/public/unilib.h
-
-namespace internal {
-
-// Checks if the buffer contains structurally-valid UTF-8. Implemented in
-// structurally_valid.cc.
-PROTOBUF_EXPORT bool IsStructurallyValidUTF8(const char* buf, int len);
-
-inline bool IsStructurallyValidUTF8(StringPiece str) {
- return IsStructurallyValidUTF8(str.data(), static_cast<int>(str.length()));
-}
-
-// Returns initial number of bytes of structurally valid UTF-8.
-PROTOBUF_EXPORT int UTF8SpnStructurallyValid(StringPiece str);
-
-// Coerce UTF-8 byte string in src_str to be
-// a structurally-valid equal-length string by selectively
-// overwriting illegal bytes with replace_char (typically ' ' or '?').
-// replace_char must be legal printable 7-bit Ascii 0x20..0x7e.
-// src_str is read-only.
-//
-// Returns pointer to output buffer, src_str.data() if no changes were made,
-// or idst if some bytes were changed. idst is allocated by the caller
-// and must be at least as big as src_str
-//
-// Optimized for: all structurally valid and no byte copying is done.
-//
-PROTOBUF_EXPORT char* UTF8CoerceToStructurallyValid(StringPiece str, char* dst,
- char replace_char);
-
-} // namespace internal
-
// This lives in message_lite.h now, but we leave this here for any users that
// #include common.h and not message_lite.h.
PROTOBUF_EXPORT void ShutdownProtobufLibrary();
namespace internal {
+PROTOBUF_EXPORT bool IsStructurallyValidUTF8(const char* buf, int len);
+
// Strongly references the given variable such that the linker will be forced
// to pull in this variable's translation unit.
template <typename T>
@@ -171,26 +159,6 @@ void StrongReference(const T& var) {
} // namespace internal
-#if PROTOBUF_USE_EXCEPTIONS
-class FatalException : public std::exception {
- public:
- FatalException(const char* filename, int line, const TProtoStringType& message)
- : filename_(filename), line_(line), message_(message) {}
- virtual ~FatalException() throw();
-
- const char* what() const throw() override;
-
- const char* filename() const { return filename_; }
- int line() const { return line_; }
- const TProtoStringType& message() const { return message_; }
-
- private:
- const char* filename_;
- const int line_;
- const TProtoStringType message_;
-};
-#endif
-
// This is at the end of the file instead of the beginning to work around a bug
// in some versions of MSVC.
using string = TProtoStringType;
@@ -203,6 +171,6 @@ namespace NProtoBuf {
using namespace google::protobuf;
}
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMMON_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/int128.cc b/contrib/libs/protobuf/src/google/protobuf/stubs/int128.cc
deleted file mode 100644
index 038586ffdbd..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/int128.cc
+++ /dev/null
@@ -1,193 +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/stubs/int128.h>
-
-#include <iomanip>
-#include <ostream> // NOLINT(readability/streams)
-#include <sstream>
-
-#include <google/protobuf/stubs/logging.h>
-
-#include <google/protobuf/port_def.inc>
-
-namespace google {
-namespace protobuf {
-
-const uint128_pod kuint128max = {arc_ui64{0xFFFFFFFFFFFFFFFFu},
- arc_ui64{0xFFFFFFFFFFFFFFFFu}};
-
-// Returns the 0-based position of the last set bit (i.e., most significant bit)
-// in the given uint64. The argument may not be 0.
-//
-// For example:
-// Given: 5 (decimal) == 101 (binary)
-// Returns: 2
-#define STEP(T, n, pos, sh) \
- do { \
- if ((n) >= (static_cast<T>(1) << (sh))) { \
- (n) = (n) >> (sh); \
- (pos) |= (sh); \
- } \
- } while (0)
-static inline int Fls64(arc_ui64 n) {
- GOOGLE_DCHECK_NE(0, n);
- int pos = 0;
- STEP(arc_ui64, n, pos, 0x20);
- arc_ui32 n32 = n;
- STEP(arc_ui32, n32, pos, 0x10);
- STEP(arc_ui32, n32, pos, 0x08);
- STEP(arc_ui32, n32, pos, 0x04);
- return pos + ((arc_ui64{0x3333333322221100u} >> (n32 << 2)) & 0x3);
-}
-#undef STEP
-
-// Like Fls64() above, but returns the 0-based position of the last set bit
-// (i.e., most significant bit) in the given uint128. The argument may not be 0.
-static inline int Fls128(uint128 n) {
- if (arc_ui64 hi = Uint128High64(n)) {
- return Fls64(hi) + 64;
- }
- return Fls64(Uint128Low64(n));
-}
-
-void uint128::DivModImpl(uint128 dividend, uint128 divisor,
- uint128* quotient_ret, uint128* remainder_ret) {
- if (divisor == 0) {
- GOOGLE_LOG(FATAL) << "Division or mod by zero: dividend.hi=" << dividend.hi_
- << ", lo=" << dividend.lo_;
- } else if (dividend < divisor) {
- *quotient_ret = 0;
- *remainder_ret = dividend;
- return;
- } else {
- int dividend_bit_length = Fls128(dividend);
- int divisor_bit_length = Fls128(divisor);
- int difference = dividend_bit_length - divisor_bit_length;
- uint128 quotient = 0;
- while (difference >= 0) {
- quotient <<= 1;
- uint128 shifted_divisor = divisor << difference;
- if (shifted_divisor <= dividend) {
- dividend -= shifted_divisor;
- quotient += 1;
- }
- difference -= 1;
- }
- //record the final quotient and remainder
- *quotient_ret = quotient;
- *remainder_ret = dividend;
- }
-}
-
-
-uint128& uint128::operator/=(const uint128& divisor) {
- uint128 quotient = 0;
- uint128 remainder = 0;
- DivModImpl(*this, divisor, &quotient, &remainder);
- *this = quotient;
- return *this;
-}
-uint128& uint128::operator%=(const uint128& divisor) {
- uint128 quotient = 0;
- uint128 remainder = 0;
- DivModImpl(*this, divisor, &quotient, &remainder);
- *this = remainder;
- return *this;
-}
-
-std::ostream& operator<<(std::ostream& o, const uint128& b) {
- std::ios_base::fmtflags flags = o.flags();
-
- // Select a divisor which is the largest power of the base < 2^64.
- uint128 div;
- std::streamsize div_base_log;
- switch (flags & std::ios::basefield) {
- case std::ios::hex:
- div =
- static_cast<arc_ui64>(arc_ui64{0x1000000000000000u}); // 16^15
- div_base_log = 15;
- break;
- case std::ios::oct:
- div = static_cast<arc_ui64>(
- arc_ui64{01000000000000000000000u}); // 8^21
- div_base_log = 21;
- break;
- default: // std::ios::dec
- div = static_cast<arc_ui64>(
- arc_ui64{10000000000000000000u}); // 10^19
- div_base_log = 19;
- break;
- }
-
- // Now piece together the uint128 representation from three chunks of
- // the original value, each less than "div" and therefore representable
- // as a uint64.
- std::ostringstream os;
- std::ios_base::fmtflags copy_mask =
- std::ios::basefield | std::ios::showbase | std::ios::uppercase;
- os.setf(flags & copy_mask, copy_mask);
- uint128 high = b;
- uint128 low;
- uint128::DivModImpl(high, div, &high, &low);
- uint128 mid;
- uint128::DivModImpl(high, div, &high, &mid);
- if (high.lo_ != 0) {
- os << high.lo_;
- os << std::noshowbase << std::setfill('0') << std::setw(div_base_log);
- os << mid.lo_;
- os << std::setw(div_base_log);
- } else if (mid.lo_ != 0) {
- os << mid.lo_;
- os << std::noshowbase << std::setfill('0') << std::setw(div_base_log);
- }
- os << low.lo_;
- std::string rep = os.str();
-
- // Add the requisite padding.
- std::streamsize width = o.width(0);
- auto repSize = static_cast<std::streamsize>(rep.size());
- if (width > repSize) {
- if ((flags & std::ios::adjustfield) == std::ios::left) {
- rep.append(width - repSize, o.fill());
- } else {
- rep.insert(static_cast<TProtoStringType::size_type>(0), width - repSize,
- o.fill());
- }
- }
-
- // Stream the final representation in a single "<<" call.
- return o << rep;
-}
-
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc> // NOLINT
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/int128.h b/contrib/libs/protobuf/src/google/protobuf/stubs/int128.h
deleted file mode 100644
index f97a19ee530..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/int128.h
+++ /dev/null
@@ -1,387 +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_STUBS_INT128_H_
-#define GOOGLE_PROTOBUF_STUBS_INT128_H_
-
-#include <google/protobuf/stubs/common.h>
-
-#include <iosfwd>
-
-#include <google/protobuf/port_def.inc>
-
-namespace google {
-namespace protobuf {
-
-struct uint128_pod;
-
-// TODO(xiaofeng): Define GOOGLE_PROTOBUF_HAS_CONSTEXPR when constexpr is
-// available.
-#ifdef GOOGLE_PROTOBUF_HAS_CONSTEXPR
-# define UINT128_CONSTEXPR constexpr
-#else
-# define UINT128_CONSTEXPR
-#endif
-
-// An unsigned 128-bit integer type. Thread-compatible.
-class PROTOBUF_EXPORT uint128 {
- public:
- UINT128_CONSTEXPR uint128(); // Sets to 0, but don't trust on this behavior.
- UINT128_CONSTEXPR uint128(arc_ui64 top, arc_ui64 bottom);
-#ifndef SWIG
- UINT128_CONSTEXPR uint128(int bottom);
- UINT128_CONSTEXPR uint128(arc_ui32 bottom); // Top 96 bits = 0
-#endif
- UINT128_CONSTEXPR uint128(arc_ui64 bottom); // hi_ = 0
- UINT128_CONSTEXPR uint128(const uint128_pod &val);
-
- // Trivial copy constructor, assignment operator and destructor.
-
- void Initialize(arc_ui64 top, arc_ui64 bottom);
-
- // Arithmetic operators.
- uint128& operator+=(const uint128& b);
- uint128& operator-=(const uint128& b);
- uint128& operator*=(const uint128& b);
- // Long division/modulo for uint128.
- uint128& operator/=(const uint128& b);
- uint128& operator%=(const uint128& b);
- uint128 operator++(int);
- uint128 operator--(int);
- uint128& operator<<=(int);
- uint128& operator>>=(int);
- uint128& operator&=(const uint128& b);
- uint128& operator|=(const uint128& b);
- uint128& operator^=(const uint128& b);
- uint128& operator++();
- uint128& operator--();
-
- friend arc_ui64 Uint128Low64(const uint128& v);
- friend arc_ui64 Uint128High64(const uint128& v);
-
- // We add "std::" to avoid including all of port.h.
- PROTOBUF_EXPORT friend std::ostream& operator<<(std::ostream& o,
- const uint128& b);
-
- private:
- static void DivModImpl(uint128 dividend, uint128 divisor,
- uint128* quotient_ret, uint128* remainder_ret);
-
- // Little-endian memory order optimizations can benefit from
- // having lo_ first, hi_ last.
- // See util/endian/endian.h and Load128/Store128 for storing a uint128.
- arc_ui64 lo_;
- arc_ui64 hi_;
-
- // Not implemented, just declared for catching automatic type conversions.
- uint128(uint8_t);
- uint128(uint16_t);
- uint128(float v);
- uint128(double v);
-};
-
-// This is a POD form of uint128 which can be used for static variables which
-// need to be operated on as uint128.
-struct uint128_pod {
- // Note: The ordering of fields is different than 'class uint128' but the
- // same as its 2-arg constructor. This enables more obvious initialization
- // of static instances, which is the primary reason for this struct in the
- // first place. This does not seem to defeat any optimizations wrt
- // operations involving this struct.
- arc_ui64 hi;
- arc_ui64 lo;
-};
-
-PROTOBUF_EXPORT extern const uint128_pod kuint128max;
-
-// allow uint128 to be logged
-PROTOBUF_EXPORT extern std::ostream& operator<<(std::ostream& o,
- const uint128& b);
-
-// Methods to access low and high pieces of 128-bit value.
-// Defined externally from uint128 to facilitate conversion
-// to native 128-bit types when compilers support them.
-inline arc_ui64 Uint128Low64(const uint128& v) { return v.lo_; }
-inline arc_ui64 Uint128High64(const uint128& v) { return v.hi_; }
-
-// TODO: perhaps it would be nice to have int128, a signed 128-bit type?
-
-// --------------------------------------------------------------------------
-// Implementation details follow
-// --------------------------------------------------------------------------
-inline bool operator==(const uint128& lhs, const uint128& rhs) {
- return (Uint128Low64(lhs) == Uint128Low64(rhs) &&
- Uint128High64(lhs) == Uint128High64(rhs));
-}
-inline bool operator!=(const uint128& lhs, const uint128& rhs) {
- return !(lhs == rhs);
-}
-
-inline UINT128_CONSTEXPR uint128::uint128() : lo_(0), hi_(0) {}
-inline UINT128_CONSTEXPR uint128::uint128(arc_ui64 top, arc_ui64 bottom)
- : lo_(bottom), hi_(top) {}
-inline UINT128_CONSTEXPR uint128::uint128(const uint128_pod& v)
- : lo_(v.lo), hi_(v.hi) {}
-inline UINT128_CONSTEXPR uint128::uint128(arc_ui64 bottom)
- : lo_(bottom), hi_(0) {}
-#ifndef SWIG
-inline UINT128_CONSTEXPR uint128::uint128(arc_ui32 bottom)
- : lo_(bottom), hi_(0) {}
-inline UINT128_CONSTEXPR uint128::uint128(int bottom)
- : lo_(bottom), hi_(static_cast<arc_i64>((bottom < 0) ? -1 : 0)) {}
-#endif
-
-#undef UINT128_CONSTEXPR
-
-inline void uint128::Initialize(arc_ui64 top, arc_ui64 bottom) {
- hi_ = top;
- lo_ = bottom;
-}
-
-// Comparison operators.
-
-#define CMP128(op) \
-inline bool operator op(const uint128& lhs, const uint128& rhs) { \
- return (Uint128High64(lhs) == Uint128High64(rhs)) ? \
- (Uint128Low64(lhs) op Uint128Low64(rhs)) : \
- (Uint128High64(lhs) op Uint128High64(rhs)); \
-}
-
-CMP128(<)
-CMP128(>)
-CMP128(>=)
-CMP128(<=)
-
-#undef CMP128
-
-// Unary operators
-
-inline uint128 operator-(const uint128& val) {
- const arc_ui64 hi_flip = ~Uint128High64(val);
- const arc_ui64 lo_flip = ~Uint128Low64(val);
- const arc_ui64 lo_add = lo_flip + 1;
- if (lo_add < lo_flip) {
- return uint128(hi_flip + 1, lo_add);
- }
- return uint128(hi_flip, lo_add);
-}
-
-inline bool operator!(const uint128& val) {
- return !Uint128High64(val) && !Uint128Low64(val);
-}
-
-// Logical operators.
-
-inline uint128 operator~(const uint128& val) {
- return uint128(~Uint128High64(val), ~Uint128Low64(val));
-}
-
-#define LOGIC128(op) \
-inline uint128 operator op(const uint128& lhs, const uint128& rhs) { \
- return uint128(Uint128High64(lhs) op Uint128High64(rhs), \
- Uint128Low64(lhs) op Uint128Low64(rhs)); \
-}
-
-LOGIC128(|)
-LOGIC128(&)
-LOGIC128(^)
-
-#undef LOGIC128
-
-#define LOGICASSIGN128(op) \
-inline uint128& uint128::operator op(const uint128& other) { \
- hi_ op other.hi_; \
- lo_ op other.lo_; \
- return *this; \
-}
-
-LOGICASSIGN128(|=)
-LOGICASSIGN128(&=)
-LOGICASSIGN128(^=)
-
-#undef LOGICASSIGN128
-
-// Shift operators.
-
-inline uint128 operator<<(const uint128& val, int amount) {
- // uint64 shifts of >= 64 are undefined, so we will need some special-casing.
- if (amount < 64) {
- if (amount == 0) {
- return val;
- }
- arc_ui64 new_hi = (Uint128High64(val) << amount) |
- (Uint128Low64(val) >> (64 - amount));
- arc_ui64 new_lo = Uint128Low64(val) << amount;
- return uint128(new_hi, new_lo);
- } else if (amount < 128) {
- return uint128(Uint128Low64(val) << (amount - 64), 0);
- } else {
- return uint128(0, 0);
- }
-}
-
-inline uint128 operator>>(const uint128& val, int amount) {
- // uint64 shifts of >= 64 are undefined, so we will need some special-casing.
- if (amount < 64) {
- if (amount == 0) {
- return val;
- }
- arc_ui64 new_hi = Uint128High64(val) >> amount;
- arc_ui64 new_lo = (Uint128Low64(val) >> amount) |
- (Uint128High64(val) << (64 - amount));
- return uint128(new_hi, new_lo);
- } else if (amount < 128) {
- return uint128(0, Uint128High64(val) >> (amount - 64));
- } else {
- return uint128(0, 0);
- }
-}
-
-inline uint128& uint128::operator<<=(int amount) {
- // uint64 shifts of >= 64 are undefined, so we will need some special-casing.
- if (amount < 64) {
- if (amount != 0) {
- hi_ = (hi_ << amount) | (lo_ >> (64 - amount));
- lo_ = lo_ << amount;
- }
- } else if (amount < 128) {
- hi_ = lo_ << (amount - 64);
- lo_ = 0;
- } else {
- hi_ = 0;
- lo_ = 0;
- }
- return *this;
-}
-
-inline uint128& uint128::operator>>=(int amount) {
- // uint64 shifts of >= 64 are undefined, so we will need some special-casing.
- if (amount < 64) {
- if (amount != 0) {
- lo_ = (lo_ >> amount) | (hi_ << (64 - amount));
- hi_ = hi_ >> amount;
- }
- } else if (amount < 128) {
- lo_ = hi_ >> (amount - 64);
- hi_ = 0;
- } else {
- lo_ = 0;
- hi_ = 0;
- }
- return *this;
-}
-
-inline uint128 operator+(const uint128& lhs, const uint128& rhs) {
- return uint128(lhs) += rhs;
-}
-
-inline uint128 operator-(const uint128& lhs, const uint128& rhs) {
- return uint128(lhs) -= rhs;
-}
-
-inline uint128 operator*(const uint128& lhs, const uint128& rhs) {
- return uint128(lhs) *= rhs;
-}
-
-inline uint128 operator/(const uint128& lhs, const uint128& rhs) {
- return uint128(lhs) /= rhs;
-}
-
-inline uint128 operator%(const uint128& lhs, const uint128& rhs) {
- return uint128(lhs) %= rhs;
-}
-
-inline uint128& uint128::operator+=(const uint128& b) {
- hi_ += b.hi_;
- arc_ui64 lolo = lo_ + b.lo_;
- if (lolo < lo_)
- ++hi_;
- lo_ = lolo;
- return *this;
-}
-
-inline uint128& uint128::operator-=(const uint128& b) {
- hi_ -= b.hi_;
- if (b.lo_ > lo_)
- --hi_;
- lo_ -= b.lo_;
- return *this;
-}
-
-inline uint128& uint128::operator*=(const uint128& b) {
- arc_ui64 a96 = hi_ >> 32;
- arc_ui64 a64 = hi_ & 0xffffffffu;
- arc_ui64 a32 = lo_ >> 32;
- arc_ui64 a00 = lo_ & 0xffffffffu;
- arc_ui64 b96 = b.hi_ >> 32;
- arc_ui64 b64 = b.hi_ & 0xffffffffu;
- arc_ui64 b32 = b.lo_ >> 32;
- arc_ui64 b00 = b.lo_ & 0xffffffffu;
- // multiply [a96 .. a00] x [b96 .. b00]
- // terms higher than c96 disappear off the high side
- // terms c96 and c64 are safe to ignore carry bit
- arc_ui64 c96 = a96 * b00 + a64 * b32 + a32 * b64 + a00 * b96;
- arc_ui64 c64 = a64 * b00 + a32 * b32 + a00 * b64;
- this->hi_ = (c96 << 32) + c64;
- this->lo_ = 0;
- // add terms after this one at a time to capture carry
- *this += uint128(a32 * b00) << 32;
- *this += uint128(a00 * b32) << 32;
- *this += a00 * b00;
- return *this;
-}
-
-inline uint128 uint128::operator++(int) {
- uint128 tmp(*this);
- *this += 1;
- return tmp;
-}
-
-inline uint128 uint128::operator--(int) {
- uint128 tmp(*this);
- *this -= 1;
- return tmp;
-}
-
-inline uint128& uint128::operator++() {
- *this += 1;
- return *this;
-}
-
-inline uint128& uint128::operator--() {
- *this -= 1;
- return *this;
-}
-
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#endif // GOOGLE_PROTOBUF_STUBS_INT128_H_
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/logging.h b/contrib/libs/protobuf/src/google/protobuf/stubs/logging.h
deleted file mode 100644
index 61a271434fc..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/logging.h
+++ /dev/null
@@ -1,239 +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_STUBS_LOGGING_H_
-#define GOOGLE_PROTOBUF_STUBS_LOGGING_H_
-
-#include <google/protobuf/stubs/macros.h>
-#include <google/protobuf/stubs/port.h>
-#include <google/protobuf/stubs/status.h>
-#include <google/protobuf/stubs/stringpiece.h>
-
-#include <google/protobuf/port_def.inc>
-
-// ===================================================================
-// emulates google3/base/logging.h
-
-namespace google {
-namespace protobuf {
-
-enum LogLevel {
- LOGLEVEL_INFO, // Informational. This is never actually used by
- // libprotobuf.
- LOGLEVEL_WARNING, // Warns about issues that, although not technically a
- // problem now, could cause problems in the future. For
- // example, a // warning will be printed when parsing a
- // message that is near the message size limit.
- LOGLEVEL_ERROR, // An error occurred which should never happen during
- // normal use.
- LOGLEVEL_FATAL, // An error occurred from which the library cannot
- // recover. This usually indicates a programming error
- // in the code which calls the library, especially when
- // compiled in debug mode.
-
-#ifdef NDEBUG
- LOGLEVEL_DFATAL = LOGLEVEL_ERROR
-#else
- LOGLEVEL_DFATAL = LOGLEVEL_FATAL
-#endif
-};
-
-class uint128;
-namespace internal {
-
-class LogFinisher;
-
-class PROTOBUF_EXPORT LogMessage {
- public:
- LogMessage(LogLevel level, const char* filename, int line);
- ~LogMessage();
-
- LogMessage& operator<<(const TProtoStringType& value);
- LogMessage& operator<<(const char* value);
- LogMessage& operator<<(char value);
- LogMessage& operator<<(int value);
- LogMessage& operator<<(uint value);
- LogMessage& operator<<(long value);
- LogMessage& operator<<(unsigned long value);
- LogMessage& operator<<(long long value);
- LogMessage& operator<<(unsigned long long value);
- LogMessage& operator<<(double value);
- LogMessage& operator<<(void* value);
- LogMessage& operator<<(const StringPiece& value);
- LogMessage& operator<<(const util::Status& status);
- LogMessage& operator<<(const uint128& value);
-
- private:
- friend class LogFinisher;
- void Finish();
-
- LogLevel level_;
- const char* filename_;
- int line_;
- TProtoStringType message_;
-};
-
-// Used to make the entire "LOG(BLAH) << etc." expression have a void return
-// type and print a newline after each message.
-class PROTOBUF_EXPORT LogFinisher {
- public:
- void operator=(LogMessage& other);
-};
-
-template<typename T>
-bool IsOk(T status) { return status.ok(); }
-template<>
-inline bool IsOk(bool status) { return status; }
-
-} // namespace internal
-
-// Undef everything in case we're being mixed with some other Google library
-// which already defined them itself. Presumably all Google libraries will
-// support the same syntax for these so it should not be a big deal if they
-// end up using our definitions instead.
-#undef GOOGLE_LOG
-#undef GOOGLE_LOG_IF
-
-#undef GOOGLE_CHECK
-#undef GOOGLE_CHECK_OK
-#undef GOOGLE_CHECK_EQ
-#undef GOOGLE_CHECK_NE
-#undef GOOGLE_CHECK_LT
-#undef GOOGLE_CHECK_LE
-#undef GOOGLE_CHECK_GT
-#undef GOOGLE_CHECK_GE
-#undef GOOGLE_CHECK_NOTNULL
-
-#undef GOOGLE_DLOG
-#undef GOOGLE_DCHECK
-#undef GOOGLE_DCHECK_OK
-#undef GOOGLE_DCHECK_EQ
-#undef GOOGLE_DCHECK_NE
-#undef GOOGLE_DCHECK_LT
-#undef GOOGLE_DCHECK_LE
-#undef GOOGLE_DCHECK_GT
-#undef GOOGLE_DCHECK_GE
-
-#define GOOGLE_LOG(LEVEL) \
- ::google::protobuf::internal::LogFinisher() = \
- ::google::protobuf::internal::LogMessage( \
- ::google::protobuf::LOGLEVEL_##LEVEL, __FILE__, __LINE__)
-#define GOOGLE_LOG_IF(LEVEL, CONDITION) \
- !(CONDITION) ? (void)0 : GOOGLE_LOG(LEVEL)
-
-#define GOOGLE_CHECK(EXPRESSION) \
- GOOGLE_LOG_IF(FATAL, !(EXPRESSION)) << "CHECK failed: " #EXPRESSION ": "
-#define GOOGLE_CHECK_OK(A) GOOGLE_CHECK(::google::protobuf::internal::IsOk(A))
-#define GOOGLE_CHECK_EQ(A, B) GOOGLE_CHECK((A) == (B))
-#define GOOGLE_CHECK_NE(A, B) GOOGLE_CHECK((A) != (B))
-#define GOOGLE_CHECK_LT(A, B) GOOGLE_CHECK((A) < (B))
-#define GOOGLE_CHECK_LE(A, B) GOOGLE_CHECK((A) <= (B))
-#define GOOGLE_CHECK_GT(A, B) GOOGLE_CHECK((A) > (B))
-#define GOOGLE_CHECK_GE(A, B) GOOGLE_CHECK((A) >= (B))
-
-namespace internal {
-template<typename T>
-T* CheckNotNull(const char* /* file */, int /* line */,
- const char* name, T* val) {
- if (val == nullptr) {
- GOOGLE_LOG(FATAL) << name;
- }
- return val;
-}
-} // namespace internal
-#define GOOGLE_CHECK_NOTNULL(A) \
- ::google::protobuf::internal::CheckNotNull( \
- __FILE__, __LINE__, "'" #A "' must not be nullptr", (A))
-
-#ifdef NDEBUG
-
-#define GOOGLE_DLOG(LEVEL) GOOGLE_LOG_IF(LEVEL, false)
-
-#define GOOGLE_DCHECK(EXPRESSION) while(false) GOOGLE_CHECK(EXPRESSION)
-#define GOOGLE_DCHECK_OK(E) GOOGLE_DCHECK(::google::protobuf::internal::IsOk(E))
-#define GOOGLE_DCHECK_EQ(A, B) GOOGLE_DCHECK((A) == (B))
-#define GOOGLE_DCHECK_NE(A, B) GOOGLE_DCHECK((A) != (B))
-#define GOOGLE_DCHECK_LT(A, B) GOOGLE_DCHECK((A) < (B))
-#define GOOGLE_DCHECK_LE(A, B) GOOGLE_DCHECK((A) <= (B))
-#define GOOGLE_DCHECK_GT(A, B) GOOGLE_DCHECK((A) > (B))
-#define GOOGLE_DCHECK_GE(A, B) GOOGLE_DCHECK((A) >= (B))
-
-#else // NDEBUG
-
-#define GOOGLE_DLOG GOOGLE_LOG
-
-#define GOOGLE_DCHECK GOOGLE_CHECK
-#define GOOGLE_DCHECK_OK GOOGLE_CHECK_OK
-#define GOOGLE_DCHECK_EQ GOOGLE_CHECK_EQ
-#define GOOGLE_DCHECK_NE GOOGLE_CHECK_NE
-#define GOOGLE_DCHECK_LT GOOGLE_CHECK_LT
-#define GOOGLE_DCHECK_LE GOOGLE_CHECK_LE
-#define GOOGLE_DCHECK_GT GOOGLE_CHECK_GT
-#define GOOGLE_DCHECK_GE GOOGLE_CHECK_GE
-
-#endif // !NDEBUG
-
-typedef void LogHandler(LogLevel level, const char* filename, int line,
- const TProtoStringType& message);
-
-// The protobuf library sometimes writes warning and error messages to
-// stderr. These messages are primarily useful for developers, but may
-// also help end users figure out a problem. If you would prefer that
-// these messages be sent somewhere other than stderr, call SetLogHandler()
-// to set your own handler. This returns the old handler. Set the handler
-// to nullptr to ignore log messages (but see also LogSilencer, below).
-//
-// Obviously, SetLogHandler is not thread-safe. You should only call it
-// at initialization time, and probably not from library code. If you
-// simply want to suppress log messages temporarily (e.g. because you
-// have some code that tends to trigger them frequently and you know
-// the warnings are not important to you), use the LogSilencer class
-// below.
-PROTOBUF_EXPORT LogHandler* SetLogHandler(LogHandler* new_func);
-
-// Create a LogSilencer if you want to temporarily suppress all log
-// messages. As long as any LogSilencer objects exist, non-fatal
-// log messages will be discarded (the current LogHandler will *not*
-// be called). Constructing a LogSilencer is thread-safe. You may
-// accidentally suppress log messages occurring in another thread, but
-// since messages are generally for debugging purposes only, this isn't
-// a big deal. If you want to intercept log messages, use SetLogHandler().
-class PROTOBUF_EXPORT LogSilencer {
- public:
- LogSilencer();
- ~LogSilencer();
-};
-
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#endif // GOOGLE_PROTOBUF_STUBS_LOGGING_H_
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/macros.h b/contrib/libs/protobuf/src/google/protobuf/stubs/macros.h
deleted file mode 100644
index ae9a8b987f2..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/macros.h
+++ /dev/null
@@ -1,93 +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_MACROS_H__
-#define GOOGLE_PROTOBUF_MACROS_H__
-
-namespace google {
-namespace protobuf {
-
-#undef GOOGLE_DISALLOW_EVIL_CONSTRUCTORS
-#define GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeName) \
- TypeName(const TypeName&) = delete; \
- void operator=(const TypeName&) = delete
-
-#undef GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS
-#define GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
- TypeName() = delete; \
- TypeName(const TypeName&) = delete; \
- void operator=(const TypeName&) = delete
-
-// ===================================================================
-// from google3/base/basictypes.h
-
-// The GOOGLE_ARRAYSIZE(arr) macro returns the # of elements in an array arr.
-// The expression is a compile-time constant, and therefore can be
-// used in defining new arrays, for example.
-//
-// GOOGLE_ARRAYSIZE catches a few type errors. If you see a compiler error
-//
-// "warning: division by zero in ..."
-//
-// when using GOOGLE_ARRAYSIZE, you are (wrongfully) giving it a pointer.
-// You should only use GOOGLE_ARRAYSIZE on statically allocated arrays.
-//
-// The following comments are on the implementation details, and can
-// be ignored by the users.
-//
-// ARRAYSIZE(arr) works by inspecting sizeof(arr) (the # of bytes in
-// the array) and sizeof(*(arr)) (the # of bytes in one array
-// element). If the former is divisible by the latter, perhaps arr is
-// indeed an array, in which case the division result is the # of
-// elements in the array. Otherwise, arr cannot possibly be an array,
-// and we generate a compiler error to prevent the code from
-// compiling.
-//
-// Since the size of bool is implementation-defined, we need to cast
-// !(sizeof(a) & sizeof(*(a))) to size_t in order to ensure the final
-// result has type size_t.
-//
-// This macro is not perfect as it wrongfully accepts certain
-// pointers, namely where the pointer size is divisible by the pointee
-// size. Since all our code has to go through a 32-bit compiler,
-// where a pointer is 4 bytes, this means all pointers to a type whose
-// size is 3 or greater than 4 will be (righteously) rejected.
-//
-// Kudos to Jorg Brown for this simple and elegant implementation.
-
-#undef GOOGLE_ARRAYSIZE
-#define GOOGLE_ARRAYSIZE(a) \
- ((sizeof(a) / sizeof(*(a))) / \
- static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
-
-} // namespace protobuf
-} // namespace google
-
-#endif // GOOGLE_PROTOBUF_MACROS_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/map_util.h b/contrib/libs/protobuf/src/google/protobuf/stubs/map_util.h
deleted file mode 100644
index 24e098ad1bc..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/map_util.h
+++ /dev/null
@@ -1,769 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2014 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.
-
-// from google3/util/gtl/map_util.h
-// Author: Anton Carver
-
-#ifndef GOOGLE_PROTOBUF_STUBS_MAP_UTIL_H__
-#define GOOGLE_PROTOBUF_STUBS_MAP_UTIL_H__
-
-#include <stddef.h>
-#include <iterator>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include <google/protobuf/stubs/common.h>
-
-namespace google {
-namespace protobuf {
-namespace internal {
-// Local implementation of RemoveConst to avoid including base/type_traits.h.
-template <class T> struct RemoveConst { typedef T type; };
-template <class T> struct RemoveConst<const T> : RemoveConst<T> {};
-} // namespace internal
-
-//
-// Find*()
-//
-
-// Returns a const reference to the value associated with the given key if it
-// exists. Crashes otherwise.
-//
-// This is intended as a replacement for operator[] as an rvalue (for reading)
-// when the key is guaranteed to exist.
-//
-// operator[] for lookup is discouraged for several reasons:
-// * It has a side-effect of inserting missing keys
-// * It is not thread-safe (even when it is not inserting, it can still
-// choose to resize the underlying storage)
-// * It invalidates iterators (when it chooses to resize)
-// * It default constructs a value object even if it doesn't need to
-//
-// This version assumes the key is printable, and includes it in the fatal log
-// message.
-template <class Collection>
-const typename Collection::value_type::second_type&
-FindOrDie(const Collection& collection,
- const typename Collection::value_type::first_type& key) {
- typename Collection::const_iterator it = collection.find(key);
- GOOGLE_CHECK(it != collection.end()) << "Map key not found: " << key;
- return it->second;
-}
-
-// Same as above, but returns a non-const reference.
-template <class Collection>
-typename Collection::value_type::second_type&
-FindOrDie(Collection& collection, // NOLINT
- const typename Collection::value_type::first_type& key) {
- typename Collection::iterator it = collection.find(key);
- GOOGLE_CHECK(it != collection.end()) << "Map key not found: " << key;
- return it->second;
-}
-
-// Same as FindOrDie above, but doesn't log the key on failure.
-template <class Collection>
-const typename Collection::value_type::second_type&
-FindOrDieNoPrint(const Collection& collection,
- const typename Collection::value_type::first_type& key) {
- typename Collection::const_iterator it = collection.find(key);
- GOOGLE_CHECK(it != collection.end()) << "Map key not found";
- return it->second;
-}
-
-// Same as above, but returns a non-const reference.
-template <class Collection>
-typename Collection::value_type::second_type&
-FindOrDieNoPrint(Collection& collection, // NOLINT
- const typename Collection::value_type::first_type& key) {
- typename Collection::iterator it = collection.find(key);
- GOOGLE_CHECK(it != collection.end()) << "Map key not found";
- return it->second;
-}
-
-// Returns a const reference to the value associated with the given key if it
-// exists, otherwise returns a const reference to the provided default value.
-//
-// WARNING: If a temporary object is passed as the default "value,"
-// this function will return a reference to that temporary object,
-// which will be destroyed at the end of the statement. A common
-// example: if you have a map with string values, and you pass a char*
-// as the default "value," either use the returned value immediately
-// or store it in a string (not string&).
-// Details: http://go/findwithdefault
-template <class Collection>
-const typename Collection::value_type::second_type&
-FindWithDefault(const Collection& collection,
- const typename Collection::value_type::first_type& key,
- const typename Collection::value_type::second_type& value) {
- typename Collection::const_iterator it = collection.find(key);
- if (it == collection.end()) {
- return value;
- }
- return it->second;
-}
-
-// Returns a pointer to the const value associated with the given key if it
-// exists, or nullptr otherwise.
-template <class Collection>
-const typename Collection::value_type::second_type*
-FindOrNull(const Collection& collection,
- const typename Collection::value_type::first_type& key) {
- typename Collection::const_iterator it = collection.find(key);
- if (it == collection.end()) {
- return 0;
- }
- return &it->second;
-}
-
-// Same as above but returns a pointer to the non-const value.
-template <class Collection>
-typename Collection::value_type::second_type*
-FindOrNull(Collection& collection, // NOLINT
- const typename Collection::value_type::first_type& key) {
- typename Collection::iterator it = collection.find(key);
- if (it == collection.end()) {
- return 0;
- }
- return &it->second;
-}
-
-// Returns the pointer value associated with the given key. If none is found,
-// nullptr is returned. The function is designed to be used with a map of keys to
-// pointers.
-//
-// This function does not distinguish between a missing key and a key mapped
-// to nullptr.
-template <class Collection>
-typename Collection::value_type::second_type
-FindPtrOrNull(const Collection& collection,
- const typename Collection::value_type::first_type& key) {
- typename Collection::const_iterator it = collection.find(key);
- if (it == collection.end()) {
- return typename Collection::value_type::second_type();
- }
- return it->second;
-}
-
-// Same as above, except takes non-const reference to collection.
-//
-// This function is needed for containers that propagate constness to the
-// pointee, such as boost::ptr_map.
-template <class Collection>
-typename Collection::value_type::second_type
-FindPtrOrNull(Collection& collection, // NOLINT
- const typename Collection::value_type::first_type& key) {
- typename Collection::iterator it = collection.find(key);
- if (it == collection.end()) {
- return typename Collection::value_type::second_type();
- }
- return it->second;
-}
-
-// Finds the pointer value associated with the given key in a map whose values
-// are linked_ptrs. Returns nullptr if key is not found.
-template <class Collection>
-typename Collection::value_type::second_type::element_type*
-FindLinkedPtrOrNull(const Collection& collection,
- const typename Collection::value_type::first_type& key) {
- typename Collection::const_iterator it = collection.find(key);
- if (it == collection.end()) {
- return 0;
- }
- // Since linked_ptr::get() is a const member returning a non const,
- // we do not need a version of this function taking a non const collection.
- return it->second.get();
-}
-
-// Same as above, but dies if the key is not found.
-template <class Collection>
-typename Collection::value_type::second_type::element_type&
-FindLinkedPtrOrDie(const Collection& collection,
- const typename Collection::value_type::first_type& key) {
- typename Collection::const_iterator it = collection.find(key);
- GOOGLE_CHECK(it != collection.end()) << "key not found: " << key;
- // Since linked_ptr::operator*() is a const member returning a non const,
- // we do not need a version of this function taking a non const collection.
- return *it->second;
-}
-
-// Finds the value associated with the given key and copies it to *value (if not
-// nullptr). Returns false if the key was not found, true otherwise.
-template <class Collection, class Key, class Value>
-bool FindCopy(const Collection& collection,
- const Key& key,
- Value* const value) {
- typename Collection::const_iterator it = collection.find(key);
- if (it == collection.end()) {
- return false;
- }
- if (value) {
- *value = it->second;
- }
- return true;
-}
-
-//
-// Contains*()
-//
-
-// Returns true if and only if the given collection contains the given key.
-template <class Collection, class Key>
-bool ContainsKey(const Collection& collection, const Key& key) {
- return collection.find(key) != collection.end();
-}
-
-// Returns true if and only if the given collection contains the given key-value
-// pair.
-template <class Collection, class Key, class Value>
-bool ContainsKeyValuePair(const Collection& collection,
- const Key& key,
- const Value& value) {
- typedef typename Collection::const_iterator const_iterator;
- std::pair<const_iterator, const_iterator> range = collection.equal_range(key);
- for (const_iterator it = range.first; it != range.second; ++it) {
- if (it->second == value) {
- return true;
- }
- }
- return false;
-}
-
-//
-// Insert*()
-//
-
-// Inserts the given key-value pair into the collection. Returns true if and
-// only if the key from the given pair didn't previously exist. Otherwise, the
-// value in the map is replaced with the value from the given pair.
-template <class Collection>
-bool InsertOrUpdate(Collection* const collection,
- const typename Collection::value_type& vt) {
- std::pair<typename Collection::iterator, bool> ret = collection->insert(vt);
- if (!ret.second) {
- // update
- ret.first->second = vt.second;
- return false;
- }
- return true;
-}
-
-// Same as above, except that the key and value are passed separately.
-template <class Collection>
-bool InsertOrUpdate(Collection* const collection,
- const typename Collection::value_type::first_type& key,
- const typename Collection::value_type::second_type& value) {
- return InsertOrUpdate(
- collection, typename Collection::value_type(key, value));
-}
-
-// Inserts/updates all the key-value pairs from the range defined by the
-// iterators "first" and "last" into the given collection.
-template <class Collection, class InputIterator>
-void InsertOrUpdateMany(Collection* const collection,
- InputIterator first, InputIterator last) {
- for (; first != last; ++first) {
- InsertOrUpdate(collection, *first);
- }
-}
-
-// Change the value associated with a particular key in a map or hash_map
-// of the form map<Key, Value*> which owns the objects pointed to by the
-// value pointers. If there was an existing value for the key, it is deleted.
-// True indicates an insert took place, false indicates an update + delete.
-template <class Collection>
-bool InsertAndDeleteExisting(
- Collection* const collection,
- const typename Collection::value_type::first_type& key,
- const typename Collection::value_type::second_type& value) {
- std::pair<typename Collection::iterator, bool> ret =
- collection->insert(typename Collection::value_type(key, value));
- if (!ret.second) {
- delete ret.first->second;
- ret.first->second = value;
- return false;
- }
- return true;
-}
-
-// Inserts the given key and value into the given collection if and only if the
-// given key did NOT already exist in the collection. If the key previously
-// existed in the collection, the value is not changed. Returns true if the
-// key-value pair was inserted; returns false if the key was already present.
-template <class Collection>
-bool InsertIfNotPresent(Collection* const collection,
- const typename Collection::value_type& vt) {
- return collection->insert(vt).second;
-}
-
-// Same as above except the key and value are passed separately.
-template <class Collection>
-bool InsertIfNotPresent(
- Collection* const collection,
- const typename Collection::value_type::first_type& key,
- const typename Collection::value_type::second_type& value) {
- return InsertIfNotPresent(
- collection, typename Collection::value_type(key, value));
-}
-
-// Same as above except dies if the key already exists in the collection.
-template <class Collection>
-void InsertOrDie(Collection* const collection,
- const typename Collection::value_type& value) {
- GOOGLE_CHECK(InsertIfNotPresent(collection, value))
- << "duplicate value: " << value;
-}
-
-// Same as above except doesn't log the value on error.
-template <class Collection>
-void InsertOrDieNoPrint(Collection* const collection,
- const typename Collection::value_type& value) {
- GOOGLE_CHECK(InsertIfNotPresent(collection, value)) << "duplicate value.";
-}
-
-// Inserts the key-value pair into the collection. Dies if key was already
-// present.
-template <class Collection>
-void InsertOrDie(Collection* const collection,
- const typename Collection::value_type::first_type& key,
- const typename Collection::value_type::second_type& data) {
- GOOGLE_CHECK(InsertIfNotPresent(collection, key, data))
- << "duplicate key: " << key;
-}
-
-// Same as above except doesn't log the key on error.
-template <class Collection>
-void InsertOrDieNoPrint(
- Collection* const collection,
- const typename Collection::value_type::first_type& key,
- const typename Collection::value_type::second_type& data) {
- GOOGLE_CHECK(InsertIfNotPresent(collection, key, data)) << "duplicate key.";
-}
-
-// Inserts a new key and default-initialized value. Dies if the key was already
-// present. Returns a reference to the value. Example usage:
-//
-// map<int, SomeProto> m;
-// SomeProto& proto = InsertKeyOrDie(&m, 3);
-// proto.set_field("foo");
-template <class Collection>
-typename Collection::value_type::second_type& InsertKeyOrDie(
- Collection* const collection,
- const typename Collection::value_type::first_type& key) {
- typedef typename Collection::value_type value_type;
- std::pair<typename Collection::iterator, bool> res =
- collection->insert(value_type(key, typename value_type::second_type()));
- GOOGLE_CHECK(res.second) << "duplicate key: " << key;
- return res.first->second;
-}
-
-//
-// Lookup*()
-//
-
-// Looks up a given key and value pair in a collection and inserts the key-value
-// pair if it's not already present. Returns a reference to the value associated
-// with the key.
-template <class Collection>
-typename Collection::value_type::second_type&
-LookupOrInsert(Collection* const collection,
- const typename Collection::value_type& vt) {
- return collection->insert(vt).first->second;
-}
-
-// Same as above except the key-value are passed separately.
-template <class Collection>
-typename Collection::value_type::second_type&
-LookupOrInsert(Collection* const collection,
- const typename Collection::value_type::first_type& key,
- const typename Collection::value_type::second_type& value) {
- return LookupOrInsert(
- collection, typename Collection::value_type(key, value));
-}
-
-// Counts the number of equivalent elements in the given "sequence", and stores
-// the results in "count_map" with element as the key and count as the value.
-//
-// Example:
-// vector<string> v = {"a", "b", "c", "a", "b"};
-// map<string, int> m;
-// AddTokenCounts(v, 1, &m);
-// assert(m["a"] == 2);
-// assert(m["b"] == 2);
-// assert(m["c"] == 1);
-template <typename Sequence, typename Collection>
-void AddTokenCounts(
- const Sequence& sequence,
- const typename Collection::value_type::second_type& increment,
- Collection* const count_map) {
- for (typename Sequence::const_iterator it = sequence.begin();
- it != sequence.end(); ++it) {
- typename Collection::value_type::second_type& value =
- LookupOrInsert(count_map, *it,
- typename Collection::value_type::second_type());
- value += increment;
- }
-}
-
-// Returns a reference to the value associated with key. If not found, a value
-// is default constructed on the heap and added to the map.
-//
-// This function is useful for containers of the form map<Key, Value*>, where
-// inserting a new key, value pair involves constructing a new heap-allocated
-// Value, and storing a pointer to that in the collection.
-template <class Collection>
-typename Collection::value_type::second_type&
-LookupOrInsertNew(Collection* const collection,
- const typename Collection::value_type::first_type& key) {
- typedef typename std::iterator_traits<
- typename Collection::value_type::second_type>::value_type Element;
- std::pair<typename Collection::iterator, bool> ret =
- collection->insert(typename Collection::value_type(
- key,
- static_cast<typename Collection::value_type::second_type>(nullptr)));
- if (ret.second) {
- ret.first->second = new Element();
- }
- return ret.first->second;
-}
-
-// Same as above but constructs the value using the single-argument constructor
-// and the given "arg".
-template <class Collection, class Arg>
-typename Collection::value_type::second_type&
-LookupOrInsertNew(Collection* const collection,
- const typename Collection::value_type::first_type& key,
- const Arg& arg) {
- typedef typename std::iterator_traits<
- typename Collection::value_type::second_type>::value_type Element;
- std::pair<typename Collection::iterator, bool> ret =
- collection->insert(typename Collection::value_type(
- key,
- static_cast<typename Collection::value_type::second_type>(nullptr)));
- if (ret.second) {
- ret.first->second = new Element(arg);
- }
- return ret.first->second;
-}
-
-// Lookup of linked/shared pointers is used in two scenarios:
-//
-// Use LookupOrInsertNewLinkedPtr if the container owns the elements.
-// In this case it is fine working with the raw pointer as long as it is
-// guaranteed that no other thread can delete/update an accessed element.
-// A mutex will need to lock the container operation as well as the use
-// of the returned elements. Finding an element may be performed using
-// FindLinkedPtr*().
-//
-// Use LookupOrInsertNewSharedPtr if the container does not own the elements
-// for their whole lifetime. This is typically the case when a reader allows
-// parallel updates to the container. In this case a Mutex only needs to lock
-// container operations, but all element operations must be performed on the
-// shared pointer. Finding an element must be performed using FindPtr*() and
-// cannot be done with FindLinkedPtr*() even though it compiles.
-
-// Lookup a key in a map or hash_map whose values are linked_ptrs. If it is
-// missing, set collection[key].reset(new Value::element_type) and return that.
-// Value::element_type must be default constructable.
-template <class Collection>
-typename Collection::value_type::second_type::element_type*
-LookupOrInsertNewLinkedPtr(
- Collection* const collection,
- const typename Collection::value_type::first_type& key) {
- typedef typename Collection::value_type::second_type Value;
- std::pair<typename Collection::iterator, bool> ret =
- collection->insert(typename Collection::value_type(key, Value()));
- if (ret.second) {
- ret.first->second.reset(new typename Value::element_type);
- }
- return ret.first->second.get();
-}
-
-// A variant of LookupOrInsertNewLinkedPtr where the value is constructed using
-// a single-parameter constructor. Note: the constructor argument is computed
-// even if it will not be used, so only values cheap to compute should be passed
-// here. On the other hand it does not matter how expensive the construction of
-// the actual stored value is, as that only occurs if necessary.
-template <class Collection, class Arg>
-typename Collection::value_type::second_type::element_type*
-LookupOrInsertNewLinkedPtr(
- Collection* const collection,
- const typename Collection::value_type::first_type& key,
- const Arg& arg) {
- typedef typename Collection::value_type::second_type Value;
- std::pair<typename Collection::iterator, bool> ret =
- collection->insert(typename Collection::value_type(key, Value()));
- if (ret.second) {
- ret.first->second.reset(new typename Value::element_type(arg));
- }
- return ret.first->second.get();
-}
-
-// Lookup a key in a map or hash_map whose values are shared_ptrs. If it is
-// missing, set collection[key].reset(new Value::element_type). Unlike
-// LookupOrInsertNewLinkedPtr, this function returns the shared_ptr instead of
-// the raw pointer. Value::element_type must be default constructable.
-template <class Collection>
-typename Collection::value_type::second_type&
-LookupOrInsertNewSharedPtr(
- Collection* const collection,
- const typename Collection::value_type::first_type& key) {
- typedef typename Collection::value_type::second_type SharedPtr;
- typedef typename Collection::value_type::second_type::element_type Element;
- std::pair<typename Collection::iterator, bool> ret =
- collection->insert(typename Collection::value_type(key, SharedPtr()));
- if (ret.second) {
- ret.first->second.reset(new Element());
- }
- return ret.first->second;
-}
-
-// A variant of LookupOrInsertNewSharedPtr where the value is constructed using
-// a single-parameter constructor. Note: the constructor argument is computed
-// even if it will not be used, so only values cheap to compute should be passed
-// here. On the other hand it does not matter how expensive the construction of
-// the actual stored value is, as that only occurs if necessary.
-template <class Collection, class Arg>
-typename Collection::value_type::second_type&
-LookupOrInsertNewSharedPtr(
- Collection* const collection,
- const typename Collection::value_type::first_type& key,
- const Arg& arg) {
- typedef typename Collection::value_type::second_type SharedPtr;
- typedef typename Collection::value_type::second_type::element_type Element;
- std::pair<typename Collection::iterator, bool> ret =
- collection->insert(typename Collection::value_type(key, SharedPtr()));
- if (ret.second) {
- ret.first->second.reset(new Element(arg));
- }
- return ret.first->second;
-}
-
-//
-// Misc Utility Functions
-//
-
-// Updates the value associated with the given key. If the key was not already
-// present, then the key-value pair are inserted and "previous" is unchanged. If
-// the key was already present, the value is updated and "*previous" will
-// contain a copy of the old value.
-//
-// InsertOrReturnExisting has complementary behavior that returns the
-// address of an already existing value, rather than updating it.
-template <class Collection>
-bool UpdateReturnCopy(Collection* const collection,
- const typename Collection::value_type::first_type& key,
- const typename Collection::value_type::second_type& value,
- typename Collection::value_type::second_type* previous) {
- std::pair<typename Collection::iterator, bool> ret =
- collection->insert(typename Collection::value_type(key, value));
- if (!ret.second) {
- // update
- if (previous) {
- *previous = ret.first->second;
- }
- ret.first->second = value;
- return true;
- }
- return false;
-}
-
-// Same as above except that the key and value are passed as a pair.
-template <class Collection>
-bool UpdateReturnCopy(Collection* const collection,
- const typename Collection::value_type& vt,
- typename Collection::value_type::second_type* previous) {
- std::pair<typename Collection::iterator, bool> ret = collection->insert(vt);
- if (!ret.second) {
- // update
- if (previous) {
- *previous = ret.first->second;
- }
- ret.first->second = vt.second;
- return true;
- }
- return false;
-}
-
-// Tries to insert the given key-value pair into the collection. Returns nullptr if
-// the insert succeeds. Otherwise, returns a pointer to the existing value.
-//
-// This complements UpdateReturnCopy in that it allows to update only after
-// verifying the old value and still insert quickly without having to look up
-// twice. Unlike UpdateReturnCopy this also does not come with the issue of an
-// undefined previous* in case new data was inserted.
-template <class Collection>
-typename Collection::value_type::second_type* InsertOrReturnExisting(
- Collection* const collection, const typename Collection::value_type& vt) {
- std::pair<typename Collection::iterator, bool> ret = collection->insert(vt);
- if (ret.second) {
- return nullptr; // Inserted, no existing previous value.
- } else {
- return &ret.first->second; // Return address of already existing value.
- }
-}
-
-// Same as above, except for explicit key and data.
-template <class Collection>
-typename Collection::value_type::second_type* InsertOrReturnExisting(
- Collection* const collection,
- const typename Collection::value_type::first_type& key,
- const typename Collection::value_type::second_type& data) {
- return InsertOrReturnExisting(collection,
- typename Collection::value_type(key, data));
-}
-
-// Erases the collection item identified by the given key, and returns the value
-// associated with that key. It is assumed that the value (i.e., the
-// mapped_type) is a pointer. Returns nullptr if the key was not found in the
-// collection.
-//
-// Examples:
-// map<string, MyType*> my_map;
-//
-// One line cleanup:
-// delete EraseKeyReturnValuePtr(&my_map, "abc");
-//
-// Use returned value:
-// std::unique_ptr<MyType> value_ptr(
-// EraseKeyReturnValuePtr(&my_map, "abc"));
-// if (value_ptr.get())
-// value_ptr->DoSomething();
-//
-template <class Collection>
-typename Collection::value_type::second_type EraseKeyReturnValuePtr(
- Collection* const collection,
- const typename Collection::value_type::first_type& key) {
- typename Collection::iterator it = collection->find(key);
- if (it == collection->end()) {
- return nullptr;
- }
- typename Collection::value_type::second_type v = it->second;
- collection->erase(it);
- return v;
-}
-
-// Inserts all the keys from map_container into key_container, which must
-// support insert(MapContainer::key_type).
-//
-// Note: any initial contents of the key_container are not cleared.
-template <class MapContainer, class KeyContainer>
-void InsertKeysFromMap(const MapContainer& map_container,
- KeyContainer* key_container) {
- GOOGLE_CHECK(key_container != nullptr);
- for (typename MapContainer::const_iterator it = map_container.begin();
- it != map_container.end(); ++it) {
- key_container->insert(it->first);
- }
-}
-
-// Appends all the keys from map_container into key_container, which must
-// support push_back(MapContainer::key_type).
-//
-// Note: any initial contents of the key_container are not cleared.
-template <class MapContainer, class KeyContainer>
-void AppendKeysFromMap(const MapContainer& map_container,
- KeyContainer* key_container) {
- GOOGLE_CHECK(key_container != nullptr);
- for (typename MapContainer::const_iterator it = map_container.begin();
- it != map_container.end(); ++it) {
- key_container->push_back(it->first);
- }
-}
-
-// A more specialized overload of AppendKeysFromMap to optimize reallocations
-// for the common case in which we're appending keys to a vector and hence can
-// (and sometimes should) call reserve() first.
-//
-// (It would be possible to play SFINAE games to call reserve() for any
-// container that supports it, but this seems to get us 99% of what we need
-// without the complexity of a SFINAE-based solution.)
-template <class MapContainer, class KeyType>
-void AppendKeysFromMap(const MapContainer& map_container,
- std::vector<KeyType>* key_container) {
- GOOGLE_CHECK(key_container != nullptr);
- // We now have the opportunity to call reserve(). Calling reserve() every
- // time is a bad idea for some use cases: libstdc++'s implementation of
- // vector<>::reserve() resizes the vector's backing store to exactly the
- // given size (unless it's already at least that big). Because of this,
- // the use case that involves appending a lot of small maps (total size
- // N) one by one to a vector would be O(N^2). But never calling reserve()
- // loses the opportunity to improve the use case of adding from a large
- // map to an empty vector (this improves performance by up to 33%). A
- // number of heuristics are possible; see the discussion in
- // cl/34081696. Here we use the simplest one.
- if (key_container->empty()) {
- key_container->reserve(map_container.size());
- }
- for (typename MapContainer::const_iterator it = map_container.begin();
- it != map_container.end(); ++it) {
- key_container->push_back(it->first);
- }
-}
-
-// Inserts all the values from map_container into value_container, which must
-// support push_back(MapContainer::mapped_type).
-//
-// Note: any initial contents of the value_container are not cleared.
-template <class MapContainer, class ValueContainer>
-void AppendValuesFromMap(const MapContainer& map_container,
- ValueContainer* value_container) {
- GOOGLE_CHECK(value_container != nullptr);
- for (typename MapContainer::const_iterator it = map_container.begin();
- it != map_container.end(); ++it) {
- value_container->push_back(it->second);
- }
-}
-
-// A more specialized overload of AppendValuesFromMap to optimize reallocations
-// for the common case in which we're appending values to a vector and hence
-// can (and sometimes should) call reserve() first.
-//
-// (It would be possible to play SFINAE games to call reserve() for any
-// container that supports it, but this seems to get us 99% of what we need
-// without the complexity of a SFINAE-based solution.)
-template <class MapContainer, class ValueType>
-void AppendValuesFromMap(const MapContainer& map_container,
- std::vector<ValueType>* value_container) {
- GOOGLE_CHECK(value_container != nullptr);
- // See AppendKeysFromMap for why this is done.
- if (value_container->empty()) {
- value_container->reserve(map_container.size());
- }
- for (typename MapContainer::const_iterator it = map_container.begin();
- it != map_container.end(); ++it) {
- value_container->push_back(it->second);
- }
-}
-
-} // namespace protobuf
-} // namespace google
-
-#endif // GOOGLE_PROTOBUF_STUBS_MAP_UTIL_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/mathutil.h b/contrib/libs/protobuf/src/google/protobuf/stubs/mathutil.h
deleted file mode 100644
index 1d16bcedb2a..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/mathutil.h
+++ /dev/null
@@ -1,162 +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_STUBS_MATHUTIL_H_
-#define GOOGLE_PROTOBUF_STUBS_MATHUTIL_H_
-
-#include <cmath>
-#include <float.h>
-#include <limits>
-
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/logging.h>
-
-namespace google {
-namespace protobuf {
-namespace internal {
-
-// Like std::make_unsigned_t except floating point types map to themselves.
-template <typename T>
-using MakeUnsignedT =
- typename std::conditional<std::is_integral<T>::value, std::make_unsigned<T>,
- std::common_type<T>>::type::type;
-
-// Like std::isnan() except a template function that is defined for all numeric
-// types.
-template <typename T,
- typename std::enable_if<std::is_integral<T>::value, int>::type = 0>
-bool IsNan(T /*val*/) {
- return false;
-}
-
-template <typename T, typename std::enable_if<std::is_floating_point<T>::value,
- int>::type = 0>
-bool IsNan(T val) {
- return std::isnan(val);
-}
-
-template<typename T>
-bool AlmostEquals(T a, T b) {
- return a == b;
-}
-template<>
-inline bool AlmostEquals(float a, float b) {
- return fabs(a - b) < 32 * FLT_EPSILON;
-}
-
-template<>
-inline bool AlmostEquals(double a, double b) {
- return fabs(a - b) < 32 * DBL_EPSILON;
-}
-
-} // namespace internal
-
-class MathUtil {
- public:
- template <typename T>
- static T Sign(T value) {
- if (value == T(0) || internal::IsNan(value)) {
- return value;
- }
- return value > T(0) ? 1 : -1;
- }
-
- template <typename T>
- static bool AlmostEquals(T a, T b) {
- return internal::AlmostEquals(a, b);
- }
-
- // Largest of two values.
- // Works correctly for special floating point values.
- // Note: 0.0 and -0.0 are not differentiated by Max (Max(0.0, -0.0) is -0.0),
- // which should be OK because, although they (can) have different
- // bit representation, they are observably the same when examined
- // with arithmetic and (in)equality operators.
- template <typename T>
- static T Max(const T x, const T y) {
- return internal::IsNan(x) || x > y ? x : y;
- }
-
- // Absolute value of x
- // Works correctly for unsigned types and
- // for special floating point values.
- // Note: 0.0 and -0.0 are not differentiated by Abs (Abs(0.0) is -0.0),
- // which should be OK: see the comment for Max above.
- template<typename T>
- static T Abs(const T x) {
- return x > T(0) ? x : -x;
- }
-
- // Absolute value of the difference between two numbers.
- // Works correctly for signed types and special floating point values.
- template <typename T>
- static typename internal::MakeUnsignedT<T> AbsDiff(const T x, const T y) {
- // Carries out arithmetic as unsigned to avoid overflow.
- typedef typename internal::MakeUnsignedT<T> R;
- return x > y ? R(x) - R(y) : R(y) - R(x);
- }
-
- // If two (usually floating point) numbers are within a certain
- // fraction of their magnitude or within a certain absolute margin of error.
- // This is the same as the following but faster:
- // WithinFraction(x, y, fraction) || WithinMargin(x, y, margin)
- // E.g. WithinFraction(0.0, 1e-10, 1e-5) is false but
- // WithinFractionOrMargin(0.0, 1e-10, 1e-5, 1e-5) is true.
- template<typename T>
- static bool WithinFractionOrMargin(const T x, const T y,
- const T fraction, const T margin);
-};
-
-template<typename T>
-bool MathUtil::WithinFractionOrMargin(const T x, const T y,
- const T fraction, const T margin) {
- // Not just "0 <= fraction" to fool the compiler for unsigned types.
- GOOGLE_DCHECK((T(0) < fraction || T(0) == fraction) &&
- fraction < T(1) &&
- margin >= T(0));
-
- // Template specialization will convert the if() condition to a constant,
- // which will cause the compiler to generate code for either the "if" part
- // or the "then" part. In this way we avoid a compiler warning
- // about a potential integer overflow in crosstool v12 (gcc 4.3.1).
- if (std::numeric_limits<T>::is_integer) {
- return x == y;
- } else {
- if (!std::isfinite(x) || !std::isfinite(y)) {
- return false;
- }
- T relative_margin = static_cast<T>(fraction * Max(Abs(x), Abs(y)));
- return AbsDiff(x, y) <= Max(margin, relative_margin);
- }
-}
-
-} // namespace protobuf
-} // namespace google
-
-#endif // GOOGLE_PROTOBUF_STUBS_MATHUTIL_H_
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/mutex.h b/contrib/libs/protobuf/src/google/protobuf/stubs/mutex.h
deleted file mode 100644
index c4599913be2..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/mutex.h
+++ /dev/null
@@ -1,218 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// 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_STUBS_MUTEX_H_
-#define GOOGLE_PROTOBUF_STUBS_MUTEX_H_
-
-#include <mutex>
-
-#ifdef GOOGLE_PROTOBUF_SUPPORT_WINDOWS_XP
-
-#include <windows.h>
-
-// GetMessage conflicts with GeneratedMessageReflection::GetMessage().
-#ifdef GetMessage
-#undef GetMessage
-#endif
-
-#endif
-
-#include <google/protobuf/stubs/macros.h>
-
-// Define thread-safety annotations for use below, if we are building with
-// Clang.
-#if defined(__clang__) && !defined(SWIG)
-#define GOOGLE_PROTOBUF_ACQUIRE(...) \
- __attribute__((acquire_capability(__VA_ARGS__)))
-#define GOOGLE_PROTOBUF_RELEASE(...) \
- __attribute__((release_capability(__VA_ARGS__)))
-#define GOOGLE_PROTOBUF_SCOPED_CAPABILITY __attribute__((scoped_lockable))
-#define GOOGLE_PROTOBUF_CAPABILITY(x) __attribute__((capability(x)))
-#else
-#define GOOGLE_PROTOBUF_ACQUIRE(...)
-#define GOOGLE_PROTOBUF_RELEASE(...)
-#define GOOGLE_PROTOBUF_SCOPED_CAPABILITY
-#define GOOGLE_PROTOBUF_CAPABILITY(x)
-#endif
-
-#include <google/protobuf/port_def.inc>
-
-// ===================================================================
-// emulates google3/base/mutex.h
-namespace google {
-namespace protobuf {
-namespace internal {
-
-#define GOOGLE_PROTOBUF_LINKER_INITIALIZED
-
-#ifdef GOOGLE_PROTOBUF_SUPPORT_WINDOWS_XP
-
-// This class is a lightweight replacement for std::mutex on Windows platforms.
-// std::mutex does not work on Windows XP SP2 with the latest VC++ libraries,
-// because it utilizes the Concurrency Runtime that is only supported on Windows
-// XP SP3 and above.
-class PROTOBUF_EXPORT CriticalSectionLock {
- public:
- CriticalSectionLock() { InitializeCriticalSection(&critical_section_); }
- ~CriticalSectionLock() { DeleteCriticalSection(&critical_section_); }
- void lock() { EnterCriticalSection(&critical_section_); }
- void unlock() { LeaveCriticalSection(&critical_section_); }
-
- private:
- CRITICAL_SECTION critical_section_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CriticalSectionLock);
-};
-
-#endif
-
-// In MSVC std::mutex does not have a constexpr constructor.
-// This wrapper makes the constructor constexpr.
-template <typename T>
-class CallOnceInitializedMutex {
- public:
- constexpr CallOnceInitializedMutex() : flag_{}, buf_{} {}
- ~CallOnceInitializedMutex() { get().~T(); }
-
- void lock() { get().lock(); }
- void unlock() { get().unlock(); }
-
- private:
- T& get() {
- std::call_once(flag_, [&] { ::new (static_cast<void*>(&buf_)) T(); });
- return reinterpret_cast<T&>(buf_);
- }
-
- std::once_flag flag_;
- alignas(T) char buf_[sizeof(T)];
-};
-
-// Mutex is a natural type to wrap. As both google and other organization have
-// specialized mutexes. gRPC also provides an injection mechanism for custom
-// mutexes.
-class GOOGLE_PROTOBUF_CAPABILITY("mutex") PROTOBUF_EXPORT WrappedMutex {
- public:
-#if defined(__QNX__)
- constexpr WrappedMutex() = default;
-#else
- constexpr WrappedMutex() {}
-#endif
- void Lock() GOOGLE_PROTOBUF_ACQUIRE() { mu_.lock(); }
- void Unlock() GOOGLE_PROTOBUF_RELEASE() { mu_.unlock(); }
- // Crash if this Mutex is not held exclusively by this thread.
- // May fail to crash when it should; will never crash when it should not.
- void AssertHeld() const {}
-
- private:
-#if defined(GOOGLE_PROTOBUF_SUPPORT_WINDOWS_XP)
- CallOnceInitializedMutex<CriticalSectionLock> mu_{};
-#elif defined(_WIN32)
- CallOnceInitializedMutex<std::mutex> mu_{};
-#else
- std::mutex mu_{};
-#endif
-};
-
-using Mutex = WrappedMutex;
-
-// MutexLock(mu) acquires mu when constructed and releases it when destroyed.
-class GOOGLE_PROTOBUF_SCOPED_CAPABILITY PROTOBUF_EXPORT MutexLock {
- public:
- explicit MutexLock(Mutex* mu) GOOGLE_PROTOBUF_ACQUIRE(mu) : mu_(mu) {
- this->mu_->Lock();
- }
- ~MutexLock() GOOGLE_PROTOBUF_RELEASE() { this->mu_->Unlock(); }
-
- private:
- Mutex *const mu_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MutexLock);
-};
-
-// TODO(kenton): Implement these? Hard to implement portably.
-typedef MutexLock ReaderMutexLock;
-typedef MutexLock WriterMutexLock;
-
-// MutexLockMaybe is like MutexLock, but is a no-op when mu is nullptr.
-class PROTOBUF_EXPORT MutexLockMaybe {
- public:
- explicit MutexLockMaybe(Mutex *mu) :
- mu_(mu) { if (this->mu_ != nullptr) { this->mu_->Lock(); } }
- ~MutexLockMaybe() { if (this->mu_ != nullptr) { this->mu_->Unlock(); } }
- private:
- Mutex *const mu_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MutexLockMaybe);
-};
-
-#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)
-template<typename T>
-class ThreadLocalStorage {
- public:
- ThreadLocalStorage() {
- pthread_key_create(&key_, &ThreadLocalStorage::Delete);
- }
- ~ThreadLocalStorage() {
- pthread_key_delete(key_);
- }
- T* Get() {
- T* result = static_cast<T*>(pthread_getspecific(key_));
- if (result == nullptr) {
- result = new T();
- pthread_setspecific(key_, result);
- }
- return result;
- }
- private:
- static void Delete(void* value) {
- delete static_cast<T*>(value);
- }
- pthread_key_t key_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ThreadLocalStorage);
-};
-#endif
-
-} // namespace internal
-
-// We made these internal so that they would show up as such in the docs,
-// but we don't want to stick "internal::" in front of them everywhere.
-using internal::Mutex;
-using internal::MutexLock;
-using internal::ReaderMutexLock;
-using internal::WriterMutexLock;
-using internal::MutexLockMaybe;
-
-} // namespace protobuf
-} // namespace google
-
-#undef GOOGLE_PROTOBUF_ACQUIRE
-#undef GOOGLE_PROTOBUF_RELEASE
-
-#include <google/protobuf/port_undef.inc>
-
-#endif // GOOGLE_PROTOBUF_STUBS_MUTEX_H_
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/platform_macros.h b/contrib/libs/protobuf/src/google/protobuf/stubs/platform_macros.h
index 24799600dcf..d10faf9aa24 100644
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/platform_macros.h
+++ b/contrib/libs/protobuf/src/google/protobuf/stubs/platform_macros.h
@@ -122,11 +122,11 @@ GOOGLE_PROTOBUF_PLATFORM_ERROR
#undef GOOGLE_PROTOBUF_PLATFORM_ERROR
-#if defined(GOOGLE_PROTOBUF_OS_ANDROID) || defined(GOOGLE_PROTOBUF_OS_IPHONE) || defined(__OpenBSD__)
+#if defined(GOOGLE_PROTOBUF_OS_ANDROID) || defined(GOOGLE_PROTOBUF_OS_IPHONE)
// Android ndk does not support the __thread keyword very well yet. Here
// we use pthread_key_create()/pthread_getspecific()/... methods for
// TLS support on android.
-// iOS and OpenBSD also do not support the __thread keyword.
+// iOS also does not support the __thread keyword.
#define GOOGLE_PROTOBUF_NO_THREADLOCAL
#endif
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/port.h b/contrib/libs/protobuf/src/google/protobuf/stubs/port.h
index bf1dcd20d95..b85084a8993 100644
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/port.h
+++ b/contrib/libs/protobuf/src/google/protobuf/stubs/port.h
@@ -36,15 +36,17 @@
#include <util/stream/output.h>
#include <util/system/types.h>
#include <assert.h>
-#include <cstdint>
#include <stdlib.h>
+#include <string.h>
+
#include <cstddef>
+#include <cstdint>
#include <string>
-#include <string.h>
-#include <google/protobuf/stubs/platform_macros.h>
+#include "google/protobuf/stubs/platform_macros.h"
-#include <google/protobuf/port_def.inc>
+// Must be last.
+#include "google/protobuf/port_def.inc" // NOLINT
#undef PROTOBUF_LITTLE_ENDIAN
#ifdef _WIN32
@@ -69,11 +71,11 @@
#error #include <sys/isa_defs.h> // __BYTE_ORDER
#elif defined(_AIX) || defined(__TOS_AIX__)
#include <sys/machine.h> // BYTE_ORDER
+#elif defined(__QNX__)
+#include <sys/param.h> // BYTE_ORDER
#else
-#if !defined(__QNX__)
#include <endian.h> // __BYTE_ORDER
#endif
-#endif
#if ((defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || \
(defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN) || \
(defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN)) && \
@@ -132,8 +134,6 @@ using TProtoStringType = TString;
namespace google {
namespace protobuf {
-using ConstStringParam = const TProtoStringType &;
-
typedef unsigned int uint;
typedef int8_t int8;
@@ -153,57 +153,6 @@ static const int64 kint64min = -kint64max - 1;
static const uint32 kuint32max = 0xFFFFFFFFu;
static const uint64 kuint64max = arc_ui64{0xFFFFFFFFFFFFFFFFu};
-#if defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) ||\
- defined(MEMORY_SANITIZER)
-
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-uint16_t __sanitizer_unaligned_load16(const void *p);
-arc_ui32 __sanitizer_unaligned_load32(const void *p);
-arc_ui64 __sanitizer_unaligned_load64(const void *p);
-void __sanitizer_unaligned_store16(void *p, uint16_t v);
-void __sanitizer_unaligned_store32(void *p, arc_ui32 v);
-void __sanitizer_unaligned_store64(void *p, arc_ui64 v);
-#ifdef __cplusplus
-} // extern "C"
-#endif // __cplusplus
-
-inline uint16_t GOOGLE_UNALIGNED_LOAD16(const void *p) {
- return __sanitizer_unaligned_load16(p);
-}
-
-inline arc_ui32 GOOGLE_UNALIGNED_LOAD32(const void *p) {
- return __sanitizer_unaligned_load32(p);
-}
-
-inline arc_ui64 GOOGLE_UNALIGNED_LOAD64(const void *p) {
- return __sanitizer_unaligned_load64(p);
-}
-
-inline void GOOGLE_UNALIGNED_STORE16(void *p, uint16_t v) {
- __sanitizer_unaligned_store16(p, v);
-}
-
-inline void GOOGLE_UNALIGNED_STORE32(void *p, arc_ui32 v) {
- __sanitizer_unaligned_store32(p, v);
-}
-
-inline void GOOGLE_UNALIGNED_STORE64(void *p, arc_ui64 v) {
- __sanitizer_unaligned_store64(p, v);
-}
-
-#elif defined(GOOGLE_PROTOBUF_USE_UNALIGNED) && GOOGLE_PROTOBUF_USE_UNALIGNED
-
-#define GOOGLE_UNALIGNED_LOAD16(_p) (*reinterpret_cast<const uint16_t *>(_p))
-#define GOOGLE_UNALIGNED_LOAD32(_p) (*reinterpret_cast<const arc_ui32 *>(_p))
-#define GOOGLE_UNALIGNED_LOAD64(_p) (*reinterpret_cast<const arc_ui64 *>(_p))
-
-#define GOOGLE_UNALIGNED_STORE16(_p, _val) (*reinterpret_cast<uint16_t *>(_p) = (_val))
-#define GOOGLE_UNALIGNED_STORE32(_p, _val) (*reinterpret_cast<arc_ui32 *>(_p) = (_val))
-#define GOOGLE_UNALIGNED_STORE64(_p, _val) (*reinterpret_cast<arc_ui64 *>(_p) = (_val))
-
-#else
inline uint16_t GOOGLE_UNALIGNED_LOAD16(const void *p) {
uint16_t t;
memcpy(&t, p, sizeof t);
@@ -233,7 +182,6 @@ inline void GOOGLE_UNALIGNED_STORE32(void *p, arc_ui32 v) {
inline void GOOGLE_UNALIGNED_STORE64(void *p, arc_ui64 v) {
memcpy(p, &v, sizeof v);
}
-#endif
#if defined(GOOGLE_PROTOBUF_OS_NACL) \
|| (defined(__ANDROID__) && defined(__clang__) \
@@ -289,69 +237,6 @@ static inline arc_ui64 bswap_64(arc_ui64 x) {
#endif
// ===================================================================
-// from google3/util/bits/bits.h
-
-class Bits {
- public:
- static arc_ui32 Log2FloorNonZero(arc_ui32 n) {
-#if defined(__GNUC__)
- return 31 ^ static_cast<arc_ui32>(__builtin_clz(n));
-#elif defined(_MSC_VER)
- unsigned long where;
- _BitScanReverse(&where, n);
- return where;
-#else
- return Log2FloorNonZero_Portable(n);
-#endif
- }
-
- static arc_ui32 Log2FloorNonZero64(arc_ui64 n) {
- // Older versions of clang run into an instruction-selection failure when
- // it encounters __builtin_clzll:
- // https://bugs.chromium.org/p/nativeclient/issues/detail?id=4395
- // This includes arm-nacl-clang and clang in older Android NDK versions.
- // To work around this, when we build with those we use the portable
- // implementation instead.
-#if defined(__GNUC__) && !defined(GOOGLE_PROTOBUF_USE_PORTABLE_LOG2)
- return 63 ^ static_cast<arc_ui32>(__builtin_clzll(n));
-#elif defined(_MSC_VER) && defined(_M_X64)
- unsigned long where;
- _BitScanReverse64(&where, n);
- return where;
-#else
- return Log2FloorNonZero64_Portable(n);
-#endif
- }
- private:
- static int Log2FloorNonZero_Portable(arc_ui32 n) {
- if (n == 0)
- return -1;
- int log = 0;
- arc_ui32 value = n;
- for (int i = 4; i >= 0; --i) {
- int shift = (1 << i);
- arc_ui32 x = value >> shift;
- if (x != 0) {
- value = x;
- log += shift;
- }
- }
- assert(value == 1);
- return log;
- }
-
- static int Log2FloorNonZero64_Portable(arc_ui64 n) {
- const arc_ui32 topbits = static_cast<arc_ui32>(n >> 32);
- if (topbits == 0) {
- // Top bits are zero, so scan in bottom bits
- return static_cast<int>(Log2FloorNonZero(static_cast<arc_ui32>(n)));
- } else {
- return 32 + static_cast<int>(Log2FloorNonZero(topbits));
- }
- }
-};
-
-// ===================================================================
// from google3/util/endian/endian.h
PROTOBUF_EXPORT arc_ui32 ghtonl(arc_ui32 x);
@@ -414,6 +299,6 @@ class BigEndian {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_STUBS_PORT_H_
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/status_macros.h b/contrib/libs/protobuf/src/google/protobuf/stubs/status_macros.h
index 407ff4c280e..c07e0ba2911 100644
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/status_macros.h
+++ b/contrib/libs/protobuf/src/google/protobuf/stubs/status_macros.h
@@ -33,9 +33,12 @@
#ifndef GOOGLE_PROTOBUF_STUBS_STATUS_MACROS_H_
#define GOOGLE_PROTOBUF_STUBS_STATUS_MACROS_H_
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/status.h>
-#include <google/protobuf/stubs/statusor.h>
+#include "y_absl/status/status.h"
+#include "y_absl/status/statusor.h"
+#include "google/protobuf/stubs/common.h"
+
+// Needs to be last.
+#include "google/protobuf/port_def.inc" // NOLINT
namespace google {
namespace protobuf {
@@ -49,7 +52,7 @@ namespace util {
#define RETURN_IF_ERROR(expr) \
do { \
/* Using _status below to avoid capture problems if expr is "status". */ \
- const PROTOBUF_NAMESPACE_ID::util::Status _status = (expr); \
+ const y_absl::Status _status = (expr); \
if (PROTOBUF_PREDICT_FALSE(!_status.ok())) return _status; \
} while (0)
@@ -57,16 +60,16 @@ namespace util {
#define STATUS_MACROS_CONCAT_NAME_INNER(x, y) x##y
#define STATUS_MACROS_CONCAT_NAME(x, y) STATUS_MACROS_CONCAT_NAME_INNER(x, y)
-template<typename T>
-Status DoAssignOrReturn(T& lhs, StatusOr<T> result) {
+template <typename T>
+y_absl::Status DoAssignOrReturn(T& lhs, y_absl::StatusOr<T> result) {
if (result.ok()) {
lhs = result.value();
}
return result.status();
}
-#define ASSIGN_OR_RETURN_IMPL(status, lhs, rexpr) \
- Status status = DoAssignOrReturn(lhs, (rexpr)); \
+#define ASSIGN_OR_RETURN_IMPL(status, lhs, rexpr) \
+ y_absl::Status status = DoAssignOrReturn(lhs, (rexpr)); \
if (PROTOBUF_PREDICT_FALSE(!status.ok())) return status;
// Executes an expression that returns a util::StatusOr, extracting its value
@@ -79,11 +82,13 @@ Status DoAssignOrReturn(T& lhs, StatusOr<T> result) {
// WARNING: ASSIGN_OR_RETURN expands into multiple statements; it cannot be used
// in a single statement (e.g. as the body of an if statement without {})!
#define ASSIGN_OR_RETURN(lhs, rexpr) \
- ASSIGN_OR_RETURN_IMPL( \
+ ASSIGN_OR_RETURN_IMPL( \
STATUS_MACROS_CONCAT_NAME(_status_or_value, __COUNTER__), lhs, rexpr);
} // namespace util
} // namespace protobuf
} // namespace google
+#include "google/protobuf/port_undef.inc" // NOLINT
+
#endif // GOOGLE_PROTOBUF_STUBS_STATUS_H_
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/statusor.h b/contrib/libs/protobuf/src/google/protobuf/stubs/statusor.h
deleted file mode 100644
index 20e603ea049..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/statusor.h
+++ /dev/null
@@ -1,253 +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.
-
-// StatusOr<T> is the union of a Status object and a T
-// object. StatusOr models the concept of an object that is either a
-// usable value, or an error Status explaining why such a value is
-// not present. To this end, StatusOr<T> does not allow its Status
-// value to be OkStatus(). Further, StatusOr<T*> does not allow the
-// contained pointer to be nullptr.
-//
-// The primary use-case for StatusOr<T> is as the return value of a
-// function which may fail.
-//
-// Example client usage for a StatusOr<T>, where T is not a pointer:
-//
-// StatusOr<float> result = DoBigCalculationThatCouldFail();
-// if (result.ok()) {
-// float answer = result.value();
-// printf("Big calculation yielded: %f", answer);
-// } else {
-// LOG(ERROR) << result.status();
-// }
-//
-// Example client usage for a StatusOr<T*>:
-//
-// StatusOr<Foo*> result = FooFactory::MakeNewFoo(arg);
-// if (result.ok()) {
-// std::unique_ptr<Foo> foo(result.value());
-// foo->DoSomethingCool();
-// } else {
-// LOG(ERROR) << result.status();
-// }
-//
-// Example factory implementation returning StatusOr<T*>:
-//
-// StatusOr<Foo*> FooFactory::MakeNewFoo(int arg) {
-// if (arg <= 0) {
-// return InvalidArgumentError("Arg must be positive");
-// } else {
-// return new Foo(arg);
-// }
-// }
-//
-
-#ifndef GOOGLE_PROTOBUF_STUBS_STATUSOR_H_
-#define GOOGLE_PROTOBUF_STUBS_STATUSOR_H_
-
-#include <new>
-#include <string>
-#include <utility>
-
-#include <google/protobuf/stubs/status.h>
-
-#include <google/protobuf/port_def.inc>
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace statusor_internal {
-
-template<typename T>
-class StatusOr {
- template<typename U> friend class StatusOr;
-
- public:
- using value_type = T;
-
- // Construct a new StatusOr with Status::UNKNOWN status.
- // Construct a new StatusOr with UnknownError() status.
- explicit StatusOr();
-
- // Construct a new StatusOr with the given non-ok status. After calling
- // this constructor, calls to value() will CHECK-fail.
- //
- // NOTE: Not explicit - we want to use StatusOr<T> as a return
- // value, so it is convenient and sensible to be able to do 'return
- // Status()' when the return type is StatusOr<T>.
- //
- // REQUIRES: status != OkStatus(). This requirement is DCHECKed.
- // In optimized builds, passing OkStatus() here will have the effect
- // of passing PosixErrorSpace::EINVAL as a fallback.
- StatusOr(const Status& status); // NOLINT
-
- // Construct a new StatusOr with the given value. If T is a plain pointer,
- // value must not be nullptr. After calling this constructor, calls to
- // value() will succeed, and calls to status() will return OK.
- //
- // NOTE: Not explicit - we want to use StatusOr<T> as a return type
- // so it is convenient and sensible to be able to do 'return T()'
- // when when the return type is StatusOr<T>.
- //
- // REQUIRES: if T is a plain pointer, value != nullptr. This requirement is
- // DCHECKed. In optimized builds, passing a null pointer here will have
- // the effect of passing PosixErrorSpace::EINVAL as a fallback.
- StatusOr(const T& value); // NOLINT
-
- // Copy constructor.
- StatusOr(const StatusOr& other);
-
- // Conversion copy constructor, T must be copy constructible from U
- template<typename U>
- StatusOr(const StatusOr<U>& other);
-
- // Assignment operator.
- StatusOr& operator=(const StatusOr& other);
-
- // Conversion assignment operator, T must be assignable from U
- template<typename U>
- StatusOr& operator=(const StatusOr<U>& other);
-
- // Returns a reference to our status. If this contains a T, then
- // returns OkStatus().
- const Status& status() const;
-
- // Returns this->status().ok()
- bool ok() const;
-
- // Returns a reference to our current value, or CHECK-fails if !this->ok().
- const T& value () const;
-
- private:
- Status status_;
- T value_;
-};
-
-////////////////////////////////////////////////////////////////////////////////
-// Implementation details for StatusOr<T>
-
-class PROTOBUF_EXPORT StatusOrHelper {
- public:
- // Move type-agnostic error handling to the .cc.
- static void Crash(const util::Status& status);
-
- // Customized behavior for StatusOr<T> vs. StatusOr<T*>
- template<typename T>
- struct Specialize;
-};
-
-template<typename T>
-struct StatusOrHelper::Specialize {
- // For non-pointer T, a reference can never be nullptr.
- static inline bool IsValueNull(const T& /*t*/) { return false; }
-};
-
-template<typename T>
-struct StatusOrHelper::Specialize<T*> {
- static inline bool IsValueNull(const T* t) { return t == nullptr; }
-};
-
-template <typename T>
-inline StatusOr<T>::StatusOr() : status_(util::UnknownError("")) {}
-
-template<typename T>
-inline StatusOr<T>::StatusOr(const Status& status) {
- if (status.ok()) {
- status_ = util::InternalError("OkStatus() is not a valid argument.");
- } else {
- status_ = status;
- }
-}
-
-template<typename T>
-inline StatusOr<T>::StatusOr(const T& value) {
- if (StatusOrHelper::Specialize<T>::IsValueNull(value)) {
- status_ = util::InternalError("nullptr is not a valid argument.");
- } else {
- status_ = util::OkStatus();
- value_ = value;
- }
-}
-
-template<typename T>
-inline StatusOr<T>::StatusOr(const StatusOr<T>& other)
- : status_(other.status_), value_(other.value_) {
-}
-
-template<typename T>
-inline StatusOr<T>& StatusOr<T>::operator=(const StatusOr<T>& other) {
- status_ = other.status_;
- value_ = other.value_;
- return *this;
-}
-
-template<typename T>
-template<typename U>
-inline StatusOr<T>::StatusOr(const StatusOr<U>& other)
- : status_(other.status_), value_(other.status_.ok() ? other.value_ : T()) {
-}
-
-template<typename T>
-template<typename U>
-inline StatusOr<T>& StatusOr<T>::operator=(const StatusOr<U>& other) {
- status_ = other.status_;
- if (status_.ok()) value_ = other.value_;
- return *this;
-}
-
-template<typename T>
-inline const Status& StatusOr<T>::status() const {
- return status_;
-}
-
-template<typename T>
-inline bool StatusOr<T>::ok() const {
- return status().ok();
-}
-
-template<typename T>
-inline const T& StatusOr<T>::value() const {
- if (!status_.ok()) {
- StatusOrHelper::Crash(status_);
- }
- return value_;
-}
-
-} // namespace statusor_internal
-
-using ::google::protobuf::util::statusor_internal::StatusOr;
-
-} // namespace util
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#endif // GOOGLE_PROTOBUF_STUBS_STATUSOR_H_
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 94bc9c65fd7..64c4a86d9eb 100644
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/stl_util.h
+++ b/contrib/libs/protobuf/src/google/protobuf/stubs/stl_util.h
@@ -37,9 +37,6 @@
#include <algorithm>
-// Must be last.
-#include <google/protobuf/port_def.inc> // NOLINT
-
namespace google {
namespace protobuf {
@@ -50,7 +47,7 @@ namespace protobuf {
// place in open source code. Feel free to fill this function in with your
// own disgusting hack if you want the perf boost.
inline void STLStringResizeUninitialized(TProtoStringType* s, size_t new_size) {
- s->ReserveAndResize(new_size);
+ s->resize(new_size);
}
// As above, but we make sure to follow amortized growth in which we always
@@ -60,7 +57,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<size_t>(new_size, 2 * cap));
+ s->reserve(std::max(new_size, 2 * cap));
}
STLStringResizeUninitialized(s, new_size);
}
@@ -77,6 +74,11 @@ inline void STLStringResizeUninitializedAmortized(TProtoStringType* s,
// (http://www.open-std.org/JTC1/SC22/WG21/docs/lwg-active.html#530)
// proposes this as the method. According to Matt Austern, this should
// already work on all current implementations.
+inline char* string_as_array(std::string* str) {
+ // DO NOT USE const_cast<char*>(str->data())! See the unittest for why.
+ return str->empty() ? nullptr : &*str->begin();
+}
+
inline char* string_as_array(TProtoStringType* str) {
// DO NOT USE const_cast<char*>(str->data())! See the unittest for why.
return str->empty() ? nullptr : &*str->begin();
@@ -85,6 +87,4 @@ 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/stringpiece.cc b/contrib/libs/protobuf/src/google/protobuf/stubs/stringpiece.cc
index 52416cee61c..b2b1690e44f 100644
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/stringpiece.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/stubs/stringpiece.cc
@@ -35,7 +35,7 @@
#include <string>
#include <ostream>
-#include <google/protobuf/stubs/logging.h>
+#include <y_absl/log/absl_log.h>
namespace google {
namespace protobuf {
@@ -47,7 +47,7 @@ std::ostream& operator<<(std::ostream& o, StringPiece piece) {
}
void StringPiece::LogFatalSizeTooBig(size_t size, const char* details) {
- GOOGLE_LOG(FATAL) << "size too big: " << size << " details: " << details;
+ Y_ABSL_LOG(FATAL) << "size too big: " << size << " details: " << details;
}
void StringPiece::CopyToString(TProtoStringType* target) const {
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/stringprintf.cc b/contrib/libs/protobuf/src/google/protobuf/stubs/stringprintf.cc
deleted file mode 100644
index 413578c918d..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/stringprintf.cc
+++ /dev/null
@@ -1,175 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2012 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.
-
-// from google3/base/stringprintf.cc
-
-#include <google/protobuf/stubs/stringprintf.h>
-
-#include <errno.h>
-#include <stdarg.h> // For va_list and related operations
-#include <stdio.h> // MSVC requires this for _vsnprintf
-#include <vector>
-
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/logging.h>
-
-namespace google {
-namespace protobuf {
-
-#ifdef _MSC_VER
-#ifndef va_copy
-// Define va_copy for MSVC. This is a hack, assuming va_list is simply a
-// pointer into the stack and is safe to copy.
-#define va_copy(dest, src) ((dest) = (src))
-#endif
-#endif
-
-void StringAppendV(TProtoStringType* dst, const char* format, va_list ap) {
- // First try with a small fixed size buffer
- static const int kSpaceLength = 1024;
- char space[kSpaceLength];
-
- // It's possible for methods that use a va_list to invalidate
- // the data in it upon use. The fix is to make a copy
- // of the structure before using it and use that copy instead.
- va_list backup_ap;
- va_copy(backup_ap, ap);
- int result = vsnprintf(space, kSpaceLength, format, backup_ap);
- va_end(backup_ap);
-
- if (result < kSpaceLength) {
- if (result >= 0) {
- // Normal case -- everything fit.
- dst->append(space, result);
- return;
- }
-
-#ifdef _MSC_VER
- {
- // Error or MSVC running out of space. MSVC 8.0 and higher
- // can be asked about space needed with the special idiom below:
- va_copy(backup_ap, ap);
- result = vsnprintf(nullptr, 0, format, backup_ap);
- va_end(backup_ap);
- }
-#endif
-
- if (result < 0) {
- // Just an error.
- return;
- }
- }
-
- // Increase the buffer size to the size requested by vsnprintf,
- // plus one for the closing \0.
- int length = result+1;
- char* buf = new char[length];
-
- // Restore the va_list before we use it again
- va_copy(backup_ap, ap);
- result = vsnprintf(buf, length, format, backup_ap);
- va_end(backup_ap);
-
- if (result >= 0 && result < length) {
- // It fit
- dst->append(buf, result);
- }
- delete[] buf;
-}
-
-TProtoStringType StringPrintf(const char* format, ...) {
- va_list ap;
- va_start(ap, format);
- TProtoStringType result;
- StringAppendV(&result, format, ap);
- va_end(ap);
- return result;
-}
-
-const TProtoStringType& SStringPrintf(TProtoStringType* dst, const char* format, ...) {
- va_list ap;
- va_start(ap, format);
- dst->clear();
- StringAppendV(dst, format, ap);
- va_end(ap);
- return *dst;
-}
-
-void StringAppendF(TProtoStringType* dst, const char* format, ...) {
- va_list ap;
- va_start(ap, format);
- StringAppendV(dst, format, ap);
- va_end(ap);
-}
-
-// Max arguments supported by StringPrintVector
-const int kStringPrintfVectorMaxArgs = 32;
-
-// An empty block of zero for filler arguments. This is const so that if
-// printf tries to write to it (via %n) then the program gets a SIGSEGV
-// and we can fix the problem or protect against an attack.
-static const char string_printf_empty_block[256] = { '\0' };
-
-TProtoStringType StringPrintfVector(const char* format,
- const std::vector<TProtoStringType>& v) {
- GOOGLE_CHECK_LE(v.size(), kStringPrintfVectorMaxArgs)
- << "StringPrintfVector currently only supports up to "
- << kStringPrintfVectorMaxArgs << " arguments. "
- << "Feel free to add support for more if you need it.";
-
- // Add filler arguments so that bogus format+args have a harder time
- // crashing the program, corrupting the program (%n),
- // or displaying random chunks of memory to users.
-
- const char* cstr[kStringPrintfVectorMaxArgs];
- for (int i = 0; i < v.size(); ++i) {
- cstr[i] = v[i].c_str();
- }
- for (int i = v.size(); i < GOOGLE_ARRAYSIZE(cstr); ++i) {
- cstr[i] = &string_printf_empty_block[0];
- }
-
- // I do not know any way to pass kStringPrintfVectorMaxArgs arguments,
- // or any way to build a va_list by hand, or any API for printf
- // that accepts an array of arguments. The best I can do is stick
- // this COMPILE_ASSERT right next to the actual statement.
-
- static_assert(kStringPrintfVectorMaxArgs == 32, "arg_count_mismatch");
- return StringPrintf(format,
- cstr[0], cstr[1], cstr[2], cstr[3], cstr[4],
- cstr[5], cstr[6], cstr[7], cstr[8], cstr[9],
- cstr[10], cstr[11], cstr[12], cstr[13], cstr[14],
- cstr[15], cstr[16], cstr[17], cstr[18], cstr[19],
- cstr[20], cstr[21], cstr[22], cstr[23], cstr[24],
- cstr[25], cstr[26], cstr[27], cstr[28], cstr[29],
- cstr[30], cstr[31]);
-}
-} // namespace protobuf
-} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/stringprintf.h b/contrib/libs/protobuf/src/google/protobuf/stubs/stringprintf.h
deleted file mode 100644
index b8f457f5ad7..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/stringprintf.h
+++ /dev/null
@@ -1,85 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2012 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.
-
-// from google3/base/stringprintf.h
-//
-// Printf variants that place their output in a C++ string.
-//
-// Usage:
-// string result = StringPrintf("%d %s\n", 10, "hello");
-// SStringPrintf(&result, "%d %s\n", 10, "hello");
-// StringAppendF(&result, "%d %s\n", 20, "there");
-
-#ifndef GOOGLE_PROTOBUF_STUBS_STRINGPRINTF_H
-#define GOOGLE_PROTOBUF_STUBS_STRINGPRINTF_H
-
-#include <stdarg.h>
-#include <string>
-#include <vector>
-
-#include <google/protobuf/stubs/common.h>
-
-#include <google/protobuf/port_def.inc>
-
-namespace google {
-namespace protobuf {
-
-// Return a C++ string
-PROTOBUF_EXPORT extern TProtoStringType StringPrintf(const char* format, ...);
-
-// Store result into a supplied string and return it
-PROTOBUF_EXPORT extern const TProtoStringType& SStringPrintf(TProtoStringType* dst,
- const char* format,
- ...);
-
-// Append result to a supplied string
-PROTOBUF_EXPORT extern void StringAppendF(TProtoStringType* dst, const char* format,
- ...);
-
-// Lower-level routine that takes a va_list and appends to a specified
-// string. All other routines are just convenience wrappers around it.
-PROTOBUF_EXPORT extern void StringAppendV(TProtoStringType* dst, const char* format,
- va_list ap);
-
-// The max arguments supported by StringPrintfVector
-PROTOBUF_EXPORT extern const int kStringPrintfVectorMaxArgs;
-
-// You can use this version when all your arguments are strings, but
-// you don't know how many arguments you'll have at compile time.
-// StringPrintfVector will LOG(FATAL) if v.size() > kStringPrintfVectorMaxArgs
-PROTOBUF_EXPORT extern TProtoStringType StringPrintfVector(
- const char* format, const std::vector<TProtoStringType>& v);
-
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#endif // GOOGLE_PROTOBUF_STUBS_STRINGPRINTF_H
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/strutil.cc b/contrib/libs/protobuf/src/google/protobuf/stubs/strutil.cc
index fe35e97c4a8..0c314585cc9 100644
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/strutil.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/stubs/strutil.cc
@@ -40,7 +40,8 @@
#include <iterator>
#include <limits>
-#include <google/protobuf/stubs/logging.h>
+#include <y_absl/log/absl_log.h>
+#include <y_absl/log/absl_check.h>
#include <google/protobuf/stubs/stl_util.h>
#ifdef _WIN32
@@ -261,7 +262,7 @@ void SplitStringAllowEmpty(StringPiece full, const char *delim,
template <class ITERATOR>
static void JoinStringsIterator(const ITERATOR &start, const ITERATOR &end,
const char *delim, TProtoStringType *result) {
- GOOGLE_CHECK(result != nullptr);
+ Y_ABSL_CHECK(result != nullptr);
result->clear();
int delim_length = strlen(delim);
@@ -305,7 +306,7 @@ void JoinStrings(const std::vector<TProtoStringType> &components, const char *de
// Protocol buffers doesn't ever care about errors, but I don't want to remove
// the code.
-#define LOG_STRING(LEVEL, VECTOR) GOOGLE_LOG_IF(LEVEL, false)
+#define LOG_STRING(LEVEL, VECTOR) Y_ABSL_LOG_IF(LEVEL, false)
int UnescapeCEscapeSequences(const char* source, char* dest) {
return UnescapeCEscapeSequences(source, dest, nullptr);
@@ -313,7 +314,7 @@ int UnescapeCEscapeSequences(const char* source, char* dest) {
int UnescapeCEscapeSequences(const char *source, char *dest,
std::vector<TProtoStringType> *errors) {
- GOOGLE_DCHECK(errors == nullptr) << "Error reporting not implemented.";
+ Y_ABSL_DCHECK(errors == nullptr) << "Error reporting not implemented.";
char* d = dest;
const char* p = source;
@@ -453,7 +454,7 @@ int UnescapeCEscapeString(const TProtoStringType &src, TProtoStringType *dest,
std::vector<TProtoStringType> *errors) {
std::unique_ptr<char[]> unescaped(new char[src.size() + 1]);
int len = UnescapeCEscapeSequences(src.c_str(), unescaped.get(), errors);
- GOOGLE_CHECK(dest);
+ Y_ABSL_CHECK(dest);
dest->assign(unescaped.get(), len);
return len;
}
@@ -605,7 +606,7 @@ TProtoStringType Utf8SafeCEscape(const TProtoStringType &src) {
std::unique_ptr<char[]> dest(new char[dest_length]);
const int len = CEscapeInternal(src.data(), src.size(),
dest.get(), dest_length, false, true);
- GOOGLE_DCHECK_GE(len, 0);
+ Y_ABSL_DCHECK_GE(len, 0);
return TProtoStringType(dest.get(), len);
}
@@ -614,7 +615,7 @@ TProtoStringType CHexEscape(const TProtoStringType &src) {
std::unique_ptr<char[]> dest(new char[dest_length]);
const int len = CEscapeInternal(src.data(), src.size(),
dest.get(), dest_length, true, false);
- GOOGLE_DCHECK_GE(len, 0);
+ Y_ABSL_DCHECK_GE(len, 0);
return TProtoStringType(dest.get(), len);
}
@@ -884,7 +885,7 @@ char *FastInt32ToBuffer(arc_i32 i, char* buffer) {
}
char *FastHexToBuffer(int i, char* buffer) {
- GOOGLE_CHECK(i >= 0) << "FastHexToBuffer() wants non-negative integers, not " << i;
+ Y_ABSL_CHECK(i >= 0) << "FastHexToBuffer() wants non-negative integers, not " << i;
static const char *hexdigits = "0123456789abcdef";
char *p = buffer + 21;
@@ -1065,7 +1066,7 @@ char* FastUInt64ToBufferLeft(arc_ui64 u64, char* buffer) {
u = u64 - (top_11_digits * 1000000000);
digits = u / 10000000; // 10,000,000
- GOOGLE_DCHECK_LT(digits, 100);
+ Y_ABSL_DCHECK_LT(digits, 100);
ASCII_digits = two_ASCII_digits[digits];
buffer[0] = ASCII_digits[0];
buffer[1] = ASCII_digits[1];
@@ -1262,7 +1263,7 @@ char* DoubleToBuffer(double value, char* buffer) {
// The snprintf should never overflow because the buffer is significantly
// larger than the precision we asked for.
- GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kDoubleToBufferSize);
+ Y_ABSL_DCHECK(snprintf_result > 0 && snprintf_result < kDoubleToBufferSize);
// We need to make parsed_value volatile in order to force the compiler to
// write it out to the stack. Otherwise, it may keep the value in a
@@ -1276,7 +1277,7 @@ char* DoubleToBuffer(double value, char* buffer) {
snprintf(buffer, kDoubleToBufferSize, "%.*g", DBL_DIG + 2, value);
// Should never overflow; see above.
- GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kDoubleToBufferSize);
+ Y_ABSL_DCHECK(snprintf_result > 0 && snprintf_result < kDoubleToBufferSize);
}
DelocalizeRadix(buffer);
@@ -1302,7 +1303,7 @@ inline bool CaseEqual(StringPiece s1, StringPiece s2) {
}
bool safe_strtob(StringPiece str, bool* value) {
- GOOGLE_CHECK(value != nullptr) << "nullptr output boolean given.";
+ Y_ABSL_CHECK(value != nullptr) << "nullptr output boolean given.";
if (CaseEqual(str, "true") || CaseEqual(str, "t") ||
CaseEqual(str, "yes") || CaseEqual(str, "y") ||
CaseEqual(str, "1")) {
@@ -1380,7 +1381,7 @@ char* FloatToBuffer(float value, char* buffer) {
// The snprintf should never overflow because the buffer is significantly
// larger than the precision we asked for.
- GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize);
+ Y_ABSL_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize);
float parsed_value;
if (!safe_strtof(buffer, &parsed_value) || parsed_value != value) {
@@ -1388,7 +1389,7 @@ char* FloatToBuffer(float value, char* buffer) {
snprintf(buffer, kFloatToBufferSize, "%.*g", FLT_DIG + 3, value);
// Should never overflow; see above.
- GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize);
+ Y_ABSL_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize);
}
DelocalizeRadix(buffer);
@@ -1474,7 +1475,7 @@ TProtoStringType StrCat(const AlphaNum &a, const AlphaNum &b) {
result.resize(a.size() + b.size());
char *const begin = &*result.begin();
char *out = Append2(begin, a, b);
- GOOGLE_DCHECK_EQ(out, begin + result.size());
+ Y_ABSL_DCHECK_EQ(out, begin + result.size());
return result;
}
@@ -1484,7 +1485,7 @@ TProtoStringType StrCat(const AlphaNum &a, const AlphaNum &b, const AlphaNum &c)
char *const begin = &*result.begin();
char *out = Append2(begin, a, b);
out = Append1(out, c);
- GOOGLE_DCHECK_EQ(out, begin + result.size());
+ Y_ABSL_DCHECK_EQ(out, begin + result.size());
return result;
}
@@ -1494,7 +1495,7 @@ TProtoStringType StrCat(const AlphaNum &a, const AlphaNum &b, const AlphaNum &c,
result.resize(a.size() + b.size() + c.size() + d.size());
char *const begin = &*result.begin();
char *out = Append4(begin, a, b, c, d);
- GOOGLE_DCHECK_EQ(out, begin + result.size());
+ Y_ABSL_DCHECK_EQ(out, begin + result.size());
return result;
}
@@ -1505,7 +1506,7 @@ TProtoStringType StrCat(const AlphaNum &a, const AlphaNum &b, const AlphaNum &c,
char *const begin = &*result.begin();
char *out = Append4(begin, a, b, c, d);
out = Append1(out, e);
- GOOGLE_DCHECK_EQ(out, begin + result.size());
+ Y_ABSL_DCHECK_EQ(out, begin + result.size());
return result;
}
@@ -1517,7 +1518,7 @@ TProtoStringType StrCat(const AlphaNum &a, const AlphaNum &b, const AlphaNum &c,
char *const begin = &*result.begin();
char *out = Append4(begin, a, b, c, d);
out = Append2(out, e, f);
- GOOGLE_DCHECK_EQ(out, begin + result.size());
+ Y_ABSL_DCHECK_EQ(out, begin + result.size());
return result;
}
@@ -1531,7 +1532,7 @@ TProtoStringType StrCat(const AlphaNum &a, const AlphaNum &b, const AlphaNum &c,
char *out = Append4(begin, a, b, c, d);
out = Append2(out, e, f);
out = Append1(out, g);
- GOOGLE_DCHECK_EQ(out, begin + result.size());
+ Y_ABSL_DCHECK_EQ(out, begin + result.size());
return result;
}
@@ -1544,7 +1545,7 @@ TProtoStringType StrCat(const AlphaNum &a, const AlphaNum &b, const AlphaNum &c,
char *const begin = &*result.begin();
char *out = Append4(begin, a, b, c, d);
out = Append4(out, e, f, g, h);
- GOOGLE_DCHECK_EQ(out, begin + result.size());
+ Y_ABSL_DCHECK_EQ(out, begin + result.size());
return result;
}
@@ -1558,7 +1559,7 @@ TProtoStringType StrCat(const AlphaNum &a, const AlphaNum &b, const AlphaNum &c,
char *out = Append4(begin, a, b, c, d);
out = Append4(out, e, f, g, h);
out = Append1(out, i);
- GOOGLE_DCHECK_EQ(out, begin + result.size());
+ Y_ABSL_DCHECK_EQ(out, begin + result.size());
return result;
}
@@ -1566,54 +1567,54 @@ TProtoStringType StrCat(const AlphaNum &a, const AlphaNum &b, const AlphaNum &c,
// the string we're appending to. However the results of this are random.
// Therefore, check for this in debug mode. Use unsigned math so we only have
// to do one comparison.
-#define GOOGLE_DCHECK_NO_OVERLAP(dest, src) \
- GOOGLE_DCHECK_GT(uintptr_t((src).data() - (dest).data()), \
+#define Y_ABSL_DCHECK_NO_OVERLAP(dest, src) \
+ Y_ABSL_DCHECK_GT(uintptr_t((src).data() - (dest).data()), \
uintptr_t((dest).size()))
void StrAppend(TProtoStringType *result, const AlphaNum &a) {
- GOOGLE_DCHECK_NO_OVERLAP(*result, a);
+ Y_ABSL_DCHECK_NO_OVERLAP(*result, a);
result->append(a.data(), a.size());
}
void StrAppend(TProtoStringType *result, const AlphaNum &a, const AlphaNum &b) {
- GOOGLE_DCHECK_NO_OVERLAP(*result, a);
- GOOGLE_DCHECK_NO_OVERLAP(*result, b);
+ Y_ABSL_DCHECK_NO_OVERLAP(*result, a);
+ Y_ABSL_DCHECK_NO_OVERLAP(*result, b);
TProtoStringType::size_type old_size = result->size();
result->resize(old_size + a.size() + b.size());
char *const begin = &*result->begin();
char *out = Append2(begin + old_size, a, b);
- GOOGLE_DCHECK_EQ(out, begin + result->size());
+ Y_ABSL_DCHECK_EQ(out, begin + result->size());
}
void StrAppend(TProtoStringType *result, const AlphaNum &a, const AlphaNum &b,
const AlphaNum &c) {
- GOOGLE_DCHECK_NO_OVERLAP(*result, a);
- GOOGLE_DCHECK_NO_OVERLAP(*result, b);
- GOOGLE_DCHECK_NO_OVERLAP(*result, c);
+ Y_ABSL_DCHECK_NO_OVERLAP(*result, a);
+ Y_ABSL_DCHECK_NO_OVERLAP(*result, b);
+ Y_ABSL_DCHECK_NO_OVERLAP(*result, c);
TProtoStringType::size_type old_size = result->size();
result->resize(old_size + a.size() + b.size() + c.size());
char *const begin = &*result->begin();
char *out = Append2(begin + old_size, a, b);
out = Append1(out, c);
- GOOGLE_DCHECK_EQ(out, begin + result->size());
+ Y_ABSL_DCHECK_EQ(out, begin + result->size());
}
void StrAppend(TProtoStringType *result, const AlphaNum &a, const AlphaNum &b,
const AlphaNum &c, const AlphaNum &d) {
- GOOGLE_DCHECK_NO_OVERLAP(*result, a);
- GOOGLE_DCHECK_NO_OVERLAP(*result, b);
- GOOGLE_DCHECK_NO_OVERLAP(*result, c);
- GOOGLE_DCHECK_NO_OVERLAP(*result, d);
+ Y_ABSL_DCHECK_NO_OVERLAP(*result, a);
+ Y_ABSL_DCHECK_NO_OVERLAP(*result, b);
+ Y_ABSL_DCHECK_NO_OVERLAP(*result, c);
+ Y_ABSL_DCHECK_NO_OVERLAP(*result, d);
TProtoStringType::size_type old_size = result->size();
result->resize(old_size + a.size() + b.size() + c.size() + d.size());
char *const begin = &*result->begin();
char *out = Append4(begin + old_size, a, b, c, d);
- GOOGLE_DCHECK_EQ(out, begin + result->size());
+ Y_ABSL_DCHECK_EQ(out, begin + result->size());
}
int GlobalReplaceSubstring(const TProtoStringType &substring,
const TProtoStringType &replacement, TProtoStringType *s) {
- GOOGLE_CHECK(s != nullptr);
+ Y_ABSL_CHECK(s != nullptr);
if (s->empty() || substring.empty())
return 0;
TProtoStringType tmp;
@@ -1929,7 +1930,7 @@ int Base64UnescapeInternal(const char *src_param, int szsrc,
default:
// state should have no other values at this point.
- GOOGLE_LOG(FATAL) << "This can't happen; base64 decoder state = " << state;
+ Y_ABSL_LOG(FATAL) << "This can't happen; base64 decoder state = " << state;
}
// The remainder of the string should be all whitespace, mixed with
@@ -2072,7 +2073,7 @@ static bool Base64UnescapeInternal(const char *src, int slen, TProtoStringType *
}
// could be shorter if there was padding
- GOOGLE_DCHECK_LE(len, dest_len);
+ Y_ABSL_DCHECK_LE(len, dest_len);
dest->erase(len);
return true;
@@ -2180,7 +2181,7 @@ int Base64EscapeInternal(const unsigned char *src, int szsrc,
default:
// Should not be reached: blocks of 4 bytes are handled
// in the while loop before this switch statement.
- GOOGLE_LOG(FATAL) << "Logic problem? szsrc = " << szsrc;
+ Y_ABSL_LOG(FATAL) << "Logic problem? szsrc = " << szsrc;
break;
}
return (cur_dest - dest);
@@ -2212,7 +2213,7 @@ void Base64EscapeInternal(const unsigned char *src, int szsrc,
dest->size(),
base64_chars,
do_padding);
- GOOGLE_DCHECK_EQ(calc_escaped_size, escaped_len);
+ Y_ABSL_DCHECK_EQ(calc_escaped_size, escaped_len);
dest->erase(escaped_len);
}
@@ -2424,9 +2425,9 @@ TProtoStringType LocalizeRadix(const char *input, const char *radix_pos) {
// thread-safe.
char temp[16];
int size = snprintf(temp, sizeof(temp), "%.1f", 1.5);
- GOOGLE_CHECK_EQ(temp[0], '1');
- GOOGLE_CHECK_EQ(temp[size - 1], '5');
- GOOGLE_CHECK_LE(size, 6);
+ Y_ABSL_CHECK_EQ(temp[0], '1');
+ Y_ABSL_CHECK_EQ(temp[size - 1], '5');
+ Y_ABSL_CHECK_LE(size, 6);
// Now replace the '.' in the input with it.
TProtoStringType result;
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/substitute.cc b/contrib/libs/protobuf/src/google/protobuf/stubs/substitute.cc
index bd2ccd25884..b766aadd673 100644
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/substitute.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/stubs/substitute.cc
@@ -32,7 +32,8 @@
#include <google/protobuf/stubs/substitute.h>
-#include <google/protobuf/stubs/logging.h>
+#include <y_absl/log/absl_log.h>
+#include <y_absl/log/absl_check.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/stl_util.h>
@@ -81,7 +82,7 @@ void SubstituteAndAppend(TProtoStringType* output, const char* format,
if (ascii_isdigit(format[i+1])) {
int index = format[i+1] - '0';
if (args_array[index]->size() == -1) {
- GOOGLE_LOG(DFATAL)
+ Y_ABSL_LOG(FATAL)
<< "strings::Substitute format string invalid: asked for \"$"
<< index << "\", but only " << CountSubstituteArgs(args_array)
<< " args were given. Full format string was: \""
@@ -94,7 +95,7 @@ void SubstituteAndAppend(TProtoStringType* output, const char* format,
++size;
++i; // Skip next char.
} else {
- GOOGLE_LOG(DFATAL)
+ Y_ABSL_LOG(FATAL)
<< "Invalid strings::Substitute() format string: \""
<< CEscape(format) << "\".";
return;
@@ -128,7 +129,7 @@ void SubstituteAndAppend(TProtoStringType* output, const char* format,
}
}
- GOOGLE_DCHECK_EQ(target - output->data(), output->size());
+ Y_ABSL_DCHECK_EQ(target - output->data(), output->size());
}
} // namespace strings
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/time.cc b/contrib/libs/protobuf/src/google/protobuf/stubs/time.cc
deleted file mode 100644
index a882e58698e..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/time.cc
+++ /dev/null
@@ -1,365 +0,0 @@
-#include <google/protobuf/stubs/time.h>
-
-#include <ctime>
-
-#include <google/protobuf/stubs/stringprintf.h>
-#include <google/protobuf/stubs/strutil.h>
-
-namespace google {
-namespace protobuf {
-namespace internal {
-
-namespace {
-static const arc_i64 kSecondsPerMinute = 60;
-static const arc_i64 kSecondsPerHour = 3600;
-static const arc_i64 kSecondsPerDay = kSecondsPerHour * 24;
-static const arc_i64 kSecondsPer400Years =
- kSecondsPerDay * (400 * 365 + 400 / 4 - 3);
-// Seconds from 0001-01-01T00:00:00 to 1970-01-01T:00:00:00
-static const arc_i64 kSecondsFromEraToEpoch = 62135596800LL;
-// The range of timestamp values we support.
-static const arc_i64 kMinTime = -62135596800LL; // 0001-01-01T00:00:00
-static const arc_i64 kMaxTime = 253402300799LL; // 9999-12-31T23:59:59
-
-static const int kNanosPerMillisecond = 1000000;
-static const int kNanosPerMicrosecond = 1000;
-
-// Count the seconds from the given year (start at Jan 1, 00:00) to 100 years
-// after.
-arc_i64 SecondsPer100Years(int year) {
- if (year % 400 == 0 || year % 400 > 300) {
- return kSecondsPerDay * (100 * 365 + 100 / 4);
- } else {
- return kSecondsPerDay * (100 * 365 + 100 / 4 - 1);
- }
-}
-
-// Count the seconds from the given year (start at Jan 1, 00:00) to 4 years
-// after.
-arc_i64 SecondsPer4Years(int year) {
- if ((year % 100 == 0 || year % 100 > 96) &&
- !(year % 400 == 0 || year % 400 > 396)) {
- // No leap years.
- return kSecondsPerDay * (4 * 365);
- } else {
- // One leap years.
- return kSecondsPerDay * (4 * 365 + 1);
- }
-}
-
-bool IsLeapYear(int year) {
- return year % 400 == 0 || (year % 4 == 0 && year % 100 != 0);
-}
-
-arc_i64 SecondsPerYear(int year) {
- return kSecondsPerDay * (IsLeapYear(year) ? 366 : 365);
-}
-
-static const int kDaysInMonth[13] = {
- 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
-};
-
-arc_i64 SecondsPerMonth(int month, bool leap) {
- if (month == 2 && leap) {
- return kSecondsPerDay * (kDaysInMonth[month] + 1);
- }
- return kSecondsPerDay * kDaysInMonth[month];
-}
-
-static const int kDaysSinceJan[13] = {
- 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334,
-};
-
-bool ValidateDateTime(const DateTime& time) {
- if (time.year < 1 || time.year > 9999 ||
- time.month < 1 || time.month > 12 ||
- time.day < 1 || time.day > 31 ||
- time.hour < 0 || time.hour > 23 ||
- time.minute < 0 || time.minute > 59 ||
- time.second < 0 || time.second > 59) {
- return false;
- }
- if (time.month == 2 && IsLeapYear(time.year)) {
- return time.day <= kDaysInMonth[time.month] + 1;
- } else {
- return time.day <= kDaysInMonth[time.month];
- }
-}
-
-// Count the number of seconds elapsed from 0001-01-01T00:00:00 to the given
-// time.
-arc_i64 SecondsSinceCommonEra(const DateTime& time) {
- arc_i64 result = 0;
- // Years should be between 1 and 9999.
- assert(time.year >= 1 && time.year <= 9999);
- int year = 1;
- if ((time.year - year) >= 400) {
- int count_400years = (time.year - year) / 400;
- result += kSecondsPer400Years * count_400years;
- year += count_400years * 400;
- }
- while ((time.year - year) >= 100) {
- result += SecondsPer100Years(year);
- year += 100;
- }
- while ((time.year - year) >= 4) {
- result += SecondsPer4Years(year);
- year += 4;
- }
- while (time.year > year) {
- result += SecondsPerYear(year);
- ++year;
- }
- // Months should be between 1 and 12.
- assert(time.month >= 1 && time.month <= 12);
- int month = time.month;
- result += kSecondsPerDay * kDaysSinceJan[month];
- if (month > 2 && IsLeapYear(year)) {
- result += kSecondsPerDay;
- }
- assert(time.day >= 1 &&
- time.day <= (month == 2 && IsLeapYear(year)
- ? kDaysInMonth[month] + 1
- : kDaysInMonth[month]));
- result += kSecondsPerDay * (time.day - 1);
- result += kSecondsPerHour * time.hour +
- kSecondsPerMinute * time.minute +
- time.second;
- return result;
-}
-
-// Format nanoseconds with either 3, 6, or 9 digits depending on the required
-// precision to represent the exact value.
-TProtoStringType FormatNanos(arc_i32 nanos) {
- if (nanos % kNanosPerMillisecond == 0) {
- return StringPrintf("%03d", nanos / kNanosPerMillisecond);
- } else if (nanos % kNanosPerMicrosecond == 0) {
- return StringPrintf("%06d", nanos / kNanosPerMicrosecond);
- } else {
- return StringPrintf("%09d", nanos);
- }
-}
-
-// Parses an integer from a null-terminated char sequence. The method
-// consumes at most "width" chars. Returns a pointer after the consumed
-// integer, or nullptr if the data does not start with an integer or the
-// integer value does not fall in the range of [min_value, max_value].
-const char* ParseInt(const char* data, int width, int min_value,
- int max_value, int* result) {
- if (!ascii_isdigit(*data)) {
- return nullptr;
- }
- int value = 0;
- for (int i = 0; i < width; ++i, ++data) {
- if (ascii_isdigit(*data)) {
- value = value * 10 + (*data - '0');
- } else {
- break;
- }
- }
- if (value >= min_value && value <= max_value) {
- *result = value;
- return data;
- } else {
- return nullptr;
- }
-}
-
-// Consumes the fractional parts of a second into nanos. For example,
-// "010" will be parsed to 10000000 nanos.
-const char* ParseNanos(const char* data, arc_i32* nanos) {
- if (!ascii_isdigit(*data)) {
- return nullptr;
- }
- int value = 0;
- int len = 0;
- // Consume as many digits as there are but only take the first 9 into
- // account.
- while (ascii_isdigit(*data)) {
- if (len < 9) {
- value = value * 10 + *data - '0';
- }
- ++len;
- ++data;
- }
- while (len < 9) {
- value = value * 10;
- ++len;
- }
- *nanos = value;
- return data;
-}
-
-const char* ParseTimezoneOffset(const char* data, arc_i64* offset) {
- // Accept format "HH:MM". E.g., "08:00"
- int hour;
- if ((data = ParseInt(data, 2, 0, 23, &hour)) == nullptr) {
- return nullptr;
- }
- if (*data++ != ':') {
- return nullptr;
- }
- int minute;
- if ((data = ParseInt(data, 2, 0, 59, &minute)) == nullptr) {
- return nullptr;
- }
- *offset = (hour * 60 + minute) * 60;
- return data;
-}
-} // namespace
-
-bool SecondsToDateTime(arc_i64 seconds, DateTime* time) {
- if (seconds < kMinTime || seconds > kMaxTime) {
- return false;
- }
- // It's easier to calculate the DateTime starting from 0001-01-01T00:00:00
- seconds = seconds + kSecondsFromEraToEpoch;
- int year = 1;
- if (seconds >= kSecondsPer400Years) {
- int count_400years = seconds / kSecondsPer400Years;
- year += 400 * count_400years;
- seconds %= kSecondsPer400Years;
- }
- while (seconds >= SecondsPer100Years(year)) {
- seconds -= SecondsPer100Years(year);
- year += 100;
- }
- while (seconds >= SecondsPer4Years(year)) {
- seconds -= SecondsPer4Years(year);
- year += 4;
- }
- while (seconds >= SecondsPerYear(year)) {
- seconds -= SecondsPerYear(year);
- year += 1;
- }
- bool leap = IsLeapYear(year);
- int month = 1;
- while (seconds >= SecondsPerMonth(month, leap)) {
- seconds -= SecondsPerMonth(month, leap);
- ++month;
- }
- int day = 1 + seconds / kSecondsPerDay;
- seconds %= kSecondsPerDay;
- int hour = seconds / kSecondsPerHour;
- seconds %= kSecondsPerHour;
- int minute = seconds / kSecondsPerMinute;
- seconds %= kSecondsPerMinute;
- time->year = year;
- time->month = month;
- time->day = day;
- time->hour = hour;
- time->minute = minute;
- time->second = static_cast<int>(seconds);
- return true;
-}
-
-bool DateTimeToSeconds(const DateTime& time, arc_i64* seconds) {
- if (!ValidateDateTime(time)) {
- return false;
- }
- *seconds = SecondsSinceCommonEra(time) - kSecondsFromEraToEpoch;
- return true;
-}
-
-void GetCurrentTime(arc_i64* seconds, arc_i32* nanos) {
- // TODO(xiaofeng): Improve the accuracy of this implementation (or just
- // remove this method from protobuf).
- *seconds = time(nullptr);
- *nanos = 0;
-}
-
-TProtoStringType FormatTime(arc_i64 seconds, arc_i32 nanos) {
- DateTime time;
- if (nanos < 0 || nanos > 999999999 || !SecondsToDateTime(seconds, &time)) {
- return "InvalidTime";
- }
- TProtoStringType result =
- StringPrintf("%04d-%02d-%02dT%02d:%02d:%02d", time.year, time.month,
- time.day, time.hour, time.minute, time.second);
- if (nanos != 0) {
- result += "." + FormatNanos(nanos);
- }
- return result + "Z";
-}
-
-bool ParseTime(const TProtoStringType& value, arc_i64* seconds, arc_i32* nanos) {
- DateTime time;
- const char* data = value.c_str();
- // We only accept:
- // Z-normalized: 2015-05-20T13:29:35.120Z
- // With UTC offset: 2015-05-20T13:29:35.120-08:00
-
- // Parse year
- if ((data = ParseInt(data, 4, 1, 9999, &time.year)) == nullptr) {
- return false;
- }
- // Expect '-'
- if (*data++ != '-') return false;
- // Parse month
- if ((data = ParseInt(data, 2, 1, 12, &time.month)) == nullptr) {
- return false;
- }
- // Expect '-'
- if (*data++ != '-') return false;
- // Parse day
- if ((data = ParseInt(data, 2, 1, 31, &time.day)) == nullptr) {
- return false;
- }
- // Expect 'T'
- if (*data++ != 'T') return false;
- // Parse hour
- if ((data = ParseInt(data, 2, 0, 23, &time.hour)) == nullptr) {
- return false;
- }
- // Expect ':'
- if (*data++ != ':') return false;
- // Parse minute
- if ((data = ParseInt(data, 2, 0, 59, &time.minute)) == nullptr) {
- return false;
- }
- // Expect ':'
- if (*data++ != ':') return false;
- // Parse second
- if ((data = ParseInt(data, 2, 0, 59, &time.second)) == nullptr) {
- return false;
- }
- if (!DateTimeToSeconds(time, seconds)) {
- return false;
- }
- // Parse nanoseconds.
- if (*data == '.') {
- ++data;
- // Parse nanoseconds.
- if ((data = ParseNanos(data, nanos)) == nullptr) {
- return false;
- }
- } else {
- *nanos = 0;
- }
- // Parse UTC offsets.
- if (*data == 'Z') {
- ++data;
- } else if (*data == '+') {
- ++data;
- arc_i64 offset;
- if ((data = ParseTimezoneOffset(data, &offset)) == nullptr) {
- return false;
- }
- *seconds -= offset;
- } else if (*data == '-') {
- ++data;
- arc_i64 offset;
- if ((data = ParseTimezoneOffset(data, &offset)) == nullptr) {
- return false;
- }
- *seconds += offset;
- } else {
- return false;
- }
- // Done with parsing.
- return *data == 0;
-}
-
-} // namespace internal
-} // namespace protobuf
-} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/time.h b/contrib/libs/protobuf/src/google/protobuf/stubs/time.h
deleted file mode 100644
index 97a162cee43..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/time.h
+++ /dev/null
@@ -1,82 +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_STUBS_TIME_H_
-#define GOOGLE_PROTOBUF_STUBS_TIME_H_
-
-#include <cstdint>
-
-#include <google/protobuf/stubs/common.h>
-
-#include <google/protobuf/port_def.inc>
-
-namespace google {
-namespace protobuf {
-namespace internal {
-
-struct DateTime {
- int year;
- int month;
- int day;
- int hour;
- int minute;
- int second;
-};
-
-// Converts a timestamp (seconds elapsed since 1970-01-01T00:00:00, could be
-// negative to represent time before 1970-01-01) to DateTime. Returns false
-// if the timestamp is not in the range between 0001-01-01T00:00:00 and
-// 9999-12-31T23:59:59.
-bool PROTOBUF_EXPORT SecondsToDateTime(arc_i64 seconds, DateTime* time);
-// Converts DateTime to a timestamp (seconds since 1970-01-01T00:00:00).
-// Returns false if the DateTime is not valid or is not in the valid range.
-bool PROTOBUF_EXPORT DateTimeToSeconds(const DateTime& time, arc_i64* seconds);
-
-void PROTOBUF_EXPORT GetCurrentTime(arc_i64* seconds, arc_i32* nanos);
-
-// Formats a time string in RFC3339 format.
-//
-// For example, "2015-05-20T13:29:35.120Z". For nanos, 0, 3, 6 or 9 fractional
-// digits will be used depending on how many are required to represent the exact
-// value.
-//
-// Note that "nanos" must in the range of [0, 999999999].
-TProtoStringType PROTOBUF_EXPORT FormatTime(arc_i64 seconds, arc_i32 nanos);
-// Parses a time string. This method accepts RFC3339 date/time string with UTC
-// offset. For example, "2015-05-20T13:29:35.120-08:00".
-bool PROTOBUF_EXPORT ParseTime(const TProtoStringType& value, arc_i64* seconds,
- arc_i32* nanos);
-
-} // namespace internal
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#endif // GOOGLE_PROTOBUF_STUBS_TIME_H_
diff --git a/contrib/libs/protobuf/src/google/protobuf/text_format.cc b/contrib/libs/protobuf/src/google/protobuf/text_format.cc
index cfd19754899..3355d1d3db6 100644
--- a/contrib/libs/protobuf/src/google/protobuf/text_format.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/text_format.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/text_format.h>
+#include "google/protobuf/text_format.h"
#include <float.h>
#include <stdio.h>
@@ -42,29 +42,34 @@
#include <climits>
#include <cmath>
#include <limits>
+#include <string>
#include <utility>
#include <vector>
-#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/map_util.h>
-#include <google/protobuf/stubs/stl_util.h>
+#include "y_absl/container/btree_set.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/escaping.h"
+#include "y_absl/strings/numbers.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_join.h"
+#include "y_absl/strings/string_view.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/coded_stream.h"
+#include "google/protobuf/io/strtod.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/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"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -87,6 +92,12 @@ namespace internal {
const char kDebugStringSilentMarker[] = "";
const char kDebugStringSilentMarkerForDetection[] = "\t ";
+// Controls insertion of a marker making debug strings non-parseable.
+PROTOBUF_EXPORT std::atomic<bool> enable_debug_text_redaction_marker;
+
+// Controls insertion of a randomized marker in debug strings.
+PROTOBUF_EXPORT std::atomic<bool> enable_debug_text_random_marker;
+
// Controls insertion of kDebugStringSilentMarker.
PROTOBUF_EXPORT std::atomic<bool> enable_debug_text_format_marker;
} // namespace internal
@@ -98,6 +109,12 @@ TProtoStringType Message::DebugString() const {
printer.SetExpandAny(true);
printer.SetInsertSilentMarker(internal::enable_debug_text_format_marker.load(
std::memory_order_relaxed));
+ printer.SetRedactDebugString(
+ internal::enable_debug_text_redaction_marker.load(
+ std::memory_order_relaxed));
+ printer.SetRandomizeDebugString(
+ internal::enable_debug_text_random_marker.load(
+ std::memory_order_relaxed));
printer.PrintToString(*this, &debug_string);
@@ -112,6 +129,12 @@ TProtoStringType Message::ShortDebugString() const {
printer.SetExpandAny(true);
printer.SetInsertSilentMarker(internal::enable_debug_text_format_marker.load(
std::memory_order_relaxed));
+ printer.SetRedactDebugString(
+ internal::enable_debug_text_redaction_marker.load(
+ std::memory_order_relaxed));
+ printer.SetRandomizeDebugString(
+ internal::enable_debug_text_random_marker.load(
+ std::memory_order_relaxed));
printer.PrintToString(*this, &debug_string);
// Single line mode currently might have an extra space at the end.
@@ -130,6 +153,12 @@ TProtoStringType Message::Utf8DebugString() const {
printer.SetExpandAny(true);
printer.SetInsertSilentMarker(internal::enable_debug_text_format_marker.load(
std::memory_order_relaxed));
+ printer.SetRedactDebugString(
+ internal::enable_debug_text_redaction_marker.load(
+ std::memory_order_relaxed));
+ printer.SetRandomizeDebugString(
+ internal::enable_debug_text_random_marker.load(
+ std::memory_order_relaxed));
printer.PrintToString(*this, &debug_string);
@@ -138,6 +167,22 @@ TProtoStringType Message::Utf8DebugString() const {
void Message::PrintDebugString() const { printf("%s", DebugString().c_str()); }
+namespace internal {
+
+void PerformAbslStringify(const Message& message,
+ y_absl::FunctionRef<void(y_absl::string_view)> append) {
+ // TODO(b/249835002): consider using the single line version for short
+ TextFormat::Printer printer;
+ printer.SetExpandAny(true);
+ printer.SetRedactDebugString(true);
+ printer.SetRandomizeDebugString(true);
+ TProtoStringType result;
+ printer.PrintToString(message, &result);
+ append(result);
+}
+
+} // namespace internal
+
// ===========================================================================
// Implementation of the parse information tree class.
@@ -160,11 +205,11 @@ void CheckFieldIndex(const FieldDescriptor* field, int index) {
}
if (field->is_repeated() && index == -1) {
- GOOGLE_LOG(DFATAL) << "Index must be in range of repeated field values. "
- << "Field: " << field->name();
+ Y_ABSL_DLOG(FATAL) << "Index must be in range of repeated field values. "
+ << "Field: " << field->name();
} else if (!field->is_repeated() && index != -1) {
- GOOGLE_LOG(DFATAL) << "Index must be -1 for singular fields."
- << "Field: " << field->name();
+ Y_ABSL_DLOG(FATAL) << "Index must be -1 for singular fields."
+ << "Field: " << field->name();
}
}
@@ -175,14 +220,13 @@ TextFormat::ParseLocationRange TextFormat::ParseInfoTree::GetLocationRange(
index = 0;
}
- const std::vector<TextFormat::ParseLocationRange>* locations =
- FindOrNull(locations_, field);
- if (locations == nullptr ||
- index >= static_cast<arc_i64>(locations->size())) {
+ auto it = locations_.find(field);
+ if (it == locations_.end() ||
+ index >= static_cast<arc_i64>(it->second.size())) {
return TextFormat::ParseLocationRange();
}
- return (*locations)[index];
+ return it->second[static_cast<size_t>(index)];
}
TextFormat::ParseInfoTree* TextFormat::ParseInfoTree::GetTreeForNested(
@@ -197,7 +241,7 @@ TextFormat::ParseInfoTree* TextFormat::ParseInfoTree::GetTreeForNested(
return nullptr;
}
- return it->second[index].get();
+ return it->second[static_cast<size_t>(index)].get();
}
namespace {
@@ -229,7 +273,7 @@ const Descriptor* DefaultFinderFindAnyType(const Message& message,
// ===========================================================================
// Internal class for parsing an ASCII representation of a Protocol Message.
// This class makes use of the Protocol Message compiler's tokenizer found
-// in //net/proto2/io/public/tokenizer.h. Note that class's Parse
+// in //third_party/protobuf/io/tokenizer.h. Note that class's Parse
// method is *not* thread-safe and should only be used in a single thread at
// a time.
@@ -294,12 +338,14 @@ class TextFormat::Parser::ParserImpl {
// Consume the starting token.
tokenizer_.Next();
}
+ ParserImpl(const ParserImpl&) = delete;
+ ParserImpl& operator=(const ParserImpl&) = delete;
~ParserImpl() {}
// Parses the ASCII representation specified in input and saves the
// information into the output pointer (a Message). Returns
// false if an error occurs (an error will also be logged to
- // GOOGLE_LOG(ERROR)).
+ // Y_ABSL_LOG(ERROR)).
bool Parse(Message* output) {
// Consume fields until we cannot do so anymore.
while (true) {
@@ -307,7 +353,7 @@ class TextFormat::Parser::ParserImpl {
// Ensures recursion limit properly unwinded, but only for success
// cases. This implicitly avoids the check when `Parse` returns false
// via `DO(...)`.
- GOOGLE_DCHECK(had_errors_ || recursion_limit_ == initial_recursion_limit_)
+ Y_ABSL_DCHECK(had_errors_ || recursion_limit_ == initial_recursion_limit_)
<< "Recursion limit at end of parse should be "
<< initial_recursion_limit_ << ", but was " << recursion_limit_
<< ". Difference of " << initial_recursion_limit_ - recursion_limit_
@@ -330,34 +376,34 @@ class TextFormat::Parser::ParserImpl {
return suc && LookingAtType(io::Tokenizer::TYPE_END);
}
- void ReportError(int line, int col, const TProtoStringType& message) {
+ void ReportError(int line, int col, y_absl::string_view message) {
had_errors_ = true;
if (error_collector_ == nullptr) {
if (line >= 0) {
- GOOGLE_LOG(ERROR) << "Error parsing text-format "
- << root_message_type_->full_name() << ": " << (line + 1)
- << ":" << (col + 1) << ": " << message;
+ Y_ABSL_LOG(ERROR) << "Error parsing text-format "
+ << root_message_type_->full_name() << ": " << (line + 1)
+ << ":" << (col + 1) << ": " << message;
} else {
- GOOGLE_LOG(ERROR) << "Error parsing text-format "
- << root_message_type_->full_name() << ": " << message;
+ Y_ABSL_LOG(ERROR) << "Error parsing text-format "
+ << root_message_type_->full_name() << ": " << message;
}
} else {
- error_collector_->AddError(line, col, message);
+ error_collector_->RecordError(line, col, message);
}
}
- void ReportWarning(int line, int col, const TProtoStringType& message) {
+ void ReportWarning(int line, int col, const y_absl::string_view message) {
if (error_collector_ == nullptr) {
if (line >= 0) {
- GOOGLE_LOG(WARNING) << "Warning parsing text-format "
- << root_message_type_->full_name() << ": " << (line + 1)
- << ":" << (col + 1) << ": " << message;
+ Y_ABSL_LOG(WARNING) << "Warning parsing text-format "
+ << root_message_type_->full_name() << ": "
+ << (line + 1) << ":" << (col + 1) << ": " << message;
} else {
- GOOGLE_LOG(WARNING) << "Warning parsing text-format "
- << root_message_type_->full_name() << ": " << message;
+ Y_ABSL_LOG(WARNING) << "Warning parsing text-format "
+ << root_message_type_->full_name() << ": " << message;
}
} else {
- error_collector_->AddWarning(line, col, message);
+ error_collector_->RecordWarning(line, col, message);
}
}
@@ -368,18 +414,16 @@ class TextFormat::Parser::ParserImpl {
static constexpr arc_i64 kint64max = std::numeric_limits<arc_i64>::max();
static constexpr arc_ui64 kuint64max = std::numeric_limits<arc_ui64>::max();
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ParserImpl);
-
// Reports an error with the given message with information indicating
// the position (as derived from the current token).
- void ReportError(const TProtoStringType& message) {
+ void ReportError(y_absl::string_view message) {
ReportError(tokenizer_.current().line, tokenizer_.current().column,
message);
}
// Reports a warning with the given message with information indicating
// the position (as derived from the current token).
- void ReportWarning(const TProtoStringType& message) {
+ void ReportWarning(y_absl::string_view message) {
ReportWarning(tokenizer_.current().line, tokenizer_.current().column,
message);
}
@@ -429,7 +473,7 @@ class TextFormat::Parser::ParserImpl {
TProtoStringType full_type_name, prefix;
DO(ConsumeAnyTypeUrl(&full_type_name, &prefix));
TProtoStringType prefix_and_full_type_name =
- StrCat(prefix, full_type_name);
+ y_absl::StrCat(prefix, full_type_name);
DO(ConsumeBeforeWhitespace("]"));
TryConsumeWhitespace();
// ':' is optional between message labels and values.
@@ -441,8 +485,9 @@ class TextFormat::Parser::ParserImpl {
finder_ ? finder_->FindAnyType(*message, prefix, full_type_name)
: DefaultFinderFindAnyType(*message, prefix, full_type_name);
if (value_descriptor == nullptr) {
- ReportError("Could not find type \"" + prefix_and_full_type_name +
- "\" stored in google.protobuf.Any.");
+ ReportError(y_absl::StrCat("Could not find type \"",
+ prefix_and_full_type_name,
+ "\" stored in google.protobuf.Any."));
return false;
}
DO(ConsumeAnyValue(value_descriptor, &serialized_value));
@@ -473,15 +518,16 @@ class TextFormat::Parser::ParserImpl {
if (field == nullptr) {
if (!allow_unknown_field_ && !allow_unknown_extension_) {
- ReportError("Extension \"" + field_name +
- "\" is not defined or "
- "is not an extension of \"" +
- descriptor->full_name() + "\".");
+ ReportError(y_absl::StrCat("Extension \"", field_name,
+ "\" is not defined or "
+ "is not an extension of \"",
+ descriptor->full_name(), "\"."));
return false;
} else {
- ReportWarning("Ignoring extension \"" + field_name +
- "\" which is not defined or is not an extension of \"" +
- descriptor->full_name() + "\".");
+ ReportWarning(y_absl::StrCat(
+ "Ignoring extension \"", field_name,
+ "\" which is not defined or is not an extension of \"",
+ descriptor->full_name(), "\"."));
}
}
} else {
@@ -489,7 +535,7 @@ class TextFormat::Parser::ParserImpl {
TryConsumeWhitespace();
arc_i32 field_number;
- if (allow_field_number_ && safe_strto32(field_name, &field_number)) {
+ if (allow_field_number_ && y_absl::SimpleAtoi(field_name, &field_number)) {
if (descriptor->IsExtensionNumber(field_number)) {
field = finder_
? finder_->FindExtensionByNumber(descriptor, field_number)
@@ -507,7 +553,7 @@ class TextFormat::Parser::ParserImpl {
// field names.
if (field == nullptr) {
TProtoStringType lower_field_name = field_name;
- LowerString(&lower_field_name);
+ y_absl::AsciiStrToLower(&lower_field_name);
field = descriptor->FindFieldByName(lower_field_name);
// If the case-insensitive match worked but the field is NOT a group,
if (field != nullptr &&
@@ -523,7 +569,7 @@ class TextFormat::Parser::ParserImpl {
if (field == nullptr && allow_case_insensitive_field_) {
TProtoStringType lower_field_name = field_name;
- LowerString(&lower_field_name);
+ y_absl::AsciiStrToLower(&lower_field_name);
field = descriptor->FindFieldByLowercaseName(lower_field_name);
}
@@ -534,19 +580,22 @@ class TextFormat::Parser::ParserImpl {
if (field == nullptr && !reserved_field) {
if (!allow_unknown_field_) {
- ReportError("Message type \"" + descriptor->full_name() +
- "\" has no field named \"" + field_name + "\".");
+ ReportError(y_absl::StrCat("Message type \"", descriptor->full_name(),
+ "\" has no field named \"", field_name,
+ "\"."));
return false;
} else {
- ReportWarning("Message type \"" + descriptor->full_name() +
- "\" has no field named \"" + field_name + "\".");
+ ReportWarning(y_absl::StrCat("Message type \"", descriptor->full_name(),
+ "\" has no field named \"", field_name,
+ "\"."));
}
}
}
// Skips unknown or reserved fields.
if (field == nullptr) {
- GOOGLE_CHECK(allow_unknown_field_ || allow_unknown_extension_ || reserved_field);
+ Y_ABSL_CHECK(allow_unknown_field_ || allow_unknown_extension_ ||
+ reserved_field);
// Try to guess the type of this field.
// If this field is not a message, there should be a ":" between the
@@ -569,11 +618,16 @@ class TextFormat::Parser::ParserImpl {
return skip;
}
+ if (field->options().deprecated()) {
+ ReportWarning(y_absl::StrCat("text format contains deprecated field \"",
+ field_name, "\""));
+ }
+
if (singular_overwrite_policy_ == FORBID_SINGULAR_OVERWRITES) {
// Fail if the field is not repeated and it has already been specified.
if (!field->is_repeated() && reflection->HasField(*message, field)) {
- ReportError("Non-repeated field \"" + field_name +
- "\" is specified multiple times.");
+ ReportError(y_absl::StrCat("Non-repeated field \"", field_name,
+ "\" is specified multiple times."));
return false;
}
// Fail if the field is a member of a oneof and another member has already
@@ -582,13 +636,13 @@ class TextFormat::Parser::ParserImpl {
if (oneof != nullptr && reflection->HasOneof(*message, oneof)) {
const FieldDescriptor* other_field =
reflection->GetOneofFieldDescriptor(*message, oneof);
- ReportError("Field \"" + field_name +
- "\" is specified along with "
- "field \"" +
- other_field->name() +
- "\", another member "
- "of oneof \"" +
- oneof->name() + "\".");
+ ReportError(y_absl::StrCat("Field \"", field_name,
+ "\" is specified along with "
+ "field \"",
+ other_field->name(),
+ "\", another member "
+ "of oneof \"",
+ oneof->name(), "\"."));
return false;
}
}
@@ -644,11 +698,6 @@ class TextFormat::Parser::ParserImpl {
// semicolons.
TryConsume(";") || TryConsume(",");
- if (field->options().deprecated()) {
- ReportWarning("text format contains deprecated field \"" + field_name +
- "\"");
- }
-
// If a parse info tree exists, add the location for the parsed
// field.
if (parse_info_tree_ != nullptr) {
@@ -701,7 +750,7 @@ class TextFormat::Parser::ParserImpl {
const FieldDescriptor* field) {
if (--recursion_limit_ < 0) {
ReportError(
- StrCat("Message is too deep, the parser exceeded the "
+ y_absl::StrCat("Message is too deep, the parser exceeded the "
"configured recursion limit of ",
initial_recursion_limit_, "."));
return false;
@@ -737,7 +786,7 @@ class TextFormat::Parser::ParserImpl {
bool SkipFieldMessage() {
if (--recursion_limit_ < 0) {
ReportError(
- StrCat("Message is too deep, the parser exceeded the "
+ y_absl::StrCat("Message is too deep, the parser exceeded the "
"configured recursion limit of ",
initial_recursion_limit_, "."));
return false;
@@ -829,8 +878,9 @@ class TextFormat::Parser::ParserImpl {
} else if (value == "false" || value == "False" || value == "f") {
SET_FIELD(Bool, false);
} else {
- ReportError("Invalid value for boolean field \"" + field->name() +
- "\". Value: \"" + value + "\".");
+ ReportError(y_absl::StrCat("Invalid value for boolean field \"",
+ field->name(), "\". Value: \"", value,
+ "\"."));
return false;
}
}
@@ -851,11 +901,11 @@ class TextFormat::Parser::ParserImpl {
} else if (LookingAt("-") ||
LookingAtType(io::Tokenizer::TYPE_INTEGER)) {
DO(ConsumeSignedInteger(&int_value, kint32max));
- value = StrCat(int_value); // for error reporting
+ value = y_absl::StrCat(int_value); // for error reporting
enum_value = enum_type->FindValueByNumber(int_value);
} else {
- ReportError("Expected integer or identifier, got: " +
- tokenizer_.current().text);
+ ReportError(y_absl::StrCat("Expected integer or identifier, got: ",
+ tokenizer_.current().text));
return false;
}
@@ -865,16 +915,13 @@ class TextFormat::Parser::ParserImpl {
SET_FIELD(EnumValue, int_value);
return true;
} else if (!allow_unknown_enum_) {
- ReportError("Unknown enumeration value of \"" + value +
- "\" for "
- "field \"" +
- field->name() + "\".");
+ ReportError(y_absl::StrCat("Unknown enumeration value of \"", value,
+ "\" for field \"", field->name(), "\"."));
return false;
} else {
- ReportWarning("Unknown enumeration value of \"" + value +
- "\" for "
- "field \"" +
- field->name() + "\".");
+ ReportWarning(y_absl::StrCat("Unknown enumeration value of \"", value,
+ "\" for field \"", field->name(),
+ "\"."));
return true;
}
}
@@ -886,7 +933,7 @@ class TextFormat::Parser::ParserImpl {
case FieldDescriptor::CPPTYPE_MESSAGE: {
// We should never get here. Put here instead of a default
// so that if new types are added, we get a nice compiler warning.
- GOOGLE_LOG(FATAL) << "Reached an unintended state: CPPTYPE_MESSAGE";
+ Y_ABSL_LOG(FATAL) << "Reached an unintended state: CPPTYPE_MESSAGE";
break;
}
}
@@ -897,7 +944,7 @@ class TextFormat::Parser::ParserImpl {
bool SkipFieldValue() {
if (--recursion_limit_ < 0) {
ReportError(
- StrCat("Message is too deep, the parser exceeded the "
+ y_absl::StrCat("Message is too deep, the parser exceeded the "
"configured recursion limit of ",
initial_recursion_limit_, "."));
return false;
@@ -911,16 +958,18 @@ class TextFormat::Parser::ParserImpl {
return true;
}
if (TryConsume("[")) {
- while (true) {
- if (!LookingAt("{") && !LookingAt("<")) {
- DO(SkipFieldValue());
- } else {
- DO(SkipFieldMessage());
- }
- if (TryConsume("]")) {
- break;
+ if (!TryConsume("]")) {
+ while (true) {
+ if (!LookingAt("{") && !LookingAt("<")) {
+ DO(SkipFieldValue());
+ } else {
+ DO(SkipFieldMessage());
+ }
+ if (TryConsume("]")) {
+ break;
+ }
+ DO(Consume(","));
}
- DO(Consume(","));
}
++recursion_limit_;
return true;
@@ -951,7 +1000,8 @@ class TextFormat::Parser::ParserImpl {
!LookingAtType(io::Tokenizer::TYPE_FLOAT) &&
!LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) {
TProtoStringType text = tokenizer_.current().text;
- ReportError("Cannot skip field value, unexpected token: " + text);
+ ReportError(
+ y_absl::StrCat("Cannot skip field value, unexpected token: ", text));
++recursion_limit_;
return false;
}
@@ -963,10 +1013,10 @@ class TextFormat::Parser::ParserImpl {
// inf, inff, infinity, nan
if (has_minus && LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) {
TProtoStringType text = tokenizer_.current().text;
- LowerString(&text);
+ y_absl::AsciiStrToLower(&text);
if (text != "inf" &&
text != "infinity" && text != "nan") {
- ReportError("Invalid float number: " + text);
+ ReportError(y_absl::StrCat("Invalid float number: ", text));
++recursion_limit_;
return false;
}
@@ -987,7 +1037,7 @@ class TextFormat::Parser::ParserImpl {
}
// Consumes an identifier and saves its value in the identifier parameter.
- // Returns false if the token is not of type IDENTFIER.
+ // Returns false if the token is not of type IDENTIFIER.
bool ConsumeIdentifier(TProtoStringType* identifier) {
if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) {
*identifier = tokenizer_.current().text;
@@ -1005,7 +1055,8 @@ class TextFormat::Parser::ParserImpl {
return true;
}
- ReportError("Expected identifier, got: " + tokenizer_.current().text);
+ ReportError(
+ y_absl::StrCat("Expected identifier, got: ", tokenizer_.current().text));
return false;
}
@@ -1024,8 +1075,7 @@ class TextFormat::Parser::ParserImpl {
while (TryConsume(".")) {
TProtoStringType part;
DO(ConsumeIdentifier(&part));
- *name += ".";
- *name += part;
+ y_absl::StrAppend(name, ".", part);
}
return true;
}
@@ -1053,7 +1103,8 @@ class TextFormat::Parser::ParserImpl {
// Returns false if the token is not of type STRING.
bool ConsumeString(TProtoStringType* text) {
if (!LookingAtType(io::Tokenizer::TYPE_STRING)) {
- ReportError("Expected string, got: " + tokenizer_.current().text);
+ ReportError(
+ y_absl::StrCat("Expected string, got: ", tokenizer_.current().text));
return false;
}
@@ -1071,13 +1122,15 @@ class TextFormat::Parser::ParserImpl {
// Returns false if the token is not of type INTEGER.
bool ConsumeUnsignedInteger(arc_ui64* value, arc_ui64 max_value) {
if (!LookingAtType(io::Tokenizer::TYPE_INTEGER)) {
- ReportError("Expected integer, got: " + tokenizer_.current().text);
+ ReportError(
+ y_absl::StrCat("Expected integer, got: ", tokenizer_.current().text));
return false;
}
if (!io::Tokenizer::ParseInteger(tokenizer_.current().text, max_value,
value)) {
- ReportError("Integer out of range (" + tokenizer_.current().text + ")");
+ ReportError(y_absl::StrCat("Integer out of range (",
+ tokenizer_.current().text, ")"));
return false;
}
@@ -1121,13 +1174,14 @@ class TextFormat::Parser::ParserImpl {
// Accepts decimal numbers only, rejects hex or oct numbers.
bool ConsumeUnsignedDecimalAsDouble(double* value, arc_ui64 max_value) {
if (!LookingAtType(io::Tokenizer::TYPE_INTEGER)) {
- ReportError("Expected integer, got: " + tokenizer_.current().text);
+ ReportError(
+ y_absl::StrCat("Expected integer, got: ", tokenizer_.current().text));
return false;
}
const TProtoStringType& text = tokenizer_.current().text;
if (IsHexNumber(text) || IsOctNumber(text)) {
- ReportError("Expect a decimal number, got: " + text);
+ ReportError(y_absl::StrCat("Expect a decimal number, got: ", text));
return false;
}
@@ -1168,7 +1222,7 @@ class TextFormat::Parser::ParserImpl {
tokenizer_.Next();
} else if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) {
TProtoStringType text = tokenizer_.current().text;
- LowerString(&text);
+ y_absl::AsciiStrToLower(&text);
if (text == "inf" ||
text == "infinity") {
*value = std::numeric_limits<double>::infinity();
@@ -1177,11 +1231,12 @@ class TextFormat::Parser::ParserImpl {
*value = std::numeric_limits<double>::quiet_NaN();
tokenizer_.Next();
} else {
- ReportError("Expected double, got: " + text);
+ ReportError(y_absl::StrCat("Expected double, got: ", text));
return false;
}
} else {
- ReportError("Expected double, got: " + tokenizer_.current().text);
+ ReportError(
+ y_absl::StrCat("Expected double, got: ", tokenizer_.current().text));
return false;
}
@@ -1201,10 +1256,10 @@ class TextFormat::Parser::ParserImpl {
while (TryConsume(".")) {
TProtoStringType url;
DO(ConsumeIdentifier(&url));
- *prefix += "." + url;
+ y_absl::StrAppend(prefix, ".", url);
}
DO(Consume("/"));
- *prefix += "/";
+ y_absl::StrAppend(prefix, "/");
DO(ConsumeFullTypeName(full_type_name));
return true;
@@ -1228,9 +1283,9 @@ class TextFormat::Parser::ParserImpl {
value->AppendPartialToString(serialized_value);
} else {
if (!value->IsInitialized()) {
- ReportError(
- "Value of type \"" + value_descriptor->full_name() +
- "\" stored in google.protobuf.Any has missing required fields");
+ ReportError(y_absl::StrCat(
+ "Value of type \"", value_descriptor->full_name(),
+ "\" stored in google.protobuf.Any has missing required fields"));
return false;
}
value->AppendToString(serialized_value);
@@ -1245,8 +1300,8 @@ class TextFormat::Parser::ParserImpl {
const TProtoStringType& current_value = tokenizer_.current().text;
if (current_value != value) {
- ReportError("Expected \"" + value + "\", found \"" + current_value +
- "\".");
+ ReportError(y_absl::StrCat("Expected \"", value, "\", found \"",
+ current_value, "\"."));
return false;
}
@@ -1290,7 +1345,7 @@ class TextFormat::Parser::ParserImpl {
had_silent_marker_ = false;
if (LookingAtType(io::Tokenizer::TYPE_WHITESPACE)) {
if (tokenizer_.current().text ==
- StrCat(" ", internal::kDebugStringSilentMarkerForDetection)) {
+ y_absl::StrCat(" ", internal::kDebugStringSilentMarkerForDetection)) {
had_silent_marker_ = true;
}
tokenizer_.Next();
@@ -1306,18 +1361,20 @@ class TextFormat::Parser::ParserImpl {
explicit ParserErrorCollector(TextFormat::Parser::ParserImpl* parser)
: parser_(parser) {}
+ ParserErrorCollector(const ParserErrorCollector&) = delete;
+ ParserErrorCollector& operator=(const ParserErrorCollector&) = delete;
~ParserErrorCollector() override {}
- void AddError(int line, int column, const TProtoStringType& message) override {
+ void RecordError(int line, int column, y_absl::string_view message) override {
parser_->ReportError(line, column, message);
}
- void AddWarning(int line, int column, const TProtoStringType& message) override {
+ void RecordWarning(int line, int column,
+ y_absl::string_view message) override {
parser_->ReportWarning(line, column, message);
}
private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ParserErrorCollector);
TextFormat::Parser::ParserImpl* parser_;
};
@@ -1342,7 +1399,7 @@ class TextFormat::Parser::ParserImpl {
// ===========================================================================
// Internal class for writing text to the io::ZeroCopyOutputStream. Adapted
-// from the Printer found in //net/proto2/io/public/printer.h
+// from the Printer found in //third_party/protobuf/io/printer.h
class TextFormat::Printer::TextGenerator
: public TextFormat::BaseTextGenerator {
public:
@@ -1368,6 +1425,8 @@ class TextFormat::Printer::TextGenerator
indent_level_(initial_indent_level),
initial_indent_level_(initial_indent_level) {}
+ TextGenerator(const TextGenerator&) = delete;
+ TextGenerator& operator=(const TextGenerator&) = delete;
~TextGenerator() override {
// Only BackUp() if we're sure we've successfully called Next() at least
// once.
@@ -1385,7 +1444,7 @@ class TextFormat::Printer::TextGenerator
// level is zero.
void Outdent() override {
if (indent_level_ == 0 || indent_level_ < initial_indent_level_) {
- GOOGLE_LOG(DFATAL) << " Outdent() without matching Indent().";
+ Y_ABSL_DLOG(FATAL) << " Outdent() without matching Indent().";
return;
}
@@ -1427,15 +1486,15 @@ class TextFormat::Printer::TextGenerator
// error.)
bool failed() const { return failed_; }
- void PrintMaybeWithMarker(StringPiece text) {
+ void PrintMaybeWithMarker(MarkerToken, y_absl::string_view text) override {
Print(text.data(), text.size());
if (ConsumeInsertSilentMarker()) {
PrintLiteral(internal::kDebugStringSilentMarker);
}
}
- void PrintMaybeWithMarker(StringPiece text_head,
- StringPiece text_tail) {
+ void PrintMaybeWithMarker(MarkerToken, y_absl::string_view text_head,
+ y_absl::string_view text_tail) override {
Print(text_head.data(), text_head.size());
if (ConsumeInsertSilentMarker()) {
PrintLiteral(internal::kDebugStringSilentMarker);
@@ -1444,8 +1503,6 @@ class TextFormat::Printer::TextGenerator
}
private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TextGenerator);
-
void Write(const char* data, size_t size) {
if (failed_) return;
if (size == 0) return;
@@ -1481,7 +1538,7 @@ class TextFormat::Printer::TextGenerator
if (indent_level_ == 0) {
return;
}
- GOOGLE_DCHECK(!failed_);
+ Y_ABSL_DCHECK(!failed_);
int size = GetCurrentIndentationSize();
while (size > buffer_size_) {
@@ -1536,13 +1593,10 @@ class TextFormat::Printer::DebugStringFieldValuePrinter
void PrintMessageStart(const Message& /*message*/, int /*field_index*/,
int /*field_count*/, bool single_line_mode,
BaseTextGenerator* generator) const override {
- // This is safe as only TextGenerator is used with
- // DebugStringFieldValuePrinter.
- TextGenerator* text_generator = static_cast<TextGenerator*>(generator);
if (single_line_mode) {
- text_generator->PrintMaybeWithMarker(" ", "{ ");
+ generator->PrintMaybeWithMarker(MarkerToken(), " ", "{ ");
} else {
- text_generator->PrintMaybeWithMarker(" ", "{\n");
+ generator->PrintMaybeWithMarker(MarkerToken(), " ", "{\n");
}
}
};
@@ -1555,7 +1609,7 @@ class TextFormat::Printer::FastFieldValuePrinterUtf8Escaping
void PrintString(const TProtoStringType& val,
TextFormat::BaseTextGenerator* generator) const override {
generator->PrintLiteral("\"");
- generator->PrintString(strings::Utf8SafeCEscape(val));
+ generator->PrintString(y_absl::Utf8SafeCEscape(val));
generator->PrintLiteral("\"");
}
void PrintBytes(const TProtoStringType& val,
@@ -1609,12 +1663,12 @@ TextFormat::Parser::~Parser() {}
namespace {
-bool CheckParseInputSize(StringPiece input,
+bool CheckParseInputSize(y_absl::string_view input,
io::ErrorCollector* error_collector) {
if (input.size() > INT_MAX) {
- error_collector->AddError(
+ error_collector->RecordError(
-1, 0,
- StrCat(
+ y_absl::StrCat(
"Input size too large: ", static_cast<arc_i64>(input.size()),
" bytes", " > ", INT_MAX, " bytes."));
return false;
@@ -1641,7 +1695,7 @@ bool TextFormat::Parser::Parse(io::ZeroCopyInputStream* input,
return MergeUsingImpl(input, output, &parser);
}
-bool TextFormat::Parser::ParseFromString(ConstStringParam input,
+bool TextFormat::Parser::ParseFromString(y_absl::string_view input,
Message* output) {
DO(CheckParseInputSize(input, error_collector_));
io::ArrayInputStream input_stream(input.data(), input.size());
@@ -1659,7 +1713,7 @@ bool TextFormat::Parser::Merge(io::ZeroCopyInputStream* input,
return MergeUsingImpl(input, output, &parser);
}
-bool TextFormat::Parser::MergeFromString(ConstStringParam input,
+bool TextFormat::Parser::MergeFromString(y_absl::string_view input,
Message* output) {
DO(CheckParseInputSize(input, error_collector_));
io::ArrayInputStream input_stream(input.data(), input.size());
@@ -1674,8 +1728,8 @@ bool TextFormat::Parser::MergeUsingImpl(io::ZeroCopyInputStream* /* input */,
std::vector<TProtoStringType> missing_fields;
output->FindInitializationErrors(&missing_fields);
parser_impl->ReportError(-1, 0,
- "Message missing required fields: " +
- Join(missing_fields, ", "));
+ y_absl::StrCat("Message missing required fields: ",
+ y_absl::StrJoin(missing_fields, ", ")));
return false;
}
return true;
@@ -1704,12 +1758,12 @@ bool TextFormat::Parser::ParseFieldValueFromString(const TProtoStringType& input
return Parser().Merge(input, output);
}
-/* static */ bool TextFormat::ParseFromString(ConstStringParam input,
+/* static */ bool TextFormat::ParseFromString(y_absl::string_view input,
Message* output) {
return Parser().ParseFromString(input, output);
}
-/* static */ bool TextFormat::MergeFromString(ConstStringParam input,
+/* static */ bool TextFormat::MergeFromString(y_absl::string_view input,
Message* output) {
return Parser().MergeFromString(input, output);
}
@@ -1729,13 +1783,7 @@ class StringBaseTextGenerator : public TextFormat::BaseTextGenerator {
output_.append(text, size);
}
-// Some compilers do not support ref-qualifiers even in C++11 mode.
-// Disable the optimization for now and revisit it later.
-#if 0 // LANG_CXX11
TProtoStringType Consume() && { return std::move(output_); }
-#else // !LANG_CXX11
- const TProtoStringType& Get() { return output_; }
-#endif // LANG_CXX11
private:
TProtoStringType output_;
@@ -1749,17 +1797,10 @@ class StringBaseTextGenerator : public TextFormat::BaseTextGenerator {
TextFormat::FieldValuePrinter::FieldValuePrinter() {}
TextFormat::FieldValuePrinter::~FieldValuePrinter() {}
-#if 0 // LANG_CXX11
#define FORWARD_IMPL(fn, ...) \
StringBaseTextGenerator generator; \
delegate_.fn(__VA_ARGS__, &generator); \
return std::move(generator).Consume()
-#else // !LANG_CXX11
-#define FORWARD_IMPL(fn, ...) \
- StringBaseTextGenerator generator; \
- delegate_.fn(__VA_ARGS__, &generator); \
- return generator.Get()
-#endif // LANG_CXX11
TProtoStringType TextFormat::FieldValuePrinter::PrintBool(bool val) const {
FORWARD_IMPL(PrintBool, val);
@@ -1825,27 +1866,27 @@ void TextFormat::FastFieldValuePrinter::PrintBool(
}
void TextFormat::FastFieldValuePrinter::PrintInt32(
arc_i32 val, BaseTextGenerator* generator) const {
- generator->PrintString(StrCat(val));
+ generator->PrintString(y_absl::StrCat(val));
}
void TextFormat::FastFieldValuePrinter::PrintUInt32(
arc_ui32 val, BaseTextGenerator* generator) const {
- generator->PrintString(StrCat(val));
+ generator->PrintString(y_absl::StrCat(val));
}
void TextFormat::FastFieldValuePrinter::PrintInt64(
arc_i64 val, BaseTextGenerator* generator) const {
- generator->PrintString(StrCat(val));
+ generator->PrintString(y_absl::StrCat(val));
}
void TextFormat::FastFieldValuePrinter::PrintUInt64(
arc_ui64 val, BaseTextGenerator* generator) const {
- generator->PrintString(StrCat(val));
+ generator->PrintString(y_absl::StrCat(val));
}
void TextFormat::FastFieldValuePrinter::PrintFloat(
float val, BaseTextGenerator* generator) const {
- generator->PrintString(!std::isnan(val) ? SimpleFtoa(val) : "nan");
+ generator->PrintString(!std::isnan(val) ? io::SimpleFtoa(val) : "nan");
}
void TextFormat::FastFieldValuePrinter::PrintDouble(
double val, BaseTextGenerator* generator) const {
- generator->PrintString(!std::isnan(val) ? SimpleDtoa(val) : "nan");
+ generator->PrintString(!std::isnan(val) ? io::SimpleDtoa(val) : "nan");
}
void TextFormat::FastFieldValuePrinter::PrintEnum(
arc_i32 /*val*/, const TProtoStringType& name,
@@ -1856,7 +1897,7 @@ void TextFormat::FastFieldValuePrinter::PrintEnum(
void TextFormat::FastFieldValuePrinter::PrintString(
const TProtoStringType& val, BaseTextGenerator* generator) const {
generator->PrintLiteral("\"");
- generator->PrintString(CEscape(val));
+ generator->PrintString(y_absl::CEscape(val));
generator->PrintLiteral("\"");
}
void TextFormat::FastFieldValuePrinter::PrintBytes(
@@ -1994,15 +2035,14 @@ class FieldValuePrinterWrapper : public TextFormat::FastFieldValuePrinter {
} // namespace
-const char* const TextFormat::Printer::kDoNotParse =
- "DO NOT PARSE: fields may be stripped and missing.\n";
-
TextFormat::Printer::Printer()
: initial_indent_level_(0),
single_line_mode_(false),
use_field_number_(false),
use_short_repeated_primitives_(false),
insert_silent_marker_(false),
+ redact_debug_string_(false),
+ randomize_debug_string_(false),
hide_unknown_fields_(false),
print_message_fields_in_index_order_(false),
expand_any_(false),
@@ -2033,7 +2073,7 @@ bool TextFormat::Printer::RegisterFieldValuePrinter(
}
std::unique_ptr<FieldValuePrinterWrapper> wrapper(
new FieldValuePrinterWrapper(nullptr));
- auto pair = custom_printers_.insert(std::make_pair(field, nullptr));
+ auto pair = custom_printers_.emplace(field, nullptr);
if (pair.second) {
wrapper->SetDelegate(printer);
pair.first->second = std::move(wrapper);
@@ -2048,7 +2088,7 @@ bool TextFormat::Printer::RegisterFieldValuePrinter(
if (field == nullptr || printer == nullptr) {
return false;
}
- auto pair = custom_printers_.insert(std::make_pair(field, nullptr));
+ auto pair = custom_printers_.emplace(field, nullptr);
if (pair.second) {
pair.first->second.reset(printer);
return true;
@@ -2062,8 +2102,7 @@ bool TextFormat::Printer::RegisterMessagePrinter(
if (descriptor == nullptr || printer == nullptr) {
return false;
}
- auto pair =
- custom_message_printers_.insert(std::make_pair(descriptor, nullptr));
+ auto pair = custom_message_printers_.emplace(descriptor, nullptr);
if (pair.second) {
pair.first->second.reset(printer);
return true;
@@ -2074,7 +2113,7 @@ bool TextFormat::Printer::RegisterMessagePrinter(
bool TextFormat::Printer::PrintToString(const Message& message,
TProtoStringType* output) const {
- GOOGLE_DCHECK(output) << "output specified is nullptr";
+ Y_ABSL_DCHECK(output) << "output specified is nullptr";
output->clear();
io::StringOutputStream output_stream(output);
@@ -2084,7 +2123,7 @@ bool TextFormat::Printer::PrintToString(const Message& message,
bool TextFormat::Printer::PrintUnknownFieldsToString(
const UnknownFieldSet& unknown_fields, TProtoStringType* output) const {
- GOOGLE_DCHECK(output) << "output specified is nullptr";
+ Y_ABSL_DCHECK(output) << "output specified is nullptr";
output->clear();
io::StringOutputStream output_stream(output);
@@ -2095,6 +2134,7 @@ bool TextFormat::Printer::Print(const Message& message,
io::ZeroCopyOutputStream* output) const {
TextGenerator generator(output, insert_silent_marker_, initial_indent_level_);
+
Print(message, &generator);
// Output false if the generator failed internally.
@@ -2137,7 +2177,7 @@ struct FieldIndexSorter {
} // namespace
bool TextFormat::Printer::PrintAny(const Message& message,
- TextGenerator* generator) const {
+ BaseTextGenerator* generator) const {
const FieldDescriptor* type_url_field;
const FieldDescriptor* value_field;
if (!internal::GetAnyFieldDescriptors(message, &type_url_field,
@@ -2160,8 +2200,8 @@ bool TextFormat::Printer::PrintAny(const Message& message,
finder_ ? finder_->FindAnyType(message, url_prefix, full_type_name)
: DefaultFinderFindAnyType(message, url_prefix, full_type_name);
if (value_descriptor == nullptr) {
- GOOGLE_LOG(WARNING) << "Can't print proto content: proto type " << type_url
- << " not found";
+ Y_ABSL_LOG(WARNING) << "Can't print proto content: proto type " << type_url
+ << " not found";
return false;
}
DynamicMessageFactory factory;
@@ -2169,7 +2209,7 @@ bool TextFormat::Printer::PrintAny(const Message& message,
factory.GetPrototype(value_descriptor)->New());
TProtoStringType serialized_value = reflection->GetString(message, value_field);
if (!value_message->ParseFromString(serialized_value)) {
- GOOGLE_LOG(WARNING) << type_url << ": failed to parse contents";
+ Y_ABSL_LOG(WARNING) << type_url << ": failed to parse contents";
return false;
}
generator->PrintLiteral("[");
@@ -2185,7 +2225,7 @@ bool TextFormat::Printer::PrintAny(const Message& message,
}
void TextFormat::Printer::Print(const Message& message,
- TextGenerator* generator) const {
+ BaseTextGenerator* generator) const {
const Reflection* reflection = message.GetReflection();
if (!reflection) {
// This message does not provide any way to describe its structure.
@@ -2205,19 +2245,26 @@ void TextFormat::Printer::Print(const Message& message,
itr->second->Print(message, single_line_mode_, generator);
return;
}
+ PrintMessage(message, generator);
+}
+
+void TextFormat::Printer::PrintMessage(const Message& message,
+ BaseTextGenerator* generator) const {
+ if (generator == nullptr) {
+ return;
+ }
+ const Descriptor* descriptor = message.GetDescriptor();
if (descriptor->full_name() == internal::kAnyFullTypeName && expand_any_ &&
PrintAny(message, generator)) {
return;
}
+ const Reflection* reflection = message.GetReflection();
std::vector<const FieldDescriptor*> fields;
if (descriptor->options().map_entry()) {
fields.push_back(descriptor->field(0));
fields.push_back(descriptor->field(1));
} else {
- reflection->ListFieldsOmitStripped(message, &fields);
- if (reflection->IsMessageStripped(message.GetDescriptor())) {
- generator->Print(kDoNotParse, std::strlen(kDoNotParse));
- }
+ reflection->ListFields(message, &fields);
}
if (print_message_fields_in_index_order_) {
@@ -2236,7 +2283,7 @@ void TextFormat::Printer::PrintFieldValueToString(const Message& message,
const FieldDescriptor* field,
int index,
TProtoStringType* output) const {
- GOOGLE_DCHECK(output) << "output specified is nullptr";
+ Y_ABSL_DCHECK(output) << "output specified is nullptr";
output->clear();
io::StringOutputStream output_stream(output);
@@ -2284,7 +2331,7 @@ class MapEntryMessageComparator {
return first < second;
}
default:
- GOOGLE_LOG(DFATAL) << "Invalid key for map field.";
+ Y_ABSL_DLOG(FATAL) << "Invalid key for map field.";
return true;
}
}
@@ -2296,7 +2343,7 @@ class MapEntryMessageComparator {
namespace internal {
class MapFieldPrinterHelper {
public:
- // DynamicMapSorter::Sort cannot be used because it enfores syncing with
+ // DynamicMapSorter::Sort cannot be used because it enforces syncing with
// repeated field.
static bool SortMap(const Message& message, const Reflection* reflection,
const FieldDescriptor* field,
@@ -2355,7 +2402,7 @@ void MapFieldPrinterHelper::CopyKey(const MapKey& key, Message* message,
case FieldDescriptor::CPPTYPE_FLOAT:
case FieldDescriptor::CPPTYPE_ENUM:
case FieldDescriptor::CPPTYPE_MESSAGE:
- GOOGLE_LOG(ERROR) << "Not supported.";
+ Y_ABSL_LOG(ERROR) << "Not supported.";
break;
case FieldDescriptor::CPPTYPE_STRING:
reflection->SetString(message, field_desc, key.GetStringValue());
@@ -2423,7 +2470,7 @@ void MapFieldPrinterHelper::CopyValue(const MapValueRef& value,
void TextFormat::Printer::PrintField(const Message& message,
const Reflection* reflection,
const FieldDescriptor* field,
- TextGenerator* generator) const {
+ BaseTextGenerator* generator) const {
if (use_short_repeated_primitives_ && field->is_repeated() &&
field->cpp_type() != FieldDescriptor::CPPTYPE_STRING &&
field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) {
@@ -2471,7 +2518,7 @@ void TextFormat::Printer::PrintField(const Message& message,
printer->PrintMessageEnd(sub_message, field_index, count,
single_line_mode_, generator);
} else {
- generator->PrintMaybeWithMarker(": ");
+ generator->PrintMaybeWithMarker(MarkerToken(), ": ");
// Write the field value.
PrintFieldValue(message, reflection, field, field_index, generator);
if (single_line_mode_) {
@@ -2491,12 +2538,12 @@ void TextFormat::Printer::PrintField(const Message& message,
void TextFormat::Printer::PrintShortRepeatedField(
const Message& message, const Reflection* reflection,
- const FieldDescriptor* field, TextGenerator* generator) const {
+ const FieldDescriptor* field, BaseTextGenerator* generator) const {
// Print primitive repeated field in short form.
int size = reflection->FieldSize(message, field);
PrintFieldName(message, /*field_index=*/-1, /*field_count=*/size, reflection,
field, generator);
- generator->PrintMaybeWithMarker(": ", "[");
+ generator->PrintMaybeWithMarker(MarkerToken(), ": ", "[");
for (int i = 0; i < size; i++) {
if (i > 0) generator->PrintLiteral(", ");
PrintFieldValue(message, reflection, field, i, generator);
@@ -2512,11 +2559,11 @@ void TextFormat::Printer::PrintFieldName(const Message& message,
int field_index, int field_count,
const Reflection* reflection,
const FieldDescriptor* field,
- TextGenerator* generator) const {
+ BaseTextGenerator* generator) const {
// if use_field_number_ is true, prints field number instead
// of field name.
if (use_field_number_) {
- generator->PrintString(StrCat(field->number()));
+ generator->PrintString(y_absl::StrCat(field->number()));
return;
}
@@ -2529,11 +2576,16 @@ void TextFormat::Printer::PrintFieldValue(const Message& message,
const Reflection* reflection,
const FieldDescriptor* field,
int index,
- TextGenerator* generator) const {
- GOOGLE_DCHECK(field->is_repeated() || (index == -1))
+ BaseTextGenerator* generator) const {
+ Y_ABSL_DCHECK(field->is_repeated() || (index == -1))
<< "Index must be -1 for non-repeated fields";
const FastFieldValuePrinter* printer = GetFieldPrinter(field);
+ if (redact_debug_string_ && field->options().debug_redact()) {
+ // TODO(b/258975650): Create OSS redaction documentation
+ generator->PrintString("[REDACTED]");
+ return;
+ }
switch (field->cpp_type()) {
#define OUTPUT_FIELD(CPPTYPE, METHOD) \
@@ -2573,7 +2625,7 @@ void TextFormat::Printer::PrintFieldValue(const Message& message,
if (field->type() == FieldDescriptor::TYPE_STRING) {
printer->PrintString(*value_to_print, generator);
} else {
- GOOGLE_DCHECK_EQ(field->type(), FieldDescriptor::TYPE_BYTES);
+ Y_ABSL_DCHECK_EQ(field->type(), FieldDescriptor::TYPE_BYTES);
printer->PrintBytes(*value_to_print, generator);
}
break;
@@ -2595,7 +2647,7 @@ void TextFormat::Printer::PrintFieldValue(const Message& message,
// it is possible for the user to force an unknown integer value. So we
// simply use the integer value itself as the enum value name in this
// case.
- printer->PrintEnum(enum_value, StrCat(enum_value), generator);
+ printer->PrintEnum(enum_value, y_absl::StrCat(enum_value), generator);
}
break;
}
@@ -2641,17 +2693,17 @@ void TextFormat::Printer::PrintFieldValue(const Message& message,
}
void TextFormat::Printer::PrintUnknownFields(
- const UnknownFieldSet& unknown_fields, TextGenerator* generator,
+ const UnknownFieldSet& unknown_fields, BaseTextGenerator* generator,
int recursion_budget) const {
for (int i = 0; i < unknown_fields.field_count(); i++) {
const UnknownField& field = unknown_fields.field(i);
- TProtoStringType field_number = StrCat(field.number());
+ TProtoStringType field_number = y_absl::StrCat(field.number());
switch (field.type()) {
case UnknownField::TYPE_VARINT:
generator->PrintString(field_number);
- generator->PrintMaybeWithMarker(": ");
- generator->PrintString(StrCat(field.varint()));
+ generator->PrintMaybeWithMarker(MarkerToken(), ": ");
+ generator->PrintString(y_absl::StrCat(field.varint()));
if (single_line_mode_) {
generator->PrintLiteral(" ");
} else {
@@ -2660,9 +2712,9 @@ void TextFormat::Printer::PrintUnknownFields(
break;
case UnknownField::TYPE_FIXED32: {
generator->PrintString(field_number);
- generator->PrintMaybeWithMarker(": ", "0x");
+ generator->PrintMaybeWithMarker(MarkerToken(), ": ", "0x");
generator->PrintString(
- StrCat(strings::Hex(field.fixed32(), strings::ZERO_PAD_8)));
+ y_absl::StrCat(y_absl::Hex(field.fixed32(), y_absl::kZeroPad8)));
if (single_line_mode_) {
generator->PrintLiteral(" ");
} else {
@@ -2672,9 +2724,9 @@ void TextFormat::Printer::PrintUnknownFields(
}
case UnknownField::TYPE_FIXED64: {
generator->PrintString(field_number);
- generator->PrintMaybeWithMarker(": ", "0x");
+ generator->PrintMaybeWithMarker(MarkerToken(), ": ", "0x");
generator->PrintString(
- StrCat(strings::Hex(field.fixed64(), strings::ZERO_PAD_16)));
+ y_absl::StrCat(y_absl::Hex(field.fixed64(), y_absl::kZeroPad16)));
if (single_line_mode_) {
generator->PrintLiteral(" ");
} else {
@@ -2697,9 +2749,9 @@ void TextFormat::Printer::PrintUnknownFields(
// This field is parseable as a Message.
// So it is probably an embedded message.
if (single_line_mode_) {
- generator->PrintMaybeWithMarker(" ", "{ ");
+ generator->PrintMaybeWithMarker(MarkerToken(), " ", "{ ");
} else {
- generator->PrintMaybeWithMarker(" ", "{\n");
+ generator->PrintMaybeWithMarker(MarkerToken(), " ", "{\n");
generator->Indent();
}
PrintUnknownFields(embedded_unknown_fields, generator,
@@ -2713,8 +2765,8 @@ void TextFormat::Printer::PrintUnknownFields(
} else {
// This field is not parseable as a Message (or we ran out of
// recursion budget). So it is probably just a plain string.
- generator->PrintMaybeWithMarker(": ", "\"");
- generator->PrintString(CEscape(value));
+ generator->PrintMaybeWithMarker(MarkerToken(), ": ", "\"");
+ generator->PrintString(y_absl::CEscape(value));
if (single_line_mode_) {
generator->PrintLiteral("\" ");
} else {
@@ -2726,9 +2778,9 @@ void TextFormat::Printer::PrintUnknownFields(
case UnknownField::TYPE_GROUP:
generator->PrintString(field_number);
if (single_line_mode_) {
- generator->PrintMaybeWithMarker(" ", "{ ");
+ generator->PrintMaybeWithMarker(MarkerToken(), " ", "{ ");
} else {
- generator->PrintMaybeWithMarker(" ", "{\n");
+ generator->PrintMaybeWithMarker(MarkerToken(), " ", "{\n");
generator->Indent();
}
// For groups, we recurse without checking the budget. This is OK,
@@ -2749,4 +2801,4 @@ void TextFormat::Printer::PrintUnknownFields(
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protobuf/src/google/protobuf/text_format.h b/contrib/libs/protobuf/src/google/protobuf/text_format.h
index 287555767ee..304a6611052 100644
--- a/contrib/libs/protobuf/src/google/protobuf/text_format.h
+++ b/contrib/libs/protobuf/src/google/protobuf/text_format.h
@@ -38,20 +38,22 @@
#ifndef GOOGLE_PROTOBUF_TEXT_FORMAT_H__
#define GOOGLE_PROTOBUF_TEXT_FORMAT_H__
-
-#include <map>
+#include <atomic>
#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"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/strings/string_view.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>
+#include "google/protobuf/port_def.inc"
#ifdef SWIG
#error "You cannot SWIG proto headers"
@@ -63,6 +65,11 @@ namespace protobuf {
namespace internal {
PROTOBUF_EXPORT extern const char kDebugStringSilentMarker[1];
PROTOBUF_EXPORT extern const char kDebugStringSilentMarkerForDetection[3];
+
+PROTOBUF_EXPORT extern std::atomic<bool> enable_debug_text_redaction_marker;
+PROTOBUF_EXPORT extern std::atomic<bool> enable_debug_text_random_marker;
+PROTOBUF_EXPORT extern std::atomic<bool> enable_debug_text_format_marker;
+
} // namespace internal
namespace io {
@@ -76,6 +83,9 @@ class ErrorCollector; // tokenizer.h
// This class is really a namespace that contains only static methods.
class PROTOBUF_EXPORT TextFormat {
public:
+ TextFormat(const TextFormat&) = delete;
+ TextFormat& operator=(const TextFormat&) = delete;
+
// Outputs a textual representation of the given message to the given
// output stream. Returns false if printing fails.
static bool Print(const Message& message, io::ZeroCopyOutputStream* output);
@@ -104,7 +114,22 @@ class PROTOBUF_EXPORT TextFormat {
const FieldDescriptor* field, int index,
TProtoStringType* output);
+ // Forward declare `Printer` for `BaseTextGenerator::MarkerToken` which
+ // restricts some methods of `BaseTextGenerator` to the class `Printer`.
+ class Printer;
+
class PROTOBUF_EXPORT BaseTextGenerator {
+ private:
+ // Passkey (go/totw/134#what-about-stdshared-ptr) that allows `Printer`
+ // (but not derived classes) to call `PrintMaybeWithMarker` and its
+ // `Printer::TextGenerator` to overload it.
+ // This prevents users from bypassing the marker generation.
+ class MarkerToken {
+ private:
+ explicit MarkerToken() = default; // 'explicit' prevents aggregate init.
+ friend class Printer;
+ };
+
public:
virtual ~BaseTextGenerator();
@@ -122,6 +147,20 @@ class PROTOBUF_EXPORT TextFormat {
void PrintLiteral(const char (&text)[n]) {
Print(text, n - 1); // n includes the terminating zero character.
}
+
+ // Internal to Printer, access regulated by `MarkerToken`.
+ virtual void PrintMaybeWithMarker(MarkerToken, y_absl::string_view text) {
+ Print(text.data(), text.size());
+ }
+
+ // Internal to Printer, access regulated by `MarkerToken`.
+ virtual void PrintMaybeWithMarker(MarkerToken, y_absl::string_view text_head,
+ y_absl::string_view text_tail) {
+ Print(text_head.data(), text_head.size());
+ Print(text_tail.data(), text_tail.size());
+ }
+
+ friend class Printer;
};
// The default printer that converts scalar values from fields into their
@@ -131,6 +170,8 @@ class PROTOBUF_EXPORT TextFormat {
class PROTOBUF_EXPORT FastFieldValuePrinter {
public:
FastFieldValuePrinter();
+ FastFieldValuePrinter(const FastFieldValuePrinter&) = delete;
+ FastFieldValuePrinter& operator=(const FastFieldValuePrinter&) = delete;
virtual ~FastFieldValuePrinter();
virtual void PrintBool(bool val, BaseTextGenerator* generator) const;
virtual void PrintInt32(arc_i32 val, BaseTextGenerator* generator) const;
@@ -167,15 +208,14 @@ class PROTOBUF_EXPORT TextFormat {
virtual void PrintMessageEnd(const Message& message, int field_index,
int field_count, bool single_line_mode,
BaseTextGenerator* generator) const;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FastFieldValuePrinter);
};
// Deprecated: please use FastFieldValuePrinter instead.
class PROTOBUF_EXPORT FieldValuePrinter {
public:
FieldValuePrinter();
+ FieldValuePrinter(const FieldValuePrinter&) = delete;
+ FieldValuePrinter& operator=(const FieldValuePrinter&) = delete;
virtual ~FieldValuePrinter();
virtual TProtoStringType PrintBool(bool val) const;
virtual TProtoStringType PrintInt32(arc_i32 val) const;
@@ -199,18 +239,16 @@ class PROTOBUF_EXPORT TextFormat {
private:
FastFieldValuePrinter delegate_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldValuePrinter);
};
class PROTOBUF_EXPORT MessagePrinter {
public:
MessagePrinter() {}
+ MessagePrinter(const MessagePrinter&) = delete;
+ MessagePrinter& operator=(const MessagePrinter&) = delete;
virtual ~MessagePrinter() {}
virtual void Print(const Message& message, bool single_line_mode,
BaseTextGenerator* generator) const = 0;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessagePrinter);
};
// Interface that Printers or Parsers can use to find extensions, or types
@@ -371,17 +409,38 @@ class PROTOBUF_EXPORT TextFormat {
bool RegisterMessagePrinter(const Descriptor* descriptor,
const MessagePrinter* printer);
+ // Default printing for messages, which allows registered message printers
+ // to fall back to default printing without losing the ability to control
+ // sub-messages or fields.
+ // NOTE: If the passed in `text_generaor` is not actually the current
+ // `TextGenerator`, then no output will be produced.
+ void PrintMessage(const Message& message,
+ BaseTextGenerator* generator) const;
+
private:
friend TProtoStringType Message::DebugString() const;
friend TProtoStringType Message::ShortDebugString() const;
friend TProtoStringType Message::Utf8DebugString() const;
+ friend void internal::PerformAbslStringify(
+ const Message& message,
+ y_absl::FunctionRef<void(y_absl::string_view)> append);
- // Sets whether *DebugString should insert a silent marker.
+ // Sets whether silent markers will be inserted.
void SetInsertSilentMarker(bool v) { insert_silent_marker_ = v; }
+ // Sets whether strings will be redacted and thus unparsable.
+ void SetRedactDebugString(bool redact) { redact_debug_string_ = redact; }
+
+ // Sets whether the output string should be made non-deterministic.
+ // This discourages equality checks based on serialized string comparisons.
+ void SetRandomizeDebugString(bool randomize) {
+ randomize_debug_string_ = randomize;
+ }
+
// Forward declaration of an internal class used to print the text
// output to the OutputStream (see text_format.cc for implementation).
class TextGenerator;
+ using MarkerToken = BaseTextGenerator::MarkerToken;
// Forward declaration of an internal class used to print field values for
// DebugString APIs (see text_format.cc for implementation).
@@ -391,44 +450,42 @@ class PROTOBUF_EXPORT TextFormat {
// strings (see text_format.cc for implementation).
class FastFieldValuePrinterUtf8Escaping;
- static const char* const kDoNotParse;
-
// Internal Print method, used for writing to the OutputStream via
// the TextGenerator class.
- void Print(const Message& message, TextGenerator* generator) const;
+ void Print(const Message& message, BaseTextGenerator* generator) const;
// Print a single field.
void PrintField(const Message& message, const Reflection* reflection,
const FieldDescriptor* field,
- TextGenerator* generator) const;
+ BaseTextGenerator* generator) const;
// Print a repeated primitive field in short form.
void PrintShortRepeatedField(const Message& message,
const Reflection* reflection,
const FieldDescriptor* field,
- TextGenerator* generator) const;
+ BaseTextGenerator* generator) const;
// Print the name of a field -- i.e. everything that comes before the
// ':' for a single name/value pair.
void PrintFieldName(const Message& message, int field_index,
int field_count, const Reflection* reflection,
const FieldDescriptor* field,
- TextGenerator* generator) const;
+ BaseTextGenerator* generator) const;
// Outputs a textual representation of the value of the field supplied on
// the message supplied or the default value if not set.
void PrintFieldValue(const Message& message, const Reflection* reflection,
const FieldDescriptor* field, int index,
- TextGenerator* generator) const;
+ BaseTextGenerator* generator) const;
// Print the fields in an UnknownFieldSet. They are printed by tag number
// only. Embedded messages are heuristically identified by attempting to
// parse them (subject to the recursion budget).
void PrintUnknownFields(const UnknownFieldSet& unknown_fields,
- TextGenerator* generator,
+ BaseTextGenerator* generator,
int recursion_budget) const;
- bool PrintAny(const Message& message, TextGenerator* generator) const;
+ bool PrintAny(const Message& message, BaseTextGenerator* generator) const;
const FastFieldValuePrinter* GetFieldPrinter(
const FieldDescriptor* field) const {
@@ -442,20 +499,21 @@ class PROTOBUF_EXPORT TextFormat {
bool use_field_number_;
bool use_short_repeated_primitives_;
bool insert_silent_marker_;
+ bool redact_debug_string_;
+ bool randomize_debug_string_;
bool hide_unknown_fields_;
bool print_message_fields_in_index_order_;
bool expand_any_;
arc_i64 truncate_string_field_longer_than_;
std::unique_ptr<const FastFieldValuePrinter> default_field_value_printer_;
- typedef std::map<const FieldDescriptor*,
- std::unique_ptr<const FastFieldValuePrinter>>
- CustomPrinterMap;
- CustomPrinterMap custom_printers_;
+ y_absl::flat_hash_map<const FieldDescriptor*,
+ std::unique_ptr<const FastFieldValuePrinter>>
+ custom_printers_;
- typedef std::map<const Descriptor*, std::unique_ptr<const MessagePrinter>>
- CustomMessagePrinterMap;
- CustomMessagePrinterMap custom_message_printers_;
+ y_absl::flat_hash_map<const Descriptor*,
+ std::unique_ptr<const MessagePrinter>>
+ custom_message_printers_;
const Finder* finder_;
};
@@ -476,13 +534,13 @@ class PROTOBUF_EXPORT TextFormat {
// google::protobuf::MessageLite::ParseFromString().
static bool Parse(io::ZeroCopyInputStream* input, Message* output);
// Like Parse(), but reads directly from a string.
- static bool ParseFromString(ConstStringParam input, Message* output);
+ static bool ParseFromString(y_absl::string_view input, Message* output);
// Like Parse(), but the data is merged into the given message, as if
// using Message::MergeFrom().
static bool Merge(io::ZeroCopyInputStream* input, Message* output);
// Like Merge(), but reads directly from a string.
- static bool MergeFromString(ConstStringParam input, Message* output);
+ static bool MergeFromString(y_absl::string_view input, Message* output);
// Parse the given text as a single field value and store it into the
// given field of the given message. If the field is a repeated field,
@@ -549,17 +607,13 @@ class PROTOBUF_EXPORT TextFormat {
ParseInfoTree* CreateNested(const FieldDescriptor* field);
// Defines the map from the index-th field descriptor to its parse location.
- typedef std::map<const FieldDescriptor*, std::vector<ParseLocationRange>>
- LocationMap;
-
+ y_absl::flat_hash_map<const FieldDescriptor*, std::vector<ParseLocationRange>>
+ locations_;
// Defines the map from the index-th field descriptor to the nested parse
// info tree.
- typedef std::map<const FieldDescriptor*,
- std::vector<std::unique_ptr<ParseInfoTree>>>
- NestedMap;
-
- LocationMap locations_;
- NestedMap nested_;
+ y_absl::flat_hash_map<const FieldDescriptor*,
+ std::vector<std::unique_ptr<ParseInfoTree>>>
+ nested_;
};
// For more control over parsing, use this class.
@@ -571,11 +625,11 @@ class PROTOBUF_EXPORT TextFormat {
// Like TextFormat::Parse().
bool Parse(io::ZeroCopyInputStream* input, Message* output);
// Like TextFormat::ParseFromString().
- bool ParseFromString(ConstStringParam input, Message* output);
+ bool ParseFromString(y_absl::string_view input, Message* output);
// Like TextFormat::Merge().
bool Merge(io::ZeroCopyInputStream* input, Message* output);
// Like TextFormat::MergeFromString().
- bool MergeFromString(ConstStringParam input, Message* output);
+ bool MergeFromString(y_absl::string_view input, Message* output);
// Set where to report parse errors. If nullptr (the default), errors will
// be printed to stderr.
@@ -670,10 +724,9 @@ class PROTOBUF_EXPORT TextFormat {
ParseLocationRange location);
static inline ParseInfoTree* CreateNested(ParseInfoTree* info_tree,
const FieldDescriptor* field);
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TextFormat);
};
+
inline void TextFormat::RecordLocation(ParseInfoTree* info_tree,
const FieldDescriptor* field,
ParseLocationRange location) {
@@ -688,6 +741,6 @@ inline TextFormat::ParseInfoTree* TextFormat::CreateNested(
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_TEXT_FORMAT_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/thread_safe_arena.h b/contrib/libs/protobuf/src/google/protobuf/thread_safe_arena.h
new file mode 100644
index 00000000000..4d738d0f959
--- /dev/null
+++ b/contrib/libs/protobuf/src/google/protobuf/thread_safe_arena.h
@@ -0,0 +1,290 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2022 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.
+//
+// This file defines the internal class ThreadSafeArena
+
+#ifndef GOOGLE_PROTOBUF_THREAD_SAFE_ARENA_H__
+#define GOOGLE_PROTOBUF_THREAD_SAFE_ARENA_H__
+
+#include <algorithm>
+#include <atomic>
+#include <string>
+#include <type_traits>
+#include <utility>
+
+#include "y_absl/synchronization/mutex.h"
+#include "google/protobuf/arena_align.h"
+#include "google/protobuf/arena_allocation_policy.h"
+#include "google/protobuf/arena_cleanup.h"
+#include "google/protobuf/arena_config.h"
+#include "google/protobuf/arenaz_sampler.h"
+#include "google/protobuf/port.h"
+#include "google/protobuf/serial_arena.h"
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace internal {
+
+// This class provides the core Arena memory allocation library. Different
+// implementations only need to implement the public interface below.
+// Arena is not a template type as that would only be useful if all protos
+// in turn would be templates, which will/cannot happen. However separating
+// the memory allocation part from the cruft of the API users expect we can
+// use #ifdef the select the best implementation based on hardware / OS.
+class PROTOBUF_EXPORT ThreadSafeArena {
+ public:
+ ThreadSafeArena();
+
+ ThreadSafeArena(char* mem, size_t size);
+
+ explicit ThreadSafeArena(void* mem, size_t size,
+ const AllocationPolicy& policy);
+
+ // All protos have pointers back to the arena hence Arena must have
+ // pointer stability.
+ ThreadSafeArena(const ThreadSafeArena&) = delete;
+ ThreadSafeArena& operator=(const ThreadSafeArena&) = delete;
+ ThreadSafeArena(ThreadSafeArena&&) = delete;
+ ThreadSafeArena& operator=(ThreadSafeArena&&) = delete;
+
+ // Destructor deletes all owned heap allocated objects, and destructs objects
+ // that have non-trivial destructors, except for proto2 message objects whose
+ // destructors can be skipped. Also, frees all blocks except the initial block
+ // if it was passed in.
+ ~ThreadSafeArena();
+
+ arc_ui64 Reset();
+
+ arc_ui64 SpaceAllocated() const;
+ arc_ui64 SpaceUsed() const;
+
+ template <AllocationClient alloc_client = AllocationClient::kDefault>
+ void* AllocateAligned(size_t n) {
+ SerialArena* arena;
+ if (PROTOBUF_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
+ return arena->AllocateAligned<alloc_client>(n);
+ } else {
+ return AllocateAlignedFallback<alloc_client>(n);
+ }
+ }
+
+ 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
+ // have fallback function calls in tail position. This substantially improves
+ // code for the happy path.
+ PROTOBUF_NDEBUG_INLINE bool MaybeAllocateAligned(size_t n, void** out) {
+ SerialArena* arena;
+ if (PROTOBUF_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
+ return arena->MaybeAllocateAligned(n, out);
+ }
+ return false;
+ }
+
+ void* AllocateAlignedWithCleanup(size_t n, size_t align,
+ void (*destructor)(void*));
+
+ // Add object pointer and cleanup function pointer to the list.
+ void AddCleanup(void* elem, void (*cleanup)(void*));
+
+ void* AllocateFromStringBlock();
+
+ private:
+ friend class ArenaBenchmark;
+ friend class TcParser;
+ friend class SerialArena;
+ friend struct SerialArenaChunkHeader;
+ static arc_ui64 GetNextLifeCycleId();
+
+ class SerialArenaChunk;
+
+ // Returns a new SerialArenaChunk that has {id, serial} at slot 0. It may
+ // grow based on "prev_num_slots".
+ static SerialArenaChunk* NewSerialArenaChunk(arc_ui32 prev_capacity, void* id,
+ SerialArena* serial);
+ static SerialArenaChunk* SentrySerialArenaChunk();
+
+ // Returns the first ArenaBlock* for the first SerialArena. If users provide
+ // one, use it if it's acceptable. Otherwise returns a sentry block.
+ ArenaBlock* FirstBlock(void* buf, size_t size);
+ // Same as the above but returns a valid block if "policy" is not default.
+ ArenaBlock* FirstBlock(void* buf, size_t size,
+ const AllocationPolicy& policy);
+
+ // Adds SerialArena to the chunked list. May create a new chunk.
+ void AddSerialArena(void* id, SerialArena* serial);
+
+ // Members are declared here to track sizeof(ThreadSafeArena) and hotness
+ // centrally.
+
+ // Unique for each arena. Changes on Reset().
+ arc_ui64 tag_and_id_ = 0;
+
+ TaggedAllocationPolicyPtr alloc_policy_; // Tagged pointer to AllocPolicy.
+ ThreadSafeArenaStatsHandle arena_stats_;
+
+ // Adding a new chunk to head_ must be protected by mutex_.
+ y_absl::Mutex mutex_;
+ // Pointer to a linked list of SerialArenaChunk.
+ std::atomic<SerialArenaChunk*> head_{nullptr};
+
+ void* first_owner_;
+ // Must be declared after alloc_policy_; otherwise, it may lose info on
+ // user-provided initial block.
+ SerialArena first_arena_;
+
+ static_assert(std::is_trivially_destructible<SerialArena>{},
+ "SerialArena needs to be trivially destructible.");
+
+ const AllocationPolicy* AllocPolicy() const { return alloc_policy_.get(); }
+ void InitializeWithPolicy(const AllocationPolicy& policy);
+ void* AllocateAlignedWithCleanupFallback(size_t n, size_t align,
+ void (*destructor)(void*));
+
+ void Init();
+
+ // Delete or Destruct all objects owned by the arena.
+ void CleanupList();
+
+ inline void CacheSerialArena(SerialArena* serial) {
+ thread_cache().last_serial_arena = serial;
+ thread_cache().last_lifecycle_id_seen = tag_and_id_;
+ }
+
+ PROTOBUF_NDEBUG_INLINE bool GetSerialArenaFast(SerialArena** arena) {
+ // If this thread already owns a block in this arena then try to use that.
+ // This fast path optimizes the case where multiple threads allocate from
+ // the same arena.
+ ThreadCache* tc = &thread_cache();
+ if (PROTOBUF_PREDICT_TRUE(tc->last_lifecycle_id_seen == tag_and_id_)) {
+ *arena = tc->last_serial_arena;
+ return true;
+ }
+ return false;
+ }
+
+ // Finds SerialArena or creates one if not found. When creating a new one,
+ // create a big enough block to accommodate n bytes.
+ SerialArena* GetSerialArenaFallback(size_t n);
+
+ template <AllocationClient alloc_client = AllocationClient::kDefault>
+ void* AllocateAlignedFallback(size_t n);
+
+ // Executes callback function over SerialArenaChunk. Passes const
+ // SerialArenaChunk*.
+ template <typename Functor>
+ void WalkConstSerialArenaChunk(Functor fn) const;
+
+ // Executes callback function over SerialArenaChunk.
+ template <typename Functor>
+ void WalkSerialArenaChunk(Functor fn);
+
+ // Executes callback function over SerialArena in chunked list in reverse
+ // chronological order. Passes const SerialArena*.
+ template <typename Functor>
+ void PerConstSerialArenaInChunk(Functor fn) const;
+
+ // Releases all memory except the first block which it returns. The first
+ // block might be owned by the user and thus need some extra checks before
+ // deleting.
+ SizedPtr Free(size_t* space_allocated);
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4324)
+#endif
+ struct alignas(kCacheAlignment) ThreadCache {
+ // Number of per-thread lifecycle IDs to reserve. Must be power of two.
+ // To reduce contention on a global atomic, each thread reserves a batch of
+ // IDs. The following number is calculated based on a stress test with
+ // ~6500 threads all frequently allocating a new arena.
+ static constexpr size_t kPerThreadIds = 256;
+ // Next lifecycle ID available to this thread. We need to reserve a new
+ // batch, if `next_lifecycle_id & (kPerThreadIds - 1) == 0`.
+ arc_ui64 next_lifecycle_id{0};
+ // The ThreadCache is considered valid as long as this matches the
+ // lifecycle_id of the arena being used.
+ arc_ui64 last_lifecycle_id_seen{static_cast<arc_ui64>(-1)};
+ SerialArena* last_serial_arena{nullptr};
+ };
+
+ // Lifecycle_id can be highly contended variable in a situation of lots of
+ // arena creation. Make sure that other global variables are not sharing the
+ // cacheline.
+#ifdef _MSC_VER
+#pragma warning(disable : 4324)
+#endif
+ using LifecycleId = arc_ui64;
+ alignas(kCacheAlignment) Y_ABSL_CONST_INIT
+ static std::atomic<LifecycleId> lifecycle_id_;
+#if defined(PROTOBUF_NO_THREADLOCAL)
+ // iOS does not support __thread keyword so we use a custom thread local
+ // storage class we implemented.
+ static ThreadCache& thread_cache();
+#elif defined(PROTOBUF_USE_DLLS)
+ // Thread local variables cannot be exposed through DLL interface but we can
+ // wrap them in static functions.
+ static ThreadCache& thread_cache();
+#else
+ PROTOBUF_CONSTINIT static PROTOBUF_THREAD_LOCAL ThreadCache thread_cache_;
+ static ThreadCache& thread_cache() { return thread_cache_; }
+#endif
+
+ public:
+ // kBlockHeaderSize is sizeof(ArenaBlock), aligned up to the nearest multiple
+ // of 8 to protect the invariant that pos is always at a multiple of 8.
+ static constexpr size_t kBlockHeaderSize = SerialArena::kBlockHeaderSize;
+ static constexpr size_t kSerialArenaSize =
+ (sizeof(SerialArena) + 7) & static_cast<size_t>(-8);
+ static constexpr size_t kAllocPolicySize =
+ ArenaAlignDefault::Ceil(sizeof(AllocationPolicy));
+ static constexpr size_t kMaxCleanupNodeSize = 16;
+ static_assert(kBlockHeaderSize % 8 == 0,
+ "kBlockHeaderSize must be a multiple of 8.");
+ static_assert(kSerialArenaSize % 8 == 0,
+ "kSerialArenaSize must be a multiple of 8.");
+};
+
+} // namespace internal
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_THREAD_SAFE_ARENA_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/timestamp.pb.cc b/contrib/libs/protobuf/src/google/protobuf/timestamp.pb.cc
index 53d479307de..33ee0760963 100644
--- a/contrib/libs/protobuf/src/google/protobuf/timestamp.pb.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/timestamp.pb.cc
@@ -1,122 +1,139 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/timestamp.proto
-#include <google/protobuf/timestamp.pb.h>
+#include "google/protobuf/timestamp.pb.h"
#include <algorithm>
-
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/extension_set.h>
-#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/reflection_ops.h>
-#include <google/protobuf/wire_format.h>
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/extension_set.h"
+#include "google/protobuf/wire_format_lite.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/reflection_ops.h"
+#include "google/protobuf/wire_format.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+// Must be included last.
+#include "google/protobuf/port_def.inc"
PROTOBUF_PRAGMA_INIT_SEG
-
namespace _pb = ::PROTOBUF_NAMESPACE_ID;
-namespace _pbi = _pb::internal;
-
+namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal;
PROTOBUF_NAMESPACE_OPEN
PROTOBUF_CONSTEXPR Timestamp::Timestamp(
::_pbi::ConstantInitialized): _impl_{
- /*decltype(_impl_.seconds_)*/arc_i64{0}
- , /*decltype(_impl_.nanos_)*/0
+ /*decltype(_impl_.seconds_)*/ ::arc_i64{0}
+
+ , /*decltype(_impl_.nanos_)*/ 0
+
, /*decltype(_impl_._cached_size_)*/{}} {}
struct TimestampDefaultTypeInternal {
- PROTOBUF_CONSTEXPR TimestampDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR TimestampDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~TimestampDefaultTypeInternal() {}
union {
Timestamp _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 TimestampDefaultTypeInternal _Timestamp_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 TimestampDefaultTypeInternal _Timestamp_default_instance_;
PROTOBUF_NAMESPACE_CLOSE
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_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Timestamp, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Timestamp, _impl_.seconds_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Timestamp, _impl_.nanos_),
+static constexpr const ::_pb::EnumDescriptor**
+ file_level_enum_descriptors_google_2fprotobuf_2ftimestamp_2eproto = nullptr;
+static constexpr const ::_pb::ServiceDescriptor**
+ 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_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Timestamp, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Timestamp, _impl_.seconds_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Timestamp, _impl_.nanos_),
};
-static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
- { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Timestamp)},
+
+static const ::_pbi::MigrationSchema
+ schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Timestamp)},
};
static const ::_pb::Message* const file_default_instances[] = {
- &::PROTOBUF_NAMESPACE_ID::_Timestamp_default_instance_._instance,
+ &::PROTOBUF_NAMESPACE_ID::_Timestamp_default_instance_._instance,
};
-
-const char descriptor_table_protodef_google_2fprotobuf_2ftimestamp_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
- "\n\037google/protobuf/timestamp.proto\022\017googl"
- "e.protobuf\"+\n\tTimestamp\022\017\n\007seconds\030\001 \001(\003"
- "\022\r\n\005nanos\030\002 \001(\005B\205\001\n\023com.google.protobufB"
- "\016TimestampProtoP\001Z2google.golang.org/pro"
- "tobuf/types/known/timestamppb\370\001\001\242\002\003GPB\252\002"
- "\036Google.Protobuf.WellKnownTypesb\006proto3"
- ;
-static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_once;
+const char descriptor_table_protodef_google_2fprotobuf_2ftimestamp_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ "\n\037google/protobuf/timestamp.proto\022\017googl"
+ "e.protobuf\"+\n\tTimestamp\022\017\n\007seconds\030\001 \001(\003"
+ "\022\r\n\005nanos\030\002 \001(\005B\205\001\n\023com.google.protobufB"
+ "\016TimestampProtoP\001Z2google.golang.org/pro"
+ "tobuf/types/known/timestamppb\370\001\001\242\002\003GPB\252\002"
+ "\036Google.Protobuf.WellKnownTypesb\006proto3"
+};
+static ::y_absl::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,
+ 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,
+ &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,
};
+
+// This function exists to be marked as weak.
+// It can significantly speed up compilation by breaking up LLVM's SCC
+// in the .pb.cc translation units. Large translation units see a
+// reduction of more than 35% of walltime for optimized builds. Without
+// the weak attribute all the messages in the file, including all the
+// vtables and everything they use become part of the same SCC through
+// a cycle like:
+// GetMetadata -> descriptor table -> default instances ->
+// 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 ::_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_PRIORITY2 static ::_pbi::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
-
// ===================================================================
class Timestamp::_Internal {
public:
};
-Timestamp::Timestamp(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+Timestamp::Timestamp(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Timestamp)
}
Timestamp::Timestamp(const Timestamp& from)
- : ::PROTOBUF_NAMESPACE_ID::Message() {
- Timestamp* const _this = this; (void)_this;
- new (&_impl_) Impl_{
- decltype(_impl_.seconds_){}
- , decltype(_impl_.nanos_){}
- , /*decltype(_impl_._cached_size_)*/{}};
-
- _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- ::memcpy(&_impl_.seconds_, &from._impl_.seconds_,
- static_cast<size_t>(reinterpret_cast<char*>(&_impl_.nanos_) -
- reinterpret_cast<char*>(&_impl_.seconds_)) + sizeof(_impl_.nanos_));
+ : ::PROTOBUF_NAMESPACE_ID::Message(), _impl_(from._impl_) {
+ _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(
+ from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:google.protobuf.Timestamp)
}
-inline void Timestamp::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void Timestamp::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
- decltype(_impl_.seconds_){arc_i64{0}}
- , decltype(_impl_.nanos_){0}
+ decltype(_impl_.seconds_) { ::arc_i64{0} }
+
+ , decltype(_impl_.nanos_) { 0 }
+
, /*decltype(_impl_._cached_size_)*/{}
};
}
@@ -131,7 +148,7 @@ Timestamp::~Timestamp() {
}
inline void Timestamp::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
}
void Timestamp::SetCachedSize(int size) const {
@@ -140,11 +157,11 @@ void Timestamp::SetCachedSize(int size) const {
void Timestamp::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Timestamp)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
- ::memset(&_impl_.seconds_, 0, static_cast<size_t>(
+ ::memset(&_impl_.seconds_, 0, static_cast<::size_t>(
reinterpret_cast<char*>(&_impl_.nanos_) -
reinterpret_cast<char*>(&_impl_.seconds_)) + sizeof(_impl_.nanos_));
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
@@ -153,24 +170,26 @@ void Timestamp::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// int64 seconds = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) {
_impl_.seconds_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// int32 nanos = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 16)) {
_impl_.nanos_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -195,22 +214,24 @@ failure:
#undef CHK_
}
-uint8_t* Timestamp::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* Timestamp::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Timestamp)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// int64 seconds = 1;
if (this->_internal_seconds() != 0) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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 = ::_pbi::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())) {
@@ -221,22 +242,24 @@ uint8_t* Timestamp::_InternalSerialize(
return target;
}
-size_t Timestamp::ByteSizeLong() const {
+::size_t Timestamp::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Timestamp)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// int64 seconds = 1;
if (this->_internal_seconds() != 0) {
- total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_seconds());
+ total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(
+ this->_internal_seconds());
}
// int32 nanos = 2;
if (this->_internal_nanos() != 0) {
- total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_nanos());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(
+ this->_internal_nanos());
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -253,8 +276,8 @@ void Timestamp::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROT
auto* const _this = static_cast<Timestamp*>(&to_msg);
auto& from = static_cast<const Timestamp&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Timestamp)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
if (from._internal_seconds() != 0) {
@@ -293,7 +316,6 @@ void Timestamp::InternalSwap(Timestamp* other) {
&descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_once,
file_level_metadata_google_2fprotobuf_2ftimestamp_2eproto[0]);
}
-
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
@@ -302,6 +324,5 @@ Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Timestamp >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Timestamp >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
-
// @@protoc_insertion_point(global_scope)
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protobuf/src/google/protobuf/timestamp.pb.h b/contrib/libs/protobuf/src/google/protobuf/timestamp.pb.h
index 5afc0a69128..c0b9b7cfafe 100644
--- a/contrib/libs/protobuf/src/google/protobuf/timestamp.pb.h
+++ b/contrib/libs/protobuf/src/google/protobuf/timestamp.pb.h
@@ -1,38 +1,43 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/timestamp.proto
-#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2ftimestamp_2eproto
-#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2ftimestamp_2eproto
+#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2ftimestamp_2eproto_2epb_2eh
+#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2ftimestamp_2eproto_2epb_2eh
#include <limits>
#include <string>
-
-#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3021000
-#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 3021003 < 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.
-#endif
-
-#include <google/protobuf/port_undef.inc>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/arena.h>
-#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_util.h>
-#include <google/protobuf/metadata_lite.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h> // IWYU pragma: export
-#include <google/protobuf/extension_set.h> // IWYU pragma: export
-#include <google/protobuf/unknown_field_set.h>
+#include <type_traits>
+
+#include "google/protobuf/port_def.inc"
+#if PROTOBUF_VERSION < 4022000
+#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 // PROTOBUF_VERSION
+
+#if 4022005 < 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."
+#endif // PROTOBUF_MIN_PROTOC_VERSION
+#include "google/protobuf/port_undef.inc"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/arena.h"
+#include "google/protobuf/arenastring.h"
+#include "google/protobuf/generated_message_util.h"
+#include "google/protobuf/metadata_lite.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/repeated_field.h" // IWYU pragma: export
+#include "google/protobuf/extension_set.h" // IWYU pragma: export
+#include "google/protobuf/unknown_field_set.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2ftimestamp_2eproto PROTOBUF_EXPORT
+
PROTOBUF_NAMESPACE_OPEN
namespace internal {
class AnyMetadata;
@@ -41,21 +46,25 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2ftimestamp_2eproto {
- static const arc_ui32 offsets[];
+ static const ::arc_ui32 offsets[];
};
-PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ftimestamp_2eproto;
+PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable
+ descriptor_table_google_2fprotobuf_2ftimestamp_2eproto;
PROTOBUF_NAMESPACE_OPEN
class Timestamp;
struct TimestampDefaultTypeInternal;
PROTOBUF_EXPORT extern TimestampDefaultTypeInternal _Timestamp_default_instance_;
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Timestamp* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Timestamp>(Arena*);
PROTOBUF_NAMESPACE_CLOSE
-PROTOBUF_NAMESPACE_OPEN
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Timestamp* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Timestamp>(Arena*);
-PROTOBUF_NAMESPACE_CLOSE
+
PROTOBUF_NAMESPACE_OPEN
// ===================================================================
+
+// -------------------------------------------------------------------
+
class PROTOBUF_EXPORT Timestamp final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Timestamp) */ {
public:
@@ -124,7 +133,7 @@ class PROTOBUF_EXPORT Timestamp final :
}
void UnsafeArenaSwap(Timestamp* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -145,26 +154,25 @@ class PROTOBUF_EXPORT Timestamp final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(Timestamp* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.Timestamp";
}
protected:
- explicit Timestamp(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit Timestamp(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -181,23 +189,25 @@ class PROTOBUF_EXPORT Timestamp final :
kNanosFieldNumber = 2,
};
// int64 seconds = 1;
- void clear_seconds();
- arc_i64 seconds() const;
- void set_seconds(arc_i64 value);
+ void clear_seconds() ;
+ ::arc_i64 seconds() const;
+ void set_seconds(::arc_i64 value);
+
private:
- arc_i64 _internal_seconds() const;
- void _internal_set_seconds(arc_i64 value);
- public:
+ ::arc_i64 _internal_seconds() const;
+ void _internal_set_seconds(::arc_i64 value);
+ public:
// int32 nanos = 2;
- void clear_nanos();
- arc_i32 nanos() const;
- void set_nanos(arc_i32 value);
+ void clear_nanos() ;
+ ::arc_i32 nanos() const;
+ void set_nanos(::arc_i32 value);
+
private:
- arc_i32 _internal_nanos() const;
- void _internal_set_nanos(arc_i32 value);
- public:
+ ::arc_i32 _internal_nanos() const;
+ void _internal_set_nanos(::arc_i32 value);
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.Timestamp)
private:
class _Internal;
@@ -206,73 +216,80 @@ class PROTOBUF_EXPORT Timestamp final :
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
struct Impl_ {
- arc_i64 seconds_;
- arc_i32 nanos_;
+ ::arc_i64 seconds_;
+ ::arc_i32 nanos_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2ftimestamp_2eproto;
};
+
// ===================================================================
+
+
// ===================================================================
+
#ifdef __GNUC__
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
+// -------------------------------------------------------------------
+
// Timestamp
// int64 seconds = 1;
inline void Timestamp::clear_seconds() {
- _impl_.seconds_ = arc_i64{0};
+ _impl_.seconds_ = ::arc_i64{0};
}
-inline arc_i64 Timestamp::_internal_seconds() const {
- return _impl_.seconds_;
-}
-inline arc_i64 Timestamp::seconds() const {
+inline ::arc_i64 Timestamp::seconds() const {
// @@protoc_insertion_point(field_get:google.protobuf.Timestamp.seconds)
return _internal_seconds();
}
-inline void Timestamp::_internal_set_seconds(arc_i64 value) {
-
- _impl_.seconds_ = value;
-}
-inline void Timestamp::set_seconds(arc_i64 value) {
+inline void Timestamp::set_seconds(::arc_i64 value) {
_internal_set_seconds(value);
// @@protoc_insertion_point(field_set:google.protobuf.Timestamp.seconds)
}
+inline ::arc_i64 Timestamp::_internal_seconds() const {
+ return _impl_.seconds_;
+}
+inline void Timestamp::_internal_set_seconds(::arc_i64 value) {
+ ;
+ _impl_.seconds_ = value;
+}
// int32 nanos = 2;
inline void Timestamp::clear_nanos() {
_impl_.nanos_ = 0;
}
-inline arc_i32 Timestamp::_internal_nanos() const {
- return _impl_.nanos_;
-}
-inline arc_i32 Timestamp::nanos() const {
+inline ::arc_i32 Timestamp::nanos() const {
// @@protoc_insertion_point(field_get:google.protobuf.Timestamp.nanos)
return _internal_nanos();
}
-inline void Timestamp::_internal_set_nanos(arc_i32 value) {
-
- _impl_.nanos_ = value;
-}
-inline void Timestamp::set_nanos(arc_i32 value) {
+inline void Timestamp::set_nanos(::arc_i32 value) {
_internal_set_nanos(value);
// @@protoc_insertion_point(field_set:google.protobuf.Timestamp.nanos)
}
+inline ::arc_i32 Timestamp::_internal_nanos() const {
+ return _impl_.nanos_;
+}
+inline void Timestamp::_internal_set_nanos(::arc_i32 value) {
+ ;
+ _impl_.nanos_ = value;
+}
#ifdef __GNUC__
- #pragma GCC diagnostic pop
+#pragma GCC diagnostic pop
#endif // __GNUC__
// @@protoc_insertion_point(namespace_scope)
-
PROTOBUF_NAMESPACE_CLOSE
+
// @@protoc_insertion_point(global_scope)
-#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2ftimestamp_2eproto
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2ftimestamp_2eproto_2epb_2eh
diff --git a/contrib/libs/protobuf/src/google/protobuf/timestamp.proto b/contrib/libs/protobuf/src/google/protobuf/timestamp.proto
index 3b2df6d9116..2fb527c0c5c 100644
--- a/contrib/libs/protobuf/src/google/protobuf/timestamp.proto
+++ b/contrib/libs/protobuf/src/google/protobuf/timestamp.proto
@@ -32,13 +32,13 @@ syntax = "proto3";
package google.protobuf;
-option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option cc_enable_arenas = true;
option go_package = "google.golang.org/protobuf/types/known/timestamppb";
option java_package = "com.google.protobuf";
option java_outer_classname = "TimestampProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
+option csharp_namespace = "Google.Protobuf.WellKnownTypes";
// A Timestamp represents a point in time independent of any time zone or local
// calendar, encoded as a count of seconds and fractions of seconds at
@@ -90,7 +90,6 @@ option objc_class_prefix = "GPB";
// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
// .setNanos((int) ((millis % 1000) * 1000000)).build();
//
-//
// Example 5: Compute Timestamp from Java `Instant.now()`.
//
// Instant now = Instant.now();
@@ -99,7 +98,6 @@ option objc_class_prefix = "GPB";
// Timestamp.newBuilder().setSeconds(now.getEpochSecond())
// .setNanos(now.getNano()).build();
//
-//
// Example 6: Compute Timestamp from current time in Python.
//
// timestamp = Timestamp()
@@ -132,7 +130,6 @@ option objc_class_prefix = "GPB";
// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
// ) to obtain a formatter capable of generating timestamps in this format.
//
-//
message Timestamp {
// Represents seconds of UTC time since Unix epoch
// 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
diff --git a/contrib/libs/protobuf/src/google/protobuf/type.pb.cc b/contrib/libs/protobuf/src/google/protobuf/type.pb.cc
index 1d31d0c56d4..1de0177b030 100644
--- a/contrib/libs/protobuf/src/google/protobuf/type.pb.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/type.pb.cc
@@ -1,252 +1,321 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/type.proto
-#include <google/protobuf/type.pb.h>
+#include "google/protobuf/type.pb.h"
#include <algorithm>
-
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/extension_set.h>
-#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/reflection_ops.h>
-#include <google/protobuf/wire_format.h>
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/extension_set.h"
+#include "google/protobuf/wire_format_lite.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/reflection_ops.h"
+#include "google/protobuf/wire_format.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+// Must be included last.
+#include "google/protobuf/port_def.inc"
PROTOBUF_PRAGMA_INIT_SEG
-
namespace _pb = ::PROTOBUF_NAMESPACE_ID;
-namespace _pbi = _pb::internal;
-
+namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal;
PROTOBUF_NAMESPACE_OPEN
PROTOBUF_CONSTEXPR Type::Type(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_.fields_)*/{}
, /*decltype(_impl_.oneofs_)*/{}
, /*decltype(_impl_.options_)*/{}
- , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
+ , /*decltype(_impl_.name_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
, /*decltype(_impl_.source_context_)*/nullptr
- , /*decltype(_impl_.syntax_)*/0
+ , /*decltype(_impl_.syntax_)*/ 0
+
, /*decltype(_impl_._cached_size_)*/{}} {}
struct TypeDefaultTypeInternal {
- PROTOBUF_CONSTEXPR TypeDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR TypeDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~TypeDefaultTypeInternal() {}
union {
Type _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 TypeDefaultTypeInternal _Type_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 TypeDefaultTypeInternal _Type_default_instance_;
PROTOBUF_CONSTEXPR Field::Field(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_.options_)*/{}
- , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.type_url_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.json_name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.default_value_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.kind_)*/0
- , /*decltype(_impl_.cardinality_)*/0
- , /*decltype(_impl_.number_)*/0
- , /*decltype(_impl_.oneof_index_)*/0
- , /*decltype(_impl_.packed_)*/false
+ , /*decltype(_impl_.name_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.type_url_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.json_name_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.default_value_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.kind_)*/ 0
+
+ , /*decltype(_impl_.cardinality_)*/ 0
+
+ , /*decltype(_impl_.number_)*/ 0
+
+ , /*decltype(_impl_.oneof_index_)*/ 0
+
+ , /*decltype(_impl_.packed_)*/ false
+
, /*decltype(_impl_._cached_size_)*/{}} {}
struct FieldDefaultTypeInternal {
- PROTOBUF_CONSTEXPR FieldDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR FieldDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~FieldDefaultTypeInternal() {}
union {
Field _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldDefaultTypeInternal _Field_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldDefaultTypeInternal _Field_default_instance_;
PROTOBUF_CONSTEXPR Enum::Enum(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_.enumvalue_)*/{}
, /*decltype(_impl_.options_)*/{}
- , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
+ , /*decltype(_impl_.name_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
, /*decltype(_impl_.source_context_)*/nullptr
- , /*decltype(_impl_.syntax_)*/0
+ , /*decltype(_impl_.syntax_)*/ 0
+
, /*decltype(_impl_._cached_size_)*/{}} {}
struct EnumDefaultTypeInternal {
- PROTOBUF_CONSTEXPR EnumDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR EnumDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~EnumDefaultTypeInternal() {}
union {
Enum _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDefaultTypeInternal _Enum_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDefaultTypeInternal _Enum_default_instance_;
PROTOBUF_CONSTEXPR EnumValue::EnumValue(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_.options_)*/{}
- , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.number_)*/0
+ , /*decltype(_impl_.name_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.number_)*/ 0
+
, /*decltype(_impl_._cached_size_)*/{}} {}
struct EnumValueDefaultTypeInternal {
- PROTOBUF_CONSTEXPR EnumValueDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR EnumValueDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~EnumValueDefaultTypeInternal() {}
union {
EnumValue _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumValueDefaultTypeInternal _EnumValue_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumValueDefaultTypeInternal _EnumValue_default_instance_;
PROTOBUF_CONSTEXPR Option::Option(
::_pbi::ConstantInitialized): _impl_{
- /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
+ /*decltype(_impl_.name_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
, /*decltype(_impl_.value_)*/nullptr
, /*decltype(_impl_._cached_size_)*/{}} {}
struct OptionDefaultTypeInternal {
- PROTOBUF_CONSTEXPR OptionDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR OptionDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~OptionDefaultTypeInternal() {}
union {
Option _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OptionDefaultTypeInternal _Option_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OptionDefaultTypeInternal _Option_default_instance_;
PROTOBUF_NAMESPACE_CLOSE
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_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, _impl_.name_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, _impl_.fields_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, _impl_.oneofs_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, _impl_.options_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, _impl_.source_context_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, _impl_.syntax_),
- ~0u, // no _has_bits_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.kind_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.cardinality_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.number_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.name_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.type_url_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.oneof_index_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.packed_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.options_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.json_name_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.default_value_),
- ~0u, // no _has_bits_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, _impl_.name_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, _impl_.enumvalue_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, _impl_.options_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, _impl_.source_context_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, _impl_.syntax_),
- ~0u, // no _has_bits_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValue, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValue, _impl_.name_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValue, _impl_.number_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValue, _impl_.options_),
- ~0u, // no _has_bits_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Option, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Option, _impl_.name_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Option, _impl_.value_),
+static constexpr const ::_pb::ServiceDescriptor**
+ 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_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, _impl_.name_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, _impl_.fields_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, _impl_.oneofs_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, _impl_.options_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, _impl_.source_context_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, _impl_.syntax_),
+ ~0u, // no _has_bits_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.kind_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.cardinality_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.number_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.name_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.type_url_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.oneof_index_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.packed_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.options_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.json_name_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.default_value_),
+ ~0u, // no _has_bits_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, _impl_.name_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, _impl_.enumvalue_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, _impl_.options_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, _impl_.source_context_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, _impl_.syntax_),
+ ~0u, // no _has_bits_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValue, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValue, _impl_.name_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValue, _impl_.number_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValue, _impl_.options_),
+ ~0u, // no _has_bits_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Option, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Option, _impl_.name_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Option, _impl_.value_),
};
-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)},
- { 39, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValue)},
- { 48, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Option)},
+
+static const ::_pbi::MigrationSchema
+ schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Type)},
+ { 14, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Field)},
+ { 32, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Enum)},
+ { 45, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValue)},
+ { 56, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Option)},
};
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,
+ &::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) =
- "\n\032google/protobuf/type.proto\022\017google.pro"
- "tobuf\032\031google/protobuf/any.proto\032$google"
- "/protobuf/source_context.proto\"\327\001\n\004Type\022"
- "\014\n\004name\030\001 \001(\t\022&\n\006fields\030\002 \003(\0132\026.google.p"
- "rotobuf.Field\022\016\n\006oneofs\030\003 \003(\t\022(\n\007options"
- "\030\004 \003(\0132\027.google.protobuf.Option\0226\n\016sourc"
- "e_context\030\005 \001(\0132\036.google.protobuf.Source"
- "Context\022\'\n\006syntax\030\006 \001(\0162\027.google.protobu"
- "f.Syntax\"\325\005\n\005Field\022)\n\004kind\030\001 \001(\0162\033.googl"
- "e.protobuf.Field.Kind\0227\n\013cardinality\030\002 \001"
- "(\0162\".google.protobuf.Field.Cardinality\022\016"
- "\n\006number\030\003 \001(\005\022\014\n\004name\030\004 \001(\t\022\020\n\010type_url"
- "\030\006 \001(\t\022\023\n\013oneof_index\030\007 \001(\005\022\016\n\006packed\030\010 "
- "\001(\010\022(\n\007options\030\t \003(\0132\027.google.protobuf.O"
- "ption\022\021\n\tjson_name\030\n \001(\t\022\025\n\rdefault_valu"
- "e\030\013 \001(\t\"\310\002\n\004Kind\022\020\n\014TYPE_UNKNOWN\020\000\022\017\n\013TY"
- "PE_DOUBLE\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\nTYPE_INT6"
- "4\020\003\022\017\n\013TYPE_UINT64\020\004\022\016\n\nTYPE_INT32\020\005\022\020\n\014"
- "TYPE_FIXED64\020\006\022\020\n\014TYPE_FIXED32\020\007\022\r\n\tTYPE"
- "_BOOL\020\010\022\017\n\013TYPE_STRING\020\t\022\016\n\nTYPE_GROUP\020\n"
- "\022\020\n\014TYPE_MESSAGE\020\013\022\016\n\nTYPE_BYTES\020\014\022\017\n\013TY"
- "PE_UINT32\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rTYPE_SFIXE"
- "D32\020\017\022\021\n\rTYPE_SFIXED64\020\020\022\017\n\013TYPE_SINT32\020"
- "\021\022\017\n\013TYPE_SINT64\020\022\"t\n\013Cardinality\022\027\n\023CAR"
- "DINALITY_UNKNOWN\020\000\022\030\n\024CARDINALITY_OPTION"
- "AL\020\001\022\030\n\024CARDINALITY_REQUIRED\020\002\022\030\n\024CARDIN"
- "ALITY_REPEATED\020\003\"\316\001\n\004Enum\022\014\n\004name\030\001 \001(\t\022"
- "-\n\tenumvalue\030\002 \003(\0132\032.google.protobuf.Enu"
- "mValue\022(\n\007options\030\003 \003(\0132\027.google.protobu"
- "f.Option\0226\n\016source_context\030\004 \001(\0132\036.googl"
- "e.protobuf.SourceContext\022\'\n\006syntax\030\005 \001(\016"
- "2\027.google.protobuf.Syntax\"S\n\tEnumValue\022\014"
- "\n\004name\030\001 \001(\t\022\016\n\006number\030\002 \001(\005\022(\n\007options\030"
- "\003 \003(\0132\027.google.protobuf.Option\";\n\006Option"
- "\022\014\n\004name\030\001 \001(\t\022#\n\005value\030\002 \001(\0132\024.google.p"
- "rotobuf.Any*.\n\006Syntax\022\021\n\rSYNTAX_PROTO2\020\000"
- "\022\021\n\rSYNTAX_PROTO3\020\001B{\n\023com.google.protob"
- "ufB\tTypeProtoP\001Z-google.golang.org/proto"
- "buf/types/known/typepb\370\001\001\242\002\003GPB\252\002\036Google"
- ".Protobuf.WellKnownTypesb\006proto3"
- ;
-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,
+const char descriptor_table_protodef_google_2fprotobuf_2ftype_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ "\n\032google/protobuf/type.proto\022\017google.pro"
+ "tobuf\032\031google/protobuf/any.proto\032$google"
+ "/protobuf/source_context.proto\"\327\001\n\004Type\022"
+ "\014\n\004name\030\001 \001(\t\022&\n\006fields\030\002 \003(\0132\026.google.p"
+ "rotobuf.Field\022\016\n\006oneofs\030\003 \003(\t\022(\n\007options"
+ "\030\004 \003(\0132\027.google.protobuf.Option\0226\n\016sourc"
+ "e_context\030\005 \001(\0132\036.google.protobuf.Source"
+ "Context\022\'\n\006syntax\030\006 \001(\0162\027.google.protobu"
+ "f.Syntax\"\325\005\n\005Field\022)\n\004kind\030\001 \001(\0162\033.googl"
+ "e.protobuf.Field.Kind\0227\n\013cardinality\030\002 \001"
+ "(\0162\".google.protobuf.Field.Cardinality\022\016"
+ "\n\006number\030\003 \001(\005\022\014\n\004name\030\004 \001(\t\022\020\n\010type_url"
+ "\030\006 \001(\t\022\023\n\013oneof_index\030\007 \001(\005\022\016\n\006packed\030\010 "
+ "\001(\010\022(\n\007options\030\t \003(\0132\027.google.protobuf.O"
+ "ption\022\021\n\tjson_name\030\n \001(\t\022\025\n\rdefault_valu"
+ "e\030\013 \001(\t\"\310\002\n\004Kind\022\020\n\014TYPE_UNKNOWN\020\000\022\017\n\013TY"
+ "PE_DOUBLE\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\nTYPE_INT6"
+ "4\020\003\022\017\n\013TYPE_UINT64\020\004\022\016\n\nTYPE_INT32\020\005\022\020\n\014"
+ "TYPE_FIXED64\020\006\022\020\n\014TYPE_FIXED32\020\007\022\r\n\tTYPE"
+ "_BOOL\020\010\022\017\n\013TYPE_STRING\020\t\022\016\n\nTYPE_GROUP\020\n"
+ "\022\020\n\014TYPE_MESSAGE\020\013\022\016\n\nTYPE_BYTES\020\014\022\017\n\013TY"
+ "PE_UINT32\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rTYPE_SFIXE"
+ "D32\020\017\022\021\n\rTYPE_SFIXED64\020\020\022\017\n\013TYPE_SINT32\020"
+ "\021\022\017\n\013TYPE_SINT64\020\022\"t\n\013Cardinality\022\027\n\023CAR"
+ "DINALITY_UNKNOWN\020\000\022\030\n\024CARDINALITY_OPTION"
+ "AL\020\001\022\030\n\024CARDINALITY_REQUIRED\020\002\022\030\n\024CARDIN"
+ "ALITY_REPEATED\020\003\"\316\001\n\004Enum\022\014\n\004name\030\001 \001(\t\022"
+ "-\n\tenumvalue\030\002 \003(\0132\032.google.protobuf.Enu"
+ "mValue\022(\n\007options\030\003 \003(\0132\027.google.protobu"
+ "f.Option\0226\n\016source_context\030\004 \001(\0132\036.googl"
+ "e.protobuf.SourceContext\022\'\n\006syntax\030\005 \001(\016"
+ "2\027.google.protobuf.Syntax\"S\n\tEnumValue\022\014"
+ "\n\004name\030\001 \001(\t\022\016\n\006number\030\002 \001(\005\022(\n\007options\030"
+ "\003 \003(\0132\027.google.protobuf.Option\";\n\006Option"
+ "\022\014\n\004name\030\001 \001(\t\022#\n\005value\030\002 \001(\0132\024.google.p"
+ "rotobuf.Any*.\n\006Syntax\022\021\n\rSYNTAX_PROTO2\020\000"
+ "\022\021\n\rSYNTAX_PROTO3\020\001B{\n\023com.google.protob"
+ "ufB\tTypeProtoP\001Z-google.golang.org/proto"
+ "buf/types/known/typepb\370\001\001\242\002\003GPB\252\002\036Google"
+ ".Protobuf.WellKnownTypesb\006proto3"
+};
+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 ::_pbi::once_flag descriptor_table_google_2fprotobuf_2ftype_2eproto_once;
+static ::y_absl::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,
+ 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,
+ &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,
};
+
+// This function exists to be marked as weak.
+// It can significantly speed up compilation by breaking up LLVM's SCC
+// in the .pb.cc translation units. Large translation units see a
+// reduction of more than 35% of walltime for optimized builds. Without
+// the weak attribute all the messages in the file, including all the
+// vtables and everything they use become part of the same SCC through
+// a cycle like:
+// GetMetadata -> descriptor table -> default instances ->
+// 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 ::_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_PRIORITY2 static ::_pbi::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);
@@ -278,8 +347,9 @@ bool Field_Kind_IsValid(int value) {
return false;
}
}
+#if (__cplusplus < 201703) && \
+ (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
-#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
constexpr Field_Kind Field::TYPE_UNKNOWN;
constexpr Field_Kind Field::TYPE_DOUBLE;
constexpr Field_Kind Field::TYPE_FLOAT;
@@ -302,7 +372,9 @@ constexpr Field_Kind Field::TYPE_SINT64;
constexpr Field_Kind Field::Kind_MIN;
constexpr Field_Kind Field::Kind_MAX;
constexpr int Field::Kind_ARRAYSIZE;
-#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
+
+#endif // (__cplusplus < 201703) &&
+ // (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Field_Cardinality_descriptor() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2ftype_2eproto);
return file_level_enum_descriptors_google_2fprotobuf_2ftype_2eproto[1];
@@ -318,8 +390,9 @@ bool Field_Cardinality_IsValid(int value) {
return false;
}
}
+#if (__cplusplus < 201703) && \
+ (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
-#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
constexpr Field_Cardinality Field::CARDINALITY_UNKNOWN;
constexpr Field_Cardinality Field::CARDINALITY_OPTIONAL;
constexpr Field_Cardinality Field::CARDINALITY_REQUIRED;
@@ -327,7 +400,9 @@ constexpr Field_Cardinality Field::CARDINALITY_REPEATED;
constexpr Field_Cardinality Field::Cardinality_MIN;
constexpr Field_Cardinality Field::Cardinality_MAX;
constexpr int Field::Cardinality_ARRAYSIZE;
-#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
+
+#endif // (__cplusplus < 201703) &&
+ // (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Syntax_descriptor() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2ftype_2eproto);
return file_level_enum_descriptors_google_2fprotobuf_2ftype_2eproto[2];
@@ -341,8 +416,6 @@ bool Syntax_IsValid(int value) {
return false;
}
}
-
-
// ===================================================================
class Type::_Internal {
@@ -360,10 +433,9 @@ void Type::clear_source_context() {
}
_impl_.source_context_ = nullptr;
}
-Type::Type(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+Type::Type(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Type)
}
Type::Type(const Type& from)
@@ -373,19 +445,20 @@ Type::Type(const Type& from)
decltype(_impl_.fields_){from._impl_.fields_}
, decltype(_impl_.oneofs_){from._impl_.oneofs_}
, decltype(_impl_.options_){from._impl_.options_}
- , decltype(_impl_.name_){}
+ , decltype(_impl_.name_) {}
+
, decltype(_impl_.source_context_){nullptr}
- , decltype(_impl_.syntax_){}
+ , decltype(_impl_.syntax_) {}
+
, /*decltype(_impl_._cached_size_)*/{}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) {
- _this->_impl_.name_.Set(from._internal_name(),
- _this->GetArenaForAllocation());
+ _this->_impl_.name_.Set(from._internal_name(), _this->GetArenaForAllocation());
}
if (from._internal_has_source_context()) {
_this->_impl_.source_context_ = new ::PROTOBUF_NAMESPACE_ID::SourceContext(*from._impl_.source_context_);
@@ -394,23 +467,23 @@ Type::Type(const Type& from)
// @@protoc_insertion_point(copy_constructor:google.protobuf.Type)
}
-inline void Type::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void Type::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_.fields_){arena}
, decltype(_impl_.oneofs_){arena}
, decltype(_impl_.options_){arena}
- , decltype(_impl_.name_){}
+ , decltype(_impl_.name_) {}
+
, decltype(_impl_.source_context_){nullptr}
- , decltype(_impl_.syntax_){0}
+ , decltype(_impl_.syntax_) { 0 }
+
, /*decltype(_impl_._cached_size_)*/{}
};
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
Type::~Type() {
@@ -423,7 +496,7 @@ Type::~Type() {
}
inline void Type::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.fields_.~RepeatedPtrField();
_impl_.oneofs_.~RepeatedPtrField();
_impl_.options_.~RepeatedPtrField();
@@ -437,7 +510,7 @@ void Type::SetCachedSize(int size) const {
void Type::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Type)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -456,22 +529,23 @@ void Type::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// string name = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Type.name"));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.Field fields = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) {
ptr -= 1;
do {
ptr += 1;
@@ -479,12 +553,13 @@ const char* Type::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated string oneofs = 3;
case 3:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 26)) {
ptr -= 1;
do {
ptr += 1;
@@ -494,12 +569,13 @@ const char* Type::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Type.oneofs"));
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.Option options = 4;
case 4:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 34)) {
ptr -= 1;
do {
ptr += 1;
@@ -507,25 +583,28 @@ const char* Type::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// .google.protobuf.SourceContext source_context = 5;
case 5:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 42)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 42)) {
ptr = ctx->ParseMessage(_internal_mutable_source_context(), ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// .google.protobuf.Syntax syntax = 6;
case 6:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 48)) {
- arc_ui64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 48)) {
+ ::arc_ui32 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
_internal_set_syntax(static_cast<::PROTOBUF_NAMESPACE_ID::Syntax>(val));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -550,20 +629,18 @@ failure:
#undef CHK_
}
-uint8_t* Type::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* Type::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Type)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// string name = 1;
if (!this->_internal_name().empty()) {
+ const TProtoStringType& _s = this->_internal_name();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
- this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
- "google.protobuf.Type.name");
- target = stream->WriteStringMaybeAliased(
- 1, this->_internal_name(), target);
+ _s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Type.name");
+ target = stream->WriteStringMaybeAliased(1, _s, target);
}
// repeated .google.protobuf.Field fields = 2;
@@ -575,12 +652,10 @@ uint8_t* Type::_InternalSerialize(
}
// repeated string oneofs = 3;
- for (int i = 0, n = this->_internal_oneofs_size(); i < n; i++) {
+ for (int i = 0, n = this->_internal_oneofs_size(); i < n; ++i) {
const auto& s = this->_internal_oneofs(i);
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
- s.data(), static_cast<int>(s.length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
- "google.protobuf.Type.oneofs");
+ s.data(), static_cast<int>(s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Type.oneofs");
target = stream->WriteString(3, s, target);
}
@@ -603,7 +678,7 @@ uint8_t* Type::_InternalSerialize(
if (this->_internal_syntax() != 0) {
target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::WriteEnumToArray(
- 6, this->_internal_syntax(), target);
+ 6, this->_internal_syntax(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
@@ -614,11 +689,11 @@ uint8_t* Type::_InternalSerialize(
return target;
}
-size_t Type::ByteSizeLong() const {
+::size_t Type::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Type)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -630,11 +705,9 @@ size_t Type::ByteSizeLong() const {
}
// repeated string oneofs = 3;
- total_size += 1 *
- ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.oneofs_.size());
- for (int i = 0, n = _impl_.oneofs_.size(); i < n; i++) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- _impl_.oneofs_.Get(i));
+ total_size += 1 * ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.oneofs_.size());
+ for (int i = 0, n = _impl_.oneofs_.size(); i < n; ++i) {
+ total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(_impl_.oneofs_.Get(i));
}
// repeated .google.protobuf.Option options = 4;
@@ -646,9 +719,8 @@ size_t Type::ByteSizeLong() const {
// string name = 1;
if (!this->_internal_name().empty()) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_name());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_name());
}
// .google.protobuf.SourceContext source_context = 5;
@@ -661,7 +733,7 @@ size_t Type::ByteSizeLong() const {
// .google.protobuf.Syntax syntax = 6;
if (this->_internal_syntax() != 0) {
total_size += 1 +
- ::_pbi::WireFormatLite::EnumSize(this->_internal_syntax());
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_syntax());
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -678,8 +750,8 @@ void Type::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_
auto* const _this = static_cast<Type*>(&to_msg);
auto& from = static_cast<const Type&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Type)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.fields_.MergeFrom(from._impl_.fields_);
@@ -717,10 +789,8 @@ void Type::InternalSwap(Type* other) {
_impl_.fields_.InternalSwap(&other->_impl_.fields_);
_impl_.oneofs_.InternalSwap(&other->_impl_.oneofs_);
_impl_.options_.InternalSwap(&other->_impl_.options_);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.name_, lhs_arena,
- &other->_impl_.name_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, lhs_arena,
+ &other->_impl_.name_, rhs_arena);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(Type, _impl_.syntax_)
+ sizeof(Type::_impl_.syntax_)
@@ -734,17 +804,15 @@ void Type::InternalSwap(Type* other) {
&descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once,
file_level_metadata_google_2fprotobuf_2ftype_2eproto[0]);
}
-
// ===================================================================
class Field::_Internal {
public:
};
-Field::Field(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+Field::Field(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Field)
}
Field::Field(const Field& from)
@@ -752,89 +820,101 @@ Field::Field(const Field& from)
Field* const _this = this; (void)_this;
new (&_impl_) Impl_{
decltype(_impl_.options_){from._impl_.options_}
- , decltype(_impl_.name_){}
- , decltype(_impl_.type_url_){}
- , decltype(_impl_.json_name_){}
- , decltype(_impl_.default_value_){}
- , decltype(_impl_.kind_){}
- , decltype(_impl_.cardinality_){}
- , decltype(_impl_.number_){}
- , decltype(_impl_.oneof_index_){}
- , decltype(_impl_.packed_){}
+ , decltype(_impl_.name_) {}
+
+ , decltype(_impl_.type_url_) {}
+
+ , decltype(_impl_.json_name_) {}
+
+ , decltype(_impl_.default_value_) {}
+
+ , decltype(_impl_.kind_) {}
+
+ , decltype(_impl_.cardinality_) {}
+
+ , decltype(_impl_.number_) {}
+
+ , decltype(_impl_.oneof_index_) {}
+
+ , decltype(_impl_.packed_) {}
+
, /*decltype(_impl_._cached_size_)*/{}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) {
- _this->_impl_.name_.Set(from._internal_name(),
- _this->GetArenaForAllocation());
+ _this->_impl_.name_.Set(from._internal_name(), _this->GetArenaForAllocation());
}
_impl_.type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.type_url_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.type_url_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_type_url().empty()) {
- _this->_impl_.type_url_.Set(from._internal_type_url(),
- _this->GetArenaForAllocation());
+ _this->_impl_.type_url_.Set(from._internal_type_url(), _this->GetArenaForAllocation());
}
_impl_.json_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.json_name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.json_name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_json_name().empty()) {
- _this->_impl_.json_name_.Set(from._internal_json_name(),
- _this->GetArenaForAllocation());
+ _this->_impl_.json_name_.Set(from._internal_json_name(), _this->GetArenaForAllocation());
}
_impl_.default_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.default_value_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.default_value_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_default_value().empty()) {
- _this->_impl_.default_value_.Set(from._internal_default_value(),
- _this->GetArenaForAllocation());
+ _this->_impl_.default_value_.Set(from._internal_default_value(), _this->GetArenaForAllocation());
}
::memcpy(&_impl_.kind_, &from._impl_.kind_,
- static_cast<size_t>(reinterpret_cast<char*>(&_impl_.packed_) -
+ static_cast<::size_t>(reinterpret_cast<char*>(&_impl_.packed_) -
reinterpret_cast<char*>(&_impl_.kind_)) + sizeof(_impl_.packed_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.Field)
}
-inline void Field::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void Field::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_.options_){arena}
- , decltype(_impl_.name_){}
- , decltype(_impl_.type_url_){}
- , decltype(_impl_.json_name_){}
- , decltype(_impl_.default_value_){}
- , decltype(_impl_.kind_){0}
- , decltype(_impl_.cardinality_){0}
- , decltype(_impl_.number_){0}
- , decltype(_impl_.oneof_index_){0}
- , decltype(_impl_.packed_){false}
+ , decltype(_impl_.name_) {}
+
+ , decltype(_impl_.type_url_) {}
+
+ , decltype(_impl_.json_name_) {}
+
+ , decltype(_impl_.default_value_) {}
+
+ , decltype(_impl_.kind_) { 0 }
+
+ , decltype(_impl_.cardinality_) { 0 }
+
+ , decltype(_impl_.number_) { 0 }
+
+ , decltype(_impl_.oneof_index_) { 0 }
+
+ , decltype(_impl_.packed_) { false }
+
, /*decltype(_impl_._cached_size_)*/{}
};
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.type_url_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.type_url_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.json_name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.json_name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.json_name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.default_value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.default_value_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.default_value_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
Field::~Field() {
@@ -847,7 +927,7 @@ Field::~Field() {
}
inline void Field::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.options_.~RepeatedPtrField();
_impl_.name_.Destroy();
_impl_.type_url_.Destroy();
@@ -861,7 +941,7 @@ void Field::SetCachedSize(int size) const {
void Field::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Field)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -870,7 +950,7 @@ void Field::Clear() {
_impl_.type_url_.ClearToEmpty();
_impl_.json_name_.ClearToEmpty();
_impl_.default_value_.ClearToEmpty();
- ::memset(&_impl_.kind_, 0, static_cast<size_t>(
+ ::memset(&_impl_.kind_, 0, static_cast<::size_t>(
reinterpret_cast<char*>(&_impl_.packed_) -
reinterpret_cast<char*>(&_impl_.kind_)) + sizeof(_impl_.packed_));
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
@@ -879,74 +959,81 @@ void Field::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// .google.protobuf.Field.Kind kind = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
- arc_ui64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) {
+ ::arc_ui32 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
_internal_set_kind(static_cast<::PROTOBUF_NAMESPACE_ID::Field_Kind>(val));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// .google.protobuf.Field.Cardinality cardinality = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
- arc_ui64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 16)) {
+ ::arc_ui32 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
_internal_set_cardinality(static_cast<::PROTOBUF_NAMESPACE_ID::Field_Cardinality>(val));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// int32 number = 3;
case 3:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 24)) {
_impl_.number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// string name = 4;
case 4:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 34)) {
auto str = _internal_mutable_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Field.name"));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// string type_url = 6;
case 6:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 50)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 50)) {
auto str = _internal_mutable_type_url();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Field.type_url"));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// int32 oneof_index = 7;
case 7:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 56)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 56)) {
_impl_.oneof_index_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// bool packed = 8;
case 8:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 64)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 64)) {
_impl_.packed_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.Option options = 9;
case 9:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 74)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 74)) {
ptr -= 1;
do {
ptr += 1;
@@ -954,28 +1041,31 @@ const char* Field::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<74>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// string json_name = 10;
case 10:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 82)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 82)) {
auto str = _internal_mutable_json_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Field.json_name"));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// string default_value = 11;
case 11:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 90)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 90)) {
auto str = _internal_mutable_default_value();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Field.default_value"));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -1000,62 +1090,61 @@ failure:
#undef CHK_
}
-uint8_t* Field::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* Field::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Field)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// .google.protobuf.Field.Kind kind = 1;
if (this->_internal_kind() != 0) {
target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::WriteEnumToArray(
- 1, this->_internal_kind(), target);
+ 1, this->_internal_kind(), target);
}
// .google.protobuf.Field.Cardinality cardinality = 2;
if (this->_internal_cardinality() != 0) {
target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::WriteEnumToArray(
- 2, this->_internal_cardinality(), target);
+ 2, this->_internal_cardinality(), target);
}
// int32 number = 3;
if (this->_internal_number() != 0) {
target = stream->EnsureSpace(target);
- target = ::_pbi::WireFormatLite::WriteInt32ToArray(3, this->_internal_number(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(
+ 3, this->_internal_number(), target);
}
// string name = 4;
if (!this->_internal_name().empty()) {
+ const TProtoStringType& _s = this->_internal_name();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
- this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
- "google.protobuf.Field.name");
- target = stream->WriteStringMaybeAliased(
- 4, this->_internal_name(), target);
+ _s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Field.name");
+ target = stream->WriteStringMaybeAliased(4, _s, target);
}
// string type_url = 6;
if (!this->_internal_type_url().empty()) {
+ const TProtoStringType& _s = this->_internal_type_url();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
- this->_internal_type_url().data(), static_cast<int>(this->_internal_type_url().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
- "google.protobuf.Field.type_url");
- target = stream->WriteStringMaybeAliased(
- 6, this->_internal_type_url(), target);
+ _s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Field.type_url");
+ target = stream->WriteStringMaybeAliased(6, _s, target);
}
// int32 oneof_index = 7;
if (this->_internal_oneof_index() != 0) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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 = ::_pbi::WireFormatLite::WriteBoolToArray(8, this->_internal_packed(), target);
+ target = ::_pbi::WireFormatLite::WriteBoolToArray(
+ 8, this->_internal_packed(), target);
}
// repeated .google.protobuf.Option options = 9;
@@ -1068,22 +1157,18 @@ uint8_t* Field::_InternalSerialize(
// string json_name = 10;
if (!this->_internal_json_name().empty()) {
+ const TProtoStringType& _s = this->_internal_json_name();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
- this->_internal_json_name().data(), static_cast<int>(this->_internal_json_name().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
- "google.protobuf.Field.json_name");
- target = stream->WriteStringMaybeAliased(
- 10, this->_internal_json_name(), target);
+ _s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Field.json_name");
+ target = stream->WriteStringMaybeAliased(10, _s, target);
}
// string default_value = 11;
if (!this->_internal_default_value().empty()) {
+ const TProtoStringType& _s = this->_internal_default_value();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
- this->_internal_default_value().data(), static_cast<int>(this->_internal_default_value().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
- "google.protobuf.Field.default_value");
- target = stream->WriteStringMaybeAliased(
- 11, this->_internal_default_value(), target);
+ _s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Field.default_value");
+ target = stream->WriteStringMaybeAliased(11, _s, target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
@@ -1094,11 +1179,11 @@ uint8_t* Field::_InternalSerialize(
return target;
}
-size_t Field::ByteSizeLong() const {
+::size_t Field::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Field)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -1111,57 +1196,55 @@ size_t Field::ByteSizeLong() const {
// string name = 4;
if (!this->_internal_name().empty()) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_name());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_name());
}
// string type_url = 6;
if (!this->_internal_type_url().empty()) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_type_url());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_type_url());
}
// string json_name = 10;
if (!this->_internal_json_name().empty()) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_json_name());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_json_name());
}
// string default_value = 11;
if (!this->_internal_default_value().empty()) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_default_value());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_default_value());
}
// .google.protobuf.Field.Kind kind = 1;
if (this->_internal_kind() != 0) {
total_size += 1 +
- ::_pbi::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 +
- ::_pbi::WireFormatLite::EnumSize(this->_internal_cardinality());
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_cardinality());
}
// int32 number = 3;
if (this->_internal_number() != 0) {
- total_size += ::_pbi::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 += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_oneof_index());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(
+ this->_internal_oneof_index());
}
// bool packed = 8;
if (this->_internal_packed() != 0) {
- total_size += 1 + 1;
+ total_size += 2;
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -1178,8 +1261,8 @@ void Field::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF
auto* const _this = static_cast<Field*>(&to_msg);
auto& from = static_cast<const Field&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Field)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.options_.MergeFrom(from._impl_.options_);
@@ -1230,22 +1313,14 @@ void Field::InternalSwap(Field* other) {
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
_impl_.options_.InternalSwap(&other->_impl_.options_);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.name_, lhs_arena,
- &other->_impl_.name_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.type_url_, lhs_arena,
- &other->_impl_.type_url_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.json_name_, lhs_arena,
- &other->_impl_.json_name_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.default_value_, lhs_arena,
- &other->_impl_.default_value_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, lhs_arena,
+ &other->_impl_.name_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.type_url_, lhs_arena,
+ &other->_impl_.type_url_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.json_name_, lhs_arena,
+ &other->_impl_.json_name_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.default_value_, lhs_arena,
+ &other->_impl_.default_value_, rhs_arena);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(Field, _impl_.packed_)
+ sizeof(Field::_impl_.packed_)
@@ -1259,7 +1334,6 @@ void Field::InternalSwap(Field* other) {
&descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once,
file_level_metadata_google_2fprotobuf_2ftype_2eproto[1]);
}
-
// ===================================================================
class Enum::_Internal {
@@ -1277,10 +1351,9 @@ void Enum::clear_source_context() {
}
_impl_.source_context_ = nullptr;
}
-Enum::Enum(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+Enum::Enum(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Enum)
}
Enum::Enum(const Enum& from)
@@ -1289,19 +1362,20 @@ Enum::Enum(const Enum& from)
new (&_impl_) Impl_{
decltype(_impl_.enumvalue_){from._impl_.enumvalue_}
, decltype(_impl_.options_){from._impl_.options_}
- , decltype(_impl_.name_){}
+ , decltype(_impl_.name_) {}
+
, decltype(_impl_.source_context_){nullptr}
- , decltype(_impl_.syntax_){}
+ , decltype(_impl_.syntax_) {}
+
, /*decltype(_impl_._cached_size_)*/{}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) {
- _this->_impl_.name_.Set(from._internal_name(),
- _this->GetArenaForAllocation());
+ _this->_impl_.name_.Set(from._internal_name(), _this->GetArenaForAllocation());
}
if (from._internal_has_source_context()) {
_this->_impl_.source_context_ = new ::PROTOBUF_NAMESPACE_ID::SourceContext(*from._impl_.source_context_);
@@ -1310,22 +1384,22 @@ Enum::Enum(const Enum& from)
// @@protoc_insertion_point(copy_constructor:google.protobuf.Enum)
}
-inline void Enum::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void Enum::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_.enumvalue_){arena}
, decltype(_impl_.options_){arena}
- , decltype(_impl_.name_){}
+ , decltype(_impl_.name_) {}
+
, decltype(_impl_.source_context_){nullptr}
- , decltype(_impl_.syntax_){0}
+ , decltype(_impl_.syntax_) { 0 }
+
, /*decltype(_impl_._cached_size_)*/{}
};
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
Enum::~Enum() {
@@ -1338,7 +1412,7 @@ Enum::~Enum() {
}
inline void Enum::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.enumvalue_.~RepeatedPtrField();
_impl_.options_.~RepeatedPtrField();
_impl_.name_.Destroy();
@@ -1351,7 +1425,7 @@ void Enum::SetCachedSize(int size) const {
void Enum::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Enum)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -1369,22 +1443,23 @@ void Enum::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// string name = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Enum.name"));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.EnumValue enumvalue = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) {
ptr -= 1;
do {
ptr += 1;
@@ -1392,12 +1467,13 @@ const char* Enum::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.Option options = 3;
case 3:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 26)) {
ptr -= 1;
do {
ptr += 1;
@@ -1405,25 +1481,28 @@ const char* Enum::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// .google.protobuf.SourceContext source_context = 4;
case 4:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 34)) {
ptr = ctx->ParseMessage(_internal_mutable_source_context(), ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// .google.protobuf.Syntax syntax = 5;
case 5:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 40)) {
- arc_ui64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 40)) {
+ ::arc_ui32 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
_internal_set_syntax(static_cast<::PROTOBUF_NAMESPACE_ID::Syntax>(val));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -1448,20 +1527,18 @@ failure:
#undef CHK_
}
-uint8_t* Enum::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* Enum::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Enum)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// string name = 1;
if (!this->_internal_name().empty()) {
+ const TProtoStringType& _s = this->_internal_name();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
- this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
- "google.protobuf.Enum.name");
- target = stream->WriteStringMaybeAliased(
- 1, this->_internal_name(), target);
+ _s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Enum.name");
+ target = stream->WriteStringMaybeAliased(1, _s, target);
}
// repeated .google.protobuf.EnumValue enumvalue = 2;
@@ -1491,7 +1568,7 @@ uint8_t* Enum::_InternalSerialize(
if (this->_internal_syntax() != 0) {
target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::WriteEnumToArray(
- 5, this->_internal_syntax(), target);
+ 5, this->_internal_syntax(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
@@ -1502,11 +1579,11 @@ uint8_t* Enum::_InternalSerialize(
return target;
}
-size_t Enum::ByteSizeLong() const {
+::size_t Enum::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Enum)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -1526,9 +1603,8 @@ size_t Enum::ByteSizeLong() const {
// string name = 1;
if (!this->_internal_name().empty()) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_name());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_name());
}
// .google.protobuf.SourceContext source_context = 4;
@@ -1541,7 +1617,7 @@ size_t Enum::ByteSizeLong() const {
// .google.protobuf.Syntax syntax = 5;
if (this->_internal_syntax() != 0) {
total_size += 1 +
- ::_pbi::WireFormatLite::EnumSize(this->_internal_syntax());
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_syntax());
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -1558,8 +1634,8 @@ void Enum::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_
auto* const _this = static_cast<Enum*>(&to_msg);
auto& from = static_cast<const Enum&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Enum)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.enumvalue_.MergeFrom(from._impl_.enumvalue_);
@@ -1595,10 +1671,8 @@ void Enum::InternalSwap(Enum* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
_impl_.enumvalue_.InternalSwap(&other->_impl_.enumvalue_);
_impl_.options_.InternalSwap(&other->_impl_.options_);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.name_, lhs_arena,
- &other->_impl_.name_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, lhs_arena,
+ &other->_impl_.name_, rhs_arena);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(Enum, _impl_.syntax_)
+ sizeof(Enum::_impl_.syntax_)
@@ -1612,17 +1686,15 @@ void Enum::InternalSwap(Enum* other) {
&descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once,
file_level_metadata_google_2fprotobuf_2ftype_2eproto[2]);
}
-
// ===================================================================
class EnumValue::_Internal {
public:
};
-EnumValue::EnumValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+EnumValue::EnumValue(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.EnumValue)
}
EnumValue::EnumValue(const EnumValue& from)
@@ -1630,37 +1702,38 @@ EnumValue::EnumValue(const EnumValue& from)
EnumValue* const _this = this; (void)_this;
new (&_impl_) Impl_{
decltype(_impl_.options_){from._impl_.options_}
- , decltype(_impl_.name_){}
- , decltype(_impl_.number_){}
+ , decltype(_impl_.name_) {}
+
+ , decltype(_impl_.number_) {}
+
, /*decltype(_impl_._cached_size_)*/{}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) {
- _this->_impl_.name_.Set(from._internal_name(),
- _this->GetArenaForAllocation());
+ _this->_impl_.name_.Set(from._internal_name(), _this->GetArenaForAllocation());
}
_this->_impl_.number_ = from._impl_.number_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValue)
}
-inline void EnumValue::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void EnumValue::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_.options_){arena}
- , decltype(_impl_.name_){}
- , decltype(_impl_.number_){0}
+ , decltype(_impl_.name_) {}
+
+ , decltype(_impl_.number_) { 0 }
+
, /*decltype(_impl_._cached_size_)*/{}
};
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
EnumValue::~EnumValue() {
@@ -1673,7 +1746,7 @@ EnumValue::~EnumValue() {
}
inline void EnumValue::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.options_.~RepeatedPtrField();
_impl_.name_.Destroy();
}
@@ -1684,7 +1757,7 @@ void EnumValue::SetCachedSize(int size) const {
void EnumValue::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValue)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -1697,30 +1770,32 @@ void EnumValue::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// string name = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.EnumValue.name"));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// int32 number = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 16)) {
_impl_.number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.Option options = 3;
case 3:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 26)) {
ptr -= 1;
do {
ptr += 1;
@@ -1728,8 +1803,9 @@ const char* EnumValue::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -1754,26 +1830,25 @@ failure:
#undef CHK_
}
-uint8_t* EnumValue::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* EnumValue::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumValue)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// string name = 1;
if (!this->_internal_name().empty()) {
+ const TProtoStringType& _s = this->_internal_name();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
- this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
- "google.protobuf.EnumValue.name");
- target = stream->WriteStringMaybeAliased(
- 1, this->_internal_name(), target);
+ _s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.EnumValue.name");
+ target = stream->WriteStringMaybeAliased(1, _s, target);
}
// int32 number = 2;
if (this->_internal_number() != 0) {
target = stream->EnsureSpace(target);
- target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_number(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(
+ 2, this->_internal_number(), target);
}
// repeated .google.protobuf.Option options = 3;
@@ -1792,11 +1867,11 @@ uint8_t* EnumValue::_InternalSerialize(
return target;
}
-size_t EnumValue::ByteSizeLong() const {
+::size_t EnumValue::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValue)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -1809,14 +1884,14 @@ size_t EnumValue::ByteSizeLong() const {
// string name = 1;
if (!this->_internal_name().empty()) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_name());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_name());
}
// int32 number = 2;
if (this->_internal_number() != 0) {
- total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_number());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(
+ this->_internal_number());
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -1833,8 +1908,8 @@ void EnumValue::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROT
auto* const _this = static_cast<EnumValue*>(&to_msg);
auto& from = static_cast<const EnumValue&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValue)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.options_.MergeFrom(from._impl_.options_);
@@ -1864,10 +1939,9 @@ void EnumValue::InternalSwap(EnumValue* other) {
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
_impl_.options_.InternalSwap(&other->_impl_.options_);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.name_, lhs_arena,
- &other->_impl_.name_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, lhs_arena,
+ &other->_impl_.name_, rhs_arena);
+
swap(_impl_.number_, other->_impl_.number_);
}
@@ -1876,7 +1950,6 @@ void EnumValue::InternalSwap(EnumValue* other) {
&descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once,
file_level_metadata_google_2fprotobuf_2ftype_2eproto[3]);
}
-
// ===================================================================
class Option::_Internal {
@@ -1894,28 +1967,27 @@ void Option::clear_value() {
}
_impl_.value_ = nullptr;
}
-Option::Option(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+Option::Option(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Option)
}
Option::Option(const Option& from)
: ::PROTOBUF_NAMESPACE_ID::Message() {
Option* const _this = this; (void)_this;
new (&_impl_) Impl_{
- decltype(_impl_.name_){}
+ decltype(_impl_.name_) {}
+
, decltype(_impl_.value_){nullptr}
, /*decltype(_impl_._cached_size_)*/{}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_name().empty()) {
- _this->_impl_.name_.Set(from._internal_name(),
- _this->GetArenaForAllocation());
+ _this->_impl_.name_.Set(from._internal_name(), _this->GetArenaForAllocation());
}
if (from._internal_has_value()) {
_this->_impl_.value_ = new ::PROTOBUF_NAMESPACE_ID::Any(*from._impl_.value_);
@@ -1923,19 +1995,18 @@ Option::Option(const Option& from)
// @@protoc_insertion_point(copy_constructor:google.protobuf.Option)
}
-inline void Option::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void Option::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
- decltype(_impl_.name_){}
+ decltype(_impl_.name_) {}
+
, decltype(_impl_.value_){nullptr}
, /*decltype(_impl_._cached_size_)*/{}
};
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
Option::~Option() {
@@ -1948,7 +2019,7 @@ Option::~Option() {
}
inline void Option::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.name_.Destroy();
if (this != internal_default_instance()) delete _impl_.value_;
}
@@ -1959,7 +2030,7 @@ void Option::SetCachedSize(int size) const {
void Option::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Option)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -1974,26 +2045,28 @@ void Option::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// string name = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Option.name"));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// .google.protobuf.Any value = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) {
ptr = ctx->ParseMessage(_internal_mutable_value(), ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -2018,20 +2091,18 @@ failure:
#undef CHK_
}
-uint8_t* Option::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* Option::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Option)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// string name = 1;
if (!this->_internal_name().empty()) {
+ const TProtoStringType& _s = this->_internal_name();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
- this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
- "google.protobuf.Option.name");
- target = stream->WriteStringMaybeAliased(
- 1, this->_internal_name(), target);
+ _s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Option.name");
+ target = stream->WriteStringMaybeAliased(1, _s, target);
}
// .google.protobuf.Any value = 2;
@@ -2049,19 +2120,18 @@ uint8_t* Option::_InternalSerialize(
return target;
}
-size_t Option::ByteSizeLong() const {
+::size_t Option::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Option)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// string name = 1;
if (!this->_internal_name().empty()) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_name());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_name());
}
// .google.protobuf.Any value = 2;
@@ -2085,8 +2155,8 @@ void Option::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBU
auto* const _this = static_cast<Option*>(&to_msg);
auto& from = static_cast<const Option&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Option)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
if (!from._internal_name().empty()) {
@@ -2115,10 +2185,8 @@ void Option::InternalSwap(Option* other) {
auto* lhs_arena = GetArenaForAllocation();
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.name_, lhs_arena,
- &other->_impl_.name_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, lhs_arena,
+ &other->_impl_.name_, rhs_arena);
swap(_impl_.value_, other->_impl_.value_);
}
@@ -2127,7 +2195,6 @@ void Option::InternalSwap(Option* other) {
&descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once,
file_level_metadata_google_2fprotobuf_2ftype_2eproto[4]);
}
-
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
@@ -2152,6 +2219,5 @@ Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Option >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Option >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
-
// @@protoc_insertion_point(global_scope)
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protobuf/src/google/protobuf/type.pb.h b/contrib/libs/protobuf/src/google/protobuf/type.pb.h
index 7a5cd94bc70..c281d8401f7 100644
--- a/contrib/libs/protobuf/src/google/protobuf/type.pb.h
+++ b/contrib/libs/protobuf/src/google/protobuf/type.pb.h
@@ -1,41 +1,46 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/type.proto
-#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2ftype_2eproto
-#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2ftype_2eproto
+#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2ftype_2eproto_2epb_2eh
+#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2ftype_2eproto_2epb_2eh
#include <limits>
#include <string>
-
-#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3021000
-#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 3021003 < 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.
-#endif
-
-#include <google/protobuf/port_undef.inc>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/arena.h>
-#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_util.h>
-#include <google/protobuf/metadata_lite.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h> // IWYU pragma: export
-#include <google/protobuf/extension_set.h> // IWYU pragma: export
-#include <google/protobuf/generated_enum_reflection.h>
-#include <google/protobuf/unknown_field_set.h>
-#include <google/protobuf/any.pb.h>
-#include <google/protobuf/source_context.pb.h>
+#include <type_traits>
+
+#include "google/protobuf/port_def.inc"
+#if PROTOBUF_VERSION < 4022000
+#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 // PROTOBUF_VERSION
+
+#if 4022005 < 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."
+#endif // PROTOBUF_MIN_PROTOC_VERSION
+#include "google/protobuf/port_undef.inc"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/arena.h"
+#include "google/protobuf/arenastring.h"
+#include "google/protobuf/generated_message_util.h"
+#include "google/protobuf/metadata_lite.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/repeated_field.h" // IWYU pragma: export
+#include "google/protobuf/extension_set.h" // IWYU pragma: export
+#include "google/protobuf/generated_enum_reflection.h"
+#include "google/protobuf/unknown_field_set.h"
+#include "google/protobuf/any.pb.h"
+#include "google/protobuf/source_context.pb.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2ftype_2eproto PROTOBUF_EXPORT
+
PROTOBUF_NAMESPACE_OPEN
namespace internal {
class AnyMetadata;
@@ -44,9 +49,10 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2ftype_2eproto {
- static const arc_ui32 offsets[];
+ static const ::arc_ui32 offsets[];
};
-PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ftype_2eproto;
+PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable
+ descriptor_table_google_2fprotobuf_2ftype_2eproto;
PROTOBUF_NAMESPACE_OPEN
class Enum;
struct EnumDefaultTypeInternal;
@@ -63,16 +69,19 @@ PROTOBUF_EXPORT extern OptionDefaultTypeInternal _Option_default_instance_;
class Type;
struct TypeDefaultTypeInternal;
PROTOBUF_EXPORT extern TypeDefaultTypeInternal _Type_default_instance_;
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Enum* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Enum>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumValue* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumValue>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Field* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Field>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Option* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Option>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Type* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Type>(Arena*);
PROTOBUF_NAMESPACE_CLOSE
-PROTOBUF_NAMESPACE_OPEN
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Enum* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Enum>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumValue* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumValue>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Field* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Field>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Option* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Option>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Type* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Type>(Arena*);
-PROTOBUF_NAMESPACE_CLOSE
-PROTOBUF_NAMESPACE_OPEN
+PROTOBUF_NAMESPACE_OPEN
enum Field_Kind : int {
Field_Kind_TYPE_UNKNOWN = 0,
Field_Kind_TYPE_DOUBLE = 1,
@@ -93,82 +102,107 @@ enum Field_Kind : int {
Field_Kind_TYPE_SFIXED64 = 16,
Field_Kind_TYPE_SINT32 = 17,
Field_Kind_TYPE_SINT64 = 18,
- Field_Kind_Field_Kind_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits<arc_i32>::min(),
- Field_Kind_Field_Kind_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits<arc_i32>::max()
+ Field_Kind_Field_Kind_INT_MIN_SENTINEL_DO_NOT_USE_ =
+ std::numeric_limits<::arc_i32>::min(),
+ Field_Kind_Field_Kind_INT_MAX_SENTINEL_DO_NOT_USE_ =
+ std::numeric_limits<::arc_i32>::max(),
};
+
PROTOBUF_EXPORT bool Field_Kind_IsValid(int value);
-constexpr Field_Kind Field_Kind_Kind_MIN = Field_Kind_TYPE_UNKNOWN;
-constexpr Field_Kind Field_Kind_Kind_MAX = Field_Kind_TYPE_SINT64;
-constexpr int Field_Kind_Kind_ARRAYSIZE = Field_Kind_Kind_MAX + 1;
-
-PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Field_Kind_descriptor();
-template<typename T>
-inline const TProtoStringType& Field_Kind_Name(T enum_t_value) {
- static_assert(::std::is_same<T, Field_Kind>::value ||
- ::std::is_integral<T>::value,
- "Incorrect type passed to function Field_Kind_Name.");
- return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum(
- Field_Kind_descriptor(), enum_t_value);
-}
-inline bool Field_Kind_Parse(
- ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, Field_Kind* value) {
+constexpr Field_Kind Field_Kind_Kind_MIN = static_cast<Field_Kind>(0);
+constexpr Field_Kind Field_Kind_Kind_MAX = static_cast<Field_Kind>(18);
+constexpr int Field_Kind_Kind_ARRAYSIZE = 18 + 1;
+PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
+Field_Kind_descriptor();
+template <typename T>
+const TProtoStringType& Field_Kind_Name(T value) {
+ static_assert(std::is_same<T, Field_Kind>::value ||
+ std::is_integral<T>::value,
+ "Incorrect type passed to Kind_Name().");
+ return Field_Kind_Name(static_cast<Field_Kind>(value));
+}
+template <>
+inline const TProtoStringType& Field_Kind_Name(Field_Kind value) {
+ return ::PROTOBUF_NAMESPACE_ID::internal::NameOfDenseEnum<Field_Kind_descriptor,
+ 0, 18>(
+ static_cast<int>(value));
+}
+inline bool Field_Kind_Parse(y_absl::string_view name, Field_Kind* value) {
return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum<Field_Kind>(
- Field_Kind_descriptor(), name, value);
+ Field_Kind_descriptor(), name, value);
}
enum Field_Cardinality : int {
Field_Cardinality_CARDINALITY_UNKNOWN = 0,
Field_Cardinality_CARDINALITY_OPTIONAL = 1,
Field_Cardinality_CARDINALITY_REQUIRED = 2,
Field_Cardinality_CARDINALITY_REPEATED = 3,
- Field_Cardinality_Field_Cardinality_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits<arc_i32>::min(),
- Field_Cardinality_Field_Cardinality_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits<arc_i32>::max()
+ Field_Cardinality_Field_Cardinality_INT_MIN_SENTINEL_DO_NOT_USE_ =
+ std::numeric_limits<::arc_i32>::min(),
+ Field_Cardinality_Field_Cardinality_INT_MAX_SENTINEL_DO_NOT_USE_ =
+ std::numeric_limits<::arc_i32>::max(),
};
+
PROTOBUF_EXPORT bool Field_Cardinality_IsValid(int value);
-constexpr Field_Cardinality Field_Cardinality_Cardinality_MIN = Field_Cardinality_CARDINALITY_UNKNOWN;
-constexpr Field_Cardinality Field_Cardinality_Cardinality_MAX = Field_Cardinality_CARDINALITY_REPEATED;
-constexpr int Field_Cardinality_Cardinality_ARRAYSIZE = Field_Cardinality_Cardinality_MAX + 1;
-
-PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Field_Cardinality_descriptor();
-template<typename T>
-inline const TProtoStringType& Field_Cardinality_Name(T enum_t_value) {
- static_assert(::std::is_same<T, Field_Cardinality>::value ||
- ::std::is_integral<T>::value,
- "Incorrect type passed to function Field_Cardinality_Name.");
- return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum(
- Field_Cardinality_descriptor(), enum_t_value);
-}
-inline bool Field_Cardinality_Parse(
- ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, Field_Cardinality* value) {
+constexpr Field_Cardinality Field_Cardinality_Cardinality_MIN = static_cast<Field_Cardinality>(0);
+constexpr Field_Cardinality Field_Cardinality_Cardinality_MAX = static_cast<Field_Cardinality>(3);
+constexpr int Field_Cardinality_Cardinality_ARRAYSIZE = 3 + 1;
+PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
+Field_Cardinality_descriptor();
+template <typename T>
+const TProtoStringType& Field_Cardinality_Name(T value) {
+ static_assert(std::is_same<T, Field_Cardinality>::value ||
+ std::is_integral<T>::value,
+ "Incorrect type passed to Cardinality_Name().");
+ return Field_Cardinality_Name(static_cast<Field_Cardinality>(value));
+}
+template <>
+inline const TProtoStringType& Field_Cardinality_Name(Field_Cardinality value) {
+ return ::PROTOBUF_NAMESPACE_ID::internal::NameOfDenseEnum<Field_Cardinality_descriptor,
+ 0, 3>(
+ static_cast<int>(value));
+}
+inline bool Field_Cardinality_Parse(y_absl::string_view name, Field_Cardinality* value) {
return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum<Field_Cardinality>(
- Field_Cardinality_descriptor(), name, value);
+ Field_Cardinality_descriptor(), name, value);
}
enum Syntax : int {
SYNTAX_PROTO2 = 0,
SYNTAX_PROTO3 = 1,
- Syntax_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits<arc_i32>::min(),
- Syntax_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits<arc_i32>::max()
+ Syntax_INT_MIN_SENTINEL_DO_NOT_USE_ =
+ std::numeric_limits<::arc_i32>::min(),
+ Syntax_INT_MAX_SENTINEL_DO_NOT_USE_ =
+ std::numeric_limits<::arc_i32>::max(),
};
+
PROTOBUF_EXPORT bool Syntax_IsValid(int value);
-constexpr Syntax Syntax_MIN = SYNTAX_PROTO2;
-constexpr Syntax Syntax_MAX = SYNTAX_PROTO3;
-constexpr int Syntax_ARRAYSIZE = Syntax_MAX + 1;
-
-PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Syntax_descriptor();
-template<typename T>
-inline const TProtoStringType& Syntax_Name(T enum_t_value) {
- static_assert(::std::is_same<T, Syntax>::value ||
- ::std::is_integral<T>::value,
- "Incorrect type passed to function Syntax_Name.");
- return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum(
- Syntax_descriptor(), enum_t_value);
-}
-inline bool Syntax_Parse(
- ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, Syntax* value) {
+constexpr Syntax Syntax_MIN = static_cast<Syntax>(0);
+constexpr Syntax Syntax_MAX = static_cast<Syntax>(1);
+constexpr int Syntax_ARRAYSIZE = 1 + 1;
+PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
+Syntax_descriptor();
+template <typename T>
+const TProtoStringType& Syntax_Name(T value) {
+ static_assert(std::is_same<T, Syntax>::value ||
+ std::is_integral<T>::value,
+ "Incorrect type passed to Syntax_Name().");
+ return Syntax_Name(static_cast<Syntax>(value));
+}
+template <>
+inline const TProtoStringType& Syntax_Name(Syntax value) {
+ return ::PROTOBUF_NAMESPACE_ID::internal::NameOfDenseEnum<Syntax_descriptor,
+ 0, 1>(
+ static_cast<int>(value));
+}
+inline bool Syntax_Parse(y_absl::string_view name, Syntax* value) {
return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum<Syntax>(
- Syntax_descriptor(), name, value);
+ Syntax_descriptor(), name, value);
}
+
// ===================================================================
+
+// -------------------------------------------------------------------
+
class PROTOBUF_EXPORT Type final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Type) */ {
public:
@@ -237,7 +271,7 @@ class PROTOBUF_EXPORT Type final :
}
void UnsafeArenaSwap(Type* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -258,26 +292,25 @@ class PROTOBUF_EXPORT Type final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(Type* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.Type";
}
protected:
- explicit Type(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit Type(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -301,8 +334,9 @@ class PROTOBUF_EXPORT Type final :
int fields_size() const;
private:
int _internal_fields_size() const;
+
public:
- void clear_fields();
+ void clear_fields() ;
::PROTOBUF_NAMESPACE_ID::Field* mutable_fields(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Field >*
mutable_fields();
@@ -314,37 +348,41 @@ class PROTOBUF_EXPORT Type final :
::PROTOBUF_NAMESPACE_ID::Field* add_fields();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Field >&
fields() const;
-
// repeated string oneofs = 3;
int oneofs_size() const;
private:
int _internal_oneofs_size() const;
+
public:
- void clear_oneofs();
+ void clear_oneofs() ;
const TProtoStringType& oneofs(int index) const;
TProtoStringType* mutable_oneofs(int index);
void set_oneofs(int index, const TProtoStringType& value);
void set_oneofs(int index, TProtoStringType&& value);
void set_oneofs(int index, const char* value);
- void set_oneofs(int index, const char* value, size_t size);
+ void set_oneofs(int index, const char* value, std::size_t size);
+ void set_oneofs(int index, y_absl::string_view value);
TProtoStringType* add_oneofs();
void add_oneofs(const TProtoStringType& value);
void add_oneofs(TProtoStringType&& value);
void add_oneofs(const char* value);
- void add_oneofs(const char* value, size_t size);
+ void add_oneofs(const char* value, std::size_t size);
+ void add_oneofs(y_absl::string_view value);
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>& oneofs() const;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>* mutable_oneofs();
+
private:
const TProtoStringType& _internal_oneofs(int index) const;
TProtoStringType* _internal_add_oneofs();
- public:
+ public:
// repeated .google.protobuf.Option options = 4;
int options_size() const;
private:
int _internal_options_size() const;
+
public:
- void clear_options();
+ void clear_options() ;
::PROTOBUF_NAMESPACE_ID::Option* mutable_options(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >*
mutable_options();
@@ -356,27 +394,33 @@ class PROTOBUF_EXPORT Type final :
::PROTOBUF_NAMESPACE_ID::Option* add_options();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >&
options() const;
-
// string name = 1;
- void clear_name();
+ void clear_name() ;
const TProtoStringType& name() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_name(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_name(Arg_&& arg, Args_... args);
TProtoStringType* mutable_name();
PROTOBUF_NODISCARD TProtoStringType* release_name();
- void set_allocated_name(TProtoStringType* name);
+ void set_allocated_name(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_name() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_name();
- public:
+ public:
// .google.protobuf.SourceContext source_context = 5;
bool has_source_context() const;
private:
bool _internal_has_source_context() const;
+
public:
- void clear_source_context();
+ void clear_source_context() ;
const ::PROTOBUF_NAMESPACE_ID::SourceContext& source_context() const;
PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::SourceContext* release_source_context();
::PROTOBUF_NAMESPACE_ID::SourceContext* mutable_source_context();
@@ -388,16 +432,16 @@ class PROTOBUF_EXPORT Type final :
void unsafe_arena_set_allocated_source_context(
::PROTOBUF_NAMESPACE_ID::SourceContext* source_context);
::PROTOBUF_NAMESPACE_ID::SourceContext* unsafe_arena_release_source_context();
-
// .google.protobuf.Syntax syntax = 6;
- void clear_syntax();
+ void clear_syntax() ;
::PROTOBUF_NAMESPACE_ID::Syntax syntax() const;
void set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value);
+
private:
::PROTOBUF_NAMESPACE_ID::Syntax _internal_syntax() const;
void _internal_set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value);
- public:
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.Type)
private:
class _Internal;
@@ -416,8 +460,7 @@ class PROTOBUF_EXPORT Type final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2ftype_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT Field final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Field) */ {
@@ -487,7 +530,7 @@ class PROTOBUF_EXPORT Field final :
}
void UnsafeArenaSwap(Field* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -508,26 +551,25 @@ class PROTOBUF_EXPORT Field final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(Field* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.Field";
}
protected:
- explicit Field(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit Field(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -537,101 +579,62 @@ class PROTOBUF_EXPORT Field final :
// nested types ----------------------------------------------------
- typedef Field_Kind Kind;
- static constexpr Kind TYPE_UNKNOWN =
- Field_Kind_TYPE_UNKNOWN;
- static constexpr Kind TYPE_DOUBLE =
- Field_Kind_TYPE_DOUBLE;
- static constexpr Kind TYPE_FLOAT =
- Field_Kind_TYPE_FLOAT;
- static constexpr Kind TYPE_INT64 =
- Field_Kind_TYPE_INT64;
- static constexpr Kind TYPE_UINT64 =
- Field_Kind_TYPE_UINT64;
- static constexpr Kind TYPE_INT32 =
- Field_Kind_TYPE_INT32;
- static constexpr Kind TYPE_FIXED64 =
- Field_Kind_TYPE_FIXED64;
- static constexpr Kind TYPE_FIXED32 =
- Field_Kind_TYPE_FIXED32;
- static constexpr Kind TYPE_BOOL =
- Field_Kind_TYPE_BOOL;
- static constexpr Kind TYPE_STRING =
- Field_Kind_TYPE_STRING;
- static constexpr Kind TYPE_GROUP =
- Field_Kind_TYPE_GROUP;
- static constexpr Kind TYPE_MESSAGE =
- Field_Kind_TYPE_MESSAGE;
- static constexpr Kind TYPE_BYTES =
- Field_Kind_TYPE_BYTES;
- static constexpr Kind TYPE_UINT32 =
- Field_Kind_TYPE_UINT32;
- static constexpr Kind TYPE_ENUM =
- Field_Kind_TYPE_ENUM;
- static constexpr Kind TYPE_SFIXED32 =
- Field_Kind_TYPE_SFIXED32;
- static constexpr Kind TYPE_SFIXED64 =
- Field_Kind_TYPE_SFIXED64;
- static constexpr Kind TYPE_SINT32 =
- Field_Kind_TYPE_SINT32;
- static constexpr Kind TYPE_SINT64 =
- Field_Kind_TYPE_SINT64;
+ using Kind = Field_Kind;
+ static constexpr Kind TYPE_UNKNOWN = Field_Kind_TYPE_UNKNOWN;
+ static constexpr Kind TYPE_DOUBLE = Field_Kind_TYPE_DOUBLE;
+ static constexpr Kind TYPE_FLOAT = Field_Kind_TYPE_FLOAT;
+ static constexpr Kind TYPE_INT64 = Field_Kind_TYPE_INT64;
+ static constexpr Kind TYPE_UINT64 = Field_Kind_TYPE_UINT64;
+ static constexpr Kind TYPE_INT32 = Field_Kind_TYPE_INT32;
+ static constexpr Kind TYPE_FIXED64 = Field_Kind_TYPE_FIXED64;
+ static constexpr Kind TYPE_FIXED32 = Field_Kind_TYPE_FIXED32;
+ static constexpr Kind TYPE_BOOL = Field_Kind_TYPE_BOOL;
+ static constexpr Kind TYPE_STRING = Field_Kind_TYPE_STRING;
+ static constexpr Kind TYPE_GROUP = Field_Kind_TYPE_GROUP;
+ static constexpr Kind TYPE_MESSAGE = Field_Kind_TYPE_MESSAGE;
+ static constexpr Kind TYPE_BYTES = Field_Kind_TYPE_BYTES;
+ static constexpr Kind TYPE_UINT32 = Field_Kind_TYPE_UINT32;
+ static constexpr Kind TYPE_ENUM = Field_Kind_TYPE_ENUM;
+ static constexpr Kind TYPE_SFIXED32 = Field_Kind_TYPE_SFIXED32;
+ static constexpr Kind TYPE_SFIXED64 = Field_Kind_TYPE_SFIXED64;
+ static constexpr Kind TYPE_SINT32 = Field_Kind_TYPE_SINT32;
+ static constexpr Kind TYPE_SINT64 = Field_Kind_TYPE_SINT64;
static inline bool Kind_IsValid(int value) {
return Field_Kind_IsValid(value);
}
- static constexpr Kind Kind_MIN =
- Field_Kind_Kind_MIN;
- static constexpr Kind Kind_MAX =
- Field_Kind_Kind_MAX;
- static constexpr int Kind_ARRAYSIZE =
- Field_Kind_Kind_ARRAYSIZE;
- static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
- Kind_descriptor() {
+ static constexpr Kind Kind_MIN = Field_Kind_Kind_MIN;
+ static constexpr Kind Kind_MAX = Field_Kind_Kind_MAX;
+ static constexpr int Kind_ARRAYSIZE = Field_Kind_Kind_ARRAYSIZE;
+ static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Kind_descriptor() {
return Field_Kind_descriptor();
}
- template<typename T>
- static inline const TProtoStringType& Kind_Name(T enum_t_value) {
- static_assert(::std::is_same<T, Kind>::value ||
- ::std::is_integral<T>::value,
- "Incorrect type passed to function Kind_Name.");
- return Field_Kind_Name(enum_t_value);
+ template <typename T>
+ static inline const TProtoStringType& Kind_Name(T value) {
+ return Field_Kind_Name(value);
}
- static inline bool Kind_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name,
- Kind* value) {
+ static inline bool Kind_Parse(y_absl::string_view name, Kind* value) {
return Field_Kind_Parse(name, value);
}
- typedef Field_Cardinality Cardinality;
- static constexpr Cardinality CARDINALITY_UNKNOWN =
- Field_Cardinality_CARDINALITY_UNKNOWN;
- static constexpr Cardinality CARDINALITY_OPTIONAL =
- Field_Cardinality_CARDINALITY_OPTIONAL;
- static constexpr Cardinality CARDINALITY_REQUIRED =
- Field_Cardinality_CARDINALITY_REQUIRED;
- static constexpr Cardinality CARDINALITY_REPEATED =
- Field_Cardinality_CARDINALITY_REPEATED;
+ using Cardinality = Field_Cardinality;
+ static constexpr Cardinality CARDINALITY_UNKNOWN = Field_Cardinality_CARDINALITY_UNKNOWN;
+ static constexpr Cardinality CARDINALITY_OPTIONAL = Field_Cardinality_CARDINALITY_OPTIONAL;
+ static constexpr Cardinality CARDINALITY_REQUIRED = Field_Cardinality_CARDINALITY_REQUIRED;
+ static constexpr Cardinality CARDINALITY_REPEATED = Field_Cardinality_CARDINALITY_REPEATED;
static inline bool Cardinality_IsValid(int value) {
return Field_Cardinality_IsValid(value);
}
- static constexpr Cardinality Cardinality_MIN =
- Field_Cardinality_Cardinality_MIN;
- static constexpr Cardinality Cardinality_MAX =
- Field_Cardinality_Cardinality_MAX;
- static constexpr int Cardinality_ARRAYSIZE =
- Field_Cardinality_Cardinality_ARRAYSIZE;
- static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
- Cardinality_descriptor() {
+ static constexpr Cardinality Cardinality_MIN = Field_Cardinality_Cardinality_MIN;
+ static constexpr Cardinality Cardinality_MAX = Field_Cardinality_Cardinality_MAX;
+ static constexpr int Cardinality_ARRAYSIZE = Field_Cardinality_Cardinality_ARRAYSIZE;
+ static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Cardinality_descriptor() {
return Field_Cardinality_descriptor();
}
- template<typename T>
- static inline const TProtoStringType& Cardinality_Name(T enum_t_value) {
- static_assert(::std::is_same<T, Cardinality>::value ||
- ::std::is_integral<T>::value,
- "Incorrect type passed to function Cardinality_Name.");
- return Field_Cardinality_Name(enum_t_value);
+ template <typename T>
+ static inline const TProtoStringType& Cardinality_Name(T value) {
+ return Field_Cardinality_Name(value);
}
- static inline bool Cardinality_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name,
- Cardinality* value) {
+ static inline bool Cardinality_Parse(y_absl::string_view name, Cardinality* value) {
return Field_Cardinality_Parse(name, value);
}
@@ -653,8 +656,9 @@ class PROTOBUF_EXPORT Field final :
int options_size() const;
private:
int _internal_options_size() const;
+
public:
- void clear_options();
+ void clear_options() ;
::PROTOBUF_NAMESPACE_ID::Option* mutable_options(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >*
mutable_options();
@@ -666,108 +670,136 @@ class PROTOBUF_EXPORT Field final :
::PROTOBUF_NAMESPACE_ID::Option* add_options();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >&
options() const;
-
// string name = 4;
- void clear_name();
+ void clear_name() ;
const TProtoStringType& name() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_name(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_name(Arg_&& arg, Args_... args);
TProtoStringType* mutable_name();
PROTOBUF_NODISCARD TProtoStringType* release_name();
- void set_allocated_name(TProtoStringType* name);
+ void set_allocated_name(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_name() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_name();
- public:
+ public:
// string type_url = 6;
- void clear_type_url();
+ void clear_type_url() ;
const TProtoStringType& type_url() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_type_url(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_type_url(Arg_&& arg, Args_... args);
TProtoStringType* mutable_type_url();
PROTOBUF_NODISCARD TProtoStringType* release_type_url();
- void set_allocated_type_url(TProtoStringType* type_url);
+ void set_allocated_type_url(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_type_url() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_type_url(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_type_url(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_type_url();
- public:
+ public:
// string json_name = 10;
- void clear_json_name();
+ void clear_json_name() ;
const TProtoStringType& json_name() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_json_name(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_json_name(Arg_&& arg, Args_... args);
TProtoStringType* mutable_json_name();
PROTOBUF_NODISCARD TProtoStringType* release_json_name();
- void set_allocated_json_name(TProtoStringType* json_name);
+ void set_allocated_json_name(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_json_name() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_json_name(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_json_name(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_json_name();
- public:
+ public:
// string default_value = 11;
- void clear_default_value();
+ void clear_default_value() ;
const TProtoStringType& default_value() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_default_value(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_default_value(Arg_&& arg, Args_... args);
TProtoStringType* mutable_default_value();
PROTOBUF_NODISCARD TProtoStringType* release_default_value();
- void set_allocated_default_value(TProtoStringType* default_value);
+ void set_allocated_default_value(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_default_value() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_default_value(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_default_value(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_default_value();
- public:
+ public:
// .google.protobuf.Field.Kind kind = 1;
- void clear_kind();
+ void clear_kind() ;
::PROTOBUF_NAMESPACE_ID::Field_Kind kind() const;
void set_kind(::PROTOBUF_NAMESPACE_ID::Field_Kind value);
+
private:
::PROTOBUF_NAMESPACE_ID::Field_Kind _internal_kind() const;
void _internal_set_kind(::PROTOBUF_NAMESPACE_ID::Field_Kind value);
- public:
+ public:
// .google.protobuf.Field.Cardinality cardinality = 2;
- void clear_cardinality();
+ void clear_cardinality() ;
::PROTOBUF_NAMESPACE_ID::Field_Cardinality cardinality() const;
void set_cardinality(::PROTOBUF_NAMESPACE_ID::Field_Cardinality value);
+
private:
::PROTOBUF_NAMESPACE_ID::Field_Cardinality _internal_cardinality() const;
void _internal_set_cardinality(::PROTOBUF_NAMESPACE_ID::Field_Cardinality value);
- public:
+ public:
// int32 number = 3;
- void clear_number();
- arc_i32 number() const;
- void set_number(arc_i32 value);
+ void clear_number() ;
+ ::arc_i32 number() const;
+ void set_number(::arc_i32 value);
+
private:
- arc_i32 _internal_number() const;
- void _internal_set_number(arc_i32 value);
- public:
+ ::arc_i32 _internal_number() const;
+ void _internal_set_number(::arc_i32 value);
+ public:
// int32 oneof_index = 7;
- void clear_oneof_index();
- arc_i32 oneof_index() const;
- void set_oneof_index(arc_i32 value);
+ void clear_oneof_index() ;
+ ::arc_i32 oneof_index() const;
+ void set_oneof_index(::arc_i32 value);
+
private:
- arc_i32 _internal_oneof_index() const;
- void _internal_set_oneof_index(arc_i32 value);
- public:
+ ::arc_i32 _internal_oneof_index() const;
+ void _internal_set_oneof_index(::arc_i32 value);
+ public:
// bool packed = 8;
- void clear_packed();
+ void clear_packed() ;
bool packed() const;
void set_packed(bool value);
+
private:
bool _internal_packed() const;
void _internal_set_packed(bool value);
- public:
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.Field)
private:
class _Internal;
@@ -783,15 +815,14 @@ class PROTOBUF_EXPORT Field final :
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr default_value_;
int kind_;
int cardinality_;
- arc_i32 number_;
- arc_i32 oneof_index_;
+ ::arc_i32 number_;
+ ::arc_i32 oneof_index_;
bool packed_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2ftype_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT Enum final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Enum) */ {
@@ -861,7 +892,7 @@ class PROTOBUF_EXPORT Enum final :
}
void UnsafeArenaSwap(Enum* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -882,26 +913,25 @@ class PROTOBUF_EXPORT Enum final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(Enum* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.Enum";
}
protected:
- explicit Enum(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit Enum(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -924,8 +954,9 @@ class PROTOBUF_EXPORT Enum final :
int enumvalue_size() const;
private:
int _internal_enumvalue_size() const;
+
public:
- void clear_enumvalue();
+ void clear_enumvalue() ;
::PROTOBUF_NAMESPACE_ID::EnumValue* mutable_enumvalue(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumValue >*
mutable_enumvalue();
@@ -937,13 +968,13 @@ class PROTOBUF_EXPORT Enum final :
::PROTOBUF_NAMESPACE_ID::EnumValue* add_enumvalue();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumValue >&
enumvalue() const;
-
// repeated .google.protobuf.Option options = 3;
int options_size() const;
private:
int _internal_options_size() const;
+
public:
- void clear_options();
+ void clear_options() ;
::PROTOBUF_NAMESPACE_ID::Option* mutable_options(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >*
mutable_options();
@@ -955,27 +986,33 @@ class PROTOBUF_EXPORT Enum final :
::PROTOBUF_NAMESPACE_ID::Option* add_options();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >&
options() const;
-
// string name = 1;
- void clear_name();
+ void clear_name() ;
const TProtoStringType& name() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_name(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_name(Arg_&& arg, Args_... args);
TProtoStringType* mutable_name();
PROTOBUF_NODISCARD TProtoStringType* release_name();
- void set_allocated_name(TProtoStringType* name);
+ void set_allocated_name(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_name() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_name();
- public:
+ public:
// .google.protobuf.SourceContext source_context = 4;
bool has_source_context() const;
private:
bool _internal_has_source_context() const;
+
public:
- void clear_source_context();
+ void clear_source_context() ;
const ::PROTOBUF_NAMESPACE_ID::SourceContext& source_context() const;
PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::SourceContext* release_source_context();
::PROTOBUF_NAMESPACE_ID::SourceContext* mutable_source_context();
@@ -987,16 +1024,16 @@ class PROTOBUF_EXPORT Enum final :
void unsafe_arena_set_allocated_source_context(
::PROTOBUF_NAMESPACE_ID::SourceContext* source_context);
::PROTOBUF_NAMESPACE_ID::SourceContext* unsafe_arena_release_source_context();
-
// .google.protobuf.Syntax syntax = 5;
- void clear_syntax();
+ void clear_syntax() ;
::PROTOBUF_NAMESPACE_ID::Syntax syntax() const;
void set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value);
+
private:
::PROTOBUF_NAMESPACE_ID::Syntax _internal_syntax() const;
void _internal_set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value);
- public:
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.Enum)
private:
class _Internal;
@@ -1014,8 +1051,7 @@ class PROTOBUF_EXPORT Enum final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2ftype_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT EnumValue final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValue) */ {
@@ -1085,7 +1121,7 @@ class PROTOBUF_EXPORT EnumValue final :
}
void UnsafeArenaSwap(EnumValue* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -1106,26 +1142,25 @@ class PROTOBUF_EXPORT EnumValue final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(EnumValue* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.EnumValue";
}
protected:
- explicit EnumValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit EnumValue(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -1146,8 +1181,9 @@ class PROTOBUF_EXPORT EnumValue final :
int options_size() const;
private:
int _internal_options_size() const;
+
public:
- void clear_options();
+ void clear_options() ;
::PROTOBUF_NAMESPACE_ID::Option* mutable_options(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >*
mutable_options();
@@ -1159,30 +1195,36 @@ class PROTOBUF_EXPORT EnumValue final :
::PROTOBUF_NAMESPACE_ID::Option* add_options();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >&
options() const;
-
// string name = 1;
- void clear_name();
+ void clear_name() ;
const TProtoStringType& name() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_name(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_name(Arg_&& arg, Args_... args);
TProtoStringType* mutable_name();
PROTOBUF_NODISCARD TProtoStringType* release_name();
- void set_allocated_name(TProtoStringType* name);
+ void set_allocated_name(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_name() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_name();
- public:
+ public:
// int32 number = 2;
- void clear_number();
- arc_i32 number() const;
- void set_number(arc_i32 value);
+ void clear_number() ;
+ ::arc_i32 number() const;
+ void set_number(::arc_i32 value);
+
private:
- arc_i32 _internal_number() const;
- void _internal_set_number(arc_i32 value);
- public:
+ ::arc_i32 _internal_number() const;
+ void _internal_set_number(::arc_i32 value);
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.EnumValue)
private:
class _Internal;
@@ -1193,13 +1235,12 @@ class PROTOBUF_EXPORT EnumValue final :
struct Impl_ {
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option > options_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_;
- arc_i32 number_;
+ ::arc_i32 number_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2ftype_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT Option final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Option) */ {
@@ -1269,7 +1310,7 @@ class PROTOBUF_EXPORT Option final :
}
void UnsafeArenaSwap(Option* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -1290,26 +1331,25 @@ class PROTOBUF_EXPORT Option final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(Option* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.Option";
}
protected:
- explicit Option(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit Option(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -1326,25 +1366,32 @@ class PROTOBUF_EXPORT Option final :
kValueFieldNumber = 2,
};
// string name = 1;
- void clear_name();
+ void clear_name() ;
const TProtoStringType& name() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_name(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_name(Arg_&& arg, Args_... args);
TProtoStringType* mutable_name();
PROTOBUF_NODISCARD TProtoStringType* release_name();
- void set_allocated_name(TProtoStringType* name);
+ void set_allocated_name(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_name() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_name();
- public:
+ public:
// .google.protobuf.Any value = 2;
bool has_value() const;
private:
bool _internal_has_value() const;
+
public:
- void clear_value();
+ void clear_value() ;
const ::PROTOBUF_NAMESPACE_ID::Any& value() const;
PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::Any* release_value();
::PROTOBUF_NAMESPACE_ID::Any* mutable_value();
@@ -1356,7 +1403,6 @@ class PROTOBUF_EXPORT Option final :
void unsafe_arena_set_allocated_value(
::PROTOBUF_NAMESPACE_ID::Any* value);
::PROTOBUF_NAMESPACE_ID::Any* unsafe_arena_release_value();
-
// @@protoc_insertion_point(class_scope:google.protobuf.Option)
private:
class _Internal;
@@ -1372,15 +1418,21 @@ class PROTOBUF_EXPORT Option final :
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2ftype_2eproto;
};
+
// ===================================================================
+
+
// ===================================================================
+
#ifdef __GNUC__
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
+// -------------------------------------------------------------------
+
// Type
// string name = 1;
@@ -1391,11 +1443,11 @@ inline const TProtoStringType& Type::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Type.name)
return _internal_name();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void Type::set_name(ArgT0&& arg0, ArgT... args) {
-
- _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void Type::set_name(Arg_&& arg,
+ Args_... args) {
+ ;
+ _impl_.name_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Type.name)
}
inline TProtoStringType* Type::mutable_name() {
@@ -1407,29 +1459,26 @@ inline const TProtoStringType& Type::_internal_name() const {
return _impl_.name_.Get();
}
inline void Type::_internal_set_name(const TProtoStringType& value) {
-
+ ;
+
+
_impl_.name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Type::_internal_mutable_name() {
-
- return _impl_.name_.Mutable(GetArenaForAllocation());
+ ;
+ return _impl_.name_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* Type::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Type.name)
return _impl_.name_.Release();
}
-inline void Type::set_allocated_name(TProtoStringType* name) {
- if (name != nullptr) {
-
- } else {
-
- }
- _impl_.name_.SetAllocated(name, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+inline void Type::set_allocated_name(TProtoStringType* value) {
+ _impl_.name_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.name_.IsDefault()) {
+ _impl_.name_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.name)
}
@@ -1508,18 +1557,20 @@ inline void Type::set_oneofs(int index, TProtoStringType&& value) {
// @@protoc_insertion_point(field_set:google.protobuf.Type.oneofs)
}
inline void Type::set_oneofs(int index, const char* value) {
- GOOGLE_DCHECK(value != nullptr);
+ Y_ABSL_DCHECK(value != nullptr);
_impl_.oneofs_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.Type.oneofs)
}
-inline void Type::set_oneofs(int index, const char* value, size_t size) {
- _impl_.oneofs_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
+inline void Type::set_oneofs(int index, const char* value,
+ std::size_t size) {
+ _impl_.oneofs_.Mutable(index)->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_set_pointer:google.protobuf.Type.oneofs)
}
-inline TProtoStringType* Type::_internal_add_oneofs() {
- return _impl_.oneofs_.Add();
+inline void Type::set_oneofs(int index, y_absl::string_view value) {
+ _impl_.oneofs_.Mutable(index)->assign(value.data(), value.size());
+ // @@protoc_insertion_point(field_set_string_piece:google.protobuf.Type.oneofs)
}
+inline TProtoStringType* Type::_internal_add_oneofs() { return _impl_.oneofs_.Add(); }
inline void Type::add_oneofs(const TProtoStringType& value) {
_impl_.oneofs_.Add()->assign(value);
// @@protoc_insertion_point(field_add:google.protobuf.Type.oneofs)
@@ -1529,21 +1580,24 @@ inline void Type::add_oneofs(TProtoStringType&& value) {
// @@protoc_insertion_point(field_add:google.protobuf.Type.oneofs)
}
inline void Type::add_oneofs(const char* value) {
- GOOGLE_DCHECK(value != nullptr);
+ Y_ABSL_DCHECK(value != nullptr);
_impl_.oneofs_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.Type.oneofs)
}
-inline void Type::add_oneofs(const char* value, size_t size) {
+inline void Type::add_oneofs(const char* value, std::size_t size) {
_impl_.oneofs_.Add()->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_add_pointer:google.protobuf.Type.oneofs)
}
+inline void Type::add_oneofs(y_absl::string_view value) {
+ _impl_.oneofs_.Add()->assign(value.data(), value.size());
+ // @@protoc_insertion_point(field_add_string_piece:google.protobuf.Type.oneofs)
+}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>&
Type::oneofs() const {
// @@protoc_insertion_point(field_list:google.protobuf.Type.oneofs)
return _impl_.oneofs_;
}
-inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>*
-Type::mutable_oneofs() {
+inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>* Type::mutable_oneofs() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.Type.oneofs)
return &_impl_.oneofs_;
}
@@ -1610,11 +1664,6 @@ inline void Type::unsafe_arena_set_allocated_source_context(
delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.source_context_);
}
_impl_.source_context_ = source_context;
- if (source_context) {
-
- } else {
-
- }
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Type.source_context)
}
inline ::PROTOBUF_NAMESPACE_ID::SourceContext* Type::release_source_context() {
@@ -1665,9 +1714,9 @@ inline void Type::set_allocated_source_context(::PROTOBUF_NAMESPACE_ID::SourceCo
source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, source_context, submessage_arena);
}
-
+
} else {
-
+
}
_impl_.source_context_ = source_context;
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.source_context)
@@ -1677,21 +1726,21 @@ inline void Type::set_allocated_source_context(::PROTOBUF_NAMESPACE_ID::SourceCo
inline void Type::clear_syntax() {
_impl_.syntax_ = 0;
}
-inline ::PROTOBUF_NAMESPACE_ID::Syntax Type::_internal_syntax() const {
- return static_cast< ::PROTOBUF_NAMESPACE_ID::Syntax >(_impl_.syntax_);
-}
inline ::PROTOBUF_NAMESPACE_ID::Syntax Type::syntax() const {
// @@protoc_insertion_point(field_get:google.protobuf.Type.syntax)
return _internal_syntax();
}
-inline void Type::_internal_set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) {
-
- _impl_.syntax_ = value;
-}
inline void Type::set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) {
- _internal_set_syntax(value);
+ _internal_set_syntax(value);
// @@protoc_insertion_point(field_set:google.protobuf.Type.syntax)
}
+inline ::PROTOBUF_NAMESPACE_ID::Syntax Type::_internal_syntax() const {
+ return static_cast<::PROTOBUF_NAMESPACE_ID::Syntax>(_impl_.syntax_);
+}
+inline void Type::_internal_set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) {
+ ;
+ _impl_.syntax_ = value;
+}
// -------------------------------------------------------------------
@@ -1701,61 +1750,61 @@ inline void Type::set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) {
inline void Field::clear_kind() {
_impl_.kind_ = 0;
}
-inline ::PROTOBUF_NAMESPACE_ID::Field_Kind Field::_internal_kind() const {
- return static_cast< ::PROTOBUF_NAMESPACE_ID::Field_Kind >(_impl_.kind_);
-}
inline ::PROTOBUF_NAMESPACE_ID::Field_Kind Field::kind() const {
// @@protoc_insertion_point(field_get:google.protobuf.Field.kind)
return _internal_kind();
}
-inline void Field::_internal_set_kind(::PROTOBUF_NAMESPACE_ID::Field_Kind value) {
-
- _impl_.kind_ = value;
-}
inline void Field::set_kind(::PROTOBUF_NAMESPACE_ID::Field_Kind value) {
- _internal_set_kind(value);
+ _internal_set_kind(value);
// @@protoc_insertion_point(field_set:google.protobuf.Field.kind)
}
+inline ::PROTOBUF_NAMESPACE_ID::Field_Kind Field::_internal_kind() const {
+ return static_cast<::PROTOBUF_NAMESPACE_ID::Field_Kind>(_impl_.kind_);
+}
+inline void Field::_internal_set_kind(::PROTOBUF_NAMESPACE_ID::Field_Kind value) {
+ ;
+ _impl_.kind_ = value;
+}
// .google.protobuf.Field.Cardinality cardinality = 2;
inline void Field::clear_cardinality() {
_impl_.cardinality_ = 0;
}
-inline ::PROTOBUF_NAMESPACE_ID::Field_Cardinality Field::_internal_cardinality() const {
- return static_cast< ::PROTOBUF_NAMESPACE_ID::Field_Cardinality >(_impl_.cardinality_);
-}
inline ::PROTOBUF_NAMESPACE_ID::Field_Cardinality Field::cardinality() const {
// @@protoc_insertion_point(field_get:google.protobuf.Field.cardinality)
return _internal_cardinality();
}
-inline void Field::_internal_set_cardinality(::PROTOBUF_NAMESPACE_ID::Field_Cardinality value) {
-
- _impl_.cardinality_ = value;
-}
inline void Field::set_cardinality(::PROTOBUF_NAMESPACE_ID::Field_Cardinality value) {
- _internal_set_cardinality(value);
+ _internal_set_cardinality(value);
// @@protoc_insertion_point(field_set:google.protobuf.Field.cardinality)
}
+inline ::PROTOBUF_NAMESPACE_ID::Field_Cardinality Field::_internal_cardinality() const {
+ return static_cast<::PROTOBUF_NAMESPACE_ID::Field_Cardinality>(_impl_.cardinality_);
+}
+inline void Field::_internal_set_cardinality(::PROTOBUF_NAMESPACE_ID::Field_Cardinality value) {
+ ;
+ _impl_.cardinality_ = value;
+}
// int32 number = 3;
inline void Field::clear_number() {
_impl_.number_ = 0;
}
-inline arc_i32 Field::_internal_number() const {
- return _impl_.number_;
-}
-inline arc_i32 Field::number() const {
+inline ::arc_i32 Field::number() const {
// @@protoc_insertion_point(field_get:google.protobuf.Field.number)
return _internal_number();
}
-inline void Field::_internal_set_number(arc_i32 value) {
-
- _impl_.number_ = value;
-}
-inline void Field::set_number(arc_i32 value) {
+inline void Field::set_number(::arc_i32 value) {
_internal_set_number(value);
// @@protoc_insertion_point(field_set:google.protobuf.Field.number)
}
+inline ::arc_i32 Field::_internal_number() const {
+ return _impl_.number_;
+}
+inline void Field::_internal_set_number(::arc_i32 value) {
+ ;
+ _impl_.number_ = value;
+}
// string name = 4;
inline void Field::clear_name() {
@@ -1765,11 +1814,11 @@ inline const TProtoStringType& Field::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Field.name)
return _internal_name();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void Field::set_name(ArgT0&& arg0, ArgT... args) {
-
- _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void Field::set_name(Arg_&& arg,
+ Args_... args) {
+ ;
+ _impl_.name_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Field.name)
}
inline TProtoStringType* Field::mutable_name() {
@@ -1781,29 +1830,26 @@ inline const TProtoStringType& Field::_internal_name() const {
return _impl_.name_.Get();
}
inline void Field::_internal_set_name(const TProtoStringType& value) {
-
+ ;
+
+
_impl_.name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Field::_internal_mutable_name() {
-
- return _impl_.name_.Mutable(GetArenaForAllocation());
+ ;
+ return _impl_.name_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* Field::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Field.name)
return _impl_.name_.Release();
}
-inline void Field::set_allocated_name(TProtoStringType* name) {
- if (name != nullptr) {
-
- } else {
-
- }
- _impl_.name_.SetAllocated(name, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+inline void Field::set_allocated_name(TProtoStringType* value) {
+ _impl_.name_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.name_.IsDefault()) {
+ _impl_.name_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.name)
}
@@ -1815,11 +1861,11 @@ inline const TProtoStringType& Field::type_url() const {
// @@protoc_insertion_point(field_get:google.protobuf.Field.type_url)
return _internal_type_url();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void Field::set_type_url(ArgT0&& arg0, ArgT... args) {
-
- _impl_.type_url_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void Field::set_type_url(Arg_&& arg,
+ Args_... args) {
+ ;
+ _impl_.type_url_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Field.type_url)
}
inline TProtoStringType* Field::mutable_type_url() {
@@ -1831,29 +1877,26 @@ inline const TProtoStringType& Field::_internal_type_url() const {
return _impl_.type_url_.Get();
}
inline void Field::_internal_set_type_url(const TProtoStringType& value) {
-
+ ;
+
+
_impl_.type_url_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Field::_internal_mutable_type_url() {
-
- return _impl_.type_url_.Mutable(GetArenaForAllocation());
+ ;
+ return _impl_.type_url_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* Field::release_type_url() {
// @@protoc_insertion_point(field_release:google.protobuf.Field.type_url)
return _impl_.type_url_.Release();
}
-inline void Field::set_allocated_type_url(TProtoStringType* type_url) {
- if (type_url != nullptr) {
-
- } else {
-
- }
- _impl_.type_url_.SetAllocated(type_url, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.type_url_.IsDefault()) {
- _impl_.type_url_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+inline void Field::set_allocated_type_url(TProtoStringType* value) {
+ _impl_.type_url_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.type_url_.IsDefault()) {
+ _impl_.type_url_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.type_url)
}
@@ -1861,41 +1904,41 @@ inline void Field::set_allocated_type_url(TProtoStringType* type_url) {
inline void Field::clear_oneof_index() {
_impl_.oneof_index_ = 0;
}
-inline arc_i32 Field::_internal_oneof_index() const {
- return _impl_.oneof_index_;
-}
-inline arc_i32 Field::oneof_index() const {
+inline ::arc_i32 Field::oneof_index() const {
// @@protoc_insertion_point(field_get:google.protobuf.Field.oneof_index)
return _internal_oneof_index();
}
-inline void Field::_internal_set_oneof_index(arc_i32 value) {
-
- _impl_.oneof_index_ = value;
-}
-inline void Field::set_oneof_index(arc_i32 value) {
+inline void Field::set_oneof_index(::arc_i32 value) {
_internal_set_oneof_index(value);
// @@protoc_insertion_point(field_set:google.protobuf.Field.oneof_index)
}
+inline ::arc_i32 Field::_internal_oneof_index() const {
+ return _impl_.oneof_index_;
+}
+inline void Field::_internal_set_oneof_index(::arc_i32 value) {
+ ;
+ _impl_.oneof_index_ = value;
+}
// bool packed = 8;
inline void Field::clear_packed() {
_impl_.packed_ = false;
}
-inline bool Field::_internal_packed() const {
- return _impl_.packed_;
-}
inline bool Field::packed() const {
// @@protoc_insertion_point(field_get:google.protobuf.Field.packed)
return _internal_packed();
}
-inline void Field::_internal_set_packed(bool value) {
-
- _impl_.packed_ = value;
-}
inline void Field::set_packed(bool value) {
_internal_set_packed(value);
// @@protoc_insertion_point(field_set:google.protobuf.Field.packed)
}
+inline bool Field::_internal_packed() const {
+ return _impl_.packed_;
+}
+inline void Field::_internal_set_packed(bool value) {
+ ;
+ _impl_.packed_ = value;
+}
// repeated .google.protobuf.Option options = 9;
inline int Field::_internal_options_size() const {
@@ -1945,11 +1988,11 @@ inline const TProtoStringType& Field::json_name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Field.json_name)
return _internal_json_name();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void Field::set_json_name(ArgT0&& arg0, ArgT... args) {
-
- _impl_.json_name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void Field::set_json_name(Arg_&& arg,
+ Args_... args) {
+ ;
+ _impl_.json_name_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Field.json_name)
}
inline TProtoStringType* Field::mutable_json_name() {
@@ -1961,29 +2004,26 @@ inline const TProtoStringType& Field::_internal_json_name() const {
return _impl_.json_name_.Get();
}
inline void Field::_internal_set_json_name(const TProtoStringType& value) {
-
+ ;
+
+
_impl_.json_name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Field::_internal_mutable_json_name() {
-
- return _impl_.json_name_.Mutable(GetArenaForAllocation());
+ ;
+ return _impl_.json_name_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* Field::release_json_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Field.json_name)
return _impl_.json_name_.Release();
}
-inline void Field::set_allocated_json_name(TProtoStringType* json_name) {
- if (json_name != nullptr) {
-
- } else {
-
- }
- _impl_.json_name_.SetAllocated(json_name, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.json_name_.IsDefault()) {
- _impl_.json_name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+inline void Field::set_allocated_json_name(TProtoStringType* value) {
+ _impl_.json_name_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.json_name_.IsDefault()) {
+ _impl_.json_name_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.json_name)
}
@@ -1995,11 +2035,11 @@ inline const TProtoStringType& Field::default_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.Field.default_value)
return _internal_default_value();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void Field::set_default_value(ArgT0&& arg0, ArgT... args) {
-
- _impl_.default_value_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void Field::set_default_value(Arg_&& arg,
+ Args_... args) {
+ ;
+ _impl_.default_value_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Field.default_value)
}
inline TProtoStringType* Field::mutable_default_value() {
@@ -2011,29 +2051,26 @@ inline const TProtoStringType& Field::_internal_default_value() const {
return _impl_.default_value_.Get();
}
inline void Field::_internal_set_default_value(const TProtoStringType& value) {
-
+ ;
+
+
_impl_.default_value_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Field::_internal_mutable_default_value() {
-
- return _impl_.default_value_.Mutable(GetArenaForAllocation());
+ ;
+ return _impl_.default_value_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* Field::release_default_value() {
// @@protoc_insertion_point(field_release:google.protobuf.Field.default_value)
return _impl_.default_value_.Release();
}
-inline void Field::set_allocated_default_value(TProtoStringType* default_value) {
- if (default_value != nullptr) {
-
- } else {
-
- }
- _impl_.default_value_.SetAllocated(default_value, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.default_value_.IsDefault()) {
- _impl_.default_value_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+inline void Field::set_allocated_default_value(TProtoStringType* value) {
+ _impl_.default_value_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.default_value_.IsDefault()) {
+ _impl_.default_value_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.default_value)
}
@@ -2049,11 +2086,11 @@ inline const TProtoStringType& Enum::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Enum.name)
return _internal_name();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void Enum::set_name(ArgT0&& arg0, ArgT... args) {
-
- _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void Enum::set_name(Arg_&& arg,
+ Args_... args) {
+ ;
+ _impl_.name_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Enum.name)
}
inline TProtoStringType* Enum::mutable_name() {
@@ -2065,29 +2102,26 @@ inline const TProtoStringType& Enum::_internal_name() const {
return _impl_.name_.Get();
}
inline void Enum::_internal_set_name(const TProtoStringType& value) {
-
+ ;
+
+
_impl_.name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Enum::_internal_mutable_name() {
-
- return _impl_.name_.Mutable(GetArenaForAllocation());
+ ;
+ return _impl_.name_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* Enum::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Enum.name)
return _impl_.name_.Release();
}
-inline void Enum::set_allocated_name(TProtoStringType* name) {
- if (name != nullptr) {
-
- } else {
-
- }
- _impl_.name_.SetAllocated(name, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+inline void Enum::set_allocated_name(TProtoStringType* value) {
+ _impl_.name_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.name_.IsDefault()) {
+ _impl_.name_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.name)
}
@@ -2193,11 +2227,6 @@ inline void Enum::unsafe_arena_set_allocated_source_context(
delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.source_context_);
}
_impl_.source_context_ = source_context;
- if (source_context) {
-
- } else {
-
- }
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Enum.source_context)
}
inline ::PROTOBUF_NAMESPACE_ID::SourceContext* Enum::release_source_context() {
@@ -2248,9 +2277,9 @@ inline void Enum::set_allocated_source_context(::PROTOBUF_NAMESPACE_ID::SourceCo
source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, source_context, submessage_arena);
}
-
+
} else {
-
+
}
_impl_.source_context_ = source_context;
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.source_context)
@@ -2260,21 +2289,21 @@ inline void Enum::set_allocated_source_context(::PROTOBUF_NAMESPACE_ID::SourceCo
inline void Enum::clear_syntax() {
_impl_.syntax_ = 0;
}
-inline ::PROTOBUF_NAMESPACE_ID::Syntax Enum::_internal_syntax() const {
- return static_cast< ::PROTOBUF_NAMESPACE_ID::Syntax >(_impl_.syntax_);
-}
inline ::PROTOBUF_NAMESPACE_ID::Syntax Enum::syntax() const {
// @@protoc_insertion_point(field_get:google.protobuf.Enum.syntax)
return _internal_syntax();
}
-inline void Enum::_internal_set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) {
-
- _impl_.syntax_ = value;
-}
inline void Enum::set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) {
- _internal_set_syntax(value);
+ _internal_set_syntax(value);
// @@protoc_insertion_point(field_set:google.protobuf.Enum.syntax)
}
+inline ::PROTOBUF_NAMESPACE_ID::Syntax Enum::_internal_syntax() const {
+ return static_cast<::PROTOBUF_NAMESPACE_ID::Syntax>(_impl_.syntax_);
+}
+inline void Enum::_internal_set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) {
+ ;
+ _impl_.syntax_ = value;
+}
// -------------------------------------------------------------------
@@ -2288,11 +2317,11 @@ inline const TProtoStringType& EnumValue::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumValue.name)
return _internal_name();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void EnumValue::set_name(ArgT0&& arg0, ArgT... args) {
-
- _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void EnumValue::set_name(Arg_&& arg,
+ Args_... args) {
+ ;
+ _impl_.name_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.EnumValue.name)
}
inline TProtoStringType* EnumValue::mutable_name() {
@@ -2304,29 +2333,26 @@ inline const TProtoStringType& EnumValue::_internal_name() const {
return _impl_.name_.Get();
}
inline void EnumValue::_internal_set_name(const TProtoStringType& value) {
-
+ ;
+
+
_impl_.name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* EnumValue::_internal_mutable_name() {
-
- return _impl_.name_.Mutable(GetArenaForAllocation());
+ ;
+ return _impl_.name_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* EnumValue::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.EnumValue.name)
return _impl_.name_.Release();
}
-inline void EnumValue::set_allocated_name(TProtoStringType* name) {
- if (name != nullptr) {
-
- } else {
-
- }
- _impl_.name_.SetAllocated(name, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+inline void EnumValue::set_allocated_name(TProtoStringType* value) {
+ _impl_.name_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.name_.IsDefault()) {
+ _impl_.name_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValue.name)
}
@@ -2334,21 +2360,21 @@ inline void EnumValue::set_allocated_name(TProtoStringType* name) {
inline void EnumValue::clear_number() {
_impl_.number_ = 0;
}
-inline arc_i32 EnumValue::_internal_number() const {
- return _impl_.number_;
-}
-inline arc_i32 EnumValue::number() const {
+inline ::arc_i32 EnumValue::number() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumValue.number)
return _internal_number();
}
-inline void EnumValue::_internal_set_number(arc_i32 value) {
-
- _impl_.number_ = value;
-}
-inline void EnumValue::set_number(arc_i32 value) {
+inline void EnumValue::set_number(::arc_i32 value) {
_internal_set_number(value);
// @@protoc_insertion_point(field_set:google.protobuf.EnumValue.number)
}
+inline ::arc_i32 EnumValue::_internal_number() const {
+ return _impl_.number_;
+}
+inline void EnumValue::_internal_set_number(::arc_i32 value) {
+ ;
+ _impl_.number_ = value;
+}
// repeated .google.protobuf.Option options = 3;
inline int EnumValue::_internal_options_size() const {
@@ -2402,11 +2428,11 @@ inline const TProtoStringType& Option::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Option.name)
return _internal_name();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void Option::set_name(ArgT0&& arg0, ArgT... args) {
-
- _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void Option::set_name(Arg_&& arg,
+ Args_... args) {
+ ;
+ _impl_.name_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.Option.name)
}
inline TProtoStringType* Option::mutable_name() {
@@ -2418,29 +2444,26 @@ inline const TProtoStringType& Option::_internal_name() const {
return _impl_.name_.Get();
}
inline void Option::_internal_set_name(const TProtoStringType& value) {
-
+ ;
+
+
_impl_.name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Option::_internal_mutable_name() {
-
- return _impl_.name_.Mutable(GetArenaForAllocation());
+ ;
+ return _impl_.name_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* Option::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.Option.name)
return _impl_.name_.Release();
}
-inline void Option::set_allocated_name(TProtoStringType* name) {
- if (name != nullptr) {
-
- } else {
-
- }
- _impl_.name_.SetAllocated(name, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+inline void Option::set_allocated_name(TProtoStringType* value) {
+ _impl_.name_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.name_.IsDefault()) {
+ _impl_.name_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.name)
}
@@ -2466,11 +2489,6 @@ inline void Option::unsafe_arena_set_allocated_value(
delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.value_);
}
_impl_.value_ = value;
- if (value) {
-
- } else {
-
- }
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Option.value)
}
inline ::PROTOBUF_NAMESPACE_ID::Any* Option::release_value() {
@@ -2521,45 +2539,40 @@ inline void Option::set_allocated_value(::PROTOBUF_NAMESPACE_ID::Any* value) {
value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, value, submessage_arena);
}
-
+
} else {
-
+
}
_impl_.value_ = value;
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.value)
}
#ifdef __GNUC__
- #pragma GCC diagnostic pop
+#pragma GCC diagnostic pop
#endif // __GNUC__
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
// @@protoc_insertion_point(namespace_scope)
-
PROTOBUF_NAMESPACE_CLOSE
+
PROTOBUF_NAMESPACE_OPEN
-template <> struct is_proto_enum< ::PROTOBUF_NAMESPACE_ID::Field_Kind> : ::std::true_type {};
template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::PROTOBUF_NAMESPACE_ID::Field_Kind>() {
+struct is_proto_enum<::PROTOBUF_NAMESPACE_ID::Field_Kind> : std::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor<::PROTOBUF_NAMESPACE_ID::Field_Kind>() {
return ::PROTOBUF_NAMESPACE_ID::Field_Kind_descriptor();
}
-template <> struct is_proto_enum< ::PROTOBUF_NAMESPACE_ID::Field_Cardinality> : ::std::true_type {};
template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::PROTOBUF_NAMESPACE_ID::Field_Cardinality>() {
+struct is_proto_enum<::PROTOBUF_NAMESPACE_ID::Field_Cardinality> : std::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor<::PROTOBUF_NAMESPACE_ID::Field_Cardinality>() {
return ::PROTOBUF_NAMESPACE_ID::Field_Cardinality_descriptor();
}
-template <> struct is_proto_enum< ::PROTOBUF_NAMESPACE_ID::Syntax> : ::std::true_type {};
template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::PROTOBUF_NAMESPACE_ID::Syntax>() {
+struct is_proto_enum<::PROTOBUF_NAMESPACE_ID::Syntax> : std::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor<::PROTOBUF_NAMESPACE_ID::Syntax>() {
return ::PROTOBUF_NAMESPACE_ID::Syntax_descriptor();
}
@@ -2567,5 +2580,6 @@ PROTOBUF_NAMESPACE_CLOSE
// @@protoc_insertion_point(global_scope)
-#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2ftype_2eproto
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2ftype_2eproto_2epb_2eh
diff --git a/contrib/libs/protobuf/src/google/protobuf/type.proto b/contrib/libs/protobuf/src/google/protobuf/type.proto
index d3f6a68b839..fd25a41930c 100644
--- a/contrib/libs/protobuf/src/google/protobuf/type.proto
+++ b/contrib/libs/protobuf/src/google/protobuf/type.proto
@@ -35,12 +35,12 @@ package google.protobuf;
import "google/protobuf/any.proto";
import "google/protobuf/source_context.proto";
-option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option cc_enable_arenas = true;
option java_package = "com.google.protobuf";
option java_outer_classname = "TypeProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
+option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option go_package = "google.golang.org/protobuf/types/known/typepb";
// A protocol buffer message type.
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 837fc8bfa6a..ecc9bd6c7d7 100644
--- a/contrib/libs/protobuf/src/google/protobuf/unknown_field_set.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/unknown_field_set.cc
@@ -32,24 +32,25 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/unknown_field_set.h>
-
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.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>
+#include "google/protobuf/unknown_field_set.h"
+
+#include "y_absl/log/absl_check.h"
+#include "y_absl/strings/cord.h"
+#include "y_absl/strings/internal/resize_uninitialized.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/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/parse_context.h"
+#include "google/protobuf/wire_format.h"
+#include "google/protobuf/wire_format_lite.h"
+
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -60,7 +61,7 @@ const UnknownFieldSet& UnknownFieldSet::default_instance() {
}
void UnknownFieldSet::ClearFallback() {
- GOOGLE_DCHECK(!fields_.empty());
+ Y_ABSL_DCHECK(!fields_.empty());
int n = fields_.size();
do {
(fields_)[--n].Delete();
@@ -135,45 +136,45 @@ size_t UnknownFieldSet::SpaceUsedLong() const {
}
void UnknownFieldSet::AddVarint(int number, arc_ui64 value) {
- UnknownField field;
+ fields_.emplace_back();
+ auto& field = fields_.back();
field.number_ = number;
field.SetType(UnknownField::TYPE_VARINT);
field.data_.varint_ = value;
- fields_.push_back(field);
}
void UnknownFieldSet::AddFixed32(int number, arc_ui32 value) {
- UnknownField field;
+ fields_.emplace_back();
+ auto& field = fields_.back();
field.number_ = number;
field.SetType(UnknownField::TYPE_FIXED32);
field.data_.fixed32_ = value;
- fields_.push_back(field);
}
void UnknownFieldSet::AddFixed64(int number, arc_ui64 value) {
- UnknownField field;
+ fields_.emplace_back();
+ auto& field = fields_.back();
field.number_ = number;
field.SetType(UnknownField::TYPE_FIXED64);
field.data_.fixed64_ = value;
- fields_.push_back(field);
}
TProtoStringType* UnknownFieldSet::AddLengthDelimited(int number) {
- UnknownField field;
+ fields_.emplace_back();
+ auto& field = fields_.back();
field.number_ = number;
field.SetType(UnknownField::TYPE_LENGTH_DELIMITED);
field.data_.length_delimited_.string_value = new TProtoStringType;
- fields_.push_back(field);
return field.data_.length_delimited_.string_value;
}
UnknownFieldSet* UnknownFieldSet::AddGroup(int number) {
- UnknownField field;
+ fields_.emplace_back();
+ auto& field = fields_.back();
field.number_ = number;
field.SetType(UnknownField::TYPE_GROUP);
field.data_.group_ = new UnknownFieldSet;
- fields_.push_back(field);
return field.data_.group_;
}
@@ -243,7 +244,7 @@ bool UnknownFieldSet::ParseFromArray(const void* data, int size) {
bool UnknownFieldSet::SerializeToString(TProtoStringType* output) const {
const size_t size =
google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(*this);
- STLStringResizeUninitializedAmortized(output, size);
+ y_absl::strings_internal::STLStringResizeUninitializedAmortized(output, size);
google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
*this, reinterpret_cast<uint8_t*>(const_cast<char*>(output->data())));
return true;
@@ -254,6 +255,19 @@ bool UnknownFieldSet::SerializeToCodedStream(
google::protobuf::internal::WireFormat::SerializeUnknownFields(*this, output);
return !output->HadError();
}
+
+bool UnknownFieldSet::SerializeToCord(y_absl::Cord* output) const {
+ const size_t size =
+ google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(*this);
+ io::CordOutputStream cord_output_stream(size);
+ {
+ io::CodedOutputStream coded_output_stream(&cord_output_stream);
+ if (!SerializeToCodedStream(&coded_output_stream)) return false;
+ }
+ *output = cord_output_stream.Consume();
+ return true;
+}
+
void UnknownField::Delete() {
switch (type()) {
case UnknownField::TYPE_LENGTH_DELIMITED:
@@ -288,7 +302,7 @@ void UnknownField::DeepCopy(const UnknownField& other) {
uint8_t* UnknownField::InternalSerializeLengthDelimitedNoTag(
uint8_t* target, io::EpsCopyOutputStream* stream) const {
- GOOGLE_DCHECK_EQ(TYPE_LENGTH_DELIMITED, type());
+ Y_ABSL_DCHECK_EQ(TYPE_LENGTH_DELIMITED, type());
const TProtoStringType& data = *data_.length_delimited_.string_value;
target = io::CodedOutputStream::WriteVarint32ToArray(data.size(), target);
target = stream->WriteRaw(data.data(), data.size(), target);
@@ -347,4 +361,4 @@ const char* UnknownFieldParse(arc_ui64 tag, UnknownFieldSet* unknown,
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
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 d43d9c81bb6..f5249d66ab0 100644
--- a/contrib/libs/protobuf/src/google/protobuf/unknown_field_set.h
+++ b/contrib/libs/protobuf/src/google/protobuf/unknown_field_set.h
@@ -38,22 +38,22 @@
#ifndef GOOGLE_PROTOBUF_UNKNOWN_FIELD_SET_H__
#define GOOGLE_PROTOBUF_UNKNOWN_FIELD_SET_H__
-
#include <assert.h>
#include <string>
#include <vector>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
-#include <google/protobuf/port.h>
-#include <google/protobuf/message_lite.h>
-#include <google/protobuf/parse_context.h>
+#include "google/protobuf/stubs/common.h"
+#include "google/protobuf/port.h"
+#include "y_absl/log/absl_check.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/parse_context.h"
+#include "google/protobuf/port.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
#ifdef SWIG
#error "You cannot SWIG proto headers"
@@ -86,6 +86,8 @@ class UnknownField; // below
class PROTOBUF_EXPORT UnknownFieldSet {
public:
UnknownFieldSet();
+ UnknownFieldSet(const UnknownFieldSet&) = delete;
+ UnknownFieldSet& operator=(const UnknownFieldSet&) = delete;
~UnknownFieldSet();
// Remove all fields.
@@ -176,6 +178,7 @@ class PROTOBUF_EXPORT UnknownFieldSet {
// Serialization.
bool SerializeToString(TProtoStringType* output) const;
+ bool SerializeToCord(y_absl::Cord* output) const;
bool SerializeToCodedStream(io::CodedOutputStream* output) const;
static const UnknownFieldSet& default_instance();
@@ -209,7 +212,6 @@ class PROTOBUF_EXPORT UnknownFieldSet {
}
std::vector<UnknownField> fields_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(UnknownFieldSet);
};
namespace internal {
@@ -217,7 +219,7 @@ namespace internal {
inline void WriteVarint(arc_ui32 num, arc_ui64 val, UnknownFieldSet* unknown) {
unknown->AddVarint(num, val);
}
-inline void WriteLengthDelimited(arc_ui32 num, StringPiece val,
+inline void WriteLengthDelimited(arc_ui32 num, y_absl::string_view val,
UnknownFieldSet* unknown) {
unknown->AddLengthDelimited(num)->assign(val.data(), val.size());
}
@@ -391,7 +393,7 @@ bool UnknownFieldSet::MergeFromMessage(const MessageType& message) {
inline size_t UnknownField::GetLengthDelimitedSize() const {
- GOOGLE_DCHECK_EQ(TYPE_LENGTH_DELIMITED, type());
+ Y_ABSL_DCHECK_EQ(TYPE_LENGTH_DELIMITED, type());
return data_.length_delimited_.string_value->size();
}
@@ -403,5 +405,5 @@ inline void UnknownField::SetType(Type type) {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_UNKNOWN_FIELD_SET_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/delimited_message_util.cc b/contrib/libs/protobuf/src/google/protobuf/util/delimited_message_util.cc
index d481be474ee..615a5d72d59 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/delimited_message_util.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/util/delimited_message_util.cc
@@ -31,8 +31,9 @@
// Adapted from the patch of [email protected] (Kenton Varda)
// See https://github.com/protocolbuffers/protobuf/pull/710 for details.
-#include <google/protobuf/util/delimited_message_util.h>
-#include <google/protobuf/io/coded_stream.h>
+#include "google/protobuf/util/delimited_message_util.h"
+
+#include "google/protobuf/io/coded_stream.h"
namespace google {
namespace protobuf {
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 78625cf2f15..2f19261bc2c 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
@@ -34,21 +34,20 @@
#ifndef GOOGLE_PROTOBUF_UTIL_DELIMITED_MESSAGE_UTIL_H__
#define GOOGLE_PROTOBUF_UTIL_DELIMITED_MESSAGE_UTIL_H__
-
#include <ostream>
-#include <google/protobuf/message_lite.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/zero_copy_stream_impl.h>
+#include "google/protobuf/message_lite.h"
+#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>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
namespace util {
-// Write a single size-delimited message from the given stream. Delimited
+// Write a single size-delimited message to the given stream. Delimited
// format allows a single file or stream to contain multiple messages,
// whereas normally writing multiple non-delimited messages to the same
// stream would cause them to be merged. A delimited message is a varint
@@ -104,6 +103,6 @@ bool PROTOBUF_EXPORT SerializeDelimitedToCodedStream(
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_UTIL_DELIMITED_MESSAGE_UTIL_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/field_comparator.cc b/contrib/libs/protobuf/src/google/protobuf/util/field_comparator.cc
index 217013c5ed8..deb098ef3ce 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/field_comparator.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/util/field_comparator.cc
@@ -30,20 +30,48 @@
// Author: [email protected] (Krzysztof Sroka)
-#include <google/protobuf/util/field_comparator.h>
+#include "google/protobuf/util/field_comparator.h"
+#include <algorithm>
+#include <cfloat>
+#include <cmath>
#include <limits>
#include <string>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/util/message_differencer.h>
-#include <google/protobuf/stubs/map_util.h>
-#include <google/protobuf/stubs/mathutil.h>
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/message.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "google/protobuf/util/message_differencer.h"
namespace google {
namespace protobuf {
namespace util {
+namespace {
+template <typename T>
+struct Epsilon {};
+template <>
+struct Epsilon<float> {
+ constexpr static auto value = 32 * FLT_EPSILON;
+};
+template <>
+struct Epsilon<double> {
+ constexpr static auto value = 32 * DBL_EPSILON;
+};
+
+template <typename T>
+bool WithinFractionOrMargin(const T x, const T y, const T fraction,
+ const T margin) {
+ Y_ABSL_DCHECK(fraction >= T(0) && fraction < T(1) && margin >= T(0));
+
+ if (!std::isfinite(x) || !std::isfinite(y)) {
+ return false;
+ }
+ const T relative_margin = fraction * std::max(std::fabs(x), std::fabs(y));
+ return std::fabs(x - y) <= std::max(margin, relative_margin);
+}
+
+} // namespace
FieldComparator::FieldComparator() {}
FieldComparator::~FieldComparator() {}
@@ -121,8 +149,8 @@ FieldComparator::ComparisonResult SimpleFieldComparator::SimpleCompare(
return RECURSE;
default:
- GOOGLE_LOG(FATAL) << "No comparison code for field " << field->full_name()
- << " of CppType = " << field->cpp_type();
+ Y_ABSL_LOG(FATAL) << "No comparison code for field " << field->full_name()
+ << " of CppType = " << field->cpp_type();
return DIFFERENT;
}
}
@@ -130,7 +158,7 @@ FieldComparator::ComparisonResult SimpleFieldComparator::SimpleCompare(
bool SimpleFieldComparator::CompareWithDifferencer(
MessageDifferencer* differencer, const Message& message1,
const Message& message2, const util::FieldContext* field_context) {
- return differencer->Compare(message1, message2,
+ return differencer->Compare(message1, message2, false,
field_context->parent_fields());
}
@@ -143,8 +171,8 @@ void SimpleFieldComparator::SetDefaultFractionAndMargin(double fraction,
void SimpleFieldComparator::SetFractionAndMargin(const FieldDescriptor* field,
double fraction,
double margin) {
- GOOGLE_CHECK(FieldDescriptor::CPPTYPE_FLOAT == field->cpp_type() ||
- FieldDescriptor::CPPTYPE_DOUBLE == field->cpp_type())
+ Y_ABSL_CHECK(FieldDescriptor::CPPTYPE_FLOAT == field->cpp_type() ||
+ FieldDescriptor::CPPTYPE_DOUBLE == field->cpp_type())
<< "Field has to be float or double type. Field name is: "
<< field->full_name();
map_tolerance_[field] = Tolerance(fraction, margin);
@@ -183,19 +211,28 @@ bool SimpleFieldComparator::CompareDoubleOrFloat(const FieldDescriptor& field,
return true;
}
// float_comparison_ == APPROXIMATE covers two use cases.
- Tolerance* tolerance = FindOrNull(map_tolerance_, &field);
- if (tolerance == NULL && has_default_tolerance_) {
- tolerance = &default_tolerance_;
+ Tolerance* tolerance = nullptr;
+ if (has_default_tolerance_) tolerance = &default_tolerance_;
+
+ auto it = map_tolerance_.find(&field);
+ if (it != map_tolerance_.end()) {
+ tolerance = &it->second;
}
- if (tolerance == NULL) {
- return MathUtil::AlmostEquals(value_1, value_2);
- } else {
+
+ if (tolerance != nullptr) {
// Use user-provided fraction and margin. Since they are stored as
// doubles, we explicitly cast them to types of values provided. This
// is very likely to fail if provided values are not numeric.
- return MathUtil::WithinFractionOrMargin(
- value_1, value_2, static_cast<T>(tolerance->fraction),
- static_cast<T>(tolerance->margin));
+ return WithinFractionOrMargin(value_1, value_2,
+ static_cast<T>(tolerance->fraction),
+ static_cast<T>(tolerance->margin));
+ } else {
+ if (std::fabs(value_1) <= Epsilon<T>::value &&
+ std::fabs(value_2) <= Epsilon<T>::value) {
+ return true;
+ }
+ return WithinFractionOrMargin(value_1, value_2, Epsilon<T>::value,
+ Epsilon<T>::value);
}
}
}
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 0584f1eade8..be1c84f3bb6 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/field_comparator.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/field_comparator.h
@@ -33,16 +33,16 @@
#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>
+#include "google/protobuf/stubs/common.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "google/protobuf/port.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -63,6 +63,8 @@ class MessageDifferencer;
class PROTOBUF_EXPORT FieldComparator {
public:
FieldComparator();
+ FieldComparator(const FieldComparator&) = delete;
+ FieldComparator& operator=(const FieldComparator&) = delete;
virtual ~FieldComparator();
enum ComparisonResult {
@@ -92,9 +94,6 @@ class PROTOBUF_EXPORT FieldComparator {
const FieldDescriptor* field, int index_1,
int index_2,
const util::FieldContext* field_context) = 0;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldComparator);
};
// Basic implementation of FieldComparator. Supports three modes of floating
@@ -113,6 +112,8 @@ class PROTOBUF_EXPORT SimpleFieldComparator : public FieldComparator {
// Creates new comparator with float comparison set to EXACT.
SimpleFieldComparator();
+ SimpleFieldComparator(const SimpleFieldComparator&) = delete;
+ SimpleFieldComparator& operator=(const SimpleFieldComparator&) = delete;
~SimpleFieldComparator() override;
@@ -180,9 +181,6 @@ class PROTOBUF_EXPORT SimpleFieldComparator : public FieldComparator {
Tolerance(double f, double m) : fraction(f), margin(m) {}
};
- // Defines the map to store the tolerances for floating point comparison.
- typedef std::map<const FieldDescriptor*, Tolerance> ToleranceMap;
-
friend class MessageDifferencer;
// The following methods get executed when CompareFields is called for the
// basic types (instead of submessages). They return true on success. One
@@ -256,19 +254,12 @@ class PROTOBUF_EXPORT SimpleFieldComparator : public FieldComparator {
// Field-specific float/double tolerances, which override any default for
// those particular fields.
- ToleranceMap map_tolerance_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SimpleFieldComparator);
+ y_absl::flat_hash_map<const FieldDescriptor*, Tolerance> map_tolerance_;
};
// Default field comparison: use the basic implementation of FieldComparator.
-#ifdef PROTOBUF_FUTURE_BREAKING_CHANGES
-class PROTOBUF_EXPORT DefaultFieldComparator final
- : public SimpleFieldComparator
-#else // PROTOBUF_FUTURE_BREAKING_CHANGES
-class PROTOBUF_EXPORT DefaultFieldComparator : public SimpleFieldComparator
-#endif // PROTOBUF_FUTURE_BREAKING_CHANGES
-{
+class PROTOBUF_EXPORT DefaultFieldComparator
+ : public SimpleFieldComparator {
public:
ComparisonResult Compare(const Message& message_1, const Message& message_2,
const FieldDescriptor* field, int index_1,
@@ -283,6 +274,6 @@ class PROTOBUF_EXPORT DefaultFieldComparator : public SimpleFieldComparator
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__
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 17f3d19f1e2..881273db468 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
@@ -28,16 +28,26 @@
// (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/util/field_mask_util.h>
+#include "google/protobuf/util/field_mask_util.h"
#include <cstdint>
-
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/stubs/map_util.h>
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "y_absl/container/btree_map.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/log/die_if_null.h"
+#include "y_absl/memory/memory.h"
+#include "y_absl/strings/str_join.h"
+#include "y_absl/strings/str_split.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/strings/strip.h"
+#include "google/protobuf/message.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -46,19 +56,19 @@ namespace util {
using google::protobuf::FieldMask;
TProtoStringType FieldMaskUtil::ToString(const FieldMask& mask) {
- return Join(mask.paths(), ",");
+ return y_absl::StrJoin(mask.paths(), ",");
}
-void FieldMaskUtil::FromString(StringPiece str, FieldMask* out) {
+void FieldMaskUtil::FromString(y_absl::string_view str, FieldMask* out) {
out->Clear();
- std::vector<TProtoStringType> paths = Split(str, ",");
- for (const TProtoStringType& path : paths) {
+ std::vector<y_absl::string_view> paths = y_absl::StrSplit(str, ',');
+ for (y_absl::string_view path : paths) {
if (path.empty()) continue;
out->add_paths(path);
}
}
-bool FieldMaskUtil::SnakeCaseToCamelCase(StringPiece input,
+bool FieldMaskUtil::SnakeCaseToCamelCase(y_absl::string_view input,
TProtoStringType* output) {
output->clear();
bool after_underscore = false;
@@ -88,7 +98,7 @@ bool FieldMaskUtil::SnakeCaseToCamelCase(StringPiece input,
return true;
}
-bool FieldMaskUtil::CamelCaseToSnakeCase(StringPiece input,
+bool FieldMaskUtil::CamelCaseToSnakeCase(y_absl::string_view input,
TProtoStringType* output) {
output->clear();
for (const char c : input) {
@@ -109,7 +119,7 @@ bool FieldMaskUtil::CamelCaseToSnakeCase(StringPiece input,
bool FieldMaskUtil::ToJsonString(const FieldMask& mask, TProtoStringType* out) {
out->clear();
for (int i = 0; i < mask.paths_size(); ++i) {
- const TProtoStringType& path = mask.paths(i);
+ y_absl::string_view path = mask.paths(i);
TProtoStringType camelcase_path;
if (!SnakeCaseToCamelCase(path, &camelcase_path)) {
return false;
@@ -122,10 +132,10 @@ bool FieldMaskUtil::ToJsonString(const FieldMask& mask, TProtoStringType* out) {
return true;
}
-bool FieldMaskUtil::FromJsonString(StringPiece str, FieldMask* out) {
+bool FieldMaskUtil::FromJsonString(y_absl::string_view str, FieldMask* out) {
out->Clear();
- std::vector<TProtoStringType> paths = Split(str, ",");
- for (const TProtoStringType& path : paths) {
+ std::vector<y_absl::string_view> paths = y_absl::StrSplit(str, ',');
+ for (y_absl::string_view path : paths) {
if (path.empty()) continue;
TProtoStringType snakecase_path;
if (!CamelCaseToSnakeCase(path, &snakecase_path)) {
@@ -137,13 +147,13 @@ bool FieldMaskUtil::FromJsonString(StringPiece str, FieldMask* out) {
}
bool FieldMaskUtil::GetFieldDescriptors(
- const Descriptor* descriptor, StringPiece path,
+ const Descriptor* descriptor, y_absl::string_view path,
std::vector<const FieldDescriptor*>* field_descriptors) {
if (field_descriptors != nullptr) {
field_descriptors->clear();
}
- std::vector<TProtoStringType> parts = Split(path, ".");
- for (const TProtoStringType& field_name : parts) {
+ std::vector<y_absl::string_view> parts = y_absl::StrSplit(path, '.');
+ for (y_absl::string_view field_name : parts) {
if (descriptor == nullptr) {
return false;
}
@@ -185,6 +195,8 @@ namespace {
class FieldMaskTree {
public:
FieldMaskTree();
+ FieldMaskTree(const FieldMaskTree&) = delete;
+ FieldMaskTree& operator=(const FieldMaskTree&) = delete;
~FieldMaskTree();
void MergeFromFieldMask(const FieldMask& mask);
@@ -197,18 +209,18 @@ class FieldMaskTree {
// be added to the tree. If the path matches an existing non-leaf node in the
// tree, that non-leaf node will be turned into a leaf node with all its
// children removed because the path matches all the node's children.
- void AddPath(const TProtoStringType& path);
+ void AddPath(y_absl::string_view path);
// Remove a path from the tree.
// If the path is a sub-path of an existing field path in the tree, it means
// we need remove the existing field path and add all sub-paths except
// specified path. If the path matches an existing node in the tree, this node
// will be moved.
- void RemovePath(const TProtoStringType& path, const Descriptor* descriptor);
+ void RemovePath(y_absl::string_view path, const Descriptor* descriptor);
// Calculate the intersection part of a field path with this tree and add
// the intersection field path into out.
- void IntersectPath(const TProtoStringType& path, FieldMaskTree* out);
+ void IntersectPath(y_absl::string_view path, FieldMaskTree* out);
// Merge all fields specified by this tree from one message to another.
void MergeMessage(const Message& source,
@@ -245,31 +257,26 @@ class FieldMaskTree {
private:
struct Node {
- Node() {}
+ Node() = default;
+ Node(const Node&) = delete;
+ Node& operator=(const Node&) = delete;
~Node() { ClearChildren(); }
void ClearChildren() {
- for (std::map<TProtoStringType, Node*>::iterator it = children.begin();
- it != children.end(); ++it) {
- delete it->second;
- }
children.clear();
}
- std::map<TProtoStringType, Node*> children;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Node);
+ y_absl::btree_map<TProtoStringType, std::unique_ptr<Node>> children;
};
// Merge a sub-tree to mask. This method adds the field paths represented
// by all leaf nodes descended from "node" to mask.
- void MergeToFieldMask(const TProtoStringType& prefix, const Node* node,
+ void MergeToFieldMask(y_absl::string_view prefix, const Node* node,
FieldMask* out);
// Merge all leaf nodes of a sub-tree to another tree.
- void MergeLeafNodesToTree(const TProtoStringType& prefix, const Node* node,
+ void MergeLeafNodesToTree(y_absl::string_view prefix, const Node* node,
FieldMaskTree* out);
// Merge all fields specified by a sub-tree from one message to another.
@@ -288,8 +295,6 @@ class FieldMaskTree {
bool TrimMessage(const Node* node, Message* message);
Node root_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldMaskTree);
};
FieldMaskTree::FieldMaskTree() {}
@@ -306,8 +311,8 @@ void FieldMaskTree::MergeToFieldMask(FieldMask* mask) {
MergeToFieldMask("", &root_, mask);
}
-void FieldMaskTree::MergeToFieldMask(const TProtoStringType& prefix,
- const Node* node, FieldMask* out) {
+void FieldMaskTree::MergeToFieldMask(y_absl::string_view prefix, const Node* node,
+ FieldMask* out) {
if (node->children.empty()) {
if (prefix.empty()) {
// This is the root node.
@@ -316,41 +321,40 @@ void FieldMaskTree::MergeToFieldMask(const TProtoStringType& prefix,
out->add_paths(prefix);
return;
}
- for (std::map<TProtoStringType, Node*>::const_iterator it = node->children.begin();
- it != node->children.end(); ++it) {
+ for (const auto& kv : node->children) {
TProtoStringType current_path =
- prefix.empty() ? it->first : prefix + "." + it->first;
- MergeToFieldMask(current_path, it->second, out);
+ prefix.empty() ? kv.first : y_absl::StrCat(prefix, ".", kv.first);
+ MergeToFieldMask(current_path, kv.second.get(), out);
}
}
-void FieldMaskTree::AddPath(const TProtoStringType& path) {
- std::vector<TProtoStringType> parts = Split(path, ".");
+void FieldMaskTree::AddPath(y_absl::string_view path) {
+ std::vector<y_absl::string_view> parts = y_absl::StrSplit(path, '.');
if (parts.empty()) {
return;
}
bool new_branch = false;
Node* node = &root_;
- for (const TProtoStringType& node_name : parts) {
+ for (y_absl::string_view node_name : parts) {
if (!new_branch && node != &root_ && node->children.empty()) {
// Path matches an existing leaf node. This means the path is already
// covered by this tree (for example, adding "foo.bar.baz" to a tree
// which already contains "foo.bar").
return;
}
- Node*& child = node->children[node_name];
+ std::unique_ptr<Node>& child = node->children[node_name];
if (child == nullptr) {
new_branch = true;
- child = new Node();
+ child = y_absl::make_unique<Node>();
}
- node = child;
+ node = child.get();
}
if (!node->children.empty()) {
node->ClearChildren();
}
}
-void FieldMaskTree::RemovePath(const TProtoStringType& path,
+void FieldMaskTree::RemovePath(y_absl::string_view path,
const Descriptor* descriptor) {
if (root_.children.empty()) {
// Nothing to be removed from an empty tree. We shortcut it here so an empty
@@ -358,7 +362,7 @@ void FieldMaskTree::RemovePath(const TProtoStringType& path,
// code below.
return;
}
- std::vector<TProtoStringType> parts = Split(path, ".");
+ std::vector<y_absl::string_view> parts = y_absl::StrSplit(path, '.');
if (parts.empty()) {
return;
}
@@ -386,22 +390,19 @@ void FieldMaskTree::RemovePath(const TProtoStringType& path,
new_branch_node = node;
}
for (int j = 0; j < current_descriptor->field_count(); ++j) {
- node->children[current_descriptor->field(j)->name()] = new Node();
+ node->children[current_descriptor->field(j)->name()] =
+ y_absl::make_unique<Node>();
}
}
- if (ContainsKey(node->children, parts[i])) {
- node = node->children[parts[i]];
- if (field_descriptor->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- current_descriptor = field_descriptor->message_type();
- }
- } else {
- // Path does not exist.
- return;
+ auto it = node->children.find(parts[i]);
+ if (it == node->children.end()) return;
+ node = it->second.get();
+ if (field_descriptor->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
+ current_descriptor = field_descriptor->message_type();
}
}
// Remove path.
for (int i = parts.size() - 1; i >= 0; i--) {
- delete nodes[i]->children[parts[i]];
nodes[i]->children.erase(parts[i]);
if (!nodes[i]->children.empty()) {
break;
@@ -409,69 +410,67 @@ void FieldMaskTree::RemovePath(const TProtoStringType& path,
}
}
-void FieldMaskTree::IntersectPath(const TProtoStringType& path, FieldMaskTree* out) {
- std::vector<TProtoStringType> parts = Split(path, ".");
+void FieldMaskTree::IntersectPath(y_absl::string_view path, FieldMaskTree* out) {
+ std::vector<y_absl::string_view> parts = y_absl::StrSplit(path, '.');
if (parts.empty()) {
return;
}
const Node* node = &root_;
- for (const TProtoStringType& node_name : parts) {
+ for (y_absl::string_view node_name : parts) {
if (node->children.empty()) {
if (node != &root_) {
out->AddPath(path);
}
return;
}
- const Node* result = FindPtrOrNull(node->children, node_name);
- if (result == nullptr) {
+ auto it = node->children.find(node_name);
+ if (it == node->children.end()) {
// No intersection found.
return;
}
- node = result;
+ node = it->second.get();
}
// Now we found a matching node with the given path. Add all leaf nodes
// to out.
MergeLeafNodesToTree(path, node, out);
}
-void FieldMaskTree::MergeLeafNodesToTree(const TProtoStringType& prefix,
+void FieldMaskTree::MergeLeafNodesToTree(y_absl::string_view prefix,
const Node* node, FieldMaskTree* out) {
if (node->children.empty()) {
out->AddPath(prefix);
}
- for (std::map<TProtoStringType, Node*>::const_iterator it = node->children.begin();
- it != node->children.end(); ++it) {
+ for (const auto& kv : node->children) {
TProtoStringType current_path =
- prefix.empty() ? it->first : prefix + "." + it->first;
- MergeLeafNodesToTree(current_path, it->second, out);
+ prefix.empty() ? kv.first : y_absl::StrCat(prefix, ".", kv.first);
+ MergeLeafNodesToTree(current_path, kv.second.get(), out);
}
}
void FieldMaskTree::MergeMessage(const Node* node, const Message& source,
const FieldMaskUtil::MergeOptions& options,
Message* destination) {
- GOOGLE_DCHECK(!node->children.empty());
+ Y_ABSL_DCHECK(!node->children.empty());
const Reflection* source_reflection = source.GetReflection();
const Reflection* destination_reflection = destination->GetReflection();
const Descriptor* descriptor = source.GetDescriptor();
- for (std::map<TProtoStringType, Node*>::const_iterator it = node->children.begin();
- it != node->children.end(); ++it) {
- const TProtoStringType& field_name = it->first;
- const Node* child = it->second;
+ for (const auto& kv : node->children) {
+ y_absl::string_view field_name = kv.first;
+ const Node* child = kv.second.get();
const FieldDescriptor* field = descriptor->FindFieldByName(field_name);
if (field == nullptr) {
- GOOGLE_LOG(ERROR) << "Cannot find field \"" << field_name << "\" in message "
- << descriptor->full_name();
+ Y_ABSL_LOG(ERROR) << "Cannot find field \"" << field_name
+ << "\" in message " << descriptor->full_name();
continue;
}
if (!child->children.empty()) {
// Sub-paths are only allowed for singular message fields.
if (field->is_repeated() ||
field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) {
- GOOGLE_LOG(ERROR) << "Field \"" << field_name << "\" in message "
- << descriptor->full_name()
- << " is not a singular message field and cannot "
- << "have sub-fields.";
+ Y_ABSL_LOG(ERROR) << "Field \"" << field_name << "\" in message "
+ << descriptor->full_name()
+ << " is not a singular message field and cannot "
+ << "have sub-fields.";
continue;
}
MergeMessage(child, source_reflection->GetMessage(source, field), options,
@@ -556,11 +555,11 @@ void FieldMaskTree::AddRequiredFieldPath(Node* node,
for (int index = 0; index < field_count; ++index) {
const FieldDescriptor* field = descriptor->field(index);
if (field->is_required()) {
- const TProtoStringType& node_name = field->name();
- Node*& child = node->children[node_name];
+ y_absl::string_view node_name = field->name();
+ std::unique_ptr<Node>& child = node->children[node_name];
if (child == nullptr) {
// Add required field path to the tree
- child = new Node();
+ child = y_absl::make_unique<Node>();
} else if (child->children.empty()) {
// If the required field is in the tree and does not have any children,
// do nothing.
@@ -568,15 +567,14 @@ void FieldMaskTree::AddRequiredFieldPath(Node* node,
}
// Add required field in the children to the tree if the field is message.
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- AddRequiredFieldPath(child, field->message_type());
+ AddRequiredFieldPath(child.get(), field->message_type());
}
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- std::map<TProtoStringType, Node*>::const_iterator it =
- node->children.find(field->name());
+ auto it = node->children.find(field->name());
if (it != node->children.end()) {
// Add required fields in the children to the
// tree if the field is a message and present in the tree.
- Node* child = it->second;
+ Node* child = it->second.get();
if (!child->children.empty()) {
AddRequiredFieldPath(child, field->message_type());
}
@@ -586,15 +584,14 @@ void FieldMaskTree::AddRequiredFieldPath(Node* node,
}
bool FieldMaskTree::TrimMessage(const Node* node, Message* message) {
- GOOGLE_DCHECK(!node->children.empty());
+ Y_ABSL_DCHECK(!node->children.empty());
const Reflection* reflection = message->GetReflection();
const Descriptor* descriptor = message->GetDescriptor();
const arc_i32 field_count = descriptor->field_count();
bool modified = false;
for (int index = 0; index < field_count; ++index) {
const FieldDescriptor* field = descriptor->field(index);
- std::map<TProtoStringType, Node*>::const_iterator it =
- node->children.find(field->name());
+ auto it = node->children.find(field->name());
if (it == node->children.end()) {
if (field->is_repeated()) {
if (reflection->FieldSize(*message, field) != 0) {
@@ -608,7 +605,7 @@ bool FieldMaskTree::TrimMessage(const Node* node, Message* message) {
reflection->ClearField(message, field);
} else {
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- Node* child = it->second;
+ Node* child = it->second.get();
if (!child->children.empty() && reflection->HasField(*message, field)) {
bool nestedMessageChanged =
TrimMessage(child, reflection->MutableMessage(message, field));
@@ -665,18 +662,19 @@ void FieldMaskUtil::Subtract(const Descriptor* descriptor,
tree.MergeToFieldMask(out);
}
-bool FieldMaskUtil::IsPathInFieldMask(StringPiece path,
+bool FieldMaskUtil::IsPathInFieldMask(y_absl::string_view path,
const FieldMask& mask) {
for (int i = 0; i < mask.paths_size(); ++i) {
- const TProtoStringType& mask_path = mask.paths(i);
- if (path == mask_path) {
+ y_absl::string_view current = path;
+ y_absl::string_view mask_path = mask.paths(i);
+ if (current == mask_path) {
return true;
- } else if (mask_path.length() < path.length()) {
+ }
// Also check whether mask.paths(i) is a prefix of path.
- if (path.substr(0, mask_path.length() + 1).compare(mask_path + ".") ==
- 0) {
- return true;
- }
+ if (mask_path.length() < current.length() &&
+ y_absl::ConsumePrefix(&current, mask_path) &&
+ y_absl::ConsumePrefix(&current, ".")) {
+ return true;
}
}
return false;
@@ -685,7 +683,7 @@ bool FieldMaskUtil::IsPathInFieldMask(StringPiece path,
void FieldMaskUtil::MergeMessageTo(const Message& source, const FieldMask& mask,
const MergeOptions& options,
Message* destination) {
- GOOGLE_CHECK(source.GetDescriptor() == destination->GetDescriptor());
+ Y_ABSL_CHECK(source.GetDescriptor() == destination->GetDescriptor());
// Build a FieldMaskTree and walk through the tree to merge all specified
// fields.
FieldMaskTree tree;
@@ -698,7 +696,7 @@ bool FieldMaskUtil::TrimMessage(const FieldMask& mask, Message* message) {
// fields.
FieldMaskTree tree;
tree.MergeFromFieldMask(mask);
- return tree.TrimMessage(GOOGLE_CHECK_NOTNULL(message));
+ return tree.TrimMessage(Y_ABSL_DIE_IF_NULL(message));
}
bool FieldMaskUtil::TrimMessage(const FieldMask& mask, Message* message,
@@ -710,9 +708,9 @@ bool FieldMaskUtil::TrimMessage(const FieldMask& mask, Message* message,
// If keep_required_fields is true, implicitly add required fields of
// a message present in the tree to prevent from trimming.
if (options.keep_required_fields()) {
- tree.AddRequiredFieldPath(GOOGLE_CHECK_NOTNULL(message->GetDescriptor()));
+ tree.AddRequiredFieldPath(Y_ABSL_DIE_IF_NULL(message->GetDescriptor()));
}
- return tree.TrimMessage(GOOGLE_CHECK_NOTNULL(message));
+ return tree.TrimMessage(Y_ABSL_DIE_IF_NULL(message));
}
} // namespace util
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 10a5eb2dbb8..89ee7c2607d 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
@@ -35,13 +35,15 @@
#include <cstdint>
#include <string>
+#include <vector>
-#include <google/protobuf/field_mask.pb.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/descriptor.h>
+#include "google/protobuf/field_mask.pb.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/descriptor.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -54,7 +56,7 @@ class PROTOBUF_EXPORT FieldMaskUtil {
// Converts FieldMask to/from string, formatted by separating each path
// with a comma (e.g., "foo_bar,baz.quz").
static TProtoStringType ToString(const FieldMask& mask);
- static void FromString(StringPiece str, FieldMask* out);
+ static void FromString(y_absl::string_view str, FieldMask* out);
// Populates the FieldMask with the paths corresponding to the fields with the
// given numbers, after checking that all field numbers are valid.
@@ -64,7 +66,7 @@ class PROTOBUF_EXPORT FieldMaskUtil {
for (const auto field_number : field_numbers) {
const FieldDescriptor* field_desc =
T::descriptor()->FindFieldByNumber(field_number);
- GOOGLE_CHECK(field_desc != nullptr)
+ Y_ABSL_CHECK(field_desc != nullptr)
<< "Invalid field number for " << T::descriptor()->full_name() << ": "
<< field_number;
AddPathToFieldMask<T>(field_desc->lowercase_name(), out);
@@ -76,19 +78,19 @@ class PROTOBUF_EXPORT FieldMaskUtil {
// style conforming (i.e., not snake_case when converted to string, or not
// camelCase when converted from string), the conversion will fail.
static bool ToJsonString(const FieldMask& mask, TProtoStringType* out);
- static bool FromJsonString(StringPiece str, FieldMask* out);
+ static bool FromJsonString(y_absl::string_view str, FieldMask* out);
// Get the descriptors of the fields which the given path from the message
// descriptor traverses, if field_descriptors is not null.
// Return false if the path is not valid, and the content of field_descriptors
// is unspecified.
static bool GetFieldDescriptors(
- const Descriptor* descriptor, StringPiece path,
+ const Descriptor* descriptor, y_absl::string_view path,
std::vector<const FieldDescriptor*>* field_descriptors);
// Checks whether the given path is valid for type T.
template <typename T>
- static bool IsValidPath(StringPiece path) {
+ static bool IsValidPath(y_absl::string_view path) {
return GetFieldDescriptors(T::descriptor(), path, nullptr);
}
@@ -106,8 +108,8 @@ class PROTOBUF_EXPORT FieldMaskUtil {
// Adds a path to FieldMask after checking whether the given path is valid.
// This method check-fails if the path is not a valid path for type T.
template <typename T>
- static void AddPathToFieldMask(StringPiece path, FieldMask* mask) {
- GOOGLE_CHECK(IsValidPath<T>(path)) << path;
+ static void AddPathToFieldMask(y_absl::string_view path, FieldMask* mask) {
+ Y_ABSL_CHECK(IsValidPath<T>(path)) << path;
mask->add_paths(TProtoStringType(path));
}
@@ -159,7 +161,7 @@ class PROTOBUF_EXPORT FieldMaskUtil {
// "foo.bar" covers all paths like "foo.bar.baz", "foo.bar.quz.x", etc.
// Also note that parent paths are not covered by explicit child path, i.e.
// "foo.bar" does NOT cover "foo", even if "bar" is the only child.
- static bool IsPathInFieldMask(StringPiece path, const FieldMask& mask);
+ static bool IsPathInFieldMask(y_absl::string_view path, const FieldMask& mask);
class MergeOptions;
// Merges fields specified in a FieldMask into another message.
@@ -194,7 +196,7 @@ class PROTOBUF_EXPORT FieldMaskUtil {
// Note that the input can contain characters not allowed in C identifiers.
// For example, "foo_bar,baz_quz" will be converted to "fooBar,bazQuz"
// successfully.
- static bool SnakeCaseToCamelCase(StringPiece input,
+ static bool SnakeCaseToCamelCase(y_absl::string_view input,
TProtoStringType* output);
// Converts a field name from camelCase to snake_case:
// 1. Every uppercase letter is converted to lowercase with an additional
@@ -208,7 +210,7 @@ class PROTOBUF_EXPORT FieldMaskUtil {
// Note that the input can contain characters not allowed in C identifiers.
// For example, "fooBar,bazQuz" will be converted to "foo_bar,baz_quz"
// successfully.
- static bool CamelCaseToSnakeCase(StringPiece input,
+ static bool CamelCaseToSnakeCase(y_absl::string_view input,
TProtoStringType* output);
};
@@ -258,6 +260,6 @@ class PROTOBUF_EXPORT FieldMaskUtil::TrimOptions {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_UTIL_FIELD_MASK_UTIL_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/constants.h b/contrib/libs/protobuf/src/google/protobuf/util/internal/constants.h
deleted file mode 100644
index e7b8f4483fd..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/constants.h
+++ /dev/null
@@ -1,101 +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_UTIL_INTERNAL_CONSTANTS_H__
-#define GOOGLE_PROTOBUF_UTIL_INTERNAL_CONSTANTS_H__
-
-#include <cstdint>
-
-#include <google/protobuf/stubs/common.h>
-
-// This file contains constants used by //net/proto2/util/converter.
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-// Prefix for type URLs.
-const char kTypeServiceBaseUrl[] = "type.googleapis.com";
-
-// Format string for RFC3339 timestamp formatting.
-const char kRfc3339TimeFormat[] = "%E4Y-%m-%dT%H:%M:%S";
-
-// Same as above, but the year value is not zero-padded i.e. this accepts
-// timestamps like "1-01-0001T23:59:59Z" instead of "0001-01-0001T23:59:59Z".
-const char kRfc3339TimeFormatNoPadding[] = "%Y-%m-%dT%H:%M:%S";
-
-// Minimum seconds allowed in a google.protobuf.Timestamp value.
-const arc_i64 kTimestampMinSeconds = -62135596800LL;
-
-// Maximum seconds allowed in a google.protobuf.Timestamp value.
-const arc_i64 kTimestampMaxSeconds = 253402300799LL;
-
-// Minimum seconds allowed in a google.protobuf.Duration value.
-const arc_i64 kDurationMinSeconds = -315576000000LL;
-
-// Maximum seconds allowed in a google.protobuf.Duration value.
-const arc_i64 kDurationMaxSeconds = 315576000000LL;
-
-// Nano seconds in a second.
-const arc_i32 kNanosPerSecond = 1000000000;
-
-// Type url representing NULL values in google.protobuf.Struct type.
-const char kStructNullValueTypeUrl[] =
- "type.googleapis.com/google.protobuf.NullValue";
-
-// Type string for google.protobuf.Struct
-const char kStructType[] = "google.protobuf.Struct";
-
-// Type string for struct.proto's google.protobuf.Value value type.
-const char kStructValueType[] = "google.protobuf.Value";
-
-// Type string for struct.proto's google.protobuf.ListValue value type.
-const char kStructListValueType[] = "google.protobuf.ListValue";
-
-// Type string for google.protobuf.Timestamp
-const char kTimestampType[] = "google.protobuf.Timestamp";
-
-// Type string for google.protobuf.Duration
-const char kDurationType[] = "google.protobuf.Duration";
-
-// Type URL for struct value type google.protobuf.Value
-const char kStructValueTypeUrl[] = "type.googleapis.com/google.protobuf.Value";
-
-// Type string for google.protobuf.Any
-const char kAnyType[] = "google.protobuf.Any";
-
-// The protobuf option name of jspb.message_id;
-const char kOptionJspbMessageId[] = "jspb.message_id";
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
-#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
deleted file mode 100644
index 1ae65eb21fd..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/datapiece.cc
+++ /dev/null
@@ -1,441 +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/util/internal/datapiece.h>
-
-#include <cmath>
-#include <cstdint>
-#include <limits>
-
-#include <google/protobuf/struct.pb.h>
-#include <google/protobuf/type.pb.h>
-#include <google/protobuf/descriptor.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 {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-using util::Status;
-
-namespace {
-
-template <typename To, typename From>
-util::StatusOr<To> ValidateNumberConversion(To after, From before) {
- if (after == before &&
- MathUtil::Sign<From>(before) == MathUtil::Sign<To>(after)) {
- return after;
- } else {
- return util::InvalidArgumentError(
- std::is_integral<From>::value ? ValueAsString(before)
- : std::is_same<From, double>::value ? DoubleAsString(before)
- : FloatAsString(before));
- }
-}
-
-// For general conversion between
-// int32, int64, uint32, uint64, double and float
-// except conversion between double and float.
-template <typename To, typename From>
-util::StatusOr<To> NumberConvertAndCheck(From before) {
- if (std::is_same<From, To>::value) return before;
-
- To after = static_cast<To>(before);
- return ValidateNumberConversion(after, before);
-}
-
-// For conversion to integer types (int32, int64, uint32, uint64) from floating
-// point types (double, float) only.
-template <typename To, typename From>
-util::StatusOr<To> FloatingPointToIntConvertAndCheck(From before) {
- if (std::is_same<From, To>::value) return before;
-
- To after = static_cast<To>(before);
- return ValidateNumberConversion(after, before);
-}
-
-// For conversion between double and float only.
-util::StatusOr<double> FloatToDouble(float before) {
- // Casting float to double should just work as double has more precision
- // than float.
- return static_cast<double>(before);
-}
-
-util::StatusOr<float> DoubleToFloat(double before) {
- if (std::isnan(before)) {
- return std::numeric_limits<float>::quiet_NaN();
- } else if (!std::isfinite(before)) {
- // Converting a double +inf/-inf to float should just work.
- return static_cast<float>(before);
- } else if (before > std::numeric_limits<float>::max() ||
- before < -std::numeric_limits<float>::max()) {
- // Some doubles are larger than the largest float, but after
- // rounding they will be equal to the largest float.
- // We can't just attempt the conversion because that has UB if
- // the value really is out-of-range.
- // Here we take advantage that 1/2-ing a large floating point
- // will not lose precision.
- double half_before = before * 0.5;
- if (half_before < std::numeric_limits<float>::max() &&
- half_before > -std::numeric_limits<float>::max()) {
- const float half_fmax = std::numeric_limits<float>::max() * 0.5f;
- // If after being cut in half, the value is less than the largest float,
- // then it's safe to convert it to float. Importantly, this conversion
- // rounds in the same way that the original does.
- float half_after = static_cast<float>(half_before);
- if (half_after <= half_fmax && half_after >= -half_fmax) {
- return half_after + half_after;
- }
- }
- // Double value outside of the range of float.
- return util::InvalidArgumentError(DoubleAsString(before));
- } else {
- return static_cast<float>(before);
- }
-}
-
-} // namespace
-
-util::StatusOr<arc_i32> DataPiece::ToInt32() const {
- if (type_ == TYPE_STRING)
- return StringToNumber<arc_i32>(safe_strto32);
-
- if (type_ == TYPE_DOUBLE)
- return FloatingPointToIntConvertAndCheck<arc_i32, double>(double_);
-
- if (type_ == TYPE_FLOAT)
- return FloatingPointToIntConvertAndCheck<arc_i32, float>(float_);
-
- return GenericConvert<arc_i32>();
-}
-
-util::StatusOr<arc_ui32> DataPiece::ToUint32() const {
- if (type_ == TYPE_STRING)
- return StringToNumber<arc_ui32>(safe_strtou32);
-
- if (type_ == TYPE_DOUBLE)
- return FloatingPointToIntConvertAndCheck<arc_ui32, double>(double_);
-
- if (type_ == TYPE_FLOAT)
- return FloatingPointToIntConvertAndCheck<arc_ui32, float>(float_);
-
- return GenericConvert<arc_ui32>();
-}
-
-util::StatusOr<arc_i64> DataPiece::ToInt64() const {
- if (type_ == TYPE_STRING)
- return StringToNumber<arc_i64>(safe_strto64);
-
- if (type_ == TYPE_DOUBLE)
- return FloatingPointToIntConvertAndCheck<arc_i64, double>(double_);
-
- if (type_ == TYPE_FLOAT)
- return FloatingPointToIntConvertAndCheck<arc_i64, float>(float_);
-
- return GenericConvert<arc_i64>();
-}
-
-util::StatusOr<arc_ui64> DataPiece::ToUint64() const {
- if (type_ == TYPE_STRING)
- return StringToNumber<arc_ui64>(safe_strtou64);
-
- if (type_ == TYPE_DOUBLE)
- return FloatingPointToIntConvertAndCheck<arc_ui64, double>(double_);
-
- if (type_ == TYPE_FLOAT)
- return FloatingPointToIntConvertAndCheck<arc_ui64, float>(float_);
-
- return GenericConvert<arc_ui64>();
-}
-
-util::StatusOr<double> DataPiece::ToDouble() const {
- if (type_ == TYPE_FLOAT) {
- return FloatToDouble(float_);
- }
- if (type_ == TYPE_STRING) {
- if (str_ == "Infinity") return std::numeric_limits<double>::infinity();
- if (str_ == "-Infinity") return -std::numeric_limits<double>::infinity();
- if (str_ == "NaN") return std::numeric_limits<double>::quiet_NaN();
- util::StatusOr<double> value = StringToNumber<double>(safe_strtod);
- if (value.ok() && !std::isfinite(value.value())) {
- // safe_strtod converts out-of-range values to +inf/-inf, but we want
- // to report them as errors.
- return util::InvalidArgumentError(StrCat("\"", str_, "\""));
- } else {
- return value;
- }
- }
- return GenericConvert<double>();
-}
-
-util::StatusOr<float> DataPiece::ToFloat() const {
- if (type_ == TYPE_DOUBLE) {
- return DoubleToFloat(double_);
- }
- if (type_ == TYPE_STRING) {
- if (str_ == "Infinity") return std::numeric_limits<float>::infinity();
- if (str_ == "-Infinity") return -std::numeric_limits<float>::infinity();
- if (str_ == "NaN") return std::numeric_limits<float>::quiet_NaN();
- // SafeStrToFloat() is used instead of safe_strtof() because the later
- // does not fail on inputs like SimpleDtoa(DBL_MAX).
- return StringToNumber<float>(SafeStrToFloat);
- }
- return GenericConvert<float>();
-}
-
-util::StatusOr<bool> DataPiece::ToBool() const {
- switch (type_) {
- case TYPE_BOOL:
- return bool_;
- case TYPE_STRING:
- return StringToNumber<bool>(safe_strtob);
- default:
- return util::InvalidArgumentError(
- ValueAsStringOrDefault("Wrong type. Cannot convert to Bool."));
- }
-}
-
-util::StatusOr<TProtoStringType> DataPiece::ToString() const {
- switch (type_) {
- case TYPE_STRING:
- return TProtoStringType(str_);
- case TYPE_BYTES: {
- TProtoStringType base64;
- Base64Escape(str_, &base64);
- return base64;
- }
- default:
- return util::InvalidArgumentError(
- ValueAsStringOrDefault("Cannot convert to string."));
- }
-}
-
-TProtoStringType DataPiece::ValueAsStringOrDefault(
- StringPiece default_string) const {
- switch (type_) {
- case TYPE_INT32:
- return StrCat(i32_);
- case TYPE_INT64:
- return StrCat(i64_);
- case TYPE_UINT32:
- return StrCat(u32_);
- case TYPE_UINT64:
- return StrCat(u64_);
- case TYPE_DOUBLE:
- return DoubleAsString(double_);
- case TYPE_FLOAT:
- return FloatAsString(float_);
- case TYPE_BOOL:
- return SimpleBtoa(bool_);
- case TYPE_STRING:
- return StrCat("\"", str_.ToString(), "\"");
- case TYPE_BYTES: {
- TProtoStringType base64;
- WebSafeBase64Escape(str_, &base64);
- return StrCat("\"", base64, "\"");
- }
- case TYPE_NULL:
- return "null";
- default:
- return TProtoStringType(default_string);
- }
-}
-
-util::StatusOr<TProtoStringType> DataPiece::ToBytes() const {
- if (type_ == TYPE_BYTES) return str_.ToString();
- if (type_ == TYPE_STRING) {
- TProtoStringType decoded;
- if (!DecodeBase64(str_, &decoded)) {
- return util::InvalidArgumentError(
- ValueAsStringOrDefault("Invalid data in input."));
- }
- return decoded;
- } else {
- return util::InvalidArgumentError(ValueAsStringOrDefault(
- "Wrong type. Only String or Bytes can be converted to Bytes."));
- }
-}
-
-util::StatusOr<int> DataPiece::ToEnum(const google::protobuf::Enum* enum_type,
- bool use_lower_camel_for_enums,
- bool case_insensitive_enum_parsing,
- bool ignore_unknown_enum_values,
- bool* is_unknown_enum_value) const {
- if (type_ == TYPE_NULL) return google::protobuf::NULL_VALUE;
-
- if (type_ == TYPE_STRING) {
- // First try the given value as a name.
- TProtoStringType enum_name = TProtoStringType(str_);
- const google::protobuf::EnumValue* value =
- FindEnumValueByNameOrNull(enum_type, enum_name);
- if (value != nullptr) return value->number();
-
- // Check if int version of enum is sent as string.
- util::StatusOr<arc_i32> int_value = ToInt32();
- if (int_value.ok()) {
- if (const google::protobuf::EnumValue* enum_value =
- FindEnumValueByNumberOrNull(enum_type, int_value.value())) {
- return enum_value->number();
- }
- }
-
- // Next try a normalized name.
- bool should_normalize_enum =
- case_insensitive_enum_parsing || use_lower_camel_for_enums;
- if (should_normalize_enum) {
- for (TProtoStringType::iterator it = enum_name.begin(); it != enum_name.end();
- ++it) {
- *it = *it == '-' ? '_' : ascii_toupper(*it);
- }
- value = FindEnumValueByNameOrNull(enum_type, enum_name);
- if (value != nullptr) return value->number();
- }
-
- // If use_lower_camel_for_enums is true try with enum name without
- // underscore. This will also accept camel case names as the enum_name has
- // been normalized before.
- if (use_lower_camel_for_enums) {
- value = FindEnumValueByNameWithoutUnderscoreOrNull(enum_type, enum_name);
- if (value != nullptr) return value->number();
- }
-
- // If ignore_unknown_enum_values is true an unknown enum value is ignored.
- if (ignore_unknown_enum_values) {
- *is_unknown_enum_value = true;
- if (enum_type->enumvalue_size() > 0) {
- return enum_type->enumvalue(0).number();
- }
- }
- } else {
- // We don't need to check whether the value is actually declared in the
- // enum because we preserve unknown enum values as well.
- return ToInt32();
- }
- return util::InvalidArgumentError(
- ValueAsStringOrDefault("Cannot find enum with given value."));
-}
-
-template <typename To>
-util::StatusOr<To> DataPiece::GenericConvert() const {
- switch (type_) {
- case TYPE_INT32:
- return NumberConvertAndCheck<To, arc_i32>(i32_);
- case TYPE_INT64:
- return NumberConvertAndCheck<To, arc_i64>(i64_);
- case TYPE_UINT32:
- return NumberConvertAndCheck<To, arc_ui32>(u32_);
- case TYPE_UINT64:
- return NumberConvertAndCheck<To, arc_ui64>(u64_);
- case TYPE_DOUBLE:
- return NumberConvertAndCheck<To, double>(double_);
- case TYPE_FLOAT:
- return NumberConvertAndCheck<To, float>(float_);
- default: // TYPE_ENUM, TYPE_STRING, TYPE_CORD, TYPE_BOOL
- return util::InvalidArgumentError(ValueAsStringOrDefault(
- "Wrong type. Bool, Enum, String and Cord not supported in "
- "GenericConvert."));
- }
-}
-
-template <typename To>
-util::StatusOr<To> DataPiece::StringToNumber(bool (*func)(StringPiece,
- To*)) const {
- if (str_.size() > 0 && (str_[0] == ' ' || str_[str_.size() - 1] == ' ')) {
- return util::InvalidArgumentError(StrCat("\"", str_, "\""));
- }
- To result;
- if (func(str_, &result)) return result;
- return util::InvalidArgumentError(
- StrCat("\"", TProtoStringType(str_), "\""));
-}
-
-bool DataPiece::DecodeBase64(StringPiece src, TProtoStringType* dest) const {
- // Try web-safe decode first, if it fails, try the non-web-safe decode.
- if (WebSafeBase64Unescape(src, dest)) {
- if (use_strict_base64_decoding_) {
- // In strict mode, check if the escaped version gives us the same value as
- // unescaped.
- TProtoStringType encoded;
- // WebSafeBase64Escape does no padding by default.
- WebSafeBase64Escape(*dest, &encoded);
- // Remove trailing padding '=' characters before comparison.
- StringPiece src_no_padding = StringPiece(src).substr(
- 0, HasSuffixString(src, "=") ? src.find_last_not_of('=') + 1
- : src.length());
- return encoded == src_no_padding;
- }
- return true;
- }
-
- if (Base64Unescape(src, dest)) {
- if (use_strict_base64_decoding_) {
- TProtoStringType encoded;
- Base64Escape(reinterpret_cast<const unsigned char*>(dest->data()),
- dest->length(), &encoded, false);
- StringPiece src_no_padding = StringPiece(src).substr(
- 0, HasSuffixString(src, "=") ? src.find_last_not_of('=') + 1
- : src.length());
- return encoded == src_no_padding;
- }
- return true;
- }
-
- return false;
-}
-
-void DataPiece::InternalCopy(const DataPiece& other) {
- type_ = other.type_;
- use_strict_base64_decoding_ = other.use_strict_base64_decoding_;
- switch (type_) {
- case TYPE_INT32:
- case TYPE_INT64:
- case TYPE_UINT32:
- case TYPE_UINT64:
- case TYPE_DOUBLE:
- case TYPE_FLOAT:
- case TYPE_BOOL:
- case TYPE_ENUM:
- case TYPE_NULL:
- case TYPE_BYTES:
- case TYPE_STRING: {
- str_ = other.str_;
- break;
- }
- }
-}
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // 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
deleted file mode 100644
index bef9e389f2e..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/datapiece.h
+++ /dev/null
@@ -1,219 +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_UTIL_INTERNAL_DATAPIECE_H__
-#define GOOGLE_PROTOBUF_UTIL_INTERNAL_DATAPIECE_H__
-
-#include <cstdint>
-#include <string>
-
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/type.pb.h>
-#include <google/protobuf/stubs/statusor.h>
-#include <google/protobuf/stubs/strutil.h>
-
-// Must be included last.
-#include <google/protobuf/port_def.inc>
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-class ProtoWriter;
-
-// Container for a single piece of data together with its data type.
-//
-// For primitive types (int32, int64, uint32, uint64, double, float, bool),
-// the data is stored by value.
-//
-// For string, a StringPiece is stored. For Cord, a pointer to Cord is stored.
-// Just like StringPiece, the DataPiece class does not own the storage for
-// the actual string or Cord, so it is the user's responsibility to guarantee
-// that the underlying storage is still valid when the DataPiece is accessed.
-class PROTOBUF_EXPORT DataPiece {
- public:
- // Identifies data type of the value.
- // These are the types supported by DataPiece.
- enum Type {
- TYPE_INT32 = 1,
- TYPE_INT64 = 2,
- TYPE_UINT32 = 3,
- TYPE_UINT64 = 4,
- TYPE_DOUBLE = 5,
- TYPE_FLOAT = 6,
- TYPE_BOOL = 7,
- TYPE_ENUM = 8,
- TYPE_STRING = 9,
- TYPE_BYTES = 10,
- TYPE_NULL = 11, // explicit NULL type
- };
-
- // Constructors and Destructor
- explicit DataPiece(const arc_i32 value)
- : type_(TYPE_INT32), i32_(value), use_strict_base64_decoding_(false) {}
- explicit DataPiece(const arc_i64 value)
- : type_(TYPE_INT64), i64_(value), use_strict_base64_decoding_(false) {}
- explicit DataPiece(const arc_ui32 value)
- : type_(TYPE_UINT32), u32_(value), use_strict_base64_decoding_(false) {}
- explicit DataPiece(const arc_ui64 value)
- : type_(TYPE_UINT64), u64_(value), use_strict_base64_decoding_(false) {}
- explicit DataPiece(const double value)
- : type_(TYPE_DOUBLE),
- double_(value),
- use_strict_base64_decoding_(false) {}
- explicit DataPiece(const float value)
- : type_(TYPE_FLOAT), float_(value), use_strict_base64_decoding_(false) {}
- explicit DataPiece(const bool value)
- : type_(TYPE_BOOL), bool_(value), use_strict_base64_decoding_(false) {}
- DataPiece(StringPiece value, bool use_strict_base64_decoding)
- : type_(TYPE_STRING),
- str_(value),
- use_strict_base64_decoding_(use_strict_base64_decoding) {}
- // Constructor for bytes. The second parameter is not used.
- DataPiece(StringPiece value, bool /*dummy*/, bool use_strict_base64_decoding)
- : type_(TYPE_BYTES),
- str_(value),
- use_strict_base64_decoding_(use_strict_base64_decoding) {}
-
- DataPiece(const DataPiece& r) : type_(r.type_) { InternalCopy(r); }
-
- DataPiece& operator=(const DataPiece& x) {
- InternalCopy(x);
- return *this;
- }
-
- static DataPiece NullData() { return DataPiece(TYPE_NULL, 0); }
-
- virtual ~DataPiece() {
- }
-
- // Accessors
- Type type() const { return type_; }
-
- bool use_strict_base64_decoding() { return use_strict_base64_decoding_; }
-
- StringPiece str() const {
- GOOGLE_LOG_IF(DFATAL, type_ != TYPE_STRING) << "Not a string type.";
- return str_;
- }
-
-
- // Parses, casts or converts the value stored in the DataPiece into an int32.
- util::StatusOr<arc_i32> ToInt32() const;
-
- // Parses, casts or converts the value stored in the DataPiece into a uint32.
- util::StatusOr<arc_ui32> ToUint32() const;
-
- // Parses, casts or converts the value stored in the DataPiece into an int64.
- util::StatusOr<arc_i64> ToInt64() const;
-
- // Parses, casts or converts the value stored in the DataPiece into a uint64.
- util::StatusOr<arc_ui64> ToUint64() const;
-
- // Parses, casts or converts the value stored in the DataPiece into a double.
- util::StatusOr<double> ToDouble() const;
-
- // Parses, casts or converts the value stored in the DataPiece into a float.
- util::StatusOr<float> ToFloat() const;
-
- // Parses, casts or converts the value stored in the DataPiece into a bool.
- util::StatusOr<bool> ToBool() const;
-
- // Parses, casts or converts the value stored in the DataPiece into a string.
- util::StatusOr<TProtoStringType> ToString() const;
-
- // Tries to convert the value contained in this datapiece to string. If the
- // conversion fails, it returns the default_string.
- TProtoStringType ValueAsStringOrDefault(StringPiece default_string) const;
-
- util::StatusOr<TProtoStringType> ToBytes() const;
-
- private:
- friend class ProtoWriter;
-
- // Disallow implicit constructor.
- DataPiece();
-
- // Helper to create NULL or ENUM types.
- DataPiece(Type type, arc_i32 val)
- : type_(type), i32_(val), use_strict_base64_decoding_(false) {}
-
- // Same as the ToEnum() method above but with additional flag to ignore
- // unknown enum values.
- util::StatusOr<int> ToEnum(const google::protobuf::Enum* enum_type,
- bool use_lower_camel_for_enums,
- bool case_insensitive_enum_parsing,
- bool ignore_unknown_enum_values,
- bool* is_unknown_enum_value) const;
-
- // For numeric conversion between
- // int32, int64, uint32, uint64, double, float and bool
- template <typename To>
- util::StatusOr<To> GenericConvert() const;
-
- // For conversion from string to
- // int32, int64, uint32, uint64, double, float and bool
- template <typename To>
- util::StatusOr<To> StringToNumber(bool (*func)(StringPiece, To*)) const;
-
- // Decodes a base64 string. Returns true on success.
- bool DecodeBase64(StringPiece src, TProtoStringType* dest) const;
-
- // Helper function to initialize this DataPiece with 'other'.
- void InternalCopy(const DataPiece& other);
-
- // Data type for this piece of data.
- Type type_;
-
- // Stored piece of data.
- union {
- arc_i32 i32_;
- arc_i64 i64_;
- arc_ui32 u32_;
- arc_ui64 u64_;
- double double_;
- float float_;
- bool bool_;
- StringPiece str_;
- };
-
- // Uses a stricter version of base64 decoding for byte fields.
- bool use_strict_base64_decoding_;
-};
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_DATAPIECE_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.cc b/contrib/libs/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.cc
deleted file mode 100644
index 46b5513d15e..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.cc
+++ /dev/null
@@ -1,642 +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/util/internal/default_value_objectwriter.h>
-
-#include <cstdint>
-#include <unordered_map>
-
-#include <google/protobuf/util/internal/constants.h>
-#include <google/protobuf/util/internal/utility.h>
-#include <google/protobuf/stubs/map_util.h>
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-namespace {
-// Helper function to convert string value to given data type by calling the
-// passed converter function on the DataPiece created from "value" argument.
-// If value is empty or if conversion fails, the default_value is returned.
-template <typename T>
-T ConvertTo(StringPiece value,
- util::StatusOr<T> (DataPiece::*converter_fn)() const,
- T default_value) {
- if (value.empty()) return default_value;
- util::StatusOr<T> result = (DataPiece(value, true).*converter_fn)();
- return result.ok() ? result.value() : default_value;
-}
-} // namespace
-
-DefaultValueObjectWriter::DefaultValueObjectWriter(
- TypeResolver* type_resolver, const google::protobuf::Type& type,
- ObjectWriter* ow)
- : typeinfo_(TypeInfo::NewTypeInfo(type_resolver)),
- own_typeinfo_(true),
- type_(type),
- current_(nullptr),
- root_(nullptr),
- suppress_empty_list_(false),
- preserve_proto_field_names_(false),
- use_ints_for_enums_(false),
- ow_(ow) {}
-
-DefaultValueObjectWriter::~DefaultValueObjectWriter() {
- if (own_typeinfo_) {
- delete typeinfo_;
- }
-}
-
-DefaultValueObjectWriter* DefaultValueObjectWriter::RenderBool(
- StringPiece name, bool value) {
- if (current_ == nullptr) {
- ow_->RenderBool(name, value);
- } else {
- RenderDataPiece(name, DataPiece(value));
- }
- return this;
-}
-
-DefaultValueObjectWriter* DefaultValueObjectWriter::RenderInt32(
- StringPiece name, arc_i32 value) {
- if (current_ == nullptr) {
- ow_->RenderInt32(name, value);
- } else {
- RenderDataPiece(name, DataPiece(value));
- }
- return this;
-}
-
-DefaultValueObjectWriter* DefaultValueObjectWriter::RenderUint32(
- StringPiece name, arc_ui32 value) {
- if (current_ == nullptr) {
- ow_->RenderUint32(name, value);
- } else {
- RenderDataPiece(name, DataPiece(value));
- }
- return this;
-}
-
-DefaultValueObjectWriter* DefaultValueObjectWriter::RenderInt64(
- StringPiece name, arc_i64 value) {
- if (current_ == nullptr) {
- ow_->RenderInt64(name, value);
- } else {
- RenderDataPiece(name, DataPiece(value));
- }
- return this;
-}
-
-DefaultValueObjectWriter* DefaultValueObjectWriter::RenderUint64(
- StringPiece name, arc_ui64 value) {
- if (current_ == nullptr) {
- ow_->RenderUint64(name, value);
- } else {
- RenderDataPiece(name, DataPiece(value));
- }
- return this;
-}
-
-DefaultValueObjectWriter* DefaultValueObjectWriter::RenderDouble(
- StringPiece name, double value) {
- if (current_ == nullptr) {
- ow_->RenderDouble(name, value);
- } else {
- RenderDataPiece(name, DataPiece(value));
- }
- return this;
-}
-
-DefaultValueObjectWriter* DefaultValueObjectWriter::RenderFloat(
- StringPiece name, float value) {
- if (current_ == nullptr) {
- ow_->RenderBool(name, value);
- } else {
- RenderDataPiece(name, DataPiece(value));
- }
- return this;
-}
-
-DefaultValueObjectWriter* DefaultValueObjectWriter::RenderString(
- StringPiece name, StringPiece value) {
- if (current_ == nullptr) {
- ow_->RenderString(name, value);
- } else {
- // Since StringPiece is essentially a pointer, takes a copy of "value" to
- // avoid ownership issues.
- string_values_.emplace_back(new TProtoStringType(value));
- RenderDataPiece(name, DataPiece(*string_values_.back(), true));
- }
- return this;
-}
-
-DefaultValueObjectWriter* DefaultValueObjectWriter::RenderBytes(
- StringPiece name, StringPiece value) {
- if (current_ == nullptr) {
- ow_->RenderBytes(name, value);
- } else {
- // Since StringPiece is essentially a pointer, takes a copy of "value" to
- // avoid ownership issues.
- string_values_.emplace_back(new TProtoStringType(value));
- RenderDataPiece(name, DataPiece(*string_values_.back(), false, true));
- }
- return this;
-}
-
-DefaultValueObjectWriter* DefaultValueObjectWriter::RenderNull(
- StringPiece name) {
- if (current_ == nullptr) {
- ow_->RenderNull(name);
- } else {
- RenderDataPiece(name, DataPiece::NullData());
- }
- return this;
-}
-
-void DefaultValueObjectWriter::RegisterFieldScrubCallBack(
- FieldScrubCallBack field_scrub_callback) {
- field_scrub_callback_ = std::move(field_scrub_callback);
-}
-
-DefaultValueObjectWriter::Node* DefaultValueObjectWriter::CreateNewNode(
- const TProtoStringType& name, const google::protobuf::Type* type, NodeKind kind,
- const DataPiece& data, bool is_placeholder,
- const std::vector<TProtoStringType>& path, bool suppress_empty_list,
- bool preserve_proto_field_names, bool use_ints_for_enums,
- FieldScrubCallBack field_scrub_callback) {
- return new Node(name, type, kind, data, is_placeholder, path,
- suppress_empty_list, preserve_proto_field_names,
- use_ints_for_enums, std::move(field_scrub_callback));
-}
-
-DefaultValueObjectWriter::Node::Node(
- const TProtoStringType& name, const google::protobuf::Type* type, NodeKind kind,
- const DataPiece& data, bool is_placeholder,
- const std::vector<TProtoStringType>& path, bool suppress_empty_list,
- bool preserve_proto_field_names, bool use_ints_for_enums,
- FieldScrubCallBack field_scrub_callback)
- : name_(name),
- type_(type),
- kind_(kind),
- is_any_(false),
- data_(data),
- is_placeholder_(is_placeholder),
- path_(path),
- suppress_empty_list_(suppress_empty_list),
- preserve_proto_field_names_(preserve_proto_field_names),
- use_ints_for_enums_(use_ints_for_enums),
- field_scrub_callback_(std::move(field_scrub_callback)) {}
-
-DefaultValueObjectWriter::Node* DefaultValueObjectWriter::Node::FindChild(
- StringPiece name) {
- if (name.empty() || kind_ != OBJECT) {
- return nullptr;
- }
- for (Node* child : children_) {
- if (child->name() == name) {
- return child;
- }
- }
- return nullptr;
-}
-
-void DefaultValueObjectWriter::Node::WriteTo(ObjectWriter* ow) {
- if (kind_ == PRIMITIVE) {
- ObjectWriter::RenderDataPieceTo(data_, name_, ow);
- return;
- }
-
- // Render maps. Empty maps are rendered as "{}".
- if (kind_ == MAP) {
- ow->StartObject(name_);
- WriteChildren(ow);
- ow->EndObject();
- return;
- }
-
- // Write out lists. If we didn't have any list in response, write out empty
- // list.
- if (kind_ == LIST) {
- // Suppress empty lists if requested.
- if (suppress_empty_list_ && is_placeholder_) return;
-
- ow->StartList(name_);
- WriteChildren(ow);
- ow->EndList();
- return;
- }
-
- // If is_placeholder_ = true, we didn't see this node in the response, so
- // skip output.
- if (is_placeholder_) return;
-
- ow->StartObject(name_);
- WriteChildren(ow);
- ow->EndObject();
-}
-
-void DefaultValueObjectWriter::Node::WriteChildren(ObjectWriter* ow) {
- for (Node* child : children_) {
- child->WriteTo(ow);
- }
-}
-
-const google::protobuf::Type* DefaultValueObjectWriter::Node::GetMapValueType(
- const google::protobuf::Type& found_type, const TypeInfo* typeinfo) {
- // If this field is a map, we should use the type of its "Value" as
- // the type of the child node.
- for (int i = 0; i < found_type.fields_size(); ++i) {
- const google::protobuf::Field& sub_field = found_type.fields(i);
- if (sub_field.number() != 2) {
- continue;
- }
- if (sub_field.kind() != google::protobuf::Field::TYPE_MESSAGE) {
- // This map's value type is not a message type. We don't need to
- // get the field_type in this case.
- break;
- }
- util::StatusOr<const google::protobuf::Type*> sub_type =
- typeinfo->ResolveTypeUrl(sub_field.type_url());
- if (!sub_type.ok()) {
- GOOGLE_LOG(WARNING) << "Cannot resolve type '" << sub_field.type_url() << "'.";
- } else {
- return sub_type.value();
- }
- break;
- }
- return nullptr;
-}
-
-void DefaultValueObjectWriter::Node::PopulateChildren(
- const TypeInfo* typeinfo) {
- // Ignores well known types that don't require automatically populating their
- // primitive children. For type "Any", we only populate its children when the
- // "@type" field is set.
- // TODO(tsun): remove "kStructValueType" from the list. It's being checked
- // now because of a bug in the tool-chain that causes the "oneof_index"
- // of kStructValueType to not be set correctly.
- if (type_ == nullptr || type_->name() == kAnyType ||
- type_->name() == kStructType || type_->name() == kTimestampType ||
- type_->name() == kDurationType || type_->name() == kStructValueType) {
- return;
- }
- std::vector<Node*> new_children;
- std::unordered_map<TProtoStringType, int> orig_children_map;
-
- // Creates a map of child nodes to speed up lookup.
- for (int i = 0; i < children_.size(); ++i) {
- InsertIfNotPresent(&orig_children_map, children_[i]->name_, i);
- }
-
- for (int i = 0; i < type_->fields_size(); ++i) {
- const google::protobuf::Field& field = type_->fields(i);
-
- // This code is checking if the field to be added to the tree should be
- // scrubbed or not by calling the field_scrub_callback_ callback function.
- std::vector<TProtoStringType> path;
- if (!path_.empty()) {
- path.insert(path.begin(), path_.begin(), path_.end());
- }
- path.push_back(field.name());
- if (field_scrub_callback_ && field_scrub_callback_(path, &field)) {
- continue;
- }
-
- std::unordered_map<TProtoStringType, int>::iterator found =
- orig_children_map.find(field.name());
- // If the child field has already been set, we just add it to the new list
- // of children.
- if (found != orig_children_map.end()) {
- new_children.push_back(children_[found->second]);
- children_[found->second] = nullptr;
- continue;
- }
-
- const google::protobuf::Type* field_type = nullptr;
- bool is_map = false;
- NodeKind kind = PRIMITIVE;
-
- if (field.kind() == google::protobuf::Field::TYPE_MESSAGE) {
- kind = OBJECT;
- util::StatusOr<const google::protobuf::Type*> found_result =
- typeinfo->ResolveTypeUrl(field.type_url());
- if (!found_result.ok()) {
- // "field" is of an unknown type.
- GOOGLE_LOG(WARNING) << "Cannot resolve type '" << field.type_url() << "'.";
- } else {
- const google::protobuf::Type* found_type = found_result.value();
- is_map = IsMap(field, *found_type);
-
- if (!is_map) {
- field_type = found_type;
- } else {
- // If this field is a map, we should use the type of its "Value" as
- // the type of the child node.
- field_type = GetMapValueType(*found_type, typeinfo);
- kind = MAP;
- }
- }
- }
-
- if (!is_map &&
- field.cardinality() == google::protobuf::Field::CARDINALITY_REPEATED) {
- kind = LIST;
- }
-
- // If oneof_index() != 0, the child field is part of a "oneof", which means
- // the child field is optional and we shouldn't populate its default
- // primitive value.
- if (field.oneof_index() != 0 && kind == PRIMITIVE) continue;
-
- // If the child field is of primitive type, sets its data to the default
- // value of its type.
- std::unique_ptr<Node> child(
- new Node(preserve_proto_field_names_ ? field.name() : field.json_name(),
- field_type, kind,
- kind == PRIMITIVE ? CreateDefaultDataPieceForField(
- field, typeinfo, use_ints_for_enums_)
- : DataPiece::NullData(),
- true, path, suppress_empty_list_, preserve_proto_field_names_,
- use_ints_for_enums_, field_scrub_callback_));
- new_children.push_back(child.release());
- }
- // Adds all leftover nodes in children_ to the beginning of new_child.
- for (int i = 0; i < children_.size(); ++i) {
- if (children_[i] == nullptr) {
- continue;
- }
- new_children.insert(new_children.begin(), children_[i]);
- children_[i] = nullptr;
- }
- children_.swap(new_children);
-}
-
-void DefaultValueObjectWriter::MaybePopulateChildrenOfAny(Node* node) {
- // If this is an "Any" node with "@type" already given and no other children
- // have been added, populates its children.
- if (node != nullptr && node->is_any() && node->type() != nullptr &&
- node->type()->name() != kAnyType && node->number_of_children() == 1) {
- node->PopulateChildren(typeinfo_);
- }
-}
-
-DataPiece DefaultValueObjectWriter::FindEnumDefault(
- const google::protobuf::Field& field, const TypeInfo* typeinfo,
- bool use_ints_for_enums) {
- const google::protobuf::Enum* enum_type =
- typeinfo->GetEnumByTypeUrl(field.type_url());
- if (!enum_type) {
- GOOGLE_LOG(WARNING) << "Could not find enum with type '" << field.type_url()
- << "'";
- return DataPiece::NullData();
- }
- if (!field.default_value().empty()) {
- if (!use_ints_for_enums) {
- return DataPiece(field.default_value(), true);
- } else {
- const TProtoStringType& enum_default_value_name = field.default_value();
- for (int enum_index = 0; enum_index < enum_type->enumvalue_size();
- ++enum_index) {
- auto& enum_value = enum_type->enumvalue(enum_index);
- if (enum_value.name() == enum_default_value_name)
- return DataPiece(enum_value.number());
- }
- GOOGLE_LOG(WARNING) << "Could not find enum value '" << enum_default_value_name
- << "' with type '" << field.type_url() << "'";
- return DataPiece::NullData();
- }
- }
- // We treat the first value as the default if none is specified.
- return enum_type->enumvalue_size() > 0
- ? (use_ints_for_enums
- ? DataPiece(enum_type->enumvalue(0).number())
- : DataPiece(enum_type->enumvalue(0).name(), true))
- : DataPiece::NullData();
-}
-
-DataPiece DefaultValueObjectWriter::CreateDefaultDataPieceForField(
- const google::protobuf::Field& field, const TypeInfo* typeinfo,
- bool use_ints_for_enums) {
- switch (field.kind()) {
- case google::protobuf::Field::TYPE_DOUBLE: {
- return DataPiece(ConvertTo<double>(
- field.default_value(), &DataPiece::ToDouble, static_cast<double>(0)));
- }
- case google::protobuf::Field::TYPE_FLOAT: {
- return DataPiece(ConvertTo<float>(
- field.default_value(), &DataPiece::ToFloat, static_cast<float>(0)));
- }
- case google::protobuf::Field::TYPE_INT64:
- case google::protobuf::Field::TYPE_SINT64:
- case google::protobuf::Field::TYPE_SFIXED64: {
- return DataPiece(ConvertTo<arc_i64>(
- field.default_value(), &DataPiece::ToInt64, static_cast<arc_i64>(0)));
- }
- case google::protobuf::Field::TYPE_UINT64:
- case google::protobuf::Field::TYPE_FIXED64: {
- return DataPiece(ConvertTo<arc_ui64>(field.default_value(),
- &DataPiece::ToUint64,
- static_cast<arc_ui64>(0)));
- }
- case google::protobuf::Field::TYPE_INT32:
- case google::protobuf::Field::TYPE_SINT32:
- case google::protobuf::Field::TYPE_SFIXED32: {
- return DataPiece(ConvertTo<arc_i32>(
- field.default_value(), &DataPiece::ToInt32, static_cast<arc_i32>(0)));
- }
- case google::protobuf::Field::TYPE_BOOL: {
- return DataPiece(
- ConvertTo<bool>(field.default_value(), &DataPiece::ToBool, false));
- }
- case google::protobuf::Field::TYPE_STRING: {
- return DataPiece(field.default_value(), true);
- }
- case google::protobuf::Field::TYPE_BYTES: {
- return DataPiece(field.default_value(), false, true);
- }
- case google::protobuf::Field::TYPE_UINT32:
- case google::protobuf::Field::TYPE_FIXED32: {
- return DataPiece(ConvertTo<arc_ui32>(field.default_value(),
- &DataPiece::ToUint32,
- static_cast<arc_ui32>(0)));
- }
- case google::protobuf::Field::TYPE_ENUM: {
- return FindEnumDefault(field, typeinfo, use_ints_for_enums);
- }
- default: {
- return DataPiece::NullData();
- }
- }
-}
-
-DefaultValueObjectWriter* DefaultValueObjectWriter::StartObject(
- StringPiece name) {
- if (current_ == nullptr) {
- std::vector<TProtoStringType> path;
- root_.reset(CreateNewNode(TProtoStringType(name), &type_, OBJECT,
- DataPiece::NullData(), false, path,
- suppress_empty_list_, preserve_proto_field_names_,
- use_ints_for_enums_, field_scrub_callback_));
- root_->PopulateChildren(typeinfo_);
- current_ = root_.get();
- return this;
- }
- MaybePopulateChildrenOfAny(current_);
- Node* child = current_->FindChild(name);
- if (current_->kind() == LIST || current_->kind() == MAP || child == nullptr) {
- // If current_ is a list or a map node, we should create a new child and use
- // the type of current_ as the type of the new child.
- std::unique_ptr<Node> node(
- CreateNewNode(TProtoStringType(name),
- ((current_->kind() == LIST || current_->kind() == MAP)
- ? current_->type()
- : nullptr),
- OBJECT, DataPiece::NullData(), false,
- child == nullptr ? current_->path() : child->path(),
- suppress_empty_list_, preserve_proto_field_names_,
- use_ints_for_enums_, field_scrub_callback_));
- child = node.get();
- current_->AddChild(node.release());
- }
-
- child->set_is_placeholder(false);
- if (child->kind() == OBJECT && child->number_of_children() == 0) {
- child->PopulateChildren(typeinfo_);
- }
-
- stack_.push(current_);
- current_ = child;
- return this;
-}
-
-DefaultValueObjectWriter* DefaultValueObjectWriter::EndObject() {
- if (stack_.empty()) {
- // The root object ends here. Writes out the tree.
- WriteRoot();
- return this;
- }
- current_ = stack_.top();
- stack_.pop();
- return this;
-}
-
-DefaultValueObjectWriter* DefaultValueObjectWriter::StartList(
- StringPiece name) {
- if (current_ == nullptr) {
- std::vector<TProtoStringType> path;
- root_.reset(CreateNewNode(TProtoStringType(name), &type_, LIST,
- DataPiece::NullData(), false, path,
- suppress_empty_list_, preserve_proto_field_names_,
- use_ints_for_enums_, field_scrub_callback_));
- current_ = root_.get();
- return this;
- }
- MaybePopulateChildrenOfAny(current_);
- Node* child = current_->FindChild(name);
- if (child == nullptr || child->kind() != LIST) {
- std::unique_ptr<Node> node(CreateNewNode(
- TProtoStringType(name), nullptr, LIST, DataPiece::NullData(), false,
- child == nullptr ? current_->path() : child->path(),
- suppress_empty_list_, preserve_proto_field_names_, use_ints_for_enums_,
- field_scrub_callback_));
- child = node.get();
- current_->AddChild(node.release());
- }
- child->set_is_placeholder(false);
-
- stack_.push(current_);
- current_ = child;
- return this;
-}
-
-void DefaultValueObjectWriter::WriteRoot() {
- root_->WriteTo(ow_);
- root_.reset(nullptr);
- current_ = nullptr;
-}
-
-DefaultValueObjectWriter* DefaultValueObjectWriter::EndList() {
- if (stack_.empty()) {
- WriteRoot();
- return this;
- }
- current_ = stack_.top();
- stack_.pop();
- return this;
-}
-
-void DefaultValueObjectWriter::RenderDataPiece(StringPiece name,
- const DataPiece& data) {
- MaybePopulateChildrenOfAny(current_);
- if (current_->type() != nullptr && current_->type()->name() == kAnyType &&
- name == "@type") {
- util::StatusOr<TProtoStringType> data_string = data.ToString();
- if (data_string.ok()) {
- const TProtoStringType& string_value = data_string.value();
- // If the type of current_ is "Any" and its "@type" field is being set
- // here, sets the type of current_ to be the type specified by the
- // "@type".
- util::StatusOr<const google::protobuf::Type*> found_type =
- typeinfo_->ResolveTypeUrl(string_value);
- if (!found_type.ok()) {
- GOOGLE_LOG(WARNING) << "Failed to resolve type '" << string_value << "'.";
- } else {
- current_->set_type(found_type.value());
- }
- current_->set_is_any(true);
- // If the "@type" field is placed after other fields, we should populate
- // other children of primitive type now. Otherwise, we should wait until
- // the first value field is rendered before we populate the children,
- // because the "value" field of a Any message could be omitted.
- if (current_->number_of_children() > 1 && current_->type() != nullptr) {
- current_->PopulateChildren(typeinfo_);
- }
- }
- }
- Node* child = current_->FindChild(name);
- if (child == nullptr || child->kind() != PRIMITIVE) {
- // No children are found, creates a new child.
- std::unique_ptr<Node> node(
- CreateNewNode(TProtoStringType(name), nullptr, PRIMITIVE, data, false,
- child == nullptr ? current_->path() : child->path(),
- suppress_empty_list_, preserve_proto_field_names_,
- use_ints_for_enums_, field_scrub_callback_));
- current_->AddChild(node.release());
- } else {
- child->set_data(data);
- child->set_is_placeholder(false);
- }
-}
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
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
deleted file mode 100644
index e161cb806fa..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.h
+++ /dev/null
@@ -1,332 +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_UTIL_INTERNAL_DEFAULT_VALUE_OBJECTWRITER_H__
-#define GOOGLE_PROTOBUF_UTIL_INTERNAL_DEFAULT_VALUE_OBJECTWRITER_H__
-
-#include <cstdint>
-#include <functional>
-#include <memory>
-#include <stack>
-#include <vector>
-
-#include <google/protobuf/stubs/common.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>
-
-// Must be included last.
-#include <google/protobuf/port_def.inc>
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-// An ObjectWriter that renders non-repeated primitive fields of proto messages
-// with their default values. DefaultValueObjectWriter holds objects, lists and
-// fields it receives in a tree structure and writes them out to another
-// ObjectWriter when EndObject() is called on the root object. It also writes
-// out all non-repeated primitive fields that haven't been explicitly rendered
-// with their default values (0 for numbers, "" for strings, etc).
-class PROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
- public:
- // A Callback function to check whether a field needs to be scrubbed.
- //
- // Returns true if the field should not be present in the output. Returns
- // false otherwise.
- //
- // The 'path' parameter is a vector of path to the field from root. For
- // example: if a nested field "a.b.c" (b is the parent message field of c and
- // a is the parent message field of b), then the vector should contain { "a",
- // "b", "c" }.
- //
- // The Field* should point to the google::protobuf::Field of "c".
- typedef std::function<bool(
- const std::vector<TProtoStringType>& /*path of the field*/,
- const google::protobuf::Field* /*field*/)>
- FieldScrubCallBack;
-
- DefaultValueObjectWriter(TypeResolver* type_resolver,
- const google::protobuf::Type& type,
- ObjectWriter* ow);
-
- ~DefaultValueObjectWriter() override;
-
- // ObjectWriter methods.
- DefaultValueObjectWriter* StartObject(StringPiece name) override;
-
- DefaultValueObjectWriter* EndObject() override;
-
- DefaultValueObjectWriter* StartList(StringPiece name) override;
-
- DefaultValueObjectWriter* EndList() override;
-
- DefaultValueObjectWriter* RenderBool(StringPiece name,
- bool value) override;
-
- DefaultValueObjectWriter* RenderInt32(StringPiece name,
- arc_i32 value) override;
-
- DefaultValueObjectWriter* RenderUint32(StringPiece name,
- arc_ui32 value) override;
-
- DefaultValueObjectWriter* RenderInt64(StringPiece name,
- arc_i64 value) override;
-
- DefaultValueObjectWriter* RenderUint64(StringPiece name,
- arc_ui64 value) override;
-
- DefaultValueObjectWriter* RenderDouble(StringPiece name,
- double value) override;
-
- DefaultValueObjectWriter* RenderFloat(StringPiece name,
- float value) override;
-
- DefaultValueObjectWriter* RenderString(StringPiece name,
- StringPiece value) override;
- DefaultValueObjectWriter* RenderBytes(StringPiece name,
- StringPiece value) override;
-
- DefaultValueObjectWriter* RenderNull(StringPiece name) override;
-
- // Register the callback for scrubbing of fields.
- void RegisterFieldScrubCallBack(FieldScrubCallBack field_scrub_callback);
-
- // If set to true, empty lists are suppressed from output when default values
- // are written.
- void set_suppress_empty_list(bool value) { suppress_empty_list_ = value; }
-
- // If set to true, original proto field names are used
- void set_preserve_proto_field_names(bool value) {
- preserve_proto_field_names_ = value;
- }
-
- // If set to true, enums are rendered as ints from output when default values
- // are written.
- void set_print_enums_as_ints(bool value) { use_ints_for_enums_ = value; }
-
- protected:
- enum NodeKind {
- PRIMITIVE = 0,
- OBJECT = 1,
- LIST = 2,
- MAP = 3,
- };
-
- // "Node" represents a node in the tree that holds the input of
- // DefaultValueObjectWriter.
- class PROTOBUF_EXPORT Node {
- public:
- Node(const TProtoStringType& name, const google::protobuf::Type* type,
- NodeKind kind, const DataPiece& data, bool is_placeholder,
- const std::vector<TProtoStringType>& path, bool suppress_empty_list,
- bool preserve_proto_field_names, bool use_ints_for_enums,
- FieldScrubCallBack field_scrub_callback);
- virtual ~Node() {
- for (int i = 0; i < children_.size(); ++i) {
- delete children_[i];
- }
- }
-
- // Adds a child to this node. Takes ownership of this child.
- void AddChild(Node* child) { children_.push_back(child); }
-
- // Finds the child given its name.
- Node* FindChild(StringPiece name);
-
- // Populates children of this Node based on its type. If there are already
- // children created, they will be merged to the result. Caller should pass
- // in TypeInfo for looking up types of the children.
- virtual void PopulateChildren(const TypeInfo* typeinfo);
-
- // If this node is a leaf (has data), writes the current node to the
- // ObjectWriter; if not, then recursively writes the children to the
- // ObjectWriter.
- virtual void WriteTo(ObjectWriter* ow);
-
- // Accessors
- const TProtoStringType& name() const { return name_; }
-
- const std::vector<TProtoStringType>& path() const { return path_; }
-
- const google::protobuf::Type* type() const { return type_; }
-
- void set_type(const google::protobuf::Type* type) { type_ = type; }
-
- NodeKind kind() const { return kind_; }
-
- int number_of_children() const { return children_.size(); }
-
- void set_data(const DataPiece& data) { data_ = data; }
-
- bool is_any() const { return is_any_; }
-
- void set_is_any(bool is_any) { is_any_ = is_any; }
-
- void set_is_placeholder(bool is_placeholder) {
- is_placeholder_ = is_placeholder;
- }
-
- protected:
- // Returns the Value Type of a map given the Type of the map entry and a
- // TypeInfo instance.
- const google::protobuf::Type* GetMapValueType(
- const google::protobuf::Type& found_type, const TypeInfo* typeinfo);
-
- // Calls WriteTo() on every child in children_.
- void WriteChildren(ObjectWriter* ow);
-
- // The name of this node.
- TProtoStringType name_;
- // google::protobuf::Type of this node. Owned by TypeInfo.
- const google::protobuf::Type* type_;
- // The kind of this node.
- NodeKind kind_;
- // Whether this is a node for "Any".
- bool is_any_;
- // The data of this node when it is a leaf node.
- DataPiece data_;
- // Children of this node.
- std::vector<Node*> children_;
- // Whether this node is a placeholder for an object or list automatically
- // generated when creating the parent node. Should be set to false after
- // the parent node's StartObject()/StartList() method is called with this
- // node's name.
- bool is_placeholder_;
-
- // Path of the field of this node
- std::vector<TProtoStringType> path_;
-
- // Whether to suppress empty list output.
- bool suppress_empty_list_;
-
- // Whether to preserve original proto field names
- bool preserve_proto_field_names_;
-
- // Whether to always print enums as ints
- bool use_ints_for_enums_;
-
- // Function for determining whether a field needs to be scrubbed or not.
- FieldScrubCallBack field_scrub_callback_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Node);
- };
-
- // Creates a new Node and returns it. Caller owns memory of returned object.
- virtual Node* CreateNewNode(const TProtoStringType& name,
- const google::protobuf::Type* type, NodeKind kind,
- const DataPiece& data, bool is_placeholder,
- const std::vector<TProtoStringType>& path,
- bool suppress_empty_list,
- bool preserve_proto_field_names,
- bool use_ints_for_enums,
- FieldScrubCallBack field_scrub_callback);
-
- // Creates a DataPiece containing the default value of the type of the field.
- static DataPiece CreateDefaultDataPieceForField(
- const google::protobuf::Field& field, const TypeInfo* typeinfo) {
- return CreateDefaultDataPieceForField(field, typeinfo, false);
- }
-
- // Same as the above but with a flag to use ints instead of enum names.
- static DataPiece CreateDefaultDataPieceForField(
- const google::protobuf::Field& field, const TypeInfo* typeinfo,
- bool use_ints_for_enums);
-
- protected:
- // Returns a pointer to current Node in tree.
- Node* current() { return current_; }
-
- private:
- // Populates children of "node" if it is an "any" Node and its real type has
- // been given.
- void MaybePopulateChildrenOfAny(Node* node);
-
- // Writes the root_ node to ow_ and resets the root_ and current_ pointer to
- // nullptr.
- void WriteRoot();
-
- // Adds or replaces the data_ of a primitive child node.
- void RenderDataPiece(StringPiece name, const DataPiece& data);
-
- // Returns the default enum value as a DataPiece, or the first enum value if
- // there is no default. For proto3, where we cannot specify an explicit
- // default, a zero value will always be returned.
- static DataPiece FindEnumDefault(const google::protobuf::Field& field,
- const TypeInfo* typeinfo,
- bool use_ints_for_enums);
-
- // Type information for all the types used in the descriptor. Used to find
- // google::protobuf::Type of nested messages/enums.
- const TypeInfo* typeinfo_;
- // Whether the TypeInfo object is owned by this class.
- bool own_typeinfo_;
- // google::protobuf::Type of the root message type.
- const google::protobuf::Type& type_;
- // Holds copies of strings passed to RenderString.
- std::vector<std::unique_ptr<TProtoStringType>> string_values_;
-
- // The current Node. Owned by its parents.
- Node* current_;
- // The root Node.
- std::unique_ptr<Node> root_;
- // The stack to hold the path of Nodes from current_ to root_;
- std::stack<Node*> stack_;
-
- // Whether to suppress output of empty lists.
- bool suppress_empty_list_;
-
- // Whether to preserve original proto field names
- bool preserve_proto_field_names_;
-
- // Whether to always print enums as ints
- bool use_ints_for_enums_;
-
- // Function for determining whether a field needs to be scrubbed or not.
- FieldScrubCallBack field_scrub_callback_;
-
- ObjectWriter* ow_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DefaultValueObjectWriter);
-};
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#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
deleted file mode 100644
index 8c9c5016820..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/error_listener.h
+++ /dev/null
@@ -1,109 +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_UTIL_INTERNAL_ERROR_LISTENER_H__
-#define GOOGLE_PROTOBUF_UTIL_INTERNAL_ERROR_LISTENER_H__
-
-#include <algorithm>
-#include <memory>
-#include <string>
-#include <vector>
-
-#include <google/protobuf/stubs/callback.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/logging.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>
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-// Interface for error listener.
-class PROTOBUF_EXPORT ErrorListener {
- public:
- virtual ~ErrorListener() {}
-
- // Reports an invalid name at the given location.
- virtual void InvalidName(const LocationTrackerInterface& loc,
- StringPiece invalid_name,
- StringPiece message) = 0;
-
- // Reports an invalid value for a field.
- virtual void InvalidValue(const LocationTrackerInterface& loc,
- StringPiece type_name,
- StringPiece value) = 0;
-
- // Reports a missing required field.
- virtual void MissingField(const LocationTrackerInterface& loc,
- StringPiece missing_name) = 0;
-
- protected:
- ErrorListener() {}
-
- private:
- // Do not add any data members to this class.
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ErrorListener);
-};
-
-// An error listener that ignores all errors.
-class PROTOBUF_EXPORT NoopErrorListener : public ErrorListener {
- public:
- NoopErrorListener() {}
- ~NoopErrorListener() override {}
-
- void InvalidName(const LocationTrackerInterface& /*loc*/,
- StringPiece /* invalid_name */,
- StringPiece /* message */) override {}
-
- void InvalidValue(const LocationTrackerInterface& /*loc*/,
- StringPiece /* type_name */,
- StringPiece /* value */) override {}
-
- void MissingField(const LocationTrackerInterface& /* loc */,
- StringPiece /* missing_name */) override {}
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(NoopErrorListener);
-};
-
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#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
deleted file mode 100644
index 4dd5145b47e..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/field_mask_utility.cc
+++ /dev/null
@@ -1,218 +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/util/internal/field_mask_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.
-#include <google/protobuf/port_def.inc>
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-namespace {
-
-// Appends a FieldMask path segment to a prefix.
-TProtoStringType AppendPathSegmentToPrefix(StringPiece prefix,
- StringPiece segment) {
- if (prefix.empty()) {
- return TProtoStringType(segment);
- }
- if (segment.empty()) {
- return TProtoStringType(prefix);
- }
- // If the segment is a map key, appends it to the prefix without the ".".
- if (HasPrefixString(segment, "[\"")) {
- return StrCat(prefix, segment);
- }
- return StrCat(prefix, ".", segment);
-}
-
-} // namespace
-
-TProtoStringType ConvertFieldMaskPath(const StringPiece path,
- ConverterCallback converter) {
- TProtoStringType result;
- result.reserve(path.size() << 1);
-
- bool is_quoted = false;
- bool is_escaping = false;
- int current_segment_start = 0;
-
- // Loops until 1 passed the end of the input to make handling the last
- // segment easier.
- for (size_t i = 0; i <= path.size(); ++i) {
- // Outputs quoted string as-is.
- if (is_quoted) {
- if (i == path.size()) {
- break;
- }
- result.push_back(path[i]);
- if (is_escaping) {
- is_escaping = false;
- } else if (path[i] == '\\') {
- is_escaping = true;
- } else if (path[i] == '\"') {
- current_segment_start = i + 1;
- is_quoted = false;
- }
- continue;
- }
- if (i == path.size() || path[i] == '.' || path[i] == '(' ||
- path[i] == ')' || path[i] == '\"') {
- result += converter(
- path.substr(current_segment_start, i - current_segment_start));
- if (i < path.size()) {
- result.push_back(path[i]);
- }
- current_segment_start = i + 1;
- }
- if (i < path.size() && path[i] == '\"') {
- is_quoted = true;
- }
- }
- return result;
-}
-
-util::Status DecodeCompactFieldMaskPaths(StringPiece paths,
- PathSinkCallback path_sink) {
- std::stack<TProtoStringType> prefix;
- int length = paths.length();
- int previous_position = 0;
- bool in_map_key = false;
- bool is_escaping = false;
- // Loops until 1 passed the end of the input to make the handle of the last
- // segment easier.
- for (int i = 0; i <= length; ++i) {
- if (i != length) {
- // Skips everything in a map key until we hit the end of it, which is
- // marked by an un-escaped '"' immediately followed by a ']'.
- if (in_map_key) {
- if (is_escaping) {
- is_escaping = false;
- continue;
- }
- if (paths[i] == '\\') {
- is_escaping = true;
- continue;
- }
- if (paths[i] != '\"') {
- continue;
- }
- // Un-escaped '"' must be followed with a ']'.
- if (i >= length - 1 || paths[i + 1] != ']') {
- return util::InvalidArgumentError(StrCat(
- "Invalid FieldMask '", paths,
- "'. Map keys should be represented as [\"some_key\"]."));
- }
- // The end of the map key ("\"]") has been found.
- in_map_key = false;
- // Skips ']'.
- i++;
- // Checks whether the key ends at the end of a path segment.
- if (i < length - 1 && paths[i + 1] != '.' && paths[i + 1] != ',' &&
- paths[i + 1] != ')' && paths[i + 1] != '(') {
- return util::InvalidArgumentError(StrCat(
- "Invalid FieldMask '", paths,
- "'. Map keys should be at the end of a path segment."));
- }
- is_escaping = false;
- continue;
- }
-
- // We are not in a map key, look for the start of one.
- if (paths[i] == '[') {
- if (i >= length - 1 || paths[i + 1] != '\"') {
- return util::InvalidArgumentError(StrCat(
- "Invalid FieldMask '", paths,
- "'. Map keys should be represented as [\"some_key\"]."));
- }
- // "[\"" starts a map key.
- in_map_key = true;
- i++; // Skips the '\"'.
- continue;
- }
- // If the current character is not a special character (',', '(' or ')'),
- // continue to the next.
- if (paths[i] != ',' && paths[i] != ')' && paths[i] != '(') {
- continue;
- }
- }
- // Gets the current segment - sub-string between previous position (after
- // '(', ')', ',', or the beginning of the input) and the current position.
- StringPiece segment =
- paths.substr(previous_position, i - previous_position);
- TProtoStringType current_prefix = prefix.empty() ? "" : prefix.top();
-
- if (i < length && paths[i] == '(') {
- // Builds a prefix and save it into the stack.
- prefix.push(AppendPathSegmentToPrefix(current_prefix, segment));
- } else if (!segment.empty()) {
- // When the current character is ')', ',' or the current position has
- // passed the end of the input, builds and outputs a new paths by
- // concatenating the last prefix with the current segment.
- RETURN_IF_ERROR(
- path_sink(AppendPathSegmentToPrefix(current_prefix, segment)));
- }
-
- // Removes the last prefix after seeing a ')'.
- if (i < length && paths[i] == ')') {
- if (prefix.empty()) {
- return util::InvalidArgumentError(
- StrCat("Invalid FieldMask '", paths,
- "'. Cannot find matching '(' for all ')'."));
- }
- prefix.pop();
- }
- previous_position = i + 1;
- }
- if (in_map_key) {
- return util::InvalidArgumentError(
- StrCat("Invalid FieldMask '", paths,
- "'. Cannot find matching ']' for all '['."));
- }
- if (!prefix.empty()) {
- return util::InvalidArgumentError(
- StrCat("Invalid FieldMask '", paths,
- "'. Cannot find matching ')' for all '('."));
- }
- return util::Status();
-}
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
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
deleted file mode 100644
index 288aa7a15bd..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/field_mask_utility.h
+++ /dev/null
@@ -1,74 +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.
-
-// FieldMask related utility methods.
-
-#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_FIELD_MASK_UTILITY_H__
-#define GOOGLE_PROTOBUF_UTIL_INTERNAL_FIELD_MASK_UTILITY_H__
-
-#include <functional>
-#include <stack>
-
-#include <google/protobuf/stubs/callback.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/status.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/status.h>
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-typedef std::function<TProtoStringType(StringPiece)> ConverterCallback;
-typedef std::function<util::Status(StringPiece)> PathSinkCallback;
-
-// Applies a 'converter' to each segment of a FieldMask path and returns the
-// result. Quoted strings in the 'path' are copied to the output as-is without
-// converting their content. Escaping is supported within quoted strings.
-// For example, "ab\"_c" will be returned as "ab\"_c" without any changes.
-TProtoStringType ConvertFieldMaskPath(const StringPiece path,
- ConverterCallback converter);
-
-// Decodes a compact list of FieldMasks. For example, "a.b,a.c.d,a.c.e" will be
-// decoded into a list of field paths - "a.b", "a.c.d", "a.c.e". And the results
-// will be sent to 'path_sink', i.e. 'path_sink' will be called once per
-// resulting path.
-// Note that we also support Apiary style FieldMask form. The above example in
-// the Apiary style will look like "a.b,a.c(d,e)".
-util::Status DecodeCompactFieldMaskPaths(StringPiece paths,
- PathSinkCallback path_sink);
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
-
-#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_FIELD_MASK_UTILITY_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/json_escaping.cc b/contrib/libs/protobuf/src/google/protobuf/util/internal/json_escaping.cc
deleted file mode 100644
index 699de65b0f7..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/json_escaping.cc
+++ /dev/null
@@ -1,372 +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/util/internal/json_escaping.h>
-
-#include <cstdint>
-
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-namespace {
-
-// Array of hex characters for conversion to hex.
-static const char kHex[] = "0123456789abcdef";
-
-// Characters 0x00 to 0x9f are very commonly used, so we provide a special
-// table lookup.
-//
-// For unicode code point ch < 0xa0:
-// kCommonEscapes[ch] is the escaped string of ch, if escaping is needed;
-// or an empty string, if escaping is not needed.
-static const char kCommonEscapes[160][7] = {
- // C0 (ASCII and derivatives) control characters
- "\\u0000", "\\u0001", "\\u0002", "\\u0003", // 0x00
- "\\u0004", "\\u0005", "\\u0006", "\\u0007", "\\b", "\\t", "\\n", "\\u000b",
- "\\f", "\\r", "\\u000e", "\\u000f", "\\u0010", "\\u0011", "\\u0012",
- "\\u0013", // 0x10
- "\\u0014", "\\u0015", "\\u0016", "\\u0017", "\\u0018", "\\u0019", "\\u001a",
- "\\u001b", "\\u001c", "\\u001d", "\\u001e", "\\u001f",
- // Escaping of " and \ are required by www.json.org string definition.
- // Escaping of < and > are required for HTML security.
- "", "", "\\\"", "", "", "", "", "", // 0x20
- "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", // 0x30
- "", "", "", "", "\\u003c", "", "\\u003e", "", "", "", "", "", "", "", "",
- "", // 0x40
- "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", // 0x50
- "", "", "", "", "\\\\", "", "", "", "", "", "", "", "", "", "", "", // 0x60
- "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", // 0x70
- "", "", "", "", "", "", "", "\\u007f",
- // C1 (ISO 8859 and Unicode) extended control characters
- "\\u0080", "\\u0081", "\\u0082", "\\u0083", // 0x80
- "\\u0084", "\\u0085", "\\u0086", "\\u0087", "\\u0088", "\\u0089", "\\u008a",
- "\\u008b", "\\u008c", "\\u008d", "\\u008e", "\\u008f", "\\u0090", "\\u0091",
- "\\u0092", "\\u0093", // 0x90
- "\\u0094", "\\u0095", "\\u0096", "\\u0097", "\\u0098", "\\u0099", "\\u009a",
- "\\u009b", "\\u009c", "\\u009d", "\\u009e", "\\u009f"};
-
-// Determines if the given char value is a unicode surrogate code unit (either
-// high-surrogate or low-surrogate).
-inline bool IsSurrogate(arc_ui32 c) {
- // Optimized form of:
- // return c >= kMinHighSurrogate && c <= kMaxLowSurrogate;
- // (Reduced from 3 ALU instructions to 2 ALU instructions)
- return (c & 0xfffff800) == JsonEscaping::kMinHighSurrogate;
-}
-
-// Returns true if the given unicode code point cp is a valid
-// unicode code point (i.e. in the range 0 <= cp <= kMaxCodePoint).
-inline bool IsValidCodePoint(arc_ui32 cp) {
- return cp <= JsonEscaping::kMaxCodePoint;
-}
-
-// Returns the low surrogate for the given unicode code point. The result is
-// meaningless if the given code point is not a supplementary character.
-inline uint16_t ToLowSurrogate(arc_ui32 cp) {
- return (cp &
- (JsonEscaping::kMaxLowSurrogate - JsonEscaping::kMinLowSurrogate)) +
- JsonEscaping::kMinLowSurrogate;
-}
-
-// Returns the high surrogate for the given unicode code point. The result is
-// meaningless if the given code point is not a supplementary character.
-inline uint16_t ToHighSurrogate(arc_ui32 cp) {
- return (cp >> 10) + (JsonEscaping::kMinHighSurrogate -
- (JsonEscaping::kMinSupplementaryCodePoint >> 10));
-}
-
-// Input str is encoded in UTF-8. A unicode code point could be encoded in
-// UTF-8 using anywhere from 1 to 4 characters, and it could span multiple
-// reads of the ByteSource.
-//
-// This function reads the next unicode code point from the input (str) at
-// the given position (index), taking into account any left-over partial
-// code point from the previous iteration (cp), together with the number
-// of characters left to read to complete this code point (num_left).
-//
-// This function assumes that the input (str) is valid at the given position
-// (index). In order words, at least one character could be read successfully.
-//
-// The code point read (partial or complete) is stored in (cp). Upon return,
-// (num_left) stores the number of characters that has yet to be read in
-// order to complete the current unicode code point. If the read is complete,
-// then (num_left) is 0. Also, (num_read) is the number of characters read.
-//
-// Returns false if we encounter an invalid UTF-8 string. Returns true
-// otherwise, including the case when we reach the end of the input (str)
-// before a complete unicode code point is read.
-bool ReadCodePoint(StringPiece str, int index, arc_ui32* cp,
- int* num_left, int* num_read) {
- if (*num_left == 0) {
- // Last read was complete. Start reading a new unicode code point.
- *cp = static_cast<uint8_t>(str[index++]);
- *num_read = 1;
- // The length of the code point is determined from reading the first byte.
- //
- // If the first byte is between:
- // 0..0x7f: that's the value of the code point.
- // 0x80..0xbf: <invalid>
- // 0xc0..0xdf: 11-bit code point encoded in 2 bytes.
- // bit 10-6, bit 5-0
- // 0xe0..0xef: 16-bit code point encoded in 3 bytes.
- // bit 15-12, bit 11-6, bit 5-0
- // 0xf0..0xf7: 21-bit code point encoded in 4 bytes.
- // bit 20-18, bit 17-12, bit 11-6, bit 5-0
- // 0xf8..0xff: <invalid>
- //
- // Meaning of each bit:
- // <msb> bit 7: 0 - single byte code point: bits 6-0 are values.
- // 1 - multibyte code point
- // bit 6: 0 - subsequent bytes of multibyte code point:
- // bits 5-0 are values.
- // 1 - first byte of multibyte code point
- // bit 5: 0 - first byte of 2-byte code point: bits 4-0 are values.
- // 1 - first byte of code point with >= 3 bytes.
- // bit 4: 0 - first byte of 3-byte code point: bits 3-0 are values.
- // 1 - first byte of code point with >= 4 bytes.
- // bit 3: 0 - first byte of 4-byte code point: bits 2-0 are values.
- // 1 - reserved for future expansion.
- if (*cp <= 0x7f) {
- return true;
- } else if (*cp <= 0xbf) {
- return false;
- } else if (*cp <= 0xdf) {
- *cp &= 0x1f;
- *num_left = 1;
- } else if (*cp <= 0xef) {
- *cp &= 0x0f;
- *num_left = 2;
- } else if (*cp <= 0xf7) {
- *cp &= 0x07;
- *num_left = 3;
- } else {
- return false;
- }
- } else {
- // Last read was partial. Initialize num_read to 0 and continue reading
- // the last unicode code point.
- *num_read = 0;
- }
- while (*num_left > 0 && index < str.size()) {
- arc_ui32 ch = static_cast<uint8_t>(str[index++]);
- --(*num_left);
- ++(*num_read);
- *cp = (*cp << 6) | (ch & 0x3f);
- if (ch < 0x80 || ch > 0xbf) return false;
- }
- return *num_left > 0 || (!IsSurrogate(*cp) && IsValidCodePoint(*cp));
-}
-
-// Stores the 16-bit unicode code point as its hexadecimal digits in buffer
-// and returns a StringPiece that points to this buffer. The input buffer needs
-// to be at least 6 bytes long.
-StringPiece ToHex(uint16_t cp, char* buffer) {
- buffer[5] = kHex[cp & 0x0f];
- cp >>= 4;
- buffer[4] = kHex[cp & 0x0f];
- cp >>= 4;
- buffer[3] = kHex[cp & 0x0f];
- cp >>= 4;
- buffer[2] = kHex[cp & 0x0f];
- return StringPiece(buffer, 6);
-}
-
-// Stores the 32-bit unicode code point as its hexadecimal digits in buffer
-// and returns a StringPiece that points to this buffer. The input buffer needs
-// to be at least 12 bytes long.
-StringPiece ToSurrogateHex(arc_ui32 cp, char* buffer) {
- uint16_t low = ToLowSurrogate(cp);
- uint16_t high = ToHighSurrogate(cp);
-
- buffer[11] = kHex[low & 0x0f];
- low >>= 4;
- buffer[10] = kHex[low & 0x0f];
- low >>= 4;
- buffer[9] = kHex[low & 0x0f];
- low >>= 4;
- buffer[8] = kHex[low & 0x0f];
-
- buffer[5] = kHex[high & 0x0f];
- high >>= 4;
- buffer[4] = kHex[high & 0x0f];
- high >>= 4;
- buffer[3] = kHex[high & 0x0f];
- high >>= 4;
- buffer[2] = kHex[high & 0x0f];
-
- return StringPiece(buffer, 12);
-}
-
-// If the given unicode code point needs escaping, then returns the
-// escaped form. The returned StringPiece either points to statically
-// pre-allocated char[] or to the given buffer. The input buffer needs
-// to be at least 12 bytes long.
-//
-// If the given unicode code point does not need escaping, an empty
-// StringPiece is returned.
-StringPiece EscapeCodePoint(arc_ui32 cp, char* buffer) {
- if (cp < 0xa0) return kCommonEscapes[cp];
- switch (cp) {
- // These are not required by json spec
- // but used to prevent security bugs in javascript.
- case 0xfeff: // Zero width no-break space
- case 0xfff9: // Interlinear annotation anchor
- case 0xfffa: // Interlinear annotation separator
- case 0xfffb: // Interlinear annotation terminator
-
- case 0x00ad: // Soft-hyphen
- case 0x06dd: // Arabic end of ayah
- case 0x070f: // Syriac abbreviation mark
- case 0x17b4: // Khmer vowel inherent Aq
- case 0x17b5: // Khmer vowel inherent Aa
- return ToHex(cp, buffer);
-
- default:
- if ((cp >= 0x0600 && cp <= 0x0603) || // Arabic signs
- (cp >= 0x200b && cp <= 0x200f) || // Zero width etc.
- (cp >= 0x2028 && cp <= 0x202e) || // Separators etc.
- (cp >= 0x2060 && cp <= 0x2064) || // Invisible etc.
- (cp >= 0x206a && cp <= 0x206f)) { // Shaping etc.
- return ToHex(cp, buffer);
- }
-
- if (cp == 0x000e0001 || // Language tag
- (cp >= 0x0001d173 && cp <= 0x0001d17a) || // Music formatting
- (cp >= 0x000e0020 && cp <= 0x000e007f)) { // TAG symbols
- return ToSurrogateHex(cp, buffer);
- }
- }
- return StringPiece();
-}
-
-// Tries to escape the given code point first. If the given code point
-// does not need to be escaped, but force_output is true, then render
-// the given multi-byte code point in UTF8 in the buffer and returns it.
-StringPiece EscapeCodePoint(arc_ui32 cp, char* buffer,
- bool force_output) {
- StringPiece sp = EscapeCodePoint(cp, buffer);
- if (force_output && sp.empty()) {
- buffer[5] = (cp & 0x3f) | 0x80;
- cp >>= 6;
- if (cp <= 0x1f) {
- buffer[4] = cp | 0xc0;
- sp = StringPiece(buffer + 4, 2);
- return sp;
- }
- buffer[4] = (cp & 0x3f) | 0x80;
- cp >>= 6;
- if (cp <= 0x0f) {
- buffer[3] = cp | 0xe0;
- sp = StringPiece(buffer + 3, 3);
- return sp;
- }
- buffer[3] = (cp & 0x3f) | 0x80;
- buffer[2] = ((cp >> 6) & 0x07) | 0xf0;
- sp = StringPiece(buffer + 2, 4);
- }
- return sp;
-}
-
-} // namespace
-
-void JsonEscaping::Escape(strings::ByteSource* input,
- strings::ByteSink* output) {
- char buffer[12] = "\\udead\\ubee";
- arc_ui32 cp = 0; // Current unicode code point.
- int num_left = 0; // Num of chars to read to complete the code point.
- while (input->Available() > 0) {
- StringPiece str = input->Peek();
- StringPiece escaped;
- int i = 0;
- int num_read;
- bool ok;
- bool cp_was_split = num_left > 0;
- // Loop until we encounter either
- // i) a code point that needs to be escaped; or
- // ii) a split code point is completely read; or
- // iii) a character that is not a valid utf8; or
- // iv) end of the StringPiece str is reached.
- do {
- ok = ReadCodePoint(str, i, &cp, &num_left, &num_read);
- if (num_left > 0 || !ok) break; // case iii or iv
- escaped = EscapeCodePoint(cp, buffer, cp_was_split);
- if (!escaped.empty()) break; // case i or ii
- i += num_read;
- num_read = 0;
- } while (i < str.length()); // case iv
- // First copy the un-escaped prefix, if any, to the output ByteSink.
- if (i > 0) input->CopyTo(output, i);
- if (num_read > 0) input->Skip(num_read);
- if (!ok) {
- // Case iii: Report error.
- // TODO(wpoon): Add error reporting.
- num_left = 0;
- } else if (num_left == 0 && !escaped.empty()) {
- // Case i or ii: Append the escaped code point to the output ByteSink.
- output->Append(escaped.data(), escaped.size());
- }
- }
- if (num_left > 0) {
- // Treat as case iii: report error.
- // TODO(wpoon): Add error reporting.
- }
-}
-
-void JsonEscaping::Escape(StringPiece input, strings::ByteSink* output) {
- const size_t len = input.length();
- const char* p = input.data();
-
- bool can_skip_escaping = true;
- for (int i = 0; i < len; i++) {
- char c = p[i];
- if (c < 0x20 || c >= 0x7F || c == '"' || c == '<' || c == '>' ||
- c == '\\') {
- can_skip_escaping = false;
- break;
- }
- }
-
- if (can_skip_escaping) {
- output->Append(input.data(), input.length());
- } else {
- strings::ArrayByteSource source(input);
- Escape(&source, output);
- }
-}
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
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
deleted file mode 100644
index b70190244fe..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/json_escaping.h
+++ /dev/null
@@ -1,98 +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_UTIL_INTERNAL_JSON_ESCAPING_H__
-#define GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_ESCAPING_H__
-
-#include <cstdint>
-
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/bytestream.h>
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-class JsonEscaping {
- public:
- // The minimum value of a unicode high-surrogate code unit in the utf-16
- // encoding. A high-surrogate is also known as a leading-surrogate.
- // See http://www.unicode.org/glossary/#high_surrogate_code_unit
- static constexpr uint16_t kMinHighSurrogate = 0xd800;
-
- // The maximum value of a unicide high-surrogate code unit in the utf-16
- // encoding. A high-surrogate is also known as a leading-surrogate.
- // See http://www.unicode.org/glossary/#high_surrogate_code_unit
- static constexpr uint16_t kMaxHighSurrogate = 0xdbff;
-
- // The minimum value of a unicode low-surrogate code unit in the utf-16
- // encoding. A low-surrogate is also known as a trailing-surrogate.
- // See http://www.unicode.org/glossary/#low_surrogate_code_unit
- static constexpr uint16_t kMinLowSurrogate = 0xdc00;
-
- // The maximum value of a unicode low-surrogate code unit in the utf-16
- // encoding. A low-surrogate is also known as a trailing surrogate.
- // See http://www.unicode.org/glossary/#low_surrogate_code_unit
- static constexpr uint16_t kMaxLowSurrogate = 0xdfff;
-
- // The minimum value of a unicode supplementary code point.
- // See http://www.unicode.org/glossary/#supplementary_code_point
- static constexpr arc_ui32 kMinSupplementaryCodePoint = 0x010000;
-
- // The minimum value of a unicode code point.
- // See http://www.unicode.org/glossary/#code_point
- static constexpr arc_ui32 kMinCodePoint = 0x000000;
-
- // The maximum value of a unicode code point.
- // See http://www.unicode.org/glossary/#code_point
- static constexpr arc_ui32 kMaxCodePoint = 0x10ffff;
-
- JsonEscaping() {}
- virtual ~JsonEscaping() {}
-
- // Escape the given ByteSource to the given ByteSink.
- static void Escape(strings::ByteSource* input, strings::ByteSink* output);
-
- // Escape the given ByteSource to the given ByteSink.
- // This is optimized for the case where the string is all printable 7-bit
- // ASCII and does not contain a few other characters (such as quotes).
- static void Escape(StringPiece input, strings::ByteSink* output);
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(JsonEscaping);
-};
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
-
-#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
deleted file mode 100644
index b179899f4de..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/json_objectwriter.cc
+++ /dev/null
@@ -1,190 +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/util/internal/json_objectwriter.h>
-
-#include <cmath>
-#include <cstdint>
-#include <limits>
-
-#include <google/protobuf/stubs/casts.h>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/util/internal/utility.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/util/internal/json_escaping.h>
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-
-JsonObjectWriter::~JsonObjectWriter() {
- if (element_ && !element_->is_root()) {
- GOOGLE_LOG(WARNING) << "JsonObjectWriter was not fully closed.";
- }
-}
-
-JsonObjectWriter* JsonObjectWriter::StartObject(StringPiece name) {
- WritePrefix(name);
- WriteChar('{');
- PushObject();
- return this;
-}
-
-JsonObjectWriter* JsonObjectWriter::EndObject() {
- Pop();
- WriteChar('}');
- if (element() && element()->is_root()) NewLine();
- return this;
-}
-
-JsonObjectWriter* JsonObjectWriter::StartList(StringPiece name) {
- WritePrefix(name);
- WriteChar('[');
- PushArray();
- return this;
-}
-
-JsonObjectWriter* JsonObjectWriter::EndList() {
- Pop();
- WriteChar(']');
- if (element()->is_root()) NewLine();
- return this;
-}
-
-JsonObjectWriter* JsonObjectWriter::RenderBool(StringPiece name,
- bool value) {
- return RenderSimple(name, value ? "true" : "false");
-}
-
-JsonObjectWriter* JsonObjectWriter::RenderInt32(StringPiece name,
- arc_i32 value) {
- return RenderSimple(name, StrCat(value));
-}
-
-JsonObjectWriter* JsonObjectWriter::RenderUint32(StringPiece name,
- arc_ui32 value) {
- return RenderSimple(name, StrCat(value));
-}
-
-JsonObjectWriter* JsonObjectWriter::RenderInt64(StringPiece name,
- arc_i64 value) {
- WritePrefix(name);
- WriteChar('"');
- WriteRawString(StrCat(value));
- WriteChar('"');
- return this;
-}
-
-JsonObjectWriter* JsonObjectWriter::RenderUint64(StringPiece name,
- arc_ui64 value) {
- WritePrefix(name);
- WriteChar('"');
- WriteRawString(StrCat(value));
- WriteChar('"');
- return this;
-}
-
-JsonObjectWriter* JsonObjectWriter::RenderDouble(StringPiece name,
- double value) {
- if (std::isfinite(value)) {
- return RenderSimple(name, SimpleDtoa(value));
- }
-
- // Render quoted with NaN/Infinity-aware DoubleAsString.
- return RenderString(name, DoubleAsString(value));
-}
-
-JsonObjectWriter* JsonObjectWriter::RenderFloat(StringPiece name,
- float value) {
- if (std::isfinite(value)) {
- return RenderSimple(name, SimpleFtoa(value));
- }
-
- // Render quoted with NaN/Infinity-aware FloatAsString.
- return RenderString(name, FloatAsString(value));
-}
-
-JsonObjectWriter* JsonObjectWriter::RenderString(StringPiece name,
- StringPiece value) {
- WritePrefix(name);
- WriteChar('"');
- JsonEscaping::Escape(value, &sink_);
- WriteChar('"');
- return this;
-}
-
-JsonObjectWriter* JsonObjectWriter::RenderBytes(StringPiece name,
- StringPiece value) {
- WritePrefix(name);
- TProtoStringType base64;
-
- if (use_websafe_base64_for_bytes_)
- WebSafeBase64EscapeWithPadding(TProtoStringType(value), &base64);
- else
- Base64Escape(value, &base64);
-
- WriteChar('"');
- // TODO(wpoon): Consider a ByteSink solution that writes the base64 bytes
- // directly to the stream, rather than first putting them
- // into a string and then writing them to the stream.
- stream_->WriteRaw(base64.data(), base64.size());
- WriteChar('"');
- return this;
-}
-
-JsonObjectWriter* JsonObjectWriter::RenderNull(StringPiece name) {
- return RenderSimple(name, "null");
-}
-
-JsonObjectWriter* JsonObjectWriter::RenderNullAsEmpty(StringPiece name) {
- return RenderSimple(name, "");
-}
-
-void JsonObjectWriter::WritePrefix(StringPiece name) {
- bool not_first = !element()->is_first();
- if (not_first) WriteChar(',');
- if (not_first || !element()->is_root()) NewLine();
- if (!name.empty() || element()->is_json_object()) {
- WriteChar('"');
- if (!name.empty()) {
- JsonEscaping::Escape(name, &sink_);
- }
- WriteRawString("\":");
- if (!indent_string_.empty()) WriteChar(' ');
- }
-}
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
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
deleted file mode 100644
index 4eb5587f299..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/json_objectwriter.h
+++ /dev/null
@@ -1,278 +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_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/stubs/bytestream.h>
-#include <google/protobuf/util/internal/structured_objectwriter.h>
-
-// clang-format off
-#include <google/protobuf/port_def.inc>
-// clang-format on
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-
-// An ObjectWriter implementation that outputs JSON. This ObjectWriter
-// supports writing a compact form or a pretty printed form.
-//
-// Sample usage:
-// string output;
-// StringOutputStream* str_stream = new StringOutputStream(&output);
-// CodedOutputStream* out_stream = new CodedOutputStream(str_stream);
-// JsonObjectWriter* ow = new JsonObjectWriter(" ", out_stream);
-// ow->StartObject("")
-// ->RenderString("name", "value")
-// ->RenderString("emptystring", string())
-// ->StartObject("nested")
-// ->RenderInt64("light", 299792458);
-// ->RenderDouble("pi", 3.141592653589793);
-// ->EndObject()
-// ->StartList("empty")
-// ->EndList()
-// ->EndObject();
-//
-// And then the output string would become:
-// {
-// "name": "value",
-// "emptystring": "",
-// "nested": {
-// "light": "299792458",
-// "pi": 3.141592653589793
-// },
-// "empty": []
-// }
-//
-// JsonObjectWriter does not validate if calls actually result in valid JSON.
-// For example, passing an empty name when one would be required won't result
-// in an error, just an invalid output.
-//
-// Note that all int64 and uint64 are rendered as strings instead of numbers.
-// This is because JavaScript parses numbers as 64-bit float thus int64 and
-// uint64 would lose precision if rendered as numbers.
-//
-// JsonObjectWriter is thread-unsafe.
-class PROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
- public:
- JsonObjectWriter(StringPiece indent_string, io::CodedOutputStream* out)
- : element_(new Element(/*parent=*/nullptr, /*is_json_object=*/false)),
- stream_(out),
- sink_(out),
- indent_string_(indent_string),
- indent_char_('\0'),
- indent_count_(0),
- use_websafe_base64_for_bytes_(false) {
- // See if we have a trivial sequence of indent characters.
- if (!indent_string.empty()) {
- indent_char_ = indent_string[0];
- indent_count_ = indent_string.length();
- for (int i = 1; i < indent_string.length(); i++) {
- if (indent_char_ != indent_string_[i]) {
- indent_char_ = '\0';
- indent_count_ = 0;
- break;
- }
- }
- }
- }
- ~JsonObjectWriter() override;
-
- // ObjectWriter methods.
- JsonObjectWriter* StartObject(StringPiece name) override;
- JsonObjectWriter* EndObject() override;
- JsonObjectWriter* StartList(StringPiece name) override;
- JsonObjectWriter* EndList() override;
- JsonObjectWriter* RenderBool(StringPiece name, bool value) override;
- JsonObjectWriter* RenderInt32(StringPiece name, arc_i32 value) override;
- JsonObjectWriter* RenderUint32(StringPiece name,
- arc_ui32 value) override;
- JsonObjectWriter* RenderInt64(StringPiece name, arc_i64 value) override;
- JsonObjectWriter* RenderUint64(StringPiece name,
- arc_ui64 value) override;
- JsonObjectWriter* RenderDouble(StringPiece name, double value) override;
- JsonObjectWriter* RenderFloat(StringPiece name, float value) override;
- JsonObjectWriter* RenderString(StringPiece name,
- StringPiece value) override;
- JsonObjectWriter* RenderBytes(StringPiece name, StringPiece value) override;
- JsonObjectWriter* RenderNull(StringPiece name) override;
- virtual JsonObjectWriter* RenderNullAsEmpty(StringPiece name);
-
- void set_use_websafe_base64_for_bytes(bool value) {
- use_websafe_base64_for_bytes_ = value;
- }
-
- protected:
- class PROTOBUF_EXPORT Element : public BaseElement {
- public:
- Element(Element* parent, bool is_json_object)
- : BaseElement(parent),
- is_first_(true),
- is_json_object_(is_json_object) {}
-
- // Called before each field of the Element is to be processed.
- // Returns true if this is the first call (processing the first field).
- bool is_first() {
- if (is_first_) {
- is_first_ = false;
- return true;
- }
- return false;
- }
-
- // Whether we are currently rendering inside a JSON object (i.e., between
- // StartObject() and EndObject()).
- bool is_json_object() const { return is_json_object_; }
-
- private:
- bool is_first_;
- bool is_json_object_;
-
- GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(Element);
- };
-
- Element* element() override { return element_.get(); }
-
- private:
- class PROTOBUF_EXPORT ByteSinkWrapper : public strings::ByteSink {
- public:
- explicit ByteSinkWrapper(io::CodedOutputStream* stream) : stream_(stream) {}
- ~ByteSinkWrapper() override {}
-
- // ByteSink methods.
- void Append(const char* bytes, size_t n) override {
- stream_->WriteRaw(bytes, n);
- }
-
- private:
- io::CodedOutputStream* stream_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ByteSinkWrapper);
- };
-
- // Renders a simple value as a string. By default all non-string Render
- // methods convert their argument to a string and call this method. This
- // method can then be used to render the simple value without escaping it.
- JsonObjectWriter* RenderSimple(StringPiece name,
- StringPiece value) {
- WritePrefix(name);
- WriteRawString(value);
- return this;
- }
-
- // Pushes a new JSON array element to the stack.
- void PushArray() {
- element_.reset(new Element(element_.release(), /*is_json_object=*/false));
- }
-
- // Pushes a new JSON object element to the stack.
- void PushObject() {
- element_.reset(new Element(element_.release(), /*is_json_object=*/true));
- }
-
- // Pops an element off of the stack and deletes the popped element.
- void Pop() {
- bool needs_newline = !element_->is_first();
- element_.reset(element_->pop<Element>());
- if (needs_newline) NewLine();
- }
-
- // If pretty printing is enabled, this will write a newline to the output,
- // followed by optional indentation. Otherwise this method is a noop.
- void NewLine() {
- if (!indent_string_.empty()) {
- size_t len = sizeof('\n') + (indent_string_.size() * element()->level());
-
- // Take the slow-path if we don't have sufficient characters remaining in
- // our buffer or we have a non-trivial indent string which would prevent
- // us from using memset.
- uint8_t* out = nullptr;
- if (indent_count_ > 0) {
- out = stream_->GetDirectBufferForNBytesAndAdvance(len);
- }
-
- if (out != nullptr) {
- out[0] = '\n';
- memset(&out[1], indent_char_, len - 1);
- } else {
- // Slow path, no contiguous output buffer available.
- WriteChar('\n');
- for (int i = 0; i < element()->level(); i++) {
- stream_->WriteRaw(indent_string_.c_str(), indent_string_.length());
- }
- }
- }
- }
-
- // Writes a prefix. This will write out any pretty printing and
- // commas that are required, followed by the name and a ':' if
- // the name is not null.
- void WritePrefix(StringPiece name);
-
- // Writes an individual character to the output.
- void WriteChar(const char c) { stream_->WriteRaw(&c, sizeof(c)); }
-
- // Writes a string to the output.
- void WriteRawString(StringPiece s) {
- stream_->WriteRaw(s.data(), s.length());
- }
-
- std::unique_ptr<Element> element_;
- io::CodedOutputStream* stream_;
- ByteSinkWrapper sink_;
- const TProtoStringType indent_string_;
-
- // For the common case of indent being a single character repeated.
- char indent_char_;
- int indent_count_;
-
- // Whether to use regular or websafe base64 encoding for byte fields. Defaults
- // to regular base64 encoding.
- bool use_websafe_base64_for_bytes_;
-
- GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(JsonObjectWriter);
-};
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#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
deleted file mode 100644
index 880c6bb0bc3..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/json_stream_parser.cc
+++ /dev/null
@@ -1,995 +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/util/internal/json_stream_parser.h>
-
-#include <algorithm>
-#include <cctype>
-#include <cmath>
-#include <memory>
-#include <stack>
-#include <string>
-
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/status.h>
-#include <google/protobuf/util/internal/object_writer.h>
-#include <google/protobuf/util/internal/json_escaping.h>
-
-
-namespace google {
-namespace protobuf {
-namespace util {
-
-namespace converter {
-
-// Number of digits in an escaped UTF-16 code unit ('\\' 'u' X X X X)
-static const int kUnicodeEscapedLength = 6;
-
-static const int kDefaultMaxRecursionDepth = 100;
-
-// These cannot be constexpr for portability with VS2015.
-static const StringPiece kKeywordTrue = "true";
-static const StringPiece kKeywordFalse = "false";
-static const StringPiece kKeywordNull = "null";
-
-inline bool IsLetter(char c) {
- return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || (c == '_') ||
- (c == '$');
-}
-
-inline bool IsAlphanumeric(char c) {
- return IsLetter(c) || ('0' <= c && c <= '9');
-}
-
-// Indicates a character may not be part of an unquoted key.
-inline bool IsKeySeparator(char c) {
- return (ascii_isspace(c) || c == '"' || c == '\'' || c == '{' ||
- c == '}' || c == '[' || c == ']' || c == ':' || c == ',');
-}
-
-inline void ReplaceInvalidCodePoints(StringPiece str,
- const TProtoStringType& replacement,
- TProtoStringType* dst) {
- while (!str.empty()) {
- int n_valid_bytes = internal::UTF8SpnStructurallyValid(str);
- StringPiece valid_part = str.substr(0, n_valid_bytes);
- StrAppend(dst, valid_part);
-
- if (n_valid_bytes == str.size()) {
- break;
- }
-
- // Append replacement value.
- StrAppend(dst, replacement);
-
- // Move past valid bytes + one invalid byte.
- str.remove_prefix(n_valid_bytes + 1);
- }
-}
-
-static bool ConsumeKey(StringPiece* input, StringPiece* key) {
- if (input->empty() || !IsLetter((*input)[0])) return false;
- int len = 1;
- for (; len < input->size(); ++len) {
- if (!IsAlphanumeric((*input)[len])) {
- break;
- }
- }
- *key = StringPiece(input->data(), len);
- *input = StringPiece(input->data() + len, input->size() - len);
- return true;
-}
-
-// Same as 'ConsumeKey', but allows a widened set of key characters.
-static bool ConsumeKeyPermissive(StringPiece* input,
- StringPiece* key) {
- if (input->empty() || !IsLetter((*input)[0])) return false;
- int len = 1;
- for (; len < input->size(); ++len) {
- if (IsKeySeparator((*input)[len])) {
- break;
- }
- }
- *key = StringPiece(input->data(), len);
- *input = StringPiece(input->data() + len, input->size() - len);
- return true;
-}
-
-static bool MatchKey(StringPiece input) {
- return !input.empty() && IsLetter(input[0]);
-}
-
-JsonStreamParser::JsonStreamParser(ObjectWriter* ow)
- : ow_(ow),
- stack_(),
- leftover_(),
- json_(),
- p_(),
- key_(),
- key_storage_(),
- finishing_(false),
- seen_non_whitespace_(false),
- allow_no_root_element_(false),
- parsed_(),
- parsed_storage_(),
- string_open_(0),
- chunk_storage_(),
- coerce_to_utf8_(false),
- utf8_replacement_character_(" "),
- allow_empty_null_(false),
- allow_permissive_key_naming_(false),
- loose_float_number_conversion_(false),
- recursion_depth_(0),
- max_recursion_depth_(kDefaultMaxRecursionDepth) {
- // Initialize the stack with a single value to be parsed.
- stack_.push(VALUE);
-}
-
-JsonStreamParser::~JsonStreamParser() {}
-
-
-util::Status JsonStreamParser::Parse(StringPiece json) {
- StringPiece chunk = json;
- // If we have leftovers from a previous chunk, append the new chunk to it
- // and create a new StringPiece pointing at the string's data. This could
- // be large but we rely on the chunks to be small, assuming they are
- // fragments of a Cord.
- if (!leftover_.empty()) {
- // Don't point chunk to leftover_ because leftover_ will be updated in
- // ParseChunk(chunk).
- chunk_storage_.swap(leftover_);
- StrAppend(&chunk_storage_, json);
- chunk = StringPiece(chunk_storage_);
- }
-
- // Find the structurally valid UTF8 prefix and parse only that.
- int n = internal::UTF8SpnStructurallyValid(chunk);
- if (n > 0) {
- util::Status status = ParseChunk(chunk.substr(0, n));
-
- // Any leftover characters are stashed in leftover_ for later parsing when
- // there is more data available.
- StrAppend(&leftover_, chunk.substr(n));
- return status;
- } else {
- leftover_.assign(chunk.data(), chunk.size());
- return util::Status();
- }
-}
-
-util::Status JsonStreamParser::FinishParse() {
- // If we do not expect anything and there is nothing left to parse we're all
- // done.
- if (stack_.empty() && leftover_.empty()) {
- return util::Status();
- }
-
- // Lifetime needs to last until RunParser returns, so keep this variable
- // outside of the coerce_to_utf8 block.
- std::unique_ptr<TProtoStringType> scratch;
-
- bool is_valid_utf8 = internal::IsStructurallyValidUTF8(leftover_);
- if (coerce_to_utf8_ && !is_valid_utf8) {
- scratch.reset(new TProtoStringType);
- scratch->reserve(leftover_.size() * utf8_replacement_character_.size());
- ReplaceInvalidCodePoints(leftover_, utf8_replacement_character_,
- scratch.get());
- p_ = json_ = *scratch;
- } else {
- p_ = json_ = leftover_;
- if (!is_valid_utf8) {
- return ReportFailure("Encountered non UTF-8 code points.",
- ParseErrorType::NON_UTF_8);
- }
- }
-
- // Parse the remainder in finishing mode, which reports errors for things like
- // unterminated strings or unknown tokens that would normally be retried.
- finishing_ = true;
- util::Status result = RunParser();
- if (result.ok()) {
- SkipWhitespace();
- if (!p_.empty()) {
- result =
- ReportFailure("Parsing terminated before end of input.",
- ParseErrorType::PARSING_TERMINATED_BEFORE_END_OF_INPUT);
- }
- }
- return result;
-}
-
-util::Status JsonStreamParser::ParseChunk(StringPiece chunk) {
- // Do not do any work if the chunk is empty.
- if (chunk.empty()) return util::Status();
-
- p_ = json_ = chunk;
-
- finishing_ = false;
- util::Status result = RunParser();
- if (!result.ok()) return result;
-
- SkipWhitespace();
- if (p_.empty()) {
- // If we parsed everything we had, clear the leftover.
- leftover_.clear();
- } else {
- // If we do not expect anything i.e. stack is empty, and we have non-empty
- // string left to parse, we report an error.
- if (stack_.empty()) {
- return ReportFailure(
- "Parsing terminated before end of input.",
- ParseErrorType::PARSING_TERMINATED_BEFORE_END_OF_INPUT);
- }
- // If we expect future data i.e. stack is non-empty, and we have some
- // unparsed data left, we save it for later parse.
- leftover_ = TProtoStringType(p_);
- }
- return util::Status();
-}
-
-bool JsonStreamParser::IsInputAllWhiteSpaces(TokenType type) {
- // Conclude the whole input is full of white spaces by:
- // - it is at the finishing stage
- // - we have run out of the input data
- // - haven't seen non-whitespace char so far
- if (finishing_ && p_.empty() && type == UNKNOWN && !seen_non_whitespace_) {
- return true;
- }
- return false;
-}
-
-util::Status JsonStreamParser::RunParser() {
- while (!stack_.empty()) {
- ParseType type = stack_.top();
- TokenType t = (string_open_ == 0) ? GetNextTokenType() : BEGIN_STRING;
- stack_.pop();
- util::Status result;
- switch (type) {
- case VALUE:
- if (allow_no_root_element_ && IsInputAllWhiteSpaces(t)) {
- return util::Status();
- }
- result = ParseValue(t);
- break;
-
- case OBJ_MID:
- result = ParseObjectMid(t);
- break;
-
- case ENTRY:
- result = ParseEntry(t);
- break;
-
- case ENTRY_MID:
- result = ParseEntryMid(t);
- break;
-
- case ARRAY_VALUE:
- result = ParseArrayValue(t);
- break;
-
- case ARRAY_MID:
- result = ParseArrayMid(t);
- break;
-
- default:
- result =
- util::InternalError(StrCat("Unknown parse type: ", type));
- break;
- }
- if (!result.ok()) {
- // If we were cancelled, save our state and try again later.
- if (!finishing_ && util::IsCancelled(result)) {
- stack_.push(type);
- // If we have a key we still need to render, make sure to save off the
- // contents in our own storage.
- if (!key_.empty() && key_storage_.empty()) {
- StrAppend(&key_storage_, key_);
- key_ = StringPiece(key_storage_);
- }
- result = util::Status();
- }
- return result;
- }
- }
- return util::Status();
-}
-
-util::Status JsonStreamParser::ParseValue(TokenType type) {
- switch (type) {
- case BEGIN_OBJECT:
- return HandleBeginObject();
- case BEGIN_ARRAY:
- return HandleBeginArray();
- case BEGIN_STRING:
- return ParseString();
- case BEGIN_NUMBER:
- return ParseNumber();
- case BEGIN_TRUE:
- return ParseTrue();
- case BEGIN_FALSE:
- return ParseFalse();
- case BEGIN_NULL:
- return ParseNull();
- case UNKNOWN:
- return ReportUnknown("Expected a value.", ParseErrorType::EXPECTED_VALUE);
- default: {
- // Special case for having been cut off while parsing, wait for more data.
- // This handles things like 'fals' being at the end of the string, we
- // don't know if the next char would be e, completing it, or something
- // else, making it invalid.
- if (!finishing_ && p_.length() < kKeywordFalse.length()) {
- return util::CancelledError("");
- }
-
- if (allow_empty_null_ && IsEmptyNullAllowed(type)) {
- return ParseEmptyNull();
- }
- return ReportFailure("Unexpected token.",
- ParseErrorType::UNEXPECTED_TOKEN);
- }
- }
-}
-
-util::Status JsonStreamParser::ParseString() {
- util::Status result = ParseStringHelper();
- if (result.ok()) {
- ow_->RenderString(key_, parsed_);
- key_ = StringPiece();
- parsed_ = StringPiece();
- parsed_storage_.clear();
- }
- return result;
-}
-
-util::Status JsonStreamParser::ParseStringHelper() {
- // If we haven't seen the start quote, grab it and remember it for later.
- if (string_open_ == 0) {
- string_open_ = *p_.data();
- GOOGLE_DCHECK(string_open_ == '\"' || string_open_ == '\'');
- Advance();
- }
- // Track where we last copied data from so we can minimize copying.
- const char* last = p_.data();
- while (!p_.empty()) {
- const char* data = p_.data();
- if (*data == '\\') {
- // We're about to handle an escape, copy all bytes from last to data.
- if (last < data) {
- parsed_storage_.append(last, data - last);
- }
- // If we ran out of string after the \, cancel or report an error
- // depending on if we expect more data later.
- if (p_.length() == 1) {
- if (!finishing_) {
- return util::CancelledError("");
- }
- return ReportFailure("Closing quote expected in string.",
- ParseErrorType::EXPECTED_CLOSING_QUOTE);
- }
- // Parse a unicode escape if we found \u in the string.
- if (data[1] == 'u') {
- util::Status result = ParseUnicodeEscape();
- if (!result.ok()) {
- return result;
- }
- // Move last pointer past the unicode escape and continue.
- last = p_.data();
- continue;
- }
- // Handle the standard set of backslash-escaped characters.
- switch (data[1]) {
- case 'b':
- parsed_storage_.push_back('\b');
- break;
- case 'f':
- parsed_storage_.push_back('\f');
- break;
- case 'n':
- parsed_storage_.push_back('\n');
- break;
- case 'r':
- parsed_storage_.push_back('\r');
- break;
- case 't':
- parsed_storage_.push_back('\t');
- break;
- case 'v':
- parsed_storage_.push_back('\v');
- break;
- default:
- parsed_storage_.push_back(data[1]);
- }
- // We handled two characters, so advance past them and continue.
- p_.remove_prefix(2);
- last = p_.data();
- continue;
- }
- // If we found the closing quote note it, advance past it, and return.
- if (*data == string_open_) {
- // If we didn't copy anything, reuse the input buffer.
- if (parsed_storage_.empty()) {
- parsed_ = StringPiece(last, data - last);
- } else {
- if (last < data) {
- parsed_storage_.append(last, data - last);
- }
- parsed_ = StringPiece(parsed_storage_);
- }
- // Clear the quote char so next time we try to parse a string we'll
- // start fresh.
- string_open_ = 0;
- Advance();
- return util::Status();
- }
- // Normal character, just advance past it.
- Advance();
- }
- // If we ran out of characters, copy over what we have so far.
- if (last < p_.data()) {
- parsed_storage_.append(last, p_.data() - last);
- }
- // If we didn't find the closing quote but we expect more data, cancel for now
- if (!finishing_) {
- return util::CancelledError("");
- }
- // End of string reached without a closing quote, report an error.
- string_open_ = 0;
- return ReportFailure("Closing quote expected in string.",
- ParseErrorType::EXPECTED_CLOSING_QUOTE);
-}
-
-// Converts a unicode escaped character to a decimal value stored in a char32
-// for use in UTF8 encoding utility. We assume that str begins with \uhhhh and
-// convert that from the hex number to a decimal value.
-//
-// There are some security exploits with UTF-8 that we should be careful of:
-// - http://www.unicode.org/reports/tr36/#UTF-8_Exploit
-// - http://sites/intl-eng/design-guide/core-application
-util::Status JsonStreamParser::ParseUnicodeEscape() {
- if (p_.length() < kUnicodeEscapedLength) {
- if (!finishing_) {
- return util::CancelledError("");
- }
- return ReportFailure("Illegal hex string.",
- ParseErrorType::ILLEGAL_HEX_STRING);
- }
- GOOGLE_DCHECK_EQ('\\', p_.data()[0]);
- GOOGLE_DCHECK_EQ('u', p_.data()[1]);
- arc_ui32 code = 0;
- for (int i = 2; i < kUnicodeEscapedLength; ++i) {
- if (!isxdigit(p_.data()[i])) {
- return ReportFailure("Invalid escape sequence.",
- ParseErrorType::INVALID_ESCAPE_SEQUENCE);
- }
- code = (code << 4) + hex_digit_to_int(p_.data()[i]);
- }
- if (code >= JsonEscaping::kMinHighSurrogate &&
- code <= JsonEscaping::kMaxHighSurrogate) {
- if (p_.length() < 2 * kUnicodeEscapedLength) {
- if (!finishing_) {
- return util::CancelledError("");
- }
- if (!coerce_to_utf8_) {
- return ReportFailure("Missing low surrogate.",
- ParseErrorType::MISSING_LOW_SURROGATE);
- }
- } else if (p_.data()[kUnicodeEscapedLength] == '\\' &&
- p_.data()[kUnicodeEscapedLength + 1] == 'u') {
- arc_ui32 low_code = 0;
- for (int i = kUnicodeEscapedLength + 2; i < 2 * kUnicodeEscapedLength;
- ++i) {
- if (!isxdigit(p_.data()[i])) {
- return ReportFailure("Invalid escape sequence.",
- ParseErrorType::INVALID_ESCAPE_SEQUENCE);
- }
- low_code = (low_code << 4) + hex_digit_to_int(p_.data()[i]);
- }
- if (low_code >= JsonEscaping::kMinLowSurrogate &&
- low_code <= JsonEscaping::kMaxLowSurrogate) {
- // Convert UTF-16 surrogate pair to 21-bit Unicode codepoint.
- code = (((code & 0x3FF) << 10) | (low_code & 0x3FF)) +
- JsonEscaping::kMinSupplementaryCodePoint;
- // Advance past the first code unit escape.
- p_.remove_prefix(kUnicodeEscapedLength);
- } else if (!coerce_to_utf8_) {
- return ReportFailure("Invalid low surrogate.",
- ParseErrorType::INVALID_LOW_SURROGATE);
- }
- } else if (!coerce_to_utf8_) {
- return ReportFailure("Missing low surrogate.",
- ParseErrorType::MISSING_LOW_SURROGATE);
- }
- }
- if (!coerce_to_utf8_ && !IsValidCodePoint(code)) {
- return ReportFailure("Invalid unicode code point.",
- ParseErrorType::INVALID_UNICODE);
- }
- char buf[UTFmax];
- int len = EncodeAsUTF8Char(code, buf);
- // Advance past the [final] code unit escape.
- p_.remove_prefix(kUnicodeEscapedLength);
- parsed_storage_.append(buf, len);
- return util::Status();
-}
-
-util::Status JsonStreamParser::ParseNumber() {
- NumberResult number;
- util::Status result = ParseNumberHelper(&number);
- if (result.ok()) {
- switch (number.type) {
- case NumberResult::DOUBLE:
- ow_->RenderDouble(key_, number.double_val);
- key_ = StringPiece();
- break;
-
- case NumberResult::INT:
- ow_->RenderInt64(key_, number.int_val);
- key_ = StringPiece();
- break;
-
- case NumberResult::UINT:
- ow_->RenderUint64(key_, number.uint_val);
- key_ = StringPiece();
- break;
-
- default:
- return ReportFailure("Unable to parse number.",
- ParseErrorType::UNABLE_TO_PARSE_NUMBER);
- }
- }
- return result;
-}
-
-util::Status JsonStreamParser::ParseDoubleHelper(const TProtoStringType& number,
- NumberResult* result) {
- if (!safe_strtod(number, &result->double_val)) {
- return ReportFailure("Unable to parse number.",
- ParseErrorType::UNABLE_TO_PARSE_NUMBER);
- }
- if (!loose_float_number_conversion_ && !std::isfinite(result->double_val)) {
- return ReportFailure("Number exceeds the range of double.",
- ParseErrorType::NUMBER_EXCEEDS_RANGE_DOUBLE);
- }
- result->type = NumberResult::DOUBLE;
- return util::Status();
-}
-
-util::Status JsonStreamParser::ParseNumberHelper(NumberResult* result) {
- const char* data = p_.data();
- int length = p_.length();
-
- // Look for the first non-numeric character, or the end of the string.
- int index = 0;
- bool floating = false;
- bool negative = data[index] == '-';
- // Find the first character that cannot be part of the number. Along the way
- // detect if the number needs to be parsed as a double.
- // Note that this restricts numbers to the JSON specification, so for example
- // we do not support hex or octal notations.
- for (; index < length; ++index) {
- char c = data[index];
- if (isdigit(c)) continue;
- if (c == '.' || c == 'e' || c == 'E') {
- floating = true;
- continue;
- }
- if (c == '+' || c == '-' || c == 'x') continue;
- // Not a valid number character, break out.
- break;
- }
-
- // If the entire input is a valid number, and we may have more content in the
- // future, we abort for now and resume when we know more.
- if (index == length && !finishing_) {
- return util::CancelledError("");
- }
-
- // Create a string containing just the number, so we can use safe_strtoX
- TProtoStringType number = TProtoStringType(p_.substr(0, index));
-
- // Floating point number, parse as a double.
- if (floating) {
- util::Status status = ParseDoubleHelper(number, result);
- if (status.ok()) {
- p_.remove_prefix(index);
- }
- return status;
- }
-
- // 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') {
- return ReportFailure(
- "Octal/hex numbers are not valid JSON values.",
- ParseErrorType::OCTAL_OR_HEX_ARE_NOT_VALID_JSON_VALUES);
- }
- if (safe_strtou64(number, &result->uint_val)) {
- result->type = NumberResult::UINT;
- p_.remove_prefix(index);
- return util::Status();
- } else {
- // If the value is too large, parse it as double.
- util::Status status = ParseDoubleHelper(number, result);
- if (status.ok()) {
- p_.remove_prefix(index);
- }
- return status;
- }
- }
-
- // Octal/Hex numbers are not valid JSON values.
- if (number.length() >= 3 && number[1] == '0') {
- return ReportFailure(
- "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 arc_i64.
- if (safe_strto64(number, &result->int_val)) {
- result->type = NumberResult::INT;
- p_.remove_prefix(index);
- return util::Status();
- } else {
- // If the value is too large, parse it as double.
- util::Status status = ParseDoubleHelper(number, result);
- if (status.ok()) {
- p_.remove_prefix(index);
- }
- return status;
- }
-}
-
-util::Status JsonStreamParser::HandleBeginObject() {
- GOOGLE_DCHECK_EQ('{', *p_.data());
- Advance();
- ow_->StartObject(key_);
- auto status = IncrementRecursionDepth(key_);
- if (!status.ok()) {
- return status;
- }
- key_ = StringPiece();
- stack_.push(ENTRY);
- return util::Status();
-}
-
-util::Status JsonStreamParser::ParseObjectMid(TokenType type) {
- if (type == UNKNOWN) {
- return ReportUnknown("Expected , or } after key:value pair.",
- ParseErrorType::EXPECTED_COMMA_OR_BRACES);
- }
-
- // Object is complete, advance past the comma and render the EndObject.
- if (type == END_OBJECT) {
- Advance();
- ow_->EndObject();
- --recursion_depth_;
- return util::Status();
- }
- // Found a comma, advance past it and get ready for an entry.
- if (type == VALUE_SEPARATOR) {
- Advance();
- stack_.push(ENTRY);
- return util::Status();
- }
- // Illegal token after key:value pair.
- return ReportFailure("Expected , or } after key:value pair.",
- ParseErrorType::EXPECTED_COMMA_OR_BRACES);
-}
-
-util::Status JsonStreamParser::ParseEntry(TokenType type) {
- if (type == UNKNOWN) {
- return ReportUnknown("Expected an object key or }.",
- ParseErrorType::EXPECTED_OBJECT_KEY_OR_BRACES);
- }
-
- // Close the object and return. This allows for trailing commas.
- if (type == END_OBJECT) {
- ow_->EndObject();
- Advance();
- --recursion_depth_;
- return util::Status();
- }
-
- util::Status result;
- if (type == BEGIN_STRING) {
- // Key is a string (standard JSON), parse it and store the string.
- result = ParseStringHelper();
- if (result.ok()) {
- key_storage_.clear();
- if (!parsed_storage_.empty()) {
- parsed_storage_.swap(key_storage_);
- key_ = StringPiece(key_storage_);
- } else {
- key_ = parsed_;
- }
- parsed_ = StringPiece();
- }
- } else if (type == BEGIN_KEY) {
- // Key is a bare key (back compat), create a StringPiece pointing to it.
- result = ParseKey();
- } else if (type == BEGIN_NULL || type == BEGIN_TRUE || type == BEGIN_FALSE) {
- // Key may be a bare key that begins with a reserved word.
- result = ParseKey();
- if (result.ok() && (key_ == kKeywordNull || key_ == kKeywordTrue ||
- key_ == kKeywordFalse)) {
- result = ReportFailure("Expected an object key or }.",
- ParseErrorType::EXPECTED_OBJECT_KEY_OR_BRACES);
- }
- } else {
- // Unknown key type, report an error.
- result = ReportFailure("Expected an object key or }.",
- ParseErrorType::EXPECTED_OBJECT_KEY_OR_BRACES);
- }
- // On success we next expect an entry mid ':' then an object mid ',' or '}'
- if (result.ok()) {
- stack_.push(OBJ_MID);
- stack_.push(ENTRY_MID);
- }
- return result;
-}
-
-util::Status JsonStreamParser::ParseEntryMid(TokenType type) {
- if (type == UNKNOWN) {
- return ReportUnknown("Expected : between key:value pair.",
- ParseErrorType::EXPECTED_COLON);
- }
- if (type == ENTRY_SEPARATOR) {
- Advance();
- stack_.push(VALUE);
- return util::Status();
- }
- return ReportFailure("Expected : between key:value pair.",
- ParseErrorType::EXPECTED_COLON);
-}
-
-util::Status JsonStreamParser::HandleBeginArray() {
- GOOGLE_DCHECK_EQ('[', *p_.data());
- Advance();
- ow_->StartList(key_);
- key_ = StringPiece();
- stack_.push(ARRAY_VALUE);
- return util::Status();
-}
-
-util::Status JsonStreamParser::ParseArrayValue(TokenType type) {
- if (type == UNKNOWN) {
- return ReportUnknown("Expected a value or ] within an array.",
- ParseErrorType::EXPECTED_VALUE_OR_BRACKET);
- }
-
- if (type == END_ARRAY) {
- ow_->EndList();
- Advance();
- return util::Status();
- }
-
- // The ParseValue call may push something onto the stack so we need to make
- // sure an ARRAY_MID is after it, so we push it on now. Also, the parsing of
- // empty-null array value is relying on this ARRAY_MID token.
- stack_.push(ARRAY_MID);
- util::Status result = ParseValue(type);
- if (util::IsCancelled(result)) {
- // If we were cancelled, pop back off the ARRAY_MID so we don't try to
- // push it on again when we try over.
- stack_.pop();
- }
- return result;
-}
-
-util::Status JsonStreamParser::ParseArrayMid(TokenType type) {
- if (type == UNKNOWN) {
- return ReportUnknown("Expected , or ] after array value.",
- ParseErrorType::EXPECTED_COMMA_OR_BRACKET);
- }
-
- if (type == END_ARRAY) {
- ow_->EndList();
- Advance();
- return util::Status();
- }
-
- // Found a comma, advance past it and expect an array value next.
- if (type == VALUE_SEPARATOR) {
- Advance();
- stack_.push(ARRAY_VALUE);
- return util::Status();
- }
- // Illegal token after array value.
- return ReportFailure("Expected , or ] after array value.",
- ParseErrorType::EXPECTED_COMMA_OR_BRACKET);
-}
-
-util::Status JsonStreamParser::ParseTrue() {
- ow_->RenderBool(key_, true);
- key_ = StringPiece();
- p_.remove_prefix(kKeywordTrue.length());
- return util::Status();
-}
-
-util::Status JsonStreamParser::ParseFalse() {
- ow_->RenderBool(key_, false);
- key_ = StringPiece();
- p_.remove_prefix(kKeywordFalse.length());
- return util::Status();
-}
-
-util::Status JsonStreamParser::ParseNull() {
- ow_->RenderNull(key_);
- key_ = StringPiece();
- p_.remove_prefix(kKeywordNull.length());
- return util::Status();
-}
-
-util::Status JsonStreamParser::ParseEmptyNull() {
- ow_->RenderNull(key_);
- key_ = StringPiece();
- return util::Status();
-}
-
-bool JsonStreamParser::IsEmptyNullAllowed(TokenType type) {
- if (stack_.empty()) return false;
- return (stack_.top() == ARRAY_MID && type == VALUE_SEPARATOR) ||
- stack_.top() == OBJ_MID;
-}
-
-util::Status JsonStreamParser::ReportFailure(StringPiece message,
- ParseErrorType parse_code) {
- (void)parse_code; // Parameter is used in Google-internal code.
- static const int kContextLength = 20;
- const char* p_start = p_.data();
- const char* json_start = json_.data();
- const char* begin = std::max(p_start - kContextLength, json_start);
- const char* end =
- std::min(p_start + kContextLength, json_start + json_.size());
- StringPiece segment(begin, end - begin);
- TProtoStringType location(p_start - begin, ' ');
- location.push_back('^');
- auto status = util::InvalidArgumentError(
- StrCat(message, "\n", segment, "\n", location));
- return status;
-}
-
-util::Status JsonStreamParser::ReportUnknown(StringPiece message,
- ParseErrorType parse_code) {
- // If we aren't finishing the parse, cancel parsing and try later.
- if (!finishing_) {
- return util::CancelledError("");
- }
- if (p_.empty()) {
- return ReportFailure(StrCat("Unexpected end of string. ", message),
- parse_code);
- }
- return ReportFailure(message, parse_code);
-}
-
-util::Status JsonStreamParser::IncrementRecursionDepth(
- StringPiece key) const {
- if (++recursion_depth_ > max_recursion_depth_) {
- return util::InvalidArgumentError(StrCat(
- "Message too deep. Max recursion depth reached for key '", key, "'"));
- }
- return util::Status();
-}
-
-void JsonStreamParser::SkipWhitespace() {
- while (!p_.empty() && ascii_isspace(*p_.data())) {
- Advance();
- }
- if (!p_.empty() && !ascii_isspace(*p_.data())) {
- seen_non_whitespace_ = true;
- }
-}
-
-void JsonStreamParser::Advance() {
- // Advance by moving one UTF8 character while making sure we don't go beyond
- // the length of StringPiece.
- p_.remove_prefix(std::min<int>(
- p_.length(), UTF8FirstLetterNumBytes(p_.data(), p_.length())));
-}
-
-util::Status JsonStreamParser::ParseKey() {
- StringPiece original = p_;
-
- if (allow_permissive_key_naming_) {
- if (!ConsumeKeyPermissive(&p_, &key_)) {
- return ReportFailure("Invalid key or variable name.",
- ParseErrorType::INVALID_KEY_OR_VARIABLE_NAME);
- }
- } else {
- if (!ConsumeKey(&p_, &key_)) {
- return ReportFailure("Invalid key or variable name.",
- ParseErrorType::INVALID_KEY_OR_VARIABLE_NAME);
- }
- }
-
- // If we consumed everything but expect more data, reset p_ and cancel since
- // we can't know if the key was complete or not.
- if (!finishing_ && p_.empty()) {
- p_ = original;
- return util::CancelledError("");
- }
- // Since we aren't using the key storage, clear it out.
- key_storage_.clear();
- return util::Status();
-}
-
-JsonStreamParser::TokenType JsonStreamParser::GetNextTokenType() {
- SkipWhitespace();
-
- int size = p_.size();
- if (size == 0) {
- // If we ran out of data, report unknown and we'll place the previous parse
- // type onto the stack and try again when we have more data.
- return UNKNOWN;
- }
- // TODO(sven): Split this method based on context since different contexts
- // support different tokens. Would slightly speed up processing?
- const char* data = p_.data();
- StringPiece data_view = StringPiece(data, size);
- if (*data == '\"' || *data == '\'') return BEGIN_STRING;
- if (*data == '-' || ('0' <= *data && *data <= '9')) {
- return BEGIN_NUMBER;
- }
- if (size >= kKeywordTrue.length() &&
- HasPrefixString(data_view, kKeywordTrue)) {
- return BEGIN_TRUE;
- }
- if (size >= kKeywordFalse.length() &&
- HasPrefixString(data_view, kKeywordFalse)) {
- return BEGIN_FALSE;
- }
- if (size >= kKeywordNull.length() &&
- HasPrefixString(data_view, kKeywordNull)) {
- return BEGIN_NULL;
- }
- if (*data == '{') return BEGIN_OBJECT;
- if (*data == '}') return END_OBJECT;
- if (*data == '[') return BEGIN_ARRAY;
- if (*data == ']') return END_ARRAY;
- if (*data == ':') return ENTRY_SEPARATOR;
- if (*data == ',') return VALUE_SEPARATOR;
- if (MatchKey(p_)) {
- return BEGIN_KEY;
- }
-
- // We don't know that we necessarily have an invalid token here, just that we
- // can't parse what we have so far. So we don't report an error and just
- // return UNKNOWN so we can try again later when we have more data, or if we
- // finish and we have leftovers.
- return UNKNOWN;
-}
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
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
deleted file mode 100644
index 0a0c6823a46..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/json_stream_parser.h
+++ /dev/null
@@ -1,350 +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_UTIL_INTERNAL_JSON_STREAM_PARSER_H__
-#define GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_STREAM_PARSER_H__
-
-#include <cstdint>
-#include <stack>
-#include <string>
-
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/status.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/status.h>
-
-// Must be included last.
-#include <google/protobuf/port_def.inc>
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-
-class ObjectWriter;
-
-// A JSON parser that can parse a stream of JSON chunks rather than needing the
-// entire JSON string up front. It is a modified version of the parser in
-// //net/proto/json/json-parser.h that has been changed in the following ways:
-// - Changed from recursion to an explicit stack to allow resumption
-// - Added support for int64 and uint64 numbers
-// - Removed support for octal and decimal escapes
-// - Removed support for numeric keys
-// - Removed support for functions (javascript)
-// - Removed some lax-comma support (but kept trailing comma support)
-// - Writes directly to an ObjectWriter rather than using subclassing
-//
-// Here is an example usage:
-// JsonStreamParser parser(ow_.get());
-// util::Status result = parser.Parse(chunk1);
-// result.Update(parser.Parse(chunk2));
-// result.Update(parser.FinishParse());
-// GOOGLE_DCHECK(result.ok()) << "Failed to parse JSON";
-//
-// This parser is thread-compatible as long as only one thread is calling a
-// Parse() method at a time.
-class PROTOBUF_EXPORT JsonStreamParser {
- public:
- // Creates a JsonStreamParser that will write to the given ObjectWriter.
- explicit JsonStreamParser(ObjectWriter* ow);
- virtual ~JsonStreamParser();
-
- // Parses a UTF-8 encoded JSON string from a StringPiece. If the returned
- // status is non-ok, the status might contain a payload ParseErrorType with
- // type_url kParseErrorTypeUrl and a payload containing string snippet of the
- // error with type_url kParseErrorSnippetUrl.
- util::Status Parse(StringPiece json);
-
-
- // Finish parsing the JSON string. If the returned status is non-ok, the
- // status might contain a payload ParseErrorType with type_url
- // kParseErrorTypeUrl and a payload containing string snippet of the error
- // with type_url kParseErrorSnippetUrl.
- util::Status FinishParse();
-
-
- // Sets the max recursion depth of JSON message to be deserialized. JSON
- // messages over this depth will fail to be deserialized.
- // Default value is 100.
- void set_max_recursion_depth(int max_depth) {
- max_recursion_depth_ = max_depth;
- }
-
- // Denotes the cause of error.
- enum ParseErrorType {
- UNKNOWN_PARSE_ERROR,
- OCTAL_OR_HEX_ARE_NOT_VALID_JSON_VALUES,
- EXPECTED_COLON,
- EXPECTED_COMMA_OR_BRACKET,
- EXPECTED_VALUE,
- EXPECTED_COMMA_OR_BRACES,
- EXPECTED_OBJECT_KEY_OR_BRACES,
- EXPECTED_VALUE_OR_BRACKET,
- INVALID_KEY_OR_VARIABLE_NAME,
- NON_UTF_8,
- PARSING_TERMINATED_BEFORE_END_OF_INPUT,
- UNEXPECTED_TOKEN,
- EXPECTED_CLOSING_QUOTE,
- ILLEGAL_HEX_STRING,
- INVALID_ESCAPE_SEQUENCE,
- MISSING_LOW_SURROGATE,
- INVALID_LOW_SURROGATE,
- INVALID_UNICODE,
- UNABLE_TO_PARSE_NUMBER,
- NUMBER_EXCEEDS_RANGE_DOUBLE
- };
-
- private:
- friend class JsonStreamParserTest;
- // Return the current recursion depth.
- int recursion_depth() { return recursion_depth_; }
-
- enum TokenType {
- BEGIN_STRING, // " or '
- BEGIN_NUMBER, // - or digit
- BEGIN_TRUE, // true
- BEGIN_FALSE, // false
- BEGIN_NULL, // null
- BEGIN_OBJECT, // {
- END_OBJECT, // }
- BEGIN_ARRAY, // [
- END_ARRAY, // ]
- ENTRY_SEPARATOR, // :
- VALUE_SEPARATOR, // ,
- BEGIN_KEY, // letter, _, $ or digit. Must begin with non-digit
- UNKNOWN // Unknown token or we ran out of the stream.
- };
-
- enum ParseType {
- VALUE, // Expects a {, [, true, false, null, string or number
- OBJ_MID, // Expects a ',' or }
- ENTRY, // Expects a key or }
- ENTRY_MID, // Expects a :
- ARRAY_VALUE, // Expects a value or ]
- ARRAY_MID // Expects a ',' or ]
- };
-
- // Holds the result of parsing a number
- struct NumberResult {
- enum Type { DOUBLE, INT, UINT };
- Type type;
- union {
- double double_val;
- arc_i64 int_val;
- arc_ui64 uint_val;
- };
- };
-
- // Parses a single chunk of JSON, returning an error if the JSON was invalid.
- util::Status ParseChunk(StringPiece chunk);
-
- // Runs the parser based on stack_ and p_, until the stack is empty or p_ runs
- // out of data. If we unexpectedly run out of p_ we push the latest back onto
- // the stack and return.
- util::Status RunParser();
-
- // Parses a value from p_ and writes it to ow_.
- // A value may be an object, array, true, false, null, string or number.
- util::Status ParseValue(TokenType type);
-
- // Parses a string and writes it out to the ow_.
- util::Status ParseString();
-
- // Parses a string, storing the result in parsed_.
- util::Status ParseStringHelper();
-
- // This function parses unicode escape sequences in strings. It returns an
- // error when there's a parsing error, either the size is not the expected
- // size or a character is not a hex digit. When it returns str will contain
- // what has been successfully parsed so far.
- util::Status ParseUnicodeEscape();
-
- // Expects p_ to point to a JSON number, writes the number to the writer using
- // the appropriate Render method based on the type of number.
- util::Status ParseNumber();
-
- // Parse a number into a NumberResult, reporting an error if no number could
- // be parsed. This method will try to parse into a uint64, int64, or double
- // based on whether the number was positive or negative or had a decimal
- // component.
- util::Status ParseNumberHelper(NumberResult* result);
-
- // Parse a number as double into a NumberResult.
- util::Status ParseDoubleHelper(const TProtoStringType& number,
- NumberResult* result);
-
- // Handles a { during parsing of a value.
- util::Status HandleBeginObject();
-
- // Parses from the ENTRY state.
- util::Status ParseEntry(TokenType type);
-
- // Parses from the ENTRY_MID state.
- util::Status ParseEntryMid(TokenType type);
-
- // Parses from the OBJ_MID state.
- util::Status ParseObjectMid(TokenType type);
-
- // Handles a [ during parsing of a value.
- util::Status HandleBeginArray();
-
- // Parses from the ARRAY_VALUE state.
- util::Status ParseArrayValue(TokenType type);
-
- // Parses from the ARRAY_MID state.
- util::Status ParseArrayMid(TokenType type);
-
- // Expects p_ to point to an unquoted literal
- util::Status ParseTrue();
- util::Status ParseFalse();
- util::Status ParseNull();
- util::Status ParseEmptyNull();
-
- // Whether an empty-null is allowed in the current state.
- bool IsEmptyNullAllowed(TokenType type);
-
- // Whether the whole input is all whitespaces.
- bool IsInputAllWhiteSpaces(TokenType type);
-
- // Report a failure as a util::Status.
- util::Status ReportFailure(StringPiece message,
- ParseErrorType parse_code);
-
- // Report a failure due to an UNKNOWN token type. We check if we hit the
- // end of the stream and if we're finishing or not to detect what type of
- // status to return in this case.
- util::Status ReportUnknown(StringPiece message,
- ParseErrorType parse_code);
-
- // Helper function to check recursion depth and increment it. It will return
- // OkStatus() if the current depth is allowed. Otherwise an error is returned.
- // key is used for error reporting.
- util::Status IncrementRecursionDepth(StringPiece key) const;
-
- // Advance p_ past all whitespace or until the end of the string.
- void SkipWhitespace();
-
- // Advance p_ one UTF-8 character
- void Advance();
-
- // Expects p_ to point to the beginning of a key.
- util::Status ParseKey();
-
- // Return the type of the next token at p_.
- TokenType GetNextTokenType();
-
- // The object writer to write parse events to.
- ObjectWriter* ow_;
-
- // The stack of parsing we still need to do. When the stack runs empty we will
- // have parsed a single value from the root (e.g. an object or list).
- std::stack<ParseType> stack_;
-
- // Contains any leftover text from a previous chunk that we weren't able to
- // fully parse, for example the start of a key or number.
- TProtoStringType leftover_;
-
- // The current chunk of JSON being parsed. Primarily used for providing
- // context during error reporting.
- StringPiece json_;
-
- // A pointer within the current JSON being parsed, used to track location.
- StringPiece p_;
-
- // Stores the last key read, as we separate parsing of keys and values.
- StringPiece key_;
-
- // Storage for key_ if we need to keep ownership, for example between chunks
- // or if the key was unescaped from a JSON string.
- TProtoStringType key_storage_;
-
- // True during the FinishParse() call, so we know that any errors are fatal.
- // For example an unterminated string will normally result in cancelling and
- // trying during the next chunk, but during FinishParse() it is an error.
- bool finishing_;
-
- // Whether non whitespace tokens have been seen during parsing.
- // It is used to handle the case of a pure whitespace stream input.
- bool seen_non_whitespace_;
-
- // The JsonStreamParser requires a root element by default and it will raise
- // error if the root element is missing. If `allow_no_root_element_` is true,
- // the JsonStreamParser can also handle this case.
- bool allow_no_root_element_;
-
- // String we parsed during a call to ParseStringHelper().
- StringPiece parsed_;
-
- // Storage for the string we parsed. This may be empty if the string was able
- // to be parsed directly from the input.
- TProtoStringType parsed_storage_;
-
- // The character that opened the string, either ' or ".
- // A value of 0 indicates that string parsing is not in process.
- char string_open_;
-
- // Storage for the chunk that are being parsed in ParseChunk().
- TProtoStringType chunk_storage_;
-
- // Whether to allow non UTF-8 encoded input and replace invalid code points.
- bool coerce_to_utf8_;
-
- // Replacement character for invalid UTF-8 code points.
- TProtoStringType utf8_replacement_character_;
-
- // Whether allows empty string represented null array value or object entry
- // value.
- bool allow_empty_null_;
-
- // Whether unquoted object keys can contain embedded non-alphanumeric
- // characters when this is unambiguous for parsing.
- bool allow_permissive_key_naming_;
-
- // Whether allows out-of-range floating point numbers or reject them.
- bool loose_float_number_conversion_;
-
- // Tracks current recursion depth.
- mutable int recursion_depth_;
-
- // Maximum allowed recursion depth.
- int max_recursion_depth_;
-
- GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(JsonStreamParser);
-};
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_STREAM_PARSER_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
deleted file mode 100644
index fc7672e5fa5..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/object_source.h
+++ /dev/null
@@ -1,85 +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_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>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/status.h>
-
-// Must be included last.
-#include <google/protobuf/port_def.inc>
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-class ObjectWriter;
-
-// An ObjectSource is anything that can write to an ObjectWriter.
-// Implementation of this interface typically provide constructors or
-// factory methods to create an instance based on some source data, for
-// example, a character stream, or protobuf.
-//
-// Derived classes could be thread-unsafe.
-class PROTOBUF_EXPORT ObjectSource {
- public:
- virtual ~ObjectSource() {}
-
- // Writes to the ObjectWriter
- virtual util::Status WriteTo(ObjectWriter* ow) const {
- return NamedWriteTo("", ow);
- }
-
- // Writes to the ObjectWriter with a custom name for the message.
- // This is useful when you chain ObjectSource together by embedding one
- // within another.
- virtual util::Status NamedWriteTo(StringPiece name,
- ObjectWriter* ow) const = 0;
-
- protected:
- ObjectSource() {}
-
- private:
- // Do not add any data members to this class.
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ObjectSource);
-};
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_SOURCE_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/object_writer.cc b/contrib/libs/protobuf/src/google/protobuf/util/internal/object_writer.cc
deleted file mode 100644
index 4dabd378e47..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/object_writer.cc
+++ /dev/null
@@ -1,93 +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/util/internal/object_writer.h>
-
-#include <google/protobuf/util/internal/datapiece.h>
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-// static
-void ObjectWriter::RenderDataPieceTo(const DataPiece& data,
- StringPiece name, ObjectWriter* ow) {
- switch (data.type()) {
- case DataPiece::TYPE_INT32: {
- ow->RenderInt32(name, data.ToInt32().value());
- break;
- }
- case DataPiece::TYPE_INT64: {
- ow->RenderInt64(name, data.ToInt64().value());
- break;
- }
- case DataPiece::TYPE_UINT32: {
- ow->RenderUint32(name, data.ToUint32().value());
- break;
- }
- case DataPiece::TYPE_UINT64: {
- ow->RenderUint64(name, data.ToUint64().value());
- break;
- }
- case DataPiece::TYPE_DOUBLE: {
- ow->RenderDouble(name, data.ToDouble().value());
- break;
- }
- case DataPiece::TYPE_FLOAT: {
- ow->RenderFloat(name, data.ToFloat().value());
- break;
- }
- case DataPiece::TYPE_BOOL: {
- ow->RenderBool(name, data.ToBool().value());
- break;
- }
- case DataPiece::TYPE_STRING: {
- ow->RenderString(name, data.ToString().value());
- break;
- }
- case DataPiece::TYPE_BYTES: {
- ow->RenderBytes(name, data.ToBytes().value());
- break;
- }
- case DataPiece::TYPE_NULL: {
- ow->RenderNull(name);
- break;
- }
- default:
- break;
- }
-}
-
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
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
deleted file mode 100644
index f265386e75f..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/object_writer.h
+++ /dev/null
@@ -1,151 +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_UTIL_INTERNAL_OBJECT_WRITER_H__
-#define GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_WRITER_H__
-
-#include <cstdint>
-
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/strutil.h>
-
-// Must be included last.
-#include <google/protobuf/port_def.inc>
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-
-class DataPiece;
-
-// An ObjectWriter is an interface for writing a stream of events
-// representing objects and collections. Implementation of this
-// interface can be used to write an object stream to an in-memory
-// structure, protobufs, JSON, XML, or any other output format
-// desired. The ObjectSource interface is typically used as the
-// source of an object stream.
-//
-// See JsonObjectWriter for a sample implementation of ObjectWriter
-// and its use.
-//
-// Derived classes could be thread-unsafe.
-//
-// TODO(xinb): seems like a prime candidate to apply the RAII paradigm
-// and get rid the need to call EndXXX().
-class PROTOBUF_EXPORT ObjectWriter {
- public:
- virtual ~ObjectWriter() {}
-
- // Starts an object. If the name is empty, the object will not be named.
- virtual ObjectWriter* StartObject(StringPiece name) = 0;
-
- // Ends an object.
- virtual ObjectWriter* EndObject() = 0;
-
- // Starts a list. If the name is empty, the list will not be named.
- virtual ObjectWriter* StartList(StringPiece name) = 0;
-
- // Ends a list.
- virtual ObjectWriter* EndList() = 0;
-
- // Renders a boolean value.
- virtual ObjectWriter* RenderBool(StringPiece name, bool value) = 0;
-
- // Renders an 32-bit integer value.
- virtual ObjectWriter* RenderInt32(StringPiece name, arc_i32 value) = 0;
-
- // Renders an 32-bit unsigned integer value.
- virtual ObjectWriter* RenderUint32(StringPiece name,
- arc_ui32 value) = 0;
-
- // Renders a 64-bit integer value.
- virtual ObjectWriter* RenderInt64(StringPiece name, arc_i64 value) = 0;
-
- // Renders an 64-bit unsigned integer value.
- virtual ObjectWriter* RenderUint64(StringPiece name,
- arc_ui64 value) = 0;
-
-
- // Renders a double value.
- virtual ObjectWriter* RenderDouble(StringPiece name, double value) = 0;
- // Renders a float value.
- virtual ObjectWriter* RenderFloat(StringPiece name, float value) = 0;
-
- // Renders a StringPiece value. This is for rendering strings.
- virtual ObjectWriter* RenderString(StringPiece name,
- StringPiece value) = 0;
-
- // Renders a bytes value.
- virtual ObjectWriter* RenderBytes(StringPiece name, StringPiece value) = 0;
-
- // Renders a Null value.
- virtual ObjectWriter* RenderNull(StringPiece name) = 0;
-
-
- // Renders a DataPiece object to a ObjectWriter.
- static void RenderDataPieceTo(const DataPiece& data, StringPiece name,
- ObjectWriter* ow);
-
-
- // Indicates whether this ObjectWriter has completed writing the root message,
- // usually this means writing of one complete object. Subclasses must override
- // this behavior appropriately.
- virtual bool done() { return false; }
-
- void set_use_strict_base64_decoding(bool value) {
- use_strict_base64_decoding_ = value;
- }
-
- bool use_strict_base64_decoding() const {
- return use_strict_base64_decoding_;
- }
-
- protected:
- ObjectWriter() : use_strict_base64_decoding_(true) {}
-
- private:
- // If set to true, we use the stricter version of base64 decoding for byte
- // fields by making sure decoded version encodes back to the original string.
- bool use_strict_base64_decoding_;
-
- // Do not add any data members to this class.
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ObjectWriter);
-};
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#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
deleted file mode 100644
index 40cbe18bfec..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/proto_writer.cc
+++ /dev/null
@@ -1,827 +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/util/internal/proto_writer.h>
-
-#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/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 {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-using io::CodedOutputStream;
-using ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite;
-
-ProtoWriter::ProtoWriter(TypeResolver* type_resolver,
- const google::protobuf::Type& type,
- strings::ByteSink* output, ErrorListener* listener)
- : master_type_(type),
- typeinfo_(TypeInfo::NewTypeInfo(type_resolver)),
- own_typeinfo_(true),
- done_(false),
- ignore_unknown_fields_(false),
- ignore_unknown_enum_values_(false),
- use_lower_camel_for_enums_(false),
- case_insensitive_enum_parsing_(true),
- use_json_name_in_missing_fields_(false),
- element_(nullptr),
- size_insert_(),
- output_(output),
- buffer_(),
- adapter_(&buffer_),
- stream_(new CodedOutputStream(&adapter_)),
- listener_(listener),
- invalid_depth_(0),
- tracker_(new ObjectLocationTracker()) {}
-
-ProtoWriter::ProtoWriter(const TypeInfo* typeinfo,
- const google::protobuf::Type& type,
- strings::ByteSink* output, ErrorListener* listener)
- : master_type_(type),
- typeinfo_(typeinfo),
- own_typeinfo_(false),
- done_(false),
- ignore_unknown_fields_(false),
- ignore_unknown_enum_values_(false),
- use_lower_camel_for_enums_(false),
- case_insensitive_enum_parsing_(true),
- use_json_name_in_missing_fields_(false),
- element_(nullptr),
- size_insert_(),
- output_(output),
- buffer_(),
- adapter_(&buffer_),
- stream_(new CodedOutputStream(&adapter_)),
- listener_(listener),
- invalid_depth_(0),
- tracker_(new ObjectLocationTracker()) {}
-
-ProtoWriter::~ProtoWriter() {
- if (own_typeinfo_) {
- delete typeinfo_;
- }
- if (element_ == nullptr) return;
- // Cleanup explicitly in order to avoid destructor stack overflow when input
- // is deeply nested.
- // Cast to BaseElement to avoid doing additional checks (like missing fields)
- // during pop().
- std::unique_ptr<BaseElement> element(
- static_cast<BaseElement*>(element_.get())->pop<BaseElement>());
- while (element != nullptr) {
- element.reset(element->pop<BaseElement>());
- }
-}
-
-namespace {
-
-// Writes an INT32 field, including tag to the stream.
-inline util::Status WriteInt32(int field_number, const DataPiece& data,
- CodedOutputStream* stream) {
- util::StatusOr<arc_i32> i32 = data.ToInt32();
- if (i32.ok()) {
- WireFormatLite::WriteInt32(field_number, i32.value(), stream);
- }
- return i32.status();
-}
-
-// writes an SFIXED32 field, including tag, to the stream.
-inline util::Status WriteSFixed32(int field_number, const DataPiece& data,
- CodedOutputStream* stream) {
- util::StatusOr<arc_i32> i32 = data.ToInt32();
- if (i32.ok()) {
- WireFormatLite::WriteSFixed32(field_number, i32.value(), stream);
- }
- return i32.status();
-}
-
-// Writes an SINT32 field, including tag, to the stream.
-inline util::Status WriteSInt32(int field_number, const DataPiece& data,
- CodedOutputStream* stream) {
- util::StatusOr<arc_i32> i32 = data.ToInt32();
- if (i32.ok()) {
- WireFormatLite::WriteSInt32(field_number, i32.value(), stream);
- }
- return i32.status();
-}
-
-// Writes a FIXED32 field, including tag, to the stream.
-inline util::Status WriteFixed32(int field_number, const DataPiece& data,
- CodedOutputStream* stream) {
- util::StatusOr<arc_ui32> u32 = data.ToUint32();
- if (u32.ok()) {
- WireFormatLite::WriteFixed32(field_number, u32.value(), stream);
- }
- return u32.status();
-}
-
-// Writes a UINT32 field, including tag, to the stream.
-inline util::Status WriteUInt32(int field_number, const DataPiece& data,
- CodedOutputStream* stream) {
- util::StatusOr<arc_ui32> u32 = data.ToUint32();
- if (u32.ok()) {
- WireFormatLite::WriteUInt32(field_number, u32.value(), stream);
- }
- return u32.status();
-}
-
-// Writes an INT64 field, including tag, to the stream.
-inline util::Status WriteInt64(int field_number, const DataPiece& data,
- CodedOutputStream* stream) {
- util::StatusOr<arc_i64> i64 = data.ToInt64();
- if (i64.ok()) {
- WireFormatLite::WriteInt64(field_number, i64.value(), stream);
- }
- return i64.status();
-}
-
-// Writes an SFIXED64 field, including tag, to the stream.
-inline util::Status WriteSFixed64(int field_number, const DataPiece& data,
- CodedOutputStream* stream) {
- util::StatusOr<arc_i64> i64 = data.ToInt64();
- if (i64.ok()) {
- WireFormatLite::WriteSFixed64(field_number, i64.value(), stream);
- }
- return i64.status();
-}
-
-// Writes an SINT64 field, including tag, to the stream.
-inline util::Status WriteSInt64(int field_number, const DataPiece& data,
- CodedOutputStream* stream) {
- util::StatusOr<arc_i64> i64 = data.ToInt64();
- if (i64.ok()) {
- WireFormatLite::WriteSInt64(field_number, i64.value(), stream);
- }
- return i64.status();
-}
-
-// Writes a FIXED64 field, including tag, to the stream.
-inline util::Status WriteFixed64(int field_number, const DataPiece& data,
- CodedOutputStream* stream) {
- util::StatusOr<arc_ui64> u64 = data.ToUint64();
- if (u64.ok()) {
- WireFormatLite::WriteFixed64(field_number, u64.value(), stream);
- }
- return u64.status();
-}
-
-// Writes a UINT64 field, including tag, to the stream.
-inline util::Status WriteUInt64(int field_number, const DataPiece& data,
- CodedOutputStream* stream) {
- util::StatusOr<arc_ui64> u64 = data.ToUint64();
- if (u64.ok()) {
- WireFormatLite::WriteUInt64(field_number, u64.value(), stream);
- }
- return u64.status();
-}
-
-// Writes a DOUBLE field, including tag, to the stream.
-inline util::Status WriteDouble(int field_number, const DataPiece& data,
- CodedOutputStream* stream) {
- util::StatusOr<double> d = data.ToDouble();
- if (d.ok()) {
- WireFormatLite::WriteDouble(field_number, d.value(), stream);
- }
- return d.status();
-}
-
-// Writes a FLOAT field, including tag, to the stream.
-inline util::Status WriteFloat(int field_number, const DataPiece& data,
- CodedOutputStream* stream) {
- util::StatusOr<float> f = data.ToFloat();
- if (f.ok()) {
- WireFormatLite::WriteFloat(field_number, f.value(), stream);
- }
- return f.status();
-}
-
-// Writes a BOOL field, including tag, to the stream.
-inline util::Status WriteBool(int field_number, const DataPiece& data,
- CodedOutputStream* stream) {
- util::StatusOr<bool> b = data.ToBool();
- if (b.ok()) {
- WireFormatLite::WriteBool(field_number, b.value(), stream);
- }
- return b.status();
-}
-
-// Writes a BYTES field, including tag, to the stream.
-inline util::Status WriteBytes(int field_number, const DataPiece& data,
- CodedOutputStream* stream) {
- util::StatusOr<TProtoStringType> c = data.ToBytes();
- if (c.ok()) {
- WireFormatLite::WriteBytes(field_number, c.value(), stream);
- }
- return c.status();
-}
-
-// Writes a STRING field, including tag, to the stream.
-inline util::Status WriteString(int field_number, const DataPiece& data,
- CodedOutputStream* stream) {
- util::StatusOr<TProtoStringType> s = data.ToString();
- if (s.ok()) {
- WireFormatLite::WriteString(field_number, s.value(), stream);
- }
- return s.status();
-}
-
-// Given a google::protobuf::Type, returns the set of all required fields.
-std::unordered_set<const google::protobuf::Field*> GetRequiredFields(
- const google::protobuf::Type& type) {
- 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) {
- required.insert(&field);
- }
- }
- return required;
-}
-
-} // namespace
-
-ProtoWriter::ProtoElement::ProtoElement(const TypeInfo* typeinfo,
- const google::protobuf::Type& type,
- ProtoWriter* enclosing)
- : BaseElement(nullptr),
- ow_(enclosing),
- parent_field_(nullptr),
- typeinfo_(typeinfo),
- proto3_(type.syntax() == google::protobuf::SYNTAX_PROTO3),
- type_(type),
- size_index_(-1),
- array_index_(-1),
- // oneof_indices_ values are 1-indexed (0 means not present).
- oneof_indices_(type.oneofs_size() + 1) {
- if (!proto3_) {
- required_fields_ = GetRequiredFields(type_);
- }
-}
-
-ProtoWriter::ProtoElement::ProtoElement(ProtoWriter::ProtoElement* parent,
- const google::protobuf::Field* field,
- const google::protobuf::Type& type,
- bool is_list)
- : BaseElement(parent),
- ow_(this->parent()->ow_),
- parent_field_(field),
- typeinfo_(this->parent()->typeinfo_),
- proto3_(type.syntax() == google::protobuf::SYNTAX_PROTO3),
- type_(type),
- size_index_(!is_list &&
- field->kind() == google::protobuf::Field::TYPE_MESSAGE
- ? ow_->size_insert_.size()
- : -1),
- array_index_(is_list ? 0 : -1),
- // oneof_indices_ values are 1-indexed (0 means not present).
- oneof_indices_(type_.oneofs_size() + 1) {
- if (!is_list) {
- if (ow_->IsRepeated(*field)) {
- // Update array_index_ if it is an explicit list.
- if (this->parent()->array_index_ >= 0) this->parent()->array_index_++;
- } else if (!proto3_) {
- // For required fields tracking.
- this->parent()->RegisterField(field);
- }
-
- if (field->kind() == google::protobuf::Field::TYPE_MESSAGE) {
- if (!proto3_) {
- required_fields_ = GetRequiredFields(type_);
- }
- int start_pos = ow_->stream_->ByteCount();
- // length of serialized message is the final buffer position minus
- // starting buffer position, plus length adjustments for size fields
- // of any nested messages. We start with -start_pos here, so we only
- // need to add the final buffer position to it at the end.
- SizeInfo info = {start_pos, -start_pos};
- ow_->size_insert_.push_back(info);
- }
- }
-}
-
-ProtoWriter::ProtoElement* ProtoWriter::ProtoElement::pop() {
- if (!proto3_) {
- // Calls the registered error listener for any required field(s) not yet
- // seen.
- 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_
- ? (*it)->json_name()
- : (*it)->name());
- }
- }
- // Computes the total number of proto bytes used by a message, also adjusts
- // the size of all parent messages by the length of this size field.
- // If size_index_ < 0, this is not a message, so no size field is added.
- if (size_index_ >= 0) {
- // Add the final buffer position to compute the total length of this
- // serialized message. The stored value (before this addition) already
- // contains the total length of the size fields of all nested messages
- // minus the initial buffer position.
- ow_->size_insert_[size_index_].size += ow_->stream_->ByteCount();
- // Calculate the length required to serialize the size field of the
- // message, and propagate this additional size information upward to
- // all enclosing messages.
- int size = ow_->size_insert_[size_index_].size;
- int length = CodedOutputStream::VarintSize32(size);
- for (ProtoElement* e = parent(); e != nullptr; e = e->parent()) {
- // Only nested messages have size field, lists do not have size field.
- if (e->size_index_ >= 0) {
- ow_->size_insert_[e->size_index_].size += length;
- }
- }
- }
- return BaseElement::pop<ProtoElement>();
-}
-
-void ProtoWriter::ProtoElement::RegisterField(
- const google::protobuf::Field* field) {
- if (!required_fields_.empty() &&
- field->cardinality() == google::protobuf::Field::CARDINALITY_REQUIRED) {
- required_fields_.erase(field);
- }
-}
-
-TProtoStringType ProtoWriter::ProtoElement::ToString() const {
- TProtoStringType loc = "";
-
- // first populate a stack with the nodes since we need to process them
- // from root to leaf when generating the string location
- const ProtoWriter::ProtoElement* now = this;
- std::stack<const ProtoWriter::ProtoElement*> element_stack;
- while (now->parent() != nullptr) {
- element_stack.push(now);
- now = now->parent();
- }
-
- // now pop each node from the stack and append to the location string
- while (!element_stack.empty()) {
- now = element_stack.top();
- element_stack.pop();
-
- if (!ow_->IsRepeated(*(now->parent_field_)) ||
- now->parent()->parent_field_ != now->parent_field_) {
- TProtoStringType name = now->parent_field_->name();
- int i = 0;
- while (i < name.size() &&
- (ascii_isalnum(name[i]) || name[i] == '_'))
- ++i;
- if (i > 0 && i == name.size()) { // safe field name
- if (loc.empty()) {
- loc = name;
- } else {
- StrAppend(&loc, ".", name);
- }
- } else {
- StrAppend(&loc, "[\"", CEscape(name), "\"]");
- }
- }
-
- int array_index_now = now->array_index_;
- if (ow_->IsRepeated(*(now->parent_field_)) && array_index_now > 0) {
- StrAppend(&loc, "[", array_index_now - 1, "]");
- }
- }
-
- return loc;
-}
-
-bool ProtoWriter::ProtoElement::IsOneofIndexTaken(arc_i32 index) {
- return oneof_indices_[index];
-}
-
-void ProtoWriter::ProtoElement::TakeOneofIndex(arc_i32 index) {
- oneof_indices_[index] = true;
-}
-
-void ProtoWriter::InvalidName(StringPiece unknown_name,
- StringPiece message) {
- listener_->InvalidName(location(), unknown_name, message);
-}
-
-void ProtoWriter::InvalidValue(StringPiece type_name,
- StringPiece value) {
- listener_->InvalidValue(location(), type_name, value);
-}
-
-void ProtoWriter::MissingField(StringPiece missing_name) {
- listener_->MissingField(location(), missing_name);
-}
-
-ProtoWriter* ProtoWriter::StartObject(
- StringPiece name) {
- // Starting the root message. Create the root ProtoElement and return.
- if (element_ == nullptr) {
- if (!name.empty()) {
- InvalidName(name, "Root element should not be named.");
- }
- element_.reset(new ProtoElement(typeinfo_, master_type_, this));
- return this;
- }
-
- const google::protobuf::Field* field = BeginNamed(name, false);
-
- if (field == nullptr) return this;
-
- // Check to see if this field is a oneof and that no oneof in that group has
- // already been set.
- if (!ValidOneof(*field, name)) {
- ++invalid_depth_;
- return this;
- }
-
- const google::protobuf::Type* type = LookupType(field);
- if (type == nullptr) {
- ++invalid_depth_;
- InvalidName(name, StrCat("Missing descriptor for field: ",
- field->type_url()));
- return this;
- }
-
- return StartObjectField(*field, *type);
-}
-
-
-ProtoWriter* ProtoWriter::EndObject() {
- if (invalid_depth_ > 0) {
- --invalid_depth_;
- return this;
- }
-
- if (element_ != nullptr) {
- element_.reset(element_->pop());
- }
-
-
- // If ending the root element,
- // then serialize the full message with calculated sizes.
- if (element_ == nullptr) {
- WriteRootMessage();
- }
- return this;
-}
-
-ProtoWriter* ProtoWriter::StartList(
- StringPiece name) {
-
- const google::protobuf::Field* field = BeginNamed(name, true);
-
- if (field == nullptr) return this;
-
- if (!ValidOneof(*field, name)) {
- ++invalid_depth_;
- return this;
- }
-
- const google::protobuf::Type* type = LookupType(field);
- if (type == nullptr) {
- ++invalid_depth_;
- InvalidName(name, StrCat("Missing descriptor for field: ",
- field->type_url()));
- return this;
- }
-
- return StartListField(*field, *type);
-}
-
-
-ProtoWriter* ProtoWriter::EndList() {
- if (invalid_depth_ > 0) {
- --invalid_depth_;
- } else if (element_ != nullptr) {
- element_.reset(element_->pop());
- }
- return this;
-}
-
-ProtoWriter* ProtoWriter::RenderDataPiece(
- StringPiece name, const DataPiece& data) {
- util::Status status;
- if (invalid_depth_ > 0) return this;
-
- const google::protobuf::Field* field = Lookup(name);
-
- if (field == nullptr) return this;
-
- if (!ValidOneof(*field, name)) return this;
-
- const google::protobuf::Type* type = LookupType(field);
- if (type == nullptr) {
- InvalidName(name, StrCat("Missing descriptor for field: ",
- field->type_url()));
- return this;
- }
-
- return RenderPrimitiveField(*field, *type, data);
-}
-
-bool ProtoWriter::ValidOneof(const google::protobuf::Field& field,
- StringPiece unnormalized_name) {
- if (element_ == nullptr) return true;
-
- if (field.oneof_index() > 0) {
- if (element_->IsOneofIndexTaken(field.oneof_index())) {
- InvalidValue(
- "oneof",
- StrCat(
- "oneof field '", element_->type().oneofs(field.oneof_index() - 1),
- "' is already set. Cannot set '", unnormalized_name, "'"));
- return false;
- }
- element_->TakeOneofIndex(field.oneof_index());
- }
- return true;
-}
-
-bool ProtoWriter::IsRepeated(const google::protobuf::Field& field) {
- return field.cardinality() == google::protobuf::Field::CARDINALITY_REPEATED;
-}
-
-ProtoWriter* ProtoWriter::StartObjectField(const google::protobuf::Field& field,
- const google::protobuf::Type& type) {
- WriteTag(field);
- element_.reset(new ProtoElement(element_.release(), &field, type, false));
- return this;
-}
-
-ProtoWriter* ProtoWriter::StartListField(const google::protobuf::Field& field,
- const google::protobuf::Type& type) {
- element_.reset(new ProtoElement(element_.release(), &field, type, true));
- return this;
-}
-
-util::Status ProtoWriter::WriteEnum(int field_number, const DataPiece& data,
- const google::protobuf::Enum* enum_type,
- CodedOutputStream* stream,
- bool use_lower_camel_for_enums,
- bool case_insensitive_enum_parsing,
- bool ignore_unknown_values) {
- bool is_unknown_enum_value = false;
- util::StatusOr<int> e = data.ToEnum(
- enum_type, use_lower_camel_for_enums, case_insensitive_enum_parsing,
- ignore_unknown_values, &is_unknown_enum_value);
- if (e.ok() && !is_unknown_enum_value) {
- WireFormatLite::WriteEnum(field_number, e.value(), stream);
- }
- return e.status();
-}
-
-ProtoWriter* ProtoWriter::RenderPrimitiveField(
- const google::protobuf::Field& field, const google::protobuf::Type& type,
- const DataPiece& data) {
- util::Status status;
-
- // Pushing a ProtoElement and then pop it off at the end for 2 purposes:
- // error location reporting and required field accounting.
- //
- // For proto3, since there is no required field tracking, we only need to
- // push ProtoElement for error cases.
- if (!element_->proto3()) {
- element_.reset(new ProtoElement(element_.release(), &field, type, false));
- }
-
- switch (field.kind()) {
- case google::protobuf::Field::TYPE_INT32: {
- status = WriteInt32(field.number(), data, stream_.get());
- break;
- }
- case google::protobuf::Field::TYPE_SFIXED32: {
- status = WriteSFixed32(field.number(), data, stream_.get());
- break;
- }
- case google::protobuf::Field::TYPE_SINT32: {
- status = WriteSInt32(field.number(), data, stream_.get());
- break;
- }
- case google::protobuf::Field::TYPE_FIXED32: {
- status = WriteFixed32(field.number(), data, stream_.get());
- break;
- }
- case google::protobuf::Field::TYPE_UINT32: {
- status = WriteUInt32(field.number(), data, stream_.get());
- break;
- }
- case google::protobuf::Field::TYPE_INT64: {
- status = WriteInt64(field.number(), data, stream_.get());
- break;
- }
- case google::protobuf::Field::TYPE_SFIXED64: {
- status = WriteSFixed64(field.number(), data, stream_.get());
- break;
- }
- case google::protobuf::Field::TYPE_SINT64: {
- status = WriteSInt64(field.number(), data, stream_.get());
- break;
- }
- case google::protobuf::Field::TYPE_FIXED64: {
- status = WriteFixed64(field.number(), data, stream_.get());
- break;
- }
- case google::protobuf::Field::TYPE_UINT64: {
- status = WriteUInt64(field.number(), data, stream_.get());
- break;
- }
- case google::protobuf::Field::TYPE_DOUBLE: {
- status = WriteDouble(field.number(), data, stream_.get());
- break;
- }
- case google::protobuf::Field::TYPE_FLOAT: {
- status = WriteFloat(field.number(), data, stream_.get());
- break;
- }
- case google::protobuf::Field::TYPE_BOOL: {
- status = WriteBool(field.number(), data, stream_.get());
- break;
- }
- case google::protobuf::Field::TYPE_BYTES: {
- status = WriteBytes(field.number(), data, stream_.get());
- break;
- }
- case google::protobuf::Field::TYPE_STRING: {
- status = WriteString(field.number(), data, stream_.get());
- break;
- }
- case google::protobuf::Field::TYPE_ENUM: {
- status = WriteEnum(
- field.number(), data, typeinfo_->GetEnumByTypeUrl(field.type_url()),
- stream_.get(), use_lower_camel_for_enums_,
- case_insensitive_enum_parsing_, ignore_unknown_enum_values_);
- break;
- }
- default: // TYPE_GROUP, TYPE_MESSAGE, TYPE_UNKNOWN.
- status = util::InvalidArgumentError(data.ValueAsStringOrDefault(""));
- }
-
- if (!status.ok()) {
- // Push a ProtoElement for location reporting purposes.
- if (element_->proto3()) {
- element_.reset(new ProtoElement(element_.release(), &field, type, false));
- }
- InvalidValue(field.type_url().empty()
- ? google::protobuf::Field_Kind_Name(field.kind())
- : field.type_url(),
- status.message());
- element_.reset(element()->pop());
- return this;
- }
-
- if (!element_->proto3()) element_.reset(element()->pop());
-
- return this;
-}
-
-const google::protobuf::Field* ProtoWriter::BeginNamed(StringPiece name,
- bool is_list) {
- if (invalid_depth_ > 0) {
- ++invalid_depth_;
- return nullptr;
- }
- const google::protobuf::Field* field = Lookup(name);
- if (field == nullptr) {
- ++invalid_depth_;
- // InvalidName() already called in Lookup().
- return nullptr;
- }
- if (is_list && !IsRepeated(*field)) {
- ++invalid_depth_;
- InvalidName(name, "Proto field is not repeating, cannot start list.");
- return nullptr;
- }
- return field;
-}
-
-const google::protobuf::Field* ProtoWriter::Lookup(
- StringPiece unnormalized_name) {
- ProtoElement* e = element();
- if (e == nullptr) {
- InvalidName(unnormalized_name, "Root element must be a message.");
- return nullptr;
- }
- if (unnormalized_name.empty()) {
- // Objects in repeated field inherit the same field descriptor.
- if (e->parent_field() == nullptr) {
- InvalidName(unnormalized_name, "Proto fields must have a name.");
- } else if (!IsRepeated(*e->parent_field())) {
- InvalidName(unnormalized_name, "Proto fields must have a name.");
- return nullptr;
- }
- return e->parent_field();
- }
- const google::protobuf::Field* field =
- typeinfo_->FindField(&e->type(), unnormalized_name);
- if (field == nullptr && !ignore_unknown_fields_) {
- InvalidName(unnormalized_name, "Cannot find field.");
- }
- return field;
-}
-
-const google::protobuf::Type* ProtoWriter::LookupType(
- const google::protobuf::Field* field) {
- return ((field->kind() == google::protobuf::Field::TYPE_MESSAGE ||
- field->kind() == google::protobuf::Field::TYPE_GROUP)
- ? typeinfo_->GetTypeByTypeUrl(field->type_url())
- : &element_->type());
-}
-
-void ProtoWriter::WriteRootMessage() {
- GOOGLE_DCHECK(!done_);
- int curr_pos = 0;
- // Calls the destructor of CodedOutputStream to remove any uninitialized
- // memory from the Cord before we read it.
- stream_.reset(nullptr);
- const void* data;
- int length;
- io::ArrayInputStream input_stream(buffer_.data(), buffer_.size());
- while (input_stream.Next(&data, &length)) {
- if (length == 0) continue;
- int num_bytes = length;
- // Write up to where we need to insert the size field.
- // The number of bytes we may write is the smaller of:
- // - the current fragment size
- // - the distance to the next position where a size field needs to be
- // inserted.
- if (!size_insert_.empty() &&
- size_insert_.front().pos - curr_pos < num_bytes) {
- num_bytes = size_insert_.front().pos - curr_pos;
- }
- output_->Append(static_cast<const char*>(data), num_bytes);
- if (num_bytes < length) {
- input_stream.BackUp(length - num_bytes);
- }
- curr_pos += num_bytes;
- // Insert the size field.
- // size_insert_.front(): the next <index, size> pair to be written.
- // size_insert_.front().pos: position of the size field.
- // size_insert_.front().size: the size (integer) to be inserted.
- if (!size_insert_.empty() && curr_pos == size_insert_.front().pos) {
- // Varint32 occupies at most 10 bytes.
- uint8_t insert_buffer[10];
- uint8_t* insert_buffer_pos = CodedOutputStream::WriteVarint32ToArray(
- size_insert_.front().size, insert_buffer);
- output_->Append(reinterpret_cast<const char*>(insert_buffer),
- insert_buffer_pos - insert_buffer);
- size_insert_.pop_front();
- }
- }
- output_->Flush();
- stream_.reset(new CodedOutputStream(&adapter_));
- done_ = true;
-}
-
-void ProtoWriter::WriteTag(const google::protobuf::Field& field) {
- WireFormatLite::WireType wire_type = WireFormatLite::WireTypeForFieldType(
- static_cast<WireFormatLite::FieldType>(field.kind()));
- stream_->WriteTag(WireFormatLite::MakeTag(field.number(), wire_type));
-}
-
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
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
deleted file mode 100644
index a4d0b1f67e8..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/proto_writer.h
+++ /dev/null
@@ -1,389 +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_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>
-#include <google/protobuf/type.pb.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/zero_copy_stream_impl.h>
-#include <google/protobuf/descriptor.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/hash.h>
-#include <google/protobuf/stubs/status.h>
-
-// Must be included last.
-#include <google/protobuf/port_def.inc>
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-
-class ObjectLocationTracker;
-
-// An ObjectWriter that can write protobuf bytes directly from writer events.
-// This class does not support special types like Struct or Map. However, since
-// this class supports raw protobuf, it can be used to provide support for
-// special types by inheriting from it or by wrapping it.
-//
-// It also supports streaming.
-class PROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter {
- public:
-// Constructor. Does not take ownership of any parameter passed in.
- ProtoWriter(TypeResolver* type_resolver, const google::protobuf::Type& type,
- strings::ByteSink* output, ErrorListener* listener);
- ~ProtoWriter() override;
-
- // ObjectWriter methods.
- ProtoWriter* StartObject(StringPiece name) override;
- ProtoWriter* EndObject() override;
- ProtoWriter* StartList(StringPiece name) override;
- ProtoWriter* EndList() override;
- ProtoWriter* RenderBool(StringPiece name, bool value) override {
- return RenderDataPiece(name, DataPiece(value));
- }
- ProtoWriter* RenderInt32(StringPiece name, arc_i32 value) override {
- return RenderDataPiece(name, DataPiece(value));
- }
- ProtoWriter* RenderUint32(StringPiece name, arc_ui32 value) override {
- return RenderDataPiece(name, DataPiece(value));
- }
- ProtoWriter* RenderInt64(StringPiece name, arc_i64 value) override {
- return RenderDataPiece(name, DataPiece(value));
- }
- ProtoWriter* RenderUint64(StringPiece name, arc_ui64 value) override {
- return RenderDataPiece(name, DataPiece(value));
- }
- ProtoWriter* RenderDouble(StringPiece name, double value) override {
- return RenderDataPiece(name, DataPiece(value));
- }
- ProtoWriter* RenderFloat(StringPiece name, float value) override {
- return RenderDataPiece(name, DataPiece(value));
- }
- ProtoWriter* RenderString(StringPiece name,
- StringPiece value) override {
- return RenderDataPiece(name,
- DataPiece(value, use_strict_base64_decoding()));
- }
-
- ProtoWriter* RenderBytes(StringPiece name, StringPiece value) override {
- return RenderDataPiece(
- name, DataPiece(value, false, use_strict_base64_decoding()));
- }
-
- ProtoWriter* RenderNull(StringPiece name) override {
- return RenderDataPiece(name, DataPiece::NullData());
- }
-
-
- // Renders a DataPiece 'value' into a field whose wire type is determined
- // from the given field 'name'.
- virtual ProtoWriter* RenderDataPiece(StringPiece name,
- const DataPiece& data);
-
-
- // Returns the location tracker to use for tracking locations for errors.
- const LocationTrackerInterface& location() {
- return element_ != nullptr ? *element_ : *tracker_;
- }
-
- // When true, we finished writing to output a complete message.
- bool done() override { return done_; }
-
- // Returns the proto stream object.
- io::CodedOutputStream* stream() { return stream_.get(); }
-
- // Getters and mutators of invalid_depth_.
- void IncrementInvalidDepth() { ++invalid_depth_; }
- void DecrementInvalidDepth() { --invalid_depth_; }
- int invalid_depth() { return invalid_depth_; }
-
- ErrorListener* listener() { return listener_; }
-
- const TypeInfo* typeinfo() { return typeinfo_; }
-
- void set_ignore_unknown_fields(bool ignore_unknown_fields) {
- ignore_unknown_fields_ = ignore_unknown_fields;
- }
-
- bool ignore_unknown_fields() { return ignore_unknown_fields_; }
-
- void set_ignore_unknown_enum_values(bool ignore_unknown_enum_values) {
- ignore_unknown_enum_values_ = ignore_unknown_enum_values;
- }
-
- void set_use_lower_camel_for_enums(bool use_lower_camel_for_enums) {
- use_lower_camel_for_enums_ = use_lower_camel_for_enums;
- }
-
- void set_case_insensitive_enum_parsing(bool case_insensitive_enum_parsing) {
- case_insensitive_enum_parsing_ = case_insensitive_enum_parsing;
- }
-
- void set_use_json_name_in_missing_fields(
- bool use_json_name_in_missing_fields) {
- use_json_name_in_missing_fields_ = use_json_name_in_missing_fields;
- }
-
- protected:
- class PROTOBUF_EXPORT ProtoElement : public BaseElement,
- public LocationTrackerInterface {
- public:
- // Constructor for the root element. No parent nor field.
- ProtoElement(const TypeInfo* typeinfo, const google::protobuf::Type& type,
- ProtoWriter* enclosing);
-
- // Constructor for a field of an element.
- ProtoElement(ProtoElement* parent, const google::protobuf::Field* field,
- const google::protobuf::Type& type, bool is_list);
-
- ~ProtoElement() override {}
-
- // Called just before the destructor for clean up:
- // - reports any missing required fields
- // - computes the space needed by the size field, and augment the
- // length of all parent messages by this additional space.
- // - releases and returns the parent pointer.
- ProtoElement* pop();
-
- // Accessors
- // parent_field() may be nullptr if we are at root.
- const google::protobuf::Field* parent_field() const {
- return parent_field_;
- }
- const google::protobuf::Type& type() const { return type_; }
-
- // Registers field for accounting required fields.
- void RegisterField(const google::protobuf::Field* field);
-
- // To report location on error messages.
- TProtoStringType ToString() const override;
-
- ProtoElement* parent() const override {
- return static_cast<ProtoElement*>(BaseElement::parent());
- }
-
- // Returns true if the index is already taken by a preceding oneof input.
- bool IsOneofIndexTaken(arc_i32 index);
-
- // Marks the oneof 'index' as taken. Future inputs to this oneof will
- // generate an error.
- void TakeOneofIndex(arc_i32 index);
-
- bool proto3() { return proto3_; }
-
- private:
- // Used for access to variables of the enclosing instance of
- // ProtoWriter.
- ProtoWriter* ow_;
-
- // Describes the element as a field in the parent message.
- // parent_field_ is nullptr if and only if this element is the root element.
- const google::protobuf::Field* parent_field_;
-
- // TypeInfo to lookup types.
- const TypeInfo* typeinfo_;
-
- // Whether the type_ is proto3 or not.
- bool proto3_;
-
- // Additional variables if this element is a message:
- // (Root element is always a message).
- // type_ : the type of this element.
- // required_fields_ : set of required fields.
- // size_index_ : index into ProtoWriter::size_insert_
- // for later insertion of serialized message length.
- const google::protobuf::Type& type_;
- std::unordered_set<const google::protobuf::Field*> required_fields_;
- const int size_index_;
-
- // Tracks position in repeated fields, needed for LocationTrackerInterface.
- int array_index_;
-
- // Set of oneof indices already seen for the type_. Used to validate
- // incoming messages so no more than one oneof is set.
- std::vector<bool> oneof_indices_;
-
- GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(ProtoElement);
- };
-
- // Container for inserting 'size' information at the 'pos' position.
- struct SizeInfo {
- const int pos;
- int size;
- };
-
- ProtoWriter(const TypeInfo* typeinfo, const google::protobuf::Type& type,
- strings::ByteSink* output, ErrorListener* listener);
-
- ProtoElement* element() override { return element_.get(); }
-
- // Helper methods for calling ErrorListener. See error_listener.h.
- void InvalidName(StringPiece unknown_name, StringPiece message);
- void InvalidValue(StringPiece type_name, StringPiece value);
- void MissingField(StringPiece missing_name);
-
- // Common code for BeginObject() and BeginList() that does invalid_depth_
- // bookkeeping associated with name lookup.
- const google::protobuf::Field* BeginNamed(StringPiece name,
- bool is_list);
-
- // Lookup the field in the current element. Looks in the base descriptor
- // and in any extension. This will report an error if the field cannot be
- // found when ignore_unknown_names_ is false or if multiple matching
- // extensions are found.
- const google::protobuf::Field* Lookup(StringPiece name);
-
- // Lookup the field type in the type descriptor. Returns nullptr if the type
- // is not known.
- const google::protobuf::Type* LookupType(
- const google::protobuf::Field* field);
-
- // Write serialized output to the final output ByteSink, inserting all
- // the size information for nested messages that are missing from the
- // intermediate Cord buffer.
- void WriteRootMessage();
-
- // Helper method to write proto tags based on the given field.
- void WriteTag(const google::protobuf::Field& field);
-
-
- // Returns true if the field for type_ can be set as a oneof. If field is not
- // a oneof type, this function does nothing and returns true.
- // If another field for this oneof is already set, this function returns
- // false. It also calls the appropriate error callback.
- // unnormalized_name is used for error string.
- bool ValidOneof(const google::protobuf::Field& field,
- StringPiece unnormalized_name);
-
- // Returns true if the field is repeated.
- bool IsRepeated(const google::protobuf::Field& field);
-
- // Starts an object given the field and the enclosing type.
- ProtoWriter* StartObjectField(const google::protobuf::Field& field,
- const google::protobuf::Type& type);
-
- // Starts a list given the field and the enclosing type.
- ProtoWriter* StartListField(const google::protobuf::Field& field,
- const google::protobuf::Type& type);
-
- // Renders a primitive field given the field and the enclosing type.
- ProtoWriter* RenderPrimitiveField(const google::protobuf::Field& field,
- const google::protobuf::Type& type,
- const DataPiece& data);
-
- private:
- // Writes an ENUM field, including tag, to the stream.
- static util::Status WriteEnum(int field_number, const DataPiece& data,
- const google::protobuf::Enum* enum_type,
- io::CodedOutputStream* stream,
- bool use_lower_camel_for_enums,
- bool case_insensitive_enum_parsing,
- bool ignore_unknown_values);
-
- // Variables for describing the structure of the input tree:
- // master_type_: descriptor for the whole protobuf message.
- // typeinfo_ : the TypeInfo object to lookup types.
- const google::protobuf::Type& master_type_;
- const TypeInfo* typeinfo_;
- // Whether we own the typeinfo_ object.
- bool own_typeinfo_;
-
- // Indicates whether we finished writing root message completely.
- bool done_;
-
- // If true, don't report unknown field names to the listener.
- bool ignore_unknown_fields_;
-
- // If true, don't report unknown enum values to the listener.
- bool ignore_unknown_enum_values_;
-
- // If true, check if enum name in camel case or without underscore matches the
- // field name.
- bool use_lower_camel_for_enums_;
-
- // If true, check if enum name in UPPER_CASE matches the field name.
- bool case_insensitive_enum_parsing_;
-
- // If true, use the json name in missing fields errors.
- bool use_json_name_in_missing_fields_;
-
- // Variable for internal state processing:
- // element_ : the current element.
- // size_insert_: sizes of nested messages.
- // pos - position to insert the size field.
- // size - size value to be inserted.
- std::unique_ptr<ProtoElement> element_;
- std::deque<SizeInfo> size_insert_;
-
- // Variables for output generation:
- // output_ : pointer to an external ByteSink for final user-visible output.
- // buffer_ : buffer holding partial message before being ready for output_.
- // adapter_ : internal adapter between CodedOutputStream and buffer_.
- // stream_ : wrapper for writing tags and other encodings in wire format.
- strings::ByteSink* output_;
- TProtoStringType buffer_;
- io::StringOutputStream adapter_;
- std::unique_ptr<io::CodedOutputStream> stream_;
-
- // Variables for error tracking and reporting:
- // listener_ : a place to report any errors found.
- // invalid_depth_: number of enclosing invalid nested messages.
- // tracker_ : the root location tracker interface.
- ErrorListener* listener_;
- int invalid_depth_;
- std::unique_ptr<LocationTrackerInterface> tracker_;
-
- GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(ProtoWriter);
-};
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#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
deleted file mode 100644
index a51650c3a92..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc
+++ /dev/null
@@ -1,1114 +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/util/internal/protostream_objectsource.h>
-
-#include <cstdint>
-#include <unordered_map>
-#include <utility>
-
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/zero_copy_stream_impl.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/stubs/once.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/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 {
-namespace converter {
-
-using ::PROTOBUF_NAMESPACE_ID::internal::WireFormat;
-using ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite;
-
-namespace {
-
-static int kDefaultMaxRecursionDepth = 64;
-
-// Finds a field with the given number. nullptr if none found.
-const google::protobuf::Field* FindFieldByNumber(
- const google::protobuf::Type& type, int number);
-
-// Returns true if the field is packable.
-bool IsPackable(const google::protobuf::Field& field);
-
-// Finds an enum value with the given number. nullptr if none found.
-const google::protobuf::EnumValue* FindEnumValueByNumber(
- const google::protobuf::Enum& tech_enum, int number);
-
-// Utility function to format nanos.
-const TProtoStringType FormatNanos(arc_ui32 nanos, bool with_trailing_zeros);
-
-util::StatusOr<TProtoStringType> MapKeyDefaultValueAsString(
- const google::protobuf::Field& field) {
- switch (field.kind()) {
- case google::protobuf::Field::TYPE_BOOL:
- return TProtoStringType("false");
- case google::protobuf::Field::TYPE_INT32:
- case google::protobuf::Field::TYPE_INT64:
- case google::protobuf::Field::TYPE_UINT32:
- case google::protobuf::Field::TYPE_UINT64:
- case google::protobuf::Field::TYPE_SINT32:
- case google::protobuf::Field::TYPE_SINT64:
- case google::protobuf::Field::TYPE_SFIXED32:
- case google::protobuf::Field::TYPE_SFIXED64:
- case google::protobuf::Field::TYPE_FIXED32:
- case google::protobuf::Field::TYPE_FIXED64:
- return TProtoStringType("0");
- case google::protobuf::Field::TYPE_STRING:
- return TProtoStringType();
- default:
- return util::InternalError("Invalid map key type.");
- }
-}
-} // namespace
-
-
-ProtoStreamObjectSource::ProtoStreamObjectSource(
- io::CodedInputStream* stream, TypeResolver* type_resolver,
- const google::protobuf::Type& type, const RenderOptions& render_options)
- : stream_(stream),
- typeinfo_(TypeInfo::NewTypeInfo(type_resolver)),
- own_typeinfo_(true),
- type_(type),
- render_options_(render_options),
- recursion_depth_(0),
- max_recursion_depth_(kDefaultMaxRecursionDepth) {
- GOOGLE_LOG_IF(DFATAL, stream == nullptr) << "Input stream is nullptr.";
-}
-
-ProtoStreamObjectSource::ProtoStreamObjectSource(
- io::CodedInputStream* stream, const TypeInfo* typeinfo,
- const google::protobuf::Type& type, const RenderOptions& render_options)
- : stream_(stream),
- typeinfo_(typeinfo),
- own_typeinfo_(false),
- type_(type),
- render_options_(render_options),
- recursion_depth_(0),
- max_recursion_depth_(kDefaultMaxRecursionDepth) {
- GOOGLE_LOG_IF(DFATAL, stream == nullptr) << "Input stream is nullptr.";
-}
-
-ProtoStreamObjectSource::~ProtoStreamObjectSource() {
- if (own_typeinfo_) {
- delete typeinfo_;
- }
-}
-
-util::Status ProtoStreamObjectSource::NamedWriteTo(StringPiece name,
- ObjectWriter* ow) const {
- return WriteMessage(type_, name, 0, true, ow);
-}
-
-const google::protobuf::Field* ProtoStreamObjectSource::FindAndVerifyField(
- const google::protobuf::Type& type, arc_ui32 tag) const {
- // Lookup the new field in the type by tag number.
- const google::protobuf::Field* field = FindFieldByNumber(type, tag >> 3);
- // Verify if the field corresponds to the wire type in tag.
- // If there is any discrepancy, mark the field as not found.
- if (field != nullptr) {
- WireFormatLite::WireType expected_type =
- WireFormatLite::WireTypeForFieldType(
- static_cast<WireFormatLite::FieldType>(field->kind()));
- WireFormatLite::WireType actual_type = WireFormatLite::GetTagWireType(tag);
- if (actual_type != expected_type &&
- (!IsPackable(*field) ||
- actual_type != WireFormatLite::WIRETYPE_LENGTH_DELIMITED)) {
- field = nullptr;
- }
- }
- return field;
-}
-
-util::Status ProtoStreamObjectSource::WriteMessage(
- const google::protobuf::Type& type, StringPiece name,
- const arc_ui32 end_tag, bool include_start_and_end,
- ObjectWriter* ow) const {
-
- const TypeRenderer* type_renderer = FindTypeRenderer(type.name());
- if (type_renderer != nullptr) {
- return (*type_renderer)(this, type, name, ow);
- }
-
- const google::protobuf::Field* field = nullptr;
- TProtoStringType field_name;
- // last_tag set to dummy value that is different from tag.
- arc_ui32 tag = stream_->ReadTag(), last_tag = tag + 1;
- UnknownFieldSet unknown_fields;
-
-
- if (include_start_and_end) {
- ow->StartObject(name);
- }
- while (tag != end_tag && tag != 0) {
- if (tag != last_tag) { // Update field only if tag is changed.
- last_tag = tag;
- field = FindAndVerifyField(type, tag);
- if (field != nullptr) {
- if (render_options_.preserve_proto_field_names) {
- field_name = field->name();
- } else {
- field_name = field->json_name();
- }
- }
- }
- if (field == nullptr) {
- // If we didn't find a field, skip this unknown tag.
- // TODO(wpoon): Check return boolean value.
- WireFormat::SkipField(
- stream_, tag,
- nullptr);
- tag = stream_->ReadTag();
- continue;
- }
-
- if (field->cardinality() == google::protobuf::Field::CARDINALITY_REPEATED) {
- if (IsMap(*field)) {
- ow->StartObject(field_name);
- ASSIGN_OR_RETURN(tag, RenderMap(field, field_name, tag, ow));
- ow->EndObject();
- } else {
- ASSIGN_OR_RETURN(tag, RenderList(field, field_name, tag, ow));
- }
- } else {
- // Render the field.
- RETURN_IF_ERROR(RenderField(field, field_name, ow));
- tag = stream_->ReadTag();
- }
- }
-
-
- if (include_start_and_end) {
- ow->EndObject();
- }
- return util::Status();
-}
-
-util::StatusOr<arc_ui32> ProtoStreamObjectSource::RenderList(
- const google::protobuf::Field* field, StringPiece name,
- arc_ui32 list_tag, ObjectWriter* ow) const {
- arc_ui32 tag_to_return = 0;
- ow->StartList(name);
- if (IsPackable(*field) &&
- list_tag ==
- WireFormatLite::MakeTag(field->number(),
- WireFormatLite::WIRETYPE_LENGTH_DELIMITED)) {
- RETURN_IF_ERROR(RenderPacked(field, ow));
- // Since packed fields have a single tag, read another tag from stream to
- // return.
- tag_to_return = stream_->ReadTag();
- } else {
- do {
- RETURN_IF_ERROR(RenderField(field, "", ow));
- } while ((tag_to_return = stream_->ReadTag()) == list_tag);
- }
- ow->EndList();
- return tag_to_return;
-}
-
-util::StatusOr<arc_ui32> ProtoStreamObjectSource::RenderMap(
- const google::protobuf::Field* field, StringPiece /* name */,
- arc_ui32 list_tag, ObjectWriter* ow) const {
- const google::protobuf::Type* field_type =
- typeinfo_->GetTypeByTypeUrl(field->type_url());
- arc_ui32 tag_to_return = 0;
- do {
- // Render map entry message type.
- arc_ui32 buffer32;
- stream_->ReadVarint32(&buffer32); // message length
- int old_limit = stream_->PushLimit(buffer32);
- TProtoStringType map_key;
- for (arc_ui32 tag = stream_->ReadTag(); tag != 0;
- tag = stream_->ReadTag()) {
- const google::protobuf::Field* map_entry_field =
- FindAndVerifyField(*field_type, tag);
- if (map_entry_field == nullptr) {
- WireFormat::SkipField(stream_, tag, nullptr);
- continue;
- }
- // Map field numbers are key = 1 and value = 2
- if (map_entry_field->number() == 1) {
- map_key = ReadFieldValueAsString(*map_entry_field);
- } else if (map_entry_field->number() == 2) {
- if (map_key.empty()) {
- // An absent map key is treated as the default.
- const google::protobuf::Field* key_field =
- FindFieldByNumber(*field_type, 1);
- if (key_field == nullptr) {
- // The Type info for this map entry is incorrect. It should always
- // have a field named "key" and with field number 1.
- return util::InternalError("Invalid map entry.");
- }
- ASSIGN_OR_RETURN(map_key, MapKeyDefaultValueAsString(*key_field));
- }
- RETURN_IF_ERROR(RenderField(map_entry_field, map_key, ow));
- } else {
- // The Type info for this map entry is incorrect. It should contain
- // exactly two fields with field number 1 and 2.
- return util::InternalError("Invalid map entry.");
- }
- }
- stream_->PopLimit(old_limit);
- } while ((tag_to_return = stream_->ReadTag()) == list_tag);
- return tag_to_return;
-}
-
-util::Status ProtoStreamObjectSource::RenderPacked(
- const google::protobuf::Field* field, ObjectWriter* ow) const {
- arc_ui32 length;
- stream_->ReadVarint32(&length);
- int old_limit = stream_->PushLimit(length);
- while (stream_->BytesUntilLimit() > 0) {
- RETURN_IF_ERROR(RenderField(field, StringPiece(), ow));
- }
- stream_->PopLimit(old_limit);
- return util::Status();
-}
-
-util::Status ProtoStreamObjectSource::RenderTimestamp(
- const ProtoStreamObjectSource* os, const google::protobuf::Type& type,
- StringPiece field_name, ObjectWriter* ow) {
- std::pair<arc_i64, arc_i32> p = os->ReadSecondsAndNanos(type);
- arc_i64 seconds = p.first;
- arc_i32 nanos = p.second;
- if (seconds > kTimestampMaxSeconds || seconds < kTimestampMinSeconds) {
- return util::InternalError(StrCat(
- "Timestamp seconds exceeds limit for field: ", field_name));
- }
-
- if (nanos < 0 || nanos >= kNanosPerSecond) {
- return util::InternalError(
- StrCat("Timestamp nanos exceeds limit for field: ", field_name));
- }
-
- ow->RenderString(field_name,
- ::google::protobuf::internal::FormatTime(seconds, nanos));
-
- return util::Status();
-}
-
-util::Status ProtoStreamObjectSource::RenderDuration(
- const ProtoStreamObjectSource* os, const google::protobuf::Type& type,
- StringPiece field_name, ObjectWriter* ow) {
- std::pair<arc_i64, arc_i32> p = os->ReadSecondsAndNanos(type);
- arc_i64 seconds = p.first;
- arc_i32 nanos = p.second;
- if (seconds > kDurationMaxSeconds || seconds < kDurationMinSeconds) {
- return util::InternalError(
- StrCat("Duration seconds exceeds limit for field: ", field_name));
- }
-
- if (nanos <= -kNanosPerSecond || nanos >= kNanosPerSecond) {
- return util::InternalError(
- StrCat("Duration nanos exceeds limit for field: ", field_name));
- }
-
- TProtoStringType sign = "";
- if (seconds < 0) {
- if (nanos > 0) {
- return util::InternalError(
- StrCat("Duration nanos is non-negative, but seconds is "
- "negative for field: ",
- field_name));
- }
- sign = "-";
- seconds = -seconds;
- nanos = -nanos;
- } else if (seconds == 0 && nanos < 0) {
- sign = "-";
- nanos = -nanos;
- }
- TProtoStringType formatted_duration = StringPrintf(
- "%s%lld%ss", sign.c_str(), static_cast<long long>(seconds), // NOLINT
- FormatNanos(
- nanos,
- false
- )
- .c_str());
- ow->RenderString(field_name, formatted_duration);
- return util::Status();
-}
-
-util::Status ProtoStreamObjectSource::RenderDouble(
- const ProtoStreamObjectSource* os, const google::protobuf::Type& /*type*/,
- StringPiece field_name, ObjectWriter* ow) {
- arc_ui32 tag = os->stream_->ReadTag();
- arc_ui64 buffer64 = 0; // default value of Double wrapper value
- if (tag != 0) {
- os->stream_->ReadLittleEndian64(&buffer64);
- os->stream_->ReadTag();
- }
- ow->RenderDouble(field_name, bit_cast<double>(buffer64));
- return util::Status();
-}
-
-util::Status ProtoStreamObjectSource::RenderFloat(
- const ProtoStreamObjectSource* os, const google::protobuf::Type& /*type*/,
- StringPiece field_name, ObjectWriter* ow) {
- arc_ui32 tag = os->stream_->ReadTag();
- arc_ui32 buffer32 = 0; // default value of Float wrapper value
- if (tag != 0) {
- os->stream_->ReadLittleEndian32(&buffer32);
- os->stream_->ReadTag();
- }
- ow->RenderFloat(field_name, bit_cast<float>(buffer32));
- return util::Status();
-}
-
-util::Status ProtoStreamObjectSource::RenderInt64(
- const ProtoStreamObjectSource* os, const google::protobuf::Type& /*type*/,
- StringPiece field_name, ObjectWriter* ow) {
- arc_ui32 tag = os->stream_->ReadTag();
- arc_ui64 buffer64 = 0; // default value of Int64 wrapper value
- if (tag != 0) {
- os->stream_->ReadVarint64(&buffer64);
- os->stream_->ReadTag();
- }
- ow->RenderInt64(field_name, bit_cast<arc_i64>(buffer64));
- return util::Status();
-}
-
-util::Status ProtoStreamObjectSource::RenderUInt64(
- const ProtoStreamObjectSource* os, const google::protobuf::Type& /*type*/,
- StringPiece field_name, ObjectWriter* ow) {
- arc_ui32 tag = os->stream_->ReadTag();
- arc_ui64 buffer64 = 0; // default value of UInt64 wrapper value
- if (tag != 0) {
- os->stream_->ReadVarint64(&buffer64);
- os->stream_->ReadTag();
- }
- ow->RenderUint64(field_name, bit_cast<arc_ui64>(buffer64));
- return util::Status();
-}
-
-util::Status ProtoStreamObjectSource::RenderInt32(
- const ProtoStreamObjectSource* os, const google::protobuf::Type& /*type*/,
- StringPiece field_name, ObjectWriter* ow) {
- arc_ui32 tag = os->stream_->ReadTag();
- arc_ui32 buffer32 = 0; // default value of Int32 wrapper value
- if (tag != 0) {
- os->stream_->ReadVarint32(&buffer32);
- os->stream_->ReadTag();
- }
- ow->RenderInt32(field_name, bit_cast<arc_i32>(buffer32));
- return util::Status();
-}
-
-util::Status ProtoStreamObjectSource::RenderUInt32(
- const ProtoStreamObjectSource* os, const google::protobuf::Type& /*type*/,
- StringPiece field_name, ObjectWriter* ow) {
- arc_ui32 tag = os->stream_->ReadTag();
- arc_ui32 buffer32 = 0; // default value of UInt32 wrapper value
- if (tag != 0) {
- os->stream_->ReadVarint32(&buffer32);
- os->stream_->ReadTag();
- }
- ow->RenderUint32(field_name, bit_cast<arc_ui32>(buffer32));
- return util::Status();
-}
-
-util::Status ProtoStreamObjectSource::RenderBool(
- const ProtoStreamObjectSource* os, const google::protobuf::Type& /*type*/,
- StringPiece field_name, ObjectWriter* ow) {
- arc_ui32 tag = os->stream_->ReadTag();
- arc_ui64 buffer64 = 0; // results in 'false' value as default, which is the
- // default value of Bool wrapper
- if (tag != 0) {
- os->stream_->ReadVarint64(&buffer64);
- os->stream_->ReadTag();
- }
- ow->RenderBool(field_name, buffer64 != 0);
- return util::Status();
-}
-
-util::Status ProtoStreamObjectSource::RenderString(
- const ProtoStreamObjectSource* os, const google::protobuf::Type& /*type*/,
- StringPiece field_name, ObjectWriter* ow) {
- arc_ui32 tag = os->stream_->ReadTag();
- arc_ui32 buffer32;
- TProtoStringType str; // default value of empty for String wrapper
- if (tag != 0) {
- os->stream_->ReadVarint32(&buffer32); // string size.
- os->stream_->ReadString(&str, buffer32);
- os->stream_->ReadTag();
- }
- ow->RenderString(field_name, str);
- return util::Status();
-}
-
-util::Status ProtoStreamObjectSource::RenderBytes(
- const ProtoStreamObjectSource* os, const google::protobuf::Type& /*type*/,
- StringPiece field_name, ObjectWriter* ow) {
- arc_ui32 tag = os->stream_->ReadTag();
- arc_ui32 buffer32;
- TProtoStringType str;
- if (tag != 0) {
- os->stream_->ReadVarint32(&buffer32);
- os->stream_->ReadString(&str, buffer32);
- os->stream_->ReadTag();
- }
- ow->RenderBytes(field_name, str);
- return util::Status();
-}
-
-util::Status ProtoStreamObjectSource::RenderStruct(
- const ProtoStreamObjectSource* os, const google::protobuf::Type& type,
- StringPiece field_name, ObjectWriter* ow) {
- const google::protobuf::Field* field = nullptr;
- arc_ui32 tag = os->stream_->ReadTag();
- ow->StartObject(field_name);
- while (tag != 0) {
- field = os->FindAndVerifyField(type, tag);
- if (field == nullptr) {
- WireFormat::SkipField(os->stream_, tag, nullptr);
- tag = os->stream_->ReadTag();
- continue;
- }
- // google.protobuf.Struct has only one field that is a map. Hence we use
- // RenderMap to render that field.
- if (os->IsMap(*field)) {
- ASSIGN_OR_RETURN(tag, os->RenderMap(field, field_name, tag, ow));
- }
- }
- ow->EndObject();
- return util::Status();
-}
-
-util::Status ProtoStreamObjectSource::RenderStructValue(
- const ProtoStreamObjectSource* os, const google::protobuf::Type& type,
- StringPiece field_name, ObjectWriter* ow) {
- const google::protobuf::Field* field = nullptr;
- for (arc_ui32 tag = os->stream_->ReadTag(); tag != 0;
- tag = os->stream_->ReadTag()) {
- field = os->FindAndVerifyField(type, tag);
- if (field == nullptr) {
- WireFormat::SkipField(os->stream_, tag, nullptr);
- continue;
- }
- RETURN_IF_ERROR(os->RenderField(field, field_name, ow));
- }
- return util::Status();
-}
-
-// TODO(skarvaje): Avoid code duplication of for loops and SkipField logic.
-util::Status ProtoStreamObjectSource::RenderStructListValue(
- const ProtoStreamObjectSource* os, const google::protobuf::Type& type,
- StringPiece field_name, ObjectWriter* ow) {
- arc_ui32 tag = os->stream_->ReadTag();
-
- // Render empty list when we find empty ListValue message.
- if (tag == 0) {
- ow->StartList(field_name);
- ow->EndList();
- return util::Status();
- }
-
- while (tag != 0) {
- const google::protobuf::Field* field = os->FindAndVerifyField(type, tag);
- if (field == nullptr) {
- WireFormat::SkipField(os->stream_, tag, nullptr);
- tag = os->stream_->ReadTag();
- continue;
- }
- ASSIGN_OR_RETURN(tag, os->RenderList(field, field_name, tag, ow));
- }
- return util::Status();
-}
-
-util::Status ProtoStreamObjectSource::RenderAny(
- const ProtoStreamObjectSource* os, const google::protobuf::Type& type,
- StringPiece field_name, ObjectWriter* ow) {
- // An Any is of the form { string type_url = 1; bytes value = 2; }
- arc_ui32 tag;
- TProtoStringType type_url;
- TProtoStringType value;
-
- // First read out the type_url and value from the proto stream
- for (tag = os->stream_->ReadTag(); tag != 0; tag = os->stream_->ReadTag()) {
- const google::protobuf::Field* field = os->FindAndVerifyField(type, tag);
- if (field == nullptr) {
- WireFormat::SkipField(os->stream_, tag, nullptr);
- continue;
- }
- // 'type_url' has field number of 1 and 'value' has field number 2
- // //google/protobuf/any.proto
- if (field->number() == 1) {
- // read type_url
- arc_ui32 type_url_size;
- os->stream_->ReadVarint32(&type_url_size);
- os->stream_->ReadString(&type_url, type_url_size);
- } else if (field->number() == 2) {
- // read value
- arc_ui32 value_size;
- os->stream_->ReadVarint32(&value_size);
- os->stream_->ReadString(&value, value_size);
- }
- }
-
- // If there is no value, we don't lookup the type, we just output it (if
- // present). If both type and value are empty we output an empty object.
- if (value.empty()) {
- ow->StartObject(field_name);
- if (!type_url.empty()) {
- ow->RenderString("@type", type_url);
- }
- ow->EndObject();
- return util::Status();
- }
-
- // If there is a value but no type, we cannot render it, so report an error.
- if (type_url.empty()) {
- // TODO(sven): Add an external message once those are ready.
- return util::InternalError("Invalid Any, the type_url is missing.");
- }
-
- util::StatusOr<const google::protobuf::Type*> resolved_type =
- os->typeinfo_->ResolveTypeUrl(type_url);
-
- if (!resolved_type.ok()) {
- // Convert into an internal error, since this means the backend gave us
- // an invalid response (missing or invalid type information).
- return util::InternalError(resolved_type.status().message());
- }
- // nested_type cannot be null at this time.
- const google::protobuf::Type* nested_type = resolved_type.value();
-
- io::ArrayInputStream zero_copy_stream(value.data(), value.size());
- io::CodedInputStream in_stream(&zero_copy_stream);
- // We know the type so we can render it. Recursively parse the nested stream
- // using a nested ProtoStreamObjectSource using our nested type information.
- ProtoStreamObjectSource nested_os(&in_stream, os->typeinfo_, *nested_type,
- os->render_options_);
-
- // We manually call start and end object here so we can inject the @type.
- ow->StartObject(field_name);
- ow->RenderString("@type", type_url);
- util::Status result =
- nested_os.WriteMessage(nested_os.type_, "value", 0, false, ow);
- ow->EndObject();
- return result;
-}
-
-util::Status ProtoStreamObjectSource::RenderFieldMask(
- const ProtoStreamObjectSource* os, const google::protobuf::Type& type,
- StringPiece field_name, ObjectWriter* ow) {
- TProtoStringType combined;
- arc_ui32 buffer32;
- arc_ui32 paths_field_tag = 0;
- for (arc_ui32 tag = os->stream_->ReadTag(); tag != 0;
- tag = os->stream_->ReadTag()) {
- if (paths_field_tag == 0) {
- const google::protobuf::Field* field = os->FindAndVerifyField(type, tag);
- if (field != nullptr && field->number() == 1 &&
- field->name() == "paths") {
- paths_field_tag = tag;
- }
- }
- if (paths_field_tag != tag) {
- return util::InternalError("Invalid FieldMask, unexpected field.");
- }
- TProtoStringType str;
- os->stream_->ReadVarint32(&buffer32); // string size.
- os->stream_->ReadString(&str, buffer32);
- if (!combined.empty()) {
- combined.append(",");
- }
- combined.append(ConvertFieldMaskPath(str, &ToCamelCase));
- }
- ow->RenderString(field_name, combined);
- return util::Status();
-}
-
-
-std::unordered_map<TProtoStringType, ProtoStreamObjectSource::TypeRenderer>*
- ProtoStreamObjectSource::renderers_ = nullptr;
-PROTOBUF_NAMESPACE_ID::internal::once_flag source_renderers_init_;
-
-
-void ProtoStreamObjectSource::InitRendererMap() {
- renderers_ = new std::unordered_map<TProtoStringType,
- ProtoStreamObjectSource::TypeRenderer>();
- (*renderers_)["google.protobuf.Timestamp"] =
- &ProtoStreamObjectSource::RenderTimestamp;
- (*renderers_)["google.protobuf.Duration"] =
- &ProtoStreamObjectSource::RenderDuration;
- (*renderers_)["google.protobuf.DoubleValue"] =
- &ProtoStreamObjectSource::RenderDouble;
- (*renderers_)["google.protobuf.FloatValue"] =
- &ProtoStreamObjectSource::RenderFloat;
- (*renderers_)["google.protobuf.Int64Value"] =
- &ProtoStreamObjectSource::RenderInt64;
- (*renderers_)["google.protobuf.UInt64Value"] =
- &ProtoStreamObjectSource::RenderUInt64;
- (*renderers_)["google.protobuf.Int32Value"] =
- &ProtoStreamObjectSource::RenderInt32;
- (*renderers_)["google.protobuf.UInt32Value"] =
- &ProtoStreamObjectSource::RenderUInt32;
- (*renderers_)["google.protobuf.BoolValue"] =
- &ProtoStreamObjectSource::RenderBool;
- (*renderers_)["google.protobuf.StringValue"] =
- &ProtoStreamObjectSource::RenderString;
- (*renderers_)["google.protobuf.BytesValue"] =
- &ProtoStreamObjectSource::RenderBytes;
- (*renderers_)["google.protobuf.Any"] = &ProtoStreamObjectSource::RenderAny;
- (*renderers_)["google.protobuf.Struct"] =
- &ProtoStreamObjectSource::RenderStruct;
- (*renderers_)["google.protobuf.Value"] =
- &ProtoStreamObjectSource::RenderStructValue;
- (*renderers_)["google.protobuf.ListValue"] =
- &ProtoStreamObjectSource::RenderStructListValue;
- (*renderers_)["google.protobuf.FieldMask"] =
- &ProtoStreamObjectSource::RenderFieldMask;
- ::google::protobuf::internal::OnShutdown(&DeleteRendererMap);
-}
-
-void ProtoStreamObjectSource::DeleteRendererMap() {
- delete ProtoStreamObjectSource::renderers_;
- renderers_ = nullptr;
-}
-
-// static
-ProtoStreamObjectSource::TypeRenderer*
-ProtoStreamObjectSource::FindTypeRenderer(const TProtoStringType& type_url) {
- PROTOBUF_NAMESPACE_ID::internal::call_once(source_renderers_init_,
- InitRendererMap);
- return FindOrNull(*renderers_, type_url);
-}
-
-util::Status ProtoStreamObjectSource::RenderField(
- const google::protobuf::Field* field, StringPiece field_name,
- ObjectWriter* ow) const {
- // Short-circuit message types as it tends to call WriteMessage recursively
- // and ends up using a lot of stack space. Keep the stack usage of this
- // message small in order to preserve stack space and not crash.
- if (field->kind() == google::protobuf::Field::TYPE_MESSAGE) {
- arc_ui32 buffer32;
- stream_->ReadVarint32(&buffer32); // message length
- int old_limit = stream_->PushLimit(buffer32);
- // Get the nested message type for this field.
- const google::protobuf::Type* type =
- typeinfo_->GetTypeByTypeUrl(field->type_url());
- if (type == nullptr) {
- return util::InternalError(
- StrCat("Invalid configuration. Could not find the type: ",
- field->type_url()));
- }
-
- // Short-circuit any special type rendering to save call-stack space.
- const TypeRenderer* type_renderer = FindTypeRenderer(type->name());
-
- RETURN_IF_ERROR(IncrementRecursionDepth(type->name(), field_name));
- if (type_renderer != nullptr) {
- RETURN_IF_ERROR((*type_renderer)(this, *type, field_name, ow));
- } else {
- RETURN_IF_ERROR(WriteMessage(*type, field_name, 0, true, ow));
- }
- --recursion_depth_;
-
- if (!stream_->ConsumedEntireMessage()) {
- return util::InvalidArgumentError(
- "Nested protocol message not parsed in its entirety.");
- }
- stream_->PopLimit(old_limit);
- } else {
- // Render all other non-message types.
- return RenderNonMessageField(field, field_name, ow);
- }
- return util::Status();
-}
-
-util::Status ProtoStreamObjectSource::RenderNonMessageField(
- const google::protobuf::Field* field, StringPiece field_name,
- ObjectWriter* ow) const {
- // Temporary buffers of different types.
- arc_ui32 buffer32 = 0;
- arc_ui64 buffer64 = 0;
- TProtoStringType strbuffer;
- switch (field->kind()) {
- case google::protobuf::Field::TYPE_BOOL: {
- stream_->ReadVarint64(&buffer64);
- ow->RenderBool(field_name, buffer64 != 0);
- break;
- }
- case google::protobuf::Field::TYPE_INT32: {
- stream_->ReadVarint32(&buffer32);
- ow->RenderInt32(field_name, bit_cast<arc_i32>(buffer32));
- break;
- }
- case google::protobuf::Field::TYPE_INT64: {
- stream_->ReadVarint64(&buffer64);
- ow->RenderInt64(field_name, bit_cast<arc_i64>(buffer64));
- break;
- }
- case google::protobuf::Field::TYPE_UINT32: {
- stream_->ReadVarint32(&buffer32);
- ow->RenderUint32(field_name, bit_cast<arc_ui32>(buffer32));
- break;
- }
- case google::protobuf::Field::TYPE_UINT64: {
- stream_->ReadVarint64(&buffer64);
- ow->RenderUint64(field_name, bit_cast<arc_ui64>(buffer64));
- break;
- }
- case google::protobuf::Field::TYPE_SINT32: {
- stream_->ReadVarint32(&buffer32);
- ow->RenderInt32(field_name, WireFormatLite::ZigZagDecode32(buffer32));
- break;
- }
- case google::protobuf::Field::TYPE_SINT64: {
- stream_->ReadVarint64(&buffer64);
- ow->RenderInt64(field_name, WireFormatLite::ZigZagDecode64(buffer64));
- break;
- }
- case google::protobuf::Field::TYPE_SFIXED32: {
- stream_->ReadLittleEndian32(&buffer32);
- ow->RenderInt32(field_name, bit_cast<arc_i32>(buffer32));
- break;
- }
- case google::protobuf::Field::TYPE_SFIXED64: {
- stream_->ReadLittleEndian64(&buffer64);
- ow->RenderInt64(field_name, bit_cast<arc_i64>(buffer64));
- break;
- }
- case google::protobuf::Field::TYPE_FIXED32: {
- stream_->ReadLittleEndian32(&buffer32);
- ow->RenderUint32(field_name, bit_cast<arc_ui32>(buffer32));
- break;
- }
- case google::protobuf::Field::TYPE_FIXED64: {
- stream_->ReadLittleEndian64(&buffer64);
- ow->RenderUint64(field_name, bit_cast<arc_ui64>(buffer64));
- break;
- }
- case google::protobuf::Field::TYPE_FLOAT: {
- stream_->ReadLittleEndian32(&buffer32);
- ow->RenderFloat(field_name, bit_cast<float>(buffer32));
- break;
- }
- case google::protobuf::Field::TYPE_DOUBLE: {
- stream_->ReadLittleEndian64(&buffer64);
- ow->RenderDouble(field_name, bit_cast<double>(buffer64));
- break;
- }
- case google::protobuf::Field::TYPE_ENUM: {
- stream_->ReadVarint32(&buffer32);
-
- // If the field represents an explicit NULL value, render null.
- if (field->type_url() == kStructNullValueTypeUrl) {
- ow->RenderNull(field_name);
- break;
- }
-
- // Get the nested enum type for this field.
- // TODO(skarvaje): Avoid string manipulation. Find ways to speed this
- // up.
- const google::protobuf::Enum* en =
- typeinfo_->GetEnumByTypeUrl(field->type_url());
- // Lookup the name of the enum, and render that. Unknown enum values
- // are printed as integers.
- if (en != nullptr) {
- const google::protobuf::EnumValue* enum_value =
- FindEnumValueByNumber(*en, buffer32);
- if (enum_value != nullptr) {
- if (render_options_.use_ints_for_enums) {
- ow->RenderInt32(field_name, buffer32);
- } else if (render_options_.use_lower_camel_for_enums) {
- ow->RenderString(field_name,
- EnumValueNameToLowerCamelCase(enum_value->name()));
- } else {
- ow->RenderString(field_name, enum_value->name());
- }
- } else {
- ow->RenderInt32(field_name, buffer32);
- }
- } else {
- ow->RenderInt32(field_name, buffer32);
- }
- break;
- }
- case google::protobuf::Field::TYPE_STRING: {
- stream_->ReadVarint32(&buffer32); // string size.
- stream_->ReadString(&strbuffer, buffer32);
- ow->RenderString(field_name, strbuffer);
- break;
- }
- case google::protobuf::Field::TYPE_BYTES: {
- stream_->ReadVarint32(&buffer32); // bytes size.
- stream_->ReadString(&strbuffer, buffer32);
- ow->RenderBytes(field_name, strbuffer);
- break;
- }
- default:
- break;
- }
- return util::Status();
-}
-
-// TODO(skarvaje): Fix this to avoid code duplication.
-const TProtoStringType ProtoStreamObjectSource::ReadFieldValueAsString(
- const google::protobuf::Field& field) const {
- TProtoStringType result;
- switch (field.kind()) {
- case google::protobuf::Field::TYPE_BOOL: {
- arc_ui64 buffer64;
- stream_->ReadVarint64(&buffer64);
- result = buffer64 != 0 ? "true" : "false";
- break;
- }
- case google::protobuf::Field::TYPE_INT32: {
- arc_ui32 buffer32;
- stream_->ReadVarint32(&buffer32);
- result = StrCat(bit_cast<arc_i32>(buffer32));
- break;
- }
- case google::protobuf::Field::TYPE_INT64: {
- arc_ui64 buffer64;
- stream_->ReadVarint64(&buffer64);
- result = StrCat(bit_cast<arc_i64>(buffer64));
- break;
- }
- case google::protobuf::Field::TYPE_UINT32: {
- arc_ui32 buffer32;
- stream_->ReadVarint32(&buffer32);
- result = StrCat(bit_cast<arc_ui32>(buffer32));
- break;
- }
- case google::protobuf::Field::TYPE_UINT64: {
- arc_ui64 buffer64;
- stream_->ReadVarint64(&buffer64);
- result = StrCat(bit_cast<arc_ui64>(buffer64));
- break;
- }
- case google::protobuf::Field::TYPE_SINT32: {
- arc_ui32 buffer32;
- stream_->ReadVarint32(&buffer32);
- result = StrCat(WireFormatLite::ZigZagDecode32(buffer32));
- break;
- }
- case google::protobuf::Field::TYPE_SINT64: {
- arc_ui64 buffer64;
- stream_->ReadVarint64(&buffer64);
- result = StrCat(WireFormatLite::ZigZagDecode64(buffer64));
- break;
- }
- case google::protobuf::Field::TYPE_SFIXED32: {
- arc_ui32 buffer32;
- stream_->ReadLittleEndian32(&buffer32);
- result = StrCat(bit_cast<arc_i32>(buffer32));
- break;
- }
- case google::protobuf::Field::TYPE_SFIXED64: {
- arc_ui64 buffer64;
- stream_->ReadLittleEndian64(&buffer64);
- result = StrCat(bit_cast<arc_i64>(buffer64));
- break;
- }
- case google::protobuf::Field::TYPE_FIXED32: {
- arc_ui32 buffer32;
- stream_->ReadLittleEndian32(&buffer32);
- result = StrCat(bit_cast<arc_ui32>(buffer32));
- break;
- }
- case google::protobuf::Field::TYPE_FIXED64: {
- arc_ui64 buffer64;
- stream_->ReadLittleEndian64(&buffer64);
- result = StrCat(bit_cast<arc_ui64>(buffer64));
- break;
- }
- case google::protobuf::Field::TYPE_FLOAT: {
- arc_ui32 buffer32;
- stream_->ReadLittleEndian32(&buffer32);
- result = SimpleFtoa(bit_cast<float>(buffer32));
- break;
- }
- case google::protobuf::Field::TYPE_DOUBLE: {
- arc_ui64 buffer64;
- stream_->ReadLittleEndian64(&buffer64);
- result = SimpleDtoa(bit_cast<double>(buffer64));
- break;
- }
- case google::protobuf::Field::TYPE_ENUM: {
- arc_ui32 buffer32;
- stream_->ReadVarint32(&buffer32);
- // Get the nested enum type for this field.
- // TODO(skarvaje): Avoid string manipulation. Find ways to speed this
- // up.
- const google::protobuf::Enum* en =
- typeinfo_->GetEnumByTypeUrl(field.type_url());
- // Lookup the name of the enum, and render that. Skips unknown enums.
- if (en != nullptr) {
- const google::protobuf::EnumValue* enum_value =
- FindEnumValueByNumber(*en, buffer32);
- if (enum_value != nullptr) {
- result = enum_value->name();
- }
- }
- break;
- }
- case google::protobuf::Field::TYPE_STRING: {
- arc_ui32 buffer32;
- stream_->ReadVarint32(&buffer32); // string size.
- stream_->ReadString(&result, buffer32);
- break;
- }
- case google::protobuf::Field::TYPE_BYTES: {
- arc_ui32 buffer32;
- stream_->ReadVarint32(&buffer32); // bytes size.
- stream_->ReadString(&result, buffer32);
- break;
- }
- default:
- break;
- }
- return result;
-}
-
-// Field is a map if it is a repeated message and it has an option "map_type".
-// TODO(skarvaje): Consider pre-computing the IsMap() into Field directly.
-bool ProtoStreamObjectSource::IsMap(
- const google::protobuf::Field& field) const {
- const google::protobuf::Type* field_type =
- typeinfo_->GetTypeByTypeUrl(field.type_url());
- return field.kind() == google::protobuf::Field::TYPE_MESSAGE &&
- util::converter::IsMap(field, *field_type);
-}
-
-std::pair<arc_i64, arc_i32> ProtoStreamObjectSource::ReadSecondsAndNanos(
- const google::protobuf::Type& type) const {
- arc_ui64 seconds = 0;
- arc_ui32 nanos = 0;
- arc_ui32 tag = 0;
- arc_i64 signed_seconds = 0;
- arc_i32 signed_nanos = 0;
-
- for (tag = stream_->ReadTag(); tag != 0; tag = stream_->ReadTag()) {
- const google::protobuf::Field* field = FindAndVerifyField(type, tag);
- if (field == nullptr) {
- WireFormat::SkipField(stream_, tag, nullptr);
- continue;
- }
- // 'seconds' has field number of 1 and 'nanos' has field number 2
- // //google/protobuf/timestamp.proto & duration.proto
- if (field->number() == 1) {
- // read seconds
- stream_->ReadVarint64(&seconds);
- signed_seconds = bit_cast<arc_i64>(seconds);
- } else if (field->number() == 2) {
- // read nanos
- stream_->ReadVarint32(&nanos);
- signed_nanos = bit_cast<arc_i32>(nanos);
- }
- }
- return std::pair<arc_i64, arc_i32>(signed_seconds, signed_nanos);
-}
-
-util::Status ProtoStreamObjectSource::IncrementRecursionDepth(
- StringPiece type_name, StringPiece field_name) const {
- if (++recursion_depth_ > max_recursion_depth_) {
- return util::InvalidArgumentError(
- StrCat("Message too deep. Max recursion depth reached for type '",
- type_name, "', field '", field_name, "'"));
- }
- return util::Status();
-}
-
-namespace {
-// TODO(skarvaje): Speed this up by not doing a linear scan.
-const google::protobuf::Field* FindFieldByNumber(
- const google::protobuf::Type& type, int number) {
- for (int i = 0; i < type.fields_size(); ++i) {
- if (type.fields(i).number() == number) {
- return &type.fields(i);
- }
- }
- return nullptr;
-}
-
-// TODO(skarvaje): Replace FieldDescriptor by implementing IsTypePackable()
-// using tech Field.
-bool IsPackable(const google::protobuf::Field& field) {
- return field.cardinality() == google::protobuf::Field::CARDINALITY_REPEATED &&
- FieldDescriptor::IsTypePackable(
- static_cast<FieldDescriptor::Type>(field.kind()));
-}
-
-// TODO(skarvaje): Speed this up by not doing a linear scan.
-const google::protobuf::EnumValue* FindEnumValueByNumber(
- const google::protobuf::Enum& tech_enum, int number) {
- for (int i = 0; i < tech_enum.enumvalue_size(); ++i) {
- const google::protobuf::EnumValue& ev = tech_enum.enumvalue(i);
- if (ev.number() == number) {
- return &ev;
- }
- }
- return nullptr;
-}
-
-// TODO(skarvaje): Look into optimizing this by not doing computation on
-// double.
-const TProtoStringType FormatNanos(arc_ui32 nanos, bool with_trailing_zeros) {
- if (nanos == 0) {
- return with_trailing_zeros ? ".000" : "";
- }
-
- 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);
-}
-} // namespace
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
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
deleted file mode 100644
index 6be281e291f..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectsource.h
+++ /dev/null
@@ -1,329 +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_UTIL_INTERNAL_PROTOSTREAM_OBJECTSOURCE_H__
-#define GOOGLE_PROTOBUF_UTIL_INTERNAL_PROTOSTREAM_OBJECTSOURCE_H__
-
-#include <cstdint>
-#include <functional>
-#include <string>
-#include <unordered_map>
-
-#include <google/protobuf/stubs/status.h>
-
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/type.pb.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/hash.h>
-#include <google/protobuf/stubs/status.h>
-
-
-// Must be included last.
-#include <google/protobuf/port_def.inc>
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-class TypeInfo;
-
-// An ObjectSource that can parse a stream of bytes as a protocol buffer.
-// Its WriteTo() method can be given an ObjectWriter.
-// This implementation uses a google.protobuf.Type for tag and name lookup.
-// The field names are converted into lower camel-case when writing to the
-// ObjectWriter.
-//
-// Sample usage: (suppose input is: string proto)
-// ArrayInputStream arr_stream(proto.data(), proto.size());
-// CodedInputStream in_stream(&arr_stream);
-// ProtoStreamObjectSource os(&in_stream, /*ServiceTypeInfo*/ typeinfo,
-// <your message google::protobuf::Type>);
-//
-// Status status = os.WriteTo(<some ObjectWriter>);
-class PROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource {
- public:
-
- struct RenderOptions {
- RenderOptions() = default;
- RenderOptions(const RenderOptions&) = default;
-
- // Sets whether or not to use lowerCamelCase casing for enum values. If set
- // to false, enum values are output without any case conversions.
- //
- // For example, if we have an enum:
- // enum Type {
- // ACTION_AND_ADVENTURE = 1;
- // }
- // Type type = 20;
- //
- // And this option is set to true. Then the rendered "type" field will have
- // the string "actionAndAdventure".
- // {
- // ...
- // "type": "actionAndAdventure",
- // ...
- // }
- //
- // If set to false, the rendered "type" field will have the string
- // "ACTION_AND_ADVENTURE".
- // {
- // ...
- // "type": "ACTION_AND_ADVENTURE",
- // ...
- // }
- bool use_lower_camel_for_enums = false;
-
- // Sets whether to always output enums as ints, by default this is off, and
- // enums are rendered as strings.
- bool use_ints_for_enums = false;
-
- // Whether to preserve proto field names
- bool preserve_proto_field_names = false;
-
- };
-
- ProtoStreamObjectSource(io::CodedInputStream* stream,
- TypeResolver* type_resolver,
- const google::protobuf::Type& type)
- : ProtoStreamObjectSource(stream, type_resolver, type, RenderOptions()) {}
- ProtoStreamObjectSource(io::CodedInputStream* stream,
- TypeResolver* type_resolver,
- const google::protobuf::Type& type,
- const RenderOptions& render_options);
-
- ~ProtoStreamObjectSource() override;
-
- util::Status NamedWriteTo(StringPiece name,
- ObjectWriter* ow) const override;
-
- // Sets the max recursion depth of proto message to be deserialized. Proto
- // messages over this depth will fail to be deserialized.
- // Default value is 64.
- void set_max_recursion_depth(int max_depth) {
- max_recursion_depth_ = max_depth;
- }
-
- protected:
- // Writes a proto2 Message to the ObjectWriter. When the given end_tag is
- // found this method will complete, allowing it to be used for parsing both
- // nested messages (end with 0) and nested groups (end with group end tag).
- // The include_start_and_end parameter allows this method to be called when
- // already inside of an object, and skip calling StartObject and EndObject.
- virtual util::Status WriteMessage(const google::protobuf::Type& type,
- StringPiece name,
- const arc_ui32 end_tag,
- bool include_start_and_end,
- ObjectWriter* ow) const;
-
- // Renders a repeating field (packed or unpacked). Returns the next tag after
- // reading all sequential repeating elements. The caller should use this tag
- // before reading more tags from the stream.
- virtual util::StatusOr<arc_ui32> RenderList(
- const google::protobuf::Field* field, StringPiece name,
- arc_ui32 list_tag, ObjectWriter* ow) const;
-
- // Looks up a field and verify its consistency with wire type in tag.
- const google::protobuf::Field* FindAndVerifyField(
- const google::protobuf::Type& type, arc_ui32 tag) const;
-
- // Renders a field value to the ObjectWriter.
- virtual util::Status RenderField(const google::protobuf::Field* field,
- StringPiece field_name,
- ObjectWriter* ow) const;
-
- // Reads field value according to Field spec in 'field' and returns the read
- // value as string. This only works for primitive datatypes (no message
- // types).
- const TProtoStringType ReadFieldValueAsString(
- const google::protobuf::Field& field) const;
-
-
- // Returns the input stream.
- io::CodedInputStream* stream() const { return stream_; }
-
- private:
- ProtoStreamObjectSource(io::CodedInputStream* stream,
- const TypeInfo* typeinfo,
- const google::protobuf::Type& type,
- const RenderOptions& render_options);
- // Function that renders a well known type with a modified behavior.
- typedef util::Status (*TypeRenderer)(const ProtoStreamObjectSource*,
- const google::protobuf::Type&,
- StringPiece, ObjectWriter*);
-
- // TODO(skarvaje): Mark these methods as non-const as they modify internal
- // state (stream_).
- //
- // Renders a NWP map.
- // Returns the next tag after reading all map entries. The caller should use
- // this tag before reading more tags from the stream.
- util::StatusOr<arc_ui32> RenderMap(const google::protobuf::Field* field,
- StringPiece name, arc_ui32 list_tag,
- ObjectWriter* ow) const;
-
- // Renders a packed repeating field. A packed field is stored as:
- // {tag length item1 item2 item3} instead of the less efficient
- // {tag item1 tag item2 tag item3}.
- util::Status RenderPacked(const google::protobuf::Field* field,
- ObjectWriter* ow) const;
-
- // Renders a google.protobuf.Timestamp value to ObjectWriter
- static util::Status RenderTimestamp(const ProtoStreamObjectSource* os,
- const google::protobuf::Type& type,
- StringPiece name, ObjectWriter* ow);
-
- // Renders a google.protobuf.Duration value to ObjectWriter
- static util::Status RenderDuration(const ProtoStreamObjectSource* os,
- const google::protobuf::Type& type,
- StringPiece name, ObjectWriter* ow);
-
- // Following RenderTYPE functions render well known types in
- // google/protobuf/wrappers.proto corresponding to TYPE.
- static util::Status RenderDouble(const ProtoStreamObjectSource* os,
- const google::protobuf::Type& type,
- StringPiece name, ObjectWriter* ow);
- static util::Status RenderFloat(const ProtoStreamObjectSource* os,
- const google::protobuf::Type& type,
- StringPiece name, ObjectWriter* ow);
- static util::Status RenderInt64(const ProtoStreamObjectSource* os,
- const google::protobuf::Type& type,
- StringPiece name, ObjectWriter* ow);
- static util::Status RenderUInt64(const ProtoStreamObjectSource* os,
- const google::protobuf::Type& type,
- StringPiece name, ObjectWriter* ow);
- static util::Status RenderInt32(const ProtoStreamObjectSource* os,
- const google::protobuf::Type& type,
- StringPiece name, ObjectWriter* ow);
- static util::Status RenderUInt32(const ProtoStreamObjectSource* os,
- const google::protobuf::Type& type,
- StringPiece name, ObjectWriter* ow);
- static util::Status RenderBool(const ProtoStreamObjectSource* os,
- const google::protobuf::Type& type,
- StringPiece name, ObjectWriter* ow);
- static util::Status RenderString(const ProtoStreamObjectSource* os,
- const google::protobuf::Type& type,
- StringPiece name, ObjectWriter* ow);
- static util::Status RenderBytes(const ProtoStreamObjectSource* os,
- const google::protobuf::Type& type,
- StringPiece name, ObjectWriter* ow);
-
- // Renders a google.protobuf.Struct to ObjectWriter.
- static util::Status RenderStruct(const ProtoStreamObjectSource* os,
- const google::protobuf::Type& type,
- StringPiece name, ObjectWriter* ow);
-
- // Helper to render google.protobuf.Struct's Value fields to ObjectWriter.
- static util::Status RenderStructValue(const ProtoStreamObjectSource* os,
- const google::protobuf::Type& type,
- StringPiece name,
- ObjectWriter* ow);
-
- // Helper to render google.protobuf.Struct's ListValue fields to ObjectWriter.
- static util::Status RenderStructListValue(const ProtoStreamObjectSource* os,
- const google::protobuf::Type& type,
- StringPiece name,
- ObjectWriter* ow);
-
- // Render the "Any" type.
- static util::Status RenderAny(const ProtoStreamObjectSource* os,
- const google::protobuf::Type& type,
- StringPiece name, ObjectWriter* ow);
-
- // Render the "FieldMask" type.
- static util::Status RenderFieldMask(const ProtoStreamObjectSource* os,
- const google::protobuf::Type& type,
- StringPiece name, ObjectWriter* ow);
-
- static std::unordered_map<TProtoStringType, TypeRenderer>* renderers_;
- static void InitRendererMap();
- static void DeleteRendererMap();
- static TypeRenderer* FindTypeRenderer(const TProtoStringType& type_url);
-
- // Same as above but renders all non-message field types. Callers don't call
- // this function directly. They just use RenderField.
- util::Status RenderNonMessageField(const google::protobuf::Field* field,
- StringPiece field_name,
- ObjectWriter* ow) const;
-
-
- // Utility function to detect proto maps. The 'field' MUST be repeated.
- bool IsMap(const google::protobuf::Field& field) const;
-
- // Utility to read int64 and int32 values from a message type in stream_.
- // Used for reading google.protobuf.Timestamp and Duration messages.
- std::pair<arc_i64, arc_i32> ReadSecondsAndNanos(
- const google::protobuf::Type& type) const;
-
- // Helper function to check recursion depth and increment it. It will return
- // OkStatus() if the current depth is allowed. Otherwise an error is returned.
- // type_name and field_name are used for error reporting.
- util::Status IncrementRecursionDepth(StringPiece type_name,
- StringPiece field_name) const;
-
- // Input stream to read from. Ownership rests with the caller.
- mutable io::CodedInputStream* stream_;
-
- // Type information for all the types used in the descriptor. Used to find
- // google::protobuf::Type of nested messages/enums.
- const TypeInfo* typeinfo_;
-
- // Whether this class owns the typeinfo_ object. If true the typeinfo_ object
- // should be deleted in the destructor.
- bool own_typeinfo_;
-
- // google::protobuf::Type of the message source.
- const google::protobuf::Type& type_;
-
-
- const RenderOptions render_options_;
-
- // Tracks current recursion depth.
- mutable int recursion_depth_;
-
- // Maximum allowed recursion depth.
- int max_recursion_depth_;
-
- GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(ProtoStreamObjectSource);
-};
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#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
deleted file mode 100644
index af86e78943c..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.cc
+++ /dev/null
@@ -1,1401 +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/util/internal/protostream_objectwriter.h>
-
-#include <cstdint>
-#include <functional>
-#include <stack>
-#include <unordered_map>
-#include <unordered_set>
-
-#include <google/protobuf/stubs/once.h>
-#include <google/protobuf/wire_format_lite.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 {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-using util::Status;
-using ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite;
-using std::placeholders::_1;
-
-
-ProtoStreamObjectWriter::ProtoStreamObjectWriter(
- TypeResolver* type_resolver, const google::protobuf::Type& type,
- strings::ByteSink* output, ErrorListener* listener,
- const ProtoStreamObjectWriter::Options& options)
- : ProtoWriter(type_resolver, type, output, listener),
- master_type_(type),
- current_(nullptr),
- options_(options) {
- set_ignore_unknown_fields(options_.ignore_unknown_fields);
- set_ignore_unknown_enum_values(options_.ignore_unknown_enum_values);
- set_use_lower_camel_for_enums(options_.use_lower_camel_for_enums);
- set_case_insensitive_enum_parsing(options_.case_insensitive_enum_parsing);
- set_use_json_name_in_missing_fields(options.use_json_name_in_missing_fields);
-}
-
-ProtoStreamObjectWriter::ProtoStreamObjectWriter(
- const TypeInfo* typeinfo, const google::protobuf::Type& type,
- strings::ByteSink* output, ErrorListener* listener,
- const ProtoStreamObjectWriter::Options& options)
- : ProtoWriter(typeinfo, type, output, listener),
- master_type_(type),
- current_(nullptr),
- options_(options) {
- set_ignore_unknown_fields(options_.ignore_unknown_fields);
- set_use_lower_camel_for_enums(options.use_lower_camel_for_enums);
- set_case_insensitive_enum_parsing(options_.case_insensitive_enum_parsing);
- set_use_json_name_in_missing_fields(options.use_json_name_in_missing_fields);
-}
-
-ProtoStreamObjectWriter::ProtoStreamObjectWriter(
- const TypeInfo* typeinfo, const google::protobuf::Type& type,
- strings::ByteSink* output, ErrorListener* listener)
- : ProtoWriter(typeinfo, type, output, listener),
- master_type_(type),
- current_(nullptr),
- options_(ProtoStreamObjectWriter::Options::Defaults()) {}
-
-ProtoStreamObjectWriter::~ProtoStreamObjectWriter() {
- if (current_ == nullptr) return;
- // Cleanup explicitly in order to avoid destructor stack overflow when input
- // is deeply nested.
- // Cast to BaseElement to avoid doing additional checks (like missing fields)
- // during pop().
- std::unique_ptr<BaseElement> element(
- static_cast<BaseElement*>(current_.get())->pop<BaseElement>());
- while (element != nullptr) {
- element.reset(element->pop<BaseElement>());
- }
-}
-
-namespace {
-// Utility method to split a string representation of Timestamp or Duration and
-// return the parts.
-void SplitSecondsAndNanos(StringPiece input, StringPiece* seconds,
- StringPiece* nanos) {
- size_t idx = input.rfind('.');
- if (idx != TProtoStringType::npos) {
- *seconds = input.substr(0, idx);
- *nanos = input.substr(idx + 1);
- } else {
- *seconds = input;
- *nanos = StringPiece();
- }
-}
-
-Status GetNanosFromStringPiece(StringPiece s_nanos,
- const char* parse_failure_message,
- const char* exceeded_limit_message,
- arc_i32* nanos) {
- *nanos = 0;
-
- // Count the number of leading 0s and consume them.
- int num_leading_zeros = 0;
- while (s_nanos.Consume("0")) {
- num_leading_zeros++;
- }
- arc_i32 i_nanos = 0;
- // 's_nanos' contains fractional seconds -- i.e. 'nanos' is equal to
- // "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)) {
- return util::InvalidArgumentError(parse_failure_message);
- }
- if (i_nanos > kNanosPerSecond || i_nanos < 0) {
- return util::InvalidArgumentError(exceeded_limit_message);
- }
- // s_nanos should only have digits. No whitespace.
- if (s_nanos.find_first_not_of("0123456789") != StringPiece::npos) {
- return util::InvalidArgumentError(parse_failure_message);
- }
-
- if (i_nanos > 0) {
- // 'scale' is the number of digits to the right of the decimal
- // 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<arc_i32>(std::pow(10, scale))
- // For efficiency, we precompute the conversion factor.
- arc_i32 conversion = 0;
- switch (scale) {
- case 1:
- conversion = 100000000;
- break;
- case 2:
- conversion = 10000000;
- break;
- case 3:
- conversion = 1000000;
- break;
- case 4:
- conversion = 100000;
- break;
- case 5:
- conversion = 10000;
- break;
- case 6:
- conversion = 1000;
- break;
- case 7:
- conversion = 100;
- break;
- case 8:
- conversion = 10;
- break;
- case 9:
- conversion = 1;
- break;
- default:
- return util::InvalidArgumentError(exceeded_limit_message);
- }
- *nanos = i_nanos * conversion;
- }
-
- return Status();
-}
-
-} // namespace
-
-ProtoStreamObjectWriter::AnyWriter::AnyWriter(ProtoStreamObjectWriter* parent)
- : parent_(parent),
- ow_(),
- invalid_(false),
- data_(),
- output_(&data_),
- depth_(0),
- is_well_known_type_(false),
- well_known_type_render_(nullptr) {}
-
-ProtoStreamObjectWriter::AnyWriter::~AnyWriter() {}
-
-void ProtoStreamObjectWriter::AnyWriter::StartObject(StringPiece name) {
- ++depth_;
- // If an object writer is absent, that means we have not called StartAny()
- // before reaching here, which happens when we have data before the "@type"
- // field.
- if (ow_ == nullptr) {
- // Save data before the "@type" field for later replay.
- uninterpreted_events_.push_back(Event(Event::START_OBJECT, name));
- } else if (is_well_known_type_ && depth_ == 1) {
- // For well-known types, the only other field besides "@type" should be a
- // "value" field.
- if (name != "value" && !invalid_) {
- parent_->InvalidValue("Any",
- "Expect a \"value\" field for well-known types.");
- invalid_ = true;
- }
- ow_->StartObject("");
- } else {
- // Forward the call to the child writer if:
- // 1. the type is not a well-known type.
- // 2. or, we are in a nested Any, Struct, or Value object.
- ow_->StartObject(name);
- }
-}
-
-bool ProtoStreamObjectWriter::AnyWriter::EndObject() {
- --depth_;
- if (ow_ == nullptr) {
- if (depth_ >= 0) {
- // Save data before the "@type" field for later replay.
- uninterpreted_events_.push_back(Event(Event::END_OBJECT));
- }
- } else if (depth_ >= 0 || !is_well_known_type_) {
- // As long as depth_ >= 0, we know we haven't reached the end of Any.
- // Propagate these EndObject() calls to the contained ow_. For regular
- // message types, we propagate the end of Any as well.
- ow_->EndObject();
- }
- // A negative depth_ implies that we have reached the end of Any
- // object. Now we write out its contents.
- if (depth_ < 0) {
- WriteAny();
- return false;
- }
- return true;
-}
-
-void ProtoStreamObjectWriter::AnyWriter::StartList(StringPiece name) {
- ++depth_;
- if (ow_ == nullptr) {
- // Save data before the "@type" field for later replay.
- uninterpreted_events_.push_back(Event(Event::START_LIST, name));
- } else if (is_well_known_type_ && depth_ == 1) {
- if (name != "value" && !invalid_) {
- parent_->InvalidValue("Any",
- "Expect a \"value\" field for well-known types.");
- invalid_ = true;
- }
- ow_->StartList("");
- } else {
- ow_->StartList(name);
- }
-}
-
-void ProtoStreamObjectWriter::AnyWriter::EndList() {
- --depth_;
- if (depth_ < 0) {
- GOOGLE_LOG(DFATAL) << "Mismatched EndList found, should not be possible";
- depth_ = 0;
- }
- if (ow_ == nullptr) {
- // Save data before the "@type" field for later replay.
- uninterpreted_events_.push_back(Event(Event::END_LIST));
- } else {
- ow_->EndList();
- }
-}
-
-void ProtoStreamObjectWriter::AnyWriter::RenderDataPiece(
- StringPiece name, const DataPiece& value) {
- // Start an Any only at depth_ 0. Other RenderDataPiece calls with "@type"
- // should go to the contained ow_ as they indicate nested Anys.
- if (depth_ == 0 && ow_ == nullptr && name == "@type") {
- StartAny(value);
- } else if (ow_ == nullptr) {
- // Save data before the "@type" field.
- uninterpreted_events_.push_back(Event(name, value));
- } else if (depth_ == 0 && is_well_known_type_) {
- if (name != "value" && !invalid_) {
- parent_->InvalidValue("Any",
- "Expect a \"value\" field for well-known types.");
- invalid_ = true;
- }
- if (well_known_type_render_ == nullptr) {
- // Only Any and Struct don't have a special type render but both of
- // them expect a JSON object (i.e., a StartObject() call).
- if (value.type() != DataPiece::TYPE_NULL && !invalid_) {
- parent_->InvalidValue("Any", "Expect a JSON object.");
- invalid_ = true;
- }
- } else {
- ow_->ProtoWriter::StartObject("");
- Status status = (*well_known_type_render_)(ow_.get(), value);
- if (!status.ok()) ow_->InvalidValue("Any", status.message());
- ow_->ProtoWriter::EndObject();
- }
- } else {
- ow_->RenderDataPiece(name, value);
- }
-}
-
-void ProtoStreamObjectWriter::AnyWriter::StartAny(const DataPiece& value) {
- // Figure out the type url. This is a copy-paste from WriteString but we also
- // need the value, so we can't just call through to that.
- if (value.type() == DataPiece::TYPE_STRING) {
- type_url_ = TProtoStringType(value.str());
- } else {
- util::StatusOr<TProtoStringType> s = value.ToString();
- if (!s.ok()) {
- parent_->InvalidValue("String", s.status().message());
- invalid_ = true;
- return;
- }
- type_url_ = s.value();
- }
- // Resolve the type url, and report an error if we failed to resolve it.
- util::StatusOr<const google::protobuf::Type*> resolved_type =
- parent_->typeinfo()->ResolveTypeUrl(type_url_);
- if (!resolved_type.ok()) {
- parent_->InvalidValue("Any", resolved_type.status().message());
- invalid_ = true;
- return;
- }
- // At this point, type is never null.
- const google::protobuf::Type* type = resolved_type.value();
-
- well_known_type_render_ = FindTypeRenderer(type_url_);
- if (well_known_type_render_ != nullptr ||
- // Explicitly list Any and Struct here because they don't have a
- // custom renderer.
- type->name() == kAnyType || type->name() == kStructType) {
- is_well_known_type_ = true;
- }
-
- // Create our object writer and initialize it with the first StartObject
- // call.
- ow_.reset(new ProtoStreamObjectWriter(parent_->typeinfo(), *type, &output_,
- parent_->listener(),
- parent_->options_));
-
- // Don't call StartObject() for well-known types yet. Depending on the
- // type of actual data, we may not need to call StartObject(). For
- // example:
- // {
- // "@type": "type.googleapis.com/google.protobuf.Value",
- // "value": [1, 2, 3],
- // }
- // With the above JSON representation, we will only call StartList() on the
- // contained ow_.
- if (!is_well_known_type_) {
- ow_->StartObject("");
- }
-
- // Now we know the proto type and can interpret all data fields we gathered
- // before the "@type" field.
- for (int i = 0; i < uninterpreted_events_.size(); ++i) {
- uninterpreted_events_[i].Replay(this);
- }
-}
-
-void ProtoStreamObjectWriter::AnyWriter::WriteAny() {
- if (ow_ == nullptr) {
- if (uninterpreted_events_.empty()) {
- // We never got any content, so just return immediately, which is
- // equivalent to writing an empty Any.
- return;
- } else {
- // There are uninterpreted data, but we never got a "@type" field.
- if (!invalid_) {
- parent_->InvalidValue("Any",
- StrCat("Missing @type for any field in ",
- parent_->master_type_.name()));
- invalid_ = true;
- }
- return;
- }
- }
- // Render the type_url and value fields directly to the stream.
- // type_url has tag 1 and value has tag 2.
- WireFormatLite::WriteString(1, type_url_, parent_->stream());
- if (!data_.empty()) {
- WireFormatLite::WriteBytes(2, data_, parent_->stream());
- }
-}
-
-void ProtoStreamObjectWriter::AnyWriter::Event::Replay(
- AnyWriter* writer) const {
- switch (type_) {
- case START_OBJECT:
- writer->StartObject(name_);
- break;
- case END_OBJECT:
- writer->EndObject();
- break;
- case START_LIST:
- writer->StartList(name_);
- break;
- case END_LIST:
- writer->EndList();
- break;
- case RENDER_DATA_PIECE:
- writer->RenderDataPiece(name_, value_);
- break;
- }
-}
-
-void ProtoStreamObjectWriter::AnyWriter::Event::DeepCopy() {
- // DataPiece only contains a string reference. To make sure the referenced
- // string value stays valid, we make a copy of the string value and update
- // DataPiece to reference our own copy.
- if (value_.type() == DataPiece::TYPE_STRING) {
- StrAppend(&value_storage_, value_.str());
- value_ = DataPiece(value_storage_, value_.use_strict_base64_decoding());
- } else if (value_.type() == DataPiece::TYPE_BYTES) {
- value_storage_ = value_.ToBytes().value();
- value_ =
- DataPiece(value_storage_, true, value_.use_strict_base64_decoding());
- }
-}
-
-ProtoStreamObjectWriter::Item::Item(ProtoStreamObjectWriter* enclosing,
- ItemType item_type, bool is_placeholder,
- bool is_list)
- : BaseElement(nullptr),
- ow_(enclosing),
- any_(),
- item_type_(item_type),
- is_placeholder_(is_placeholder),
- is_list_(is_list) {
- if (item_type_ == ANY) {
- any_.reset(new AnyWriter(ow_));
- }
- if (item_type == MAP) {
- map_keys_.reset(new std::unordered_set<TProtoStringType>);
- }
-}
-
-ProtoStreamObjectWriter::Item::Item(ProtoStreamObjectWriter::Item* parent,
- ItemType item_type, bool is_placeholder,
- bool is_list)
- : BaseElement(parent),
- ow_(this->parent()->ow_),
- any_(),
- item_type_(item_type),
- is_placeholder_(is_placeholder),
- is_list_(is_list) {
- if (item_type == ANY) {
- any_.reset(new AnyWriter(ow_));
- }
- if (item_type == MAP) {
- map_keys_.reset(new std::unordered_set<TProtoStringType>);
- }
-}
-
-bool ProtoStreamObjectWriter::Item::InsertMapKeyIfNotPresent(
- StringPiece map_key) {
- return InsertIfNotPresent(map_keys_.get(), TProtoStringType(map_key));
-}
-
-
-ProtoStreamObjectWriter* ProtoStreamObjectWriter::StartObject(
- StringPiece name) {
- if (invalid_depth() > 0) {
- IncrementInvalidDepth();
- return this;
- }
-
- // Starting the root message. Create the root Item and return.
- // ANY message type does not need special handling, just set the ItemType
- // to ANY.
- if (current_ == nullptr) {
- ProtoWriter::StartObject(name);
- current_.reset(new Item(
- this, master_type_.name() == kAnyType ? Item::ANY : Item::MESSAGE,
- false, false));
-
- // If master type is a special type that needs extra values to be written to
- // stream, we write those values.
- if (master_type_.name() == kStructType) {
- // Struct has a map<string, Value> field called "fields".
- // https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/struct.proto
- // "fields": [
- Push("fields", Item::MAP, true, true);
- return this;
- }
-
- if (master_type_.name() == kStructValueType) {
- // We got a StartObject call with google.protobuf.Value field. The only
- // object within that type is a struct type. So start a struct.
- //
- // The struct field in Value type is named "struct_value"
- // https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/struct.proto
- // Also start the map field "fields" within the struct.
- // "struct_value": {
- // "fields": [
- Push("struct_value", Item::MESSAGE, true, false);
- Push("fields", Item::MAP, true, true);
- return this;
- }
-
- if (master_type_.name() == kStructListValueType) {
- InvalidValue(kStructListValueType,
- "Cannot start root message with ListValue.");
- }
-
- return this;
- }
-
- // Send all ANY events to AnyWriter.
- if (current_->IsAny()) {
- current_->any()->StartObject(name);
- return this;
- }
-
- // If we are within a map, we render name as keys and send StartObject to the
- // value field.
- if (current_->IsMap()) {
- if (!ValidMapKey(name)) {
- IncrementInvalidDepth();
- return this;
- }
-
- // Map is a repeated field of message type with a "key" and a "value" field.
- // https://developers.google.com/protocol-buffers/docs/proto3?hl=en#maps
- // message MapFieldEntry {
- // key_type key = 1;
- // value_type value = 2;
- // }
- //
- // repeated MapFieldEntry map_field = N;
- //
- // That means, we render the following element within a list (hence no
- // name):
- // { "key": "<name>", "value": {
- Push("", Item::MESSAGE, false, false);
- ProtoWriter::RenderDataPiece("key",
- DataPiece(name, use_strict_base64_decoding()));
- Push("value", IsAny(*Lookup("value")) ? Item::ANY : Item::MESSAGE, true,
- false);
-
- // Make sure we are valid so far after starting map fields.
- if (invalid_depth() > 0) return this;
-
- // If top of stack is g.p.Struct type, start the struct the map field within
- // it.
- if (element() != nullptr && IsStruct(*element()->parent_field())) {
- // Render "fields": [
- Push("fields", Item::MAP, true, true);
- return this;
- }
-
- // If top of stack is g.p.Value type, start the Struct within it.
- if (element() != nullptr && IsStructValue(*element()->parent_field())) {
- // Render
- // "struct_value": {
- // "fields": [
- Push("struct_value", Item::MESSAGE, true, false);
- Push("fields", Item::MAP, true, true);
- }
- return this;
- }
-
- const google::protobuf::Field* field = BeginNamed(name, false);
-
- if (field == nullptr) return this;
-
- // Legacy JSON map is a list of key value pairs. Starts a map entry object.
- if (options_.use_legacy_json_map_format && name.empty()) {
- Push(name, IsAny(*field) ? Item::ANY : Item::MESSAGE, false, false);
- return this;
- }
-
- if (IsMap(*field)) {
- // Begin a map. A map is triggered by a StartObject() call if the current
- // field has a map type.
- // A map type is always repeated, hence set is_list to true.
- // Render
- // "<name>": [
- Push(name, Item::MAP, false, true);
- return this;
- }
-
- if (options_.disable_implicit_message_list) {
- // If the incoming object is repeated, the top-level object on stack should
- // be list. Report an error otherwise.
- if (IsRepeated(*field) && !current_->is_list()) {
- IncrementInvalidDepth();
-
- if (!options_.suppress_implicit_message_list_error) {
- InvalidValue(
- field->name(),
- "Starting an object in a repeated field but the parent object "
- "is not a list");
- }
- return this;
- }
- }
-
- if (IsStruct(*field)) {
- // Start a struct object.
- // Render
- // "<name>": {
- // "fields": {
- Push(name, Item::MESSAGE, false, false);
- Push("fields", Item::MAP, true, true);
- return this;
- }
-
- if (IsStructValue(*field)) {
- // We got a StartObject call with google.protobuf.Value field. The only
- // object within that type is a struct type. So start a struct.
- // Render
- // "<name>": {
- // "struct_value": {
- // "fields": {
- Push(name, Item::MESSAGE, false, false);
- Push("struct_value", Item::MESSAGE, true, false);
- Push("fields", Item::MAP, true, true);
- return this;
- }
-
- if (field->kind() != google::protobuf::Field::TYPE_GROUP &&
- field->kind() != google::protobuf::Field::TYPE_MESSAGE) {
- IncrementInvalidDepth();
- if (!options_.suppress_object_to_scalar_error) {
- InvalidValue(field->name(), "Starting an object on a scalar field");
- }
-
- return this;
- }
-
- // A regular message type. Pass it directly to ProtoWriter.
- // Render
- // "<name>": {
- Push(name, IsAny(*field) ? Item::ANY : Item::MESSAGE, false, false);
- return this;
-}
-
-ProtoStreamObjectWriter* ProtoStreamObjectWriter::EndObject() {
- if (invalid_depth() > 0) {
- DecrementInvalidDepth();
- return this;
- }
-
- if (current_ == nullptr) return this;
-
- if (current_->IsAny()) {
- if (current_->any()->EndObject()) return this;
- }
-
- Pop();
-
- return this;
-}
-
-
-ProtoStreamObjectWriter* ProtoStreamObjectWriter::StartList(
- StringPiece name) {
- if (invalid_depth() > 0) {
- IncrementInvalidDepth();
- return this;
- }
-
- // Since we cannot have a top-level repeated item in protobuf, the only way
- // this is valid is if we start a special type google.protobuf.ListValue or
- // google.protobuf.Value.
- if (current_ == nullptr) {
- if (!name.empty()) {
- InvalidName(name, "Root element should not be named.");
- IncrementInvalidDepth();
- return this;
- }
-
- // If master type is a special type that needs extra values to be written to
- // stream, we write those values.
- if (master_type_.name() == kStructValueType) {
- // We got a StartList with google.protobuf.Value master type. This means
- // we have to start the "list_value" within google.protobuf.Value.
- //
- // See
- // https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/struct.proto
- //
- // Render
- // "<name>": {
- // "list_value": {
- // "values": [ // Start this list.
- ProtoWriter::StartObject(name);
- current_.reset(new Item(this, Item::MESSAGE, false, false));
- Push("list_value", Item::MESSAGE, true, false);
- Push("values", Item::MESSAGE, true, true);
- return this;
- }
-
- if (master_type_.name() == kStructListValueType) {
- // We got a StartList with google.protobuf.ListValue master type. This
- // means we have to start the "values" within google.protobuf.ListValue.
- //
- // Render
- // "<name>": {
- // "values": [ // Start this list.
- ProtoWriter::StartObject(name);
- current_.reset(new Item(this, Item::MESSAGE, false, false));
- Push("values", Item::MESSAGE, true, true);
- return this;
- }
-
- // Send the event to ProtoWriter so proper errors can be reported.
- //
- // Render a regular list:
- // "<name>": [
- ProtoWriter::StartList(name);
- current_.reset(new Item(this, Item::MESSAGE, false, true));
- return this;
- }
-
- if (current_->IsAny()) {
- current_->any()->StartList(name);
- return this;
- }
-
- // If the top of stack is a map, we are starting a list value within a map.
- // Since map does not allow repeated values, this can only happen when the map
- // value is of a special type that renders a list in JSON. These can be one
- // of 3 cases:
- // i. We are rendering a list value within google.protobuf.Struct
- // ii. We are rendering a list value within google.protobuf.Value
- // iii. We are rendering a list value with type google.protobuf.ListValue.
- if (current_->IsMap()) {
- if (!ValidMapKey(name)) {
- IncrementInvalidDepth();
- return this;
- }
-
- // Start the repeated map entry object.
- // Render
- // { "key": "<name>", "value": {
- Push("", Item::MESSAGE, false, false);
- ProtoWriter::RenderDataPiece("key",
- DataPiece(name, use_strict_base64_decoding()));
- Push("value", Item::MESSAGE, true, false);
-
- // Make sure we are valid after pushing all above items.
- if (invalid_depth() > 0) return this;
-
- // case i and ii above. Start "list_value" field within g.p.Value
- if (element() != nullptr && element()->parent_field() != nullptr) {
- // Render
- // "list_value": {
- // "values": [ // Start this list
- if (IsStructValue(*element()->parent_field())) {
- Push("list_value", Item::MESSAGE, true, false);
- Push("values", Item::MESSAGE, true, true);
- return this;
- }
-
- // Render
- // "values": [
- if (IsStructListValue(*element()->parent_field())) {
- // case iii above. Bind directly to g.p.ListValue
- Push("values", Item::MESSAGE, true, true);
- return this;
- }
- }
-
- // Report an error.
- InvalidValue("Map", StrCat("Cannot have repeated items ('", name,
- "') within a map."));
- return this;
- }
-
- // When name is empty and stack is not empty, we are rendering an item within
- // a list.
- if (name.empty()) {
- if (element() != nullptr && element()->parent_field() != nullptr) {
- if (IsStructValue(*element()->parent_field())) {
- // Since it is g.p.Value, we bind directly to the list_value.
- // Render
- // { // g.p.Value item within the list
- // "list_value": {
- // "values": [
- Push("", Item::MESSAGE, false, false);
- Push("list_value", Item::MESSAGE, true, false);
- Push("values", Item::MESSAGE, true, true);
- return this;
- }
-
- if (IsStructListValue(*element()->parent_field())) {
- // Since it is g.p.ListValue, we bind to it directly.
- // Render
- // { // g.p.ListValue item within the list
- // "values": [
- Push("", Item::MESSAGE, false, false);
- Push("values", Item::MESSAGE, true, true);
- return this;
- }
- }
-
- // Pass the event to underlying ProtoWriter.
- Push(name, Item::MESSAGE, false, true);
- return this;
- }
-
- // name is not empty
- const google::protobuf::Field* field = Lookup(name);
-
- if (field == nullptr) {
- IncrementInvalidDepth();
- return this;
- }
-
- if (IsStructValue(*field)) {
- // If g.p.Value is repeated, start that list. Otherwise, start the
- // "list_value" within it.
- if (IsRepeated(*field)) {
- // Render it just like a regular repeated field.
- // "<name>": [
- Push(name, Item::MESSAGE, false, true);
- return this;
- }
-
- // Start the "list_value" field.
- // Render
- // "<name>": {
- // "list_value": {
- // "values": [
- Push(name, Item::MESSAGE, false, false);
- Push("list_value", Item::MESSAGE, true, false);
- Push("values", Item::MESSAGE, true, true);
- return this;
- }
-
- if (IsStructListValue(*field)) {
- // If g.p.ListValue is repeated, start that list. Otherwise, start the
- // "values" within it.
- if (IsRepeated(*field)) {
- // Render it just like a regular repeated field.
- // "<name>": [
- Push(name, Item::MESSAGE, false, true);
- return this;
- }
-
- // Start the "values" field within g.p.ListValue.
- // Render
- // "<name>": {
- // "values": [
- Push(name, Item::MESSAGE, false, false);
- Push("values", Item::MESSAGE, true, true);
- return this;
- }
-
- // If we are here, the field should be repeated. Report an error otherwise.
- if (!IsRepeated(*field)) {
- IncrementInvalidDepth();
- InvalidName(name, "Proto field is not repeating, cannot start list.");
- return this;
- }
-
- if (IsMap(*field)) {
- if (options_.use_legacy_json_map_format) {
- Push(name, Item::MESSAGE, false, true);
- return this;
- }
- InvalidValue("Map", StrCat("Cannot bind a list to map for field '",
- name, "'."));
- IncrementInvalidDepth();
- return this;
- }
-
- // Pass the event to ProtoWriter.
- // Render
- // "<name>": [
- Push(name, Item::MESSAGE, false, true);
- return this;
-}
-
-ProtoStreamObjectWriter* ProtoStreamObjectWriter::EndList() {
- if (invalid_depth() > 0) {
- DecrementInvalidDepth();
- return this;
- }
-
- if (current_ == nullptr) return this;
-
- if (current_->IsAny()) {
- current_->any()->EndList();
- return this;
- }
-
- Pop();
- return this;
-}
-
-Status ProtoStreamObjectWriter::RenderStructValue(ProtoStreamObjectWriter* ow,
- const DataPiece& data) {
- TProtoStringType struct_field_name;
- switch (data.type()) {
- case DataPiece::TYPE_INT32: {
- if (ow->options_.struct_integers_as_strings) {
- util::StatusOr<arc_i32> int_value = data.ToInt32();
- if (int_value.ok()) {
- ow->ProtoWriter::RenderDataPiece(
- "string_value",
- DataPiece(SimpleDtoa(int_value.value()), true));
- return Status();
- }
- }
- struct_field_name = "number_value";
- break;
- }
- case DataPiece::TYPE_UINT32: {
- if (ow->options_.struct_integers_as_strings) {
- util::StatusOr<arc_ui32> int_value = data.ToUint32();
- if (int_value.ok()) {
- ow->ProtoWriter::RenderDataPiece(
- "string_value",
- DataPiece(SimpleDtoa(int_value.value()), true));
- return Status();
- }
- }
- struct_field_name = "number_value";
- break;
- }
- case DataPiece::TYPE_INT64: {
- // If the option to treat integers as strings is set, then render them as
- // strings. Otherwise, fallback to rendering them as double.
- if (ow->options_.struct_integers_as_strings) {
- util::StatusOr<arc_i64> int_value = data.ToInt64();
- if (int_value.ok()) {
- ow->ProtoWriter::RenderDataPiece(
- "string_value", DataPiece(StrCat(int_value.value()), true));
- return Status();
- }
- }
- struct_field_name = "number_value";
- break;
- }
- case DataPiece::TYPE_UINT64: {
- // If the option to treat integers as strings is set, then render them as
- // strings. Otherwise, fallback to rendering them as double.
- if (ow->options_.struct_integers_as_strings) {
- util::StatusOr<arc_ui64> int_value = data.ToUint64();
- if (int_value.ok()) {
- ow->ProtoWriter::RenderDataPiece(
- "string_value", DataPiece(StrCat(int_value.value()), true));
- return Status();
- }
- }
- struct_field_name = "number_value";
- break;
- }
- case DataPiece::TYPE_FLOAT: {
- if (ow->options_.struct_integers_as_strings) {
- util::StatusOr<float> float_value = data.ToFloat();
- if (float_value.ok()) {
- ow->ProtoWriter::RenderDataPiece(
- "string_value",
- DataPiece(SimpleDtoa(float_value.value()), true));
- return Status();
- }
- }
- struct_field_name = "number_value";
- break;
- }
- case DataPiece::TYPE_DOUBLE: {
- if (ow->options_.struct_integers_as_strings) {
- util::StatusOr<double> double_value = data.ToDouble();
- if (double_value.ok()) {
- ow->ProtoWriter::RenderDataPiece(
- "string_value",
- DataPiece(SimpleDtoa(double_value.value()), true));
- return Status();
- }
- }
- struct_field_name = "number_value";
- break;
- }
- case DataPiece::TYPE_STRING: {
- struct_field_name = "string_value";
- break;
- }
- case DataPiece::TYPE_BOOL: {
- struct_field_name = "bool_value";
- break;
- }
- case DataPiece::TYPE_NULL: {
- struct_field_name = "null_value";
- break;
- }
- default: {
- return util::InvalidArgumentError(
- "Invalid struct data type. Only number, string, boolean or null "
- "values are supported.");
- }
- }
- ow->ProtoWriter::RenderDataPiece(struct_field_name, data);
- return Status();
-}
-
-Status ProtoStreamObjectWriter::RenderTimestamp(ProtoStreamObjectWriter* ow,
- const DataPiece& data) {
- if (data.type() == DataPiece::TYPE_NULL) return Status();
- if (data.type() != DataPiece::TYPE_STRING) {
- return util::InvalidArgumentError(
- StrCat("Invalid data type for timestamp, value is ",
- data.ValueAsStringOrDefault("")));
- }
-
- StringPiece value(data.str());
-
- arc_i64 seconds;
- arc_i32 nanos;
- if (!::google::protobuf::internal::ParseTime(value.ToString(), &seconds,
- &nanos)) {
- return util::InvalidArgumentError(StrCat("Invalid time format: ", value));
- }
-
-
- ow->ProtoWriter::RenderDataPiece("seconds", DataPiece(seconds));
- ow->ProtoWriter::RenderDataPiece("nanos", DataPiece(nanos));
- return Status();
-}
-
-static inline util::Status RenderOneFieldPath(ProtoStreamObjectWriter* ow,
- StringPiece path) {
- ow->ProtoWriter::RenderDataPiece(
- "paths", DataPiece(ConvertFieldMaskPath(path, &ToSnakeCase), true));
- return Status();
-}
-
-Status ProtoStreamObjectWriter::RenderFieldMask(ProtoStreamObjectWriter* ow,
- const DataPiece& data) {
- if (data.type() == DataPiece::TYPE_NULL) return Status();
- if (data.type() != DataPiece::TYPE_STRING) {
- return util::InvalidArgumentError(
- StrCat("Invalid data type for field mask, value is ",
- data.ValueAsStringOrDefault("")));
- }
-
- // TODO(tsun): figure out how to do proto descriptor based snake case
- // conversions as much as possible. Because ToSnakeCase sometimes returns the
- // wrong value.
- return DecodeCompactFieldMaskPaths(data.str(),
- std::bind(&RenderOneFieldPath, ow, _1));
-}
-
-Status ProtoStreamObjectWriter::RenderDuration(ProtoStreamObjectWriter* ow,
- const DataPiece& data) {
- if (data.type() == DataPiece::TYPE_NULL) return Status();
- if (data.type() != DataPiece::TYPE_STRING) {
- return util::InvalidArgumentError(
- StrCat("Invalid data type for duration, value is ",
- data.ValueAsStringOrDefault("")));
- }
-
- StringPiece value(data.str());
-
- if (!HasSuffixString(value, "s")) {
- return util::InvalidArgumentError(
- "Illegal duration format; duration must end with 's'");
- }
- value = value.substr(0, value.size() - 1);
- int sign = 1;
- if (HasPrefixString(value, "-")) {
- sign = -1;
- value = value.substr(1);
- }
-
- StringPiece s_secs, s_nanos;
- SplitSecondsAndNanos(value, &s_secs, &s_nanos);
- arc_ui64 unsigned_seconds;
- if (!safe_strtou64(s_secs, &unsigned_seconds)) {
- return util::InvalidArgumentError(
- "Invalid duration format, failed to parse seconds");
- }
-
- arc_i32 nanos = 0;
- Status nanos_status = GetNanosFromStringPiece(
- s_nanos, "Invalid duration format, failed to parse nano seconds",
- "Duration value exceeds limits", &nanos);
- if (!nanos_status.ok()) {
- return nanos_status;
- }
- nanos = sign * nanos;
-
- arc_i64 seconds = sign * unsigned_seconds;
- if (seconds > kDurationMaxSeconds || seconds < kDurationMinSeconds ||
- nanos <= -kNanosPerSecond || nanos >= kNanosPerSecond) {
- return util::InvalidArgumentError("Duration value exceeds limits");
- }
-
- ow->ProtoWriter::RenderDataPiece("seconds", DataPiece(seconds));
- ow->ProtoWriter::RenderDataPiece("nanos", DataPiece(nanos));
- return Status();
-}
-
-Status ProtoStreamObjectWriter::RenderWrapperType(ProtoStreamObjectWriter* ow,
- const DataPiece& data) {
- if (data.type() == DataPiece::TYPE_NULL) return Status();
- ow->ProtoWriter::RenderDataPiece("value", data);
- return Status();
-}
-
-ProtoStreamObjectWriter* ProtoStreamObjectWriter::RenderDataPiece(
- StringPiece name, const DataPiece& data) {
- Status status;
- if (invalid_depth() > 0) return this;
-
- if (current_ == nullptr) {
- const TypeRenderer* type_renderer =
- FindTypeRenderer(GetFullTypeWithUrl(master_type_.name()));
- if (type_renderer == nullptr) {
- InvalidName(name, "Root element must be a message.");
- return this;
- }
- // Render the special type.
- // "<name>": {
- // ... Render special type ...
- // }
- ProtoWriter::StartObject(name);
- status = (*type_renderer)(this, data);
- if (!status.ok()) {
- InvalidValue(master_type_.name(),
- StrCat("Field '", name, "', ", status.message()));
- }
- ProtoWriter::EndObject();
- return this;
- }
-
- if (current_->IsAny()) {
- current_->any()->RenderDataPiece(name, data);
- return this;
- }
-
- const google::protobuf::Field* field = nullptr;
- if (current_->IsMap()) {
- if (!ValidMapKey(name)) return this;
-
- field = Lookup("value");
- if (field == nullptr) {
- GOOGLE_LOG(DFATAL) << "Map does not have a value field.";
- return this;
- }
-
- if (options_.ignore_null_value_map_entry) {
- // If we are rendering explicit null values and the backend proto field is
- // not of the google.protobuf.NullType type, interpret null as absence.
- if (data.type() == DataPiece::TYPE_NULL &&
- field->type_url() != kStructNullValueTypeUrl) {
- return this;
- }
- }
-
- // Render an item in repeated map list.
- // { "key": "<name>", "value":
- Push("", Item::MESSAGE, false, false);
- ProtoWriter::RenderDataPiece("key",
- DataPiece(name, use_strict_base64_decoding()));
-
- const TypeRenderer* type_renderer = FindTypeRenderer(field->type_url());
- if (type_renderer != nullptr) {
- // Map's value type is a special type. Render it like a message:
- // "value": {
- // ... Render special type ...
- // }
- Push("value", Item::MESSAGE, true, false);
- status = (*type_renderer)(this, data);
- if (!status.ok()) {
- InvalidValue(field->type_url(),
- StrCat("Field '", name, "', ", status.message()));
- }
- Pop();
- return this;
- }
-
- // If we are rendering explicit null values and the backend proto field is
- // not of the google.protobuf.NullType type, we do nothing.
- if (data.type() == DataPiece::TYPE_NULL &&
- field->type_url() != kStructNullValueTypeUrl) {
- Pop();
- return this;
- }
-
- // Render the map value as a primitive type.
- ProtoWriter::RenderDataPiece("value", data);
- Pop();
- return this;
- }
-
- field = Lookup(name);
- if (field == nullptr) return this;
-
- // Check if the field is of special type. Render it accordingly if so.
- const TypeRenderer* type_renderer = FindTypeRenderer(field->type_url());
- if (type_renderer != nullptr) {
- // Pass through null value only for google.protobuf.Value. For other
- // types we ignore null value just like for regular field types.
- if (data.type() != DataPiece::TYPE_NULL ||
- field->type_url() == kStructValueTypeUrl) {
- Push(name, Item::MESSAGE, false, false);
- status = (*type_renderer)(this, data);
- if (!status.ok()) {
- InvalidValue(field->type_url(),
- StrCat("Field '", name, "', ", status.message()));
- }
- Pop();
- }
- return this;
- }
-
- // If we are rendering explicit null values and the backend proto field is
- // not of the google.protobuf.NullType type, we do nothing.
- if (data.type() == DataPiece::TYPE_NULL &&
- field->type_url() != kStructNullValueTypeUrl) {
- return this;
- }
-
- if (IsRepeated(*field) && !current_->is_list()) {
- if (options_.disable_implicit_scalar_list) {
- if (!options_.suppress_implicit_scalar_list_error) {
- InvalidValue(
- field->name(),
- "Starting an primitive in a repeated field but the parent field "
- "is not a list");
- }
-
- return this;
- }
- }
-
- ProtoWriter::RenderDataPiece(name, data);
- return this;
-}
-
-// Map of functions that are responsible for rendering well known type
-// represented by the key.
-std::unordered_map<TProtoStringType, ProtoStreamObjectWriter::TypeRenderer>*
- ProtoStreamObjectWriter::renderers_ = nullptr;
-PROTOBUF_NAMESPACE_ID::internal::once_flag writer_renderers_init_;
-
-void ProtoStreamObjectWriter::InitRendererMap() {
- renderers_ = new std::unordered_map<TProtoStringType,
- ProtoStreamObjectWriter::TypeRenderer>();
- (*renderers_)["type.googleapis.com/google.protobuf.Timestamp"] =
- &ProtoStreamObjectWriter::RenderTimestamp;
- (*renderers_)["type.googleapis.com/google.protobuf.Duration"] =
- &ProtoStreamObjectWriter::RenderDuration;
- (*renderers_)["type.googleapis.com/google.protobuf.FieldMask"] =
- &ProtoStreamObjectWriter::RenderFieldMask;
- (*renderers_)["type.googleapis.com/google.protobuf.Double"] =
- &ProtoStreamObjectWriter::RenderWrapperType;
- (*renderers_)["type.googleapis.com/google.protobuf.Float"] =
- &ProtoStreamObjectWriter::RenderWrapperType;
- (*renderers_)["type.googleapis.com/google.protobuf.Int64"] =
- &ProtoStreamObjectWriter::RenderWrapperType;
- (*renderers_)["type.googleapis.com/google.protobuf.UInt64"] =
- &ProtoStreamObjectWriter::RenderWrapperType;
- (*renderers_)["type.googleapis.com/google.protobuf.Int32"] =
- &ProtoStreamObjectWriter::RenderWrapperType;
- (*renderers_)["type.googleapis.com/google.protobuf.UInt32"] =
- &ProtoStreamObjectWriter::RenderWrapperType;
- (*renderers_)["type.googleapis.com/google.protobuf.Bool"] =
- &ProtoStreamObjectWriter::RenderWrapperType;
- (*renderers_)["type.googleapis.com/google.protobuf.String"] =
- &ProtoStreamObjectWriter::RenderWrapperType;
- (*renderers_)["type.googleapis.com/google.protobuf.Bytes"] =
- &ProtoStreamObjectWriter::RenderWrapperType;
- (*renderers_)["type.googleapis.com/google.protobuf.DoubleValue"] =
- &ProtoStreamObjectWriter::RenderWrapperType;
- (*renderers_)["type.googleapis.com/google.protobuf.FloatValue"] =
- &ProtoStreamObjectWriter::RenderWrapperType;
- (*renderers_)["type.googleapis.com/google.protobuf.Int64Value"] =
- &ProtoStreamObjectWriter::RenderWrapperType;
- (*renderers_)["type.googleapis.com/google.protobuf.UInt64Value"] =
- &ProtoStreamObjectWriter::RenderWrapperType;
- (*renderers_)["type.googleapis.com/google.protobuf.Int32Value"] =
- &ProtoStreamObjectWriter::RenderWrapperType;
- (*renderers_)["type.googleapis.com/google.protobuf.UInt32Value"] =
- &ProtoStreamObjectWriter::RenderWrapperType;
- (*renderers_)["type.googleapis.com/google.protobuf.BoolValue"] =
- &ProtoStreamObjectWriter::RenderWrapperType;
- (*renderers_)["type.googleapis.com/google.protobuf.StringValue"] =
- &ProtoStreamObjectWriter::RenderWrapperType;
- (*renderers_)["type.googleapis.com/google.protobuf.BytesValue"] =
- &ProtoStreamObjectWriter::RenderWrapperType;
- (*renderers_)["type.googleapis.com/google.protobuf.Value"] =
- &ProtoStreamObjectWriter::RenderStructValue;
- ::google::protobuf::internal::OnShutdown(&DeleteRendererMap);
-}
-
-void ProtoStreamObjectWriter::DeleteRendererMap() {
- delete ProtoStreamObjectWriter::renderers_;
- renderers_ = nullptr;
-}
-
-ProtoStreamObjectWriter::TypeRenderer*
-ProtoStreamObjectWriter::FindTypeRenderer(const TProtoStringType& type_url) {
- PROTOBUF_NAMESPACE_ID::internal::call_once(writer_renderers_init_,
- InitRendererMap);
- return FindOrNull(*renderers_, type_url);
-}
-
-bool ProtoStreamObjectWriter::ValidMapKey(StringPiece unnormalized_name) {
- if (current_ == nullptr) return true;
-
- if (!current_->InsertMapKeyIfNotPresent(unnormalized_name)) {
- listener()->InvalidName(
- location(), unnormalized_name,
- StrCat("Repeated map key: '", unnormalized_name,
- "' is already set."));
- return false;
- }
-
- return true;
-}
-
-void ProtoStreamObjectWriter::Push(
- StringPiece name, Item::ItemType item_type, bool is_placeholder,
- bool is_list) {
- is_list ? ProtoWriter::StartList(name) : ProtoWriter::StartObject(name);
-
- // invalid_depth == 0 means it is a successful StartObject or StartList.
- if (invalid_depth() == 0)
- current_.reset(
- new Item(current_.release(), item_type, is_placeholder, is_list));
-}
-
-void ProtoStreamObjectWriter::Pop() {
- // Pop all placeholder items sending StartObject or StartList events to
- // ProtoWriter according to is_list value.
- while (current_ != nullptr && current_->is_placeholder()) {
- PopOneElement();
- }
- if (current_ != nullptr) {
- PopOneElement();
- }
-}
-
-void ProtoStreamObjectWriter::PopOneElement() {
- current_->is_list() ? ProtoWriter::EndList() : ProtoWriter::EndObject();
- current_.reset(current_->pop<Item>());
-}
-
-bool ProtoStreamObjectWriter::IsMap(const google::protobuf::Field& field) {
- if (field.type_url().empty() ||
- field.kind() != google::protobuf::Field::TYPE_MESSAGE ||
- field.cardinality() != google::protobuf::Field::CARDINALITY_REPEATED) {
- return false;
- }
- const google::protobuf::Type* field_type =
- typeinfo()->GetTypeByTypeUrl(field.type_url());
-
- return converter::IsMap(field, *field_type);
-}
-
-bool ProtoStreamObjectWriter::IsAny(const google::protobuf::Field& field) {
- return GetTypeWithoutUrl(field.type_url()) == kAnyType;
-}
-
-bool ProtoStreamObjectWriter::IsStruct(const google::protobuf::Field& field) {
- return GetTypeWithoutUrl(field.type_url()) == kStructType;
-}
-
-bool ProtoStreamObjectWriter::IsStructValue(
- const google::protobuf::Field& field) {
- return GetTypeWithoutUrl(field.type_url()) == kStructValueType;
-}
-
-bool ProtoStreamObjectWriter::IsStructListValue(
- const google::protobuf::Field& field) {
- return GetTypeWithoutUrl(field.type_url()) == kStructListValueType;
-}
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
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
deleted file mode 100644
index 0ea06c682db..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.h
+++ /dev/null
@@ -1,453 +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_UTIL_INTERNAL_PROTOSTREAM_OBJECTWRITER_H__
-#define GOOGLE_PROTOBUF_UTIL_INTERNAL_PROTOSTREAM_OBJECTWRITER_H__
-
-#include <deque>
-#include <string>
-#include <unordered_map>
-#include <unordered_set>
-
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/type.pb.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/zero_copy_stream_impl.h>
-#include <google/protobuf/descriptor.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/hash.h>
-
-// Must be included last.
-#include <google/protobuf/port_def.inc>
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-class ObjectLocationTracker;
-
-// An ObjectWriter that can write protobuf bytes directly from writer events.
-// This class supports all special types like Struct and Map. It uses
-// the ProtoWriter class to write raw proto bytes.
-//
-// It also supports streaming.
-class PROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
- public:
- // Options that control ProtoStreamObjectWriter class's behavior.
- struct Options {
- // Treats numeric inputs in google.protobuf.Struct as strings. Normally,
- // numeric values are returned in double field "number_value" of
- // google.protobuf.Struct. However, this can cause precision loss for
- // int64/uint64/double inputs. This option is provided for cases that want
- // to preserve number precision.
- //
- // TODO(skarvaje): Rename to struct_numbers_as_strings as it covers double
- // as well.
- bool struct_integers_as_strings;
-
- // Not treat unknown fields as an error. If there is an unknown fields,
- // just ignore it and continue to process the rest. Note that this doesn't
- // apply to unknown enum values.
- bool ignore_unknown_fields;
-
- // Ignore unknown enum values.
- bool ignore_unknown_enum_values;
-
- // If true, check if enum name in camel case or without underscore matches
- // the field name.
- bool use_lower_camel_for_enums;
-
- // If true, check if enum name in UPPER_CASE matches the field name.
- bool case_insensitive_enum_parsing;
-
- // If true, skips rendering the map entry if map value is null unless the
- // value type is google.protobuf.NullType.
- bool ignore_null_value_map_entry;
-
- // If true, accepts repeated key/value pair for a map proto field.
- bool use_legacy_json_map_format;
-
- // If true, disable implicitly creating message list.
- bool disable_implicit_message_list;
-
- // If true, suppress the error of implicitly creating message list when it
- // is disabled.
- bool suppress_implicit_message_list_error;
-
- // If true, disable implicitly creating scalar list.
- bool disable_implicit_scalar_list;
-
- // If true, suppress the error of implicitly creating scalar list when it
- // is disabled.
- bool suppress_implicit_scalar_list_error;
-
- // If true, suppress the error of rendering scalar field if the source is an
- // object.
- bool suppress_object_to_scalar_error;
-
- // If true, use the json name in missing fields errors.
- bool use_json_name_in_missing_fields;
-
- Options()
- : struct_integers_as_strings(false),
- ignore_unknown_fields(false),
- ignore_unknown_enum_values(false),
- use_lower_camel_for_enums(false),
- case_insensitive_enum_parsing(false),
- ignore_null_value_map_entry(false),
- use_legacy_json_map_format(false),
- disable_implicit_message_list(false),
- suppress_implicit_message_list_error(false),
- disable_implicit_scalar_list(false),
- suppress_implicit_scalar_list_error(false),
- suppress_object_to_scalar_error(false),
- use_json_name_in_missing_fields(false) {}
-
- // Default instance of Options with all options set to defaults.
- static const Options& Defaults() {
- static Options defaults;
- return defaults;
- }
- };
-
- // Constructor. Does not take ownership of any parameter passed in.
- ProtoStreamObjectWriter(TypeResolver* type_resolver,
- const google::protobuf::Type& type,
- strings::ByteSink* output, ErrorListener* listener,
- const ProtoStreamObjectWriter::Options& options =
- ProtoStreamObjectWriter::Options::Defaults());
- ~ProtoStreamObjectWriter() override;
-
- // ObjectWriter methods.
- ProtoStreamObjectWriter* StartObject(StringPiece name) override;
- ProtoStreamObjectWriter* EndObject() override;
- ProtoStreamObjectWriter* StartList(StringPiece name) override;
- ProtoStreamObjectWriter* EndList() override;
-
- // Renders a DataPiece 'value' into a field whose wire type is determined
- // from the given field 'name'.
- ProtoStreamObjectWriter* RenderDataPiece(StringPiece name,
- const DataPiece& data) override;
-
- protected:
- // Function that renders a well known type with modified behavior.
- typedef util::Status (*TypeRenderer)(ProtoStreamObjectWriter*,
- const DataPiece&);
-
- // Handles writing Anys out using nested object writers and the like.
- class PROTOBUF_EXPORT AnyWriter {
- public:
- explicit AnyWriter(ProtoStreamObjectWriter* parent);
- ~AnyWriter();
-
- // Passes a StartObject call through to the Any writer.
- void StartObject(StringPiece name);
-
- // Passes an EndObject call through to the Any. Returns true if the any
- // handled the EndObject call, false if the Any is now all done and is no
- // longer needed.
- bool EndObject();
-
- // Passes a StartList call through to the Any writer.
- void StartList(StringPiece name);
-
- // Passes an EndList call through to the Any writer.
- void EndList();
-
- // Renders a data piece on the any.
- void RenderDataPiece(StringPiece name, const DataPiece& value);
-
- private:
- // Before the "@type" field is encountered, we store all incoming data
- // into this Event struct and replay them after we get the "@type" field.
- class PROTOBUF_EXPORT Event {
- public:
- enum Type {
- START_OBJECT = 0,
- END_OBJECT = 1,
- START_LIST = 2,
- END_LIST = 3,
- RENDER_DATA_PIECE = 4,
- };
-
- // Constructor for END_OBJECT and END_LIST events.
- explicit Event(Type type) : type_(type), value_(DataPiece::NullData()) {}
-
- // Constructor for START_OBJECT and START_LIST events.
- explicit Event(Type type, StringPiece name)
- : type_(type), name_(name), value_(DataPiece::NullData()) {}
-
- // Constructor for RENDER_DATA_PIECE events.
- explicit Event(StringPiece name, const DataPiece& value)
- : type_(RENDER_DATA_PIECE), name_(name), value_(value) {
- DeepCopy();
- }
-
- Event(const Event& other)
- : type_(other.type_), name_(other.name_), value_(other.value_) {
- DeepCopy();
- }
-
- Event& operator=(const Event& other) {
- type_ = other.type_;
- name_ = other.name_;
- value_ = other.value_;
- DeepCopy();
- return *this;
- }
-
- void Replay(AnyWriter* writer) const;
-
- private:
- void DeepCopy();
-
- Type type_;
- TProtoStringType name_;
- DataPiece value_;
- TProtoStringType value_storage_;
- };
-
- // Handles starting up the any once we have a type.
- void StartAny(const DataPiece& value);
-
- // Writes the Any out to the parent writer in its serialized form.
- void WriteAny();
-
- // The parent of this writer, needed for various bits such as type info and
- // the listeners.
- ProtoStreamObjectWriter* parent_;
-
- // The nested object writer, used to write events.
- std::unique_ptr<ProtoStreamObjectWriter> ow_;
-
- // The type_url_ that this Any represents.
- TProtoStringType type_url_;
-
- // Whether this any is invalid. This allows us to only report an invalid
- // Any message a single time rather than every time we get a nested field.
- bool invalid_;
-
- // The output data and wrapping ByteSink.
- TProtoStringType data_;
- strings::StringByteSink output_;
-
- // The depth within the Any, so we can track when we're done.
- int depth_;
-
- // True if the type is a well-known type. Well-known types in Any
- // has a special formatting:
- // {
- // "@type": "type.googleapis.com/google.protobuf.XXX",
- // "value": <JSON representation of the type>,
- // }
- bool is_well_known_type_;
- TypeRenderer* well_known_type_render_;
-
- // Store data before the "@type" field.
- std::vector<Event> uninterpreted_events_;
- };
-
- // Represents an item in a stack of items used to keep state between
- // ObjectWrier events.
- class PROTOBUF_EXPORT Item : public BaseElement {
- public:
- // Indicates the type of item.
- enum ItemType {
- MESSAGE, // Simple message
- MAP, // Proto3 map type
- ANY, // Proto3 Any type
- };
-
- // Constructor for the root item.
- Item(ProtoStreamObjectWriter* enclosing, ItemType item_type,
- bool is_placeholder, bool is_list);
-
- // Constructor for a field of a message.
- Item(Item* parent, ItemType item_type, bool is_placeholder, bool is_list);
-
- ~Item() override {}
-
- // These functions return true if the element type is corresponding to the
- // type in function name.
- bool IsMap() { return item_type_ == MAP; }
- bool IsAny() { return item_type_ == ANY; }
-
- AnyWriter* any() const { return any_.get(); }
-
- Item* parent() const override {
- return static_cast<Item*>(BaseElement::parent());
- }
-
- // Inserts map key into hash set if and only if the key did NOT already
- // exist in hash set.
- // The hash set (map_keys_) is ONLY used to keep track of map keys.
- // Return true if insert successfully; returns false if the map key was
- // already present.
- bool InsertMapKeyIfNotPresent(StringPiece map_key);
-
- bool is_placeholder() const { return is_placeholder_; }
- bool is_list() const { return is_list_; }
-
- private:
- // Used for access to variables of the enclosing instance of
- // ProtoStreamObjectWriter.
- ProtoStreamObjectWriter* ow_;
-
- // A writer for Any objects, handles all Any-related nonsense.
- std::unique_ptr<AnyWriter> any_;
-
- // The type of this element, see enum for permissible types.
- ItemType item_type_;
-
- // Set of map keys already seen for the type_. Used to validate incoming
- // messages so no map key appears more than once.
- std::unique_ptr<std::unordered_set<TProtoStringType> > map_keys_;
-
- // Conveys whether this Item is a placeholder or not. Placeholder items are
- // pushed to stack to account for special types.
- bool is_placeholder_;
-
- // Conveys whether this Item is a list or not. This is used to send
- // StartList or EndList calls to underlying ObjectWriter.
- bool is_list_;
-
- GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(Item);
- };
-
- ProtoStreamObjectWriter(const TypeInfo* typeinfo,
- const google::protobuf::Type& type,
- strings::ByteSink* output, ErrorListener* listener);
-
- ProtoStreamObjectWriter(const TypeInfo* typeinfo,
- const google::protobuf::Type& type,
- strings::ByteSink* output, ErrorListener* listener,
- const ProtoStreamObjectWriter::Options& options);
-
- // Returns true if the field is a map.
- inline bool IsMap(const google::protobuf::Field& field);
-
- // Returns true if the field is an any.
- inline bool IsAny(const google::protobuf::Field& field);
-
- // Returns true if the field is google.protobuf.Struct.
- inline bool IsStruct(const google::protobuf::Field& field);
-
- // Returns true if the field is google.protobuf.Value.
- inline bool IsStructValue(const google::protobuf::Field& field);
-
- // Returns true if the field is google.protobuf.ListValue.
- inline bool IsStructListValue(const google::protobuf::Field& field);
-
- // Renders google.protobuf.Value in struct.proto. It picks the right oneof
- // type based on value's type.
- static util::Status RenderStructValue(ProtoStreamObjectWriter* ow,
- const DataPiece& data);
-
- // Renders google.protobuf.Timestamp value.
- static util::Status RenderTimestamp(ProtoStreamObjectWriter* ow,
- const DataPiece& data);
-
- // Renders google.protobuf.FieldMask value.
- static util::Status RenderFieldMask(ProtoStreamObjectWriter* ow,
- const DataPiece& data);
-
- // Renders google.protobuf.Duration value.
- static util::Status RenderDuration(ProtoStreamObjectWriter* ow,
- const DataPiece& data);
-
- // Renders wrapper message types for primitive types in
- // google/protobuf/wrappers.proto.
- static util::Status RenderWrapperType(ProtoStreamObjectWriter* ow,
- const DataPiece& data);
-
- static void InitRendererMap();
- static void DeleteRendererMap();
- static TypeRenderer* FindTypeRenderer(const TProtoStringType& type_url);
-
- // Returns true if the map key for type_ is not duplicated key.
- // If map key is duplicated key, this function returns false.
- // Note that caller should make sure that the current proto element (current_)
- // is of element type MAP or STRUCT_MAP.
- // It also calls the appropriate error callback and unnormalzied_name is used
- // for error string.
- bool ValidMapKey(StringPiece unnormalized_name);
-
- // Pushes an item on to the stack. Also calls either StartObject or StartList
- // on the underlying ObjectWriter depending on whether is_list is false or
- // not.
- // is_placeholder conveys whether the item is a placeholder item or not.
- // Placeholder items are pushed when adding auxiliary types' StartObject or
- // StartList calls.
- void Push(StringPiece name, Item::ItemType item_type,
- bool is_placeholder, bool is_list);
-
-
- // Pops items from the stack. All placeholder items are popped until a
- // non-placeholder item is found.
- void Pop();
-
- // Pops one element from the stack. Calls EndObject() or EndList() on the
- // underlying ObjectWriter depending on the value of is_list_.
- void PopOneElement();
-
- private:
- // Helper functions to create the map and find functions responsible for
- // rendering well known types, keyed by type URL.
- static std::unordered_map<TProtoStringType, TypeRenderer>* renderers_;
-
- // Variables for describing the structure of the input tree:
- // master_type_: descriptor for the whole protobuf message.
- const google::protobuf::Type& master_type_;
-
- // The current element, variable for internal state processing.
- std::unique_ptr<Item> current_;
-
- // Reference to the options that control this class's behavior.
- const ProtoStreamObjectWriter::Options options_;
-
- GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(ProtoStreamObjectWriter);
-};
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#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
deleted file mode 100644
index f6f7c89e578..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/structured_objectwriter.h
+++ /dev/null
@@ -1,121 +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_UTIL_INTERNAL_STRUCTURED_OBJECTWRITER_H__
-#define GOOGLE_PROTOBUF_UTIL_INTERNAL_STRUCTURED_OBJECTWRITER_H__
-
-#include <memory>
-
-#include <google/protobuf/stubs/casts.h>
-#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 {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-// An StructuredObjectWriter is an ObjectWriter for writing
-// tree-structured data in a stream of events representing objects
-// and collections. Implementation of this interface can be used to
-// write an object stream to an in-memory structure, protobufs,
-// JSON, XML, or any other output format desired. The ObjectSource
-// interface is typically used as the source of an object stream.
-//
-// See JsonObjectWriter for a sample implementation of
-// StructuredObjectWriter and its use.
-//
-// Derived classes could be thread-unsafe.
-class PROTOBUF_EXPORT StructuredObjectWriter : public ObjectWriter {
- public:
- ~StructuredObjectWriter() override {}
-
- protected:
- // A base element class for subclasses to extend, makes tracking state easier.
- //
- // StructuredObjectWriter behaves as a visitor. BaseElement represents a node
- // in the input tree. Implementation of StructuredObjectWriter should also
- // extend BaseElement to keep track of the location in the input tree.
- class PROTOBUF_EXPORT BaseElement {
- public:
- // Takes ownership of the parent Element.
- explicit BaseElement(BaseElement* parent)
- : parent_(parent),
- level_(parent == nullptr ? 0 : parent->level() + 1) {}
- virtual ~BaseElement() {}
-
- // Releases ownership of the parent and returns a pointer to it.
- template <typename ElementType>
- ElementType* pop() {
- return down_cast<ElementType*>(parent_.release());
- }
-
- // Returns true if this element is the root.
- bool is_root() const { return parent_ == nullptr; }
-
- // Returns the number of hops from this element to the root element.
- int level() const { return level_; }
-
- protected:
- // Returns pointer to parent element without releasing ownership.
- virtual BaseElement* parent() const { return parent_.get(); }
-
- private:
- // Pointer to the parent Element.
- std::unique_ptr<BaseElement> parent_;
-
- // Number of hops to the root Element.
- // The root Element has nullptr parent_ and a level_ of 0.
- const int level_;
-
- GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(BaseElement);
- };
-
- StructuredObjectWriter() {}
-
- // Returns the current element. Used for indentation and name overrides.
- virtual BaseElement* element() = 0;
-
- private:
- // Do not add any data members to this class.
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StructuredObjectWriter);
-};
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#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
deleted file mode 100644
index f1bd827a2bc..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/type_info.cc
+++ /dev/null
@@ -1,182 +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/util/internal/type_info.h>
-
-#include <map>
-#include <set>
-
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/type.pb.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>
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-namespace {
-// A TypeInfo that looks up information provided by a TypeResolver.
-class TypeInfoForTypeResolver : public TypeInfo {
- public:
- explicit TypeInfoForTypeResolver(TypeResolver* type_resolver)
- : type_resolver_(type_resolver) {}
-
- ~TypeInfoForTypeResolver() override {
- DeleteCachedTypes(&cached_types_);
- DeleteCachedTypes(&cached_enums_);
- }
-
- util::StatusOr<const google::protobuf::Type*> ResolveTypeUrl(
- StringPiece type_url) const override {
- std::map<StringPiece, StatusOrType>::iterator it =
- cached_types_.find(type_url);
- if (it != cached_types_.end()) {
- return it->second;
- }
- // Stores the string value so it can be referenced using StringPiece in the
- // cached_types_ map.
- const TProtoStringType& string_type_url =
- *string_storage_.insert(TProtoStringType(type_url)).first;
- std::unique_ptr<google::protobuf::Type> type(new google::protobuf::Type());
- util::Status status =
- type_resolver_->ResolveMessageType(string_type_url, type.get());
- StatusOrType result =
- status.ok() ? StatusOrType(type.release()) : StatusOrType(status);
- cached_types_[string_type_url] = result;
- return result;
- }
-
- const google::protobuf::Type* GetTypeByTypeUrl(
- StringPiece type_url) const override {
- StatusOrType result = ResolveTypeUrl(type_url);
- return result.ok() ? result.value() : NULL;
- }
-
- const google::protobuf::Enum* GetEnumByTypeUrl(
- StringPiece type_url) const override {
- std::map<StringPiece, StatusOrEnum>::iterator it =
- cached_enums_.find(type_url);
- if (it != cached_enums_.end()) {
- return it->second.ok() ? it->second.value() : NULL;
- }
- // Stores the string value so it can be referenced using StringPiece in the
- // cached_enums_ map.
- const TProtoStringType& string_type_url =
- *string_storage_.insert(TProtoStringType(type_url)).first;
- std::unique_ptr<google::protobuf::Enum> enum_type(
- new google::protobuf::Enum());
- util::Status status =
- type_resolver_->ResolveEnumType(string_type_url, enum_type.get());
- StatusOrEnum result =
- status.ok() ? StatusOrEnum(enum_type.release()) : StatusOrEnum(status);
- cached_enums_[string_type_url] = result;
- return result.ok() ? result.value() : NULL;
- }
-
- const google::protobuf::Field* FindField(
- const google::protobuf::Type* type,
- StringPiece camel_case_name) const override {
- std::map<const google::protobuf::Type*, CamelCaseNameTable>::const_iterator
- it = indexed_types_.find(type);
- const CamelCaseNameTable& camel_case_name_table =
- (it == indexed_types_.end())
- ? PopulateNameLookupTable(type, &indexed_types_[type])
- : it->second;
- StringPiece name = FindWithDefault(
- camel_case_name_table, camel_case_name, StringPiece());
- if (name.empty()) {
- // Didn't find a mapping. Use whatever provided.
- name = camel_case_name;
- }
- return FindFieldInTypeOrNull(type, name);
- }
-
- private:
- typedef util::StatusOr<const google::protobuf::Type*> StatusOrType;
- typedef util::StatusOr<const google::protobuf::Enum*> StatusOrEnum;
- typedef std::map<StringPiece, StringPiece> CamelCaseNameTable;
-
- template <typename T>
- static void DeleteCachedTypes(std::map<StringPiece, T>* cached_types) {
- for (typename std::map<StringPiece, T>::iterator it =
- cached_types->begin();
- it != cached_types->end(); ++it) {
- if (it->second.ok()) {
- delete it->second.value();
- }
- }
- }
-
- const CamelCaseNameTable& PopulateNameLookupTable(
- const google::protobuf::Type* type,
- CamelCaseNameTable* camel_case_name_table) const {
- for (int i = 0; i < type->fields_size(); ++i) {
- const google::protobuf::Field& field = type->fields(i);
- StringPiece name = field.name();
- StringPiece camel_case_name = field.json_name();
- const StringPiece* existing = InsertOrReturnExisting(
- camel_case_name_table, camel_case_name, name);
- if (existing && *existing != name) {
- GOOGLE_LOG(WARNING) << "Field '" << name << "' and '" << *existing
- << "' map to the same camel case name '" << camel_case_name
- << "'.";
- }
- }
- return *camel_case_name_table;
- }
-
- TypeResolver* type_resolver_;
-
- // Stores string values that will be referenced by StringPieces in
- // cached_types_, cached_enums_.
- mutable std::set<TProtoStringType> string_storage_;
-
- mutable std::map<StringPiece, StatusOrType> cached_types_;
- mutable std::map<StringPiece, StatusOrEnum> cached_enums_;
-
- mutable std::map<const google::protobuf::Type*, CamelCaseNameTable>
- indexed_types_;
-};
-} // namespace
-
-TypeInfo* TypeInfo::NewTypeInfo(TypeResolver* type_resolver) {
- return new TypeInfoForTypeResolver(type_resolver);
-}
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
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
deleted file mode 100644
index 257df5bad68..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/type_info.h
+++ /dev/null
@@ -1,97 +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_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/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.
-#include <google/protobuf/port_def.inc>
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-// Internal helper class for type resolving. Note that this class is not
-// thread-safe and should only be accessed in one thread.
-class PROTOBUF_EXPORT TypeInfo {
- public:
- TypeInfo() {}
- virtual ~TypeInfo() {}
-
- // Resolves a type url into a Type. If the type url is invalid, returns
- // INVALID_ARGUMENT error status. If the type url is valid but the
- // corresponding type cannot be found, returns a NOT_FOUND error status.
- //
- // This TypeInfo class retains the ownership of the returned pointer.
- virtual util::StatusOr<const google::protobuf::Type*> ResolveTypeUrl(
- StringPiece type_url) const = 0;
-
- // Resolves a type url into a Type. Like ResolveTypeUrl() but returns
- // NULL if the type url is invalid or the type cannot be found.
- //
- // This TypeInfo class retains the ownership of the returned pointer.
- virtual const google::protobuf::Type* GetTypeByTypeUrl(
- StringPiece type_url) const = 0;
-
- // Resolves a type url for an enum. Returns NULL if the type url is
- // invalid or the type cannot be found.
- //
- // This TypeInfo class retains the ownership of the returned pointer.
- virtual const google::protobuf::Enum* GetEnumByTypeUrl(
- StringPiece type_url) const = 0;
-
- // Looks up a field in the specified type given a CamelCase name.
- virtual const google::protobuf::Field* FindField(
- const google::protobuf::Type* type,
- StringPiece camel_case_name) const = 0;
-
- // Creates a TypeInfo object that looks up type information from a
- // TypeResolver. Caller takes ownership of the returned pointer.
- static TypeInfo* NewTypeInfo(TypeResolver* type_resolver);
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeInfo);
-};
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#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
deleted file mode 100644
index d2d650b32cc..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/utility.cc
+++ /dev/null
@@ -1,414 +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/util/internal/utility.h>
-
-#include <algorithm>
-#include <cmath>
-#include <cstdint>
-#include <limits>
-
-#include <google/protobuf/stubs/callback.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/wrappers.pb.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/descriptor.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>
-
-// clang-format off
-#include <google/protobuf/port_def.inc>
-// clang-format on
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-bool GetBoolOptionOrDefault(
- const RepeatedPtrField<google::protobuf::Option>& options,
- StringPiece option_name, bool default_value) {
- const google::protobuf::Option* opt = FindOptionOrNull(options, option_name);
- if (opt == nullptr) {
- return default_value;
- }
- return GetBoolFromAny(opt->value());
-}
-
-arc_i64 GetInt64OptionOrDefault(
- const RepeatedPtrField<google::protobuf::Option>& options,
- StringPiece option_name, arc_i64 default_value) {
- const google::protobuf::Option* opt = FindOptionOrNull(options, option_name);
- if (opt == nullptr) {
- return default_value;
- }
- return GetInt64FromAny(opt->value());
-}
-
-double GetDoubleOptionOrDefault(
- const RepeatedPtrField<google::protobuf::Option>& options,
- StringPiece option_name, double default_value) {
- const google::protobuf::Option* opt = FindOptionOrNull(options, option_name);
- if (opt == nullptr) {
- return default_value;
- }
- return GetDoubleFromAny(opt->value());
-}
-
-TProtoStringType GetStringOptionOrDefault(
- const RepeatedPtrField<google::protobuf::Option>& options,
- StringPiece option_name, StringPiece default_value) {
- const google::protobuf::Option* opt = FindOptionOrNull(options, option_name);
- if (opt == nullptr) {
- return TProtoStringType(default_value);
- }
- return GetStringFromAny(opt->value());
-}
-
-template <typename T>
-void ParseFromAny(const TProtoStringType& data, T* result) {
- result->ParseFromString(data);
-}
-
-// Returns a boolean value contained in Any type.
-// TODO(skarvaje): Add type checking & error messages here.
-bool GetBoolFromAny(const google::protobuf::Any& any) {
- google::protobuf::BoolValue b;
- ParseFromAny(any.value(), &b);
- return b.value();
-}
-
-arc_i64 GetInt64FromAny(const google::protobuf::Any& any) {
- google::protobuf::Int64Value i;
- ParseFromAny(any.value(), &i);
- return i.value();
-}
-
-double GetDoubleFromAny(const google::protobuf::Any& any) {
- google::protobuf::DoubleValue i;
- ParseFromAny(any.value(), &i);
- return i.value();
-}
-
-TProtoStringType GetStringFromAny(const google::protobuf::Any& any) {
- google::protobuf::StringValue s;
- ParseFromAny(any.value(), &s);
- return s.value();
-}
-
-const StringPiece GetTypeWithoutUrl(StringPiece type_url) {
- if (type_url.size() > kTypeUrlSize && type_url[kTypeUrlSize] == '/') {
- return type_url.substr(kTypeUrlSize + 1);
- } else {
- size_t idx = type_url.rfind('/');
- if (idx != type_url.npos) {
- type_url.remove_prefix(idx + 1);
- }
- return type_url;
- }
-}
-
-const TProtoStringType GetFullTypeWithUrl(StringPiece simple_type) {
- return StrCat(kTypeServiceBaseUrl, "/", simple_type);
-}
-
-const google::protobuf::Option* FindOptionOrNull(
- const RepeatedPtrField<google::protobuf::Option>& options,
- StringPiece option_name) {
- for (int i = 0; i < options.size(); ++i) {
- const google::protobuf::Option& opt = options.Get(i);
- if (opt.name() == option_name) {
- return &opt;
- }
- }
- return nullptr;
-}
-
-const google::protobuf::Field* FindFieldInTypeOrNull(
- const google::protobuf::Type* type, StringPiece field_name) {
- if (type != nullptr) {
- for (int i = 0; i < type->fields_size(); ++i) {
- const google::protobuf::Field& field = type->fields(i);
- if (field.name() == field_name) {
- return &field;
- }
- }
- }
- return nullptr;
-}
-
-const google::protobuf::Field* FindJsonFieldInTypeOrNull(
- const google::protobuf::Type* type, StringPiece json_name) {
- if (type != nullptr) {
- for (int i = 0; i < type->fields_size(); ++i) {
- const google::protobuf::Field& field = type->fields(i);
- if (field.json_name() == json_name) {
- return &field;
- }
- }
- }
- return nullptr;
-}
-
-const google::protobuf::Field* FindFieldInTypeByNumberOrNull(
- const google::protobuf::Type* type, arc_i32 number) {
- if (type != nullptr) {
- for (int i = 0; i < type->fields_size(); ++i) {
- const google::protobuf::Field& field = type->fields(i);
- if (field.number() == number) {
- return &field;
- }
- }
- }
- return nullptr;
-}
-
-const google::protobuf::EnumValue* FindEnumValueByNameOrNull(
- const google::protobuf::Enum* enum_type, StringPiece enum_name) {
- if (enum_type != nullptr) {
- for (int i = 0; i < enum_type->enumvalue_size(); ++i) {
- const google::protobuf::EnumValue& enum_value = enum_type->enumvalue(i);
- if (enum_value.name() == enum_name) {
- return &enum_value;
- }
- }
- }
- return nullptr;
-}
-
-const google::protobuf::EnumValue* FindEnumValueByNumberOrNull(
- const google::protobuf::Enum* enum_type, arc_i32 value) {
- if (enum_type != nullptr) {
- for (int i = 0; i < enum_type->enumvalue_size(); ++i) {
- const google::protobuf::EnumValue& enum_value = enum_type->enumvalue(i);
- if (enum_value.number() == value) {
- return &enum_value;
- }
- }
- }
- return nullptr;
-}
-
-const google::protobuf::EnumValue* FindEnumValueByNameWithoutUnderscoreOrNull(
- const google::protobuf::Enum* enum_type, StringPiece enum_name) {
- if (enum_type != nullptr) {
- for (int i = 0; i < enum_type->enumvalue_size(); ++i) {
- const google::protobuf::EnumValue& enum_value = enum_type->enumvalue(i);
- TProtoStringType enum_name_without_underscore = enum_value.name();
-
- // Remove underscore from the name.
- RemoveAll(enum_name_without_underscore, '_');
- // Make the name uppercase.
- for (TProtoStringType::iterator it = enum_name_without_underscore.begin();
- it != enum_name_without_underscore.end(); ++it) {
- *it = ascii_toupper(*it);
- }
-
- if (enum_name_without_underscore == enum_name) {
- return &enum_value;
- }
- }
- }
- return nullptr;
-}
-
-TProtoStringType EnumValueNameToLowerCamelCase(StringPiece input) {
- TProtoStringType input_string(input);
- input_string.to_lower();
- return ToCamelCase(input_string);
-}
-
-TProtoStringType ToCamelCase(StringPiece input) {
- bool capitalize_next = false;
- bool was_cap = true;
- bool is_cap = false;
- bool first_word = true;
- TProtoStringType result;
- result.reserve(input.size());
-
- for (size_t i = 0; i < input.size(); ++i, was_cap = is_cap) {
- is_cap = ascii_isupper(input[i]);
- if (input[i] == '_') {
- capitalize_next = true;
- if (!result.empty()) first_word = false;
- continue;
- } else if (first_word) {
- // Consider when the current character B is capitalized,
- // first word ends when:
- // 1) following a lowercase: "...aB..."
- // 2) followed by a lowercase: "...ABc..."
- if (!result.empty() && is_cap &&
- (!was_cap ||
- (i + 1 < input.size() && ascii_islower(input[i + 1])))) {
- first_word = false;
- result.push_back(input[i]);
- } else {
- result.push_back(ascii_tolower(input[i]));
- continue;
- }
- } else if (capitalize_next) {
- capitalize_next = false;
- if (ascii_islower(input[i])) {
- result.push_back(ascii_toupper(input[i]));
- continue;
- } else {
- result.push_back(input[i]);
- continue;
- }
- } else {
- result.push_back(ascii_tolower(input[i]));
- }
- }
- return result;
-}
-
-TProtoStringType ToSnakeCase(StringPiece input) {
- bool was_not_underscore = false; // Initialize to false for case 1 (below)
- bool was_not_cap = false;
- TProtoStringType result;
- result.reserve(input.size() << 1);
-
- for (size_t i = 0; i < input.size(); ++i) {
- if (ascii_isupper(input[i])) {
- // Consider when the current character B is capitalized:
- // 1) At beginning of input: "B..." => "b..."
- // (e.g. "Biscuit" => "biscuit")
- // 2) Following a lowercase: "...aB..." => "...a_b..."
- // (e.g. "gBike" => "g_bike")
- // 3) At the end of input: "...AB" => "...ab"
- // (e.g. "GoogleLAB" => "google_lab")
- // 4) Followed by a lowercase: "...ABc..." => "...a_bc..."
- // (e.g. "GBike" => "g_bike")
- if (was_not_underscore && // case 1 out
- (was_not_cap || // case 2 in, case 3 out
- (i + 1 < input.size() && // case 3 out
- ascii_islower(input[i + 1])))) { // case 4 in
- // We add an underscore for case 2 and case 4.
- result.push_back('_');
- }
- result.push_back(ascii_tolower(input[i]));
- was_not_underscore = true;
- was_not_cap = false;
- } else {
- result.push_back(input[i]);
- was_not_underscore = input[i] != '_';
- was_not_cap = true;
- }
- }
- return result;
-}
-
-std::set<TProtoStringType>* well_known_types_ = nullptr;
-PROTOBUF_NAMESPACE_ID::internal::once_flag well_known_types_init_;
-const char* well_known_types_name_array_[] = {
- "google.protobuf.Timestamp", "google.protobuf.Duration",
- "google.protobuf.DoubleValue", "google.protobuf.FloatValue",
- "google.protobuf.Int64Value", "google.protobuf.UInt64Value",
- "google.protobuf.Int32Value", "google.protobuf.UInt32Value",
- "google.protobuf.BoolValue", "google.protobuf.StringValue",
- "google.protobuf.BytesValue", "google.protobuf.FieldMask"};
-
-void DeleteWellKnownTypes() { delete well_known_types_; }
-
-void InitWellKnownTypes() {
- well_known_types_ = new std::set<TProtoStringType>;
- for (int i = 0; i < GOOGLE_ARRAYSIZE(well_known_types_name_array_); ++i) {
- well_known_types_->insert(well_known_types_name_array_[i]);
- }
- google::protobuf::internal::OnShutdown(&DeleteWellKnownTypes);
-}
-
-bool IsWellKnownType(const TProtoStringType& type_name) {
- PROTOBUF_NAMESPACE_ID::internal::call_once(well_known_types_init_,
- InitWellKnownTypes);
- return ContainsKey(*well_known_types_, type_name);
-}
-
-bool IsValidBoolString(StringPiece bool_string) {
- return bool_string == "true" || bool_string == "false" ||
- bool_string == "1" || bool_string == "0";
-}
-
-bool IsMap(const google::protobuf::Field& field,
- const google::protobuf::Type& type) {
- return field.cardinality() == google::protobuf::Field::CARDINALITY_REPEATED &&
- (GetBoolOptionOrDefault(type.options(), "map_entry", false) ||
- GetBoolOptionOrDefault(type.options(),
- "google.protobuf.MessageOptions.map_entry",
- false));
-}
-
-bool IsMessageSetWireFormat(const google::protobuf::Type& type) {
- return GetBoolOptionOrDefault(type.options(), "message_set_wire_format",
- false) ||
- GetBoolOptionOrDefault(
- type.options(),
- "google.protobuf.MessageOptions.message_set_wire_format", false);
-}
-
-TProtoStringType DoubleAsString(double value) {
- if (value == std::numeric_limits<double>::infinity()) return "Infinity";
- if (value == -std::numeric_limits<double>::infinity()) return "-Infinity";
- if (std::isnan(value)) return "NaN";
-
- return SimpleDtoa(value);
-}
-
-TProtoStringType FloatAsString(float value) {
- if (std::isfinite(value)) return SimpleFtoa(value);
- return DoubleAsString(value);
-}
-
-bool SafeStrToFloat(StringPiece str, float* value) {
- double double_value;
- if (!safe_strtod(str, &double_value)) {
- return false;
- }
-
- if (std::isinf(double_value) || std::isnan(double_value)) return false;
-
- // Fail if the value is not representable in float.
- if (double_value > std::numeric_limits<float>::max() ||
- double_value < -std::numeric_limits<float>::max()) {
- return false;
- }
-
- *value = static_cast<float>(double_value);
- return true;
-}
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/utility.h b/contrib/libs/protobuf/src/google/protobuf/util/internal/utility.h
deleted file mode 100644
index 40ae5ae5665..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/utility.h
+++ /dev/null
@@ -1,204 +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_UTIL_INTERNAL_UTILITY_H__
-#define GOOGLE_PROTOBUF_UTIL_INTERNAL_UTILITY_H__
-
-#include <cstdint>
-#include <memory>
-#include <string>
-#include <utility>
-
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/any.pb.h>
-#include <google/protobuf/type.pb.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/statusor.h>
-#include <google/protobuf/stubs/status.h>
-
-// Must be included last.
-#include <google/protobuf/port_def.inc>
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-// Size of "type.googleapis.com"
-static const arc_i64 kTypeUrlSize = 19;
-
-// Finds the tech option identified by option_name. Parses the boolean value and
-// returns it.
-// When the option with the given name is not found, default_value is returned.
-PROTOBUF_EXPORT bool GetBoolOptionOrDefault(
- const RepeatedPtrField<google::protobuf::Option>& options,
- StringPiece option_name, bool default_value);
-
-// Returns int64 option value. If the option isn't found, returns the
-// default_value.
-PROTOBUF_EXPORT arc_i64 GetInt64OptionOrDefault(
- const RepeatedPtrField<google::protobuf::Option>& options,
- StringPiece option_name, arc_i64 default_value);
-
-// Returns double option value. If the option isn't found, returns the
-// default_value.
-PROTOBUF_EXPORT double GetDoubleOptionOrDefault(
- const RepeatedPtrField<google::protobuf::Option>& options,
- StringPiece option_name, double default_value);
-
-// Returns string option value. If the option isn't found, returns the
-// default_value.
-PROTOBUF_EXPORT TProtoStringType GetStringOptionOrDefault(
- const RepeatedPtrField<google::protobuf::Option>& options,
- StringPiece option_name, StringPiece default_value);
-
-// Returns a boolean value contained in Any type.
-// TODO(skarvaje): Make these utilities dealing with Any types more generic,
-// add more error checking and move to a more public/shareable location so
-// others can use.
-PROTOBUF_EXPORT bool GetBoolFromAny(const google::protobuf::Any& any);
-
-// Returns int64 value contained in Any type.
-PROTOBUF_EXPORT arc_i64 GetInt64FromAny(const google::protobuf::Any& any);
-
-// Returns double value contained in Any type.
-PROTOBUF_EXPORT double GetDoubleFromAny(const google::protobuf::Any& any);
-
-// Returns string value contained in Any type.
-PROTOBUF_EXPORT TProtoStringType GetStringFromAny(const google::protobuf::Any& any);
-
-// Returns the type string without the url prefix. e.g.: If the passed type is
-// 'type.googleapis.com/tech.type.Bool', the returned value is 'tech.type.Bool'.
-PROTOBUF_EXPORT const StringPiece GetTypeWithoutUrl(
- StringPiece type_url);
-
-// Returns the simple_type with the base type url (kTypeServiceBaseUrl)
-// prefixed.
-//
-// E.g:
-// GetFullTypeWithUrl("google.protobuf.Timestamp") returns the string
-// "type.googleapis.com/google.protobuf.Timestamp".
-PROTOBUF_EXPORT const TProtoStringType GetFullTypeWithUrl(
- StringPiece simple_type);
-
-// Finds and returns option identified by name and option_name within the
-// provided map. Returns nullptr if none found.
-const google::protobuf::Option* FindOptionOrNull(
- const RepeatedPtrField<google::protobuf::Option>& options,
- StringPiece option_name);
-
-// Finds and returns the field identified by field_name in the passed tech Type
-// object. Returns nullptr if none found.
-const google::protobuf::Field* FindFieldInTypeOrNull(
- const google::protobuf::Type* type, StringPiece field_name);
-
-// Similar to FindFieldInTypeOrNull, but this looks up fields with given
-// json_name.
-const google::protobuf::Field* FindJsonFieldInTypeOrNull(
- const google::protobuf::Type* type, StringPiece json_name);
-
-// Similar to FindFieldInTypeOrNull, but this looks up fields by number.
-const google::protobuf::Field* FindFieldInTypeByNumberOrNull(
- const google::protobuf::Type* type, arc_i32 number);
-
-// Finds and returns the EnumValue identified by enum_name in the passed tech
-// Enum object. Returns nullptr if none found.
-const google::protobuf::EnumValue* FindEnumValueByNameOrNull(
- const google::protobuf::Enum* enum_type, StringPiece enum_name);
-
-// Finds and returns the EnumValue identified by value in the passed tech
-// Enum object. Returns nullptr if none found.
-const google::protobuf::EnumValue* FindEnumValueByNumberOrNull(
- const google::protobuf::Enum* enum_type, arc_i32 value);
-
-// Finds and returns the EnumValue identified by enum_name without underscore in
-// the passed tech Enum object. Returns nullptr if none found.
-// For Ex. if enum_name is ACTIONANDADVENTURE it can get accepted if
-// EnumValue's name is action_and_adventure or ACTION_AND_ADVENTURE.
-const google::protobuf::EnumValue* FindEnumValueByNameWithoutUnderscoreOrNull(
- const google::protobuf::Enum* enum_type, StringPiece enum_name);
-
-// Converts input to camel-case and returns it.
-PROTOBUF_EXPORT TProtoStringType ToCamelCase(const StringPiece input);
-
-// Converts enum name string to camel-case and returns it.
-TProtoStringType EnumValueNameToLowerCamelCase(const StringPiece input);
-
-// Converts input to snake_case and returns it.
-PROTOBUF_EXPORT TProtoStringType ToSnakeCase(StringPiece input);
-
-// Returns true if type_name represents a well-known type.
-PROTOBUF_EXPORT bool IsWellKnownType(const TProtoStringType& type_name);
-
-// Returns true if 'bool_string' represents a valid boolean value. Only "true",
-// "false", "0" and "1" are allowed.
-PROTOBUF_EXPORT bool IsValidBoolString(StringPiece bool_string);
-
-// Returns true if "field" is a protobuf map field based on its type.
-PROTOBUF_EXPORT bool IsMap(const google::protobuf::Field& field,
- const google::protobuf::Type& type);
-
-// Returns true if the given type has special MessageSet wire format.
-bool IsMessageSetWireFormat(const google::protobuf::Type& type);
-
-// Infinity/NaN-aware conversion to string.
-PROTOBUF_EXPORT TProtoStringType DoubleAsString(double value);
-PROTOBUF_EXPORT TProtoStringType FloatAsString(float value);
-
-// Convert from int32, int64, uint32, uint64, double or float to string.
-template <typename T>
-TProtoStringType ValueAsString(T value) {
- return StrCat(value);
-}
-
-template <>
-inline TProtoStringType ValueAsString(float value) {
- return FloatAsString(value);
-}
-
-template <>
-inline TProtoStringType ValueAsString(double value) {
- return DoubleAsString(value);
-}
-
-// Converts a string to float. Unlike safe_strtof, conversion will fail if the
-// value fits into double but not float (e.g., DBL_MAX).
-PROTOBUF_EXPORT bool SafeStrToFloat(StringPiece str, float* value);
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#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
deleted file mode 100644
index 401adc94a76..00000000000
--- a/contrib/libs/protobuf/src/google/protobuf/util/json_util.cc
+++ /dev/null
@@ -1,284 +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/util/json_util.h>
-
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/once.h>
-#include <google/protobuf/stubs/status.h>
-#include <google/protobuf/stubs/bytestream.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/zero_copy_stream.h>
-#include <google/protobuf/util/internal/default_value_objectwriter.h>
-#include <google/protobuf/util/internal/error_listener.h>
-#include <google/protobuf/util/internal/json_objectwriter.h>
-#include <google/protobuf/util/internal/json_stream_parser.h>
-#include <google/protobuf/util/internal/protostream_objectsource.h>
-#include <google/protobuf/util/internal/protostream_objectwriter.h>
-#include <google/protobuf/util/type_resolver.h>
-#include <google/protobuf/util/type_resolver_util.h>
-#include <google/protobuf/stubs/status_macros.h>
-
-// clang-format off
-#include <google/protobuf/port_def.inc>
-// clang-format on
-
-namespace google {
-namespace protobuf {
-namespace util {
-
-namespace internal {
-ZeroCopyStreamByteSink::~ZeroCopyStreamByteSink() {
- if (buffer_size_ > 0) {
- stream_->BackUp(buffer_size_);
- }
-}
-
-void ZeroCopyStreamByteSink::Append(const char* bytes, size_t len) {
- while (true) {
- if (len <= buffer_size_) { // NOLINT
- memcpy(buffer_, bytes, len);
- buffer_ = static_cast<char*>(buffer_) + len;
- buffer_size_ -= len;
- return;
- }
- if (buffer_size_ > 0) {
- memcpy(buffer_, bytes, buffer_size_);
- bytes += buffer_size_;
- len -= buffer_size_;
- }
- if (!stream_->Next(&buffer_, &buffer_size_)) {
- // There isn't a way for ByteSink to report errors.
- buffer_size_ = 0;
- return;
- }
- }
-}
-} // namespace internal
-
-util::Status BinaryToJsonStream(TypeResolver* resolver,
- const TProtoStringType& type_url,
- io::ZeroCopyInputStream* binary_input,
- io::ZeroCopyOutputStream* json_output,
- const JsonPrintOptions& options) {
- io::CodedInputStream in_stream(binary_input);
- google::protobuf::Type type;
- RETURN_IF_ERROR(resolver->ResolveMessageType(type_url, &type));
- converter::ProtoStreamObjectSource::RenderOptions render_options;
- render_options.use_ints_for_enums = options.always_print_enums_as_ints;
- render_options.preserve_proto_field_names =
- options.preserve_proto_field_names;
- converter::ProtoStreamObjectSource proto_source(&in_stream, resolver, type,
- render_options);
- io::CodedOutputStream out_stream(json_output);
- converter::JsonObjectWriter json_writer(options.add_whitespace ? " " : "",
- &out_stream);
- if (options.always_print_primitive_fields) {
- converter::DefaultValueObjectWriter default_value_writer(resolver, type,
- &json_writer);
- default_value_writer.set_preserve_proto_field_names(
- options.preserve_proto_field_names);
- default_value_writer.set_print_enums_as_ints(
- options.always_print_enums_as_ints);
- return proto_source.WriteTo(&default_value_writer);
- } else {
- return proto_source.WriteTo(&json_writer);
- }
-}
-
-util::Status BinaryToJsonString(TypeResolver* resolver,
- const TProtoStringType& type_url,
- const TProtoStringType& binary_input,
- TProtoStringType* json_output,
- const JsonPrintOptions& options) {
- io::ArrayInputStream input_stream(binary_input.data(), binary_input.size());
- io::StringOutputStream output_stream(json_output);
- return BinaryToJsonStream(resolver, type_url, &input_stream, &output_stream,
- options);
-}
-
-namespace {
-class StatusErrorListener : public converter::ErrorListener {
- public:
- StatusErrorListener() {}
- ~StatusErrorListener() override {}
-
- util::Status GetStatus() { return status_; }
-
- void InvalidName(const converter::LocationTrackerInterface& loc,
- StringPiece unknown_name,
- StringPiece message) override {
- TProtoStringType loc_string = GetLocString(loc);
- if (!loc_string.empty()) {
- loc_string.append(" ");
- }
- status_ = util::InvalidArgumentError(
- StrCat(loc_string, unknown_name, ": ", message));
- }
-
- void InvalidValue(const converter::LocationTrackerInterface& loc,
- StringPiece type_name,
- StringPiece value) override {
- status_ = util::InvalidArgumentError(
- StrCat(GetLocString(loc), ": invalid value ", TProtoStringType(value),
- " for type ", TProtoStringType(type_name)));
- }
-
- void MissingField(const converter::LocationTrackerInterface& loc,
- StringPiece missing_name) override {
- status_ = util::InvalidArgumentError(StrCat(
- GetLocString(loc), ": missing field ", TProtoStringType(missing_name)));
- }
-
- private:
- util::Status status_;
-
- TProtoStringType GetLocString(const converter::LocationTrackerInterface& loc) {
- TProtoStringType loc_string = loc.ToString();
- StripWhitespace(&loc_string);
- if (!loc_string.empty()) {
- loc_string = StrCat("(", loc_string, ")");
- }
- return loc_string;
- }
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StatusErrorListener);
-};
-} // namespace
-
-util::Status JsonToBinaryStream(TypeResolver* resolver,
- const TProtoStringType& type_url,
- io::ZeroCopyInputStream* json_input,
- io::ZeroCopyOutputStream* binary_output,
- const JsonParseOptions& options) {
- google::protobuf::Type type;
- RETURN_IF_ERROR(resolver->ResolveMessageType(type_url, &type));
- internal::ZeroCopyStreamByteSink sink(binary_output);
- StatusErrorListener listener;
- converter::ProtoStreamObjectWriter::Options proto_writer_options;
- proto_writer_options.ignore_unknown_fields = options.ignore_unknown_fields;
- proto_writer_options.ignore_unknown_enum_values =
- options.ignore_unknown_fields;
- proto_writer_options.case_insensitive_enum_parsing =
- options.case_insensitive_enum_parsing;
- converter::ProtoStreamObjectWriter proto_writer(
- resolver, type, &sink, &listener, proto_writer_options);
-
- converter::JsonStreamParser parser(&proto_writer);
- const void* buffer;
- int length;
- while (json_input->Next(&buffer, &length)) {
- if (length == 0) continue;
- RETURN_IF_ERROR(parser.Parse(
- StringPiece(static_cast<const char*>(buffer), length)));
- }
- RETURN_IF_ERROR(parser.FinishParse());
-
- return listener.GetStatus();
-}
-
-util::Status JsonToBinaryString(TypeResolver* resolver,
- const TProtoStringType& type_url,
- StringPiece json_input,
- TProtoStringType* binary_output,
- const JsonParseOptions& options) {
- io::ArrayInputStream input_stream(json_input.data(), json_input.size());
- io::StringOutputStream output_stream(binary_output);
- return JsonToBinaryStream(resolver, type_url, &input_stream, &output_stream,
- options);
-}
-
-namespace {
-const char* kTypeUrlPrefix = "type.googleapis.com";
-TypeResolver* generated_type_resolver_ = nullptr;
-PROTOBUF_NAMESPACE_ID::internal::once_flag generated_type_resolver_init_;
-
-TProtoStringType GetTypeUrl(const Message& message) {
- return TProtoStringType(kTypeUrlPrefix) + "/" +
- message.GetDescriptor()->full_name();
-}
-
-void DeleteGeneratedTypeResolver() { // NOLINT
- delete generated_type_resolver_;
-}
-
-void InitGeneratedTypeResolver() {
- generated_type_resolver_ = NewTypeResolverForDescriptorPool(
- kTypeUrlPrefix, DescriptorPool::generated_pool());
- ::google::protobuf::internal::OnShutdown(&DeleteGeneratedTypeResolver);
-}
-
-TypeResolver* GetGeneratedTypeResolver() {
- PROTOBUF_NAMESPACE_ID::internal::call_once(generated_type_resolver_init_,
- InitGeneratedTypeResolver);
- return generated_type_resolver_;
-}
-} // namespace
-
-util::Status MessageToJsonString(const Message& message, TProtoStringType* output,
- const JsonOptions& options) {
- const DescriptorPool* pool = message.GetDescriptor()->file()->pool();
- TypeResolver* resolver =
- pool == DescriptorPool::generated_pool()
- ? GetGeneratedTypeResolver()
- : NewTypeResolverForDescriptorPool(kTypeUrlPrefix, pool);
- util::Status result =
- BinaryToJsonString(resolver, GetTypeUrl(message),
- message.SerializeAsString(), output, options);
- if (pool != DescriptorPool::generated_pool()) {
- delete resolver;
- }
- return result;
-}
-
-util::Status JsonStringToMessage(StringPiece input, Message* message,
- const JsonParseOptions& options) {
- const DescriptorPool* pool = message->GetDescriptor()->file()->pool();
- TypeResolver* resolver =
- pool == DescriptorPool::generated_pool()
- ? GetGeneratedTypeResolver()
- : NewTypeResolverForDescriptorPool(kTypeUrlPrefix, pool);
- TProtoStringType binary;
- util::Status result = JsonToBinaryString(resolver, GetTypeUrl(*message),
- input, &binary, options);
- if (result.ok() && !message->ParseFromString(binary)) {
- result = util::InvalidArgumentError(
- "JSON transcoder produced invalid protobuf output.");
- }
- if (pool != DescriptorPool::generated_pool()) {
- delete resolver;
- }
- return result;
-}
-
-} // namespace util
-} // namespace protobuf
-} // namespace google
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 d4085d04cf9..6d54fd92f79 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/json_util.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/json_util.h
@@ -1,204 +1,2 @@
-// 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.
-
-// Utility functions to convert between protobuf binary format and proto3 JSON
-// format.
-#ifndef GOOGLE_PROTOBUF_UTIL_JSON_UTIL_H__
-#define GOOGLE_PROTOBUF_UTIL_JSON_UTIL_H__
-
-#include <google/protobuf/stubs/bytestream.h>
-#include <google/protobuf/stubs/status.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/util/type_resolver.h>
-
-// Must be included last.
-#include <google/protobuf/port_def.inc>
-
-namespace google {
-namespace protobuf {
-namespace io {
-class ZeroCopyInputStream;
-class ZeroCopyOutputStream;
-} // namespace io
-namespace util {
-
-struct JsonParseOptions {
- // Whether to ignore unknown JSON fields during parsing
- bool ignore_unknown_fields;
-
- // If true, when a lowercase enum value fails to parse, try convert it to
- // UPPER_CASE and see if it matches a valid enum.
- // WARNING: This option exists only to preserve legacy behavior. Avoid using
- // this option. If your enum needs to support different casing, consider using
- // allow_alias instead.
- bool case_insensitive_enum_parsing;
-
- JsonParseOptions()
- : ignore_unknown_fields(false), case_insensitive_enum_parsing(false) {}
-};
-
-struct JsonPrintOptions {
- // Whether to add spaces, line breaks and indentation to make the JSON output
- // easy to read.
- bool add_whitespace;
- // Whether to always print primitive fields. By default proto3 primitive
- // fields with default values will be omitted in JSON output. For example, an
- // int32 field set to 0 will be omitted. Set this flag to true will override
- // the default behavior and print primitive fields regardless of their values.
- bool always_print_primitive_fields;
- // Whether to always print enums as ints. By default they are rendered as
- // strings.
- bool always_print_enums_as_ints;
- // Whether to preserve proto field names
- bool preserve_proto_field_names;
-
- JsonPrintOptions()
- : add_whitespace(false),
- always_print_primitive_fields(false),
- always_print_enums_as_ints(false),
- preserve_proto_field_names(false) {}
-};
-
-// DEPRECATED. Use JsonPrintOptions instead.
-typedef JsonPrintOptions JsonOptions;
-
-// Converts from protobuf message to JSON and appends it to |output|. This is a
-// simple wrapper of BinaryToJsonString(). It will use the DescriptorPool of the
-// passed-in message to resolve Any types.
-PROTOBUF_EXPORT util::Status MessageToJsonString(const Message& message,
- TProtoStringType* output,
- const JsonOptions& options);
-
-inline util::Status MessageToJsonString(const Message& message,
- TProtoStringType* output) {
- return MessageToJsonString(message, output, JsonOptions());
-}
-
-// Converts from JSON to protobuf message. This is a simple wrapper of
-// JsonStringToBinary(). It will use the DescriptorPool of the passed-in
-// message to resolve Any types.
-PROTOBUF_EXPORT util::Status JsonStringToMessage(
- StringPiece input, Message* message, const JsonParseOptions& options);
-
-inline util::Status JsonStringToMessage(StringPiece input,
- Message* message) {
- return JsonStringToMessage(input, message, JsonParseOptions());
-}
-
-// Converts protobuf binary data to JSON.
-// The conversion will fail if:
-// 1. TypeResolver fails to resolve a type.
-// 2. input is not valid protobuf wire format, or conflicts with the type
-// information returned by TypeResolver.
-// Note that unknown fields will be discarded silently.
-PROTOBUF_EXPORT util::Status BinaryToJsonStream(
- TypeResolver* resolver, const TProtoStringType& type_url,
- io::ZeroCopyInputStream* binary_input,
- io::ZeroCopyOutputStream* json_output, const JsonPrintOptions& options);
-
-inline util::Status BinaryToJsonStream(TypeResolver* resolver,
- const TProtoStringType& type_url,
- io::ZeroCopyInputStream* binary_input,
- io::ZeroCopyOutputStream* json_output) {
- return BinaryToJsonStream(resolver, type_url, binary_input, json_output,
- JsonPrintOptions());
-}
-
-PROTOBUF_EXPORT util::Status BinaryToJsonString(
- TypeResolver* resolver, const TProtoStringType& type_url,
- const TProtoStringType& binary_input, TProtoStringType* json_output,
- const JsonPrintOptions& options);
-
-inline util::Status BinaryToJsonString(TypeResolver* resolver,
- const TProtoStringType& type_url,
- const TProtoStringType& binary_input,
- TProtoStringType* json_output) {
- return BinaryToJsonString(resolver, type_url, binary_input, json_output,
- JsonPrintOptions());
-}
-
-// Converts JSON data to protobuf binary format.
-// The conversion will fail if:
-// 1. TypeResolver fails to resolve a type.
-// 2. input is not valid JSON format, or conflicts with the type
-// information returned by TypeResolver.
-PROTOBUF_EXPORT util::Status JsonToBinaryStream(
- TypeResolver* resolver, const TProtoStringType& type_url,
- io::ZeroCopyInputStream* json_input,
- io::ZeroCopyOutputStream* binary_output, const JsonParseOptions& options);
-
-inline util::Status JsonToBinaryStream(
- TypeResolver* resolver, const TProtoStringType& type_url,
- io::ZeroCopyInputStream* json_input,
- io::ZeroCopyOutputStream* binary_output) {
- return JsonToBinaryStream(resolver, type_url, json_input, binary_output,
- JsonParseOptions());
-}
-
-PROTOBUF_EXPORT util::Status JsonToBinaryString(
- TypeResolver* resolver, const TProtoStringType& type_url,
- StringPiece json_input, TProtoStringType* binary_output,
- const JsonParseOptions& options);
-
-inline util::Status JsonToBinaryString(TypeResolver* resolver,
- const TProtoStringType& type_url,
- StringPiece json_input,
- TProtoStringType* binary_output) {
- return JsonToBinaryString(resolver, type_url, json_input, binary_output,
- JsonParseOptions());
-}
-
-namespace internal {
-// Internal helper class. Put in the header so we can write unit-tests for it.
-class PROTOBUF_EXPORT ZeroCopyStreamByteSink : public strings::ByteSink {
- public:
- explicit ZeroCopyStreamByteSink(io::ZeroCopyOutputStream* stream)
- : stream_(stream), buffer_(nullptr), buffer_size_(0) {}
- ~ZeroCopyStreamByteSink() override;
-
- void Append(const char* bytes, size_t len) override;
-
- private:
- io::ZeroCopyOutputStream* stream_;
- void* buffer_;
- int buffer_size_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ZeroCopyStreamByteSink);
-};
-} // namespace internal
-
-} // namespace util
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#endif // GOOGLE_PROTOBUF_UTIL_JSON_UTIL_H__
+#define USE_DEPRECATED_NAMESPACE 1
+#include "google/protobuf/json/json.h" \ No newline at end of file
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 b3ec430a2a2..eab2d753d27 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/message_differencer.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/util/message_differencer.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/util/message_differencer.h>
+#include "google/protobuf/util/message_differencer.h"
#include <algorithm>
#include <cstddef>
@@ -42,24 +42,28 @@
#include <memory>
#include <utility>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/zero_copy_stream.h>
-#include <google/protobuf/io/zero_copy_stream_impl.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/dynamic_message.h>
-#include <google/protobuf/generated_enum_reflection.h>
-#include <google/protobuf/map_field.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/text_format.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/stringprintf.h>
-#include <google/protobuf/util/field_comparator.h>
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/dynamic_message.h"
+#include "google/protobuf/generated_enum_reflection.h"
+#include "google/protobuf/map_field.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/text_format.h"
+#include "y_absl/container/fixed_array.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/escaping.h"
+#include "y_absl/strings/match.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+#include "google/protobuf/io/printer.h"
+#include "google/protobuf/io/zero_copy_stream.h"
+#include "google/protobuf/io/zero_copy_stream_impl.h"
+#include "google/protobuf/util/field_comparator.h"
// Always include as last one, otherwise it can break compilation
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -140,9 +144,9 @@ class MessageDifferencer::MultipleFieldsMapKeyComparator
const std::vector<std::vector<const FieldDescriptor*> >& key_field_paths)
: message_differencer_(message_differencer),
key_field_paths_(key_field_paths) {
- GOOGLE_CHECK(!key_field_paths_.empty());
+ Y_ABSL_CHECK(!key_field_paths_.empty());
for (const auto& path : key_field_paths_) {
- GOOGLE_CHECK(!path.empty());
+ Y_ABSL_CHECK(!path.empty());
}
}
MultipleFieldsMapKeyComparator(MessageDifferencer* message_differencer,
@@ -152,10 +156,16 @@ class MessageDifferencer::MultipleFieldsMapKeyComparator
key_field_path.push_back(key);
key_field_paths_.push_back(key_field_path);
}
+ MultipleFieldsMapKeyComparator(const MultipleFieldsMapKeyComparator&) =
+ delete;
+ MultipleFieldsMapKeyComparator& operator=(
+ const MultipleFieldsMapKeyComparator&) = delete;
bool IsMatch(const Message& message1, const Message& message2,
+ int unpacked_any,
const std::vector<SpecificField>& parent_fields) const override {
for (const auto& path : key_field_paths_) {
- if (!IsMatchInternal(message1, message2, parent_fields, path, 0)) {
+ if (!IsMatchInternal(message1, message2, unpacked_any, parent_fields,
+ path, 0)) {
return false;
}
}
@@ -164,7 +174,7 @@ class MessageDifferencer::MultipleFieldsMapKeyComparator
private:
bool IsMatchInternal(
- const Message& message1, const Message& message2,
+ const Message& message1, const Message& message2, int unpacked_any,
const std::vector<SpecificField>& parent_fields,
const std::vector<const FieldDescriptor*>& key_field_path,
int path_index) const {
@@ -172,14 +182,15 @@ class MessageDifferencer::MultipleFieldsMapKeyComparator
std::vector<SpecificField> current_parent_fields(parent_fields);
if (path_index == static_cast<arc_i64>(key_field_path.size() - 1)) {
if (field->is_map()) {
- return message_differencer_->CompareMapField(message1, message2, field,
- &current_parent_fields);
+ return message_differencer_->CompareMapField(
+ message1, message2, unpacked_any, field, &current_parent_fields);
} else if (field->is_repeated()) {
return message_differencer_->CompareRepeatedField(
- message1, message2, field, &current_parent_fields);
+ message1, message2, unpacked_any, field, &current_parent_fields);
} else {
return message_differencer_->CompareFieldValueUsingParentFields(
- message1, message2, field, -1, -1, &current_parent_fields);
+ message1, message2, unpacked_any, field, -1, -1,
+ &current_parent_fields);
}
} else {
const Reflection* reflection1 = message1.GetReflection();
@@ -193,17 +204,19 @@ class MessageDifferencer::MultipleFieldsMapKeyComparator
return false;
}
SpecificField specific_field;
+ specific_field.message1 = &message1;
+ specific_field.message2 = &message2;
+ specific_field.unpacked_any = unpacked_any;
specific_field.field = field;
current_parent_fields.push_back(specific_field);
return IsMatchInternal(reflection1->GetMessage(message1, field),
reflection2->GetMessage(message2, field),
- current_parent_fields, key_field_path,
- path_index + 1);
+ false /*key is never Any*/, current_parent_fields,
+ key_field_path, path_index + 1);
}
}
MessageDifferencer* message_differencer_;
std::vector<std::vector<const FieldDescriptor*> > key_field_paths_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MultipleFieldsMapKeyComparator);
};
// Preserve the order when treating repeated field as SMART_LIST. The current
@@ -254,7 +267,7 @@ MessageDifferencer::MapEntryKeyComparator::MapEntryKeyComparator(
: message_differencer_(message_differencer) {}
bool MessageDifferencer::MapEntryKeyComparator::IsMatch(
- const Message& message1, const Message& message2,
+ const Message& message1, const Message& message2, int unpacked_any,
const std::vector<SpecificField>& parent_fields) const {
// Map entry has its key in the field with tag 1. See the comment for
// map_entry in MessageOptions.
@@ -268,11 +281,11 @@ bool MessageDifferencer::MapEntryKeyComparator::IsMatch(
std::vector<SpecificField> current_parent_fields(parent_fields);
if (treat_as_set) {
- return message_differencer_->Compare(message1, message2,
+ return message_differencer_->Compare(message1, message2, unpacked_any,
&current_parent_fields);
}
return message_differencer_->CompareFieldValueUsingParentFields(
- message1, message2, key, -1, -1, &current_parent_fields);
+ message1, message2, unpacked_any, key, -1, -1, &current_parent_fields);
}
bool MessageDifferencer::Equals(const Message& message1,
@@ -326,25 +339,20 @@ MessageDifferencer::~MessageDifferencer() {
for (MapKeyComparator* comparator : owned_key_comparators_) {
delete comparator;
}
- for (IgnoreCriteria* criteria : ignore_criteria_) {
- delete criteria;
- }
}
void MessageDifferencer::set_field_comparator(FieldComparator* comparator) {
- GOOGLE_CHECK(comparator) << "Field comparator can't be NULL.";
+ Y_ABSL_CHECK(comparator) << "Field comparator can't be NULL.";
field_comparator_kind_ = kFCBase;
field_comparator_.base = comparator;
}
-#ifdef PROTOBUF_FUTURE_BREAKING_CHANGES
void MessageDifferencer::set_field_comparator(
DefaultFieldComparator* comparator) {
- GOOGLE_CHECK(comparator) << "Field comparator can't be NULL.";
+ Y_ABSL_CHECK(comparator) << "Field comparator can't be NULL.";
field_comparator_kind_ = kFCDefault;
field_comparator_.default_impl = comparator;
}
-#endif // PROTOBUF_FUTURE_BREAKING_CHANGES
void MessageDifferencer::set_message_field_comparison(
MessageFieldComparison comparison) {
@@ -379,10 +387,10 @@ MessageDifferencer::repeated_field_comparison() const {
void MessageDifferencer::CheckRepeatedFieldComparisons(
const FieldDescriptor* field,
const RepeatedFieldComparison& new_comparison) {
- GOOGLE_CHECK(field->is_repeated())
+ Y_ABSL_CHECK(field->is_repeated())
<< "Field must be repeated: " << field->full_name();
const MapKeyComparator* key_comparator = GetMapKeyComparator(field);
- GOOGLE_CHECK(key_comparator == NULL)
+ Y_ABSL_CHECK(key_comparator == NULL)
<< "Cannot treat this repeated field as both MAP and " << new_comparison
<< " for comparison. Field name is: " << field->full_name();
}
@@ -414,14 +422,14 @@ void MessageDifferencer::TreatAsSmartList(const FieldDescriptor* field) {
void MessageDifferencer::TreatAsMap(const FieldDescriptor* field,
const FieldDescriptor* key) {
- GOOGLE_CHECK_EQ(FieldDescriptor::CPPTYPE_MESSAGE, field->cpp_type())
+ Y_ABSL_CHECK_EQ(FieldDescriptor::CPPTYPE_MESSAGE, field->cpp_type())
<< "Field has to be message type. Field name is: " << field->full_name();
- GOOGLE_CHECK(key->containing_type() == field->message_type())
+ Y_ABSL_CHECK(key->containing_type() == field->message_type())
<< key->full_name()
<< " must be a direct subfield within the repeated field "
<< field->full_name() << ", not " << key->containing_type()->full_name();
- GOOGLE_CHECK(repeated_field_comparisons_.find(field) ==
- repeated_field_comparisons_.end())
+ Y_ABSL_CHECK(repeated_field_comparisons_.find(field) ==
+ repeated_field_comparisons_.end())
<< "Cannot treat the same field as both "
<< repeated_field_comparisons_[field]
<< " and MAP. Field name is: " << field->full_name();
@@ -446,29 +454,30 @@ void MessageDifferencer::TreatAsMapWithMultipleFieldsAsKey(
void MessageDifferencer::TreatAsMapWithMultipleFieldPathsAsKey(
const FieldDescriptor* field,
const std::vector<std::vector<const FieldDescriptor*> >& key_field_paths) {
- GOOGLE_CHECK(field->is_repeated())
+ Y_ABSL_CHECK(field->is_repeated())
<< "Field must be repeated: " << field->full_name();
- GOOGLE_CHECK_EQ(FieldDescriptor::CPPTYPE_MESSAGE, field->cpp_type())
+ Y_ABSL_CHECK_EQ(FieldDescriptor::CPPTYPE_MESSAGE, field->cpp_type())
<< "Field has to be message type. Field name is: " << field->full_name();
for (const auto& key_field_path : key_field_paths) {
for (size_t j = 0; j < key_field_path.size(); ++j) {
const FieldDescriptor* parent_field =
j == 0 ? field : key_field_path[j - 1];
const FieldDescriptor* child_field = key_field_path[j];
- GOOGLE_CHECK(child_field->containing_type() == parent_field->message_type())
+ Y_ABSL_CHECK(child_field->containing_type() == parent_field->message_type())
<< child_field->full_name()
<< " must be a direct subfield within the field: "
<< parent_field->full_name();
if (j != 0) {
- GOOGLE_CHECK_EQ(FieldDescriptor::CPPTYPE_MESSAGE, parent_field->cpp_type())
+ Y_ABSL_CHECK_EQ(FieldDescriptor::CPPTYPE_MESSAGE,
+ parent_field->cpp_type())
<< parent_field->full_name() << " has to be of type message.";
- GOOGLE_CHECK(!parent_field->is_repeated())
+ Y_ABSL_CHECK(!parent_field->is_repeated())
<< parent_field->full_name() << " cannot be a repeated field.";
}
}
}
- GOOGLE_CHECK(repeated_field_comparisons_.find(field) ==
- repeated_field_comparisons_.end())
+ Y_ABSL_CHECK(repeated_field_comparisons_.find(field) ==
+ repeated_field_comparisons_.end())
<< "Cannot treat the same field as both "
<< repeated_field_comparisons_[field]
<< " and MAP. Field name is: " << field->full_name();
@@ -480,18 +489,19 @@ void MessageDifferencer::TreatAsMapWithMultipleFieldPathsAsKey(
void MessageDifferencer::TreatAsMapUsingKeyComparator(
const FieldDescriptor* field, const MapKeyComparator* key_comparator) {
- GOOGLE_CHECK(field->is_repeated())
+ Y_ABSL_CHECK(field->is_repeated())
<< "Field must be repeated: " << field->full_name();
- GOOGLE_CHECK(repeated_field_comparisons_.find(field) ==
- repeated_field_comparisons_.end())
+ Y_ABSL_CHECK(repeated_field_comparisons_.find(field) ==
+ repeated_field_comparisons_.end())
<< "Cannot treat the same field as both "
<< repeated_field_comparisons_[field]
<< " and MAP. Field name is: " << field->full_name();
map_field_key_comparator_[field] = key_comparator;
}
-void MessageDifferencer::AddIgnoreCriteria(IgnoreCriteria* ignore_criteria) {
- ignore_criteria_.push_back(ignore_criteria);
+void MessageDifferencer::AddIgnoreCriteria(
+ std::unique_ptr<IgnoreCriteria> ignore_criteria) {
+ ignore_criteria_.push_back(std::move(ignore_criteria));
}
void MessageDifferencer::IgnoreField(const FieldDescriptor* field) {
@@ -504,7 +514,7 @@ void MessageDifferencer::SetFractionAndMargin(const FieldDescriptor* field,
}
void MessageDifferencer::ReportDifferencesToString(TProtoStringType* output) {
- GOOGLE_DCHECK(output) << "Specified output string was NULL";
+ Y_ABSL_DCHECK(output) << "Specified output string was NULL";
output_string_ = output;
output_string_->clear();
@@ -547,10 +557,10 @@ bool MessageDifferencer::Compare(const Message& message1,
StreamReporter reporter(&output_stream);
reporter.SetMessages(message1, message2);
reporter_ = &reporter;
- result = Compare(message1, message2, &parent_fields);
+ result = Compare(message1, message2, false, &parent_fields);
reporter_ = NULL;
} else {
- result = Compare(message1, message2, &parent_fields);
+ result = Compare(message1, message2, false, &parent_fields);
}
return result;
}
@@ -560,8 +570,8 @@ bool MessageDifferencer::CompareWithFields(
const std::vector<const FieldDescriptor*>& message1_fields_arg,
const std::vector<const FieldDescriptor*>& message2_fields_arg) {
if (message1.GetDescriptor() != message2.GetDescriptor()) {
- GOOGLE_LOG(DFATAL) << "Comparison between two messages with different "
- << "descriptors.";
+ Y_ABSL_DLOG(FATAL) << "Comparison between two messages with different "
+ << "descriptors.";
return false;
}
@@ -590,25 +600,27 @@ bool MessageDifferencer::CompareWithFields(
StreamReporter reporter(&output_stream);
reporter_ = &reporter;
result = CompareRequestedFieldsUsingSettings(
- message1, message2, message1_fields, message2_fields, &parent_fields);
+ message1, message2, false, message1_fields, message2_fields,
+ &parent_fields);
reporter_ = NULL;
} else {
result = CompareRequestedFieldsUsingSettings(
- message1, message2, message1_fields, message2_fields, &parent_fields);
+ message1, message2, false, message1_fields, message2_fields,
+ &parent_fields);
}
return result;
}
bool MessageDifferencer::Compare(const Message& message1,
- const Message& message2,
+ const Message& message2, int unpacked_any,
std::vector<SpecificField>* parent_fields) {
const Descriptor* descriptor1 = message1.GetDescriptor();
const Descriptor* descriptor2 = message2.GetDescriptor();
if (descriptor1 != descriptor2) {
- GOOGLE_LOG(DFATAL) << "Comparison between two messages with different "
- << "descriptors. " << descriptor1->full_name() << " vs "
- << descriptor2->full_name();
+ Y_ABSL_DLOG(FATAL) << "Comparison between two messages with different "
+ << "descriptors. " << descriptor1->full_name() << " vs "
+ << descriptor2->full_name();
return false;
}
@@ -622,15 +634,15 @@ bool MessageDifferencer::Compare(const Message& message1,
if (data1->GetDescriptor() != data2->GetDescriptor()) {
return false;
}
- return Compare(*data1, *data2, parent_fields);
+ return Compare(*data1, *data2, unpacked_any + 1, parent_fields);
}
}
- const Reflection* reflection1 = message1.GetReflection();
- const Reflection* reflection2 = message2.GetReflection();
bool unknown_compare_result = true;
// Ignore unknown fields in EQUIVALENT mode
if (message_field_comparison_ != EQUIVALENT) {
+ const Reflection* reflection1 = message1.GetReflection();
+ const Reflection* reflection2 = message2.GetReflection();
const UnknownFieldSet& unknown_field_set1 =
reflection1->GetUnknownFields(message1);
const UnknownFieldSet& unknown_field_set2 =
@@ -647,7 +659,7 @@ bool MessageDifferencer::Compare(const Message& message1,
FieldDescriptorArray message1_fields = RetrieveFields(message1, true);
FieldDescriptorArray message2_fields = RetrieveFields(message2, false);
- return CompareRequestedFieldsUsingSettings(message1, message2,
+ return CompareRequestedFieldsUsingSettings(message1, message2, unpacked_any,
message1_fields, message2_fields,
parent_fields) &&
unknown_compare_result;
@@ -685,7 +697,7 @@ FieldDescriptorArray MessageDifferencer::RetrieveFields(const Message& message,
}
bool MessageDifferencer::CompareRequestedFieldsUsingSettings(
- const Message& message1, const Message& message2,
+ const Message& message1, const Message& message2, int unpacked_any,
const FieldDescriptorArray& message1_fields,
const FieldDescriptorArray& message2_fields,
std::vector<SpecificField>* parent_fields) {
@@ -696,20 +708,23 @@ bool MessageDifferencer::CompareRequestedFieldsUsingSettings(
// rather than the addition or deletion of fields).
FieldDescriptorArray fields_union =
CombineFields(message1_fields, FULL, message2_fields, FULL);
- return CompareWithFieldsInternal(message1, message2, fields_union,
- fields_union, parent_fields);
+ return CompareWithFieldsInternal(message1, message2, unpacked_any,
+ fields_union, fields_union,
+ parent_fields);
} else {
// Simple equality comparison, use the unaltered field lists.
- return CompareWithFieldsInternal(message1, message2, message1_fields,
- message2_fields, parent_fields);
+ return CompareWithFieldsInternal(message1, message2, unpacked_any,
+ message1_fields, message2_fields,
+ parent_fields);
}
} else {
if (message_field_comparison_ == EQUIVALENT) {
// We use the list of fields for message1 for both messages when
// comparing. This way, extra fields in message2 are ignored,
// and missing fields in message2 use their default value.
- return CompareWithFieldsInternal(message1, message2, message1_fields,
- message1_fields, parent_fields);
+ return CompareWithFieldsInternal(message1, message2, unpacked_any,
+ message1_fields, message1_fields,
+ parent_fields);
} else {
// We need to consider the full list of fields for message1
// but only the intersection for message2. This way, any fields
@@ -717,8 +732,9 @@ bool MessageDifferencer::CompareRequestedFieldsUsingSettings(
// present in message1 will be marked as a difference.
FieldDescriptorArray fields_intersection =
CombineFields(message1_fields, PARTIAL, message2_fields, PARTIAL);
- return CompareWithFieldsInternal(message1, message2, message1_fields,
- fields_intersection, parent_fields);
+ return CompareWithFieldsInternal(message1, message2, unpacked_any,
+ message1_fields, fields_intersection,
+ parent_fields);
}
}
}
@@ -761,7 +777,7 @@ FieldDescriptorArray MessageDifferencer::CombineFields(
}
bool MessageDifferencer::CompareWithFieldsInternal(
- const Message& message1, const Message& message2,
+ const Message& message1, const Message& message2, int unpacked_any,
const FieldDescriptorArray& message1_fields,
const FieldDescriptorArray& message2_fields,
std::vector<SpecificField>* parent_fields) {
@@ -789,6 +805,9 @@ bool MessageDifferencer::CompareWithFieldsInternal(
// the next field in message1_fields.
if (reporter_ != NULL) {
SpecificField specific_field;
+ specific_field.message1 = &message1;
+ specific_field.message2 = &message2;
+ specific_field.unpacked_any = unpacked_any;
specific_field.field = field1;
parent_fields->push_back(specific_field);
if (report_ignores_) {
@@ -808,6 +827,9 @@ bool MessageDifferencer::CompareWithFieldsInternal(
for (int i = 0; i < count; ++i) {
SpecificField specific_field;
+ specific_field.message1 = &message1;
+ specific_field.message2 = &message2;
+ specific_field.unpacked_any = unpacked_any;
specific_field.field = field1;
if (field1->is_repeated()) {
AddSpecificIndex(&specific_field, message1, field1, i);
@@ -834,6 +856,9 @@ bool MessageDifferencer::CompareWithFieldsInternal(
// the next field in message2_fields.
if (reporter_ != NULL) {
SpecificField specific_field;
+ specific_field.message1 = &message1;
+ specific_field.message2 = &message2;
+ specific_field.unpacked_any = unpacked_any;
specific_field.field = field2;
parent_fields->push_back(specific_field);
if (report_ignores_) {
@@ -852,6 +877,9 @@ bool MessageDifferencer::CompareWithFieldsInternal(
for (int i = 0; i < count; ++i) {
SpecificField specific_field;
+ specific_field.message1 = &message1,
+ specific_field.message2 = &message2;
+ specific_field.unpacked_any = unpacked_any;
specific_field.field = field2;
if (field2->is_repeated()) {
specific_field.index = i;
@@ -881,6 +909,9 @@ bool MessageDifferencer::CompareWithFieldsInternal(
// Ignore this field. Report and move on.
if (reporter_ != NULL) {
SpecificField specific_field;
+ specific_field.message1 = &message1;
+ specific_field.message2 = &message2;
+ specific_field.unpacked_any = unpacked_any;
specific_field.field = field1;
parent_fields->push_back(specific_field);
if (report_ignores_) {
@@ -897,17 +928,20 @@ bool MessageDifferencer::CompareWithFieldsInternal(
bool fieldDifferent = false;
assert(field1 != NULL);
if (field1->is_map()) {
- fieldDifferent =
- !CompareMapField(message1, message2, field1, parent_fields);
+ fieldDifferent = !CompareMapField(message1, message2, unpacked_any,
+ field1, parent_fields);
} else if (field1->is_repeated()) {
- fieldDifferent =
- !CompareRepeatedField(message1, message2, field1, parent_fields);
+ fieldDifferent = !CompareRepeatedField(message1, message2, unpacked_any,
+ field1, parent_fields);
} else {
fieldDifferent = !CompareFieldValueUsingParentFields(
- message1, message2, field1, -1, -1, parent_fields);
+ message1, message2, unpacked_any, field1, -1, -1, parent_fields);
if (reporter_ != nullptr) {
SpecificField specific_field;
+ specific_field.message1 = &message1;
+ specific_field.message2 = &message2;
+ specific_field.unpacked_any = unpacked_any;
specific_field.field = field1;
parent_fields->push_back(specific_field);
if (fieldDifferent) {
@@ -934,13 +968,14 @@ bool MessageDifferencer::CompareWithFieldsInternal(
bool MessageDifferencer::IsMatch(
const FieldDescriptor* repeated_field,
const MapKeyComparator* key_comparator, const Message* message1,
- const Message* message2, const std::vector<SpecificField>& parent_fields,
- Reporter* reporter, int index1, int index2) {
+ const Message* message2, int unpacked_any,
+ const std::vector<SpecificField>& parent_fields, Reporter* reporter,
+ int index1, int index2) {
std::vector<SpecificField> current_parent_fields(parent_fields);
if (repeated_field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) {
- return CompareFieldValueUsingParentFields(*message1, *message2,
- repeated_field, index1, index2,
- &current_parent_fields);
+ return CompareFieldValueUsingParentFields(
+ *message1, *message2, unpacked_any, repeated_field, index1, index2,
+ &current_parent_fields);
}
// Back up the Reporter and output_string_. They will be reset in the
// following code.
@@ -951,9 +986,9 @@ bool MessageDifferencer::IsMatch(
bool match;
if (key_comparator == NULL) {
- match = CompareFieldValueUsingParentFields(*message1, *message2,
- repeated_field, index1, index2,
- &current_parent_fields);
+ match = CompareFieldValueUsingParentFields(
+ *message1, *message2, unpacked_any, repeated_field, index1, index2,
+ &current_parent_fields);
} else {
const Reflection* reflection1 = message1->GetReflection();
const Reflection* reflection2 = message2->GetReflection();
@@ -962,6 +997,9 @@ bool MessageDifferencer::IsMatch(
const Message& m2 =
reflection2->GetRepeatedMessage(*message2, repeated_field, index2);
SpecificField specific_field;
+ specific_field.message1 = message1;
+ specific_field.message2 = message2;
+ specific_field.unpacked_any = unpacked_any;
specific_field.field = repeated_field;
if (repeated_field->is_map()) {
specific_field.map_entry1 = &m1;
@@ -970,7 +1008,7 @@ bool MessageDifferencer::IsMatch(
specific_field.index = index1;
specific_field.new_index = index2;
current_parent_fields.push_back(specific_field);
- match = key_comparator->IsMatch(m1, m2, current_parent_fields);
+ match = key_comparator->IsMatch(m1, m2, false, current_parent_fields);
}
reporter_ = backup_reporter;
@@ -979,14 +1017,14 @@ bool MessageDifferencer::IsMatch(
}
bool MessageDifferencer::CompareMapFieldByMapReflection(
- const Message& message1, const Message& message2,
+ const Message& message1, const Message& message2, int unpacked_any,
const FieldDescriptor* map_field, std::vector<SpecificField>* parent_fields,
DefaultFieldComparator* comparator) {
- GOOGLE_DCHECK_EQ(nullptr, reporter_);
- GOOGLE_DCHECK(map_field->is_map());
- GOOGLE_DCHECK(map_field_key_comparator_.find(map_field) ==
- map_field_key_comparator_.end());
- GOOGLE_DCHECK_EQ(repeated_field_comparison_, AS_LIST);
+ Y_ABSL_DCHECK_EQ(nullptr, reporter_);
+ Y_ABSL_DCHECK(map_field->is_map());
+ Y_ABSL_DCHECK(map_field_key_comparator_.find(map_field) ==
+ map_field_key_comparator_.end());
+ Y_ABSL_DCHECK_EQ(repeated_field_comparison_, AS_LIST);
const Reflection* reflection1 = message1.GetReflection();
const Reflection* reflection2 = message2.GetReflection();
const int count1 = reflection1->MapSize(message1, map_field);
@@ -1054,10 +1092,14 @@ bool MessageDifferencer::CompareMapFieldByMapReflection(
reflection2->LookupMapValue(message2, map_field, it.GetKey(), &value2);
// Append currently compared field to the end of parent_fields.
SpecificField specific_value_field;
+ specific_value_field.message1 = &message1;
+ specific_value_field.message2 = &message2;
+ specific_value_field.unpacked_any = unpacked_any;
specific_value_field.field = val_des;
parent_fields->push_back(specific_value_field);
- compare_result = Compare(it.GetValueRef().GetMessageValue(),
- value2.GetMessageValue(), parent_fields);
+ compare_result =
+ Compare(it.GetValueRef().GetMessageValue(),
+ value2.GetMessageValue(), false, parent_fields);
parent_fields->pop_back();
if (!compare_result) {
return false;
@@ -1070,10 +1112,10 @@ bool MessageDifferencer::CompareMapFieldByMapReflection(
}
bool MessageDifferencer::CompareMapField(
- const Message& message1, const Message& message2,
+ const Message& message1, const Message& message2, int unpacked_any,
const FieldDescriptor* repeated_field,
std::vector<SpecificField>* parent_fields) {
- GOOGLE_DCHECK(repeated_field->is_map());
+ Y_ABSL_DCHECK(repeated_field->is_map());
// the input FieldDescriptor is guaranteed to be repeated field.
const Reflection* reflection1 = message1.GetReflection();
@@ -1096,33 +1138,38 @@ bool MessageDifferencer::CompareMapField(
repeated_field->message_type()->map_value();
std::vector<SpecificField> current_parent_fields(*parent_fields);
SpecificField specific_field;
+ specific_field.message1 = &message1;
+ specific_field.message2 = &message2;
+ specific_field.unpacked_any = unpacked_any;
specific_field.field = repeated_field;
current_parent_fields.push_back(specific_field);
if (!IsIgnored(message1, message2, key_des, current_parent_fields) &&
!IsIgnored(message1, message2, val_des, current_parent_fields)) {
- return CompareMapFieldByMapReflection(message1, message2, repeated_field,
- &current_parent_fields,
- field_comparator_.default_impl);
+ return CompareMapFieldByMapReflection(
+ message1, message2, unpacked_any, repeated_field,
+ &current_parent_fields, field_comparator_.default_impl);
}
}
- return CompareRepeatedRep(message1, message2, repeated_field, parent_fields);
+ return CompareRepeatedRep(message1, message2, unpacked_any, repeated_field,
+ parent_fields);
}
bool MessageDifferencer::CompareRepeatedField(
- const Message& message1, const Message& message2,
+ const Message& message1, const Message& message2, int unpacked_any,
const FieldDescriptor* repeated_field,
std::vector<SpecificField>* parent_fields) {
- GOOGLE_DCHECK(!repeated_field->is_map());
- return CompareRepeatedRep(message1, message2, repeated_field, parent_fields);
+ Y_ABSL_DCHECK(!repeated_field->is_map());
+ return CompareRepeatedRep(message1, message2, unpacked_any, repeated_field,
+ parent_fields);
}
bool MessageDifferencer::CompareRepeatedRep(
- const Message& message1, const Message& message2,
+ const Message& message1, const Message& message2, int unpacked_any,
const FieldDescriptor* repeated_field,
std::vector<SpecificField>* parent_fields) {
// the input FieldDescriptor is guaranteed to be repeated field.
- GOOGLE_DCHECK(repeated_field->is_repeated());
+ Y_ABSL_DCHECK(repeated_field->is_repeated());
const Reflection* reflection1 = message1.GetReflection();
const Reflection* reflection2 = message2.GetReflection();
@@ -1157,9 +1204,9 @@ bool MessageDifferencer::CompareRepeatedRep(
// match_list2.
if (!simple_list) {
// Try to match indices of the repeated fields. Return false if match fails.
- if (!MatchRepeatedFieldIndices(message1, message2, repeated_field,
- key_comparator, *parent_fields, &match_list1,
- &match_list2) &&
+ if (!MatchRepeatedFieldIndices(
+ message1, message2, unpacked_any, repeated_field, key_comparator,
+ *parent_fields, &match_list1, &match_list2) &&
reporter_ == nullptr) {
return false;
}
@@ -1167,6 +1214,9 @@ bool MessageDifferencer::CompareRepeatedRep(
bool fieldDifferent = false;
SpecificField specific_field;
+ specific_field.message1 = &message1;
+ specific_field.message2 = &message2;
+ specific_field.unpacked_any = unpacked_any;
specific_field.field = repeated_field;
// At this point, we have already matched pairs of fields (with the reporting
@@ -1191,7 +1241,7 @@ bool MessageDifferencer::CompareRepeatedRep(
}
if (smart_list) {
for (int j = next_unmatched_index; j < match_list1[i]; ++j) {
- GOOGLE_CHECK_LE(0, j);
+ Y_ABSL_CHECK_LE(0, j);
if (reporter_ == nullptr) return false;
specific_field.index = j;
AddSpecificNewIndex(&specific_field, message2, repeated_field, j);
@@ -1213,8 +1263,8 @@ bool MessageDifferencer::CompareRepeatedRep(
}
const bool result = CompareFieldValueUsingParentFields(
- message1, message2, repeated_field, i, specific_field.new_index,
- parent_fields);
+ message1, message2, unpacked_any, repeated_field, i,
+ specific_field.new_index, parent_fields);
// If we have found differences, either report them or terminate if
// no reporter is present. Note that ReportModified, ReportMoved, and
@@ -1269,14 +1319,15 @@ bool MessageDifferencer::CompareRepeatedRep(
bool MessageDifferencer::CompareFieldValue(const Message& message1,
const Message& message2,
+ int unpacked_any,
const FieldDescriptor* field,
int index1, int index2) {
- return CompareFieldValueUsingParentFields(message1, message2, field, index1,
- index2, NULL);
+ return CompareFieldValueUsingParentFields(message1, message2, unpacked_any,
+ field, index1, index2, nullptr);
}
bool MessageDifferencer::CompareFieldValueUsingParentFields(
- const Message& message1, const Message& message2,
+ const Message& message1, const Message& message2, int unpacked_any,
const FieldDescriptor* field, int index1, int index2,
std::vector<SpecificField>* parent_fields) {
FieldContext field_context(parent_fields);
@@ -1302,11 +1353,14 @@ bool MessageDifferencer::CompareFieldValueUsingParentFields(
if (parent_fields != NULL) {
// Append currently compared field to the end of parent_fields.
SpecificField specific_field;
+ specific_field.message1 = &message1;
+ specific_field.message2 = &message2;
+ specific_field.unpacked_any = unpacked_any;
specific_field.field = field;
AddSpecificIndex(&specific_field, message1, field, index1);
AddSpecificNewIndex(&specific_field, message2, field, index2);
parent_fields->push_back(specific_field);
- const bool compare_result = Compare(m1, m2, parent_fields);
+ const bool compare_result = Compare(m1, m2, false, parent_fields);
parent_fields->pop_back();
return compare_result;
} else {
@@ -1371,7 +1425,7 @@ bool MessageDifferencer::IsIgnored(
if (ignored_fields_.find(field) != ignored_fields_.end()) {
return true;
}
- for (IgnoreCriteria* criteria : ignore_criteria_) {
+ for (const auto& criteria : ignore_criteria_) {
if (criteria->IsIgnored(message1, message2, field, parent_fields)) {
return true;
}
@@ -1383,7 +1437,7 @@ bool MessageDifferencer::IsUnknownFieldIgnored(
const Message& message1, const Message& message2,
const SpecificField& field,
const std::vector<SpecificField>& parent_fields) {
- for (IgnoreCriteria* criteria : ignore_criteria_) {
+ for (const auto& criteria : ignore_criteria_) {
if (criteria->IsUnknownFieldIgnored(message1, message2, field,
parent_fields)) {
return true;
@@ -1394,9 +1448,8 @@ bool MessageDifferencer::IsUnknownFieldIgnored(
const MessageDifferencer::MapKeyComparator*
MessageDifferencer ::GetMapKeyComparator(const FieldDescriptor* field) const {
- if (!field->is_repeated()) return NULL;
- FieldKeyComparatorMap::const_iterator it =
- map_field_key_comparator_.find(field);
+ if (!field->is_repeated()) return nullptr;
+ auto it = map_field_key_comparator_.find(field);
if (it != map_field_key_comparator_.end()) {
return it->second;
}
@@ -1405,7 +1458,7 @@ MessageDifferencer ::GetMapKeyComparator(const FieldDescriptor* field) const {
// TreatAsSet() call GetMapKeyComparator() and fail if it returns non-NULL.
return &map_entry_key_comparator_;
}
- return NULL;
+ return nullptr;
}
namespace {
@@ -1441,7 +1494,6 @@ bool MessageDifferencer::UnpackAnyField::UnpackAny(
any.GetDescriptor()->file()->pool()->FindMessageTypeByName(
full_type_name);
if (desc == NULL) {
- GOOGLE_LOG(INFO) << "Proto type '" << full_type_name << "' not found";
return false;
}
@@ -1451,7 +1503,7 @@ bool MessageDifferencer::UnpackAnyField::UnpackAny(
data->reset(dynamic_message_factory_->GetPrototype(desc)->New());
TProtoStringType serialized_value = reflection->GetString(any, value_field);
if (!(*data)->ParsePartialFromString(serialized_value)) {
- GOOGLE_DLOG(ERROR) << "Failed to parse value for " << full_type_name;
+ Y_ABSL_DLOG(ERROR) << "Failed to parse value for " << full_type_name;
return false;
}
return true;
@@ -1586,6 +1638,8 @@ bool MessageDifferencer::CompareUnknownFields(
// Build the SpecificField. This is slightly complicated.
SpecificField specific_field;
+ specific_field.message1 = &message1;
+ specific_field.message2 = &message2;
specific_field.unknown_field_number = focus_field->number();
specific_field.unknown_field_type = focus_field->type();
@@ -1688,6 +1742,8 @@ class MaximumMatcher {
// match_list1[i] == -1 means the node is not matched. Same with match_list2.
MaximumMatcher(int count1, int count2, NodeMatchCallback callback,
std::vector<int>* match_list1, std::vector<int>* match_list2);
+ MaximumMatcher(const MaximumMatcher&) = delete;
+ MaximumMatcher& operator=(const MaximumMatcher&) = delete;
// Find a maximum match and return the number of matched node pairs.
// If early_return is true, this method will return 0 immediately when it
// finds that not all nodes on the left side can be matched.
@@ -1705,10 +1761,9 @@ class MaximumMatcher {
int count1_;
int count2_;
NodeMatchCallback match_callback_;
- std::map<std::pair<int, int>, bool> cached_match_results_;
+ y_absl::flat_hash_map<std::pair<int, int>, bool> cached_match_results_;
std::vector<int>* match_list1_;
std::vector<int>* match_list2_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MaximumMatcher);
};
MaximumMatcher::MaximumMatcher(int count1, int count2,
@@ -1746,13 +1801,12 @@ int MaximumMatcher::FindMaximumMatch(bool early_return) {
bool MaximumMatcher::Match(int left, int right) {
std::pair<int, int> p(left, right);
- std::map<std::pair<int, int>, bool>::iterator it =
- cached_match_results_.find(p);
+ auto it = cached_match_results_.find(p);
if (it != cached_match_results_.end()) {
return it->second;
}
- cached_match_results_[p] = match_callback_(left, right);
- return cached_match_results_[p];
+ it = cached_match_results_.emplace_hint(it, p, match_callback_(left, right));
+ return it->second;
}
bool MaximumMatcher::FindArgumentPathDFS(int v, std::vector<bool>* visited) {
@@ -1788,7 +1842,7 @@ bool MaximumMatcher::FindArgumentPathDFS(int v, std::vector<bool>* visited) {
} // namespace
bool MessageDifferencer::MatchRepeatedFieldIndices(
- const Message& message1, const Message& message2,
+ const Message& message1, const Message& message2, int unpacked_any,
const FieldDescriptor* repeated_field,
const MapKeyComparator* key_comparator,
const std::vector<SpecificField>& parent_fields,
@@ -1822,7 +1876,7 @@ bool MessageDifferencer::MatchRepeatedFieldIndices(
// Here we use the augmenting path algorithm.
auto callback = [&](int i1, int i2) {
return IsMatch(repeated_field, key_comparator, &message1, &message2,
- parent_fields, nullptr, i1, i2);
+ unpacked_any, parent_fields, nullptr, i1, i2);
};
MaximumMatcher matcher(count1, count2, std::move(callback), match_list1,
match_list2);
@@ -1841,7 +1895,7 @@ bool MessageDifferencer::MatchRepeatedFieldIndices(
start_offset = std::min(count1, count2);
for (int i = 0; i < count1 && i < count2; i++) {
if (IsMatch(repeated_field, key_comparator, &message1, &message2,
- parent_fields, nullptr, i, i)) {
+ unpacked_any, parent_fields, nullptr, i, i)) {
match_list1->at(i) = i;
match_list2->at(i) = i;
} else {
@@ -1865,11 +1919,12 @@ bool MessageDifferencer::MatchRepeatedFieldIndices(
if (is_treated_as_smart_set) {
num_diffs_reporter.Reset();
- match = IsMatch(repeated_field, key_comparator, &message1, &message2,
- parent_fields, &num_diffs_reporter, i, j);
+ match =
+ IsMatch(repeated_field, key_comparator, &message1, &message2,
+ unpacked_any, parent_fields, &num_diffs_reporter, i, j);
} else {
match = IsMatch(repeated_field, key_comparator, &message1, &message2,
- parent_fields, nullptr, i, j);
+ unpacked_any, parent_fields, nullptr, i, j);
}
if (is_treated_as_smart_set) {
@@ -2000,19 +2055,18 @@ void MessageDifferencer::StreamReporter::PrintPath(
continue;
}
} else {
- printer_->PrintRaw(StrCat(specific_field.unknown_field_number));
+ printer_->PrintRaw(y_absl::StrCat(specific_field.unknown_field_number));
}
if (left_side && specific_field.index >= 0) {
- printer_->Print("[$name$]", "name", StrCat(specific_field.index));
+ printer_->Print("[$name$]", "name", y_absl::StrCat(specific_field.index));
}
if (!left_side && specific_field.new_index >= 0) {
printer_->Print("[$name$]", "name",
- StrCat(specific_field.new_index));
+ y_absl::StrCat(specific_field.new_index));
}
}
}
-
void MessageDifferencer::StreamReporter::PrintValue(
const Message& message, const std::vector<SpecificField>& field_path,
bool left_side) {
@@ -2067,24 +2121,24 @@ void MessageDifferencer::StreamReporter::PrintValue(
void MessageDifferencer::StreamReporter::PrintUnknownFieldValue(
const UnknownField* unknown_field) {
- GOOGLE_CHECK(unknown_field != NULL) << " Cannot print NULL unknown_field.";
+ Y_ABSL_CHECK(unknown_field != NULL) << " Cannot print NULL unknown_field.";
TProtoStringType output;
switch (unknown_field->type()) {
case UnknownField::TYPE_VARINT:
- output = StrCat(unknown_field->varint());
+ output = y_absl::StrCat(unknown_field->varint());
break;
case UnknownField::TYPE_FIXED32:
- output = StrCat(
- "0x", strings::Hex(unknown_field->fixed32(), strings::ZERO_PAD_8));
+ output = y_absl::StrCat(
+ "0x", y_absl::Hex(unknown_field->fixed32(), y_absl::kZeroPad8));
break;
case UnknownField::TYPE_FIXED64:
- output = StrCat(
- "0x", strings::Hex(unknown_field->fixed64(), strings::ZERO_PAD_16));
+ output = y_absl::StrCat(
+ "0x", y_absl::Hex(unknown_field->fixed64(), y_absl::kZeroPad16));
break;
case UnknownField::TYPE_LENGTH_DELIMITED:
- output = StringPrintf(
- "\"%s\"", CEscape(unknown_field->length_delimited()).c_str());
+ output = y_absl::StrFormat(
+ "\"%s\"", y_absl::CEscape(unknown_field->length_delimited()).c_str());
break;
case UnknownField::TYPE_GROUP:
// TODO(kenton): Print the contents of the group like we do for
@@ -2103,9 +2157,9 @@ void MessageDifferencer::StreamReporter::Print(const TProtoStringType& str) {
void MessageDifferencer::StreamReporter::PrintMapKey(
bool left_side, const SpecificField& specific_field) {
if (message1_ == nullptr || message2_ == nullptr) {
- GOOGLE_LOG(INFO) << "PrintPath cannot log map keys; "
- "use SetMessages to provide the messages "
- "being compared prior to any processing.";
+ Y_ABSL_LOG(INFO) << "PrintPath cannot log map keys; "
+ "use SetMessages to provide the messages "
+ "being compared prior to any processing.";
return;
}
@@ -2126,7 +2180,7 @@ void MessageDifferencer::StreamReporter::PrintMapKey(
if (key_string.empty()) {
key_string = "''";
}
- printer_->PrintRaw(StrCat("[", key_string, "]"));
+ printer_->PrintRaw(y_absl::StrCat("[", key_string, "]"));
}
}
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 fbd5da78972..e4d423ed4bb 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/message_differencer.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/message_differencer.h
@@ -43,21 +43,23 @@
#ifndef GOOGLE_PROTOBUF_UTIL_MESSAGE_DIFFERENCER_H__
#define GOOGLE_PROTOBUF_UTIL_MESSAGE_DIFFERENCER_H__
-
#include <functional>
-#include <map>
#include <memory>
-#include <set>
#include <string>
#include <vector>
-#include <google/protobuf/descriptor.h> // FieldDescriptor
-#include <google/protobuf/message.h> // Message
-#include <google/protobuf/unknown_field_set.h>
-#include <google/protobuf/util/field_comparator.h>
+#include "google/protobuf/descriptor.h" // FieldDescriptor
+#include "google/protobuf/message.h" // Message
+#include "google/protobuf/unknown_field_set.h"
+#include "google/protobuf/stubs/common.h"
+#include "y_absl/container/fixed_array.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/log/absl_check.h"
+#include "google/protobuf/util/field_comparator.h"
// Always include as last one, otherwise it can break compilation
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -76,10 +78,10 @@ class DefaultFieldComparator;
class FieldContext; // declared below MessageDifferencer
// Defines a collection of field descriptors.
-// In case of internal google codebase we are using absl::FixedArray instead
+// In case of internal google codebase we are using y_absl::FixedArray instead
// of vector. It significantly speeds up proto comparison (by ~30%) by
// reducing the number of malloc/free operations
-typedef std::vector<const FieldDescriptor*> FieldDescriptorArray;
+typedef y_absl::FixedArray<const FieldDescriptor*, 16> FieldDescriptorArray;
// A basic differencer that can be used to determine
// the differences between two specified Protocol Messages. If any differences
@@ -177,6 +179,22 @@ class PROTOBUF_EXPORT MessageDifferencer {
// Identifies an individual field in a message instance. Used for field_path,
// below.
struct SpecificField {
+ // The messages that contain this field. They are always set. They are valid
+ // only during a call to Reporter::Report* methods.
+ //
+ // If the original messages are of type google.protobuf.Any, these fields
+ // will store the unpacked payloads, and unpacked_any will become > 0. More
+ // precisely, unpacked_any defines the nesting level of Any. For example,
+ // if the original message packs another Any, then unpacked_any=2, assuming
+ // the differencer unpacked both of them.
+ //
+ // When an Any object packs a non-Any proto object whose field includes
+ // Any, then unpacked_any=1. Thus, in most practical applications,
+ // unpacked_any will be 0 or 1.
+ const Message* message1 = nullptr;
+ const Message* message2 = nullptr;
+ int unpacked_any = 0;
+
// For known fields, "field" is filled in and "unknown_field_number" is -1.
// For unknown fields, "field" is NULL, "unknown_field_number" is the field
// number, and "unknown_field_type" is its type.
@@ -238,21 +256,22 @@ class PROTOBUF_EXPORT MessageDifferencer {
class PROTOBUF_EXPORT Reporter {
public:
Reporter();
+ Reporter(const Reporter&) = delete;
+ Reporter& operator=(const Reporter&) = delete;
virtual ~Reporter();
// Reports that a field has been added into Message2.
virtual void ReportAdded(const Message& message1, const Message& message2,
- const std::vector<SpecificField>& field_path) = 0;
+ const std::vector<SpecificField>& field_path) {}
// Reports that a field has been deleted from Message1.
- virtual void ReportDeleted(
- const Message& message1, const Message& message2,
- const std::vector<SpecificField>& field_path) = 0;
+ virtual void ReportDeleted(const Message& message1, const Message& message2,
+ const std::vector<SpecificField>& field_path) {}
// Reports that the value of a field has been modified.
- virtual void ReportModified(
- const Message& message1, const Message& message2,
- const std::vector<SpecificField>& field_path) = 0;
+ virtual void ReportModified(const Message& message1,
+ const Message& message2,
+ const std::vector<SpecificField>& field_path) {}
// Reports that a repeated field has been moved to another location. This
// only applies when using TreatAsSet or TreatAsMap() -- see below. Also
@@ -300,9 +319,6 @@ class PROTOBUF_EXPORT MessageDifferencer {
virtual void ReportUnknownFieldIgnored(
const Message& /* message1 */, const Message& /* message2 */,
const std::vector<SpecificField>& /* field_path */) {}
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Reporter);
};
// MapKeyComparator is used to determine if two elements have the same key
@@ -310,17 +326,25 @@ class PROTOBUF_EXPORT MessageDifferencer {
class PROTOBUF_EXPORT MapKeyComparator {
public:
MapKeyComparator();
+ MapKeyComparator(const MapKeyComparator&) = delete;
+ MapKeyComparator& operator=(const MapKeyComparator&) = delete;
virtual ~MapKeyComparator();
- virtual bool IsMatch(
- const Message& /* message1 */, const Message& /* message2 */,
- const std::vector<SpecificField>& /* parent_fields */) const {
- GOOGLE_CHECK(false) << "IsMatch() is not implemented.";
+ // This method should be overridden by every implementation. The arg
+ // unmapped_any is nonzero the original messages provided by the user are of
+ // type google.protobuf.Any.
+ //
+ // More precisely, unpacked_any defines the nesting level of Any. For
+ // example, if Any packs another Any then unpacked_any=2, assuming the
+ // patcher unpacked both. Note that when an Any object packs a non-Any
+ // proto object whose field includes Any, then unpacked_any=1. Thus, in most
+ // practical applications, unpacked_any will be 0 or 1.
+ virtual bool IsMatch(const Message& message1, const Message& message2,
+ int /* unmapped_any */,
+ const std::vector<SpecificField>& fields) const {
+ Y_ABSL_CHECK(false) << "IsMatch() is not implemented.";
return false;
}
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapKeyComparator);
};
// Abstract base class from which all IgnoreCriteria derive.
@@ -354,6 +378,8 @@ class PROTOBUF_EXPORT MessageDifferencer {
// To add a Reporter, construct default here, then use ReportDifferencesTo or
// ReportDifferencesToString.
explicit MessageDifferencer();
+ MessageDifferencer(const MessageDifferencer&) = delete;
+ MessageDifferencer& operator=(const MessageDifferencer&) = delete;
~MessageDifferencer();
@@ -503,7 +529,10 @@ class PROTOBUF_EXPORT MessageDifferencer {
// Add a custom ignore criteria that is evaluated in addition to the
// ignored fields added with IgnoreField.
// Takes ownership of ignore_criteria.
- void AddIgnoreCriteria(IgnoreCriteria* ignore_criteria);
+ void AddIgnoreCriteria(IgnoreCriteria* ignore_criteria) {
+ AddIgnoreCriteria(y_absl::WrapUnique(ignore_criteria));
+ }
+ void AddIgnoreCriteria(std::unique_ptr<IgnoreCriteria> ignore_criteria);
// Indicates that any field with the given descriptor should be
// ignored for the purposes of comparing two messages. This applies
@@ -524,9 +553,7 @@ class PROTOBUF_EXPORT MessageDifferencer {
// Note that this method must be called before Compare for the comparator to
// be used.
void set_field_comparator(FieldComparator* comparator);
-#ifdef PROTOBUF_FUTURE_BREAKING_CHANGES
void set_field_comparator(DefaultFieldComparator* comparator);
-#endif // PROTOBUF_FUTURE_BREAKING_CHANGES
// DEPRECATED. Pass a DefaultFieldComparator instance instead.
// Sets the fraction and margin for the float comparison of a given field.
@@ -648,6 +675,8 @@ class PROTOBUF_EXPORT MessageDifferencer {
public:
explicit StreamReporter(io::ZeroCopyOutputStream* output);
explicit StreamReporter(io::Printer* printer); // delimiter '$'
+ StreamReporter(const StreamReporter&) = delete;
+ StreamReporter& operator=(const StreamReporter&) = delete;
~StreamReporter() override;
// When set to true, the stream reporter will also output aggregates nodes
@@ -715,7 +744,6 @@ class PROTOBUF_EXPORT MessageDifferencer {
const Message* message1_;
const Message* message2_;
MessageDifferencer::UnpackAnyField unpack_any_field_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StreamReporter);
};
private:
@@ -732,7 +760,7 @@ class PROTOBUF_EXPORT MessageDifferencer {
public:
explicit MapEntryKeyComparator(MessageDifferencer* message_differencer);
bool IsMatch(
- const Message& message1, const Message& message2,
+ const Message& message1, const Message& message2, int unpacked_any,
const std::vector<SpecificField>& parent_fields) const override;
private:
@@ -762,7 +790,7 @@ class PROTOBUF_EXPORT MessageDifferencer {
// (i.e. if the current message is an embedded message, the parent_fields
// vector will contain the field that has this embedded message).
bool Compare(const Message& message1, const Message& message2,
- std::vector<SpecificField>* parent_fields);
+ int unpacked_any, std::vector<SpecificField>* parent_fields);
// Compares all the unknown fields in two messages.
bool CompareUnknownFields(const Message& message1, const Message& message2,
@@ -773,46 +801,47 @@ class PROTOBUF_EXPORT MessageDifferencer {
// lists are modified depending on comparison settings, and then passed to
// CompareWithFieldsInternal.
bool CompareRequestedFieldsUsingSettings(
- const Message& message1, const Message& message2,
+ const Message& message1, const Message& message2, int unpacked_any,
const FieldDescriptorArray& message1_fields,
const FieldDescriptorArray& message2_fields,
std::vector<SpecificField>* parent_fields);
// Compares the specified messages with the specified field lists.
bool CompareWithFieldsInternal(const Message& message1,
- const Message& message2,
+ const Message& message2, int unpacked_any,
const FieldDescriptorArray& message1_fields,
const FieldDescriptorArray& message2_fields,
std::vector<SpecificField>* parent_fields);
// Compares the repeated fields, and report the error.
bool CompareRepeatedField(const Message& message1, const Message& message2,
- const FieldDescriptor* field,
+ int unpacked_any, const FieldDescriptor* field,
std::vector<SpecificField>* parent_fields);
// Compares map fields, and report the error.
bool CompareMapField(const Message& message1, const Message& message2,
- const FieldDescriptor* field,
+ int unpacked_any, const FieldDescriptor* field,
std::vector<SpecificField>* parent_fields);
// Helper for CompareRepeatedField and CompareMapField: compares and reports
// differences element-wise. This is the implementation for non-map fields,
// and can also compare map fields by using the underlying representation.
bool CompareRepeatedRep(const Message& message1, const Message& message2,
- const FieldDescriptor* field,
+ int unpacked_any, const FieldDescriptor* field,
std::vector<SpecificField>* parent_fields);
// Helper for CompareMapField: compare the map fields using map reflection
// instead of sync to repeated.
bool CompareMapFieldByMapReflection(const Message& message1,
- const Message& message2,
+ const Message& message2, int unpacked_any,
const FieldDescriptor* field,
std::vector<SpecificField>* parent_fields,
DefaultFieldComparator* comparator);
// Shorthand for CompareFieldValueUsingParentFields with NULL parent_fields.
bool CompareFieldValue(const Message& message1, const Message& message2,
- const FieldDescriptor* field, int index1, int index2);
+ int unpacked_any, const FieldDescriptor* field,
+ int index1, int index2);
// Compares the specified field on the two messages, returning
// true if they are the same, false otherwise. For repeated fields,
@@ -824,7 +853,7 @@ class PROTOBUF_EXPORT MessageDifferencer {
// To avoid confusing users you should not set it to NULL unless you modified
// Reporter to handle the change of parent_fields correctly.
bool CompareFieldValueUsingParentFields(
- const Message& message1, const Message& message2,
+ const Message& message1, const Message& message2, int unpacked_any,
const FieldDescriptor* field, int index1, int index2,
std::vector<SpecificField>* parent_fields);
@@ -840,7 +869,7 @@ class PROTOBUF_EXPORT MessageDifferencer {
// elements are equal.
bool IsMatch(const FieldDescriptor* repeated_field,
const MapKeyComparator* key_comparator, const Message* message1,
- const Message* message2,
+ const Message* message2, int unpacked_any,
const std::vector<SpecificField>& parent_fields,
Reporter* reporter, int index1, int index2);
@@ -888,7 +917,7 @@ class PROTOBUF_EXPORT MessageDifferencer {
// that the comparison succeeds when this method returns true (you need to
// double-check in this case).
bool MatchRepeatedFieldIndices(
- const Message& message1, const Message& message2,
+ const Message& message1, const Message& message2, int unpacked_any,
const FieldDescriptor* repeated_field,
const MapKeyComparator* key_comparator,
const std::vector<SpecificField>& parent_fields,
@@ -897,29 +926,20 @@ class PROTOBUF_EXPORT MessageDifferencer {
// Checks if index is equal to new_index in all the specific fields.
static bool CheckPathChanged(const std::vector<SpecificField>& parent_fields);
- // CHECKs that the given repeated field can be compared according to
+ // Y_ABSL_CHECKs that the given repeated field can be compared according to
// new_comparison.
void CheckRepeatedFieldComparisons(
const FieldDescriptor* field,
const RepeatedFieldComparison& new_comparison);
- // Defines a map between field descriptors and their MapKeyComparators.
- // Used for repeated fields when they are configured as TreatAsMap.
- typedef std::map<const FieldDescriptor*, const MapKeyComparator*>
- FieldKeyComparatorMap;
-
- // Defines a set to store field descriptors. Used for repeated fields when
- // they are configured as TreatAsSet.
- typedef std::set<const FieldDescriptor*> FieldSet;
- typedef std::map<const FieldDescriptor*, RepeatedFieldComparison> FieldMap;
-
Reporter* reporter_;
DefaultFieldComparator default_field_comparator_;
MessageFieldComparison message_field_comparison_;
Scope scope_;
RepeatedFieldComparison repeated_field_comparison_;
- FieldMap repeated_field_comparisons_;
+ y_absl::flat_hash_map<const FieldDescriptor*, RepeatedFieldComparison>
+ repeated_field_comparisons_;
// Keeps track of MapKeyComparators that are created within
// MessageDifferencer. These MapKeyComparators should be deleted
// before MessageDifferencer is destroyed.
@@ -927,13 +947,14 @@ class PROTOBUF_EXPORT MessageDifferencer {
// store the supplied FieldDescriptors directly. Instead, a new
// MapKeyComparator is created for comparison purpose.
std::vector<MapKeyComparator*> owned_key_comparators_;
- FieldKeyComparatorMap map_field_key_comparator_;
+ y_absl::flat_hash_map<const FieldDescriptor*, const MapKeyComparator*>
+ map_field_key_comparator_;
MapEntryKeyComparator map_entry_key_comparator_;
- std::vector<IgnoreCriteria*> ignore_criteria_;
+ std::vector<std::unique_ptr<IgnoreCriteria>> ignore_criteria_;
// Reused multiple times in RetrieveFields to avoid extra allocations
std::vector<const FieldDescriptor*> tmp_message_fields_;
- FieldSet ignored_fields_;
+ y_absl::flat_hash_set<const FieldDescriptor*> ignored_fields_;
union {
DefaultFieldComparator* default_impl;
@@ -952,7 +973,6 @@ class PROTOBUF_EXPORT MessageDifferencer {
match_indices_for_smart_list_callback_;
MessageDifferencer::UnpackAnyField unpack_any_field_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageDifferencer);
};
// This class provides extra information to the FieldComparator::Compare
@@ -975,6 +995,6 @@ class PROTOBUF_EXPORT FieldContext {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_UTIL_MESSAGE_DIFFERENCER_H__
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 a686e911da2..bc1b8be6fe2 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/time_util.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/util/time_util.cc
@@ -28,19 +28,23 @@
// (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/util/time_util.h>
+#include "google/protobuf/util/time_util.h"
#include <cstdint>
-
-#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>
+#include <cstdlib>
+
+#include "google/protobuf/duration.pb.h"
+#include "google/protobuf/timestamp.pb.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/numeric/int128.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/time/clock.h"
+#include "y_absl/time/time.h"
// Must go after other includes.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -50,19 +54,24 @@ using google::protobuf::Duration;
using google::protobuf::Timestamp;
namespace {
-static const int kNanosPerSecond = 1000000000;
-static const int kMicrosPerSecond = 1000000;
-static const int kMillisPerSecond = 1000;
-static const int kNanosPerMillisecond = 1000000;
-static const int kNanosPerMicrosecond = 1000;
-static const int kSecondsPerMinute = 60; // Note that we ignore leap seconds.
-static const int kSecondsPerHour = 3600;
+static constexpr arc_i32 kNanosPerSecond = 1000000000;
+static constexpr arc_i32 kMicrosPerSecond = 1000000;
+static constexpr arc_i32 kMillisPerSecond = 1000;
+static constexpr arc_i32 kNanosPerMillisecond = 1000000;
+static constexpr arc_i32 kNanosPerMicrosecond = 1000;
+static constexpr arc_i32 kSecondsPerMinute =
+ 60; // Note that we ignore leap seconds.
+static constexpr arc_i32 kSecondsPerHour = 3600;
template <typename T>
-T CreateNormalized(arc_i64 seconds, arc_i64 nanos);
+T CreateNormalized(arc_i64 seconds, arc_i32 nanos);
template <>
-Timestamp CreateNormalized(arc_i64 seconds, arc_i64 nanos) {
+Timestamp CreateNormalized(arc_i64 seconds, arc_i32 nanos) {
+ Y_ABSL_DCHECK(seconds >= TimeUtil::kTimestampMinSeconds &&
+ seconds <= TimeUtil::kTimestampMaxSeconds)
+ << "Timestamp seconds are outside of the valid range";
+
// Make sure nanos is in the range.
if (nanos <= -kNanosPerSecond || nanos >= kNanosPerSecond) {
seconds += nanos / kNanosPerSecond;
@@ -73,8 +82,12 @@ Timestamp CreateNormalized(arc_i64 seconds, arc_i64 nanos) {
seconds -= 1;
nanos += kNanosPerSecond;
}
- GOOGLE_DCHECK(seconds >= TimeUtil::kTimestampMinSeconds &&
- seconds <= TimeUtil::kTimestampMaxSeconds);
+
+ Y_ABSL_DCHECK(seconds >= TimeUtil::kTimestampMinSeconds &&
+ seconds <= TimeUtil::kTimestampMaxSeconds &&
+ nanos >= TimeUtil::kTimestampMinNanoseconds &&
+ nanos <= TimeUtil::kTimestampMaxNanoseconds)
+ << "Timestamp is outside of the valid range";
Timestamp result;
result.set_seconds(seconds);
result.set_nanos(static_cast<arc_i32>(nanos));
@@ -82,7 +95,11 @@ Timestamp CreateNormalized(arc_i64 seconds, arc_i64 nanos) {
}
template <>
-Duration CreateNormalized(arc_i64 seconds, arc_i64 nanos) {
+Duration CreateNormalized(arc_i64 seconds, arc_i32 nanos) {
+ Y_ABSL_DCHECK(seconds >= TimeUtil::kDurationMinSeconds &&
+ seconds <= TimeUtil::kDurationMaxSeconds)
+ << "Duration seconds are outside of the valid range";
+
// Make sure nanos is in the range.
if (nanos <= -kNanosPerSecond || nanos >= kNanosPerSecond) {
seconds += nanos / kNanosPerSecond;
@@ -96,8 +113,12 @@ Duration CreateNormalized(arc_i64 seconds, arc_i64 nanos) {
seconds -= 1;
nanos += kNanosPerSecond;
}
- GOOGLE_DCHECK(seconds >= TimeUtil::kDurationMinSeconds &&
- seconds <= TimeUtil::kDurationMaxSeconds);
+
+ Y_ABSL_DCHECK(seconds >= TimeUtil::kDurationMinSeconds &&
+ seconds <= TimeUtil::kDurationMaxSeconds &&
+ nanos >= TimeUtil::kDurationMinNanoseconds &&
+ nanos <= TimeUtil::kDurationMaxNanoseconds)
+ << "Duration is outside of the valid range";
Duration result;
result.set_seconds(seconds);
result.set_nanos(static_cast<arc_i32>(nanos));
@@ -108,24 +129,49 @@ Duration CreateNormalized(arc_i64 seconds, arc_i64 nanos) {
// precision to represent the exact value.
TProtoStringType FormatNanos(arc_i32 nanos) {
if (nanos % kNanosPerMillisecond == 0) {
- return StringPrintf("%03d", nanos / kNanosPerMillisecond);
+ return y_absl::StrFormat("%03d", nanos / kNanosPerMillisecond);
} else if (nanos % kNanosPerMicrosecond == 0) {
- return StringPrintf("%06d", nanos / kNanosPerMicrosecond);
+ return y_absl::StrFormat("%06d", nanos / kNanosPerMicrosecond);
} else {
- return StringPrintf("%09d", nanos);
+ return y_absl::StrFormat("%09d", nanos);
}
}
TProtoStringType FormatTime(arc_i64 seconds, arc_i32 nanos) {
- return ::google::protobuf::internal::FormatTime(seconds, nanos);
+ static constexpr y_absl::string_view kTimestampFormat = "%E4Y-%m-%dT%H:%M:%S";
+
+ timespec spec;
+ spec.tv_sec = seconds;
+ // We only use y_absl::FormatTime to format the seconds part because we need
+ // finer control over the precision of nanoseconds.
+ spec.tv_nsec = 0;
+ TProtoStringType result = y_absl::FormatTime(
+ kTimestampFormat, y_absl::TimeFromTimespec(spec), y_absl::UTCTimeZone());
+ // We format the nanoseconds part separately to meet the precision
+ // requirement.
+ if (nanos != 0) {
+ y_absl::StrAppend(&result, ".", FormatNanos(nanos));
+ }
+ y_absl::StrAppend(&result, "Z");
+ return result;
}
-bool ParseTime(const TProtoStringType& value, arc_i64* seconds, arc_i32* nanos) {
- return ::google::protobuf::internal::ParseTime(value, seconds, nanos);
+bool ParseTime(y_absl::string_view value, arc_i64* seconds, arc_i32* nanos) {
+ y_absl::Time result;
+ if (!y_absl::ParseTime(y_absl::RFC3339_full, value, &result, nullptr)) {
+ return false;
+ }
+ timespec spec = y_absl::ToTimespec(result);
+ *seconds = spec.tv_sec;
+ *nanos = spec.tv_nsec;
+ return true;
}
void CurrentTime(arc_i64* seconds, arc_i32* nanos) {
- return ::google::protobuf::internal::GetCurrentTime(seconds, nanos);
+ y_absl::Time now = y_absl::Now();
+ timespec spec = y_absl::ToTimespec(now);
+ *seconds = spec.tv_sec;
+ *nanos = spec.tv_nsec;
}
// Truncates the remainder part after division.
@@ -148,17 +194,21 @@ arc_i64 RoundTowardZero(arc_i64 value, arc_i64 divider) {
// Actually define these static const integers. Required by C++ standard (but
// some compilers don't like it).
#ifndef _MSC_VER
-const arc_i64 TimeUtil::kTimestampMinSeconds;
-const arc_i64 TimeUtil::kTimestampMaxSeconds;
-const arc_i64 TimeUtil::kDurationMaxSeconds;
-const arc_i64 TimeUtil::kDurationMinSeconds;
+constexpr arc_i64 TimeUtil::kTimestampMinSeconds;
+constexpr arc_i64 TimeUtil::kTimestampMaxSeconds;
+constexpr arc_i32 TimeUtil::kTimestampMinNanoseconds;
+constexpr arc_i32 TimeUtil::kTimestampMaxNanoseconds;
+constexpr arc_i64 TimeUtil::kDurationMaxSeconds;
+constexpr arc_i64 TimeUtil::kDurationMinSeconds;
+constexpr arc_i32 TimeUtil::kDurationMaxNanoseconds;
+constexpr arc_i32 TimeUtil::kDurationMinNanoseconds;
#endif // !_MSC_VER
TProtoStringType TimeUtil::ToString(const Timestamp& timestamp) {
return FormatTime(timestamp.seconds(), timestamp.nanos());
}
-bool TimeUtil::FromString(const TProtoStringType& value, Timestamp* timestamp) {
+bool TimeUtil::FromString(y_absl::string_view value, Timestamp* timestamp) {
arc_i64 seconds;
arc_i32 nanos;
if (!ParseTime(value, &seconds, &nanos)) {
@@ -182,15 +232,15 @@ TProtoStringType TimeUtil::ToString(const Duration& duration) {
arc_i64 seconds = duration.seconds();
arc_i32 nanos = duration.nanos();
if (seconds < 0 || nanos < 0) {
- result += "-";
+ result = "-";
seconds = -seconds;
nanos = -nanos;
}
- result += StrCat(seconds);
+ y_absl::StrAppend(&result, seconds);
if (nanos != 0) {
- result += "." + FormatNanos(nanos);
+ y_absl::StrAppend(&result, ".", FormatNanos(nanos));
}
- result += "s";
+ y_absl::StrAppend(&result, "s");
return result;
}
@@ -202,7 +252,7 @@ static arc_i64 Pow(arc_i64 x, int y) {
return result;
}
-bool TimeUtil::FromString(const TProtoStringType& value, Duration* duration) {
+bool TimeUtil::FromString(y_absl::string_view value, Duration* duration) {
if (value.length() <= 1 || value[value.length() - 1] != 's') {
return false;
}
@@ -213,18 +263,21 @@ bool TimeUtil::FromString(const TProtoStringType& value, Duration* duration) {
TProtoStringType seconds_part, nanos_part;
size_t pos = value.find_last_of('.');
if (pos == TProtoStringType::npos) {
- seconds_part = value.substr(sign_length, value.length() - 1 - sign_length);
+ seconds_part = TProtoStringType(
+ value.substr(sign_length, value.length() - 1 - sign_length));
nanos_part = "0";
} else {
- seconds_part = value.substr(sign_length, pos - sign_length);
- nanos_part = value.substr(pos + 1, value.length() - pos - 2);
+ seconds_part = TProtoStringType(value.substr(sign_length, pos - sign_length));
+ nanos_part = TProtoStringType(value.substr(pos + 1, value.length() - pos - 2));
}
char* end;
- arc_i64 seconds = strto64(seconds_part.c_str(), &end, 10);
+ static_assert(sizeof(arc_i64) == sizeof(long long),
+ "sizeof arc_i64 is not sizeof long long");
+ arc_i64 seconds = std::strtoll(seconds_part.c_str(), &end, 10);
if (end != seconds_part.c_str() + seconds_part.length()) {
return false;
}
- arc_i64 nanos = strto64(nanos_part.c_str(), &end, 10);
+ arc_i64 nanos = std::strtoll(nanos_part.c_str(), &end, 10);
if (end != nanos_part.c_str() + nanos_part.length()) {
return false;
}
@@ -261,37 +314,45 @@ Duration TimeUtil::SecondsToDuration(arc_i64 seconds) {
}
Duration TimeUtil::MinutesToDuration(arc_i64 minutes) {
- return CreateNormalized<Duration>(minutes * kSecondsPerMinute, 0);
+ Y_ABSL_DCHECK(minutes >= TimeUtil::kDurationMinSeconds / kSecondsPerMinute &&
+ minutes <= TimeUtil::kDurationMaxSeconds / kSecondsPerMinute)
+ << "Duration minutes are outside of the valid range";
+ return SecondsToDuration(minutes * kSecondsPerMinute);
}
Duration TimeUtil::HoursToDuration(arc_i64 hours) {
- return CreateNormalized<Duration>(hours * kSecondsPerHour, 0);
+ Y_ABSL_DCHECK(hours >= TimeUtil::kDurationMinSeconds / kSecondsPerHour &&
+ hours <= TimeUtil::kDurationMaxSeconds / kSecondsPerHour)
+ << "Duration hours are outside of the valid range";
+ return SecondsToDuration(hours * kSecondsPerHour);
}
arc_i64 TimeUtil::DurationToNanoseconds(const Duration& duration) {
+ Y_ABSL_DCHECK(IsDurationValid(duration))
+ << "Duration is outside of the valid range";
return duration.seconds() * kNanosPerSecond + duration.nanos();
}
arc_i64 TimeUtil::DurationToMicroseconds(const Duration& duration) {
- return duration.seconds() * kMicrosPerSecond +
- RoundTowardZero(duration.nanos(), kNanosPerMicrosecond);
+ return RoundTowardZero(DurationToNanoseconds(duration), kNanosPerMicrosecond);
}
arc_i64 TimeUtil::DurationToMilliseconds(const Duration& duration) {
- return duration.seconds() * kMillisPerSecond +
- RoundTowardZero(duration.nanos(), kNanosPerMillisecond);
+ return RoundTowardZero(DurationToNanoseconds(duration), kNanosPerMillisecond);
}
arc_i64 TimeUtil::DurationToSeconds(const Duration& duration) {
+ Y_ABSL_DCHECK(IsDurationValid(duration))
+ << "Duration is outside of the valid range";
return duration.seconds();
}
arc_i64 TimeUtil::DurationToMinutes(const Duration& duration) {
- return RoundTowardZero(duration.seconds(), kSecondsPerMinute);
+ return RoundTowardZero(DurationToSeconds(duration), kSecondsPerMinute);
}
arc_i64 TimeUtil::DurationToHours(const Duration& duration) {
- return RoundTowardZero(duration.seconds(), kSecondsPerHour);
+ return RoundTowardZero(DurationToSeconds(duration), kSecondsPerHour);
}
Timestamp TimeUtil::NanosecondsToTimestamp(arc_i64 nanos) {
@@ -316,20 +377,28 @@ Timestamp TimeUtil::SecondsToTimestamp(arc_i64 seconds) {
}
arc_i64 TimeUtil::TimestampToNanoseconds(const Timestamp& timestamp) {
+ Y_ABSL_DCHECK(IsTimestampValid(timestamp))
+ << "Timestamp is outside of the valid range";
return timestamp.seconds() * kNanosPerSecond + timestamp.nanos();
}
arc_i64 TimeUtil::TimestampToMicroseconds(const Timestamp& timestamp) {
+ Y_ABSL_DCHECK(IsTimestampValid(timestamp))
+ << "Timestamp is outside of the valid range";
return timestamp.seconds() * kMicrosPerSecond +
RoundTowardZero(timestamp.nanos(), kNanosPerMicrosecond);
}
arc_i64 TimeUtil::TimestampToMilliseconds(const Timestamp& timestamp) {
+ Y_ABSL_DCHECK(IsTimestampValid(timestamp))
+ << "Timestamp is outside of the valid range";
return timestamp.seconds() * kMillisPerSecond +
RoundTowardZero(timestamp.nanos(), kNanosPerMillisecond);
}
arc_i64 TimeUtil::TimestampToSeconds(const Timestamp& timestamp) {
+ Y_ABSL_DCHECK(IsTimestampValid(timestamp))
+ << "Timestamp is outside of the valid range";
return timestamp.seconds();
}
@@ -381,7 +450,7 @@ using ::PROTOBUF_NAMESPACE_ID::util::CreateNormalized;
using ::PROTOBUF_NAMESPACE_ID::util::kNanosPerSecond;
// Convert a Duration to uint128.
-void ToUint128(const Duration& value, uint128* result, bool* negative) {
+void ToUint128(const Duration& value, y_absl::uint128* result, bool* negative) {
if (value.seconds() < 0 || value.nanos() < 0) {
*negative = true;
*result = static_cast<arc_ui64>(-value.seconds());
@@ -393,11 +462,11 @@ void ToUint128(const Duration& value, uint128* result, bool* negative) {
}
}
-void ToDuration(const uint128& value, bool negative, Duration* duration) {
+void ToDuration(const y_absl::uint128& value, bool negative, Duration* duration) {
arc_i64 seconds =
- static_cast<arc_i64>(Uint128Low64(value / kNanosPerSecond));
+ static_cast<arc_i64>(y_absl::Uint128Low64(value / kNanosPerSecond));
arc_i32 nanos =
- static_cast<arc_i32>(Uint128Low64(value % kNanosPerSecond));
+ static_cast<arc_i32>(y_absl::Uint128Low64(value % kNanosPerSecond));
if (negative) {
seconds = -seconds;
nanos = -nanos;
@@ -421,7 +490,7 @@ Duration& operator-=(Duration& d1, const Duration& d2) { // NOLINT
Duration& operator*=(Duration& d, arc_i64 r) { // NOLINT
bool negative;
- uint128 value;
+ y_absl::uint128 value;
ToUint128(d, &value, &negative);
if (r > 0) {
value *= static_cast<arc_ui64>(r);
@@ -450,7 +519,7 @@ Duration& operator*=(Duration& d, double r) { // NOLINT
Duration& operator/=(Duration& d, arc_i64 r) { // NOLINT
bool negative;
- uint128 value;
+ y_absl::uint128 value;
ToUint128(d, &value, &negative);
if (r > 0) {
value /= static_cast<arc_ui64>(r);
@@ -468,10 +537,10 @@ Duration& operator/=(Duration& d, double r) { // NOLINT
Duration& operator%=(Duration& d1, const Duration& d2) { // NOLINT
bool negative1, negative2;
- uint128 value1, value2;
+ y_absl::uint128 value1, value2;
ToUint128(d1, &value1, &negative1);
ToUint128(d2, &value2, &negative2);
- uint128 result = value1 % value2;
+ y_absl::uint128 result = value1 % value2;
// When negative values are involved in division, we round the division
// result towards zero. With this semantics, sign of the remainder is the
// same as the dividend. For example:
@@ -484,10 +553,10 @@ Duration& operator%=(Duration& d1, const Duration& d2) { // NOLINT
arc_i64 operator/(const Duration& d1, const Duration& d2) {
bool negative1, negative2;
- uint128 value1, value2;
+ y_absl::uint128 value1, value2;
ToUint128(d1, &value1, &negative1);
ToUint128(d2, &value2, &negative2);
- arc_i64 result = Uint128Low64(value1 / value2);
+ arc_i64 result = y_absl::Uint128Low64(value1 / value2);
if (negative1 != negative2) {
result = -result;
}
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 fcf70d1e5a7..83b42654f08 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/time_util.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/time_util.h
@@ -50,11 +50,11 @@ struct timeval {
#include <sys/time.h>
#endif
-#include <google/protobuf/duration.pb.h>
-#include <google/protobuf/timestamp.pb.h>
+#include "google/protobuf/duration.pb.h"
+#include "google/protobuf/timestamp.pb.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -69,11 +69,31 @@ class PROTOBUF_EXPORT TimeUtil {
// The min/max Timestamp/Duration values we support.
//
// For "0001-01-01T00:00:00Z".
- static const arc_i64 kTimestampMinSeconds = -62135596800LL;
+ static constexpr arc_i64 kTimestampMinSeconds = -62135596800LL;
// For "9999-12-31T23:59:59.999999999Z".
- static const arc_i64 kTimestampMaxSeconds = 253402300799LL;
- static const arc_i64 kDurationMinSeconds = -315576000000LL;
- static const arc_i64 kDurationMaxSeconds = 315576000000LL;
+ static constexpr arc_i64 kTimestampMaxSeconds = 253402300799LL;
+ static constexpr arc_i32 kTimestampMinNanoseconds = 0;
+ static constexpr arc_i32 kTimestampMaxNanoseconds = 999999999;
+ static constexpr arc_i64 kDurationMinSeconds = -315576000000LL;
+ static constexpr arc_i64 kDurationMaxSeconds = 315576000000LL;
+ static constexpr arc_i32 kDurationMinNanoseconds = -999999999;
+ static constexpr arc_i32 kDurationMaxNanoseconds = 999999999;
+
+ static bool IsTimestampValid(const Timestamp& timestamp) {
+ return timestamp.seconds() <= kTimestampMaxSeconds &&
+ timestamp.seconds() >= kTimestampMinSeconds &&
+ timestamp.nanos() <= kTimestampMaxNanoseconds &&
+ timestamp.nanos() >= kTimestampMinNanoseconds;
+ }
+
+ static bool IsDurationValid(const Duration& duration) {
+ return duration.seconds() <= kDurationMaxSeconds &&
+ duration.seconds() >= kDurationMinSeconds &&
+ duration.nanos() <= kDurationMaxNanoseconds &&
+ duration.nanos() >= kDurationMinNanoseconds &&
+ !(duration.seconds() >= 1 && duration.nanos() < 0) &&
+ !(duration.seconds() <= -1 && duration.nanos() > 0);
+ }
// Converts Timestamp to/from RFC 3339 date string format.
// Generated output will always be Z-normalized and uses 3, 6 or 9
@@ -91,7 +111,7 @@ class PROTOBUF_EXPORT TimeUtil {
// Example of accepted format:
// "1972-01-01T10:00:20.021-05:00"
static TProtoStringType ToString(const Timestamp& timestamp);
- static bool FromString(const TProtoStringType& value, Timestamp* timestamp);
+ static bool FromString(y_absl::string_view value, Timestamp* timestamp);
// Converts Duration to/from string format. The string format will contains
// 3, 6, or 9 fractional digits depending on the precision required to
@@ -100,11 +120,8 @@ class PROTOBUF_EXPORT TimeUtil {
// The range that can be represented by Duration is from -315,576,000,000
// to +315,576,000,000 inclusive (in seconds).
static TProtoStringType ToString(const Duration& duration);
- static bool FromString(const TProtoStringType& value, Duration* timestamp);
+ static bool FromString(y_absl::string_view value, Duration* duration);
-#ifdef GetCurrentTime
-#undef GetCurrentTime // Visual Studio has macro GetCurrentTime
-#endif
// Gets the current UTC time.
static Timestamp GetCurrentTime();
// Returns the Time representing "1970-01-01 00:00:00".
@@ -309,6 +326,6 @@ inline std::ostream& operator<<(std::ostream& out, const Timestamp& t) {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_UTIL_TIME_UTIL_H__
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 00082f2adfe..7c11cddff49 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/type_resolver.h
+++ b/contrib/libs/protobuf/src/google/protobuf/util/type_resolver.h
@@ -35,13 +35,13 @@
#include <string>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/type.pb.h>
-#include <google/protobuf/stubs/status.h>
-#include <google/protobuf/stubs/status.h>
+#include "google/protobuf/type.pb.h"
+#include "y_absl/status/status.h"
+#include "google/protobuf/port.h"
+
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -54,24 +54,23 @@ namespace util {
class PROTOBUF_EXPORT TypeResolver {
public:
TypeResolver() {}
+ TypeResolver(const TypeResolver&) = delete;
+ TypeResolver& operator=(const TypeResolver&) = delete;
virtual ~TypeResolver() {}
// Resolves a type url for a message type.
- virtual util::Status ResolveMessageType(
+ virtual y_absl::Status ResolveMessageType(
const TProtoStringType& type_url, google::protobuf::Type* message_type) = 0;
// Resolves a type url for an enum type.
- virtual util::Status ResolveEnumType(const TProtoStringType& type_url,
+ virtual y_absl::Status ResolveEnumType(const TProtoStringType& type_url,
google::protobuf::Enum* enum_type) = 0;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeResolver);
};
} // namespace util
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_H__
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 94079dc4e1a..7b751263984 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
@@ -28,20 +28,23 @@
// (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/util/type_resolver_util.h>
+#include "google/protobuf/util/type_resolver_util.h"
-#include <google/protobuf/type.pb.h>
-#include <google/protobuf/wrappers.pb.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/descriptor.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>
+#include "google/protobuf/type.pb.h"
+#include "google/protobuf/wrappers.pb.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/descriptor.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/status/status.h"
+#include "y_absl/strings/escaping.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/strings/strip.h"
+#include "google/protobuf/io/strtod.h"
+#include "google/protobuf/util/type_resolver.h"
// clang-format off
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
// clang-format on
namespace google {
@@ -66,42 +69,42 @@ using google::protobuf::UInt64Value;
class DescriptorPoolTypeResolver : public TypeResolver {
public:
- DescriptorPoolTypeResolver(const TProtoStringType& url_prefix,
+ DescriptorPoolTypeResolver(y_absl::string_view url_prefix,
const DescriptorPool* pool)
: url_prefix_(url_prefix), pool_(pool) {}
- util::Status ResolveMessageType(const TProtoStringType& type_url,
+ y_absl::Status ResolveMessageType(const TProtoStringType& type_url,
Type* type) override {
TProtoStringType type_name;
- util::Status status = ParseTypeUrl(type_url, &type_name);
+ y_absl::Status status = ParseTypeUrl(type_url, &type_name);
if (!status.ok()) {
return status;
}
const Descriptor* descriptor = pool_->FindMessageTypeByName(type_name);
if (descriptor == NULL) {
- return util::NotFoundError("Invalid type URL, unknown type: " +
- type_name);
+ return y_absl::NotFoundError(
+ y_absl::StrCat("Invalid type URL, unknown type: ", type_name));
}
ConvertDescriptor(descriptor, type);
- return util::Status();
+ return y_absl::Status();
}
- util::Status ResolveEnumType(const TProtoStringType& type_url,
+ y_absl::Status ResolveEnumType(const TProtoStringType& type_url,
Enum* enum_type) override {
TProtoStringType type_name;
- util::Status status = ParseTypeUrl(type_url, &type_name);
+ y_absl::Status status = ParseTypeUrl(type_url, &type_name);
if (!status.ok()) {
return status;
}
const EnumDescriptor* descriptor = pool_->FindEnumTypeByName(type_name);
if (descriptor == NULL) {
- return util::InvalidArgumentError("Invalid type URL, unknown type: " +
- type_name);
+ return y_absl::InvalidArgumentError(
+ y_absl::StrCat("Invalid type URL, unknown type: ", type_name));
}
ConvertEnumDescriptor(descriptor, enum_type);
- return util::Status();
+ return y_absl::Status();
}
private:
@@ -296,50 +299,52 @@ class DescriptorPoolTypeResolver : public TypeResolver {
}
TProtoStringType GetTypeUrl(const Descriptor* descriptor) {
- return url_prefix_ + "/" + descriptor->full_name();
+ return y_absl::StrCat(url_prefix_, "/", descriptor->full_name());
}
TProtoStringType GetTypeUrl(const EnumDescriptor* descriptor) {
- return url_prefix_ + "/" + descriptor->full_name();
+ return y_absl::StrCat(url_prefix_, "/", descriptor->full_name());
}
- util::Status ParseTypeUrl(const TProtoStringType& type_url,
+ y_absl::Status ParseTypeUrl(y_absl::string_view type_url,
TProtoStringType* type_name) {
- if (type_url.substr(0, url_prefix_.size() + 1) != url_prefix_ + "/") {
- return util::InvalidArgumentError(
- StrCat("Invalid type URL, type URLs must be of the form '",
+ y_absl::string_view stripped = type_url;
+ if (!y_absl::ConsumePrefix(&stripped, url_prefix_) ||
+ !y_absl::ConsumePrefix(&stripped, "/")) {
+ return y_absl::InvalidArgumentError(
+ y_absl::StrCat("Invalid type URL, type URLs must be of the form '",
url_prefix_, "/<typename>', got: ", type_url));
}
- *type_name = type_url.substr(url_prefix_.size() + 1);
- return util::Status();
+ *type_name = TProtoStringType(stripped);
+ return y_absl::Status();
}
TProtoStringType DefaultValueAsString(const FieldDescriptor* descriptor) {
switch (descriptor->cpp_type()) {
case FieldDescriptor::CPPTYPE_INT32:
- return StrCat(descriptor->default_value_int32());
+ return y_absl::StrCat(descriptor->default_value_int32());
break;
case FieldDescriptor::CPPTYPE_INT64:
- return StrCat(descriptor->default_value_int64());
+ return y_absl::StrCat(descriptor->default_value_int64());
break;
case FieldDescriptor::CPPTYPE_UINT32:
- return StrCat(descriptor->default_value_uint32());
+ return y_absl::StrCat(descriptor->default_value_uint32());
break;
case FieldDescriptor::CPPTYPE_UINT64:
- return StrCat(descriptor->default_value_uint64());
+ return y_absl::StrCat(descriptor->default_value_uint64());
break;
case FieldDescriptor::CPPTYPE_FLOAT:
- return SimpleFtoa(descriptor->default_value_float());
+ return io::SimpleFtoa(descriptor->default_value_float());
break;
case FieldDescriptor::CPPTYPE_DOUBLE:
- return SimpleDtoa(descriptor->default_value_double());
+ return io::SimpleDtoa(descriptor->default_value_double());
break;
case FieldDescriptor::CPPTYPE_BOOL:
return descriptor->default_value_bool() ? "true" : "false";
break;
case FieldDescriptor::CPPTYPE_STRING:
if (descriptor->type() == FieldDescriptor::TYPE_BYTES) {
- return CEscape(descriptor->default_value_string());
+ return y_absl::CEscape(descriptor->default_value_string());
} else {
return descriptor->default_value_string();
}
@@ -348,7 +353,7 @@ class DescriptorPoolTypeResolver : public TypeResolver {
return descriptor->default_value_enum()->name();
break;
case FieldDescriptor::CPPTYPE_MESSAGE:
- GOOGLE_LOG(DFATAL) << "Messages can't have default values!";
+ Y_ABSL_DLOG(FATAL) << "Messages can't have default values!";
break;
}
return "";
@@ -360,7 +365,7 @@ class DescriptorPoolTypeResolver : public TypeResolver {
} // namespace
-TypeResolver* NewTypeResolverForDescriptorPool(const TProtoStringType& url_prefix,
+TypeResolver* NewTypeResolverForDescriptorPool(y_absl::string_view url_prefix,
const DescriptorPool* pool) {
return new DescriptorPoolTypeResolver(url_prefix, pool);
}
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 9d4fdaf8b89..4499a43c022 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
@@ -33,27 +33,28 @@
#ifndef GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_UTIL_H__
#define GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_UTIL_H__
-#include <string>
+#include "y_absl/strings/string_view.h"
+
#include <google/protobuf/stubs/port.h>
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
namespace google {
namespace protobuf {
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
// pool. Caller takes ownership of the returned TypeResolver.
PROTOBUF_EXPORT TypeResolver* NewTypeResolverForDescriptorPool(
- const TProtoStringType& url_prefix, const DescriptorPool* pool);
+ y_absl::string_view url_prefix, const DescriptorPool* pool);
} // namespace util
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_UTIL_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/wire_format.cc b/contrib/libs/protobuf/src/google/protobuf/wire_format.cc
index 82b181bae44..ed9d386a2d2 100644
--- a/contrib/libs/protobuf/src/google/protobuf/wire_format.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/wire_format.cc
@@ -32,30 +32,31 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/wire_format.h>
+#include "google/protobuf/wire_format.h"
#include <stack>
#include <string>
#include <vector>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.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>
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/cord.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/dynamic_message.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/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>
+#include "google/protobuf/port_def.inc"
const size_t kMapEntryTagByteSize = 2;
@@ -401,7 +402,7 @@ bool WireFormat::ParseAndMergeMessageSetField(arc_ui32 field_number,
field->type() != FieldDescriptor::TYPE_MESSAGE) {
// This shouldn't happen as we only allow optional message extensions to
// MessageSet.
- GOOGLE_LOG(ERROR) << "Extensions of MessageSets must be optional messages.";
+ Y_ABSL_LOG(ERROR) << "Extensions of MessageSets must be optional messages.";
return false;
} else {
Message* sub_message = message_reflection->MutableMessage(
@@ -657,9 +658,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 +671,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 +702,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 +726,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.
@@ -779,8 +790,8 @@ const char* WireFormat::_InternalParse(Message* msg, const char* ptr,
internal::ParseContext* ctx) {
const Descriptor* descriptor = msg->GetDescriptor();
const Reflection* reflection = msg->GetReflection();
- GOOGLE_DCHECK(descriptor);
- GOOGLE_DCHECK(reflection);
+ Y_ABSL_DCHECK(descriptor);
+ Y_ABSL_DCHECK(reflection);
if (descriptor->options().message_set_wire_format()) {
MessageSetParser message_set{msg, descriptor, reflection};
return message_set.ParseMessageSet(ptr, ctx);
@@ -879,7 +890,7 @@ const char* WireFormat::_InternalParseAndMergeField(
case FieldDescriptor::TYPE_GROUP:
case FieldDescriptor::TYPE_MESSAGE:
case FieldDescriptor::TYPE_BYTES:
- GOOGLE_LOG(FATAL) << "Can't reach";
+ Y_ABSL_LOG(FATAL) << "Can't reach";
return nullptr;
}
} else {
@@ -1019,7 +1030,25 @@ const char* WireFormat::_InternalParseAndMergeField(
sub_message =
reflection->MutableMessage(msg, field, ctx->data().factory);
}
- return ctx->ParseMessage(sub_message, ptr);
+ ptr = ctx->ParseMessage(sub_message, ptr);
+
+ // For map entries, if the value is an unknown enum we have to push it
+ // into the unknown field set and remove it from the list.
+ if (ptr != nullptr && field->is_map()) {
+ auto* value_field = field->message_type()->map_value();
+ auto* enum_type = value_field->enum_type();
+ if (enum_type != nullptr &&
+ !internal::cpp::HasPreservingUnknownEnumSemantics(value_field) &&
+ enum_type->FindValueByNumber(
+ sub_message->GetReflection()->GetEnumValue(
+ *sub_message, value_field)) == nullptr) {
+ reflection->MutableUnknownFields(msg)->AddLengthDelimited(
+ field->number(), sub_message->SerializeAsString());
+ reflection->RemoveLast(msg, field);
+ }
+ }
+
+ return ptr;
}
}
@@ -1070,7 +1099,7 @@ uint8_t* SerializeMapKeyWithCachedSizes(const FieldDescriptor* field,
case FieldDescriptor::TYPE_MESSAGE:
case FieldDescriptor::TYPE_BYTES:
case FieldDescriptor::TYPE_ENUM:
- GOOGLE_LOG(FATAL) << "Unsupported";
+ Y_ABSL_LOG(FATAL) << "Unsupported";
break;
#define CASE_TYPE(FieldType, CamelFieldType, CamelCppType) \
case FieldDescriptor::TYPE_##FieldType: \
@@ -1159,7 +1188,7 @@ class MapKeySorter {
class MapKeyComparator {
public:
bool operator()(const MapKey& a, const MapKey& b) const {
- GOOGLE_DCHECK(a.type() == b.type());
+ Y_ABSL_DCHECK(a.type() == b.type());
switch (a.type()) {
#define CASE_TYPE(CppType, CamelCppType) \
case FieldDescriptor::CPPTYPE_##CppType: { \
@@ -1174,7 +1203,7 @@ class MapKeySorter {
#undef CASE_TYPE
default:
- GOOGLE_LOG(DFATAL) << "Invalid key for map field.";
+ Y_ABSL_DLOG(FATAL) << "Invalid key for map field.";
return true;
}
}
@@ -1316,7 +1345,7 @@ uint8_t* WireFormat::InternalSerializeField(const FieldDescriptor* field,
HANDLE_PRIMITIVE_TYPE(BOOL, bool, Bool, Bool)
#undef HANDLE_PRIMITIVE_TYPE
default:
- GOOGLE_LOG(FATAL) << "Invalid descriptor";
+ Y_ABSL_LOG(FATAL) << "Invalid descriptor";
}
return target;
}
@@ -1532,7 +1561,7 @@ size_t WireFormat::FieldByteSize(const FieldDescriptor* field,
size_t MapKeyDataOnlyByteSize(const FieldDescriptor* field,
const MapKey& value) {
- GOOGLE_DCHECK_EQ(FieldDescriptor::TypeToCppType(field->type()), value.type());
+ Y_ABSL_DCHECK_EQ(FieldDescriptor::TypeToCppType(field->type()), value.type());
switch (field->type()) {
case FieldDescriptor::TYPE_DOUBLE:
case FieldDescriptor::TYPE_FLOAT:
@@ -1540,7 +1569,7 @@ size_t MapKeyDataOnlyByteSize(const FieldDescriptor* field,
case FieldDescriptor::TYPE_MESSAGE:
case FieldDescriptor::TYPE_BYTES:
case FieldDescriptor::TYPE_ENUM:
- GOOGLE_LOG(FATAL) << "Unsupported";
+ Y_ABSL_LOG(FATAL) << "Unsupported";
return 0;
#define CASE_TYPE(FieldType, CamelFieldType, CamelCppType) \
case FieldDescriptor::TYPE_##FieldType: \
@@ -1567,7 +1596,7 @@ size_t MapKeyDataOnlyByteSize(const FieldDescriptor* field,
#undef CASE_TYPE
#undef FIXED_CASE_TYPE
}
- GOOGLE_LOG(FATAL) << "Cannot get here";
+ Y_ABSL_LOG(FATAL) << "Cannot get here";
return 0;
}
@@ -1575,7 +1604,7 @@ static size_t MapValueRefDataOnlyByteSize(const FieldDescriptor* field,
const MapValueConstRef& value) {
switch (field->type()) {
case FieldDescriptor::TYPE_GROUP:
- GOOGLE_LOG(FATAL) << "Unsupported";
+ Y_ABSL_LOG(FATAL) << "Unsupported";
return 0;
#define CASE_TYPE(FieldType, CamelFieldType, CamelCppType) \
case FieldDescriptor::TYPE_##FieldType: \
@@ -1607,7 +1636,7 @@ static size_t MapValueRefDataOnlyByteSize(const FieldDescriptor* field,
#undef CASE_TYPE
#undef FIXED_CASE_TYPE
}
- GOOGLE_LOG(FATAL) << "Cannot get here";
+ Y_ABSL_LOG(FATAL) << "Cannot get here";
return 0;
}
@@ -1755,4 +1784,4 @@ size_t ComputeUnknownFieldsSize(const InternalMetadata& metadata,
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protobuf/src/google/protobuf/wire_format.h b/contrib/libs/protobuf/src/google/protobuf/wire_format.h
index 0be9ca22f7f..164c03f3d08 100644
--- a/contrib/libs/protobuf/src/google/protobuf/wire_format.h
+++ b/contrib/libs/protobuf/src/google/protobuf/wire_format.h
@@ -39,23 +39,23 @@
#ifndef GOOGLE_PROTOBUF_WIRE_FORMAT_H__
#define GOOGLE_PROTOBUF_WIRE_FORMAT_H__
-
-#include <google/protobuf/stubs/common.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/common.h"
+#include "y_absl/base/casts.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/generated_message_util.h"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/metadata_lite.h"
+#include "google/protobuf/parse_context.h"
+#include "google/protobuf/port.h"
+#include "google/protobuf/wire_format_lite.h"
#ifdef SWIG
#error "You cannot SWIG proto headers"
#endif
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -79,6 +79,8 @@ namespace internal {
// This class is really a namespace that contains only static methods
class PROTOBUF_EXPORT WireFormat {
public:
+ WireFormat() = delete;
+
// Given a field return its WireType
static inline WireFormatLite::WireType WireTypeForField(
const FieldDescriptor* field);
@@ -127,7 +129,7 @@ class PROTOBUF_EXPORT WireFormat {
int expected_endpoint = output->ByteCount() + size;
output->SetCur(
_InternalSerialize(message, output->Cur(), output->EpsCopy()));
- GOOGLE_CHECK_EQ(output->ByteCount(), expected_endpoint)
+ Y_ABSL_CHECK_EQ(output->ByteCount(), expected_endpoint)
<< ": Protocol message serialized to a size different from what was "
"originally expected. Perhaps it was modified by another thread "
"during serialization?";
@@ -285,6 +287,7 @@ class PROTOBUF_EXPORT WireFormat {
private:
struct MessageSetParser;
+ friend class TcParser;
// Skip a MessageSet field.
static bool SkipMessageSetField(io::CodedInputStream* input,
arc_ui32 field_number,
@@ -301,8 +304,6 @@ class PROTOBUF_EXPORT WireFormat {
arc_ui64 tag,
const Reflection* reflection,
const FieldDescriptor* field);
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(WireFormat);
};
// Subclass of FieldSkipper which saves skipped fields to an UnknownFieldSet.
@@ -337,7 +338,7 @@ inline WireFormatLite::WireType WireFormat::WireTypeForFieldType(
// Some compilers don't like enum -> enum casts, so we implicit_cast to
// int first.
return WireFormatLite::WireTypeForFieldType(
- static_cast<WireFormatLite::FieldType>(implicit_cast<int>(type)));
+ static_cast<WireFormatLite::FieldType>(y_absl::implicit_cast<int>(type)));
}
inline arc_ui32 WireFormat::MakeTag(const FieldDescriptor* field) {
@@ -350,14 +351,15 @@ inline size_t WireFormat::TagSize(int field_number,
// int first.
return WireFormatLite::TagSize(
field_number,
- static_cast<WireFormatLite::FieldType>(implicit_cast<int>(type)));
+ static_cast<WireFormatLite::FieldType>(y_absl::implicit_cast<int>(type)));
}
inline void WireFormat::VerifyUTF8String(const char* data, int size,
WireFormat::Operation op) {
#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
- WireFormatLite::VerifyUtf8String(
- data, size, static_cast<WireFormatLite::Operation>(op), nullptr);
+ WireFormatLite::VerifyUtf8String(data, size,
+ static_cast<WireFormatLite::Operation>(op),
+ /* field_name = */ "");
#else
// Avoid the compiler warning about unused variables.
(void)data;
@@ -409,6 +411,6 @@ uint8_t* SerializeMapKeyWithCachedSizes(const FieldDescriptor* field,
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_WIRE_FORMAT_H__
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 5abdc7ab728..627f0a0ab20 100644
--- a/contrib/libs/protobuf/src/google/protobuf/wire_format_lite.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/wire_format_lite.cc
@@ -32,23 +32,23 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/wire_format_lite.h>
+#include "google/protobuf/wire_format_lite.h"
#include <limits>
#include <stack>
#include <string>
#include <vector>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.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>
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/cord.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+#include "utf8_validity.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -64,6 +64,14 @@ const int WireFormatLite::kMessageSetMessageTag;
#endif
+constexpr size_t WireFormatLite::kFixed32Size;
+constexpr size_t WireFormatLite::kFixed64Size;
+constexpr size_t WireFormatLite::kSFixed32Size;
+constexpr size_t WireFormatLite::kSFixed64Size;
+constexpr size_t WireFormatLite::kFloatSize;
+constexpr size_t WireFormatLite::kDoubleSize;
+constexpr size_t WireFormatLite::kBoolSize;
+
// IBM xlC requires prefixing constants with WireFormatLite::
const size_t WireFormatLite::kMessageSetItemTagsSize =
io::CodedOutputStream::StaticVarintSize32<
@@ -483,7 +491,7 @@ void WireFormatLite::WriteString(int field_number, const TProtoStringType& value
io::CodedOutputStream* output) {
// String is for UTF-8 text only
WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output);
- GOOGLE_CHECK_LE(value.size(), kInt32MaxSize);
+ Y_ABSL_CHECK_LE(value.size(), kInt32MaxSize);
output->WriteVarint32(value.size());
output->WriteString(value);
}
@@ -492,14 +500,14 @@ void WireFormatLite::WriteStringMaybeAliased(int field_number,
io::CodedOutputStream* output) {
// String is for UTF-8 text only
WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output);
- GOOGLE_CHECK_LE(value.size(), kInt32MaxSize);
+ Y_ABSL_CHECK_LE(value.size(), kInt32MaxSize);
output->WriteVarint32(value.size());
output->WriteRawMaybeAliased(value.data(), value.size());
}
void WireFormatLite::WriteBytes(int field_number, const TProtoStringType& value,
io::CodedOutputStream* output) {
WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output);
- GOOGLE_CHECK_LE(value.size(), kInt32MaxSize);
+ Y_ABSL_CHECK_LE(value.size(), kInt32MaxSize);
output->WriteVarint32(value.size());
output->WriteString(value);
}
@@ -507,7 +515,7 @@ void WireFormatLite::WriteBytesMaybeAliased(int field_number,
const TProtoStringType& value,
io::CodedOutputStream* output) {
WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output);
- GOOGLE_CHECK_LE(value.size(), kInt32MaxSize);
+ Y_ABSL_CHECK_LE(value.size(), kInt32MaxSize);
output->WriteVarint32(value.size());
output->WriteRawMaybeAliased(value.data(), value.size());
}
@@ -593,34 +601,41 @@ bool WireFormatLite::ReadBytes(io::CodedInputStream* input, TProtoStringType** p
return ReadBytesToString(input, *p);
}
-void PrintUTF8ErrorLog(StringPiece message_name,
- StringPiece field_name, const char* operation_str,
+void PrintUTF8ErrorLog(y_absl::string_view message_name,
+ y_absl::string_view field_name, const char* operation_str,
bool emit_stacktrace) {
+ #ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
TProtoStringType stacktrace;
(void)emit_stacktrace; // Parameter is used by Google-internal code.
TProtoStringType quoted_field_name = "";
if (!field_name.empty()) {
if (!message_name.empty()) {
quoted_field_name =
- StrCat(" '", message_name, ".", field_name, "'");
+ y_absl::StrCat(" '", message_name, ".", field_name, "'");
} else {
- quoted_field_name = StrCat(" '", field_name, "'");
+ quoted_field_name = y_absl::StrCat(" '", field_name, "'");
}
}
TProtoStringType error_message =
- StrCat("String field", quoted_field_name,
+ y_absl::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;
+ Y_ABSL_LOG(ERROR) << error_message;
+ #else
+ (void)message_name;
+ (void)field_name;
+ (void)emit_stacktrace;
+ (void)operation_str;
+ #endif
}
bool WireFormatLite::VerifyUtf8String(const char* data, int size, Operation op,
const char* field_name) {
- if (!IsStructurallyValidUTF8(data, size)) {
+ if (!utf8_range::IsStructurallyValid({data, static_cast<size_t>(size)})) {
const char* operation_str = nullptr;
switch (op) {
case PARSE:
@@ -815,4 +830,4 @@ size_t WireFormatLite::SInt64Size(const RepeatedField<arc_i64>& value) {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
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 d18870f60a3..f92b6546df4 100644
--- a/contrib/libs/protobuf/src/google/protobuf/wire_format_lite.h
+++ b/contrib/libs/protobuf/src/google/protobuf/wire_format_lite.h
@@ -40,18 +40,18 @@
#ifndef GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_H__
#define GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_H__
-
#include <limits>
#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/repeated_field.h>
+#include "google/protobuf/stubs/common.h"
+#include "google/protobuf/port.h"
+#include "y_absl/base/casts.h"
+#include "y_absl/log/absl_check.h"
+#include "google/protobuf/arenastring.h"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/message_lite.h"
+#include "google/protobuf/port.h"
+#include "google/protobuf/repeated_field.h"
// Avoid conflict with iOS where <ConditionalMacros.h> #defines TYPE_BOOL.
@@ -66,7 +66,7 @@
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -83,6 +83,7 @@ namespace internal {
// This class is really a namespace that contains only static methods.
class PROTOBUF_EXPORT WireFormatLite {
public:
+ WireFormatLite() = delete;
// -----------------------------------------------------------------
// Helper constants and functions related to the format. These are
// mostly meant for internal and generated code to use.
@@ -98,7 +99,11 @@ class PROTOBUF_EXPORT WireFormatLite {
// identifies the encoding of this data, it is possible to skip
// unrecognized fields for forwards compatibility.
- enum WireType {
+ enum WireType
+#ifndef SWIG
+ : int
+#endif // !SWIG
+ {
WIRETYPE_VARINT = 0,
WIRETYPE_FIXED64 = 1,
WIRETYPE_LENGTH_DELIMITED = 2,
@@ -738,8 +743,6 @@ class PROTOBUF_EXPORT WireFormatLite {
static const WireFormatLite::WireType kWireTypeForFieldType[];
static void WriteSubMessageMaybeToArray(int size, const MessageLite& value,
io::CodedOutputStream* output);
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(WireFormatLite);
};
// A class which deals with unknown values. The default implementation just
@@ -814,19 +817,19 @@ inline size_t WireFormatLite::TagSize(int field_number,
}
inline arc_ui32 WireFormatLite::EncodeFloat(float value) {
- return bit_cast<arc_ui32>(value);
+ return y_absl::bit_cast<arc_ui32>(value);
}
inline float WireFormatLite::DecodeFloat(arc_ui32 value) {
- return bit_cast<float>(value);
+ return y_absl::bit_cast<float>(value);
}
inline arc_ui64 WireFormatLite::EncodeDouble(double value) {
- return bit_cast<arc_ui64>(value);
+ return y_absl::bit_cast<arc_ui64>(value);
}
inline double WireFormatLite::DecodeDouble(arc_ui64 value) {
- return bit_cast<double>(value);
+ return y_absl::bit_cast<double>(value);
}
// ZigZag Transform: Encodes signed integers so that they can be
@@ -1078,7 +1081,7 @@ template <typename CType, enum WireFormatLite::FieldType DeclaredType>
inline bool WireFormatLite::ReadRepeatedFixedSizePrimitive(
int tag_size, arc_ui32 tag, io::CodedInputStream* input,
RepeatedField<CType>* values) {
- GOOGLE_DCHECK_EQ(UInt32Size(tag), static_cast<size_t>(tag_size));
+ Y_ABSL_DCHECK_EQ(UInt32Size(tag), static_cast<size_t>(tag_size));
CType value;
if (!ReadPrimitive<CType, DeclaredType>(input, &value)) return false;
values->Add(value);
@@ -1439,7 +1442,7 @@ inline uint8_t* WireFormatLite::WritePrimitiveNoTagToArray(
const RepeatedField<T>& value, uint8_t* (*Writer)(T, uint8_t*),
uint8_t* target) {
const int n = value.size();
- GOOGLE_DCHECK_GT(n, 0);
+ Y_ABSL_DCHECK_GT(n, 0);
const T* ii = value.data();
int i = 0;
@@ -1458,7 +1461,7 @@ inline uint8_t* WireFormatLite::WriteFixedNoTagToArray(
(void)Writer;
const int n = value.size();
- GOOGLE_DCHECK_GT(n, 0);
+ Y_ABSL_DCHECK_GT(n, 0);
const T* ii = value.data();
const int bytes = n * static_cast<int>(sizeof(ii[0]));
@@ -1827,6 +1830,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;
@@ -1835,26 +1841,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;
@@ -1865,11 +1879,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;
@@ -1890,6 +1902,6 @@ bool ParseMessageSetItemImpl(io::CodedInputStream* input, MS ms) {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_H__
diff --git a/contrib/libs/protobuf/src/google/protobuf/wrappers.pb.cc b/contrib/libs/protobuf/src/google/protobuf/wrappers.pb.cc
index ebd26d300c9..ee07edd7943 100644
--- a/contrib/libs/protobuf/src/google/protobuf/wrappers.pb.cc
+++ b/contrib/libs/protobuf/src/google/protobuf/wrappers.pb.cc
@@ -1,298 +1,352 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/wrappers.proto
-#include <google/protobuf/wrappers.pb.h>
+#include "google/protobuf/wrappers.pb.h"
#include <algorithm>
-
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/extension_set.h>
-#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/reflection_ops.h>
-#include <google/protobuf/wire_format.h>
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/extension_set.h"
+#include "google/protobuf/wire_format_lite.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/reflection_ops.h"
+#include "google/protobuf/wire_format.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+// Must be included last.
+#include "google/protobuf/port_def.inc"
PROTOBUF_PRAGMA_INIT_SEG
-
namespace _pb = ::PROTOBUF_NAMESPACE_ID;
-namespace _pbi = _pb::internal;
-
+namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal;
PROTOBUF_NAMESPACE_OPEN
PROTOBUF_CONSTEXPR DoubleValue::DoubleValue(
::_pbi::ConstantInitialized): _impl_{
- /*decltype(_impl_.value_)*/0
+ /*decltype(_impl_.value_)*/ 0
+
, /*decltype(_impl_._cached_size_)*/{}} {}
struct DoubleValueDefaultTypeInternal {
- PROTOBUF_CONSTEXPR DoubleValueDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR DoubleValueDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~DoubleValueDefaultTypeInternal() {}
union {
DoubleValue _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DoubleValueDefaultTypeInternal _DoubleValue_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DoubleValueDefaultTypeInternal _DoubleValue_default_instance_;
PROTOBUF_CONSTEXPR FloatValue::FloatValue(
::_pbi::ConstantInitialized): _impl_{
- /*decltype(_impl_.value_)*/0
+ /*decltype(_impl_.value_)*/ 0
+
, /*decltype(_impl_._cached_size_)*/{}} {}
struct FloatValueDefaultTypeInternal {
- PROTOBUF_CONSTEXPR FloatValueDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR FloatValueDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~FloatValueDefaultTypeInternal() {}
union {
FloatValue _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FloatValueDefaultTypeInternal _FloatValue_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FloatValueDefaultTypeInternal _FloatValue_default_instance_;
PROTOBUF_CONSTEXPR Int64Value::Int64Value(
::_pbi::ConstantInitialized): _impl_{
- /*decltype(_impl_.value_)*/arc_i64{0}
+ /*decltype(_impl_.value_)*/ ::arc_i64{0}
+
, /*decltype(_impl_._cached_size_)*/{}} {}
struct Int64ValueDefaultTypeInternal {
- PROTOBUF_CONSTEXPR Int64ValueDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR Int64ValueDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~Int64ValueDefaultTypeInternal() {}
union {
Int64Value _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 Int64ValueDefaultTypeInternal _Int64Value_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 Int64ValueDefaultTypeInternal _Int64Value_default_instance_;
PROTOBUF_CONSTEXPR UInt64Value::UInt64Value(
::_pbi::ConstantInitialized): _impl_{
- /*decltype(_impl_.value_)*/arc_ui64{0u}
+ /*decltype(_impl_.value_)*/ ::arc_ui64{0u}
+
, /*decltype(_impl_._cached_size_)*/{}} {}
struct UInt64ValueDefaultTypeInternal {
- PROTOBUF_CONSTEXPR UInt64ValueDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR UInt64ValueDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~UInt64ValueDefaultTypeInternal() {}
union {
UInt64Value _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UInt64ValueDefaultTypeInternal _UInt64Value_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UInt64ValueDefaultTypeInternal _UInt64Value_default_instance_;
PROTOBUF_CONSTEXPR Int32Value::Int32Value(
::_pbi::ConstantInitialized): _impl_{
- /*decltype(_impl_.value_)*/0
+ /*decltype(_impl_.value_)*/ 0
+
, /*decltype(_impl_._cached_size_)*/{}} {}
struct Int32ValueDefaultTypeInternal {
- PROTOBUF_CONSTEXPR Int32ValueDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR Int32ValueDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~Int32ValueDefaultTypeInternal() {}
union {
Int32Value _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 Int32ValueDefaultTypeInternal _Int32Value_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 Int32ValueDefaultTypeInternal _Int32Value_default_instance_;
PROTOBUF_CONSTEXPR UInt32Value::UInt32Value(
::_pbi::ConstantInitialized): _impl_{
- /*decltype(_impl_.value_)*/0u
+ /*decltype(_impl_.value_)*/ 0u
+
, /*decltype(_impl_._cached_size_)*/{}} {}
struct UInt32ValueDefaultTypeInternal {
- PROTOBUF_CONSTEXPR UInt32ValueDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR UInt32ValueDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~UInt32ValueDefaultTypeInternal() {}
union {
UInt32Value _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UInt32ValueDefaultTypeInternal _UInt32Value_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UInt32ValueDefaultTypeInternal _UInt32Value_default_instance_;
PROTOBUF_CONSTEXPR BoolValue::BoolValue(
::_pbi::ConstantInitialized): _impl_{
- /*decltype(_impl_.value_)*/false
+ /*decltype(_impl_.value_)*/ false
+
, /*decltype(_impl_._cached_size_)*/{}} {}
struct BoolValueDefaultTypeInternal {
- PROTOBUF_CONSTEXPR BoolValueDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR BoolValueDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~BoolValueDefaultTypeInternal() {}
union {
BoolValue _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 BoolValueDefaultTypeInternal _BoolValue_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 BoolValueDefaultTypeInternal _BoolValue_default_instance_;
PROTOBUF_CONSTEXPR StringValue::StringValue(
::_pbi::ConstantInitialized): _impl_{
- /*decltype(_impl_.value_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
+ /*decltype(_impl_.value_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
, /*decltype(_impl_._cached_size_)*/{}} {}
struct StringValueDefaultTypeInternal {
- PROTOBUF_CONSTEXPR StringValueDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR StringValueDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~StringValueDefaultTypeInternal() {}
union {
StringValue _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 StringValueDefaultTypeInternal _StringValue_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 StringValueDefaultTypeInternal _StringValue_default_instance_;
PROTOBUF_CONSTEXPR BytesValue::BytesValue(
::_pbi::ConstantInitialized): _impl_{
- /*decltype(_impl_.value_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
+ /*decltype(_impl_.value_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
, /*decltype(_impl_._cached_size_)*/{}} {}
struct BytesValueDefaultTypeInternal {
- PROTOBUF_CONSTEXPR BytesValueDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR BytesValueDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~BytesValueDefaultTypeInternal() {}
union {
BytesValue _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 BytesValueDefaultTypeInternal _BytesValue_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 BytesValueDefaultTypeInternal _BytesValue_default_instance_;
PROTOBUF_NAMESPACE_CLOSE
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_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DoubleValue, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DoubleValue, _impl_.value_),
- ~0u, // no _has_bits_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FloatValue, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FloatValue, _impl_.value_),
- ~0u, // no _has_bits_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Int64Value, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Int64Value, _impl_.value_),
- ~0u, // no _has_bits_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UInt64Value, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UInt64Value, _impl_.value_),
- ~0u, // no _has_bits_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Int32Value, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Int32Value, _impl_.value_),
- ~0u, // no _has_bits_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UInt32Value, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UInt32Value, _impl_.value_),
- ~0u, // no _has_bits_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::BoolValue, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::BoolValue, _impl_.value_),
- ~0u, // no _has_bits_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::StringValue, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::StringValue, _impl_.value_),
- ~0u, // no _has_bits_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::BytesValue, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::BytesValue, _impl_.value_),
+static constexpr const ::_pb::EnumDescriptor**
+ file_level_enum_descriptors_google_2fprotobuf_2fwrappers_2eproto = nullptr;
+static constexpr const ::_pb::ServiceDescriptor**
+ 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_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DoubleValue, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DoubleValue, _impl_.value_),
+ ~0u, // no _has_bits_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FloatValue, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FloatValue, _impl_.value_),
+ ~0u, // no _has_bits_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Int64Value, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Int64Value, _impl_.value_),
+ ~0u, // no _has_bits_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UInt64Value, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UInt64Value, _impl_.value_),
+ ~0u, // no _has_bits_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Int32Value, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Int32Value, _impl_.value_),
+ ~0u, // no _has_bits_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UInt32Value, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UInt32Value, _impl_.value_),
+ ~0u, // no _has_bits_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::BoolValue, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::BoolValue, _impl_.value_),
+ ~0u, // no _has_bits_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::StringValue, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::StringValue, _impl_.value_),
+ ~0u, // no _has_bits_
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::BytesValue, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::BytesValue, _impl_.value_),
};
-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)},
- { 21, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UInt64Value)},
- { 28, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Int32Value)},
- { 35, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UInt32Value)},
- { 42, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::BoolValue)},
- { 49, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::StringValue)},
- { 56, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::BytesValue)},
+
+static const ::_pbi::MigrationSchema
+ schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DoubleValue)},
+ { 9, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FloatValue)},
+ { 18, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Int64Value)},
+ { 27, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UInt64Value)},
+ { 36, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Int32Value)},
+ { 45, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UInt32Value)},
+ { 54, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::BoolValue)},
+ { 63, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::StringValue)},
+ { 72, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::BytesValue)},
};
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,
+ &::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) =
- "\n\036google/protobuf/wrappers.proto\022\017google"
- ".protobuf\"\034\n\013DoubleValue\022\r\n\005value\030\001 \001(\001\""
- "\033\n\nFloatValue\022\r\n\005value\030\001 \001(\002\"\033\n\nInt64Val"
- "ue\022\r\n\005value\030\001 \001(\003\"\034\n\013UInt64Value\022\r\n\005valu"
- "e\030\001 \001(\004\"\033\n\nInt32Value\022\r\n\005value\030\001 \001(\005\"\034\n\013"
- "UInt32Value\022\r\n\005value\030\001 \001(\r\"\032\n\tBoolValue\022"
- "\r\n\005value\030\001 \001(\010\"\034\n\013StringValue\022\r\n\005value\030\001"
- " \001(\t\"\033\n\nBytesValue\022\r\n\005value\030\001 \001(\014B\203\001\n\023co"
- "m.google.protobufB\rWrappersProtoP\001Z1goog"
- "le.golang.org/protobuf/types/known/wrapp"
- "erspb\370\001\001\242\002\003GPB\252\002\036Google.Protobuf.WellKno"
- "wnTypesb\006proto3"
- ;
-static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once;
+const char descriptor_table_protodef_google_2fprotobuf_2fwrappers_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ "\n\036google/protobuf/wrappers.proto\022\017google"
+ ".protobuf\"\034\n\013DoubleValue\022\r\n\005value\030\001 \001(\001\""
+ "\033\n\nFloatValue\022\r\n\005value\030\001 \001(\002\"\033\n\nInt64Val"
+ "ue\022\r\n\005value\030\001 \001(\003\"\034\n\013UInt64Value\022\r\n\005valu"
+ "e\030\001 \001(\004\"\033\n\nInt32Value\022\r\n\005value\030\001 \001(\005\"\034\n\013"
+ "UInt32Value\022\r\n\005value\030\001 \001(\r\"\032\n\tBoolValue\022"
+ "\r\n\005value\030\001 \001(\010\"\034\n\013StringValue\022\r\n\005value\030\001"
+ " \001(\t\"\033\n\nBytesValue\022\r\n\005value\030\001 \001(\014B\203\001\n\023co"
+ "m.google.protobufB\rWrappersProtoP\001Z1goog"
+ "le.golang.org/protobuf/types/known/wrapp"
+ "erspb\370\001\001\242\002\003GPB\252\002\036Google.Protobuf.WellKno"
+ "wnTypesb\006proto3"
+};
+static ::y_absl::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,
+ 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,
+ &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,
};
+
+// This function exists to be marked as weak.
+// It can significantly speed up compilation by breaking up LLVM's SCC
+// in the .pb.cc translation units. Large translation units see a
+// reduction of more than 35% of walltime for optimized builds. Without
+// the weak attribute all the messages in the file, including all the
+// vtables and everything they use become part of the same SCC through
+// a cycle like:
+// GetMetadata -> descriptor table -> default instances ->
+// 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 ::_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_PRIORITY2 static ::_pbi::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
-
// ===================================================================
class DoubleValue::_Internal {
public:
};
-DoubleValue::DoubleValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+DoubleValue::DoubleValue(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.DoubleValue)
}
DoubleValue::DoubleValue(const DoubleValue& from)
- : ::PROTOBUF_NAMESPACE_ID::Message() {
- DoubleValue* const _this = this; (void)_this;
- new (&_impl_) Impl_{
- decltype(_impl_.value_){}
- , /*decltype(_impl_._cached_size_)*/{}};
-
- _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- _this->_impl_.value_ = from._impl_.value_;
+ : ::PROTOBUF_NAMESPACE_ID::Message(), _impl_(from._impl_) {
+ _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(
+ from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:google.protobuf.DoubleValue)
}
-inline void DoubleValue::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void DoubleValue::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
- decltype(_impl_.value_){0}
+ decltype(_impl_.value_) { 0 }
+
, /*decltype(_impl_._cached_size_)*/{}
};
}
@@ -307,7 +361,7 @@ DoubleValue::~DoubleValue() {
}
inline void DoubleValue::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
}
void DoubleValue::SetCachedSize(int size) const {
@@ -316,7 +370,7 @@ void DoubleValue::SetCachedSize(int size) const {
void DoubleValue::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.DoubleValue)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -327,16 +381,17 @@ void DoubleValue::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// double value = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 9)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 9)) {
_impl_.value_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<double>(ptr);
ptr += sizeof(double);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -361,20 +416,21 @@ failure:
#undef CHK_
}
-uint8_t* DoubleValue::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* DoubleValue::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DoubleValue)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// double value = 1;
- static_assert(sizeof(arc_ui64) == sizeof(double), "Code assumes arc_ui64 and double are the same size.");
+ static_assert(sizeof(::arc_ui64) == sizeof(double), "Code assumes ::arc_ui64 and double are the same size.");
double tmp_value = this->_internal_value();
- arc_ui64 raw_value;
+ ::arc_ui64 raw_value;
memcpy(&raw_value, &tmp_value, sizeof(tmp_value));
if (raw_value != 0) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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())) {
@@ -385,21 +441,21 @@ uint8_t* DoubleValue::_InternalSerialize(
return target;
}
-size_t DoubleValue::ByteSizeLong() const {
+::size_t DoubleValue::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.DoubleValue)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// double value = 1;
- static_assert(sizeof(arc_ui64) == sizeof(double), "Code assumes arc_ui64 and double are the same size.");
+ static_assert(sizeof(::arc_ui64) == sizeof(double), "Code assumes ::arc_ui64 and double are the same size.");
double tmp_value = this->_internal_value();
- arc_ui64 raw_value;
+ ::arc_ui64 raw_value;
memcpy(&raw_value, &tmp_value, sizeof(tmp_value));
if (raw_value != 0) {
- total_size += 1 + 8;
+ total_size += 9;
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -416,13 +472,13 @@ void DoubleValue::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PR
auto* const _this = static_cast<DoubleValue*>(&to_msg);
auto& from = static_cast<const DoubleValue&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DoubleValue)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
- static_assert(sizeof(arc_ui64) == sizeof(double), "Code assumes arc_ui64 and double are the same size.");
+ static_assert(sizeof(::arc_ui64) == sizeof(double), "Code assumes ::arc_ui64 and double are the same size.");
double tmp_value = from._internal_value();
- arc_ui64 raw_value;
+ ::arc_ui64 raw_value;
memcpy(&raw_value, &tmp_value, sizeof(tmp_value));
if (raw_value != 0) {
_this->_internal_set_value(from._internal_value());
@@ -444,6 +500,7 @@ bool DoubleValue::IsInitialized() const {
void DoubleValue::InternalSwap(DoubleValue* other) {
using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
+
swap(_impl_.value_, other->_impl_.value_);
}
@@ -452,37 +509,29 @@ void DoubleValue::InternalSwap(DoubleValue* other) {
&descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once,
file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[0]);
}
-
// ===================================================================
class FloatValue::_Internal {
public:
};
-FloatValue::FloatValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+FloatValue::FloatValue(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.FloatValue)
}
FloatValue::FloatValue(const FloatValue& from)
- : ::PROTOBUF_NAMESPACE_ID::Message() {
- FloatValue* const _this = this; (void)_this;
- new (&_impl_) Impl_{
- decltype(_impl_.value_){}
- , /*decltype(_impl_._cached_size_)*/{}};
-
- _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- _this->_impl_.value_ = from._impl_.value_;
+ : ::PROTOBUF_NAMESPACE_ID::Message(), _impl_(from._impl_) {
+ _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(
+ from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:google.protobuf.FloatValue)
}
-inline void FloatValue::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void FloatValue::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
- decltype(_impl_.value_){0}
+ decltype(_impl_.value_) { 0 }
+
, /*decltype(_impl_._cached_size_)*/{}
};
}
@@ -497,7 +546,7 @@ FloatValue::~FloatValue() {
}
inline void FloatValue::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
}
void FloatValue::SetCachedSize(int size) const {
@@ -506,7 +555,7 @@ void FloatValue::SetCachedSize(int size) const {
void FloatValue::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FloatValue)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -517,16 +566,17 @@ void FloatValue::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// float value = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 13)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 13)) {
_impl_.value_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<float>(ptr);
ptr += sizeof(float);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -551,20 +601,21 @@ failure:
#undef CHK_
}
-uint8_t* FloatValue::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* FloatValue::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FloatValue)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// float value = 1;
- static_assert(sizeof(arc_ui32) == sizeof(float), "Code assumes arc_ui32 and float are the same size.");
+ static_assert(sizeof(::arc_ui32) == sizeof(float), "Code assumes ::arc_ui32 and float are the same size.");
float tmp_value = this->_internal_value();
- arc_ui32 raw_value;
+ ::arc_ui32 raw_value;
memcpy(&raw_value, &tmp_value, sizeof(tmp_value));
if (raw_value != 0) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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())) {
@@ -575,21 +626,21 @@ uint8_t* FloatValue::_InternalSerialize(
return target;
}
-size_t FloatValue::ByteSizeLong() const {
+::size_t FloatValue::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FloatValue)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// float value = 1;
- static_assert(sizeof(arc_ui32) == sizeof(float), "Code assumes arc_ui32 and float are the same size.");
+ static_assert(sizeof(::arc_ui32) == sizeof(float), "Code assumes ::arc_ui32 and float are the same size.");
float tmp_value = this->_internal_value();
- arc_ui32 raw_value;
+ ::arc_ui32 raw_value;
memcpy(&raw_value, &tmp_value, sizeof(tmp_value));
if (raw_value != 0) {
- total_size += 1 + 4;
+ total_size += 5;
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -606,13 +657,13 @@ void FloatValue::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PRO
auto* const _this = static_cast<FloatValue*>(&to_msg);
auto& from = static_cast<const FloatValue&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FloatValue)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
- static_assert(sizeof(arc_ui32) == sizeof(float), "Code assumes arc_ui32 and float are the same size.");
+ static_assert(sizeof(::arc_ui32) == sizeof(float), "Code assumes ::arc_ui32 and float are the same size.");
float tmp_value = from._internal_value();
- arc_ui32 raw_value;
+ ::arc_ui32 raw_value;
memcpy(&raw_value, &tmp_value, sizeof(tmp_value));
if (raw_value != 0) {
_this->_internal_set_value(from._internal_value());
@@ -634,6 +685,7 @@ bool FloatValue::IsInitialized() const {
void FloatValue::InternalSwap(FloatValue* other) {
using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
+
swap(_impl_.value_, other->_impl_.value_);
}
@@ -642,37 +694,29 @@ void FloatValue::InternalSwap(FloatValue* other) {
&descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once,
file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[1]);
}
-
// ===================================================================
class Int64Value::_Internal {
public:
};
-Int64Value::Int64Value(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+Int64Value::Int64Value(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Int64Value)
}
Int64Value::Int64Value(const Int64Value& from)
- : ::PROTOBUF_NAMESPACE_ID::Message() {
- Int64Value* const _this = this; (void)_this;
- new (&_impl_) Impl_{
- decltype(_impl_.value_){}
- , /*decltype(_impl_._cached_size_)*/{}};
-
- _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- _this->_impl_.value_ = from._impl_.value_;
+ : ::PROTOBUF_NAMESPACE_ID::Message(), _impl_(from._impl_) {
+ _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(
+ from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:google.protobuf.Int64Value)
}
-inline void Int64Value::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void Int64Value::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
- decltype(_impl_.value_){arc_i64{0}}
+ decltype(_impl_.value_) { ::arc_i64{0} }
+
, /*decltype(_impl_._cached_size_)*/{}
};
}
@@ -687,7 +731,7 @@ Int64Value::~Int64Value() {
}
inline void Int64Value::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
}
void Int64Value::SetCachedSize(int size) const {
@@ -696,27 +740,28 @@ void Int64Value::SetCachedSize(int size) const {
void Int64Value::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Int64Value)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
- _impl_.value_ = arc_i64{0};
+ _impl_.value_ = ::arc_i64{0};
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// int64 value = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) {
_impl_.value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -741,16 +786,17 @@ failure:
#undef CHK_
}
-uint8_t* Int64Value::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* Int64Value::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Int64Value)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// int64 value = 1;
if (this->_internal_value() != 0) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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())) {
@@ -761,17 +807,18 @@ uint8_t* Int64Value::_InternalSerialize(
return target;
}
-size_t Int64Value::ByteSizeLong() const {
+::size_t Int64Value::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Int64Value)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// int64 value = 1;
if (this->_internal_value() != 0) {
- total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_value());
+ total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(
+ this->_internal_value());
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -788,8 +835,8 @@ void Int64Value::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PRO
auto* const _this = static_cast<Int64Value*>(&to_msg);
auto& from = static_cast<const Int64Value&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Int64Value)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
if (from._internal_value() != 0) {
@@ -812,6 +859,7 @@ bool Int64Value::IsInitialized() const {
void Int64Value::InternalSwap(Int64Value* other) {
using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
+
swap(_impl_.value_, other->_impl_.value_);
}
@@ -820,37 +868,29 @@ void Int64Value::InternalSwap(Int64Value* other) {
&descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once,
file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[2]);
}
-
// ===================================================================
class UInt64Value::_Internal {
public:
};
-UInt64Value::UInt64Value(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+UInt64Value::UInt64Value(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.UInt64Value)
}
UInt64Value::UInt64Value(const UInt64Value& from)
- : ::PROTOBUF_NAMESPACE_ID::Message() {
- UInt64Value* const _this = this; (void)_this;
- new (&_impl_) Impl_{
- decltype(_impl_.value_){}
- , /*decltype(_impl_._cached_size_)*/{}};
-
- _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- _this->_impl_.value_ = from._impl_.value_;
+ : ::PROTOBUF_NAMESPACE_ID::Message(), _impl_(from._impl_) {
+ _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(
+ from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:google.protobuf.UInt64Value)
}
-inline void UInt64Value::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void UInt64Value::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
- decltype(_impl_.value_){arc_ui64{0u}}
+ decltype(_impl_.value_) { ::arc_ui64{0u} }
+
, /*decltype(_impl_._cached_size_)*/{}
};
}
@@ -865,7 +905,7 @@ UInt64Value::~UInt64Value() {
}
inline void UInt64Value::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
}
void UInt64Value::SetCachedSize(int size) const {
@@ -874,27 +914,28 @@ void UInt64Value::SetCachedSize(int size) const {
void UInt64Value::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.UInt64Value)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
- _impl_.value_ = arc_ui64{0u};
+ _impl_.value_ = ::arc_ui64{0u};
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// uint64 value = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) {
_impl_.value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -919,16 +960,17 @@ failure:
#undef CHK_
}
-uint8_t* UInt64Value::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* UInt64Value::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UInt64Value)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// uint64 value = 1;
if (this->_internal_value() != 0) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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())) {
@@ -939,17 +981,18 @@ uint8_t* UInt64Value::_InternalSerialize(
return target;
}
-size_t UInt64Value::ByteSizeLong() const {
+::size_t UInt64Value::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.UInt64Value)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// uint64 value = 1;
if (this->_internal_value() != 0) {
- total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_value());
+ total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(
+ this->_internal_value());
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -966,8 +1009,8 @@ void UInt64Value::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PR
auto* const _this = static_cast<UInt64Value*>(&to_msg);
auto& from = static_cast<const UInt64Value&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UInt64Value)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
if (from._internal_value() != 0) {
@@ -990,6 +1033,7 @@ bool UInt64Value::IsInitialized() const {
void UInt64Value::InternalSwap(UInt64Value* other) {
using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
+
swap(_impl_.value_, other->_impl_.value_);
}
@@ -998,37 +1042,29 @@ void UInt64Value::InternalSwap(UInt64Value* other) {
&descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once,
file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[3]);
}
-
// ===================================================================
class Int32Value::_Internal {
public:
};
-Int32Value::Int32Value(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+Int32Value::Int32Value(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Int32Value)
}
Int32Value::Int32Value(const Int32Value& from)
- : ::PROTOBUF_NAMESPACE_ID::Message() {
- Int32Value* const _this = this; (void)_this;
- new (&_impl_) Impl_{
- decltype(_impl_.value_){}
- , /*decltype(_impl_._cached_size_)*/{}};
-
- _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- _this->_impl_.value_ = from._impl_.value_;
+ : ::PROTOBUF_NAMESPACE_ID::Message(), _impl_(from._impl_) {
+ _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(
+ from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:google.protobuf.Int32Value)
}
-inline void Int32Value::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void Int32Value::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
- decltype(_impl_.value_){0}
+ decltype(_impl_.value_) { 0 }
+
, /*decltype(_impl_._cached_size_)*/{}
};
}
@@ -1043,7 +1079,7 @@ Int32Value::~Int32Value() {
}
inline void Int32Value::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
}
void Int32Value::SetCachedSize(int size) const {
@@ -1052,7 +1088,7 @@ void Int32Value::SetCachedSize(int size) const {
void Int32Value::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Int32Value)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -1063,16 +1099,17 @@ void Int32Value::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// int32 value = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) {
_impl_.value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -1097,16 +1134,17 @@ failure:
#undef CHK_
}
-uint8_t* Int32Value::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* Int32Value::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Int32Value)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// int32 value = 1;
if (this->_internal_value() != 0) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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())) {
@@ -1117,17 +1155,18 @@ uint8_t* Int32Value::_InternalSerialize(
return target;
}
-size_t Int32Value::ByteSizeLong() const {
+::size_t Int32Value::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Int32Value)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// int32 value = 1;
if (this->_internal_value() != 0) {
- total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_value());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(
+ this->_internal_value());
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -1144,8 +1183,8 @@ void Int32Value::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PRO
auto* const _this = static_cast<Int32Value*>(&to_msg);
auto& from = static_cast<const Int32Value&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Int32Value)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
if (from._internal_value() != 0) {
@@ -1168,6 +1207,7 @@ bool Int32Value::IsInitialized() const {
void Int32Value::InternalSwap(Int32Value* other) {
using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
+
swap(_impl_.value_, other->_impl_.value_);
}
@@ -1176,37 +1216,29 @@ void Int32Value::InternalSwap(Int32Value* other) {
&descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once,
file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[4]);
}
-
// ===================================================================
class UInt32Value::_Internal {
public:
};
-UInt32Value::UInt32Value(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+UInt32Value::UInt32Value(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.UInt32Value)
}
UInt32Value::UInt32Value(const UInt32Value& from)
- : ::PROTOBUF_NAMESPACE_ID::Message() {
- UInt32Value* const _this = this; (void)_this;
- new (&_impl_) Impl_{
- decltype(_impl_.value_){}
- , /*decltype(_impl_._cached_size_)*/{}};
-
- _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- _this->_impl_.value_ = from._impl_.value_;
+ : ::PROTOBUF_NAMESPACE_ID::Message(), _impl_(from._impl_) {
+ _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(
+ from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:google.protobuf.UInt32Value)
}
-inline void UInt32Value::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void UInt32Value::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
- decltype(_impl_.value_){0u}
+ decltype(_impl_.value_) { 0u }
+
, /*decltype(_impl_._cached_size_)*/{}
};
}
@@ -1221,7 +1253,7 @@ UInt32Value::~UInt32Value() {
}
inline void UInt32Value::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
}
void UInt32Value::SetCachedSize(int size) const {
@@ -1230,7 +1262,7 @@ void UInt32Value::SetCachedSize(int size) const {
void UInt32Value::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.UInt32Value)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -1241,16 +1273,17 @@ void UInt32Value::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// uint32 value = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) {
_impl_.value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -1275,16 +1308,17 @@ failure:
#undef CHK_
}
-uint8_t* UInt32Value::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* UInt32Value::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UInt32Value)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// uint32 value = 1;
if (this->_internal_value() != 0) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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())) {
@@ -1295,17 +1329,18 @@ uint8_t* UInt32Value::_InternalSerialize(
return target;
}
-size_t UInt32Value::ByteSizeLong() const {
+::size_t UInt32Value::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.UInt32Value)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// uint32 value = 1;
if (this->_internal_value() != 0) {
- total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_value());
+ total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(
+ this->_internal_value());
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -1322,8 +1357,8 @@ void UInt32Value::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PR
auto* const _this = static_cast<UInt32Value*>(&to_msg);
auto& from = static_cast<const UInt32Value&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UInt32Value)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
if (from._internal_value() != 0) {
@@ -1346,6 +1381,7 @@ bool UInt32Value::IsInitialized() const {
void UInt32Value::InternalSwap(UInt32Value* other) {
using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
+
swap(_impl_.value_, other->_impl_.value_);
}
@@ -1354,37 +1390,29 @@ void UInt32Value::InternalSwap(UInt32Value* other) {
&descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once,
file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[5]);
}
-
// ===================================================================
class BoolValue::_Internal {
public:
};
-BoolValue::BoolValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+BoolValue::BoolValue(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.BoolValue)
}
BoolValue::BoolValue(const BoolValue& from)
- : ::PROTOBUF_NAMESPACE_ID::Message() {
- BoolValue* const _this = this; (void)_this;
- new (&_impl_) Impl_{
- decltype(_impl_.value_){}
- , /*decltype(_impl_._cached_size_)*/{}};
-
- _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- _this->_impl_.value_ = from._impl_.value_;
+ : ::PROTOBUF_NAMESPACE_ID::Message(), _impl_(from._impl_) {
+ _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(
+ from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:google.protobuf.BoolValue)
}
-inline void BoolValue::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void BoolValue::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
- decltype(_impl_.value_){false}
+ decltype(_impl_.value_) { false }
+
, /*decltype(_impl_._cached_size_)*/{}
};
}
@@ -1399,7 +1427,7 @@ BoolValue::~BoolValue() {
}
inline void BoolValue::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
}
void BoolValue::SetCachedSize(int size) const {
@@ -1408,7 +1436,7 @@ void BoolValue::SetCachedSize(int size) const {
void BoolValue::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.BoolValue)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -1419,16 +1447,17 @@ void BoolValue::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// bool value = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) {
_impl_.value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -1453,16 +1482,17 @@ failure:
#undef CHK_
}
-uint8_t* BoolValue::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* BoolValue::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.BoolValue)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// bool value = 1;
if (this->_internal_value() != 0) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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())) {
@@ -1473,17 +1503,17 @@ uint8_t* BoolValue::_InternalSerialize(
return target;
}
-size_t BoolValue::ByteSizeLong() const {
+::size_t BoolValue::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.BoolValue)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// bool value = 1;
if (this->_internal_value() != 0) {
- total_size += 1 + 1;
+ total_size += 2;
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -1500,8 +1530,8 @@ void BoolValue::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROT
auto* const _this = static_cast<BoolValue*>(&to_msg);
auto& from = static_cast<const BoolValue&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.BoolValue)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
if (from._internal_value() != 0) {
@@ -1524,6 +1554,7 @@ bool BoolValue::IsInitialized() const {
void BoolValue::InternalSwap(BoolValue* other) {
using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
+
swap(_impl_.value_, other->_impl_.value_);
}
@@ -1532,50 +1563,47 @@ void BoolValue::InternalSwap(BoolValue* other) {
&descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once,
file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[6]);
}
-
// ===================================================================
class StringValue::_Internal {
public:
};
-StringValue::StringValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+StringValue::StringValue(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.StringValue)
}
StringValue::StringValue(const StringValue& from)
: ::PROTOBUF_NAMESPACE_ID::Message() {
StringValue* const _this = this; (void)_this;
new (&_impl_) Impl_{
- decltype(_impl_.value_){}
+ decltype(_impl_.value_) {}
+
, /*decltype(_impl_._cached_size_)*/{}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.value_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.value_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_value().empty()) {
- _this->_impl_.value_.Set(from._internal_value(),
- _this->GetArenaForAllocation());
+ _this->_impl_.value_.Set(from._internal_value(), _this->GetArenaForAllocation());
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.StringValue)
}
-inline void StringValue::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void StringValue::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
- decltype(_impl_.value_){}
+ decltype(_impl_.value_) {}
+
, /*decltype(_impl_._cached_size_)*/{}
};
_impl_.value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.value_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.value_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
StringValue::~StringValue() {
@@ -1588,7 +1616,7 @@ StringValue::~StringValue() {
}
inline void StringValue::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.value_.Destroy();
}
@@ -1598,7 +1626,7 @@ void StringValue::SetCachedSize(int size) const {
void StringValue::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.StringValue)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -1609,18 +1637,19 @@ void StringValue::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// string value = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_value();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.StringValue.value"));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -1645,20 +1674,18 @@ failure:
#undef CHK_
}
-uint8_t* StringValue::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* StringValue::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.StringValue)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// string value = 1;
if (!this->_internal_value().empty()) {
+ const TProtoStringType& _s = this->_internal_value();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
- this->_internal_value().data(), static_cast<int>(this->_internal_value().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
- "google.protobuf.StringValue.value");
- target = stream->WriteStringMaybeAliased(
- 1, this->_internal_value(), target);
+ _s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.StringValue.value");
+ target = stream->WriteStringMaybeAliased(1, _s, target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
@@ -1669,19 +1696,18 @@ uint8_t* StringValue::_InternalSerialize(
return target;
}
-size_t StringValue::ByteSizeLong() const {
+::size_t StringValue::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.StringValue)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// string value = 1;
if (!this->_internal_value().empty()) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_value());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_value());
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -1698,8 +1724,8 @@ void StringValue::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PR
auto* const _this = static_cast<StringValue*>(&to_msg);
auto& from = static_cast<const StringValue&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.StringValue)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
if (!from._internal_value().empty()) {
@@ -1724,10 +1750,8 @@ void StringValue::InternalSwap(StringValue* other) {
auto* lhs_arena = GetArenaForAllocation();
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.value_, lhs_arena,
- &other->_impl_.value_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.value_, lhs_arena,
+ &other->_impl_.value_, rhs_arena);
}
::PROTOBUF_NAMESPACE_ID::Metadata StringValue::GetMetadata() const {
@@ -1735,50 +1759,47 @@ void StringValue::InternalSwap(StringValue* other) {
&descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once,
file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[7]);
}
-
// ===================================================================
class BytesValue::_Internal {
public:
};
-BytesValue::BytesValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+BytesValue::BytesValue(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.BytesValue)
}
BytesValue::BytesValue(const BytesValue& from)
: ::PROTOBUF_NAMESPACE_ID::Message() {
BytesValue* const _this = this; (void)_this;
new (&_impl_) Impl_{
- decltype(_impl_.value_){}
+ decltype(_impl_.value_) {}
+
, /*decltype(_impl_._cached_size_)*/{}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.value_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.value_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_value().empty()) {
- _this->_impl_.value_.Set(from._internal_value(),
- _this->GetArenaForAllocation());
+ _this->_impl_.value_.Set(from._internal_value(), _this->GetArenaForAllocation());
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.BytesValue)
}
-inline void BytesValue::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void BytesValue::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
- decltype(_impl_.value_){}
+ decltype(_impl_.value_) {}
+
, /*decltype(_impl_._cached_size_)*/{}
};
_impl_.value_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.value_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.value_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
BytesValue::~BytesValue() {
@@ -1791,7 +1812,7 @@ BytesValue::~BytesValue() {
}
inline void BytesValue::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.value_.Destroy();
}
@@ -1801,7 +1822,7 @@ void BytesValue::SetCachedSize(int size) const {
void BytesValue::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.BytesValue)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -1812,17 +1833,18 @@ void BytesValue::Clear() {
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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// bytes value = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_value();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -1847,16 +1869,16 @@ failure:
#undef CHK_
}
-uint8_t* BytesValue::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* BytesValue::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.BytesValue)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// bytes value = 1;
if (!this->_internal_value().empty()) {
- target = stream->WriteBytesMaybeAliased(
- 1, this->_internal_value(), target);
+ const TProtoStringType& _s = this->_internal_value();
+ target = stream->WriteBytesMaybeAliased(1, _s, target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
@@ -1867,19 +1889,18 @@ uint8_t* BytesValue::_InternalSerialize(
return target;
}
-size_t BytesValue::ByteSizeLong() const {
+::size_t BytesValue::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.BytesValue)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// bytes value = 1;
if (!this->_internal_value().empty()) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize(
- this->_internal_value());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize(
+ this->_internal_value());
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -1896,8 +1917,8 @@ void BytesValue::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PRO
auto* const _this = static_cast<BytesValue*>(&to_msg);
auto& from = static_cast<const BytesValue&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.BytesValue)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
if (!from._internal_value().empty()) {
@@ -1922,10 +1943,8 @@ void BytesValue::InternalSwap(BytesValue* other) {
auto* lhs_arena = GetArenaForAllocation();
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.value_, lhs_arena,
- &other->_impl_.value_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.value_, lhs_arena,
+ &other->_impl_.value_, rhs_arena);
}
::PROTOBUF_NAMESPACE_ID::Metadata BytesValue::GetMetadata() const {
@@ -1933,7 +1952,6 @@ void BytesValue::InternalSwap(BytesValue* other) {
&descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once,
file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[8]);
}
-
// @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
@@ -1974,6 +1992,5 @@ Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::BytesValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::BytesValue >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
-
// @@protoc_insertion_point(global_scope)
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protobuf/src/google/protobuf/wrappers.pb.h b/contrib/libs/protobuf/src/google/protobuf/wrappers.pb.h
index 422c20bf538..37d1c822ebd 100644
--- a/contrib/libs/protobuf/src/google/protobuf/wrappers.pb.h
+++ b/contrib/libs/protobuf/src/google/protobuf/wrappers.pb.h
@@ -1,38 +1,43 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/wrappers.proto
-#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fwrappers_2eproto
-#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fwrappers_2eproto
+#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fwrappers_2eproto_2epb_2eh
+#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fwrappers_2eproto_2epb_2eh
#include <limits>
#include <string>
-
-#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3021000
-#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 3021003 < 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.
-#endif
-
-#include <google/protobuf/port_undef.inc>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/arena.h>
-#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_util.h>
-#include <google/protobuf/metadata_lite.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h> // IWYU pragma: export
-#include <google/protobuf/extension_set.h> // IWYU pragma: export
-#include <google/protobuf/unknown_field_set.h>
+#include <type_traits>
+
+#include "google/protobuf/port_def.inc"
+#if PROTOBUF_VERSION < 4022000
+#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 // PROTOBUF_VERSION
+
+#if 4022005 < 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."
+#endif // PROTOBUF_MIN_PROTOC_VERSION
+#include "google/protobuf/port_undef.inc"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/arena.h"
+#include "google/protobuf/arenastring.h"
+#include "google/protobuf/generated_message_util.h"
+#include "google/protobuf/metadata_lite.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/repeated_field.h" // IWYU pragma: export
+#include "google/protobuf/extension_set.h" // IWYU pragma: export
+#include "google/protobuf/unknown_field_set.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fwrappers_2eproto PROTOBUF_EXPORT
+
PROTOBUF_NAMESPACE_OPEN
namespace internal {
class AnyMetadata;
@@ -41,9 +46,10 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fwrappers_2eproto {
- static const arc_ui32 offsets[];
+ static const ::arc_ui32 offsets[];
};
-PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fwrappers_2eproto;
+PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable
+ descriptor_table_google_2fprotobuf_2fwrappers_2eproto;
PROTOBUF_NAMESPACE_OPEN
class BoolValue;
struct BoolValueDefaultTypeInternal;
@@ -72,22 +78,33 @@ PROTOBUF_EXPORT extern UInt32ValueDefaultTypeInternal _UInt32Value_default_insta
class UInt64Value;
struct UInt64ValueDefaultTypeInternal;
PROTOBUF_EXPORT extern UInt64ValueDefaultTypeInternal _UInt64Value_default_instance_;
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::BoolValue* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::BoolValue>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::BytesValue* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::BytesValue>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::DoubleValue* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::DoubleValue>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FloatValue* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FloatValue>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Int32Value* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Int32Value>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Int64Value* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Int64Value>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::StringValue* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::StringValue>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::UInt32Value* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::UInt32Value>(Arena*);
+template <>
+PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::UInt64Value* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::UInt64Value>(Arena*);
PROTOBUF_NAMESPACE_CLOSE
-PROTOBUF_NAMESPACE_OPEN
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::BoolValue* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::BoolValue>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::BytesValue* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::BytesValue>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::DoubleValue* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::DoubleValue>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FloatValue* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FloatValue>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Int32Value* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Int32Value>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Int64Value* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Int64Value>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::StringValue* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::StringValue>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::UInt32Value* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::UInt32Value>(Arena*);
-template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::UInt64Value* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::UInt64Value>(Arena*);
-PROTOBUF_NAMESPACE_CLOSE
+
PROTOBUF_NAMESPACE_OPEN
// ===================================================================
+
+// -------------------------------------------------------------------
+
class PROTOBUF_EXPORT DoubleValue final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DoubleValue) */ {
public:
@@ -156,7 +173,7 @@ class PROTOBUF_EXPORT DoubleValue final :
}
void UnsafeArenaSwap(DoubleValue* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -177,26 +194,25 @@ class PROTOBUF_EXPORT DoubleValue final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(DoubleValue* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.DoubleValue";
}
protected:
- explicit DoubleValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit DoubleValue(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -212,14 +228,15 @@ class PROTOBUF_EXPORT DoubleValue final :
kValueFieldNumber = 1,
};
// double value = 1;
- void clear_value();
+ void clear_value() ;
double value() const;
void set_value(double value);
+
private:
double _internal_value() const;
void _internal_set_value(double value);
- public:
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.DoubleValue)
private:
class _Internal;
@@ -233,8 +250,7 @@ class PROTOBUF_EXPORT DoubleValue final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fwrappers_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT FloatValue final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FloatValue) */ {
@@ -304,7 +320,7 @@ class PROTOBUF_EXPORT FloatValue final :
}
void UnsafeArenaSwap(FloatValue* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -325,26 +341,25 @@ class PROTOBUF_EXPORT FloatValue final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(FloatValue* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.FloatValue";
}
protected:
- explicit FloatValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit FloatValue(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -360,14 +375,15 @@ class PROTOBUF_EXPORT FloatValue final :
kValueFieldNumber = 1,
};
// float value = 1;
- void clear_value();
+ void clear_value() ;
float value() const;
void set_value(float value);
+
private:
float _internal_value() const;
void _internal_set_value(float value);
- public:
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.FloatValue)
private:
class _Internal;
@@ -381,8 +397,7 @@ class PROTOBUF_EXPORT FloatValue final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fwrappers_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT Int64Value final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Int64Value) */ {
@@ -452,7 +467,7 @@ class PROTOBUF_EXPORT Int64Value final :
}
void UnsafeArenaSwap(Int64Value* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -473,26 +488,25 @@ class PROTOBUF_EXPORT Int64Value final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(Int64Value* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.Int64Value";
}
protected:
- explicit Int64Value(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit Int64Value(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -508,14 +522,15 @@ class PROTOBUF_EXPORT Int64Value final :
kValueFieldNumber = 1,
};
// int64 value = 1;
- void clear_value();
- arc_i64 value() const;
- void set_value(arc_i64 value);
+ void clear_value() ;
+ ::arc_i64 value() const;
+ void set_value(::arc_i64 value);
+
private:
- arc_i64 _internal_value() const;
- void _internal_set_value(arc_i64 value);
- public:
+ ::arc_i64 _internal_value() const;
+ void _internal_set_value(::arc_i64 value);
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.Int64Value)
private:
class _Internal;
@@ -524,13 +539,12 @@ class PROTOBUF_EXPORT Int64Value final :
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
struct Impl_ {
- arc_i64 value_;
+ ::arc_i64 value_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fwrappers_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT UInt64Value final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UInt64Value) */ {
@@ -600,7 +614,7 @@ class PROTOBUF_EXPORT UInt64Value final :
}
void UnsafeArenaSwap(UInt64Value* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -621,26 +635,25 @@ class PROTOBUF_EXPORT UInt64Value final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(UInt64Value* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.UInt64Value";
}
protected:
- explicit UInt64Value(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit UInt64Value(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -656,14 +669,15 @@ class PROTOBUF_EXPORT UInt64Value final :
kValueFieldNumber = 1,
};
// uint64 value = 1;
- void clear_value();
- arc_ui64 value() const;
- void set_value(arc_ui64 value);
+ void clear_value() ;
+ ::arc_ui64 value() const;
+ void set_value(::arc_ui64 value);
+
private:
- arc_ui64 _internal_value() const;
- void _internal_set_value(arc_ui64 value);
- public:
+ ::arc_ui64 _internal_value() const;
+ void _internal_set_value(::arc_ui64 value);
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.UInt64Value)
private:
class _Internal;
@@ -672,13 +686,12 @@ class PROTOBUF_EXPORT UInt64Value final :
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
struct Impl_ {
- arc_ui64 value_;
+ ::arc_ui64 value_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fwrappers_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT Int32Value final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Int32Value) */ {
@@ -748,7 +761,7 @@ class PROTOBUF_EXPORT Int32Value final :
}
void UnsafeArenaSwap(Int32Value* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -769,26 +782,25 @@ class PROTOBUF_EXPORT Int32Value final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(Int32Value* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.Int32Value";
}
protected:
- explicit Int32Value(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit Int32Value(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -804,14 +816,15 @@ class PROTOBUF_EXPORT Int32Value final :
kValueFieldNumber = 1,
};
// int32 value = 1;
- void clear_value();
- arc_i32 value() const;
- void set_value(arc_i32 value);
+ void clear_value() ;
+ ::arc_i32 value() const;
+ void set_value(::arc_i32 value);
+
private:
- arc_i32 _internal_value() const;
- void _internal_set_value(arc_i32 value);
- public:
+ ::arc_i32 _internal_value() const;
+ void _internal_set_value(::arc_i32 value);
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.Int32Value)
private:
class _Internal;
@@ -820,13 +833,12 @@ class PROTOBUF_EXPORT Int32Value final :
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
struct Impl_ {
- arc_i32 value_;
+ ::arc_i32 value_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fwrappers_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT UInt32Value final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UInt32Value) */ {
@@ -896,7 +908,7 @@ class PROTOBUF_EXPORT UInt32Value final :
}
void UnsafeArenaSwap(UInt32Value* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -917,26 +929,25 @@ class PROTOBUF_EXPORT UInt32Value final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(UInt32Value* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.UInt32Value";
}
protected:
- explicit UInt32Value(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit UInt32Value(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -952,14 +963,15 @@ class PROTOBUF_EXPORT UInt32Value final :
kValueFieldNumber = 1,
};
// uint32 value = 1;
- void clear_value();
- arc_ui32 value() const;
- void set_value(arc_ui32 value);
+ void clear_value() ;
+ ::arc_ui32 value() const;
+ void set_value(::arc_ui32 value);
+
private:
- arc_ui32 _internal_value() const;
- void _internal_set_value(arc_ui32 value);
- public:
+ ::arc_ui32 _internal_value() const;
+ void _internal_set_value(::arc_ui32 value);
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.UInt32Value)
private:
class _Internal;
@@ -968,13 +980,12 @@ class PROTOBUF_EXPORT UInt32Value final :
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
struct Impl_ {
- arc_ui32 value_;
+ ::arc_ui32 value_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fwrappers_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT BoolValue final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.BoolValue) */ {
@@ -1044,7 +1055,7 @@ class PROTOBUF_EXPORT BoolValue final :
}
void UnsafeArenaSwap(BoolValue* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -1065,26 +1076,25 @@ class PROTOBUF_EXPORT BoolValue final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(BoolValue* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.BoolValue";
}
protected:
- explicit BoolValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit BoolValue(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -1100,14 +1110,15 @@ class PROTOBUF_EXPORT BoolValue final :
kValueFieldNumber = 1,
};
// bool value = 1;
- void clear_value();
+ void clear_value() ;
bool value() const;
void set_value(bool value);
+
private:
bool _internal_value() const;
void _internal_set_value(bool value);
- public:
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.BoolValue)
private:
class _Internal;
@@ -1121,8 +1132,7 @@ class PROTOBUF_EXPORT BoolValue final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fwrappers_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT StringValue final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.StringValue) */ {
@@ -1192,7 +1202,7 @@ class PROTOBUF_EXPORT StringValue final :
}
void UnsafeArenaSwap(StringValue* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -1213,26 +1223,25 @@ class PROTOBUF_EXPORT StringValue final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(StringValue* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.StringValue";
}
protected:
- explicit StringValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit StringValue(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -1248,19 +1257,25 @@ class PROTOBUF_EXPORT StringValue final :
kValueFieldNumber = 1,
};
// string value = 1;
- void clear_value();
+ void clear_value() ;
const TProtoStringType& value() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_value(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_value(Arg_&& arg, Args_... args);
TProtoStringType* mutable_value();
PROTOBUF_NODISCARD TProtoStringType* release_value();
- void set_allocated_value(TProtoStringType* value);
+ void set_allocated_value(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_value() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_value(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_value(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_value();
- public:
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.StringValue)
private:
class _Internal;
@@ -1274,8 +1289,7 @@ class PROTOBUF_EXPORT StringValue final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fwrappers_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOBUF_EXPORT BytesValue final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.BytesValue) */ {
@@ -1345,7 +1359,7 @@ class PROTOBUF_EXPORT BytesValue final :
}
void UnsafeArenaSwap(BytesValue* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -1366,26 +1380,25 @@ class PROTOBUF_EXPORT BytesValue final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(BytesValue* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.BytesValue";
}
protected:
- explicit BytesValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit BytesValue(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -1401,19 +1414,25 @@ class PROTOBUF_EXPORT BytesValue final :
kValueFieldNumber = 1,
};
// bytes value = 1;
- void clear_value();
+ void clear_value() ;
const TProtoStringType& value() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_value(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_value(Arg_&& arg, Args_... args);
TProtoStringType* mutable_value();
PROTOBUF_NODISCARD TProtoStringType* release_value();
- void set_allocated_value(TProtoStringType* value);
+ void set_allocated_value(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_value() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_value(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_value(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_value();
- public:
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.BytesValue)
private:
class _Internal;
@@ -1428,36 +1447,42 @@ class PROTOBUF_EXPORT BytesValue final :
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fwrappers_2eproto;
};
+
// ===================================================================
+
+
// ===================================================================
+
#ifdef __GNUC__
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
+// -------------------------------------------------------------------
+
// DoubleValue
// double value = 1;
inline void DoubleValue::clear_value() {
_impl_.value_ = 0;
}
-inline double DoubleValue::_internal_value() const {
- return _impl_.value_;
-}
inline double DoubleValue::value() const {
// @@protoc_insertion_point(field_get:google.protobuf.DoubleValue.value)
return _internal_value();
}
-inline void DoubleValue::_internal_set_value(double value) {
-
- _impl_.value_ = value;
-}
inline void DoubleValue::set_value(double value) {
_internal_set_value(value);
// @@protoc_insertion_point(field_set:google.protobuf.DoubleValue.value)
}
+inline double DoubleValue::_internal_value() const {
+ return _impl_.value_;
+}
+inline void DoubleValue::_internal_set_value(double value) {
+ ;
+ _impl_.value_ = value;
+}
// -------------------------------------------------------------------
@@ -1467,21 +1492,21 @@ inline void DoubleValue::set_value(double value) {
inline void FloatValue::clear_value() {
_impl_.value_ = 0;
}
-inline float FloatValue::_internal_value() const {
- return _impl_.value_;
-}
inline float FloatValue::value() const {
// @@protoc_insertion_point(field_get:google.protobuf.FloatValue.value)
return _internal_value();
}
-inline void FloatValue::_internal_set_value(float value) {
-
- _impl_.value_ = value;
-}
inline void FloatValue::set_value(float value) {
_internal_set_value(value);
// @@protoc_insertion_point(field_set:google.protobuf.FloatValue.value)
}
+inline float FloatValue::_internal_value() const {
+ return _impl_.value_;
+}
+inline void FloatValue::_internal_set_value(float value) {
+ ;
+ _impl_.value_ = value;
+}
// -------------------------------------------------------------------
@@ -1489,23 +1514,23 @@ inline void FloatValue::set_value(float value) {
// int64 value = 1;
inline void Int64Value::clear_value() {
- _impl_.value_ = arc_i64{0};
+ _impl_.value_ = ::arc_i64{0};
}
-inline arc_i64 Int64Value::_internal_value() const {
- return _impl_.value_;
-}
-inline arc_i64 Int64Value::value() const {
+inline ::arc_i64 Int64Value::value() const {
// @@protoc_insertion_point(field_get:google.protobuf.Int64Value.value)
return _internal_value();
}
-inline void Int64Value::_internal_set_value(arc_i64 value) {
-
- _impl_.value_ = value;
-}
-inline void Int64Value::set_value(arc_i64 value) {
+inline void Int64Value::set_value(::arc_i64 value) {
_internal_set_value(value);
// @@protoc_insertion_point(field_set:google.protobuf.Int64Value.value)
}
+inline ::arc_i64 Int64Value::_internal_value() const {
+ return _impl_.value_;
+}
+inline void Int64Value::_internal_set_value(::arc_i64 value) {
+ ;
+ _impl_.value_ = value;
+}
// -------------------------------------------------------------------
@@ -1513,23 +1538,23 @@ inline void Int64Value::set_value(arc_i64 value) {
// uint64 value = 1;
inline void UInt64Value::clear_value() {
- _impl_.value_ = arc_ui64{0u};
+ _impl_.value_ = ::arc_ui64{0u};
}
-inline arc_ui64 UInt64Value::_internal_value() const {
- return _impl_.value_;
-}
-inline arc_ui64 UInt64Value::value() const {
+inline ::arc_ui64 UInt64Value::value() const {
// @@protoc_insertion_point(field_get:google.protobuf.UInt64Value.value)
return _internal_value();
}
-inline void UInt64Value::_internal_set_value(arc_ui64 value) {
-
- _impl_.value_ = value;
-}
-inline void UInt64Value::set_value(arc_ui64 value) {
+inline void UInt64Value::set_value(::arc_ui64 value) {
_internal_set_value(value);
// @@protoc_insertion_point(field_set:google.protobuf.UInt64Value.value)
}
+inline ::arc_ui64 UInt64Value::_internal_value() const {
+ return _impl_.value_;
+}
+inline void UInt64Value::_internal_set_value(::arc_ui64 value) {
+ ;
+ _impl_.value_ = value;
+}
// -------------------------------------------------------------------
@@ -1539,21 +1564,21 @@ inline void UInt64Value::set_value(arc_ui64 value) {
inline void Int32Value::clear_value() {
_impl_.value_ = 0;
}
-inline arc_i32 Int32Value::_internal_value() const {
- return _impl_.value_;
-}
-inline arc_i32 Int32Value::value() const {
+inline ::arc_i32 Int32Value::value() const {
// @@protoc_insertion_point(field_get:google.protobuf.Int32Value.value)
return _internal_value();
}
-inline void Int32Value::_internal_set_value(arc_i32 value) {
-
- _impl_.value_ = value;
-}
-inline void Int32Value::set_value(arc_i32 value) {
+inline void Int32Value::set_value(::arc_i32 value) {
_internal_set_value(value);
// @@protoc_insertion_point(field_set:google.protobuf.Int32Value.value)
}
+inline ::arc_i32 Int32Value::_internal_value() const {
+ return _impl_.value_;
+}
+inline void Int32Value::_internal_set_value(::arc_i32 value) {
+ ;
+ _impl_.value_ = value;
+}
// -------------------------------------------------------------------
@@ -1563,21 +1588,21 @@ inline void Int32Value::set_value(arc_i32 value) {
inline void UInt32Value::clear_value() {
_impl_.value_ = 0u;
}
-inline arc_ui32 UInt32Value::_internal_value() const {
- return _impl_.value_;
-}
-inline arc_ui32 UInt32Value::value() const {
+inline ::arc_ui32 UInt32Value::value() const {
// @@protoc_insertion_point(field_get:google.protobuf.UInt32Value.value)
return _internal_value();
}
-inline void UInt32Value::_internal_set_value(arc_ui32 value) {
-
- _impl_.value_ = value;
-}
-inline void UInt32Value::set_value(arc_ui32 value) {
+inline void UInt32Value::set_value(::arc_ui32 value) {
_internal_set_value(value);
// @@protoc_insertion_point(field_set:google.protobuf.UInt32Value.value)
}
+inline ::arc_ui32 UInt32Value::_internal_value() const {
+ return _impl_.value_;
+}
+inline void UInt32Value::_internal_set_value(::arc_ui32 value) {
+ ;
+ _impl_.value_ = value;
+}
// -------------------------------------------------------------------
@@ -1587,21 +1612,21 @@ inline void UInt32Value::set_value(arc_ui32 value) {
inline void BoolValue::clear_value() {
_impl_.value_ = false;
}
-inline bool BoolValue::_internal_value() const {
- return _impl_.value_;
-}
inline bool BoolValue::value() const {
// @@protoc_insertion_point(field_get:google.protobuf.BoolValue.value)
return _internal_value();
}
-inline void BoolValue::_internal_set_value(bool value) {
-
- _impl_.value_ = value;
-}
inline void BoolValue::set_value(bool value) {
_internal_set_value(value);
// @@protoc_insertion_point(field_set:google.protobuf.BoolValue.value)
}
+inline bool BoolValue::_internal_value() const {
+ return _impl_.value_;
+}
+inline void BoolValue::_internal_set_value(bool value) {
+ ;
+ _impl_.value_ = value;
+}
// -------------------------------------------------------------------
@@ -1615,11 +1640,11 @@ inline const TProtoStringType& StringValue::value() const {
// @@protoc_insertion_point(field_get:google.protobuf.StringValue.value)
return _internal_value();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void StringValue::set_value(ArgT0&& arg0, ArgT... args) {
-
- _impl_.value_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void StringValue::set_value(Arg_&& arg,
+ Args_... args) {
+ ;
+ _impl_.value_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.StringValue.value)
}
inline TProtoStringType* StringValue::mutable_value() {
@@ -1631,29 +1656,26 @@ inline const TProtoStringType& StringValue::_internal_value() const {
return _impl_.value_.Get();
}
inline void StringValue::_internal_set_value(const TProtoStringType& value) {
-
+ ;
+
+
_impl_.value_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* StringValue::_internal_mutable_value() {
-
- return _impl_.value_.Mutable(GetArenaForAllocation());
+ ;
+ return _impl_.value_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* StringValue::release_value() {
// @@protoc_insertion_point(field_release:google.protobuf.StringValue.value)
return _impl_.value_.Release();
}
inline void StringValue::set_allocated_value(TProtoStringType* value) {
- if (value != nullptr) {
-
- } else {
-
- }
_impl_.value_.SetAllocated(value, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.value_.IsDefault()) {
- _impl_.value_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.value_.IsDefault()) {
+ _impl_.value_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.StringValue.value)
}
@@ -1669,11 +1691,11 @@ inline const TProtoStringType& BytesValue::value() const {
// @@protoc_insertion_point(field_get:google.protobuf.BytesValue.value)
return _internal_value();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void BytesValue::set_value(ArgT0&& arg0, ArgT... args) {
-
- _impl_.value_.SetBytes(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void BytesValue::set_value(Arg_&& arg,
+ Args_... args) {
+ ;
+ _impl_.value_.SetBytes(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.BytesValue.value)
}
inline TProtoStringType* BytesValue::mutable_value() {
@@ -1685,57 +1707,39 @@ inline const TProtoStringType& BytesValue::_internal_value() const {
return _impl_.value_.Get();
}
inline void BytesValue::_internal_set_value(const TProtoStringType& value) {
-
+ ;
+
+
_impl_.value_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* BytesValue::_internal_mutable_value() {
-
- return _impl_.value_.Mutable(GetArenaForAllocation());
+ ;
+ return _impl_.value_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* BytesValue::release_value() {
// @@protoc_insertion_point(field_release:google.protobuf.BytesValue.value)
return _impl_.value_.Release();
}
inline void BytesValue::set_allocated_value(TProtoStringType* value) {
- if (value != nullptr) {
-
- } else {
-
- }
_impl_.value_.SetAllocated(value, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.value_.IsDefault()) {
- _impl_.value_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.value_.IsDefault()) {
+ _impl_.value_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.BytesValue.value)
}
#ifdef __GNUC__
- #pragma GCC diagnostic pop
+#pragma GCC diagnostic pop
#endif // __GNUC__
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
// @@protoc_insertion_point(namespace_scope)
-
PROTOBUF_NAMESPACE_CLOSE
+
// @@protoc_insertion_point(global_scope)
-#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fwrappers_2eproto
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fwrappers_2eproto_2epb_2eh
diff --git a/contrib/libs/protobuf/src/google/protobuf/wrappers.proto b/contrib/libs/protobuf/src/google/protobuf/wrappers.proto
index d49dd53c8d8..1959fa55a4e 100644
--- a/contrib/libs/protobuf/src/google/protobuf/wrappers.proto
+++ b/contrib/libs/protobuf/src/google/protobuf/wrappers.proto
@@ -27,7 +27,7 @@
// 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.
-
+//
// Wrappers for primitive (non-message) types. These types are useful
// for embedding primitives in the `google.protobuf.Any` type and for places
// where we need to distinguish between the absence of a primitive
@@ -42,13 +42,13 @@ syntax = "proto3";
package google.protobuf;
-option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option cc_enable_arenas = true;
option go_package = "google.golang.org/protobuf/types/known/wrapperspb";
option java_package = "com.google.protobuf";
option java_outer_classname = "WrappersProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
+option csharp_namespace = "Google.Protobuf.WellKnownTypes";
// Wrapper message for `double`.
//
diff --git a/contrib/libs/protobuf/third_party/utf8_range/CONTRIBUTING.md b/contrib/libs/protobuf/third_party/utf8_range/CONTRIBUTING.md
new file mode 100644
index 00000000000..3e5b62eebfe
--- /dev/null
+++ b/contrib/libs/protobuf/third_party/utf8_range/CONTRIBUTING.md
@@ -0,0 +1,31 @@
+# How to Contribute
+
+This repository is currently a read-only clone of internal Google code for use
+in open-source projects. We don't currently have a mechanism to upstream
+changes, but if you'd like to contribute, please reach out to us to discuss your
+proposed changes.
+
+## Contributor License Agreement
+
+Contributions to this project must be accompanied by a Contributor License
+Agreement (CLA). You (or your employer) retain the copyright to your
+contribution; this simply gives us permission to use and redistribute your
+contributions as part of the project. Head over to
+<https://cla.developers.google.com/> to see your current agreements on file or
+to sign a new one.
+
+You generally only need to submit a CLA once, so if you've already submitted one
+(even if it was for a different project), you probably don't need to do it
+again.
+
+## Code Reviews
+
+All submissions, including submissions by project members, require review. We
+use GitHub pull requests for this purpose. Consult
+[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
+information on using pull requests.
+
+## Community Guidelines
+
+This project follows
+[Google's Open Source Community Guidelines](https://opensource.google/conduct/).
diff --git a/contrib/libs/protobuf/third_party/utf8_range/LICENSE b/contrib/libs/protobuf/third_party/utf8_range/LICENSE
new file mode 100644
index 00000000000..e59f14fa55d
--- /dev/null
+++ b/contrib/libs/protobuf/third_party/utf8_range/LICENSE
@@ -0,0 +1,22 @@
+MIT License
+
+Copyright (c) 2019 Yibo Cai
+Copyright 2022 Google LLC
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/contrib/libs/protobuf/third_party/utf8_range/README.md b/contrib/libs/protobuf/third_party/utf8_range/README.md
new file mode 100644
index 00000000000..30ff5b785b8
--- /dev/null
+++ b/contrib/libs/protobuf/third_party/utf8_range/README.md
@@ -0,0 +1,264 @@
+[![Build Status](https://travis-ci.com/cyb70289/utf8.svg?branch=master)](https://travis-ci.com/cyb70289/utf8)
+
+# Fast UTF-8 validation with Range algorithm (NEON+SSE4+AVX2)
+
+This is a brand new algorithm to leverage SIMD for fast UTF-8 string validation. Both **NEON**(armv8a) and **SSE4** versions are implemented. **AVX2** implementation contributed by [ioioioio](https://github.com/ioioioio).
+
+Four UTF-8 validation methods are compared on both x86 and Arm platforms. Benchmark result shows range base algorithm is the best solution on Arm, and achieves same performance as [Lemire's approach](https://lemire.me/blog/2018/05/16/validating-utf-8-strings-using-as-little-as-0-7-cycles-per-byte/) on x86.
+
+* Range based algorithm
+ * range-neon.c: NEON version
+ * range-sse.c: SSE4 version
+ * range-avx2.c: AVX2 version
+ * range2-neon.c, range2-sse.c: Process two blocks in one iteration
+* [Lemire's SIMD implementation](https://github.com/lemire/fastvalidate-utf-8)
+ * lemire-sse.c: SSE4 version
+ * lemire-avx2.c: AVX2 version
+ * lemire-neon.c: NEON porting
+* naive.c: Naive UTF-8 validation byte by byte
+* lookup.c: [Lookup-table method](http://bjoern.hoehrmann.de/utf-8/decoder/dfa/)
+
+## About the code
+
+* Run "make" to build. Built and tested with gcc-7.3.
+* Run "./utf8" to see all command line options.
+* Benchmark
+ * Run "./utf8 bench" to bechmark all algorithms with [default test file](https://raw.githubusercontent.com/cyb70289/utf8/master/UTF-8-demo.txt).
+ * Run "./utf8 bench size NUM" to benchmark specified string size.
+* Run "./utf8 test" to test all algorithms with positive and negative test cases.
+* To benchmark or test specific algorithm, run something like "./utf8 bench range".
+
+## Benchmark result (MB/s)
+
+### Method
+1. Generate UTF-8 test buffer per [test file](https://raw.githubusercontent.com/cyb70289/utf8/master/UTF-8-demo.txt) or buffer size.
+1. Call validation sub-routines in a loop until 1G bytes are checked.
+1. Calculate speed(MB/s) of validating UTF-8 strings.
+
+### NEON(armv8a)
+Test case | naive | lookup | lemire | range | range2
+:-------- | :---- | :----- | :----- | :---- | :-----
+[UTF-demo.txt](https://raw.githubusercontent.com/cyb70289/utf8/master/UTF-8-demo.txt) | 562.25 | 412.84 | 1198.50 | 1411.72 | **1579.85**
+32 bytes | 651.55 | 441.70 | 891.38 | 1003.95 | **1043.58**
+33 bytes | 660.00 | 446.78 | 588.77 | 1009.31 | **1048.12**
+129 bytes | 771.89 | 402.55 | 938.07 | 1283.77 | **1401.76**
+1K bytes | 811.92 | 411.58 | 1188.96 | 1398.15 | **1560.23**
+8K bytes | 812.25 | 412.74 | 1198.90 | 1412.18 | **1580.65**
+64K bytes | 817.35 | 412.24 | 1200.20 | 1415.11 | **1583.86**
+1M bytes | 815.70 | 411.93 | 1200.93 | 1415.65 | **1585.40**
+
+### SSE4(E5-2650)
+Test case | naive | lookup | lemire | range | range2
+:-------- | :---- | :----- | :----- | :---- | :-----
+[UTF-demo.txt](https://raw.githubusercontent.com/cyb70289/utf8/master/UTF-8-demo.txt) | 753.70 | 310.41 | 3954.74 | 3945.60 | **3986.13**
+32 bytes | 1135.76 | 364.07 | **2890.52** | 2351.81 | 2173.02
+33 bytes | 1161.85 | 376.29 | 1352.95 | **2239.55** | 2041.43
+129 bytes | 1161.22 | 322.47 | 2742.49 | **3315.33** | 3249.35
+1K bytes | 1310.95 | 310.72 | 3755.88 | 3781.23 | **3874.17**
+8K bytes | 1348.32 | 307.93 | 3860.71 | 3922.81 | **3968.93**
+64K bytes | 1301.34 | 308.39 | 3935.15 | 3973.50 | **3983.44**
+1M bytes | 1279.78 | 309.06 | 3923.51 | 3953.00 | **3960.49**
+
+## Range algorithm analysis
+
+Basic idea:
+* Load 16 bytes
+* Leverage SIMD to calculate value range for each byte efficiently
+* Validate 16 bytes at once
+
+### UTF-8 coding format
+
+http://www.unicode.org/versions/Unicode6.0.0/ch03.pdf, page 94
+
+Table 3-7. Well-Formed UTF-8 Byte Sequences
+
+Code Points | First Byte | Second Byte | Third Byte | Fourth Byte |
+:---------- | :--------- | :---------- | :--------- | :---------- |
+U+0000..U+007F | 00..7F | | | |
+U+0080..U+07FF | C2..DF | 80..BF | | |
+U+0800..U+0FFF | E0 | ***A0***..BF| 80..BF | |
+U+1000..U+CFFF | E1..EC | 80..BF | 80..BF | |
+U+D000..U+D7FF | ED | 80..***9F***| 80..BF | |
+U+E000..U+FFFF | EE..EF | 80..BF | 80..BF | |
+U+10000..U+3FFFF | F0 | ***90***..BF| 80..BF | 80..BF |
+U+40000..U+FFFFF | F1..F3 | 80..BF | 80..BF | 80..BF |
+U+100000..U+10FFFF | F4 | 80..***8F***| 80..BF | 80..BF |
+
+To summarise UTF-8 encoding:
+* Depending on First Byte, one legal character can be 1, 2, 3, 4 bytes
+ * For First Byte within C0..DF, character length = 2
+ * For First Byte within E0..EF, character length = 3
+ * For First Byte within F0..F4, character length = 4
+* C0, C1, F5..FF are not allowed
+* Second,Third,Fourth Bytes must lie in 80..BF.
+* There are four **special cases** for Second Byte, shown ***bold italic*** in above table.
+
+### Range table
+
+Range table maps range index 0 ~ 15 to minimal and maximum values allowed. Our task is to observe input string, find the pattern and set correct range index for each byte, then validate input string.
+
+Index | Min | Max | Byte type
+:---- | :-- | :-- | :--------
+0 | 00 | 7F | First Byte, ASCII
+1,2,3 | 80 | BF | Second, Third, Fourth Bytes
+4 | A0 | BF | Second Byte after E0
+5 | 80 | 9F | Second Byte after ED
+6 | 90 | BF | Second Byte after F0
+7 | 80 | 8F | Second Byte after F4
+8 | C2 | F4 | First Byte, non-ASCII
+9..15(NEON) | FF | 00 | Illegal: unsigned char >= 255 && unsigned char <= 0
+9..15(SSE) | 7F | 80 | Illegal: signed char >= 127 && signed char <= -128
+
+### Calculate byte ranges (ignore special cases)
+
+Ignoring the four special cases(E0,ED,F0,F4), how should we set range index for each byte?
+
+* Set range index to 0(00..7F) for all bytes by default
+* Find non-ASCII First Byte (C0..FF), set their range index to 8(C2..F4)
+* For First Byte within C0..DF, set next byte's range index to 1(80..BF)
+* For First Byte within E0..EF, set next two byte's range index to 2,1(80..BF) in sequence
+* For First Byte within F0..FF, set next three byte's range index to 3,2,1(80..BF) in sequence
+
+To implement above operations efficiently with SIMD:
+* For 16 input bytes, use lookup table to map C0..DF to 1, E0..EF to 2, F0..FF to 3, others to 0. Save to first_len.
+* Map C0..FF to 8, we get range indices for First Byte.
+* Shift first_len one byte, we get range indices for Second Byte.
+* Saturate substract first_len by one(3->2, 2->1, 1->0, 0->0), then shift two bytes, we get range indices for Third Byte.
+* Saturate substract first_len by two(3->1, 2->0, 1->0, 0->0), then shift three bytes, we get range indices for Fourth Byte.
+
+Example(assume no previous data)
+
+Input | F1 | 80 | 80 | 80 | 80 | C2 | 80 | 80 | ...
+:---- | :- | :- | :- | :- | :- | :- | :- | :- | :--
+*first_len* |*3* |*0* |*0* |*0* |*0* |*1* |*0* |*0* |*...*
+First Byte | 8 | 0 | 0 | 0 | 0 | 8 | 0 | 0 | ...
+Second Byte | 0 | 3 | 0 | 0 | 0 | 0 | 1 | 0 | ...
+Third Byte | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | ...
+Fourth Byte | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | ...
+Range index | 8 | 3 | 2 | 1 | 0 | 8 | 1 | 0 | ...
+
+```c
+Range_index = First_Byte | Second_Byte | Third_Byte | Fourth_Byte
+```
+
+#### Error handling
+
+* C0,C1,F5..FF are not included in range table and will always be detected.
+* Illegal 80..BF will have range index 0(00..7F) and be detected.
+* Based on First Byte, according Second, Third and Fourth Bytes will have range index 1/2/3, to make sure they must lie in 80..BF.
+* If non-ASCII First Byte overlaps, above algorithm will set range index of the latter First Byte to 9,10,11, which are illegal ranges. E.g, Input = F1 80 C2 90 --> Range index = 8 3 10 1, where 10 indicates error. See table below.
+
+Overlapped non-ASCII First Byte
+
+Input | F1 | 80 | C2 | 90
+:---- | :- | :- | :- | :-
+*first_len* |*3* |*0* |*1* |*0*
+First Byte | 8 | 0 | 8 | 0
+Second Byte | 0 | 3 | 0 | 1
+Third Byte | 0 | 0 | 2 | 0
+Fourth Byte | 0 | 0 | 0 | 1
+Range index | 8 | 3 |***10***| 1
+
+### Adjust Second Byte range for special cases
+
+Range index adjustment for four special cases
+
+First Byte | Second Byte | Before adjustment | Correct index | Adjustment |
+:--------- | :---------- | :---------------- | :------------ | :---------
+E0 | A0..BF | 2 | 4 | **2**
+ED | 80..9F | 2 | 5 | **3**
+F0 | 90..BF | 3 | 6 | **3**
+F4 | 80..8F | 3 | 7 | **4**
+
+Range index adjustment can be reduced to below problem:
+
+***Given 16 bytes, replace E0 with 2, ED with 3, F0 with 3, F4 with 4, others with 0.***
+
+A naive SIMD approach:
+1. Compare 16 bytes with E0, get the mask for eacy byte (FF if equal, 00 otherwise)
+1. And the mask with 2 to get adjustment for E0
+1. Repeat step 1,2 for ED,F0,F4
+
+At least **eight** operations are required for naive approach.
+
+Observing special bytes(E0,ED,F0,F4) are close to each other, we can do much better using lookup table.
+
+#### NEON
+
+NEON ```tbl``` instruction is very convenient for table lookup:
+* Table can be up to 16x4 bytes in size
+* Return zero if index is out of range
+
+Leverage these features, we can solve the problem with as few as **two** operations:
+* Precreate a 16x2 lookup table, where table[0]=2, table[13]=3, table[16]=3, table[20]=4, table[others]=0.
+* Substract input bytes with E0 (E0 -> 0, ED -> 13, F0 -> 16, F4 -> 20).
+* Use the substracted byte as index of lookup table and get range adjustment directly.
+ * For indices less than 32, we get zero or required adjustment value per input byte
+ * For out of bound indices, we get zero per ```tbl``` behaviour
+
+#### SSE
+
+SSE ```pshufb``` instruction is not as friendly as NEON ```tbl``` in this case:
+* Table can only be 16 bytes in size
+* Out of bound indices are handled this way:
+ * If 7-th bit of index is 0, least four bits are used as index (E.g, index 0x73 returns 3rd element)
+ * If 7-th bit of index is 1, return 0 (E.g, index 0x83 returns 0)
+
+We can still leverage these features to solve the problem in **five** operations:
+* Precreate two tables:
+ * table_df[1] = 2, table_df[14] = 3, table_df[others] = 0
+ * table_ef[1] = 3, table_ef[5] = 4, table_ef[others] = 0
+* Substract input bytes with EF (E0 -> 241, ED -> 254, F0 -> 1, F4 -> 5) to get the temporary indices
+* Get range index for E0,ED
+ * Saturate substract temporary indices with 240 (E0 -> 1, ED -> 14, all values below 240 becomes 0)
+ * Use substracted indices to look up table_df, get the correct adjustment
+* Get range index for F0,F4
+ * Saturate add temporary indices with 112(0x70) (F0 -> 0x71, F4 -> 0x75, all values above 16 will be larger than 128(7-th bit set))
+ * Use added indices to look up table_ef, get the correct adjustment (index 0x71,0x75 returns 1st,5th elements, per ```pshufb``` behaviour)
+
+#### Error handling
+
+* For overlapped non-ASCII First Byte, range index before adjustment is 9,10,11. After adjustment (adds 2,3,4 or 0), the range index will be 9 to 15, which is still illegal in range table. So the error will be detected.
+
+### Handling remaining bytes
+
+For remaining input less than 16 bytes, we will fallback to naive byte by byte approach to validate them, which is actually faster than SIMD processing.
+* Look back last 16 bytes buffer to find First Byte. At most three bytes need to look back. Otherwise we either happen to be at character boundray, or there are some errors we already detected.
+* Validate string byte by byte starting from the First Byte.
+
+## Tests
+
+It's necessary to design test cases to cover corner cases as more as possible.
+
+### Positive cases
+
+1. Prepare correct characters
+2. Validate correct characters
+3. Validate long strings
+ * Round concatenate characters starting from first character to 1024 bytes
+ * Validate 1024 bytes string
+ * Shift 1 byte, validate 1025 bytes string
+ * Shift 2 bytes, Validate 1026 bytes string
+ * ...
+ * Shift 16 bytes, validate 1040 bytes string
+4. Repeat step3, test buffer starting from second character
+5. Repeat step3, test buffer starting from third character
+6. ...
+
+### Negative cases
+
+1. Prepare bad characters and bad strings
+ * Bad character
+ * Bad character cross 16 bytes boundary
+ * Bad character cross last 16 bytes and remaining bytes boundary
+2. Test long strings
+ * Prepare correct long strings same as positive cases
+ * Append bad characters
+ * Shift one byte for each iteration
+ * Validate each shift
+
+## Code breakdown
+
+Below table shows how 16 bytes input are processed step by step. See [range-neon.c](range-neon.c) for according code.
+
+![Range based UTF-8 validation algorithm](https://raw.githubusercontent.com/cyb70289/utf8/master/range.png)
diff --git a/contrib/libs/protobuf/third_party/utf8_range/UTF-8-demo.txt b/contrib/libs/protobuf/third_party/utf8_range/UTF-8-demo.txt
new file mode 100644
index 00000000000..ff915b268aa
--- /dev/null
+++ b/contrib/libs/protobuf/third_party/utf8_range/UTF-8-demo.txt
@@ -0,0 +1,212 @@
+
+UTF-8 encoded sample plain-text file
+‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
+
+Markus Kuhn [ˈmaʳkʊs kuːn] <http://www.cl.cam.ac.uk/~mgk25/> — 2002-07-25 CC BY
+
+
+The ASCII compatible UTF-8 encoding used in this plain-text file
+is defined in Unicode, ISO 10646-1, and RFC 2279.
+
+
+Using Unicode/UTF-8, you can write in emails and source code things such as
+
+Mathematics and sciences:
+
+ ∮ E⋅da = Q, n → ∞, ∑ f(i) = ∏ g(i), ⎧⎡⎛┌─────┐⎞⎤⎫
+ ⎪⎢⎜│a²+b³ ⎟⎥⎪
+ ∀x∈ℝ: ⌈x⌉ = −⌊−x⌋, α ∧ ¬β = ¬(¬α ∨ β), ⎪⎢⎜│───── ⎟⎥⎪
+ ⎪⎢⎜⎷ c₈ ⎟⎥⎪
+ ℕ ⊆ ℕ₀ ⊂ ℤ ⊂ ℚ ⊂ ℝ ⊂ ℂ, ⎨⎢⎜ ⎟⎥⎬
+ ⎪⎢⎜ ∞ ⎟⎥⎪
+ ⊥ < a ≠ b ≡ c ≤ d ≪ ⊤ ⇒ (⟦A⟧ ⇔ ⟪B⟫), ⎪⎢⎜ ⎲ ⎟⎥⎪
+ ⎪⎢⎜ ⎳aⁱ-bⁱ⎟⎥⎪
+ 2H₂ + O₂ ⇌ 2H₂O, R = 4.7 kΩ, ⌀ 200 mm ⎩⎣⎝i=1 ⎠⎦⎭
+
+Linguistics and dictionaries:
+
+ ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeıʃn
+ Y [ˈʏpsilɔn], Yen [jɛn], Yoga [ˈjoːgɑ]
+
+APL:
+
+ ((V⍳V)=⍳⍴V)/V←,V ⌷←⍳→⍴∆∇⊃‾⍎⍕⌈
+
+Nicer typography in plain text files:
+
+ ╔══════════════════════════════════════════╗
+ ║ ║
+ ║ • ‘single’ and “double” quotes ║
+ ║ ║
+ ║ • Curly apostrophes: “We’ve been here” ║
+ ║ ║
+ ║ • Latin-1 apostrophe and accents: '´` ║
+ ║ ║
+ ║ • ‚deutsche‘ „Anführungszeichen“ ║
+ ║ ║
+ ║ • †, ‡, ‰, •, 3–4, —, −5/+5, ™, … ║
+ ║ ║
+ ║ • ASCII safety test: 1lI|, 0OD, 8B ║
+ ║ ╭─────────╮ ║
+ ║ • the euro symbol: │ 14.95 € │ ║
+ ║ ╰─────────╯ ║
+ ╚══════════════════════════════════════════╝
+
+Combining characters:
+
+ STARGΛ̊TE SG-1, a = v̇ = r̈, a⃑ ⊥ b⃑
+
+Greek (in Polytonic):
+
+ The Greek anthem:
+
+ Σὲ γνωρίζω ἀπὸ τὴν κόψη
+ τοῦ σπαθιοῦ τὴν τρομερή,
+ σὲ γνωρίζω ἀπὸ τὴν ὄψη
+ ποὺ μὲ βία μετράει τὴ γῆ.
+
+ ᾿Απ᾿ τὰ κόκκαλα βγαλμένη
+ τῶν ῾Ελλήνων τὰ ἱερά
+ καὶ σὰν πρῶτα ἀνδρειωμένη
+ χαῖρε, ὦ χαῖρε, ᾿Ελευθεριά!
+
+ From a speech of Demosthenes in the 4th century BC:
+
+ Οὐχὶ ταὐτὰ παρίσταταί μοι γιγνώσκειν, ὦ ἄνδρες ᾿Αθηναῖοι,
+ ὅταν τ᾿ εἰς τὰ πράγματα ἀποβλέψω καὶ ὅταν πρὸς τοὺς
+ λόγους οὓς ἀκούω· τοὺς μὲν γὰρ λόγους περὶ τοῦ
+ τιμωρήσασθαι Φίλιππον ὁρῶ γιγνομένους, τὰ δὲ πράγματ᾿
+ εἰς τοῦτο προήκοντα, ὥσθ᾿ ὅπως μὴ πεισόμεθ᾿ αὐτοὶ
+ πρότερον κακῶς σκέψασθαι δέον. οὐδέν οὖν ἄλλο μοι δοκοῦσιν
+ οἱ τὰ τοιαῦτα λέγοντες ἢ τὴν ὑπόθεσιν, περὶ ἧς βουλεύεσθαι,
+ οὐχὶ τὴν οὖσαν παριστάντες ὑμῖν ἁμαρτάνειν. ἐγὼ δέ, ὅτι μέν
+ ποτ᾿ ἐξῆν τῇ πόλει καὶ τὰ αὑτῆς ἔχειν ἀσφαλῶς καὶ Φίλιππον
+ τιμωρήσασθαι, καὶ μάλ᾿ ἀκριβῶς οἶδα· ἐπ᾿ ἐμοῦ γάρ, οὐ πάλαι
+ γέγονεν ταῦτ᾿ ἀμφότερα· νῦν μέντοι πέπεισμαι τοῦθ᾿ ἱκανὸν
+ προλαβεῖν ἡμῖν εἶναι τὴν πρώτην, ὅπως τοὺς συμμάχους
+ σώσομεν. ἐὰν γὰρ τοῦτο βεβαίως ὑπάρξῃ, τότε καὶ περὶ τοῦ
+ τίνα τιμωρήσεταί τις καὶ ὃν τρόπον ἐξέσται σκοπεῖν· πρὶν δὲ
+ τὴν ἀρχὴν ὀρθῶς ὑποθέσθαι, μάταιον ἡγοῦμαι περὶ τῆς
+ τελευτῆς ὁντινοῦν ποιεῖσθαι λόγον.
+
+ Δημοσθένους, Γ´ ᾿Ολυνθιακὸς
+
+Georgian:
+
+ From a Unicode conference invitation:
+
+ გთხოვთ ახლავე გაიაროთ რეგისტრაცია Unicode-ის მეათე საერთაშორისო
+ კონფერენციაზე დასასწრებად, რომელიც გაიმართება 10-12 მარტს,
+ ქ. მაინცში, გერმანიაში. კონფერენცია შეჰკრებს ერთად მსოფლიოს
+ ექსპერტებს ისეთ დარგებში როგორიცაა ინტერნეტი და Unicode-ი,
+ ინტერნაციონალიზაცია და ლოკალიზაცია, Unicode-ის გამოყენება
+ ოპერაციულ სისტემებსა, და გამოყენებით პროგრამებში, შრიფტებში,
+ ტექსტების დამუშავებასა და მრავალენოვან კომპიუტერულ სისტემებში.
+
+Russian:
+
+ From a Unicode conference invitation:
+
+ Зарегистрируйтесь сейчас на Десятую Международную Конференцию по
+ Unicode, которая состоится 10-12 марта 1997 года в Майнце в Германии.
+ Конференция соберет широкий круг экспертов по вопросам глобального
+ Интернета и Unicode, локализации и интернационализации, воплощению и
+ применению Unicode в различных операционных системах и программных
+ приложениях, шрифтах, верстке и многоязычных компьютерных системах.
+
+Thai (UCS Level 2):
+
+ Excerpt from a poetry on The Romance of The Three Kingdoms (a Chinese
+ classic 'San Gua'):
+
+ [----------------------------|------------------------]
+ ๏ แผ่นดินฮั่นเสื่อมโทรมแสนสังเวช พระปกเกศกองบู๊กู้ขึ้นใหม่
+ สิบสองกษัตริย์ก่อนหน้าแลถัดไป สององค์ไซร้โง่เขลาเบาปัญญา
+ ทรงนับถือขันทีเป็นที่พึ่ง บ้านเมืองจึงวิปริตเป็นนักหนา
+ โฮจิ๋นเรียกทัพทั่วหัวเมืองมา หมายจะฆ่ามดชั่วตัวสำคัญ
+ เหมือนขับไสไล่เสือจากเคหา รับหมาป่าเข้ามาเลยอาสัญ
+ ฝ่ายอ้องอุ้นยุแยกให้แตกกัน ใช้สาวนั้นเป็นชนวนชื่นชวนใจ
+ พลันลิฉุยกุยกีกลับก่อเหตุ ช่างอาเพศจริงหนาฟ้าร้องไห้
+ ต้องรบราฆ่าฟันจนบรรลัย ฤๅหาใครค้ำชูกู้บรรลังก์ ฯ
+
+ (The above is a two-column text. If combining characters are handled
+ correctly, the lines of the second column should be aligned with the
+ | character above.)
+
+Ethiopian:
+
+ Proverbs in the Amharic language:
+
+ ሰማይ አይታረስ ንጉሥ አይከሰስ።
+ ብላ ካለኝ እንደአባቴ በቆመጠኝ።
+ ጌጥ ያለቤቱ ቁምጥና ነው።
+ ደሀ በሕልሙ ቅቤ ባይጠጣ ንጣት በገደለው።
+ የአፍ ወለምታ በቅቤ አይታሽም።
+ አይጥ በበላ ዳዋ ተመታ።
+ ሲተረጉሙ ይደረግሙ።
+ ቀስ በቀስ፥ ዕንቁላል በእግሩ ይሄዳል።
+ ድር ቢያብር አንበሳ ያስር።
+ ሰው እንደቤቱ እንጅ እንደ ጉረቤቱ አይተዳደርም።
+ እግዜር የከፈተውን ጉሮሮ ሳይዘጋው አይድርም።
+ የጎረቤት ሌባ፥ ቢያዩት ይስቅ ባያዩት ያጠልቅ።
+ ሥራ ከመፍታት ልጄን ላፋታት።
+ ዓባይ ማደሪያ የለው፥ ግንድ ይዞ ይዞራል።
+ የእስላም አገሩ መካ የአሞራ አገሩ ዋርካ።
+ ተንጋሎ ቢተፉ ተመልሶ ባፉ።
+ ወዳጅህ ማር ቢሆን ጨርስህ አትላሰው።
+ እግርህን በፍራሽህ ልክ ዘርጋ።
+
+Runes:
+
+ ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ
+
+ (Old English, which transcribed into Latin reads 'He cwaeth that he
+ bude thaem lande northweardum with tha Westsae.' and means 'He said
+ that he lived in the northern land near the Western Sea.')
+
+Braille:
+
+ ⡌⠁⠧⠑ ⠼⠁⠒ ⡍⠜⠇⠑⠹⠰⠎ ⡣⠕⠌
+
+ ⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠙⠑⠁⠙⠒ ⠞⠕ ⠃⠑⠛⠔ ⠺⠊⠹⠲ ⡹⠻⠑ ⠊⠎ ⠝⠕ ⠙⠳⠃⠞
+ ⠱⠁⠞⠑⠧⠻ ⠁⠃⠳⠞ ⠹⠁⠞⠲ ⡹⠑ ⠗⠑⠛⠊⠌⠻ ⠕⠋ ⠙⠊⠎ ⠃⠥⠗⠊⠁⠇ ⠺⠁⠎
+ ⠎⠊⠛⠝⠫ ⠃⠹ ⠹⠑ ⠊⠇⠻⠛⠹⠍⠁⠝⠂ ⠹⠑ ⠊⠇⠻⠅⠂ ⠹⠑ ⠥⠝⠙⠻⠞⠁⠅⠻⠂
+ ⠁⠝⠙ ⠹⠑ ⠡⠊⠑⠋ ⠍⠳⠗⠝⠻⠲ ⡎⠊⠗⠕⠕⠛⠑ ⠎⠊⠛⠝⠫ ⠊⠞⠲ ⡁⠝⠙
+ ⡎⠊⠗⠕⠕⠛⠑⠰⠎ ⠝⠁⠍⠑ ⠺⠁⠎ ⠛⠕⠕⠙ ⠥⠏⠕⠝ ⠰⡡⠁⠝⠛⠑⠂ ⠋⠕⠗ ⠁⠝⠹⠹⠔⠛ ⠙⠑
+ ⠡⠕⠎⠑ ⠞⠕ ⠏⠥⠞ ⠙⠊⠎ ⠙⠁⠝⠙ ⠞⠕⠲
+
+ ⡕⠇⠙ ⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠁⠎ ⠙⠑⠁⠙ ⠁⠎ ⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲
+
+ ⡍⠔⠙⠖ ⡊ ⠙⠕⠝⠰⠞ ⠍⠑⠁⠝ ⠞⠕ ⠎⠁⠹ ⠹⠁⠞ ⡊ ⠅⠝⠪⠂ ⠕⠋ ⠍⠹
+ ⠪⠝ ⠅⠝⠪⠇⠫⠛⠑⠂ ⠱⠁⠞ ⠹⠻⠑ ⠊⠎ ⠏⠜⠞⠊⠊⠥⠇⠜⠇⠹ ⠙⠑⠁⠙ ⠁⠃⠳⠞
+ ⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲ ⡊ ⠍⠊⠣⠞ ⠙⠁⠧⠑ ⠃⠑⠲ ⠔⠊⠇⠔⠫⠂ ⠍⠹⠎⠑⠇⠋⠂ ⠞⠕
+ ⠗⠑⠛⠜⠙ ⠁ ⠊⠕⠋⠋⠔⠤⠝⠁⠊⠇ ⠁⠎ ⠹⠑ ⠙⠑⠁⠙⠑⠌ ⠏⠊⠑⠊⠑ ⠕⠋ ⠊⠗⠕⠝⠍⠕⠝⠛⠻⠹
+ ⠔ ⠹⠑ ⠞⠗⠁⠙⠑⠲ ⡃⠥⠞ ⠹⠑ ⠺⠊⠎⠙⠕⠍ ⠕⠋ ⠳⠗ ⠁⠝⠊⠑⠌⠕⠗⠎
+ ⠊⠎ ⠔ ⠹⠑ ⠎⠊⠍⠊⠇⠑⠆ ⠁⠝⠙ ⠍⠹ ⠥⠝⠙⠁⠇⠇⠪⠫ ⠙⠁⠝⠙⠎
+ ⠩⠁⠇⠇ ⠝⠕⠞ ⠙⠊⠌⠥⠗⠃ ⠊⠞⠂ ⠕⠗ ⠹⠑ ⡊⠳⠝⠞⠗⠹⠰⠎ ⠙⠕⠝⠑ ⠋⠕⠗⠲ ⡹⠳
+ ⠺⠊⠇⠇ ⠹⠻⠑⠋⠕⠗⠑ ⠏⠻⠍⠊⠞ ⠍⠑ ⠞⠕ ⠗⠑⠏⠑⠁⠞⠂ ⠑⠍⠏⠙⠁⠞⠊⠊⠁⠇⠇⠹⠂ ⠹⠁⠞
+ ⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠁⠎ ⠙⠑⠁⠙ ⠁⠎ ⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲
+
+ (The first couple of paragraphs of "A Christmas Carol" by Dickens)
+
+Compact font selection example text:
+
+ ABCDEFGHIJKLMNOPQRSTUVWXYZ /0123456789
+ abcdefghijklmnopqrstuvwxyz £©µÀÆÖÞßéöÿ
+ –—‘“”„†•…‰™œŠŸž€ ΑΒΓΔΩαβγδω АБВГДабвгд
+ ∀∂∈ℝ∧∪≡∞ ↑↗↨↻⇣ ┐┼╔╘░►☺♀ fi�⑀₂ἠḂӥẄɐː⍎אԱა
+
+Greetings in various languages:
+
+ Hello world, Καλημέρα κόσμε, コンニチハ
+
+Box drawing alignment tests: █
+ ▉
+ ╔══╦══╗ ┌──┬──┐ ╭──┬──╮ ╭──┬──╮ ┏━━┳━━┓ ┎┒┏┑ ╷ ╻ ┏┯┓ ┌┰┐ ▊ ╱╲╱╲╳╳╳
+ ║┌─╨─┐║ │╔═╧═╗│ │╒═╪═╕│ │╓─╁─╖│ ┃┌─╂─┐┃ ┗╃╄┙ ╶┼╴╺╋╸┠┼┨ ┝╋┥ ▋ ╲╱╲╱╳╳╳
+ ║│╲ ╱│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╿ │┃ ┍╅╆┓ ╵ ╹ ┗┷┛ └┸┘ ▌ ╱╲╱╲╳╳╳
+ ╠╡ ╳ ╞╣ ├╢ ╟┤ ├┼─┼─┼┤ ├╫─╂─╫┤ ┣┿╾┼╼┿┫ ┕┛┖┚ ┌┄┄┐ ╎ ┏┅┅┓ ┋ ▍ ╲╱╲╱╳╳╳
+ ║│╱ ╲│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╽ │┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▎
+ ║└─╥─┘║ │╚═╤═╝│ │╘═╪═╛│ │╙─╀─╜│ ┃└─╂─┘┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▏
+ ╚══╩══╝ └──┴──┘ ╰──┴──╯ ╰──┴──╯ ┗━━┻━━┛ ▗▄▖▛▀▜ └╌╌┘ ╎ ┗╍╍┛ ┋ ▁▂▃▄▅▆▇█
+ ▝▀▘▙▄▟
diff --git a/contrib/libs/protobuf/third_party/utf8_range/utf8_validity.cc b/contrib/libs/protobuf/third_party/utf8_range/utf8_validity.cc
new file mode 100644
index 00000000000..c77c99636a5
--- /dev/null
+++ b/contrib/libs/protobuf/third_party/utf8_range/utf8_validity.cc
@@ -0,0 +1,458 @@
+// Copyright 2022 Google LLC
+//
+// Use of this source code is governed by an MIT-style
+// license that can be found in the LICENSE file or at
+// https://opensource.org/licenses/MIT.
+
+/* This is a wrapper for the Google range-sse.cc algorithm which checks whether a
+ * sequence of bytes is a valid UTF-8 sequence and finds the longest valid prefix of
+ * the UTF-8 sequence.
+ *
+ * The key difference is that it checks for as much ASCII symbols as possible
+ * and then falls back to the range-sse.cc algorithm. The changes to the
+ * algorithm are cosmetic, mostly to trick the clang compiler to produce optimal
+ * code.
+ *
+ * For API see the utf8_validity.h header.
+ */
+#include "utf8_validity.h"
+
+#include <cstddef>
+#include <cstdint>
+
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/string_view.h"
+
+#ifdef __SSE4_1__
+#include <emmintrin.h>
+#include <smmintrin.h>
+#include <tmmintrin.h>
+#endif
+
+namespace utf8_range {
+namespace {
+
+inline arc_ui64 UNALIGNED_LOAD64(const void* p) {
+ arc_ui64 t;
+ memcpy(&t, p, sizeof t);
+ return t;
+}
+
+inline bool TrailByteOk(const char c) {
+ return static_cast<int8_t>(c) <= static_cast<int8_t>(0xBF);
+}
+
+/* If ReturnPosition is false then it returns 1 if |data| is a valid utf8
+ * sequence, otherwise returns 0.
+ * If ReturnPosition is set to true, returns the length in bytes of the prefix
+ of |data| that is all structurally valid UTF-8.
+ */
+template <bool ReturnPosition>
+size_t ValidUTF8Span(const char* data, const char* end) {
+ /* We return err_pos in the loop which is always 0 if !ReturnPosition */
+ size_t err_pos = 0;
+ size_t codepoint_bytes = 0;
+ /* The early check is done because of early continue's on codepoints of all
+ * sizes, i.e. we first check for ascii and if it is, we call continue, then
+ * for 2 byte codepoints, etc. This is done in order to reduce indentation and
+ * improve readability of the codepoint validity check.
+ */
+ while (data + codepoint_bytes < end) {
+ if (ReturnPosition) {
+ err_pos += codepoint_bytes;
+ }
+ data += codepoint_bytes;
+ const size_t len = end - data;
+ const unsigned char byte1 = data[0];
+
+ /* We do not skip many ascii bytes at the same time as this function is
+ used for tail checking (< 16 bytes) and for non x86 platforms. We also
+ don't think that cases where non-ASCII codepoints are followed by ascii
+ happen often. For small strings it also introduces some penalty. For
+ purely ascii UTF8 strings (which is the overwhelming case) we call
+ SkipAscii function which is multiplatform and extremely fast.
+ */
+ /* [00..7F] ASCII -> 1 byte */
+ if (y_absl::ascii_isascii(byte1)) {
+ codepoint_bytes = 1;
+ continue;
+ }
+ /* [C2..DF], [80..BF] -> 2 bytes */
+ if (len >= 2 && byte1 >= 0xC2 && byte1 <= 0xDF && TrailByteOk(data[1])) {
+ codepoint_bytes = 2;
+ continue;
+ }
+ if (len >= 3) {
+ const unsigned char byte2 = data[1];
+ const unsigned char byte3 = data[2];
+
+ /* Is byte2, byte3 between [0x80, 0xBF]
+ * Check for 0x80 was done above.
+ */
+ if (!TrailByteOk(byte2) || !TrailByteOk(byte3)) {
+ return err_pos;
+ }
+
+ if (/* E0, A0..BF, 80..BF */
+ ((byte1 == 0xE0 && byte2 >= 0xA0) ||
+ /* E1..EC, 80..BF, 80..BF */
+ (byte1 >= 0xE1 && byte1 <= 0xEC) ||
+ /* ED, 80..9F, 80..BF */
+ (byte1 == 0xED && byte2 <= 0x9F) ||
+ /* EE..EF, 80..BF, 80..BF */
+ (byte1 >= 0xEE && byte1 <= 0xEF))) {
+ codepoint_bytes = 3;
+ continue;
+ }
+ if (len >= 4) {
+ const unsigned char byte4 = data[3];
+ /* Is byte4 between 0x80 ~ 0xBF */
+ if (!TrailByteOk(byte4)) {
+ return err_pos;
+ }
+
+ if (/* F0, 90..BF, 80..BF, 80..BF */
+ ((byte1 == 0xF0 && byte2 >= 0x90) ||
+ /* F1..F3, 80..BF, 80..BF, 80..BF */
+ (byte1 >= 0xF1 && byte1 <= 0xF3) ||
+ /* F4, 80..8F, 80..BF, 80..BF */
+ (byte1 == 0xF4 && byte2 <= 0x8F))) {
+ codepoint_bytes = 4;
+ continue;
+ }
+ }
+ }
+ return err_pos;
+ }
+ if (ReturnPosition) {
+ err_pos += codepoint_bytes;
+ }
+ /* if ReturnPosition is false, this returns 1.
+ * if ReturnPosition is true, this returns err_pos.
+ */
+ return err_pos + (1 - ReturnPosition);
+}
+
+/* Returns the number of bytes needed to skip backwards to get to the first
+ byte of codepoint.
+ */
+inline int CodepointSkipBackwards(arc_i32 codepoint_word) {
+ const int8_t* const codepoint =
+ reinterpret_cast<const int8_t*>(&codepoint_word);
+ if (!TrailByteOk(codepoint[3])) {
+ return 1;
+ } else if (!TrailByteOk(codepoint[2])) {
+ return 2;
+ } else if (!TrailByteOk(codepoint[1])) {
+ return 3;
+ }
+ return 0;
+}
+
+/* Skipping over ASCII as much as possible, per 8 bytes. It is intentional
+ as most strings to check for validity consist only of 1 byte codepoints.
+ */
+inline const char* SkipAscii(const char* data, const char* end) {
+ while (8 <= end - data &&
+ (UNALIGNED_LOAD64(data) & 0x8080808080808080) == 0) {
+ data += 8;
+ }
+ while (data < end && y_absl::ascii_isascii(*data)) {
+ ++data;
+ }
+ return data;
+}
+
+template <bool ReturnPosition>
+size_t ValidUTF8(const char* data, size_t len) {
+ if (len == 0) return 1 - ReturnPosition;
+ const char* const end = data + len;
+ data = SkipAscii(data, end);
+ /* SIMD algorithm always outperforms the naive version for any data of
+ length >=16.
+ */
+ if (end - data < 16) {
+ return (ReturnPosition ? (data - (end - len)) : 0) +
+ ValidUTF8Span<ReturnPosition>(data, end);
+ }
+#ifndef __SSE4_1__
+ return (ReturnPosition ? (data - (end - len)) : 0) +
+ ValidUTF8Span<ReturnPosition>(data, end);
+#else
+ /* This code checks that utf-8 ranges are structurally valid 16 bytes at once
+ * using superscalar instructions.
+ * The mapping between ranges of codepoint and their corresponding utf-8
+ * sequences is below.
+ */
+
+ /*
+ * U+0000...U+007F 00...7F
+ * U+0080...U+07FF C2...DF 80...BF
+ * U+0800...U+0FFF E0 A0...BF 80...BF
+ * U+1000...U+CFFF E1...EC 80...BF 80...BF
+ * U+D000...U+D7FF ED 80...9F 80...BF
+ * U+E000...U+FFFF EE...EF 80...BF 80...BF
+ * U+10000...U+3FFFF F0 90...BF 80...BF 80...BF
+ * U+40000...U+FFFFF F1...F3 80...BF 80...BF 80...BF
+ * U+100000...U+10FFFF F4 80...8F 80...BF 80...BF
+ */
+
+ /* First we compute the type for each byte, as given by the table below.
+ * This type will be used as an index later on.
+ */
+
+ /*
+ * Index Min Max Byte Type
+ * 0 00 7F Single byte sequence
+ * 1,2,3 80 BF Second, third and fourth byte for many of the sequences.
+ * 4 A0 BF Second byte after E0
+ * 5 80 9F Second byte after ED
+ * 6 90 BF Second byte after F0
+ * 7 80 8F Second byte after F4
+ * 8 C2 F4 First non ASCII byte
+ * 9..15 7F 80 Invalid byte
+ */
+
+ /* After the first step we compute the index for all bytes, then we permute
+ the bytes according to their indices to check the ranges from the range
+ table.
+ * The range for a given type can be found in the range_min_table and
+ range_max_table, the range for type/index X is in range_min_table[X] ...
+ range_max_table[X].
+ */
+
+ /* Algorithm:
+ * Put index zero to all bytes.
+ * Find all non ASCII characters, give them index 8.
+ * For each tail byte in a codepoint sequence, give it an index corresponding
+ to the 1 based index from the end.
+ * If the first byte of the codepoint is in the [C0...DF] range, we write
+ index 1 in the following byte.
+ * If the first byte of the codepoint is in the range [E0...EF], we write
+ indices 2 and 1 in the next two bytes.
+ * If the first byte of the codepoint is in the range [F0...FF] we write
+ indices 3,2,1 into the next three bytes.
+ * For finding the number of bytes we need to look at high nibbles (4 bits)
+ and do the lookup from the table, it can be done with shift by 4 + shuffle
+ instructions. We call it `first_len`.
+ * Then we shift first_len by 8 bits to get the indices of the 2nd bytes.
+ * Saturating sub 1 and shift by 8 bits to get the indices of the 3rd bytes.
+ * Again to get the indices of the 4th bytes.
+ * Take OR of all that 4 values and check within range.
+ */
+ /* For example:
+ * input C3 80 68 E2 80 20 A6 F0 A0 80 AC 20 F0 93 80 80
+ * first_len 1 0 0 2 0 0 0 3 0 0 0 0 3 0 0 0
+ * 1st byte 8 0 0 8 0 0 0 8 0 0 0 0 8 0 0 0
+ * 2nd byte 0 1 0 0 2 0 0 0 3 0 0 0 0 3 0 0 // Shift + sub
+ * 3rd byte 0 0 0 0 0 1 0 0 0 2 0 0 0 0 2 0 // Shift + sub
+ * 4th byte 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 // Shift + sub
+ * Index 8 1 0 8 2 1 0 8 3 2 1 0 8 3 2 1 // OR of results
+ */
+
+ /* Checking for errors:
+ * Error checking is done by looking up the high nibble (4 bits) of each byte
+ against an error checking table.
+ * Because the lookup value for the second byte depends of the value of the
+ first byte in codepoint, we use saturated operations to adjust the index.
+ * Specifically we need to add 2 for E0, 3 for ED, 3 for F0 and 4 for F4 to
+ match the correct index.
+ * If we subtract from all bytes EF then EO -> 241, ED -> 254, F0 -> 1,
+ F4 -> 5
+ * Do saturating sub 240, then E0 -> 1, ED -> 14 and we can do lookup to
+ match the adjustment
+ * Add saturating 112, then F0 -> 113, F4 -> 117, all that were > 16 will
+ be more 128 and lookup in ef_fe_table will return 0 but for F0
+ and F4 it will be 4 and 5 accordingly
+ */
+ /*
+ * Then just check the appropriate ranges with greater/smaller equal
+ instructions. Check tail with a naive algorithm.
+ * To save from previous 16 byte checks we just align previous_first_len to
+ get correct continuations of the codepoints.
+ */
+
+ /*
+ * Map high nibble of "First Byte" to legal character length minus 1
+ * 0x00 ~ 0xBF --> 0
+ * 0xC0 ~ 0xDF --> 1
+ * 0xE0 ~ 0xEF --> 2
+ * 0xF0 ~ 0xFF --> 3
+ */
+ const __m128i first_len_table =
+ _mm_setr_epi8(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3);
+
+ /* Map "First Byte" to 8-th item of range table (0xC2 ~ 0xF4) */
+ const __m128i first_range_table =
+ _mm_setr_epi8(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8);
+
+ /*
+ * Range table, map range index to min and max values
+ */
+ const __m128i range_min_table =
+ _mm_setr_epi8(0x00, 0x80, 0x80, 0x80, 0xA0, 0x80, 0x90, 0x80, 0xC2, 0x7F,
+ 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F);
+
+ const __m128i range_max_table =
+ _mm_setr_epi8(0x7F, 0xBF, 0xBF, 0xBF, 0xBF, 0x9F, 0xBF, 0x8F, 0xF4, 0x80,
+ 0x80, 0x80, 0x80, 0x80, 0x80, 0x80);
+
+ /*
+ * Tables for fast handling of four special First Bytes(E0,ED,F0,F4), after
+ * which the Second Byte are not 80~BF. It contains "range index adjustment".
+ * +------------+---------------+------------------+----------------+
+ * | First Byte | original range| range adjustment | adjusted range |
+ * +------------+---------------+------------------+----------------+
+ * | E0 | 2 | 2 | 4 |
+ * +------------+---------------+------------------+----------------+
+ * | ED | 2 | 3 | 5 |
+ * +------------+---------------+------------------+----------------+
+ * | F0 | 3 | 3 | 6 |
+ * +------------+---------------+------------------+----------------+
+ * | F4 | 4 | 4 | 8 |
+ * +------------+---------------+------------------+----------------+
+ */
+
+ /* df_ee_table[1] -> E0, df_ee_table[14] -> ED as ED - E0 = 13 */
+ // The values represent the adjustment in the Range Index table for a correct
+ // index.
+ const __m128i df_ee_table =
+ _mm_setr_epi8(0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0);
+
+ /* ef_fe_table[1] -> F0, ef_fe_table[5] -> F4, F4 - F0 = 4 */
+ // The values represent the adjustment in the Range Index table for a correct
+ // index.
+ const __m128i ef_fe_table =
+ _mm_setr_epi8(0, 3, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+
+ __m128i prev_input = _mm_set1_epi8(0);
+ __m128i prev_first_len = _mm_set1_epi8(0);
+ __m128i error = _mm_set1_epi8(0);
+ while (end - data >= 16) {
+ const __m128i input =
+ _mm_loadu_si128(reinterpret_cast<const __m128i*>(data));
+
+ /* high_nibbles = input >> 4 */
+ const __m128i high_nibbles =
+ _mm_and_si128(_mm_srli_epi16(input, 4), _mm_set1_epi8(0x0F));
+
+ /* first_len = legal character length minus 1 */
+ /* 0 for 00~7F, 1 for C0~DF, 2 for E0~EF, 3 for F0~FF */
+ /* first_len = first_len_table[high_nibbles] */
+ __m128i first_len = _mm_shuffle_epi8(first_len_table, high_nibbles);
+
+ /* First Byte: set range index to 8 for bytes within 0xC0 ~ 0xFF */
+ /* range = first_range_table[high_nibbles] */
+ __m128i range = _mm_shuffle_epi8(first_range_table, high_nibbles);
+
+ /* Second Byte: set range index to first_len */
+ /* 0 for 00~7F, 1 for C0~DF, 2 for E0~EF, 3 for F0~FF */
+ /* range |= (first_len, prev_first_len) << 1 byte */
+ range = _mm_or_si128(range, _mm_alignr_epi8(first_len, prev_first_len, 15));
+
+ /* Third Byte: set range index to saturate_sub(first_len, 1) */
+ /* 0 for 00~7F, 0 for C0~DF, 1 for E0~EF, 2 for F0~FF */
+ __m128i tmp1;
+ __m128i tmp2;
+ /* tmp1 = saturate_sub(first_len, 1) */
+ tmp1 = _mm_subs_epu8(first_len, _mm_set1_epi8(1));
+ /* tmp2 = saturate_sub(prev_first_len, 1) */
+ tmp2 = _mm_subs_epu8(prev_first_len, _mm_set1_epi8(1));
+ /* range |= (tmp1, tmp2) << 2 bytes */
+ range = _mm_or_si128(range, _mm_alignr_epi8(tmp1, tmp2, 14));
+
+ /* Fourth Byte: set range index to saturate_sub(first_len, 2) */
+ /* 0 for 00~7F, 0 for C0~DF, 0 for E0~EF, 1 for F0~FF */
+ /* tmp1 = saturate_sub(first_len, 2) */
+ tmp1 = _mm_subs_epu8(first_len, _mm_set1_epi8(2));
+ /* tmp2 = saturate_sub(prev_first_len, 2) */
+ tmp2 = _mm_subs_epu8(prev_first_len, _mm_set1_epi8(2));
+ /* range |= (tmp1, tmp2) << 3 bytes */
+ range = _mm_or_si128(range, _mm_alignr_epi8(tmp1, tmp2, 13));
+
+ /*
+ * Now we have below range indices calculated
+ * Correct cases:
+ * - 8 for C0~FF
+ * - 3 for 1st byte after F0~FF
+ * - 2 for 1st byte after E0~EF or 2nd byte after F0~FF
+ * - 1 for 1st byte after C0~DF or 2nd byte after E0~EF or
+ * 3rd byte after F0~FF
+ * - 0 for others
+ * Error cases:
+ * >9 for non ascii First Byte overlapping
+ * E.g., F1 80 C2 90 --> 8 3 10 2, where 10 indicates error
+ */
+
+ /* Adjust Second Byte range for special First Bytes(E0,ED,F0,F4) */
+ /* Overlaps lead to index 9~15, which are illegal in range table */
+ __m128i shift1;
+ __m128i pos;
+ __m128i range2;
+ /* shift1 = (input, prev_input) << 1 byte */
+ shift1 = _mm_alignr_epi8(input, prev_input, 15);
+ pos = _mm_sub_epi8(shift1, _mm_set1_epi8(0xEF));
+ /*
+ * shift1: | EF F0 ... FE | FF 00 ... ... DE | DF E0 ... EE |
+ * pos: | 0 1 15 | 16 17 239| 240 241 255|
+ * pos-240: | 0 0 0 | 0 0 0 | 0 1 15 |
+ * pos+112: | 112 113 127| >= 128 | >= 128 |
+ */
+ tmp1 = _mm_subs_epu8(pos, _mm_set1_epi8(-16));
+ range2 = _mm_shuffle_epi8(df_ee_table, tmp1);
+ tmp2 = _mm_adds_epu8(pos, _mm_set1_epi8(112));
+ range2 = _mm_add_epi8(range2, _mm_shuffle_epi8(ef_fe_table, tmp2));
+
+ range = _mm_add_epi8(range, range2);
+
+ /* Load min and max values per calculated range index */
+ __m128i min_range = _mm_shuffle_epi8(range_min_table, range);
+ __m128i max_range = _mm_shuffle_epi8(range_max_table, range);
+
+ /* Check value range */
+ if (ReturnPosition) {
+ error = _mm_cmplt_epi8(input, min_range);
+ error = _mm_or_si128(error, _mm_cmpgt_epi8(input, max_range));
+ /* 5% performance drop from this conditional branch */
+ if (!_mm_testz_si128(error, error)) {
+ break;
+ }
+ } else {
+ error = _mm_or_si128(error, _mm_cmplt_epi8(input, min_range));
+ error = _mm_or_si128(error, _mm_cmpgt_epi8(input, max_range));
+ }
+
+ prev_input = input;
+ prev_first_len = first_len;
+
+ data += 16;
+ }
+ /* If we got to the end, we don't need to skip any bytes backwards */
+ if (ReturnPosition && (data - (end - len)) == 0) {
+ return ValidUTF8Span<true>(data, end);
+ }
+ /* Find previous codepoint (not 80~BF) */
+ data -= CodepointSkipBackwards(_mm_extract_epi32(prev_input, 3));
+ if (ReturnPosition) {
+ return (data - (end - len)) + ValidUTF8Span<true>(data, end);
+ }
+ /* Test if there was any error */
+ if (!_mm_testz_si128(error, error)) {
+ return 0;
+ }
+ /* Check the tail */
+ return ValidUTF8Span<false>(data, end);
+#endif
+}
+
+} // namespace
+
+bool IsStructurallyValid(y_absl::string_view str) {
+ return ValidUTF8</*ReturnPosition=*/false>(str.data(), str.size());
+}
+
+size_t SpanStructurallyValid(y_absl::string_view str) {
+ return ValidUTF8</*ReturnPosition=*/true>(str.data(), str.size());
+}
+
+} // namespace utf8_range
diff --git a/contrib/libs/protobuf/third_party/utf8_range/utf8_validity.h b/contrib/libs/protobuf/third_party/utf8_range/utf8_validity.h
new file mode 100644
index 00000000000..076c175f6f3
--- /dev/null
+++ b/contrib/libs/protobuf/third_party/utf8_range/utf8_validity.h
@@ -0,0 +1,23 @@
+// Copyright 2022 Google LLC
+//
+// Use of this source code is governed by an MIT-style
+// license that can be found in the LICENSE file or at
+// https://opensource.org/licenses/MIT.
+
+#ifndef THIRD_PARTY_UTF8_RANGE_UTF8_VALIDITY_H_
+#define THIRD_PARTY_UTF8_RANGE_UTF8_VALIDITY_H_
+
+#include "y_absl/strings/string_view.h"
+
+namespace utf8_range {
+
+// Returns true if the sequence of characters is a valid UTF-8 sequence.
+bool IsStructurallyValid(y_absl::string_view str);
+
+// Returns the length in bytes of the prefix of str that is all
+// structurally valid UTF-8.
+size_t SpanStructurallyValid(y_absl::string_view str);
+
+} // namespace utf8_range
+
+#endif // THIRD_PARTY_UTF8_RANGE_UTF8_VALIDITY_H_
diff --git a/contrib/libs/protobuf/ya.make b/contrib/libs/protobuf/ya.make
index 1208fd114ee..ef458741f3b 100644
--- a/contrib/libs/protobuf/ya.make
+++ b/contrib/libs/protobuf/ya.make
@@ -4,6 +4,7 @@ LIBRARY()
LICENSE(
BSD-3-Clause AND
+ MIT AND
Protobuf-License
)
@@ -11,9 +12,9 @@ LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
PROVIDES(protobuf)
-VERSION(3.21.3)
+VERSION(3.22.5)
-ORIGINAL_SOURCE(https://github.com/protocolbuffers/protobuf/archive/v3.21.3.tar.gz)
+ORIGINAL_SOURCE(https://github.com/protocolbuffers/protobuf/archive/v3.22.5.tar.gz)
IF (OPENSOURCE_REPLACE_PROTOBUF AND EXPORT_CMAKE)
OPENSOURCE_EXPORT_REPLACEMENT(
@@ -43,6 +44,12 @@ ENDIF()
PEERDIR(
contrib/libs/zlib
library/cpp/sanitizer/include
+ contrib/restricted/abseil-cpp-tstring/y_absl/status
+ contrib/restricted/abseil-cpp-tstring/y_absl/log
+)
+
+ADDINCL(
+ contrib/libs/protobuf/third_party/utf8_range
)
NO_COMPILER_WARNINGS()
@@ -63,6 +70,8 @@ SRCS(
src/google/protobuf/any_lite.cc
src/google/protobuf/api.pb.cc
src/google/protobuf/arena.cc
+ src/google/protobuf/arena_align.cc
+ src/google/protobuf/arena_config.cc
src/google/protobuf/arenastring.cc
src/google/protobuf/arenaz_sampler.cc
src/google/protobuf/descriptor.cc
@@ -78,6 +87,7 @@ SRCS(
src/google/protobuf/generated_message_bases.cc
src/google/protobuf/generated_message_reflection.cc
src/google/protobuf/generated_message_tctable_full.cc
+ src/google/protobuf/generated_message_tctable_gen.cc
src/google/protobuf/generated_message_tctable_lite.cc
src/google/protobuf/implicit_weak_message.cc
src/google/protobuf/inlined_string_field.cc
@@ -87,9 +97,19 @@ SRCS(
src/google/protobuf/io/printer.cc
src/google/protobuf/io/strtod.cc
src/google/protobuf/io/tokenizer.cc
+ src/google/protobuf/io/zero_copy_sink.cc
src/google/protobuf/io/zero_copy_stream.cc
src/google/protobuf/io/zero_copy_stream_impl.cc
src/google/protobuf/io/zero_copy_stream_impl_lite.cc
+ src/google/protobuf/json/internal/lexer.cc
+ src/google/protobuf/json/internal/message_path.cc
+ src/google/protobuf/json/internal/parser.cc
+ src/google/protobuf/json/internal/unparser.cc
+ src/google/protobuf/json/internal/untyped_message.cc
+ src/google/protobuf/json/internal/writer.cc
+ src/google/protobuf/json/internal/zero_copy_buffered_stream.cc
+ src/google/protobuf/json/json.cc
+ src/google/protobuf/json/old_json.cc
src/google/protobuf/json_util.cc
src/google/protobuf/map.cc
src/google/protobuf/map_field.cc
@@ -103,17 +123,12 @@ SRCS(
src/google/protobuf/service.cc
src/google/protobuf/source_context.pb.cc
src/google/protobuf/struct.pb.cc
- src/google/protobuf/stubs/bytestream.cc
src/google/protobuf/stubs/common.cc
- src/google/protobuf/stubs/int128.cc
src/google/protobuf/stubs/status.cc
- src/google/protobuf/stubs/statusor.cc
src/google/protobuf/stubs/stringpiece.cc
- src/google/protobuf/stubs/stringprintf.cc
src/google/protobuf/stubs/structurally_valid.cc
src/google/protobuf/stubs/strutil.cc
src/google/protobuf/stubs/substitute.cc
- src/google/protobuf/stubs/time.cc
src/google/protobuf/text_format.cc
src/google/protobuf/timestamp.pb.cc
src/google/protobuf/type.pb.cc
@@ -121,26 +136,13 @@ SRCS(
src/google/protobuf/util/delimited_message_util.cc
src/google/protobuf/util/field_comparator.cc
src/google/protobuf/util/field_mask_util.cc
- src/google/protobuf/util/internal/datapiece.cc
- src/google/protobuf/util/internal/default_value_objectwriter.cc
- src/google/protobuf/util/internal/error_listener.cc
- src/google/protobuf/util/internal/field_mask_utility.cc
- src/google/protobuf/util/internal/json_escaping.cc
- src/google/protobuf/util/internal/json_objectwriter.cc
- src/google/protobuf/util/internal/json_stream_parser.cc
- src/google/protobuf/util/internal/object_writer.cc
- src/google/protobuf/util/internal/proto_writer.cc
- src/google/protobuf/util/internal/protostream_objectsource.cc
- src/google/protobuf/util/internal/protostream_objectwriter.cc
- src/google/protobuf/util/internal/type_info.cc
- src/google/protobuf/util/internal/utility.cc
- src/google/protobuf/util/json_util.cc
src/google/protobuf/util/message_differencer.cc
src/google/protobuf/util/time_util.cc
src/google/protobuf/util/type_resolver_util.cc
src/google/protobuf/wire_format.cc
src/google/protobuf/wire_format_lite.cc
src/google/protobuf/wrappers.pb.cc
+ third_party/utf8_range/utf8_validity.cc
)
FILES(
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 f714df372ae..21291b6b29f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.cc
@@ -32,13 +32,17 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/code_generator.h>
+#include "google/protobuf/compiler/code_generator.h"
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/compiler/plugin.pb.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/stubs/strutil.h>
+#include <utility>
+
+#include "google/protobuf/compiler/plugin.pb.h"
+#include "google/protobuf/descriptor.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_split.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/strings/strip.h"
namespace google {
namespace protobuf {
@@ -62,7 +66,7 @@ bool CodeGenerator::GenerateAll(const std::vector<const FileDescriptor*>& files,
"description.";
}
if (error && !error->empty()) {
- *error = file->name() + ": " + *error;
+ *error = y_absl::StrCat(file->name(), ": ", *error);
break;
}
if (!succeeded) {
@@ -81,7 +85,7 @@ io::ZeroCopyOutputStream* GeneratorContext::OpenForAppend(
io::ZeroCopyOutputStream* GeneratorContext::OpenForInsert(
const TProtoStringType& filename, const TProtoStringType& insertion_point) {
- GOOGLE_LOG(FATAL) << "This GeneratorContext does not support insertion.";
+ Y_ABSL_LOG(FATAL) << "This GeneratorContext does not support insertion.";
return nullptr; // make compiler happy
}
@@ -93,7 +97,7 @@ io::ZeroCopyOutputStream* GeneratorContext::OpenForInsertWithGeneratedCodeInfo(
void GeneratorContext::ListParsedFiles(
std::vector<const FileDescriptor*>* output) {
- GOOGLE_LOG(FATAL) << "This GeneratorContext does not support ListParsedFiles";
+ Y_ABSL_LOG(FATAL) << "This GeneratorContext does not support ListParsedFiles";
}
void GeneratorContext::GetCompilerVersion(Version* version) const {
@@ -105,30 +109,28 @@ void GeneratorContext::GetCompilerVersion(Version* version) const {
// Parses a set of comma-delimited name/value pairs.
void ParseGeneratorParameter(
- const TProtoStringType& text,
+ y_absl::string_view text,
std::vector<std::pair<TProtoStringType, TProtoStringType> >* output) {
- std::vector<TProtoStringType> parts = Split(text, ",", true);
-
- for (int i = 0; i < parts.size(); i++) {
- TProtoStringType::size_type equals_pos = parts[i].find_first_of('=');
- std::pair<TProtoStringType, TProtoStringType> value;
- if (equals_pos == TProtoStringType::npos) {
- value.first = parts[i];
- value.second = "";
+ std::vector<y_absl::string_view> parts =
+ y_absl::StrSplit(text, ',', y_absl::SkipEmpty());
+
+ for (y_absl::string_view part : parts) {
+ auto equals_pos = part.find_first_of('=');
+ if (equals_pos == y_absl::string_view::npos) {
+ output->emplace_back(part, "");
} else {
- value.first = parts[i].substr(0, equals_pos);
- value.second = parts[i].substr(equals_pos + 1);
+ output->emplace_back(part.substr(0, equals_pos),
+ part.substr(equals_pos + 1));
}
- output->push_back(value);
}
}
// Strips ".proto" or ".protodevel" from the end of a filename.
-TProtoStringType StripProto(const TProtoStringType& filename) {
- if (HasSuffixString(filename, ".protodevel")) {
- return StripSuffixString(filename, ".protodevel");
+TProtoStringType StripProto(y_absl::string_view filename) {
+ if (y_absl::EndsWith(filename, ".protodevel")) {
+ return TProtoStringType(y_absl::StripSuffix(filename, ".protodevel"));
} else {
- return StripSuffixString(filename, ".proto");
+ return TProtoStringType(y_absl::StripSuffix(filename, ".proto"));
}
}
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 2bbd80d650f..f0b5650a792 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.h
@@ -41,10 +41,12 @@
#include <string>
#include <utility>
#include <vector>
-#include <google/protobuf/stubs/common.h>
+
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/port.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -69,7 +71,9 @@ class GeneratorContext;
// be registered with CommandLineInterface to support various languages.
class PROTOC_EXPORT CodeGenerator {
public:
- inline CodeGenerator() {}
+ CodeGenerator() {}
+ CodeGenerator(const CodeGenerator&) = delete;
+ CodeGenerator& operator=(const CodeGenerator&) = delete;
virtual ~CodeGenerator();
// Generates code for the given proto file, generating one or more files in
@@ -120,9 +124,6 @@ class PROTOC_EXPORT CodeGenerator {
// version of the library. When protobufs does a api breaking change, the
// method can be removed.
virtual bool HasGenerateAll() const { return true; }
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CodeGenerator);
};
// CodeGenerators generate one or more files in a given directory. This
@@ -131,8 +132,10 @@ class PROTOC_EXPORT CodeGenerator {
// runs.
class PROTOC_EXPORT GeneratorContext {
public:
- inline GeneratorContext() {
+ GeneratorContext() {
}
+ GeneratorContext(const GeneratorContext&) = delete;
+ GeneratorContext& operator=(const GeneratorContext&) = delete;
virtual ~GeneratorContext();
// Opens the given file, truncating it if it exists, and returns a
@@ -177,9 +180,6 @@ class PROTOC_EXPORT GeneratorContext {
// this GeneratorContext.
virtual void GetCompilerVersion(Version* version) const;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratorContext);
};
// The type GeneratorContext was once called OutputDirectory. This typedef
@@ -193,15 +193,15 @@ typedef GeneratorContext OutputDirectory;
// parses to the pairs:
// ("foo", "bar"), ("baz", ""), ("moo", "corge")
PROTOC_EXPORT void ParseGeneratorParameter(
- const TProtoStringType&, std::vector<std::pair<TProtoStringType, TProtoStringType> >*);
+ y_absl::string_view, std::vector<std::pair<TProtoStringType, TProtoStringType> >*);
// Strips ".proto" or ".protodevel" from the end of a filename.
-PROTOC_EXPORT TProtoStringType StripProto(const TProtoStringType& filename);
+PROTOC_EXPORT TProtoStringType StripProto(y_absl::string_view filename);
} // namespace compiler
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_CODE_GENERATOR_H__
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 3de6dc2f6d6..4568848cd11 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
@@ -32,11 +32,15 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/command_line_interface.h>
+#include "google/protobuf/compiler/command_line_interface.h"
-#include <google/protobuf/stubs/platform_macros.h>
+#include "y_absl/container/btree_set.h"
+#include "y_absl/container/flat_hash_map.h"
+
+#include "google/protobuf/stubs/platform_macros.h"
#include <stdio.h>
+#include <stdlib.h>
#include <sys/types.h>
#ifdef major
#undef major
@@ -58,6 +62,9 @@
#include <limits.h> // For PATH_MAX
#include <memory>
+#include <string>
+#include <utility>
+#include <vector>
#if defined(__APPLE__)
#include <mach-o/dyld.h>
@@ -65,29 +72,32 @@
#include <sys/sysctl.h>
#endif
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/compiler/subprocess.h>
-#include <google/protobuf/compiler/plugin.pb.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/stringprintf.h>
-#include <google/protobuf/stubs/substitute.h>
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/compiler/importer.h>
-#include <google/protobuf/compiler/zip_writer.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/dynamic_message.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/io_win32.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/zero_copy_stream_impl.h>
-#include <google/protobuf/text_format.h>
-#include <google/protobuf/stubs/map_util.h>
-#include <google/protobuf/stubs/stl_util.h>
+#include "google/protobuf/stubs/common.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "google/protobuf/compiler/subprocess.h"
+#include "google/protobuf/compiler/plugin.pb.h"
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/strings/match.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/str_replace.h"
+#include "y_absl/strings/str_split.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/strings/substitute.h"
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/compiler/importer.h"
+#include "google/protobuf/compiler/zip_writer.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/dynamic_message.h"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/io/io_win32.h"
+#include "google/protobuf/io/printer.h"
+#include "google/protobuf/io/zero_copy_stream_impl.h"
+#include "google/protobuf/text_format.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -132,7 +142,7 @@ void SetFdToTextMode(int fd) {
#ifdef _WIN32
if (setmode(fd, _O_TEXT) == -1) {
// This should never happen, I think.
- GOOGLE_LOG(WARNING) << "setmode(" << fd << ", _O_TEXT): " << strerror(errno);
+ Y_ABSL_LOG(WARNING) << "setmode(" << fd << ", _O_TEXT): " << strerror(errno);
}
#endif
// (Text and binary are the same on non-Windows platforms.)
@@ -142,7 +152,8 @@ void SetFdToBinaryMode(int fd) {
#ifdef _WIN32
if (setmode(fd, _O_BINARY) == -1) {
// This should never happen, I think.
- GOOGLE_LOG(WARNING) << "setmode(" << fd << ", _O_BINARY): " << strerror(errno);
+ Y_ABSL_LOG(WARNING) << "setmode(" << fd
+ << ", _O_BINARY): " << strerror(errno);
}
#endif
// (Text and binary are the same on non-Windows platforms.)
@@ -174,7 +185,7 @@ bool TryCreateParentDirectory(const TProtoStringType& prefix,
// Recursively create parent directories to the output file.
// On Windows, both '/' and '\' are valid path separators.
std::vector<TProtoStringType> parts =
- Split(filename, "/\\", true);
+ y_absl::StrSplit(filename, y_absl::ByAnyChar("/\\"), y_absl::SkipEmpty());
TProtoStringType path_so_far = prefix;
for (int i = 0; i < parts.size() - 1; i++) {
path_so_far += parts[i];
@@ -227,9 +238,10 @@ bool GetProtocAbsolutePath(TProtoStringType* path) {
// Whether a path is where google/protobuf/descriptor.proto and other well-known
// type protos are installed.
-bool IsInstalledProtoPath(const TProtoStringType& path) {
+bool IsInstalledProtoPath(y_absl::string_view path) {
// Checking the descriptor.proto file should be good enough.
- TProtoStringType file_path = path + "/google/protobuf/descriptor.proto";
+ TProtoStringType file_path =
+ y_absl::StrCat(path, "/google/protobuf/descriptor.proto");
return access(file_path.c_str(), F_OK) != -1;
}
@@ -240,25 +252,26 @@ void AddDefaultProtoPaths(
// TODO(xiaofeng): The code currently only checks relative paths of where
// the protoc binary is installed. We probably should make it handle more
// cases than that.
- TProtoStringType path;
- if (!GetProtocAbsolutePath(&path)) {
+ TProtoStringType path_str;
+ if (!GetProtocAbsolutePath(&path_str)) {
return;
}
+ y_absl::string_view path(path_str);
// Strip the binary name.
size_t pos = path.find_last_of("/\\");
- if (pos == TProtoStringType::npos || pos == 0) {
+ if (pos == path.npos || pos == 0) {
return;
}
path = path.substr(0, pos);
// Check the binary's directory.
if (IsInstalledProtoPath(path)) {
- paths->push_back(std::pair<TProtoStringType, TProtoStringType>("", path));
+ paths->emplace_back("", path);
return;
}
// Check if there is an include subdirectory.
- if (IsInstalledProtoPath(path + "/include")) {
- paths->push_back(
- std::pair<TProtoStringType, TProtoStringType>("", path + "/include"));
+ TProtoStringType include_path = y_absl::StrCat(path, "/include");
+ if (IsInstalledProtoPath(include_path)) {
+ paths->emplace_back("", std::move(include_path));
return;
}
// Check if the upper level directory has an "include" subdirectory.
@@ -267,18 +280,19 @@ void AddDefaultProtoPaths(
return;
}
path = path.substr(0, pos);
- if (IsInstalledProtoPath(path + "/include")) {
- paths->push_back(
- std::pair<TProtoStringType, TProtoStringType>("", path + "/include"));
+ include_path = y_absl::StrCat(path, "/include");
+ if (IsInstalledProtoPath(include_path)) {
+ paths->emplace_back("", std::move(include_path));
return;
}
}
-TProtoStringType PluginName(const TProtoStringType& plugin_prefix,
- const TProtoStringType& directive) {
+TProtoStringType PluginName(y_absl::string_view plugin_prefix,
+ y_absl::string_view directive) {
// Assuming the directive starts with "--" and ends with "_out" or "_opt",
// strip the "--" and "_out/_opt" and add the plugin prefix.
- return plugin_prefix + "gen-" + directive.substr(2, directive.size() - 6);
+ return y_absl::StrCat(plugin_prefix, "gen-",
+ directive.substr(2, directive.size() - 6));
}
} // namespace
@@ -297,37 +311,37 @@ class CommandLineInterface::ErrorPrinter
~ErrorPrinter() override {}
// implements MultiFileErrorCollector ------------------------------
- void AddError(const TProtoStringType& filename, int line, int column,
- const TProtoStringType& message) override {
+ void RecordError(y_absl::string_view filename, int line, int column,
+ y_absl::string_view message) override {
found_errors_ = true;
AddErrorOrWarning(filename, line, column, message, "error", std::cerr);
}
- void AddWarning(const TProtoStringType& filename, int line, int column,
- const TProtoStringType& message) override {
+ void RecordWarning(y_absl::string_view filename, int line, int column,
+ y_absl::string_view message) override {
found_warnings_ = true;
AddErrorOrWarning(filename, line, column, message, "warning", std::clog);
}
// implements io::ErrorCollector -----------------------------------
- void AddError(int line, int column, const TProtoStringType& message) override {
- AddError("input", line, column, message);
+ void RecordError(int line, int column, y_absl::string_view message) override {
+ RecordError("input", line, column, message);
}
- void AddWarning(int line, int column, const TProtoStringType& message) override {
+ void RecordWarning(int line, int column, y_absl::string_view message) override {
AddErrorOrWarning("input", line, column, message, "warning", std::clog);
}
// implements DescriptorPool::ErrorCollector-------------------------
- void AddError(const TProtoStringType& filename, const TProtoStringType& element_name,
- const Message* descriptor, ErrorLocation location,
- const TProtoStringType& message) override {
+ void RecordError(y_absl::string_view filename, y_absl::string_view element_name,
+ const Message* descriptor, ErrorLocation location,
+ y_absl::string_view message) override {
AddErrorOrWarning(filename, -1, -1, message, "error", std::cerr);
}
- void AddWarning(const TProtoStringType& filename, const TProtoStringType& element_name,
- const Message* descriptor, ErrorLocation location,
- const TProtoStringType& message) override {
+ void RecordWarning(y_absl::string_view filename, y_absl::string_view element_name,
+ const Message* descriptor, ErrorLocation location,
+ y_absl::string_view message) override {
AddErrorOrWarning(filename, -1, -1, message, "warning", std::clog);
}
@@ -336,12 +350,15 @@ class CommandLineInterface::ErrorPrinter
bool FoundWarnings() const { return found_warnings_; }
private:
- void AddErrorOrWarning(const TProtoStringType& filename, int line, int column,
- const TProtoStringType& message, const TProtoStringType& type,
+ void AddErrorOrWarning(y_absl::string_view filename, int line, int column,
+ y_absl::string_view message, y_absl::string_view type,
std::ostream& out) {
- // Print full path when running under MSVS
TProtoStringType dfile;
- if (format_ == CommandLineInterface::ERROR_FORMAT_MSVS &&
+ if (
+#ifndef PROTOBUF_OPENSOURCE
+ // Print full path when running under MSVS
+ format_ == CommandLineInterface::ERROR_FORMAT_MSVS &&
+#endif // !PROTOBUF_OPENSOURCE
tree_ != nullptr && tree_->VirtualFileToDiskFile(filename, &dfile)) {
out << dfile;
} else {
@@ -398,7 +415,6 @@ class CommandLineInterface::GeneratorContextImpl : public GeneratorContext {
// Get name of all output files.
void GetOutputFilenames(std::vector<TProtoStringType>* output_filenames);
-
// implements GeneratorContext --------------------------------------
io::ZeroCopyOutputStream* Open(const TProtoStringType& filename) override;
io::ZeroCopyOutputStream* OpenForAppend(const TProtoStringType& filename) override;
@@ -417,7 +433,7 @@ class CommandLineInterface::GeneratorContextImpl : public GeneratorContext {
// The files_ field maps from path keys to file content values. It's a map
// instead of an unordered_map so that files are written in order (good when
// writing zips).
- std::map<TProtoStringType, TProtoStringType> files_;
+ y_absl::btree_map<TProtoStringType, TProtoStringType> files_;
const std::vector<const FileDescriptor*>& parsed_files_;
bool had_error_;
};
@@ -708,7 +724,7 @@ void CommandLineInterface::MemoryOutputStream::InsertShiftedInfo(
void CommandLineInterface::MemoryOutputStream::UpdateMetadata(
const TProtoStringType& insertion_content, size_t insertion_offset,
size_t insertion_length, size_t indent_length) {
- auto it = directory_->files_.find(filename_ + ".pb.meta");
+ auto it = directory_->files_.find(y_absl::StrCat(filename_, ".pb.meta"));
if (it == directory_->files_.end() && info_to_insert_.annotation().empty()) {
// No metadata was recorded for this file.
return;
@@ -738,7 +754,8 @@ void CommandLineInterface::MemoryOutputStream::UpdateMetadata(
} else {
// Create a new file to store the new metadata in info_to_insert_.
encoded_data =
- &directory_->files_.insert({filename_ + ".pb.meta", ""}).first->second;
+ &directory_->files_.try_emplace(y_absl::StrCat(filename_, ".pb.meta"), "")
+ .first->second;
}
GeneratedCodeInfo new_metadata;
bool crossed_offset = false;
@@ -795,96 +812,95 @@ CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() {
}
it->second.swap(data_);
- } else {
- // This was an OpenForInsert().
+ return;
+ }
+ // This was an OpenForInsert().
- // If the data doesn't end with a clean line break, add one.
- if (!data_.empty() && data_[data_.size() - 1] != '\n') {
- data_.push_back('\n');
- }
+ // If the data doesn't end with a clean line break, add one.
+ if (!data_.empty() && data_[data_.size() - 1] != '\n') {
+ data_.push_back('\n');
+ }
- // Find the file we are going to insert into.
- if (!already_present) {
- std::cerr << filename_
- << ": Tried to insert into file that doesn't exist."
- << std::endl;
- directory_->had_error_ = true;
- return;
- }
- TProtoStringType* target = &it->second;
+ // Find the file we are going to insert into.
+ if (!already_present) {
+ std::cerr << filename_ << ": Tried to insert into file that doesn't exist."
+ << std::endl;
+ directory_->had_error_ = true;
+ return;
+ }
+ TProtoStringType* target = &it->second;
- // Find the insertion point.
- TProtoStringType magic_string =
- strings::Substitute("@@protoc_insertion_point($0)", insertion_point_);
- TProtoStringType::size_type pos = target->find(magic_string);
+ // Find the insertion point.
+ TProtoStringType magic_string =
+ y_absl::Substitute("@@protoc_insertion_point($0)", insertion_point_);
+ TProtoStringType::size_type pos = target->find(magic_string);
- if (pos == TProtoStringType::npos) {
- std::cerr << filename_ << ": insertion point \"" << insertion_point_
- << "\" not found." << std::endl;
- directory_->had_error_ = true;
- return;
- }
+ if (pos == TProtoStringType::npos) {
+ std::cerr << filename_ << ": insertion point \"" << insertion_point_
+ << "\" not found." << std::endl;
+ directory_->had_error_ = true;
+ return;
+ }
- if ((pos > 3) && (target->substr(pos - 3, 2) == "/*")) {
- // Support for inline "/* @@protoc_insertion_point() */"
- pos = pos - 3;
+ if ((pos > 3) && (target->substr(pos - 3, 2) == "/*")) {
+ // Support for inline "/* @@protoc_insertion_point() */"
+ pos = pos - 3;
+ } else {
+ // Seek backwards to the beginning of the line, which is where we will
+ // insert the data. Note that this has the effect of pushing the
+ // insertion point down, so the data is inserted before it. This is
+ // intentional because it means that multiple insertions at the same point
+ // will end up in the expected order in the final output.
+ pos = target->find_last_of('\n', pos);
+ if (pos == TProtoStringType::npos) {
+ // Insertion point is on the first line.
+ pos = 0;
} else {
- // Seek backwards to the beginning of the line, which is where we will
- // insert the data. Note that this has the effect of pushing the
- // insertion point down, so the data is inserted before it. This is
- // intentional because it means that multiple insertions at the same point
- // will end up in the expected order in the final output.
- pos = target->find_last_of('\n', pos);
- if (pos == TProtoStringType::npos) {
- // Insertion point is on the first line.
- pos = 0;
- } else {
- // Advance to character after '\n'.
- ++pos;
- }
+ // Advance to character after '\n'.
+ ++pos;
}
+ }
- // Extract indent.
- TProtoStringType indent_(*target, pos,
- target->find_first_not_of(" \t", pos) - pos);
+ // Extract indent.
+ TProtoStringType indent_(*target, pos,
+ target->find_first_not_of(" \t", pos) - pos);
- if (indent_.empty()) {
- // No indent. This makes things easier.
- target->insert(pos, data_);
- UpdateMetadata(data_, pos, data_.size(), 0);
- } else {
- // Calculate how much space we need.
- int indent_size = 0;
- for (int i = 0; i < data_.size(); i++) {
- if (data_[i] == '\n') indent_size += indent_.size();
- }
+ if (indent_.empty()) {
+ // No indent. This makes things easier.
+ target->insert(pos, data_);
+ UpdateMetadata(data_, pos, data_.size(), 0);
+ return;
+ }
+ // Calculate how much space we need.
+ int indent_size = 0;
+ for (int i = 0; i < data_.size(); i++) {
+ if (data_[i] == '\n') indent_size += indent_.size();
+ }
- // Make a hole for it.
- target->insert(pos, data_.size() + indent_size, '\0');
-
- // Now copy in the data.
- TProtoStringType::size_type data_pos = 0;
- char* target_ptr = ::google::protobuf::string_as_array(target) + pos;
- while (data_pos < data_.size()) {
- // Copy indent.
- memcpy(target_ptr, indent_.data(), indent_.size());
- target_ptr += indent_.size();
-
- // Copy line from data_.
- // We already guaranteed that data_ ends with a newline (above), so this
- // search can't fail.
- TProtoStringType::size_type line_length =
- data_.find_first_of('\n', data_pos) + 1 - data_pos;
- memcpy(target_ptr, data_.data() + data_pos, line_length);
- target_ptr += line_length;
- data_pos += line_length;
- }
- UpdateMetadata(data_, pos, data_.size() + indent_size, indent_.size());
+ // Make a hole for it.
+ target->insert(pos, data_.size() + indent_size, '\0');
- GOOGLE_CHECK_EQ(target_ptr,
- ::google::protobuf::string_as_array(target) + pos + data_.size() + indent_size);
- }
+ // Now copy in the data.
+ TProtoStringType::size_type data_pos = 0;
+ char* target_ptr = &(*target)[pos];
+ while (data_pos < data_.size()) {
+ // Copy indent.
+ memcpy(target_ptr, indent_.data(), indent_.size());
+ target_ptr += indent_.size();
+
+ // Copy line from data_.
+ // We already guaranteed that data_ ends with a newline (above), so this
+ // search can't fail.
+ TProtoStringType::size_type line_length =
+ data_.find_first_of('\n', data_pos) + 1 - data_pos;
+ memcpy(target_ptr, data_.data() + data_pos, line_length);
+ target_ptr += line_length;
+ data_pos += line_length;
}
+
+ Y_ABSL_CHECK_EQ(target_ptr, &(*target)[pos] + data_.size() + indent_size);
+
+ UpdateMetadata(data_, pos, data_.size() + indent_size, indent_.size());
}
// ===================================================================
@@ -954,6 +970,77 @@ bool ContainsProto3Optional(const FileDescriptor* file) {
return false;
}
+template <typename Visitor>
+struct VisitImpl {
+ Visitor visitor;
+ void Visit(const FieldDescriptor* descriptor) { visitor(descriptor); }
+
+ void Visit(const EnumDescriptor* descriptor) { visitor(descriptor); }
+
+ void Visit(const Descriptor* descriptor) {
+ visitor(descriptor);
+
+ for (int i = 0; i < descriptor->enum_type_count(); i++) {
+ Visit(descriptor->enum_type(i));
+ }
+
+ for (int i = 0; i < descriptor->field_count(); i++) {
+ Visit(descriptor->field(i));
+ }
+
+ for (int i = 0; i < descriptor->nested_type_count(); i++) {
+ Visit(descriptor->nested_type(i));
+ }
+
+ for (int i = 0; i < descriptor->extension_count(); i++) {
+ Visit(descriptor->extension(i));
+ }
+ }
+
+ void Visit(const std::vector<const FileDescriptor*>& descriptors) {
+ for (auto* descriptor : descriptors) {
+ visitor(descriptor);
+ for (int i = 0; i < descriptor->message_type_count(); i++) {
+ Visit(descriptor->message_type(i));
+ }
+ for (int i = 0; i < descriptor->enum_type_count(); i++) {
+ Visit(descriptor->enum_type(i));
+ }
+ for (int i = 0; i < descriptor->extension_count(); i++) {
+ Visit(descriptor->extension(i));
+ }
+ }
+ }
+};
+
+// Visit every node in the descriptors calling `visitor(node)`.
+// The visitor does not need to handle all possible node types. Types that are
+// not visitable via `visitor` will be ignored.
+// Disclaimer: this is not fully implemented yet to visit _every_ node.
+// VisitImpl might need to be updated where needs arise.
+template <typename Visitor>
+void VisitDescriptors(const std::vector<const FileDescriptor*>& descriptors,
+ Visitor visitor) {
+ // Provide a fallback to ignore all the nodes that are not interesting to the
+ // input visitor.
+ struct VisitorImpl : Visitor {
+ explicit VisitorImpl(Visitor visitor) : Visitor(visitor) {}
+ using Visitor::operator();
+ // Honeypot to ignore all inputs that Visitor does not take.
+ void operator()(const void*) const {}
+ };
+
+ VisitImpl<VisitorImpl>{VisitorImpl(visitor)}.Visit(descriptors);
+}
+
+bool HasReservedFieldNumber(const FieldDescriptor* field) {
+ if (field->number() >= FieldDescriptor::kFirstReservedNumber &&
+ field->number() <= FieldDescriptor::kLastReservedNumber) {
+ return true;
+ }
+ return false;
+}
+
} // namespace
namespace {
@@ -963,6 +1050,7 @@ PopulateSingleSimpleDescriptorDatabase(const TProtoStringType& descriptor_set_na
int CommandLineInterface::Run(int argc, const char* const argv[]) {
Clear();
+
switch (ParseArguments(argc, argv)) {
case PARSE_ARGUMENT_DONE_AND_EXIT:
return 0;
@@ -1046,6 +1134,38 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
return 1;
}
+ bool validation_error = false; // Defer exiting so we log more warnings.
+
+ VisitDescriptors(parsed_files, [&](const FieldDescriptor* field) {
+ if (HasReservedFieldNumber(field)) {
+ const char* error_link = nullptr;
+ validation_error = true;
+ TProtoStringType error;
+ if (field->number() >= FieldDescriptor::kFirstReservedNumber &&
+ field->number() <= FieldDescriptor::kLastReservedNumber) {
+ error = y_absl::Substitute(
+ "Field numbers $0 through $1 are reserved "
+ "for the protocol buffer library implementation.",
+ FieldDescriptor::kFirstReservedNumber,
+ FieldDescriptor::kLastReservedNumber);
+ } else {
+ error = y_absl::Substitute(
+ "Field number $0 is reserved for specific purposes.",
+ field->number());
+ }
+ if (error_link) {
+ y_absl::StrAppend(&error, "(See ", error_link, ")");
+ }
+ static_cast<DescriptorPool::ErrorCollector*>(error_collector.get())
+ ->RecordError(field->file()->name(), field->full_name(), nullptr,
+ DescriptorPool::ErrorCollector::NUMBER, error);
+ }
+ });
+
+
+ if (validation_error) {
+ return 1;
+ }
// We construct a separate GeneratorContext for each output location. Note
// that two code generators may output to the same location, in which case
@@ -1056,9 +1176,9 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
if (mode_ == MODE_COMPILE) {
for (int i = 0; i < output_directives_.size(); i++) {
TProtoStringType output_location = output_directives_[i].output_location;
- if (!HasSuffixString(output_location, ".zip") &&
- !HasSuffixString(output_location, ".jar") &&
- !HasSuffixString(output_location, ".srcjar")) {
+ if (!y_absl::EndsWith(output_location, ".zip") &&
+ !y_absl::EndsWith(output_location, ".jar") &&
+ !y_absl::EndsWith(output_location, ".srcjar")) {
AddTrailingSlash(&output_location);
}
@@ -1066,7 +1186,7 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
if (!generator) {
// First time we've seen this output location.
- generator.reset(new GeneratorContextImpl(parsed_files));
+ generator = std::make_unique<GeneratorContextImpl>(parsed_files);
}
if (!GenerateOutput(parsed_files, output_directives_[i],
@@ -1076,16 +1196,15 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
}
}
- // Write all output to disk.
for (const auto& pair : output_directories) {
const TProtoStringType& location = pair.first;
GeneratorContextImpl* directory = pair.second.get();
- if (HasSuffixString(location, "/")) {
+ if (y_absl::EndsWith(location, "/")) {
if (!directory->WriteAllToDisk(location)) {
return 1;
}
} else {
- if (HasSuffixString(location, ".jar")) {
+ if (y_absl::EndsWith(location, ".jar")) {
directory->AddJarManifest();
}
@@ -1096,7 +1215,7 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
}
if (!dependency_out_name_.empty()) {
- GOOGLE_DCHECK(disk_source_tree.get());
+ Y_ABSL_DCHECK(disk_source_tree.get());
if (!GenerateDependencyManifestFile(parsed_files, output_directories,
disk_source_tree.get())) {
return 1;
@@ -1116,7 +1235,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) != nullptr);
+ Y_ABSL_CHECK(pool.BuildFile(file) != nullptr);
codec_type_ = "EmptyMessage";
if (!EncodeOrDecode(&pool)) {
return 1;
@@ -1144,14 +1263,14 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
}
break;
case PRINT_NONE:
- GOOGLE_LOG(ERROR) << "If the code reaches here, it usually means a bug of "
- "flag parsing in the CommandLineInterface.";
+ Y_ABSL_LOG(ERROR)
+ << "If the code reaches here, it usually means a bug of "
+ "flag parsing in the CommandLineInterface.";
return 1;
// Do not add a default case.
}
}
-
return 0;
}
@@ -1276,6 +1395,7 @@ bool CommandLineInterface::ParseInputFiles(
}
parsed_files->push_back(parsed_file);
+
// Enforce --disallow_services.
if (disallow_services_ && parsed_file->service_count() > 0) {
std::cerr << parsed_file->name()
@@ -1295,9 +1415,9 @@ bool CommandLineInterface::ParseInputFiles(
direct_dependencies_.end()) {
indirect_imports = true;
std::cerr << parsed_file->name() << ": "
- << StringReplace(direct_dependencies_violation_msg_, "%s",
- parsed_file->dependency(i)->name(),
- true /* replace_all */)
+ << y_absl::StrReplaceAll(
+ direct_dependencies_violation_msg_,
+ {{"%s", parsed_file->dependency(i)->name()}})
<< std::endl;
}
}
@@ -1486,19 +1606,15 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments(
// Make sure each plugin option has a matching plugin output.
bool foundUnknownPluginOption = false;
- for (std::map<TProtoStringType, TProtoStringType>::const_iterator i =
- plugin_parameters_.begin();
- i != plugin_parameters_.end(); ++i) {
- if (plugins_.find(i->first) != plugins_.end()) {
+ for (const auto& kv : plugin_parameters_) {
+ if (plugins_.find(kv.first) != plugins_.end()) {
continue;
}
bool foundImplicitPlugin = false;
- for (std::vector<OutputDirective>::const_iterator j =
- output_directives_.begin();
- j != output_directives_.end(); ++j) {
- if (j->generator == nullptr) {
- TProtoStringType plugin_name = PluginName(plugin_prefix_, j->name);
- if (plugin_name == i->first) {
+ for (const auto& d : output_directives_) {
+ if (d.generator == nullptr) {
+ TProtoStringType plugin_name = PluginName(plugin_prefix_, d.name);
+ if (plugin_name == kv.first) {
foundImplicitPlugin = true;
break;
}
@@ -1507,7 +1623,7 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments(
if (!foundImplicitPlugin) {
std::cerr << "Unknown flag: "
// strip prefix + "gen-" and add back "_opt"
- << "--" + i->first.substr(plugin_prefix_.size() + 4) + "_opt"
+ << "--" << kv.first.substr(plugin_prefix_.size() + 4) << "_opt"
<< std::endl;
foundUnknownPluginOption = true;
}
@@ -1552,7 +1668,7 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments(
input_files_.empty() && descriptor_set_in_names_.empty();
break;
default:
- GOOGLE_LOG(FATAL) << "Unexpected mode: " << mode_;
+ Y_ABSL_LOG(FATAL) << "Unexpected mode: " << mode_;
}
if (missing_proto_definitions) {
std::cerr << "Missing input file." << std::endl;
@@ -1686,8 +1802,7 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name,
})) {
case google::protobuf::io::win32::ExpandWildcardsResult::kSuccess:
break;
- case google::protobuf::io::win32::ExpandWildcardsResult::
- kErrorNoMatchingFile:
+ case google::protobuf::io::win32::ExpandWildcardsResult::kErrorNoMatchingFile:
// Path does not exist, is not a file, or it's longer than MAX_PATH and
// long path handling is disabled.
std::cerr << "Invalid file name pattern or missing input file \""
@@ -1708,9 +1823,9 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name,
// Java's -classpath (and some other languages) delimits path components
// with colons. Let's accept that syntax too just to make things more
// intuitive.
- std::vector<TProtoStringType> parts = Split(
- value, CommandLineInterface::kPathSeparator,
- true);
+ std::vector<TProtoStringType> parts = y_absl::StrSplit(
+ value, y_absl::ByAnyChar(CommandLineInterface::kPathSeparator),
+ y_absl::SkipEmpty());
for (int i = 0; i < parts.size(); i++) {
TProtoStringType virtual_path;
@@ -1764,8 +1879,8 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name,
direct_dependencies_explicitly_set_ = true;
std::vector<TProtoStringType> direct =
- Split(value, ":", true);
- GOOGLE_DCHECK(direct_dependencies_.empty());
+ y_absl::StrSplit(value, ":", y_absl::SkipEmpty());
+ Y_ABSL_DCHECK(direct_dependencies_.empty());
direct_dependencies_.insert(direct.begin(), direct.end());
} else if (name == "--direct_dependencies_violation_msg") {
@@ -1790,9 +1905,9 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name,
return PARSE_ARGUMENT_FAIL;
}
- descriptor_set_in_names_ = Split(
- value, CommandLineInterface::kPathSeparator,
- true);
+ descriptor_set_in_names_ = y_absl::StrSplit(
+ value, y_absl::ByAnyChar(CommandLineInterface::kPathSeparator),
+ y_absl::SkipEmpty());
} else if (name == "-o" || name == "--descriptor_set_out") {
if (!descriptor_set_out_name_.empty()) {
@@ -1850,7 +1965,7 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name,
if (!version_info_.empty()) {
std::cout << version_info_ << std::endl;
}
- std::cout << "libprotoc " << internal::VersionString(PROTOBUF_VERSION)
+ std::cout << "libprotoc " << internal::ProtocVersionString(PROTOBUF_VERSION)
<< PROTOBUF_VERSION_SUFFIX << std::endl;
return PARSE_ARGUMENT_DONE_AND_EXIT; // Exit without running compiler.
@@ -1979,14 +2094,30 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name,
}
mode_ = MODE_PRINT;
print_mode_ = PRINT_FREE_FIELDS;
+ } else if (name == "--enable_codegen_trace") {
+ // We use environment variables here so that subprocesses see this setting
+ // when we spawn them.
+ //
+ // Setting environment variables is more-or-less asking for a data race,
+ // because C got this wrong and did not mandate synchronization.
+ // In practice, this code path is "only" in the main thread of protoc, and
+ // it is common knowledge that touching setenv in a library is asking for
+ // life-ruining bugs *anyways*. As such, there is a reasonable probability
+ // that there isn't another thread kicking environment variables at this
+ // moment.
+
+#ifdef _WIN32
+ ::_putenv(y_absl::StrCat(io::Printer::kProtocCodegenTrace, "=yes").c_str());
+#else
+ ::setenv(io::Printer::kProtocCodegenTrace.data(), "yes", 0);
+#endif
} else {
// Some other flag. Look it up in the generators list.
- const GeneratorInfo* generator_info =
- FindOrNull(generators_by_flag_name_, name);
+ const GeneratorInfo* generator_info = FindGeneratorByFlag(name);
if (generator_info == nullptr &&
- (plugin_prefix_.empty() || !HasSuffixString(name, "_out"))) {
+ (plugin_prefix_.empty() || !y_absl::EndsWith(name, "_out"))) {
// Check if it's a generator option flag.
- generator_info = FindOrNull(generators_by_option_name_, name);
+ generator_info = FindGeneratorByOption(name);
if (generator_info != nullptr) {
TProtoStringType* parameters =
&generator_parameters_[generator_info->flag_name];
@@ -1994,7 +2125,7 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name,
parameters->append(",");
}
parameters->append(value);
- } else if (HasPrefixString(name, "--") && HasSuffixString(name, "_opt")) {
+ } else if (y_absl::StartsWith(name, "--") && y_absl::EndsWith(name, "_opt")) {
TProtoStringType* parameters =
&plugin_parameters_[PluginName(plugin_prefix_, name)];
if (!parameters->empty()) {
@@ -2109,7 +2240,10 @@ Parse PROTO_FILES and generate output based on the options given:
defined in the given proto files. Groups share
the same field number space with the parent
message. Extension ranges are counted as
- occupied fields numbers.)";
+ occupied fields numbers.
+ --enable_codegen_trace Enables tracing which parts of protoc are
+ responsible for what codegen output. Not supported
+ by all backends or on all platforms.)";
if (!plugin_prefix_.empty()) {
std::cout << R"(
--plugin=EXECUTABLE Specifies a plugin executable to use.
@@ -2122,16 +2256,15 @@ Parse PROTO_FILES and generate output based on the options given:
the executable's own name differs.)";
}
- for (GeneratorMap::iterator iter = generators_by_flag_name_.begin();
- iter != generators_by_flag_name_.end(); ++iter) {
+ for (const auto& kv : generators_by_flag_name_) {
// FIXME(kenton): If the text is long enough it will wrap, which is ugly,
// but fixing this nicely (e.g. splitting on spaces) is probably more
// trouble than it's worth.
std::cout << std::endl
- << " " << iter->first << "=OUT_DIR "
- << TProtoStringType(19 - iter->first.size(),
+ << " " << kv.first << "=OUT_DIR "
+ << TProtoStringType(19 - kv.first.size(),
' ') // Spaces for alignment.
- << iter->second.help_text;
+ << kv.second.help_text;
}
std::cout << R"(
@<filename> Read options and filenames from file. If a
@@ -2163,7 +2296,8 @@ bool CommandLineInterface::EnforceProto3OptionalSupport(
<< codegen_name
<< " hasn't been updated to support optional fields in "
"proto3. Please ask the owner of this code generator to "
- "support proto3 optional.";
+ "support proto3 optional."
+ << std::endl;
return false;
}
}
@@ -2179,8 +2313,8 @@ bool CommandLineInterface::GenerateOutput(
TProtoStringType error;
if (output_directive.generator == nullptr) {
// This is a plugin.
- GOOGLE_CHECK(HasPrefixString(output_directive.name, "--") &&
- HasSuffixString(output_directive.name, "_out"))
+ Y_ABSL_CHECK(y_absl::StartsWith(output_directive.name, "--") &&
+ y_absl::EndsWith(output_directive.name, "_out"))
<< "Bad name for plugin generator: " << output_directive.name;
TProtoStringType plugin_name = PluginName(plugin_prefix_, output_directive.name);
@@ -2228,7 +2362,7 @@ bool CommandLineInterface::GenerateDependencyManifestFile(
DiskSourceTree* source_tree) {
FileDescriptorSet file_set;
- std::set<const FileDescriptor*> already_seen;
+ y_absl::flat_hash_set<const FileDescriptor*> already_seen;
for (int i = 0; i < parsed_files.size(); i++) {
GetTransitiveDependencies(parsed_files[i], false, false, &already_seen,
file_set.mutable_file());
@@ -2268,7 +2402,7 @@ bool CommandLineInterface::GenerateDependencyManifestFile(
io::Printer printer(&out, '$');
for (int i = 0; i < output_filenames.size(); i++) {
- printer.Print(output_filenames[i].c_str());
+ printer.Print(output_filenames[i]);
if (i == output_filenames.size() - 1) {
printer.Print(":");
} else {
@@ -2309,7 +2443,7 @@ bool CommandLineInterface::GeneratePluginOutput(
}
- std::set<const FileDescriptor*> already_seen;
+ y_absl::flat_hash_set<const FileDescriptor*> already_seen;
for (int i = 0; i < parsed_files.size(); i++) {
request.add_file_to_generate(parsed_files[i]->name());
GetTransitiveDependencies(parsed_files[i],
@@ -2336,7 +2470,7 @@ bool CommandLineInterface::GeneratePluginOutput(
TProtoStringType communicate_error;
if (!subprocess.Communicate(request, &response, &communicate_error)) {
- *error = strings::Substitute("$0: $1", plugin_name, communicate_error);
+ *error = y_absl::Substitute("$0: $1", plugin_name, communicate_error);
return false;
}
@@ -2363,7 +2497,7 @@ bool CommandLineInterface::GeneratePluginOutput(
current_output.reset();
current_output.reset(generator_context->Open(output_file.name()));
} else if (current_output == nullptr) {
- *error = strings::Substitute(
+ *error = y_absl::Substitute(
"$0: First file chunk returned by plugin did not specify a file "
"name.",
plugin_name);
@@ -2482,13 +2616,13 @@ bool CommandLineInterface::WriteDescriptorSet(
const std::vector<const FileDescriptor*>& parsed_files) {
FileDescriptorSet file_set;
- std::set<const FileDescriptor*> already_seen;
+ y_absl::flat_hash_set<const FileDescriptor*> already_seen;
if (!imports_in_descriptor_set_) {
// Since we don't want to output transitive dependencies, but we do want
// things to be in dependency order, add all dependencies that aren't in
// parsed_files to already_seen. This will short circuit the recursion
// in GetTransitiveDependencies.
- std::set<const FileDescriptor*> to_output;
+ y_absl::flat_hash_set<const FileDescriptor*> to_output;
to_output.insert(parsed_files.begin(), parsed_files.end());
for (int i = 0; i < parsed_files.size(); i++) {
const FileDescriptor* file = parsed_files[i];
@@ -2546,7 +2680,7 @@ bool CommandLineInterface::WriteDescriptorSet(
void CommandLineInterface::GetTransitiveDependencies(
const FileDescriptor* file, bool include_json_name,
bool include_source_code_info,
- std::set<const FileDescriptor*>* already_seen,
+ y_absl::flat_hash_set<const FileDescriptor*>* already_seen,
RepeatedPtrField<FileDescriptorProto>* output) {
if (!already_seen->insert(file).second) {
// Already saw this file. Skip.
@@ -2570,6 +2704,20 @@ void CommandLineInterface::GetTransitiveDependencies(
}
}
+const CommandLineInterface::GeneratorInfo*
+CommandLineInterface::FindGeneratorByFlag(const TProtoStringType& name) const {
+ auto it = generators_by_flag_name_.find(name);
+ if (it == generators_by_flag_name_.end()) return nullptr;
+ return &it->second;
+}
+
+const CommandLineInterface::GeneratorInfo*
+CommandLineInterface::FindGeneratorByOption(const TProtoStringType& option) const {
+ auto it = generators_by_option_name_.find(option);
+ if (it == generators_by_option_name_.end()) return nullptr;
+ return &it->second;
+}
+
namespace {
// Utility function for PrintFreeFieldNumbers.
@@ -2605,9 +2753,9 @@ namespace {
// order of the nested messages is also preserved.
typedef std::pair<int, int> FieldRange;
void GatherOccupiedFieldRanges(
- const Descriptor* descriptor, std::set<FieldRange>* ranges,
+ const Descriptor* descriptor, y_absl::btree_set<FieldRange>* ranges,
std::vector<const Descriptor*>* nested_messages) {
- std::set<const Descriptor*> groups;
+ y_absl::flat_hash_set<const Descriptor*> groups;
for (int i = 0; i < descriptor->field_count(); ++i) {
const FieldDescriptor* fd = descriptor->field(i);
ranges->insert(FieldRange(fd->number(), fd->number() + 1));
@@ -2639,30 +2787,29 @@ void GatherOccupiedFieldRanges(
// Actually prints the formatted free field numbers for given message name and
// occupied ranges.
void FormatFreeFieldNumbers(const TProtoStringType& name,
- const std::set<FieldRange>& ranges) {
+ const y_absl::btree_set<FieldRange>& ranges) {
TProtoStringType output;
- StringAppendF(&output, "%-35s free:", name.c_str());
+ y_absl::StrAppendFormat(&output, "%-35s free:", name.c_str());
int next_free_number = 1;
- for (std::set<FieldRange>::const_iterator i = ranges.begin();
- i != ranges.end(); ++i) {
+ for (const auto& range : ranges) {
// This happens when groups re-use parent field numbers, in which
// case we skip the FieldRange entirely.
- if (next_free_number >= i->second) continue;
+ if (next_free_number >= range.second) continue;
- if (next_free_number < i->first) {
- if (next_free_number + 1 == i->first) {
+ if (next_free_number < range.first) {
+ if (next_free_number + 1 == range.first) {
// Singleton
- StringAppendF(&output, " %d", next_free_number);
+ y_absl::StrAppendFormat(&output, " %d", next_free_number);
} else {
// Range
- StringAppendF(&output, " %d-%d", next_free_number,
- i->first - 1);
+ y_absl::StrAppendFormat(&output, " %d-%d", next_free_number,
+ range.first - 1);
}
}
- next_free_number = i->second;
+ next_free_number = range.second;
}
if (next_free_number <= FieldDescriptor::kMaxNumber) {
- StringAppendF(&output, " %d-INF", next_free_number);
+ y_absl::StrAppendFormat(&output, " %d-INF", next_free_number);
}
std::cout << output << std::endl;
}
@@ -2670,7 +2817,7 @@ void FormatFreeFieldNumbers(const TProtoStringType& name,
} // namespace
void CommandLineInterface::PrintFreeFieldNumbers(const Descriptor* descriptor) {
- std::set<FieldRange> ranges;
+ y_absl::btree_set<FieldRange> ranges;
std::vector<const Descriptor*> nested_messages;
GatherOccupiedFieldRanges(descriptor, &ranges, &nested_messages);
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 a2a3dffe4b2..054efd0dbc9 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
@@ -39,19 +39,20 @@
#define GOOGLE_PROTOBUF_COMPILER_COMMAND_LINE_INTERFACE_H__
#include <cstdint>
-#include <map>
+#include <functional>
#include <memory>
-#include <set>
#include <string>
-#include <unordered_map>
-#include <unordered_set>
#include <utility>
#include <vector>
-#include <google/protobuf/stubs/common.h>
+#include "y_absl/container/btree_map.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/port.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -115,6 +116,8 @@ class PROTOC_EXPORT CommandLineInterface {
static const char* const kPathSeparator;
CommandLineInterface();
+ CommandLineInterface(const CommandLineInterface&) = delete;
+ CommandLineInterface& operator=(const CommandLineInterface&) = delete;
~CommandLineInterface();
// Register a code generator for a language.
@@ -212,8 +215,8 @@ class PROTOC_EXPORT CommandLineInterface {
class ErrorPrinter;
class GeneratorContextImpl;
class MemoryOutputStream;
- typedef std::unordered_map<TProtoStringType, std::unique_ptr<GeneratorContextImpl>>
- GeneratorContextMap;
+ using GeneratorContextMap =
+ y_absl::flat_hash_map<TProtoStringType, std::unique_ptr<GeneratorContextImpl>>;
// Clear state from previous Run().
void Clear();
@@ -318,7 +321,7 @@ class PROTOC_EXPORT CommandLineInterface {
static void GetTransitiveDependencies(
const FileDescriptor* file, bool include_json_name,
bool include_source_code_info,
- std::set<const FileDescriptor*>* already_seen,
+ y_absl::flat_hash_set<const FileDescriptor*>* already_seen,
RepeatedPtrField<FileDescriptorProto>* output);
// Implements the --print_free_field_numbers. This function prints free field
@@ -352,16 +355,19 @@ class PROTOC_EXPORT CommandLineInterface {
CodeGenerator* generator;
TProtoStringType help_text;
};
- typedef std::map<TProtoStringType, GeneratorInfo> GeneratorMap;
- GeneratorMap generators_by_flag_name_;
- GeneratorMap generators_by_option_name_;
+
+ const GeneratorInfo* FindGeneratorByFlag(const TProtoStringType& name) const;
+ const GeneratorInfo* FindGeneratorByOption(const TProtoStringType& option) const;
+
+ y_absl::btree_map<TProtoStringType, GeneratorInfo> generators_by_flag_name_;
+ y_absl::flat_hash_map<TProtoStringType, GeneratorInfo> generators_by_option_name_;
// A map from generator names to the parameters specified using the option
// flag. For example, if the user invokes the compiler with:
// protoc --foo_out=outputdir --foo_opt=enable_bar ...
// Then there will be an entry ("--foo_out", "enable_bar") in this map.
- std::map<TProtoStringType, TProtoStringType> generator_parameters_;
+ y_absl::flat_hash_map<TProtoStringType, TProtoStringType> generator_parameters_;
// Similar to generator_parameters_, but stores the parameters for plugins.
- std::map<TProtoStringType, TProtoStringType> plugin_parameters_;
+ y_absl::flat_hash_map<TProtoStringType, TProtoStringType> plugin_parameters_;
// See AllowPlugins(). If this is empty, plugins aren't allowed.
TProtoStringType plugin_prefix_;
@@ -369,7 +375,7 @@ class PROTOC_EXPORT CommandLineInterface {
// Maps specific plugin names to files. When executing a plugin, this map
// is searched first to find the plugin executable. If not found here, the
// PATH (or other OS-specific search strategy) is searched.
- std::map<TProtoStringType, TProtoStringType> plugins_;
+ y_absl::flat_hash_map<TProtoStringType, TProtoStringType> plugins_;
// Stuff parsed from command line.
enum Mode {
@@ -403,13 +409,13 @@ class PROTOC_EXPORT CommandLineInterface {
// True if we should treat warnings as errors that fail the compilation.
bool fatal_warnings_ = false;
- std::vector<std::pair<TProtoStringType, TProtoStringType> >
+ std::vector<std::pair<TProtoStringType, TProtoStringType>>
proto_path_; // Search path for proto files.
std::vector<TProtoStringType> input_files_; // Names of the input proto files.
// Names of proto files which are allowed to be imported. Used by build
// systems to enforce depend-on-what-you-import.
- std::set<TProtoStringType> direct_dependencies_;
+ y_absl::flat_hash_set<TProtoStringType> direct_dependencies_;
bool direct_dependencies_explicitly_set_ = false;
// If there's a violation of depend-on-what-you-import, this string will be
@@ -456,14 +462,12 @@ class PROTOC_EXPORT CommandLineInterface {
// When using --encode, this will be passed to SetSerializationDeterministic.
bool deterministic_output_ = false;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CommandLineInterface);
};
} // namespace compiler
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_COMMAND_LINE_INTERFACE_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum.cc
index 91d0b9442b7..917cc761288 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum.cc
@@ -32,26 +32,49 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/cpp/enum.h>
+#include "google/protobuf/compiler/cpp/enum.h"
+#include <algorithm>
#include <cstdint>
#include <limits>
-#include <map>
-
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/cpp/helpers.h>
-#include <google/protobuf/compiler/cpp/names.h>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "google/protobuf/descriptor.h"
+#include "y_absl/container/btree_map.h"
+#include "y_absl/container/btree_set.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/cpp/helpers.h"
+#include "google/protobuf/compiler/cpp/names.h"
namespace google {
namespace protobuf {
namespace compiler {
namespace cpp {
-
namespace {
-// The GOOGLE_ARRAYSIZE constant is the max enum value plus 1. If the max enum value
-// is kint32max, GOOGLE_ARRAYSIZE will overflow. In such cases we should omit the
-// generation of the GOOGLE_ARRAYSIZE constant.
+using Sub = ::google::protobuf::io::Printer::Sub;
+
+y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> EnumVars(
+ const EnumDescriptor* enum_, const Options& options,
+ const EnumValueDescriptor* min, const EnumValueDescriptor* max) {
+ auto classname = ClassName(enum_, false);
+ return {
+ {"Enum", enum_->name()},
+ {"Enum_", ResolveKeyword(enum_->name())},
+ {"Msg_Enum", classname},
+ {"::Msg_Enum", QualifiedClassName(enum_, options)},
+ {"Msg_Enum_",
+ enum_->containing_type() == nullptr ? "" : y_absl::StrCat(classname, "_")},
+ {"kMin", y_absl::StrCat(min->number())},
+ {"kMax", y_absl::StrCat(max->number())},
+ };
+}
+
+// The ARRAYSIZE constant is the max enum value plus 1. If the max enum value
+// is kint32max, ARRAYSIZE will overflow. In such cases we should omit the
+// generation of the ARRAYSIZE constant.
bool ShouldGenerateArraySize(const EnumDescriptor* descriptor) {
arc_i32 max_value = descriptor->value(0)->number();
for (int i = 0; i < descriptor->value_count(); i++) {
@@ -61,251 +84,323 @@ bool ShouldGenerateArraySize(const EnumDescriptor* descriptor) {
}
return max_value != std::numeric_limits<arc_i32>::max();
}
-
-// Returns the number of unique numeric enum values. This is less than
-// descriptor->value_count() when there are aliased values.
-int CountUniqueValues(const EnumDescriptor* descriptor) {
- std::set<int> values;
- for (int i = 0; i < descriptor->value_count(); ++i) {
- values.insert(descriptor->value(i)->number());
+} // namespace
+EnumGenerator::ValueLimits EnumGenerator::ValueLimits::FromEnum(
+ const EnumDescriptor* descriptor) {
+ const EnumValueDescriptor* min_desc = descriptor->value(0);
+ const EnumValueDescriptor* max_desc = descriptor->value(0);
+
+ for (int i = 1; i < descriptor->value_count(); ++i) {
+ if (descriptor->value(i)->number() < min_desc->number()) {
+ min_desc = descriptor->value(i);
+ }
+ if (descriptor->value(i)->number() > max_desc->number()) {
+ max_desc = descriptor->value(i);
+ }
}
- return values.size();
-}
-} // namespace
+ return EnumGenerator::ValueLimits{min_desc, max_desc};
+}
EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor,
- const std::map<TProtoStringType, TProtoStringType>& vars,
const Options& options)
- : descriptor_(descriptor),
- classname_(ClassName(descriptor, false)),
+ : enum_(descriptor),
options_(options),
generate_array_size_(ShouldGenerateArraySize(descriptor)),
- variables_(vars) {
- variables_["classname"] = classname_;
- variables_["classtype"] = QualifiedClassName(descriptor_, options);
- variables_["short_name"] = descriptor_->name();
- variables_["nested_name"] = descriptor_->name();
- variables_["resolved_name"] = ResolveKeyword(descriptor_->name());
- variables_["prefix"] =
- (descriptor_->containing_type() == nullptr) ? "" : classname_ + "_";
+ has_reflection_(HasDescriptorMethods(enum_->file(), options_)),
+ limits_(ValueLimits::FromEnum(enum_)) {
+ // The conditions here for what is "sparse" are not rigorously
+ // chosen.
+ size_t values_range = static_cast<size_t>(limits_.max->number()) -
+ static_cast<size_t>(limits_.min->number());
+ size_t total_values = static_cast<size_t>(enum_->value_count());
+ should_cache_ = has_reflection_ &&
+ (values_range < 16u || values_range < total_values * 2u);
}
-EnumGenerator::~EnumGenerator() {}
-
-void EnumGenerator::GenerateDefinition(io::Printer* printer) {
- Formatter format(printer, variables_);
- format("enum ${1$$classname$$}$ : int {\n", descriptor_);
- format.Indent();
-
- const EnumValueDescriptor* min_value = descriptor_->value(0);
- const EnumValueDescriptor* max_value = descriptor_->value(0);
-
- for (int i = 0; i < descriptor_->value_count(); i++) {
- auto format_value = format;
- format_value.Set("name", EnumValueName(descriptor_->value(i)));
- // In C++, an value of -2147483648 gets interpreted as the negative of
- // 2147483648, and since 2147483648 can't fit in an integer, this produces a
- // compiler warning. This works around that issue.
- format_value.Set("number", Int32ToString(descriptor_->value(i)->number()));
- format_value.Set("deprecation",
- DeprecatedAttribute(options_, descriptor_->value(i)));
-
- if (i > 0) format_value(",\n");
- format_value("${1$$prefix$$name$$}$ $deprecation$= $number$",
- descriptor_->value(i));
-
- if (descriptor_->value(i)->number() < min_value->number()) {
- min_value = descriptor_->value(i);
- }
- if (descriptor_->value(i)->number() > max_value->number()) {
- max_value = descriptor_->value(i);
- }
- }
-
- if (descriptor_->file()->syntax() == FileDescriptor::SYNTAX_PROTO3) {
- // For new enum semantics: generate min and max sentinel values equal to
- // INT32_MIN and INT32_MAX
- if (descriptor_->value_count() > 0) format(",\n");
- format(
- "$classname$_$prefix$INT_MIN_SENTINEL_DO_NOT_USE_ = "
- "std::numeric_limits<$int32$>::min(),\n"
- "$classname$_$prefix$INT_MAX_SENTINEL_DO_NOT_USE_ = "
- "std::numeric_limits<$int32$>::max()");
- }
-
- format.Outdent();
- format("\n};\n");
-
- format(
- "$dllexport_decl $bool $classname$_IsValid(int value);\n"
- "constexpr $classname$ ${1$$prefix$$short_name$_MIN$}$ = "
- "$prefix$$2$;\n"
- "constexpr $classname$ ${1$$prefix$$short_name$_MAX$}$ = "
- "$prefix$$3$;\n",
- descriptor_, EnumValueName(min_value), EnumValueName(max_value));
+void EnumGenerator::GenerateDefinition(io::Printer* p) {
+ auto v1 = p->WithVars(EnumVars(enum_, options_, limits_.min, limits_.max));
+
+ auto v2 = p->WithVars({
+ Sub("Msg_Enum_Enum_MIN",
+ y_absl::StrCat(p->LookupVar("Msg_Enum_"), enum_->name(), "_MIN"))
+ .AnnotatedAs(enum_),
+ Sub("Msg_Enum_Enum_MAX",
+ y_absl::StrCat(p->LookupVar("Msg_Enum_"), enum_->name(), "_MAX"))
+ .AnnotatedAs(enum_),
+ });
+ p->Emit(
+ {
+ {"values",
+ [&] {
+ for (int i = 0; i < enum_->value_count(); ++i) {
+ const auto* value = enum_->value(i);
+ p->Emit(
+ {
+ Sub("Msg_Enum_VALUE",
+ y_absl::StrCat(p->LookupVar("Msg_Enum_"),
+ EnumValueName(value)))
+ .AnnotatedAs(value),
+ {"kNumber", Int32ToString(value->number())},
+ {"DEPRECATED", value->options().deprecated()
+ ? "PROTOBUF_DEPRECATED_ENUM"
+ : ""},
+ },
+ R"cc(
+ $Msg_Enum_VALUE$$ DEPRECATED$ = $kNumber$,
+ )cc");
+ }
+ }},
+ // Only emit annotations for the $Msg_Enum$ used in the `enum`
+ // definition.
+ Sub("Msg_Enum_annotated", p->LookupVar("Msg_Enum"))
+ .AnnotatedAs(enum_),
+ {"open_enum_sentinels",
+ [&] {
+ if (enum_->is_closed()) {
+ return;
+ }
+
+ // For open enum semantics: generate min and max sentinel values
+ // equal to INT32_MIN and INT32_MAX
+ p->Emit({{"Msg_Enum_Msg_Enum_",
+ y_absl::StrCat(p->LookupVar("Msg_Enum"), "_",
+ p->LookupVar("Msg_Enum_"))}},
+ R"cc(
+ $Msg_Enum_Msg_Enum_$INT_MIN_SENTINEL_DO_NOT_USE_ =
+ std::numeric_limits<::arc_i32>::min(),
+ $Msg_Enum_Msg_Enum_$INT_MAX_SENTINEL_DO_NOT_USE_ =
+ std::numeric_limits<::arc_i32>::max(),
+ )cc");
+ }},
+ },
+ R"cc(
+ enum $Msg_Enum_annotated$ : int {
+ $values$,
+ $open_enum_sentinels$,
+ };
+
+ $dllexport_decl $bool $Msg_Enum$_IsValid(int value);
+ constexpr $Msg_Enum$ $Msg_Enum_Enum_MIN$ = static_cast<$Msg_Enum$>($kMin$);
+ constexpr $Msg_Enum$ $Msg_Enum_Enum_MAX$ = static_cast<$Msg_Enum$>($kMax$);
+ )cc");
if (generate_array_size_) {
- format(
- "constexpr int ${1$$prefix$$short_name$_ARRAYSIZE$}$ = "
- "$prefix$$short_name$_MAX + 1;\n\n",
- descriptor_);
+ p->Emit({Sub("Msg_Enum_Enum_ARRAYSIZE",
+ y_absl::StrCat(p->LookupVar("Msg_Enum_"), enum_->name(),
+ "_ARRAYSIZE"))
+ .AnnotatedAs(enum_)},
+ R"cc(
+ constexpr int $Msg_Enum_Enum_ARRAYSIZE$ = $kMax$ + 1;
+ )cc");
}
- if (HasDescriptorMethods(descriptor_->file(), options_)) {
- format(
- "$dllexport_decl $const ::$proto_ns$::EnumDescriptor* "
- "$classname$_descriptor();\n");
+ if (has_reflection_) {
+ p->Emit(R"cc(
+ $dllexport_decl $const ::$proto_ns$::EnumDescriptor*
+ $Msg_Enum$_descriptor();
+ )cc");
+ } else {
+ p->Emit(R"cc(
+ const TProtoStringType& $Msg_Enum$_Name($Msg_Enum$ value);
+ )cc");
}
- // The _Name and _Parse functions. The lite implementation is table-based, so
- // we make sure to keep the tables hidden in the .cc file.
- if (!HasDescriptorMethods(descriptor_->file(), options_)) {
- format("const TProtoStringType& $classname$_Name($classname$ value);\n");
- }
- // The _Name() function accepts the enum type itself but also any integral
- // type.
- format(
- "template<typename T>\n"
- "inline const TProtoStringType& $classname$_Name(T enum_t_value) {\n"
- " static_assert(::std::is_same<T, $classname$>::value ||\n"
- " ::std::is_integral<T>::value,\n"
- " \"Incorrect type passed to function $classname$_Name.\");\n");
- if (HasDescriptorMethods(descriptor_->file(), options_)) {
- format(
- " return ::$proto_ns$::internal::NameOfEnum(\n"
- " $classname$_descriptor(), enum_t_value);\n");
+ // There are three possible implementations of $Enum$_Name() and
+ // $Msg_Enum$_Parse(), depending on whether we are using a dense enum name
+ // cache or not, and whether or not we have reflection. Very little code is
+ // shared between the three, so it is split into three Emit() calls.
+
+ // Can't use WithVars here, since callbacks can only be passed to Emit()
+ // directly. Because this includes $Enum$, it must be a callback.
+ auto write_assert = [&] {
+ p->Emit(R"cc(
+ static_assert(std::is_same<T, $Msg_Enum$>::value ||
+ std::is_integral<T>::value,
+ "Incorrect type passed to $Enum$_Name().");
+ )cc");
+ };
+
+ if (should_cache_ || !has_reflection_) {
+ p->Emit({{"static_assert", write_assert}}, R"cc(
+ template <typename T>
+ const TProtoStringType& $Msg_Enum$_Name(T value) {
+ $static_assert$;
+ return $Msg_Enum$_Name(static_cast<$Msg_Enum$>(value));
+ }
+ )cc");
+ if (should_cache_) {
+ // Using the NameOfEnum routine can be slow, so we create a small
+ // cache of pointers to the TProtoStringType objects that reflection
+ // stores internally. This cache is a simple contiguous array of
+ // pointers, so if the enum values are sparse, it's not worth it.
+ p->Emit(R"cc(
+ template <>
+ inline const TProtoStringType& $Msg_Enum$_Name($Msg_Enum$ value) {
+ return ::$proto_ns$::internal::NameOfDenseEnum<$Msg_Enum$_descriptor,
+ $kMin$, $kMax$>(
+ static_cast<int>(value));
+ }
+ )cc");
+ } else {
+ p->Emit(R"cc(
+ const TProtoStringType& $Msg_Enum$_Name($Msg_Enum$ value);
+ )cc");
+ }
} else {
- format(
- " return $classname$_Name(static_cast<$classname$>(enum_t_value));\n");
+ p->Emit({{"static_assert", write_assert}}, R"cc(
+ template <typename T>
+ const TProtoStringType& $Msg_Enum$_Name(T value) {
+ $static_assert$;
+ return ::$proto_ns$::internal::NameOfEnum($Msg_Enum$_descriptor(), value);
+ }
+ )cc");
}
- format("}\n");
-
- if (HasDescriptorMethods(descriptor_->file(), options_)) {
- format(
- "inline bool $classname$_Parse(\n"
- " ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, $classname$* "
- "value) "
- "{\n"
- " return ::$proto_ns$::internal::ParseNamedEnum<$classname$>(\n"
- " $classname$_descriptor(), name, value);\n"
- "}\n");
+
+ if (has_reflection_) {
+ p->Emit(R"cc(
+ inline bool $Msg_Enum$_Parse(y_absl::string_view name, $Msg_Enum$* value) {
+ return ::$proto_ns$::internal::ParseNamedEnum<$Msg_Enum$>(
+ $Msg_Enum$_descriptor(), name, value);
+ }
+ )cc");
} else {
- format(
- "bool $classname$_Parse(\n"
- " ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, $classname$* "
- "value);\n");
+ p->Emit(R"cc(
+ bool $Msg_Enum$_Parse(y_absl::string_view name, $Msg_Enum$* value);
+ )cc");
}
}
-void EnumGenerator::GenerateGetEnumDescriptorSpecializations(
- io::Printer* printer) {
- Formatter format(printer, variables_);
- format(
- "template <> struct is_proto_enum< $classtype$> : ::std::true_type "
- "{};\n");
- if (HasDescriptorMethods(descriptor_->file(), options_)) {
- format(
- "template <>\n"
- "inline const EnumDescriptor* GetEnumDescriptor< $classtype$>() {\n"
- " return $classtype$_descriptor();\n"
- "}\n");
+void EnumGenerator::GenerateGetEnumDescriptorSpecializations(io::Printer* p) {
+ auto v = p->WithVars(EnumVars(enum_, options_, limits_.min, limits_.max));
+
+ p->Emit(R"cc(
+ template <>
+ struct is_proto_enum<$::Msg_Enum$> : std::true_type {};
+ )cc");
+ if (!has_reflection_) {
+ return;
}
+ p->Emit(R"cc(
+ template <>
+ inline const EnumDescriptor* GetEnumDescriptor<$::Msg_Enum$>() {
+ return $::Msg_Enum$_descriptor();
+ }
+ )cc");
}
-void EnumGenerator::GenerateSymbolImports(io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("typedef $classname$ $resolved_name$;\n");
-
- for (int j = 0; j < descriptor_->value_count(); j++) {
- TProtoStringType deprecated_attr =
- DeprecatedAttribute(options_, descriptor_->value(j));
- format(
- "$1$static constexpr $resolved_name$ ${2$$3$$}$ =\n"
- " $classname$_$3$;\n",
- deprecated_attr, descriptor_->value(j),
- EnumValueName(descriptor_->value(j)));
+void EnumGenerator::GenerateSymbolImports(io::Printer* p) const {
+ auto v = p->WithVars(EnumVars(enum_, options_, limits_.min, limits_.max));
+
+ p->Emit({Sub("Enum_", p->LookupVar("Enum_")).AnnotatedAs(enum_)}, R"cc(
+ using $Enum_$ = $Msg_Enum$;
+ )cc");
+
+ for (int j = 0; j < enum_->value_count(); ++j) {
+ const auto* value = enum_->value(j);
+ p->Emit(
+ {
+ Sub("VALUE", EnumValueName(enum_->value(j))).AnnotatedAs(value),
+ {"DEPRECATED",
+ value->options().deprecated() ? "PROTOBUF_DEPRECATED_ENUM" : ""},
+ },
+ R"cc(
+ $DEPRECATED $static constexpr $Enum_$ $VALUE$ = $Msg_Enum$_$VALUE$;
+ )cc");
}
- format(
- "static inline bool $nested_name$_IsValid(int value) {\n"
- " return $classname$_IsValid(value);\n"
- "}\n"
- "static constexpr $resolved_name$ ${1$$nested_name$_MIN$}$ =\n"
- " $classname$_$nested_name$_MIN;\n"
- "static constexpr $resolved_name$ ${1$$nested_name$_MAX$}$ =\n"
- " $classname$_$nested_name$_MAX;\n",
- descriptor_);
+ p->Emit(
+ {
+ Sub("Enum_MIN", y_absl::StrCat(enum_->name(), "_MIN"))
+ .AnnotatedAs(enum_),
+ Sub("Enum_MAX", y_absl::StrCat(enum_->name(), "_MAX"))
+ .AnnotatedAs(enum_),
+ },
+ R"cc(
+ static inline bool $Enum$_IsValid(int value) {
+ return $Msg_Enum$_IsValid(value);
+ }
+ static constexpr $Enum_$ $Enum_MIN$ = $Msg_Enum$_$Enum$_MIN;
+ static constexpr $Enum_$ $Enum_MAX$ = $Msg_Enum$_$Enum$_MAX;
+ )cc");
+
if (generate_array_size_) {
- format(
- "static constexpr int ${1$$nested_name$_ARRAYSIZE$}$ =\n"
- " $classname$_$nested_name$_ARRAYSIZE;\n",
- descriptor_);
+ p->Emit(
+ {
+ Sub("Enum_ARRAYSIZE", y_absl::StrCat(enum_->name(), "_ARRAYSIZE"))
+ .AnnotatedAs(enum_),
+ },
+ R"cc(
+ static constexpr int $Enum_ARRAYSIZE$ = $Msg_Enum$_$Enum$_ARRAYSIZE;
+ )cc");
}
- if (HasDescriptorMethods(descriptor_->file(), options_)) {
- format(
- "static inline const ::$proto_ns$::EnumDescriptor*\n"
- "$nested_name$_descriptor() {\n"
- " return $classname$_descriptor();\n"
- "}\n");
+ if (has_reflection_) {
+ p->Emit(R"cc(
+ static inline const ::$proto_ns$::EnumDescriptor* $Enum$_descriptor() {
+ return $Msg_Enum$_descriptor();
+ }
+ )cc");
}
- format(
- "template<typename T>\n"
- "static inline const TProtoStringType& $nested_name$_Name(T enum_t_value) {\n"
- " static_assert(::std::is_same<T, $resolved_name$>::value ||\n"
- " ::std::is_integral<T>::value,\n"
- " \"Incorrect type passed to function $nested_name$_Name.\");\n"
- " return $classname$_Name(enum_t_value);\n"
- "}\n");
- format(
- "static inline bool "
- "$nested_name$_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name,\n"
- " $resolved_name$* value) {\n"
- " return $classname$_Parse(name, value);\n"
- "}\n");
+ p->Emit(R"cc(
+ template <typename T>
+ static inline const TProtoStringType& $Enum$_Name(T value) {
+ return $Msg_Enum$_Name(value);
+ }
+ static inline bool $Enum$_Parse(y_absl::string_view name, $Enum_$* value) {
+ return $Msg_Enum$_Parse(name, value);
+ }
+ )cc");
}
-void EnumGenerator::GenerateMethods(int idx, io::Printer* printer) {
- Formatter format(printer, variables_);
- if (HasDescriptorMethods(descriptor_->file(), options_)) {
- format(
- "const ::$proto_ns$::EnumDescriptor* $classname$_descriptor() {\n"
- " ::$proto_ns$::internal::AssignDescriptors(&$desc_table$);\n"
- " return $file_level_enum_descriptors$[$1$];\n"
- "}\n",
- idx);
- }
-
- format(
- "bool $classname$_IsValid(int value) {\n"
- " switch (value) {\n");
-
- // Multiple values may have the same number. Make sure we only cover
- // each number once by first constructing a set containing all valid
- // numbers, then printing a case statement for each element.
-
- std::set<int> numbers;
- for (int j = 0; j < descriptor_->value_count(); j++) {
- const EnumValueDescriptor* value = descriptor_->value(j);
- numbers.insert(value->number());
- }
+void EnumGenerator::GenerateMethods(int idx, io::Printer* p) {
+ auto v = p->WithVars(EnumVars(enum_, options_, limits_.min, limits_.max));
- for (std::set<int>::iterator iter = numbers.begin(); iter != numbers.end();
- ++iter) {
- format(" case $1$:\n", Int32ToString(*iter));
+ if (has_reflection_) {
+ p->Emit({{"idx", idx}}, R"cc(
+ const ::$proto_ns$::EnumDescriptor* $Msg_Enum$_descriptor() {
+ ::$proto_ns$::internal::AssignDescriptors(&$desc_table$);
+ return $file_level_enum_descriptors$[$idx$];
+ }
+ )cc");
}
- format(
- " return true;\n"
- " default:\n"
- " return false;\n"
- " }\n"
- "}\n"
- "\n");
-
- if (!HasDescriptorMethods(descriptor_->file(), options_)) {
+ p->Emit({{"cases",
+ [&] {
+ // Multiple values may have the same number. Make sure we only
+ // cover each number once by first constructing a set containing
+ // all valid numbers, then printing a case statement for each
+ // element.
+
+ std::vector<int> numbers;
+ numbers.reserve(enum_->value_count());
+ for (int i = 0; i < enum_->value_count(); ++i) {
+ numbers.push_back(enum_->value(i)->number());
+ }
+ // Sort and deduplicate `numbers`.
+ y_absl::c_sort(numbers);
+ numbers.erase(std::unique(numbers.begin(), numbers.end()),
+ numbers.end());
+
+ for (int n : numbers) {
+ p->Emit({{"n", n}}, R"cc(
+ case $n$:
+ )cc");
+ }
+ }}},
+ R"(
+ bool $Msg_Enum$_IsValid(int value) {
+ switch (value) {
+ $cases$;
+ return true;
+ default:
+ return false;
+ }
+ }
+ )");
+
+ if (!has_reflection_) {
// In lite mode (where descriptors are unavailable), we generate separate
// tables for mapping between enum names and numbers. The _entries table
// contains the bulk of the data and is sorted by name, while
@@ -319,119 +414,168 @@ void EnumGenerator::GenerateMethods(int idx, io::Printer* printer) {
// numerical value. In cases where there are multiple names for the same
// number, we treat the first name appearing in the .proto file as the
// canonical one.
- std::map<TProtoStringType, int> name_to_number;
- std::map<int, TProtoStringType> number_to_canonical_name;
- for (int i = 0; i < descriptor_->value_count(); i++) {
- const EnumValueDescriptor* value = descriptor_->value(i);
+
+ y_absl::btree_map<TProtoStringType, int> name_to_number;
+ y_absl::flat_hash_map<int, TProtoStringType> number_to_canonical_name;
+ for (int i = 0; i < enum_->value_count(); ++i) {
+ const auto* value = enum_->value(i);
name_to_number.emplace(value->name(), value->number());
+
// The same number may appear with multiple names, so we use emplace() to
// let the first name win.
number_to_canonical_name.emplace(value->number(), value->name());
}
- format(
- "static ::$proto_ns$::internal::ExplicitlyConstructed<TProtoStringType> "
- "$classname$_strings[$1$] = {};\n\n",
- CountUniqueValues(descriptor_));
-
- // We concatenate all the names for a given enum into one big string
- // literal. If instead we store an array of string literals, the linker
- // seems to put all enum strings for a given .proto file in the same
- // section, which hinders its ability to strip out unused strings.
- format("static const char $classname$_names[] =");
- for (const auto& p : name_to_number) {
- format("\n \"$1$\"", p.first);
+ // Build the offset table for the strings table.
+ struct Offset {
+ int number;
+ size_t index, byte_offset, len;
+ };
+ std::vector<Offset> offsets;
+ size_t index = 0;
+ size_t offset = 0;
+ for (const auto& e : name_to_number) {
+ offsets.push_back(Offset{e.second, index, offset, e.first.size()});
+ ++index;
+ offset += e.first.size();
}
- format(";\n\n");
-
- format(
- "static const ::$proto_ns$::internal::EnumEntry $classname$_entries[] "
- "= {\n");
- int i = 0;
- std::map<int, int> number_to_index;
- int data_index = 0;
- for (const auto& p : name_to_number) {
- format(" { {$classname$_names + $1$, $2$}, $3$ },\n", data_index,
- p.first.size(), p.second);
- if (number_to_canonical_name[p.second] == p.first) {
- number_to_index.emplace(p.second, i);
- }
- ++i;
- data_index += p.first.size();
- }
-
- format(
- "};\n"
- "\n"
- "static const int $classname$_entries_by_number[] = {\n");
- for (const auto& p : number_to_index) {
- format(" $1$, // $2$ -> $3$\n", p.second, p.first,
- number_to_canonical_name[p.first]);
- }
- format(
- "};\n"
- "\n");
-
- format(
- "const TProtoStringType& $classname$_Name(\n"
- " $classname$ value) {\n"
- " static const bool dummy =\n"
- " ::$proto_ns$::internal::InitializeEnumStrings(\n"
- " $classname$_entries,\n"
- " $classname$_entries_by_number,\n"
- " $1$, $classname$_strings);\n"
- " (void) dummy;\n"
- " int idx = ::$proto_ns$::internal::LookUpEnumName(\n"
- " $classname$_entries,\n"
- " $classname$_entries_by_number,\n"
- " $1$, value);\n"
- " return idx == -1 ? ::$proto_ns$::internal::GetEmptyString() :\n"
- " $classname$_strings[idx].get();\n"
- "}\n",
- CountUniqueValues(descriptor_));
- format(
- "bool $classname$_Parse(\n"
- " ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, $classname$* "
- "value) "
- "{\n"
- " int int_value;\n"
- " bool success = ::$proto_ns$::internal::LookUpEnumValue(\n"
- " $classname$_entries, $1$, name, &int_value);\n"
- " if (success) {\n"
- " *value = static_cast<$classname$>(int_value);\n"
- " }\n"
- " return success;\n"
- "}\n",
- descriptor_->value_count());
+ y_absl::c_sort(offsets, [](const auto& a, const auto& b) {
+ return a.byte_offset < b.byte_offset;
+ });
+
+ std::vector<Offset> offsets_by_number = offsets;
+ y_absl::c_sort(offsets_by_number, [](const auto& a, const auto& b) {
+ return a.number < b.number;
+ });
+
+ offsets_by_number.erase(
+ std::unique(
+ offsets_by_number.begin(), offsets_by_number.end(),
+ [](const auto& a, const auto& b) { return a.number == b.number; }),
+ offsets_by_number.end());
+
+ p->Emit(
+ {
+ {"num_unique", number_to_canonical_name.size()},
+ {"num_declared", enum_->value_count()},
+ {"names",
+ // We concatenate all the names for a given enum into one big
+ // string literal. If instead we store an array of string
+ // literals, the linker seems to put all enum strings for a given
+ // .proto file in the same section, which hinders its ability to
+ // strip out unused strings.
+ [&] {
+ for (const auto& e : name_to_number) {
+ p->Emit({{"name", e.first}}, R"cc(
+ "$name$"
+ )cc");
+ }
+ }},
+ {"entries",
+ [&] {
+ for (const auto& offset : offsets) {
+ p->Emit({{"number", offset.number},
+ {"offset", offset.byte_offset},
+ {"len", offset.len}},
+ R"cc(
+ {{&$Msg_Enum$_names[$offset$], $len$}, $number$},
+ )cc");
+ }
+ }},
+ {"entries_by_number",
+ [&] {
+ for (const auto& offset : offsets_by_number) {
+ p->Emit({{"number", offset.number},
+ {"index", offset.index},
+ {"name", number_to_canonical_name[offset.number]}},
+ R"cc(
+ $index$, // $number$ -> $name$
+ )cc");
+ }
+ }},
+ },
+ R"cc(
+ static ::$proto_ns$::internal::ExplicitlyConstructed<TProtoStringType>
+ $Msg_Enum$_strings[$num_unique$] = {};
+
+ static const char $Msg_Enum$_names[] = {
+ $names$,
+ };
+
+ static const ::$proto_ns$::internal::EnumEntry $Msg_Enum$_entries[] =
+ {
+ $entries$,
+ };
+
+ static const int $Msg_Enum$_entries_by_number[] = {
+ $entries_by_number$,
+ };
+
+ const TProtoStringType& $Msg_Enum$_Name($Msg_Enum$ value) {
+ static const bool kDummy =
+ ::$proto_ns$::internal::InitializeEnumStrings(
+ $Msg_Enum$_entries, $Msg_Enum$_entries_by_number,
+ $num_unique$, $Msg_Enum$_strings);
+ (void)kDummy;
+
+ int idx = ::$proto_ns$::internal::LookUpEnumName(
+ $Msg_Enum$_entries, $Msg_Enum$_entries_by_number, $num_unique$,
+ value);
+ return idx == -1 ? ::$proto_ns$::internal::GetEmptyString()
+ : $Msg_Enum$_strings[idx].get();
+ }
+
+ bool $Msg_Enum$_Parse(y_absl::string_view name, $Msg_Enum$* value) {
+ int int_value;
+ bool success = ::$proto_ns$::internal::LookUpEnumValue(
+ $Msg_Enum$_entries, $num_declared$, name, &int_value);
+ if (success) {
+ *value = static_cast<$Msg_Enum$>(int_value);
+ }
+ return success;
+ }
+ )cc");
}
- if (descriptor_->containing_type() != nullptr) {
- TProtoStringType parent = ClassName(descriptor_->containing_type(), false);
+ if (enum_->containing_type() != nullptr) {
// Before C++17, we must define the static constants which were
// declared in the header, to give the linker a place to put them.
// But MSVC++ pre-2015 and post-2017 (version 15.5+) insists that we not.
- format(
- "#if (__cplusplus < 201703) && "
- "(!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))\n");
-
- for (int i = 0; i < descriptor_->value_count(); i++) {
- format("constexpr $classname$ $1$::$2$;\n", parent,
- EnumValueName(descriptor_->value(i)));
- }
- format(
- "constexpr $classname$ $1$::$nested_name$_MIN;\n"
- "constexpr $classname$ $1$::$nested_name$_MAX;\n",
- parent);
- if (generate_array_size_) {
- format("constexpr int $1$::$nested_name$_ARRAYSIZE;\n", parent);
- }
-
- format(
- "#endif // (__cplusplus < 201703) && "
- "(!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))\n");
+ p->Emit(
+ {
+ {"Msg_", ClassName(enum_->containing_type(), false)},
+ {"constexpr_storage",
+ [&] {
+ for (int i = 0; i < enum_->value_count(); i++) {
+ p->Emit({{"VALUE", EnumValueName(enum_->value(i))}},
+ R"cc(
+ constexpr $Msg_Enum$ $Msg_$::$VALUE$;
+ )cc");
+ }
+ }},
+ {"array_size",
+ [&] {
+ if (generate_array_size_) {
+ p->Emit(R"cc(
+ constexpr int $Msg_$::$Enum$_ARRAYSIZE;
+ )cc");
+ }
+ }},
+ },
+ R"(
+ #if (__cplusplus < 201703) && \
+ (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
+
+ $constexpr_storage$;
+ constexpr $Msg_Enum$ $Msg_$::$Enum$_MIN;
+ constexpr $Msg_Enum$ $Msg_$::$Enum$_MAX;
+ $array_size$;
+
+ #endif // (__cplusplus < 201703) &&
+ // (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
+ )");
}
}
-
} // namespace cpp
} // namespace compiler
} // namespace protobuf
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum.h
index 550f43b1ed4..58a62f5533a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum.h
@@ -35,67 +35,64 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_H__
#define GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_H__
-#include <map>
-#include <set>
#include <string>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/compiler/cpp/options.h>
-
-namespace google {
-namespace protobuf {
-namespace io {
-class Printer; // printer.h
-}
-} // namespace protobuf
-} // namespace google
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/compiler/cpp/options.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
namespace compiler {
namespace cpp {
-
class EnumGenerator {
public:
- // See generator.cc for the meaning of dllexport_decl.
- EnumGenerator(const EnumDescriptor* descriptor,
- const std::map<TProtoStringType, TProtoStringType>& vars,
- const Options& options);
- ~EnumGenerator();
+ EnumGenerator(const EnumDescriptor* descriptor, const Options& options);
+
+ EnumGenerator(const EnumGenerator&) = delete;
+ EnumGenerator& operator=(const EnumGenerator&) = delete;
+
+ ~EnumGenerator() = default;
// Generate header code defining the enum. This code should be placed
// within the enum's package namespace, but NOT within any class, even for
// nested enums.
- void GenerateDefinition(io::Printer* printer);
+ void GenerateDefinition(io::Printer* p);
// Generate specialization of GetEnumDescriptor<MyEnum>().
// Precondition: in ::google::protobuf namespace.
- void GenerateGetEnumDescriptorSpecializations(io::Printer* printer);
+ void GenerateGetEnumDescriptorSpecializations(io::Printer* p);
// For enums nested within a message, generate code to import all the enum's
// symbols (e.g. the enum type name, all its values, etc.) into the class's
// namespace. This should be placed inside the class definition in the
// header.
- void GenerateSymbolImports(io::Printer* printer) const;
+ void GenerateSymbolImports(io::Printer* p) const;
// Source file stuff.
// Generate non-inline methods related to the enum, such as IsValidValue().
// Goes in the .cc file. EnumDescriptors are stored in an array, idx is
// the index in this array that corresponds with this enum.
- void GenerateMethods(int idx, io::Printer* printer);
+ void GenerateMethods(int idx, io::Printer* p);
private:
- const EnumDescriptor* descriptor_;
- const TProtoStringType classname_;
- const Options& options_;
- // whether to generate the *_ARRAYSIZE constant.
- const bool generate_array_size_;
+ friend class FileGenerator;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ struct ValueLimits {
+ const EnumValueDescriptor* min;
+ const EnumValueDescriptor* max;
- friend class FileGenerator;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator);
+ static ValueLimits FromEnum(const EnumDescriptor* descriptor);
+ };
+
+ const EnumDescriptor* enum_;
+ Options options_;
+
+ bool generate_array_size_;
+ bool should_cache_;
+ bool has_reflection_;
+ ValueLimits limits_;
};
} // namespace cpp
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum_field.cc
deleted file mode 100644
index dc8dc524815..00000000000
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum_field.cc
+++ /dev/null
@@ -1,451 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#include <google/protobuf/compiler/cpp/enum_field.h>
-
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/cpp/field.h>
-#include <google/protobuf/compiler/cpp/helpers.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-namespace {
-
-void SetEnumVariables(const FieldDescriptor* descriptor,
- std::map<TProtoStringType, TProtoStringType>* variables,
- const Options& options) {
- SetCommonFieldVariables(descriptor, variables, options);
- const EnumValueDescriptor* default_value = descriptor->default_value_enum();
- (*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);
- bool cold = ShouldSplit(descriptor, options);
- (*variables)["cached_byte_size_field"] =
- MakeVarintCachedSizeFieldName(descriptor, cold);
-}
-
-} // namespace
-
-// ===================================================================
-
-EnumFieldGenerator::EnumFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options)
- : FieldGenerator(descriptor, options) {
- SetEnumVariables(descriptor, &variables_, options);
-}
-
-EnumFieldGenerator::~EnumFieldGenerator() {}
-
-void EnumFieldGenerator::GeneratePrivateMembers(io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("int $name$_;\n");
-}
-
-void EnumFieldGenerator::GenerateAccessorDeclarations(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format(
- "$deprecated_attr$$type$ ${1$$name$$}$() const;\n"
- "$deprecated_attr$void ${1$set_$name$$}$($type$ value);\n"
- "private:\n"
- "$type$ ${1$_internal_$name$$}$() const;\n"
- "void ${1$_internal_set_$name$$}$($type$ value);\n"
- "public:\n",
- descriptor_);
-}
-
-void EnumFieldGenerator::GenerateInlineAccessorDefinitions(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format(
- "inline $type$ $classname$::_internal_$name$() const {\n"
- " return static_cast< $type$ >($field$);\n"
- "}\n"
- "inline $type$ $classname$::$name$() const {\n"
- "$annotate_get$"
- " // @@protoc_insertion_point(field_get:$full_name$)\n"
- " return _internal_$name$();\n"
- "}\n"
- "inline void $classname$::_internal_set_$name$($type$ value) {\n");
- if (!HasPreservingUnknownEnumSemantics(descriptor_)) {
- format(" assert($type$_IsValid(value));\n");
- }
- format(
- " $set_hasbit$\n"
- " $field$ = value;\n"
- "}\n"
- "inline void $classname$::set_$name$($type$ value) {\n"
- "$maybe_prepare_split_message$"
- " _internal_set_$name$(value);\n"
- "$annotate_set$"
- " // @@protoc_insertion_point(field_set:$full_name$)\n"
- "}\n");
-}
-
-void EnumFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("$field$ = $default$;\n");
-}
-
-void EnumFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("_this->_internal_set_$name$(from._internal_$name$());\n");
-}
-
-void EnumFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("swap($field$, other->$field$);\n");
-}
-
-void EnumFieldGenerator::GenerateCopyConstructorCode(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("_this->$field$ = from.$field$;\n");
-}
-
-void EnumFieldGenerator::GenerateSerializeWithCachedSizesToArray(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format(
- "target = stream->EnsureSpace(target);\n"
- "target = ::_pbi::WireFormatLite::WriteEnumToArray(\n"
- " $number$, this->_internal_$name$(), target);\n");
-}
-
-void EnumFieldGenerator::GenerateByteSize(io::Printer* printer) const {
- Formatter format(printer, variables_);
- format(
- "total_size += $tag_size$ +\n"
- " ::_pbi::WireFormatLite::EnumSize(this->_internal_$name$());\n");
-}
-
-void EnumFieldGenerator::GenerateConstexprAggregateInitializer(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("/*decltype($field$)*/$default$");
-}
-
-void EnumFieldGenerator::GenerateAggregateInitializer(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- if (ShouldSplit(descriptor_, options_)) {
- format("decltype(Impl_::Split::$name$_){$default$}");
- return;
- }
- format("decltype($field$){$default$}");
-}
-
-void EnumFieldGenerator::GenerateCopyAggregateInitializer(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("decltype($field$){}");
-}
-
-// ===================================================================
-
-EnumOneofFieldGenerator::EnumOneofFieldGenerator(
- const FieldDescriptor* descriptor, const Options& options)
- : EnumFieldGenerator(descriptor, options) {
- SetCommonOneofFieldVariables(descriptor, &variables_);
-}
-
-EnumOneofFieldGenerator::~EnumOneofFieldGenerator() {}
-
-void EnumOneofFieldGenerator::GenerateInlineAccessorDefinitions(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format(
- "inline $type$ $classname$::_internal_$name$() const {\n"
- " if (_internal_has_$name$()) {\n"
- " return static_cast< $type$ >($field$);\n"
- " }\n"
- " return static_cast< $type$ >($default$);\n"
- "}\n"
- "inline $type$ $classname$::$name$() const {\n"
- "$annotate_get$"
- " // @@protoc_insertion_point(field_get:$full_name$)\n"
- " return _internal_$name$();\n"
- "}\n"
- "inline void $classname$::_internal_set_$name$($type$ value) {\n");
- if (!HasPreservingUnknownEnumSemantics(descriptor_)) {
- format(" assert($type$_IsValid(value));\n");
- }
- format(
- " if (!_internal_has_$name$()) {\n"
- " clear_$oneof_name$();\n"
- " set_has_$name$();\n"
- " }\n"
- " $field$ = value;\n"
- "}\n"
- "inline void $classname$::set_$name$($type$ value) {\n"
- " _internal_set_$name$(value);\n"
- "$annotate_set$"
- " // @@protoc_insertion_point(field_set:$full_name$)\n"
- "}\n");
-}
-
-void EnumOneofFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("$field$ = $default$;\n");
-}
-
-void EnumOneofFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
- // Don't print any swapping code. Swapping the union will swap this field.
-}
-
-void EnumOneofFieldGenerator::GenerateConstructorCode(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("$ns$::_$classname$_default_instance_.$field$ = $default$;\n");
-}
-
-// ===================================================================
-
-RepeatedEnumFieldGenerator::RepeatedEnumFieldGenerator(
- const FieldDescriptor* descriptor, const Options& options)
- : FieldGenerator(descriptor, options) {
- SetEnumVariables(descriptor, &variables_, options);
-}
-
-RepeatedEnumFieldGenerator::~RepeatedEnumFieldGenerator() {}
-
-void RepeatedEnumFieldGenerator::GeneratePrivateMembers(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("::$proto_ns$::RepeatedField<int> $name$_;\n");
- if (descriptor_->is_packed() &&
- HasGeneratedMethods(descriptor_->file(), options_)) {
- format("mutable std::atomic<int> $cached_byte_size_name$;\n");
- }
-}
-
-void RepeatedEnumFieldGenerator::GenerateAccessorDeclarations(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format(
- "private:\n"
- "$type$ ${1$_internal_$name$$}$(int index) const;\n"
- "void ${1$_internal_add_$name$$}$($type$ value);\n"
- "::$proto_ns$::RepeatedField<int>* "
- "${1$_internal_mutable_$name$$}$();\n"
- "public:\n"
- "$deprecated_attr$$type$ ${1$$name$$}$(int index) const;\n"
- "$deprecated_attr$void ${1$set_$name$$}$(int index, $type$ value);\n"
- "$deprecated_attr$void ${1$add_$name$$}$($type$ value);\n"
- "$deprecated_attr$const ::$proto_ns$::RepeatedField<int>& "
- "${1$$name$$}$() const;\n"
- "$deprecated_attr$::$proto_ns$::RepeatedField<int>* "
- "${1$mutable_$name$$}$();\n",
- descriptor_);
-}
-
-void RepeatedEnumFieldGenerator::GenerateInlineAccessorDefinitions(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format(
- "inline $type$ $classname$::_internal_$name$(int index) const {\n"
- " return static_cast< $type$ >($field$.Get(index));\n"
- "}\n"
- "inline $type$ $classname$::$name$(int index) const {\n"
- "$annotate_get$"
- " // @@protoc_insertion_point(field_get:$full_name$)\n"
- " return _internal_$name$(index);\n"
- "}\n"
- "inline void $classname$::set_$name$(int index, $type$ value) {\n");
- if (!HasPreservingUnknownEnumSemantics(descriptor_)) {
- format(" assert($type$_IsValid(value));\n");
- }
- format(
- " $field$.Set(index, value);\n"
- "$annotate_set$"
- " // @@protoc_insertion_point(field_set:$full_name$)\n"
- "}\n"
- "inline void $classname$::_internal_add_$name$($type$ value) {\n");
- if (!HasPreservingUnknownEnumSemantics(descriptor_)) {
- format(" assert($type$_IsValid(value));\n");
- }
- format(
- " $field$.Add(value);\n"
- "}\n"
- "inline void $classname$::add_$name$($type$ value) {\n"
- " _internal_add_$name$(value);\n"
- "$annotate_add$"
- " // @@protoc_insertion_point(field_add:$full_name$)\n"
- "}\n"
- "inline const ::$proto_ns$::RepeatedField<int>&\n"
- "$classname$::$name$() const {\n"
- "$annotate_list$"
- " // @@protoc_insertion_point(field_list:$full_name$)\n"
- " return $field$;\n"
- "}\n"
- "inline ::$proto_ns$::RepeatedField<int>*\n"
- "$classname$::_internal_mutable_$name$() {\n"
- " return &$field$;\n"
- "}\n"
- "inline ::$proto_ns$::RepeatedField<int>*\n"
- "$classname$::mutable_$name$() {\n"
- "$annotate_mutable_list$"
- " // @@protoc_insertion_point(field_mutable_list:$full_name$)\n"
- " return _internal_mutable_$name$();\n"
- "}\n");
-}
-
-void RepeatedEnumFieldGenerator::GenerateClearingCode(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("$field$.Clear();\n");
-}
-
-void RepeatedEnumFieldGenerator::GenerateMergingCode(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("_this->$field$.MergeFrom(from.$field$);\n");
-}
-
-void RepeatedEnumFieldGenerator::GenerateSwappingCode(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("$field$.InternalSwap(&other->$field$);\n");
-}
-
-void RepeatedEnumFieldGenerator::GenerateConstructorCode(
- io::Printer* printer) const {
- // Not needed for repeated fields.
-}
-
-void RepeatedEnumFieldGenerator::GenerateDestructorCode(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("$field$.~RepeatedField();\n");
-}
-
-void RepeatedEnumFieldGenerator::GenerateSerializeWithCachedSizesToArray(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- if (descriptor_->is_packed()) {
- // Write the tag and the size.
- format(
- "{\n"
- " int byte_size = "
- "$cached_byte_size_field$.load(std::memory_order_relaxed);\n"
- " if (byte_size > 0) {\n"
- " target = stream->WriteEnumPacked(\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 = ::_pbi::WireFormatLite::WriteEnumToArray(\n"
- " $number$, this->_internal_$name$(i), target);\n"
- "}\n");
- }
-}
-
-void RepeatedEnumFieldGenerator::GenerateByteSize(io::Printer* printer) const {
- Formatter format(printer, variables_);
- format(
- "{\n"
- " size_t data_size = 0;\n"
- " unsigned int count = static_cast<unsigned "
- "int>(this->_internal_$name$_size());");
- format.Indent();
- format(
- "for (unsigned int i = 0; i < count; i++) {\n"
- " data_size += ::_pbi::WireFormatLite::EnumSize(\n"
- " this->_internal_$name$(static_cast<int>(i)));\n"
- "}\n");
-
- if (descriptor_->is_packed()) {
- format(
- "if (data_size > 0) {\n"
- " total_size += $tag_size$ +\n"
- " "
- "::_pbi::WireFormatLite::Int32Size(static_cast<$int32$>(data_size));\n"
- "}\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 {
- format("total_size += ($tag_size$UL * count) + data_size;\n");
- }
- format.Outdent();
- format("}\n");
-}
-
-void RepeatedEnumFieldGenerator::GenerateConstexprAggregateInitializer(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("/*decltype($field$)*/{}");
- if (descriptor_->is_packed() &&
- HasGeneratedMethods(descriptor_->file(), options_)) {
- format("\n, /*decltype($cached_byte_size_field$)*/{0}");
- }
-}
-
-void RepeatedEnumFieldGenerator::GenerateAggregateInitializer(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("decltype($field$){arena}");
- if (descriptor_->is_packed() &&
- HasGeneratedMethods(descriptor_->file(), options_)) {
- // std::atomic has no copy constructor, which prevents explicit aggregate
- // initialization pre-C++17.
- format("\n, /*decltype($cached_byte_size_field$)*/{0}");
- }
-}
-
-void RepeatedEnumFieldGenerator::GenerateCopyAggregateInitializer(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("decltype($field$){from.$field$}");
- if (descriptor_->is_packed() &&
- HasGeneratedMethods(descriptor_->file(), options_)) {
- // std::atomic has no copy constructor.
- format("\n, /*decltype($cached_byte_size_field$)*/{0}");
- }
-}
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum_field.h
deleted file mode 100644
index 61bae855cd6..00000000000
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum_field.h
+++ /dev/null
@@ -1,125 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_FIELD_H__
-#define GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_FIELD_H__
-
-#include <map>
-#include <string>
-
-#include <google/protobuf/compiler/cpp/field.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-class EnumFieldGenerator : public FieldGenerator {
- public:
- EnumFieldGenerator(const FieldDescriptor* descriptor, const Options& options);
- ~EnumFieldGenerator() override;
-
- // implements FieldGenerator ---------------------------------------
- void GeneratePrivateMembers(io::Printer* printer) const override;
- void GenerateAccessorDeclarations(io::Printer* printer) const override;
- void GenerateInlineAccessorDefinitions(io::Printer* printer) const override;
- 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 GenerateSerializeWithCachedSizesToArray(
- io::Printer* printer) const override;
- void GenerateByteSize(io::Printer* printer) const override;
- void GenerateConstexprAggregateInitializer(
- io::Printer* printer) const override;
- void GenerateAggregateInitializer(io::Printer* printer) const override;
- void GenerateCopyAggregateInitializer(io::Printer* printer) const override;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator);
-};
-
-class EnumOneofFieldGenerator : public EnumFieldGenerator {
- public:
- EnumOneofFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
- ~EnumOneofFieldGenerator() override;
-
- // implements FieldGenerator ---------------------------------------
- void GenerateInlineAccessorDefinitions(io::Printer* printer) const override;
- void GenerateClearingCode(io::Printer* printer) const override;
- void GenerateSwappingCode(io::Printer* printer) const override;
- void GenerateConstructorCode(io::Printer* printer) const override;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumOneofFieldGenerator);
-};
-
-class RepeatedEnumFieldGenerator : public FieldGenerator {
- public:
- RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
- ~RepeatedEnumFieldGenerator() override;
-
- // implements FieldGenerator ---------------------------------------
- void GeneratePrivateMembers(io::Printer* printer) const override;
- void GenerateAccessorDeclarations(io::Printer* printer) const override;
- void GenerateInlineAccessorDefinitions(io::Printer* printer) const override;
- 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 {
- GOOGLE_CHECK(!ShouldSplit(descriptor_, options_));
- }
- void GenerateDestructorCode(io::Printer* printer) const override;
- void GenerateSerializeWithCachedSizesToArray(
- io::Printer* printer) const override;
- void GenerateByteSize(io::Printer* printer) const override;
- void GenerateConstexprAggregateInitializer(
- io::Printer* printer) const override;
- void GenerateAggregateInitializer(io::Printer* printer) const override;
- void GenerateCopyAggregateInitializer(io::Printer* printer) const override;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedEnumFieldGenerator);
-};
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_FIELD_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.cc
index ed85f75960a..60ef25c1356 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.cc
@@ -32,14 +32,13 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/cpp/extension.h>
+#include "google/protobuf/compiler/cpp/extension.h"
-#include <map>
-
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/cpp/helpers.h>
-#include <google/protobuf/descriptor.pb.h>
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_replace.h"
+#include "google/protobuf/compiler/cpp/helpers.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
@@ -77,7 +76,6 @@ ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor,
type_traits_.append(" >");
break;
}
- SetCommonVars(options, &variables_);
SetCommonMessageDataVariables(descriptor_->containing_type(), &variables_);
variables_["extendee"] =
QualifiedClassName(descriptor_->containing_type(), options_);
@@ -86,14 +84,18 @@ ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor,
variables_["name"] = ResolveKeyword(name);
variables_["constant_name"] = FieldConstantName(descriptor_);
variables_["field_type"] =
- StrCat(static_cast<int>(descriptor_->type()));
+ y_absl::StrCat(static_cast<int>(descriptor_->type()));
variables_["packed"] = descriptor_->is_packed() ? "true" : "false";
- TProtoStringType scope =
- IsScoped() ? ClassName(descriptor_->extension_scope(), false) + "::" : "";
+ TProtoStringType scope;
+ if (IsScoped()) {
+ scope =
+ y_absl::StrCat(ClassName(descriptor_->extension_scope(), false), "::");
+ }
+
variables_["scope"] = scope;
variables_["scoped_name"] = ExtensionName(descriptor_);
- variables_["number"] = StrCat(descriptor_->number());
+ variables_["number"] = y_absl::StrCat(descriptor_->number());
bool add_verify_fn =
// Only verify msgs.
@@ -104,7 +106,7 @@ ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor,
variables_["verify_fn"] =
add_verify_fn
- ? StrCat("&", FieldMessageTypeName(descriptor_, options_),
+ ? y_absl::StrCat("&", FieldMessageTypeName(descriptor_, options_),
"::InternalVerify")
: "nullptr";
}
@@ -125,7 +127,7 @@ void ExtensionGenerator::GenerateDeclaration(io::Printer* printer) const {
if (!IsScoped()) {
qualifier = "extern";
if (!options_.dllexport_decl.empty()) {
- qualifier = options_.dllexport_decl + " " + qualifier;
+ qualifier = y_absl::StrCat(options_.dllexport_decl, " ", qualifier);
}
} else {
qualifier = "static";
@@ -159,14 +161,15 @@ void ExtensionGenerator::GenerateDefinition(io::Printer* printer) {
// it in the header which would be annoying for other reasons. So we
// replace :: with _ in the name and declare it as a global.
default_str =
- StringReplace(variables_["scoped_name"], "::", "_", true) + "_default";
+ y_absl::StrReplaceAll(variables_["scoped_name"], {{"::", "_"}}) +
+ "_default";
format("const TProtoStringType $1$($2$);\n", default_str,
DefaultValue(options_, descriptor_));
} else if (descriptor_->message_type()) {
// We have to initialize the default instance for extensions at registration
// time.
- default_str =
- FieldMessageTypeName(descriptor_, options_) + "::default_instance()";
+ default_str = y_absl::StrCat(FieldMessageTypeName(descriptor_, options_),
+ "::default_instance()");
} else {
default_str = DefaultValue(options_, descriptor_);
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.h
index b94b178868a..e93473dbab1 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.h
@@ -35,11 +35,11 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_EXTENSION_H__
#define GOOGLE_PROTOBUF_COMPILER_CPP_EXTENSION_H__
-#include <map>
#include <string>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/compiler/cpp/options.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "google/protobuf/compiler/cpp/options.h"
+#include "google/protobuf/port.h"
namespace google {
namespace protobuf {
@@ -66,6 +66,8 @@ class ExtensionGenerator {
explicit ExtensionGenerator(const FieldDescriptor* descriptor,
const Options& options,
MessageSCCAnalyzer* scc_analyzer);
+ ExtensionGenerator(const ExtensionGenerator&) = delete;
+ ExtensionGenerator& operator=(const ExtensionGenerator&) = delete;
~ExtensionGenerator();
// Header stuff.
@@ -82,9 +84,7 @@ class ExtensionGenerator {
Options options_;
MessageSCCAnalyzer* scc_analyzer_;
- std::map<TProtoStringType, TProtoStringType> variables_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator);
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables_;
};
} // namespace cpp
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field.cc
index d5359b6d247..361c039cc52 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field.cc
@@ -32,276 +32,89 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/cpp/field.h>
+#include "google/protobuf/compiler/cpp/field.h"
#include <cstdint>
#include <memory>
#include <string>
-
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/substitute.h>
-#include <google/protobuf/compiler/cpp/helpers.h>
-#include <google/protobuf/compiler/cpp/primitive_field.h>
-#include <google/protobuf/compiler/cpp/string_field.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/enum_field.h>
-#include <google/protobuf/compiler/cpp/map_field.h>
-#include <google/protobuf/compiler/cpp/message_field.h>
-#include <google/protobuf/descriptor.pb.h>
+#include <vector>
+
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/types/optional.h"
+#include "google/protobuf/compiler/cpp/field_generators/generators.h"
+#include "google/protobuf/compiler/cpp/helpers.h"
+#include "google/protobuf/compiler/cpp/options.h"
+#include "google/protobuf/compiler/cpp/tracker.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/printer.h"
+#include "google/protobuf/wire_format.h"
namespace google {
namespace protobuf {
namespace compiler {
namespace cpp {
-
-using internal::WireFormat;
-
-namespace {
-
-void MaySetAnnotationVariable(const Options& options,
- StringPiece annotation_name,
- StringPiece substitute_template_prefix,
- StringPiece prepared_template,
- int field_index, StringPiece access_type,
- std::map<TProtoStringType, TProtoStringType>* variables) {
- if (options.field_listener_options.forbidden_field_listener_events.count(
- TProtoStringType(annotation_name)))
- return;
- (*variables)[StrCat("annotate_", annotation_name)] = strings::Substitute(
- StrCat(substitute_template_prefix, prepared_template, ");\n"),
- field_index, access_type);
-}
-
-TProtoStringType GenerateTemplateForOneofString(const FieldDescriptor* descriptor,
- StringPiece proto_ns,
- StringPiece field_member) {
- TProtoStringType field_name = google::protobuf::compiler::cpp::FieldName(descriptor);
- TProtoStringType field_pointer =
- descriptor->options().ctype() == google::protobuf::FieldOptions::STRING
- ? "$0.UnsafeGetPointer()"
- : "$0";
-
- if (descriptor->default_value_string().empty()) {
- return strings::Substitute(StrCat("_internal_has_", field_name, "() ? ",
- field_pointer, ": nullptr"),
- field_member);
- }
-
- if (descriptor->options().ctype() == google::protobuf::FieldOptions::STRING_PIECE) {
- return strings::Substitute(StrCat("_internal_has_", field_name, "() ? ",
- field_pointer, ": nullptr"),
- field_member);
- }
-
- TProtoStringType default_value_pointer =
- descriptor->options().ctype() == google::protobuf::FieldOptions::STRING
- ? "&$1.get()"
- : "&$1";
- return strings::Substitute(
- StrCat("_internal_has_", field_name, "() ? ", field_pointer, " : ",
- default_value_pointer),
- field_member, MakeDefaultFieldName(descriptor));
-}
-
-TProtoStringType GenerateTemplateForSingleString(const FieldDescriptor* descriptor,
- StringPiece field_member) {
- if (descriptor->default_value_string().empty()) {
- return StrCat("&", field_member);
- }
-
- if (descriptor->options().ctype() == google::protobuf::FieldOptions::STRING) {
- return strings::Substitute(
- "$0.IsDefault() ? &$1.get() : $0.UnsafeGetPointer()", field_member,
- MakeDefaultFieldName(descriptor));
- }
-
- return StrCat("&", field_member);
-}
-
-} // namespace
-
-void AddAccessorAnnotations(const FieldDescriptor* descriptor,
- const Options& options,
- std::map<TProtoStringType, TProtoStringType>* variables) {
- // Can be expanded to include more specific calls, for example, for arena or
- // clear calls.
- static constexpr const char* kAccessorsAnnotations[] = {
- "annotate_add", "annotate_get", "annotate_has",
- "annotate_list", "annotate_mutable", "annotate_mutable_list",
- "annotate_release", "annotate_set", "annotate_size",
- "annotate_clear", "annotate_add_mutable",
+using ::google::protobuf::internal::WireFormat;
+using Sub = ::google::protobuf::io::Printer::Sub;
+
+std::vector<Sub> FieldVars(const FieldDescriptor* field, const Options& opts) {
+ bool split = ShouldSplit(field, opts);
+ std::vector<Sub> vars = {
+ // This will eventually be renamed to "field", once the existing "field"
+ // variable is replaced with "field_" everywhere.
+ {"name", FieldName(field)},
+
+ {"index", field->index()},
+ {"number", field->number()},
+ {"pkg.Msg.field", field->full_name()},
+
+ {"field_", FieldMemberName(field, split)},
+ {"DeclaredType", DeclaredTypeMethodName(field->type())},
+ {"kTagBytes", WireFormat::TagSize(field->number(), field->type())},
+ Sub("PrepareSplitMessageForWrite",
+ split ? "PrepareSplitMessageForWrite();" : "")
+ .WithSuffix(";"),
+ Sub("DEPRECATED", DeprecatedAttribute(opts, field)).WithSuffix(" "),
+
+ // These variables are placeholders to pick out the beginning and ends of
+ // identifiers for annotations (when doing so with existing variables
+ // would be ambiguous or impossible). They should never be set to anything
+ // but the empty string.
+ {"{", ""},
+ {"}", ""},
+
+ // Old-style names.
+ {"field", FieldMemberName(field, split)},
+ {"maybe_prepare_split_message",
+ split ? "PrepareSplitMessageForWrite();" : ""},
+ {"declared_type", DeclaredTypeMethodName(field->type())},
+ {"classname", ClassName(FieldScope(field), false)},
+ {"ns", Namespace(field, opts)},
+ {"tag_size", WireFormat::TagSize(field->number(), field->type())},
+ {"deprecated_attr", DeprecatedAttribute(opts, field)},
};
- for (size_t i = 0; i < GOOGLE_ARRAYSIZE(kAccessorsAnnotations); ++i) {
- (*variables)[kAccessorsAnnotations[i]] = "";
- }
- if (options.annotate_accessor) {
- for (size_t i = 0; i < GOOGLE_ARRAYSIZE(kAccessorsAnnotations); ++i) {
- (*variables)[kAccessorsAnnotations[i]] = StrCat(
- " ", FieldName(descriptor), "_AccessedNoStrip = true;\n");
- }
- }
- if (!options.field_listener_options.inject_field_listener_events) {
- return;
- }
- if (descriptor->file()->options().optimize_for() ==
- google::protobuf::FileOptions::LITE_RUNTIME) {
- return;
- }
- TProtoStringType field_member = (*variables)["field"];
- const google::protobuf::OneofDescriptor* oneof_member =
- descriptor->real_containing_oneof();
- const TProtoStringType proto_ns = (*variables)["proto_ns"];
- 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
- // inside the returned values, for example, for repeated fields and maps.
- TProtoStringType prepared_flat_template;
- TProtoStringType prepared_add_template;
- // TODO(b/190614678): Support fields with type Message or Map.
- if (descriptor->is_repeated() && !descriptor->is_map()) {
- if (descriptor->type() != FieldDescriptor::TYPE_MESSAGE &&
- descriptor->type() != FieldDescriptor::TYPE_GROUP) {
- prepared_template = strings::Substitute("&$0.Get(index)", field_member);
- prepared_add_template =
- strings::Substitute("&$0.Get($0.size() - 1)", field_member);
- } else {
- prepared_template = "nullptr";
- prepared_add_template = "nullptr";
- }
- } else if (descriptor->is_map()) {
- prepared_template = "nullptr";
- } else if (descriptor->type() == FieldDescriptor::TYPE_MESSAGE &&
- !IsExplicitLazy(descriptor)) {
- prepared_template = "nullptr";
- } else if (descriptor->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {
- if (oneof_member) {
- prepared_template = GenerateTemplateForOneofString(
- descriptor, (*variables)["proto_ns"], field_member);
- } else {
- prepared_template =
- GenerateTemplateForSingleString(descriptor, field_member);
- }
- } else {
- prepared_template = StrCat("&", field_member);
- }
- if (descriptor->is_repeated() && !descriptor->is_map() &&
- descriptor->type() != FieldDescriptor::TYPE_MESSAGE &&
- descriptor->type() != FieldDescriptor::TYPE_GROUP) {
- prepared_flat_template = StrCat("&", field_member);
- } else {
- prepared_flat_template = prepared_template;
- }
- MaySetAnnotationVariable(options, "get", substitute_template_prefix,
- prepared_template, descriptor->index(), "OnGet",
- variables);
- MaySetAnnotationVariable(options, "set", substitute_template_prefix,
- prepared_template, descriptor->index(), "OnSet",
- variables);
- MaySetAnnotationVariable(options, "has", substitute_template_prefix,
- prepared_template, descriptor->index(), "OnHas",
- variables);
- MaySetAnnotationVariable(options, "mutable", substitute_template_prefix,
- prepared_template, descriptor->index(), "OnMutable",
- variables);
- MaySetAnnotationVariable(options, "release", substitute_template_prefix,
- prepared_template, descriptor->index(), "OnRelease",
- variables);
- MaySetAnnotationVariable(options, "clear", substitute_template_prefix,
- prepared_flat_template, descriptor->index(),
- "OnClear", variables);
- MaySetAnnotationVariable(options, "size", substitute_template_prefix,
- prepared_flat_template, descriptor->index(),
- "OnSize", variables);
- MaySetAnnotationVariable(options, "list", substitute_template_prefix,
- prepared_flat_template, descriptor->index(),
- "OnList", variables);
- MaySetAnnotationVariable(options, "mutable_list", substitute_template_prefix,
- prepared_flat_template, descriptor->index(),
- "OnMutableList", variables);
- MaySetAnnotationVariable(options, "add", substitute_template_prefix,
- prepared_add_template, descriptor->index(), "OnAdd",
- variables);
- MaySetAnnotationVariable(options, "add_mutable", substitute_template_prefix,
- prepared_add_template, descriptor->index(),
- "OnAddMutable", variables);
-}
-
-void SetCommonFieldVariables(const FieldDescriptor* descriptor,
- std::map<TProtoStringType, TProtoStringType>* variables,
- const Options& options) {
- SetCommonVars(options, variables);
- SetCommonMessageDataVariables(descriptor->containing_type(), 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());
- bool split = ShouldSplit(descriptor, options);
- (*variables)["field"] = FieldMemberName(descriptor, split);
-
- (*variables)["tag_size"] = StrCat(
- WireFormat::TagSize(descriptor->number(), descriptor->type()));
- (*variables)["deprecated_attr"] = DeprecatedAttribute(options, descriptor);
-
- (*variables)["set_hasbit"] = "";
- (*variables)["clear_hasbit"] = "";
- (*variables)["maybe_prepare_split_message"] =
- split ? " PrepareSplitMessageForWrite();\n" : "";
-
- AddAccessorAnnotations(descriptor, options, variables);
-
- // These variables are placeholders to pick out the beginning and ends of
- // identifiers for annotations (when doing so with existing variables would
- // be ambiguous or impossible). They should never be set to anything but the
- // empty string.
- (*variables)["{"] = "";
- (*variables)["}"] = "";
-}
-
-void FieldGenerator::SetHasBitIndex(arc_i32 has_bit_index) {
- if (!HasHasbit(descriptor_)) {
- GOOGLE_CHECK_EQ(has_bit_index, -1);
- return;
+ if (const auto* oneof = field->containing_oneof()) {
+ auto field_name = UnderscoresToCamelCase(field->name(), true);
+
+ vars.push_back({"oneof_name", oneof->name()});
+ vars.push_back({"field_name", field_name});
+ vars.push_back({"oneof_index", oneof->index()});
+ vars.push_back({"has_field", y_absl::StrFormat("%s_case() == k%s",
+ oneof->name(), field_name)});
+ vars.push_back(
+ {"not_has_field",
+ y_absl::StrFormat("%s_case() != k%s", oneof->name(), field_name)});
}
- variables_["set_hasbit"] = StrCat(
- variables_["has_bits"], "[", has_bit_index / 32, "] |= 0x",
- strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8), "u;");
- variables_["clear_hasbit"] = StrCat(
- variables_["has_bits"], "[", has_bit_index / 32, "] &= ~0x",
- strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8), "u;");
-}
-void FieldGenerator::SetInlinedStringIndex(arc_i32 inlined_string_index) {
- if (!IsStringInlined(descriptor_, options_)) {
- 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(
- "(", 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(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");
+ return vars;
}
-void FieldGenerator::GenerateAggregateInitializer(io::Printer* printer) const {
- Formatter format(printer, variables_);
+void FieldGeneratorBase::GenerateAggregateInitializer(io::Printer* p) const {
+ Formatter format(p, variables_);
if (ShouldSplit(descriptor_, options_)) {
format("decltype(Impl_::Split::$name$_){arena}");
return;
@@ -309,110 +122,159 @@ void FieldGenerator::GenerateAggregateInitializer(io::Printer* printer) const {
format("decltype($field$){arena}");
}
-void FieldGenerator::GenerateConstexprAggregateInitializer(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
+void FieldGeneratorBase::GenerateConstexprAggregateInitializer(
+ io::Printer* p) const {
+ Formatter format(p, variables_);
format("/*decltype($field$)*/{}");
}
-void FieldGenerator::GenerateCopyAggregateInitializer(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
+void FieldGeneratorBase::GenerateCopyAggregateInitializer(
+ io::Printer* p) const {
+ Formatter format(p, variables_);
format("decltype($field$){from.$field$}");
}
-void FieldGenerator::GenerateCopyConstructorCode(io::Printer* printer) const {
+void FieldGeneratorBase::GenerateCopyConstructorCode(io::Printer* p) const {
if (ShouldSplit(descriptor_, options_)) {
// There is no copy constructor for the `Split` struct, so we need to copy
// the value here.
- Formatter format(printer, variables_);
+ Formatter format(p, variables_);
format("$field$ = from.$field$;\n");
}
}
-void SetCommonOneofFieldVariables(
- const FieldDescriptor* descriptor,
- std::map<TProtoStringType, TProtoStringType>* variables) {
- const TProtoStringType prefix = descriptor->containing_oneof()->name() + "_.";
- (*variables)["oneof_name"] = descriptor->containing_oneof()->name();
-}
-
-FieldGenerator::~FieldGenerator() {}
+void FieldGeneratorBase::GenerateIfHasField(io::Printer* p) const {
+ Y_ABSL_CHECK(internal::cpp::HasHasbit(descriptor_));
-FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor,
- const Options& options,
- MessageSCCAnalyzer* scc_analyzer)
- : descriptor_(descriptor), field_generators_(descriptor->field_count()) {
- // Construct all the FieldGenerators.
- for (int i = 0; i < descriptor->field_count(); i++) {
- field_generators_[i].reset(
- MakeGenerator(descriptor->field(i), options, scc_analyzer));
- }
+ Formatter format(p);
+ format("if (($has_hasbit$) != 0) {\n");
}
-FieldGenerator* FieldGeneratorMap::MakeGoogleInternalGenerator(
- const FieldDescriptor* field, const Options& options,
- MessageSCCAnalyzer* scc_analyzer) {
-
- return nullptr;
-}
+namespace {
+std::unique_ptr<FieldGeneratorBase> MakeGenerator(const FieldDescriptor* field,
+ const Options& options,
+ MessageSCCAnalyzer* scc) {
-FieldGenerator* FieldGeneratorMap::MakeGenerator(
- const FieldDescriptor* field, const Options& options,
- MessageSCCAnalyzer* scc_analyzer) {
- FieldGenerator* generator =
- MakeGoogleInternalGenerator(field, options, scc_analyzer);
- if (generator) {
- return generator;
+ if (field->is_map()) {
+ return MakeMapGenerator(field, options, scc);
}
-
if (field->is_repeated()) {
switch (field->cpp_type()) {
case FieldDescriptor::CPPTYPE_MESSAGE:
- if (field->is_map()) {
- return new MapFieldGenerator(field, options, scc_analyzer);
- } else {
- return new RepeatedMessageFieldGenerator(field, options,
- scc_analyzer);
- }
- case FieldDescriptor::CPPTYPE_STRING:
- return new RepeatedStringFieldGenerator(field, options);
- case FieldDescriptor::CPPTYPE_ENUM:
- return new RepeatedEnumFieldGenerator(field, options);
- default:
- return new RepeatedPrimitiveFieldGenerator(field, options);
- }
- } else if (field->real_containing_oneof()) {
- switch (field->cpp_type()) {
- case FieldDescriptor::CPPTYPE_MESSAGE:
- return new MessageOneofFieldGenerator(field, options, scc_analyzer);
- case FieldDescriptor::CPPTYPE_STRING:
- return new StringOneofFieldGenerator(field, options);
- case FieldDescriptor::CPPTYPE_ENUM:
- return new EnumOneofFieldGenerator(field, options);
- default:
- return new PrimitiveOneofFieldGenerator(field, options);
- }
- } else {
- switch (field->cpp_type()) {
- case FieldDescriptor::CPPTYPE_MESSAGE:
- return new MessageFieldGenerator(field, options, scc_analyzer);
+ return MakeRepeatedMessageGenerator(field, options, scc);
case FieldDescriptor::CPPTYPE_STRING:
- return new StringFieldGenerator(field, options);
+ return MakeRepeatedStringGenerator(field, options, scc);
case FieldDescriptor::CPPTYPE_ENUM:
- return new EnumFieldGenerator(field, options);
+ return MakeRepeatedEnumGenerator(field, options, scc);
default:
- return new PrimitiveFieldGenerator(field, options);
+ return MakeRepeatedPrimitiveGenerator(field, options, scc);
}
}
+
+ if (field->real_containing_oneof() &&
+ field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
+ return MakeOneofMessageGenerator(field, options, scc);
+ }
+
+ switch (field->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_MESSAGE:
+ return MakeSinguarMessageGenerator(field, options, scc);
+ case FieldDescriptor::CPPTYPE_STRING:
+ return MakeSinguarStringGenerator(field, options, scc);
+ case FieldDescriptor::CPPTYPE_ENUM:
+ return MakeSinguarEnumGenerator(field, options, scc);
+ default:
+ return MakeSinguarPrimitiveGenerator(field, options, scc);
+ }
}
-FieldGeneratorMap::~FieldGeneratorMap() {}
+void HasBitVars(const FieldDescriptor* field, const Options& opts,
+ y_absl::optional<arc_ui32> idx, std::vector<Sub>& vars) {
+ if (!idx.has_value()) {
+ vars.emplace_back("set_hasbit", "");
+ vars.emplace_back("clear_hasbit", "");
+ return;
+ }
+
+ Y_ABSL_CHECK(internal::cpp::HasHasbit(field));
+
+ arc_i32 index = *idx / 32;
+ TProtoStringType mask = y_absl::StrFormat("0x%08xu", 1u << (*idx % 32));
-const FieldGenerator& FieldGeneratorMap::get(
- const FieldDescriptor* field) const {
- GOOGLE_CHECK_EQ(field->containing_type(), descriptor_);
- return *field_generators_[field->index()];
+ y_absl::string_view has_bits = IsMapEntryMessage(field->containing_type())
+ ? "_has_bits_"
+ : "_impl_._has_bits_";
+
+ auto has = y_absl::StrFormat("%s[%d] & %s", has_bits, index, mask);
+ auto set = y_absl::StrFormat("%s[%d] |= %s;", has_bits, index, mask);
+ auto clr = y_absl::StrFormat("%s[%d] &= ~%s;", has_bits, index, mask);
+
+ vars.emplace_back("has_hasbit", has);
+ vars.emplace_back(Sub("set_hasbit", set).WithSuffix(";"));
+ vars.emplace_back(Sub("clear_hasbit", clr).WithSuffix(";"));
+}
+
+void InlinedStringVars(const FieldDescriptor* field, const Options& opts,
+ y_absl::optional<arc_ui32> idx, std::vector<Sub>& vars) {
+ if (!IsStringInlined(field, opts)) {
+ Y_ABSL_CHECK(!idx.has_value());
+ return;
+ }
+
+ // The first bit is the tracking bit for on demand registering ArenaDtor.
+ Y_ABSL_CHECK_GT(*idx, 0)
+ << "_inlined_string_donated_'s bit 0 is reserved for arena dtor tracking";
+
+ arc_i32 index = *idx / 32;
+ TProtoStringType mask = y_absl::StrFormat("0x%08xu", 1u << (*idx % 32));
+
+ y_absl::string_view array = IsMapEntryMessage(field->containing_type())
+ ? "_inlined_string_donated_"
+ : "_impl_._inlined_string_donated_";
+
+ vars.emplace_back("inlined_string_donated",
+ y_absl::StrFormat("(%s[%d] & %s) != 0;", array, index, mask));
+ vars.emplace_back("donating_states_word",
+ y_absl::StrFormat("%s[%d]", array, index));
+ vars.emplace_back("mask_for_undonate", y_absl::StrFormat("~%s", mask));
+}
+} // namespace
+
+FieldGenerator::FieldGenerator(const FieldDescriptor* field,
+ const Options& options,
+ MessageSCCAnalyzer* scc_analyzer,
+ y_absl::optional<arc_ui32> hasbit_index,
+ y_absl::optional<arc_ui32> inlined_string_index)
+ : impl_(MakeGenerator(field, options, scc_analyzer)),
+ field_vars_(FieldVars(field, options)),
+ tracker_vars_(MakeTrackerCalls(field, options)),
+ per_generator_vars_(impl_->MakeVars()) {
+ HasBitVars(field, options, hasbit_index, field_vars_);
+ InlinedStringVars(field, options, inlined_string_index, field_vars_);
+}
+
+void FieldGeneratorTable::Build(
+ const Options& options, MessageSCCAnalyzer* scc,
+ y_absl::Span<const arc_i32> has_bit_indices,
+ y_absl::Span<const arc_i32> inlined_string_indices) {
+ // Construct all the FieldGenerators.
+ fields_.reserve(descriptor_->field_count());
+ for (const auto* field : internal::FieldRange(descriptor_)) {
+ y_absl::optional<arc_ui32> has_bit_index;
+ if (!has_bit_indices.empty() && has_bit_indices[field->index()] >= 0) {
+ has_bit_index = static_cast<arc_ui32>(has_bit_indices[field->index()]);
+ }
+
+ y_absl::optional<arc_ui32> inlined_string_index;
+ if (!inlined_string_indices.empty() &&
+ inlined_string_indices[field->index()] >= 0) {
+ inlined_string_index =
+ static_cast<arc_ui32>(inlined_string_indices[field->index()]);
+ }
+
+ fields_.push_back(FieldGenerator(field, options, scc, has_bit_index,
+ inlined_string_index));
+ }
}
} // namespace cpp
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field.h
index 95eb96f499d..0d00011ff74 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field.h
@@ -36,232 +36,384 @@
#define GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_H__
#include <cstdint>
-#include <map>
#include <memory>
#include <string>
+#include <tuple>
+#include <vector>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/compiler/cpp/helpers.h>
-#include <google/protobuf/compiler/cpp/options.h>
-
-namespace google {
-namespace protobuf {
-namespace io {
-class Printer; // printer.h
-}
-} // namespace protobuf
-} // namespace google
+#include "google/protobuf/descriptor.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_check.h"
+#include "google/protobuf/compiler/cpp/helpers.h"
+#include "google/protobuf/compiler/cpp/options.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
namespace compiler {
namespace cpp {
-// Helper function: set variables in the map that are the same for all
-// field code generators.
-// ['name', 'index', 'number', 'classname', 'declared_type', 'tag_size',
-// 'deprecation'].
-void SetCommonFieldVariables(const FieldDescriptor* descriptor,
- std::map<TProtoStringType, TProtoStringType>* variables,
- const Options& options);
+// Customization points for each field codegen type. See FieldGenerator to
+// see how each of these functions is used.
+//
+// TODO(b/245791219): Make every function except the dtor in this generator
+// non-pure-virtual. A generator with no implementation should be able to
+// automatically not contribute any code to the message it is part of, as a
+// matter of clean composability.
+class FieldGeneratorBase {
+ public:
+ FieldGeneratorBase(const FieldDescriptor* descriptor, const Options& options)
+ : descriptor_(descriptor), options_(options) {}
+
+ FieldGeneratorBase(const FieldGeneratorBase&) = delete;
+ FieldGeneratorBase& operator=(const FieldGeneratorBase&) = delete;
+
+ virtual ~FieldGeneratorBase() = 0;
+
+ virtual std::vector<io::Printer::Sub> MakeVars() const { return {}; }
+
+ virtual void GeneratePrivateMembers(io::Printer* p) const = 0;
+
+ virtual void GenerateStaticMembers(io::Printer* p) const {}
+
+ virtual void GenerateAccessorDeclarations(io::Printer* p) const = 0;
+
+ virtual void GenerateInlineAccessorDefinitions(io::Printer* p) const = 0;
+
+ virtual void GenerateNonInlineAccessorDefinitions(io::Printer* p) const {}
+
+ virtual void GenerateInternalAccessorDefinitions(io::Printer* p) const {}
+
+ virtual void GenerateInternalAccessorDeclarations(io::Printer* p) const {}
+
+ virtual void GenerateClearingCode(io::Printer* p) const = 0;
+
+ virtual void GenerateMessageClearingCode(io::Printer* p) const {
+ GenerateClearingCode(p);
+ }
+
+ virtual void GenerateMergingCode(io::Printer* p) const = 0;
+
+ virtual void GenerateCopyConstructorCode(io::Printer* p) const;
+
+ virtual void GenerateSwappingCode(io::Printer* p) const = 0;
+
+ virtual void GenerateConstructorCode(io::Printer* p) const = 0;
+
+ virtual void GenerateDestructorCode(io::Printer* p) const {}
+
+ virtual void GenerateArenaDestructorCode(io::Printer* p) const {
+ Y_ABSL_CHECK(NeedsArenaDestructor() == ArenaDtorNeeds::kNone)
+ << descriptor_->cpp_type_name();
+ }
+
+ virtual void GenerateAggregateInitializer(io::Printer* p) const;
+
+ virtual void GenerateConstexprAggregateInitializer(io::Printer* p) const;
+
+ virtual void GenerateCopyAggregateInitializer(io::Printer* p) const;
+
+ virtual void GenerateSerializeWithCachedSizesToArray(
+ io::Printer* p) const = 0;
+
+ virtual void GenerateByteSize(io::Printer* p) const = 0;
-void SetCommonOneofFieldVariables(
- const FieldDescriptor* descriptor,
- std::map<TProtoStringType, TProtoStringType>* variables);
+ virtual void GenerateIsInitialized(io::Printer* p) const {}
+
+ virtual void GenerateIfHasField(io::Printer* p) const;
+
+ virtual bool IsInlined() const { return false; }
+
+ virtual ArenaDtorNeeds NeedsArenaDestructor() const {
+ return ArenaDtorNeeds::kNone;
+ }
+
+ protected:
+ // TODO(b/245791219): Remove these members and make this a pure interface.
+ const FieldDescriptor* descriptor_;
+ const Options& options_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables_;
+};
+
+inline FieldGeneratorBase::~FieldGeneratorBase() = default;
class FieldGenerator {
+ private:
+ // This function must be defined here so that the inline definitions below
+ // can see it, which is required because it has deduced return type.
+ auto PushVarsForCall(io::Printer* p) const {
+ // NOTE: we use a struct here because:
+ // * We want to ensure that order of evaluation below is well-defined,
+ // which {...} guarantees but (...) does not.
+ // * We do not require C++17 as of writing and therefore cannot use
+ // std::tuple with CTAD.
+ // * std::make_tuple uses (...), not {...}.
+ struct Vars {
+ decltype(p->WithVars(field_vars_)) cleanup1;
+ decltype(p->WithVars(tracker_vars_)) cleanup2;
+ decltype(p->WithVars(per_generator_vars_)) cleanup3;
+ };
+
+ return Vars{p->WithVars(field_vars_), p->WithVars(tracker_vars_),
+ p->WithVars(per_generator_vars_)};
+ }
+
public:
- explicit FieldGenerator(const FieldDescriptor* descriptor,
- const Options& options)
- : descriptor_(descriptor), options_(options) {}
- virtual ~FieldGenerator();
- virtual void GenerateSerializeWithCachedSizes(
- io::Printer* printer) const final{};
- // Generate lines of code declaring members fields of the message class
- // needed to represent this field. These are placed inside the message
- // class.
- virtual void GeneratePrivateMembers(io::Printer* printer) const = 0;
-
- // Generate static default variable for this field. These are placed inside
- // the message class. Most field types don't need this, so the default
- // implementation is empty.
- virtual void GenerateStaticMembers(io::Printer* /*printer*/) const {}
-
- // Generate prototypes for all of the accessor functions related to this
- // field. These are placed inside the class definition.
- virtual void GenerateAccessorDeclarations(io::Printer* printer) const = 0;
-
- // Generate inline definitions of accessor functions for this field.
- // These are placed inside the header after all class definitions.
- virtual void GenerateInlineAccessorDefinitions(
- io::Printer* printer) const = 0;
-
- // Generate definitions of accessors that aren't inlined. These are
- // placed somewhere in the .cc file.
- // Most field types don't need this, so the default implementation is empty.
- virtual void GenerateNonInlineAccessorDefinitions(
- io::Printer* /*printer*/) const {}
-
- // Generate declarations of accessors that are for internal purposes only.
- // Most field types don't need this, so the default implementation is empty.
- virtual void GenerateInternalAccessorDefinitions(
- io::Printer* /*printer*/) const {}
-
- // Generate definitions of accessors that are for internal purposes only.
- // Most field types don't need this, so the default implementation is empty.
- virtual void GenerateInternalAccessorDeclarations(
- io::Printer* /*printer*/) const {}
-
- // Generate lines of code (statements, not declarations) which clear the
- // field. This is used to define the clear_$name$() method
- virtual void GenerateClearingCode(io::Printer* printer) const = 0;
-
- // Generate lines of code (statements, not declarations) which clear the
- // field as part of the Clear() method for the whole message. For message
- // types which have field presence bits, MessageGenerator::GenerateClear
- // will have already checked the presence bits.
+ FieldGenerator(const FieldGenerator&) = delete;
+ FieldGenerator& operator=(const FieldGenerator&) = delete;
+ FieldGenerator(FieldGenerator&&) = default;
+ FieldGenerator& operator=(FieldGenerator&&) = default;
+
+ // Prints private members needed to represent this field.
//
- // Since most field types can re-use GenerateClearingCode, this method is
- // not pure virtual.
- virtual void GenerateMessageClearingCode(io::Printer* printer) const {
- GenerateClearingCode(printer);
+ // These are placed inside the class definition.
+ void GeneratePrivateMembers(io::Printer* p) const {
+ auto vars = PushVarsForCall(p);
+ impl_->GeneratePrivateMembers(p);
}
- // Generate lines of code (statements, not declarations) which merges the
- // contents of the field from the current message to the target message,
- // which is stored in the generated code variable "from".
+ // Prints static members needed to represent this field.
+ //
+ // These are placed inside the class definition.
+ void GenerateStaticMembers(io::Printer* p) const {
+ auto vars = PushVarsForCall(p);
+ impl_->GenerateStaticMembers(p);
+ }
+
+ // Generates declarations for all of the accessor functions related to this
+ // field.
+ //
+ // These are placed inside the class definition.
+ void GenerateAccessorDeclarations(io::Printer* p) const {
+ auto vars = PushVarsForCall(p);
+ impl_->GenerateAccessorDeclarations(p);
+ }
+
+ // Generates inline definitions of accessor functions for this field.
+ //
+ // These are placed in namespace scope in the header after all class
+ // definitions.
+ void GenerateInlineAccessorDefinitions(io::Printer* p) const {
+ auto vars = PushVarsForCall(p);
+ impl_->GenerateInlineAccessorDefinitions(p);
+ }
+
+ // Generates definitions of accessors that aren't inlined.
+ //
+ // These are placed in namespace scope in the .cc file.
+ void GenerateNonInlineAccessorDefinitions(io::Printer* p) const {
+ auto vars = PushVarsForCall(p);
+ impl_->GenerateNonInlineAccessorDefinitions(p);
+ }
+
+ // Generates declarations of accessors that are for internal purposes only.
+ void GenerateInternalAccessorDefinitions(io::Printer* p) const {
+ auto vars = PushVarsForCall(p);
+ impl_->GenerateInternalAccessorDefinitions(p);
+ }
+
+ // Generates definitions of accessors that are for internal purposes only.
+ void GenerateInternalAccessorDeclarations(io::Printer* p) const {
+ auto vars = PushVarsForCall(p);
+ impl_->GenerateInternalAccessorDeclarations(p);
+ }
+
+ // Generates statements which clear the field.
+ //
+ // This is used to define the clear_$name$() method.
+ void GenerateClearingCode(io::Printer* p) const {
+ auto vars = PushVarsForCall(p);
+ impl_->GenerateClearingCode(p);
+ }
+
+ // Generates statements which clear the field as part of the Clear() method
+ // for the whole message.
+ //
+ // For message types which have field presence bits,
+ // MessageGenerator::GenerateClear will have already checked the presence
+ // bits.
+ void GenerateMessageClearingCode(io::Printer* p) const {
+ auto vars = PushVarsForCall(p);
+ impl_->GenerateMessageClearingCode(p);
+ }
+
+ // Generates statements which merge the contents of the field from the current
+ // message to the target message, which is stored in the generated code
+ // variable `from`.
+ //
// This is used to fill in the MergeFrom method for the whole message.
+ //
// Details of this usage can be found in message.cc under the
// GenerateMergeFrom method.
- virtual void GenerateMergingCode(io::Printer* printer) const = 0;
+ void GenerateMergingCode(io::Printer* p) const {
+ auto vars = PushVarsForCall(p);
+ impl_->GenerateMergingCode(p);
+ }
// Generates a copy constructor
- virtual void GenerateCopyConstructorCode(io::Printer* printer) const;
+ //
+ // TODO(b/245791219): Document this properly.
+ void GenerateCopyConstructorCode(io::Printer* p) const {
+ auto vars = PushVarsForCall(p);
+ impl_->GenerateCopyConstructorCode(p);
+ }
- // Generate lines of code (statements, not declarations) which swaps
- // this field and the corresponding field of another message, which
- // is stored in the generated code variable "other". This is used to
- // define the Swap method. Details of usage can be found in
+ // Generates statements which swap this field and the corresponding field of
+ // another message, which is stored in the generated code variable `other`.
+ //
+ // This is used to define the Swap method. Details of usage can be found in
// message.cc under the GenerateSwap method.
- virtual void GenerateSwappingCode(io::Printer* printer) const = 0;
-
- // Generate initialization code for private members declared by
- // GeneratePrivateMembers(). These go into the message class's SharedCtor()
- // method, invoked by each of the generated constructors.
- virtual void GenerateConstructorCode(io::Printer* printer) const = 0;
+ void GenerateSwappingCode(io::Printer* p) const {
+ auto vars = PushVarsForCall(p);
+ impl_->GenerateSwappingCode(p);
+ }
- // Generate initialization code for private members in the cold struct.
- virtual void GenerateCreateSplitMessageCode(io::Printer* printer) const {}
+ // Generates initialization code for private members declared by
+ // GeneratePrivateMembers().
+ //
+ // These go into the message class's SharedCtor() method, invoked by each of
+ // the generated constructors.
+ void GenerateConstructorCode(io::Printer* p) const {
+ auto vars = PushVarsForCall(p);
+ impl_->GenerateConstructorCode(p);
+ }
- // Generate any code that needs to go in the class's SharedDtor() method,
+ // Generates any code that needs to go in the class's SharedDtor() method,
// invoked by the destructor.
- // Most field types don't need this, so the default implementation is empty.
- virtual void GenerateDestructorCode(io::Printer* /*printer*/) const {}
-
- // 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().
- virtual void GenerateArenaDestructorCode(io::Printer* printer) const {
- GOOGLE_CHECK(NeedsArenaDestructor() == ArenaDtorNeeds::kNone)
- << descriptor_->cpp_type_name();
+ void GenerateDestructorCode(io::Printer* p) const {
+ auto vars = PushVarsForCall(p);
+ impl_->GenerateDestructorCode(p);
}
- // Generate initialization code for private members declared by
- // GeneratePrivateMembers(). These go into the SharedCtor's
- // aggregate initialization of the _impl_ struct and must follow the syntax
- // (e.g. `decltype($field$){$default$}`). Does not include `:` or `,`
- // separators. Default values should be specified here when possible.
+ // Generates a manual destructor invocation for use when the message is on an
+ // arena.
//
- // Note: We use `decltype($field$)` for both explicit construction and the
- // fact that it's self-documenting. Pre-C++17, copy elision isn't guaranteed
+ // The code that this method generates will be executed inside a
+ // shared-for-the-whole-message-class method registered with OwnDestructor().
+ void GenerateArenaDestructorCode(io::Printer* p) const {
+ auto vars = PushVarsForCall(p);
+ impl_->GenerateArenaDestructorCode(p);
+ }
+
+ // Generates initialization code for private members declared by
+ // GeneratePrivateMembers().
+ //
+ // These go into the SharedCtor's aggregate initialization of the _impl_
+ // struct and must follow the syntax `decltype($field$){$default$}`.
+ // Does not include `:` or `,` separators. Default values should be specified
+ // here when possible.
+ //
+ // NOTE: We use `decltype($field$)` for both explicit construction and the
+ // fact that it's self-documenting. Pre-C++17, copy elision isn't guaranteed
// in aggregate initialization so a valid copy/move constructor must exist
- // (even though it's not used). Because of this, we need to comment out the
+ // (even though it's not used). Because of this, we need to comment out the
// decltype and fallback to implicit construction.
- virtual void GenerateAggregateInitializer(io::Printer* printer) const;
-
- // Generate constinit initialization code for private members declared by
- // GeneratePrivateMembers(). These go into the constexpr constructor's
- // aggregate initialization of the _impl_ struct and must follow the syntax
- // (e.g. `/*decltype($field$)*/{}`, see above). Does not
- // include `:` or `,` separators.
- virtual void GenerateConstexprAggregateInitializer(
- io::Printer* printer) const;
-
- // Generate copy initialization code for private members declared by
- // GeneratePrivateMembers(). These go into the copy constructor's
- // aggregate initialization of the _impl_ struct and must follow the syntax
- // (e.g. `decltype($field$){from.$field$}`, see above). Does not
- // include `:` or `,` separators.
- virtual void GenerateCopyAggregateInitializer(io::Printer* printer) const;
-
- // Generate lines to serialize this field directly to the array "target",
- // which are placed within the message's SerializeWithCachedSizesToArray()
- // method. This must also advance "target" past the written bytes.
- virtual void GenerateSerializeWithCachedSizesToArray(
- io::Printer* printer) const = 0;
+ void GenerateAggregateInitializer(io::Printer* p) const {
+ auto vars = PushVarsForCall(p);
+ impl_->GenerateAggregateInitializer(p);
+ }
+
+ // Generates constinit initialization code for private members declared by
+ // GeneratePrivateMembers().
+ //
+ // These go into the constexpr constructor's aggregate initialization of the
+ // _impl_ struct and must follow the syntax `/*decltype($field$)*/{}` (see
+ // above). Does not include `:` or `,` separators.
+ void GenerateConstexprAggregateInitializer(io::Printer* p) const {
+ auto vars = PushVarsForCall(p);
+ impl_->GenerateConstexprAggregateInitializer(p);
+ }
+
+ // Generates copy initialization code for private members declared by
+ // GeneratePrivateMembers().
+ //
+ // These go into the copy constructor's aggregate initialization of the _impl_
+ // struct and must follow the syntax `decltype($field$){from.$field$}` (see
+ // above). Does not include `:` or `,` separators.
+ void GenerateCopyAggregateInitializer(io::Printer* p) const {
+ auto vars = PushVarsForCall(p);
+ impl_->GenerateCopyAggregateInitializer(p);
+ }
+
+ // Generates statements to serialize this field directly to the array
+ // `target`, which are placed within the message's
+ // SerializeWithCachedSizesToArray() method.
+ //
+ // This must also advance `target` past the written bytes.
+ void GenerateSerializeWithCachedSizesToArray(io::Printer* p) const {
+ auto vars = PushVarsForCall(p);
+ impl_->GenerateSerializeWithCachedSizesToArray(p);
+ }
- // Generate lines to compute the serialized size of this field, which
+ // Generates statements to compute the serialized size of this field, which
// are placed in the message's ByteSize() method.
- virtual void GenerateByteSize(io::Printer* printer) const = 0;
+ void GenerateByteSize(io::Printer* p) const {
+ auto vars = PushVarsForCall(p);
+ impl_->GenerateByteSize(p);
+ }
// Generates lines to call IsInitialized() for eligible message fields. Non
// message fields won't need to override this function.
- virtual void GenerateIsInitialized(io::Printer* printer) const {}
-
- virtual bool IsInlined() const { return false; }
+ void GenerateIsInitialized(io::Printer* p) const {
+ auto vars = PushVarsForCall(p);
+ impl_->GenerateIsInitialized(p);
+ }
- virtual ArenaDtorNeeds NeedsArenaDestructor() const {
- return ArenaDtorNeeds::kNone;
+ // TODO(b/245791219): Document this properly.
+ void GenerateIfHasField(io::Printer* p) const {
+ auto vars = PushVarsForCall(p);
+ impl_->GenerateIfHasField(p);
}
- void SetHasBitIndex(arc_i32 has_bit_index);
- void SetInlinedStringIndex(arc_i32 inlined_string_index);
+ // TODO(b/245791219): Document this properly.
+ bool IsInlined() const { return impl_->IsInlined(); }
- protected:
- const FieldDescriptor* descriptor_;
- const Options& options_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ // TODO(b/245791219): Document this properly.
+ ArenaDtorNeeds NeedsArenaDestructor() const {
+ return impl_->NeedsArenaDestructor();
+ }
private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGenerator);
+ friend class FieldGeneratorTable;
+ FieldGenerator(const FieldDescriptor* field, const Options& options,
+ MessageSCCAnalyzer* scc_analyzer,
+ y_absl::optional<arc_ui32> hasbit_index,
+ y_absl::optional<arc_ui32> inlined_string_index);
+
+ std::unique_ptr<FieldGeneratorBase> impl_;
+ std::vector<io::Printer::Sub> field_vars_;
+ std::vector<io::Printer::Sub> tracker_vars_;
+ std::vector<io::Printer::Sub> per_generator_vars_;
};
-// Convenience class which constructs FieldGenerators for a Descriptor.
-class FieldGeneratorMap {
+// Convenience class which constructs FieldGeneratorBases for a Descriptor.
+class FieldGeneratorTable {
public:
- FieldGeneratorMap(const Descriptor* descriptor, const Options& options,
- MessageSCCAnalyzer* scc_analyzer);
- ~FieldGeneratorMap();
+ explicit FieldGeneratorTable(const Descriptor* descriptor)
+ : descriptor_(descriptor) {}
- const FieldGenerator& get(const FieldDescriptor* field) const;
+ FieldGeneratorTable(const FieldGeneratorTable&) = delete;
+ FieldGeneratorTable& operator=(const FieldGeneratorTable&) = delete;
- void SetHasBitIndices(const std::vector<int>& has_bit_indices_) {
- for (int i = 0; i < descriptor_->field_count(); ++i) {
- field_generators_[i]->SetHasBitIndex(has_bit_indices_[i]);
- }
- }
+ void Build(const Options& options, MessageSCCAnalyzer* scc_analyzer,
+ y_absl::Span<const arc_i32> has_bit_indices,
+ y_absl::Span<const arc_i32> inlined_string_indices);
- void SetInlinedStringIndices(const std::vector<int>& inlined_string_indices) {
- for (int i = 0; i < descriptor_->field_count(); ++i) {
- field_generators_[i]->SetInlinedStringIndex(inlined_string_indices[i]);
- }
+ const FieldGenerator& get(const FieldDescriptor* field) const {
+ Y_ABSL_CHECK_EQ(field->containing_type(), descriptor_);
+ return fields_[field->index()];
}
private:
const Descriptor* descriptor_;
- std::vector<std::unique_ptr<FieldGenerator>> field_generators_;
-
- static FieldGenerator* MakeGoogleInternalGenerator(
- const FieldDescriptor* field, const Options& options,
- MessageSCCAnalyzer* scc_analyzer);
- static FieldGenerator* MakeGenerator(const FieldDescriptor* field,
- const Options& options,
- MessageSCCAnalyzer* scc_analyzer);
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorMap);
+ std::vector<FieldGenerator> fields_;
};
+// Returns variables common to all fields.
+//
+// TODO(b/245791219): Make this function .cc-private.
+std::vector<io::Printer::Sub> FieldVars(const FieldDescriptor* field,
+ const Options& opts);
} // namespace cpp
} // namespace compiler
} // namespace protobuf
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/enum_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/enum_field.cc
new file mode 100644
index 00000000000..0ee76cb710e
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/enum_field.cc
@@ -0,0 +1,471 @@
+// 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: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#include <memory>
+#include <string>
+#include <tuple>
+#include <vector>
+
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/memory/memory.h"
+#include "y_absl/strings/substitute.h"
+#include "google/protobuf/compiler/cpp/field.h"
+#include "google/protobuf/compiler/cpp/field_generators/generators.h"
+#include "google/protobuf/compiler/cpp/helpers.h"
+#include "google/protobuf/descriptor.pb.h"
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+namespace {
+using Sub = ::google::protobuf::io::Printer::Sub;
+
+std::vector<Sub> Vars(const FieldDescriptor* field, const Options& opts) {
+ const EnumValueDescriptor* default_value = field->default_value_enum();
+ bool split = ShouldSplit(field, opts);
+ bool is_open = internal::cpp::HasPreservingUnknownEnumSemantics(field);
+ auto enum_name = QualifiedClassName(field->enum_type(), opts);
+ return {
+ {"Enum", enum_name},
+ {"kDefault", Int32ToString(default_value->number())},
+ Sub("assert_valid",
+ is_open ? ""
+ : y_absl::Substitute("assert($0_IsValid(value));", enum_name))
+ .WithSuffix(";"),
+
+ {"cached_size_name", MakeVarintCachedSizeName(field)},
+ {"cached_size_", MakeVarintCachedSizeFieldName(field, split)},
+ };
+}
+
+class SingularEnum : public FieldGeneratorBase {
+ public:
+ SingularEnum(const FieldDescriptor* field, const Options& opts)
+ : FieldGeneratorBase(field, opts),
+ field_(field),
+ opts_(&opts),
+ is_oneof_(field->real_containing_oneof() != nullptr) {}
+ ~SingularEnum() override = default;
+
+ std::vector<Sub> MakeVars() const override { return Vars(field_, *opts_); }
+
+ void GeneratePrivateMembers(io::Printer* p) const override {
+ p->Emit(R"cc(
+ int $name$_;
+ )cc");
+ }
+
+ void GenerateClearingCode(io::Printer* p) const override {
+ p->Emit(R"cc(
+ $field_$ = $kDefault$;
+ )cc");
+ }
+
+ void GenerateMergingCode(io::Printer* p) const override {
+ p->Emit(R"cc(
+ _this->_internal_set_$name$(from._internal_$name$());
+ )cc");
+ }
+
+ void GenerateSwappingCode(io::Printer* p) const override {
+ if (is_oneof_) return;
+
+ p->Emit(R"cc(
+ swap($field_$, other->$field_$);
+ )cc");
+ }
+
+ void GenerateConstructorCode(io::Printer* p) const override {
+ if (!is_oneof_) return;
+ p->Emit(R"cc(
+ $ns$::_$Msg$_default_instance_.$field_$ = $kDefault$;
+ )cc");
+ }
+
+ void GenerateCopyConstructorCode(io::Printer* p) const override {
+ p->Emit(R"cc(
+ _this->$field_$ = from.$field_$;
+ )cc");
+ }
+
+ void GenerateSerializeWithCachedSizesToArray(io::Printer* p) const override {
+ p->Emit(R"cc(
+ target = stream->EnsureSpace(target);
+ target = ::_pbi::WireFormatLite::WriteEnumToArray(
+ $number$, this->_internal_$name$(), target);
+ )cc");
+ }
+
+ void GenerateByteSize(io::Printer* p) const override {
+ p->Emit(R"cc(
+ total_size += $kTagBytes$ +
+ ::_pbi::WireFormatLite::EnumSize(this->_internal_$name$());
+ )cc");
+ }
+
+ void GenerateConstexprAggregateInitializer(io::Printer* p) const override {
+ p->Emit(R"cc(
+ /*decltype($field_$)*/ $kDefault$
+ )cc");
+ }
+
+ void GenerateAggregateInitializer(io::Printer* p) const override {
+ if (ShouldSplit(descriptor_, options_)) {
+ p->Emit(R"cc(
+ decltype(Impl_::Split::$name$_) { $kDefault$ }
+ )cc");
+ return;
+ }
+
+ p->Emit(R"cc(
+ decltype($field_$) { $kDefault$ }
+ )cc");
+ }
+
+ void GenerateCopyAggregateInitializer(io::Printer* p) const override {
+ p->Emit(R"cc(
+ decltype($field_$) {}
+ )cc");
+ }
+
+ void GenerateAccessorDeclarations(io::Printer* p) const override;
+ void GenerateInlineAccessorDefinitions(io::Printer* p) const override;
+
+ private:
+ const FieldDescriptor* field_;
+ const Options* opts_;
+ bool is_oneof_;
+};
+
+void SingularEnum::GenerateAccessorDeclarations(io::Printer* p) const {
+ auto v = p->WithVars(
+ AnnotatedAccessors(field_, {"", "set_", "_internal_", "_internal_set_"}));
+ p->Emit(R"cc(
+ $DEPRECATED$ $Enum$ $name$() const;
+ $DEPRECATED$ void $set_name$($Enum$ value);
+
+ private:
+ $Enum$ $_internal_name$() const;
+ void $_internal_set_name$($Enum$ value);
+
+ public:
+ )cc");
+}
+
+void SingularEnum::GenerateInlineAccessorDefinitions(io::Printer* p) const {
+ p->Emit(R"cc(
+ inline $Enum$ $Msg$::$name$() const {
+ $annotate_get$;
+ // @@protoc_insertion_point(field_get:$pkg.Msg.field$)
+ return _internal_$name$();
+ }
+ inline void $Msg$::set_$name$($Enum$ value) {
+ $maybe_prepare_split_message$ _internal_set_$name$(value);
+ $annotate_set$;
+ // @@protoc_insertion_point(field_set:$pkg.Msg.field$)
+ }
+ )cc");
+
+ if (is_oneof_) {
+ p->Emit(R"cc(
+ inline $Enum$ $Msg$::_internal_$name$() const {
+ if ($has_field$) {
+ return static_cast<$Enum$>($field_$);
+ }
+ return static_cast<$Enum$>($kDefault$);
+ }
+ inline void $Msg$::_internal_set_$name$($Enum$ value) {
+ $assert_valid$;
+ if ($not_has_field$) {
+ clear_$oneof_name$();
+ set_has_$name$();
+ }
+ $field_$ = value;
+ }
+ )cc");
+ } else {
+ p->Emit(R"cc(
+ inline $Enum$ $Msg$::_internal_$name$() const {
+ return static_cast<$Enum$>($field_$);
+ }
+ inline void $Msg$::_internal_set_$name$($Enum$ value) {
+ $assert_valid$;
+ $set_hasbit$;
+ $field_$ = value;
+ }
+ )cc");
+ }
+}
+
+class RepeatedEnum : public FieldGeneratorBase {
+ public:
+ RepeatedEnum(const FieldDescriptor* field, const Options& opts)
+ : FieldGeneratorBase(field, opts),
+ field_(field),
+ opts_(&opts),
+ has_cached_size_(field_->is_packed() &&
+ HasGeneratedMethods(field_->file(), opts)) {}
+ ~RepeatedEnum() override = default;
+
+ std::vector<Sub> MakeVars() const override { return Vars(field_, *opts_); }
+
+ void GeneratePrivateMembers(io::Printer* p) const override {
+ p->Emit(R"cc(
+ $pb$::RepeatedField<int> $name$_;
+ )cc");
+
+ if (has_cached_size_) {
+ p->Emit(R"cc(
+ mutable $pbi$::CachedSize $cached_size_name$;
+ )cc");
+ }
+ }
+
+ void GenerateClearingCode(io::Printer* p) const override {
+ p->Emit(R"cc(
+ $field_$.Clear();
+ )cc");
+ }
+
+ void GenerateMergingCode(io::Printer* p) const override {
+ p->Emit(R"cc(
+ _this->$field_$.MergeFrom(from.$field_$);
+ )cc");
+ }
+
+ void GenerateSwappingCode(io::Printer* p) const override {
+ p->Emit(R"cc(
+ $field_$.InternalSwap(&other->$field_$);
+ )cc");
+ }
+
+ void GenerateDestructorCode(io::Printer* p) const override {
+ p->Emit(R"cc(
+ $field_$.~RepeatedField();
+ )cc");
+ }
+
+ void GenerateConstexprAggregateInitializer(io::Printer* p) const override {
+ p->Emit(R"cc(
+ /*decltype($field_$)*/ {}
+ )cc");
+ if (has_cached_size_) {
+ p->Emit(R"cc(
+ , /*decltype($cached_size_$)*/ { 0 }
+ )cc");
+ }
+ }
+
+ void GenerateAggregateInitializer(io::Printer* p) const override {
+ p->Emit(R"cc(
+ decltype($field_$) { arena }
+ )cc");
+ if (has_cached_size_) {
+ // std::atomic has no copy constructor, which prevents explicit aggregate
+ // initialization pre-C++17.
+ p->Emit(R"cc(
+ , /*decltype($cached_size_$)*/ { 0 }
+ )cc");
+ }
+ }
+
+ void GenerateCopyAggregateInitializer(io::Printer* p) const override {
+ p->Emit(R"cc(
+ decltype($field_$) { from.$field_$ })cc");
+ if (has_cached_size_) {
+ // std::atomic has no copy constructor.
+ p->Emit(R"cc(
+ , /*decltype($cached_size_$)*/ { 0 }
+ )cc");
+ }
+ }
+
+ void GenerateCopyConstructorCode(io::Printer* p) const override {
+ Y_ABSL_CHECK(!ShouldSplit(field_, *opts_));
+ }
+
+ void GenerateConstructorCode(io::Printer* p) const override {}
+
+ void GenerateAccessorDeclarations(io::Printer* p) const override;
+ void GenerateInlineAccessorDefinitions(io::Printer* p) const override;
+ void GenerateSerializeWithCachedSizesToArray(io::Printer* p) const override;
+ void GenerateByteSize(io::Printer* p) const override;
+
+ private:
+ const FieldDescriptor* field_;
+ const Options* opts_;
+ bool has_cached_size_;
+};
+
+void RepeatedEnum::GenerateAccessorDeclarations(io::Printer* p) const {
+ auto v = p->WithVars(
+ AnnotatedAccessors(field_, {"", "set_", "add_", "mutable_", "_internal_",
+ "_internal_add_", "_internal_mutable_"}));
+
+ p->Emit(R"cc(
+ public:
+ $DEPRECATED$ $Enum$ $name$(int index) const;
+ $DEPRECATED$ void $set_name$(int index, $Enum$ value);
+ $DEPRECATED$ void $add_name$($Enum$ value);
+ $DEPRECATED$ const $pb$::RepeatedField<int>& $name$() const;
+ $DEPRECATED$ $pb$::RepeatedField<int>* $mutable_name$();
+
+ private:
+ $Enum$ $_internal_name$(int index) const;
+ void $_internal_add_name$($Enum$ value);
+ $pb$::RepeatedField<int>* $_internal_mutable_name$();
+
+ public:
+ )cc");
+}
+
+void RepeatedEnum::GenerateInlineAccessorDefinitions(io::Printer* p) const {
+ p->Emit(R"cc(
+ inline $Enum$ $Msg$::$name$(int index) const {
+ $annotate_get$;
+ // @@protoc_insertion_point(field_get:$pkg.Msg.field$)
+ return _internal_$name$(index);
+ }
+ inline void $Msg$::set_$name$(int index, $Enum$ value) {
+ $assert_valid$;
+ $field_$.Set(index, value);
+ $annotate_set$
+ // @@protoc_insertion_point(field_set:$pkg.Msg.field$)
+ }
+ inline void $Msg$::add_$name$($Enum$ value) {
+ _internal_add_$name$(value);
+ $annotate_add$
+ // @@protoc_insertion_point(field_add:$pkg.Msg.field$)
+ }
+ inline const $pb$::RepeatedField<int>& $Msg$::$name$() const {
+ $annotate_list$;
+ // @@protoc_insertion_point(field_list:$pkg.Msg.field$)
+ return $field_$;
+ }
+ inline $pb$::RepeatedField<int>* $Msg$::mutable_$name$() {
+ $annotate_mutable_list$;
+ // @@protoc_insertion_point(field_mutable_list:$pkg.Msg.field$)
+ return _internal_mutable_$name$();
+ }
+ inline $Enum$ $Msg$::_internal_$name$(int index) const {
+ return static_cast<$Enum$>($field_$.Get(index));
+ }
+ inline void $Msg$::_internal_add_$name$($Enum$ value) {
+ $assert_valid$;
+ $field_$.Add(value);
+ }
+ inline $pb$::RepeatedField<int>* $Msg$::_internal_mutable_$name$() {
+ return &$field_$;
+ }
+ )cc");
+}
+
+void RepeatedEnum::GenerateSerializeWithCachedSizesToArray(
+ io::Printer* p) const {
+ if (field_->is_packed()) {
+ p->Emit(R"cc(
+ {
+ int byte_size = $cached_size_$.Get();
+ if (byte_size > 0) {
+ target = stream->WriteEnumPacked($number$, $field_$, byte_size, target);
+ }
+ }
+ )cc");
+ return;
+ }
+ p->Emit(R"cc(
+ for (int i = 0, n = this->_internal_$name$_size(); i < n; ++i) {
+ target = stream->EnsureSpace(target);
+ target = ::_pbi::WireFormatLite::WriteEnumToArray(
+ $number$, this->_internal_$name$(i), target);
+ }
+ )cc");
+}
+
+void RepeatedEnum::GenerateByteSize(io::Printer* p) const {
+ p->Emit(
+ {
+ {"add_to_size",
+ [&] {
+ if (!field_->is_packed()) {
+ p->Emit(R"cc(
+ total_size += std::size_t{$kTagBytes$} * count;
+ )cc");
+ return;
+ }
+
+ p->Emit(R"cc(
+ if (data_size > 0) {
+ total_size += $kTagBytes$;
+ total_size += ::_pbi::WireFormatLite::Int32Size(
+ static_cast<arc_i32>(data_size));
+ }
+ $cached_size_$.Set(::_pbi::ToCachedSize(data_size));
+ )cc");
+ }},
+ },
+ R"cc(
+ {
+ std::size_t data_size = 0;
+ auto count = static_cast<std::size_t>(this->_internal_$name$_size());
+
+ for (std::size_t i = 0; i < count; ++i) {
+ data_size += ::_pbi::WireFormatLite::EnumSize(
+ this->_internal_$name$(static_cast<int>(i)));
+ }
+ total_size += data_size;
+ $add_to_size$;
+ }
+ )cc");
+}
+} // namespace
+
+std::unique_ptr<FieldGeneratorBase> MakeSinguarEnumGenerator(
+ const FieldDescriptor* desc, const Options& options,
+ MessageSCCAnalyzer* scc) {
+ return y_absl::make_unique<SingularEnum>(desc, options);
+}
+
+std::unique_ptr<FieldGeneratorBase> MakeRepeatedEnumGenerator(
+ const FieldDescriptor* desc, const Options& options,
+ MessageSCCAnalyzer* scc) {
+ return y_absl::make_unique<RepeatedEnum>(desc, options);
+}
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/generators.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/generators.h
new file mode 100644
index 00000000000..c9accc56e71
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/generators.h
@@ -0,0 +1,98 @@
+// 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_CPP_FIELD_GENERATORS_GENERATORS_H__
+#define GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_GENERATORS_GENERATORS_H__
+
+#include <memory>
+
+#include "google/protobuf/compiler/cpp/field.h"
+#include "google/protobuf/compiler/cpp/helpers.h"
+
+// The functions in this file construct FieldGeneratorBase objects for
+// generating different "codegen types" of fields. The logic for selecting the
+// correct choice of generator lives in compiler/cpp/field.cc; this is merely
+// the API that file uses for constructing generators.
+//
+// Functions are of the form `Make<card><kind>Generator()`, where <card> is
+// `Singular`, `Repeated`, or `Oneof`, and <kind> is the field type, plus
+// `MakeMapGenerator()`, since map fields are always repeated message fields.
+//
+// The returned pointers are never null.
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+std::unique_ptr<FieldGeneratorBase> MakeSinguarPrimitiveGenerator(
+ const FieldDescriptor* desc, const Options& options,
+ MessageSCCAnalyzer* scc);
+
+std::unique_ptr<FieldGeneratorBase> MakeRepeatedPrimitiveGenerator(
+ const FieldDescriptor* desc, const Options& options,
+ MessageSCCAnalyzer* scc);
+
+std::unique_ptr<FieldGeneratorBase> MakeSinguarEnumGenerator(
+ const FieldDescriptor* desc, const Options& options,
+ MessageSCCAnalyzer* scc);
+
+std::unique_ptr<FieldGeneratorBase> MakeRepeatedEnumGenerator(
+ const FieldDescriptor* desc, const Options& options,
+ MessageSCCAnalyzer* scc);
+
+std::unique_ptr<FieldGeneratorBase> MakeSinguarStringGenerator(
+ const FieldDescriptor* desc, const Options& options,
+ MessageSCCAnalyzer* scc);
+
+std::unique_ptr<FieldGeneratorBase> MakeRepeatedStringGenerator(
+ const FieldDescriptor* desc, const Options& options,
+ MessageSCCAnalyzer* scc);
+
+std::unique_ptr<FieldGeneratorBase> MakeSinguarMessageGenerator(
+ const FieldDescriptor* desc, const Options& options,
+ MessageSCCAnalyzer* scc);
+
+std::unique_ptr<FieldGeneratorBase> MakeRepeatedMessageGenerator(
+ const FieldDescriptor* desc, const Options& options,
+ MessageSCCAnalyzer* scc);
+
+std::unique_ptr<FieldGeneratorBase> MakeOneofMessageGenerator(
+ const FieldDescriptor* desc, const Options& options,
+ MessageSCCAnalyzer* scc);
+
+std::unique_ptr<FieldGeneratorBase> MakeMapGenerator(
+ const FieldDescriptor* desc, const Options& options,
+ MessageSCCAnalyzer* scc);
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+#endif // GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_GENERATORS_GENERATORS_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/map_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/map_field.cc
index ba363f5267b..2fe5484ab4b 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/map_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/map_field.cc
@@ -28,28 +28,26 @@
// (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/cpp/map_field.h>
-
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/cpp/helpers.h>
+#include <memory>
+#include <string>
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/cpp/field_generators/generators.h"
+#include "google/protobuf/compiler/cpp/helpers.h"
+#include "google/protobuf/wire_format.h"
namespace google {
namespace protobuf {
namespace compiler {
namespace cpp {
-
-bool IsProto3Field(const FieldDescriptor* field_descriptor) {
- const FileDescriptor* file_descriptor = field_descriptor->file();
- return file_descriptor->syntax() == FileDescriptor::SYNTAX_PROTO3;
-}
-
-void SetMessageVariables(const FieldDescriptor* descriptor,
- std::map<TProtoStringType, TProtoStringType>* variables,
- const Options& options) {
- SetCommonFieldVariables(descriptor, variables, options);
+namespace {
+void SetMessageVariables(
+ const FieldDescriptor* descriptor,
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables,
+ const Options& options) {
(*variables)["type"] = ClassName(descriptor->message_type(), false);
(*variables)["full_name"] = descriptor->full_name();
@@ -66,13 +64,13 @@ void SetMessageVariables(const FieldDescriptor* descriptor,
default:
(*variables)["val_cpp"] = PrimitiveTypeName(options, val->cpp_type());
}
- (*variables)["key_wire_type"] =
- "TYPE_" + ToUpper(DeclaredTypeMethodName(key->type()));
- (*variables)["val_wire_type"] =
- "TYPE_" + ToUpper(DeclaredTypeMethodName(val->type()));
+ (*variables)["key_wire_type"] = y_absl::StrCat(
+ "TYPE_", y_absl::AsciiStrToUpper(DeclaredTypeMethodName(key->type())));
+ (*variables)["val_wire_type"] = y_absl::StrCat(
+ "TYPE_", y_absl::AsciiStrToUpper(DeclaredTypeMethodName(val->type())));
(*variables)["map_classname"] = ClassName(descriptor->message_type(), false);
- (*variables)["number"] = StrCat(descriptor->number());
- (*variables)["tag"] = StrCat(internal::WireFormat::MakeTag(descriptor));
+ (*variables)["number"] = y_absl::StrCat(descriptor->number());
+ (*variables)["tag"] = y_absl::StrCat(internal::WireFormat::MakeTag(descriptor));
if (HasDescriptorMethods(descriptor->file(), options)) {
(*variables)["lite"] = "";
@@ -81,17 +79,46 @@ void SetMessageVariables(const FieldDescriptor* descriptor,
}
}
+class MapFieldGenerator : public FieldGeneratorBase {
+ public:
+ MapFieldGenerator(const FieldDescriptor* descriptor, const Options& options,
+ MessageSCCAnalyzer* scc_analyzer);
+ ~MapFieldGenerator() override = default;
+
+ // implements FieldGeneratorBase ---------------------------------------
+ void GeneratePrivateMembers(io::Printer* printer) const override;
+ void GenerateAccessorDeclarations(io::Printer* printer) const override;
+ void GenerateInlineAccessorDefinitions(io::Printer* printer) const override;
+ 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 GenerateSerializeWithCachedSizesToArray(
+ io::Printer* printer) const override;
+ void GenerateByteSize(io::Printer* printer) const override;
+ void GenerateIsInitialized(io::Printer* printer) const override;
+ void GenerateConstexprAggregateInitializer(
+ io::Printer* printer) const override;
+ void GenerateCopyAggregateInitializer(io::Printer* printer) const override;
+ void GenerateAggregateInitializer(io::Printer* printer) const override;
+ void GenerateDestructorCode(io::Printer* printer) const override;
+ void GenerateArenaDestructorCode(io::Printer* printer) const override;
+ ArenaDtorNeeds NeedsArenaDestructor() const override;
+
+ private:
+ bool has_required_fields_;
+};
+
MapFieldGenerator::MapFieldGenerator(const FieldDescriptor* descriptor,
const Options& options,
MessageSCCAnalyzer* scc_analyzer)
- : FieldGenerator(descriptor, options),
+ : FieldGeneratorBase(descriptor, options),
has_required_fields_(
scc_analyzer->HasRequiredFields(descriptor->message_type())) {
SetMessageVariables(descriptor, &variables_, options);
}
-MapFieldGenerator::~MapFieldGenerator() {}
-
void MapFieldGenerator::GeneratePrivateMembers(io::Printer* printer) const {
Formatter format(printer, variables_);
format(
@@ -303,8 +330,6 @@ void MapFieldGenerator::GenerateAggregateInitializer(
}
void MapFieldGenerator::GenerateDestructorCode(io::Printer* printer) const {
- GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
-
Formatter format(printer, variables_);
if (ShouldSplit(descriptor_, options_)) {
format("$cached_split_ptr$->$name$_.Destruct();\n");
@@ -331,6 +356,13 @@ ArenaDtorNeeds MapFieldGenerator::NeedsArenaDestructor() const {
? ArenaDtorNeeds::kRequired
: ArenaDtorNeeds::kNone;
}
+} // namespace
+
+std::unique_ptr<FieldGeneratorBase> MakeMapGenerator(
+ const FieldDescriptor* desc, const Options& options,
+ MessageSCCAnalyzer* scc) {
+ return std::make_unique<MapFieldGenerator>(desc, options, scc);
+}
} // namespace cpp
} // namespace compiler
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/message_field.cc
index 9a91fd91720..49e86d936bf 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/message_field.cc
@@ -32,52 +32,63 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/cpp/message_field.h>
-
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/compiler/cpp/field.h>
-#include <google/protobuf/compiler/cpp/helpers.h>
-
-#include <google/protobuf/stubs/strutil.h>
+#include <memory>
+#include <string>
+#include <tuple>
+
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/memory/memory.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/cpp/field.h"
+#include "google/protobuf/compiler/cpp/field_generators/generators.h"
+#include "google/protobuf/compiler/cpp/helpers.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
namespace compiler {
namespace cpp {
-
namespace {
-TProtoStringType ReinterpretCast(const TProtoStringType& type,
- const TProtoStringType& expression,
+TProtoStringType ReinterpretCast(y_absl::string_view type,
+ y_absl::string_view expression,
bool implicit_weak_field) {
if (implicit_weak_field) {
- return "reinterpret_cast< " + type + " >(" + expression + ")";
+ return y_absl::StrCat("reinterpret_cast< ", type, " >(", expression, ")");
} else {
- return expression;
+ return TProtoStringType(expression);
}
}
-void SetMessageVariables(const FieldDescriptor* descriptor,
- const Options& options, bool implicit_weak,
- std::map<TProtoStringType, TProtoStringType>* variables) {
- SetCommonFieldVariables(descriptor, variables, options);
+void SetMessageVariables(
+ const FieldDescriptor* descriptor, const Options& options,
+ bool implicit_weak,
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables) {
+ bool split = ShouldSplit(descriptor, options);
+ TProtoStringType field_name = FieldMemberName(descriptor, split);
+
(*variables)["type"] = FieldMessageTypeName(descriptor, options);
- (*variables)["casted_member"] = ReinterpretCast(
- (*variables)["type"] + "*", (*variables)["field"], implicit_weak);
- (*variables)["casted_member_const"] =
- ReinterpretCast("const " + (*variables)["type"] + "&",
- "*" + (*variables)["field"], implicit_weak);
+ variables->insert(
+ {"casted_member", ReinterpretCast(y_absl::StrCat((*variables)["type"], "*"),
+ field_name, implicit_weak)});
+ variables->insert(
+ {"casted_member_const",
+ ReinterpretCast(y_absl::StrCat("const ", (*variables)["type"], "&"),
+ y_absl::StrCat("*", field_name), implicit_weak)});
(*variables)["type_default_instance"] =
QualifiedDefaultInstanceName(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 " +
- (*variables)["type"] + "&>(\n" +
- (*variables)["type_default_instance"] + "));\n")
- : "";
+ variables->insert(
+ {"type_reference_function",
+ implicit_weak
+ ? y_absl::StrCat(" ::", ProtobufNamespace(options),
+ "::internal::StrongReference(reinterpret_cast<const ",
+ (*variables)["type"], "&>(\n",
+ (*variables)["type_default_instance"], "));\n")
+ : ""});
// NOTE: Escaped here to unblock proto1->proto2 migration.
// TODO(liujisi): Extend this to apply for other conflicting methods.
(*variables)["release_name"] =
@@ -85,14 +96,92 @@ void SetMessageVariables(const FieldDescriptor* descriptor,
(*variables)["full_name"] = descriptor->full_name();
}
-} // namespace
+class MessageFieldGenerator : public FieldGeneratorBase {
+ public:
+ MessageFieldGenerator(const FieldDescriptor* descriptor,
+ const Options& options,
+ MessageSCCAnalyzer* scc_analyzer);
+ ~MessageFieldGenerator() override = default;
+
+ void GeneratePrivateMembers(io::Printer* printer) const override;
+ void GenerateAccessorDeclarations(io::Printer* printer) const override;
+ void GenerateInlineAccessorDefinitions(io::Printer* printer) const override;
+ void GenerateNonInlineAccessorDefinitions(
+ io::Printer* printer) const override;
+ void GenerateInternalAccessorDeclarations(
+ io::Printer* printer) const override;
+ void GenerateInternalAccessorDefinitions(io::Printer* printer) const override;
+ void GenerateClearingCode(io::Printer* printer) const override;
+ void GenerateMessageClearingCode(io::Printer* printer) const override;
+ void GenerateMergingCode(io::Printer* printer) const override;
+ void GenerateSwappingCode(io::Printer* printer) const override;
+ void GenerateDestructorCode(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;
+ void GenerateIsInitialized(io::Printer* printer) const override;
+ void GenerateConstexprAggregateInitializer(
+ io::Printer* printer) const override;
+ void GenerateAggregateInitializer(io::Printer* printer) const override;
+ void GenerateCopyAggregateInitializer(io::Printer* printer) const override;
+
+ protected:
+ bool implicit_weak_field_;
+ bool has_required_fields_;
+};
+
+class MessageOneofFieldGenerator : public MessageFieldGenerator {
+ public:
+ MessageOneofFieldGenerator(const FieldDescriptor* descriptor,
+ const Options& options,
+ MessageSCCAnalyzer* scc_analyzer);
+ ~MessageOneofFieldGenerator() override = default;
+
+ void GenerateInlineAccessorDefinitions(io::Printer* printer) const override;
+ void GenerateNonInlineAccessorDefinitions(
+ io::Printer* printer) const override;
+ void GenerateClearingCode(io::Printer* printer) const override;
+ void GenerateMessageClearingCode(io::Printer* printer) const override;
+ void GenerateSwappingCode(io::Printer* printer) const override;
+ void GenerateDestructorCode(io::Printer* printer) const override;
+ void GenerateConstructorCode(io::Printer* printer) const override;
+ void GenerateIsInitialized(io::Printer* printer) const override;
+};
+
+class RepeatedMessageFieldGenerator : public FieldGeneratorBase {
+ public:
+ RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor,
+ const Options& options,
+ MessageSCCAnalyzer* scc_analyzer);
+ ~RepeatedMessageFieldGenerator() override = default;
+
+ void GeneratePrivateMembers(io::Printer* printer) const override;
+ void GenerateAccessorDeclarations(io::Printer* printer) const override;
+ void GenerateInlineAccessorDefinitions(io::Printer* printer) const override;
+ 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 GenerateDestructorCode(io::Printer* printer) const override;
+ void GenerateSerializeWithCachedSizesToArray(
+ io::Printer* printer) const override;
+ void GenerateByteSize(io::Printer* printer) const override;
+ void GenerateIsInitialized(io::Printer* printer) const override;
+
+ private:
+ bool implicit_weak_field_;
+ bool has_required_fields_;
+};
// ===================================================================
MessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor,
const Options& options,
MessageSCCAnalyzer* scc_analyzer)
- : FieldGenerator(descriptor, options),
+ : FieldGeneratorBase(descriptor, options),
implicit_weak_field_(
IsImplicitWeakField(descriptor, options, scc_analyzer)),
has_required_fields_(
@@ -100,8 +189,6 @@ MessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor,
SetMessageVariables(descriptor, options, implicit_weak_field_, &variables_);
}
-MessageFieldGenerator::~MessageFieldGenerator() {}
-
void MessageFieldGenerator::GeneratePrivateMembers(io::Printer* printer) const {
Formatter format(printer, variables_);
if (implicit_weak_field_) {
@@ -114,41 +201,21 @@ void MessageFieldGenerator::GeneratePrivateMembers(io::Printer* printer) const {
void MessageFieldGenerator::GenerateAccessorDeclarations(
io::Printer* printer) const {
Formatter format(printer, variables_);
- if (IsFieldStripped(descriptor_, options_)) {
- format(
- "$deprecated_attr$const $type$& ${1$$name$$}$() const { "
- "__builtin_trap(); }\n"
- "PROTOBUF_NODISCARD $deprecated_attr$$type$* "
- "${1$$release_name$$}$() { "
- "__builtin_trap(); }\n"
- "$deprecated_attr$$type$* ${1$mutable_$name$$}$() { "
- "__builtin_trap(); }\n"
- "$deprecated_attr$void ${1$set_allocated_$name$$}$"
- "($type$* $name$) { __builtin_trap(); }\n"
- "$deprecated_attr$void "
- "${1$unsafe_arena_set_allocated_$name$$}$(\n"
- " $type$* $name$) { __builtin_trap(); }\n"
- "$deprecated_attr$$type$* ${1$unsafe_arena_release_$name$$}$() { "
- "__builtin_trap(); }\n",
- descriptor_);
- return;
- }
format(
"$deprecated_attr$const $type$& ${1$$name$$}$() const;\n"
"PROTOBUF_NODISCARD $deprecated_attr$$type$* "
- "${1$$release_name$$}$();\n"
- "$deprecated_attr$$type$* ${1$mutable_$name$$}$();\n"
+ "${1$$release_name$$}$();\n",
+ descriptor_);
+ format("$deprecated_attr$$type$* ${1$mutable_$name$$}$();\n",
+ std::make_tuple(descriptor_, GeneratedCodeInfo::Annotation::ALIAS));
+ format(
"$deprecated_attr$void ${1$set_allocated_$name$$}$"
- "($type$* $name$);\n",
+ "($type$* $name$);\n"
+ "private:\n"
+ "const $type$& ${1$_internal_$name$$}$() const;\n"
+ "$type$* ${1$_internal_mutable_$name$$}$();\n"
+ "public:\n",
descriptor_);
- if (!IsFieldStripped(descriptor_, options_)) {
- format(
- "private:\n"
- "const $type$& ${1$_internal_$name$$}$() const;\n"
- "$type$* ${1$_internal_mutable_$name$$}$();\n"
- "public:\n",
- descriptor_);
- }
format(
"$deprecated_attr$void "
"${1$unsafe_arena_set_allocated_$name$$}$(\n"
@@ -191,12 +258,15 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
} else {
format(" $field$ = $name$;\n");
}
+ if (internal::cpp::HasHasbit(descriptor_)) {
+ format(
+ " if ($name$) {\n"
+ " $set_hasbit$\n"
+ " } else {\n"
+ " $clear_hasbit$\n"
+ " }\n");
+ }
format(
- " if ($name$) {\n"
- " $set_hasbit$\n"
- " } else {\n"
- " $clear_hasbit$\n"
- " }\n"
"$annotate_set$"
" // @@protoc_insertion_point(field_unsafe_arena_set_allocated"
":$full_name$)\n"
@@ -343,14 +413,14 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions(
format(
"::$proto_ns$::MessageLite*\n"
"$classname$::_Internal::mutable_$name$($classname$* msg) {\n");
- if (HasHasbit(descriptor_)) {
+ if (internal::cpp::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"
+ " if (msg->$not_has_field$) {\n"
" msg->clear_$oneof_name$();\n"
" msg->set_has_$name$();\n");
}
@@ -373,10 +443,8 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions(
}
void MessageFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
- GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
-
Formatter format(printer, variables_);
- if (!HasHasbit(descriptor_)) {
+ if (!internal::cpp::HasHasbit(descriptor_)) {
// If we don't have has-bits, message presence is indicated only by ptr !=
// nullptr. Thus on clear, we need to delete the object.
format(
@@ -391,10 +459,8 @@ void MessageFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
void MessageFieldGenerator::GenerateMessageClearingCode(
io::Printer* printer) const {
- GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
-
Formatter format(printer, variables_);
- if (!HasHasbit(descriptor_)) {
+ if (!internal::cpp::HasHasbit(descriptor_)) {
// If we don't have has-bits, message presence is indicated only by ptr !=
// nullptr. Thus on clear, we need to delete the object.
format(
@@ -410,8 +476,6 @@ void MessageFieldGenerator::GenerateMessageClearingCode(
}
void MessageFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
- GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
-
Formatter format(printer, variables_);
if (implicit_weak_field_) {
format(
@@ -425,15 +489,11 @@ void MessageFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
}
void MessageFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
- GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
-
Formatter format(printer, variables_);
format("swap($field$, other->$field$);\n");
}
void MessageFieldGenerator::GenerateDestructorCode(io::Printer* printer) const {
- GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
-
Formatter format(printer, variables_);
if (options_.opensource_runtime) {
// TODO(gerbens) Remove this when we don't need to destruct default
@@ -450,21 +510,26 @@ void MessageFieldGenerator::GenerateDestructorCode(io::Printer* printer) const {
format("delete $field$;\n");
}
+using internal::cpp::HasHasbit;
+
void MessageFieldGenerator::GenerateCopyConstructorCode(
io::Printer* printer) const {
- GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
-
Formatter format(printer, variables_);
- format(
- "if (from._internal_has_$name$()) {\n"
- " _this->$field$ = new $type$(*from.$field$);\n"
- "}\n");
+ if (HasHasbit(descriptor_)) {
+ format(
+ "if ((from.$has_hasbit$) != 0) {\n"
+ " _this->$field$ = new $type$(*from.$field$);\n"
+ "}\n");
+ } else {
+ format(
+ "if (from._internal_has_$name$()) {\n"
+ " _this->$field$ = new $type$(*from.$field$);\n"
+ "}\n");
+ }
}
void MessageFieldGenerator::GenerateSerializeWithCachedSizesToArray(
io::Printer* printer) const {
- GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
-
Formatter format(printer, variables_);
if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) {
format(
@@ -481,8 +546,6 @@ void MessageFieldGenerator::GenerateSerializeWithCachedSizesToArray(
}
void MessageFieldGenerator::GenerateByteSize(io::Printer* printer) const {
- GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
-
Formatter format(printer, variables_);
format(
"total_size += $tag_size$ +\n"
@@ -491,15 +554,20 @@ void MessageFieldGenerator::GenerateByteSize(io::Printer* printer) const {
}
void MessageFieldGenerator::GenerateIsInitialized(io::Printer* printer) const {
- GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
-
if (!has_required_fields_) return;
Formatter format(printer, variables_);
- format(
- "if (_internal_has_$name$()) {\n"
- " if (!$field$->IsInitialized()) return false;\n"
- "}\n");
+ if (HasHasbit(descriptor_)) {
+ format(
+ "if (($has_hasbit$) != 0) {\n"
+ " if (!$field$->IsInitialized()) return false;\n"
+ "}\n");
+ } else {
+ format(
+ "if (_internal_has_$name$()) {\n"
+ " if (!$field$->IsInitialized()) return false;\n"
+ "}\n");
+ }
}
void MessageFieldGenerator::GenerateConstexprAggregateInitializer(
@@ -530,11 +598,8 @@ MessageOneofFieldGenerator::MessageOneofFieldGenerator(
const FieldDescriptor* descriptor, const Options& options,
MessageSCCAnalyzer* scc_analyzer)
: MessageFieldGenerator(descriptor, options, scc_analyzer) {
- SetCommonOneofFieldVariables(descriptor, &variables_);
}
-MessageOneofFieldGenerator::~MessageOneofFieldGenerator() {}
-
void MessageOneofFieldGenerator::GenerateNonInlineAccessorDefinitions(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -577,7 +642,7 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions(
"$annotate_release$"
" // @@protoc_insertion_point(field_release:$full_name$)\n"
"$type_reference_function$"
- " if (_internal_has_$name$()) {\n"
+ " if ($has_field$) {\n"
" clear_has_$oneof_name$();\n"
" $type$* temp = $casted_member$;\n"
" if (GetArenaForAllocation() != nullptr) {\n"
@@ -593,7 +658,7 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions(
format(
"inline const $type$& $classname$::_internal_$name$() const {\n"
"$type_reference_function$"
- " return _internal_has_$name$()\n"
+ " return $has_field$\n"
" ? $casted_member_const$\n"
" : reinterpret_cast< $type$&>($type_default_instance$);\n"
"}\n"
@@ -607,7 +672,7 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" // @@protoc_insertion_point(field_unsafe_arena_release"
":$full_name$)\n"
"$type_reference_function$"
- " if (_internal_has_$name$()) {\n"
+ " if ($has_field$) {\n"
" clear_has_$oneof_name$();\n"
" $type$* temp = $casted_member$;\n"
" $field$ = nullptr;\n"
@@ -639,7 +704,7 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions(
"}\n"
"inline $type$* $classname$::_internal_mutable_$name$() {\n"
"$type_reference_function$"
- " if (!_internal_has_$name$()) {\n"
+ " if ($not_has_field$) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n");
if (implicit_weak_field_) {
@@ -666,8 +731,6 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions(
void MessageOneofFieldGenerator::GenerateClearingCode(
io::Printer* printer) const {
- GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
-
Formatter format(printer, variables_);
format(
"if (GetArenaForAllocation() == nullptr) {\n"
@@ -703,7 +766,7 @@ void MessageOneofFieldGenerator::GenerateIsInitialized(
Formatter format(printer, variables_);
format(
- "if (_internal_has_$name$()) {\n"
+ "if ($has_field$) {\n"
" if (!$field$->IsInitialized()) return false;\n"
"}\n");
}
@@ -713,7 +776,7 @@ void MessageOneofFieldGenerator::GenerateIsInitialized(
RepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator(
const FieldDescriptor* descriptor, const Options& options,
MessageSCCAnalyzer* scc_analyzer)
- : FieldGenerator(descriptor, options),
+ : FieldGeneratorBase(descriptor, options),
implicit_weak_field_(
IsImplicitWeakField(descriptor, options, scc_analyzer)),
has_required_fields_(
@@ -721,8 +784,6 @@ RepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator(
SetMessageVariables(descriptor, options, implicit_weak_field_, &variables_);
}
-RepeatedMessageFieldGenerator::~RepeatedMessageFieldGenerator() {}
-
void RepeatedMessageFieldGenerator::GeneratePrivateMembers(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -736,34 +797,18 @@ void RepeatedMessageFieldGenerator::GeneratePrivateMembers(
void RepeatedMessageFieldGenerator::GenerateAccessorDeclarations(
io::Printer* printer) const {
Formatter format(printer, variables_);
- if (IsFieldStripped(descriptor_, options_)) {
- format(
- "$deprecated_attr$$type$* ${1$mutable_$name$$}$(int index) { "
- "__builtin_trap(); }\n"
- "$deprecated_attr$::$proto_ns$::RepeatedPtrField< $type$ >*\n"
- " ${1$mutable_$name$$}$() { __builtin_trap(); }\n"
- "$deprecated_attr$const $type$& ${1$$name$$}$(int index) const { "
- "__builtin_trap(); }\n"
- "$deprecated_attr$$type$* ${1$add_$name$$}$() { "
- "__builtin_trap(); }\n"
- "$deprecated_attr$const ::$proto_ns$::RepeatedPtrField< $type$ >&\n"
- " ${1$$name$$}$() const { __builtin_trap(); }\n",
- descriptor_);
- return;
- }
+ format("$deprecated_attr$$type$* ${1$mutable_$name$$}$(int index);\n",
+ std::make_tuple(descriptor_, GeneratedCodeInfo::Annotation::ALIAS));
format(
- "$deprecated_attr$$type$* ${1$mutable_$name$$}$(int index);\n"
"$deprecated_attr$::$proto_ns$::RepeatedPtrField< $type$ >*\n"
" ${1$mutable_$name$$}$();\n",
+ std::make_tuple(descriptor_, GeneratedCodeInfo::Annotation::ALIAS));
+ format(
+ "private:\n"
+ "const $type$& ${1$_internal_$name$$}$(int index) const;\n"
+ "$type$* ${1$_internal_add_$name$$}$();\n"
+ "public:\n",
descriptor_);
- if (!IsFieldStripped(descriptor_, options_)) {
- format(
- "private:\n"
- "const $type$& ${1$_internal_$name$$}$(int index) const;\n"
- "$type$* ${1$_internal_add_$name$$}$();\n"
- "public:\n",
- descriptor_);
- }
format(
"$deprecated_attr$const $type$& ${1$$name$$}$(int index) const;\n"
"$deprecated_attr$$type$* ${1$add_$name$$}$();\n"
@@ -837,24 +882,18 @@ void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions(
void RepeatedMessageFieldGenerator::GenerateClearingCode(
io::Printer* printer) const {
- GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
-
Formatter format(printer, variables_);
format("$field$.Clear();\n");
}
void RepeatedMessageFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
- GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
-
Formatter format(printer, variables_);
format("_this->$field$.MergeFrom(from.$field$);\n");
}
void RepeatedMessageFieldGenerator::GenerateSwappingCode(
io::Printer* printer) const {
- GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
-
Formatter format(printer, variables_);
format("$field$.InternalSwap(&other->$field$);\n");
}
@@ -866,8 +905,6 @@ void RepeatedMessageFieldGenerator::GenerateConstructorCode(
void RepeatedMessageFieldGenerator::GenerateDestructorCode(
io::Printer* printer) const {
- GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
-
Formatter format(printer, variables_);
if (implicit_weak_field_) {
format("$field$.~WeakRepeatedPtrField();\n");
@@ -878,8 +915,6 @@ void RepeatedMessageFieldGenerator::GenerateDestructorCode(
void RepeatedMessageFieldGenerator::GenerateSerializeWithCachedSizesToArray(
io::Printer* printer) const {
- GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
-
Formatter format(printer, variables_);
if (implicit_weak_field_) {
format(
@@ -923,8 +958,6 @@ void RepeatedMessageFieldGenerator::GenerateSerializeWithCachedSizesToArray(
void RepeatedMessageFieldGenerator::GenerateByteSize(
io::Printer* printer) const {
- GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
-
Formatter format(printer, variables_);
format(
"total_size += $tag_size$UL * this->_internal_$name$_size();\n"
@@ -936,8 +969,6 @@ void RepeatedMessageFieldGenerator::GenerateByteSize(
void RepeatedMessageFieldGenerator::GenerateIsInitialized(
io::Printer* printer) const {
- GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
-
if (!has_required_fields_) return;
Formatter format(printer, variables_);
@@ -951,6 +982,25 @@ void RepeatedMessageFieldGenerator::GenerateIsInitialized(
" return false;\n");
}
}
+} // namespace
+
+std::unique_ptr<FieldGeneratorBase> MakeSinguarMessageGenerator(
+ const FieldDescriptor* desc, const Options& options,
+ MessageSCCAnalyzer* scc) {
+ return y_absl::make_unique<MessageFieldGenerator>(desc, options, scc);
+}
+
+std::unique_ptr<FieldGeneratorBase> MakeRepeatedMessageGenerator(
+ const FieldDescriptor* desc, const Options& options,
+ MessageSCCAnalyzer* scc) {
+ return y_absl::make_unique<RepeatedMessageFieldGenerator>(desc, options, scc);
+}
+
+std::unique_ptr<FieldGeneratorBase> MakeOneofMessageGenerator(
+ const FieldDescriptor* desc, const Options& options,
+ MessageSCCAnalyzer* scc) {
+ return y_absl::make_unique<MessageOneofFieldGenerator>(desc, options, scc);
+}
} // namespace cpp
} // namespace compiler
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/primitive_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/primitive_field.cc
new file mode 100644
index 00000000000..9b5659fc023
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/primitive_field.cc
@@ -0,0 +1,582 @@
+// 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: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#include <memory>
+#include <string>
+#include <tuple>
+#include <vector>
+
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/memory/memory.h"
+#include "y_absl/types/optional.h"
+#include "google/protobuf/compiler/cpp/field_generators/generators.h"
+#include "google/protobuf/compiler/cpp/helpers.h"
+#include "google/protobuf/compiler/cpp/options.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/printer.h"
+#include "google/protobuf/wire_format.h"
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+namespace {
+using ::google::protobuf::internal::WireFormat;
+using ::google::protobuf::internal::WireFormatLite;
+using Sub = ::google::protobuf::io::Printer::Sub;
+using Annotation = ::google::protobuf::GeneratedCodeInfo::Annotation;
+
+// For encodings with fixed sizes, returns that size in bytes.
+y_absl::optional<size_t> FixedSize(FieldDescriptor::Type type) {
+ switch (type) {
+ case FieldDescriptor::TYPE_INT32:
+ case FieldDescriptor::TYPE_INT64:
+ case FieldDescriptor::TYPE_UINT32:
+ case FieldDescriptor::TYPE_UINT64:
+ case FieldDescriptor::TYPE_SINT32:
+ case FieldDescriptor::TYPE_SINT64:
+ case FieldDescriptor::TYPE_ENUM:
+ case FieldDescriptor::TYPE_STRING:
+ case FieldDescriptor::TYPE_BYTES:
+ case FieldDescriptor::TYPE_GROUP:
+ case FieldDescriptor::TYPE_MESSAGE:
+ return y_absl::nullopt;
+
+ case FieldDescriptor::TYPE_FIXED32:
+ return WireFormatLite::kFixed32Size;
+ case FieldDescriptor::TYPE_FIXED64:
+ return WireFormatLite::kFixed64Size;
+ case FieldDescriptor::TYPE_SFIXED32:
+ return WireFormatLite::kSFixed32Size;
+ case FieldDescriptor::TYPE_SFIXED64:
+ return WireFormatLite::kSFixed64Size;
+ case FieldDescriptor::TYPE_FLOAT:
+ return WireFormatLite::kFloatSize;
+ case FieldDescriptor::TYPE_DOUBLE:
+ return WireFormatLite::kDoubleSize;
+ case FieldDescriptor::TYPE_BOOL:
+ return WireFormatLite::kBoolSize;
+
+ // No default because we want the compiler to complain if any new
+ // types are added.
+ }
+
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
+ return y_absl::nullopt;
+}
+
+std::vector<Sub> Vars(const FieldDescriptor* field, const Options& options) {
+ bool cold = ShouldSplit(field, options);
+ return {
+ {"Type", PrimitiveTypeName(options, field->cpp_type())},
+ {"kDefault", DefaultValue(options, field)},
+ {"_field_cached_byte_size_", MakeVarintCachedSizeFieldName(field, cold)},
+ };
+}
+
+class SingularPrimitive final : public FieldGeneratorBase {
+ public:
+ SingularPrimitive(const FieldDescriptor* field, const Options& opts)
+ : FieldGeneratorBase(field, opts),
+ field_(field),
+ opts_(&opts),
+ is_oneof_(field_->real_containing_oneof() != nullptr) {}
+ ~SingularPrimitive() override = default;
+
+ std::vector<Sub> MakeVars() const override { return Vars(field_, *opts_); }
+
+ void GeneratePrivateMembers(io::Printer* p) const override {
+ p->Emit(R"cc(
+ $Type$ $name$_;
+ )cc");
+ }
+
+ void GenerateClearingCode(io::Printer* p) const override {
+ p->Emit(R"cc(
+ $field_$ = $kDefault$;
+ )cc");
+ }
+
+ void GenerateMergingCode(io::Printer* p) const override {
+ p->Emit(R"cc(
+ _this->_internal_set_$name$(from._internal_$name$());
+ )cc");
+ }
+
+ void GenerateSwappingCode(io::Printer* p) const override {
+ if (is_oneof_) {
+ // Don't print any swapping code. Swapping the union will swap this field.
+ return;
+ }
+
+ p->Emit(R"cc(
+ //~ A `using std::swap;` is already present in this function.
+ swap($field_$, other->$field_$);
+ )cc");
+ }
+
+ void GenerateConstructorCode(io::Printer* p) const override {
+ if (!is_oneof_) {
+ return;
+ }
+
+ p->Emit(R"cc(
+ $pkg$::_$Msg$_default_instance_.$field_$ = $kDefault$;
+ )cc");
+ }
+
+ void GenerateCopyConstructorCode(io::Printer* p) const override {
+ p->Emit(R"cc(
+ _this->$field_$ = from.$field_$;
+ )cc");
+ }
+
+ void GenerateConstexprAggregateInitializer(io::Printer* p) const override {
+ p->Emit(R"cc(
+ /*decltype($field_$)*/ $kDefault$
+ )cc");
+ }
+
+ void GenerateAggregateInitializer(io::Printer* p) const override {
+ p->Emit(R"cc(
+ decltype($field_$) { $kDefault$ }
+ )cc");
+ }
+
+ void GenerateCopyAggregateInitializer(io::Printer* p) const override {
+ p->Emit(R"cc(
+ decltype($field_$) {}
+ )cc");
+ }
+
+ void GenerateAccessorDeclarations(io::Printer* p) const override;
+ void GenerateInlineAccessorDefinitions(io::Printer* p) const override;
+ void GenerateSerializeWithCachedSizesToArray(io::Printer* p) const override;
+ void GenerateByteSize(io::Printer* p) const override;
+
+ private:
+ const FieldDescriptor* field_;
+ const Options* opts_;
+ bool is_oneof_;
+};
+
+void SingularPrimitive::GenerateAccessorDeclarations(io::Printer* p) const {
+ p->Emit(
+ {
+ Sub("name", p->LookupVar("name")).AnnotatedAs(field_),
+ Sub("set_name", y_absl::StrCat("set_", p->LookupVar("name")))
+ .AnnotatedAs(field_),
+ Sub("_internal_name",
+ y_absl::StrCat("_internal_", p->LookupVar("name")))
+ .AnnotatedAs(field_),
+ Sub("_internal_set_name",
+ y_absl::StrCat("_internal_set_", p->LookupVar("name")))
+ .AnnotatedAs(field_),
+ },
+ R"cc(
+ $DEPRECATED$ $Type$ $name$() const;
+ $DEPRECATED$ void $set_name$($Type$ value);
+
+ private:
+ $Type$ $_internal_name$() const;
+ void $_internal_set_name$($Type$ value);
+
+ public:
+ )cc");
+}
+
+void SingularPrimitive::GenerateInlineAccessorDefinitions(
+ io::Printer* p) const {
+ p->Emit(R"cc(
+ inline $Type$ $Msg$::$name$() const {
+ $annotate_get$;
+ // @@protoc_insertion_point(field_get:$pkg.Msg.field$)
+ return _internal_$name$();
+ }
+ inline void $Msg$::set_$name$($Type$ value) {
+ $PrepareSplitMessageForWrite$;
+ _internal_set_$name$(value);
+ $annotate_set$;
+ // @@protoc_insertion_point(field_set:$pkg.Msg.field$)
+ }
+ )cc");
+
+ if (is_oneof_) {
+ p->Emit(R"cc(
+ inline $Type$ $Msg$::_internal_$name$() const {
+ if ($has_field$) {
+ return $field_$;
+ }
+ return $kDefault$;
+ }
+ inline void $Msg$::_internal_set_$name$($Type$ value) {
+ if ($not_has_field$) {
+ clear_$oneof_name$();
+ set_has_$name$();
+ }
+ $field_$ = value;
+ }
+ )cc");
+ } else {
+ p->Emit(R"cc(
+ inline $Type$ $Msg$::_internal_$name$() const {
+ return $field_$;
+ }
+ inline void $Msg$::_internal_set_$name$($Type$ value) {
+ $set_hasbit$;
+ $field_$ = value;
+ }
+ )cc");
+ }
+}
+
+void SingularPrimitive::GenerateSerializeWithCachedSizesToArray(
+ io::Printer* p) const {
+ p->Emit(R"cc(
+ target = stream->EnsureSpace(target);
+ target = ::_pbi::WireFormatLite::Write$DeclaredType$ToArray(
+ $number$, this->_internal_$name$(), target);
+ )cc");
+}
+
+void SingularPrimitive::GenerateByteSize(io::Printer* p) const {
+ size_t tag_size = WireFormat::TagSize(field_->number(), field_->type());
+
+ auto fixed_size = FixedSize(field_->type());
+ if (fixed_size.has_value()) {
+ p->Emit({{"kFixedBytes", tag_size + *fixed_size}}, R"cc(
+ total_size += $kFixedBytes$;
+ )cc");
+ return;
+ }
+
+ // 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.
+ if (tag_size == 1) {
+ p->Emit(R"cc(
+ total_size += ::_pbi::WireFormatLite::$DeclaredType$SizePlusOne(
+ this->_internal_$name$());
+ )cc");
+ return;
+ }
+
+ p->Emit(R"cc(
+ total_size += $kTagBytes$ + ::_pbi::WireFormatLite::$DeclaredType$Size(
+ this->_internal_$name$());
+ )cc");
+}
+
+class RepeatedPrimitive final : public FieldGeneratorBase {
+ public:
+ RepeatedPrimitive(const FieldDescriptor* field, const Options& opts)
+ : FieldGeneratorBase(field, opts), field_(field), opts_(&opts) {}
+ ~RepeatedPrimitive() override = default;
+
+ std::vector<Sub> MakeVars() const override { return Vars(field_, *opts_); }
+
+ void GenerateClearingCode(io::Printer* p) const override {
+ p->Emit(R"cc(
+ $field_$.Clear();
+ )cc");
+ }
+
+ void GenerateMergingCode(io::Printer* p) const override {
+ p->Emit(R"cc(
+ _this->$field_$.MergeFrom(from.$field_$);
+ )cc");
+ }
+
+ void GenerateSwappingCode(io::Printer* p) const override {
+ p->Emit(R"cc(
+ $field_$.InternalSwap(&other->$field_$);
+ )cc");
+ }
+
+ void GenerateDestructorCode(io::Printer* p) const override {
+ p->Emit(R"cc(
+ $field_$.~RepeatedField();
+ )cc");
+ }
+
+ void GenerateConstructorCode(io::Printer* p) const override {}
+
+ void GenerateCopyConstructorCode(io::Printer* p) const override {
+ Y_ABSL_CHECK(!ShouldSplit(field_, *opts_));
+ }
+
+ void GenerateConstexprAggregateInitializer(io::Printer* p) const override {
+ p->Emit(R"cc(
+ /*decltype($field_$)*/ {}
+ )cc");
+ InitCachedSize(p);
+ }
+
+ void GenerateAggregateInitializer(io::Printer* p) const override {
+ p->Emit(R"cc(
+ decltype($field_$) { arena }
+ )cc");
+ InitCachedSize(p);
+ }
+
+ void GenerateCopyAggregateInitializer(io::Printer* p) const override {
+ p->Emit(R"cc(
+ decltype($field_$) { from.$field_$ }
+ )cc");
+ InitCachedSize(p);
+ }
+
+ void GeneratePrivateMembers(io::Printer* p) const override;
+ void GenerateAccessorDeclarations(io::Printer* p) const override;
+ void GenerateInlineAccessorDefinitions(io::Printer* p) const override;
+ void GenerateSerializeWithCachedSizesToArray(io::Printer* p) const override;
+ void GenerateByteSize(io::Printer* p) const override;
+
+ private:
+ bool HasCachedSize() const {
+ bool is_packed_varint =
+ field_->is_packed() && !FixedSize(field_->type()).has_value();
+ return is_packed_varint && HasGeneratedMethods(field_->file(), *opts_);
+ }
+
+ void InitCachedSize(io::Printer* p) const {
+ if (!HasCachedSize()) return;
+ // std::atomic has no move constructor, which prevents explicit aggregate
+ // initialization pre-C++17.
+ p->Emit(R"(
+ ,/* $_field_cached_byte_size_$ = */ { 0 }
+ )");
+ }
+
+ const FieldDescriptor* field_;
+ const Options* opts_;
+};
+
+void RepeatedPrimitive::GeneratePrivateMembers(io::Printer* p) const {
+ p->Emit(R"cc(
+ $pb$::RepeatedField<$Type$> $name$_;
+ )cc");
+
+ if (HasCachedSize()) {
+ p->Emit({{"_cached_size_", MakeVarintCachedSizeName(field_)}},
+ R"cc(
+ mutable $pbi$::CachedSize $_cached_size_$;
+ )cc");
+ }
+}
+
+void RepeatedPrimitive::GenerateAccessorDeclarations(io::Printer* p) const {
+ p->Emit(
+ {
+ Sub("name", p->LookupVar("name")).AnnotatedAs(field_),
+ Sub("set_name", y_absl::StrCat("set_", p->LookupVar("name")))
+ .AnnotatedAs(field_),
+ Sub("add_name", y_absl::StrCat("add_", p->LookupVar("name")))
+ .AnnotatedAs(field_),
+ Sub("mutable_name", y_absl::StrCat("mutable_", p->LookupVar("name")))
+ .AnnotatedAs(field_),
+
+ Sub("_internal_name",
+ y_absl::StrCat("_internal_", p->LookupVar("name")))
+ .AnnotatedAs(field_),
+ Sub("_internal_add_name",
+ y_absl::StrCat("_internal_add_", p->LookupVar("name")))
+ .AnnotatedAs(field_),
+ Sub("_internal_mutable_name",
+ y_absl::StrCat("_internal_mutable_", p->LookupVar("name")))
+ .AnnotatedAs(field_),
+ },
+ R"cc(
+ $DEPRECATED$ $Type$ $name$(int index) const;
+ $DEPRECATED$ void $set_name$(int index, $Type$ value);
+ $DEPRECATED$ void $add_name$($Type$ value);
+ $DEPRECATED$ const $pb$::RepeatedField<$Type$>& $name$() const;
+ $DEPRECATED$ $pb$::RepeatedField<$Type$>* $mutable_name$();
+
+ private:
+ $Type$ $_internal_name$(int index) const;
+ void $_internal_add_name$($Type$ value);
+ const $pb$::RepeatedField<$Type$>& $_internal_name$() const;
+ $pb$::RepeatedField<$Type$>* $_internal_mutable_name$();
+
+ public:
+ )cc");
+}
+
+void RepeatedPrimitive::GenerateInlineAccessorDefinitions(
+ io::Printer* p) const {
+ p->Emit(R"cc(
+ inline $Type$ $Msg$::$name$(int index) const {
+ $annotate_get$;
+ // @@protoc_insertion_point(field_get:$pkg.Msg.field$)
+ return _internal_$name$(index);
+ }
+ inline void $Msg$::set_$name$(int index, $Type$ value) {
+ $annotate_set$;
+ $field_$.Set(index, value);
+ // @@protoc_insertion_point(field_set:$pkg.Msg.field$)
+ }
+ inline void $Msg$::add_$name$($Type$ value) {
+ _internal_add_$name$(value);
+ $annotate_add$;
+ // @@protoc_insertion_point(field_add:$pkg.Msg.field$)
+ }
+ inline const $pb$::RepeatedField<$Type$>& $Msg$::$name$() const {
+ $annotate_list$;
+ // @@protoc_insertion_point(field_list:$pkg.Msg.field$)
+ return _internal_$name$();
+ }
+ inline $pb$::RepeatedField<$Type$>* $Msg$::mutable_$name$() {
+ $annotate_mutable_list$;
+ // @@protoc_insertion_point(field_mutable_list:$pkg.Msg.field$)
+ return _internal_mutable_$name$();
+ }
+
+ inline $Type$ $Msg$::_internal_$name$(int index) const {
+ return $field_$.Get(index);
+ }
+ inline void $Msg$::_internal_add_$name$($Type$ value) { $field_$.Add(value); }
+ inline const $pb$::RepeatedField<$Type$>& $Msg$::_internal_$name$() const {
+ return $field_$;
+ }
+ inline $pb$::RepeatedField<$Type$>* $Msg$::_internal_mutable_$name$() {
+ return &$field_$;
+ }
+ )cc");
+}
+
+void RepeatedPrimitive::GenerateSerializeWithCachedSizesToArray(
+ io::Printer* p) const {
+ if (!field_->is_packed()) {
+ p->Emit(R"cc(
+ for (int i = 0, n = this->_internal_$name$_size(); i < n; ++i) {
+ target = stream->EnsureSpace(target);
+ target = ::_pbi::WireFormatLite::Write$DeclaredType$ToArray(
+ $number$, this->_internal_$name$(i), target);
+ }
+ )cc");
+ return;
+ }
+
+ if (FixedSize(field_->type()).has_value()) {
+ p->Emit(R"cc(
+ if (this->_internal_$name$_size() > 0) {
+ target = stream->WriteFixedPacked($number$, _internal_$name$(), target);
+ }
+ )cc");
+ return;
+ }
+
+ p->Emit(R"cc(
+ {
+ int byte_size = $_field_cached_byte_size_$.Get();
+ if (byte_size > 0) {
+ target = stream->Write$DeclaredType$Packed($number$, _internal_$name$(),
+ byte_size, target);
+ }
+ }
+ )cc");
+}
+
+void RepeatedPrimitive::GenerateByteSize(io::Printer* p) const {
+ p->Emit(
+ {
+ Sub{"data_size",
+ [&] {
+ auto fixed_size = FixedSize(descriptor_->type());
+ if (fixed_size.has_value()) {
+ p->Emit({{"kFixed", *fixed_size}}, R"cc(
+ std::size_t{$kFixed$} *
+ ::_pbi::FromIntSize(this->_internal_$name$_size())
+ )cc");
+ } else {
+ p->Emit(R"cc(
+ ::_pbi::WireFormatLite::$DeclaredType$Size(this->$field_$)
+ )cc");
+ }
+ }} // Here and below, we need to disable the default ;-chomping
+ // that closure substitutions do.
+ .WithSuffix(""),
+ {"maybe_cache_data_size",
+ [&] {
+ if (!HasCachedSize()) return;
+ p->Emit(R"cc(
+ $_field_cached_byte_size_$.Set(::_pbi::ToCachedSize(data_size));
+ )cc");
+ }},
+ Sub{"tag_size",
+ [&] {
+ if (field_->is_packed()) {
+ p->Emit(R"cc(
+ data_size == 0
+ ? 0
+ : $kTagBytes$ + ::_pbi::WireFormatLite::Int32Size(
+ static_cast<arc_i32>(data_size))
+ )cc");
+ } else {
+ p->Emit(R"cc(
+ std::size_t{$kTagBytes$} *
+ ::_pbi::FromIntSize(this->_internal_$name$_size());
+ )cc");
+ }
+ }}
+ .WithSuffix(""),
+ },
+ R"cc(
+ {
+ std::size_t data_size = $data_size$;
+ $maybe_cache_data_size$;
+ std::size_t tag_size = $tag_size$;
+ total_size += tag_size + data_size;
+ }
+ )cc");
+}
+} // namespace
+
+std::unique_ptr<FieldGeneratorBase> MakeSinguarPrimitiveGenerator(
+ const FieldDescriptor* desc, const Options& options,
+ MessageSCCAnalyzer* scc) {
+ return y_absl::make_unique<SingularPrimitive>(desc, options);
+}
+
+std::unique_ptr<FieldGeneratorBase> MakeRepeatedPrimitiveGenerator(
+ const FieldDescriptor* desc, const Options& options,
+ MessageSCCAnalyzer* scc) {
+ return y_absl::make_unique<RepeatedPrimitive>(desc, options);
+}
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/string_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/string_field.cc
new file mode 100644
index 00000000000..11b5b83ea66
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field_generators/string_field.cc
@@ -0,0 +1,922 @@
+// 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: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/memory/memory.h"
+#include "google/protobuf/compiler/cpp/field.h"
+#include "google/protobuf/compiler/cpp/field_generators/generators.h"
+#include "google/protobuf/compiler/cpp/helpers.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/printer.h"
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+namespace {
+using ::google::protobuf::internal::cpp::HasHasbit;
+using ::google::protobuf::io::AnnotationCollector;
+using Sub = ::google::protobuf::io::Printer::Sub;
+
+std::vector<Sub> Vars(const FieldDescriptor* field, const Options& opts) {
+ auto trivial_default =
+ y_absl::StrCat("::", ProtobufNamespace(opts),
+ "::internal::GetEmptyStringAlreadyInited()");
+ auto lazy_var =
+ y_absl::StrCat(QualifiedClassName(field->containing_type(), opts),
+ "::", MakeDefaultFieldName(field));
+
+ bool empty_default = field->default_value_string().empty();
+ bool is_bytes = field->type() == FieldDescriptor::TYPE_BYTES;
+
+ return {
+ {"kDefault", DefaultValue(opts, field)},
+ {"kDefaultLen", field->default_value_string().size()},
+ {"default_variable_name", MakeDefaultName(field)},
+ {"default_variable_field", MakeDefaultFieldName(field)},
+
+ {"kDefaultStr",
+ !empty_default ? y_absl::StrCat(lazy_var, ".get()") : trivial_default},
+ {"kDefaultValue",
+ !empty_default ? "nullptr" : y_absl::StrCat("&", trivial_default)},
+
+ {"lazy_var", lazy_var},
+ Sub{"lazy_args", !empty_default ? y_absl::StrCat(lazy_var, ",") : ""}
+ .WithSuffix(","),
+
+ {"byte", is_bytes ? "void" : "char"},
+ {"Set", is_bytes ? "SetBytes" : "Set"},
+ };
+}
+
+class SingularString : public FieldGeneratorBase {
+ public:
+ SingularString(const FieldDescriptor* field, const Options& opts)
+ : FieldGeneratorBase(field, opts),
+ field_(field),
+ opts_(&opts),
+ is_oneof_(field->real_containing_oneof() != nullptr),
+ inlined_(IsStringInlined(field, opts)) {}
+ ~SingularString() override = default;
+
+ std::vector<Sub> MakeVars() const override { return Vars(field_, *opts_); }
+
+ bool IsInlined() const override { return inlined_; }
+
+ ArenaDtorNeeds NeedsArenaDestructor() const override {
+ return inlined_ ? ArenaDtorNeeds::kOnDemand : ArenaDtorNeeds::kNone;
+ }
+
+ void GeneratePrivateMembers(io::Printer* p) const override {
+ // Skips the automatic destruction if inlined; rather calls it explicitly if
+ // allocating arena is null.
+ p->Emit({{"Str", inlined_ ? "InlinedStringField" : "ArenaStringPtr"}}, R"cc(
+ $pbi$::$Str$ $name$_;
+ )cc");
+ }
+
+ void GenerateMergingCode(io::Printer* p) const override {
+ p->Emit(R"cc(
+ _this->_internal_set_$name$(from._internal_$name$());
+ )cc");
+ }
+
+ void GenerateArenaDestructorCode(io::Printer* p) const override {
+ if (!inlined_) return;
+
+ p->Emit(R"cc(
+ if (!_this->_internal_$name$_donated()) {
+ _this->$field_$.~InlinedStringField();
+ }
+ )cc");
+ }
+
+ void GenerateNonInlineAccessorDefinitions(io::Printer* p) const override {
+ if (EmptyDefault()) return;
+ p->Emit(R"cc(
+ /*static*/ const ::_pbi::LazyString $Msg$::$default_variable_field${
+ {{$kDefault$, $kDefaultLen$}},
+ {nullptr},
+ };
+ )cc");
+ }
+
+ void GenerateByteSize(io::Printer* p) const override {
+ p->Emit(R"cc(
+ total_size += $kTagBytes$ + $pbi$::WireFormatLite::$DeclaredType$Size(
+ this->_internal_$name$());
+ )cc");
+ }
+
+ void GenerateCopyAggregateInitializer(io::Printer* p) const override {
+ p->Emit(R"cc(
+ decltype($field_$) {}
+ )cc");
+ }
+
+ void GenerateStaticMembers(io::Printer* p) const override;
+ void GenerateAccessorDeclarations(io::Printer* p) const override;
+ void GenerateInlineAccessorDefinitions(io::Printer* p) const override;
+ void GenerateClearingCode(io::Printer* p) const override;
+ void GenerateMessageClearingCode(io::Printer* p) const override;
+ void GenerateSwappingCode(io::Printer* p) const override;
+ void GenerateConstructorCode(io::Printer* p) const override;
+ void GenerateCopyConstructorCode(io::Printer* p) const override;
+ void GenerateDestructorCode(io::Printer* p) const override;
+ void GenerateSerializeWithCachedSizesToArray(io::Printer* p) const override;
+ void GenerateConstexprAggregateInitializer(io::Printer* p) const override;
+ void GenerateAggregateInitializer(io::Printer* p) const override;
+
+ private:
+ bool EmptyDefault() const { return field_->default_value_string().empty(); }
+ void ReleaseImpl(io::Printer* p) const;
+ void SetAllocatedImpl(io::Printer* p) const;
+
+ const FieldDescriptor* field_;
+ const Options* opts_;
+ bool is_oneof_;
+ bool inlined_;
+};
+
+void SingularString::GenerateStaticMembers(io::Printer* p) const {
+ if (!EmptyDefault()) {
+ p->Emit(R"cc(
+ static const $pbi$::LazyString $default_variable_name$;
+ )cc");
+ }
+ if (inlined_) {
+ // `_init_inline_xxx` is used for initializing default instances.
+ p->Emit(R"cc(
+ static std::true_type _init_inline_$name$_;
+ )cc");
+ }
+}
+
+void SingularString::GenerateAccessorDeclarations(io::Printer* p) const {
+ // If we're using SingularString for a field with a ctype, it's
+ // because that ctype isn't actually implemented. In particular, this is
+ // true of ctype=CORD and ctype=STRING_PIECE in the open source release.
+ // We aren't releasing Cord because it has too many Google-specific
+ // dependencies and we aren't releasing StringPiece because it's hardly
+ // useful outside of Google and because it would get confusing to have
+ // multiple instances of the StringPiece class in different libraries (PCRE
+ // already includes it for their C++ bindings, which came from Google).
+ //
+ // In any case, we make all the accessors private while still actually
+ // using a string to represent the field internally. This way, we can
+ // guarantee that if we do ever implement the ctype, it won't break any
+ // existing users who might be -- for whatever reason -- already using .proto
+ // files that applied the ctype. The field can still be accessed via the
+ // reflection interface since the reflection interface is independent of
+ // the string's underlying representation.
+ bool unknown_ctype =
+ field_->options().ctype() != EffectiveStringCType(field_, options_);
+
+ if (unknown_ctype) {
+ p->Emit(R"cc(
+ private: // Hidden due to unknown ctype option.
+ )cc");
+ }
+
+ auto vars = AnnotatedAccessors(field_, {"", "set_allocated_"});
+ vars.push_back(Sub{
+ "release_name",
+ SafeFunctionName(field_->containing_type(), field_, "release_"),
+ }
+ .AnnotatedAs(field_));
+ auto v1 = p->WithVars(vars);
+ auto v2 = p->WithVars(
+ AnnotatedAccessors(field_, {"set_"}, AnnotationCollector::kSet));
+ auto v3 = p->WithVars(
+ AnnotatedAccessors(field_, {"mutable_"}, AnnotationCollector::kAlias));
+
+ p->Emit(
+ {{"donated",
+ [&] {
+ if (!inlined_) return;
+ p->Emit(R"cc(
+ inline PROTOBUF_ALWAYS_INLINE bool _internal_$name$_donated() const;
+ )cc");
+ }}},
+ R"cc(
+ $DEPRECATED$ const TProtoStringType& $name$() const;
+ //~ Using `Arg_ = const TProtoStringType&` will make the type of `arg`
+ //~ default to `const TProtoStringType&`, due to reference collapse. This is
+ //~ necessary because there are a handful of users that rely on this
+ //~ default.
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ $DEPRECATED$ void $set_name$(Arg_&& arg, Args_... args);
+ $DEPRECATED$ TProtoStringType* $mutable_name$();
+ PROTOBUF_NODISCARD $DEPRECATED$ TProtoStringType* $release_name$();
+ $DEPRECATED$ void $set_allocated_name$(TProtoStringType* ptr);
+
+ private:
+ const TProtoStringType& _internal_$name$() const;
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_$name$(
+ const TProtoStringType& value);
+ TProtoStringType* _internal_mutable_$name$();
+ $donated$;
+
+ public:
+ )cc");
+}
+
+void UpdateHasbitSet(io::Printer* p, bool is_oneof) {
+ if (!is_oneof) {
+ p->Emit(R"cc(
+ $set_hasbit$;
+ )cc");
+ return;
+ }
+
+ p->Emit(R"cc(
+ if ($not_has_field$) {
+ clear_$oneof_name$();
+
+ set_has_$name$();
+ $field_$.InitDefault();
+ }
+ )cc");
+}
+
+void ArgsForSetter(io::Printer* p, bool inlined) {
+ if (!inlined) {
+ p->Emit("GetArenaForAllocation()");
+ return;
+ }
+ p->Emit(
+ "GetArenaForAllocation(), _internal_$name$_donated(), "
+ "&$donating_states_word$, $mask_for_undonate$, this");
+}
+
+void SingularString::ReleaseImpl(io::Printer* p) const {
+ if (is_oneof_) {
+ p->Emit(R"cc(
+ if ($not_has_field$) {
+ return nullptr;
+ }
+ clear_has_$oneof_name$();
+ return $field_$.Release();
+ )cc");
+ return;
+ }
+
+ if (!HasHasbit(field_)) {
+ p->Emit(R"cc(
+ return $field_$.Release();
+ )cc");
+ return;
+ }
+
+ if (inlined_) {
+ p->Emit(R"cc(
+ if (($has_hasbit$) == 0) {
+ return nullptr;
+ }
+ $clear_hasbit$;
+
+ return $field_$.Release(GetArenaForAllocation(), _internal_$name$_donated());
+ )cc");
+ return;
+ }
+
+ p->Emit(R"cc(
+ if (($has_hasbit$) == 0) {
+ return nullptr;
+ }
+ $clear_hasbit$;
+ )cc");
+
+ if (!EmptyDefault()) {
+ p->Emit(R"cc(
+ return $field_$.Release();
+ )cc");
+ return;
+ }
+
+ p->Emit(R"cc(
+ auto* released = $field_$.Release();
+#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ $field_$.Set("", $set_args$);
+#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+ )cc");
+}
+
+void SingularString::SetAllocatedImpl(io::Printer* p) const {
+ if (is_oneof_) {
+ p->Emit(R"cc(
+ if (has_$oneof_name$()) {
+ clear_$oneof_name$();
+ }
+ if (value != nullptr) {
+ set_has_$name$();
+ $field_$.InitAllocated(value, GetArenaForAllocation());
+ }
+ )cc");
+ return;
+ }
+
+ if (HasHasbit(field_)) {
+ p->Emit(R"cc(
+ if (value != nullptr) {
+ $set_hasbit$
+ } else {
+ $clear_hasbit$
+ }
+ )cc");
+ }
+
+ if (inlined_) {
+ // Currently, string fields with default value can't be inlined.
+ p->Emit(R"cc(
+ $field_$.SetAllocated(nullptr, value, $set_args$);
+ )cc");
+ return;
+ }
+
+ p->Emit(R"cc(
+ $field_$.SetAllocated(value, $set_args$);
+ )cc");
+
+ if (EmptyDefault()) {
+ p->Emit(R"cc(
+#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ($field_$.IsDefault()) {
+ $field_$.Set("", $set_args$);
+ }
+#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ )cc");
+ }
+}
+
+void SingularString::GenerateInlineAccessorDefinitions(io::Printer* p) const {
+ p->Emit(
+ {
+ {"if_IsDefault",
+ [&] {
+ if (EmptyDefault() || is_oneof_) return;
+ p->Emit(R"cc(
+ if ($field_$.IsDefault()) {
+ return $default_variable_field$.get();
+ }
+ )cc");
+ }},
+ {"update_hasbit", [&] { UpdateHasbitSet(p, is_oneof_); }},
+ {"set_args", [&] { ArgsForSetter(p, inlined_); }},
+ {"check_hasbit",
+ [&] {
+ if (!is_oneof_) return;
+ p->Emit(R"cc(
+ if ($not_has_field$) {
+ return $kDefaultStr$;
+ }
+ )cc");
+ }},
+ {"release_name",
+ SafeFunctionName(field_->containing_type(), field_, "release_")},
+ {"release_impl", [&] { ReleaseImpl(p); }},
+ {"set_allocated_impl", [&] { SetAllocatedImpl(p); }},
+ },
+ R"cc(
+ inline const TProtoStringType& $Msg$::$name$() const {
+ $annotate_get$;
+ // @@protoc_insertion_point(field_get:$pkg.Msg.field$)
+ $if_IsDefault$;
+ return _internal_$name$();
+ }
+ template <typename Arg_, typename... Args_>
+ inline PROTOBUF_ALWAYS_INLINE void $Msg$::set_$name$(Arg_&& arg,
+ Args_... args) {
+ $PrepareSplitMessageForWrite$;
+ $update_hasbit$;
+ $field_$.$Set$(static_cast<Arg_&&>(arg), args..., $set_args$);
+ $annotate_set$;
+ // @@protoc_insertion_point(field_set:$pkg.Msg.field$)
+ }
+ inline TProtoStringType* $Msg$::mutable_$name$() {
+ $PrepareSplitMessageForWrite$;
+ TProtoStringType* _s = _internal_mutable_$name$();
+ $annotate_mutable$;
+ // @@protoc_insertion_point(field_mutable:$pkg.Msg.field$)
+ return _s;
+ }
+ inline const TProtoStringType& $Msg$::_internal_$name$() const {
+ $check_hasbit$;
+ return $field_$.Get();
+ }
+ inline void $Msg$::_internal_set_$name$(const TProtoStringType& value) {
+ $update_hasbit$;
+ //~ Don't use $Set$ here; we always want the TProtoStringType variant
+ //~ regardless of whether this is a `bytes` field.
+ $field_$.Set(value, $set_args$);
+ }
+ inline TProtoStringType* $Msg$::_internal_mutable_$name$() {
+ $update_hasbit$;
+ return $field_$.Mutable($lazy_args$, $set_args$);
+ }
+ inline TProtoStringType* $Msg$::$release_name$() {
+ $annotate_release$;
+ $PrepareSplitMessageForWrite$;
+ // @@protoc_insertion_point(field_release:$pkg.Msg.field$)
+ $release_impl$;
+ }
+ inline void $Msg$::set_allocated_$name$(TProtoStringType* value) {
+ $PrepareSplitMessageForWrite$;
+ $set_allocated_impl$;
+ $annotate_set$;
+ // @@protoc_insertion_point(field_set_allocated:$pkg.Msg.field$)
+ }
+ )cc");
+
+ if (inlined_) {
+ p->Emit(R"cc(
+ inline bool $Msg$::_internal_$name$_donated() const {
+ return $inlined_string_donated$;
+ }
+ )cc");
+ }
+}
+
+void SingularString::GenerateClearingCode(io::Printer* p) const {
+ if (is_oneof_) {
+ p->Emit(R"cc(
+ $field_$.Destroy();
+ )cc");
+ return;
+ }
+
+ if (EmptyDefault()) {
+ p->Emit(R"cc(
+ $field_$.ClearToEmpty();
+ )cc");
+ return;
+ }
+
+ Y_ABSL_DCHECK(!inlined_);
+ p->Emit(R"cc(
+ $field_$.ClearToDefault($lazy_var$, GetArenaForAllocation());
+ )cc");
+}
+
+void SingularString::GenerateMessageClearingCode(io::Printer* p) const {
+ if (is_oneof_) {
+ p->Emit(R"cc(
+ $field_$.Destroy();
+ )cc");
+ return;
+ }
+
+ // Two-dimension specialization here: supporting arenas, field presence, or
+ // not, and default value is the empty string or not. Complexity here ensures
+ // the minimal number of branches / amount of extraneous code at runtime
+ // (given that the below methods are inlined one-liners)!
+
+ // If we have a hasbit, then the Clear() method of the protocol buffer
+ // will have checked that this field is set. If so, we can avoid redundant
+ // checks against the default variable.
+
+ if (inlined_ && HasHasbit(field_)) {
+ // Calling mutable_$name$() gives us a string reference and sets the has bit
+ // for $name$ (in proto2). We may get here when the string field is inlined
+ // but the string's contents have not been changed by the user, so we cannot
+ // make an assertion about the contents of the string and could never make
+ // an assertion about the string instance.
+ //
+ // For non-inlined strings, we distinguish from non-default by comparing
+ // instances, rather than contents.
+ p->Emit(R"cc(
+ $DCHK$(!$field_$.IsDefault());
+ )cc");
+ }
+
+ if (!EmptyDefault()) {
+ // 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.
+ p->Emit(R"cc(
+ $field_$.ClearToDefault($lazy_var$, GetArenaForAllocation());
+ )cc");
+ return;
+ }
+
+ p->Emit({{"Clear",
+ HasHasbit(field_) ? "ClearNonDefaultToEmpty" : "ClearToEmpty"}},
+ R"cc(
+ $field_$.$Clear$();
+ )cc");
+}
+
+void SingularString::GenerateSwappingCode(io::Printer* p) const {
+ if (is_oneof_) {
+ // Don't print any swapping code. Swapping the union will swap this field.
+ return;
+ }
+
+ if (!inlined_) {
+ p->Emit(R"cc(
+ ::_pbi::ArenaStringPtr::InternalSwap(&$field_$, lhs_arena,
+ &other->$field_$, rhs_arena);
+ )cc");
+ return;
+ }
+
+ p->Emit(R"cc(
+ {
+ bool lhs_dtor_registered = ($inlined_string_donated_array$[0] & 1) == 0;
+ bool rhs_dtor_registered =
+ (other->$inlined_string_donated_array$[0] & 1) == 0;
+ ::_pbi::InlinedStringField::InternalSwap(
+ &$field_$, lhs_arena, lhs_dtor_registered, this, &other->$field_$,
+ rhs_arena, rhs_dtor_registered, other);
+ }
+ )cc");
+}
+
+void SingularString::GenerateConstructorCode(io::Printer* p) const {
+ if ((inlined_ && EmptyDefault()) || is_oneof_) return;
+ Y_ABSL_DCHECK(!inlined_);
+
+ p->Emit(R"cc(
+ $field_$.InitDefault();
+ )cc");
+
+ if (IsString(field_, *opts_) && EmptyDefault()) {
+ p->Emit(R"cc(
+#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ $field_$.Set("", GetArenaForAllocation());
+#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ )cc");
+ }
+}
+
+void SingularString::GenerateCopyConstructorCode(io::Printer* p) const {
+ GenerateConstructorCode(p);
+
+ if (inlined_) {
+ p->Emit(R"cc(
+ new (&_this->$field_$)::_pbi::InlinedStringField;
+ )cc");
+ }
+
+ p->Emit(
+ {{"hazzer",
+ [&] {
+ if (HasHasbit(field_)) {
+ p->Emit(R"cc((from.$has_hasbit$) != 0)cc");
+ } else {
+ p->Emit(R"cc(!from._internal_$name$().empty())cc");
+ }
+ }},
+ {"set_args",
+ [&] {
+ if (!inlined_) {
+ p->Emit("_this->GetArenaForAllocation()");
+ } else {
+ p->Emit(
+ "_this->GetArenaForAllocation(), "
+ "_this->_internal_$name$_donated(), "
+ "&_this->$donating_states_word$, $mask_for_undonate$, _this");
+ }
+ }}},
+ R"cc(
+ if ($hazzer$) {
+ _this->$field_$.Set(from._internal_$name$(), $set_args$);
+ }
+ )cc");
+}
+
+void SingularString::GenerateDestructorCode(io::Printer* p) const {
+ if (inlined_) {
+ // Explicitly calls ~InlinedStringField as its automatic call is disabled.
+ // Destructor has been implicitly skipped as a union.
+ Y_ABSL_DCHECK(!ShouldSplit(field_, *opts_));
+ p->Emit(R"cc(
+ $field_$.~InlinedStringField();
+ )cc");
+ return;
+ }
+
+ if (ShouldSplit(field_, *opts_)) {
+ p->Emit(R"cc(
+ $cached_split_ptr$->$name$_.Destroy();
+ )cc");
+ return;
+ }
+
+ p->Emit(R"cc(
+ $field_$.Destroy();
+ )cc");
+}
+
+void SingularString::GenerateSerializeWithCachedSizesToArray(
+ io::Printer* p) const {
+ p->Emit({{"utf8_check",
+ [&] {
+ GenerateUtf8CheckCodeForString(p, field_, options_, false,
+ "_s.data(), "
+ "static_cast<int>(_s.length()),");
+ }}},
+ R"cc(
+ const TProtoStringType& _s = this->_internal_$name$();
+ $utf8_check$;
+ target = stream->Write$DeclaredType$MaybeAliased($number$, _s, target);
+ )cc");
+}
+
+void SingularString::GenerateConstexprAggregateInitializer(
+ io::Printer* p) const {
+ if (inlined_) {
+ p->Emit(R"cc(
+ /*decltype($field_$)*/ { nullptr, false }
+ )cc");
+ return;
+ }
+
+ p->Emit(R"cc(
+ /*decltype($field_$)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+ )cc");
+}
+
+void SingularString::GenerateAggregateInitializer(io::Printer* p) const {
+ if (ShouldSplit(field_, options_)) {
+ Y_ABSL_CHECK(!inlined_);
+ p->Emit(R"cc(
+ decltype(Impl_::Split::$name$_) {}
+ )cc");
+ return;
+ }
+
+ if (!inlined_) {
+ p->Emit(R"cc(
+ decltype($field_$) {}
+ )cc");
+ } else {
+ p->Emit(R"cc(
+ decltype($field_$) { arena }
+ )cc");
+ }
+}
+
+class RepeatedString : public FieldGeneratorBase {
+ public:
+ RepeatedString(const FieldDescriptor* field, const Options& opts)
+ : FieldGeneratorBase(field, opts), field_(field), opts_(&opts) {}
+ ~RepeatedString() override = default;
+
+ std::vector<Sub> MakeVars() const override { return Vars(field_, *opts_); }
+
+ void GeneratePrivateMembers(io::Printer* p) const override {
+ p->Emit(R"cc(
+ $pb$::RepeatedPtrField<TProtoStringType> $name$_;
+ )cc");
+ }
+
+ void GenerateClearingCode(io::Printer* p) const override {
+ p->Emit(R"cc(
+ $field_$.Clear();
+ )cc");
+ }
+
+ void GenerateMergingCode(io::Printer* p) const override {
+ p->Emit(R"cc(
+ _this->$field_$.MergeFrom(from.$field_$);
+ )cc");
+ }
+
+ void GenerateSwappingCode(io::Printer* p) const override {
+ p->Emit(R"cc(
+ $field_$.InternalSwap(&other->$field_$);
+ )cc");
+ }
+
+ void GenerateDestructorCode(io::Printer* p) const override {
+ p->Emit(R"cc(
+ $field_$.~RepeatedPtrField();
+ )cc");
+ }
+
+ void GenerateConstructorCode(io::Printer* p) const override {}
+
+ void GenerateCopyConstructorCode(io::Printer* p) const override {
+ Y_ABSL_CHECK(!ShouldSplit(field_, options_));
+ }
+
+ void GenerateByteSize(io::Printer* p) const override {
+ p->Emit(R"cc(
+ total_size += $kTagBytes$ * $pbi$::FromIntSize($field_$.size());
+ for (int i = 0, n = $field_$.size(); i < n; ++i) {
+ total_size += $pbi$::WireFormatLite::$DeclaredType$Size($field_$.Get(i));
+ }
+ )cc");
+ }
+
+ void GenerateAccessorDeclarations(io::Printer* p) const override;
+ void GenerateInlineAccessorDefinitions(io::Printer* p) const override;
+ void GenerateSerializeWithCachedSizesToArray(io::Printer* p) const override;
+
+ private:
+ const FieldDescriptor* field_;
+ const Options* opts_;
+};
+
+void RepeatedString::GenerateAccessorDeclarations(io::Printer* p) const {
+ bool unknown_ctype =
+ field_->options().ctype() != EffectiveStringCType(field_, options_);
+
+ if (unknown_ctype) {
+ p->Emit(R"cc(
+ private: // Hidden due to unknown ctype option.
+ )cc");
+ }
+
+ auto v1 = p->WithVars(
+ AnnotatedAccessors(field_, {"", "_internal_", "_internal_add_"}));
+ auto v2 = p->WithVars(
+ AnnotatedAccessors(field_, {"set_", "add_"}, AnnotationCollector::kSet));
+ auto v3 = p->WithVars(
+ AnnotatedAccessors(field_, {"mutable_"}, AnnotationCollector::kAlias));
+
+ p->Emit(R"cc(
+ $DEPRECATED$ const TProtoStringType& $name$(int index) const;
+ $DEPRECATED$ TProtoStringType* $mutable_name$(int index);
+ $DEPRECATED$ void $set_name$(int index, const TProtoStringType& value);
+ $DEPRECATED$ void $set_name$(int index, TProtoStringType&& value);
+ $DEPRECATED$ void $set_name$(int index, const char* value);
+ $DEPRECATED$ void $set_name$(int index, const $byte$* value, std::size_t size);
+ $DEPRECATED$ TProtoStringType* $add_name$();
+ $DEPRECATED$ void $add_name$(const TProtoStringType& value);
+ $DEPRECATED$ void $add_name$(TProtoStringType&& value);
+ $DEPRECATED$ void $add_name$(const char* value);
+ $DEPRECATED$ void $add_name$(const $byte$* value, std::size_t size);
+ $DEPRECATED$ const $pb$::RepeatedPtrField<TProtoStringType>& $name$() const;
+ $DEPRECATED$ $pb$::RepeatedPtrField<TProtoStringType>* $mutable_name$();
+
+ private:
+ const TProtoStringType& $_internal_name$(int index) const;
+ TProtoStringType* $_internal_add_name$();
+
+ public:
+ )cc");
+}
+
+void RepeatedString::GenerateInlineAccessorDefinitions(io::Printer* p) const {
+ p->Emit({{"Get", opts_->safe_boundary_check ? "InternalCheckedGet" : "Get"},
+ {"get_args",
+ [&] {
+ if (!opts_->safe_boundary_check) {
+ p->Emit("index");
+ return;
+ }
+
+ p->Emit(R"cc(index, $pbi$::GetEmptyStringAlreadyInited())cc");
+ }}},
+ R"cc(
+ inline TProtoStringType* $Msg$::add_$name$() {
+ TProtoStringType* _s = _internal_add_$name$();
+ $annotate_add_mutable$;
+ // @@protoc_insertion_point(field_add_mutable:$pkg.Msg.field$)
+ return _s;
+ }
+ inline const TProtoStringType& $Msg$::_internal_$name$(int index) const {
+ return $field_$.$Get$($get_args$);
+ }
+ inline const TProtoStringType& $Msg$::$name$(int index) const {
+ $annotate_get$;
+ // @@protoc_insertion_point(field_get:$pkg.Msg.field$)
+ return _internal_$name$(index);
+ }
+ inline TProtoStringType* $Msg$::mutable_$name$(int index) {
+ $annotate_mutable$;
+ // @@protoc_insertion_point(field_mutable:$pkg.Msg.field$)
+ return $field_$.Mutable(index);
+ }
+ inline void $Msg$::set_$name$(int index, const TProtoStringType& value) {
+ $field_$.Mutable(index)->assign(value);
+ $annotate_set$;
+ // @@protoc_insertion_point(field_set:$pkg.Msg.field$)
+ }
+ inline void $Msg$::set_$name$(int index, TProtoStringType&& value) {
+ $field_$.Mutable(index)->assign(std::move(value));
+ $annotate_set$;
+ // @@protoc_insertion_point(field_set:$pkg.Msg.field$)
+ }
+ inline void $Msg$::set_$name$(int index, const char* value) {
+ $DCHK$(value != nullptr);
+ $field_$.Mutable(index)->assign(value);
+ $annotate_set$;
+ // @@protoc_insertion_point(field_set_char:$pkg.Msg.field$)
+ }
+ inline void $Msg$::set_$name$(int index, const $byte$* value,
+ std::size_t size) {
+ $field_$.Mutable(index)->assign(reinterpret_cast<const char*>(value), size);
+ $annotate_set$;
+ // @@protoc_insertion_point(field_set_pointer:$pkg.Msg.field$)
+ }
+ inline TProtoStringType* $Msg$::_internal_add_$name$() { return $field_$.Add(); }
+ inline void $Msg$::add_$name$(const TProtoStringType& value) {
+ $field_$.Add()->assign(value);
+ $annotate_add$;
+ // @@protoc_insertion_point(field_add:$pkg.Msg.field$)
+ }
+ inline void $Msg$::add_$name$(TProtoStringType&& value) {
+ $field_$.Add(std::move(value));
+ $annotate_add$;
+ // @@protoc_insertion_point(field_add:$pkg.Msg.field$)
+ }
+ inline void $Msg$::add_$name$(const char* value) {
+ $DCHK$(value != nullptr);
+ $field_$.Add()->assign(value);
+ $annotate_add$;
+ // @@protoc_insertion_point(field_add_char:$pkg.Msg.field$)
+ }
+ inline void $Msg$::add_$name$(const $byte$* value, std::size_t size) {
+ $field_$.Add()->assign(reinterpret_cast<const char*>(value), size);
+ $annotate_add$;
+ // @@protoc_insertion_point(field_add_pointer:$pkg.Msg.field$)
+ }
+ inline const ::$proto_ns$::RepeatedPtrField<TProtoStringType>&
+ $Msg$::$name$() const {
+ $annotate_list$;
+ // @@protoc_insertion_point(field_list:$pkg.Msg.field$)
+ return $field_$;
+ }
+ inline ::$proto_ns$::RepeatedPtrField<TProtoStringType>* $Msg$::mutable_$name$() {
+ $annotate_mutable_list$;
+ // @@protoc_insertion_point(field_mutable_list:$pkg.Msg.field$)
+ return &$field_$;
+ }
+ )cc");
+}
+
+void RepeatedString::GenerateSerializeWithCachedSizesToArray(
+ io::Printer* p) const {
+ p->Emit({{"utf8_check",
+ [&] {
+ GenerateUtf8CheckCodeForString(
+ p, field_, options_, false,
+ "s.data(), static_cast<int>(s.length()),");
+ }}},
+ R"cc(
+ for (int i = 0, n = this->_internal_$name$_size(); i < n; ++i) {
+ const auto& s = this->_internal_$name$(i);
+ $utf8_check$;
+ target = stream->Write$DeclaredType$($number$, s, target);
+ }
+ )cc");
+}
+} // namespace
+
+std::unique_ptr<FieldGeneratorBase> MakeSinguarStringGenerator(
+ const FieldDescriptor* desc, const Options& options,
+ MessageSCCAnalyzer* scc) {
+ return y_absl::make_unique<SingularString>(desc, options);
+}
+
+std::unique_ptr<FieldGeneratorBase> MakeRepeatedStringGenerator(
+ const FieldDescriptor* desc, const Options& options,
+ MessageSCCAnalyzer* scc) {
+ return y_absl::make_unique<RepeatedString>(desc, options);
+}
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/file.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/file.cc
index 2d79ec11e59..bb024eb59f5 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/file.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/file.cc
@@ -32,133 +32,140 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/cpp/file.h>
+#include "google/protobuf/compiler/cpp/file.h"
#include <iostream>
-#include <map>
#include <memory>
-#include <queue>
-#include <set>
-#include <unordered_map>
-#include <unordered_set>
+#include <string>
+#include <utility>
#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/enum.h>
-#include <google/protobuf/compiler/cpp/extension.h>
-#include <google/protobuf/compiler/cpp/field.h>
-#include <google/protobuf/compiler/cpp/helpers.h>
-#include <google/protobuf/compiler/cpp/message.h>
-#include <google/protobuf/compiler/cpp/service.h>
-#include <google/protobuf/descriptor.pb.h>
+#include "google/protobuf/compiler/scc.h"
+#include "y_absl/container/btree_map.h"
+#include "y_absl/container/btree_set.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/strings/escaping.h"
+#include "y_absl/strings/match.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/strings/strip.h"
+#include "google/protobuf/compiler/cpp/enum.h"
+#include "google/protobuf/compiler/cpp/extension.h"
+#include "google/protobuf/compiler/cpp/helpers.h"
+#include "google/protobuf/compiler/cpp/message.h"
+#include "google/protobuf/compiler/cpp/names.h"
+#include "google/protobuf/compiler/cpp/service.h"
+#include "google/protobuf/compiler/retention.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/printer.h"
// Must be last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
namespace compiler {
namespace cpp {
-
namespace {
-
-// When we forward-declare things, we want to create a sorted order so our
-// output is deterministic and minimizes namespace changes.
-template <class T>
-TProtoStringType GetSortKey(const T& val) {
- return val.full_name();
-}
-
-template <>
-TProtoStringType GetSortKey<FileDescriptor>(const FileDescriptor& val) {
- return val.name();
-}
-
-template <class T>
-bool CompareSortKeys(const T* a, const T* b) {
- return GetSortKey(*a) < GetSortKey(*b);
-}
-
-template <class T>
-std::vector<const T*> Sorted(const std::unordered_set<const T*>& vals) {
- std::vector<const T*> sorted(vals.begin(), vals.end());
- std::sort(sorted.begin(), sorted.end(), CompareSortKeys<T>);
- return sorted;
+using Sub = ::google::protobuf::io::Printer::Sub;
+
+y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> FileVars(
+ const FileDescriptor* file, const Options& options) {
+ return {
+ {"filename", file->name()},
+ {"package_ns", Namespace(file, options)},
+ {"tablename", UniqueName("TableStruct", file, options)},
+ {"desc_table", DescriptorTableName(file, options)},
+ {"dllexport_decl", options.dllexport_decl},
+ {"file_level_metadata", UniqueName("file_level_metadata", file, options)},
+ {"file_level_enum_descriptors",
+ UniqueName("file_level_enum_descriptors", file, options)},
+ {"file_level_service_descriptors",
+ UniqueName("file_level_service_descriptors", file, options)},
+ };
}
// 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");
+void MuteWuninitialized(io::Printer* p) {
+ p->Emit(R"(
+ #if defined(__llvm__)
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wuninitialized"
+ #endif // __llvm__
+ )");
}
-inline void UnmuteWuninitialized(Formatter& format) {
- format(
- "#if defined(__llvm__)\n"
- " #pragma clang diagnostic pop\n"
- "#endif // __llvm__\n");
+void UnmuteWuninitialized(io::Printer* p) {
+ p->Emit(R"(
+ #if defined(__llvm__)
+ #pragma clang diagnostic pop
+ #endif // __llvm__
+ )");
}
-
} // namespace
FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options)
: file_(file), options_(options), scc_analyzer_(options) {
- // These variables are the same on a file level
- SetCommonVars(options, &variables_);
- variables_["dllexport_decl"] = options.dllexport_decl;
- variables_["tablename"] = UniqueName("TableStruct", file_, options_);
- variables_["file_level_metadata"] =
- UniqueName("file_level_metadata", file_, options_);
- variables_["desc_table"] = DescriptorTableName(file_, options_);
- variables_["file_level_enum_descriptors"] =
- UniqueName("file_level_enum_descriptors", file_, options_);
- variables_["file_level_service_descriptors"] =
- UniqueName("file_level_service_descriptors", file_, options_);
- variables_["filename"] = file_->name();
- variables_["package_ns"] = Namespace(file_, options);
-
std::vector<const Descriptor*> msgs = FlattenMessagesInFile(file);
- for (int i = 0; i < msgs.size(); i++) {
- // Deleted in destructor
- MessageGenerator* msg_gen =
- new MessageGenerator(msgs[i], variables_, i, options, &scc_analyzer_);
- message_generators_.emplace_back(msg_gen);
- msg_gen->AddGenerators(&enum_generators_, &extension_generators_);
+
+ for (int i = 0; i < msgs.size(); ++i) {
+ message_generators_.push_back(std::make_unique<MessageGenerator>(
+ msgs[i], variables_, i, options, &scc_analyzer_));
+ message_generators_.back()->AddGenerators(&enum_generators_,
+ &extension_generators_);
}
- for (int i = 0; i < file->enum_type_count(); i++) {
- enum_generators_.emplace_back(
- new EnumGenerator(file->enum_type(i), variables_, options));
+ for (int i = 0; i < file->enum_type_count(); ++i) {
+ enum_generators_.push_back(
+ std::make_unique<EnumGenerator>(file->enum_type(i), options));
}
- for (int i = 0; i < file->service_count(); i++) {
- service_generators_.emplace_back(
- new ServiceGenerator(file->service(i), variables_, options));
+ for (int i = 0; i < file->service_count(); ++i) {
+ service_generators_.push_back(std::make_unique<ServiceGenerator>(
+ file->service(i), variables_, options));
}
if (HasGenericServices(file_, options_)) {
- for (int i = 0; i < service_generators_.size(); i++) {
+ for (int i = 0; i < service_generators_.size(); ++i) {
service_generators_[i]->index_in_metadata_ = i;
}
}
- for (int i = 0; i < file->extension_count(); i++) {
- extension_generators_.emplace_back(
- new ExtensionGenerator(file->extension(i), options, &scc_analyzer_));
+
+ for (int i = 0; i < file->extension_count(); ++i) {
+ extension_generators_.push_back(std::make_unique<ExtensionGenerator>(
+ file->extension(i), options, &scc_analyzer_));
}
+
for (int i = 0; i < file->weak_dependency_count(); ++i) {
weak_deps_.insert(file->weak_dependency(i));
}
}
-FileGenerator::~FileGenerator() = default;
+void FileGenerator::GenerateFile(io::Printer* p, GeneratedFileType file_type,
+ std::function<void()> cb) {
+ auto v = p->WithVars(FileVars(file_, options_));
+ auto guard = IncludeGuard(file_, file_type, options_);
+ p->Emit({{"cb", cb}, {"guard", guard}}, R"(
+ // Generated by the protocol buffer compiler. DO NOT EDIT!
+ // source: $filename$
-void FileGenerator::GenerateMacroUndefs(io::Printer* printer) {
- Formatter format(printer, variables_);
+ #ifndef $guard$
+ #define $guard$
+
+ #include <limits>
+ #include <string>
+ #include <type_traits>
+
+ $cb$;
+
+ #endif // $guard$
+ )");
+}
+
+void FileGenerator::GenerateMacroUndefs(io::Printer* p) {
// Only do this for protobuf's own types. There are some google3 protos using
// macros as field names and the generated code compiles after the macro
// expansion. Undefing these macros actually breaks such code.
@@ -166,425 +173,478 @@ void FileGenerator::GenerateMacroUndefs(io::Printer* printer) {
file_->name() != "google/protobuf/compiler/plugin.proto") {
return;
}
- std::vector<TProtoStringType> names_to_undef;
+
std::vector<const FieldDescriptor*> fields;
ListAllFields(file_, &fields);
- for (int i = 0; i < fields.size(); i++) {
- const TProtoStringType& name = fields[i]->name();
- static const char* kMacroNames[] = {"major", "minor"};
- for (int j = 0; j < GOOGLE_ARRAYSIZE(kMacroNames); ++j) {
- if (name == kMacroNames[j]) {
- names_to_undef.push_back(name);
- break;
- }
- }
- }
- for (int i = 0; i < names_to_undef.size(); ++i) {
- format(
- "#ifdef $1$\n"
- "#undef $1$\n"
- "#endif\n",
- names_to_undef[i]);
- }
-}
-
-void FileGenerator::GenerateHeader(io::Printer* printer) {
- Formatter format(printer, variables_);
- // port_def.inc must be included after all other includes.
- IncludeFile("net/proto2/public/port_def.inc", printer);
- format("#define $1$$ dllexport_decl$\n", FileDllExport(file_, options_));
- GenerateMacroUndefs(printer);
-
- // For Any support with lite protos, we need to friend AnyMetadata, so we
- // forward-declare it here.
- format(
- "PROTOBUF_NAMESPACE_OPEN\n"
- "namespace internal {\n"
- "class AnyMetadata;\n"
- "} // namespace internal\n"
- "PROTOBUF_NAMESPACE_CLOSE\n");
-
- GenerateGlobalStateFunctionDeclarations(printer);
-
- GenerateForwardDeclarations(printer);
-
- {
- NamespaceOpener ns(Namespace(file_, options_), format);
-
- format("\n");
-
- GenerateEnumDefinitions(printer);
-
- format(kThickSeparator);
- format("\n");
-
- GenerateMessageDefinitions(printer);
-
- format("\n");
- format(kThickSeparator);
- format("\n");
-
- GenerateServiceDefinitions(printer);
-
- GenerateExtensionIdentifiers(printer);
-
- format("\n");
- format(kThickSeparator);
- format("\n");
+ y_absl::flat_hash_set<y_absl::string_view> all_fields;
+ for (const FieldDescriptor* field : fields) {
+ all_fields.insert(field->name());
+ }
- GenerateInlineFunctionDefinitions(printer);
+ for (y_absl::string_view name : {"major", "minor"}) {
+ if (!all_fields.contains(name)) {
+ continue;
+ }
- format(
- "\n"
- "// @@protoc_insertion_point(namespace_scope)\n"
- "\n");
+ p->Emit({{"name", TProtoStringType(name)}}, R"(
+ #)" "ifdef" R"( $name$
+ #)" "undef" R"( $name$
+ #)" "endif" R"( // $name$
+ )");
}
+}
- // We need to specialize some templates in the ::google::protobuf namespace:
- GenerateProto2NamespaceEnumSpecializations(printer);
- format(
- "\n"
- "// @@protoc_insertion_point(global_scope)\n"
- "\n");
- IncludeFile("net/proto2/public/port_undef.inc", printer);
+void FileGenerator::GenerateSharedHeaderCode(io::Printer* p) {
+ p->Emit(
+ {
+ {"port_def",
+ [&] { IncludeFile("third_party/protobuf/port_def.inc", p); }},
+ {"port_undef",
+ [&] { IncludeFile("third_party/protobuf/port_undef.inc", p); }},
+ {"dllexport_macro", FileDllExport(file_, options_)},
+ {"undefs", [&] { GenerateMacroUndefs(p); }},
+ {"global_state_decls",
+ [&] { GenerateGlobalStateFunctionDeclarations(p); }},
+ {"fwd_decls", [&] { GenerateForwardDeclarations(p); }},
+ {"proto2_ns_enums",
+ [&] { GenerateProto2NamespaceEnumSpecializations(p); }},
+ {"main_decls",
+ [&] {
+ NamespaceOpener ns(Namespace(file_, options_), p);
+ p->Emit(
+ {
+ {"enums", [&] { GenerateEnumDefinitions(p); }},
+ {"messages", [&] { GenerateMessageDefinitions(p); }},
+ {"services", [&] { GenerateServiceDefinitions(p); }},
+ {"extensions", [&] { GenerateExtensionIdentifiers(p); }},
+ {"inline_fns",
+ [&] { GenerateInlineFunctionDefinitions(p); }},
+ },
+ R"(
+ $enums$
+
+ $hrule_thick$
+
+ $messages$
+
+ $hrule_thick$
+
+ $services$
+
+ $extensions$
+
+ $hrule_thick$
+
+ $inline_fns$
+
+ // @@protoc_insertion_point(namespace_scope)
+ )");
+ }},
+ },
+ R"(
+ // Must be included last.
+ $port_def$
+
+ #define $dllexport_macro$$ dllexport_decl$
+ $undefs$
+
+ PROTOBUF_NAMESPACE_OPEN
+ namespace internal {
+ class AnyMetadata;
+ } // namespace internal
+ PROTOBUF_NAMESPACE_CLOSE
+
+ $global_state_decls$;
+ $fwd_decls$
+
+ $main_decls$
+
+ $proto2_ns_enums$
+
+ // @@protoc_insertion_point(global_scope)
+
+ $port_undef$
+ )");
}
-void FileGenerator::GenerateProtoHeader(io::Printer* printer,
- const TProtoStringType& info_path) {
- Formatter format(printer, variables_);
+void FileGenerator::GenerateProtoHeader(io::Printer* p,
+ y_absl::string_view info_path) {
if (!options_.proto_h) {
return;
}
- GenerateTopHeaderGuard(printer, false);
-
- if (!options_.opensource_runtime) {
- format(
- "#ifdef SWIG\n"
- "#error \"Do not SWIG-wrap protobufs.\"\n"
- "#endif // SWIG\n"
- "\n");
- }
-
- if (IsBootstrapProto(options_, file_)) {
- format("// IWYU pragma: private, include \"$1$.proto.h\"\n\n",
- StripProto(file_->name()));
- }
-
- GenerateLibraryIncludes(printer);
-
- for (int i = 0; i < file_->public_dependency_count(); i++) {
- const FileDescriptor* dep = file_->public_dependency(i);
- format("#include \"$1$.proto.h\"\n", StripProto(dep->name()));
- }
-
- format("// @@protoc_insertion_point(includes)\n");
-
- GenerateMetadataPragma(printer, info_path);
-
- GenerateHeader(printer);
-
- GenerateBottomHeaderGuard(printer, false);
-}
-
-void FileGenerator::GeneratePBHeader(io::Printer* printer,
- const TProtoStringType& info_path) {
- Formatter format(printer, variables_);
- GenerateTopHeaderGuard(printer, true);
-
- if (options_.proto_h) {
- TProtoStringType target_basename = StripProto(file_->name());
+ GenerateFile(p, GeneratedFileType::kProtoH, [&] {
if (!options_.opensource_runtime) {
- GetBootstrapBasename(options_, target_basename, &target_basename);
+ p->Emit(R"(
+ #ifdef SWIG
+ #error "Do not SWIG-wrap protobufs."
+ #endif // SWIG
+ )");
}
- format("#include \"$1$.proto.h\" // IWYU pragma: export\n",
- target_basename);
- } else {
- GenerateLibraryIncludes(printer);
- }
-
- if (options_.transitive_pb_h) {
- GenerateDependencyIncludes(printer);
- }
-
- // This is unfortunately necessary for some plugins. I don't see why we
- // need two of the same insertion points.
- // TODO(gerbens) remove this.
- format("// @@protoc_insertion_point(includes)\n");
-
- GenerateMetadataPragma(printer, info_path);
-
- if (!options_.proto_h) {
- GenerateHeader(printer);
- } else {
- {
- NamespaceOpener ns(Namespace(file_, options_), format);
- format(
- "\n"
- "// @@protoc_insertion_point(namespace_scope)\n");
+ if (IsBootstrapProto(options_, file_)) {
+ p->Emit({{"name", StripProto(file_->name())}}, R"cc(
+ // IWYU pragma: private, include "$name$.proto.h"
+ )cc");
}
- format(
- "\n"
- "// @@protoc_insertion_point(global_scope)\n"
- "\n");
- }
- GenerateBottomHeaderGuard(printer, true);
+ p->Emit(
+ {
+ {"library_includes", [&] { GenerateLibraryIncludes(p); }},
+ {"proto_includes",
+ [&] {
+ for (int i = 0; i < file_->public_dependency_count(); ++i) {
+ const FileDescriptor* dep = file_->public_dependency(i);
+ p->Emit({{"name", StripProto(dep->name())}}, R"(
+ #include "$name$.proto.h"
+ )");
+ }
+ }},
+ {"metadata_pragma", [&] { GenerateMetadataPragma(p, info_path); }},
+ {"header_main", [&] { GenerateSharedHeaderCode(p); }},
+ },
+ R"cc(
+ $library_includes$;
+ $proto_includes$;
+ // @@protoc_insertion_point(includes)
+
+ $metadata_pragma$;
+ $header_main$;
+ )cc");
+ });
}
-void FileGenerator::GeneratePBDeps(io::Printer* printer,
- const TProtoStringType& info_path) {
- Formatter format(printer, variables_);
-
- GenerateTopHeaderGuard(printer, true, true);
-
- GenerateDependencyIncludes(printer);
-
- GenerateBottomHeaderGuard(printer, true, true);
+void FileGenerator::GeneratePBHeader(io::Printer* p,
+ y_absl::string_view info_path) {
+ GenerateFile(p, GeneratedFileType::kPbH, [&] {
+ p->Emit(
+ {
+ {"library_includes",
+ [&] {
+ if (options_.proto_h) {
+ TProtoStringType target_basename = StripProto(file_->name());
+ if (!options_.opensource_runtime) {
+ GetBootstrapBasename(options_, target_basename,
+ &target_basename);
+ }
+ p->Emit({{"name", target_basename}}, R"(
+ #include "$name$.proto.h" // IWYU pragma: export
+ )");
+ } else {
+ GenerateLibraryIncludes(p);
+ }
+ }},
+ {"proto_includes",
+ [&] {
+ if (options_.transitive_pb_h) {
+ GenerateDependencyIncludes(p);
+ }
+ }},
+ {"metadata_pragma", [&] { GenerateMetadataPragma(p, info_path); }},
+ {"header_main",
+ [&] {
+ if (!options_.proto_h) {
+ GenerateSharedHeaderCode(p);
+ return;
+ }
+
+ {
+ NamespaceOpener ns(Namespace(file_, options_), p);
+ p->Emit(R"cc(
+
+ // @@protoc_insertion_point(namespace_scope)
+ )cc");
+ }
+ p->Emit(R"cc(
+
+ // @@protoc_insertion_point(global_scope)
+ )cc");
+ }},
+ },
+ R"cc(
+ $library_includes$;
+ $proto_includes$;
+ // @@protoc_insertion_point(includes)
+
+ $metadata_pragma$;
+ $header_main$;
+ )cc");
+ });
}
-void FileGenerator::DoIncludeFile(const TProtoStringType& google3_name,
- bool do_export, io::Printer* printer) {
- Formatter format(printer, variables_);
- const TProtoStringType prefix = "net/proto2/";
- GOOGLE_CHECK(google3_name.find(prefix) == 0) << google3_name;
+void FileGenerator::DoIncludeFile(y_absl::string_view google3_name,
+ bool do_export, io::Printer* p) {
+ constexpr y_absl::string_view prefix = "third_party/protobuf/";
+ Y_ABSL_CHECK(y_absl::StartsWith(google3_name, prefix)) << google3_name;
+
+ auto v = p->WithVars(
+ {{"export_suffix", do_export ? "// IWYU pragma: export" : ""}});
if (options_.opensource_runtime) {
- TProtoStringType path = google3_name.substr(prefix.size());
+ y_absl::ConsumePrefix(&google3_name, prefix);
+ y_absl::ConsumePrefix(&google3_name, "internal/");
+ y_absl::ConsumePrefix(&google3_name, "proto/");
+ y_absl::ConsumePrefix(&google3_name, "public/");
+
+ TProtoStringType path;
+ if (y_absl::ConsumePrefix(&google3_name, "io/public/")) {
+ path = y_absl::StrCat("io/", google3_name);
+ } else {
+ path = TProtoStringType(google3_name);
+ }
- path = StringReplace(path, "internal/", "", false);
- path = StringReplace(path, "proto/", "", false);
- path = StringReplace(path, "public/", "", false);
if (options_.runtime_include_base.empty()) {
- format("#include <google/protobuf/$1$>", path);
+ p->Emit({{"path", path}}, R"(
+ #include "google/protobuf/$path$"$ export_suffix$
+ )");
} else {
- format("#include \"$1$google/protobuf/$2$\"",
- options_.runtime_include_base, path);
+ p->Emit({{"base", options_.runtime_include_base}, {"path", path}},
+ R"(
+ #include "$base$google/protobuf/$path$"$ export_suffix$
+ )");
}
} else {
- TProtoStringType path = 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);
+ constexpr y_absl::string_view bootstrap_prefix = "net/proto2/public";
+ if (y_absl::ConsumePrefix(&google3_name, bootstrap_prefix)) {
+ path = y_absl::StrCat("third_party/protobuf", google3_name);
+ }
}
- format("#include \"$1$\"", path);
- }
- if (do_export) {
- format(" // IWYU pragma: export");
+ p->Emit({{"path", path}}, R"(
+ #include "$path$"$ export_suffix$
+ )");
}
-
- format("\n");
}
-TProtoStringType FileGenerator::CreateHeaderInclude(const TProtoStringType& basename,
+TProtoStringType FileGenerator::CreateHeaderInclude(y_absl::string_view basename,
const FileDescriptor* file) {
- bool use_system_include = false;
- TProtoStringType name = basename;
-
- if (options_.opensource_runtime) {
- if (IsWellKnownMessage(file)) {
- if (options_.runtime_include_base.empty()) {
- use_system_include = true;
- } else {
- name = options_.runtime_include_base + basename;
- }
- }
+ if (options_.opensource_runtime && IsWellKnownMessage(file) &&
+ !options_.runtime_include_base.empty()) {
+ return y_absl::StrCat("\"", options_.runtime_include_base, basename, "\"");
}
- TProtoStringType left = "\"";
- TProtoStringType right = "\"";
- if (use_system_include) {
- left = "<";
- right = ">";
- }
- return left + name + right;
+ return y_absl::StrCat("\"", basename, "\"");
}
-void FileGenerator::GenerateSourceIncludes(io::Printer* printer) {
- Formatter format(printer, variables_);
+void FileGenerator::GenerateSourceIncludes(io::Printer* p) {
TProtoStringType target_basename = StripProto(file_->name());
if (!options_.opensource_runtime) {
GetBootstrapBasename(options_, target_basename, &target_basename);
}
- target_basename += options_.proto_h ? ".proto.h" : ".pb.h";
- format(
- "// Generated by the protocol buffer compiler. DO NOT EDIT!\n"
- "// source: $filename$\n"
- "\n"
- "#include $1$\n"
- "\n"
- "#include <algorithm>\n" // for swap()
- "\n",
- CreateHeaderInclude(target_basename, file_));
- if (!options_.transitive_pb_h) {
- GenerateDependencyIncludes(printer);
- }
+ y_absl::StrAppend(&target_basename, options_.proto_h ? ".proto.h" : ".pb.h");
+ p->Emit({{"h_include", CreateHeaderInclude(target_basename, file_)}},
+ R"(
+ // Generated by the protocol buffer compiler. DO NOT EDIT!
+ // source: $filename$
- IncludeFile("net/proto2/io/public/coded_stream.h", printer);
+ #)" "include" R"( $h_include$
+
+ #include <algorithm>
+ )");
+
+ IncludeFile("third_party/protobuf/io/coded_stream.h", p);
// TODO(gerbens) This is to include parse_context.h, we need a better way
- IncludeFile("net/proto2/public/extension_set.h", printer);
- IncludeFile("net/proto2/public/wire_format_lite.h", printer);
+ IncludeFile("third_party/protobuf/extension_set.h", p);
+ IncludeFile("third_party/protobuf/wire_format_lite.h", p);
// Unknown fields implementation in lite mode uses StringOutputStream
if (!UseUnknownFieldSet(file_, options_) && !message_generators_.empty()) {
- IncludeFile("net/proto2/io/public/zero_copy_stream_impl_lite.h", printer);
+ IncludeFile("third_party/protobuf/io/zero_copy_stream_impl_lite.h", p);
}
if (HasDescriptorMethods(file_, options_)) {
- IncludeFile("net/proto2/public/descriptor.h", printer);
- IncludeFile("net/proto2/public/generated_message_reflection.h", printer);
- IncludeFile("net/proto2/public/reflection_ops.h", printer);
- IncludeFile("net/proto2/public/wire_format.h", printer);
+ IncludeFile("third_party/protobuf/descriptor.h", p);
+ IncludeFile("third_party/protobuf/generated_message_reflection.h", p);
+ IncludeFile("third_party/protobuf/reflection_ops.h", p);
+ IncludeFile("third_party/protobuf/wire_format.h", p);
}
if (HasGeneratedMethods(file_, options_) &&
options_.tctable_mode != Options::kTCTableNever) {
- IncludeFile("net/proto2/public/generated_message_tctable_impl.h", printer);
+ IncludeFile("third_party/protobuf/generated_message_tctable_impl.h", p);
}
if (options_.proto_h) {
// Use the smaller .proto.h files.
- for (int i = 0; i < file_->dependency_count(); i++) {
+ for (int i = 0; i < file_->dependency_count(); ++i) {
const FileDescriptor* dep = file_->dependency(i);
- // Do not import weak deps.
- if (!options_.opensource_runtime && IsDepWeak(dep)) continue;
+
+ if (!options_.opensource_runtime &&
+ IsDepWeak(dep)) { // Do not import weak deps.
+ continue;
+ }
+
TProtoStringType basename = StripProto(dep->name());
if (IsBootstrapProto(options_, file_)) {
GetBootstrapBasename(options_, basename, &basename);
}
- format("#include \"$1$.proto.h\"\n", basename);
+ p->Emit({{"name", basename}}, R"(
+ #include "$name$.proto.h"
+ )");
}
}
+
if (HasCordFields(file_, options_)) {
- format(
- "#include \"third_party/absl/strings/internal/string_constant.h\"\n");
+ p->Emit(R"(
+ #include "y_absl/strings/internal/string_constant.h"
+ )");
}
- format("// @@protoc_insertion_point(includes)\n");
- IncludeFile("net/proto2/public/port_def.inc", printer);
-}
+ p->Emit(R"cc(
+ // @@protoc_insertion_point(includes)
-void FileGenerator::GenerateSourcePrelude(io::Printer* printer) {
- Formatter format(printer, variables_);
+ // Must be included last.
+ )cc");
+ IncludeFile("third_party/protobuf/port_def.inc", p);
+}
+void FileGenerator::GenerateSourcePrelude(io::Printer* p) {
// 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_));
+ p->Emit(R"cc(
+ PROTOBUF_PRAGMA_INIT_SEG
+ namespace _pb = ::$proto_ns$;
+ namespace _pbi = ::$proto_ns$::internal;
+ )cc");
+
if (HasGeneratedMethods(file_, options_) &&
options_.tctable_mode != Options::kTCTableNever) {
- format("namespace _fl = _pbi::field_layout;\n");
+ p->Emit(R"cc(
+ namespace _fl = ::$proto_ns$::internal::field_layout;
+ )cc");
}
- format("\n");
}
-void FileGenerator::GenerateSourceDefaultInstance(int idx,
- io::Printer* printer) {
- Formatter format(printer, variables_);
+void FileGenerator::GenerateSourceDefaultInstance(int idx, io::Printer* p) {
MessageGenerator* generator = message_generators_[idx].get();
+
// Generate the split instance first because it's needed in the constexpr
// constructor.
- if (ShouldSplit(generator->descriptor_, options_)) {
+ if (ShouldSplit(generator->descriptor(), options_)) {
// Use a union to disable the destructor of the _instance member.
// We can constant initialize, but the object will still have a non-trivial
// destructor that we need to elide.
- format(
- "struct $1$ {\n"
- " PROTOBUF_CONSTEXPR $1$()\n"
- " : _instance{",
- DefaultInstanceType(generator->descriptor_, options_,
- /*split=*/true));
- generator->GenerateInitDefaultSplitInstance(printer);
- format(
- "} {}\n"
- " ~$1$() {}\n"
- " union {\n"
- " $2$ _instance;\n"
- " };\n"
- "};\n",
- DefaultInstanceType(generator->descriptor_, options_, /*split=*/true),
- StrCat(generator->classname_, "::Impl_::Split"));
+ //
// NO_DESTROY is not necessary for correctness. The empty destructor is
// 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 "
- "PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 $1$ $2$;\n",
- DefaultInstanceType(generator->descriptor_, options_, /*split=*/true),
- DefaultInstanceName(generator->descriptor_, options_, /*split=*/true));
- }
-
- generator->GenerateConstexprConstructor(printer);
- format(
- "struct $1$ {\n"
- " PROTOBUF_CONSTEXPR $1$()\n"
- " : _instance(::_pbi::ConstantInitialized{}) {}\n"
- " ~$1$() {}\n"
- " union {\n"
- " $2$ _instance;\n"
- " };\n"
- "};\n",
- DefaultInstanceType(generator->descriptor_, options_),
- generator->classname_);
- format(
- "PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT "
- "PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 $1$ $2$;\n",
- DefaultInstanceType(generator->descriptor_, options_),
- DefaultInstanceName(generator->descriptor_, options_));
-
- for (int i = 0; i < generator->descriptor_->field_count(); i++) {
- const FieldDescriptor* field = generator->descriptor_->field(i);
- if (IsStringInlined(field, options_)) {
- // Force the initialization of the inlined string in the default instance.
- format(
- "PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 std::true_type "
- "$1$::Impl_::_init_inline_$2$_ = "
- "($3$._instance.$4$.Init(), std::true_type{});\n",
- ClassName(generator->descriptor_), FieldName(field),
- DefaultInstanceName(generator->descriptor_, options_),
- FieldMemberName(field, ShouldSplit(field, options_)));
+ p->Emit(
+ {
+ {"type", DefaultInstanceType(generator->descriptor(), options_,
+ /*split=*/true)},
+ {"name", DefaultInstanceName(generator->descriptor(), options_,
+ /*split=*/true)},
+ {"default",
+ [&] { generator->GenerateInitDefaultSplitInstance(p); }},
+ {"class", y_absl::StrCat(ClassName(generator->descriptor()),
+ "::Impl_::Split")},
+ },
+ R"cc(
+ struct $type$ {
+ PROTOBUF_CONSTEXPR $type$() : _instance{$default$} {}
+ union {
+ $class$ _instance;
+ };
+ };
+
+ PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 const $type$ $name$;
+ )cc");
+ }
+
+ generator->GenerateConstexprConstructor(p);
+
+ p->Emit(
+ {
+ {"type", DefaultInstanceType(generator->descriptor(), options_)},
+ {"name", DefaultInstanceName(generator->descriptor(), options_)},
+ {"default", [&] { generator->GenerateInitDefaultSplitInstance(p); }},
+ {"class", ClassName(generator->descriptor())},
+ },
+ R"cc(
+ struct $type$ {
+ PROTOBUF_CONSTEXPR $type$() : _instance(::_pbi::ConstantInitialized{}) {}
+ ~$type$() {}
+ union {
+ $class$ _instance;
+ };
+ };
+
+ PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 $type$ $name$;
+ )cc");
+
+ for (int i = 0; i < generator->descriptor()->field_count(); ++i) {
+ const FieldDescriptor* field = generator->descriptor()->field(i);
+ if (!IsStringInlined(field, options_)) {
+ continue;
}
+
+ // Force the initialization of the inlined string in the default instance.
+ p->Emit(
+ {
+ {"class", ClassName(generator->descriptor())},
+ {"field", FieldName(field)},
+ {"default", DefaultInstanceName(generator->descriptor(), options_)},
+ {"member", FieldMemberName(field, ShouldSplit(field, options_))},
+ },
+ R"cc(
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 std::true_type
+ $class$::Impl_::_init_inline_$field$_ =
+ ($default$._instance.$member$.Init(), std::true_type{});
+ )cc");
}
if (options_.lite_implicit_weak_fields) {
- format(
- "PROTOBUF_CONSTINIT const void* $1$ =\n"
- " &$2$;\n",
- DefaultInstancePtr(generator->descriptor_, options_),
- DefaultInstanceName(generator->descriptor_, options_));
+ p->Emit(
+ {
+ {"ptr", DefaultInstancePtr(generator->descriptor(), options_)},
+ {"name", DefaultInstanceName(generator->descriptor(), options_)},
+ },
+ R"cc(
+ PROTOBUF_CONSTINIT const void* $ptr$ = &$name$;
+ )cc");
}
}
// A list of things defined in one .pb.cc file that we need to reference from
// another .pb.cc file.
struct FileGenerator::CrossFileReferences {
+ // When we forward-declare things, we want to create a sorted order so our
+ // output is deterministic and minimizes namespace changes.
+ struct DescCompare {
+ template <typename T>
+ bool operator()(const T* const& a, const T* const& b) const {
+ return a->full_name() < b->full_name();
+ }
+
+ bool operator()(const FileDescriptor* const& a,
+ const FileDescriptor* const& b) const {
+ return a->name() < b->name();
+ }
+ };
+
// Populated if we are referencing from messages or files.
- std::unordered_set<const Descriptor*> weak_default_instances;
+ y_absl::btree_set<const Descriptor*, DescCompare> weak_default_instances;
// Only if we are referencing from files.
- std::unordered_set<const FileDescriptor*> strong_reflection_files;
- std::unordered_set<const FileDescriptor*> weak_reflection_files;
+ y_absl::btree_set<const FileDescriptor*, DescCompare> strong_reflection_files;
+ y_absl::btree_set<const FileDescriptor*, DescCompare> weak_reflection_files;
};
void FileGenerator::GetCrossFileReferencesForField(const FieldDescriptor* field,
CrossFileReferences* refs) {
const Descriptor* msg = field->message_type();
- if (msg == nullptr) return;
+ if (msg == nullptr) {
+ return;
+ }
if (IsImplicitWeakField(field, options_, &scc_analyzer_) ||
IsWeak(field, options_)) {
@@ -598,10 +658,13 @@ void FileGenerator::GetCrossFileReferencesForFile(const FileDescriptor* file,
GetCrossFileReferencesForField(field, refs);
});
- if (!HasDescriptorMethods(file, options_)) return;
+ if (!HasDescriptorMethods(file, options_)) {
+ return;
+ }
- for (int i = 0; i < file->dependency_count(); i++) {
+ for (int i = 0; i < file->dependency_count(); ++i) {
const FileDescriptor* dep = file->dependency(i);
+
if (IsDepWeak(dep)) {
refs->weak_reflection_files.insert(dep);
} else {
@@ -612,119 +675,128 @@ void FileGenerator::GetCrossFileReferencesForFile(const FileDescriptor* file,
// Generates references to variables defined in other files.
void FileGenerator::GenerateInternalForwardDeclarations(
- const CrossFileReferences& refs, io::Printer* printer) {
- Formatter format(printer, variables_);
-
+ const CrossFileReferences& refs, io::Printer* p) {
{
- NamespaceOpener ns(format);
- for (auto instance : Sorted(refs.weak_default_instances)) {
+ NamespaceOpener ns(p);
+ for (auto instance : refs.weak_default_instances) {
ns.ChangeTo(Namespace(instance, options_));
+
if (options_.lite_implicit_weak_fields) {
- format(
- "PROTOBUF_CONSTINIT __attribute__((weak)) const void* $1$ =\n"
- " &::_pbi::implicit_weak_message_default_instance;\n",
- DefaultInstancePtr(instance, options_));
+ p->Emit({{"ptr", DefaultInstancePtr(instance, options_)}}, R"cc(
+ PROTOBUF_CONSTINIT __attribute__((weak)) const void* $ptr$ =
+ &::_pbi::implicit_weak_message_default_instance;
+ )cc");
} else {
- format("extern __attribute__((weak)) $1$ $2$;\n",
- DefaultInstanceType(instance, options_),
- DefaultInstanceName(instance, options_));
+ p->Emit({{"type", DefaultInstanceType(instance, options_)},
+ {"name", DefaultInstanceName(instance, options_)}},
+ R"cc(
+ extern __attribute__((weak)) $type$ $name$;
+ )cc");
}
}
}
- for (auto file : Sorted(refs.weak_reflection_files)) {
- format(
- "extern __attribute__((weak)) const ::_pbi::DescriptorTable $1$;\n",
- DescriptorTableName(file, options_));
+ for (auto file : refs.weak_reflection_files) {
+ p->Emit({{"table", DescriptorTableName(file, options_)}}, R"cc(
+ extern __attribute__((weak)) const ::_pbi::DescriptorTable $table$;
+ )cc");
}
}
-void FileGenerator::GenerateSourceForMessage(int idx, io::Printer* printer) {
- Formatter format(printer, variables_);
- GenerateSourceIncludes(printer);
- GenerateSourcePrelude(printer);
+void FileGenerator::GenerateSourceForMessage(int idx, io::Printer* p) {
+ auto v = p->WithVars(FileVars(file_, options_));
- if (IsAnyMessage(file_, options_)) MuteWuninitialized(format);
+ GenerateSourceIncludes(p);
+ GenerateSourcePrelude(p);
+
+ if (IsAnyMessage(file_, options_)) {
+ MuteWuninitialized(p);
+ }
CrossFileReferences refs;
- ForEachField(message_generators_[idx]->descriptor_,
+ ForEachField(message_generators_[idx]->descriptor(),
[this, &refs](const FieldDescriptor* field) {
GetCrossFileReferencesForField(field, &refs);
});
- GenerateInternalForwardDeclarations(refs, printer);
- { // package namespace
- NamespaceOpener ns(Namespace(file_, options_), format);
+ GenerateInternalForwardDeclarations(refs, p);
- // Define default instances
- GenerateSourceDefaultInstance(idx, printer);
+ {
+ NamespaceOpener ns(Namespace(file_, options_), p);
+ p->Emit(
+ {
+ {"defaults", [&] { GenerateSourceDefaultInstance(idx, p); }},
+ {"class_methods",
+ [&] { message_generators_[idx]->GenerateClassMethods(p); }},
+ },
+ R"cc(
+ $defaults$;
- // Generate classes.
- format("\n");
- message_generators_[idx]->GenerateClassMethods(printer);
+ $class_methods$;
- format(
- "\n"
- "// @@protoc_insertion_point(namespace_scope)\n");
- } // end package namespace
+ // @@protoc_insertion_point(namespace_scope)
+ )cc");
+ }
{
- NamespaceOpener proto_ns(ProtobufNamespace(options_), format);
- message_generators_[idx]->GenerateSourceInProto2Namespace(printer);
+ NamespaceOpener proto_ns(ProtobufNamespace(options_), p);
+ message_generators_[idx]->GenerateSourceInProto2Namespace(p);
}
- if (IsAnyMessage(file_, options_)) UnmuteWuninitialized(format);
+ if (IsAnyMessage(file_, options_)) {
+ UnmuteWuninitialized(p);
+ }
- format(
- "\n"
- "// @@protoc_insertion_point(global_scope)\n");
+ p->Emit(R"cc(
+ // @@protoc_insertion_point(global_scope)
+ )cc");
}
-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);
+void FileGenerator::GenerateSourceForExtension(int idx, io::Printer* p) {
+ auto v = p->WithVars(FileVars(file_, options_));
+ GenerateSourceIncludes(p);
+ GenerateSourcePrelude(p);
+
+ NamespaceOpener ns(Namespace(file_, options_), p);
+ extension_generators_[idx]->GenerateDefinition(p);
}
-void FileGenerator::GenerateGlobalSource(io::Printer* printer) {
- Formatter format(printer, variables_);
- GenerateSourceIncludes(printer);
- GenerateSourcePrelude(printer);
+void FileGenerator::GenerateGlobalSource(io::Printer* p) {
+ auto v = p->WithVars(FileVars(file_, options_));
+ GenerateSourceIncludes(p);
+ GenerateSourcePrelude(p);
{
// 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_)) {
- GenerateReflectionInitializationCode(printer);
+ GenerateReflectionInitializationCode(p);
}
}
- NamespaceOpener ns(Namespace(file_, options_), format);
-
- // Generate enums.
- for (int i = 0; i < enum_generators_.size(); i++) {
- enum_generators_[i]->GenerateMethods(i, printer);
+ NamespaceOpener ns(Namespace(file_, options_), p);
+ for (int i = 0; i < enum_generators_.size(); ++i) {
+ enum_generators_[i]->GenerateMethods(i, p);
}
}
-void FileGenerator::GenerateSource(io::Printer* printer) {
- Formatter format(printer, variables_);
- GenerateSourceIncludes(printer);
- GenerateSourcePrelude(printer);
+void FileGenerator::GenerateSource(io::Printer* p) {
+ auto v = p->WithVars(FileVars(file_, options_));
+
+ GenerateSourceIncludes(p);
+ GenerateSourcePrelude(p);
CrossFileReferences refs;
GetCrossFileReferencesForFile(file_, &refs);
- GenerateInternalForwardDeclarations(refs, printer);
+ GenerateInternalForwardDeclarations(refs, p);
- if (IsAnyMessage(file_, options_)) MuteWuninitialized(format);
+ if (IsAnyMessage(file_, options_)) {
+ MuteWuninitialized(p);
+ }
{
- NamespaceOpener ns(Namespace(file_, options_), format);
-
- // Define default instances
- for (int i = 0; i < message_generators_.size(); i++) {
- GenerateSourceDefaultInstance(i, printer);
+ NamespaceOpener ns(Namespace(file_, options_), p);
+ for (int i = 0; i < message_generators_.size(); ++i) {
+ GenerateSourceDefaultInstance(i, p);
}
}
@@ -732,144 +804,155 @@ void FileGenerator::GenerateSource(io::Printer* 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.
- GenerateReflectionInitializationCode(printer);
+ GenerateReflectionInitializationCode(p);
}
}
{
- NamespaceOpener ns(Namespace(file_, options_), format);
+ NamespaceOpener ns(Namespace(file_, options_), p);
// Actually implement the protos
// Generate enums.
- for (int i = 0; i < enum_generators_.size(); i++) {
- enum_generators_[i]->GenerateMethods(i, printer);
+ for (int i = 0; i < enum_generators_.size(); ++i) {
+ enum_generators_[i]->GenerateMethods(i, p);
}
// Generate classes.
- for (int i = 0; i < message_generators_.size(); i++) {
- format("\n");
- format(kThickSeparator);
- format("\n");
- message_generators_[i]->GenerateClassMethods(printer);
+ for (int i = 0; i < message_generators_.size(); ++i) {
+ p->Emit(R"(
+ $hrule_thick$
+ )");
+ message_generators_[i]->GenerateClassMethods(p);
}
if (HasGenericServices(file_, options_)) {
// Generate services.
- for (int i = 0; i < service_generators_.size(); i++) {
- if (i == 0) format("\n");
- format(kThickSeparator);
- format("\n");
- service_generators_[i]->GenerateImplementation(printer);
+ for (int i = 0; i < service_generators_.size(); ++i) {
+ p->Emit(R"(
+ $hrule_thick$
+ )");
+ service_generators_[i]->GenerateImplementation(p);
}
}
// Define extensions.
- for (int i = 0; i < extension_generators_.size(); i++) {
- extension_generators_[i]->GenerateDefinition(printer);
+ for (int i = 0; i < extension_generators_.size(); ++i) {
+ extension_generators_[i]->GenerateDefinition(p);
}
- format(
- "\n"
- "// @@protoc_insertion_point(namespace_scope)\n");
+ p->Emit(R"cc(
+ // @@protoc_insertion_point(namespace_scope)
+ )cc");
}
{
- NamespaceOpener proto_ns(ProtobufNamespace(options_), format);
- for (int i = 0; i < message_generators_.size(); i++) {
- message_generators_[i]->GenerateSourceInProto2Namespace(printer);
+ NamespaceOpener proto_ns(ProtobufNamespace(options_), p);
+ for (int i = 0; i < message_generators_.size(); ++i) {
+ message_generators_[i]->GenerateSourceInProto2Namespace(p);
}
}
- format(
- "\n"
- "// @@protoc_insertion_point(global_scope)\n");
+ p->Emit(R"cc(
+ // @@protoc_insertion_point(global_scope)
+ )cc");
- if (IsAnyMessage(file_, options_)) UnmuteWuninitialized(format);
+ if (IsAnyMessage(file_, options_)) {
+ UnmuteWuninitialized(p);
+ }
- IncludeFile("net/proto2/public/port_undef.inc", printer);
+ IncludeFile("third_party/protobuf/port_undef.inc", p);
}
-void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) {
- Formatter format(printer, variables_);
-
+void FileGenerator::GenerateReflectionInitializationCode(io::Printer* p) {
if (!message_generators_.empty()) {
- format("static ::_pb::Metadata $file_level_metadata$[$1$];\n",
- message_generators_.size());
+ p->Emit({{"len", message_generators_.size()}}, R"cc(
+ static ::_pb::Metadata $file_level_metadata$[$len$];
+ )cc");
}
+
if (!enum_generators_.empty()) {
- format(
- "static const ::_pb::EnumDescriptor* "
- "$file_level_enum_descriptors$[$1$];\n",
- enum_generators_.size());
+ p->Emit({{"len", enum_generators_.size()}}, R"cc(
+ static const ::_pb::EnumDescriptor* $file_level_enum_descriptors$[$len$];
+ )cc");
} else {
- format(
- "static "
- "constexpr ::_pb::EnumDescriptor const** "
- "$file_level_enum_descriptors$ = nullptr;\n");
+ p->Emit(R"cc(
+ static constexpr const ::_pb::EnumDescriptor**
+ $file_level_enum_descriptors$ = nullptr;
+ )cc");
}
+
if (HasGenericServices(file_, options_) && file_->service_count() > 0) {
- format(
- "static "
- "const ::_pb::ServiceDescriptor* "
- "$file_level_service_descriptors$[$1$];\n",
- file_->service_count());
+ p->Emit({{"len", file_->service_count()}}, R"cc(
+ static const ::_pb::ServiceDescriptor*
+ $file_level_service_descriptors$[$len$];
+ )cc");
} else {
- format(
- "static "
- "constexpr ::_pb::ServiceDescriptor const** "
- "$file_level_service_descriptors$ = nullptr;\n");
+ p->Emit(R"cc(
+ static constexpr const ::_pb::ServiceDescriptor**
+ $file_level_service_descriptors$ = nullptr;
+ )cc");
}
if (!message_generators_.empty()) {
- format(
- "\n"
- "const $uint32$ $tablename$::offsets[] "
- "PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n");
- format.Indent();
- std::vector<std::pair<size_t, size_t> > pairs;
- pairs.reserve(message_generators_.size());
- for (int i = 0; i < message_generators_.size(); i++) {
- pairs.push_back(message_generators_[i]->GenerateOffsets(printer));
- }
- format.Outdent();
- format(
- "};\n"
- "static const ::_pbi::MigrationSchema schemas[] "
- "PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n");
- format.Indent();
- {
- int offset = 0;
- for (int i = 0; i < message_generators_.size(); i++) {
- message_generators_[i]->GenerateSchema(printer, offset,
- pairs[i].second);
- offset += pairs[i].first;
- }
- }
- format.Outdent();
- format(
- "};\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("&$1$::_$2$_default_instance_._instance,\n",
- Namespace(descriptor, options_), // 1
- ClassName(descriptor)); // 2
- }
- format.Outdent();
- format(
- "};\n"
- "\n");
+ std::vector<std::pair<size_t, size_t>> offsets;
+ offsets.reserve(message_generators_.size());
+
+ p->Emit(
+ {
+ {"offsets",
+ [&] {
+ for (int i = 0; i < message_generators_.size(); ++i) {
+ offsets.push_back(message_generators_[i]->GenerateOffsets(p));
+ }
+ }},
+ {"schemas",
+ [&] {
+ int offset = 0;
+ for (int i = 0; i < message_generators_.size(); ++i) {
+ message_generators_[i]->GenerateSchema(p, offset,
+ offsets[i].second);
+ offset += offsets[i].first;
+ }
+ }},
+ {"defaults",
+ [&] {
+ for (auto& gen : message_generators_) {
+ p->Emit(
+ {
+ {"ns", Namespace(gen->descriptor(), options_)},
+ {"class", ClassName(gen->descriptor())},
+ },
+ R"cc(
+ &$ns$::_$class$_default_instance_._instance,
+ )cc");
+ }
+ }},
+ },
+ R"cc(
+ const ::arc_ui32 $tablename$::offsets[] PROTOBUF_SECTION_VARIABLE(
+ protodesc_cold) = {
+ $offsets$,
+ };
+
+ static const ::_pbi::MigrationSchema
+ schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ $schemas$,
+ };
+
+ static const ::_pb::Message* const file_default_instances[] = {
+ $defaults$,
+ };
+ )cc");
} else {
- // we still need these symbols to exist
- format(
- // MSVC doesn't like empty arrays, so we add a dummy.
- "const $uint32$ $tablename$::offsets[1] = {};\n"
- "static constexpr ::_pbi::MigrationSchema* schemas = nullptr;\n"
- "static constexpr ::_pb::Message* const* "
- "file_default_instances = nullptr;\n"
- "\n");
+ // Ee still need these symbols to exist.
+ //
+ // MSVC doesn't like empty arrays, so we add a dummy.
+ p->Emit(R"cc(
+ const ::arc_ui32 $tablename$::offsets[1] = {};
+ static constexpr ::_pbi::MigrationSchema* schemas = nullptr;
+ static constexpr ::_pb::Message* const* file_default_instances = nullptr;
+ )cc");
}
// ---------------------------------------------------------------
@@ -877,63 +960,87 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) {
// Embed the descriptor. We simply serialize the entire
// FileDescriptorProto/ and embed it as a string literal, which is parsed and
// built into real descriptors at initialization time.
- const TProtoStringType protodef_name =
- UniqueName("descriptor_table_protodef", file_, options_);
- format("const char $1$[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =\n",
- protodef_name);
- format.Indent();
- FileDescriptorProto file_proto;
- file_->CopyTo(&file_proto);
+
+ FileDescriptorProto file_proto = StripSourceRetentionOptions(*file_);
TProtoStringType file_data;
file_proto.SerializeToString(&file_data);
- {
- if (file_data.size() > 65535) {
- // Workaround for MSVC: "Error C1091: compiler limit: string exceeds
- // 65535 bytes in length". Declare a static array of chars rather than
- // use a string literal. Only write 25 bytes per line.
- static const int kBytesPerLine = 25;
- format("{ ");
- for (int i = 0; i < file_data.size();) {
- for (int j = 0; j < kBytesPerLine && i < file_data.size(); ++i, ++j) {
- format("'$1$', ", CEscape(file_data.substr(i, 1)));
- }
- format("\n");
- }
- format("'\\0' }"); // null-terminate
- } else {
- // Only write 40 bytes per line.
- static const int kBytesPerLine = 40;
- for (int i = 0; i < file_data.size(); i += kBytesPerLine) {
- format(
- "\"$1$\"\n",
- EscapeTrigraphs(CEscape(file_data.substr(i, kBytesPerLine))));
- }
- }
- format(";\n");
- }
- format.Outdent();
+ auto desc_name = UniqueName("descriptor_table_protodef", file_, options_);
+ p->Emit(
+ {{"desc_name", desc_name},
+ {"encoded_file_proto",
+ [&] {
+ y_absl::string_view data = file_data;
+ if (data.size() <= 65535) {
+ static constexpr size_t kBytesPerLine = 40;
+ while (!data.empty()) {
+ auto to_write = std::min(kBytesPerLine, data.size());
+ auto chunk = data.substr(0, to_write);
+ data = data.substr(to_write);
+
+ p->Emit({{"text", EscapeTrigraphs(y_absl::CEscape(chunk))}}, R"cc(
+ "$text$"
+ )cc");
+ }
+ return;
+ }
+
+ // Workaround for MSVC: "Error C1091: compiler limit: string exceeds
+ // 65535 bytes in length". Declare a static array of chars rather than
+ // use a string literal. Only write 25 bytes per line.
+ static constexpr size_t kBytesPerLine = 25;
+ while (!data.empty()) {
+ auto to_write = std::min(kBytesPerLine, data.size());
+ auto chunk = data.substr(0, to_write);
+ data = data.substr(to_write);
+
+ TProtoStringType line;
+ for (char c : chunk) {
+ y_absl::StrAppend(&line, "'",
+ y_absl::CEscape(y_absl::string_view(&c, 1)), "', ");
+ }
+
+ p->Emit({{"line", line}}, R"cc(
+ $line$
+ )cc");
+ }
+ }}},
+ R"cc(
+ const char $desc_name$[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ $encoded_file_proto$,
+ };
+ )cc");
CrossFileReferences refs;
GetCrossFileReferencesForFile(file_, &refs);
- int num_deps =
+ size_t num_deps =
refs.strong_reflection_files.size() + refs.weak_reflection_files.size();
// Build array of DescriptorTable deps.
if (num_deps > 0) {
- format(
- "static const ::_pbi::DescriptorTable* const "
- "$desc_table$_deps[$1$] = {\n",
- num_deps);
-
- for (auto dep : Sorted(refs.strong_reflection_files)) {
- format(" &::$1$,\n", DescriptorTableName(dep, options_));
- }
- for (auto dep : Sorted(refs.weak_reflection_files)) {
- format(" &::$1$,\n", DescriptorTableName(dep, options_));
- }
-
- format("};\n");
+ p->Emit(
+ {
+ {"len", num_deps},
+ {"deps",
+ [&] {
+ for (auto dep : refs.strong_reflection_files) {
+ p->Emit({{"name", DescriptorTableName(dep, options_)}}, R"cc(
+ &::$name$,
+ )cc");
+ }
+ for (auto dep : refs.weak_reflection_files) {
+ p->Emit({{"name", DescriptorTableName(dep, options_)}}, R"cc(
+ &::$name$,
+ )cc");
+ }
+ }},
+ },
+ R"cc(
+ static const ::_pbi::DescriptorTable* const $desc_table$_deps[$len$] =
+ {
+ $deps$,
+ };
+ )cc");
}
// The DescriptorTable itself.
@@ -941,391 +1048,354 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) {
// however this might cause a tsan failure in superroot b/148382879,
// so disable for now.
bool eager = false;
- format(
- "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
- // the .pb.cc translation units. Large translation units see a reduction
- // of more than 35% of walltime for optimized builds.
- // Without the weak attribute all the messages in the file, including all
- // the vtables and everything they use become part of the same SCC through
- // a cycle like:
- // GetMetadata -> descriptor table -> default instances ->
- // 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 ::_pbi::DescriptorTable* "
- "$desc_table$_getter() {\n"
- " return &$desc_table$;\n"
- "}\n"
- "\n",
- eager ? "true" : "false", file_data.size(), protodef_name,
- num_deps == 0 ? "nullptr" : variables_["desc_table"] + "_deps", num_deps,
- message_generators_.size(),
- message_generators_.empty() ? "nullptr"
- : variables_["file_level_metadata"]);
+ p->Emit(
+ {
+ {"eager", eager ? "true" : "false"},
+ {"file_proto_len", file_data.size()},
+ {"proto_name", desc_name},
+ {"deps_ptr", num_deps == 0
+ ? "nullptr"
+ : y_absl::StrCat(p->LookupVar("desc_table"), "_deps")},
+ {"num_deps", num_deps},
+ {"num_msgs", message_generators_.size()},
+ {"msgs_ptr", message_generators_.empty()
+ ? "nullptr"
+ : TProtoStringType(p->LookupVar("file_level_metadata"))},
+ },
+ R"cc(
+ static ::y_absl::once_flag $desc_table$_once;
+ const ::_pbi::DescriptorTable $desc_table$ = {
+ false,
+ $eager$,
+ $file_proto_len$,
+ $proto_name$,
+ "$filename$",
+ &$desc_table$_once,
+ $deps_ptr$,
+ $num_deps$,
+ $num_msgs$,
+ schemas,
+ file_default_instances,
+ $tablename$::offsets,
+ $msgs_ptr$,
+ $file_level_enum_descriptors$,
+ $file_level_service_descriptors$,
+ };
+
+ // This function exists to be marked as weak.
+ // It can significantly speed up compilation by breaking up LLVM's SCC
+ // in the .pb.cc translation units. Large translation units see a
+ // reduction of more than 35% of walltime for optimized builds. Without
+ // the weak attribute all the messages in the file, including all the
+ // vtables and everything they use become part of the same SCC through
+ // a cycle like:
+ // GetMetadata -> descriptor table -> default instances ->
+ // 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 ::_pbi::DescriptorTable* $desc_table$_getter() {
+ return &$desc_table$;
+ }
+ )cc");
// For descriptor.proto we want to avoid doing any dynamic initialization,
// because in some situations that would otherwise pull in a lot of
// unnecessary code that can't be stripped by --gc-sections. Descriptor
// initialization will still be performed lazily when it's needed.
- if (file_->name() != "net/proto2/proto/descriptor.proto") {
- format(
- "// Force running AddDescriptors() at dynamic initialization time.\n"
- "PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 "
- "static ::_pbi::AddDescriptorsRunner $1$(&$desc_table$);\n",
- UniqueName("dynamic_init_dummy", file_, options_));
+ if (file_->name() == "net/proto2/proto/descriptor.proto") {
+ return;
}
+
+ p->Emit({{"dummy", UniqueName("dynamic_init_dummy", file_, options_)}}, R"cc(
+ // Force running AddDescriptors() at dynamic initialization time.
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY2
+ static ::_pbi::AddDescriptorsRunner $dummy$(&$desc_table$);
+ )cc");
}
class FileGenerator::ForwardDeclarations {
public:
- void AddMessage(const Descriptor* d) { classes_[ClassName(d)] = d; }
- void AddEnum(const EnumDescriptor* d) { enums_[ClassName(d)] = d; }
- void AddSplit(const Descriptor* d) { splits_[ClassName(d)] = d; }
-
- void Print(const Formatter& format, const Options& options) const {
- for (const auto& p : enums_) {
- const TProtoStringType& enumname = p.first;
- const EnumDescriptor* enum_desc = p.second;
- format(
- "enum ${1$$2$$}$ : int;\n"
- "bool $2$_IsValid(int value);\n",
- enum_desc, enumname);
+ void AddMessage(const Descriptor* d) { classes_.emplace(ClassName(d), d); }
+ void AddEnum(const EnumDescriptor* d) { enums_.emplace(ClassName(d), d); }
+ void AddSplit(const Descriptor* d) { splits_.emplace(ClassName(d), d); }
+
+ void Print(io::Printer* p, const Options& options) const {
+ for (const auto& e : enums_) {
+ p->Emit({Sub("enum", e.first).AnnotatedAs(e.second)}, R"cc(
+ enum $enum$ : int;
+ bool $enum$_IsValid(int value);
+ )cc");
}
- for (const auto& p : classes_) {
- const TProtoStringType& classname = p.first;
- const Descriptor* class_desc = p.second;
- format(
- "class ${1$$2$$}$;\n"
- "struct $3$;\n"
- "$dllexport_decl $extern $3$ $4$;\n",
- class_desc, classname, DefaultInstanceType(class_desc, options),
- DefaultInstanceName(class_desc, options));
+
+ for (const auto& c : classes_) {
+ const Descriptor* desc = c.second;
+ p->Emit(
+ {
+ Sub("class", c.first).AnnotatedAs(desc),
+ {"default_type", DefaultInstanceType(desc, options)},
+ {"default_name", DefaultInstanceName(desc, options)},
+ },
+ R"cc(
+ class $class$;
+ struct $default_type$;
+ $dllexport_decl $extern $default_type$ $default_name$;
+ )cc");
}
- for (const auto& p : splits_) {
- const Descriptor* class_desc = p.second;
- format(
- "struct $1$;\n"
- "$dllexport_decl $extern $1$ $2$;\n",
- DefaultInstanceType(class_desc, options, /*split=*/true),
- DefaultInstanceName(class_desc, options, /*split=*/true));
+
+ for (const auto& s : splits_) {
+ const Descriptor* desc = s.second;
+ p->Emit(
+ {
+ {"default_type",
+ DefaultInstanceType(desc, options, /*split=*/true)},
+ {"default_name",
+ DefaultInstanceName(desc, options, /*split=*/true)},
+ },
+ R"cc(
+ struct $default_type$;
+ $dllexport_decl $extern const $default_type$ $default_name$;
+ )cc");
}
}
- void PrintTopLevelDecl(const Formatter& format,
- const Options& options) const {
- for (const auto& pair : classes_) {
- format(
- "template<> $dllexport_decl $"
- "$1$* Arena::CreateMaybeMessage<$1$>(Arena*);\n",
- QualifiedClassName(pair.second, options));
+ void PrintTopLevelDecl(io::Printer* p, const Options& options) const {
+ for (const auto& c : classes_) {
+ p->Emit({{"class", QualifiedClassName(c.second, options)}}, R"cc(
+ template <>
+ $dllexport_decl $$class$* Arena::CreateMaybeMessage<$class$>(Arena*);
+ )cc");
}
}
private:
- std::map<TProtoStringType, const Descriptor*> classes_;
- std::map<TProtoStringType, const EnumDescriptor*> enums_;
- std::map<TProtoStringType, const Descriptor*> splits_;
+ y_absl::btree_map<TProtoStringType, const Descriptor*> classes_;
+ y_absl::btree_map<TProtoStringType, const EnumDescriptor*> enums_;
+ y_absl::btree_map<TProtoStringType, const Descriptor*> splits_;
};
-static void PublicImportDFS(const FileDescriptor* fd,
- std::unordered_set<const FileDescriptor*>* fd_set) {
- for (int i = 0; i < fd->public_dependency_count(); i++) {
+static void PublicImportDFS(
+ const FileDescriptor* fd,
+ y_absl::flat_hash_set<const FileDescriptor*>& fd_set) {
+ for (int i = 0; i < fd->public_dependency_count(); ++i) {
const FileDescriptor* dep = fd->public_dependency(i);
- if (fd_set->insert(dep).second) PublicImportDFS(dep, fd_set);
+ if (fd_set.insert(dep).second) {
+ PublicImportDFS(dep, fd_set);
+ }
}
}
-void FileGenerator::GenerateForwardDeclarations(io::Printer* printer) {
- Formatter format(printer, variables_);
+void FileGenerator::GenerateForwardDeclarations(io::Printer* p) {
std::vector<const Descriptor*> classes;
- std::vector<const EnumDescriptor*> enums;
-
FlattenMessagesInFile(file_, &classes); // All messages need forward decls.
- std::vector<const FieldDescriptor*> fields;
- if (!options_.transitive_pb_h || options_.proto_h) {
- ListAllFields(file_, &fields);
- }
-
- if (!options_.transitive_pb_h) {
- // Add forward declaration for all messages, enums, and extended messages
- // defined outside the file
- for (int i = 0; i < fields.size(); i++) {
- const Descriptor* message_type = fields[i]->message_type();
- if (message_type && message_type->file() != file_) {
- classes.push_back(message_type);
- }
-
- const EnumDescriptor* enum_type = fields[i]->enum_type();
- if (enum_type && enum_type->file() != file_) {
- enums.push_back(enum_type);
- }
-
- if (fields[i]->is_extension()) {
- const Descriptor* message_type = fields[i]->containing_type();
- if (message_type && message_type->file() != file_) {
- classes.push_back(message_type);
- }
- }
- }
- }
-
+ std::vector<const EnumDescriptor*> enums;
if (options_.proto_h) { // proto.h needs extra forward declarations.
// All classes / enums referred to as field members
- for (int i = 0; i < fields.size(); i++) {
- classes.push_back(fields[i]->containing_type());
- classes.push_back(fields[i]->message_type());
- enums.push_back(fields[i]->enum_type());
+ std::vector<const FieldDescriptor*> fields;
+ ListAllFields(file_, &fields);
+ for (const auto* field : fields) {
+ classes.push_back(field->containing_type());
+ classes.push_back(field->message_type());
+ enums.push_back(field->enum_type());
}
+
ListAllTypesForServices(file_, &classes);
}
// Calculate the set of files whose definitions we get through include.
// No need to forward declare types that are defined in these.
- std::unordered_set<const FileDescriptor*> public_set;
- if (options_.transitive_pb_h) {
- PublicImportDFS(file_, &public_set);
- }
+ y_absl::flat_hash_set<const FileDescriptor*> public_set;
+ PublicImportDFS(file_, public_set);
- std::map<TProtoStringType, ForwardDeclarations> decls;
- for (int i = 0; i < classes.size(); i++) {
- const Descriptor* d = classes[i];
- if (d && !public_set.count(d->file()))
+ y_absl::btree_map<TProtoStringType, ForwardDeclarations> decls;
+ for (const auto* d : classes) {
+ if (d != nullptr && !public_set.count(d->file()))
decls[Namespace(d, options_)].AddMessage(d);
}
- for (int i = 0; i < enums.size(); i++) {
- const EnumDescriptor* d = enums[i];
- if (d && !public_set.count(d->file()))
- decls[Namespace(d, options_)].AddEnum(d);
+ for (const auto* e : enums) {
+ if (e != nullptr && !public_set.count(e->file()))
+ decls[Namespace(e, options_)].AddEnum(e);
}
for (const auto& mg : message_generators_) {
- const Descriptor* d = mg->descriptor_;
- if ((d != nullptr) && (public_set.count(d->file()) == 0u) &&
- ShouldSplit(mg->descriptor_, options_))
+ const Descriptor* d = mg->descriptor();
+ if (d != nullptr && public_set.count(d->file()) == 0u &&
+ ShouldSplit(mg->descriptor(), options_))
decls[Namespace(d, options_)].AddSplit(d);
}
- {
- NamespaceOpener ns(format);
- for (const auto& pair : decls) {
- ns.ChangeTo(pair.first);
- pair.second.Print(format, options_);
- }
- }
- format("PROTOBUF_NAMESPACE_OPEN\n");
- for (const auto& pair : decls) {
- pair.second.PrintTopLevelDecl(format, options_);
+ NamespaceOpener ns(p);
+ for (const auto& decl : decls) {
+ ns.ChangeTo(decl.first);
+ decl.second.Print(p, options_);
}
- format("PROTOBUF_NAMESPACE_CLOSE\n");
-}
-
-void FileGenerator::GenerateTopHeaderGuard(io::Printer* printer, bool pb_h, bool deps) {
- Formatter format(printer, variables_);
- // Generate top of header.
- format(
- "// Generated by the protocol buffer compiler. DO NOT EDIT!\n"
- "// source: $filename$\n"
- "\n"
- "#ifndef $1$\n"
- "#define $1$\n"
- "\n"
- "#include <limits>\n"
- "#include <string>\n",
- IncludeGuard(file_, pb_h, deps, options_));
- if (!options_.opensource_runtime && !enum_generators_.empty()) {
- // Add header to provide std::is_integral for safe Enum_Name() function.
- format("#include <type_traits>\n");
- }
- format("\n");
-}
-void FileGenerator::GenerateBottomHeaderGuard(io::Printer* printer, bool pb_h, bool deps) {
- Formatter format(printer, variables_);
- format("#endif // $GOOGLE_PROTOBUF$_INCLUDED_$1$\n",
- IncludeGuard(file_, pb_h, deps, options_));
+ ns.ChangeTo("PROTOBUF_NAMESPACE_ID");
+ for (const auto& decl : decls) {
+ decl.second.PrintTopLevelDecl(p, options_);
+ }
}
-void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) {
- Formatter format(printer, variables_);
+void FileGenerator::GenerateLibraryIncludes(io::Printer* p) {
if (UsingImplicitWeakFields(file_, options_)) {
- IncludeFile("net/proto2/public/implicit_weak_message.h", printer);
+ IncludeFile("third_party/protobuf/implicit_weak_message.h", p);
}
if (HasWeakFields(file_, options_)) {
- GOOGLE_CHECK(!options_.opensource_runtime);
- IncludeFile("net/proto2/public/weak_field_map.h", printer);
+ Y_ABSL_CHECK(!options_.opensource_runtime);
+ IncludeFile("third_party/protobuf/weak_field_map.h", p);
}
if (HasLazyFields(file_, options_, &scc_analyzer_)) {
- GOOGLE_CHECK(!options_.opensource_runtime);
- IncludeFile("net/proto2/public/lazy_field.h", printer);
+ Y_ABSL_CHECK(!options_.opensource_runtime);
+ IncludeFile("third_party/protobuf/lazy_field.h", p);
}
if (ShouldVerify(file_, options_, &scc_analyzer_)) {
- IncludeFile("net/proto2/public/wire_format_verify.h", printer);
+ IncludeFile("third_party/protobuf/wire_format_verify.h", p);
}
if (options_.opensource_runtime) {
// Verify the protobuf library header version is compatible with the protoc
// version before going any further.
- IncludeFile("net/proto2/public/port_def.inc", printer);
- format(
- "#if PROTOBUF_VERSION < $1$\n"
- "#error This file was generated by a newer version of protoc which is\n"
- "#error incompatible with your Protocol Buffer headers. Please update\n"
- "#error your headers.\n"
- "#endif\n"
- "#if $2$ < PROTOBUF_MIN_PROTOC_VERSION\n"
- "#error This file was generated by an older version of protoc which "
- "is\n"
- "#error incompatible with your Protocol Buffer headers. Please\n"
- "#error regenerate this file with a newer version of protoc.\n"
- "#endif\n"
- "\n",
- PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC, // 1
- PROTOBUF_VERSION); // 2
- IncludeFile("net/proto2/public/port_undef.inc", printer);
+ IncludeFile("third_party/protobuf/port_def.inc", p);
+ p->Emit(
+ {
+ {"min_version", PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC},
+ {"version", PROTOBUF_VERSION},
+ },
+ R"(
+ #if PROTOBUF_VERSION < $min_version$
+ #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 // PROTOBUF_VERSION
+
+ #if $version$ < 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."
+ #endif // PROTOBUF_MIN_PROTOC_VERSION
+ )");
+ IncludeFile("third_party/protobuf/port_undef.inc", p);
}
// OK, it's now safe to #include other files.
- IncludeFile("net/proto2/io/public/coded_stream.h", printer);
- IncludeFile("net/proto2/public/arena.h", printer);
- IncludeFile("net/proto2/public/arenastring.h", printer);
+ IncludeFile("third_party/protobuf/io/coded_stream.h", p);
+ IncludeFile("third_party/protobuf/arena.h", p);
+ IncludeFile("third_party/protobuf/arenastring.h", p);
if ((options_.force_inline_string || options_.profile_driven_inline_string) &&
!options_.opensource_runtime) {
- IncludeFile("net/proto2/public/inlined_string_field.h", printer);
+ IncludeFile("third_party/protobuf/inlined_string_field.h", p);
}
if (HasSimpleBaseClasses(file_, options_)) {
- IncludeFile("net/proto2/public/generated_message_bases.h", printer);
+ IncludeFile("third_party/protobuf/generated_message_bases.h", p);
}
if (HasGeneratedMethods(file_, options_) &&
options_.tctable_mode != Options::kTCTableNever) {
- IncludeFile("net/proto2/public/generated_message_tctable_decl.h", printer);
+ IncludeFile("third_party/protobuf/generated_message_tctable_decl.h", p);
}
- IncludeFile("net/proto2/public/generated_message_util.h", printer);
- IncludeFile("net/proto2/public/metadata_lite.h", printer);
+ IncludeFile("third_party/protobuf/generated_message_util.h", p);
+ IncludeFile("third_party/protobuf/metadata_lite.h", p);
if (HasDescriptorMethods(file_, options_)) {
- IncludeFile("net/proto2/public/generated_message_reflection.h", printer);
+ IncludeFile("third_party/protobuf/generated_message_reflection.h", p);
}
if (!message_generators_.empty()) {
if (HasDescriptorMethods(file_, options_)) {
- IncludeFile("net/proto2/public/message.h", printer);
+ IncludeFile("third_party/protobuf/message.h", p);
} else {
- IncludeFile("net/proto2/public/message_lite.h", printer);
+ IncludeFile("third_party/protobuf/message_lite.h", p);
}
}
if (options_.opensource_runtime) {
// Open-source relies on unconditional includes of these.
- IncludeFileAndExport("net/proto2/public/repeated_field.h", printer);
- IncludeFileAndExport("net/proto2/public/extension_set.h", printer);
+ IncludeFileAndExport("third_party/protobuf/repeated_field.h", p);
+ IncludeFileAndExport("third_party/protobuf/extension_set.h", p);
} else {
// Google3 includes these files only when they are necessary.
if (HasExtensionsOrExtendableMessage(file_)) {
- IncludeFileAndExport("net/proto2/public/extension_set.h", printer);
+ IncludeFileAndExport("third_party/protobuf/extension_set.h", p);
}
if (HasRepeatedFields(file_)) {
- IncludeFileAndExport("net/proto2/public/repeated_field.h", printer);
+ IncludeFileAndExport("third_party/protobuf/repeated_field.h", p);
}
if (HasStringPieceFields(file_, options_)) {
- IncludeFile("net/proto2/public/string_piece_field_support.h", printer);
+ IncludeFile("third_party/protobuf/string_piece_field_support.h", p);
}
if (HasCordFields(file_, options_)) {
- format("#include \"third_party/absl/strings/cord.h\"\n");
+ p->Emit(R"(
+ #include "y_absl/strings/cord.h"
+ )");
}
}
if (HasMapFields(file_)) {
- IncludeFileAndExport("net/proto2/public/map.h", printer);
+ IncludeFileAndExport("third_party/protobuf/map.h", p);
if (HasDescriptorMethods(file_, options_)) {
- IncludeFile("net/proto2/public/map_entry.h", printer);
- IncludeFile("net/proto2/public/map_field_inl.h", printer);
+ IncludeFile("third_party/protobuf/map_entry.h", p);
+ IncludeFile("third_party/protobuf/map_field_inl.h", p);
} else {
- IncludeFile("net/proto2/public/map_entry_lite.h", printer);
- IncludeFile("net/proto2/public/map_field_lite.h", printer);
+ IncludeFile("third_party/protobuf/map_entry_lite.h", p);
+ IncludeFile("third_party/protobuf/map_field_lite.h", p);
}
}
if (HasEnumDefinitions(file_)) {
if (HasDescriptorMethods(file_, options_)) {
- IncludeFile("net/proto2/public/generated_enum_reflection.h", printer);
+ IncludeFile("third_party/protobuf/generated_enum_reflection.h", p);
} else {
- IncludeFile("net/proto2/public/generated_enum_util.h", printer);
+ IncludeFile("third_party/protobuf/generated_enum_util.h", p);
}
}
if (HasGenericServices(file_, options_)) {
- IncludeFile("net/proto2/public/service.h", printer);
+ IncludeFile("third_party/protobuf/service.h", p);
}
if (UseUnknownFieldSet(file_, options_) && !message_generators_.empty()) {
- IncludeFile("net/proto2/public/unknown_field_set.h", printer);
+ IncludeFile("third_party/protobuf/unknown_field_set.h", p);
}
}
-void FileGenerator::GenerateMetadataPragma(io::Printer* printer,
- const TProtoStringType& info_path) {
- Formatter format(printer, variables_);
- if (!info_path.empty() && !options_.annotation_pragma_name.empty() &&
- !options_.annotation_guard_name.empty()) {
- format.Set("guard", options_.annotation_guard_name);
- format.Set("pragma", options_.annotation_pragma_name);
- format.Set("info_path", info_path);
- format(
- "#ifdef $guard$\n"
- "#pragma $pragma$ \"$info_path$\"\n"
- "#endif // $guard$\n");
+void FileGenerator::GenerateMetadataPragma(io::Printer* p,
+ y_absl::string_view info_path) {
+ if (info_path.empty() || options_.annotation_pragma_name.empty() ||
+ options_.annotation_guard_name.empty()) {
+ return;
}
-}
-
-void FileGenerator::GenerateDependencyIncludes(io::Printer* printer) {
- Formatter format(printer, variables_);
- std::queue<const FileDescriptor*> files_queue;
- std::unordered_set<const FileDescriptor*> included_files;
- files_queue.push(file_);
- included_files.insert(file_);
-
- while (!files_queue.empty()) {
- const FileDescriptor* file = files_queue.front();
- files_queue.pop();
-
- for (int i = 0; i < file->dependency_count(); i++) {
- // try figure out if this file have not been included yet
- const FileDescriptor* dependency_file = file->dependency(i);
- if (!options_.transitive_pb_h) {
- auto [iter, is_inserted] = included_files.insert(dependency_file);
- if (is_inserted) {
- files_queue.push(dependency_file);
- } else {
- continue;
- }
- }
- TProtoStringType basename = StripProto(dependency_file->name());
+ p->Emit(
+ {
+ {"guard", options_.annotation_guard_name},
+ {"pragma", options_.annotation_pragma_name},
+ {"info_path", TProtoStringType(info_path)},
+ },
+ R"(
+ #ifdef $guard$
+ #pragma $pragma$ "$info_path$"
+ #endif // $guard$
+ )");
+}
- // Do not import weak deps.
- if (IsDepWeak(dependency_file)) continue;
+void FileGenerator::GenerateDependencyIncludes(io::Printer* p) {
+ for (int i = 0; i < file_->dependency_count(); ++i) {
+ const FileDescriptor* dep = file_->dependency(i);
- if (IsBootstrapProto(options_, file)) {
- GetBootstrapBasename(options_, basename, &basename);
- }
+ // Do not import weak deps.
+ if (IsDepWeak(dep)) {
+ continue;
+ }
- format("#include $1$\n",
- CreateHeaderInclude(basename + ".pb.h", dependency_file));
+ TProtoStringType basename = StripProto(dep->name());
+ if (IsBootstrapProto(options_, file_)) {
+ GetBootstrapBasename(options_, basename, &basename);
}
+
+ p->Emit(
+ {{"name", CreateHeaderInclude(y_absl::StrCat(basename, ".pb.h"), dep)}},
+ "#" "include" "$name$\n"
+ );
}
}
-void FileGenerator::GenerateGlobalStateFunctionDeclarations(
- io::Printer* printer) {
- Formatter format(printer, variables_);
+void FileGenerator::GenerateGlobalStateFunctionDeclarations(io::Printer* p) {
// Forward-declare the DescriptorTable because this is referenced by .pb.cc
// files depending on this file.
//
@@ -1333,114 +1403,102 @@ void FileGenerator::GenerateGlobalStateFunctionDeclarations(
// weak fields must refer to table struct but cannot include the header.
// Also it annotates extra weak attributes.
// TODO(gerbens) make sure this situation is handled better.
- format(
- "\n"
- "// Internal implementation detail -- do not use these members.\n"
- "struct $dllexport_decl $$tablename$ {\n"
- " static const $uint32$ offsets[];\n"
- "};\n");
+ p->Emit(R"cc(
+ // Internal implementation detail -- do not use these members.
+ struct $dllexport_decl $$tablename$ {
+ static const ::arc_ui32 offsets[];
+ };
+ )cc");
+
if (HasDescriptorMethods(file_, options_)) {
- format(
- "$dllexport_decl $extern const ::$proto_ns$::internal::DescriptorTable "
- "$desc_table$;\n");
+ p->Emit(R"cc(
+ $dllexport_decl $extern const ::$proto_ns$::internal::DescriptorTable
+ $desc_table$;
+ )cc");
}
}
-void FileGenerator::GenerateMessageDefinitions(io::Printer* printer) {
- Formatter format(printer, variables_);
- // Generate class definitions.
- for (int i = 0; i < message_generators_.size(); i++) {
- if (i > 0) {
- format("\n");
- format(kThinSeparator);
- format("\n");
- }
- message_generators_[i]->GenerateClassDefinition(printer);
+void FileGenerator::GenerateMessageDefinitions(io::Printer* p) {
+ for (int i = 0; i < message_generators_.size(); ++i) {
+ p->Emit(R"cc(
+ $hrule_thin$
+ )cc");
+ message_generators_[i]->GenerateClassDefinition(p);
}
}
-void FileGenerator::GenerateEnumDefinitions(io::Printer* printer) {
- // Generate enum definitions.
- for (int i = 0; i < enum_generators_.size(); i++) {
- enum_generators_[i]->GenerateDefinition(printer);
+void FileGenerator::GenerateEnumDefinitions(io::Printer* p) {
+ for (int i = 0; i < enum_generators_.size(); ++i) {
+ enum_generators_[i]->GenerateDefinition(p);
}
}
-void FileGenerator::GenerateServiceDefinitions(io::Printer* printer) {
- Formatter format(printer, variables_);
- if (HasGenericServices(file_, options_)) {
- // Generate service definitions.
- for (int i = 0; i < service_generators_.size(); i++) {
- if (i > 0) {
- format("\n");
- format(kThinSeparator);
- format("\n");
- }
- service_generators_[i]->GenerateDeclarations(printer);
- }
+void FileGenerator::GenerateServiceDefinitions(io::Printer* p) {
+ if (!HasGenericServices(file_, options_)) {
+ return;
+ }
- format("\n");
- format(kThickSeparator);
- format("\n");
+ for (int i = 0; i < service_generators_.size(); ++i) {
+ p->Emit(R"cc(
+ $hrule_thin$
+ )cc");
+ service_generators_[i]->GenerateDeclarations(p);
}
+
+ p->Emit(R"cc(
+ $hrule_thick$
+ )cc");
}
-void FileGenerator::GenerateExtensionIdentifiers(io::Printer* printer) {
+void FileGenerator::GenerateExtensionIdentifiers(io::Printer* p) {
// Declare extension identifiers. These are in global scope and so only
// the global scope extensions.
for (auto& extension_generator : extension_generators_) {
- if (extension_generator->IsScoped()) continue;
- extension_generator->GenerateDeclaration(printer);
+ if (extension_generator->IsScoped()) {
+ continue;
+ }
+ extension_generator->GenerateDeclaration(p);
}
}
-void FileGenerator::GenerateInlineFunctionDefinitions(io::Printer* printer) {
- Formatter format(printer, variables_);
+void FileGenerator::GenerateInlineFunctionDefinitions(io::Printer* p) {
// TODO(gerbens) remove pragmas when gcc is no longer used. Current version
// of gcc fires a bogus error when compiled with strict-aliasing.
- format(
- "#ifdef __GNUC__\n"
- " #pragma GCC diagnostic push\n"
- " #pragma GCC diagnostic ignored \"-Wstrict-aliasing\"\n"
- "#endif // __GNUC__\n");
- // Generate class inline methods.
- for (int i = 0; i < message_generators_.size(); i++) {
- if (i > 0) {
- format(kThinSeparator);
- format("\n");
- }
- message_generators_[i]->GenerateInlineMethods(printer);
- }
- format(
- "#ifdef __GNUC__\n"
- " #pragma GCC diagnostic pop\n"
- "#endif // __GNUC__\n");
+ p->Emit(R"(
+ #ifdef __GNUC__
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wstrict-aliasing"
+ #endif // __GNUC__
+ )");
+
+ for (int i = 0; i < message_generators_.size(); ++i) {
+ p->Emit(R"cc(
+ $hrule_thin$
+ )cc");
+ message_generators_[i]->GenerateInlineMethods(p);
+ }
+
+ p->Emit(R"(
+ #ifdef __GNUC__
+ #pragma GCC diagnostic pop
+ #endif // __GNUC__
+ )");
+}
- for (int i = 0; i < message_generators_.size(); i++) {
- if (i > 0) {
- format(kThinSeparator);
- format("\n");
- }
+void FileGenerator::GenerateProto2NamespaceEnumSpecializations(io::Printer* p) {
+ // Emit GetEnumDescriptor specializations into google::protobuf namespace.
+ if (!HasEnumDefinitions(file_)) {
+ return;
}
-}
-void FileGenerator::GenerateProto2NamespaceEnumSpecializations(
- io::Printer* printer) {
- Formatter format(printer, variables_);
- // Emit GetEnumDescriptor specializations into google::protobuf namespace:
- if (HasEnumDefinitions(file_)) {
- format("\n");
- {
- NamespaceOpener proto_ns(ProtobufNamespace(options_), format);
- format("\n");
- for (int i = 0; i < enum_generators_.size(); i++) {
- enum_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer);
- }
- format("\n");
- }
+ p->PrintRaw("\n");
+ NamespaceOpener ns(ProtobufNamespace(options_), p);
+ p->PrintRaw("\n");
+ for (auto& gen : enum_generators_) {
+ gen->GenerateGetEnumDescriptorSpecializations(p);
}
+ p->PrintRaw("\n");
}
-
} // namespace cpp
} // namespace compiler
} // namespace protobuf
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/file.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/file.h
index 805b4979bf5..7f41bfae12f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/file.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/file.h
@@ -36,53 +36,47 @@
#define GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__
#include <algorithm>
+#include <functional>
#include <memory>
-#include <set>
#include <string>
#include <vector>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/compiler/cpp/field.h>
-#include <google/protobuf/compiler/cpp/helpers.h>
-#include <google/protobuf/compiler/scc.h>
-#include <google/protobuf/compiler/cpp/options.h>
-
-namespace google {
-namespace protobuf {
-class FileDescriptor; // descriptor.h
-namespace io {
-class Printer; // printer.h
-}
-} // namespace protobuf
-} // namespace google
+#include "google/protobuf/stubs/common.h"
+#include "google/protobuf/compiler/scc.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/log/absl_check.h"
+#include "google/protobuf/compiler/cpp/enum.h"
+#include "google/protobuf/compiler/cpp/extension.h"
+#include "google/protobuf/compiler/cpp/field.h"
+#include "google/protobuf/compiler/cpp/helpers.h"
+#include "google/protobuf/compiler/cpp/message.h"
+#include "google/protobuf/compiler/cpp/options.h"
+#include "google/protobuf/compiler/cpp/service.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/io/printer.h"
+#include "google/protobuf/port.h"
namespace google {
namespace protobuf {
namespace compiler {
namespace cpp {
-
-class EnumGenerator; // enum.h
-class MessageGenerator; // message.h
-class ServiceGenerator; // service.h
-class ExtensionGenerator; // extension.h
-
class FileGenerator {
public:
- // See generator.cc for the meaning of dllexport_decl.
FileGenerator(const FileDescriptor* file, const Options& options);
- ~FileGenerator();
- // Shared code between the two header generators below.
- void GenerateHeader(io::Printer* printer);
+ FileGenerator(const FileGenerator&) = delete;
+ FileGenerator& operator=(const FileGenerator&) = delete;
+
+ ~FileGenerator() = default;
// info_path, if non-empty, should be the path (relative to printer's
// output) to the metadata file describing this proto header.
- void GenerateProtoHeader(io::Printer* printer, const TProtoStringType& info_path);
+ void GenerateProtoHeader(io::Printer* p, y_absl::string_view info_path);
// info_path, if non-empty, should be the path (relative to printer's
// output) to the metadata file describing this PB header.
- void GeneratePBHeader(io::Printer* printer, const TProtoStringType& info_path);
- void GeneratePBDeps(io::Printer* printer, const TProtoStringType& info_path);
- void GenerateSource(io::Printer* printer);
+ void GeneratePBHeader(io::Printer* p, y_absl::string_view info_path);
+ void GenerateSource(io::Printer* p);
// The following member functions are used when the lite_implicit_weak_fields
// option is set. In this mode the code is organized a bit differently to
@@ -93,78 +87,86 @@ class FileGenerator {
int NumMessages() const { return message_generators_.size(); }
int NumExtensions() const { return extension_generators_.size(); }
// Generates the source file for one message.
- void GenerateSourceForMessage(int idx, io::Printer* printer);
+ void GenerateSourceForMessage(int idx, io::Printer* p);
// Generates the source file for one extension.
- void GenerateSourceForExtension(int idx, io::Printer* printer);
+ void GenerateSourceForExtension(int idx, io::Printer* p);
// Generates a source file containing everything except messages and
// extensions.
- void GenerateGlobalSource(io::Printer* printer);
+ void GenerateGlobalSource(io::Printer* p);
private:
+ // Generates a file, setting up the necessary accoutrements that start and
+ // end the file, calling `cb` in between.
+ //
+ // This includes header guards and file-global variables.
+ void GenerateFile(io::Printer* p, GeneratedFileType file_type,
+ std::function<void()> cb);
+
+ // Shared code between the two header generators.
+ void GenerateSharedHeaderCode(io::Printer* p);
+
// Internal type used by GenerateForwardDeclarations (defined in file.cc).
class ForwardDeclarations;
struct CrossFileReferences;
- void IncludeFile(const TProtoStringType& google3_name, io::Printer* printer) {
- DoIncludeFile(google3_name, false, printer);
+ void IncludeFile(y_absl::string_view google3_name, io::Printer* p) {
+ DoIncludeFile(google3_name, false, p);
}
- void IncludeFileAndExport(const TProtoStringType& google3_name,
- io::Printer* printer) {
- DoIncludeFile(google3_name, true, printer);
+ void IncludeFileAndExport(y_absl::string_view google3_name, io::Printer* p) {
+ DoIncludeFile(google3_name, true, p);
}
- void DoIncludeFile(const TProtoStringType& google3_name, bool do_export,
- io::Printer* printer);
+ void DoIncludeFile(y_absl::string_view google3_name, bool do_export,
+ io::Printer* p);
- TProtoStringType CreateHeaderInclude(const TProtoStringType& basename,
+ TProtoStringType CreateHeaderInclude(y_absl::string_view basename,
const FileDescriptor* file);
void GetCrossFileReferencesForField(const FieldDescriptor* field,
CrossFileReferences* refs);
void GetCrossFileReferencesForFile(const FileDescriptor* file,
CrossFileReferences* refs);
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);
+ io::Printer* p);
+ void GenerateSourceIncludes(io::Printer* p);
+ void GenerateSourcePrelude(io::Printer* p);
+ void GenerateSourceDefaultInstance(int idx, io::Printer* p);
void GenerateInitForSCC(const SCC* scc, const CrossFileReferences& refs,
- io::Printer* printer);
- void GenerateReflectionInitializationCode(io::Printer* printer);
+ io::Printer* p);
+ void GenerateReflectionInitializationCode(io::Printer* p);
// For other imports, generates their forward-declarations.
- void GenerateForwardDeclarations(io::Printer* printer);
+ void GenerateForwardDeclarations(io::Printer* p);
// Generates top or bottom of a header file.
- void GenerateTopHeaderGuard(io::Printer* printer, bool pb_h, bool deps = false);
- void GenerateBottomHeaderGuard(io::Printer* printer, bool pb_h, bool deps = false);
+ void GenerateTopHeaderGuard(io::Printer* p, GeneratedFileType file_type);
+ void GenerateBottomHeaderGuard(io::Printer* p, GeneratedFileType file_type);
// Generates #include directives.
- void GenerateLibraryIncludes(io::Printer* printer);
- void GenerateDependencyIncludes(io::Printer* printer);
+ void GenerateLibraryIncludes(io::Printer* p);
+ void GenerateDependencyIncludes(io::Printer* p);
// Generate a pragma to pull in metadata using the given info_path (if
// non-empty). info_path should be relative to printer's output.
- void GenerateMetadataPragma(io::Printer* printer,
- const TProtoStringType& info_path);
+ void GenerateMetadataPragma(io::Printer* p, y_absl::string_view info_path);
// Generates a couple of different pieces before definitions:
- void GenerateGlobalStateFunctionDeclarations(io::Printer* printer);
+ void GenerateGlobalStateFunctionDeclarations(io::Printer* p);
// Generates types for classes.
- void GenerateMessageDefinitions(io::Printer* printer);
+ void GenerateMessageDefinitions(io::Printer* p);
- void GenerateEnumDefinitions(io::Printer* printer);
+ void GenerateEnumDefinitions(io::Printer* p);
// Generates generic service definitions.
- void GenerateServiceDefinitions(io::Printer* printer);
+ void GenerateServiceDefinitions(io::Printer* p);
// Generates extension identifiers.
- void GenerateExtensionIdentifiers(io::Printer* printer);
+ void GenerateExtensionIdentifiers(io::Printer* p);
// Generates inline function definitions.
- void GenerateInlineFunctionDefinitions(io::Printer* printer);
+ void GenerateInlineFunctionDefinitions(io::Printer* p);
- void GenerateProto2NamespaceEnumSpecializations(io::Printer* printer);
+ void GenerateProto2NamespaceEnumSpecializations(io::Printer* p);
// Sometimes the names we use in a .proto file happen to be defined as
// macros on some platforms (e.g., macro/minor used in plugin.proto are
@@ -173,24 +175,27 @@ class FileGenerator {
// undef the macro for these few platforms, or rename the field name for all
// platforms. Since these names are part of protobuf public API, renaming is
// generally a breaking change so we prefer the #undef approach.
- void GenerateMacroUndefs(io::Printer* printer);
+ void GenerateMacroUndefs(io::Printer* p);
bool IsDepWeak(const FileDescriptor* dep) const {
if (weak_deps_.count(dep) != 0) {
- GOOGLE_CHECK(!options_.opensource_runtime);
+ Y_ABSL_CHECK(!options_.opensource_runtime);
return true;
}
return false;
}
- std::set<const FileDescriptor*> weak_deps_;
+ y_absl::flat_hash_set<const FileDescriptor*> weak_deps_;
const FileDescriptor* file_;
- const Options options_;
+ Options options_;
MessageSCCAnalyzer scc_analyzer_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ // This member is unused and should be deleted once all old-style variable
+ // maps are gone.
+ // TODO(b/245791219)
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables_;
// Contains the post-order walk of all the messages (and child messages) in
// this file. If you need a pre-order walk just reverse iterate.
@@ -198,8 +203,6 @@ class FileGenerator {
std::vector<std::unique_ptr<EnumGenerator>> enum_generators_;
std::vector<std::unique_ptr<ServiceGenerator>> service_generators_;
std::vector<std::unique_ptr<ExtensionGenerator>> extension_generators_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator);
};
} // namespace cpp
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/generator.cc
index 0da2027a1e6..6187b72cbab 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/generator.cc
@@ -32,31 +32,68 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/cpp/generator.h>
+#include "google/protobuf/compiler/cpp/generator.h"
+#include <cstdlib>
#include <memory>
#include <string>
#include <utility>
#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/file.h>
-#include <google/protobuf/compiler/cpp/helpers.h>
-#include <google/protobuf/descriptor.pb.h>
+#include "y_absl/strings/match.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/compiler/cpp/file.h"
+#include "google/protobuf/compiler/cpp/helpers.h"
+#include "google/protobuf/descriptor.pb.h"
namespace google {
namespace protobuf {
namespace compiler {
namespace cpp {
+namespace {
+TProtoStringType NumberedCcFileName(y_absl::string_view basename, int number) {
+ return y_absl::StrCat(basename, ".out/", number, ".cc");
+}
-CppGenerator::CppGenerator() {}
-CppGenerator::~CppGenerator() {}
+y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> CommonVars(
+ const Options& options) {
+ bool is_oss = options.opensource_runtime;
+ return {
+ {"proto_ns", ProtobufNamespace(options)},
+ {"pb", y_absl::StrCat("::", ProtobufNamespace(options))},
+ {"pbi", y_absl::StrCat("::", ProtobufNamespace(options), "::internal")},
-namespace {
-TProtoStringType NumberedCcFileName(const TProtoStringType& basename, int number) {
- return StrCat(basename, ".out/", number, ".cc");
+ {"string", "TProtoStringType"},
+ {"int8", "::int8_t"},
+ {"int32", "::arc_i32"},
+ {"int64", "::arc_i64"},
+ {"uint8", "::uint8_t"},
+ {"uint32", "::arc_ui32"},
+ {"uint64", "::arc_ui64"},
+
+ {"hrule_thick", kThickSeparator},
+ {"hrule_thin", kThinSeparator},
+
+ // Warning: there is some clever naming/splitting here to avoid extract
+ // script rewrites. The names of these variables must not be things that
+ // the extract script will rewrite. That's why we use "CHK" (for example)
+ // instead of "Y_ABSL_CHECK".
+ //
+ // These values are things the extract script would rewrite if we did not
+ // split them. It might not strictly matter since we don't generate
+ // google3 code in open-source. But it's good to prevent surprising
+ // things from happening.
+ {"GOOGLE_PROTOBUF", is_oss ? "GOOGLE_PROTOBUF"
+ : "GOOGLE3_PROTOBU"
+ "F"},
+ {"CHK",
+ "Y_ABSL_CHEC"
+ "K"},
+ {"DCHK",
+ "Y_ABSL_DCHEC"
+ "K"},
+ };
}
} // namespace
@@ -64,7 +101,7 @@ bool CppGenerator::Generate(const FileDescriptor* file,
const TProtoStringType& parameter,
GeneratorContext* generator_context,
TProtoStringType* error) const {
- std::vector<std::pair<TProtoStringType, TProtoStringType> > options;
+ std::vector<std::pair<TProtoStringType, TProtoStringType>> options;
ParseGeneratorParameter(parameter, &options);
// -----------------------------------------------------------------
@@ -93,72 +130,69 @@ bool CppGenerator::Generate(const FileDescriptor* file,
file_options.opensource_runtime = opensource_runtime_;
file_options.runtime_include_base = runtime_include_base_;
- for (int i = 0; i < options.size(); i++) {
- if (options[i].first == "dllexport_decl") {
- file_options.dllexport_decl = options[i].second;
- } else if (options[i].first == "safe_boundary_check") {
+ for (const auto& option : options) {
+ const auto& key = option.first;
+ const auto& value = option.second;
+
+ if (key == "dllexport_decl") {
+ file_options.dllexport_decl = value;
+ } else if (key == "safe_boundary_check") {
file_options.safe_boundary_check = true;
- } else if (options[i].first == "annotate_headers") {
+ } else if (key == "annotate_headers") {
file_options.annotate_headers = true;
- } else if (options[i].first == "annotation_pragma_name") {
- file_options.annotation_pragma_name = options[i].second;
- } else if (options[i].first == "annotation_guard_name") {
- file_options.annotation_guard_name = options[i].second;
- } else if (options[i].first == "speed") {
+ } else if (key == "annotation_pragma_name") {
+ file_options.annotation_pragma_name = value;
+ } else if (key == "annotation_guard_name") {
+ file_options.annotation_guard_name = value;
+ } else if (key == "speed") {
file_options.enforce_mode = EnforceOptimizeMode::kSpeed;
- } else if (options[i].first == "code_size") {
+ } else if (key == "code_size") {
file_options.enforce_mode = EnforceOptimizeMode::kCodeSize;
- } else if (options[i].first == "lite") {
+ } else if (key == "lite") {
file_options.enforce_mode = EnforceOptimizeMode::kLiteRuntime;
- } else if (options[i].first == "lite_implicit_weak_fields") {
+ } else if (key == "lite_implicit_weak_fields") {
file_options.enforce_mode = EnforceOptimizeMode::kLiteRuntime;
file_options.lite_implicit_weak_fields = true;
- if (!options[i].second.empty()) {
- file_options.num_cc_files =
- strto32(options[i].second.c_str(), nullptr, 10);
+ if (!value.empty()) {
+ file_options.num_cc_files = std::strtol(value.c_str(), nullptr, 10);
}
- } else if (options[i].first == "proto_h") {
+ } else if (key == "proto_h") {
file_options.proto_h = true;
- } else if (options[i].first == "annotate_accessor") {
+ } else if (key == "proto_static_reflection_h") {
+ } else if (key == "annotate_accessor") {
file_options.annotate_accessor = true;
- } else if (options[i].first == "inject_field_listener_events") {
+ } else if (key == "inject_field_listener_events") {
file_options.field_listener_options.inject_field_listener_events = true;
- } else if (options[i].first == "forbidden_field_listener_events") {
+ } else if (key == "forbidden_field_listener_events") {
std::size_t pos = 0;
do {
- std::size_t next_pos = options[i].second.find_first_of("+", pos);
+ std::size_t next_pos = value.find_first_of("+", pos);
if (next_pos == TProtoStringType::npos) {
- next_pos = options[i].second.size();
+ next_pos = value.size();
}
if (next_pos > pos)
file_options.field_listener_options.forbidden_field_listener_events
- .insert(options[i].second.substr(pos, next_pos - pos));
+ .emplace(value.substr(pos, next_pos - pos));
pos = next_pos + 1;
- } while (pos < options[i].second.size());
- } else if (options[i].first == "verified_lazy") {
- file_options.unverified_lazy = false;
- } else if (options[i].first == "unverified_lazy_message_sets") {
+ } while (pos < value.size());
+ } else if (key == "unverified_lazy_message_sets") {
file_options.unverified_lazy_message_sets = true;
- } else if (options[i].first == "message_owned_arena_trial") {
- file_options.message_owned_arena_trial = true;
- } else if (options[i].first == "force_eagerly_verified_lazy") {
+ } else if (key == "force_eagerly_verified_lazy") {
file_options.force_eagerly_verified_lazy = true;
- } else if (options[i].first == "experimental_tail_call_table_mode") {
- if (options[i].second == "never") {
+ } else if (key == "experimental_tail_call_table_mode") {
+ if (value == "never") {
file_options.tctable_mode = Options::kTCTableNever;
- } else if (options[i].second == "guarded") {
+ } else if (value == "guarded") {
file_options.tctable_mode = Options::kTCTableGuarded;
- } else if (options[i].second == "always") {
+ } else if (value == "always") {
file_options.tctable_mode = Options::kTCTableAlways;
} else {
- *error = "Unknown value for experimental_tail_call_table_mode: " +
- options[i].second;
+ *error = y_absl::StrCat(
+ "Unknown value for experimental_tail_call_table_mode: ", value);
return false;
}
- } else if (options[i].first == "transitive_pb_h") {
- file_options.transitive_pb_h = options[i].second != "false";
} else {
- *error = "Unknown generator option: " + options[i].first;
+ *error = y_absl::StrCat("Unknown generator option: ", key);
return false;
}
}
@@ -176,6 +210,17 @@ bool CppGenerator::Generate(const FileDescriptor* file,
TProtoStringType basename = StripProto(file->name());
+ auto generate_reserved_static_reflection_header = [&basename,
+ &generator_context]() {
+ auto output = y_absl::WrapUnique(generator_context->Open(
+ y_absl::StrCat(basename, ".proto.static_reflection.h")));
+ io::Printer(output.get()).Emit(R"cc(
+ // Reserved for future use.
+ )cc");
+ };
+ // Suppress maybe unused warning.
+ (void)generate_reserved_static_reflection_header;
+
if (MaybeBootstrap(file_options, generator_context, file_options.bootstrap,
&basename)) {
return true;
@@ -185,58 +230,51 @@ bool CppGenerator::Generate(const FileDescriptor* file,
// Generate header(s).
if (file_options.proto_h) {
- std::unique_ptr<io::ZeroCopyOutputStream> output(
- generator_context->Open(basename + ".proto.h"));
+ auto output = y_absl::WrapUnique(
+ generator_context->Open(y_absl::StrCat(basename, ".proto.h")));
+
GeneratedCodeInfo annotations;
io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
&annotations);
- TProtoStringType info_path = basename + ".proto.h.meta";
- io::Printer printer(
- output.get(), '$',
- file_options.annotate_headers ? &annotation_collector : nullptr);
+ io::Printer::Options options;
+ if (file_options.annotate_headers) {
+ options.annotation_collector = &annotation_collector;
+ }
+
+ io::Printer p(output.get(), options);
+ auto v = p.WithVars(CommonVars(file_options));
+
+ TProtoStringType info_path = y_absl::StrCat(basename, ".proto.h.meta");
file_generator.GenerateProtoHeader(
- &printer, file_options.annotate_headers ? info_path : "");
+ &p, file_options.annotate_headers ? info_path : "");
+
if (file_options.annotate_headers) {
- std::unique_ptr<io::ZeroCopyOutputStream> info_output(
- generator_context->Open(info_path));
+ auto info_output = y_absl::WrapUnique(generator_context->Open(info_path));
annotations.SerializeToZeroCopyStream(info_output.get());
}
}
{
- std::unique_ptr<io::ZeroCopyOutputStream> output(
- generator_context->Open(basename + ".pb.h"));
+ auto output = y_absl::WrapUnique(
+ generator_context->Open(y_absl::StrCat(basename, ".pb.h")));
+
GeneratedCodeInfo annotations;
io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
&annotations);
- TProtoStringType info_path = basename + ".pb.h.meta";
- io::Printer printer(
- output.get(), '$',
- file_options.annotate_headers ? &annotation_collector : nullptr);
- file_generator.GeneratePBHeader(
- &printer, file_options.annotate_headers ? info_path : "");
+ io::Printer::Options options;
if (file_options.annotate_headers) {
- std::unique_ptr<io::ZeroCopyOutputStream> info_output(
- generator_context->Open(info_path));
- annotations.SerializeToZeroCopyStream(info_output.get());
+ options.annotation_collector = &annotation_collector;
}
- }
- if (!file_options.transitive_pb_h) {
- std::unique_ptr<io::ZeroCopyOutputStream> output(
- generator_context->Open(basename + ".deps.pb.h"));
- GeneratedCodeInfo annotations;
- io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
- &annotations);
- TProtoStringType info_path = basename + ".deps.pb.h.meta";
- io::Printer printer(
- output.get(), '$',
- file_options.annotate_headers ? &annotation_collector : NULL);
- file_generator.GeneratePBDeps(
- &printer, file_options.annotate_headers ? info_path : "");
+ io::Printer p(output.get(), options);
+ auto v = p.WithVars(CommonVars(file_options));
+
+ TProtoStringType info_path = y_absl::StrCat(basename, ".pb.h.meta");
+ file_generator.GeneratePBHeader(
+ &p, file_options.annotate_headers ? info_path : "");
+
if (file_options.annotate_headers) {
- std::unique_ptr<io::ZeroCopyOutputStream> info_output(
- generator_context->Open(info_path));
+ auto info_output = y_absl::WrapUnique(generator_context->Open(info_path));
annotations.SerializeToZeroCopyStream(info_output.get());
}
}
@@ -246,10 +284,12 @@ bool CppGenerator::Generate(const FileDescriptor* file,
{
// This is the global .cc file, containing
// enum/services/tables/reflection
- std::unique_ptr<io::ZeroCopyOutputStream> output(
- generator_context->Open(basename + ".pb.cc"));
- io::Printer printer(output.get(), '$');
- file_generator.GenerateGlobalSource(&printer);
+ auto output = y_absl::WrapUnique(
+ generator_context->Open(y_absl::StrCat(basename, ".pb.cc")));
+ io::Printer p(output.get());
+ auto v = p.WithVars(CommonVars(file_options));
+
+ file_generator.GenerateGlobalSource(&p);
}
int num_cc_files =
@@ -260,40 +300,48 @@ bool CppGenerator::Generate(const FileDescriptor* file,
// pb.cc file. If we have more files than messages, then some files will
// be generated as empty placeholders.
if (file_options.num_cc_files > 0) {
- GOOGLE_CHECK_LE(num_cc_files, file_options.num_cc_files)
+ Y_ABSL_CHECK_LE(num_cc_files, file_options.num_cc_files)
<< "There must be at least as many numbered .cc files as messages "
"and extensions.";
num_cc_files = file_options.num_cc_files;
}
+
int cc_file_number = 0;
- for (int i = 0; i < file_generator.NumMessages(); i++) {
- std::unique_ptr<io::ZeroCopyOutputStream> output(generator_context->Open(
+ for (int i = 0; i < file_generator.NumMessages(); ++i) {
+ auto output = y_absl::WrapUnique(generator_context->Open(
NumberedCcFileName(basename, cc_file_number++)));
- io::Printer printer(output.get(), '$');
- file_generator.GenerateSourceForMessage(i, &printer);
+ io::Printer p(output.get());
+ auto v = p.WithVars(CommonVars(file_options));
+
+ file_generator.GenerateSourceForMessage(i, &p);
}
- for (int i = 0; i < file_generator.NumExtensions(); i++) {
- std::unique_ptr<io::ZeroCopyOutputStream> output(generator_context->Open(
+
+ for (int i = 0; i < file_generator.NumExtensions(); ++i) {
+ auto output = y_absl::WrapUnique(generator_context->Open(
NumberedCcFileName(basename, cc_file_number++)));
- io::Printer printer(output.get(), '$');
- file_generator.GenerateSourceForExtension(i, &printer);
+ io::Printer p(output.get());
+ auto v = p.WithVars(CommonVars(file_options));
+
+ file_generator.GenerateSourceForExtension(i, &p);
}
+
// Create empty placeholder files if necessary to match the expected number
// of files.
- for (; cc_file_number < num_cc_files; ++cc_file_number) {
- std::unique_ptr<io::ZeroCopyOutputStream> output(generator_context->Open(
- NumberedCcFileName(basename, cc_file_number)));
+ while (cc_file_number < num_cc_files) {
+ (void)y_absl::WrapUnique(generator_context->Open(
+ NumberedCcFileName(basename, cc_file_number++)));
}
} else {
- std::unique_ptr<io::ZeroCopyOutputStream> output(
- generator_context->Open(basename + ".pb.cc"));
- io::Printer printer(output.get(), '$');
- file_generator.GenerateSource(&printer);
+ auto output = y_absl::WrapUnique(
+ generator_context->Open(y_absl::StrCat(basename, ".pb.cc")));
+ io::Printer p(output.get());
+ auto v = p.WithVars(CommonVars(file_options));
+
+ file_generator.GenerateSource(&p);
}
return true;
}
-
} // namespace cpp
} // namespace compiler
} // namespace protobuf
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/generator.h
index aa63845d300..5f95dd1d2f5 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/generator.h
@@ -38,24 +38,27 @@
#define GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__
#include <string>
-#include <google/protobuf/compiler/code_generator.h>
+#include <utility>
+
+#include "google/protobuf/compiler/code_generator.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
namespace compiler {
namespace cpp {
-
// CodeGenerator implementation which generates a C++ source file and
// header. If you create your own protocol compiler binary and you want
// it to support C++ output, you can do so by registering an instance of this
// CodeGenerator with the CommandLineInterface in your main() function.
class PROTOC_EXPORT CppGenerator : public CodeGenerator {
public:
- CppGenerator();
- ~CppGenerator() override;
+ CppGenerator() = default;
+ CppGenerator(const CppGenerator&) = delete;
+ CppGenerator& operator=(const CppGenerator&) = delete;
+ ~CppGenerator() override = default;
enum class Runtime {
kGoogle3, // Use the internal google3 runtime.
@@ -74,34 +77,29 @@ class PROTOC_EXPORT CppGenerator : public CodeGenerator {
// If set to a non-empty string, generated code will do:
// #include "<BASE>/google/protobuf/message.h"
// instead of:
- // #include <google/protobuf/message.h>
+ // #include "google/protobuf/message.h"
// This has no effect if opensource_runtime = false.
- void set_runtime_include_base(const TProtoStringType& base) {
- runtime_include_base_ = base;
+ void set_runtime_include_base(TProtoStringType base) {
+ runtime_include_base_ = std::move(base);
}
- // implements CodeGenerator ----------------------------------------
bool Generate(const FileDescriptor* file, const TProtoStringType& parameter,
GeneratorContext* generator_context,
TProtoStringType* error) const override;
uint64_t GetSupportedFeatures() const override {
- // We don't fully support this yet, but this is needed to unblock the tests,
- // and we will have full support before the experimental flag is removed.
return FEATURE_PROTO3_OPTIONAL;
}
private:
- bool opensource_runtime_ = true;
+ bool opensource_runtime_ = PROTO2_IS_OSS;
TProtoStringType runtime_include_base_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CppGenerator);
};
-
} // namespace cpp
} // namespace compiler
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/helpers.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/helpers.cc
index 48879f29d57..977aa87d85e 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/helpers.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/helpers.cc
@@ -32,35 +32,45 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/cpp/helpers.h>
+#include "google/protobuf/compiler/cpp/helpers.h"
+#include <algorithm>
#include <cstdint>
#include <functional>
#include <limits>
-#include <map>
#include <memory>
#include <queue>
-#include <unordered_set>
+#include <string>
+#include <utility>
#include <vector>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/compiler/cpp/names.h>
-#include <google/protobuf/compiler/cpp/options.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/compiler/scc.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/zero_copy_stream.h>
-#include <google/protobuf/dynamic_message.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/substitute.h>
-#include <google/protobuf/stubs/hash.h>
+#include "google/protobuf/stubs/common.h"
+#include "google/protobuf/compiler/scc.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/dynamic_message.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/escaping.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_replace.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/strings/strip.h"
+#include "y_absl/strings/substitute.h"
+#include "y_absl/synchronization/mutex.h"
+#include "google/protobuf/compiler/cpp/names.h"
+#include "google/protobuf/compiler/cpp/options.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/printer.h"
+#include "google/protobuf/io/strtod.h"
+#include "google/protobuf/wire_format.h"
+#include "google/protobuf/wire_format_lite.h"
+
// Must be last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -72,11 +82,12 @@ namespace {
static const char kAnyMessageName[] = "Any";
static const char kAnyProtoFile[] = "google/protobuf/any.proto";
-TProtoStringType DotsToColons(const TProtoStringType& name) {
- return StringReplace(name, ".", "::", true);
+TProtoStringType DotsToColons(y_absl::string_view name) {
+ return y_absl::StrReplaceAll(name, {{".", "::"}});
}
-static const char* const kKeywordList[] = { //
+static const char* const kKeywordList[] = {
+ //
"NULL",
"alignas",
"alignof",
@@ -163,48 +174,36 @@ static const char* const kKeywordList[] = { //
"wchar_t",
"while",
"xor",
- "xor_eq"};
-
-static std::unordered_set<TProtoStringType>* MakeKeywordsMap() {
- auto* result = new std::unordered_set<TProtoStringType>();
- for (const auto keyword : kKeywordList) {
- result->emplace(keyword);
- }
- return result;
-}
-
-static std::unordered_set<TProtoStringType>& kKeywords = *MakeKeywordsMap();
+ "xor_eq",
+ "char8_t",
+ "char16_t",
+ "char32_t",
+ "concept",
+ "consteval",
+ "constinit",
+ "co_await",
+ "co_return",
+ "co_yield",
+ "requires",
+};
-TProtoStringType IntTypeName(const Options& options, const TProtoStringType& type) {
- return "::NProtoBuf::" + type;
-}
+const y_absl::flat_hash_set<y_absl::string_view>& Keywords() {
+ static const auto* keywords = [] {
+ auto* keywords = new y_absl::flat_hash_set<y_absl::string_view>();
-void SetIntVar(const Options& options, const TProtoStringType& type,
- std::map<TProtoStringType, TProtoStringType>* variables) {
- (*variables)[type] = IntTypeName(options, type);
+ for (const auto keyword : kKeywordList) {
+ keywords->emplace(keyword);
+ }
+ return keywords;
+ }();
+ return *keywords;
}
-// Returns true if the message can potentially allocate memory for its field.
-// This is used to determine if message-owned arena will be useful.
-bool AllocExpected(const Descriptor* descriptor) {
- return false;
+TProtoStringType IntTypeName(const Options& options, y_absl::string_view type) {
+ return y_absl::StrCat("::NProtoBuf::", type);
}
-// Describes different approaches to detect non-canonical int32 encoding. Only
-// kNever or kAlways is eligible for *simple* verification methods.
-enum class VerifyInt32Type {
- kCustom, // Only check if field number matches.
- kNever, // Do not check.
- kAlways, // Always check.
-};
-inline VerifySimpleType VerifyInt32TypeToVerifyCustom(VerifyInt32Type t) {
- static VerifySimpleType kCustomTypes[] = {
- VerifySimpleType::kCustom, VerifySimpleType::kCustomInt32Never,
- VerifySimpleType::kCustomInt32Always};
- return kCustomTypes[static_cast<arc_i32>(t) -
- static_cast<arc_i32>(VerifyInt32Type::kCustom)];
-}
} // namespace
@@ -232,86 +231,69 @@ bool IsLazilyVerifiedLazy(const FieldDescriptor* field,
return false;
}
-void SetCommonVars(const Options& options,
- std::map<TProtoStringType, TProtoStringType>* variables) {
- (*variables)["proto_ns"] = ProtobufNamespace(options);
-
- // Warning: there is some clever naming/splitting here to avoid extract script
- // rewrites. The names of these variables must not be things that the extract
- // script will rewrite. That's why we use "CHK" (for example) instead of
- // "GOOGLE_CHECK".
- if (options.opensource_runtime) {
- (*variables)["GOOGLE_PROTOBUF"] = "GOOGLE_PROTOBUF";
- (*variables)["CHK"] = "GOOGLE_CHECK";
- (*variables)["DCHK"] = "GOOGLE_DCHECK";
- } else {
- // These values are things the extract script would rewrite if we did not
- // split them. It might not strictly matter since we don't generate google3
- // code in open-source. But it's good to prevent surprising things from
- // happening.
- (*variables)["GOOGLE_PROTOBUF"] =
- "GOOGLE3"
- "_PROTOBUF";
- (*variables)["CHK"] =
- "CH"
- "ECK";
- (*variables)["DCHK"] =
- "DCH"
- "ECK";
- }
-
- SetIntVar(options, "int8", variables);
- SetIntVar(options, "uint8", variables);
- SetIntVar(options, "uint32", variables);
- SetIntVar(options, "uint64", variables);
- SetIntVar(options, "int32", variables);
- SetIntVar(options, "int64", variables);
- (*variables)["string"] = "TProtoStringType";
+y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> MessageVars(
+ const Descriptor* desc) {
+ y_absl::string_view prefix = IsMapEntryMessage(desc) ? "" : "_impl_.";
+ return {
+ {"any_metadata", y_absl::StrCat(prefix, "_any_metadata_")},
+ {"cached_size", y_absl::StrCat(prefix, "_cached_size_")},
+ {"extensions", y_absl::StrCat(prefix, "_extensions_")},
+ {"has_bits", y_absl::StrCat(prefix, "_has_bits_")},
+ {"inlined_string_donated_array",
+ y_absl::StrCat(prefix, "_inlined_string_donated_")},
+ {"oneof_case", y_absl::StrCat(prefix, "_oneof_case_")},
+ {"tracker", "Impl_::_tracker_"},
+ {"weak_field_map", y_absl::StrCat(prefix, "_weak_field_map_")},
+ {"split", y_absl::StrCat(prefix, "_split_")},
+ {"cached_split_ptr", "cached_split_ptr"},
+ };
}
void SetCommonMessageDataVariables(
const Descriptor* descriptor,
- std::map<TProtoStringType, TProtoStringType>* variables) {
- TProtoStringType prefix = IsMapEntryMessage(descriptor) ? "" : "_impl_.";
- (*variables)["any_metadata"] = prefix + "_any_metadata_";
- (*variables)["cached_size"] = prefix + "_cached_size_";
- (*variables)["extensions"] = prefix + "_extensions_";
- (*variables)["has_bits"] = prefix + "_has_bits_";
- (*variables)["inlined_string_donated_array"] =
- prefix + "_inlined_string_donated_";
- (*variables)["oneof_case"] = prefix + "_oneof_case_";
- (*variables)["tracker"] = "Impl_::_tracker_";
- (*variables)["weak_field_map"] = prefix + "_weak_field_map_";
- (*variables)["split"] = prefix + "_split_";
- (*variables)["cached_split_ptr"] = "cached_split_ptr";
-}
-
-void SetUnknownFieldsVariable(const Descriptor* descriptor,
- const Options& options,
- std::map<TProtoStringType, TProtoStringType>* variables) {
- TProtoStringType proto_ns = ProtobufNamespace(options);
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables) {
+ for (auto& pair : MessageVars(descriptor)) {
+ variables->emplace(pair);
+ }
+}
+
+y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> UnknownFieldsVars(
+ const Descriptor* desc, const Options& opts) {
+ TProtoStringType proto_ns = ProtobufNamespace(opts);
+
TProtoStringType unknown_fields_type;
- if (UseUnknownFieldSet(descriptor->file(), options)) {
- unknown_fields_type = "::" + proto_ns + "::UnknownFieldSet";
- (*variables)["unknown_fields"] =
- "_internal_metadata_.unknown_fields<" + unknown_fields_type + ">(" +
- unknown_fields_type + "::default_instance)";
+ TProtoStringType default_instance;
+ if (UseUnknownFieldSet(desc->file(), opts)) {
+ unknown_fields_type = y_absl::StrCat("::", proto_ns, "::UnknownFieldSet");
+ default_instance = y_absl::StrCat(unknown_fields_type, "::default_instance");
} else {
unknown_fields_type =
- PrimitiveTypeName(options, FieldDescriptor::CPPTYPE_STRING);
- (*variables)["unknown_fields"] = "_internal_metadata_.unknown_fields<" +
- unknown_fields_type + ">(::" + proto_ns +
- "::internal::GetEmptyString)";
+ PrimitiveTypeName(opts, FieldDescriptor::CPPTYPE_STRING);
+ default_instance =
+ y_absl::StrCat("::", proto_ns, "::internal::GetEmptyString");
+ }
+
+ return {
+ {"unknown_fields",
+ y_absl::Substitute("_internal_metadata_.unknown_fields<$0>($1)",
+ unknown_fields_type, default_instance)},
+ {"unknown_fields_type", unknown_fields_type},
+ {"have_unknown_fields", "_internal_metadata_.have_unknown_fields()"},
+ {"mutable_unknown_fields",
+ y_absl::Substitute("_internal_metadata_.mutable_unknown_fields<$0>()",
+ unknown_fields_type)},
+ };
+}
+
+void SetUnknownFieldsVariable(
+ const Descriptor* descriptor, const Options& options,
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables) {
+ for (auto& pair : UnknownFieldsVars(descriptor, options)) {
+ variables->emplace(pair);
}
- (*variables)["unknown_fields_type"] = unknown_fields_type;
- (*variables)["have_unknown_fields"] =
- "_internal_metadata_.have_unknown_fields()";
- (*variables)["mutable_unknown_fields"] =
- "_internal_metadata_.mutable_unknown_fields<" + unknown_fields_type +
- ">()";
}
-TProtoStringType UnderscoresToCamelCase(const TProtoStringType& input,
+TProtoStringType UnderscoresToCamelCase(y_absl::string_view input,
bool cap_next_letter) {
TProtoStringType result;
// Note: I distrust ctype.h due to locales.
@@ -342,7 +324,9 @@ const char kThickSeparator[] =
const char kThinSeparator[] =
"// -------------------------------------------------------------------\n";
-bool CanInitializeByZeroing(const FieldDescriptor* field) {
+bool CanInitializeByZeroing(const FieldDescriptor* field,
+ const Options& options,
+ MessageSCCAnalyzer* scc_analyzer) {
if (field->is_repeated() || field->is_extension()) return false;
switch (field->cpp_type()) {
case FieldDescriptor::CPPTYPE_ENUM:
@@ -361,6 +345,57 @@ bool CanInitializeByZeroing(const FieldDescriptor* field) {
return field->default_value_double() == 0;
case FieldDescriptor::CPPTYPE_BOOL:
return field->default_value_bool() == false;
+ case FieldDescriptor::CPPTYPE_MESSAGE:
+ // Non-repeated, non-lazy message fields are raw pointers initialized to
+ // null.
+ return !IsLazy(field, options, scc_analyzer);
+ default:
+ return false;
+ }
+}
+
+bool CanClearByZeroing(const FieldDescriptor* field) {
+ if (field->is_repeated() || field->is_extension()) return false;
+ switch (field->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_ENUM:
+ return field->default_value_enum()->number() == 0;
+ case FieldDescriptor::CPPTYPE_INT32:
+ return field->default_value_int32() == 0;
+ case FieldDescriptor::CPPTYPE_INT64:
+ return field->default_value_int64() == 0;
+ case FieldDescriptor::CPPTYPE_UINT32:
+ return field->default_value_uint32() == 0;
+ case FieldDescriptor::CPPTYPE_UINT64:
+ return field->default_value_uint64() == 0;
+ case FieldDescriptor::CPPTYPE_FLOAT:
+ return field->default_value_float() == 0;
+ case FieldDescriptor::CPPTYPE_DOUBLE:
+ return field->default_value_double() == 0;
+ case FieldDescriptor::CPPTYPE_BOOL:
+ return field->default_value_bool() == false;
+ default:
+ return false;
+ }
+}
+
+// Determines if swap can be implemented via memcpy.
+bool HasTrivialSwap(const FieldDescriptor* field, const Options& options,
+ MessageSCCAnalyzer* scc_analyzer) {
+ if (field->is_repeated() || field->is_extension()) return false;
+ switch (field->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_ENUM:
+ case FieldDescriptor::CPPTYPE_INT32:
+ case FieldDescriptor::CPPTYPE_INT64:
+ case FieldDescriptor::CPPTYPE_UINT32:
+ case FieldDescriptor::CPPTYPE_UINT64:
+ case FieldDescriptor::CPPTYPE_FLOAT:
+ case FieldDescriptor::CPPTYPE_DOUBLE:
+ case FieldDescriptor::CPPTYPE_BOOL:
+ return true;
+ case FieldDescriptor::CPPTYPE_MESSAGE:
+ // Non-repeated, non-lazy message fields are simply raw pointers, so we
+ // can swap them with memcpy.
+ return !IsLazy(field, options, scc_analyzer);
default:
return false;
}
@@ -369,9 +404,9 @@ bool CanInitializeByZeroing(const FieldDescriptor* field) {
TProtoStringType ClassName(const Descriptor* descriptor) {
const Descriptor* parent = descriptor->containing_type();
TProtoStringType res;
- if (parent) res += ClassName(parent) + "_";
- res += descriptor->name();
- if (IsMapEntryMessage(descriptor)) res += "_DoNotUse";
+ if (parent) y_absl::StrAppend(&res, ClassName(parent), "_");
+ y_absl::StrAppend(&res, descriptor->name());
+ if (IsMapEntryMessage(descriptor)) y_absl::StrAppend(&res, "_DoNotUse");
return ResolveKeyword(res);
}
@@ -379,8 +414,8 @@ TProtoStringType ClassName(const EnumDescriptor* enum_descriptor) {
if (enum_descriptor->containing_type() == nullptr) {
return ResolveKeyword(enum_descriptor->name());
} else {
- return ClassName(enum_descriptor->containing_type()) + "_" +
- enum_descriptor->name();
+ return y_absl::StrCat(ClassName(enum_descriptor->containing_type()), "_",
+ enum_descriptor->name());
}
}
@@ -403,13 +438,13 @@ TProtoStringType QualifiedClassName(const EnumDescriptor* d) {
TProtoStringType ExtensionName(const FieldDescriptor* d) {
if (const Descriptor* scope = d->extension_scope())
- return StrCat(ClassName(scope), "::", ResolveKeyword(d->name()));
+ return y_absl::StrCat(ClassName(scope), "::", ResolveKeyword(d->name()));
return ResolveKeyword(d->name());
}
TProtoStringType QualifiedExtensionName(const FieldDescriptor* d,
const Options& options) {
- GOOGLE_DCHECK(d->is_extension());
+ Y_ABSL_DCHECK(d->is_extension());
return QualifiedFileLevelSymbol(d->file(), ExtensionName(d), options);
}
@@ -417,32 +452,38 @@ TProtoStringType QualifiedExtensionName(const FieldDescriptor* d) {
return QualifiedExtensionName(d, Options());
}
-TProtoStringType Namespace(const TProtoStringType& package) {
+TProtoStringType Namespace(y_absl::string_view package) {
if (package.empty()) return "";
- return "::" + DotsToColons(package);
+ return y_absl::StrCat("::", DotsToColons(package));
}
+TProtoStringType Namespace(const FileDescriptor* d) { return Namespace(d, {}); }
TProtoStringType Namespace(const FileDescriptor* d, const Options& options) {
- TProtoStringType ret = Namespace(d->package());
+ TProtoStringType ns = Namespace(d->package());
if (IsWellKnownMessage(d) && options.opensource_runtime) {
// Written with string concatenation to prevent rewriting of
// ::google::protobuf.
- ret = StringReplace(ret,
- "::google::"
- "protobuf",
- "::PROTOBUF_NAMESPACE_ID", false);
+ constexpr y_absl::string_view prefix =
+ "::google::" // prevent clang-format reflowing
+ "protobuf";
+ y_absl::string_view new_ns(ns);
+ y_absl::ConsumePrefix(&new_ns, prefix);
+ return y_absl::StrCat("::PROTOBUF_NAMESPACE_ID", new_ns);
}
- return ret;
+ return ns;
}
+TProtoStringType Namespace(const Descriptor* d) { return Namespace(d, {}); }
TProtoStringType Namespace(const Descriptor* d, const Options& options) {
return Namespace(d->file(), options);
}
+TProtoStringType Namespace(const FieldDescriptor* d) { return Namespace(d, {}); }
TProtoStringType Namespace(const FieldDescriptor* d, const Options& options) {
return Namespace(d->file(), options);
}
+TProtoStringType Namespace(const EnumDescriptor* d) { return Namespace(d, {}); }
TProtoStringType Namespace(const EnumDescriptor* d, const Options& options) {
return Namespace(d->file(), options);
}
@@ -455,13 +496,13 @@ TProtoStringType DefaultInstanceType(const Descriptor* descriptor,
TProtoStringType DefaultInstanceName(const Descriptor* descriptor,
const Options& /*options*/, bool split) {
- return "_" + ClassName(descriptor, false) + (split ? "__Impl_Split" : "") +
- "_default_instance_";
+ return y_absl::StrCat("_", ClassName(descriptor, false),
+ (split ? "__Impl_Split" : ""), "_default_instance_");
}
TProtoStringType DefaultInstancePtr(const Descriptor* descriptor,
const Options& options, bool split) {
- return DefaultInstanceName(descriptor, options, split) + "ptr_";
+ return y_absl::StrCat(DefaultInstanceName(descriptor, options, split), "ptr_");
}
TProtoStringType QualifiedDefaultInstanceName(const Descriptor* descriptor,
@@ -473,7 +514,8 @@ TProtoStringType QualifiedDefaultInstanceName(const Descriptor* descriptor,
TProtoStringType QualifiedDefaultInstancePtr(const Descriptor* descriptor,
const Options& options, bool split) {
- return QualifiedDefaultInstanceName(descriptor, options, split) + "ptr_";
+ return y_absl::StrCat(QualifiedDefaultInstanceName(descriptor, options, split),
+ "ptr_");
}
TProtoStringType DescriptorTableName(const FileDescriptor* file,
@@ -488,60 +530,61 @@ TProtoStringType FileDllExport(const FileDescriptor* file, const Options& option
TProtoStringType SuperClassName(const Descriptor* descriptor,
const Options& options) {
if (!HasDescriptorMethods(descriptor->file(), options)) {
- return "::" + ProtobufNamespace(options) + "::MessageLite";
+ return y_absl::StrCat("::", ProtobufNamespace(options), "::MessageLite");
}
auto simple_base = SimpleBaseClass(descriptor, options);
if (simple_base.empty()) {
- return "::" + ProtobufNamespace(options) + "::Message";
+ return y_absl::StrCat("::", ProtobufNamespace(options), "::Message");
}
- return "::" + ProtobufNamespace(options) + "::internal::" + simple_base;
+ return y_absl::StrCat("::", ProtobufNamespace(options),
+ "::internal::", simple_base);
}
-TProtoStringType ResolveKeyword(const TProtoStringType& name) {
- if (kKeywords.count(name) > 0) {
- return name + "_";
+TProtoStringType ResolveKeyword(y_absl::string_view name) {
+ if (Keywords().count(name) > 0) {
+ return y_absl::StrCat(name, "_");
}
- return name;
+ return TProtoStringType(name);
}
TProtoStringType FieldName(const FieldDescriptor* field) {
TProtoStringType result = field->name();
- LowerString(&result);
- if (kKeywords.count(result) > 0) {
+ y_absl::AsciiStrToLower(&result);
+ if (Keywords().count(result) > 0) {
result.append("_");
}
return result;
}
TProtoStringType FieldMemberName(const FieldDescriptor* field, bool split) {
- StringPiece prefix =
+ y_absl::string_view prefix =
IsMapEntryMessage(field->containing_type()) ? "" : "_impl_.";
- StringPiece split_prefix = split ? "_split_->" : "";
+ y_absl::string_view split_prefix = split ? "_split_->" : "";
if (field->real_containing_oneof() == nullptr) {
- return StrCat(prefix, split_prefix, FieldName(field), "_");
+ return y_absl::StrCat(prefix, split_prefix, FieldName(field), "_");
}
// Oneof fields are never split.
- GOOGLE_CHECK(!split);
- return StrCat(prefix, field->containing_oneof()->name(), "_.",
+ Y_ABSL_CHECK(!split);
+ return y_absl::StrCat(prefix, field->containing_oneof()->name(), "_.",
FieldName(field), "_");
}
TProtoStringType OneofCaseConstantName(const FieldDescriptor* field) {
- GOOGLE_DCHECK(field->containing_oneof());
+ Y_ABSL_DCHECK(field->containing_oneof());
TProtoStringType field_name = UnderscoresToCamelCase(field->name(), true);
- return "k" + field_name;
+ return y_absl::StrCat("k", field_name);
}
TProtoStringType QualifiedOneofCaseConstantName(const FieldDescriptor* field) {
- GOOGLE_DCHECK(field->containing_oneof());
+ Y_ABSL_DCHECK(field->containing_oneof());
const TProtoStringType qualification =
QualifiedClassName(field->containing_type());
- return StrCat(qualification, "::", OneofCaseConstantName(field));
+ return y_absl::StrCat(qualification, "::", OneofCaseConstantName(field));
}
TProtoStringType EnumValueName(const EnumValueDescriptor* enum_value) {
TProtoStringType result = enum_value->name();
- if (kKeywords.count(result) > 0) {
+ if (Keywords().count(result) > 0) {
result.append("_");
}
return result;
@@ -567,13 +610,13 @@ int EstimateAlignmentSize(const FieldDescriptor* field) {
case FieldDescriptor::CPPTYPE_MESSAGE:
return 8;
}
- GOOGLE_LOG(FATAL) << "Can't get here.";
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
return -1; // Make compiler happy.
}
TProtoStringType FieldConstantName(const FieldDescriptor* field) {
TProtoStringType field_name = UnderscoresToCamelCase(field->name(), true);
- TProtoStringType result = "k" + field_name + "FieldNumber";
+ TProtoStringType result = y_absl::StrCat("k", field_name, "FieldNumber");
if (!field->is_extension() &&
field->containing_type()->FindFieldByCamelcaseName(
@@ -581,7 +624,7 @@ TProtoStringType FieldConstantName(const FieldDescriptor* field) {
// This field's camelcase name is not unique. As a hack, add the field
// number to the constant name. This makes the constant rather useless,
// but what can we do?
- result += "_" + StrCat(field->number());
+ y_absl::StrAppend(&result, "_", field->number());
}
return result;
@@ -594,7 +637,7 @@ TProtoStringType FieldMessageTypeName(const FieldDescriptor* field,
return QualifiedClassName(field->message_type(), options);
}
-TProtoStringType StripProto(const TProtoStringType& filename) {
+TProtoStringType StripProto(y_absl::string_view filename) {
/*
* TODO(github/georgthegreat) remove this proxy method
* once Google's internal codebase will become ready
@@ -605,13 +648,13 @@ TProtoStringType StripProto(const TProtoStringType& filename) {
const char* PrimitiveTypeName(FieldDescriptor::CppType type) {
switch (type) {
case FieldDescriptor::CPPTYPE_INT32:
- return "arc_i32";
+ return "::arc_i32";
case FieldDescriptor::CPPTYPE_INT64:
- return "arc_i64";
+ return "::arc_i64";
case FieldDescriptor::CPPTYPE_UINT32:
- return "arc_ui32";
+ return "::arc_ui32";
case FieldDescriptor::CPPTYPE_UINT64:
- return "arc_ui64";
+ return "::arc_ui64";
case FieldDescriptor::CPPTYPE_DOUBLE:
return "double";
case FieldDescriptor::CPPTYPE_FLOAT:
@@ -629,7 +672,7 @@ const char* PrimitiveTypeName(FieldDescriptor::CppType type) {
// CppTypes are added.
}
- GOOGLE_LOG(FATAL) << "Can't get here.";
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
return nullptr;
}
@@ -661,7 +704,7 @@ TProtoStringType PrimitiveTypeName(const Options& options,
// CppTypes are added.
}
- GOOGLE_LOG(FATAL) << "Can't get here.";
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
return "";
}
@@ -709,7 +752,7 @@ const char* DeclaredTypeMethodName(FieldDescriptor::Type type) {
// No default because we want the compiler to complain if any new
// types are added.
}
- GOOGLE_LOG(FATAL) << "Can't get here.";
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
return "";
}
@@ -717,9 +760,9 @@ TProtoStringType Int32ToString(int number) {
if (number == std::numeric_limits<arc_i32>::min()) {
// This needs to be special-cased, see explanation here:
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661
- return StrCat(number + 1, " - 1");
+ return y_absl::StrCat(number + 1, " - 1");
} else {
- return StrCat(number);
+ return y_absl::StrCat(number);
}
}
@@ -727,13 +770,13 @@ static TProtoStringType Int64ToString(arc_i64 number) {
if (number == std::numeric_limits<arc_i64>::min()) {
// This needs to be special-cased, see explanation here:
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661
- return StrCat("arc_i64{", number + 1, "} - 1");
+ return y_absl::StrCat("::arc_i64{", number + 1, "} - 1");
}
- return StrCat("arc_i64{", number, "}");
+ return y_absl::StrCat("::arc_i64{", number, "}");
}
static TProtoStringType UInt64ToString(arc_ui64 number) {
- return StrCat("arc_ui64{", number, "u}");
+ return y_absl::StrCat("::arc_ui64{", number, "u}");
}
TProtoStringType DefaultValue(const FieldDescriptor* field) {
@@ -745,7 +788,7 @@ TProtoStringType DefaultValue(const Options& options, const FieldDescriptor* fie
case FieldDescriptor::CPPTYPE_INT32:
return Int32ToString(field->default_value_int32());
case FieldDescriptor::CPPTYPE_UINT32:
- return StrCat(field->default_value_uint32()) + "u";
+ return y_absl::StrCat(field->default_value_uint32(), "u");
case FieldDescriptor::CPPTYPE_INT64:
return Int64ToString(field->default_value_int64());
case FieldDescriptor::CPPTYPE_UINT64:
@@ -759,7 +802,7 @@ TProtoStringType DefaultValue(const Options& options, const FieldDescriptor* fie
} else if (value != value) {
return "std::numeric_limits<double>::quiet_NaN()";
} else {
- return SimpleDtoa(value);
+ return io::SimpleDtoa(value);
}
}
case FieldDescriptor::CPPTYPE_FLOAT: {
@@ -771,7 +814,7 @@ TProtoStringType DefaultValue(const Options& options, const FieldDescriptor* fie
} else if (value != value) {
return "std::numeric_limits<float>::quiet_NaN()";
} else {
- TProtoStringType float_value = SimpleFtoa(value);
+ TProtoStringType float_value = io::SimpleFtoa(value);
// If floating point value contains a period (.) or an exponent
// (either E or e), then append suffix 'f' to make it a float
// literal.
@@ -786,73 +829,73 @@ TProtoStringType DefaultValue(const Options& options, const FieldDescriptor* fie
case FieldDescriptor::CPPTYPE_ENUM:
// Lazy: Generate a static_cast because we don't have a helper function
// that constructs the full name of an enum value.
- return strings::Substitute(
+ return y_absl::Substitute(
"static_cast< $0 >($1)", ClassName(field->enum_type(), true),
Int32ToString(field->default_value_enum()->number()));
case FieldDescriptor::CPPTYPE_STRING:
- return "\"" +
- EscapeTrigraphs(CEscape(field->default_value_string())) +
- "\"";
+ return y_absl::StrCat(
+ "\"", EscapeTrigraphs(y_absl::CEscape(field->default_value_string())),
+ "\"");
case FieldDescriptor::CPPTYPE_MESSAGE:
- return "*" + FieldMessageTypeName(field, options) +
- "::internal_default_instance()";
+ return y_absl::StrCat("*", FieldMessageTypeName(field, options),
+ "::internal_default_instance()");
}
// Can't actually get here; make compiler happy. (We could add a default
// case above but then we wouldn't get the nice compiler warning when a
// new type is added.)
- GOOGLE_LOG(FATAL) << "Can't get here.";
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
return "";
}
// Convert a file name into a valid identifier.
-TProtoStringType FilenameIdentifier(const TProtoStringType& filename) {
+TProtoStringType FilenameIdentifier(y_absl::string_view filename) {
TProtoStringType result;
for (int i = 0; i < filename.size(); i++) {
- if (ascii_isalnum(filename[i])) {
+ if (y_absl::ascii_isalnum(filename[i])) {
result.push_back(filename[i]);
} else {
// Not alphanumeric. To avoid any possibility of name conflicts we
// use the hex code for the character.
- StrAppend(&result, "_",
- strings::Hex(static_cast<uint8_t>(filename[i])));
+ y_absl::StrAppend(&result, "_",
+ y_absl::Hex(static_cast<uint8_t>(filename[i])));
}
}
return result;
}
-TProtoStringType UniqueName(const TProtoStringType& name, const TProtoStringType& filename,
+TProtoStringType UniqueName(y_absl::string_view name, y_absl::string_view filename,
const Options& options) {
- return name + "_" + FilenameIdentifier(filename);
+ return y_absl::StrCat(name, "_", FilenameIdentifier(filename));
}
// Return the qualified C++ name for a file level symbol.
TProtoStringType QualifiedFileLevelSymbol(const FileDescriptor* file,
- const TProtoStringType& name,
+ y_absl::string_view name,
const Options& options) {
if (file->package().empty()) {
- return StrCat("::", name);
+ return y_absl::StrCat("::", name);
}
- return StrCat(Namespace(file, options), "::", name);
+ return y_absl::StrCat(Namespace(file, options), "::", name);
}
// Escape C++ trigraphs by escaping question marks to \?
-TProtoStringType EscapeTrigraphs(const TProtoStringType& to_escape) {
- return StringReplace(to_escape, "?", "\\?", true);
+TProtoStringType EscapeTrigraphs(y_absl::string_view to_escape) {
+ return y_absl::StrReplaceAll(to_escape, {{"?", "\\?"}});
}
// Escaped function name to eliminate naming conflict.
TProtoStringType SafeFunctionName(const Descriptor* descriptor,
const FieldDescriptor* field,
- const TProtoStringType& prefix) {
+ y_absl::string_view prefix) {
// Do not use FieldName() since it will escape keywords.
TProtoStringType name = field->name();
- LowerString(&name);
- TProtoStringType function_name = prefix + name;
+ y_absl::AsciiStrToLower(&name);
+ TProtoStringType function_name = y_absl::StrCat(prefix, name);
if (descriptor->FindFieldByName(function_name)) {
// Single underscore will also make it conflicting with the private data
// member. We use double underscore to escape function names.
function_name.append("__");
- } else if (kKeywords.count(name) > 0) {
+ } else if (Keywords().count(name) > 0) {
// If the field name is a keyword, we append the underscore back to keep it
// consistent with other function names.
function_name.append("_");
@@ -860,6 +903,9 @@ TProtoStringType SafeFunctionName(const Descriptor* descriptor,
return function_name;
}
+bool IsProfileDriven(const Options& options) {
+ return options.access_info_map != nullptr;
+}
bool IsStringInlined(const FieldDescriptor* descriptor,
const Options& options) {
(void)descriptor;
@@ -907,6 +953,13 @@ bool HasLazyFields(const FileDescriptor* file, const Options& options,
bool ShouldSplit(const Descriptor*, const Options&) { return false; }
bool ShouldSplit(const FieldDescriptor*, const Options&) { return false; }
+bool ShouldForceAllocationOnConstruction(const Descriptor* desc,
+ const Options& options) {
+ (void)desc;
+ (void)options;
+ return false;
+}
+
static bool HasRepeatedFields(const Descriptor* descriptor) {
for (int i = 0; i < descriptor->field_count(); ++i) {
if (descriptor->field(i)->label() == FieldDescriptor::LABEL_REPEATED) {
@@ -1045,7 +1098,7 @@ bool ShouldVerify(const FileDescriptor* file, const Options& options,
bool IsUtf8String(const FieldDescriptor* field) {
return IsProto3(field->file()) &&
- field->type() == FieldDescriptor::TYPE_STRING;
+ field->type() == FieldDescriptor::TYPE_STRING;
}
VerifySimpleType ShouldVerifySimple(const Descriptor* descriptor) {
@@ -1069,13 +1122,13 @@ bool IsStringOrMessage(const FieldDescriptor* field) {
return true;
}
- GOOGLE_LOG(FATAL) << "Can't get here.";
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
return false;
}
FieldOptions::CType EffectiveStringCType(const FieldDescriptor* field,
const Options& options) {
- GOOGLE_DCHECK(field->cpp_type() == FieldDescriptor::CPPTYPE_STRING);
+ Y_ABSL_DCHECK(field->cpp_type() == FieldDescriptor::CPPTYPE_STRING);
if (options.opensource_runtime) {
// Open-source protobuf release only supports STRING ctype.
return FieldOptions::STRING;
@@ -1095,7 +1148,7 @@ bool IsAnyMessage(const Descriptor* descriptor, const Options& options) {
}
bool IsWellKnownMessage(const FileDescriptor* file) {
- static const std::unordered_set<TProtoStringType> well_known_files{
+ static const auto* well_known_files = new y_absl::flat_hash_set<TProtoStringType>{
"google/protobuf/any.proto",
"google/protobuf/api.proto",
"google/protobuf/compiler/plugin.proto",
@@ -1109,94 +1162,127 @@ bool IsWellKnownMessage(const FileDescriptor* file) {
"google/protobuf/type.proto",
"google/protobuf/wrappers.proto",
};
- return well_known_files.find(file->name()) != well_known_files.end();
-}
-
-static bool FieldEnforceUtf8(const FieldDescriptor* field,
- const Options& options) {
- return true;
+ return well_known_files->find(file->name()) != well_known_files->end();
}
-static bool FileUtf8Verification(const FileDescriptor* file,
- const Options& options) {
- return true;
-}
+void NamespaceOpener::ChangeTo(y_absl::string_view name) {
+ std::vector<TProtoStringType> new_stack =
+ y_absl::StrSplit(name, "::", y_absl::SkipEmpty());
+ size_t len = std::min(name_stack_.size(), new_stack.size());
+ size_t common_idx = 0;
+ while (common_idx < len) {
+ if (name_stack_[common_idx] != new_stack[common_idx]) {
+ break;
+ }
+ ++common_idx;
+ }
-// Which level of UTF-8 enforcemant is placed on this file.
-Utf8CheckMode GetUtf8CheckMode(const FieldDescriptor* field,
- const Options& options) {
- if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 &&
- FieldEnforceUtf8(field, options)) {
- return Utf8CheckMode::kStrict;
- } else if (GetOptimizeFor(field->file(), options) !=
- FileOptions::LITE_RUNTIME &&
- FileUtf8Verification(field->file(), options)) {
- return Utf8CheckMode::kVerify;
- } else {
- return Utf8CheckMode::kNone;
+ for (size_t i = name_stack_.size(); i > common_idx; i--) {
+ const auto& ns = name_stack_[i - 1];
+ if (ns == "PROTOBUF_NAMESPACE_ID") {
+ p_->Emit(R"cc(
+ PROTOBUF_NAMESPACE_CLOSE
+ )cc");
+ } else {
+ p_->Emit({{"ns", ns}}, R"(
+ } // namespace $ns$
+ )");
+ }
+ }
+ for (size_t i = common_idx; i < new_stack.size(); ++i) {
+ const auto& ns = new_stack[i];
+ if (ns == "PROTOBUF_NAMESPACE_ID") {
+ p_->Emit(R"cc(
+ PROTOBUF_NAMESPACE_OPEN
+ )cc");
+ } else {
+ p_->Emit({{"ns", ns}}, R"(
+ namespace $ns$ {
+ )");
+ }
}
+
+ name_stack_ = std::move(new_stack);
}
-static void GenerateUtf8CheckCode(const FieldDescriptor* field,
+static void GenerateUtf8CheckCode(io::Printer* p, const FieldDescriptor* field,
const Options& options, bool for_parse,
- const char* parameters,
- const char* strict_function,
- const char* verify_function,
- const Formatter& format) {
- switch (GetUtf8CheckMode(field, options)) {
- case Utf8CheckMode::kStrict: {
+ y_absl::string_view params,
+ y_absl::string_view strict_function,
+ y_absl::string_view verify_function) {
+ if (field->type() != FieldDescriptor::TYPE_STRING) return;
+
+ auto v = p->WithVars({
+ {"params", params},
+ {"Strict", strict_function},
+ {"Verify", verify_function},
+ });
+
+ bool is_lite =
+ GetOptimizeFor(field->file(), options) == FileOptions::LITE_RUNTIME;
+ switch (internal::cpp::GetUtf8CheckMode(field, is_lite)) {
+ case internal::cpp::Utf8CheckMode::kStrict:
if (for_parse) {
- format("DO_(");
- }
- format("::$proto_ns$::internal::WireFormatLite::$1$(\n", strict_function);
- format.Indent();
- format(parameters);
- if (for_parse) {
- format("::$proto_ns$::internal::WireFormatLite::PARSE,\n");
+ p->Emit(R"cc(
+ DO_($pbi$::WireFormatLite::$Strict$(
+ $params$ $pbi$::WireFormatLite::PARSE, "$pkg.Msg.field$"));
+ )cc");
} else {
- format("::$proto_ns$::internal::WireFormatLite::SERIALIZE,\n");
+ p->Emit(R"cc(
+ $pbi$::WireFormatLite::$Strict$(
+ $params$ $pbi$::WireFormatLite::SERIALIZE, "$pkg.Msg.field$");
+ )cc");
}
- format("\"$1$\")", field->full_name());
- if (for_parse) {
- format(")");
- }
- format(";\n");
- format.Outdent();
break;
- }
- case Utf8CheckMode::kVerify: {
- format("::$proto_ns$::internal::WireFormat::$1$(\n", verify_function);
- format.Indent();
- format(parameters);
+
+ case internal::cpp::Utf8CheckMode::kVerify:
if (for_parse) {
- format("::$proto_ns$::internal::WireFormat::PARSE,\n");
+ p->Emit(R"cc(
+ $pbi$::WireFormat::$Verify$($params$ $pbi$::WireFormat::PARSE,
+ "$pkg.Msg.field$");
+ )cc");
} else {
- format("::$proto_ns$::internal::WireFormat::SERIALIZE,\n");
+ p->Emit(R"cc(
+ $pbi$::WireFormat::$Verify$($params$ $pbi$::WireFormat::SERIALIZE,
+ "$pkg.Msg.field$");
+ )cc");
}
- format("\"$1$\");\n", field->full_name());
- format.Outdent();
break;
- }
- case Utf8CheckMode::kNone:
+
+ case internal::cpp::Utf8CheckMode::kNone:
break;
}
}
void GenerateUtf8CheckCodeForString(const FieldDescriptor* field,
const Options& options, bool for_parse,
- const char* parameters,
+ y_absl::string_view parameters,
const Formatter& format) {
- GenerateUtf8CheckCode(field, options, for_parse, parameters,
- "VerifyUtf8String", "VerifyUTF8StringNamedField",
- format);
+ GenerateUtf8CheckCode(format.printer(), field, options, for_parse, parameters,
+ "VerifyUtf8String", "VerifyUTF8StringNamedField");
}
void GenerateUtf8CheckCodeForCord(const FieldDescriptor* field,
const Options& options, bool for_parse,
- const char* parameters,
+ y_absl::string_view parameters,
const Formatter& format) {
- GenerateUtf8CheckCode(field, options, for_parse, parameters, "VerifyUtf8Cord",
- "VerifyUTF8CordNamedField", format);
+ GenerateUtf8CheckCode(format.printer(), field, options, for_parse, parameters,
+ "VerifyUtf8Cord", "VerifyUTF8CordNamedField");
+}
+
+void GenerateUtf8CheckCodeForString(io::Printer* p,
+ const FieldDescriptor* field,
+ const Options& options, bool for_parse,
+ y_absl::string_view parameters) {
+ GenerateUtf8CheckCode(p, field, options, for_parse, parameters,
+ "VerifyUtf8String", "VerifyUTF8StringNamedField");
+}
+
+void GenerateUtf8CheckCodeForCord(io::Printer* p, const FieldDescriptor* field,
+ const Options& options, bool for_parse,
+ y_absl::string_view parameters) {
+ GenerateUtf8CheckCode(p, field, options, for_parse, parameters,
+ "VerifyUtf8Cord", "VerifyUTF8CordNamedField");
}
void FlattenMessagesInFile(const FileDescriptor* file,
@@ -1243,7 +1329,9 @@ bool IsImplicitWeakField(const FieldDescriptor* field, const Options& options,
}
MessageAnalysis MessageSCCAnalyzer::GetSCCAnalysis(const SCC* scc) {
- if (analysis_cache_.count(scc)) return analysis_cache_[scc];
+ auto it = analysis_cache_.find(scc);
+ if (it != analysis_cache_.end()) return it->second;
+
MessageAnalysis result;
if (UsingImplicitWeakFields(scc->GetFile(), options_)) {
result.contains_weak = true;
@@ -1298,7 +1386,7 @@ MessageAnalysis MessageSCCAnalyzer::GetSCCAnalysis(const SCC* scc) {
// in the graph, the graph should be a DAG. Hence we shouldn't need to mark
// nodes visited as we can never return to them. By inserting them here
// we will go in an infinite loop if the SCC is not correct.
- return analysis_cache_[scc] = result;
+ return analysis_cache_[scc] = std::move(result);
}
void ListAllFields(const Descriptor* d,
@@ -1341,23 +1429,26 @@ void ListAllTypesForServices(const FileDescriptor* fd,
}
}
-bool GetBootstrapBasename(const Options& options, const TProtoStringType& basename,
+bool GetBootstrapBasename(const Options& options, y_absl::string_view basename,
TProtoStringType* bootstrap_basename) {
if (options.opensource_runtime) {
return false;
}
- std::unordered_map<TProtoStringType, TProtoStringType> bootstrap_mapping{
- {"net/proto2/proto/descriptor",
- "third_party/protobuf/descriptor"},
- {"net/proto2/compiler/proto/plugin",
- "net/proto2/compiler/proto/plugin"},
- {"net/proto2/compiler/proto/profile",
- "net/proto2/compiler/proto/profile_bootstrap"},
- };
- auto iter = bootstrap_mapping.find(basename);
- if (iter == bootstrap_mapping.end()) {
- *bootstrap_basename = basename;
+ static const auto* bootstrap_mapping =
+ // TODO(b/242858704) Replace these with string_view once we remove
+ // StringPiece.
+ new y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>{
+ {"net/proto2/proto/descriptor",
+ "third_party/protobuf/descriptor"},
+ {"net/proto2/compiler/proto/plugin",
+ "net/proto2/compiler/proto/plugin"},
+ {"net/proto2/compiler/proto/profile",
+ "net/proto2/compiler/proto/profile_bootstrap"},
+ };
+ auto iter = bootstrap_mapping->find(basename);
+ if (iter == bootstrap_mapping->end()) {
+ *bootstrap_basename = TProtoStringType(basename);
return false;
} else {
*bootstrap_basename = iter->second;
@@ -1381,70 +1472,64 @@ bool MaybeBootstrap(const Options& options, GeneratorContext* generator_context,
// Adjust basename, but don't abort code generation.
*basename = bootstrap_basename;
return false;
- } else {
- const TProtoStringType& forward_to_basename = bootstrap_basename;
-
- // Generate forwarding headers and empty .pb.cc.
- {
- std::unique_ptr<io::ZeroCopyOutputStream> output(
- generator_context->Open(*basename + ".pb.h"));
- io::Printer printer(output.get(), '$', nullptr);
- printer.Print(
- "#ifndef PROTOBUF_INCLUDED_$filename_identifier$_FORWARD_PB_H\n"
- "#define PROTOBUF_INCLUDED_$filename_identifier$_FORWARD_PB_H\n"
- "#include \"$forward_to_basename$.pb.h\" // IWYU pragma: export\n"
- "#endif // PROTOBUF_INCLUDED_$filename_identifier$_FORWARD_PB_H\n",
- "forward_to_basename", forward_to_basename, "filename_identifier",
- FilenameIdentifier(*basename));
-
- if (!options.opensource_runtime) {
- // HACK HACK HACK, tech debt from the deeps of proto1 and SWIG
- // protocoltype is SWIG'ed and we need to forward
- if (*basename == "net/proto/protocoltype") {
- printer.Print(
- "#ifdef SWIG\n"
- "%include \"$forward_to_basename$.pb.h\"\n"
- "#endif // SWIG\n",
- "forward_to_basename", forward_to_basename);
- }
- }
- }
-
- {
- std::unique_ptr<io::ZeroCopyOutputStream> output(
- generator_context->Open(*basename + ".proto.h"));
- io::Printer printer(output.get(), '$', nullptr);
- printer.Print(
- "#ifndef PROTOBUF_INCLUDED_$filename_identifier$_FORWARD_PROTO_H\n"
- "#define PROTOBUF_INCLUDED_$filename_identifier$_FORWARD_PROTO_H\n"
- "#include \"$forward_to_basename$.proto.h\" // IWYU pragma: "
- "export\n"
- "#endif // "
- "PROTOBUF_INCLUDED_$filename_identifier$_FORWARD_PROTO_H\n",
- "forward_to_basename", forward_to_basename, "filename_identifier",
- FilenameIdentifier(*basename));
- }
-
- {
- std::unique_ptr<io::ZeroCopyOutputStream> output(
- generator_context->Open(*basename + ".pb.cc"));
- io::Printer printer(output.get(), '$', nullptr);
- printer.Print("\n");
- }
-
- {
- std::unique_ptr<io::ZeroCopyOutputStream> output(
- generator_context->Open(*basename + ".pb.h.meta"));
- }
-
- {
- std::unique_ptr<io::ZeroCopyOutputStream> output(
- generator_context->Open(*basename + ".proto.h.meta"));
- }
-
- // Abort code generation.
- return true;
}
+
+ auto pb_h = y_absl::WrapUnique(
+ generator_context->Open(y_absl::StrCat(*basename, ".pb.h")));
+
+ io::Printer p(pb_h.get());
+ p.Emit(
+ {
+ {"fwd_to", bootstrap_basename},
+ {"file", FilenameIdentifier(*basename)},
+ {"fwd_to_suffix", options.opensource_runtime ? "pb" : "proto"},
+ {"swig_evil",
+ [&] {
+ if (options.opensource_runtime) {
+ return;
+ }
+ p.Emit(R"(
+ #ifdef SWIG
+ %include "$fwd_to$.pb.h"
+ #endif // SWIG
+ )");
+ }},
+ },
+ R"(
+ #ifndef PROTOBUF_INCLUDED_$file$_FORWARD_PB_H
+ #define PROTOBUF_INCLUDED_$file$_FORWARD_PB_H
+ #include "$fwd_to$.$fwd_to_suffix$.h" // IWYU pragma: export
+ #endif // PROTOBUF_INCLUDED_$file$_FORWARD_PB_H
+ $swig_evil$;
+ )");
+
+ auto proto_h = y_absl::WrapUnique(
+ generator_context->Open(y_absl::StrCat(*basename, ".proto.h")));
+ io::Printer(proto_h.get())
+ .Emit(
+ {
+ {"fwd_to", bootstrap_basename},
+ {"file", FilenameIdentifier(*basename)},
+ },
+ R"(
+ #ifndef PROTOBUF_INCLUDED_$file$_FORWARD_PROTO_H
+ #define PROTOBUF_INCLUDED_$file$_FORWARD_PROTO_H
+ #include "$fwd_to$.proto.h" // IWYU pragma: export
+ #endif // PROTOBUF_INCLUDED_$file$_FORWARD_PROTO_H
+ )");
+
+ auto pb_cc = y_absl::WrapUnique(
+ generator_context->Open(y_absl::StrCat(*basename, ".pb.cc")));
+ io::Printer(pb_cc.get()).PrintRaw("\n");
+
+ (void)y_absl::WrapUnique(
+ generator_context->Open(y_absl::StrCat(*basename, ".pb.h.meta")));
+
+ (void)y_absl::WrapUnique(
+ generator_context->Open(y_absl::StrCat(*basename, ".proto.h.meta")));
+
+ // Abort code generation.
+ return true;
}
static bool HasExtensionFromFile(const Message& msg, const FileDescriptor* file,
@@ -1492,9 +1577,18 @@ static bool HasExtensionFromFile(const Message& msg, const FileDescriptor* file,
static bool HasBootstrapProblem(const FileDescriptor* file,
const Options& options,
bool* has_opt_codesize_extension) {
- static auto& cache = *new std::unordered_map<const FileDescriptor*, bool>;
- auto it = cache.find(file);
- if (it != cache.end()) return it->second;
+ struct BoostrapGlobals {
+ y_absl::Mutex mutex;
+ y_absl::flat_hash_set<const FileDescriptor*> cached Y_ABSL_GUARDED_BY(mutex);
+ y_absl::flat_hash_set<const FileDescriptor*> non_cached
+ Y_ABSL_GUARDED_BY(mutex);
+ };
+ static auto& bootstrap_cache = *new BoostrapGlobals();
+
+ y_absl::MutexLock lock(&bootstrap_cache.mutex);
+ if (bootstrap_cache.cached.contains(file)) return true;
+ if (bootstrap_cache.non_cached.contains(file)) return false;
+
// In order to build the data structures for the reflective parse, it needs
// to parse the serialized descriptor describing all the messages defined in
// this file. Obviously this presents a bootstrap problem for descriptor
@@ -1530,9 +1624,13 @@ static bool HasBootstrapProblem(const FileDescriptor* file,
Message* fd_proto = factory.GetPrototype(fd_proto_descriptor)->New();
fd_proto->ParseFromString(linkedin_fd_proto.SerializeAsString());
- bool& res = cache[file];
- res = HasExtensionFromFile(*fd_proto, file, options,
- has_opt_codesize_extension);
+ bool res = HasExtensionFromFile(*fd_proto, file, options,
+ has_opt_codesize_extension);
+ if (res) {
+ bootstrap_cache.cached.insert(file);
+ } else {
+ bootstrap_cache.non_cached.insert(file);
+ }
delete fd_proto;
return res;
}
@@ -1557,38 +1655,21 @@ FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file,
case EnforceOptimizeMode::kNoEnforcement:
if (file->options().optimize_for() == FileOptions::CODE_SIZE) {
if (HasBootstrapProblem(file, options, has_opt_codesize_extension)) {
- GOOGLE_LOG(WARNING) << "Proto states optimize_for = CODE_SIZE, but we "
- "cannot honor that because it contains custom option "
- "extensions defined in the same proto.";
+ Y_ABSL_LOG(WARNING)
+ << "Proto states optimize_for = CODE_SIZE, but we "
+ "cannot honor that because it contains custom option "
+ "extensions defined in the same proto.";
return FileOptions::SPEED;
}
}
return file->options().optimize_for();
}
- GOOGLE_LOG(FATAL) << "Unknown optimization enforcement requested.";
+ Y_ABSL_LOG(FATAL) << "Unknown optimization enforcement requested.";
// The phony return below serves to silence a warning from GCC 8.
return FileOptions::SPEED;
}
-inline bool IsMessageOwnedArenaEligible(const Descriptor* desc,
- const Options& options) {
- return GetOptimizeFor(desc->file(), options) != FileOptions::LITE_RUNTIME &&
- !options.bootstrap && !options.opensource_runtime &&
- AllocExpected(desc);
-}
-
-bool EnableMessageOwnedArena(const Descriptor* desc, const Options& options) {
- (void)desc;
- (void)options;
- return false;
-}
-
-bool EnableMessageOwnedArenaTrial(const Descriptor* desc,
- const Options& options) {
- return false;
-}
-
bool HasMessageFieldOrExtension(const Descriptor* desc) {
if (desc->extension_range_count() > 0) return true;
for (const auto* f : FieldRange(desc)) {
@@ -1597,6 +1678,21 @@ bool HasMessageFieldOrExtension(const Descriptor* desc) {
return false;
}
+std::vector<io::Printer::Sub> AnnotatedAccessors(
+ const FieldDescriptor* field, y_absl::Span<const y_absl::string_view> prefixes,
+ y_absl::optional<google::protobuf::io::AnnotationCollector::Semantic> semantic) {
+ auto field_name = FieldName(field);
+
+ std::vector<io::Printer::Sub> vars;
+ for (auto prefix : prefixes) {
+ vars.push_back(io::Printer::Sub(y_absl::StrCat(prefix, "name"),
+ y_absl::StrCat(prefix, field_name))
+ .AnnotatedAs({field, semantic}));
+ }
+
+ return vars;
+}
+
} // namespace cpp
} // namespace compiler
} // namespace protobuf
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/helpers.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/helpers.h
index 690a577591e..437c178c60c 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/helpers.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/helpers.h
@@ -38,21 +38,27 @@
#include <algorithm>
#include <cstdint>
#include <iterator>
-#include <map>
#include <string>
-
-#include <google/protobuf/compiler/scc.h>
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/compiler/cpp/names.h>
-#include <google/protobuf/compiler/cpp/options.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/port.h>
-#include <google/protobuf/stubs/strutil.h>
+#include <tuple>
+
+#include "google/protobuf/compiler/scc.h"
+#include "google/protobuf/compiler/code_generator.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/strings/match.h"
+#include "y_absl/strings/str_split.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/types/optional.h"
+#include "google/protobuf/compiler/cpp/names.h"
+#include "google/protobuf/compiler/cpp/options.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/port.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/io/printer.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -84,19 +90,22 @@ inline TProtoStringType DeprecatedAttribute(const Options& /* options */,
extern const char kThickSeparator[];
extern const char kThinSeparator[];
-void SetCommonVars(const Options& options,
- std::map<TProtoStringType, TProtoStringType>* variables);
+y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> MessageVars(
+ const Descriptor* desc);
// Variables to access message data from the message scope.
void SetCommonMessageDataVariables(
const Descriptor* descriptor,
- std::map<TProtoStringType, TProtoStringType>* variables);
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables);
+
+y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> UnknownFieldsVars(
+ const Descriptor* desc, const Options& opts);
-void SetUnknownFieldsVariable(const Descriptor* descriptor,
- const Options& options,
- std::map<TProtoStringType, TProtoStringType>* variables);
+void SetUnknownFieldsVariable(
+ const Descriptor* descriptor, const Options& options,
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables);
-bool GetBootstrapBasename(const Options& options, const TProtoStringType& basename,
+bool GetBootstrapBasename(const Options& options, y_absl::string_view basename,
TProtoStringType* bootstrap_basename);
bool MaybeBootstrap(const Options& options, GeneratorContext* generator_context,
bool bootstrap_flag, TProtoStringType* basename);
@@ -110,18 +119,31 @@ TProtoStringType Namespace(const FileDescriptor* d, const Options& options);
TProtoStringType Namespace(const Descriptor* d, const Options& options);
TProtoStringType Namespace(const FieldDescriptor* d, const Options& options);
TProtoStringType Namespace(const EnumDescriptor* d, const Options& options);
+PROTOC_EXPORT TProtoStringType Namespace(const FileDescriptor* d);
+PROTOC_EXPORT TProtoStringType Namespace(const Descriptor* d);
+PROTOC_EXPORT TProtoStringType Namespace(const FieldDescriptor* d);
+PROTOC_EXPORT TProtoStringType Namespace(const EnumDescriptor* d);
+
+class MessageSCCAnalyzer;
+// Returns true if it's safe to init "field" to zero.
+bool CanInitializeByZeroing(const FieldDescriptor* field,
+ const Options& options,
+ MessageSCCAnalyzer* scc_analyzer);
// Returns true if it's safe to reset "field" to zero.
-bool CanInitializeByZeroing(const FieldDescriptor* field);
+bool CanClearByZeroing(const FieldDescriptor* field);
+// Determines if swap can be implemented via memcpy.
+bool HasTrivialSwap(const FieldDescriptor* field, const Options& options,
+ MessageSCCAnalyzer* scc_analyzer);
-TProtoStringType ClassName(const Descriptor* descriptor);
-TProtoStringType ClassName(const EnumDescriptor* enum_descriptor);
+PROTOC_EXPORT TProtoStringType ClassName(const Descriptor* descriptor);
+PROTOC_EXPORT TProtoStringType ClassName(const EnumDescriptor* enum_descriptor);
TProtoStringType QualifiedClassName(const Descriptor* d, const Options& options);
TProtoStringType QualifiedClassName(const EnumDescriptor* d, const Options& options);
-TProtoStringType QualifiedClassName(const Descriptor* d);
-TProtoStringType QualifiedClassName(const EnumDescriptor* d);
+PROTOC_EXPORT TProtoStringType QualifiedClassName(const Descriptor* d);
+PROTOC_EXPORT TProtoStringType QualifiedClassName(const EnumDescriptor* d);
// DEPRECATED just use ClassName or QualifiedClassName, a boolean is very
// unreadable at the callsite.
@@ -187,13 +209,13 @@ TProtoStringType SuperClassName(const Descriptor* descriptor,
const Options& options);
// Adds an underscore if necessary to prevent conflicting with a keyword.
-TProtoStringType ResolveKeyword(const TProtoStringType& name);
+TProtoStringType ResolveKeyword(y_absl::string_view name);
// Get the (unqualified) name that should be used for this field in C++ code.
// The name is coerced to lower-case to emulate proto1 behavior. People
// should be using lowercase-with-underscores style for proto field names
// anyway, so normally this just returns field->name().
-TProtoStringType FieldName(const FieldDescriptor* field);
+PROTOC_EXPORT TProtoStringType FieldName(const FieldDescriptor* field);
// Returns the (unqualified) private member name for this field in C++ code.
TProtoStringType FieldMemberName(const FieldDescriptor* field, bool split);
@@ -220,7 +242,7 @@ inline const Descriptor* FieldScope(const FieldDescriptor* field) {
TProtoStringType FieldMessageTypeName(const FieldDescriptor* field,
const Options& options);
-// Get the C++ type name for a primitive type (e.g. "double", "::google::protobuf::int32", etc.).
+// Get the C++ type name for a primitive type (e.g. "double", "::int32", etc.).
const char* PrimitiveTypeName(FieldDescriptor::CppType type);
TProtoStringType PrimitiveTypeName(const Options& options,
FieldDescriptor::CppType type);
@@ -239,25 +261,25 @@ TProtoStringType DefaultValue(const Options& options, const FieldDescriptor* fie
TProtoStringType DefaultValue(const FieldDescriptor* field);
// Convert a file name into a valid identifier.
-TProtoStringType FilenameIdentifier(const TProtoStringType& filename);
+TProtoStringType FilenameIdentifier(y_absl::string_view filename);
// For each .proto file generates a unique name. To prevent collisions of
// symbols in the global namespace
-TProtoStringType UniqueName(const TProtoStringType& name, const TProtoStringType& filename,
+TProtoStringType UniqueName(y_absl::string_view name, y_absl::string_view filename,
const Options& options);
-inline TProtoStringType UniqueName(const TProtoStringType& name, const FileDescriptor* d,
+inline TProtoStringType UniqueName(y_absl::string_view name, const FileDescriptor* d,
const Options& options) {
return UniqueName(name, d->name(), options);
}
-inline TProtoStringType UniqueName(const TProtoStringType& name, const Descriptor* d,
+inline TProtoStringType UniqueName(y_absl::string_view name, const Descriptor* d,
const Options& options) {
return UniqueName(name, d->file(), options);
}
-inline TProtoStringType UniqueName(const TProtoStringType& name, const EnumDescriptor* d,
+inline TProtoStringType UniqueName(y_absl::string_view name, const EnumDescriptor* d,
const Options& options) {
return UniqueName(name, d->file(), options);
}
-inline TProtoStringType UniqueName(const TProtoStringType& name,
+inline TProtoStringType UniqueName(y_absl::string_view name,
const ServiceDescriptor* d,
const Options& options) {
return UniqueName(name, d->file(), options);
@@ -270,38 +292,36 @@ inline Options InternalRuntimeOptions() {
options.opensource_runtime = false;
return options;
}
-inline TProtoStringType UniqueName(const TProtoStringType& name,
- const TProtoStringType& filename) {
+inline TProtoStringType UniqueName(y_absl::string_view name,
+ y_absl::string_view filename) {
return UniqueName(name, filename, InternalRuntimeOptions());
}
-inline TProtoStringType UniqueName(const TProtoStringType& name,
- const FileDescriptor* d) {
+inline TProtoStringType UniqueName(y_absl::string_view name, const FileDescriptor* d) {
return UniqueName(name, d->name(), InternalRuntimeOptions());
}
-inline TProtoStringType UniqueName(const TProtoStringType& name, const Descriptor* d) {
+inline TProtoStringType UniqueName(y_absl::string_view name, const Descriptor* d) {
return UniqueName(name, d->file(), InternalRuntimeOptions());
}
-inline TProtoStringType UniqueName(const TProtoStringType& name,
- const EnumDescriptor* d) {
+inline TProtoStringType UniqueName(y_absl::string_view name, const EnumDescriptor* d) {
return UniqueName(name, d->file(), InternalRuntimeOptions());
}
-inline TProtoStringType UniqueName(const TProtoStringType& name,
+inline TProtoStringType UniqueName(y_absl::string_view name,
const ServiceDescriptor* d) {
return UniqueName(name, d->file(), InternalRuntimeOptions());
}
// Return the qualified C++ name for a file level symbol.
TProtoStringType QualifiedFileLevelSymbol(const FileDescriptor* file,
- const TProtoStringType& name,
+ y_absl::string_view name,
const Options& options);
// Escape C++ trigraphs by escaping question marks to \?
-TProtoStringType EscapeTrigraphs(const TProtoStringType& to_escape);
+TProtoStringType EscapeTrigraphs(y_absl::string_view to_escape);
// Escaped function name to eliminate naming conflict.
TProtoStringType SafeFunctionName(const Descriptor* descriptor,
const FieldDescriptor* field,
- const TProtoStringType& prefix);
+ y_absl::string_view prefix);
// Returns true if generated messages have public unknown fields accessors
inline bool PublicUnknownFieldsAccessors(const Descriptor* message) {
@@ -321,12 +341,14 @@ inline bool UseUnknownFieldSet(const FileDescriptor* file,
inline bool IsWeak(const FieldDescriptor* field, const Options& options) {
if (field->options().weak()) {
- GOOGLE_CHECK(!options.opensource_runtime);
+ Y_ABSL_CHECK(!options.opensource_runtime);
return true;
}
return false;
}
+bool IsProfileDriven(const Options& options);
+
bool IsStringInlined(const FieldDescriptor* descriptor, const Options& options);
// For a string field, returns the effective ctype. If the actual ctype is
@@ -350,8 +372,6 @@ inline bool IsStringPiece(const FieldDescriptor* field,
EffectiveStringCType(field, options) == FieldOptions::STRING_PIECE;
}
-class MessageSCCAnalyzer;
-
// Does the given FileDescriptor use lazy fields?
bool HasLazyFields(const FileDescriptor* file, const Options& options,
MessageSCCAnalyzer* scc_analyzer);
@@ -377,17 +397,16 @@ bool ShouldSplit(const Descriptor* desc, const Options& options);
// Is the given field being split out?
bool ShouldSplit(const FieldDescriptor* field, const Options& options);
+// Should we generate code that force creating an allocation in the constructor
+// of the given message?
+bool ShouldForceAllocationOnConstruction(const Descriptor* desc,
+ const Options& options);
+
inline bool IsFieldUsed(const FieldDescriptor* /* field */,
const Options& /* options */) {
return true;
}
-// Returns true if "field" is stripped.
-inline bool IsFieldStripped(const FieldDescriptor* /*field*/,
- const Options& /*options*/) {
- return false;
-}
-
// Does the file contain any definitions that need extension_set.h?
bool HasExtensionsOrExtendableMessage(const FileDescriptor* file);
@@ -448,42 +467,20 @@ inline bool IsMapEntryMessage(const Descriptor* descriptor) {
// Returns true if the field's CPPTYPE is string or message.
bool IsStringOrMessage(const FieldDescriptor* field);
-TProtoStringType UnderscoresToCamelCase(const TProtoStringType& input,
+TProtoStringType UnderscoresToCamelCase(y_absl::string_view input,
bool cap_next_letter);
inline bool IsProto3(const FileDescriptor* file) {
return file->syntax() == FileDescriptor::SYNTAX_PROTO3;
}
-inline bool HasHasbit(const FieldDescriptor* field) {
- // This predicate includes proto3 message fields only if they have "optional".
- // Foo submsg1 = 1; // HasHasbit() == false
- // optional Foo submsg2 = 2; // HasHasbit() == true
- // This is slightly odd, as adding "optional" to a singular proto3 field does
- // not change the semantics or API. However whenever any field in a message
- // has a hasbit, it forces reflection to include hasbit offsets for *all*
- // fields, even if almost all of them are set to -1 (no hasbit). So to avoid
- // causing a sudden size regression for ~all proto3 messages, we give proto3
- // message fields a hasbit only if "optional" is present. If the user is
- // explicitly writing "optional", it is likely they are writing it on
- // primitive fields also.
- return (field->has_optional_keyword() || field->is_required()) &&
- !field->options().weak();
-}
-
-// Returns true if 'enum' semantics are such that unknown values are preserved
-// in the enum field itself, rather than going to the UnknownFieldSet.
-inline bool HasPreservingUnknownEnumSemantics(const FieldDescriptor* field) {
- return field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3;
-}
-
inline bool IsCrossFileMessage(const FieldDescriptor* field) {
return field->type() == FieldDescriptor::TYPE_MESSAGE &&
field->message_type()->file() != field->file();
}
inline TProtoStringType MakeDefaultName(const FieldDescriptor* field) {
- return StrCat("_i_give_permission_to_break_this_code_default_",
+ return y_absl::StrCat("_i_give_permission_to_break_this_code_default_",
FieldName(field), "_");
}
@@ -498,11 +495,11 @@ inline TProtoStringType MakeDefaultName(const FieldDescriptor* 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 StrCat("Impl_::", MakeDefaultName(field));
+ return y_absl::StrCat("Impl_::", MakeDefaultName(field));
}
inline TProtoStringType MakeVarintCachedSizeName(const FieldDescriptor* field) {
- return StrCat("_", FieldName(field), "_cached_byte_size_");
+ return y_absl::StrCat("_", FieldName(field), "_cached_byte_size_");
}
// Semantically distinct from MakeVarintCachedSizeName in that it gives the C++
@@ -518,7 +515,7 @@ inline TProtoStringType MakeVarintCachedSizeName(const FieldDescriptor* field) {
// internal_container_._field_cached_byte_size_;
inline TProtoStringType MakeVarintCachedSizeFieldName(const FieldDescriptor* field,
bool split) {
- return StrCat("_impl_.", split ? "_split_->" : "", "_",
+ return y_absl::StrCat("_impl_.", split ? "_split_->" : "", "_",
FieldName(field), "_cached_byte_size_");
}
@@ -531,20 +528,34 @@ bool IsAnyMessage(const Descriptor* descriptor, const Options& options);
bool IsWellKnownMessage(const FileDescriptor* descriptor);
-inline TProtoStringType IncludeGuard(const FileDescriptor* file, bool pb_h,
- bool deps,
+enum class GeneratedFileType : int { kPbH, kProtoH, kProtoStaticReflectionH };
+
+inline TProtoStringType IncludeGuard(const FileDescriptor* file,
+ GeneratedFileType file_type,
const Options& options) {
// If we are generating a .pb.h file and the proto_h option is enabled, then
// the .pb.h gets an extra suffix.
- TProtoStringType filename_identifier = FilenameIdentifier(
- file->name() + (deps ? ".deps": "") + (pb_h && options.proto_h ? ".pb.h" : ""));
+ TProtoStringType extension;
+ switch (file_type) {
+ case GeneratedFileType::kPbH:
+ extension = ".pb.h";
+ break;
+ case GeneratedFileType::kProtoH:
+ extension = ".proto.h";
+ break;
+ case GeneratedFileType::kProtoStaticReflectionH:
+ extension = ".proto.static_reflection.h";
+ }
+ TProtoStringType filename_identifier =
+ FilenameIdentifier(file->name() + extension);
if (IsWellKnownMessage(file)) {
// For well-known messages we need third_party/protobuf and net/proto2 to
// have distinct include guards, because some source files include both and
// both need to be defined (the third_party copies will be in the
// google::protobuf_opensource namespace).
- return MacroPrefix(options) + "_INCLUDED_" + filename_identifier;
+ return y_absl::StrCat(MacroPrefix(options), "_INCLUDED_",
+ filename_identifier);
} else {
// Ideally this case would use distinct include guards for opensource and
// google3 protos also. (The behavior of "first #included wins" is not
@@ -552,7 +563,7 @@ inline TProtoStringType IncludeGuard(const FileDescriptor* file, bool pb_h,
// the identical include guards to avoid compile errors.
//
// We should clean this up so that this case can be removed.
- return "GOOGLE_PROTOBUF_INCLUDED_" + filename_identifier;
+ return y_absl::StrCat("GOOGLE_PROTOBUF_INCLUDED_", filename_identifier);
}
}
@@ -663,7 +674,7 @@ class PROTOC_EXPORT MessageSCCAnalyzer {
};
SCCAnalyzer<DepsGenerator> analyzer_;
Options options_;
- std::map<const SCC*, MessageAnalysis> analysis_cache_;
+ y_absl::flat_hash_map<const SCC*, MessageAnalysis> analysis_cache_;
};
void ListAllFields(const Descriptor* d,
@@ -747,6 +758,8 @@ inline bool HasImplData(const Descriptor* desc, const Options& options) {
return !HasSimpleBaseClass(desc, options);
}
+// DO NOT USE IN NEW CODE! Use io::Printer directly instead. See b/242326974.
+//
// Formatter is a functor class which acts as a closure around printer and
// the variable map. It's much like printer->Print except it supports both named
// variables that are substituted using a key value map and direct arguments. In
@@ -789,15 +802,15 @@ class PROTOC_EXPORT Formatter {
public:
explicit Formatter(io::Printer* printer) : printer_(printer) {}
Formatter(io::Printer* printer,
- const std::map<TProtoStringType, TProtoStringType>& vars)
+ const y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>& vars)
: printer_(printer), vars_(vars) {}
template <typename T>
- void Set(const TProtoStringType& key, const T& value) {
+ void Set(y_absl::string_view key, const T& value) {
vars_[key] = ToString(value);
}
- void AddMap(const std::map<TProtoStringType, TProtoStringType>& vars) {
+ void AddMap(const y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>& vars) {
for (const auto& keyval : vars) vars_[keyval.first] = keyval.second;
}
@@ -839,31 +852,69 @@ class PROTOC_EXPORT Formatter {
private:
Formatter* format_;
- std::map<TProtoStringType, TProtoStringType> vars_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars_;
};
private:
io::Printer* printer_;
- std::map<TProtoStringType, TProtoStringType> vars_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars_;
// Convenience overloads to accept different types as arguments.
- static TProtoStringType ToString(const TProtoStringType& s) { return s; }
+ static TProtoStringType ToString(y_absl::string_view s) { return TProtoStringType(s); }
template <typename I, typename = typename std::enable_if<
std::is_integral<I>::value>::type>
static TProtoStringType ToString(I x) {
- return StrCat(x);
+ return y_absl::StrCat(x);
+ }
+ static TProtoStringType ToString(y_absl::Hex x) { return y_absl::StrCat(x); }
+ static TProtoStringType ToString(const FieldDescriptor* d) {
+ return Payload(d, GeneratedCodeInfo::Annotation::NONE);
+ }
+ static TProtoStringType ToString(const Descriptor* d) {
+ return Payload(d, GeneratedCodeInfo::Annotation::NONE);
+ }
+ static TProtoStringType ToString(const EnumDescriptor* d) {
+ return Payload(d, GeneratedCodeInfo::Annotation::NONE);
}
- static TProtoStringType ToString(strings::Hex x) { return StrCat(x); }
- static TProtoStringType ToString(const FieldDescriptor* d) { return Payload(d); }
- static TProtoStringType ToString(const Descriptor* d) { return Payload(d); }
- static TProtoStringType ToString(const EnumDescriptor* d) { return Payload(d); }
static TProtoStringType ToString(const EnumValueDescriptor* d) {
- return Payload(d);
+ return Payload(d, GeneratedCodeInfo::Annotation::NONE);
+ }
+ static TProtoStringType ToString(const OneofDescriptor* d) {
+ return Payload(d, GeneratedCodeInfo::Annotation::NONE);
+ }
+
+ static TProtoStringType ToString(
+ std::tuple<const FieldDescriptor*,
+ GeneratedCodeInfo::Annotation::Semantic>
+ p) {
+ return Payload(std::get<0>(p), std::get<1>(p));
+ }
+ static TProtoStringType ToString(
+ std::tuple<const Descriptor*, GeneratedCodeInfo::Annotation::Semantic>
+ p) {
+ return Payload(std::get<0>(p), std::get<1>(p));
+ }
+ static TProtoStringType ToString(
+ std::tuple<const EnumDescriptor*, GeneratedCodeInfo::Annotation::Semantic>
+ p) {
+ return Payload(std::get<0>(p), std::get<1>(p));
+ }
+ static TProtoStringType ToString(
+ std::tuple<const EnumValueDescriptor*,
+ GeneratedCodeInfo::Annotation::Semantic>
+ p) {
+ return Payload(std::get<0>(p), std::get<1>(p));
+ }
+ static TProtoStringType ToString(
+ std::tuple<const OneofDescriptor*,
+ GeneratedCodeInfo::Annotation::Semantic>
+ p) {
+ return Payload(std::get<0>(p), std::get<1>(p));
}
- static TProtoStringType ToString(const OneofDescriptor* d) { return Payload(d); }
template <typename Descriptor>
- static TProtoStringType Payload(const Descriptor* descriptor) {
+ static TProtoStringType Payload(const Descriptor* descriptor,
+ GeneratedCodeInfo::Annotation::Semantic semantic) {
std::vector<int> path;
descriptor->GetLocationPath(&path);
GeneratedCodeInfo::Annotation annotation;
@@ -871,119 +922,71 @@ class PROTOC_EXPORT Formatter {
annotation.add_path(index);
}
annotation.set_source_file(descriptor->file()->name());
+ annotation.set_semantic(semantic);
return annotation.SerializeAsString();
}
};
-template <class T>
-void PrintFieldComment(const Formatter& format, const T* field) {
+template <typename T>
+TProtoStringType FieldComment(const T* field) {
// Print the field's (or oneof's) proto-syntax definition as a comment.
// We don't want to print group bodies so we cut off after the first
// line.
DebugStringOptions options;
options.elide_group_body = true;
options.elide_oneof_body = true;
- TProtoStringType def = field->DebugStringWithOptions(options);
- format("// $1$\n", def.substr(0, def.find_first_of('\n')));
+
+ for (y_absl::string_view chunk :
+ y_absl::StrSplit(field->DebugStringWithOptions(options), '\n')) {
+ return TProtoStringType(chunk);
+ }
+
+ return "<unknown>";
+}
+
+template <class T>
+void PrintFieldComment(const Formatter& format, const T* field) {
+ format("// $1$\n", FieldComment(field));
}
class PROTOC_EXPORT NamespaceOpener {
public:
- explicit NamespaceOpener(const Formatter& format)
- : printer_(format.printer()) {}
- NamespaceOpener(const TProtoStringType& name, const Formatter& format)
+ explicit NamespaceOpener(io::Printer* p) : p_(p) {}
+ explicit NamespaceOpener(const Formatter& format) : p_(format.printer()) {}
+ NamespaceOpener(y_absl::string_view name, const Formatter& format)
: NamespaceOpener(format) {
ChangeTo(name);
}
+ NamespaceOpener(y_absl::string_view name, io::Printer* p) : NamespaceOpener(p) {
+ ChangeTo(name);
+ }
~NamespaceOpener() { ChangeTo(""); }
- void ChangeTo(const TProtoStringType& name) {
- std::vector<TProtoStringType> new_stack_ =
- Split(name, "::", true);
- size_t len = std::min(name_stack_.size(), new_stack_.size());
- size_t common_idx = 0;
- while (common_idx < len) {
- if (name_stack_[common_idx] != new_stack_[common_idx]) break;
- common_idx++;
- }
- for (auto it = name_stack_.crbegin();
- it != name_stack_.crend() - common_idx; ++it) {
- if (*it == "PROTOBUF_NAMESPACE_ID") {
- printer_->Print("PROTOBUF_NAMESPACE_CLOSE\n");
- } else {
- printer_->Print("} // namespace $ns$\n", "ns", *it);
- }
- }
- name_stack_.swap(new_stack_);
- for (size_t i = common_idx; i < name_stack_.size(); ++i) {
- if (name_stack_[i] == "PROTOBUF_NAMESPACE_ID") {
- printer_->Print("PROTOBUF_NAMESPACE_OPEN\n");
- } else {
- printer_->Print("namespace $ns$ {\n", "ns", name_stack_[i]);
- }
- }
- }
+ void ChangeTo(y_absl::string_view name);
private:
- io::Printer* printer_;
+ io::Printer* p_;
std::vector<TProtoStringType> name_stack_;
};
-enum class Utf8CheckMode {
- kStrict = 0, // Parsing will fail if non UTF-8 data is in string fields.
- kVerify = 1, // Only log an error but parsing will succeed.
- kNone = 2, // No UTF-8 check.
-};
-
-Utf8CheckMode GetUtf8CheckMode(const FieldDescriptor* field,
- const Options& options);
-
void GenerateUtf8CheckCodeForString(const FieldDescriptor* field,
const Options& options, bool for_parse,
- const char* parameters,
+ y_absl::string_view parameters,
const Formatter& format);
void GenerateUtf8CheckCodeForCord(const FieldDescriptor* field,
const Options& options, bool for_parse,
- const char* parameters,
+ y_absl::string_view parameters,
const Formatter& format);
-template <typename T>
-struct FieldRangeImpl {
- struct Iterator {
- using iterator_category = std::forward_iterator_tag;
- using value_type = const FieldDescriptor*;
- using difference_type = int;
-
- value_type operator*() { return descriptor->field(idx); }
-
- friend bool operator==(const Iterator& a, const Iterator& b) {
- GOOGLE_DCHECK(a.descriptor == b.descriptor);
- return a.idx == b.idx;
- }
- friend bool operator!=(const Iterator& a, const Iterator& b) {
- return !(a == b);
- }
-
- Iterator& operator++() {
- idx++;
- return *this;
- }
-
- int idx;
- const T* descriptor;
- };
-
- Iterator begin() const { return {0, descriptor}; }
- Iterator end() const { return {descriptor->field_count(), descriptor}; }
-
- const T* descriptor;
-};
+void GenerateUtf8CheckCodeForString(io::Printer* p,
+ const FieldDescriptor* field,
+ const Options& options, bool for_parse,
+ y_absl::string_view parameters);
-template <typename T>
-FieldRangeImpl<T> FieldRange(const T* desc) {
- return {desc};
-}
+void GenerateUtf8CheckCodeForCord(io::Printer* p, const FieldDescriptor* field,
+ const Options& options, bool for_parse,
+ y_absl::string_view parameters);
struct OneOfRangeImpl {
struct Iterator {
@@ -994,7 +997,7 @@ struct OneOfRangeImpl {
value_type operator*() { return descriptor->oneof_decl(idx); }
friend bool operator==(const Iterator& a, const Iterator& b) {
- GOOGLE_DCHECK(a.descriptor == b.descriptor);
+ Y_ABSL_DCHECK(a.descriptor == b.descriptor);
return a.idx == b.idx;
}
friend bool operator!=(const Iterator& a, const Iterator& b) {
@@ -1020,12 +1023,8 @@ struct OneOfRangeImpl {
inline OneOfRangeImpl OneOfRange(const Descriptor* desc) { return {desc}; }
-PROTOC_EXPORT TProtoStringType StripProto(const TProtoStringType& filename);
-
-bool EnableMessageOwnedArena(const Descriptor* desc, const Options& options);
-
-bool EnableMessageOwnedArenaTrial(const Descriptor* desc,
- const Options& options);
+// Strips ".proto" or ".protodevel" from the end of a filename.
+PROTOC_EXPORT TProtoStringType StripProto(y_absl::string_view filename);
bool ShouldVerify(const Descriptor* descriptor, const Options& options,
MessageSCCAnalyzer* scc_analyzer);
@@ -1055,11 +1054,21 @@ bool IsUtf8String(const FieldDescriptor* field);
bool HasMessageFieldOrExtension(const Descriptor* desc);
+// Generates a vector of substitutions for use with Printer::WithVars that
+// contains annotated accessor names for a particular field.
+//
+// Each substitution will be named `y_absl::StrCat(prefix, "name")`, and will
+// be annotated with `field`.
+std::vector<io::Printer::Sub> AnnotatedAccessors(
+ const FieldDescriptor* field, y_absl::Span<const y_absl::string_view> prefixes,
+ y_absl::optional<google::protobuf::io::AnnotationCollector::Semantic> semantic =
+ y_absl::nullopt);
+
} // namespace cpp
} // namespace compiler
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/map_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/map_field.h
deleted file mode 100644
index 678a128bd18..00000000000
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/map_field.h
+++ /dev/null
@@ -1,83 +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_COMPILER_CPP_MAP_FIELD_H__
-#define GOOGLE_PROTOBUF_COMPILER_CPP_MAP_FIELD_H__
-
-#include <map>
-#include <string>
-
-#include <google/protobuf/compiler/cpp/helpers.h>
-#include <google/protobuf/compiler/cpp/message_field.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-class MapFieldGenerator : public FieldGenerator {
- public:
- MapFieldGenerator(const FieldDescriptor* descriptor, const Options& options,
- MessageSCCAnalyzer* scc_analyzer);
- ~MapFieldGenerator() override;
-
- // implements FieldGenerator ---------------------------------------
- void GeneratePrivateMembers(io::Printer* printer) const override;
- void GenerateAccessorDeclarations(io::Printer* printer) const override;
- void GenerateInlineAccessorDefinitions(io::Printer* printer) const override;
- 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 GenerateSerializeWithCachedSizesToArray(
- io::Printer* printer) const override;
- void GenerateByteSize(io::Printer* printer) const override;
- void GenerateIsInitialized(io::Printer* printer) const override;
- void GenerateConstexprAggregateInitializer(
- io::Printer* printer) const override;
- void GenerateCopyAggregateInitializer(io::Printer* printer) const override;
- void GenerateAggregateInitializer(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_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapFieldGenerator);
-};
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_CPP_MAP_FIELD_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message.cc
index 77702a68dfc..a80ae0922af 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message.cc
@@ -32,49 +32,60 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/cpp/message.h>
+#include "google/protobuf/compiler/cpp/message.h"
#include <algorithm>
+#include <array>
+#include <cmath>
#include <cstdint>
#include <functional>
-#include <map>
+#include <limits>
#include <memory>
-#include <unordered_map>
+#include <type_traits>
#include <utility>
#include <vector>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/descriptor.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/stringprintf.h>
-#include <google/protobuf/stubs/substitute.h>
-#include <google/protobuf/compiler/cpp/enum.h>
-#include <google/protobuf/compiler/cpp/extension.h>
-#include <google/protobuf/compiler/cpp/field.h>
-#include <google/protobuf/compiler/cpp/helpers.h>
-#include <google/protobuf/compiler/cpp/padding_optimizer.h>
-#include <google/protobuf/compiler/cpp/parse_function_generator.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/stubs/hash.h>
+#include "google/protobuf/stubs/common.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/generated_message_util.h"
+#include "google/protobuf/map_entry_lite.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/escaping.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/str_join.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/strings/substitute.h"
+#include "google/protobuf/compiler/cpp/enum.h"
+#include "google/protobuf/compiler/cpp/extension.h"
+#include "google/protobuf/compiler/cpp/field.h"
+#include "google/protobuf/compiler/cpp/helpers.h"
+#include "google/protobuf/compiler/cpp/names.h"
+#include "google/protobuf/compiler/cpp/padding_optimizer.h"
+#include "google/protobuf/compiler/cpp/parse_function_generator.h"
+#include "google/protobuf/compiler/cpp/tracker.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/printer.h"
+#include "google/protobuf/wire_format.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
namespace compiler {
namespace cpp {
-
-using internal::WireFormat;
-using internal::WireFormatLite;
-
namespace {
+using ::google::protobuf::internal::WireFormat;
+using ::google::protobuf::internal::WireFormatLite;
+using ::google::protobuf::internal::cpp::HasHasbit;
+using ::google::protobuf::internal::cpp::Utf8CheckMode;
+using Sub = ::google::protobuf::io::Printer::Sub;
static constexpr int kNoHasbit = -1;
@@ -84,27 +95,28 @@ static constexpr int kNoHasbit = -1;
// masks must be non-zero.
TProtoStringType ConditionalToCheckBitmasks(
const std::vector<arc_ui32>& masks, bool return_success = true,
- StringPiece has_bits_var = "_impl_._has_bits_") {
+ y_absl::string_view has_bits_var = "_impl_._has_bits_") {
std::vector<TProtoStringType> parts;
for (int i = 0; i < masks.size(); i++) {
if (masks[i] == 0) continue;
- TProtoStringType m = StrCat("0x", strings::Hex(masks[i], strings::ZERO_PAD_8));
+ TProtoStringType m = y_absl::StrCat("0x", y_absl::Hex(masks[i], y_absl::kZeroPad8));
// Each xor evaluates to 0 if the expected bits are present.
parts.push_back(
- StrCat("((", has_bits_var, "[", i, "] & ", m, ") ^ ", m, ")"));
+ y_absl::StrCat("((", has_bits_var, "[", i, "] & ", m, ") ^ ", m, ")"));
}
- GOOGLE_CHECK(!parts.empty());
+ Y_ABSL_CHECK(!parts.empty());
// If we have multiple parts, each expected to be 0, then bitwise-or them.
TProtoStringType result =
parts.size() == 1
? parts[0]
- : StrCat("(", Join(parts, "\n | "), ")");
+ : y_absl::StrCat("(", y_absl::StrJoin(parts, "\n | "), ")");
return result + (return_success ? " == 0" : " != 0");
}
-void PrintPresenceCheck(const Formatter& format, const FieldDescriptor* field,
- const std::vector<int>& has_bit_indices,
- io::Printer* printer, int* cached_has_word_index) {
+void PrintPresenceCheck(const FieldDescriptor* field,
+ const std::vector<int>& has_bit_indices, io::Printer* p,
+ int* cached_has_word_index) {
+ Formatter format(p);
if (!field->options().weak()) {
int has_bit_index = has_bit_indices[field->index()];
if (*cached_has_word_index != (has_bit_index / 32)) {
@@ -112,7 +124,7 @@ void PrintPresenceCheck(const Formatter& format, const FieldDescriptor* field,
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));
+ y_absl::StrCat(y_absl::Hex(1u << (has_bit_index % 32), y_absl::kZeroPad8));
format("if (cached_has_bits & 0x$1$u) {\n", mask);
} else {
format("if (has_$1$()) {\n", FieldName(field));
@@ -166,32 +178,11 @@ bool IsPOD(const FieldDescriptor* field) {
}
}
-// Helper for the code that emits the SharedCtor() and InternalSwap() methods.
-// Anything that is a POD or a "normal" message (represented by a pointer) can
-// be manipulated as raw bytes.
-bool CanBeManipulatedAsRawBytes(const FieldDescriptor* field,
- const Options& options,
- MessageSCCAnalyzer* scc_analyzer) {
- bool ret = CanInitializeByZeroing(field);
-
- // Non-repeated, non-lazy message fields are simply raw pointers, so we can
- // swap them or use memset to initialize these in SharedCtor. We cannot use
- // this in Clear, as we need to potentially delete the existing value.
- ret =
- ret || (!field->is_repeated() && !IsLazy(field, options, scc_analyzer) &&
- field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE);
- return ret;
-}
-
-bool StrContains(const TProtoStringType& haystack, const TProtoStringType& needle) {
- return haystack.find(needle) != TProtoStringType::npos;
-}
-
// Finds runs of fields for which `predicate` is true.
// RunMap maps from fields that start each run to the number of fields in that
// run. This is optimized for the common case that there are very few runs in
// a message and that most of the eligible fields appear together.
-using RunMap = std::unordered_map<const FieldDescriptor*, size_t>;
+using RunMap = y_absl::flat_hash_map<const FieldDescriptor*, size_t>;
RunMap FindRuns(const std::vector<const FieldDescriptor*>& fields,
const std::function<bool(const FieldDescriptor*)>& predicate) {
RunMap runs;
@@ -215,13 +206,14 @@ RunMap FindRuns(const std::vector<const FieldDescriptor*>& fields,
// considered non-default (will be sent over the wire), for message types
// without true field presence. Should only be called if
// !HasHasbit(field).
-bool EmitFieldNonDefaultCondition(io::Printer* printer,
- const TProtoStringType& prefix,
+bool EmitFieldNonDefaultCondition(io::Printer* p, const TProtoStringType& prefix,
const FieldDescriptor* field) {
- GOOGLE_CHECK(!HasHasbit(field));
- Formatter format(printer);
- format.Set("prefix", prefix);
- format.Set("name", FieldName(field));
+ Y_ABSL_CHECK(!HasHasbit(field));
+ Formatter format(p);
+ auto v = p->WithVars({{
+ {"prefix", prefix},
+ {"name", FieldName(field)},
+ }});
// Merge and serialize semantics: primitive fields are merged/serialized only
// if non-zero (numeric) or non-empty (string).
if (!field->is_repeated() && !field->containing_oneof()) {
@@ -232,18 +224,18 @@ bool EmitFieldNonDefaultCondition(io::Printer* printer,
format("if ($prefix$_internal_has_$name$()) {\n");
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_FLOAT) {
format(
- "static_assert(sizeof(arc_ui32) == sizeof(float), \"Code assumes "
- "arc_ui32 and float are the same size.\");\n"
+ "static_assert(sizeof(::arc_ui32) == sizeof(float), \"Code assumes "
+ "::arc_ui32 and float are the same size.\");\n"
"float tmp_$name$ = $prefix$_internal_$name$();\n"
- "arc_ui32 raw_$name$;\n"
+ "::arc_ui32 raw_$name$;\n"
"memcpy(&raw_$name$, &tmp_$name$, sizeof(tmp_$name$));\n"
"if (raw_$name$ != 0) {\n");
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_DOUBLE) {
format(
- "static_assert(sizeof(arc_ui64) == sizeof(double), \"Code assumes "
- "arc_ui64 and double are the same size.\");\n"
+ "static_assert(sizeof(::arc_ui64) == sizeof(double), \"Code assumes "
+ "::arc_ui64 and double are the same size.\");\n"
"double tmp_$name$ = $prefix$_internal_$name$();\n"
- "arc_ui64 raw_$name$;\n"
+ "::arc_ui64 raw_$name$;\n"
"memcpy(&raw_$name$, &tmp_$name$, sizeof(tmp_$name$));\n"
"if (raw_$name$ != 0) {\n");
} else {
@@ -252,7 +244,7 @@ bool EmitFieldNonDefaultCondition(io::Printer* printer,
format.Indent();
return true;
} else if (field->real_containing_oneof()) {
- format("if (_internal_has_$name$()) {\n");
+ format("if ($has_field$) {\n");
format.Indent();
return true;
}
@@ -271,11 +263,17 @@ bool HasHasMethod(const FieldDescriptor* field) {
field->has_optional_keyword() || field->real_containing_oneof();
}
+bool HasInternalHasMethod(const FieldDescriptor* field) {
+ return !HasHasbit(field) &&
+ field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE;
+}
+
// Collects map entry message type information.
-void CollectMapInfo(const Options& options, const Descriptor* descriptor,
- std::map<TProtoStringType, TProtoStringType>* variables) {
- GOOGLE_CHECK(IsMapEntryMessage(descriptor));
- std::map<TProtoStringType, TProtoStringType>& vars = *variables;
+void CollectMapInfo(
+ const Options& options, const Descriptor* descriptor,
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables) {
+ Y_ABSL_CHECK(IsMapEntryMessage(descriptor));
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>& vars = *variables;
const FieldDescriptor* key = descriptor->map_key();
const FieldDescriptor* val = descriptor->map_value();
vars["key_cpp"] = PrimitiveTypeName(options, key->cpp_type());
@@ -289,26 +287,10 @@ void CollectMapInfo(const Options& options, const Descriptor* descriptor,
default:
vars["val_cpp"] = PrimitiveTypeName(options, val->cpp_type());
}
- vars["key_wire_type"] =
- "TYPE_" + ToUpper(DeclaredTypeMethodName(key->type()));
- vars["val_wire_type"] =
- "TYPE_" + ToUpper(DeclaredTypeMethodName(val->type()));
-}
-
-// Does the given field have a private (internal helper only) has_$name$()
-// method?
-bool HasPrivateHasMethod(const FieldDescriptor* field) {
- // Only for oneofs in message types with no field presence. has_$name$(),
- // based on the oneof case, is still useful internally for generated code.
- return IsProto3(field->file()) && field->real_containing_oneof();
-}
-
-// TODO(ckennelly): Cull these exclusions if/when these protos do not have
-// their methods overridden by subclasses.
-
-bool ShouldMarkClassAsFinal(const Descriptor* descriptor,
- const Options& options) {
- return false;
+ vars["key_wire_type"] = y_absl::StrCat(
+ "TYPE_", y_absl::AsciiStrToUpper(DeclaredTypeMethodName(key->type())));
+ vars["val_wire_type"] = y_absl::StrCat(
+ "TYPE_", y_absl::AsciiStrToUpper(DeclaredTypeMethodName(val->type())));
}
@@ -376,16 +358,16 @@ std::vector<std::vector<const FieldDescriptor*>> CollectFields(
// masked to tell if any thing in "fields" is present.
arc_ui32 GenChunkMask(const std::vector<const FieldDescriptor*>& fields,
const std::vector<int>& has_bit_indices) {
- GOOGLE_CHECK(!fields.empty());
+ Y_ABSL_CHECK(!fields.empty());
int first_index_offset = has_bit_indices[fields.front()->index()] / 32;
arc_ui32 chunk_mask = 0;
for (auto field : fields) {
// "index" defines where in the _has_bits_ the field appears.
int index = has_bit_indices[field->index()];
- GOOGLE_CHECK_EQ(first_index_offset, index / 32);
+ Y_ABSL_CHECK_EQ(first_index_offset, index / 32);
chunk_mask |= static_cast<arc_ui32>(1) << (index % 32);
}
- GOOGLE_CHECK_NE(0, chunk_mask);
+ Y_ABSL_CHECK_NE(0, chunk_mask);
return chunk_mask;
}
@@ -411,7 +393,6 @@ class ColdChunkSkipper {
has_bit_indices_(has_bit_indices),
access_info_map_(options.access_info_map),
cold_threshold_(cold_threshold) {
- SetCommonVars(options, &variables_);
SetCommonMessageDataVariables(descriptor, &variables_);
}
@@ -419,8 +400,8 @@ class ColdChunkSkipper {
// prefix to _has_bits_ to allow MergeFrom to use "from._has_bits_".
// Otherwise, it should be "".
void OnStartChunk(int chunk, int cached_has_word_index,
- const TProtoStringType& from, io::Printer* printer);
- bool OnEndChunk(int chunk, io::Printer* printer);
+ const TProtoStringType& from, io::Printer* p);
+ bool OnEndChunk(int chunk, io::Printer* p);
private:
bool IsColdChunk(int chunk);
@@ -433,7 +414,7 @@ class ColdChunkSkipper {
const std::vector<int>& has_bit_indices_;
const AccessInfoMap* access_info_map_;
const double cold_threshold_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables_;
int limit_chunk_ = -1;
};
@@ -448,9 +429,8 @@ bool ColdChunkSkipper::IsColdChunk(int chunk) {
void ColdChunkSkipper::OnStartChunk(int chunk, int cached_has_word_index,
- const TProtoStringType& from,
- io::Printer* printer) {
- Formatter format(printer, variables_);
+ const TProtoStringType& from, io::Printer* p) {
+ Formatter format(p);
if (!access_info_map_) {
return;
} else if (chunk < limit_chunk_) {
@@ -484,7 +464,7 @@ void ColdChunkSkipper::OnStartChunk(int chunk, int cached_has_word_index,
for (auto field : chunks_[chunk]) {
int hasbit_index = has_bit_indices_[field->index()];
// Fields on a chunk must be in the same word.
- GOOGLE_CHECK_EQ(this_word, hasbit_index / 32);
+ Y_ABSL_CHECK_EQ(this_word, hasbit_index / 32);
mask |= 1 << (hasbit_index % 32);
}
}
@@ -492,7 +472,7 @@ void ColdChunkSkipper::OnStartChunk(int chunk, int cached_has_word_index,
if (this_word != first_word) {
format(" ||\n ");
}
- format.Set("mask", strings::Hex(mask, strings::ZERO_PAD_8));
+ auto v = p->WithVars({{"mask", y_absl::Hex(mask, y_absl::kZeroPad8)}});
if (this_word == cached_has_word_index) {
format("(cached_has_bits & 0x$mask$u) != 0");
} else {
@@ -503,8 +483,8 @@ void ColdChunkSkipper::OnStartChunk(int chunk, int cached_has_word_index,
format.Indent();
}
-bool ColdChunkSkipper::OnEndChunk(int chunk, io::Printer* printer) {
- Formatter format(printer, variables_);
+bool ColdChunkSkipper::OnEndChunk(int chunk, io::Printer* p) {
+ Formatter format(p);
if (chunk != limit_chunk_ - 1) {
return false;
}
@@ -513,86 +493,37 @@ bool ColdChunkSkipper::OnEndChunk(int chunk, io::Printer* printer) {
return true;
}
-void MaySetAnnotationVariable(const Options& options,
- StringPiece annotation_name,
- StringPiece injector_template_prefix,
- StringPiece injector_template_suffix,
- std::map<TProtoStringType, TProtoStringType>* variables) {
- if (options.field_listener_options.forbidden_field_listener_events.count(
- TProtoStringType(annotation_name)))
- return;
- (*variables)[StrCat("annotate_", annotation_name)] = strings::Substitute(
- StrCat(injector_template_prefix, injector_template_suffix),
- (*variables)["classtype"]);
+y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> ClassVars(
+ const Descriptor* desc, Options opts) {
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars = MessageVars(desc);
+
+ vars.emplace("pkg", Namespace(desc, opts));
+ vars.emplace("Msg", ClassName(desc, false));
+ vars.emplace("pkg::Msg", QualifiedClassName(desc, opts));
+ vars.emplace("pkg.Msg", desc->full_name());
+
+ // Old-style names, to be removed once all usages are gone in this and other
+ // files.
+ vars.emplace("classname", ClassName(desc, false));
+ vars.emplace("classtype", QualifiedClassName(desc, opts));
+ vars.emplace("full_name", desc->full_name());
+ vars.emplace("superclass", SuperClassName(desc, opts));
+
+ for (auto& pair : UnknownFieldsVars(desc, opts)) {
+ vars.emplace(pair);
+ }
+
+ return vars;
}
-void GenerateExtensionAnnotations(
- const Descriptor* descriptor, const Options& options,
- std::map<TProtoStringType, TProtoStringType>* variables) {
- const std::map<TProtoStringType, TProtoStringType> accessor_annotations_to_hooks = {
- {"annotate_extension_has", "OnHasExtension"},
- {"annotate_extension_clear", "OnClearExtension"},
- {"annotate_extension_repeated_size", "OnExtensionSize"},
- {"annotate_extension_get", "OnGetExtension"},
- {"annotate_extension_mutable", "OnMutableExtension"},
- {"annotate_extension_set", "OnSetExtension"},
- {"annotate_extension_release", "OnReleaseExtension"},
- {"annotate_repeated_extension_get", "OnGetExtension"},
- {"annotate_repeated_extension_mutable", "OnMutableExtension"},
- {"annotate_repeated_extension_set", "OnSetExtension"},
- {"annotate_repeated_extension_add", "OnAddExtension"},
- {"annotate_repeated_extension_add_mutable", "OnAddMutableExtension"},
- {"annotate_repeated_extension_list", "OnListExtension"},
- {"annotate_repeated_extension_list_mutable", "OnMutableListExtension"},
+y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> HasbitVars(
+ int has_bit_index) {
+ return {
+ {"has_array_index", y_absl::StrCat(has_bit_index / 32)},
+ {"has_mask",
+ y_absl::StrCat(
+ "0x", y_absl::Hex(1u << (has_bit_index % 32), y_absl::kZeroPad8), "u")},
};
- for (const auto& annotation : accessor_annotations_to_hooks) {
- (*variables)[annotation.first] = "";
- }
- if (!HasTracker(descriptor, options)) {
- 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;
- if (!StrContains(annotation_name, "repeated") &&
- !StrContains(annotation_name, "size") &&
- !StrContains(annotation_name, "clear")) {
- // 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()));");
- } 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 = StrCat(extensions, ".ExtensionSize(id.number()) - 1");
- }
- (*variables)[annotation_name] =
- StrCat(" ", tracker, ".", listener_call,
- "(this, id.number(), "
- "_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, "));");
- } else {
- // Generic accessors such as "clear".
- // TODO(b/190614678): Generalize clear from both repeated and non repeated
- // calls, currently their underlying memory interfaces are very different.
- // Or think of removing clear callback as no usages are needed and no
- // memory exist after calling clear().
- }
- }
}
} // anonymous namespace
@@ -601,68 +532,28 @@ void GenerateExtensionAnnotations(
MessageGenerator::MessageGenerator(
const Descriptor* descriptor,
- const std::map<TProtoStringType, TProtoStringType>& vars, int index_in_file_messages,
- const Options& options, MessageSCCAnalyzer* scc_analyzer)
+ const y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>&,
+ int index_in_file_messages, const Options& options,
+ MessageSCCAnalyzer* scc_analyzer)
: descriptor_(descriptor),
index_in_file_messages_(index_in_file_messages),
- classname_(ClassName(descriptor, false)),
options_(options),
- field_generators_(descriptor, options, scc_analyzer),
- max_has_bit_index_(0),
- max_inlined_string_index_(0),
- num_weak_fields_(0),
- scc_analyzer_(scc_analyzer),
- variables_(vars) {
- if (!message_layout_helper_) {
- message_layout_helper_.reset(new PaddingOptimizer());
- }
- SetCommonMessageDataVariables(descriptor, &variables_);
+ field_generators_(descriptor),
+ scc_analyzer_(scc_analyzer) {
- // Variables that apply to this class
- variables_["classname"] = classname_;
- variables_["classtype"] = QualifiedClassName(descriptor_, options);
- variables_["full_name"] = descriptor_->full_name();
- variables_["superclass"] = SuperClassName(descriptor_, options_);
- variables_["annotate_serialize"] = "";
- variables_["annotate_deserialize"] = "";
- variables_["annotate_reflection"] = "";
- variables_["annotate_bytesize"] = "";
- variables_["annotate_mergefrom"] = "";
-
- if (HasTracker(descriptor_, options_)) {
- const TProtoStringType injector_template =
- StrCat(" ", variables_["tracker"], ".");
-
- MaySetAnnotationVariable(options, "serialize", injector_template,
- "OnSerialize(this);\n", &variables_);
- MaySetAnnotationVariable(options, "deserialize", injector_template,
- "OnDeserialize(this);\n", &variables_);
- // TODO(danilak): Ideally annotate_reflection should not exist and we need
- // to annotate all reflective calls on our own, however, as this is a cause
- // for side effects, i.e. reading values dynamically, we want the users know
- // that dynamic access can happen.
- MaySetAnnotationVariable(options, "reflection", injector_template,
- "OnGetMetadata();\n", &variables_);
- MaySetAnnotationVariable(options, "bytesize", injector_template,
- "OnByteSize(this);\n", &variables_);
- MaySetAnnotationVariable(options, "mergefrom", injector_template,
- "OnMergeFrom(_this, &from);\n", &variables_);
+ if (!message_layout_helper_) {
+ message_layout_helper_ = std::make_unique<PaddingOptimizer>();
}
- GenerateExtensionAnnotations(descriptor_, options_, &variables_);
-
- SetUnknownFieldsVariable(descriptor_, options_, &variables_);
-
// Compute optimized field order to be used for layout and initialization
// purposes.
for (auto field : FieldRange(descriptor_)) {
- if (IsFieldStripped(field, options_)) {
+ if (IsWeak(field, options_)) {
+ ++num_weak_fields_;
continue;
}
- if (IsWeak(field, options_)) {
- num_weak_fields_++;
- } else if (!field->real_containing_oneof()) {
+ if (!field->real_containing_oneof()) {
optimized_order_.push_back(field);
}
}
@@ -683,34 +574,26 @@ MessageGenerator::MessageGenerator(
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_++;
+ ++max_inlined_string_index_;
}
+
inlined_string_indices_[field->index()] = max_inlined_string_index_++;
}
}
+ field_generators_.Build(options_, scc_analyzer_, has_bit_indices_,
+ inlined_string_indices_);
- if (!has_bit_indices_.empty()) {
- field_generators_.SetHasBitIndices(has_bit_indices_);
- }
-
- if (!inlined_string_indices_.empty()) {
- field_generators_.SetInlinedStringIndices(inlined_string_indices_);
- }
-
- num_required_fields_ = 0;
for (int i = 0; i < descriptor->field_count(); i++) {
if (descriptor->field(i)->is_required()) {
++num_required_fields_;
}
}
- parse_function_generator_.reset(new ParseFunctionGenerator(
+ parse_function_generator_ = std::make_unique<ParseFunctionGenerator>(
descriptor_, max_has_bit_index_, has_bit_indices_,
- inlined_string_indices_, options_, scc_analyzer_, variables_));
+ inlined_string_indices_, options_, scc_analyzer_, variables_);
}
-MessageGenerator::~MessageGenerator() = default;
-
size_t MessageGenerator::HasBitsSize() const {
return (max_has_bit_index_ + 31) / 32;
}
@@ -739,94 +622,131 @@ void MessageGenerator::AddGenerators(
std::vector<std::unique_ptr<ExtensionGenerator>>* extension_generators) {
for (int i = 0; i < descriptor_->enum_type_count(); i++) {
enum_generators->emplace_back(
- new EnumGenerator(descriptor_->enum_type(i), variables_, options_));
+ std::make_unique<EnumGenerator>(descriptor_->enum_type(i), options_));
enum_generators_.push_back(enum_generators->back().get());
}
for (int i = 0; i < descriptor_->extension_count(); i++) {
- extension_generators->emplace_back(new ExtensionGenerator(
+ extension_generators->emplace_back(std::make_unique<ExtensionGenerator>(
descriptor_->extension(i), options_, scc_analyzer_));
extension_generators_.push_back(extension_generators->back().get());
}
}
-void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* printer) {
- Formatter format(printer, variables_);
+void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* p) {
+ auto v = p->WithVars(MessageVars(descriptor_));
+ Formatter format(p);
+
// optimized_fields_ does not contain fields where
// field->real_containing_oneof()
// so we need to iterate over those as well.
//
// We place the non-oneof fields in optimized_order_, as that controls the
- // order of the _has_bits_ entries and we want GDB's pretty printers to be
+ // order of the _has_bits_ entries and we want GDB's pretty ps to be
// able to infer these indices from the k[FIELDNAME]FieldNumber order.
std::vector<const FieldDescriptor*> ordered_fields;
ordered_fields.reserve(descriptor_->field_count());
-
ordered_fields.insert(ordered_fields.begin(), optimized_order_.begin(),
optimized_order_.end());
+
for (auto field : FieldRange(descriptor_)) {
- if (!field->real_containing_oneof() && !field->options().weak() &&
- !IsFieldStripped(field, options_)) {
+ if (!field->real_containing_oneof() && !field->options().weak()) {
continue;
}
ordered_fields.push_back(field);
}
if (!ordered_fields.empty()) {
- format("enum : int {\n");
- for (auto field : ordered_fields) {
- Formatter::SaveState save(&format);
-
- std::map<TProtoStringType, TProtoStringType> vars;
- SetCommonFieldVariables(field, &vars, options_);
- format.AddMap(vars);
- format(" ${1$$2$$}$ = $number$,\n", field, FieldConstantName(field));
- }
- format("};\n");
+ p->Emit({{
+ "kFields",
+ [&] {
+ for (auto field : ordered_fields) {
+ auto v = p->WithVars(FieldVars(field, options_));
+ p->Emit({Sub("kField", FieldConstantName(field))
+ .AnnotatedAs(field)},
+ R"cc(
+ $kField$ = $number$,
+ )cc");
+ }
+ },
+ }},
+ R"cc(
+ enum : int {
+ $kFields$,
+ };
+ )cc");
}
for (auto field : ordered_fields) {
- PrintFieldComment(format, field);
-
- Formatter::SaveState save(&format);
-
- std::map<TProtoStringType, TProtoStringType> vars;
- SetCommonFieldVariables(field, &vars, options_);
- format.AddMap(vars);
-
- if (field->is_repeated()) {
- format("$deprecated_attr$int ${1$$name$_size$}$() const$2$\n", field,
- !IsFieldStripped(field, options_) ? ";" : " {__builtin_trap();}");
- if (!IsFieldStripped(field, options_)) {
- format(
- "private:\n"
- "int ${1$_internal_$name$_size$}$() const;\n"
- "public:\n",
- field);
- }
- } else if (HasHasMethod(field)) {
- format("$deprecated_attr$bool ${1$has_$name$$}$() const$2$\n", field,
- !IsFieldStripped(field, options_) ? ";" : " {__builtin_trap();}");
- if (!IsFieldStripped(field, options_)) {
- format(
- "private:\n"
- "bool _internal_has_$name$() const;\n"
- "public:\n");
- }
- } else if (HasPrivateHasMethod(field)) {
- if (!IsFieldStripped(field, options_)) {
- format(
- "private:\n"
- "bool ${1$_internal_has_$name$$}$() const;\n"
- "public:\n",
- field);
- }
- }
- format("$deprecated_attr$void ${1$clear_$name$$}$()$2$\n", field,
- !IsFieldStripped(field, options_) ? ";" : "{__builtin_trap();}");
-
- // Generate type-specific accessor declarations.
- field_generators_.get(field).GenerateAccessorDeclarations(printer);
-
- format("\n");
+ auto name = FieldName(field);
+
+ auto v = p->WithVars(FieldVars(field, options_));
+ auto t = p->WithVars(MakeTrackerCalls(field, options_));
+ p->Emit(
+ {{"field_comment", FieldComment(field)},
+ Sub("const_impl", "const;").WithSuffix(";"),
+ Sub("impl", ";").WithSuffix(";"),
+ {"sizer",
+ [&] {
+ if (!field->is_repeated()) return;
+ p->Emit({Sub("name_size", y_absl::StrCat(name, "_size"))
+ .AnnotatedAs(field)},
+ R"cc(
+ $deprecated_attr $int $name_size$() $const_impl$;
+ )cc");
+
+ p->Emit({Sub("_internal_name_size",
+ y_absl::StrCat("_internal_", name, "_size"))
+ .AnnotatedAs(field)},
+ R"cc(
+ private:
+ int $_internal_name_size$() const;
+
+ public:
+ )cc");
+ }},
+ {"hazzer",
+ [&] {
+ if (!field->has_presence()) return;
+ p->Emit({Sub("has_name", y_absl::StrCat("has_", name))
+ .AnnotatedAs(field)},
+ R"cc(
+ $deprecated_attr $bool $has_name$() $const_impl$;
+ )cc");
+ }},
+ {"internal_hazzer",
+ [&] {
+ if (field->is_repeated() || !HasInternalHasMethod(field)) {
+ return;
+ }
+ p->Emit(
+ {Sub("_internal_has_name", y_absl::StrCat("_internal_has_", name))
+ .AnnotatedAs(field)},
+ R"cc(
+ private:
+ bool $_internal_has_name$() const;
+
+ public:
+ )cc");
+ }},
+ {"clearer",
+ [&] {
+ p->Emit({Sub("clear_name", y_absl::StrCat("clear_", name))
+ .AnnotatedAs(field)},
+ R"cc(
+ $deprecated_attr $void $clear_name$() $impl$;
+ )cc");
+ }},
+ {"accessors",
+ [&] {
+ field_generators_.get(field).GenerateAccessorDeclarations(p);
+ }}},
+ R"cc(
+ // $field_comment$
+ $sizer$;
+ $hazzer$;
+ $internal_hazzer$;
+ $clearer$;
+ $accessors$;
+ )cc");
}
if (descriptor_->extension_range_count() > 0) {
@@ -839,211 +759,195 @@ void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* printer) {
// For similar reason, we use "_field_type" and "_is_packed" as parameter
// names below, so that "field_type" and "is_packed" can be used as field
// names.
- format(R"(
-template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
- bool _is_packed>
-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());
-}
+ p->Emit(R"cc(
+ template <typename _proto_TypeTraits, $pbi$::FieldType _field_type,
+ bool _is_packed>
+ inline bool HasExtension(
+ const $pbi$::ExtensionIdentifier<$Msg$, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
+ $annotate_extension_has$;
+ return $extensions$.Has(id.number());
+ }
-template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
- bool _is_packed>
-inline void ClearExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- $classname$, _proto_TypeTraits, _field_type, _is_packed>& id) {
- $extensions$.ClearExtension(id.number());
-$annotate_extension_clear$
-}
+ template <typename _proto_TypeTraits, $pbi$::FieldType _field_type,
+ bool _is_packed>
+ inline void ClearExtension(
+ const $pbi$::ExtensionIdentifier<$Msg$, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ $extensions$.ClearExtension(id.number());
+ $annotate_extension_clear$;
+ }
-template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
- bool _is_packed>
-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());
-}
+ template <typename _proto_TypeTraits, $pbi$::FieldType _field_type,
+ bool _is_packed>
+ inline int ExtensionSize(
+ const $pbi$::ExtensionIdentifier<$Msg$, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
+ $annotate_extension_repeated_size$;
+ return $extensions$.ExtensionSize(id.number());
+ }
-template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
- bool _is_packed>
-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$,
- id.default_value());
-}
+ template <typename _proto_TypeTraits, $pbi$::FieldType _field_type,
+ bool _is_packed>
+ inline typename _proto_TypeTraits::Singular::ConstType GetExtension(
+ const $pbi$::ExtensionIdentifier<$Msg$, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
+ $annotate_extension_get$;
+ return _proto_TypeTraits::Get(id.number(), $extensions$, id.default_value());
+ }
-template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
- bool _is_packed>
-inline typename _proto_TypeTraits::Singular::MutableType MutableExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- $classname$, _proto_TypeTraits, _field_type, _is_packed>& id) {
-$annotate_extension_mutable$
- return _proto_TypeTraits::Mutable(id.number(), _field_type,
- &$extensions$);
-}
+ template <typename _proto_TypeTraits, $pbi$::FieldType _field_type,
+ bool _is_packed>
+ inline typename _proto_TypeTraits::Singular::MutableType MutableExtension(
+ const $pbi$::ExtensionIdentifier<$Msg$, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ $annotate_extension_mutable$;
+ return _proto_TypeTraits::Mutable(id.number(), _field_type, &$extensions$);
+ }
-template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
- bool _is_packed>
-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$);
-$annotate_extension_set$
-}
+ template <typename _proto_TypeTraits, $pbi$::FieldType _field_type,
+ bool _is_packed>
+ inline void SetExtension(
+ const $pbi$::ExtensionIdentifier<$Msg$, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
+ typename _proto_TypeTraits::Singular::ConstType value) {
+ _proto_TypeTraits::Set(id.number(), _field_type, value, &$extensions$);
+ $annotate_extension_set$;
+ }
-template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
- bool _is_packed>
-inline void SetAllocatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- $classname$, _proto_TypeTraits, _field_type, _is_packed>& id,
- typename _proto_TypeTraits::Singular::MutableType value) {
- _proto_TypeTraits::SetAllocated(id.number(), _field_type, value,
- &$extensions$);
-$annotate_extension_set$
-}
-template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
- bool _is_packed>
-inline void UnsafeArenaSetAllocatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- $classname$, _proto_TypeTraits, _field_type, _is_packed>& id,
- typename _proto_TypeTraits::Singular::MutableType value) {
- _proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type,
- value, &$extensions$);
-$annotate_extension_set$
-}
-template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
- bool _is_packed>
-PROTOBUF_NODISCARD inline
- typename _proto_TypeTraits::Singular::MutableType
- ReleaseExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- $classname$, _proto_TypeTraits, _field_type, _is_packed>& id) {
-$annotate_extension_release$
- return _proto_TypeTraits::Release(id.number(), _field_type,
- &$extensions$);
-}
-template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
- bool _is_packed>
-inline typename _proto_TypeTraits::Singular::MutableType
-UnsafeArenaReleaseExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- $classname$, _proto_TypeTraits, _field_type, _is_packed>& id) {
-$annotate_extension_release$
- return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type,
- &$extensions$);
-}
+ template <typename _proto_TypeTraits, $pbi$::FieldType _field_type,
+ bool _is_packed>
+ inline void SetAllocatedExtension(
+ const $pbi$::ExtensionIdentifier<$Msg$, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
+ typename _proto_TypeTraits::Singular::MutableType value) {
+ _proto_TypeTraits::SetAllocated(id.number(), _field_type, value,
+ &$extensions$);
+ $annotate_extension_set$;
+ }
+ template <typename _proto_TypeTraits, $pbi$::FieldType _field_type,
+ bool _is_packed>
+ inline void UnsafeArenaSetAllocatedExtension(
+ const $pbi$::ExtensionIdentifier<$Msg$, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
+ typename _proto_TypeTraits::Singular::MutableType value) {
+ _proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type,
+ value, &$extensions$);
+ $annotate_extension_set$;
+ }
+ template <typename _proto_TypeTraits, $pbi$::FieldType _field_type,
+ bool _is_packed>
+ PROTOBUF_NODISCARD inline
+ typename _proto_TypeTraits::Singular::MutableType
+ ReleaseExtension(
+ const $pbi$::ExtensionIdentifier<$Msg$, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ $annotate_extension_release$;
+ return _proto_TypeTraits::Release(id.number(), _field_type, &$extensions$);
+ }
+ template <typename _proto_TypeTraits, $pbi$::FieldType _field_type,
+ bool _is_packed>
+ inline typename _proto_TypeTraits::Singular::MutableType
+ UnsafeArenaReleaseExtension(
+ const $pbi$::ExtensionIdentifier<$Msg$, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ $annotate_extension_release$;
+ return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type,
+ &$extensions$);
+ }
-template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
- bool _is_packed>
-inline typename _proto_TypeTraits::Repeated::ConstType GetExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- $classname$, _proto_TypeTraits, _field_type, _is_packed>& id,
- int index) const {
-$annotate_repeated_extension_get$
- return _proto_TypeTraits::Get(id.number(), $extensions$, index);
-}
+ template <typename _proto_TypeTraits, $pbi$::FieldType _field_type,
+ bool _is_packed>
+ inline typename _proto_TypeTraits::Repeated::ConstType GetExtension(
+ const $pbi$::ExtensionIdentifier<$Msg$, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
+ int index) const {
+ $annotate_repeated_extension_get$;
+ return _proto_TypeTraits::Get(id.number(), $extensions$, index);
+ }
-template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
- bool _is_packed>
-inline typename _proto_TypeTraits::Repeated::MutableType MutableExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- $classname$, _proto_TypeTraits, _field_type, _is_packed>& id,
- int index) {
-$annotate_repeated_extension_mutable$
- return _proto_TypeTraits::Mutable(id.number(), index, &$extensions$);
-}
+ template <typename _proto_TypeTraits, $pbi$::FieldType _field_type,
+ bool _is_packed>
+ inline typename _proto_TypeTraits::Repeated::MutableType MutableExtension(
+ const $pbi$::ExtensionIdentifier<$Msg$, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
+ int index) {
+ $annotate_repeated_extension_mutable$;
+ return _proto_TypeTraits::Mutable(id.number(), index, &$extensions$);
+ }
-template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
- bool _is_packed>
-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$);
-$annotate_repeated_extension_set$
-}
+ template <typename _proto_TypeTraits, $pbi$::FieldType _field_type,
+ bool _is_packed>
+ inline void SetExtension(
+ const $pbi$::ExtensionIdentifier<$Msg$, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
+ int index, typename _proto_TypeTraits::Repeated::ConstType value) {
+ _proto_TypeTraits::Set(id.number(), index, value, &$extensions$);
+ $annotate_repeated_extension_set$;
+ }
-template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
- bool _is_packed>
-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$);
-$annotate_repeated_extension_add_mutable$
- return to_add;
-}
+ template <typename _proto_TypeTraits, $pbi$::FieldType _field_type,
+ bool _is_packed>
+ inline typename _proto_TypeTraits::Repeated::MutableType AddExtension(
+ const $pbi$::ExtensionIdentifier<$Msg$, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ typename _proto_TypeTraits::Repeated::MutableType to_add =
+ _proto_TypeTraits::Add(id.number(), _field_type, &$extensions$);
+ $annotate_repeated_extension_add_mutable$;
+ return to_add;
+ }
-template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
- bool _is_packed>
-inline void AddExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- $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$);
-$annotate_repeated_extension_add$
-}
+ template <typename _proto_TypeTraits, $pbi$::FieldType _field_type,
+ bool _is_packed>
+ inline void AddExtension(
+ const $pbi$::ExtensionIdentifier<$Msg$, _proto_TypeTraits,
+ _field_type, _is_packed>& id,
+ typename _proto_TypeTraits::Repeated::ConstType value) {
+ _proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value,
+ &$extensions$);
+ $annotate_repeated_extension_add$;
+ }
-template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
- bool _is_packed>
-inline const typename _proto_TypeTraits::Repeated::RepeatedFieldType&
-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$);
-}
+ template <typename _proto_TypeTraits, $pbi$::FieldType _field_type,
+ bool _is_packed>
+ inline const typename _proto_TypeTraits::Repeated::RepeatedFieldType&
+ GetRepeatedExtension(
+ const $pbi$::ExtensionIdentifier<$Msg$, _proto_TypeTraits,
+ _field_type, _is_packed>& id) const {
+ $annotate_repeated_extension_list$;
+ return _proto_TypeTraits::GetRepeated(id.number(), $extensions$);
+ }
-template <typename _proto_TypeTraits,
- ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
- bool _is_packed>
-inline typename _proto_TypeTraits::Repeated::RepeatedFieldType*
-MutableRepeatedExtension(
- const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
- $classname$, _proto_TypeTraits, _field_type, _is_packed>& id) {
-$annotate_repeated_extension_list_mutable$
- return _proto_TypeTraits::MutableRepeated(id.number(), _field_type,
- _is_packed, &$extensions$);
-}
+ template <typename _proto_TypeTraits, $pbi$::FieldType _field_type,
+ bool _is_packed>
+ inline typename _proto_TypeTraits::Repeated::RepeatedFieldType*
+ MutableRepeatedExtension(
+ const $pbi$::ExtensionIdentifier<$Msg$, _proto_TypeTraits,
+ _field_type, _is_packed>& id) {
+ $annotate_repeated_extension_list_mutable$;
+ return _proto_TypeTraits::MutableRepeated(id.number(), _field_type,
+ _is_packed, &$extensions$);
+ }
+ )cc");
-)");
// Generate MessageSet specific APIs for proto2 MessageSet.
// For testing purposes we don't check for bridge.MessageSet, so
// we don't use IsProto2MessageSet
if (descriptor_->options().message_set_wire_format() &&
!options_.opensource_runtime && !options_.lite_implicit_weak_fields) {
- // Special-case MessageSet
- format("GOOGLE_PROTOBUF_EXTENSION_MESSAGE_SET_ACCESSORS($classname$)\n");
+ // Special-case MessageSet.
+ p->Emit(R"cc(
+ GOOGLE_PROTOBUF_EXTENSION_MESSAGE_SET_ACCESSORS($Msg$);
+ )cc");
}
}
for (auto oneof : OneOfRange(descriptor_)) {
Formatter::SaveState saver(&format);
- format.Set("oneof_name", oneof->name());
- format.Set("camel_oneof_name", UnderscoresToCamelCase(oneof->name(), true));
+ auto v = p->WithVars({
+ {"oneof_name", oneof->name()},
+ {"camel_oneof_name", UnderscoresToCamelCase(oneof->name(), true)},
+ });
format(
"void ${1$clear_$oneof_name$$}$();\n"
"$camel_oneof_name$Case $oneof_name$_case() const;\n",
@@ -1052,13 +956,9 @@ $annotate_repeated_extension_list_mutable$
}
void MessageGenerator::GenerateSingularFieldHasBits(
- const FieldDescriptor* field, Formatter format) {
- if (IsFieldStripped(field, options_)) {
- format(
- "inline bool $classname$::has_$name$() const { "
- "__builtin_trap(); }\n");
- return;
- }
+ const FieldDescriptor* field, io::Printer* p) {
+ auto t = p->WithVars(MakeTrackerCalls(field, options_));
+ Formatter format(p);
if (field->options().weak()) {
format(
"inline bool $classname$::has_$name$() const {\n"
@@ -1069,15 +969,13 @@ void MessageGenerator::GenerateSingularFieldHasBits(
}
if (HasHasbit(field)) {
int has_bit_index = HasBitIndex(field);
- GOOGLE_CHECK_NE(has_bit_index, kNoHasbit);
+ Y_ABSL_CHECK_NE(has_bit_index, kNoHasbit);
- format.Set("has_array_index", has_bit_index / 32);
- format.Set("has_mask",
- strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8));
+ auto v = p->WithVars(HasbitVars(has_bit_index));
format(
- "inline bool $classname$::_internal_has_$name$() const {\n"
- " bool value = "
- "($has_bits$[$has_array_index$] & 0x$has_mask$u) != 0;\n");
+ "inline bool $classname$::has_$name$() const {\n"
+ "$annotate_has$"
+ " bool value = ($has_bits$[$has_array_index$] & $has_mask$) != 0;\n");
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
!IsLazy(field, options_, scc_analyzer_)) {
@@ -1089,10 +987,6 @@ void MessageGenerator::GenerateSingularFieldHasBits(
format(
" return value;\n"
- "}\n"
- "inline bool $classname$::has_$name$() const {\n"
- "$annotate_has$"
- " return _internal_has_$name$();\n"
"}\n");
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
// Message fields have a has_$name$() method.
@@ -1116,12 +1010,14 @@ void MessageGenerator::GenerateSingularFieldHasBits(
}
}
-void MessageGenerator::GenerateOneofHasBits(io::Printer* printer) {
- Formatter format(printer, variables_);
- for (auto oneof : OneOfRange(descriptor_)) {
- format.Set("oneof_name", oneof->name());
- format.Set("oneof_index", oneof->index());
- format.Set("cap_oneof_name", ToUpper(oneof->name()));
+void MessageGenerator::GenerateOneofHasBits(io::Printer* p) {
+ Formatter format(p);
+ for (const auto* oneof : OneOfRange(descriptor_)) {
+ auto v = p->WithVars({
+ {"oneof_index", oneof->index()},
+ {"oneof_name", oneof->name()},
+ {"cap_oneof_name", y_absl::AsciiStrToUpper(oneof->name())},
+ });
format(
"inline bool $classname$::has_$oneof_name$() const {\n"
" return $oneof_name$_case() != $cap_oneof_name$_NOT_SET;\n"
@@ -1133,40 +1029,24 @@ void MessageGenerator::GenerateOneofHasBits(io::Printer* printer) {
}
void MessageGenerator::GenerateOneofMemberHasBits(const FieldDescriptor* field,
- const Formatter& format) {
- if (IsFieldStripped(field, options_)) {
- if (HasHasMethod(field)) {
- format(
- "inline bool $classname$::has_$name$() const { "
- "__builtin_trap(); }\n");
- }
- format(
- "inline void $classname$::set_has_$name$() { __builtin_trap(); "
- "}\n");
- return;
- }
+ io::Printer* p) {
+ auto t = p->WithVars(MakeTrackerCalls(field, options_));
+ Formatter format(p);
// Singular field in a oneof
// N.B.: Without field presence, we do not use has-bits or generate
// has_$name$() methods, but oneofs still have set_has_$name$().
- // Oneofs also have has_$name$() but only as a private helper
- // method, so that generated code is slightly cleaner (vs. comparing
- // _oneof_case_[index] against a constant everywhere).
- //
- // If has_$name$() is private, there is no need to add an internal accessor.
- // Only annotate public accessors.
+ // Oneofs also have private _internal_has_$name$() a helper method.
if (HasHasMethod(field)) {
format(
- "inline bool $classname$::_internal_has_$name$() const {\n"
- " return $oneof_name$_case() == k$field_name$;\n"
- "}\n"
"inline bool $classname$::has_$name$() const {\n"
"$annotate_has$"
- " return _internal_has_$name$();\n"
+ " return $has_field$;\n"
"}\n");
- } else if (HasPrivateHasMethod(field)) {
+ }
+ if (HasInternalHasMethod(field)) {
format(
"inline bool $classname$::_internal_has_$name$() const {\n"
- " return $oneof_name$_case() == k$field_name$;\n"
+ " return $has_field$;\n"
"}\n");
}
// set_has_$name$() for oneof fields is always private; hence should not be
@@ -1178,11 +1058,9 @@ void MessageGenerator::GenerateOneofMemberHasBits(const FieldDescriptor* field,
}
void MessageGenerator::GenerateFieldClear(const FieldDescriptor* field,
- bool is_inline, Formatter format) {
- if (IsFieldStripped(field, options_)) {
- format("void $classname$::clear_$name$() { __builtin_trap(); }\n");
- return;
- }
+ bool is_inline, io::Printer* p) {
+ auto t = p->WithVars(MakeTrackerCalls(field, options_));
+ Formatter format(p);
// Generate clear_$name$().
if (is_inline) {
@@ -1195,9 +1073,10 @@ void MessageGenerator::GenerateFieldClear(const FieldDescriptor* field,
if (field->real_containing_oneof()) {
// Clear this field only if it is the active field in this oneof,
// otherwise ignore
- format("if (_internal_has_$name$()) {\n");
+ auto t = p->WithVars(MakeTrackerCalls(field, options_));
+ format("if ($has_field$) {\n");
format.Indent();
- field_generators_.get(field).GenerateClearingCode(format.printer());
+ field_generators_.get(field).GenerateClearingCode(p);
format("clear_has_$oneof_name$();\n");
format.Outdent();
format("}\n");
@@ -1205,13 +1084,11 @@ void MessageGenerator::GenerateFieldClear(const FieldDescriptor* field,
if (ShouldSplit(field, options_)) {
format("if (IsSplitMessageDefault()) return;\n");
}
- field_generators_.get(field).GenerateClearingCode(format.printer());
+ field_generators_.get(field).GenerateClearingCode(p);
if (HasHasbit(field)) {
int has_bit_index = HasBitIndex(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");
+ auto v = p->WithVars(HasbitVars(has_bit_index));
+ format("$has_bits$[$has_array_index$] &= ~$has_mask$;\n");
}
}
format("$annotate_clear$");
@@ -1219,81 +1096,60 @@ void MessageGenerator::GenerateFieldClear(const FieldDescriptor* field,
format("}\n");
}
-void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* printer) {
- Formatter format(printer, variables_);
+void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* p) {
+ Formatter format(p);
format("// $classname$\n\n");
for (auto field : FieldRange(descriptor_)) {
PrintFieldComment(format, field);
- if (IsFieldStripped(field, options_)) {
- continue;
- }
-
- std::map<TProtoStringType, TProtoStringType> vars;
- SetCommonFieldVariables(field, &vars, options_);
-
- Formatter::SaveState saver(&format);
- format.AddMap(vars);
-
+ auto v = p->WithVars(FieldVars(field, options_));
+ auto t = p->WithVars(MakeTrackerCalls(field, options_));
// Generate has_$name$() or $name$_size().
if (field->is_repeated()) {
- if (IsFieldStripped(field, options_)) {
- format(
- "inline int $classname$::$name$_size() const { "
- "__builtin_trap(); }\n");
- } else {
- format(
- "inline int $classname$::_internal_$name$_size() const {\n"
- " return $field$$1$.size();\n"
- "}\n"
- "inline int $classname$::$name$_size() const {\n"
- "$annotate_size$"
- " return _internal_$name$_size();\n"
- "}\n",
- IsImplicitWeakField(field, options_, scc_analyzer_) &&
- field->message_type()
- ? ".weak"
- : "");
- }
+ format(
+ "inline int $classname$::_internal_$name$_size() const {\n"
+ " return $field$$1$.size();\n"
+ "}\n"
+ "inline int $classname$::$name$_size() const {\n"
+ "$annotate_size$"
+ " return _internal_$name$_size();\n"
+ "}\n",
+ IsImplicitWeakField(field, options_, scc_analyzer_) &&
+ field->message_type()
+ ? ".weak"
+ : "");
} else if (field->real_containing_oneof()) {
- format.Set("field_name", UnderscoresToCamelCase(field->name(), true));
- format.Set("oneof_name", field->containing_oneof()->name());
- format.Set("oneof_index",
- StrCat(field->containing_oneof()->index()));
- GenerateOneofMemberHasBits(field, format);
+ GenerateOneofMemberHasBits(field, p);
} else {
// Singular field.
- GenerateSingularFieldHasBits(field, format);
+ GenerateSingularFieldHasBits(field, p);
}
if (!IsCrossFileMaybeMap(field)) {
- GenerateFieldClear(field, true, format);
+ GenerateFieldClear(field, true, p);
}
-
// Generate type-specific accessors.
- if (!IsFieldStripped(field, options_)) {
- field_generators_.get(field).GenerateInlineAccessorDefinitions(printer);
- }
+ field_generators_.get(field).GenerateInlineAccessorDefinitions(p);
format("\n");
}
// Generate has_$name$() and clear_has_$name$() functions for oneofs.
- GenerateOneofHasBits(printer);
+ GenerateOneofHasBits(p);
}
-void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
- Formatter format(printer, variables_);
- format.Set("class_final",
- ShouldMarkClassAsFinal(descriptor_, options_) ? "final" : "");
+void MessageGenerator::GenerateClassDefinition(io::Printer* p) {
+ auto v = p->WithVars(ClassVars(descriptor_, options_));
+ auto t = p->WithVars(MakeTrackerCalls(descriptor_, options_));
+ Formatter format(p);
if (IsMapEntryMessage(descriptor_)) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
CollectMapInfo(options_, descriptor_, &vars);
vars["lite"] =
HasDescriptorMethods(descriptor_->file(), options_) ? "" : "Lite";
- format.AddMap(vars);
+ auto v = p->WithVars(std::move(vars));
format(
"class $classname$ : public "
"::$proto_ns$::internal::MapEntry$lite$<$classname$, \n"
@@ -1314,7 +1170,9 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
" static const $classname$* internal_default_instance() { return "
"reinterpret_cast<const "
"$classname$*>(&_$classname$_default_instance_); }\n");
- auto utf8_check = GetUtf8CheckMode(descriptor_->field(0), options_);
+ auto utf8_check = internal::cpp::GetUtf8CheckMode(
+ descriptor_->field(0), GetOptimizeFor(descriptor_->file(), options_) ==
+ FileOptions::LITE_RUNTIME);
if (descriptor_->field(0)->type() == FieldDescriptor::TYPE_STRING &&
utf8_check != Utf8CheckMode::kNone) {
if (utf8_check == Utf8CheckMode::kStrict) {
@@ -1326,7 +1184,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
" }\n",
descriptor_->field(0)->full_name());
} else {
- GOOGLE_CHECK(utf8_check == Utf8CheckMode::kVerify);
+ Y_ABSL_CHECK(utf8_check == Utf8CheckMode::kVerify);
format(
" static bool ValidateKey(TProtoStringType* s) {\n"
"#ifndef NDEBUG\n"
@@ -1355,7 +1213,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
" }\n",
descriptor_->field(1)->full_name());
} else {
- GOOGLE_CHECK(utf8_check == Utf8CheckMode::kVerify);
+ Y_ABSL_CHECK(utf8_check == Utf8CheckMode::kVerify);
format(
" static bool ValidateValue(TProtoStringType* s) {\n"
"#ifndef NDEBUG\n"
@@ -1386,25 +1244,14 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
}
format(
- "class $dllexport_decl $${1$$classname$$}$$ class_final$ :\n"
+ "class $dllexport_decl $${1$$classname$$}$ final :\n"
" public $superclass$ /* @@protoc_insertion_point("
"class_definition:$full_name$) */ {\n",
descriptor_);
format(" public:\n");
format.Indent();
- if (EnableMessageOwnedArena(descriptor_, options_)) {
- format(
- "inline $classname$() : $classname$("
- "::$proto_ns$::Arena::InternalCreateMessageOwnedArena(), true) {}\n");
- } else if (EnableMessageOwnedArenaTrial(descriptor_, options_)) {
- format(
- "inline $classname$() : $classname$(InMoaTrial() ? "
- "::$proto_ns$::Arena::InternalCreateMessageOwnedArena() : nullptr, "
- "InMoaTrial()) {}\n");
- } else {
- format("inline $classname$() : $classname$(nullptr) {}\n");
- }
+ format("inline $classname$() : $classname$(nullptr) {}\n");
if (!HasSimpleBaseClass(descriptor_, options_)) {
format("~$classname$() override;\n");
}
@@ -1489,7 +1336,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
format("$1$ = $2$,\n", OneofCaseConstantName(field), // 1
field->number()); // 2
}
- format("$1$_NOT_SET = 0,\n", ToUpper(oneof->name()));
+ format("$1$_NOT_SET = 0,\n", y_absl::AsciiStrToUpper(oneof->name()));
format.Outdent();
format(
"};\n"
@@ -1518,8 +1365,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
" return $any_metadata$.PackFrom(GetArena(), message);\n"
"}\n"
"bool PackFrom(const ::$proto_ns$::Message& message,\n"
- " ::PROTOBUF_NAMESPACE_ID::ConstStringParam "
- "type_url_prefix) {\n"
+ " ::y_absl::string_view type_url_prefix) {\n"
" $DCHK$_NE(&message, this);\n"
" return $any_metadata$.PackFrom(GetArena(), message, "
"type_url_prefix);\n"
@@ -1541,8 +1387,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"!std::is_convertible<T, const ::$proto_ns$::Message&>"
"::value>::type>\n"
"bool PackFrom(const T& message,\n"
- " ::PROTOBUF_NAMESPACE_ID::ConstStringParam "
- "type_url_prefix) {\n"
+ " ::y_absl::string_view type_url_prefix) {\n"
" return $any_metadata$.PackFrom<T>(GetArena(), message, "
"type_url_prefix);"
"}\n"
@@ -1560,8 +1405,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"}\n"
"template <typename T>\n"
"bool PackFrom(const T& message,\n"
- " ::PROTOBUF_NAMESPACE_ID::ConstStringParam "
- "type_url_prefix) {\n"
+ " ::y_absl::string_view type_url_prefix) {\n"
" return $any_metadata$.PackFrom(GetArena(), message, "
"type_url_prefix);\n"
"}\n"
@@ -1574,8 +1418,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"template<typename T> bool Is() const {\n"
" return $any_metadata$.Is<T>();\n"
"}\n"
- "static bool ParseAnyTypeUrl(::PROTOBUF_NAMESPACE_ID::ConstStringParam "
- "type_url,\n"
+ "static bool ParseAnyTypeUrl(::y_absl::string_view type_url,\n"
" TProtoStringType* full_type_name);\n");
}
@@ -1612,9 +1455,9 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
// For instances that derive from Message (rather than MessageLite), some
// methods are virtual and should be marked as final.
- format.Set("full_final", HasDescriptorMethods(descriptor_->file(), options_)
- ? "final"
- : "");
+ auto v2 = p->WithVars(
+ {{"full_final",
+ HasDescriptorMethods(descriptor_->file(), options_) ? "final" : ""}});
if (HasGeneratedMethods(descriptor_->file(), options_)) {
if (HasDescriptorMethods(descriptor_->file(), options_)) {
@@ -1662,9 +1505,9 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;\n"
"bool IsInitialized() const final;\n"
"\n"
- "size_t ByteSizeLong() const final;\n");
+ "::size_t ByteSizeLong() const final;\n");
- parse_function_generator_->GenerateMethodDecls(printer);
+ parse_function_generator_->GenerateMethodDecls(p);
format(
"$uint8$* _InternalSerialize(\n"
@@ -1683,7 +1526,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"int GetCachedSize() const final { return "
"$cached_size$.Get(); }"
"\n\nprivate:\n"
- "void SharedCtor(::$proto_ns$::Arena* arena, bool is_message_owned);\n"
+ "void SharedCtor(::$proto_ns$::Arena* arena);\n"
"void SharedDtor();\n"
"void SetCachedSize(int size) const$ full_final$;\n"
"void InternalSwap($classname$* other);\n");
@@ -1693,19 +1536,16 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
// Friend AnyMetadata so that it can call this FullMessageName() method.
"\nprivate:\n"
"friend class ::$proto_ns$::internal::AnyMetadata;\n"
- "static $1$ FullMessageName() {\n"
+ "static ::y_absl::string_view FullMessageName() {\n"
" return \"$full_name$\";\n"
- "}\n",
- options_.opensource_runtime ? "::PROTOBUF_NAMESPACE_ID::StringPiece"
- : "::StringPiece");
+ "}\n");
format(
// TODO(gerbens) Make this private! Currently people are deriving from
// protos to give access to this constructor, breaking the invariants
// we rely on.
"protected:\n"
- "explicit $classname$(::$proto_ns$::Arena* arena,\n"
- " bool is_message_owned = false);\n");
+ "explicit $classname$(::$proto_ns$::Arena* arena);\n");
switch (NeedsArenaDestructor()) {
case ArenaDtorNeeds::kOnDemand:
@@ -1758,7 +1598,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
format(
"private:\n"
"inline bool IsSplitMessageDefault() const {\n"
- " return $split$ == reinterpret_cast<Impl_::Split*>(&$1$);\n"
+ " return $split$ == reinterpret_cast<const Impl_::Split*>(&$1$);\n"
"}\n"
"PROTOBUF_NOINLINE void PrepareSplitMessageForWrite();\n"
"public:\n",
@@ -1773,8 +1613,9 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
for (int i = 0; i < descriptor_->nested_type_count(); i++) {
const Descriptor* nested_type = descriptor_->nested_type(i);
if (!IsMapEntryMessage(nested_type)) {
- format.Set("nested_full_name", ClassName(nested_type, false));
- format.Set("nested_name", ResolveKeyword(nested_type->name()));
+ auto v =
+ p->WithVars({{"nested_full_name", ClassName(nested_type, false)},
+ {"nested_name", ResolveKeyword(nested_type->name())}});
format("typedef ${1$$nested_full_name$$}$ ${1$$nested_name$$}$;\n",
nested_type);
}
@@ -1787,7 +1628,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
// Import all nested enums and their values into this class's scope with
// typedefs and constants.
for (int i = 0; i < descriptor_->enum_type_count(); i++) {
- enum_generators_[i]->GenerateSymbolImports(printer);
+ enum_generators_[i]->GenerateSymbolImports(p);
format("\n");
}
@@ -1796,11 +1637,11 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"\n");
// Generate accessor methods for all fields.
- GenerateFieldAccessorDeclarations(printer);
+ GenerateFieldAccessorDeclarations(p);
// Declare extension identifiers.
for (int i = 0; i < descriptor_->extension_count(); i++) {
- extension_generators_[i]->GenerateDeclaration(printer);
+ extension_generators_[i]->GenerateDeclaration(p);
}
@@ -1835,11 +1676,11 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
num_required_fields_ > 1) {
format(
"// helper for ByteSizeLong()\n"
- "size_t RequiredFieldsByteSizeFallback() const;\n\n");
+ "::size_t RequiredFieldsByteSizeFallback() const;\n\n");
}
if (HasGeneratedMethods(descriptor_->file(), options_)) {
- parse_function_generator_->GenerateDataDecls(printer);
+ parse_function_generator_->GenerateDataDecls(p);
}
// Prepare decls for _cached_size_ and _has_bits_. Their position in the
@@ -1852,7 +1693,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
const size_t sizeof_has_bits = HasBitsSize();
const TProtoStringType has_bits_decl =
sizeof_has_bits == 0 ? ""
- : StrCat("::$proto_ns$::internal::HasBits<",
+ : y_absl::StrCat("::$proto_ns$::internal::HasBits<",
sizeof_has_bits, "> _has_bits_;\n");
format(
@@ -1907,10 +1748,9 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
// Emit some private and static members
for (auto field : optimized_order_) {
- const FieldGenerator& generator = field_generators_.get(field);
- generator.GenerateStaticMembers(printer);
+ field_generators_.get(field).GenerateStaticMembers(p);
if (!ShouldSplit(field, options_)) {
- generator.GeneratePrivateMembers(printer);
+ field_generators_.get(field).GeneratePrivateMembers(p);
}
}
if (ShouldSplit(descriptor_, options_)) {
@@ -1918,14 +1758,15 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
format.Indent();
for (auto field : optimized_order_) {
if (!ShouldSplit(field, options_)) continue;
- const FieldGenerator& generator = field_generators_.get(field);
- generator.GeneratePrivateMembers(printer);
+ field_generators_.get(field).GeneratePrivateMembers(p);
}
format.Outdent();
format(
" typedef void InternalArenaConstructable_;\n"
" typedef void DestructorSkippable_;\n"
"};\n"
+ "static_assert(std::is_trivially_copy_constructible<Split>::value);\n"
+ "static_assert(std::is_trivially_destructible<Split>::value);\n"
"Split* _split_;\n");
}
@@ -1941,16 +1782,12 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
" ::$proto_ns$::internal::ConstantInitialized _constinit_;\n",
camel_oneof_name);
for (auto field : FieldRange(oneof)) {
- if (!IsFieldStripped(field, options_)) {
- field_generators_.get(field).GeneratePrivateMembers(printer);
- }
+ field_generators_.get(field).GeneratePrivateMembers(p);
}
format.Outdent();
format("} $1$_;\n", oneof->name());
for (auto field : FieldRange(oneof)) {
- if (!IsFieldStripped(field, options_)) {
- field_generators_.get(field).GenerateStaticMembers(printer);
- }
+ field_generators_.get(field).GenerateStaticMembers(p);
}
}
@@ -1986,9 +1823,6 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
}
if (ShouldSplit(descriptor_, options_)) {
- format(
- "static Impl_::Split* CreateSplitMessage("
- "::$proto_ns$::Arena* arena);\n");
format("friend struct $1$;\n",
DefaultInstanceType(descriptor_, options_, /*split=*/true));
}
@@ -1999,19 +1833,23 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
format.Outdent();
format("};");
- GOOGLE_DCHECK(!need_to_emit_cached_size);
+ Y_ABSL_DCHECK(!need_to_emit_cached_size);
} // NOLINT(readability/fn_size)
-void MessageGenerator::GenerateInlineMethods(io::Printer* printer) {
+void MessageGenerator::GenerateInlineMethods(io::Printer* p) {
+ auto v = p->WithVars(ClassVars(descriptor_, options_));
+ auto t = p->WithVars(MakeTrackerCalls(descriptor_, options_));
if (IsMapEntryMessage(descriptor_)) return;
- GenerateFieldAccessorDefinitions(printer);
+ GenerateFieldAccessorDefinitions(p);
// Generate oneof_case() functions.
for (auto oneof : OneOfRange(descriptor_)) {
- Formatter format(printer, variables_);
- format.Set("camel_oneof_name", UnderscoresToCamelCase(oneof->name(), true));
- format.Set("oneof_name", oneof->name());
- format.Set("oneof_index", oneof->index());
+ Formatter format(p);
+ auto v = p->WithVars({
+ {"camel_oneof_name", UnderscoresToCamelCase(oneof->name(), true)},
+ {"oneof_name", oneof->name()},
+ {"oneof_index", oneof->index()},
+ });
format(
"inline $classname$::$camel_oneof_name$Case $classname$::"
"${1$$oneof_name$_case$}$() const {\n"
@@ -2022,9 +1860,11 @@ void MessageGenerator::GenerateInlineMethods(io::Printer* printer) {
}
}
-void MessageGenerator::GenerateSchema(io::Printer* printer, int offset,
+void MessageGenerator::GenerateSchema(io::Printer* p, int offset,
int has_offset) {
- Formatter format(printer, variables_);
+ auto v = p->WithVars(ClassVars(descriptor_, options_));
+ auto t = p->WithVars(MakeTrackerCalls(descriptor_, options_));
+ Formatter format(p);
has_offset = !has_bit_indices_.empty() || IsMapEntryMessage(descriptor_)
? offset + has_offset
: -1;
@@ -2032,17 +1872,18 @@ void MessageGenerator::GenerateSchema(io::Printer* printer, int offset,
if (inlined_string_indices_.empty()) {
inlined_string_indices_offset = -1;
} else {
- GOOGLE_DCHECK_NE(has_offset, -1);
- GOOGLE_DCHECK(!IsMapEntryMessage(descriptor_));
+ Y_ABSL_DCHECK_NE(has_offset, -1);
+ Y_ABSL_DCHECK(!IsMapEntryMessage(descriptor_));
inlined_string_indices_offset = has_offset + has_bit_indices_.size();
}
-
format("{ $1$, $2$, $3$, sizeof($classtype$)},\n", offset, has_offset,
inlined_string_indices_offset);
}
-void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
- Formatter format(printer, variables_);
+void MessageGenerator::GenerateClassMethods(io::Printer* p) {
+ auto v = p->WithVars(ClassVars(descriptor_, options_));
+ auto t = p->WithVars(MakeTrackerCalls(descriptor_, options_));
+ Formatter format(p);
if (IsMapEntryMessage(descriptor_)) {
format(
"$classname$::$classname$() {}\n"
@@ -2087,7 +1928,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
}
format(
"bool $classname$::ParseAnyTypeUrl(\n"
- " ::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url,\n"
+ " ::y_absl::string_view type_url,\n"
" TProtoStringType* full_type_name) {\n"
" return ::_pbi::ParseAnyTypeUrl(type_url, full_type_name);\n"
"}\n"
@@ -2101,16 +1942,21 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
if (!has_bit_indices_.empty()) {
format(
"using HasBits = "
- "decltype(std::declval<$classname$>().$has_bits$);\n");
+ "decltype(std::declval<$classname$>().$has_bits$);\n"
+ "static constexpr ::arc_i32 kHasBitsOffset =\n"
+ " 8 * PROTOBUF_FIELD_OFFSET($classname$, _impl_._has_bits_);\n");
+ }
+ if (descriptor_->real_oneof_decl_count() > 0) {
+ format(
+ "static constexpr ::arc_i32 kOneofCaseOffset =\n"
+ " PROTOBUF_FIELD_OFFSET($classtype$, $oneof_case$);\n");
}
for (auto field : FieldRange(descriptor_)) {
- field_generators_.get(field).GenerateInternalAccessorDeclarations(printer);
- if (IsFieldStripped(field, options_)) {
- continue;
- }
+ auto t = p->WithVars(MakeTrackerCalls(field, options_));
+ field_generators_.get(field).GenerateInternalAccessorDeclarations(p);
if (HasHasbit(field)) {
int has_bit_index = HasBitIndex(field);
- GOOGLE_CHECK_NE(has_bit_index, kNoHasbit) << field->full_name();
+ Y_ABSL_CHECK_NE(has_bit_index, kNoHasbit) << field->full_name();
format(
"static void set_has_$1$(HasBits* has_bits) {\n"
" (*has_bits)[$2$] |= $3$u;\n"
@@ -2131,65 +1977,54 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
format.Outdent();
format("};\n\n");
for (auto field : FieldRange(descriptor_)) {
- if (!IsFieldStripped(field, options_)) {
- field_generators_.get(field).GenerateInternalAccessorDefinitions(
- printer);
- }
+ field_generators_.get(field).GenerateInternalAccessorDefinitions(p);
}
// Generate non-inline field definitions.
for (auto field : FieldRange(descriptor_)) {
- if (IsFieldStripped(field, options_)) {
- continue;
- }
- field_generators_.get(field).GenerateNonInlineAccessorDefinitions(printer);
+ auto v = p->WithVars(FieldVars(field, options_));
+ auto t = p->WithVars(MakeTrackerCalls(field, options_));
+ field_generators_.get(field).GenerateNonInlineAccessorDefinitions(p);
if (IsCrossFileMaybeMap(field)) {
- Formatter::SaveState saver(&format);
- std::map<TProtoStringType, TProtoStringType> vars;
- SetCommonFieldVariables(field, &vars, options_);
- if (field->real_containing_oneof()) {
- SetCommonOneofFieldVariables(field, &vars);
- }
- format.AddMap(vars);
- GenerateFieldClear(field, false, format);
+ GenerateFieldClear(field, false, p);
}
}
- GenerateStructors(printer);
+ GenerateStructors(p);
format("\n");
if (descriptor_->real_oneof_decl_count() > 0) {
- GenerateOneofClear(printer);
+ GenerateOneofClear(p);
format("\n");
}
if (HasGeneratedMethods(descriptor_->file(), options_)) {
- GenerateClear(printer);
+ GenerateClear(p);
format("\n");
if (!HasSimpleBaseClass(descriptor_, options_)) {
- parse_function_generator_->GenerateMethodImpls(printer);
+ parse_function_generator_->GenerateMethodImpls(p);
format("\n");
- parse_function_generator_->GenerateDataDefinitions(printer);
+ parse_function_generator_->GenerateDataDefinitions(p);
}
- GenerateSerializeWithCachedSizesToArray(printer);
+ GenerateSerializeWithCachedSizesToArray(p);
format("\n");
- GenerateByteSize(printer);
+ GenerateByteSize(p);
format("\n");
- GenerateMergeFrom(printer);
+ GenerateMergeFrom(p);
format("\n");
- GenerateClassSpecificMergeImpl(printer);
+ GenerateClassSpecificMergeImpl(p);
format("\n");
- GenerateCopyFrom(printer);
+ GenerateCopyFrom(p);
format("\n");
- GenerateIsInitialized(printer);
+ GenerateIsInitialized(p);
format("\n");
}
@@ -2197,14 +2032,19 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
format(
"void $classname$::PrepareSplitMessageForWrite() {\n"
" if (IsSplitMessageDefault()) {\n"
- " $split$ = CreateSplitMessage(GetArenaForAllocation());\n"
+ " void* chunk = "
+ "::PROTOBUF_NAMESPACE_ID::internal::CreateSplitMessageGeneric("
+ "GetArenaForAllocation(), &$1$, sizeof(Impl_::Split), this, &$2$);\n"
+ " $split$ = reinterpret_cast<Impl_::Split*>(chunk);\n"
" }\n"
- "}\n");
+ "}\n",
+ DefaultInstanceName(descriptor_, options_, /*split=*/true),
+ DefaultInstanceName(descriptor_, options_, /*split=*/false));
}
- GenerateVerify(printer);
+ GenerateVerify(p);
- GenerateSwap(printer);
+ GenerateSwap(p);
format("\n");
if (HasDescriptorMethods(descriptor_->file(), options_)) {
@@ -2242,9 +2082,10 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
}
}
-std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
- io::Printer* printer) {
- Formatter format(printer, variables_);
+std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(io::Printer* p) {
+ auto v = p->WithVars(ClassVars(descriptor_, options_));
+ auto t = p->WithVars(MakeTrackerCalls(descriptor_, options_));
+ Formatter format(p);
if (!has_bit_indices_.empty() || IsMapEntryMessage(descriptor_)) {
format("PROTOBUF_FIELD_OFFSET($classtype$, $has_bits$),\n");
@@ -2274,15 +2115,20 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
} else {
format("~0u, // no _inlined_string_donated_\n");
}
- const int kNumGenericOffsets = 6; // the number of fixed offsets above
+ if (ShouldSplit(descriptor_, options_)) {
+ format(
+ "PROTOBUF_FIELD_OFFSET($classtype$, $split$),\n"
+ "sizeof($classtype$::Impl_::Split),\n");
+ } else {
+ format(
+ "~0u, // no _split_\n"
+ "~0u, // no sizeof(Split)\n");
+ }
+ const int kNumGenericOffsets = 8; // the number of fixed offsets above
const size_t offsets = kNumGenericOffsets + descriptor_->field_count() +
descriptor_->real_oneof_decl_count();
size_t entries = offsets;
for (auto field : FieldRange(descriptor_)) {
- if (IsFieldStripped(field, options_)) {
- format("~0u, // stripped\n");
- continue;
- }
// TODO(sbenza): We should not have an entry in the offset table for fields
// that do not use them.
if (field->options().weak() || field->real_containing_oneof()) {
@@ -2293,7 +2139,7 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
format("PROTOBUF_FIELD_OFFSET($classtype$$1$, $2$)",
ShouldSplit(field, options_) ? "::Impl_::Split" : "",
ShouldSplit(field, options_)
- ? FieldName(field) + "_"
+ ? y_absl::StrCat(FieldName(field), "_")
: FieldMemberName(field, /*cold=*/false));
}
@@ -2302,12 +2148,17 @@ 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 eagerly verified lazy or inlined string to the
- // LSB of the offset.
+ // We embed whether the field is cold to the MSB of the offset, and whether
+ // the field is eagerly verified lazy or inlined string to the LSB of the
+ // offset.
+
+ if (ShouldSplit(field, options_)) {
+ format(" | ::_pbi::kSplitFieldOffsetMask /*split*/");
+ }
if (IsEagerlyVerifiedLazy(field, options_, scc_analyzer_)) {
- format(" | 0x1u // eagerly verified lazy\n");
+ format(" | 0x1u /*eagerly verified lazy*/");
} else if (IsStringInlined(field, options_)) {
- format(" | 0x1u // inlined\n");
+ format(" | 0x1u /*inlined*/");
}
format(",\n");
}
@@ -2317,7 +2168,7 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
format("PROTOBUF_FIELD_OFFSET($classtype$, _impl_.$1$_),\n", oneof->name());
count++;
}
- GOOGLE_CHECK_EQ(count, descriptor_->real_oneof_decl_count());
+ Y_ABSL_CHECK_EQ(count, descriptor_->real_oneof_decl_count());
if (IsMapEntryMessage(descriptor_)) {
entries += 2;
@@ -2328,7 +2179,7 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
entries += has_bit_indices_.size();
for (int i = 0; i < has_bit_indices_.size(); i++) {
const TProtoStringType index =
- has_bit_indices_[i] >= 0 ? StrCat(has_bit_indices_[i]) : "~0u";
+ has_bit_indices_[i] >= 0 ? y_absl::StrCat(has_bit_indices_[i]) : "~0u";
format("$1$,\n", index);
}
}
@@ -2337,7 +2188,7 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
for (int inlined_string_index : inlined_string_indices_) {
const TProtoStringType index =
inlined_string_index >= 0
- ? StrCat(inlined_string_index, ", // inlined_string_index")
+ ? y_absl::StrCat(inlined_string_index, ", // inlined_string_index")
: "~0u,";
format("$1$\n", index);
}
@@ -2346,15 +2197,13 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
return std::make_pair(entries, offsets);
}
-void MessageGenerator::GenerateSharedConstructorCode(io::Printer* printer) {
+void MessageGenerator::GenerateSharedConstructorCode(io::Printer* p) {
if (HasSimpleBaseClass(descriptor_, options_)) return;
- Formatter format(printer, variables_);
+ Formatter format(p);
format(
- "inline void $classname$::SharedCtor(\n"
- " ::_pb::Arena* arena, bool is_message_owned) {\n"
- " (void)arena;\n"
- " (void)is_message_owned;\n");
+ "inline void $classname$::SharedCtor(::_pb::Arena* arena) {\n"
+ " (void)arena;\n");
format.Indent();
// Impl_ _impl_.
@@ -2389,17 +2238,23 @@ void MessageGenerator::GenerateSharedConstructorCode(io::Printer* printer) {
// Initialize member variables with arena constructor.
for (auto field : optimized_order_) {
- GOOGLE_DCHECK(!IsFieldStripped(field, options_));
if (ShouldSplit(field, options_)) {
continue;
}
put_sep();
- field_generators_.get(field).GenerateAggregateInitializer(printer);
+ field_generators_.get(field).GenerateAggregateInitializer(p);
}
if (ShouldSplit(descriptor_, options_)) {
put_sep();
- format("decltype($split$){reinterpret_cast<Impl_::Split*>(&$1$)}",
- DefaultInstanceName(descriptor_, options_, /*split=*/true));
+ // We can't assign the default split to this->split without the const_cast
+ // because the former is a const. The const_cast is safe because we don't
+ // intend to modify the default split through this pointer, and we also
+ // expect the default split to be in the rodata section which is protected
+ // from mutation.
+ format(
+ "decltype($split$){const_cast<Impl_::Split*>"
+ "(reinterpret_cast<const Impl_::Split*>(&$1$))}",
+ DefaultInstanceName(descriptor_, options_, /*split=*/true));
}
for (auto oneof : OneOfRange(descriptor_)) {
put_sep();
@@ -2436,13 +2291,7 @@ void MessageGenerator::GenerateSharedConstructorCode(io::Printer* printer) {
// 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");
+ format(" $inlined_string_donated_array$[0] = ~0u;\n");
} else {
format(" $inlined_string_donated_array$[0] = 0xFFFFFFFEu;\n");
}
@@ -2457,7 +2306,14 @@ void MessageGenerator::GenerateSharedConstructorCode(io::Printer* printer) {
if (ShouldSplit(field, options_)) {
continue;
}
- field_generators_.get(field).GenerateConstructorCode(printer);
+ field_generators_.get(field).GenerateConstructorCode(p);
+ }
+
+ if (ShouldForceAllocationOnConstruction(descriptor_, options_)) {
+ format(
+ "#ifdef PROTOBUF_FORCE_ALLOCATION_ON_CONSTRUCTION\n"
+ "$mutable_unknown_fields$;\n"
+ "#endif // PROTOBUF_FORCE_ALLOCATION_ON_CONSTRUCTION\n");
}
for (auto oneof : OneOfRange(descriptor_)) {
@@ -2468,49 +2324,12 @@ void MessageGenerator::GenerateSharedConstructorCode(io::Printer* printer) {
format("}\n\n");
}
-void MessageGenerator::GenerateCreateSplitMessage(io::Printer* printer) {
- Formatter format(printer, variables_);
- format(
- "$classname$::Impl_::Split* "
- "$classname$::CreateSplitMessage(::$proto_ns$::Arena* arena) {\n");
- format.Indent();
- const char* field_sep = " ";
- const auto put_sep = [&] {
- format("\n$1$ ", field_sep);
- field_sep = ",";
- };
- format(
- "const size_t size = sizeof(Impl_::Split);\n"
- "void* chunk = (arena == nullptr) ?\n"
- " ::operator new(size) :\n"
- " arena->AllocateAligned(size, alignof(Impl_::Split));\n"
- "Impl_::Split* ptr = reinterpret_cast<Impl_::Split*>(chunk);\n"
- "new (ptr) Impl_::Split{");
- format.Indent();
- for (const FieldDescriptor* field : optimized_order_) {
- GOOGLE_DCHECK(!IsFieldStripped(field, options_));
- if (ShouldSplit(field, options_)) {
- put_sep();
- field_generators_.get(field).GenerateAggregateInitializer(printer);
- }
- }
- format.Outdent();
- format("};\n");
- for (const FieldDescriptor* field : optimized_order_) {
- GOOGLE_DCHECK(!IsFieldStripped(field, options_));
- if (ShouldSplit(field, options_)) {
- field_generators_.get(field).GenerateCreateSplitMessageCode(printer);
- }
- }
- format("return ptr;\n");
- format.Outdent();
- format("}\n");
-}
-
-void MessageGenerator::GenerateInitDefaultSplitInstance(io::Printer* printer) {
+void MessageGenerator::GenerateInitDefaultSplitInstance(io::Printer* p) {
if (!ShouldSplit(descriptor_, options_)) return;
- Formatter format(printer, variables_);
+ auto v = p->WithVars(ClassVars(descriptor_, options_));
+ auto t = p->WithVars(MakeTrackerCalls(descriptor_, options_));
+ Formatter format(p);
const char* field_sep = " ";
const auto put_sep = [&] {
format("\n$1$ ", field_sep);
@@ -2519,15 +2338,14 @@ void MessageGenerator::GenerateInitDefaultSplitInstance(io::Printer* printer) {
for (const auto* field : optimized_order_) {
if (ShouldSplit(field, options_)) {
put_sep();
- field_generators_.get(field).GenerateConstexprAggregateInitializer(
- printer);
+ field_generators_.get(field).GenerateConstexprAggregateInitializer(p);
}
}
}
-void MessageGenerator::GenerateSharedDestructorCode(io::Printer* printer) {
+void MessageGenerator::GenerateSharedDestructorCode(io::Printer* p) {
if (HasSimpleBaseClass(descriptor_, options_)) return;
- Formatter format(printer, variables_);
+ Formatter format(p);
format("inline void $classname$::SharedDtor() {\n");
format.Indent();
@@ -2543,7 +2361,7 @@ void MessageGenerator::GenerateSharedDestructorCode(io::Printer* printer) {
if (ShouldSplit(field, options_)) {
continue;
}
- field_generators_.get(field).GenerateDestructorCode(printer);
+ field_generators_.get(field).GenerateDestructorCode(p);
}
if (ShouldSplit(descriptor_, options_)) {
format("if (!IsSplitMessageDefault()) {\n");
@@ -2551,7 +2369,7 @@ void MessageGenerator::GenerateSharedDestructorCode(io::Printer* printer) {
format("auto* $cached_split_ptr$ = $split$;\n");
for (auto field : optimized_order_) {
if (ShouldSplit(field, options_)) {
- field_generators_.get(field).GenerateDestructorCode(printer);
+ field_generators_.get(field).GenerateDestructorCode(p);
}
}
format("delete $cached_split_ptr$;\n");
@@ -2586,17 +2404,16 @@ 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) {
- GOOGLE_CHECK(NeedsArenaDestructor() > ArenaDtorNeeds::kNone);
+void MessageGenerator::GenerateArenaDestructorCode(io::Printer* p) {
+ Y_ABSL_CHECK(NeedsArenaDestructor() > ArenaDtorNeeds::kNone);
- Formatter format(printer, variables_);
+ Formatter format(p);
// Generate the ArenaDtor() method. Track whether any fields actually produced
// code that needs to be called.
@@ -2611,19 +2428,15 @@ void MessageGenerator::GenerateArenaDestructorCode(io::Printer* printer) {
// Process non-oneof fields first.
for (auto field : optimized_order_) {
- if (IsFieldStripped(field, options_) || ShouldSplit(field, options_))
- continue;
- const FieldGenerator& fg = field_generators_.get(field);
- fg.GenerateArenaDestructorCode(printer);
+ if (ShouldSplit(field, options_)) continue;
+ field_generators_.get(field).GenerateArenaDestructorCode(p);
}
if (ShouldSplit(descriptor_, options_)) {
format("if (!_this->IsSplitMessageDefault()) {\n");
format.Indent();
for (auto field : optimized_order_) {
- if (IsFieldStripped(field, options_) || !ShouldSplit(field, options_))
- continue;
- const FieldGenerator& fg = field_generators_.get(field);
- fg.GenerateArenaDestructorCode(printer);
+ if (!ShouldSplit(field, options_)) continue;
+ field_generators_.get(field).GenerateArenaDestructorCode(p);
}
format.Outdent();
format("}\n");
@@ -2632,8 +2445,7 @@ void MessageGenerator::GenerateArenaDestructorCode(io::Printer* printer) {
// Process oneof fields.
for (auto oneof : OneOfRange(descriptor_)) {
for (auto field : FieldRange(oneof)) {
- if (IsFieldStripped(field, options_)) continue;
- field_generators_.get(field).GenerateArenaDestructorCode(printer);
+ field_generators_.get(field).GenerateArenaDestructorCode(p);
}
}
@@ -2641,8 +2453,10 @@ void MessageGenerator::GenerateArenaDestructorCode(io::Printer* printer) {
format("}\n");
}
-void MessageGenerator::GenerateConstexprConstructor(io::Printer* printer) {
- Formatter format(printer, variables_);
+void MessageGenerator::GenerateConstexprConstructor(io::Printer* p) {
+ auto v = p->WithVars(ClassVars(descriptor_, options_));
+ auto t = p->WithVars(MakeTrackerCalls(descriptor_, options_));
+ Formatter format(p);
if (IsMapEntryMessage(descriptor_) || !HasImplData(descriptor_, options_)) {
format(
@@ -2685,12 +2499,11 @@ void MessageGenerator::GenerateConstexprConstructor(io::Printer* printer) {
continue;
}
put_sep();
- field_generators_.get(field).GenerateConstexprAggregateInitializer(
- printer);
+ field_generators_.get(field).GenerateConstexprAggregateInitializer(p);
}
if (ShouldSplit(descriptor_, options_)) {
put_sep();
- format("/*decltype($split$)*/&$1$._instance",
+ format("/*decltype($split$)*/const_cast<Impl_::Split*>(&$1$._instance)",
DefaultInstanceName(descriptor_, options_, /*split=*/true));
}
@@ -2725,8 +2538,8 @@ void MessageGenerator::GenerateConstexprConstructor(io::Printer* printer) {
format("} {}\n");
}
-void MessageGenerator::GenerateCopyConstructorBody(io::Printer* printer) const {
- Formatter format(printer, variables_);
+void MessageGenerator::GenerateCopyConstructorBody(io::Printer* p) const {
+ Formatter format(p);
const RunMap runs =
FindRuns(optimized_order_, [this](const FieldDescriptor* field) {
@@ -2735,20 +2548,14 @@ void MessageGenerator::GenerateCopyConstructorBody(io::Printer* printer) const {
TProtoStringType pod_template =
"::memcpy(&$first$, &from.$first$,\n"
- " static_cast<size_t>(reinterpret_cast<char*>(&$last$) -\n"
+ " static_cast<::size_t>(reinterpret_cast<char*>(&$last$) -\n"
" reinterpret_cast<char*>(&$first$)) + sizeof($last$));\n";
- if (ShouldSplit(descriptor_, options_)) {
- format("if (!from.IsSplitMessageDefault()) {\n");
- format.Indent();
- format("_this->PrepareSplitMessageForWrite();\n");
- for (auto field : optimized_order_) {
- if (ShouldSplit(field, options_)) {
- field_generators_.get(field).GenerateCopyConstructorCode(printer);
- }
- }
- format.Outdent();
- format("}\n");
+ if (ShouldForceAllocationOnConstruction(descriptor_, options_)) {
+ format(
+ "#ifdef PROTOBUF_FORCE_ALLOCATION_ON_CONSTRUCTION\n"
+ "$mutable_unknown_fields$;\n"
+ "#endif // PROTOBUF_FORCE_ALLOCATION_ON_CONSTRUCTION\n");
}
for (size_t i = 0; i < optimized_order_.size(); ++i) {
@@ -2768,33 +2575,47 @@ void MessageGenerator::GenerateCopyConstructorBody(io::Printer* printer) const {
const TProtoStringType last_field_name =
FieldMemberName(optimized_order_[i + run_length - 1], /*cold=*/false);
- format.Set("first", first_field_name);
- format.Set("last", last_field_name);
-
+ auto v = p->WithVars({
+ {"first", first_field_name},
+ {"last", last_field_name},
+ });
format(pod_template.c_str());
i += run_length - 1;
// ++i at the top of the loop.
} else {
- field_generators_.get(field).GenerateCopyConstructorCode(printer);
+ field_generators_.get(field).GenerateCopyConstructorCode(p);
}
}
+
+ if (ShouldSplit(descriptor_, options_)) {
+ format("if (!from.IsSplitMessageDefault()) {\n");
+ format.Indent();
+ format("_this->PrepareSplitMessageForWrite();\n");
+ // TODO(b/122856539): cache the split pointers.
+ for (auto field : optimized_order_) {
+ if (ShouldSplit(field, options_)) {
+ field_generators_.get(field).GenerateCopyConstructorCode(p);
+ }
+ }
+ format.Outdent();
+ format("}\n");
+ }
}
-void MessageGenerator::GenerateStructors(io::Printer* printer) {
- Formatter format(printer, variables_);
+void MessageGenerator::GenerateStructors(io::Printer* p) {
+ Formatter format(p);
format(
- "$classname$::$classname$(::$proto_ns$::Arena* arena,\n"
- " bool is_message_owned)\n"
- " : $1$(arena, is_message_owned) {\n",
+ "$classname$::$classname$(::$proto_ns$::Arena* arena)\n"
+ " : $1$(arena) {\n",
SuperClassName(descriptor_, options_));
if (!HasSimpleBaseClass(descriptor_, options_)) {
- format(" SharedCtor(arena, is_message_owned);\n");
+ format(" SharedCtor(arena);\n");
if (NeedsArenaDestructor() == ArenaDtorNeeds::kRequired) {
format(
- " if (arena != nullptr && !is_message_owned) {\n"
+ " if (arena != nullptr) {\n"
" arena->OwnCustomDestructor(this, &$classname$::ArenaDtor);\n"
" }\n");
}
@@ -2803,9 +2624,30 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
" // @@protoc_insertion_point(arena_constructor:$full_name$)\n"
"}\n");
- std::map<TProtoStringType, TProtoStringType> vars;
- SetUnknownFieldsVariable(descriptor_, options_, &vars);
- format.AddMap(vars);
+ // If the message contains only scalar fields (ints and enums),
+ // then we can copy the entire impl_ section with a single statement.
+ bool copy_construct_impl =
+ !ShouldSplit(descriptor_, options_) &&
+ !HasSimpleBaseClass(descriptor_, options_) &&
+ (descriptor_->extension_range_count() == 0 &&
+ descriptor_->real_oneof_decl_count() == 0 && num_weak_fields_ == 0);
+ for (const auto& field : optimized_order_) {
+ if (!copy_construct_impl) break;
+ if (field->is_repeated() || field->is_extension()) {
+ copy_construct_impl = false;
+ } else if (field->cpp_type() != FieldDescriptor::CPPTYPE_ENUM &&
+ field->cpp_type() != FieldDescriptor::CPPTYPE_INT32 &&
+ field->cpp_type() != FieldDescriptor::CPPTYPE_INT64 &&
+ field->cpp_type() != FieldDescriptor::CPPTYPE_UINT32 &&
+ field->cpp_type() != FieldDescriptor::CPPTYPE_UINT64 &&
+ field->cpp_type() != FieldDescriptor::CPPTYPE_FLOAT &&
+ field->cpp_type() != FieldDescriptor::CPPTYPE_DOUBLE &&
+ field->cpp_type() != FieldDescriptor::CPPTYPE_BOOL) {
+ copy_construct_impl = false;
+ } else {
+ // non-repeated integer fields are fine to copy en masse.
+ }
+ }
// Generate the copy constructor.
if (UsingImplicitWeakFields(descriptor_->file(), options_)) {
@@ -2818,6 +2660,16 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
" : $classname$() {\n"
" MergeFrom(from);\n"
"}\n");
+ } else if (copy_construct_impl) {
+ format(
+ "$classname$::$classname$(const $classname$& from)\n"
+ " : $superclass$(), _impl_(from._impl_) {\n"
+ " _internal_metadata_.MergeFrom<$unknown_fields_type$>(\n"
+ " from._internal_metadata_);\n");
+ format(
+ " // @@protoc_insertion_point(copy_constructor:$full_name$)\n"
+ "}\n"
+ "\n");
} else {
format(
"$classname$::$classname$(const $classname$& from)\n"
@@ -2863,12 +2715,14 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
continue;
}
put_sep();
- field_generators_.get(field).GenerateCopyAggregateInitializer(printer);
+ field_generators_.get(field).GenerateCopyAggregateInitializer(p);
}
if (ShouldSplit(descriptor_, options_)) {
put_sep();
- format("decltype($split$){reinterpret_cast<Impl_::Split*>(&$1$)}",
- DefaultInstanceName(descriptor_, options_, /*split=*/true));
+ format(
+ "decltype($split$){const_cast<Impl_::Split*>"
+ "(reinterpret_cast<const Impl_::Split*>(&$1$))}",
+ DefaultInstanceName(descriptor_, options_, /*split=*/true));
}
for (auto oneof : OneOfRange(descriptor_)) {
put_sep();
@@ -2907,7 +2761,7 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
"from.$extensions$);\n");
}
- GenerateCopyConstructorBody(printer);
+ GenerateCopyConstructorBody(p);
// Copy oneof fields. Oneof field requires oneof case check.
for (auto oneof : OneOfRange(descriptor_)) {
@@ -2919,9 +2773,7 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
for (auto field : FieldRange(oneof)) {
format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true));
format.Indent();
- if (!IsFieldStripped(field, options_)) {
- field_generators_.get(field).GenerateMergingCode(printer);
- }
+ field_generators_.get(field).GenerateMergingCode(p);
format("break;\n");
format.Outdent();
format("}\n");
@@ -2930,7 +2782,7 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
"case $1$_NOT_SET: {\n"
" break;\n"
"}\n",
- ToUpper(oneof->name()));
+ y_absl::AsciiStrToUpper(oneof->name()));
format.Outdent();
format("}\n");
}
@@ -2943,11 +2795,7 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
}
// Generate the shared constructor code.
- GenerateSharedConstructorCode(printer);
-
- if (ShouldSplit(descriptor_, options_)) {
- GenerateCreateSplitMessage(printer);
- }
+ GenerateSharedConstructorCode(p);
// Generate the destructor.
if (!HasSimpleBaseClass(descriptor_, options_)) {
@@ -2977,11 +2825,11 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
}
// Generate the shared destructor code.
- GenerateSharedDestructorCode(printer);
+ GenerateSharedDestructorCode(p);
// Generate the arena-specific destructor code.
if (NeedsArenaDestructor() > ArenaDtorNeeds::kNone) {
- GenerateArenaDestructorCode(printer);
+ GenerateArenaDestructorCode(p);
}
if (!HasSimpleBaseClass(descriptor_, options_)) {
@@ -2993,8 +2841,10 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
}
}
-void MessageGenerator::GenerateSourceInProto2Namespace(io::Printer* printer) {
- Formatter format(printer, variables_);
+void MessageGenerator::GenerateSourceInProto2Namespace(io::Printer* p) {
+ auto v = p->WithVars(ClassVars(descriptor_, options_));
+ auto t = p->WithVars(MakeTrackerCalls(descriptor_, options_));
+ Formatter format(p);
format(
"template<> "
"PROTOBUF_NOINLINE $classtype$*\n"
@@ -3003,9 +2853,9 @@ void MessageGenerator::GenerateSourceInProto2Namespace(io::Printer* printer) {
"}\n");
}
-void MessageGenerator::GenerateClear(io::Printer* printer) {
+void MessageGenerator::GenerateClear(io::Printer* p) {
if (HasSimpleBaseClass(descriptor_, options_)) return;
- Formatter format(printer, variables_);
+ Formatter format(p);
// The maximum number of bytes we will memset to zero without checking their
// hasbit to see if a zero-init is necessary.
@@ -3031,7 +2881,7 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
// checks all hasbits in the chunk and skips it if none are set.
int zero_init_bytes = 0;
for (const auto& field : optimized_order_) {
- if (CanInitializeByZeroing(field)) {
+ if (CanClearByZeroing(field)) {
zero_init_bytes += EstimateAlignmentSize(field);
}
}
@@ -3044,12 +2894,12 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
chunk_count++;
// This predicate guarantees that there is only a single zero-init
// (memset) per chunk, and if present it will be at the beginning.
- bool same = HasByteIndex(a) == HasByteIndex(b) &&
- a->is_repeated() == b->is_repeated() &&
- ShouldSplit(a, options_) == ShouldSplit(b, options_) &&
- (CanInitializeByZeroing(a) == CanInitializeByZeroing(b) ||
- (CanInitializeByZeroing(a) &&
- (chunk_count == 1 || merge_zero_init)));
+ bool same =
+ HasByteIndex(a) == HasByteIndex(b) &&
+ a->is_repeated() == b->is_repeated() &&
+ ShouldSplit(a, options_) == ShouldSplit(b, options_) &&
+ (CanClearByZeroing(a) == CanClearByZeroing(b) ||
+ (CanClearByZeroing(a) && (chunk_count == 1 || merge_zero_init)));
if (!same) chunk_count = 0;
return same;
});
@@ -3057,18 +2907,29 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
ColdChunkSkipper cold_skipper(descriptor_, options_, chunks, has_bit_indices_,
kColdRatio);
int cached_has_word_index = -1;
-
- for (int chunk_index = 0; chunk_index < chunks.size(); chunk_index++) {
+ bool first_split_chunk_processed = false;
+ for (size_t chunk_index = 0; chunk_index < chunks.size(); chunk_index++) {
std::vector<const FieldDescriptor*>& chunk = chunks[chunk_index];
- cold_skipper.OnStartChunk(chunk_index, cached_has_word_index, "", printer);
+ cold_skipper.OnStartChunk(chunk_index, cached_has_word_index, "", p);
const FieldDescriptor* memset_start = nullptr;
const FieldDescriptor* memset_end = nullptr;
bool saw_non_zero_init = false;
- bool chunk_is_cold = !chunk.empty() && ShouldSplit(chunk.front(), options_);
+ bool chunk_is_split =
+ !chunk.empty() && ShouldSplit(chunk.front(), options_);
+ // All chunks after the first split chunk should also be split.
+ Y_ABSL_CHECK(!first_split_chunk_processed || chunk_is_split);
+ if (chunk_is_split && !first_split_chunk_processed) {
+ // Some fields are cleared without checking has_bit. So we add the
+ // condition here to avoid writing to the default split instance.
+ format("if (!IsSplitMessageDefault()) {\n");
+ format.Indent();
+ first_split_chunk_processed = true;
+ }
+
for (const auto& field : chunk) {
- if (CanInitializeByZeroing(field)) {
- GOOGLE_CHECK(!saw_non_zero_init);
+ if (CanClearByZeroing(field)) {
+ Y_ABSL_CHECK(!saw_non_zero_init);
if (!memset_start) memset_start = field;
memset_end = field;
} else {
@@ -3089,13 +2950,13 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
// Emit an if() that will let us skip the whole chunk if none are set.
arc_ui32 chunk_mask = GenChunkMask(chunk, has_bit_indices_);
TProtoStringType chunk_mask_str =
- StrCat(strings::Hex(chunk_mask, strings::ZERO_PAD_8));
+ y_absl::StrCat(y_absl::Hex(chunk_mask, y_absl::kZeroPad8));
// Check (up to) 8 has_bits at a time if we have more than one field in
// this chunk. Due to field layout ordering, we may check
// _has_bits_[last_chunk * 8 / 32] multiple times.
- GOOGLE_DCHECK_LE(2, popcnt(chunk_mask));
- GOOGLE_DCHECK_GE(8, popcnt(chunk_mask));
+ Y_ABSL_DCHECK_LE(2, popcnt(chunk_mask));
+ Y_ABSL_DCHECK_GE(8, popcnt(chunk_mask));
if (cached_has_word_index != HasWordIndex(chunk.front())) {
cached_has_word_index = HasWordIndex(chunk.front());
@@ -3105,31 +2966,25 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
format.Indent();
}
- if (chunk_is_cold) {
- format("if (!IsSplitMessageDefault()) {\n");
- format.Indent();
- }
-
if (memset_start) {
if (memset_start == memset_end) {
// For clarity, do not memset a single field.
- field_generators_.get(memset_start)
- .GenerateMessageClearingCode(printer);
+ field_generators_.get(memset_start).GenerateMessageClearingCode(p);
} else {
- GOOGLE_CHECK_EQ(chunk_is_cold, ShouldSplit(memset_start, options_));
- GOOGLE_CHECK_EQ(chunk_is_cold, ShouldSplit(memset_end, options_));
+ Y_ABSL_CHECK_EQ(chunk_is_split, ShouldSplit(memset_start, options_));
+ Y_ABSL_CHECK_EQ(chunk_is_split, ShouldSplit(memset_end, options_));
format(
- "::memset(&$1$, 0, static_cast<size_t>(\n"
+ "::memset(&$1$, 0, static_cast<::size_t>(\n"
" reinterpret_cast<char*>(&$2$) -\n"
" reinterpret_cast<char*>(&$1$)) + sizeof($2$));\n",
- FieldMemberName(memset_start, chunk_is_cold),
- FieldMemberName(memset_end, chunk_is_cold));
+ FieldMemberName(memset_start, chunk_is_split),
+ FieldMemberName(memset_end, chunk_is_split));
}
}
// Clear all non-zero-initializable fields in the chunk.
for (const auto& field : chunk) {
- if (CanInitializeByZeroing(field)) continue;
+ if (CanClearByZeroing(field)) continue;
// It's faster to just overwrite primitive types, but we should only
// clear strings and messages if they were set.
//
@@ -3140,11 +2995,10 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
field->cpp_type() == FieldDescriptor::CPPTYPE_STRING);
if (have_enclosing_if) {
- PrintPresenceCheck(format, field, has_bit_indices_, printer,
- &cached_has_word_index);
+ PrintPresenceCheck(field, has_bit_indices_, p, &cached_has_word_index);
}
- field_generators_.get(field).GenerateMessageClearingCode(printer);
+ field_generators_.get(field).GenerateMessageClearingCode(p);
if (have_enclosing_if) {
format.Outdent();
@@ -3152,17 +3006,19 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
}
}
- if (chunk_is_cold) {
+ if (have_outer_if) {
format.Outdent();
format("}\n");
}
- if (have_outer_if) {
- format.Outdent();
- format("}\n");
+ if (chunk_index == chunks.size() - 1) {
+ if (first_split_chunk_processed) {
+ format.Outdent();
+ format("}\n");
+ }
}
- if (cold_skipper.OnEndChunk(chunk_index, printer)) {
+ if (cold_skipper.OnEndChunk(chunk_index, p)) {
// Reset here as it may have been updated in just closed if statement.
cached_has_word_index = -1;
}
@@ -3184,21 +3040,18 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
format("$has_bits$.Clear();\n");
}
- std::map<TProtoStringType, TProtoStringType> vars;
- SetUnknownFieldsVariable(descriptor_, options_, &vars);
- format.AddMap(vars);
format("_internal_metadata_.Clear<$unknown_fields_type$>();\n");
format.Outdent();
format("}\n");
}
-void MessageGenerator::GenerateOneofClear(io::Printer* printer) {
+void MessageGenerator::GenerateOneofClear(io::Printer* p) {
// Generated function clears the active field and union case (e.g. foo_case_).
int i = 0;
for (auto oneof : OneOfRange(descriptor_)) {
- Formatter format(printer, variables_);
- format.Set("oneofname", oneof->name());
+ Formatter format(p);
+ auto v = p->WithVars({{"oneofname", oneof->name()}});
format(
"void $classname$::clear_$oneofname$() {\n"
@@ -3210,10 +3063,10 @@ void MessageGenerator::GenerateOneofClear(io::Printer* printer) {
format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true));
format.Indent();
// We clear only allocated objects in oneofs
- if (!IsStringOrMessage(field) || IsFieldStripped(field, options_)) {
+ if (!IsStringOrMessage(field)) {
format("// No need to clear\n");
} else {
- field_generators_.get(field).GenerateClearingCode(printer);
+ field_generators_.get(field).GenerateClearingCode(p);
}
format("break;\n");
format.Outdent();
@@ -3223,12 +3076,12 @@ void MessageGenerator::GenerateOneofClear(io::Printer* printer) {
"case $1$_NOT_SET: {\n"
" break;\n"
"}\n",
- ToUpper(oneof->name()));
+ y_absl::AsciiStrToUpper(oneof->name()));
format.Outdent();
format(
"}\n"
"$oneof_case$[$1$] = $2$_NOT_SET;\n",
- i, ToUpper(oneof->name()));
+ i, y_absl::AsciiStrToUpper(oneof->name()));
format.Outdent();
format(
"}\n"
@@ -3237,9 +3090,9 @@ void MessageGenerator::GenerateOneofClear(io::Printer* printer) {
}
}
-void MessageGenerator::GenerateSwap(io::Printer* printer) {
+void MessageGenerator::GenerateSwap(io::Printer* p) {
if (HasSimpleBaseClass(descriptor_, options_)) return;
- Formatter format(printer, variables_);
+ Formatter format(p);
format("void $classname$::InternalSwap($classname$* other) {\n");
format.Indent();
@@ -3252,9 +3105,6 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) {
"\n");
}
- std::map<TProtoStringType, TProtoStringType> vars;
- SetUnknownFieldsVariable(descriptor_, options_, &vars);
- format.AddMap(vars);
if (HasNonSplitOptionalString(descriptor_, options_)) {
format(
"auto* lhs_arena = GetArenaForAllocation();\n"
@@ -3272,7 +3122,7 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) {
const RunMap runs =
FindRuns(optimized_order_, [this](const FieldDescriptor* field) {
return !ShouldSplit(field, options_) &&
- CanBeManipulatedAsRawBytes(field, options_, scc_analyzer_);
+ HasTrivialSwap(field, options_, scc_analyzer_);
});
for (size_t i = 0; i < optimized_order_.size(); ++i) {
@@ -3293,8 +3143,10 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) {
const TProtoStringType last_field_name = FieldMemberName(
optimized_order_[i + run_length - 1], /*cold=*/false);
- format.Set("first", first_field_name);
- format.Set("last", last_field_name);
+ auto v = p->WithVars({
+ {"first", first_field_name},
+ {"last", last_field_name},
+ });
format(
"::PROTOBUF_NAMESPACE_ID::internal::memswap<\n"
@@ -3307,7 +3159,7 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) {
i += run_length - 1;
// ++i at the top of the loop.
} else {
- field_generators_.get(field).GenerateSwappingCode(printer);
+ field_generators_.get(field).GenerateSwappingCode(p);
}
}
if (ShouldSplit(descriptor_, options_)) {
@@ -3344,8 +3196,8 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) {
format("}\n");
}
-void MessageGenerator::GenerateMergeFrom(io::Printer* printer) {
- Formatter format(printer, variables_);
+void MessageGenerator::GenerateMergeFrom(io::Printer* p) {
+ Formatter format(p);
if (!HasSimpleBaseClass(descriptor_, options_)) {
if (HasDescriptorMethods(descriptor_->file(), options_)) {
// We don't override the generalized MergeFrom (aka that which
@@ -3391,10 +3243,11 @@ void MessageGenerator::GenerateMergeFrom(io::Printer* printer) {
}
}
-void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* printer) {
+void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* p) {
if (HasSimpleBaseClass(descriptor_, options_)) return;
- // Generate the class-specific MergeFrom, which avoids the GOOGLE_CHECK and cast.
- Formatter format(printer, variables_);
+ // Generate the class-specific MergeFrom, which avoids the Y_ABSL_CHECK and
+ // cast.
+ Formatter format(p);
if (!HasDescriptorMethods(descriptor_->file(), options_)) {
// For messages that don't inherit from Message, just implement MergeFrom
// directly.
@@ -3445,20 +3298,19 @@ void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* printer) {
const std::vector<const FieldDescriptor*>& chunk = chunks[chunk_index];
bool have_outer_if =
chunk.size() > 1 && HasByteIndex(chunk.front()) != kNoHasbit;
- cold_skipper.OnStartChunk(chunk_index, cached_has_word_index, "from.",
- printer);
+ cold_skipper.OnStartChunk(chunk_index, cached_has_word_index, "from.", p);
if (have_outer_if) {
// Emit an if() that will let us skip the whole chunk if none are set.
arc_ui32 chunk_mask = GenChunkMask(chunk, has_bit_indices_);
TProtoStringType chunk_mask_str =
- StrCat(strings::Hex(chunk_mask, strings::ZERO_PAD_8));
+ y_absl::StrCat(y_absl::Hex(chunk_mask, y_absl::kZeroPad8));
// Check (up to) 8 has_bits at a time if we have more than one field in
// this chunk. Due to field layout ordering, we may check
// _has_bits_[last_chunk * 8 / 32] multiple times.
- GOOGLE_DCHECK_LE(2, popcnt(chunk_mask));
- GOOGLE_DCHECK_GE(8, popcnt(chunk_mask));
+ Y_ABSL_DCHECK_LE(2, popcnt(chunk_mask));
+ Y_ABSL_DCHECK_GE(8, popcnt(chunk_mask));
if (cached_has_word_index != HasWordIndex(chunk.front())) {
cached_has_word_index = HasWordIndex(chunk.front());
@@ -3473,16 +3325,16 @@ void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* printer) {
// Go back and emit merging code for each of the fields we processed.
bool deferred_has_bit_changes = false;
for (const auto field : chunk) {
- const FieldGenerator& generator = field_generators_.get(field);
+ const auto& generator = field_generators_.get(field);
if (field->is_repeated()) {
- generator.GenerateMergingCode(printer);
+ generator.GenerateMergingCode(p);
} else if (field->is_optional() && !HasHasbit(field)) {
// Merge semantics without true field presence: primitive fields are
// merged only if non-zero (numeric) or non-empty (string).
bool have_enclosing_if =
- EmitFieldNonDefaultCondition(printer, "from.", field);
- generator.GenerateMergingCode(printer);
+ EmitFieldNonDefaultCondition(p, "from.", field);
+ generator.GenerateMergingCode(p);
if (have_enclosing_if) {
format.Outdent();
format("}\n");
@@ -3490,18 +3342,20 @@ void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* printer) {
} else if (field->options().weak() ||
cached_has_word_index != HasWordIndex(field)) {
// Check hasbit, not using cached bits.
- GOOGLE_CHECK(HasHasbit(field));
- format("if (from._internal_has_$1$()) {\n", FieldName(field));
+ Y_ABSL_CHECK(HasHasbit(field));
+ auto v = p->WithVars(HasbitVars(HasBitIndex(field)));
+ format(
+ "if ((from.$has_bits$[$has_array_index$] & $has_mask$) != 0) {\n");
format.Indent();
- generator.GenerateMergingCode(printer);
+ generator.GenerateMergingCode(p);
format.Outdent();
format("}\n");
} else {
// Check hasbit, using cached bits.
- GOOGLE_CHECK(HasHasbit(field));
+ Y_ABSL_CHECK(HasHasbit(field));
int has_bit_index = has_bit_indices_[field->index()];
- const TProtoStringType mask = StrCat(
- strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8));
+ const TProtoStringType mask = y_absl::StrCat(
+ y_absl::Hex(1u << (has_bit_index % 32), y_absl::kZeroPad8));
format("if (cached_has_bits & 0x$1$u) {\n", mask);
format.Indent();
@@ -3509,9 +3363,9 @@ void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* printer) {
// Defer hasbit modification until the end of chunk.
// This can reduce the number of loads/stores by up to 7 per 8 fields.
deferred_has_bit_changes = true;
- generator.GenerateCopyConstructorCode(printer);
+ generator.GenerateCopyConstructorCode(p);
} else {
- generator.GenerateMergingCode(printer);
+ generator.GenerateMergingCode(p);
}
format.Outdent();
@@ -3522,7 +3376,7 @@ void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* printer) {
if (have_outer_if) {
if (deferred_has_bit_changes) {
// Flush the has bits for the primitives we deferred.
- GOOGLE_CHECK_LE(0, cached_has_word_index);
+ Y_ABSL_CHECK_LE(0, cached_has_word_index);
format("_this->$has_bits$[$1$] |= cached_has_bits;\n",
cached_has_word_index);
}
@@ -3531,7 +3385,7 @@ void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* printer) {
format("}\n");
}
- if (cold_skipper.OnEndChunk(chunk_index, printer)) {
+ if (cold_skipper.OnEndChunk(chunk_index, p)) {
// Reset here as it may have been updated in just closed if statement.
cached_has_word_index = -1;
}
@@ -3544,9 +3398,7 @@ void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* printer) {
for (auto field : FieldRange(oneof)) {
format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true));
format.Indent();
- if (!IsFieldStripped(field, options_)) {
- field_generators_.get(field).GenerateMergingCode(printer);
- }
+ field_generators_.get(field).GenerateMergingCode(p);
format("break;\n");
format.Outdent();
format("}\n");
@@ -3555,7 +3407,7 @@ void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* printer) {
"case $1$_NOT_SET: {\n"
" break;\n"
"}\n",
- ToUpper(oneof->name()));
+ y_absl::AsciiStrToUpper(oneof->name()));
format.Outdent();
format("}\n");
}
@@ -3582,9 +3434,9 @@ void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* printer) {
format("}\n");
}
-void MessageGenerator::GenerateCopyFrom(io::Printer* printer) {
+void MessageGenerator::GenerateCopyFrom(io::Printer* p) {
if (HasSimpleBaseClass(descriptor_, options_)) return;
- Formatter format(printer, variables_);
+ Formatter format(p);
if (HasDescriptorMethods(descriptor_->file(), options_)) {
// We don't override the generalized CopyFrom (aka that which
// takes in the Message base class as a parameter); instead we just
@@ -3613,21 +3465,22 @@ void MessageGenerator::GenerateCopyFrom(io::Printer* printer) {
// It is also disabled if a message has neither message fields nor
// extensions, as it's impossible to copy from its descendant.
//
- // Note that FailIfCopyFromDescendant is implemented by reflection and not
- // available for lite runtime. In that case, check if the size of the source
- // has changed after Clear.
- format("#ifndef NDEBUG\n");
+ // Note that IsDescendant is implemented by reflection and not available for
+ // lite runtime. In that case, check if the size of the source has changed
+ // after Clear.
if (HasDescriptorMethods(descriptor_->file(), options_)) {
- format("FailIfCopyFromDescendant(*this, from);\n");
+ format(
+ "$DCHK$(!::_pbi::IsDescendant(*this, from))\n"
+ " << \"Source of CopyFrom cannot be a descendant of the "
+ "target.\";\n"
+ "Clear();\n");
} else {
- format("size_t from_size = from.ByteSizeLong();\n");
- }
- format(
- "#endif\n"
- "Clear();\n");
- if (!HasDescriptorMethods(descriptor_->file(), options_)) {
format(
"#ifndef NDEBUG\n"
+ "::size_t from_size = from.ByteSizeLong();\n"
+ "#endif\n"
+ "Clear();\n"
+ "#ifndef NDEBUG\n"
"$CHK$_EQ(from_size, from.ByteSizeLong())\n"
" << \"Source of CopyFrom changed when clearing target. Either \"\n"
" \"source is a nested message in target (not allowed), or \"\n"
@@ -3643,15 +3496,15 @@ void MessageGenerator::GenerateCopyFrom(io::Printer* printer) {
format("}\n");
}
-void MessageGenerator::GenerateVerify(io::Printer* printer) {
+void MessageGenerator::GenerateVerify(io::Printer* p) {
}
void MessageGenerator::GenerateSerializeOneofFields(
- io::Printer* printer, const std::vector<const FieldDescriptor*>& fields) {
- Formatter format(printer, variables_);
- GOOGLE_CHECK(!fields.empty());
+ io::Printer* p, const std::vector<const FieldDescriptor*>& fields) {
+ Formatter format(p);
+ Y_ABSL_CHECK(!fields.empty());
if (fields.size() == 1) {
- GenerateSerializeOneField(printer, fields[0], -1);
+ GenerateSerializeOneField(p, fields[0], -1);
return;
}
// We have multiple mutually exclusive choices. Emit a switch statement.
@@ -3661,8 +3514,7 @@ void MessageGenerator::GenerateSerializeOneofFields(
for (auto field : fields) {
format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true));
format.Indent();
- field_generators_.get(field).GenerateSerializeWithCachedSizesToArray(
- printer);
+ field_generators_.get(field).GenerateSerializeWithCachedSizesToArray(p);
format("break;\n");
format.Outdent();
format("}\n");
@@ -3674,10 +3526,11 @@ void MessageGenerator::GenerateSerializeOneofFields(
"}\n");
}
-void MessageGenerator::GenerateSerializeOneField(io::Printer* printer,
+void MessageGenerator::GenerateSerializeOneField(io::Printer* p,
const FieldDescriptor* field,
int cached_has_bits_index) {
- Formatter format(printer, variables_);
+ auto v = p->WithVars(FieldVars(field, options_));
+ Formatter format(p);
if (!field->options().weak()) {
// For weakfields, PrintFieldComment is called during iteration.
PrintFieldComment(format, field);
@@ -3688,22 +3541,20 @@ void MessageGenerator::GenerateSerializeOneField(io::Printer* printer,
} else if (HasHasbit(field)) {
// Attempt to use the state of cached_has_bits, if possible.
int has_bit_index = HasBitIndex(field);
+ auto v = p->WithVars(HasbitVars(has_bit_index));
if (cached_has_bits_index == has_bit_index / 32) {
- const TProtoStringType mask =
- StrCat(strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8));
-
- format("if (cached_has_bits & 0x$1$u) {\n", mask);
+ format("if (cached_has_bits & $has_mask$) {\n");
} else {
- format("if (_internal_has_$1$()) {\n", FieldName(field));
+ field_generators_.get(field).GenerateIfHasField(p);
}
format.Indent();
have_enclosing_if = true;
} else if (field->is_optional() && !HasHasbit(field)) {
- have_enclosing_if = EmitFieldNonDefaultCondition(printer, "this->", field);
+ have_enclosing_if = EmitFieldNonDefaultCondition(p, "this->", field);
}
- field_generators_.get(field).GenerateSerializeWithCachedSizesToArray(printer);
+ field_generators_.get(field).GenerateSerializeWithCachedSizesToArray(p);
if (have_enclosing_if) {
format.Outdent();
@@ -3713,21 +3564,20 @@ void MessageGenerator::GenerateSerializeOneField(io::Printer* printer,
}
void MessageGenerator::GenerateSerializeOneExtensionRange(
- io::Printer* printer, const Descriptor::ExtensionRange* range) {
- std::map<TProtoStringType, TProtoStringType> vars = variables_;
- vars["start"] = StrCat(range->start);
- vars["end"] = StrCat(range->end);
- Formatter format(printer, vars);
+ io::Printer* p, const Descriptor::ExtensionRange* range) {
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars = variables_;
+ vars["start"] = y_absl::StrCat(range->start);
+ vars["end"] = y_absl::StrCat(range->end);
+ Formatter format(p, vars);
format("// Extension range [$start$, $end$)\n");
format(
"target = $extensions$._InternalSerialize(\n"
"internal_default_instance(), $start$, $end$, target, stream);\n\n");
}
-void MessageGenerator::GenerateSerializeWithCachedSizesToArray(
- io::Printer* printer) {
+void MessageGenerator::GenerateSerializeWithCachedSizesToArray(io::Printer* p) {
if (HasSimpleBaseClass(descriptor_, options_)) return;
- Formatter format(printer, variables_);
+ Formatter format(p);
if (descriptor_->options().message_set_wire_format()) {
// Special-case MessageSet.
format(
@@ -3738,9 +3588,7 @@ void MessageGenerator::GenerateSerializeWithCachedSizesToArray(
" target = $extensions$."
"InternalSerializeMessageSetWithCachedSizesToArray(\n" //
"internal_default_instance(), target, stream);\n");
- std::map<TProtoStringType, TProtoStringType> vars;
- SetUnknownFieldsVariable(descriptor_, options_, &vars);
- format.AddMap(vars);
+
format(
" target = ::_pbi::"
"InternalSerializeUnknownMessageSetItemsToArray(\n"
@@ -3766,14 +3614,14 @@ void MessageGenerator::GenerateSerializeWithCachedSizesToArray(
format.Indent();
}
- GenerateSerializeWithCachedSizesBody(printer);
+ GenerateSerializeWithCachedSizesBody(p);
if (!ShouldSerializeInOrder(descriptor_, options_)) {
format.Outdent();
format("#else // NDEBUG\n");
format.Indent();
- GenerateSerializeWithCachedSizesBodyShuffled(printer);
+ GenerateSerializeWithCachedSizesBodyShuffled(p);
format.Outdent();
format("#endif // !NDEBUG\n");
@@ -3788,10 +3636,9 @@ void MessageGenerator::GenerateSerializeWithCachedSizesToArray(
"}\n");
}
-void MessageGenerator::GenerateSerializeWithCachedSizesBody(
- io::Printer* printer) {
+void MessageGenerator::GenerateSerializeWithCachedSizesBody(io::Printer* p) {
if (HasSimpleBaseClass(descriptor_, options_)) return;
- Formatter format(printer, variables_);
+ Formatter format(p);
// If there are multiple fields in a row from the same oneof then we
// coalesce them and emit a switch statement. This is more efficient
// because it lets the C++ compiler know this is a "at most one can happen"
@@ -3799,9 +3646,9 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
// compiler's emitted code might check has_y() even when has_x() is true.
class LazySerializerEmitter {
public:
- LazySerializerEmitter(MessageGenerator* mg, io::Printer* printer)
+ LazySerializerEmitter(MessageGenerator* mg, io::Printer* p)
: mg_(mg),
- format_(printer),
+ p_(p),
eager_(IsProto3(mg->descriptor_->file())),
cached_has_bit_index_(kNoHasbit) {}
@@ -3810,6 +3657,7 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
// If conditions allow, try to accumulate a run of fields from the same
// oneof, and handle them at the next Flush().
void Emit(const FieldDescriptor* field) {
+ Formatter format(p_);
if (eager_ || MustFlush(field)) {
Flush();
}
@@ -3825,14 +3673,13 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
// Reload.
int new_index = has_bit_index / 32;
- format_("cached_has_bits = _impl_._has_bits_[$1$];\n", new_index);
+ format("cached_has_bits = _impl_._has_bits_[$1$];\n", new_index);
cached_has_bit_index_ = new_index;
}
}
- mg_->GenerateSerializeOneField(format_.printer(), field,
- cached_has_bit_index_);
+ mg_->GenerateSerializeOneField(p_, field, cached_has_bit_index_);
} else {
v_.push_back(field);
}
@@ -3846,7 +3693,7 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
void Flush() {
if (!v_.empty()) {
- mg_->GenerateSerializeOneofFields(format_.printer(), v_);
+ mg_->GenerateSerializeOneofFields(p_, v_);
v_.clear();
}
}
@@ -3860,8 +3707,8 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
}
MessageGenerator* mg_;
- Formatter format_;
- const bool eager_;
+ io::Printer* p_;
+ bool eager_;
std::vector<const FieldDescriptor*> v_;
// cached_has_bit_index_ maintains that:
@@ -3872,8 +3719,8 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
class LazyExtensionRangeEmitter {
public:
- LazyExtensionRangeEmitter(MessageGenerator* mg, io::Printer* printer)
- : mg_(mg), format_(printer) {}
+ LazyExtensionRangeEmitter(MessageGenerator* mg, io::Printer* p)
+ : mg_(mg), p_(p) {}
void AddToRange(const Descriptor::ExtensionRange* range) {
if (!has_current_range_) {
@@ -3889,15 +3736,14 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
void Flush() {
if (has_current_range_) {
- mg_->GenerateSerializeOneExtensionRange(format_.printer(),
- &current_combined_range_);
+ mg_->GenerateSerializeOneExtensionRange(p_, &current_combined_range_);
}
has_current_range_ = false;
}
private:
MessageGenerator* mg_;
- Formatter format_;
+ io::Printer* p_;
bool has_current_range_ = false;
Descriptor::ExtensionRange current_combined_range_;
};
@@ -3947,8 +3793,8 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
// Merge the fields and the extension ranges, both sorted by field number.
{
- LazySerializerEmitter e(this, printer);
- LazyExtensionRangeEmitter re(this, printer);
+ LazySerializerEmitter e(this, p);
+ LazyExtensionRangeEmitter re(this, p);
LargestWeakFieldHolder largest_weak_field;
int i, j;
for (i = 0, j = 0;
@@ -3957,9 +3803,6 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
(i < descriptor_->field_count() &&
ordered_fields[i]->number() < sorted_extensions[j]->start)) {
const FieldDescriptor* field = ordered_fields[i++];
- if (IsFieldStripped(field, options_)) {
- continue;
- }
re.Flush();
if (field->options().weak()) {
largest_weak_field.ReplaceIfLarger(field);
@@ -3978,9 +3821,6 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
e.EmitIfNotNull(largest_weak_field.Release());
}
- std::map<TProtoStringType, TProtoStringType> vars;
- SetUnknownFieldsVariable(descriptor_, options_, &vars);
- format.AddMap(vars);
format("if (PROTOBUF_PREDICT_FALSE($have_unknown_fields$)) {\n");
format.Indent();
if (UseUnknownFieldSet(descriptor_->file(), options_)) {
@@ -3999,8 +3839,8 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
}
void MessageGenerator::GenerateSerializeWithCachedSizesBodyShuffled(
- io::Printer* printer) {
- Formatter format(printer, variables_);
+ io::Printer* p) {
+ Formatter format(p);
std::vector<const FieldDescriptor*> ordered_fields =
SortFieldsByNumber(descriptor_);
@@ -4021,7 +3861,7 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBodyShuffled(
int num_fields = ordered_fields.size() + sorted_extensions.size();
constexpr int kLargePrime = 1000003;
- GOOGLE_CHECK_LT(num_fields, kLargePrime)
+ Y_ABSL_CHECK_LT(num_fields, kLargePrime)
<< "Prime offset must be greater than the number of fields to ensure "
"those are coprime.";
@@ -4042,7 +3882,7 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBodyShuffled(
format("case $1$: {\n", index++);
format.Indent();
- GenerateSerializeOneField(printer, f, -1);
+ GenerateSerializeOneField(p, f, -1);
format("break;\n");
format.Outdent();
@@ -4053,7 +3893,7 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBodyShuffled(
format("case $1$: {\n", index++);
format.Indent();
- GenerateSerializeOneExtensionRange(printer, r);
+ GenerateSerializeOneExtensionRange(p, r);
format("break;\n");
format.Outdent();
@@ -4070,9 +3910,6 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBodyShuffled(
format.Outdent();
format("}\n");
- std::map<TProtoStringType, TProtoStringType> vars;
- SetUnknownFieldsVariable(descriptor_, options_, &vars);
- format.AddMap(vars);
format("if (PROTOBUF_PREDICT_FALSE($have_unknown_fields$)) {\n");
format.Indent();
if (UseUnknownFieldSet(descriptor_->file(), options_)) {
@@ -4106,20 +3943,17 @@ std::vector<arc_ui32> MessageGenerator::RequiredFieldsBitMask() const {
return masks;
}
-void MessageGenerator::GenerateByteSize(io::Printer* printer) {
+void MessageGenerator::GenerateByteSize(io::Printer* p) {
if (HasSimpleBaseClass(descriptor_, options_)) return;
- Formatter format(printer, variables_);
+ Formatter format(p);
if (descriptor_->options().message_set_wire_format()) {
// Special-case MessageSet.
- std::map<TProtoStringType, TProtoStringType> vars;
- SetUnknownFieldsVariable(descriptor_, options_, &vars);
- format.AddMap(vars);
format(
- "size_t $classname$::ByteSizeLong() const {\n"
+ "::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 += ::_pbi::\n"
" ComputeUnknownMessageSetItemsSize($unknown_fields$);\n"
@@ -4136,20 +3970,18 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
// Emit a function (rarely used, we hope) that handles the required fields
// by checking for each one individually.
format(
- "size_t $classname$::RequiredFieldsByteSizeFallback() const {\n"
+ "::size_t $classname$::RequiredFieldsByteSizeFallback() const {\n"
"// @@protoc_insertion_point(required_fields_byte_size_fallback_start:"
"$full_name$)\n");
format.Indent();
- format("size_t total_size = 0;\n");
+ format("::size_t total_size = 0;\n");
for (auto field : optimized_order_) {
if (field->is_required()) {
- format(
- "\n"
- "if (_internal_has_$1$()) {\n",
- FieldName(field));
+ format("\n");
+ field_generators_.get(field).GenerateIfHasField(p);
format.Indent();
PrintFieldComment(format, field);
- field_generators_.get(field).GenerateByteSize(printer);
+ field_generators_.get(field).GenerateByteSize(p);
format.Outdent();
format("}\n");
}
@@ -4162,12 +3994,12 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
}
format(
- "size_t $classname$::ByteSizeLong() const {\n"
+ "::size_t $classname$::ByteSizeLong() const {\n"
"$annotate_bytesize$"
"// @@protoc_insertion_point(message_byte_size_start:$full_name$)\n");
format.Indent();
format(
- "size_t total_size = 0;\n"
+ "::size_t total_size = 0;\n"
"\n");
if (descriptor_->extension_range_count() > 0) {
@@ -4176,10 +4008,6 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
"\n");
}
- std::map<TProtoStringType, TProtoStringType> vars;
- SetUnknownFieldsVariable(descriptor_, options_, &vars);
- format.AddMap(vars);
-
// Handle required fields (if any). We expect all of them to be
// present, so emit one conditional that checks for that. If they are all
// present then the fast path executes; otherwise the slow path executes.
@@ -4194,7 +4022,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
for (auto field : optimized_order_) {
if (!field->is_required()) continue;
PrintFieldComment(format, field);
- field_generators_.get(field).GenerateByteSize(printer);
+ field_generators_.get(field).GenerateByteSize(p);
format("\n");
}
format.Outdent();
@@ -4207,9 +4035,9 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
for (auto field : optimized_order_) {
if (!field->is_required()) continue;
PrintFieldComment(format, field);
- format("if (_internal_has_$1$()) {\n", FieldName(field));
+ field_generators_.get(field).GenerateIfHasField(p);
format.Indent();
- field_generators_.get(field).GenerateByteSize(printer);
+ field_generators_.get(field).GenerateByteSize(p);
format.Outdent();
format("}\n");
}
@@ -4239,19 +4067,19 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
const std::vector<const FieldDescriptor*>& chunk = chunks[chunk_index];
const bool have_outer_if =
chunk.size() > 1 && HasWordIndex(chunk[0]) != kNoHasbit;
- cold_skipper.OnStartChunk(chunk_index, cached_has_word_index, "", printer);
+ cold_skipper.OnStartChunk(chunk_index, cached_has_word_index, "", p);
if (have_outer_if) {
// Emit an if() that will let us skip the whole chunk if none are set.
arc_ui32 chunk_mask = GenChunkMask(chunk, has_bit_indices_);
TProtoStringType chunk_mask_str =
- StrCat(strings::Hex(chunk_mask, strings::ZERO_PAD_8));
+ y_absl::StrCat(y_absl::Hex(chunk_mask, y_absl::kZeroPad8));
// Check (up to) 8 has_bits at a time if we have more than one field in
// this chunk. Due to field layout ordering, we may check
// _has_bits_[last_chunk * 8 / 32] multiple times.
- GOOGLE_DCHECK_LE(2, popcnt(chunk_mask));
- GOOGLE_DCHECK_GE(8, popcnt(chunk_mask));
+ Y_ABSL_DCHECK_LE(2, popcnt(chunk_mask));
+ Y_ABSL_DCHECK_GE(8, popcnt(chunk_mask));
if (cached_has_word_index != HasWordIndex(chunk.front())) {
cached_has_word_index = HasWordIndex(chunk.front());
@@ -4264,7 +4092,6 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
// Go back and emit checks for each of the fields we processed.
for (int j = 0; j < chunk.size(); j++) {
const FieldDescriptor* field = chunk[j];
- const FieldGenerator& generator = field_generators_.get(field);
bool have_enclosing_if = false;
bool need_extra_newline = false;
@@ -4274,17 +4101,15 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
// No presence check is required.
need_extra_newline = true;
} else if (HasHasbit(field)) {
- PrintPresenceCheck(format, field, has_bit_indices_, printer,
- &cached_has_word_index);
+ PrintPresenceCheck(field, has_bit_indices_, p, &cached_has_word_index);
have_enclosing_if = true;
} else {
// Without field presence: field is serialized only if it has a
// non-default value.
- have_enclosing_if =
- EmitFieldNonDefaultCondition(printer, "this->", field);
+ have_enclosing_if = EmitFieldNonDefaultCondition(p, "this->", field);
}
- generator.GenerateByteSize(printer);
+ field_generators_.get(field).GenerateByteSize(p);
if (have_enclosing_if) {
format.Outdent();
@@ -4302,7 +4127,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
format("}\n");
}
- if (cold_skipper.OnEndChunk(chunk_index, printer)) {
+ if (cold_skipper.OnEndChunk(chunk_index, p)) {
// Reset here as it may have been updated in just closed if statement.
cached_has_word_index = -1;
}
@@ -4317,9 +4142,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
PrintFieldComment(format, field);
format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true));
format.Indent();
- if (!IsFieldStripped(field, options_)) {
- field_generators_.get(field).GenerateByteSize(printer);
- }
+ field_generators_.get(field).GenerateByteSize(p);
format("break;\n");
format.Outdent();
format("}\n");
@@ -4328,7 +4151,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
"case $1$_NOT_SET: {\n"
" break;\n"
"}\n",
- ToUpper(oneof->name()));
+ y_absl::AsciiStrToUpper(oneof->name()));
format.Outdent();
format("}\n");
}
@@ -4367,15 +4190,15 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
format("}\n");
}
-void MessageGenerator::GenerateIsInitialized(io::Printer* printer) {
+void MessageGenerator::GenerateIsInitialized(io::Printer* p) {
if (HasSimpleBaseClass(descriptor_, options_)) return;
- Formatter format(printer, variables_);
+ Formatter format(p);
format("bool $classname$::IsInitialized() const {\n");
format.Indent();
if (descriptor_->extension_range_count() > 0) {
format(
- "if (!$extensions$.IsInitialized()) {\n"
+ "if (!$extensions$.IsInitialized(internal_default_instance())) {\n"
" return false;\n"
"}\n\n");
}
@@ -4388,7 +4211,7 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) {
// Now check that all non-oneof embedded messages are initialized.
for (auto field : optimized_order_) {
- field_generators_.get(field).GenerateIsInitialized(printer);
+ field_generators_.get(field).GenerateIsInitialized(p);
}
if (num_weak_fields_) {
// For Weak fields.
@@ -4416,9 +4239,7 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) {
for (auto field : FieldRange(oneof)) {
format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true));
format.Indent();
- if (!IsFieldStripped(field, options_)) {
- field_generators_.get(field).GenerateIsInitialized(printer);
- }
+ field_generators_.get(field).GenerateIsInitialized(p);
format("break;\n");
format.Outdent();
format("}\n");
@@ -4427,7 +4248,7 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) {
"case $1$_NOT_SET: {\n"
" break;\n"
"}\n",
- ToUpper(oneof->name()));
+ y_absl::AsciiStrToUpper(oneof->name()));
format.Outdent();
format("}\n");
}
@@ -4443,4 +4264,4 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message.h
index 960bea8e5af..f1dcd65ef20 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message.h
@@ -36,40 +36,38 @@
#define GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__
#include <cstdint>
+#include <limits>
#include <memory>
-#include <set>
#include <string>
-
-#include <google/protobuf/compiler/cpp/field.h>
-#include <google/protobuf/compiler/cpp/helpers.h>
-#include <google/protobuf/compiler/cpp/message_layout_helper.h>
-#include <google/protobuf/compiler/cpp/options.h>
-#include <google/protobuf/compiler/cpp/parse_function_generator.h>
-
-namespace google {
-namespace protobuf {
-namespace io {
-class Printer; // printer.h
-}
-} // namespace protobuf
-} // namespace google
+#include <utility>
+#include <vector>
+
+#include "y_absl/container/flat_hash_map.h"
+#include "google/protobuf/compiler/cpp/enum.h"
+#include "google/protobuf/compiler/cpp/extension.h"
+#include "google/protobuf/compiler/cpp/field.h"
+#include "google/protobuf/compiler/cpp/helpers.h"
+#include "google/protobuf/compiler/cpp/message_layout_helper.h"
+#include "google/protobuf/compiler/cpp/options.h"
+#include "google/protobuf/compiler/cpp/parse_function_generator.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
namespace compiler {
namespace cpp {
-
-class EnumGenerator; // enum.h
-class ExtensionGenerator; // extension.h
-
class MessageGenerator {
public:
- // See generator.cc for the meaning of dllexport_decl.
- MessageGenerator(const Descriptor* descriptor,
- const std::map<TProtoStringType, TProtoStringType>& vars,
- int index_in_file_messages, const Options& options,
- MessageSCCAnalyzer* scc_analyzer);
- ~MessageGenerator();
+ MessageGenerator(
+ const Descriptor* descriptor,
+ const y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>& ignored,
+ int index_in_file_messages, const Options& options,
+ MessageSCCAnalyzer* scc_analyzer);
+
+ MessageGenerator(const MessageGenerator&) = delete;
+ MessageGenerator& operator=(const MessageGenerator&) = delete;
+
+ ~MessageGenerator() = default;
// Append the two types of nested generators to the corresponding vector.
void AddGenerators(
@@ -77,95 +75,94 @@ class MessageGenerator {
std::vector<std::unique_ptr<ExtensionGenerator>>* extension_generators);
// Generate definitions for this class and all its nested types.
- void GenerateClassDefinition(io::Printer* printer);
+ void GenerateClassDefinition(io::Printer* p);
// Generate definitions of inline methods (placed at the end of the header
// file).
- void GenerateInlineMethods(io::Printer* printer);
-
- // Source file stuff.
+ void GenerateInlineMethods(io::Printer* p);
// Generate all non-inline methods for this class.
- void GenerateClassMethods(io::Printer* printer);
+ void GenerateClassMethods(io::Printer* p);
// Generate source file code that should go outside any namespace.
- void GenerateSourceInProto2Namespace(io::Printer* printer);
+ void GenerateSourceInProto2Namespace(io::Printer* p);
- private:
- // Generate declarations and definitions of accessors for fields.
- void GenerateFieldAccessorDeclarations(io::Printer* printer);
- void GenerateFieldAccessorDefinitions(io::Printer* printer);
+
+ void GenerateInitDefaultSplitInstance(io::Printer* p);
+
+ // Generate the constexpr constructor for constant initialization of the
+ // default instance.
+ void GenerateConstexprConstructor(io::Printer* p);
+
+ void GenerateSchema(io::Printer* p, int offset, int has_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);
+ std::pair<size_t, size_t> GenerateOffsets(io::Printer* p);
+
+ const Descriptor* descriptor() const { return descriptor_; }
+
+ private:
+ // Generate declarations and definitions of accessors for fields.
+ void GenerateFieldAccessorDeclarations(io::Printer* p);
+ void GenerateFieldAccessorDefinitions(io::Printer* p);
// Generate constructors and destructor.
- void GenerateStructors(io::Printer* printer);
+ void GenerateStructors(io::Printer* p);
// The compiler typically generates multiple copies of each constructor and
// destructor: http://gcc.gnu.org/bugs.html#nonbugs_cxx
// Placing common code in a separate method reduces the generated code size.
//
// Generate the shared constructor code.
- void GenerateSharedConstructorCode(io::Printer* printer);
+ void GenerateSharedConstructorCode(io::Printer* p);
// Generate the shared destructor code.
- void GenerateSharedDestructorCode(io::Printer* printer);
+ void GenerateSharedDestructorCode(io::Printer* p);
// Generate the arena-specific destructor code.
- void GenerateArenaDestructorCode(io::Printer* printer);
-
- // Generate the constexpr constructor for constant initialization of the
- // default instance.
- void GenerateConstexprConstructor(io::Printer* printer);
-
- void GenerateCreateSplitMessage(io::Printer* printer);
- void GenerateInitDefaultSplitInstance(io::Printer* printer);
+ void GenerateArenaDestructorCode(io::Printer* p);
// Generate standard Message methods.
- void GenerateClear(io::Printer* printer);
- void GenerateOneofClear(io::Printer* printer);
- void GenerateVerify(io::Printer* printer);
- void GenerateSerializeWithCachedSizes(io::Printer* printer);
- void GenerateSerializeWithCachedSizesToArray(io::Printer* printer);
- void GenerateSerializeWithCachedSizesBody(io::Printer* printer);
- void GenerateSerializeWithCachedSizesBodyShuffled(io::Printer* printer);
- void GenerateByteSize(io::Printer* printer);
- void GenerateMergeFrom(io::Printer* printer);
- void GenerateClassSpecificMergeImpl(io::Printer* printer);
- void GenerateCopyFrom(io::Printer* printer);
- void GenerateSwap(io::Printer* printer);
- void GenerateIsInitialized(io::Printer* printer);
+ void GenerateClear(io::Printer* p);
+ void GenerateOneofClear(io::Printer* p);
+ void GenerateVerify(io::Printer* p);
+ void GenerateSerializeWithCachedSizes(io::Printer* p);
+ void GenerateSerializeWithCachedSizesToArray(io::Printer* p);
+ void GenerateSerializeWithCachedSizesBody(io::Printer* p);
+ void GenerateSerializeWithCachedSizesBodyShuffled(io::Printer* p);
+ void GenerateByteSize(io::Printer* p);
+ void GenerateMergeFrom(io::Printer* p);
+ void GenerateClassSpecificMergeImpl(io::Printer* p);
+ void GenerateCopyFrom(io::Printer* p);
+ void GenerateSwap(io::Printer* p);
+ void GenerateIsInitialized(io::Printer* p);
// Helpers for GenerateSerializeWithCachedSizes().
//
// cached_has_bit_index maintains that:
// cached_has_bits = _has_bits_[cached_has_bit_index]
// for cached_has_bit_index >= 0
- void GenerateSerializeOneField(io::Printer* printer,
- const FieldDescriptor* field,
+ void GenerateSerializeOneField(io::Printer* p, const FieldDescriptor* field,
int cached_has_bits_index);
// Generate a switch statement to serialize 2+ fields from the same oneof.
// Or, if fields.size() == 1, just call GenerateSerializeOneField().
void GenerateSerializeOneofFields(
- io::Printer* printer, const std::vector<const FieldDescriptor*>& fields);
+ io::Printer* p, const std::vector<const FieldDescriptor*>& fields);
void GenerateSerializeOneExtensionRange(
- io::Printer* printer, const Descriptor::ExtensionRange* range);
+ io::Printer* p, const Descriptor::ExtensionRange* range);
// Generates has_foo() functions and variables for singular field has-bits.
void GenerateSingularFieldHasBits(const FieldDescriptor* field,
- Formatter format);
+ io::Printer* p);
// Generates has_foo() functions and variables for oneof field has-bits.
- void GenerateOneofHasBits(io::Printer* printer);
+ void GenerateOneofHasBits(io::Printer* p);
// Generates has_foo_bar() functions for oneof members.
- void GenerateOneofMemberHasBits(const FieldDescriptor* field,
- const Formatter& format);
+ void GenerateOneofMemberHasBits(const FieldDescriptor* field, io::Printer* p);
// Generates the clear_foo() method for a field.
void GenerateFieldClear(const FieldDescriptor* field, bool is_inline,
- Formatter format);
+ io::Printer* p);
// Generates the body of the message's copy constructor.
- void GenerateCopyConstructorBody(io::Printer* printer) const;
+ void GenerateCopyConstructorBody(io::Printer* p) const;
// Returns the level that this message needs ArenaDtor. If the message has
// a field that is not arena-exclusive, it needs an ArenaDtor
@@ -181,17 +178,15 @@ class MessageGenerator {
size_t HasBitsSize() const;
size_t InlinedStringDonatedSize() const;
- int HasBitIndex(const FieldDescriptor* a) const;
- int HasByteIndex(const FieldDescriptor* a) const;
- int HasWordIndex(const FieldDescriptor* a) const;
- bool SameHasByte(const FieldDescriptor* a, const FieldDescriptor* b) const;
+ int HasBitIndex(const FieldDescriptor* field) const;
+ int HasByteIndex(const FieldDescriptor* field) const;
+ int HasWordIndex(const FieldDescriptor* field) const;
std::vector<arc_ui32> RequiredFieldsBitMask() const;
const Descriptor* descriptor_;
int index_in_file_messages_;
- TProtoStringType classname_;
Options options_;
- FieldGeneratorMap field_generators_;
+ FieldGeneratorTable field_generators_;
// optimized_order_ is the order we layout the message's fields in the
// class. This is reused to initialize the fields in-order for cache
// efficiency.
@@ -199,29 +194,27 @@ class MessageGenerator {
// optimized_order_ excludes oneof fields and weak fields.
std::vector<const FieldDescriptor*> optimized_order_;
std::vector<int> has_bit_indices_;
- int max_has_bit_index_;
+ int max_has_bit_index_ = 0;
// A map from field index to inlined_string index. For non-inlined-string
// 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_;
+ int max_inlined_string_index_ = 0;
std::vector<const EnumGenerator*> enum_generators_;
std::vector<const ExtensionGenerator*> extension_generators_;
- int num_required_fields_;
- int num_weak_fields_;
+ int num_required_fields_ = 0;
+ int num_weak_fields_ = 0;
std::unique_ptr<MessageLayoutHelper> message_layout_helper_;
std::unique_ptr<ParseFunctionGenerator> parse_function_generator_;
MessageSCCAnalyzer* scc_analyzer_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables_;
- friend class FileGenerator;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator);
};
} // namespace cpp
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message_field.h
deleted file mode 100644
index 70c42c0eacc..00000000000
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message_field.h
+++ /dev/null
@@ -1,148 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_FIELD_H__
-#define GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_FIELD_H__
-
-#include <map>
-#include <string>
-
-#include <google/protobuf/compiler/cpp/field.h>
-#include <google/protobuf/compiler/cpp/helpers.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-class MessageFieldGenerator : public FieldGenerator {
- public:
- MessageFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options,
- MessageSCCAnalyzer* scc_analyzer);
- ~MessageFieldGenerator() override;
-
- // implements FieldGenerator ---------------------------------------
- void GeneratePrivateMembers(io::Printer* printer) const override;
- void GenerateAccessorDeclarations(io::Printer* printer) const override;
- void GenerateInlineAccessorDefinitions(io::Printer* printer) const override;
- void GenerateNonInlineAccessorDefinitions(
- io::Printer* printer) const override;
- void GenerateInternalAccessorDeclarations(
- io::Printer* printer) const override;
- void GenerateInternalAccessorDefinitions(io::Printer* printer) const override;
- void GenerateClearingCode(io::Printer* printer) const override;
- void GenerateMessageClearingCode(io::Printer* printer) const override;
- void GenerateMergingCode(io::Printer* printer) const override;
- void GenerateSwappingCode(io::Printer* printer) const override;
- void GenerateDestructorCode(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;
- void GenerateIsInitialized(io::Printer* printer) const override;
- void GenerateConstexprAggregateInitializer(
- io::Printer* printer) const override;
- void GenerateAggregateInitializer(io::Printer* printer) const override;
- void GenerateCopyAggregateInitializer(io::Printer* printer) const override;
-
- protected:
- const bool implicit_weak_field_;
- const bool has_required_fields_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator);
-};
-
-class MessageOneofFieldGenerator : public MessageFieldGenerator {
- public:
- MessageOneofFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options,
- MessageSCCAnalyzer* scc_analyzer);
- ~MessageOneofFieldGenerator() override;
-
- // implements FieldGenerator ---------------------------------------
- void GenerateInlineAccessorDefinitions(io::Printer* printer) const override;
- void GenerateNonInlineAccessorDefinitions(
- io::Printer* printer) const override;
- void GenerateClearingCode(io::Printer* printer) const override;
-
- // MessageFieldGenerator, from which we inherit, overrides this so we need to
- // override it as well.
- void GenerateMessageClearingCode(io::Printer* printer) const override;
- void GenerateSwappingCode(io::Printer* printer) const override;
- void GenerateDestructorCode(io::Printer* printer) const override;
- void GenerateConstructorCode(io::Printer* printer) const override;
- void GenerateIsInitialized(io::Printer* printer) const override;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageOneofFieldGenerator);
-};
-
-class RepeatedMessageFieldGenerator : public FieldGenerator {
- public:
- RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options,
- MessageSCCAnalyzer* scc_analyzer);
- ~RepeatedMessageFieldGenerator() override;
-
- // implements FieldGenerator ---------------------------------------
- void GeneratePrivateMembers(io::Printer* printer) const override;
- void GenerateAccessorDeclarations(io::Printer* printer) const override;
- void GenerateInlineAccessorDefinitions(io::Printer* printer) const override;
- 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 GenerateDestructorCode(io::Printer* printer) const override;
- void GenerateSerializeWithCachedSizesToArray(
- io::Printer* printer) const override;
- void GenerateByteSize(io::Printer* printer) const override;
- void GenerateIsInitialized(io::Printer* printer) const override;
-
- private:
- const bool implicit_weak_field_;
- const bool has_required_fields_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator);
-};
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_FIELD_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message_layout_helper.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message_layout_helper.h
index a8813a1f225..7727e674663 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message_layout_helper.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/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/descriptor.h>
-#include <google/protobuf/compiler/cpp/options.h>
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/compiler/cpp/options.h"
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/names.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/names.h
index 8220f7dde8c..438b27e3d24 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/names.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/names.h
@@ -33,8 +33,10 @@
#include <string>
+#include "y_absl/strings/string_view.h"
+
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -43,10 +45,23 @@ class Descriptor;
class EnumDescriptor;
class EnumValueDescriptor;
class FieldDescriptor;
+class FileDescriptor;
namespace compiler {
namespace cpp {
+// Returns the fully qualified C++ namespace.
+//
+// For example, if you had:
+// package foo.bar;
+// message Baz { message Moo {} }
+// Then the qualified namespace for Moo would be:
+// ::foo::bar
+PROTOC_EXPORT TProtoStringType Namespace(const FileDescriptor* d);
+PROTOC_EXPORT TProtoStringType Namespace(const Descriptor* d);
+PROTOC_EXPORT TProtoStringType Namespace(const FieldDescriptor* d);
+PROTOC_EXPORT TProtoStringType Namespace(const EnumDescriptor* d);
+
// Returns the unqualified C++ name.
//
// For example, if you had:
@@ -54,8 +69,8 @@ namespace cpp {
// message Baz { message Moo {} }
// Then the non-qualified version would be:
// Baz_Moo
-TProtoStringType ClassName(const Descriptor* descriptor);
-TProtoStringType ClassName(const EnumDescriptor* enum_descriptor);
+PROTOC_EXPORT TProtoStringType ClassName(const Descriptor* descriptor);
+PROTOC_EXPORT TProtoStringType ClassName(const EnumDescriptor* enum_descriptor);
// Returns the fully qualified C++ name.
//
@@ -64,34 +79,35 @@ TProtoStringType ClassName(const EnumDescriptor* enum_descriptor);
// message Baz { message Moo {} }
// Then the qualified ClassName for Moo would be:
// ::foo::bar::Baz_Moo
-TProtoStringType QualifiedClassName(const Descriptor* d);
-TProtoStringType QualifiedClassName(const EnumDescriptor* d);
-TProtoStringType QualifiedExtensionName(const FieldDescriptor* d);
+PROTOC_EXPORT TProtoStringType QualifiedClassName(const Descriptor* d);
+PROTOC_EXPORT TProtoStringType QualifiedClassName(const EnumDescriptor* d);
+PROTOC_EXPORT TProtoStringType QualifiedExtensionName(const FieldDescriptor* d);
// Get the (unqualified) name that should be used for this field in C++ code.
// The name is coerced to lower-case to emulate proto1 behavior. People
// should be using lowercase-with-underscores style for proto field names
// anyway, so normally this just returns field->name().
-TProtoStringType FieldName(const FieldDescriptor* field);
+PROTOC_EXPORT TProtoStringType FieldName(const FieldDescriptor* field);
// Requires that this field is in a oneof. Returns the (unqualified) case
// constant for this field.
-TProtoStringType OneofCaseConstantName(const FieldDescriptor* field);
+PROTOC_EXPORT TProtoStringType OneofCaseConstantName(const FieldDescriptor* field);
// Returns the quafilied case constant for this field.
-TProtoStringType QualifiedOneofCaseConstantName(const FieldDescriptor* field);
+PROTOC_EXPORT TProtoStringType QualifiedOneofCaseConstantName(
+ const FieldDescriptor* field);
// Get the (unqualified) name that should be used for this enum value in C++
// code.
-TProtoStringType EnumValueName(const EnumValueDescriptor* enum_value);
+PROTOC_EXPORT TProtoStringType EnumValueName(const EnumValueDescriptor* enum_value);
// Strips ".proto" or ".protodevel" from the end of a filename.
-PROTOC_EXPORT TProtoStringType StripProto(const TProtoStringType& filename);
+PROTOC_EXPORT TProtoStringType StripProto(y_absl::string_view filename);
} // namespace cpp
} // namespace compiler
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_CPP_NAMES_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/options.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/options.h
index 14546ca6187..449ed69f5d1 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/options.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/options.h
@@ -33,14 +33,17 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_OPTIONS_H__
#define GOOGLE_PROTOBUF_COMPILER_CPP_OPTIONS_H__
-#include <set>
#include <string>
+
+#include "y_absl/container/flat_hash_set.h"
+
#include <google/protobuf/stubs/port.h>
namespace google {
namespace protobuf {
namespace compiler {
class AccessInfoMap;
+class SplitMap;
namespace cpp {
@@ -53,12 +56,13 @@ enum class EnforceOptimizeMode {
struct FieldListenerOptions {
bool inject_field_listener_events = false;
- std::set<TProtoStringType> forbidden_field_listener_events;
+ y_absl::flat_hash_set<TProtoStringType> forbidden_field_listener_events;
};
// Generator options (see generator.cc for a description of each):
struct Options {
const AccessInfoMap* access_info_map = nullptr;
+ const SplitMap* split_map = nullptr;
TProtoStringType dllexport_decl;
TProtoStringType runtime_include_base;
TProtoStringType annotation_pragma_name;
@@ -79,12 +83,10 @@ struct Options {
bool bootstrap = false;
bool opensource_runtime = false;
bool annotate_accessor = false;
- bool unused_field_stripping = false;
bool unverified_lazy_message_sets = false;
- bool unverified_lazy = false;
bool profile_driven_inline_string = true;
- bool message_owned_arena_trial = false;
bool force_split = false;
+ bool profile_driven_split = true;
#ifdef PROTOBUF_STABLE_EXPERIMENTS
bool force_eagerly_verified_lazy = true;
bool force_inline_string = true;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/padding_optimizer.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/padding_optimizer.cc
index 20910520d63..5f2bfba18c4 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/padding_optimizer.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/padding_optimizer.cc
@@ -28,9 +28,10 @@
// (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/cpp/padding_optimizer.h>
+#include "google/protobuf/compiler/cpp/padding_optimizer.h"
-#include <google/protobuf/compiler/cpp/helpers.h>
+#include "y_absl/log/absl_log.h"
+#include "google/protobuf/compiler/cpp/helpers.h"
namespace google {
namespace protobuf {
@@ -85,41 +86,11 @@ class FieldGroup {
} // namespace
-// Reorder 'fields' so that if the fields are output into a c++ class in the new
-// order, fields of similar family (see below) are together and within each
-// family, alignment padding is minimized.
-//
-// We try to do this while keeping each field as close as possible to its field
-// number order so that we don't reduce cache locality much for function that
-// access each field in order. Originally, OptimizePadding used declaration
-// order for its decisions, but generated code minus the serializer/parsers uses
-// the output of OptimizePadding as well (stored in
-// MessageGenerator::optimized_order_). Since the serializers use field number
-// order, we use that as a tie-breaker.
-//
-// We classify each field into a particular "family" of fields, that we perform
-// the same operation on in our generated functions.
-//
-// REPEATED is placed first, as the C++ compiler automatically initializes
-// these fields in layout order.
-//
-// STRING is grouped next, as our Clear/SharedCtor/SharedDtor walks it and
-// calls ArenaStringPtr::Destroy on each.
-//
-// LAZY_MESSAGE is grouped next, as it interferes with the ability to memset
-// non-repeated fields otherwise.
-//
-// MESSAGE is grouped next, as our Clear/SharedDtor code walks it and calls
-// delete on each. We initialize these fields with a NULL pointer (see
-// MessageFieldGenerator::GenerateConstructorCode), which allows them to be
-// memset.
-//
-// ZERO_INITIALIZABLE is memset in Clear/SharedCtor
-//
-// OTHER these fields are initialized one-by-one.
-void PaddingOptimizer::OptimizeLayout(
- std::vector<const FieldDescriptor*>* fields, const Options& options,
- MessageSCCAnalyzer* scc_analyzer) {
+static void OptimizeLayoutHelper(std::vector<const FieldDescriptor*>* fields,
+ const Options& options,
+ MessageSCCAnalyzer* scc_analyzer) {
+ if (fields->empty()) return;
+
// The sorted numeric order of Family determines the declaration order in the
// memory layout.
enum Family {
@@ -151,7 +122,7 @@ void PaddingOptimizer::OptimizeLayout(
if (IsLazy(field, options, scc_analyzer)) {
f = LAZY_MESSAGE;
}
- } else if (CanInitializeByZeroing(field)) {
+ } else if (CanInitializeByZeroing(field, options, scc_analyzer)) {
f = ZERO_INITIALIZABLE;
}
@@ -167,8 +138,9 @@ void PaddingOptimizer::OptimizeLayout(
aligned_to_8[f].push_back(FieldGroup(j, field));
break;
default:
- GOOGLE_LOG(FATAL) << "Unknown alignment size " << EstimateAlignmentSize(field)
- << "for a field " << field->full_name() << ".";
+ Y_ABSL_LOG(FATAL) << "Unknown alignment size "
+ << EstimateAlignmentSize(field) << "for a field "
+ << field->full_name() << ".";
}
}
@@ -222,6 +194,61 @@ void PaddingOptimizer::OptimizeLayout(
}
}
+// Reorder 'fields' so that if the fields are output into a c++ class in the new
+// order, fields of similar family (see below) are together and within each
+// family, alignment padding is minimized.
+//
+// We try to do this while keeping each field as close as possible to its field
+// number order so that we don't reduce cache locality much for function that
+// access each field in order. Originally, OptimizePadding used declaration
+// order for its decisions, but generated code minus the serializer/parsers uses
+// the output of OptimizePadding as well (stored in
+// MessageGenerator::optimized_order_). Since the serializers use field number
+// order, we use that as a tie-breaker.
+//
+// We classify each field into a particular "family" of fields, that we perform
+// the same operation on in our generated functions.
+//
+// REPEATED is placed first, as the C++ compiler automatically initializes
+// these fields in layout order.
+//
+// STRING is grouped next, as our Clear/SharedCtor/SharedDtor walks it and
+// calls ArenaStringPtr::Destroy on each.
+//
+// LAZY_MESSAGE is grouped next, as it interferes with the ability to memset
+// non-repeated fields otherwise.
+//
+// MESSAGE is grouped next, as our Clear/SharedDtor code walks it and calls
+// delete on each. We initialize these fields with a NULL pointer (see
+// MessageFieldGenerator::GenerateConstructorCode), which allows them to be
+// memset.
+//
+// ZERO_INITIALIZABLE is memset in Clear/SharedCtor
+//
+// OTHER these fields are initialized one-by-one.
+//
+// If there are split fields in `fields`, they will be placed at the end. The
+// order within split fields follows the same rule, aka classify and order by
+// "family".
+void PaddingOptimizer::OptimizeLayout(
+ std::vector<const FieldDescriptor*>* fields, const Options& options,
+ MessageSCCAnalyzer* scc_analyzer) {
+ std::vector<const FieldDescriptor*> normal;
+ std::vector<const FieldDescriptor*> split;
+ for (const auto* field : *fields) {
+ if (ShouldSplit(field, options)) {
+ split.push_back(field);
+ } else {
+ normal.push_back(field);
+ }
+ }
+ OptimizeLayoutHelper(&normal, options, scc_analyzer);
+ OptimizeLayoutHelper(&split, options, scc_analyzer);
+ fields->clear();
+ fields->insert(fields->end(), normal.begin(), normal.end());
+ fields->insert(fields->end(), split.begin(), split.end());
+}
+
} // namespace cpp
} // namespace compiler
} // namespace protobuf
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/padding_optimizer.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/padding_optimizer.h
index 9c76f38c471..4f55e649a3d 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/padding_optimizer.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/padding_optimizer.h
@@ -35,7 +35,7 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_PADDING_OPTIMIZER_H__
#define GOOGLE_PROTOBUF_COMPILER_CPP_PADDING_OPTIMIZER_H__
-#include <google/protobuf/compiler/cpp/message_layout_helper.h>
+#include "google/protobuf/compiler/cpp/message_layout_helper.h"
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/parse_function_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/parse_function_generator.cc
index 1b97182acd6..74ede841a8f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/parse_function_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/parse_function_generator.cc
@@ -28,15 +28,25 @@
// (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/cpp/parse_function_generator.h>
+#include "google/protobuf/compiler/cpp/parse_function_generator.h"
#include <algorithm>
#include <limits>
#include <string>
#include <utility>
+#include <vector>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/compiler/cpp/helpers.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/cpp/helpers.h"
+#include "google/protobuf/generated_message_tctable_gen.h"
+#include "google/protobuf/generated_message_tctable_impl.h"
+#include "google/protobuf/wire_format.h"
+
+#include "util/generic/string.h"
+
+using TProtoStringType = TString;
namespace google {
namespace protobuf {
@@ -44,16 +54,26 @@ namespace compiler {
namespace cpp {
namespace {
+using internal::TailCallTableInfo;
+using internal::cpp::Utf8CheckMode;
using google::protobuf::internal::WireFormat;
using google::protobuf::internal::WireFormatLite;
+bool UseDirectTcParserTable(const FieldDescriptor* field,
+ const Options& options) {
+ if (field->cpp_type() != field->CPPTYPE_MESSAGE) return false;
+ auto* m = field->message_type();
+ return !m->options().message_set_wire_format() &&
+ m->file()->options().optimize_for() != FileOptions::CODE_SIZE &&
+ !HasSimpleBaseClass(m, options) && !HasTracker(m, options)
+ ; // NOLINT(whitespace/semicolon)
+}
+
std::vector<const FieldDescriptor*> GetOrderedFields(
const Descriptor* descriptor, const Options& options) {
std::vector<const FieldDescriptor*> ordered_fields;
for (auto field : FieldRange(descriptor)) {
- if (!IsFieldStripped(field, options)) {
- ordered_fields.push_back(field);
- }
+ ordered_fields.push_back(field);
}
std::sort(ordered_fields.begin(), ordered_fields.end(),
[](const FieldDescriptor* a, const FieldDescriptor* b) {
@@ -66,371 +86,33 @@ bool HasInternalAccessors(const FieldOptions::CType ctype) {
return ctype == FieldOptions::STRING || ctype == FieldOptions::CORD;
}
-int TagSize(arc_ui32 field_number) {
- if (field_number < 16) return 1;
- GOOGLE_CHECK_LT(field_number, (1 << 14))
- << "coded tag for " << field_number << " too big for uint16_t";
- return 2;
-}
-
-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;
- }
-
- // 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;
-
- 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;
-
- default:
- break;
- }
-
- 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;
-}
-
-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;
-
- for (const auto& entry : field_entries) {
- if (!IsFieldEligibleForFastParsing(entry, options, scc_analyzer)) {
- continue;
- }
-
- const auto* field = entry.field;
- arc_ui32 tag = WireFormat::MakeTag(field);
-
- // 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
- // 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.
- 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 {
- info.aux_idx = static_cast<uint8_t>(entry.aux_idx);
- }
- }
- return result;
-}
-
-// 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_DOUBLE:
- case FieldDescriptor::TYPE_FLOAT:
- 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_SINT64:
- case FieldDescriptor::TYPE_INT64:
- // These are handled by MiniParse, so we don't need any generated
- // fallback code.
- handled = true;
- break;
-
- 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);
- }
-
- 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),
- ", _impl_._oneof_case_)}"));
+class ParseFunctionGenerator::GeneratedOptionProvider final
+ : public internal::TailCallTableInfo::OptionProvider {
+ public:
+ explicit GeneratedOptionProvider(ParseFunctionGenerator* gen) : gen_(gen) {}
+ TailCallTableInfo::PerFieldOptions GetForField(
+ const FieldDescriptor* field) const final {
+ return {IsLazy(field, gen_->options_, gen_->scc_analyzer_),
+ IsStringInlined(field, gen_->options_),
+ IsImplicitWeakField(field, gen_->options_, gen_->scc_analyzer_),
+ UseDirectTcParserTable(field, gen_->options_),
+ GetOptimizeFor(field->file(), gen_->options_) ==
+ FileOptions::LITE_RUNTIME,
+ ShouldSplit(field, gen_->options_)};
}
- // 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),
- ", _impl_._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;
- }
- }
-
- // 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.
- use_generated_fallback =
- !fallback_fields.empty() || descriptor->extension_range_count() > 1;
-}
+ private:
+ ParseFunctionGenerator* gen_;
+};
ParseFunctionGenerator::ParseFunctionGenerator(
const Descriptor* descriptor, int max_has_bit_index,
const std::vector<int>& has_bit_indices,
const std::vector<int>& inlined_string_indices, const Options& options,
MessageSCCAnalyzer* scc_analyzer,
- const std::map<TProtoStringType, TProtoStringType>& vars)
+ const y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>& vars)
: descriptor_(descriptor),
scc_analyzer_(scc_analyzer),
options_(options),
@@ -440,10 +122,9 @@ ParseFunctionGenerator::ParseFunctionGenerator(
num_hasbits_(max_has_bit_index) {
if (should_generate_tctable()) {
tc_table_info_.reset(new TailCallTableInfo(
- descriptor_, options_, ordered_fields_, has_bit_indices,
- inlined_string_indices, scc_analyzer));
+ descriptor_, ordered_fields_, GeneratedOptionProvider(this),
+ has_bit_indices, inlined_string_indices));
}
- SetCommonVars(options_, &variables_);
SetCommonMessageDataVariables(descriptor_, &variables_);
SetUnknownFieldsVariable(descriptor_, options_, &variables_);
variables_["classname"] = ClassName(descriptor, false);
@@ -518,11 +199,14 @@ bool ParseFunctionGenerator::should_generate_tctable() const {
if (options_.tctable_mode == Options::kTCTableNever) {
return false;
}
+ if (HasSimpleBaseClass(descriptor_, options_)) {
+ return false;
+ }
return true;
}
void ParseFunctionGenerator::GenerateTailcallParseFunction(Formatter& format) {
- GOOGLE_CHECK(should_generate_tctable());
+ Y_ABSL_CHECK(should_generate_tctable());
// Generate an `_InternalParse` that starts the tail-calling loop.
format(
@@ -536,20 +220,47 @@ void ParseFunctionGenerator::GenerateTailcallParseFunction(Formatter& format) {
"}\n\n");
}
+static bool NeedsUnknownEnumSupport(const Descriptor* descriptor) {
+ for (int i = 0; i < descriptor->field_count(); ++i) {
+ auto* field = descriptor->field(i);
+ if (field->is_repeated() && field->cpp_type() == field->CPPTYPE_ENUM &&
+ !internal::cpp::HasPreservingUnknownEnumSemantics(field)) {
+ return true;
+ }
+ }
+ return false;
+}
+
void ParseFunctionGenerator::GenerateTailcallFallbackFunction(
Formatter& format) {
- GOOGLE_CHECK(should_generate_tctable());
+ Y_ABSL_CHECK(should_generate_tctable());
format(
"const char* $classname$::Tct_ParseFallback(PROTOBUF_TC_PARAM_DECL) {\n"
"#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) return nullptr\n");
format.Indent();
format("auto* typed_msg = static_cast<$classname$*>(msg);\n");
+ // If we need a side channel, generate the check to jump to the generic
+ // handler to deal with the side channel data.
+ if (NeedsUnknownEnumSupport(descriptor_)) {
+ format(
+ "if (PROTOBUF_PREDICT_FALSE(\n"
+ " _pbi::TcParser::MustFallbackToGeneric(PROTOBUF_TC_PARAM_PASS))) "
+ "{\n"
+ " PROTOBUF_MUSTTAIL return "
+ "::_pbi::TcParser::GenericFallback$1$(PROTOBUF_TC_PARAM_PASS);\n"
+ "}\n",
+ GetOptimizeFor(descriptor_->file(), options_) ==
+ FileOptions::LITE_RUNTIME
+ ? "Lite"
+ : "");
+ }
+
if (num_hasbits_ > 0) {
// Sync hasbits
- format("typed_msg->_impl_._has_bits_[0] = hasbits;\n");
+ format("typed_msg->_impl_._has_bits_[0] |= hasbits;\n");
}
- format("arc_ui32 tag = data.tag();\n");
+ format("::arc_ui32 tag = data.tag();\n");
format.Set("msg", "typed_msg->");
format.Set("this", "typed_msg");
@@ -592,6 +303,12 @@ struct NumToEntryTable {
static NumToEntryTable MakeNumToEntryTable(
const std::vector<const FieldDescriptor*>& field_descriptors);
+static int FieldNameDataSize(const std::vector<uint8_t>& data) {
+ // We add a +1 here to allow for a NUL termination character. It makes the
+ // codegen nicer.
+ return data.empty() ? 0 : data.size() + 1;
+}
+
void ParseFunctionGenerator::GenerateDataDecls(io::Printer* printer) {
if (!should_generate_tctable()) {
return;
@@ -604,10 +321,12 @@ void ParseFunctionGenerator::GenerateDataDecls(io::Printer* printer) {
}
auto field_num_to_entry_table = MakeNumToEntryTable(ordered_fields_);
format(
+ "friend class ::$proto_ns$::internal::TcParser;\n"
"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(),
+ tc_table_info_->aux_entries.size(),
+ FieldNameDataSize(tc_table_info_->field_name_data),
field_num_to_entry_table.size16());
if (should_generate_guarded_tctable()) {
format.Outdent();
@@ -656,7 +375,7 @@ void ParseFunctionGenerator::GenerateLoopingParseFunction(Formatter& format) {
format.Indent();
format(
- "arc_ui32 tag;\n"
+ "::arc_ui32 tag;\n"
"ptr = ::_pbi::ReadTag(ptr, &tag);\n");
GenerateParseIterationBody(format, descriptor_, ordered_fields_);
@@ -706,7 +425,7 @@ static NumToEntryTable MakeNumToEntryTable(
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);
+ Y_ABSL_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,
@@ -739,16 +458,16 @@ static NumToEntryTable MakeNumToEntryTable(
}
void ParseFunctionGenerator::GenerateTailCallTable(Formatter& format) {
- GOOGLE_CHECK(should_generate_tctable());
+ Y_ABSL_CHECK(should_generate_tctable());
// All entries without a fast-path parsing function need a fallback.
TProtoStringType fallback;
if (tc_table_info_->use_generated_fallback) {
- fallback = ClassName(descriptor_) + "::Tct_ParseFallback";
+ fallback = y_absl::StrCat(ClassName(descriptor_), "::Tct_ParseFallback");
} else {
fallback = "::_pbi::TcParser::GenericFallback";
if (GetOptimizeFor(descriptor_->file(), options_) ==
FileOptions::LITE_RUNTIME) {
- fallback += "Lite";
+ y_absl::StrAppend(&fallback, "Lite");
}
}
@@ -761,12 +480,13 @@ void ParseFunctionGenerator::GenerateTailCallTable(Formatter& format) {
// unknown fields and potentially an extension range.
auto field_num_to_entry_table = MakeNumToEntryTable(ordered_fields_);
format(
- "PROTOBUF_ATTRIBUTE_INIT_PRIORITY1\n"
+ "PROTOBUF_CONSTINIT 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(),
+ tc_table_info_->aux_entries.size(),
+ FieldNameDataSize(tc_table_info_->field_name_data),
field_num_to_entry_table.size16());
{
auto table_scope = format.ScopedIndent();
@@ -849,7 +569,7 @@ void ParseFunctionGenerator::GenerateTailCallTable(Formatter& format) {
format("65535, 65535\n");
}
if (ordered_fields_.empty()) {
- GOOGLE_LOG_IF(DFATAL, !tc_table_info_->aux_entries.empty())
+ Y_ABSL_DLOG_IF(FATAL, !tc_table_info_->aux_entries.empty())
<< "Invalid message: " << descriptor_->full_name() << " has "
<< tc_table_info_->aux_entries.size()
<< " auxiliary field entries, but no fields";
@@ -874,19 +594,62 @@ void ParseFunctionGenerator::GenerateTailCallTable(Formatter& format) {
{
// aux_entries[]
auto aux_scope = format.ScopedIndent();
- for (const TProtoStringType& aux_entry : tc_table_info_->aux_entries) {
- format("{$1$},\n", aux_entry);
+ for (const auto& aux_entry : tc_table_info_->aux_entries) {
+ switch (aux_entry.type) {
+ case TailCallTableInfo::kNothing:
+ format("{},\n");
+ break;
+ case TailCallTableInfo::kInlinedStringDonatedOffset:
+ format(
+ "{_fl::Offset{offsetof($classname$, "
+ "_impl_._inlined_string_donated_)}},\n");
+ break;
+ case TailCallTableInfo::kSplitOffset:
+ format(
+ "{_fl::Offset{offsetof($classname$, _impl_._split_)}},\n");
+ break;
+ case TailCallTableInfo::kSplitSizeof:
+ format("{_fl::Offset{sizeof($classname$::Impl_::Split)}},\n");
+ break;
+ case TailCallTableInfo::kSubMessage:
+ format("{::_pbi::FieldAuxDefaultMessage{}, &$1$},\n",
+ QualifiedDefaultInstanceName(
+ aux_entry.field->message_type(), options_));
+ break;
+ case TailCallTableInfo::kSubTable:
+ format("{::_pbi::TcParser::GetTable<$1$>()},\n",
+ QualifiedClassName(aux_entry.field->message_type(),
+ options_));
+ break;
+ case TailCallTableInfo::kSubMessageWeak:
+ format("{::_pbi::FieldAuxDefaultMessage{}, &$1$},\n",
+ QualifiedDefaultInstancePtr(
+ aux_entry.field->message_type(), options_));
+ break;
+ case TailCallTableInfo::kEnumRange:
+ format("{$1$, $2$},\n", aux_entry.enum_range.start,
+ aux_entry.enum_range.size);
+ break;
+ case TailCallTableInfo::kEnumValidator:
+ format(
+ "{$1$_IsValid},\n",
+ QualifiedClassName(aux_entry.field->enum_type(), options_));
+ break;
+ case TailCallTableInfo::kNumericOffset:
+ format("{_fl::Offset{$1$}},\n", aux_entry.offset);
+ break;
+ }
}
}
format("}}, {{\n");
}
} // ordered_fields_.empty()
- {
- // field_names[]
- auto field_name_scope = format.ScopedIndent();
- GenerateFieldNames(format);
- }
- format("}},\n");
+ {
+ // field_names[]
+ auto field_name_scope = format.ScopedIndent();
+ GenerateFieldNames(format);
+ }
+ format("}},\n");
}
format("};\n\n"); // _table_
}
@@ -898,145 +661,174 @@ void ParseFunctionGenerator::GenerateFastFieldEntries(Formatter& format) {
}
if (info.func_name.empty()) {
format("{::_pbi::TcParser::MiniParse, {}},\n");
+ } else if (info.field == nullptr) {
+ // Fast slot that is not associated with a field. Eg end group tags.
+ format("{$1$, {$2$, $3$}},\n", info.func_name, info.coded_tag,
+ info.nonfield_info);
} else {
- bool cold = ShouldSplit(info.field, options_);
+ Y_ABSL_CHECK(!ShouldSplit(info.field, options_));
+
+ TProtoStringType func_name = info.func_name;
+ if (GetOptimizeFor(info.field->file(), options_) == FileOptions::SPEED) {
+ // For 1-byte tags we have a more optimized version of the varint parser
+ // that can hardcode the offset and has bit.
+ if (y_absl::EndsWith(func_name, "V8S1") ||
+ y_absl::EndsWith(func_name, "V32S1") ||
+ y_absl::EndsWith(func_name, "V64S1")) {
+ TProtoStringType field_type = y_absl::EndsWith(func_name, "V8S1") ? "bool"
+ : y_absl::EndsWith(func_name, "V32S1")
+ ? "::arc_ui32"
+ : "::arc_ui64";
+ func_name = y_absl::StrCat(
+ "::_pbi::TcParser::SingularVarintNoZag1<", field_type,
+ ", offsetof(", //
+ ClassName(info.field->containing_type()), //
+ ", ", //
+ FieldMemberName(info.field, /*split=*/false), //
+ "), ", //
+ info.hasbit_idx, //
+ ">()");
+ }
+ }
+
format(
"{$1$,\n"
- " {$2$, $3$, $4$, PROTOBUF_FIELD_OFFSET($classname$$5$, $6$)}},\n",
- info.func_name, info.coded_tag, info.hasbit_idx, info.aux_idx,
- cold ? "::Impl_::Split" : "",
- cold ? FieldName(info.field) + "_"
- : FieldMemberName(info.field, /*cold=*/false));
+ " {$2$, $3$, $4$, PROTOBUF_FIELD_OFFSET($classname$, $5$)}},\n",
+ func_name, info.coded_tag, info.hasbit_idx, info.aux_idx,
+ FieldMemberName(info.field, /*split=*/false));
}
}
}
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");
- }
+ const TailCallTableInfo::FieldEntryInfo& entry) {
+ // In here we convert the runtime value of entry.type_card back into a
+ // sequence of literal enum labels. We use the mnenonic labels for nicer
+ // codegen.
+ namespace fl = internal::field_layout;
+ const uint16_t type_card = entry.type_card;
+ const int rep_index = (type_card & fl::kRepMask) >> fl::kRepShift;
+ const int tv_index = (type_card & fl::kTvMask) >> fl::kTvShift;
+
+ // Use `0|` prefix to eagerly convert the enums to int to avoid enum-enum
+ // operations. They are deprecated in C++20.
+ format("(0 | ");
+ static constexpr const char* kFieldCardNames[] = {"Singular", "Optional",
+ "Repeated", "Oneof"};
+ static_assert((fl::kFcSingular >> fl::kFcShift) == 0, "");
+ static_assert((fl::kFcOptional >> fl::kFcShift) == 1, "");
+ static_assert((fl::kFcRepeated >> fl::kFcShift) == 2, "");
+ static_assert((fl::kFcOneof >> fl::kFcShift) == 3, "");
+
+ format("::_fl::kFc$1$",
+ kFieldCardNames[(type_card & fl::kFcMask) >> fl::kFcShift]);
+
+#define PROTOBUF_INTERNAL_TYPE_CARD_CASE(x) \
+ case fl::k##x: \
+ format(" | ::_fl::k" #x); \
+ break
+
+ switch (type_card & fl::kFkMask) {
+ case fl::kFkString: {
+ switch (type_card & ~fl::kFcMask & ~fl::kRepMask & ~fl::kSplitMask) {
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(Bytes);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(RawString);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(Utf8String);
+ default:
+ Y_ABSL_LOG(FATAL) << "Unknown type_card: 0x" << type_card;
+ }
- // 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");
+ static constexpr const char* kRepNames[] = {"AString", "IString", "Cord",
+ "SPiece", "SString"};
+ static_assert((fl::kRepAString >> fl::kRepShift) == 0, "");
+ static_assert((fl::kRepIString >> fl::kRepShift) == 1, "");
+ static_assert((fl::kRepCord >> fl::kRepShift) == 2, "");
+ static_assert((fl::kRepSPiece >> fl::kRepShift) == 3, "");
+ static_assert((fl::kRepSString >> fl::kRepShift) == 4, "");
+
+ format(" | ::_fl::kRep$1$", kRepNames[rep_index]);
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");
+ }
+
+ case fl::kFkMessage: {
+ format(" | ::_fl::kMessage");
+
+ static constexpr const char* kRepNames[] = {nullptr, "Group", "Lazy"};
+ static_assert((fl::kRepGroup >> fl::kRepShift) == 1, "");
+ static_assert((fl::kRepLazy >> fl::kRepShift) == 2, "");
+
+ if (auto* rep = kRepNames[rep_index]) {
+ format(" | ::_fl::kRep$1$", rep);
}
- 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();
+ static constexpr const char* kXFormNames[] = {nullptr, "Default", "Table",
+ "WeakPtr"};
+ static_assert((fl::kTvDefault >> fl::kTvShift) == 1, "");
+ static_assert((fl::kTvTable >> fl::kTvShift) == 2, "");
+ static_assert((fl::kTvWeakPtr >> fl::kTvShift) == 3, "");
+
+ if (auto* xform = kXFormNames[tv_index]) {
+ format(" | ::_fl::kTv$1$", xform);
}
break;
}
- case FieldDescriptor::TYPE_GROUP:
- format("Message | ::_fl::kRepGroup");
+ case fl::kFkMap:
+ format(" | ::_fl::kMap");
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");
- }
- }
+
+ case fl::kFkNone:
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");
+ case fl::kFkVarint:
+ case fl::kFkPackedVarint:
+ case fl::kFkFixed:
+ case fl::kFkPackedFixed: {
+ switch (type_card & ~fl::kFcMask & ~fl::kSplitMask) {
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(Bool);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(Fixed32);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(UInt32);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(SFixed32);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(Int32);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(SInt32);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(Float);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(Enum);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(EnumRange);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(OpenEnum);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(Fixed64);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(UInt64);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(SFixed64);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(Int64);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(SInt64);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(Double);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(PackedBool);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(PackedFixed32);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(PackedUInt32);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(PackedSFixed32);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(PackedInt32);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(PackedSInt32);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(PackedFloat);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(PackedEnum);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(PackedEnumRange);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(PackedOpenEnum);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(PackedFixed64);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(PackedUInt64);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(PackedSFixed64);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(PackedInt64);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(PackedSInt64);
+ PROTOBUF_INTERNAL_TYPE_CARD_CASE(PackedDouble);
+ default:
+ Y_ABSL_LOG(FATAL) << "Unknown type_card: 0x" << type_card;
+ }
}
}
+ if (type_card & fl::kSplitMask) {
+ format(" | ::_fl::kSplitTrue");
+ }
+
+#undef PROTOBUF_INTERNAL_TYPE_CARD_CASE
+
format(")");
}
@@ -1051,91 +843,81 @@ void ParseFunctionGenerator::GenerateFieldEntries(Formatter& format) {
format("/* weak */ 0, 0, 0, 0");
} else {
const OneofDescriptor* oneof = field->real_containing_oneof();
- bool cold = ShouldSplit(field, options_);
- format("PROTOBUF_FIELD_OFFSET($classname$$1$, $2$), $3$, $4$,\n ",
- cold ? "::Impl_::Split" : "",
- cold ? FieldName(field) + "_"
- : FieldMemberName(field, /*cold=*/false),
- (oneof ? oneof->index() : entry.hasbit_idx), entry.aux_idx);
- FormatFieldKind(format, entry, options_, scc_analyzer_);
+ bool split = ShouldSplit(field, options_);
+ if (split) {
+ format("PROTOBUF_FIELD_OFFSET($classname$::Impl_::Split, $1$), ",
+ y_absl::StrCat(FieldName(field), "_"));
+ } else {
+ format("PROTOBUF_FIELD_OFFSET($classname$, $1$), ",
+ FieldMemberName(field, /*cold=*/false));
+ }
+ if (oneof) {
+ format("_Internal::kOneofCaseOffset + $1$, ", 4 * oneof->index());
+ } else if (num_hasbits_ > 0 || IsMapEntryMessage(descriptor_)) {
+ if (entry.hasbit_idx >= 0) {
+ format("_Internal::kHasBitsOffset + $1$, ", entry.hasbit_idx);
+ } else {
+ format("$1$, ", entry.hasbit_idx);
+ }
+ } else {
+ format("0, ");
+ }
+ format("$1$,\n ", entry.aux_idx);
+ FormatFieldKind(format, entry);
}
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;
+void ParseFunctionGenerator::GenerateFieldNames(Formatter& format) {
+ if (tc_table_info_->field_name_data.empty()) {
+ // No names to output.
+ return;
}
- // 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);
-}
+ // We could just output the bytes directly, but we want it to look better than
+ // that in the source code. Also, it is more efficient for compilation time to
+ // have a literal string than an initializer list of chars.
-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;
+ const int total_sizes =
+ static_cast<int>(((tc_table_info_->field_entries.size() + 1) + 7) & ~7);
+ const uint8_t* p = tc_table_info_->field_name_data.data();
+ const uint8_t* sizes = p;
+ const uint8_t* sizes_end = sizes + total_sizes;
+
+ // First print all the sizes as octal
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;
+ for (int i = 0; i < total_sizes; ++i) {
+ int size = *p++;
+ int octal_size = ((size >> 6) & 3) * 100 + //
+ ((size >> 3) & 7) * 10 + //
+ ((size >> 0) & 7);
+ format("\\$1$", octal_size);
}
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());
+
+ // Then print each name in a line of its own
+ for (; sizes < sizes_end; p += *sizes++) {
+ if (*sizes != 0) format("\"$1$\"\n", TProtoStringType((const char*)p, (const char*)p + *sizes));
}
}
void ParseFunctionGenerator::GenerateArenaString(Formatter& format,
const FieldDescriptor* field) {
- if (HasHasbit(field)) {
+ if (internal::cpp::HasHasbit(field)) {
format("_Internal::set_has_$1$(&$has_bits$);\n", FieldName(field));
}
format(
"if (arena != nullptr) {\n"
" ptr = ctx->ReadArenaString(ptr, &$msg$$field$, arena");
if (IsStringInlined(field, options_)) {
- GOOGLE_DCHECK(!inlined_string_indices_.empty());
+ Y_ABSL_DCHECK(!inlined_string_indices_.empty());
int inlined_string_index = inlined_string_indices_[field->index()];
- GOOGLE_DCHECK_GT(inlined_string_index, 0);
+ Y_ABSL_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());
+ Y_ABSL_DCHECK(field->default_value_string().empty());
}
format(
");\n"
@@ -1184,7 +966,9 @@ void ParseFunctionGenerator::GenerateStrings(Formatter& format,
// 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_);
+ auto level = internal::cpp::GetUtf8CheckMode(
+ field,
+ GetOptimizeFor(field->file(), options_) == FileOptions::LITE_RUNTIME);
switch (level) {
case Utf8CheckMode::kNone:
return;
@@ -1198,7 +982,7 @@ void ParseFunctionGenerator::GenerateStrings(Formatter& format,
TProtoStringType field_name;
field_name = "nullptr";
if (HasDescriptorMethods(field->file(), options_)) {
- field_name = StrCat("\"", field->full_name(), "\"");
+ field_name = y_absl::StrCat("\"", field->full_name(), "\"");
}
format("::_pbi::VerifyUTF8(str, $1$)", field_name);
switch (level) {
@@ -1219,7 +1003,7 @@ void ParseFunctionGenerator::GenerateLengthDelim(Formatter& format,
const FieldDescriptor* field) {
if (field->is_packable()) {
if (field->type() == FieldDescriptor::TYPE_ENUM &&
- !HasPreservingUnknownEnumSemantics(field)) {
+ !internal::cpp::HasPreservingUnknownEnumSemantics(field)) {
TProtoStringType enum_type = QualifiedClassName(field->enum_type(), options_);
format(
"ptr = "
@@ -1246,9 +1030,9 @@ void ParseFunctionGenerator::GenerateLengthDelim(Formatter& format,
case FieldDescriptor::TYPE_MESSAGE: {
if (field->is_map()) {
const FieldDescriptor* val = field->message_type()->map_value();
- GOOGLE_CHECK(val);
+ Y_ABSL_CHECK(val);
if (val->type() == FieldDescriptor::TYPE_ENUM &&
- !HasPreservingUnknownEnumSemantics(field)) {
+ !internal::cpp::HasPreservingUnknownEnumSemantics(field)) {
format(
"auto object = "
"::$proto_ns$::internal::InitEnumParseWrapper<"
@@ -1267,13 +1051,13 @@ void ParseFunctionGenerator::GenerateLengthDelim(Formatter& format,
format(
"ctx->set_lazy_eager_verify_func($1$);\n",
eager_verify
- ? StrCat("&", ClassName(field->message_type(), true),
+ ? y_absl::StrCat("&", ClassName(field->message_type(), true),
"::InternalVerify")
: "nullptr");
}
if (field->real_containing_oneof()) {
format(
- "if (!$msg$_internal_has_$name$()) {\n"
+ "if ($msg$$1$_case() != k$2$) {\n"
" $msg$clear_$1$();\n"
" $msg$$field$ = ::$proto_ns$::Arena::CreateMessage<\n"
" ::$proto_ns$::internal::LazyField>("
@@ -1281,8 +1065,9 @@ void ParseFunctionGenerator::GenerateLengthDelim(Formatter& format,
" $msg$set_has_$name$();\n"
"}\n"
"auto* lazy_field = $msg$$field$;\n",
- field->containing_oneof()->name());
- } else if (HasHasbit(field)) {
+ field->containing_oneof()->name(),
+ UnderscoresToCamelCase(field->name(), true));
+ } else if (internal::cpp::HasHasbit(field)) {
format(
"_Internal::set_has_$name$(&$has_bits$);\n"
"auto* lazy_field = &$msg$$field$;\n");
@@ -1333,8 +1118,8 @@ void ParseFunctionGenerator::GenerateLengthDelim(Formatter& format,
break;
}
default:
- GOOGLE_LOG(FATAL) << "Illegal combination for length delimited wiretype "
- << " filed type is " << field->type();
+ Y_ABSL_LOG(FATAL) << "Illegal combination for length delimited wiretype "
+ << " filed type is " << field->type();
}
}
}
@@ -1356,29 +1141,31 @@ void ParseFunctionGenerator::GenerateFieldBody(
{{"name", FieldName(field)},
{"primitive_type", PrimitiveTypeName(options_, field->cpp_type())}});
if (field->is_repeated()) {
- format.AddMap({{"put_field", StrCat("add_", FieldName(field))},
- {"mutable_field", StrCat("add_", FieldName(field))}});
+ format.AddMap({{"put_field", y_absl::StrCat("add_", FieldName(field))},
+ {"mutable_field", y_absl::StrCat("add_", FieldName(field))}});
} else {
format.AddMap(
- {{"put_field", StrCat("set_", FieldName(field))},
- {"mutable_field", StrCat("mutable_", FieldName(field))}});
+ {{"put_field", y_absl::StrCat("set_", FieldName(field))},
+ {"mutable_field", y_absl::StrCat("mutable_", FieldName(field))}});
}
arc_ui32 tag = WireFormatLite::MakeTag(field->number(), wiretype);
switch (wiretype) {
case WireFormatLite::WIRETYPE_VARINT: {
- TProtoStringType type = PrimitiveTypeName(options_, field->cpp_type());
if (field->type() == FieldDescriptor::TYPE_ENUM) {
format.Set("enum_type",
QualifiedClassName(field->enum_type(), options_));
format(
- "$uint64$ val = ::$proto_ns$::internal::ReadVarint64(&ptr);\n"
+ "$uint32$ val = ::$proto_ns$::internal::ReadVarint32(&ptr);\n"
"CHK_(ptr);\n");
- if (!HasPreservingUnknownEnumSemantics(field)) {
- format("if (PROTOBUF_PREDICT_TRUE($enum_type$_IsValid(val))) {\n");
+ if (!internal::cpp::HasPreservingUnknownEnumSemantics(field)) {
+ format(
+ "if "
+ "(PROTOBUF_PREDICT_TRUE($enum_type$_IsValid(static_cast<int>(val)"
+ "))) {\n");
format.Indent();
}
format("$msg$_internal_$put_field$(static_cast<$enum_type$>(val));\n");
- if (!HasPreservingUnknownEnumSemantics(field)) {
+ if (!internal::cpp::HasPreservingUnknownEnumSemantics(field)) {
format.Outdent();
format(
"} else {\n"
@@ -1405,7 +1192,7 @@ void ParseFunctionGenerator::GenerateFieldBody(
"CHK_(ptr);\n",
zigzag, size);
} else {
- if (HasHasbit(field)) {
+ if (internal::cpp::HasHasbit(field)) {
format("_Internal::set_has_$name$(&$has_bits$);\n");
}
format(
@@ -1424,7 +1211,7 @@ void ParseFunctionGenerator::GenerateFieldBody(
"::$proto_ns$::internal::UnalignedLoad<$primitive_type$>(ptr));\n"
"ptr += sizeof($primitive_type$);\n");
} else {
- if (HasHasbit(field)) {
+ if (internal::cpp::HasHasbit(field)) {
format("_Internal::set_has_$name$(&$has_bits$);\n");
}
format(
@@ -1446,7 +1233,7 @@ void ParseFunctionGenerator::GenerateFieldBody(
break;
}
case WireFormatLite::WIRETYPE_END_GROUP: {
- GOOGLE_LOG(FATAL) << "Can't have end group field\n";
+ Y_ABSL_LOG(FATAL) << "Can't have end group field\n";
break;
}
} // switch (wire_type)
@@ -1460,7 +1247,7 @@ static arc_ui32 ExpectedTag(const FieldDescriptor* field,
if (field->is_packable()) {
auto expected_wiretype = WireFormat::WireTypeForFieldType(field->type());
expected_tag = WireFormatLite::MakeTag(field->number(), expected_wiretype);
- GOOGLE_CHECK(expected_wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED);
+ Y_ABSL_CHECK(expected_wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED);
auto fallback_wiretype = WireFormatLite::WIRETYPE_LENGTH_DELIMITED;
arc_ui32 fallback_tag =
WireFormatLite::MakeTag(field->number(), fallback_wiretype);
@@ -1599,8 +1386,9 @@ void ParseFunctionGenerator::GenerateFieldSwitch(
format.Outdent();
}
format(
- "} else\n"
+ "} else {\n"
" goto handle_unusual;\n"
+ "}\n"
"$next_tag$;\n");
format.Outdent();
} // for loop over ordered fields
@@ -1612,113 +1400,6 @@ void ParseFunctionGenerator::GenerateFieldSwitch(
format("} // switch\n");
}
-namespace {
-
-TProtoStringType FieldParseFunctionName(
- const TailCallTableInfo::FieldEntryInfo& entry, const Options& options) {
- const FieldDescriptor* field = entry.field;
- TProtoStringType name = "::_pbi::TcParser::Fast";
-
- switch (field->type()) {
- case FieldDescriptor::TYPE_FIXED32:
- case FieldDescriptor::TYPE_SFIXED32:
- case FieldDescriptor::TYPE_FLOAT:
- name.append("F32");
- break;
-
- 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:
- name.append("V32");
- break;
- case FieldDescriptor::TYPE_INT64:
- case FieldDescriptor::TYPE_UINT64:
- name.append("V64");
- break;
-
- 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:
- name.append("Z32");
- break;
- case FieldDescriptor::TYPE_SINT64:
- name.append("Z64");
- break;
-
- case FieldDescriptor::TYPE_BYTES:
- name.append("B");
- if (IsStringInlined(field, options)) {
- name.append("i");
- }
- break;
- case FieldDescriptor::TYPE_STRING:
- switch (GetUtf8CheckMode(field, options)) {
- case Utf8CheckMode::kNone:
- name.append("B");
- break;
- case Utf8CheckMode::kVerify:
- 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;
-
- case FieldDescriptor::TYPE_MESSAGE:
- name.append("M");
- break;
- case FieldDescriptor::TYPE_GROUP:
- name.append("G");
- break;
-
- default:
- GOOGLE_LOG(DFATAL) << "Type not handled: " << field->DebugString();
- return "";
- }
-
- // 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");
-
- // Append the tag length. Fast parsing only handles 1- or 2-byte tags.
- name.append(TagSize(field->number()) == 1 ? "1" : "2");
-
- return name;
-}
-
-} // namespace
-
} // namespace cpp
} // namespace compiler
} // namespace protobuf
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/parse_function_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/parse_function_generator.h
index 7e2b674852f..c12c2057328 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/parse_function_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/parse_function_generator.h
@@ -31,72 +31,32 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_PARSE_FUNCTION_GENERATOR_H__
#define GOOGLE_PROTOBUF_COMPILER_CPP_PARSE_FUNCTION_GENERATOR_H__
-#include <map>
#include <string>
#include <vector>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/compiler/cpp/helpers.h>
-#include <google/protobuf/compiler/cpp/options.h>
+#include "google/protobuf/descriptor.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "google/protobuf/compiler/cpp/helpers.h"
+#include "google/protobuf/compiler/cpp/options.h"
+#include "google/protobuf/generated_message_tctable_gen.h"
+#include "google/protobuf/io/printer.h"
+#include "google/protobuf/wire_format_lite.h"
namespace google {
namespace protobuf {
namespace compiler {
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);
-
- // 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;
- };
- 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.
- arc_ui32 has_hasbits_required_mask;
- // True if a generated fallback function is required instead of generic.
- bool use_generated_fallback;
-};
-
// ParseFunctionGenerator generates the _InternalParse function for a message
// (and any associated supporting members).
class ParseFunctionGenerator {
public:
- ParseFunctionGenerator(const Descriptor* descriptor, int max_has_bit_index,
- const std::vector<int>& has_bit_indices,
- const std::vector<int>& inlined_string_indices,
- const Options& options,
- MessageSCCAnalyzer* scc_analyzer,
- const std::map<TProtoStringType, TProtoStringType>& vars);
+ ParseFunctionGenerator(
+ const Descriptor* descriptor, int max_has_bit_index,
+ const std::vector<int>& has_bit_indices,
+ const std::vector<int>& inlined_string_indices, const Options& options,
+ MessageSCCAnalyzer* scc_analyzer,
+ const y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>& vars);
// Emits class-level method declarations to `printer`:
void GenerateMethodDecls(io::Printer* printer);
@@ -111,6 +71,8 @@ class ParseFunctionGenerator {
void GenerateDataDefinitions(io::Printer* printer);
private:
+ class GeneratedOptionProvider;
+
// Returns true if tailcall table code should be generated.
bool should_generate_tctable() const;
@@ -134,7 +96,6 @@ class ParseFunctionGenerator {
void GenerateTailCallTable(Formatter& format);
void GenerateFastFieldEntries(Formatter& format);
void GenerateFieldEntries(Formatter& format);
- int CalculateFieldNamesSize() const;
void GenerateFieldNames(Formatter& format);
// Generates parsing code for an `ArenaString` field.
@@ -165,8 +126,8 @@ class ParseFunctionGenerator {
const Descriptor* descriptor_;
MessageSCCAnalyzer* scc_analyzer_;
const Options& options_;
- std::map<TProtoStringType, TProtoStringType> variables_;
- std::unique_ptr<TailCallTableInfo> tc_table_info_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables_;
+ std::unique_ptr<internal::TailCallTableInfo> tc_table_info_;
std::vector<int> inlined_string_indices_;
const std::vector<const FieldDescriptor*> ordered_fields_;
int num_hasbits_;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/primitive_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/primitive_field.cc
deleted file mode 100644
index 9dbf16ae7eb..00000000000
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/primitive_field.cc
+++ /dev/null
@@ -1,539 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#include <google/protobuf/compiler/cpp/primitive_field.h>
-
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/cpp/helpers.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-using internal::WireFormatLite;
-
-namespace {
-
-// For encodings with fixed sizes, returns that size in bytes. Otherwise
-// returns -1.
-int FixedSize(FieldDescriptor::Type type) {
- switch (type) {
- case FieldDescriptor::TYPE_INT32:
- return -1;
- case FieldDescriptor::TYPE_INT64:
- return -1;
- case FieldDescriptor::TYPE_UINT32:
- return -1;
- case FieldDescriptor::TYPE_UINT64:
- return -1;
- case FieldDescriptor::TYPE_SINT32:
- return -1;
- case FieldDescriptor::TYPE_SINT64:
- return -1;
- case FieldDescriptor::TYPE_FIXED32:
- return WireFormatLite::kFixed32Size;
- case FieldDescriptor::TYPE_FIXED64:
- return WireFormatLite::kFixed64Size;
- case FieldDescriptor::TYPE_SFIXED32:
- return WireFormatLite::kSFixed32Size;
- case FieldDescriptor::TYPE_SFIXED64:
- return WireFormatLite::kSFixed64Size;
- case FieldDescriptor::TYPE_FLOAT:
- return WireFormatLite::kFloatSize;
- case FieldDescriptor::TYPE_DOUBLE:
- return WireFormatLite::kDoubleSize;
-
- case FieldDescriptor::TYPE_BOOL:
- return WireFormatLite::kBoolSize;
- case FieldDescriptor::TYPE_ENUM:
- return -1;
-
- case FieldDescriptor::TYPE_STRING:
- return -1;
- case FieldDescriptor::TYPE_BYTES:
- return -1;
- case FieldDescriptor::TYPE_GROUP:
- return -1;
- case FieldDescriptor::TYPE_MESSAGE:
- return -1;
-
- // No default because we want the compiler to complain if any new
- // types are added.
- }
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return -1;
-}
-
-void SetPrimitiveVariables(const FieldDescriptor* descriptor,
- std::map<TProtoStringType, TProtoStringType>* variables,
- const Options& options) {
- SetCommonFieldVariables(descriptor, variables, options);
- (*variables)["type"] = PrimitiveTypeName(options, descriptor->cpp_type());
- (*variables)["default"] = DefaultValue(options, descriptor);
- (*variables)["cached_byte_size_name"] = MakeVarintCachedSizeName(descriptor);
- bool cold = ShouldSplit(descriptor, options);
- (*variables)["cached_byte_size_field"] =
- MakeVarintCachedSizeFieldName(descriptor, cold);
- (*variables)["tag"] = StrCat(internal::WireFormat::MakeTag(descriptor));
- int fixed_size = FixedSize(descriptor->type());
- if (fixed_size != -1) {
- (*variables)["fixed_size"] = StrCat(fixed_size);
- }
- (*variables)["wire_format_field_type"] = FieldDescriptorProto_Type_Name(
- static_cast<FieldDescriptorProto_Type>(descriptor->type()));
- (*variables)["full_name"] = descriptor->full_name();
-}
-
-} // namespace
-
-// ===================================================================
-
-PrimitiveFieldGenerator::PrimitiveFieldGenerator(
- const FieldDescriptor* descriptor, const Options& options)
- : FieldGenerator(descriptor, options) {
- SetPrimitiveVariables(descriptor, &variables_, options);
-}
-
-PrimitiveFieldGenerator::~PrimitiveFieldGenerator() {}
-
-void PrimitiveFieldGenerator::GeneratePrivateMembers(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("$type$ $name$_;\n");
-}
-
-void PrimitiveFieldGenerator::GenerateAccessorDeclarations(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format(
- "$deprecated_attr$$type$ ${1$$name$$}$() const;\n"
- "$deprecated_attr$void ${1$set_$name$$}$($type$ value);\n"
- "private:\n"
- "$type$ ${1$_internal_$name$$}$() const;\n"
- "void ${1$_internal_set_$name$$}$($type$ value);\n"
- "public:\n",
- descriptor_);
-}
-
-void PrimitiveFieldGenerator::GenerateInlineAccessorDefinitions(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format(
- "inline $type$ $classname$::_internal_$name$() const {\n"
- " return $field$;\n"
- "}\n"
- "inline $type$ $classname$::$name$() const {\n"
- "$annotate_get$"
- " // @@protoc_insertion_point(field_get:$full_name$)\n"
- " return _internal_$name$();\n"
- "}\n"
- "inline void $classname$::_internal_set_$name$($type$ value) {\n"
- " $set_hasbit$\n"
- " $field$ = value;\n"
- "}\n"
- "inline void $classname$::set_$name$($type$ value) {\n"
- "$maybe_prepare_split_message$"
- " _internal_set_$name$(value);\n"
- "$annotate_set$"
- " // @@protoc_insertion_point(field_set:$full_name$)\n"
- "}\n");
-}
-
-void PrimitiveFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("$field$ = $default$;\n");
-}
-
-void PrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("_this->_internal_set_$name$(from._internal_$name$());\n");
-}
-
-void PrimitiveFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("swap($field$, other->$field$);\n");
-}
-
-void PrimitiveFieldGenerator::GenerateCopyConstructorCode(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("_this->$field$ = from.$field$;\n");
-}
-
-void PrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format(
- "target = stream->EnsureSpace(target);\n"
- "target = "
- "::_pbi::WireFormatLite::Write$declared_type$ToArray("
- "$number$, this->_internal_$name$(), target);\n");
-}
-
-void PrimitiveFieldGenerator::GenerateByteSize(io::Printer* printer) const {
- Formatter format(printer, variables_);
- int fixed_size = FixedSize(descriptor_->type());
- if (fixed_size == -1) {
- if (internal::WireFormat::TagSize(descriptor_->number(),
- descriptor_->type()) == 1) {
- // 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 += ::_pbi::WireFormatLite::"
- "$declared_type$SizePlusOne(this->_internal_$name$());\n");
- } else {
- format(
- "total_size += $tag_size$ +\n"
- " ::_pbi::WireFormatLite::$declared_type$Size(\n"
- " this->_internal_$name$());\n");
- }
- } else {
- format("total_size += $tag_size$ + $fixed_size$;\n");
- }
-}
-
-void PrimitiveFieldGenerator::GenerateConstexprAggregateInitializer(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("/*decltype($field$)*/$default$");
-}
-
-void PrimitiveFieldGenerator::GenerateAggregateInitializer(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- if (ShouldSplit(descriptor_, options_)) {
- format("decltype(Impl_::Split::$name$_){$default$}");
- return;
- }
- format("decltype($field$){$default$}");
-}
-
-void PrimitiveFieldGenerator::GenerateCopyAggregateInitializer(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("decltype($field$){}");
-}
-
-// ===================================================================
-
-PrimitiveOneofFieldGenerator::PrimitiveOneofFieldGenerator(
- const FieldDescriptor* descriptor, const Options& options)
- : PrimitiveFieldGenerator(descriptor, options) {
- SetCommonOneofFieldVariables(descriptor, &variables_);
-}
-
-PrimitiveOneofFieldGenerator::~PrimitiveOneofFieldGenerator() {}
-
-void PrimitiveOneofFieldGenerator::GenerateInlineAccessorDefinitions(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format(
- "inline $type$ $classname$::_internal_$name$() const {\n"
- " if (_internal_has_$name$()) {\n"
- " return $field$;\n"
- " }\n"
- " return $default$;\n"
- "}\n"
- "inline void $classname$::_internal_set_$name$($type$ value) {\n"
- " if (!_internal_has_$name$()) {\n"
- " clear_$oneof_name$();\n"
- " set_has_$name$();\n"
- " }\n"
- " $field$ = value;\n"
- "}\n"
- "inline $type$ $classname$::$name$() const {\n"
- "$annotate_get$"
- " // @@protoc_insertion_point(field_get:$full_name$)\n"
- " return _internal_$name$();\n"
- "}\n"
- "inline void $classname$::set_$name$($type$ value) {\n"
- " _internal_set_$name$(value);\n"
- "$annotate_set$"
- " // @@protoc_insertion_point(field_set:$full_name$)\n"
- "}\n");
-}
-
-void PrimitiveOneofFieldGenerator::GenerateClearingCode(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("$field$ = $default$;\n");
-}
-
-void PrimitiveOneofFieldGenerator::GenerateSwappingCode(
- io::Printer* printer) const {
- // Don't print any swapping code. Swapping the union will swap this field.
-}
-
-void PrimitiveOneofFieldGenerator::GenerateConstructorCode(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("$ns$::_$classname$_default_instance_.$field$ = $default$;\n");
-}
-
-// ===================================================================
-
-RepeatedPrimitiveFieldGenerator::RepeatedPrimitiveFieldGenerator(
- const FieldDescriptor* descriptor, const Options& options)
- : FieldGenerator(descriptor, options) {
- SetPrimitiveVariables(descriptor, &variables_, options);
-
- if (descriptor->is_packed()) {
- variables_["packed_reader"] = "ReadPackedPrimitive";
- variables_["repeated_reader"] = "ReadRepeatedPrimitiveNoInline";
- } else {
- variables_["packed_reader"] = "ReadPackedPrimitiveNoInline";
- variables_["repeated_reader"] = "ReadRepeatedPrimitive";
- }
-}
-
-RepeatedPrimitiveFieldGenerator::~RepeatedPrimitiveFieldGenerator() {}
-
-void RepeatedPrimitiveFieldGenerator::GeneratePrivateMembers(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("::$proto_ns$::RepeatedField< $type$ > $name$_;\n");
- if (descriptor_->is_packed() && FixedSize(descriptor_->type()) == -1 &&
- HasGeneratedMethods(descriptor_->file(), options_)) {
- format("mutable std::atomic<int> $cached_byte_size_name$;\n");
- }
-}
-
-void RepeatedPrimitiveFieldGenerator::GenerateAccessorDeclarations(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format(
- "private:\n"
- "$type$ ${1$_internal_$name$$}$(int index) const;\n"
- "const ::$proto_ns$::RepeatedField< $type$ >&\n"
- " ${1$_internal_$name$$}$() const;\n"
- "void ${1$_internal_add_$name$$}$($type$ value);\n"
- "::$proto_ns$::RepeatedField< $type$ >*\n"
- " ${1$_internal_mutable_$name$$}$();\n"
- "public:\n"
- "$deprecated_attr$$type$ ${1$$name$$}$(int index) const;\n"
- "$deprecated_attr$void ${1$set_$name$$}$(int index, $type$ value);\n"
- "$deprecated_attr$void ${1$add_$name$$}$($type$ value);\n"
- "$deprecated_attr$const ::$proto_ns$::RepeatedField< $type$ >&\n"
- " ${1$$name$$}$() const;\n"
- "$deprecated_attr$::$proto_ns$::RepeatedField< $type$ >*\n"
- " ${1$mutable_$name$$}$();\n",
- descriptor_);
-}
-
-void RepeatedPrimitiveFieldGenerator::GenerateInlineAccessorDefinitions(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format(
- "inline $type$ $classname$::_internal_$name$(int index) const {\n"
- " return $field$.Get(index);\n"
- "}\n"
- "inline $type$ $classname$::$name$(int index) const {\n"
- "$annotate_get$"
- " // @@protoc_insertion_point(field_get:$full_name$)\n"
- " return _internal_$name$(index);\n"
- "}\n"
- "inline void $classname$::set_$name$(int index, $type$ value) {\n"
- "$annotate_set$"
- " $field$.Set(index, value);\n"
- " // @@protoc_insertion_point(field_set:$full_name$)\n"
- "}\n"
- "inline void $classname$::_internal_add_$name$($type$ value) {\n"
- " $field$.Add(value);\n"
- "}\n"
- "inline void $classname$::add_$name$($type$ value) {\n"
- " _internal_add_$name$(value);\n"
- "$annotate_add$"
- " // @@protoc_insertion_point(field_add:$full_name$)\n"
- "}\n"
- "inline const ::$proto_ns$::RepeatedField< $type$ >&\n"
- "$classname$::_internal_$name$() const {\n"
- " return $field$;\n"
- "}\n"
- "inline const ::$proto_ns$::RepeatedField< $type$ >&\n"
- "$classname$::$name$() const {\n"
- "$annotate_list$"
- " // @@protoc_insertion_point(field_list:$full_name$)\n"
- " return _internal_$name$();\n"
- "}\n"
- "inline ::$proto_ns$::RepeatedField< $type$ >*\n"
- "$classname$::_internal_mutable_$name$() {\n"
- " return &$field$;\n"
- "}\n"
- "inline ::$proto_ns$::RepeatedField< $type$ >*\n"
- "$classname$::mutable_$name$() {\n"
- "$annotate_mutable_list$"
- " // @@protoc_insertion_point(field_mutable_list:$full_name$)\n"
- " return _internal_mutable_$name$();\n"
- "}\n");
-}
-
-void RepeatedPrimitiveFieldGenerator::GenerateClearingCode(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("$field$.Clear();\n");
-}
-
-void RepeatedPrimitiveFieldGenerator::GenerateMergingCode(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("_this->$field$.MergeFrom(from.$field$);\n");
-}
-
-void RepeatedPrimitiveFieldGenerator::GenerateSwappingCode(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("$field$.InternalSwap(&other->$field$);\n");
-}
-
-void RepeatedPrimitiveFieldGenerator::GenerateDestructorCode(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("$field$.~RepeatedField();\n");
-}
-
-void RepeatedPrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- if (descriptor_->is_packed()) {
- if (FixedSize(descriptor_->type()) == -1) {
- format(
- "{\n"
- " int byte_size = "
- "$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"
- " }\n"
- "}\n");
- } else {
- format(
- "if (this->_internal_$name$_size() > 0) {\n"
- " target = stream->WriteFixedPacked($number$, _internal_$name$(), "
- "target);\n"
- "}\n");
- }
- } else {
- format(
- "for (int i = 0, n = this->_internal_$name$_size(); i < n; i++) {\n"
- " target = stream->EnsureSpace(target);\n"
- " target = ::_pbi::WireFormatLite::"
- "Write$declared_type$ToArray($number$, this->_internal_$name$(i), "
- "target);\n"
- "}\n");
- }
-}
-
-void RepeatedPrimitiveFieldGenerator::GenerateByteSize(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("{\n");
- format.Indent();
- int fixed_size = FixedSize(descriptor_->type());
- if (fixed_size == -1) {
- format(
- "size_t data_size = ::_pbi::WireFormatLite::\n"
- " $declared_type$Size(this->$field$);\n");
- } else {
- format(
- "unsigned int count = static_cast<unsigned "
- "int>(this->_internal_$name$_size());\n"
- "size_t data_size = $fixed_size$UL * count;\n");
- }
-
- if (descriptor_->is_packed()) {
- format(
- "if (data_size > 0) {\n"
- " total_size += $tag_size$ +\n"
- " "
- "::_pbi::WireFormatLite::Int32Size(static_cast<$int32$>(data_size));\n"
- "}\n");
- if (FixedSize(descriptor_->type()) == -1) {
- format(
- "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");
- } else {
- format(
- "total_size += $tag_size$ *\n"
- " "
- "::_pbi::FromIntSize(this->_internal_$name$_size());\n"
- "total_size += data_size;\n");
- }
- format.Outdent();
- format("}\n");
-}
-
-void RepeatedPrimitiveFieldGenerator::GenerateConstexprAggregateInitializer(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("/*decltype($field$)*/{}");
- if (descriptor_->is_packed() && FixedSize(descriptor_->type()) == -1 &&
- HasGeneratedMethods(descriptor_->file(), options_)) {
- format("\n, /*decltype($cached_byte_size_field$)*/{0}");
- }
-}
-
-void RepeatedPrimitiveFieldGenerator::GenerateAggregateInitializer(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("decltype($field$){arena}");
- if (descriptor_->is_packed() && FixedSize(descriptor_->type()) == -1 &&
- HasGeneratedMethods(descriptor_->file(), options_)) {
- // std::atomic has no move constructor, which prevents explicit aggregate
- // initialization pre-C++17.
- format("\n, /*decltype($cached_byte_size_field$)*/{0}");
- }
-}
-
-void RepeatedPrimitiveFieldGenerator::GenerateCopyAggregateInitializer(
- io::Printer* printer) const {
-
- Formatter format(printer, variables_);
- format("decltype($field$){from.$field$}");
- if (descriptor_->is_packed() && FixedSize(descriptor_->type()) == -1 &&
- HasGeneratedMethods(descriptor_->file(), options_)) {
- // std::atomic has no move constructor.
- format("\n, /*decltype($cached_byte_size_field$)*/{0}");
- }
-}
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/primitive_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/primitive_field.h
deleted file mode 100644
index bb8a08aa141..00000000000
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/primitive_field.h
+++ /dev/null
@@ -1,126 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_PRIMITIVE_FIELD_H__
-#define GOOGLE_PROTOBUF_COMPILER_CPP_PRIMITIVE_FIELD_H__
-
-#include <map>
-#include <string>
-
-#include <google/protobuf/compiler/cpp/field.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-class PrimitiveFieldGenerator : public FieldGenerator {
- public:
- PrimitiveFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
- ~PrimitiveFieldGenerator() override;
-
- // implements FieldGenerator ---------------------------------------
- void GeneratePrivateMembers(io::Printer* printer) const override;
- void GenerateAccessorDeclarations(io::Printer* printer) const override;
- void GenerateInlineAccessorDefinitions(io::Printer* printer) const override;
- 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 GenerateSerializeWithCachedSizesToArray(
- io::Printer* printer) const override;
- void GenerateByteSize(io::Printer* printer) const override;
- void GenerateConstexprAggregateInitializer(
- io::Printer* printer) const override;
- void GenerateAggregateInitializer(io::Printer* printer) const override;
- void GenerateCopyAggregateInitializer(io::Printer* printer) const override;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator);
-};
-
-class PrimitiveOneofFieldGenerator : public PrimitiveFieldGenerator {
- public:
- PrimitiveOneofFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
- ~PrimitiveOneofFieldGenerator() override;
-
- // implements FieldGenerator ---------------------------------------
- void GenerateInlineAccessorDefinitions(io::Printer* printer) const override;
- void GenerateClearingCode(io::Printer* printer) const override;
- void GenerateSwappingCode(io::Printer* printer) const override;
- void GenerateConstructorCode(io::Printer* printer) const override;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveOneofFieldGenerator);
-};
-
-class RepeatedPrimitiveFieldGenerator : public FieldGenerator {
- public:
- RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
- ~RepeatedPrimitiveFieldGenerator() override;
-
- // implements FieldGenerator ---------------------------------------
- void GeneratePrivateMembers(io::Printer* printer) const override;
- void GenerateAccessorDeclarations(io::Printer* printer) const override;
- void GenerateInlineAccessorDefinitions(io::Printer* printer) const override;
- 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 {
- GOOGLE_CHECK(!ShouldSplit(descriptor_, options_));
- }
- void GenerateDestructorCode(io::Printer* printer) const override;
- void GenerateSerializeWithCachedSizesToArray(
- io::Printer* printer) const override;
- void GenerateByteSize(io::Printer* printer) const override;
- void GenerateConstexprAggregateInitializer(
- io::Printer* printer) const override;
- void GenerateAggregateInitializer(io::Printer* printer) const override;
- void GenerateCopyAggregateInitializer(io::Printer* printer) const override;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPrimitiveFieldGenerator);
-};
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_CPP_PRIMITIVE_FIELD_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/service.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/service.cc
index fae7128a097..ae1d2b8a2da 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/service.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/service.cc
@@ -32,293 +32,279 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/cpp/service.h>
+#include "google/protobuf/compiler/cpp/service.h"
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/cpp/helpers.h>
+#include <string>
+
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/cpp/helpers.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
namespace compiler {
namespace cpp {
-
-namespace {
-
-void InitMethodVariables(const MethodDescriptor* method, const Options& options,
- Formatter* format) {
- format->Set("name", method->name());
- format->Set("input_type", QualifiedClassName(method->input_type(), options));
- format->Set("output_type",
- QualifiedClassName(method->output_type(), options));
-}
-
-} // namespace
-
-ServiceGenerator::ServiceGenerator(
- const ServiceDescriptor* descriptor,
- const std::map<TProtoStringType, TProtoStringType>& vars, const Options& options)
- : descriptor_(descriptor), vars_(vars), options_(options) {
- vars_["classname"] = descriptor_->name();
- vars_["full_name"] = descriptor_->full_name();
-}
-
-ServiceGenerator::~ServiceGenerator() {}
-
void ServiceGenerator::GenerateDeclarations(io::Printer* printer) {
- Formatter format(printer, vars_);
- // Forward-declare the stub type.
- format(
- "class $classname$_Stub;\n"
- "\n");
-
- GenerateInterface(printer);
- GenerateStubDefinition(printer);
-}
-
-void ServiceGenerator::GenerateInterface(io::Printer* printer) {
- Formatter format(printer, vars_);
- format(
- "class $dllexport_decl $$classname$ : public ::$proto_ns$::Service {\n"
- " protected:\n"
- " // This class should be treated as an abstract interface.\n"
- " inline $classname$() {};\n"
- " public:\n"
- " virtual ~$classname$();\n");
- printer->Indent();
-
- format(
- "\n"
- "typedef $classname$_Stub Stub;\n"
- "\n"
- "static const ::$proto_ns$::ServiceDescriptor* descriptor();\n"
- "\n");
-
- GenerateMethodSignatures(VIRTUAL, printer);
-
- format(
- "\n"
- "// implements Service ----------------------------------------------\n"
- "\n"
- "const ::$proto_ns$::ServiceDescriptor* GetDescriptor();\n"
- "void CallMethod(const ::$proto_ns$::MethodDescriptor* method,\n"
- " ::$proto_ns$::RpcController* controller,\n"
- " const ::$proto_ns$::Message* request,\n"
- " ::$proto_ns$::Message* response,\n"
- " ::google::protobuf::Closure* done);\n"
- "const ::$proto_ns$::Message& GetRequestPrototype(\n"
- " const ::$proto_ns$::MethodDescriptor* method) const;\n"
- "const ::$proto_ns$::Message& GetResponsePrototype(\n"
- " const ::$proto_ns$::MethodDescriptor* method) const;\n");
-
- printer->Outdent();
- format(
- "\n"
- " private:\n"
- " GOOGLE_DISALLOW_EVIL_CONSTRUCTORS($classname$);\n"
- "};\n"
- "\n");
-}
-
-void ServiceGenerator::GenerateStubDefinition(io::Printer* printer) {
- Formatter format(printer, vars_);
- format(
- "class $dllexport_decl $$classname$_Stub : public $classname$ {\n"
- " public:\n");
-
- printer->Indent();
-
- format(
- "$classname$_Stub(::$proto_ns$::RpcChannel* channel);\n"
- "$classname$_Stub(::$proto_ns$::RpcChannel* channel,\n"
- " ::$proto_ns$::Service::ChannelOwnership ownership);\n"
- "~$classname$_Stub();\n"
- "\n"
- "inline ::$proto_ns$::RpcChannel* channel() { return channel_; }\n"
- "\n"
- "// implements $classname$ ------------------------------------------\n"
- "\n");
-
- GenerateMethodSignatures(NON_VIRTUAL, printer);
-
- printer->Outdent();
- format(
- " private:\n"
- " ::$proto_ns$::RpcChannel* channel_;\n"
- " bool owns_channel_;\n"
- " GOOGLE_DISALLOW_EVIL_CONSTRUCTORS($classname$_Stub);\n"
- "};\n"
- "\n");
+ auto vars = printer->WithVars(&vars_);
+ printer->Emit(
+ {
+ {"virts", [&] { GenerateMethodSignatures(kVirtual, printer); }},
+ {"impls", [&] { GenerateMethodSignatures(kNonVirtual, printer); }},
+ },
+ R"cc(
+ class $classname$_Stub;
+ class $dllexport_decl $$classname$ : public ::$proto_ns$::Service {
+ protected:
+ $classname$() = default;
+
+ public:
+ using Stub = $classname$_Stub;
+
+ $classname$(const $classname$&) = delete;
+ $classname$& operator=(const $classname$&) = delete;
+ virtual ~$classname$() = default;
+
+ static const ::$proto_ns$::ServiceDescriptor* descriptor();
+
+ $virts$;
+
+ // implements Service ----------------------------------------------
+ const ::$proto_ns$::ServiceDescriptor* GetDescriptor() override;
+
+ void CallMethod(const ::$proto_ns$::MethodDescriptor* method,
+ ::$proto_ns$::RpcController* controller,
+ const ::$proto_ns$::Message* request,
+ ::$proto_ns$::Message* response,
+ ::google::protobuf::Closure* done) override;
+
+ const ::$proto_ns$::Message& GetRequestPrototype(
+ const ::$proto_ns$::MethodDescriptor* method) const override;
+
+ const ::$proto_ns$::Message& GetResponsePrototype(
+ const ::$proto_ns$::MethodDescriptor* method) const override;
+ };
+
+ class $dllexport_decl $$classname$_Stub final : public $classname$ {
+ public:
+ $classname$_Stub(::$proto_ns$::RpcChannel* channel);
+ $classname$_Stub(::$proto_ns$::RpcChannel* channel,
+ ::$proto_ns$::Service::ChannelOwnership ownership);
+
+ $classname$_Stub(const $classname$_Stub&) = delete;
+ $classname$_Stub& operator=(const $classname$_Stub&) = delete;
+
+ ~$classname$_Stub() override;
+
+ inline ::$proto_ns$::RpcChannel* channel() { return channel_; }
+
+ // implements $classname$ ------------------------------------------
+ $impls$;
+
+ private:
+ ::$proto_ns$::RpcChannel* channel_;
+ bool owns_channel_;
+ };
+ )cc");
}
-void ServiceGenerator::GenerateMethodSignatures(VirtualOrNon virtual_or_non,
+void ServiceGenerator::GenerateMethodSignatures(VirtualOrNot virtual_or_not,
io::Printer* printer) {
- for (int i = 0; i < descriptor_->method_count(); i++) {
+ for (int i = 0; i < descriptor_->method_count(); ++i) {
const MethodDescriptor* method = descriptor_->method(i);
- Formatter format(printer, vars_);
- InitMethodVariables(method, options_, &format);
- format.Set("virtual", virtual_or_non == VIRTUAL ? "virtual " : "");
- format(
- "$virtual$void $name$(::$proto_ns$::RpcController* controller,\n"
- " const $input_type$* request,\n"
- " $output_type$* response,\n"
- " ::google::protobuf::Closure* done);\n");
+
+ printer->Emit(
+ {
+ {"name", method->name()},
+ {"input", QualifiedClassName(method->input_type(), *options_)},
+ {"output", QualifiedClassName(method->output_type(), *options_)},
+ {"virtual", virtual_or_not == kVirtual ? "virtual" : ""},
+ {"override", virtual_or_not != kVirtual ? "override" : ""},
+ },
+ // No cc, clang-format does not format this string well due to the
+ // $ override$ substitution.
+ R"(
+ $virtual $void $name$(::$proto_ns$::RpcController* controller,
+ const $input$* request,
+ $output$* response,
+ ::google::protobuf::Closure* done)$ override$;
+ )");
}
}
// ===================================================================
void ServiceGenerator::GenerateImplementation(io::Printer* printer) {
- Formatter format(printer, vars_);
- format(
- "$classname$::~$classname$() {}\n"
- "\n"
- "const ::$proto_ns$::ServiceDescriptor* $classname$::descriptor() {\n"
- " "
- "::$proto_ns$::internal::AssignDescriptors(&$desc_table$);\n"
- " return $file_level_service_descriptors$[$1$];\n"
- "}\n"
- "\n"
- "const ::$proto_ns$::ServiceDescriptor* $classname$::GetDescriptor() {\n"
- " return descriptor();\n"
- "}\n"
- "\n",
- index_in_metadata_);
-
- // Generate methods of the interface.
- GenerateNotImplementedMethods(printer);
- GenerateCallMethod(printer);
- GenerateGetPrototype(REQUEST, printer);
- GenerateGetPrototype(RESPONSE, printer);
-
- // Generate stub implementation.
- format(
- "$classname$_Stub::$classname$_Stub(::$proto_ns$::RpcChannel* channel)\n"
- " : channel_(channel), owns_channel_(false) {}\n"
- "$classname$_Stub::$classname$_Stub(\n"
- " ::$proto_ns$::RpcChannel* channel,\n"
- " ::$proto_ns$::Service::ChannelOwnership ownership)\n"
- " : channel_(channel),\n"
- " owns_channel_(ownership == "
- "::$proto_ns$::Service::STUB_OWNS_CHANNEL) "
- "{}\n"
- "$classname$_Stub::~$classname$_Stub() {\n"
- " if (owns_channel_) delete channel_;\n"
- "}\n"
- "\n");
-
- GenerateStubMethods(printer);
+ auto vars = printer->WithVars(&vars_);
+ printer->Emit(
+ {
+ {"index", index_in_metadata_},
+ {"no_impl_methods", [&] { GenerateNotImplementedMethods(printer); }},
+ {"call_method", [&] { GenerateCallMethod(printer); }},
+ {"get_request", [&] { GenerateGetPrototype(kRequest, printer); }},
+ {"get_response", [&] { GenerateGetPrototype(kResponse, printer); }},
+ {"stub_methods", [&] { GenerateStubMethods(printer); }},
+ },
+ R"cc(
+ const ::$proto_ns$::ServiceDescriptor* $classname$::descriptor() {
+ ::$proto_ns$::internal::AssignDescriptors(&$desc_table$);
+ return $file_level_service_descriptors$[$index$];
+ }
+
+ const ::$proto_ns$::ServiceDescriptor* $classname$::GetDescriptor() {
+ return descriptor();
+ }
+
+ $no_impl_methods$;
+
+ $call_method$;
+
+ $get_request$;
+
+ $get_response$;
+
+ $classname$_Stub::$classname$_Stub(::$proto_ns$::RpcChannel* channel)
+ : channel_(channel), owns_channel_(false) {}
+
+ $classname$_Stub::$classname$_Stub(
+ ::$proto_ns$::RpcChannel* channel,
+ ::$proto_ns$::Service::ChannelOwnership ownership)
+ : channel_(channel),
+ owns_channel_(ownership ==
+ ::$proto_ns$::Service::STUB_OWNS_CHANNEL) {}
+
+ $classname$_Stub::~$classname$_Stub() {
+ if (owns_channel_) delete channel_;
+ }
+
+ $stub_methods$;
+ )cc");
}
void ServiceGenerator::GenerateNotImplementedMethods(io::Printer* printer) {
- for (int i = 0; i < descriptor_->method_count(); i++) {
+ for (int i = 0; i < descriptor_->method_count(); ++i) {
const MethodDescriptor* method = descriptor_->method(i);
- Formatter format(printer, vars_);
- InitMethodVariables(method, options_, &format);
- format(
- "void $classname$::$name$(::$proto_ns$::RpcController* controller,\n"
- " const $input_type$*,\n"
- " $output_type$*,\n"
- " ::google::protobuf::Closure* done) {\n"
- " controller->SetFailed(\"Method $name$() not implemented.\");\n"
- " done->Run();\n"
- "}\n"
- "\n");
+
+ printer->Emit(
+ {
+ {"name", method->name()},
+ {"input", QualifiedClassName(method->input_type(), *options_)},
+ {"output", QualifiedClassName(method->output_type(), *options_)},
+ },
+ R"cc(
+ void $classname$::$name$(::$proto_ns$::RpcController* controller,
+ const $input$*, $output$*, ::google::protobuf::Closure* done) {
+ controller->SetFailed("Method $name$() not implemented.");
+ done->Run();
+ }
+ )cc");
}
}
void ServiceGenerator::GenerateCallMethod(io::Printer* printer) {
- Formatter format(printer, vars_);
- format(
- "void $classname$::CallMethod(const ::$proto_ns$::MethodDescriptor* "
- "method,\n"
- " ::$proto_ns$::RpcController* controller,\n"
- " const ::$proto_ns$::Message* request,\n"
- " ::$proto_ns$::Message* response,\n"
- " ::google::protobuf::Closure* done) {\n"
- " GOOGLE_DCHECK_EQ(method->service(), $file_level_service_descriptors$[$1$]);\n"
- " switch(method->index()) {\n",
- index_in_metadata_);
-
- for (int i = 0; i < descriptor_->method_count(); i++) {
- const MethodDescriptor* method = descriptor_->method(i);
- Formatter format_method(printer, vars_);
- InitMethodVariables(method, options_, &format_method);
-
- // Note: down_cast does not work here because it only works on pointers,
- // not references.
- format_method(
- " case $1$:\n"
- " $name$(controller,\n"
- " ::$proto_ns$::internal::DownCast<const $input_type$*>(\n"
- " request),\n"
- " ::$proto_ns$::internal::DownCast<$output_type$*>(\n"
- " response),\n"
- " done);\n"
- " break;\n",
- i);
- }
-
- format(
- " default:\n"
- " GOOGLE_LOG(FATAL) << \"Bad method index; this should never happen.\";\n"
- " break;\n"
- " }\n"
- "}\n"
- "\n");
+ printer->Emit(
+ {
+ {"index", y_absl::StrCat(index_in_metadata_)},
+ {"cases", [&] { GenerateCallMethodCases(printer); }},
+ },
+ R"cc(
+ void $classname$::CallMethod(
+ const ::$proto_ns$::MethodDescriptor* method,
+ ::$proto_ns$::RpcController* controller,
+ const ::$proto_ns$::Message* request,
+ ::$proto_ns$::Message* response, ::google::protobuf::Closure* done) {
+ Y_ABSL_DCHECK_EQ(method->service(), $file_level_service_descriptors$[$index$]);
+ switch (method->index()) {
+ $cases$;
+
+ default:
+ Y_ABSL_LOG(FATAL) << "Bad method index; this should never happen.";
+ break;
+ }
+ }
+ )cc");
}
void ServiceGenerator::GenerateGetPrototype(RequestOrResponse which,
io::Printer* printer) {
- Formatter format(printer, vars_);
- if (which == REQUEST) {
- format("const ::$proto_ns$::Message& $classname$::GetRequestPrototype(\n");
- } else {
- format("const ::$proto_ns$::Message& $classname$::GetResponsePrototype(\n");
- }
-
- format(
- " const ::$proto_ns$::MethodDescriptor* method) const {\n"
- " GOOGLE_DCHECK_EQ(method->service(), descriptor());\n"
- " switch(method->index()) {\n");
+ printer->Emit(
+ {
+ {"which", which == kRequest ? "Request" : "Response"},
+ {"which_type", which == kRequest ? "input" : "output"},
+ {"cases",
+ [&] {
+ for (int i = 0; i < descriptor_->method_count(); ++i) {
+ const MethodDescriptor* method = descriptor_->method(i);
+ const Descriptor* type = which == kRequest
+ ? method->input_type()
+ : method->output_type();
+
+ printer->Emit(
+ {
+ {"index", y_absl::StrCat(i)},
+ {"type", QualifiedClassName(type, *options_)},
+ },
+ R"cc(
+ case $index$:
+ return $type$::default_instance();
+ )cc");
+ }
+ }},
+ },
+ R"cc(
+ const ::$proto_ns$::Message& $classname$::Get$which$Prototype(
+ const ::$proto_ns$::MethodDescriptor* method) const {
+ Y_ABSL_DCHECK_EQ(method->service(), descriptor());
+ switch (method->index()) {
+ $cases$;
+
+ default:
+ Y_ABSL_LOG(FATAL) << "Bad method index; this should never happen.";
+ return *::$proto_ns$::MessageFactory::generated_factory()
+ ->GetPrototype(method->$which_type$_type());
+ }
+ }
+ )cc");
+}
- for (int i = 0; i < descriptor_->method_count(); i++) {
+void ServiceGenerator::GenerateCallMethodCases(io::Printer* printer) {
+ for (int i = 0; i < descriptor_->method_count(); ++i) {
const MethodDescriptor* method = descriptor_->method(i);
- const Descriptor* type =
- (which == REQUEST) ? method->input_type() : method->output_type();
-
- format(
- " case $1$:\n"
- " return $2$::default_instance();\n",
- i, QualifiedClassName(type, options_));
+ printer->Emit(
+ {
+ {"name", method->name()},
+ {"input", QualifiedClassName(method->input_type(), *options_)},
+ {"output", QualifiedClassName(method->output_type(), *options_)},
+ {"index", y_absl::StrCat(i)},
+ },
+ R"cc(
+ case $index$:
+ $name$(controller,
+ ::$proto_ns$::internal::DownCast<const $input$*>(request),
+ ::$proto_ns$::internal::DownCast<$output$*>(response), done);
+ break;
+ )cc");
}
-
- format(
- " default:\n"
- " GOOGLE_LOG(FATAL) << \"Bad method index; this should never happen.\";\n"
- " return *::$proto_ns$::MessageFactory::generated_factory()\n"
- " ->GetPrototype(method->$1$_type());\n"
- " }\n"
- "}\n"
- "\n",
- which == REQUEST ? "input" : "output");
}
void ServiceGenerator::GenerateStubMethods(io::Printer* printer) {
- for (int i = 0; i < descriptor_->method_count(); i++) {
+ for (int i = 0; i < descriptor_->method_count(); ++i) {
const MethodDescriptor* method = descriptor_->method(i);
- Formatter format(printer, vars_);
- InitMethodVariables(method, options_, &format);
- format(
- "void $classname$_Stub::$name$(::$proto_ns$::RpcController* "
- "controller,\n"
- " const $input_type$* request,\n"
- " $output_type$* response,\n"
- " ::google::protobuf::Closure* done) {\n"
- " channel_->CallMethod(descriptor()->method($1$),\n"
- " controller, request, response, done);\n"
- "}\n",
- i);
+
+ printer->Emit(
+ {
+ {"name", method->name()},
+ {"input", QualifiedClassName(method->input_type(), *options_)},
+ {"output", QualifiedClassName(method->output_type(), *options_)},
+ {"index", y_absl::StrCat(i)},
+ },
+ R"cc(
+ void $classname$_Stub::$name$(::$proto_ns$::RpcController* controller,
+ const $input$* request,
+ $output$* response, ::google::protobuf::Closure* done) {
+ channel_->CallMethod(descriptor()->method($index$), controller,
+ request, response, done);
+ }
+ )cc");
}
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/service.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/service.h
index 56982cf566b..183a4ecb1c8 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/service.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/service.h
@@ -35,63 +35,52 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_SERVICE_H__
#define GOOGLE_PROTOBUF_COMPILER_CPP_SERVICE_H__
-#include <map>
#include <string>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/compiler/cpp/options.h>
-
-namespace google {
-namespace protobuf {
-namespace io {
-class Printer; // printer.h
-}
-} // namespace protobuf
-} // namespace google
+#include "google/protobuf/descriptor.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "google/protobuf/compiler/cpp/options.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
namespace compiler {
namespace cpp {
-
class ServiceGenerator {
public:
// See generator.cc for the meaning of dllexport_decl.
- explicit ServiceGenerator(const ServiceDescriptor* descriptor,
- const std::map<TProtoStringType, TProtoStringType>& vars,
- const Options& options);
- ~ServiceGenerator();
-
- // Header stuff.
+ ServiceGenerator(
+ const ServiceDescriptor* descriptor,
+ const y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>& vars,
+ const Options& options)
+ : descriptor_(descriptor), options_(&options), vars_(vars) {
+ vars_["classname"] = descriptor_->name();
+ vars_["full_name"] = descriptor_->full_name();
+ }
+
+ ServiceGenerator(const ServiceGenerator&) = delete;
+ ServiceGenerator& operator=(const ServiceGenerator&) = delete;
+ ServiceGenerator(ServiceGenerator&&) = delete;
+ ServiceGenerator& operator=(ServiceGenerator&&) = delete;
+
+ ~ServiceGenerator() = default;
// Generate the class definitions for the service's interface and the
// stub implementation.
void GenerateDeclarations(io::Printer* printer);
- // Source file stuff.
-
// Generate implementations of everything declared by
// GenerateDeclarations().
void GenerateImplementation(io::Printer* printer);
private:
- enum RequestOrResponse { REQUEST, RESPONSE };
- enum VirtualOrNon { VIRTUAL, NON_VIRTUAL };
-
- // Header stuff.
-
- // Generate the service abstract interface.
- void GenerateInterface(io::Printer* printer);
-
- // Generate the stub class definition.
- void GenerateStubDefinition(io::Printer* printer);
+ enum RequestOrResponse { kRequest, kResponse };
+ enum VirtualOrNot { kVirtual, kNonVirtual };
// Prints signatures for all methods in the
- void GenerateMethodSignatures(VirtualOrNon virtual_or_non,
+ void GenerateMethodSignatures(VirtualOrNot virtual_or_not,
io::Printer* printer);
- // Source file stuff.
-
// Generate the default implementations of the service methods, which
// produce a "not implemented" error.
void GenerateNotImplementedMethods(io::Printer* printer);
@@ -102,19 +91,20 @@ class ServiceGenerator {
// Generate the Get{Request,Response}Prototype() methods.
void GenerateGetPrototype(RequestOrResponse which, io::Printer* printer);
+ // Generate the cases in CallMethod().
+ void GenerateCallMethodCases(io::Printer* printer);
+
// Generate the stub's implementations of the service methods.
void GenerateStubMethods(io::Printer* printer);
const ServiceDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> vars_;
- const Options& options_;
+ const Options* options_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars_;
int index_in_metadata_;
friend class FileGenerator;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceGenerator);
};
-
} // namespace cpp
} // namespace compiler
} // namespace protobuf
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/string_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/string_field.cc
deleted file mode 100644
index 5f30d3b511e..00000000000
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/string_field.cc
+++ /dev/null
@@ -1,957 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#include <google/protobuf/compiler/cpp/string_field.h>
-
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/cpp/helpers.h>
-#include <google/protobuf/descriptor.pb.h>
-
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-namespace {
-
-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());
- (*variables)["default_variable_name"] = MakeDefaultName(descriptor);
- (*variables)["default_variable_field"] = MakeDefaultFieldName(descriptor);
-
- 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"] =
- 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"] =
- descriptor->type() == FieldDescriptor::TYPE_BYTES ? "SetBytes" : "Set";
- (*variables)["null_check"] = (*variables)["DCHK"] + "(value != nullptr);\n";
- // NOTE: Escaped here to unblock proto1->proto2 migration.
- // TODO(liujisi): Extend this to apply for other conflicting methods.
- (*variables)["release_name"] =
- SafeFunctionName(descriptor->containing_type(), descriptor, "release_");
- (*variables)["full_name"] = descriptor->full_name();
-
- if (options.opensource_runtime) {
- (*variables)["string_piece"] = "TProtoStringType";
- } else {
- (*variables)["string_piece"] = "::StringPiece";
- }
-}
-
-} // namespace
-
-// ===================================================================
-
-StringFieldGenerator::StringFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options)
- : FieldGenerator(descriptor, options),
- inlined_(IsStringInlined(descriptor, options)) {
- SetStringVariables(descriptor, &variables_, options);
-}
-
-StringFieldGenerator::~StringFieldGenerator() {}
-
-void StringFieldGenerator::GeneratePrivateMembers(io::Printer* printer) const {
- Formatter format(printer, variables_);
- 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.
- format("::$proto_ns$::internal::InlinedStringField $name$_;\n");
- }
-}
-
-void StringFieldGenerator::GenerateStaticMembers(io::Printer* printer) const {
- Formatter format(printer, variables_);
- if (!descriptor_->default_value_string().empty()) {
- format(
- "static const ::$proto_ns$::internal::LazyString"
- " $default_variable_name$;\n");
- }
- if (inlined_) {
- // `_init_inline_xxx` is used for initializing default instances.
- format("static std::true_type _init_inline_$name$_;\n");
- }
-}
-
-void StringFieldGenerator::GenerateAccessorDeclarations(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- // If we're using StringFieldGenerator for a field with a ctype, it's
- // because that ctype isn't actually implemented. In particular, this is
- // true of ctype=CORD and ctype=STRING_PIECE in the open source release.
- // We aren't releasing Cord because it has too many Google-specific
- // dependencies and we aren't releasing StringPiece because it's hardly
- // useful outside of Google and because it would get confusing to have
- // multiple instances of the StringPiece class in different libraries (PCRE
- // already includes it for their C++ bindings, which came from Google).
- //
- // In any case, we make all the accessors private while still actually
- // using a string to represent the field internally. This way, we can
- // guarantee that if we do ever implement the ctype, it won't break any
- // existing users who might be -- for whatever reason -- already using .proto
- // files that applied the ctype. The field can still be accessed via the
- // reflection interface since the reflection interface is independent of
- // the string's underlying representation.
-
- bool unknown_ctype = descriptor_->options().ctype() !=
- EffectiveStringCType(descriptor_, options_);
-
- if (unknown_ctype) {
- format.Outdent();
- format(
- " private:\n"
- " // Hidden due to unknown ctype option.\n");
- format.Indent();
- }
-
- format(
- "$deprecated_attr$const TProtoStringType& ${1$$name$$}$() const;\n"
- "template <typename ArgT0 = const TProtoStringType&, typename... ArgT>\n"
- "$deprecated_attr$void ${1$set_$name$$}$(ArgT0&& arg0, ArgT... args);\n",
- descriptor_);
- format(
- "$deprecated_attr$TProtoStringType* ${1$mutable_$name$$}$();\n"
- "PROTOBUF_NODISCARD $deprecated_attr$TProtoStringType* "
- "${1$$release_name$$}$();\n"
- "$deprecated_attr$void ${1$set_allocated_$name$$}$(TProtoStringType* "
- "$name$);\n",
- descriptor_);
- format(
- "private:\n"
- "const TProtoStringType& _internal_$name$() const;\n"
- "inline PROTOBUF_ALWAYS_INLINE void "
- "_internal_set_$name$(const TProtoStringType& value);\n"
- "TProtoStringType* _internal_mutable_$name$();\n");
- if (inlined_) {
- format(
- "inline PROTOBUF_ALWAYS_INLINE bool _internal_$name$_donated() "
- "const;\n");
- }
- format("public:\n");
-
- if (unknown_ctype) {
- format.Outdent();
- format(" public:\n");
- format.Indent();
- }
-}
-
-void StringFieldGenerator::GenerateInlineAccessorDefinitions(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format(
- "inline const TProtoStringType& $classname$::$name$() const {\n"
- "$annotate_get$"
- " // @@protoc_insertion_point(field_get:$full_name$)\n");
- if (!descriptor_->default_value_string().empty()) {
- format(
- " if ($field$.IsDefault()) return "
- "$default_variable_field$.get();\n");
- }
- format(
- " return _internal_$name$();\n"
- "}\n");
- if (!inlined_) {
- format(
- "template <typename ArgT0, typename... ArgT>\n"
- "inline PROTOBUF_ALWAYS_INLINE\n"
- "void $classname$::set_$name$(ArgT0&& arg0, ArgT... args) {\n"
- "$maybe_prepare_split_message$"
- " $set_hasbit$\n"
- " $field$.$setter$(static_cast<ArgT0 &&>(arg0),"
- " args..., GetArenaForAllocation());\n"
- "$annotate_set$"
- " // @@protoc_insertion_point(field_set:$full_name$)\n"
- "}\n");
- } else {
- format(
- "template <typename ArgT0, typename... ArgT>\n"
- "inline PROTOBUF_ALWAYS_INLINE\n"
- "void $classname$::set_$name$(ArgT0&& arg0, ArgT... args) {\n"
- "$maybe_prepare_split_message$"
- " $set_hasbit$\n"
- " $field$.$setter$(static_cast<ArgT0 &&>(arg0),"
- " args..., GetArenaForAllocation(), _internal_$name$_donated(), "
- "&$donating_states_word$, $mask_for_undonate$, this);\n"
- "$annotate_set$"
- " // @@protoc_insertion_point(field_set:$full_name$)\n"
- "}\n"
- "inline bool $classname$::_internal_$name$_donated() const {\n"
- " bool value = $inlined_string_donated$\n"
- " return value;\n"
- "}\n");
- }
- format(
- "inline TProtoStringType* $classname$::mutable_$name$() {\n"
- "$maybe_prepare_split_message$"
- " TProtoStringType* _s = _internal_mutable_$name$();\n"
- "$annotate_mutable$"
- " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
- " return _s;\n"
- "}\n"
- "inline const TProtoStringType& $classname$::_internal_$name$() const {\n"
- " return $field$.Get();\n"
- "}\n"
- "inline void $classname$::_internal_set_$name$(const TProtoStringType& "
- "value) {\n"
- " $set_hasbit$\n");
- if (!inlined_) {
- format(
- " $field$.Set(value, GetArenaForAllocation());\n"
- "}\n");
- } else {
- format(
- " $field$.Set(value, GetArenaForAllocation(),\n"
- " _internal_$name$_donated(), &$donating_states_word$, "
- "$mask_for_undonate$, this);\n"
- "}\n");
- }
- format(
- "inline TProtoStringType* $classname$::_internal_mutable_$name$() {\n"
- " $set_hasbit$\n");
- if (!inlined_) {
- format(
- " return $field$.Mutable($lazy_variable_args$"
- "GetArenaForAllocation());\n"
- "}\n");
- } else {
- format(
- " return $field$.Mutable($lazy_variable_args$"
- "GetArenaForAllocation(), _internal_$name$_donated(), "
- "&$donating_states_word$, $mask_for_undonate$, this);\n"
- "}\n");
- }
- format(
- "inline TProtoStringType* $classname$::$release_name$() {\n"
- "$annotate_release$"
- "$maybe_prepare_split_message$"
- " // @@protoc_insertion_point(field_release:$full_name$)\n");
-
- if (HasHasbit(descriptor_)) {
- format(
- " if (!_internal_has_$name$()) {\n"
- " return nullptr;\n"
- " }\n"
- " $clear_hasbit$\n");
- if (!inlined_) {
- format(" auto* p = $field$.Release();\n");
- if (descriptor_->default_value_string().empty()) {
- format(
- "#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING\n"
- " if ($field$.IsDefault()) {\n"
- " $field$.Set(\"\", GetArenaForAllocation());\n"
- " }\n"
- "#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING\n");
- }
- format(" return p;\n");
- } else {
- format(
- " return $field$.Release(GetArenaForAllocation(), "
- "_internal_$name$_donated());\n");
- }
- } else {
- format(" return $field$.Release();\n");
- }
-
- format(
- "}\n"
- "inline void $classname$::set_allocated_$name$(TProtoStringType* $name$) {\n"
- "$maybe_prepare_split_message$"
- " if ($name$ != nullptr) {\n"
- " $set_hasbit$\n"
- " } else {\n"
- " $clear_hasbit$\n"
- " }\n");
- if (!inlined_) {
- format(" $field$.SetAllocated($name$, GetArenaForAllocation());\n");
- if (descriptor_->default_value_string().empty()) {
- format(
- "#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING\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(
- " $field$.SetAllocated(nullptr, $name$, GetArenaForAllocation(), "
- "_internal_$name$_donated(), &$donating_states_word$, "
- "$mask_for_undonate$, this);\n");
- }
- format(
- "$annotate_set$"
- " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
- "}\n");
-}
-
-void StringFieldGenerator::GenerateNonInlineAccessorDefinitions(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- if (!descriptor_->default_value_string().empty()) {
- format(
- "const ::$proto_ns$::internal::LazyString "
- "$classname$::$default_variable_field$"
- "{{{$default$, $default_length$}}, {nullptr}};\n");
- }
-}
-
-void StringFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
- Formatter format(printer, variables_);
- if (descriptor_->default_value_string().empty()) {
- format("$field$.ClearToEmpty();\n");
- } else {
- GOOGLE_DCHECK(!inlined_);
- format(
- "$field$.ClearToDefault($lazy_variable$, GetArenaForAllocation());\n");
- }
-}
-
-void StringFieldGenerator::GenerateMessageClearingCode(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- // Two-dimension specialization here: supporting arenas, field presence, or
- // not, and default value is the empty string or not. Complexity here ensures
- // the minimal number of branches / amount of extraneous code at runtime
- // (given that the below methods are inlined one-liners)!
-
- // If we have a hasbit, then the Clear() method of the protocol buffer
- // will have checked that this field is set. If so, we can avoid redundant
- // checks against the default variable.
- const bool must_be_present = HasHasbit(descriptor_);
-
- if (inlined_ && must_be_present) {
- // Calling mutable_$name$() gives us a string reference and sets the has bit
- // for $name$ (in proto2). We may get here when the string field is inlined
- // but the string's contents have not been changed by the user, so we cannot
- // make an assertion about the contents of the string and could never make
- // an assertion about the string instance.
- //
- // For non-inlined strings, we distinguish from non-default by comparing
- // instances, rather than contents.
- format("$DCHK$(!$field$.IsDefault());\n");
- }
-
- if (descriptor_->default_value_string().empty()) {
- if (must_be_present) {
- format("$field$.ClearNonDefaultToEmpty();\n");
- } else {
- 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(
- "$field$.ClearToDefault($lazy_variable$, GetArenaForAllocation());\n ");
- }
-}
-
-void StringFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
- Formatter format(printer, variables_);
- // TODO(gpike): improve this
- format("_this->_internal_set_$name$(from._internal_$name$());\n");
-}
-
-void StringFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
- Formatter format(printer, variables_);
- if (!inlined_) {
- format(
- "::$proto_ns$::internal::ArenaStringPtr::InternalSwap(\n"
- " &$field$, lhs_arena,\n"
- " &other->$field$, rhs_arena\n"
- ");\n");
- } else {
- format(
- "::$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()) {
- return;
- }
- GOOGLE_DCHECK(!inlined_);
- format("$field$.InitDefault();\n");
- if (IsString(descriptor_, options_) &&
- descriptor_->default_value_string().empty()) {
- format(
- "#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING\n"
- " $field$.Set(\"\", GetArenaForAllocation());\n"
- "#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING\n");
- }
-}
-
-void StringFieldGenerator::GenerateCreateSplitMessageCode(
- io::Printer* printer) const {
- GOOGLE_CHECK(ShouldSplit(descriptor_, options_));
- GOOGLE_CHECK(!inlined_);
- Formatter format(printer, variables_);
- format("ptr->$name$_.InitDefault();\n");
- if (IsString(descriptor_, options_) &&
- descriptor_->default_value_string().empty()) {
- format(
- "#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING\n"
- " ptr->$name$_.Set(\"\", GetArenaForAllocation());\n"
- "#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING\n");
- }
-}
-
-void StringFieldGenerator::GenerateCopyConstructorCode(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- GenerateConstructorCode(printer);
- if (inlined_) {
- format("new (&_this->$field$) ::_pbi::InlinedStringField();\n");
- }
-
- if (HasHasbit(descriptor_)) {
- format("if (from._internal_has_$name$()) {\n");
- } else {
- format("if (!from._internal_$name$().empty()) {\n");
- }
-
- format.Indent();
-
- if (!inlined_) {
- format(
- "_this->$field$.Set(from._internal_$name$(), \n"
- " _this->GetArenaForAllocation());\n");
- } else {
- format(
- "_this->$field$.Set(from._internal_$name$(),\n"
- " _this->GetArenaForAllocation(), _this->_internal_$name$_donated(), "
- "&_this->$donating_states_word$, $mask_for_undonate$, _this);\n");
- }
-
- format.Outdent();
- format("}\n");
-}
-
-void StringFieldGenerator::GenerateDestructorCode(io::Printer* printer) const {
- Formatter format(printer, variables_);
- if (!inlined_) {
- if (ShouldSplit(descriptor_, options_)) {
- format("$cached_split_ptr$->$name$_.Destroy();\n");
- return;
- }
- 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).
- GOOGLE_DCHECK(!ShouldSplit(descriptor_, options_));
- format("$field$.~InlinedStringField();\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(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
- GenerateUtf8CheckCodeForString(
- descriptor_, options_, false,
- "this->_internal_$name$().data(), "
- "static_cast<int>(this->_internal_$name$().length()),\n",
- format);
- }
- format(
- "target = stream->Write$declared_type$MaybeAliased(\n"
- " $number$, this->_internal_$name$(), target);\n");
-}
-
-void StringFieldGenerator::GenerateByteSize(io::Printer* printer) const {
- Formatter format(printer, variables_);
- format(
- "total_size += $tag_size$ +\n"
- " ::$proto_ns$::internal::WireFormatLite::$declared_type$Size(\n"
- " this->_internal_$name$());\n");
-}
-
-void StringFieldGenerator::GenerateConstexprAggregateInitializer(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- if (inlined_) {
- format("/*decltype($field$)*/{nullptr, false}");
- return;
- }
- if (descriptor_->default_value_string().empty()) {
- format(
- "/*decltype($field$)*/{&::_pbi::fixed_address_empty_string, "
- "::_pbi::ConstantInitialized{}}");
- } else {
- format("/*decltype($field$)*/{nullptr, ::_pbi::ConstantInitialized{}}");
- }
-}
-
-void StringFieldGenerator::GenerateAggregateInitializer(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- if (ShouldSplit(descriptor_, options_)) {
- GOOGLE_CHECK(!inlined_);
- format("decltype(Impl_::Split::$name$_){}");
- return;
- }
- if (!inlined_) {
- format("decltype($field$){}");
- } else {
- format("decltype($field$)(arena)");
- }
-}
-
-void StringFieldGenerator::GenerateCopyAggregateInitializer(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("decltype($field$){}");
-}
-
-// ===================================================================
-
-StringOneofFieldGenerator::StringOneofFieldGenerator(
- const FieldDescriptor* descriptor, const Options& options)
- : StringFieldGenerator(descriptor, options) {
- SetCommonOneofFieldVariables(descriptor, &variables_);
- variables_["field_name"] = UnderscoresToCamelCase(descriptor->name(), true);
- variables_["oneof_index"] =
- StrCat(descriptor->containing_oneof()->index());
-}
-
-StringOneofFieldGenerator::~StringOneofFieldGenerator() {}
-
-void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format(
- "inline const TProtoStringType& $classname$::$name$() const {\n"
- "$annotate_get$"
- " // @@protoc_insertion_point(field_get:$full_name$)\n"
- " return _internal_$name$();\n"
- "}\n"
- "template <typename ArgT0, typename... ArgT>\n"
- "inline void $classname$::set_$name$(ArgT0&& arg0, ArgT... args) {\n"
- " if (!_internal_has_$name$()) {\n"
- " clear_$oneof_name$();\n"
- " set_has_$name$();\n"
- " $field$.InitDefault();\n"
- " }\n"
- " $field$.$setter$("
- " static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());\n"
- "$annotate_set$"
- " // @@protoc_insertion_point(field_set:$full_name$)\n"
- "}\n"
- "inline TProtoStringType* $classname$::mutable_$name$() {\n"
- " TProtoStringType* _s = _internal_mutable_$name$();\n"
- "$annotate_mutable$"
- " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
- " return _s;\n"
- "}\n"
- "inline const TProtoStringType& $classname$::_internal_$name$() const {\n"
- " if (_internal_has_$name$()) {\n"
- " return $field$.Get();\n"
- " }\n"
- " return $default_string$;\n"
- "}\n"
- "inline void $classname$::_internal_set_$name$(const TProtoStringType& "
- "value) {\n"
- " if (!_internal_has_$name$()) {\n"
- " clear_$oneof_name$();\n"
- " set_has_$name$();\n"
- " $field$.InitDefault();\n"
- " }\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$.InitDefault();\n"
- " }\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$.Release();\n"
- " } else {\n"
- " return nullptr;\n"
- " }\n"
- "}\n"
- "inline void $classname$::set_allocated_$name$(TProtoStringType* $name$) {\n"
- " if (has_$oneof_name$()) {\n"
- " clear_$oneof_name$();\n"
- " }\n"
- " if ($name$ != nullptr) {\n"
- " set_has_$name$();\n"
- " $field$.InitAllocated($name$, GetArenaForAllocation());\n"
- " }\n"
- "$annotate_set$"
- " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
- "}\n");
-}
-
-void StringOneofFieldGenerator::GenerateClearingCode(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("$field$.Destroy();\n");
-}
-
-void StringOneofFieldGenerator::GenerateMessageClearingCode(
- io::Printer* printer) const {
- return GenerateClearingCode(printer);
-}
-
-void StringOneofFieldGenerator::GenerateSwappingCode(
- io::Printer* printer) const {
- // Don't print any swapping code. Swapping the union will swap this field.
-}
-
-void StringOneofFieldGenerator::GenerateConstructorCode(
- io::Printer* printer) const {
- // Nothing required here.
-}
-
-// ===================================================================
-
-RepeatedStringFieldGenerator::RepeatedStringFieldGenerator(
- const FieldDescriptor* descriptor, const Options& options)
- : FieldGenerator(descriptor, options) {
- SetStringVariables(descriptor, &variables_, options);
-}
-
-RepeatedStringFieldGenerator::~RepeatedStringFieldGenerator() {}
-
-void RepeatedStringFieldGenerator::GeneratePrivateMembers(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("::$proto_ns$::RepeatedPtrField<TProtoStringType> $name$_;\n");
-}
-
-void RepeatedStringFieldGenerator::GenerateAccessorDeclarations(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- // See comment above about unknown ctypes.
- bool unknown_ctype = descriptor_->options().ctype() !=
- EffectiveStringCType(descriptor_, options_);
-
- if (unknown_ctype) {
- format.Outdent();
- format(
- " private:\n"
- " // Hidden due to unknown ctype option.\n");
- format.Indent();
- }
-
- format(
- "$deprecated_attr$const TProtoStringType& ${1$$name$$}$(int index) const;\n"
- "$deprecated_attr$TProtoStringType* ${1$mutable_$name$$}$(int index);\n"
- "$deprecated_attr$void ${1$set_$name$$}$(int index, const "
- "TProtoStringType& value);\n"
- "$deprecated_attr$void ${1$set_$name$$}$(int index, TProtoStringType&& "
- "value);\n"
- "$deprecated_attr$void ${1$set_$name$$}$(int index, const "
- "char* value);\n",
- descriptor_);
- if (!options_.opensource_runtime) {
- format(
- "$deprecated_attr$void ${1$set_$name$$}$(int index, "
- "StringPiece value);\n",
- descriptor_);
- }
- format(
- "$deprecated_attr$void ${1$set_$name$$}$("
- "int index, const $pointer_type$* value, size_t size);\n"
- "$deprecated_attr$TProtoStringType* ${1$add_$name$$}$();\n"
- "$deprecated_attr$void ${1$add_$name$$}$(const TProtoStringType& value);\n"
- "$deprecated_attr$void ${1$add_$name$$}$(TProtoStringType&& value);\n"
- "$deprecated_attr$void ${1$add_$name$$}$(const char* value);\n",
- descriptor_);
- if (!options_.opensource_runtime) {
- format(
- "$deprecated_attr$void ${1$add_$name$$}$(StringPiece value);\n",
- descriptor_);
- }
- format(
- "$deprecated_attr$void ${1$add_$name$$}$(const $pointer_type$* "
- "value, size_t size)"
- ";\n"
- "$deprecated_attr$const ::$proto_ns$::RepeatedPtrField<TProtoStringType>& "
- "${1$$name$$}$() "
- "const;\n"
- "$deprecated_attr$::$proto_ns$::RepeatedPtrField<TProtoStringType>* "
- "${1$mutable_$name$$}$()"
- ";\n"
- "private:\n"
- "const TProtoStringType& ${1$_internal_$name$$}$(int index) const;\n"
- "TProtoStringType* _internal_add_$name$();\n"
- "public:\n",
- descriptor_);
-
- if (unknown_ctype) {
- format.Outdent();
- format(" public:\n");
- format.Indent();
- }
-}
-
-void RepeatedStringFieldGenerator::GenerateInlineAccessorDefinitions(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format(
- "inline TProtoStringType* $classname$::add_$name$() {\n"
- " TProtoStringType* _s = _internal_add_$name$();\n"
- "$annotate_add_mutable$"
- " // @@protoc_insertion_point(field_add_mutable:$full_name$)\n"
- " return _s;\n"
- "}\n");
- if (options_.safe_boundary_check) {
- format(
- "inline const TProtoStringType& $classname$::_internal_$name$(int index) "
- "const {\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 $field$.Get(index);\n"
- "}\n");
- }
- format(
- "inline const TProtoStringType& $classname$::$name$(int index) const {\n"
- "$annotate_get$"
- " // @@protoc_insertion_point(field_get:$full_name$)\n"
- " return _internal_$name$(index);\n"
- "}\n"
- "inline TProtoStringType* $classname$::mutable_$name$(int index) {\n"
- "$annotate_mutable$"
- " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
- " return $field$.Mutable(index);\n"
- "}\n"
- "inline void $classname$::set_$name$(int index, const TProtoStringType& "
- "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"
- " $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$"
- " $field$.Mutable(index)->assign(value);\n"
- "$annotate_set$"
- " // @@protoc_insertion_point(field_set_char:$full_name$)\n"
- "}\n");
- if (!options_.opensource_runtime) {
- format(
- "inline void "
- "$classname$::set_$name$(int index, StringPiece value) {\n"
- " $field$.Mutable(index)->assign(value.data(), value.size());\n"
- "$annotate_set$"
- " // @@protoc_insertion_point(field_set_string_piece:$full_name$)\n"
- "}\n");
- }
- format(
- "inline void "
- "$classname$::set_$name$"
- "(int index, const $pointer_type$* value, size_t size) {\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 $field$.Add();\n"
- "}\n"
- "inline void $classname$::add_$name$(const TProtoStringType& 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"
- " $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$"
- " $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"
- " $field$.Add()->assign(value.data(), value.size());\n"
- "$annotate_add$"
- " // @@protoc_insertion_point(field_add_string_piece:$full_name$)\n"
- "}\n");
- }
- format(
- "inline void "
- "$classname$::add_$name$(const $pointer_type$* value, size_t size) {\n"
- " $field$.Add()->assign(reinterpret_cast<const char*>(value), size);\n"
- "$annotate_add$"
- " // @@protoc_insertion_point(field_add_pointer:$full_name$)\n"
- "}\n"
- "inline const ::$proto_ns$::RepeatedPtrField<TProtoStringType>&\n"
- "$classname$::$name$() const {\n"
- "$annotate_list$"
- " // @@protoc_insertion_point(field_list:$full_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 &$field$;\n"
- "}\n");
-}
-
-void RepeatedStringFieldGenerator::GenerateClearingCode(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("$field$.Clear();\n");
-}
-
-void RepeatedStringFieldGenerator::GenerateMergingCode(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("_this->$field$.MergeFrom(from.$field$);\n");
-}
-
-void RepeatedStringFieldGenerator::GenerateSwappingCode(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("$field$.InternalSwap(&other->$field$);\n");
-}
-
-void RepeatedStringFieldGenerator::GenerateDestructorCode(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("$field$.~RepeatedPtrField();\n");
-}
-
-void RepeatedStringFieldGenerator::GenerateSerializeWithCachedSizesToArray(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format(
- "for (int i = 0, n = this->_internal_$name$_size(); i < n; i++) {\n"
- " const auto& s = this->_internal_$name$(i);\n");
- // format("for (const TProtoStringType& s : this->$name$()) {\n");
- format.Indent();
- if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
- GenerateUtf8CheckCodeForString(descriptor_, options_, false,
- "s.data(), static_cast<int>(s.length()),\n",
- format);
- }
- format.Outdent();
- format(
- " target = stream->Write$declared_type$($number$, s, target);\n"
- "}\n");
-}
-
-void RepeatedStringFieldGenerator::GenerateByteSize(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format(
- "total_size += $tag_size$ *\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"
- " $field$.Get(i));\n"
- "}\n");
-}
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/string_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/string_field.h
deleted file mode 100644
index db5f18bfb7d..00000000000
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/string_field.h
+++ /dev/null
@@ -1,136 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_STRING_FIELD_H__
-#define GOOGLE_PROTOBUF_COMPILER_CPP_STRING_FIELD_H__
-
-#include <map>
-#include <string>
-
-#include <google/protobuf/compiler/cpp/field.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-class StringFieldGenerator : public FieldGenerator {
- public:
- StringFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
- ~StringFieldGenerator() override;
-
- // implements FieldGenerator ---------------------------------------
- void GeneratePrivateMembers(io::Printer* printer) const override;
- void GenerateStaticMembers(io::Printer* printer) const override;
- void GenerateAccessorDeclarations(io::Printer* printer) const override;
- void GenerateInlineAccessorDefinitions(io::Printer* printer) const override;
- void GenerateNonInlineAccessorDefinitions(
- io::Printer* printer) const override;
- void GenerateClearingCode(io::Printer* printer) const override;
- void GenerateMessageClearingCode(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 GenerateCreateSplitMessageCode(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 GenerateConstexprAggregateInitializer(
- io::Printer* printer) const override;
- void GenerateAggregateInitializer(io::Printer* printer) const override;
- void GenerateCopyAggregateInitializer(io::Printer* printer) const override;
- bool IsInlined() const override { return inlined_; }
- ArenaDtorNeeds NeedsArenaDestructor() const override;
-
- private:
- bool inlined_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringFieldGenerator);
-};
-
-class StringOneofFieldGenerator : public StringFieldGenerator {
- public:
- StringOneofFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
- ~StringOneofFieldGenerator() override;
-
- // implements FieldGenerator ---------------------------------------
- void GenerateInlineAccessorDefinitions(io::Printer* printer) const override;
- void GenerateClearingCode(io::Printer* printer) const override;
-
- // StringFieldGenerator, from which we inherit, overrides this so we need to
- // override it as well.
- void GenerateMessageClearingCode(io::Printer* printer) const override;
- void GenerateSwappingCode(io::Printer* printer) const override;
- void GenerateConstructorCode(io::Printer* printer) const override;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringOneofFieldGenerator);
-};
-
-class RepeatedStringFieldGenerator : public FieldGenerator {
- public:
- RepeatedStringFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
- ~RepeatedStringFieldGenerator() override;
-
- // implements FieldGenerator ---------------------------------------
- void GeneratePrivateMembers(io::Printer* printer) const override;
- void GenerateAccessorDeclarations(io::Printer* printer) const override;
- void GenerateInlineAccessorDefinitions(io::Printer* printer) const override;
- 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 {
- GOOGLE_CHECK(!ShouldSplit(descriptor_, options_));
- }
- void GenerateDestructorCode(io::Printer* printer) const override;
- void GenerateSerializeWithCachedSizesToArray(
- io::Printer* printer) const override;
- void GenerateByteSize(io::Printer* printer) const override;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedStringFieldGenerator);
-};
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_CPP_STRING_FIELD_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/tracker.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/tracker.cc
new file mode 100644
index 00000000000..77c45a8ee54
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/tracker.cc
@@ -0,0 +1,339 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2022 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/cpp/tracker.h"
+
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "google/protobuf/descriptor.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/strings/substitute.h"
+#include "y_absl/types/optional.h"
+#include "google/protobuf/compiler/cpp/helpers.h"
+#include "google/protobuf/compiler/cpp/options.h"
+#include "google/protobuf/io/printer.h"
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+namespace {
+using Sub = ::google::protobuf::io::Printer::Sub;
+
+constexpr y_absl::string_view kTracker = "Impl_::_tracker_";
+constexpr y_absl::string_view kVarPrefix = "annotate_";
+constexpr y_absl::string_view kTypeTraits = "_proto_TypeTraits";
+
+struct Call {
+ Call(y_absl::string_view var, y_absl::string_view call) : var(var), call(call) {}
+ Call(y_absl::optional<int> field_index, y_absl::string_view var,
+ y_absl::string_view call)
+ : var(var), call(call), field_index(field_index) {}
+
+ Call This(y_absl::optional<y_absl::string_view> thiz) && {
+ this->thiz = thiz;
+ return std::move(*this);
+ }
+
+ template <typename... SubArgs>
+ Call Arg(y_absl::string_view format, const SubArgs&... args) && {
+ this->args.emplace_back(y_absl::Substitute(format, args...));
+ return std::move(*this);
+ }
+
+ Call Suppressed() && {
+ suppressed = true;
+ return std::move(*this);
+ }
+
+ y_absl::string_view var;
+ y_absl::string_view call;
+ y_absl::optional<int> field_index;
+ y_absl::optional<y_absl::string_view> thiz = "this";
+ std::vector<TProtoStringType> args;
+ bool suppressed = false;
+};
+
+std::vector<Sub> GenerateTrackerCalls(
+ const Options& opts, const Descriptor* message,
+ y_absl::optional<TProtoStringType> alt_annotation, y_absl::Span<const Call> calls) {
+ bool enable_tracking = HasTracker(message, opts);
+ const auto& forbidden =
+ opts.field_listener_options.forbidden_field_listener_events;
+
+ std::vector<Sub> subs;
+ for (const auto& call : calls) {
+ TProtoStringType call_str;
+ if (enable_tracking && !call.suppressed && !forbidden.contains(call.var)) {
+ y_absl::SubstituteAndAppend(&call_str, "$0.$1", kTracker, call.call);
+ if (call.field_index.has_value()) {
+ y_absl::SubstituteAndAppend(&call_str, "<$0>", *call.field_index);
+ }
+ y_absl::StrAppend(&call_str, "(");
+
+ y_absl::string_view arg_sep = "";
+ if (call.thiz.has_value()) {
+ y_absl::StrAppend(&call_str, *call.thiz);
+ arg_sep = ", ";
+ }
+
+ for (const auto& arg : call.args) {
+ y_absl::StrAppend(&call_str, arg_sep, arg);
+ arg_sep = ", ";
+ }
+
+ y_absl::StrAppend(&call_str, ");");
+ } else if (opts.annotate_accessor && alt_annotation.has_value()) {
+ call_str = *alt_annotation;
+ }
+
+ if (!call_str.empty()) {
+ // TODO(b/245791219): Until we migrate all of the C++ backend to use
+ // Emit(), we need to include a newline here so that the line that follows
+ // the annotation is on its own line.
+ call_str.push_back('\n');
+ }
+
+ subs.push_back(
+ Sub(y_absl::StrCat(kVarPrefix, call.var), call_str).WithSuffix(";"));
+ }
+
+ return subs;
+}
+} // namespace
+
+std::vector<Sub> MakeTrackerCalls(const Descriptor* message,
+ const Options& opts) {
+ y_absl::string_view extns =
+ IsMapEntryMessage(message) ? "_extensions_" : "_impl_._extensions_";
+
+ auto primitive_extn_accessor = [extns](y_absl::string_view var,
+ y_absl::string_view call) {
+ return Call(var, call)
+ .Arg("id.number()")
+ .Arg("$0::GetPtr(id.number(), $1, id.default_value_ref())", kTypeTraits,
+ extns);
+ };
+
+ auto index_extn_accessor = [extns](y_absl::string_view var,
+ y_absl::string_view call) {
+ return Call(var, call)
+ .Arg("id.number()")
+ .Arg("$0::GetPtr(id.number(), $1, index)", kTypeTraits, extns);
+ };
+
+ auto add_extn_accessor = [extns](y_absl::string_view var,
+ y_absl::string_view call) {
+ return Call(var, call)
+ .Arg("id.number()")
+ .Arg("$0::GetPtr(id.number(), $1, $1.ExtensionSize(id.number()) - 1)",
+ kTypeTraits, extns);
+ };
+
+ auto list_extn_accessor = [extns](y_absl::string_view var,
+ y_absl::string_view call) {
+ return Call(var, call)
+ .Arg("id.number()")
+ .Arg("$0::GetRepeatedPtr(id.number(), $1)", kTypeTraits, extns);
+ };
+
+ return GenerateTrackerCalls(
+ opts, message, y_absl::nullopt,
+ {
+ Call("serialize", "OnSerialize"),
+ Call("deserialize", "OnDeserialize"),
+ // TODO(danilak): Ideally annotate_reflection should not exist and we
+ // need to annotate all reflective calls on our own, however, as this
+ // is a cause for side effects, i.e. reading values dynamically, we
+ // want the users know that dynamic access can happen.
+ Call("reflection", "OnGetMetadata").This(y_absl::nullopt),
+ Call("bytesize", "OnByteSize"),
+ Call("mergefrom", "OnMergeFrom").This("_this").Arg("&from"),
+
+ // "Has" is here as users calling "has" on a repeated field is a
+ // mistake.
+ primitive_extn_accessor("extension_has", "OnHasExtension"),
+ primitive_extn_accessor("extension_get", "OnGetExtension"),
+ primitive_extn_accessor("extension_mutable", "OnMutableExtension"),
+ primitive_extn_accessor("extension_set", "OnSetExtension"),
+ primitive_extn_accessor("extension_release", "OnReleaseExtension"),
+
+ index_extn_accessor("repeated_extension_get", "OnGetExtension"),
+ index_extn_accessor("repeated_extension_mutable",
+ "OnMutableExtension"),
+ index_extn_accessor("repeated_extension_set", "OnSetExtension"),
+
+ add_extn_accessor("repeated_extension_add", "OnAddExtension"),
+ add_extn_accessor("repeated_extension_add_mutable",
+ "OnAddMutableExtension"),
+
+ list_extn_accessor("extension_repeated_size", "OnExtensionSize"),
+ list_extn_accessor("repeated_extension_list", "OnListExtension"),
+ list_extn_accessor("repeated_extension_list_mutable",
+ "OnMutableListExtension"),
+
+ // Generic accessors such as "clear".
+ // TODO(b/190614678): Generalize clear from both repeated and non
+ // repeated calls, currently their underlying memory interfaces are
+ // very different. Or think of removing clear callback as no usages
+ // are needed and no memory exist
+ Call("extension_clear", "OnClearExtension").Suppressed(),
+ });
+}
+
+namespace {
+struct Getters {
+ TProtoStringType base = "nullptr";
+ TProtoStringType for_last = "nullptr";
+ TProtoStringType for_flat = "nullptr";
+};
+
+Getters RepeatedFieldGetters(const FieldDescriptor* field,
+ const Options& opts) {
+ TProtoStringType member = FieldMemberName(field, ShouldSplit(field, opts));
+
+ Getters getters;
+ if (!field->is_map() &&
+ field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) {
+ getters.base = y_absl::Substitute("&$0.Get(index)", member);
+ getters.for_last = y_absl::Substitute("&$0.Get($0.size() - 1)", member);
+ getters.for_flat = y_absl::StrCat("&", member);
+ }
+
+ return getters;
+}
+
+Getters StringFieldGetters(const FieldDescriptor* field, const Options& opts) {
+ TProtoStringType member = FieldMemberName(field, ShouldSplit(field, opts));
+ bool is_std_string = field->options().ctype() == FieldOptions::STRING;
+
+ Getters getters;
+ if (is_std_string && !field->default_value_string().empty()) {
+ getters.base =
+ y_absl::Substitute("$0.IsDefault() ? &$1.get() : $0.UnsafeGetPointer()",
+ member, MakeDefaultFieldName(field));
+ } else {
+ getters.base = y_absl::StrCat("&", member);
+ }
+
+ getters.for_flat = getters.base;
+ return getters;
+}
+
+Getters StringOneofGetters(const FieldDescriptor* field,
+ const OneofDescriptor* oneof, const Options& opts) {
+ Y_ABSL_CHECK(oneof != nullptr);
+
+ TProtoStringType member = FieldMemberName(field, ShouldSplit(field, opts));
+ bool is_std_string = field->options().ctype() == FieldOptions::STRING;
+
+ TProtoStringType field_ptr = member;
+ if (is_std_string) {
+ field_ptr = y_absl::Substitute("$0.UnsafeGetPointer()", member);
+ }
+
+ TProtoStringType has =
+ y_absl::Substitute("$0_case() == k$1", oneof->name(),
+ UnderscoresToCamelCase(field->name(), true));
+
+ TProtoStringType default_field = MakeDefaultFieldName(field);
+ if (is_std_string) {
+ y_absl::StrAppend(&default_field, ".get()");
+ }
+
+ Getters getters;
+ if (field->default_value_string().empty() ||
+ field->options().ctype() == FieldOptions::STRING_PIECE) {
+ getters.base = y_absl::Substitute("$0 ? $1 : nullptr", has, field_ptr);
+ } else {
+ getters.base =
+ y_absl::Substitute("$0 ? $1 : &$2", has, field_ptr, default_field);
+ }
+
+ getters.for_flat = getters.base;
+ return getters;
+}
+
+Getters SingularFieldGetters(const FieldDescriptor* field,
+ const Options& opts) {
+ TProtoStringType member = FieldMemberName(field, ShouldSplit(field, opts));
+
+ Getters getters;
+ getters.base = y_absl::StrCat("&", member);
+ if (field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) {
+ getters.for_flat = y_absl::StrCat("&", member);
+ }
+ return getters;
+}
+} // namespace
+
+std::vector<Sub> MakeTrackerCalls(const FieldDescriptor* field,
+ const Options& opts) {
+ Getters getters;
+ if (field->is_repeated()) {
+ getters = RepeatedFieldGetters(field, opts);
+ } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {
+ const auto* oneof = field->real_containing_oneof();
+ if (oneof != nullptr) {
+ getters = StringOneofGetters(field, oneof, opts);
+ } else {
+ getters = StringFieldGetters(field, opts);
+ }
+ } else if (field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE ||
+ IsExplicitLazy(field)) {
+ getters = SingularFieldGetters(field, opts);
+ }
+
+ auto index = field->index();
+ return GenerateTrackerCalls(
+ opts, field->containing_type(),
+ y_absl::Substitute("$0_AccessedNoStrip = true;", FieldName(field)),
+ {
+ Call(index, "get", "OnGet").Arg(getters.base),
+ Call(index, "set", "OnSet").Arg(getters.base),
+ Call(index, "has", "OnHas").Arg(getters.base),
+ Call(index, "mutable", "OnMutable").Arg(getters.base),
+ Call(index, "release", "OnRelease").Arg(getters.base),
+ Call(index, "clear", "OnClear").Arg(getters.for_flat),
+ Call(index, "size", "OnSize").Arg(getters.for_flat),
+ Call(index, "list", "OnList").Arg(getters.for_flat),
+ Call(index, "mutable_list", "OnMutableList").Arg(getters.for_flat),
+ Call(index, "add", "OnAdd").Arg(getters.for_last),
+ Call(index, "add_mutable", "OnAddMutable").Arg(getters.for_last),
+ });
+}
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/tracker.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/tracker.h
new file mode 100644
index 00000000000..9f00495291e
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/tracker.h
@@ -0,0 +1,58 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2022 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_CPP_TRACKER_H__
+#define GOOGLE_PROTOBUF_COMPILER_CPP_TRACKER_H__
+
+#include <vector>
+
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/compiler/cpp/options.h"
+#include "google/protobuf/io/printer.h"
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
+// Generates printer substitutions for message-level tracker callbacks.
+std::vector<google::protobuf::io::Printer::Sub> MakeTrackerCalls(
+ const google::protobuf::Descriptor* message, const Options& opts);
+
+// Generates printer substitutions for field-specific tracker callbacks.
+std::vector<google::protobuf::io::Printer::Sub> MakeTrackerCalls(
+ const google::protobuf::FieldDescriptor* field, const Options& opts);
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+#endif // GOOGLE_PROTOBUF_COMPILER_CPP_TRACKER_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc
index e6f5a7ab963..1fc71f3d284 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc
@@ -31,10 +31,12 @@
// Author: [email protected] (Kenton Varda)
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/csharp/csharp_doc_comment.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
+#include "google/protobuf/compiler/csharp/csharp_doc_comment.h"
+
+#include "y_absl/strings/str_replace.h"
+#include "y_absl/strings/str_split.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
@@ -54,10 +56,9 @@ void WriteDocCommentBodyImpl(io::Printer* printer, SourceLocation location) {
}
// XML escaping... no need for apostrophes etc as the whole text is going to be a child
// node of a summary element, not part of an attribute.
- comments = StringReplace(comments, "&", "&amp;", true);
- comments = StringReplace(comments, "<", "&lt;", true);
+ comments = y_absl::StrReplaceAll(comments, {{"&", "&amp;"}, {"<", "&lt;"}});
std::vector<TProtoStringType> lines;
- lines = Split(comments, "\n", false);
+ lines = y_absl::StrSplit(comments, "\n", y_absl::AllowEmpty());
// TODO: We really should work out which part to put in the summary and which to put in the remarks...
// but that needs to be part of a bigger effort to understand the markdown better anyway.
printer->Print("/// <summary>\n");
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_doc_comment.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_doc_comment.h
index 75eb0ea04d1..40c35ec0a7b 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_doc_comment.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_doc_comment.h
@@ -32,8 +32,8 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_DOC_COMMENT_H__
#define GOOGLE_PROTOBUF_COMPILER_CSHARP_DOC_COMMENT_H__
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/descriptor.h>
+#include "google/protobuf/io/printer.h"
+#include "google/protobuf/descriptor.h"
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum.cc
index c0ee9ef1910..489b3ad1bac 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum.cc
@@ -28,19 +28,21 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <sstream>
+#include "google/protobuf/compiler/csharp/csharp_enum.h"
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/descriptor.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>
+#include <sstream>
+#include <string>
-#include <google/protobuf/compiler/csharp/csharp_doc_comment.h>
-#include <google/protobuf/compiler/csharp/csharp_enum.h>
-#include <google/protobuf/compiler/csharp/csharp_helpers.h>
-#include <google/protobuf/compiler/csharp/csharp_options.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/csharp/csharp_doc_comment.h"
+#include "google/protobuf/compiler/csharp/csharp_helpers.h"
+#include "google/protobuf/compiler/csharp/csharp_options.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
@@ -57,35 +59,42 @@ EnumGenerator::~EnumGenerator() {
void EnumGenerator::Generate(io::Printer* printer) {
WriteEnumDocComment(printer, descriptor_);
+ if (descriptor_->options().deprecated()) {
+ printer->Print("[global::System.ObsoleteAttribute]\n");
+ }
printer->Print("$access_level$ enum $name$ {\n",
"access_level", class_access_level(),
"name", descriptor_->name());
printer->Indent();
- std::set<TProtoStringType> used_names;
- std::set<int> used_number;
+ y_absl::flat_hash_set<TProtoStringType> used_names;
+ y_absl::flat_hash_set<int> used_number;
for (int i = 0; i < descriptor_->value_count(); i++) {
WriteEnumValueDocComment(printer, descriptor_->value(i));
+ if (descriptor_->value(i)->options().deprecated()) {
+ printer->Print("[global::System.ObsoleteAttribute]\n");
+ }
TProtoStringType original_name = descriptor_->value(i)->name();
TProtoStringType name =
GetEnumValueName(descriptor_->name(), descriptor_->value(i)->name());
// Make sure we don't get any duplicate names due to prefix removal.
while (!used_names.insert(name).second) {
// It's possible we'll end up giving this warning multiple times, but that's better than not at all.
- GOOGLE_LOG(WARNING) << "Duplicate enum value " << name << " (originally " << original_name
- << ") in " << descriptor_->name() << "; adding underscore to distinguish";
- name += "_";
+ Y_ABSL_LOG(WARNING) << "Duplicate enum value " << name << " (originally "
+ << original_name << ") in " << descriptor_->name()
+ << "; adding underscore to distinguish";
+ y_absl::StrAppend(&name, "_");
}
int number = descriptor_->value(i)->number();
if (!used_number.insert(number).second) {
printer->Print("[pbr::OriginalName(\"$original_name$\", PreferredAlias = false)] $name$ = $number$,\n",
"original_name", original_name,
"name", name,
- "number", StrCat(number));
+ "number", y_absl::StrCat(number));
} else {
printer->Print("[pbr::OriginalName(\"$original_name$\")] $name$ = $number$,\n",
"original_name", original_name,
"name", name,
- "number", StrCat(number));
+ "number", y_absl::StrCat(number));
}
}
printer->Outdent();
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum.h
index dcbfba36df5..73f7b713d00 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum.h
@@ -33,10 +33,10 @@
#include <string>
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/compiler/csharp/csharp_source_generator_base.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/io/printer.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/compiler/csharp/csharp_source_generator_base.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum_field.cc
index 55fb60c504a..065e1cc5e99 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum_field.cc
@@ -28,18 +28,18 @@
// (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 <sstream>
+#include "google/protobuf/compiler/csharp/csharp_enum_field.h"
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/zero_copy_stream.h>
+#include <sstream>
-#include <google/protobuf/compiler/csharp/csharp_doc_comment.h>
-#include <google/protobuf/compiler/csharp/csharp_helpers.h>
-#include <google/protobuf/compiler/csharp/csharp_options.h>
-#include <google/protobuf/compiler/csharp/csharp_enum_field.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/compiler/csharp/csharp_doc_comment.h"
+#include "google/protobuf/compiler/csharp/csharp_helpers.h"
+#include "google/protobuf/compiler/csharp/csharp_options.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 {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum_field.h
index 5d1e5f0a99a..fe2328fd5fc 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum_field.h
@@ -31,8 +31,8 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_ENUM_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_CSHARP_ENUM_FIELD_H__
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/compiler/csharp/csharp_primitive_field.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/compiler/csharp/csharp_primitive_field.h"
namespace google {
namespace protobuf {
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 7b1806e1925..88df6e54956 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
@@ -28,22 +28,25 @@
// (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/csharp/csharp_field_base.h"
+
#include <cmath>
#include <limits>
#include <sstream>
+#include <string>
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/zero_copy_stream.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/wire_format.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "y_absl/log/absl_log.h"
+#include "google/protobuf/compiler/csharp/csharp_helpers.h"
+#include "google/protobuf/compiler/csharp/names.h"
+#include "google/protobuf/descriptor.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/compiler/csharp/csharp_field_base.h>
-#include <google/protobuf/compiler/csharp/csharp_helpers.h>
-#include <google/protobuf/compiler/csharp/csharp_names.h>
+// Must be last.
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -51,7 +54,7 @@ namespace compiler {
namespace csharp {
void FieldGeneratorBase::SetCommonFieldVariables(
- std::map<TProtoStringType, TProtoStringType>* variables) {
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables) {
// Note: this will be valid even though the tag emitted for packed and unpacked versions of
// repeated fields varies by wire format. The wire format is encoded in the bottom 3 bits, which
// never effects the tag size.
@@ -63,13 +66,13 @@ void FieldGeneratorBase::SetCommonFieldVariables(
uint tag = internal::WireFormat::MakeTag(descriptor_);
uint8_t tag_array[5];
io::CodedOutputStream::WriteTagToArray(tag, tag_array);
- TProtoStringType tag_bytes = StrCat(tag_array[0]);
+ TProtoStringType tag_bytes = y_absl::StrCat(tag_array[0]);
for (int i = 1; i < part_tag_size; i++) {
- tag_bytes += ", " + StrCat(tag_array[i]);
+ y_absl::StrAppend(&tag_bytes, ", ", tag_array[i]);
}
- (*variables)["tag"] = StrCat(tag);
- (*variables)["tag_size"] = StrCat(tag_size);
+ (*variables)["tag"] = y_absl::StrCat(tag);
+ (*variables)["tag_size"] = y_absl::StrCat(tag_size);
(*variables)["tag_bytes"] = tag_bytes;
if (descriptor_->type() == FieldDescriptor::Type::TYPE_GROUP) {
@@ -77,12 +80,12 @@ void FieldGeneratorBase::SetCommonFieldVariables(
descriptor_->number(),
internal::WireFormatLite::WIRETYPE_END_GROUP);
io::CodedOutputStream::WriteTagToArray(tag, tag_array);
- tag_bytes = StrCat(tag_array[0]);
+ tag_bytes = y_absl::StrCat(tag_array[0]);
for (int i = 1; i < part_tag_size; i++) {
- tag_bytes += ", " + StrCat(tag_array[i]);
+ y_absl::StrAppend(&tag_bytes, ", ", tag_array[i]);
}
- variables_["end_tag"] = StrCat(tag);
+ variables_["end_tag"] = y_absl::StrCat(tag);
variables_["end_tag_bytes"] = tag_bytes;
}
@@ -97,40 +100,53 @@ void FieldGeneratorBase::SetCommonFieldVariables(
(*variables)["capitalized_type_name"] = capitalized_type_name();
(*variables)["number"] = number();
if (has_default_value() && !SupportsPresenceApi(descriptor_)) {
- (*variables)["name_def_message"] =
- (*variables)["name"] + "_ = " + (*variables)["default_value"];
+ variables->insert({"name_def_message",
+ y_absl::StrCat((*variables)["name"],
+ "_ = ", (*variables)["default_value"])});
} else {
- (*variables)["name_def_message"] = (*variables)["name"] + "_";
+ variables->insert(
+ {"name_def_message", y_absl::StrCat((*variables)["name"], "_")});
}
if (SupportsPresenceApi(descriptor_)) {
- (*variables)["has_property_check"] = "Has" + (*variables)["property_name"];
- (*variables)["other_has_property_check"] = "other.Has" + (*variables)["property_name"];
- (*variables)["has_not_property_check"] = "!" + (*variables)["has_property_check"];
- (*variables)["other_has_not_property_check"] = "!" + (*variables)["other_has_property_check"];
+ variables->insert({"has_property_check",
+ y_absl::StrCat("Has", (*variables)["property_name"])});
+ variables->insert(
+ {"other_has_property_check",
+ y_absl::StrCat("other.Has", (*variables)["property_name"])});
+ variables->insert({"has_not_property_check",
+ y_absl::StrCat("!", (*variables)["has_property_check"])});
+ variables->insert(
+ {"other_has_not_property_check",
+ y_absl::StrCat("!", (*variables)["other_has_property_check"])});
if (presenceIndex_ != -1) {
- TProtoStringType hasBitsNumber = StrCat(presenceIndex_ / 32);
- TProtoStringType hasBitsMask = StrCat(1 << (presenceIndex_ % 32));
- (*variables)["has_field_check"] = "(_hasBits" + hasBitsNumber + " & " + hasBitsMask + ") != 0";
- (*variables)["set_has_field"] = "_hasBits" + hasBitsNumber + " |= " + hasBitsMask;
- (*variables)["clear_has_field"] = "_hasBits" + hasBitsNumber + " &= ~" + hasBitsMask;
+ const int hasBitsNumber = presenceIndex_ / 32;
+ const int hasBitsMask = 1 << (presenceIndex_ % 32);
+ (*variables)["has_field_check"] = y_absl::StrCat(
+ "(_hasBits", hasBitsNumber, " & ", hasBitsMask, ") != 0");
+ (*variables)["set_has_field"] =
+ y_absl::StrCat("_hasBits", hasBitsNumber, " |= ", hasBitsMask);
+ (*variables)["clear_has_field"] =
+ y_absl::StrCat("_hasBits", hasBitsNumber, " &= ~", hasBitsMask);
}
} else {
- (*variables)["has_property_check"] =
- (*variables)["property_name"] + " != " + (*variables)["default_value"];
- (*variables)["other_has_property_check"] = "other." +
- (*variables)["property_name"] + " != " + (*variables)["default_value"];
+ variables->insert({"has_property_check",
+ y_absl::StrCat((*variables)["property_name"],
+ " != ", (*variables)["default_value"])});
+ variables->insert({"other_has_property_check",
+ y_absl::StrCat("other.", (*variables)["property_name"],
+ " != ", (*variables)["default_value"])});
}
}
void FieldGeneratorBase::SetCommonOneofFieldVariables(
- std::map<TProtoStringType, TProtoStringType>* variables) {
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables) {
(*variables)["oneof_name"] = oneof_name();
if (SupportsPresenceApi(descriptor_)) {
- (*variables)["has_property_check"] = "Has" + property_name();
+ (*variables)["has_property_check"] = y_absl::StrCat("Has", property_name());
} else {
(*variables)["has_property_check"] =
- oneof_name() + "Case_ == " + oneof_property_name() +
- "OneofCase." + oneof_case_name();
+ y_absl::StrCat(oneof_name(), "Case_ == ", oneof_property_name(),
+ "OneofCase.", oneof_case_name());
}
(*variables)["oneof_case_name"] = oneof_case_name();
(*variables)["oneof_property_name"] = oneof_property_name();
@@ -228,7 +244,7 @@ TProtoStringType FieldGeneratorBase::type_name(const FieldDescriptor* descriptor
wrapped_field->type() == FieldDescriptor::TYPE_BYTES) {
return wrapped_field_type_name;
} else {
- return wrapped_field_type_name + "?";
+ return y_absl::StrCat(wrapped_field_type_name, "?");
}
}
return GetClassName(descriptor->message_type());
@@ -263,7 +279,7 @@ TProtoStringType FieldGeneratorBase::type_name(const FieldDescriptor* descriptor
case FieldDescriptor::TYPE_SINT64:
return "long";
default:
- GOOGLE_LOG(FATAL)<< "Unknown field type.";
+ Y_ABSL_LOG(FATAL) << "Unknown field type.";
return "";
}
}
@@ -305,12 +321,12 @@ bool FieldGeneratorBase::has_default_value() {
case FieldDescriptor::TYPE_SINT64:
return descriptor_->default_value_int64() != 0L;
default:
- GOOGLE_LOG(FATAL)<< "Unknown field type.";
+ Y_ABSL_LOG(FATAL) << "Unknown field type.";
return true;
}
}
-bool AllPrintableAscii(const TProtoStringType& text) {
+bool AllPrintableAscii(y_absl::string_view text) {
for(int i = 0; i < text.size(); i++) {
if (text[i] < 0x20 || text[i] > 0x7e) {
return false;
@@ -322,17 +338,19 @@ bool AllPrintableAscii(const TProtoStringType& text) {
TProtoStringType FieldGeneratorBase::GetStringDefaultValueInternal(const FieldDescriptor* descriptor) {
if (descriptor->default_value_string().empty())
return "\"\"";
- else
- return "global::System.Text.Encoding.UTF8.GetString(global::System."
- "Convert.FromBase64String(\"" +
- StringToBase64(descriptor->default_value_string()) + "\"), 0, " + StrCat(descriptor->default_value_string().length()) + ")";
+ return y_absl::StrCat(
+ "global::System.Text.Encoding.UTF8.GetString(global::System."
+ "Convert.FromBase64String(\"",
+ StringToBase64(descriptor->default_value_string()), "\"), 0, ",
+ descriptor->default_value_string().length(), ")");
}
TProtoStringType FieldGeneratorBase::GetBytesDefaultValueInternal(const FieldDescriptor* descriptor) {
if (descriptor->default_value_string().empty())
return "pb::ByteString.Empty";
- else
- return "pb::ByteString.FromBase64(\"" + StringToBase64(descriptor->default_value_string()) + "\")";
+ return y_absl::StrCat("pb::ByteString.FromBase64(\"",
+ StringToBase64(descriptor->default_value_string()),
+ "\")");
}
TProtoStringType FieldGeneratorBase::default_value() {
@@ -342,8 +360,10 @@ TProtoStringType FieldGeneratorBase::default_value() {
TProtoStringType FieldGeneratorBase::default_value(const FieldDescriptor* descriptor) {
switch (descriptor->type()) {
case FieldDescriptor::TYPE_ENUM:
- return GetClassName(descriptor->default_value_enum()->type()) + "." +
- GetEnumValueName(descriptor->default_value_enum()->type()->name(), descriptor->default_value_enum()->name());
+ return y_absl::StrCat(
+ GetClassName(descriptor->default_value_enum()->type()), ".",
+ GetEnumValueName(descriptor->default_value_enum()->type()->name(),
+ descriptor->default_value_enum()->name()));
case FieldDescriptor::TYPE_MESSAGE:
case FieldDescriptor::TYPE_GROUP:
if (IsWrapperType(descriptor)) {
@@ -361,7 +381,7 @@ TProtoStringType FieldGeneratorBase::default_value(const FieldDescriptor* descri
} else if (std::isnan(value)) {
return "double.NaN";
}
- return StrCat(value) + "D";
+ return y_absl::StrCat(value, "D");
}
case FieldDescriptor::TYPE_FLOAT: {
float value = descriptor->default_value_float();
@@ -372,18 +392,18 @@ TProtoStringType FieldGeneratorBase::default_value(const FieldDescriptor* descri
} else if (std::isnan(value)) {
return "float.NaN";
}
- return StrCat(value) + "F";
+ return y_absl::StrCat(value, "F");
}
case FieldDescriptor::TYPE_INT64:
- return StrCat(descriptor->default_value_int64()) + "L";
+ return y_absl::StrCat(descriptor->default_value_int64(), "L");
case FieldDescriptor::TYPE_UINT64:
- return StrCat(descriptor->default_value_uint64()) + "UL";
+ return y_absl::StrCat(descriptor->default_value_uint64(), "UL");
case FieldDescriptor::TYPE_INT32:
- return StrCat(descriptor->default_value_int32());
+ return y_absl::StrCat(descriptor->default_value_int32());
case FieldDescriptor::TYPE_FIXED64:
- return StrCat(descriptor->default_value_uint64()) + "UL";
+ return y_absl::StrCat(descriptor->default_value_uint64(), "UL");
case FieldDescriptor::TYPE_FIXED32:
- return StrCat(descriptor->default_value_uint32());
+ return y_absl::StrCat(descriptor->default_value_uint32());
case FieldDescriptor::TYPE_BOOL:
if (descriptor->default_value_bool()) {
return "true";
@@ -395,23 +415,23 @@ TProtoStringType FieldGeneratorBase::default_value(const FieldDescriptor* descri
case FieldDescriptor::TYPE_BYTES:
return GetBytesDefaultValueInternal(descriptor);
case FieldDescriptor::TYPE_UINT32:
- return StrCat(descriptor->default_value_uint32());
+ return y_absl::StrCat(descriptor->default_value_uint32());
case FieldDescriptor::TYPE_SFIXED32:
- return StrCat(descriptor->default_value_int32());
+ return y_absl::StrCat(descriptor->default_value_int32());
case FieldDescriptor::TYPE_SFIXED64:
- return StrCat(descriptor->default_value_int64()) + "L";
+ return y_absl::StrCat(descriptor->default_value_int64(), "L");
case FieldDescriptor::TYPE_SINT32:
- return StrCat(descriptor->default_value_int32());
+ return y_absl::StrCat(descriptor->default_value_int32());
case FieldDescriptor::TYPE_SINT64:
- return StrCat(descriptor->default_value_int64()) + "L";
+ return y_absl::StrCat(descriptor->default_value_int64(), "L");
default:
- GOOGLE_LOG(FATAL)<< "Unknown field type.";
+ Y_ABSL_LOG(FATAL) << "Unknown field type.";
return "";
}
}
TProtoStringType FieldGeneratorBase::number() {
- return StrCat(descriptor_->number());
+ return y_absl::StrCat(descriptor_->number());
}
TProtoStringType FieldGeneratorBase::capitalized_type_name() {
@@ -453,7 +473,7 @@ TProtoStringType FieldGeneratorBase::capitalized_type_name() {
case FieldDescriptor::TYPE_SINT64:
return "SInt64";
default:
- GOOGLE_LOG(FATAL)<< "Unknown field type.";
+ Y_ABSL_LOG(FATAL) << "Unknown field type.";
return "";
}
}
@@ -462,3 +482,5 @@ TProtoStringType FieldGeneratorBase::capitalized_type_name() {
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_field_base.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_field_base.h
index e553202792f..26ce67f9678 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_field_base.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_field_base.h
@@ -32,12 +32,16 @@
#define GOOGLE_PROTOBUF_COMPILER_CSHARP_FIELD_BASE_H__
#include <string>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/compiler/csharp/csharp_source_generator_base.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/io/printer.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/escaping.h"
+#include "y_absl/strings/str_replace.h"
+#include "y_absl/strings/str_split.h"
+#include "google/protobuf/compiler/csharp/csharp_source_generator_base.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
@@ -74,7 +78,7 @@ class FieldGeneratorBase : public SourceGeneratorBase {
protected:
const FieldDescriptor* descriptor_;
const int presenceIndex_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables_;
void AddDeprecatedFlag(io::Printer* printer);
void AddNullCheck(io::Printer* printer);
@@ -82,7 +86,7 @@ class FieldGeneratorBase : public SourceGeneratorBase {
void AddPublicMemberAttributes(io::Printer* printer);
void SetCommonOneofFieldVariables(
- std::map<TProtoStringType, TProtoStringType>* variables);
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables);
TProtoStringType oneof_property_name();
TProtoStringType oneof_case_name();
@@ -98,7 +102,8 @@ class FieldGeneratorBase : public SourceGeneratorBase {
TProtoStringType capitalized_type_name();
private:
- void SetCommonFieldVariables(std::map<TProtoStringType, TProtoStringType>* variables);
+ void SetCommonFieldVariables(
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables);
TProtoStringType GetStringDefaultValueInternal(const FieldDescriptor* descriptor);
TProtoStringType GetBytesDefaultValueInternal(const FieldDescriptor* descriptor);
};
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_generator.cc
index 266b073c762..8e36faeb5b0 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_generator.cc
@@ -28,20 +28,19 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <sstream>
+#include "google/protobuf/compiler/csharp/csharp_generator.h"
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/descriptor.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>
+#include <sstream>
-#include <google/protobuf/compiler/csharp/csharp_generator.h>
-#include <google/protobuf/compiler/csharp/csharp_helpers.h>
-#include <google/protobuf/compiler/csharp/csharp_names.h>
-#include <google/protobuf/compiler/csharp/csharp_options.h>
-#include <google/protobuf/compiler/csharp/csharp_reflection_class.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/compiler/csharp/csharp_helpers.h"
+#include "google/protobuf/compiler/csharp/csharp_options.h"
+#include "google/protobuf/compiler/csharp/csharp_reflection_class.h"
+#include "google/protobuf/compiler/csharp/names.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 {
@@ -70,7 +69,7 @@ bool Generator::Generate(const FileDescriptor* file,
struct Options cli_options;
- for (int i = 0; i < options.size(); i++) {
+ for (size_t i = 0; i < options.size(); i++) {
if (options[i].first == "file_extension") {
cli_options.file_extension = options[i].second;
} else if (options[i].first == "base_namespace") {
@@ -81,7 +80,7 @@ bool Generator::Generate(const FileDescriptor* file,
} else if (options[i].first == "serializable") {
cli_options.serializable = true;
} else {
- *error = "Unknown generator option: " + options[i].first;
+ *error = y_absl::StrCat("Unknown generator option: ", options[i].first);
return false;
}
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_generator.h
index c82c38f23f4..2a1aefdd865 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_generator.h
@@ -35,9 +35,9 @@
#include <string>
-#include <google/protobuf/compiler/code_generator.h>
+#include "google/protobuf/compiler/code_generator.h"
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -65,6 +65,6 @@ class PROTOC_EXPORT Generator : public CodeGenerator {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_GENERATOR_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_helpers.cc
index 8b5d09e5311..065eb434c72 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_helpers.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_helpers.cc
@@ -32,28 +32,34 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
+#include "google/protobuf/compiler/csharp/csharp_helpers.h"
+
#include <algorithm>
#include <limits>
-#include <vector>
#include <sstream>
+#include <string>
+#include <vector>
-#include <google/protobuf/compiler/csharp/csharp_helpers.h>
-#include <google/protobuf/compiler/csharp/csharp_names.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
-
-#include <google/protobuf/compiler/csharp/csharp_field_base.h>
-#include <google/protobuf/compiler/csharp/csharp_enum_field.h>
-#include <google/protobuf/compiler/csharp/csharp_map_field.h>
-#include <google/protobuf/compiler/csharp/csharp_message_field.h>
-#include <google/protobuf/compiler/csharp/csharp_options.h>
-#include <google/protobuf/compiler/csharp/csharp_primitive_field.h>
-#include <google/protobuf/compiler/csharp/csharp_repeated_enum_field.h>
-#include <google/protobuf/compiler/csharp/csharp_repeated_message_field.h>
-#include <google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h>
-#include <google/protobuf/compiler/csharp/csharp_wrapper_field.h>
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/str_replace.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/compiler/csharp/csharp_enum_field.h"
+#include "google/protobuf/compiler/csharp/csharp_field_base.h"
+#include "google/protobuf/compiler/csharp/csharp_map_field.h"
+#include "google/protobuf/compiler/csharp/csharp_message_field.h"
+#include "google/protobuf/compiler/csharp/csharp_options.h"
+#include "google/protobuf/compiler/csharp/csharp_primitive_field.h"
+#include "google/protobuf/compiler/csharp/csharp_repeated_enum_field.h"
+#include "google/protobuf/compiler/csharp/csharp_repeated_message_field.h"
+#include "google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h"
+#include "google/protobuf/compiler/csharp/csharp_wrapper_field.h"
+#include "google/protobuf/compiler/csharp/names.h"
+#include "google/protobuf/descriptor.pb.h"
+
+// Must be last.
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -102,88 +108,10 @@ CSharpType GetCSharpType(FieldDescriptor::Type type) {
// No default because we want the compiler to complain if any new
// types are added.
}
- GOOGLE_LOG(FATAL)<< "Can't get here.";
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
return (CSharpType) -1;
}
-TProtoStringType StripDotProto(const TProtoStringType& proto_file) {
- int lastindex = proto_file.find_last_of(".");
- return proto_file.substr(0, lastindex);
-}
-
-TProtoStringType GetFileNamespace(const FileDescriptor* descriptor) {
- if (descriptor->options().has_csharp_namespace()) {
- return descriptor->options().csharp_namespace();
- }
- return UnderscoresToCamelCase(descriptor->package(), true, true);
-}
-
-// Returns the Pascal-cased last part of the proto file. For example,
-// input of "google/protobuf/foo_bar.proto" would result in "FooBar".
-TProtoStringType GetFileNameBase(const FileDescriptor* descriptor) {
- TProtoStringType proto_file = descriptor->name();
- int lastslash = proto_file.find_last_of("/");
- TProtoStringType base = proto_file.substr(lastslash + 1);
- return UnderscoresToPascalCase(StripDotProto(base));
-}
-
-TProtoStringType GetReflectionClassUnqualifiedName(const FileDescriptor* descriptor) {
- // TODO: Detect collisions with existing messages,
- // and append an underscore if necessary.
- return GetFileNameBase(descriptor) + "Reflection";
-}
-
-TProtoStringType GetExtensionClassUnqualifiedName(const FileDescriptor* descriptor) {
- // TODO: Detect collisions with existing messages,
- // and append an underscore if necessary.
- return GetFileNameBase(descriptor) + "Extensions";
-}
-
-// TODO(jtattermusch): can we reuse a utility function?
-TProtoStringType UnderscoresToCamelCase(const TProtoStringType& input,
- bool cap_next_letter,
- bool preserve_period) {
- TProtoStringType result;
- // Note: I distrust ctype.h due to locales.
- for (int i = 0; i < input.size(); i++) {
- if ('a' <= input[i] && input[i] <= 'z') {
- if (cap_next_letter) {
- result += input[i] + ('A' - 'a');
- } else {
- result += input[i];
- }
- cap_next_letter = false;
- } else if ('A' <= input[i] && input[i] <= 'Z') {
- if (i == 0 && !cap_next_letter) {
- // Force first letter to lower-case unless explicitly told to
- // capitalize it.
- result += input[i] + ('a' - 'A');
- } else {
- // Capital letters after the first are left as-is.
- result += input[i];
- }
- cap_next_letter = false;
- } else if ('0' <= input[i] && input[i] <= '9') {
- result += input[i];
- cap_next_letter = true;
- } else {
- cap_next_letter = true;
- if (input[i] == '.' && preserve_period) {
- result += '.';
- }
- }
- }
- // Add a trailing "_" if the name should be altered.
- if (input.size() > 0 && input[input.size() - 1] == '#') {
- result += '_';
- }
- return result;
-}
-
-TProtoStringType UnderscoresToPascalCase(const TProtoStringType& input) {
- return UnderscoresToCamelCase(input, true);
-}
-
// Convert a string which is expected to be SHOUTY_CASE (but may not be *precisely* shouty)
// into a PascalCase string. Precise rules implemented:
@@ -194,24 +122,24 @@ TProtoStringType UnderscoresToPascalCase(const TProtoStringType& input) {
// Numeric Alphanumeric Upper
// Lower letter Alphanumeric Same as current
// Upper letter Alphanumeric Lower
-TProtoStringType ShoutyToPascalCase(const TProtoStringType& input) {
+TProtoStringType ShoutyToPascalCase(y_absl::string_view input) {
TProtoStringType result;
// Simple way of implementing "always start with upper"
char previous = '_';
for (int i = 0; i < input.size(); i++) {
char current = input[i];
- if (!ascii_isalnum(current)) {
+ if (!y_absl::ascii_isalnum(current)) {
previous = current;
continue;
}
- if (!ascii_isalnum(previous)) {
- result += ascii_toupper(current);
- } else if (ascii_isdigit(previous)) {
- result += ascii_toupper(current);
- } else if (ascii_islower(previous)) {
+ if (!y_absl::ascii_isalnum(previous)) {
+ result += y_absl::ascii_toupper(current);
+ } else if (y_absl::ascii_isdigit(previous)) {
+ result += y_absl::ascii_toupper(current);
+ } else if (y_absl::ascii_islower(previous)) {
result += current;
} else {
- result += ascii_tolower(current);
+ result += y_absl::ascii_tolower(current);
}
previous = current;
}
@@ -224,12 +152,12 @@ TProtoStringType ShoutyToPascalCase(const TProtoStringType& input) {
// (foo_bar, foobarbaz) => baz - underscore in prefix is ignored
// (foobar, foo_barbaz) => baz - underscore in value is ignored
// (foo, bar) => bar - prefix isn't matched; return original value
-TProtoStringType TryRemovePrefix(const TProtoStringType& prefix, const TProtoStringType& value) {
+TProtoStringType TryRemovePrefix(y_absl::string_view prefix, y_absl::string_view value) {
// First normalize to a lower-case no-underscores prefix to match against
TProtoStringType prefix_to_match = "";
for (size_t i = 0; i < prefix.size(); i++) {
if (prefix[i] != '_') {
- prefix_to_match += ascii_tolower(prefix[i]);
+ prefix_to_match += y_absl::ascii_tolower(prefix[i]);
}
}
@@ -242,15 +170,15 @@ TProtoStringType TryRemovePrefix(const TProtoStringType& prefix, const TProtoStr
if (value[value_index] == '_') {
continue;
}
- if (ascii_tolower(value[value_index]) != prefix_to_match[prefix_index++]) {
+ if (y_absl::ascii_tolower(value[value_index]) != prefix_to_match[prefix_index++]) {
// Failed to match the prefix - bail out early.
- return value;
+ return TProtoStringType(value);
}
}
// If we didn't finish looking through the prefix, we can't strip it.
if (prefix_index < prefix_to_match.size()) {
- return value;
+ return TProtoStringType(value);
}
// Step over any underscores after the prefix
@@ -260,10 +188,10 @@ TProtoStringType TryRemovePrefix(const TProtoStringType& prefix, const TProtoStr
// If there's nothing left (e.g. it was a prefix with only underscores afterwards), don't strip.
if (value_index == value.size()) {
- return value;
+ return TProtoStringType(value);
}
- return value.substr(value_index);
+ return TProtoStringType(value.substr(value_index));
}
// Format the enum value name in a pleasant way for C#:
@@ -271,13 +199,14 @@ TProtoStringType TryRemovePrefix(const TProtoStringType& prefix, const TProtoStr
// - Convert to PascalCase.
// For example, an enum called Color with a value of COLOR_BLUE should
// result in an enum value in C# called just Blue
-TProtoStringType GetEnumValueName(const TProtoStringType& enum_name, const TProtoStringType& enum_value_name) {
+TProtoStringType GetEnumValueName(y_absl::string_view enum_name,
+ y_absl::string_view enum_value_name) {
TProtoStringType stripped = TryRemovePrefix(enum_name, enum_value_name);
TProtoStringType result = ShoutyToPascalCase(stripped);
// Just in case we have an enum name of FOO and a value of FOO_2... make sure the returned
// string is a valid identifier.
- if (ascii_isdigit(result[0])) {
- result = "_" + result;
+ if (y_absl::ascii_isdigit(result[0])) {
+ return y_absl::StrCat("_", result);
}
return result;
}
@@ -320,47 +249,14 @@ uint GetGroupEndTag(const Descriptor* descriptor) {
return 0;
}
-TProtoStringType ToCSharpName(const TProtoStringType& name, const FileDescriptor* file) {
- TProtoStringType result = GetFileNamespace(file);
- if (!result.empty()) {
- result += '.';
- }
- TProtoStringType classname;
- if (file->package().empty()) {
- classname = name;
- } else {
- // Strip the proto package from full_name since we've replaced it with
- // the C# namespace.
- classname = name.substr(file->package().size() + 1);
- }
- result += StringReplace(classname, ".", ".Types.", true);
- return "global::" + result;
-}
-
-TProtoStringType GetReflectionClassName(const FileDescriptor* descriptor) {
- TProtoStringType result = GetFileNamespace(descriptor);
- if (!result.empty()) {
- result += '.';
- }
- result += GetReflectionClassUnqualifiedName(descriptor);
- return "global::" + result;
-}
-
TProtoStringType GetFullExtensionName(const FieldDescriptor* descriptor) {
if (descriptor->extension_scope()) {
- return GetClassName(descriptor->extension_scope()) + ".Extensions." + GetPropertyName(descriptor);
- }
- else {
- return GetExtensionClassUnqualifiedName(descriptor->file()) + "." + GetPropertyName(descriptor);
+ return y_absl::StrCat(GetClassName(descriptor->extension_scope()),
+ ".Extensions.", GetPropertyName(descriptor));
}
-}
-
-TProtoStringType GetClassName(const Descriptor* descriptor) {
- return ToCSharpName(descriptor->full_name(), descriptor->file());
-}
-TProtoStringType GetClassName(const EnumDescriptor* descriptor) {
- return ToCSharpName(descriptor->full_name(), descriptor->file());
+ return y_absl::StrCat(GetExtensionClassUnqualifiedName(descriptor->file()), ".",
+ GetPropertyName(descriptor));
}
// Groups are hacky: The name of the field is just the lower-cased name
@@ -375,20 +271,35 @@ TProtoStringType GetFieldName(const FieldDescriptor* descriptor) {
}
TProtoStringType GetFieldConstantName(const FieldDescriptor* field) {
- return GetPropertyName(field) + "FieldNumber";
+ return y_absl::StrCat(GetPropertyName(field), "FieldNumber");
}
TProtoStringType GetPropertyName(const FieldDescriptor* descriptor) {
+ // Names of members declared or overridden in the message.
+ static const auto& reserved_member_names = *new y_absl::flat_hash_set<y_absl::string_view>({
+ "Types",
+ "Descriptor",
+ "Equals",
+ "ToString",
+ "GetHashCode",
+ "WriteTo",
+ "Clone",
+ "CalculateSize",
+ "MergeFrom",
+ "OnConstruction",
+ "Parser"
+ });
+
// TODO(jtattermusch): consider introducing csharp_property_name field option
TProtoStringType property_name = UnderscoresToPascalCase(GetFieldName(descriptor));
- // Avoid either our own type name or reserved names. Note that not all names
- // are reserved - a field called to_string, write_to etc would still cause a problem.
+ // Avoid either our own type name or reserved names.
// There are various ways of ending up with naming collisions, but we try to avoid obvious
- // ones.
+ // ones. In particular, we avoid the names of all the members we generate.
+ // Note that we *don't* add an underscore for MemberwiseClone or GetType. Those generate
+ // warnings, but not errors; changing the name now could be a breaking change.
if (property_name == descriptor->containing_type()->name()
- || property_name == "Types"
- || property_name == "Descriptor") {
- property_name += "_";
+ || reserved_member_names.find(property_name) != reserved_member_names.end()) {
+ y_absl::StrAppend(&property_name, "_");
}
return property_name;
}
@@ -400,40 +311,6 @@ TProtoStringType GetOneofCaseName(const FieldDescriptor* descriptor) {
return property_name == "None" ? "None_" : property_name;
}
-TProtoStringType GetOutputFile(const FileDescriptor* descriptor,
- const TProtoStringType file_extension,
- const bool generate_directories,
- const TProtoStringType base_namespace,
- TProtoStringType* error) {
- TProtoStringType relative_filename = GetFileNameBase(descriptor) + file_extension;
- if (!generate_directories) {
- return relative_filename;
- }
- TProtoStringType ns = GetFileNamespace(descriptor);
- TProtoStringType namespace_suffix = ns;
- if (!base_namespace.empty()) {
- // Check that the base_namespace is either equal to or a leading part of
- // the file namespace. This isn't just a simple prefix; "Foo.B" shouldn't
- // be regarded as a prefix of "Foo.Bar". The simplest option is to add "."
- // to both.
- TProtoStringType extended_ns = ns + ".";
- if (extended_ns.find(base_namespace + ".") != 0) {
- *error = "Namespace " + ns + " is not a prefix namespace of base namespace " + base_namespace;
- return ""; // This will be ignored, because we've set an error.
- }
- namespace_suffix = ns.substr(base_namespace.length());
- if (namespace_suffix.find(".") == 0) {
- namespace_suffix = namespace_suffix.substr(1);
- }
- }
-
- TProtoStringType namespace_dir = StringReplace(namespace_suffix, ".", "/", true);
- if (!namespace_dir.empty()) {
- namespace_dir += "/";
- }
- return namespace_dir + relative_filename;
-}
-
// TODO: c&p from Java protoc plugin
// For encodings with fixed sizes, returns that size in bytes. Otherwise
// returns -1.
@@ -463,17 +340,17 @@ int GetFixedSize(FieldDescriptor::Type type) {
// No default because we want the compiler to complain if any new
// types are added.
}
- GOOGLE_LOG(FATAL) << "Can't get here.";
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
return -1;
}
static const char base64_chars[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-TProtoStringType StringToBase64(const TProtoStringType& input) {
+TProtoStringType StringToBase64(y_absl::string_view input) {
TProtoStringType result;
size_t remaining = input.size();
- const unsigned char *src = (const unsigned char*) input.c_str();
+ const unsigned char* src = (const unsigned char*)input.data();
while (remaining > 2) {
result += base64_chars[src[0] >> 2];
result += base64_chars[((src[0] & 0x3) << 4) | (src[1] >> 4)];
@@ -588,7 +465,7 @@ bool IsNullable(const FieldDescriptor* descriptor) {
return true;
default:
- GOOGLE_LOG(FATAL) << "Unknown field type.";
+ Y_ABSL_LOG(FATAL) << "Unknown field type.";
return true;
}
}
@@ -597,3 +474,5 @@ bool IsNullable(const FieldDescriptor* descriptor) {
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include "google/protobuf/port_undef.inc"
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 0a325464dcc..818eef1a3c4 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
@@ -36,14 +36,16 @@
#define GOOGLE_PROTOBUF_COMPILER_CSHARP_HELPERS_H__
#include <string>
-#include <google/protobuf/port.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/compiler/code_generator.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/compiler/csharp/names.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/printer.h"
+#include "google/protobuf/port.h"
+#include "google/protobuf/port_def.inc"
+#include "google/protobuf/stubs/common.h"
namespace google {
namespace protobuf {
@@ -72,15 +74,6 @@ enum CSharpType {
// Converts field type to corresponding C# type.
CSharpType GetCSharpType(FieldDescriptor::Type type);
-TProtoStringType StripDotProto(const TProtoStringType& proto_file);
-
-// Gets unqualified name of the reflection class
-TProtoStringType GetReflectionClassUnqualifiedName(const FileDescriptor* descriptor);
-// Gets unqualified name of the extension class
-TProtoStringType GetExtensionClassUnqualifiedName(const FileDescriptor* descriptor);
-
-TProtoStringType GetClassName(const EnumDescriptor* descriptor);
-
TProtoStringType GetFieldName(const FieldDescriptor* descriptor);
TProtoStringType GetFieldConstantName(const FieldDescriptor* field);
@@ -91,23 +84,13 @@ TProtoStringType GetOneofCaseName(const FieldDescriptor* descriptor);
int GetFixedSize(FieldDescriptor::Type type);
-TProtoStringType UnderscoresToCamelCase(const TProtoStringType& input,
- bool cap_next_letter,
- bool preserve_period);
-
-inline TProtoStringType UnderscoresToCamelCase(const TProtoStringType& input, bool cap_next_letter) {
- return UnderscoresToCamelCase(input, cap_next_letter, false);
-}
-
-TProtoStringType UnderscoresToPascalCase(const TProtoStringType& input);
-
// Note that we wouldn't normally want to export this (we're not expecting
// it to be used outside libprotoc itself) but this exposes it for testing.
-TProtoStringType PROTOC_EXPORT GetEnumValueName(const TProtoStringType& enum_name,
- const TProtoStringType& enum_value_name);
+TProtoStringType PROTOC_EXPORT GetEnumValueName(y_absl::string_view enum_name,
+ y_absl::string_view enum_value_name);
// TODO(jtattermusch): perhaps we could move this to strutil
-TProtoStringType StringToBase64(const TProtoStringType& input);
+TProtoStringType StringToBase64(y_absl::string_view input);
TProtoStringType FileDescriptorToBase64(const FileDescriptor* descriptor);
@@ -193,6 +176,6 @@ inline bool RequiresPresenceBit(const FieldDescriptor* descriptor) {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_HELPERS_H__
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 a13b995da8c..062e3a73b7e 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
@@ -28,18 +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.
-#include <sstream>
+#include "google/protobuf/compiler/csharp/csharp_map_field.h"
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/descriptor.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>
+#include <sstream>
-#include <google/protobuf/compiler/csharp/csharp_doc_comment.h>
-#include <google/protobuf/compiler/csharp/csharp_helpers.h>
-#include <google/protobuf/compiler/csharp/csharp_map_field.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/compiler/csharp/csharp_doc_comment.h"
+#include "google/protobuf/compiler/csharp/csharp_helpers.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
@@ -88,9 +86,8 @@ void MapFieldGenerator::GenerateMembers(io::Printer* printer) {
}
void MapFieldGenerator::GenerateMergingCode(io::Printer* printer) {
- printer->Print(
- variables_,
- "$name$_.Add(other.$name$_);\n");
+ printer->Print(variables_,
+ "$name$_.MergeFrom(other.$name$_);\n");
}
void MapFieldGenerator::GenerateParsingCode(io::Printer* printer) {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_map_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_map_field.h
index b03f65b74a3..3fbc6e53f8c 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_map_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_map_field.h
@@ -31,8 +31,8 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_MAP_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_CSHARP_MAP_FIELD_H__
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/compiler/csharp/csharp_field_base.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/compiler/csharp/csharp_field_base.h"
namespace google {
namespace protobuf {
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 e96b329cab0..d5b7f48e33d 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
@@ -28,26 +28,29 @@
// (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 <sstream>
+#include "google/protobuf/compiler/csharp/csharp_message.h"
+
#include <algorithm>
-#include <map>
-
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/descriptor.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>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/wire_format_lite.h>
-
-#include <google/protobuf/compiler/csharp/csharp_options.h>
-#include <google/protobuf/compiler/csharp/csharp_doc_comment.h>
-#include <google/protobuf/compiler/csharp/csharp_enum.h>
-#include <google/protobuf/compiler/csharp/csharp_field_base.h>
-#include <google/protobuf/compiler/csharp/csharp_helpers.h>
-#include <google/protobuf/compiler/csharp/csharp_message.h>
-#include <google/protobuf/compiler/csharp/csharp_names.h>
+#include <sstream>
+
+#include "google/protobuf/compiler/code_generator.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/csharp/csharp_doc_comment.h"
+#include "google/protobuf/compiler/csharp/csharp_enum.h"
+#include "google/protobuf/compiler/csharp/csharp_field_base.h"
+#include "google/protobuf/compiler/csharp/csharp_helpers.h"
+#include "google/protobuf/compiler/csharp/csharp_options.h"
+#include "google/protobuf/compiler/csharp/names.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/printer.h"
+#include "google/protobuf/wire_format.h"
+#include "google/protobuf/wire_format_lite.h"
+
+// Must be last.
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -112,7 +115,7 @@ void MessageGenerator::AddSerializableAttribute(io::Printer* printer) {
}
void MessageGenerator::Generate(io::Printer* printer) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
vars["class_name"] = class_name();
vars["access_level"] = class_access_level();
@@ -161,7 +164,7 @@ void MessageGenerator::Generate(io::Printer* printer) {
for (int i = 0; i < has_bit_field_count_; i++) {
// don't use arrays since all arrays are heap allocated, saving allocations
// use ints instead of bytes since bytes lack bitwise operators, saving casts
- printer->Print("private int _hasBits$i$;\n", "i", StrCat(i));
+ printer->Print("private int _hasBits$i$;\n", "i", y_absl::StrCat(i));
}
WriteGeneratedCodeAttributes(printer);
@@ -172,11 +175,13 @@ void MessageGenerator::Generate(io::Printer* printer) {
// Access the message descriptor via the relevant file descriptor or containing message descriptor.
if (!descriptor_->containing_type()) {
- vars["descriptor_accessor"] = GetReflectionClassName(descriptor_->file())
- + ".Descriptor.MessageTypes[" + StrCat(descriptor_->index()) + "]";
+ vars["descriptor_accessor"] =
+ y_absl::StrCat(GetReflectionClassName(descriptor_->file()),
+ ".Descriptor.MessageTypes[", descriptor_->index(), "]");
} else {
- vars["descriptor_accessor"] = GetClassName(descriptor_->containing_type())
- + ".Descriptor.NestedTypes[" + StrCat(descriptor_->index()) + "]";
+ vars["descriptor_accessor"] =
+ y_absl::StrCat(GetClassName(descriptor_->containing_type()),
+ ".Descriptor.NestedTypes[", descriptor_->index(), "]");
}
WriteGeneratedCodeAttributes(printer);
@@ -216,7 +221,7 @@ void MessageGenerator::Generate(io::Printer* printer) {
"public const int $field_constant_name$ = $index$;\n",
"field_name", fieldDescriptor->name(),
"field_constant_name", GetFieldConstantName(fieldDescriptor),
- "index", StrCat(fieldDescriptor->number()));
+ "index", y_absl::StrCat(fieldDescriptor->number()));
std::unique_ptr<FieldGeneratorBase> generator(
CreateFieldGeneratorInternal(fieldDescriptor));
generator->GenerateMembers(printer);
@@ -240,7 +245,7 @@ void MessageGenerator::Generate(io::Printer* printer) {
const FieldDescriptor* field = oneof->field(j);
printer->Print("$oneof_case_name$ = $index$,\n",
"oneof_case_name", GetOneofCaseName(field),
- "index", StrCat(field->number()));
+ "index", y_absl::StrCat(field->number()));
}
printer->Outdent();
printer->Print("}\n");
@@ -374,7 +379,7 @@ bool MessageGenerator::HasNestedGeneratedTypes()
}
void MessageGenerator::GenerateCloningCode(io::Printer* printer) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
WriteGeneratedCodeAttributes(printer);
vars["class_name"] = class_name();
printer->Print(
@@ -382,7 +387,7 @@ void MessageGenerator::GenerateCloningCode(io::Printer* printer) {
"public $class_name$($class_name$ other) : this() {\n");
printer->Indent();
for (int i = 0; i < has_bit_field_count_; i++) {
- printer->Print("_hasBits$i$ = other._hasBits$i$;\n", "i", StrCat(i));
+ printer->Print("_hasBits$i$ = other._hasBits$i$;\n", "i", y_absl::StrCat(i));
}
// Clone non-oneof fields first (treating optional proto3 fields as non-oneof)
for (int i = 0; i < descriptor_->field_count(); i++) {
@@ -438,32 +443,30 @@ void MessageGenerator::GenerateFreezingCode(io::Printer* printer) {
}
void MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) {
- std::map<TProtoStringType, TProtoStringType> vars;
- vars["class_name"] = class_name();
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
+ vars["class_name"] = class_name();
- // Equality
- WriteGeneratedCodeAttributes(printer);
- printer->Print(
- vars,
- "public override bool Equals(object other) {\n"
- " return Equals(other as $class_name$);\n"
- "}\n\n");
- WriteGeneratedCodeAttributes(printer);
- printer->Print(
- vars,
- "public bool Equals($class_name$ other) {\n"
- " if (ReferenceEquals(other, null)) {\n"
- " return false;\n"
- " }\n"
- " if (ReferenceEquals(other, this)) {\n"
- " return true;\n"
- " }\n");
- printer->Indent();
- for (int i = 0; i < descriptor_->field_count(); i++) {
- std::unique_ptr<FieldGeneratorBase> generator(
- CreateFieldGeneratorInternal(descriptor_->field(i)));
- generator->WriteEquals(printer);
- }
+ // Equality
+ WriteGeneratedCodeAttributes(printer);
+ printer->Print(vars,
+ "public override bool Equals(object other) {\n"
+ " return Equals(other as $class_name$);\n"
+ "}\n\n");
+ WriteGeneratedCodeAttributes(printer);
+ printer->Print(vars,
+ "public bool Equals($class_name$ other) {\n"
+ " if (ReferenceEquals(other, null)) {\n"
+ " return false;\n"
+ " }\n"
+ " if (ReferenceEquals(other, this)) {\n"
+ " return true;\n"
+ " }\n");
+ printer->Indent();
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ std::unique_ptr<FieldGeneratorBase> generator(
+ CreateFieldGeneratorInternal(descriptor_->field(i)));
+ generator->WriteEquals(printer);
+ }
for (int i = 0; i < descriptor_->real_oneof_decl_count(); i++) {
printer->Print("if ($property_name$Case != other.$property_name$Case) return false;\n",
"property_name", UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), true));
@@ -605,7 +608,7 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) {
// Note: These are separate from GenerateMessageSerializationMethods()
// because they need to be generated even for messages that are optimized
// for code size.
- std::map<TProtoStringType, TProtoStringType> vars;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
vars["class_name"] = class_name();
WriteGeneratedCodeAttributes(printer);
@@ -685,7 +688,7 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) {
}
void MessageGenerator::GenerateMainParseLoop(io::Printer* printer, bool use_parse_context) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
vars["maybe_ref_input"] = use_parse_context ? "ref input" : "input";
printer->Print(
@@ -698,7 +701,7 @@ void MessageGenerator::GenerateMainParseLoop(io::Printer* printer, bool use_pars
printer->Print(
"case $end_tag$:\n"
" return;\n",
- "end_tag", StrCat(end_tag_));
+ "end_tag", y_absl::StrCat(end_tag_));
}
if (has_extension_ranges_) {
printer->Print(vars,
@@ -727,13 +730,13 @@ void MessageGenerator::GenerateMainParseLoop(io::Printer* printer, bool use_pars
printer->Print(
"case $packed_tag$:\n",
"packed_tag",
- StrCat(
+ y_absl::StrCat(
internal::WireFormatLite::MakeTag(
field->number(),
internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED)));
}
- printer->Print("case $tag$: {\n", "tag", StrCat(tag));
+ printer->Print("case $tag$: {\n", "tag", y_absl::StrCat(tag));
printer->Indent();
std::unique_ptr<FieldGeneratorBase> generator(
CreateFieldGeneratorInternal(field));
@@ -764,7 +767,8 @@ int MessageGenerator::GetPresenceIndex(const FieldDescriptor* descriptor) {
index++;
}
}
- GOOGLE_LOG(DFATAL)<< "Could not find presence index for field " << descriptor->name();
+ Y_ABSL_DLOG(FATAL) << "Could not find presence index for field "
+ << descriptor->name();
return -1;
}
@@ -777,3 +781,5 @@ FieldGeneratorBase* MessageGenerator::CreateFieldGeneratorInternal(
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message.h
index ef399d2ec4f..fa61b33f4b8 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message.h
@@ -34,9 +34,9 @@
#include <string>
#include <vector>
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/compiler/csharp/csharp_source_generator_base.h>
-#include <google/protobuf/compiler/csharp/csharp_helpers.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/compiler/csharp/csharp_source_generator_base.h"
+#include "google/protobuf/compiler/csharp/csharp_helpers.h"
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message_field.cc
index 487d01ddef3..f43f2d99527 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message_field.cc
@@ -28,21 +28,17 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <sstream>
+#include "google/protobuf/compiler/csharp/csharp_message_field.h"
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/descriptor.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>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/wire_format_lite.h>
+#include <sstream>
-#include <google/protobuf/compiler/csharp/csharp_doc_comment.h>
-#include <google/protobuf/compiler/csharp/csharp_helpers.h>
-#include <google/protobuf/compiler/csharp/csharp_message_field.h>
-#include <google/protobuf/compiler/csharp/csharp_options.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/compiler/csharp/csharp_doc_comment.h"
+#include "google/protobuf/compiler/csharp/csharp_helpers.h"
+#include "google/protobuf/compiler/csharp/csharp_options.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
@@ -54,8 +50,8 @@ MessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor,
const Options *options)
: FieldGeneratorBase(descriptor, presenceIndex, options) {
if (!SupportsPresenceApi(descriptor_)) {
- variables_["has_property_check"] = name() + "_ != null";
- variables_["has_not_property_check"] = name() + "_ == null";
+ variables_["has_property_check"] = y_absl::StrCat(name(), "_ != null");
+ variables_["has_not_property_check"] = y_absl::StrCat(name(), "_ == null");
}
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message_field.h
index 2da1d71701f..3cae2bd0b24 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message_field.h
@@ -31,8 +31,8 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_MESSAGE_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_CSHARP_MESSAGE_FIELD_H__
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/compiler/csharp/csharp_field_base.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/compiler/csharp/csharp_field_base.h"
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_names.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_names.h
index cb135e1a22c..bff07d1e979 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_names.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_names.h
@@ -1,109 +1,2 @@
-// 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: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-//
-// Provides a mechanism for mapping a descriptor to the
-// fully-qualified name of the corresponding C# class.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__
-#define GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__
-
-#include <string>
-#include <google/protobuf/port.h>
-#include <google/protobuf/stubs/common.h>
-
-#include <google/protobuf/port_def.inc>
-
-namespace google {
-namespace protobuf {
-
-class Descriptor;
-class EnumDescriptor;
-class FileDescriptor;
-class ServiceDescriptor;
-
-namespace compiler {
-namespace csharp {
-
-// Requires:
-// descriptor != NULL
-//
-// Returns:
-// The namespace to use for given file descriptor.
-TProtoStringType PROTOC_EXPORT GetFileNamespace(const FileDescriptor* descriptor);
-
-// Requires:
-// descriptor != NULL
-//
-// Returns:
-// The fully-qualified C# class name.
-TProtoStringType PROTOC_EXPORT GetClassName(const Descriptor* descriptor);
-
-// Requires:
-// descriptor != NULL
-//
-// Returns:
-// The fully-qualified name of the C# class that provides
-// access to the file descriptor. Proto compiler generates
-// such class for each .proto file processed.
-TProtoStringType PROTOC_EXPORT
-GetReflectionClassName(const FileDescriptor* descriptor);
-
-// Generates output file name for given file descriptor. If generate_directories
-// is true, the output file will be put under directory corresponding to file's
-// namespace. base_namespace can be used to strip some of the top level
-// directories. E.g. for file with namespace "Bar.Foo" and base_namespace="Bar",
-// the resulting file will be put under directory "Foo" (and not "Bar/Foo").
-//
-// Requires:
-// descriptor != NULL
-// error != NULL
-//
-// Returns:
-// The file name to use as output file for given file descriptor. In case
-// of failure, this function will return empty string and error parameter
-// will contain the error message.
-TProtoStringType PROTOC_EXPORT GetOutputFile(const FileDescriptor* descriptor,
- const TProtoStringType file_extension,
- const bool generate_directories,
- const TProtoStringType base_namespace,
- TProtoStringType* error);
-
-} // namespace csharp
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__
+#include "names.h"
+#include "names.h" \ No newline at end of file
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc
index e7d51168d17..455269a8d52 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc
@@ -28,19 +28,20 @@
// (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 <sstream>
-
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/descriptor.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>
+#include "google/protobuf/compiler/csharp/csharp_primitive_field.h"
-#include <google/protobuf/compiler/csharp/csharp_doc_comment.h>
-#include <google/protobuf/compiler/csharp/csharp_helpers.h>
-#include <google/protobuf/compiler/csharp/csharp_options.h>
-#include <google/protobuf/compiler/csharp/csharp_primitive_field.h>
+#include <sstream>
+#include <string>
+#include <utility>
+
+#include "google/protobuf/compiler/code_generator.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/csharp/csharp_doc_comment.h"
+#include "google/protobuf/compiler/csharp/csharp_helpers.h"
+#include "google/protobuf/compiler/csharp/csharp_options.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
@@ -54,8 +55,11 @@ PrimitiveFieldGenerator::PrimitiveFieldGenerator(
is_value_type = descriptor->type() != FieldDescriptor::TYPE_STRING
&& descriptor->type() != FieldDescriptor::TYPE_BYTES;
if (!is_value_type && !SupportsPresenceApi(descriptor_)) {
- variables_["has_property_check"] = variables_["property_name"] + ".Length != 0";
- variables_["other_has_property_check"] = "other." + variables_["property_name"] + ".Length != 0";
+ TProtoStringType property_name = variables_["property_name"];
+ variables_["has_property_check"] =
+ y_absl::StrCat(property_name, ".Length != 0");
+ variables_["other_has_property_check"] =
+ y_absl::StrCat("other.", property_name, ".Length != 0");
}
}
@@ -81,10 +85,12 @@ void PrimitiveFieldGenerator::GenerateMembers(io::Printer* printer) {
printer->Print(
variables_,
"private readonly static $type_name$ $property_name$DefaultValue = $default_value$;\n\n");
+ TProtoStringType property_name = variables_["property_name"];
variables_["default_value_access"] =
- variables_["property_name"] + "DefaultValue";
+ y_absl::StrCat(property_name, "DefaultValue");
} else {
- variables_["default_value_access"] = variables_["default_value"];
+ TProtoStringType default_value = variables_["default_value"];
+ variables_["default_value_access"] = std::move(default_value);
}
// Declare the field itself.
@@ -215,7 +221,7 @@ void PrimitiveFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) {
} else {
printer->Print(
"size += $tag_size$ + $fixed_size$;\n",
- "fixed_size", StrCat(fixedSize),
+ "fixed_size", y_absl::StrCat(fixedSize),
"tag_size", variables_["tag_size"]);
}
printer->Outdent();
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_primitive_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_primitive_field.h
index e98c3698a00..0abf8278f16 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_primitive_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_primitive_field.h
@@ -31,8 +31,8 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_PRIMITIVE_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_CSHARP_PRIMITIVE_FIELD_H__
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/compiler/csharp/csharp_field_base.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/compiler/csharp/csharp_field_base.h"
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc
index c142195cf53..6471da7c2c4 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc
@@ -28,23 +28,24 @@
// (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 <sstream>
+#include "google/protobuf/compiler/csharp/csharp_reflection_class.h"
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/descriptor.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>
+#include <sstream>
+#include "google/protobuf/compiler/code_generator.h"
+#include "y_absl/strings/str_join.h"
+#include "google/protobuf/compiler/csharp/csharp_enum.h"
+#include "google/protobuf/compiler/csharp/csharp_field_base.h"
+#include "google/protobuf/compiler/csharp/csharp_helpers.h"
+#include "google/protobuf/compiler/csharp/csharp_message.h"
+#include "google/protobuf/compiler/csharp/csharp_options.h"
+#include "google/protobuf/compiler/csharp/names.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/printer.h"
-#include <google/protobuf/compiler/csharp/csharp_enum.h>
-#include <google/protobuf/compiler/csharp/csharp_helpers.h>
-#include <google/protobuf/compiler/csharp/csharp_field_base.h>
-#include <google/protobuf/compiler/csharp/csharp_message.h>
-#include <google/protobuf/compiler/csharp/csharp_names.h>
-#include <google/protobuf/compiler/csharp/csharp_options.h>
-#include <google/protobuf/compiler/csharp/csharp_reflection_class.h>
+// Must be last.
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -213,7 +214,7 @@ void ReflectionClassGenerator::WriteDescriptor(io::Printer* printer) {
for (int i = 0; i < file_->extension_count(); i++) {
extensions.push_back(GetFullExtensionName(file_->extension(i)));
}
- printer->Print("new pb::Extension[] { $extensions$ }, ", "extensions", Join(extensions, ", "));
+ printer->Print("new pb::Extension[] { $extensions$ }, ", "extensions", y_absl::StrJoin(extensions, ", "));
}
else {
printer->Print("null, ");
@@ -265,7 +266,7 @@ void ReflectionClassGenerator::WriteGeneratedCodeInfo(const Descriptor* descript
for (int i = 0; i < descriptor->field_count(); i++) {
fields.push_back(GetPropertyName(descriptor->field(i)));
}
- printer->Print("new[]{ \"$fields$\" }, ", "fields", Join(fields, "\", \""));
+ printer->Print("new[]{ \"$fields$\" }, ", "fields", y_absl::StrJoin(fields, "\", \""));
}
else {
printer->Print("null, ");
@@ -278,7 +279,7 @@ void ReflectionClassGenerator::WriteGeneratedCodeInfo(const Descriptor* descript
for (int i = 0; i < descriptor->oneof_decl_count(); i++) {
oneofs.push_back(UnderscoresToCamelCase(descriptor->oneof_decl(i)->name(), true));
}
- printer->Print("new[]{ \"$oneofs$\" }, ", "oneofs", Join(oneofs, "\", \""));
+ printer->Print("new[]{ \"$oneofs$\" }, ", "oneofs", y_absl::StrJoin(oneofs, "\", \""));
}
else {
printer->Print("null, ");
@@ -291,7 +292,7 @@ void ReflectionClassGenerator::WriteGeneratedCodeInfo(const Descriptor* descript
for (int i = 0; i < descriptor->enum_type_count(); i++) {
enums.push_back(GetClassName(descriptor->enum_type(i)));
}
- printer->Print("new[]{ typeof($enums$) }, ", "enums", Join(enums, "), typeof("));
+ printer->Print("new[]{ typeof($enums$) }, ", "enums", y_absl::StrJoin(enums, "), typeof("));
}
else {
printer->Print("null, ");
@@ -303,7 +304,7 @@ void ReflectionClassGenerator::WriteGeneratedCodeInfo(const Descriptor* descript
for (int i = 0; i < descriptor->extension_count(); i++) {
extensions.push_back(GetFullExtensionName(descriptor->extension(i)));
}
- printer->Print("new pb::Extension[] { $extensions$ }, ", "extensions", Join(extensions, ", "));
+ printer->Print("new pb::Extension[] { $extensions$ }, ", "extensions", y_absl::StrJoin(extensions, ", "));
}
else {
printer->Print("null, ");
@@ -328,3 +329,5 @@ void ReflectionClassGenerator::WriteGeneratedCodeInfo(const Descriptor* descript
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_reflection_class.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_reflection_class.h
index 392e559ddfb..11de54ea275 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_reflection_class.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_reflection_class.h
@@ -33,10 +33,10 @@
#include <string>
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/compiler/csharp/csharp_source_generator_base.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/io/printer.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/compiler/csharp/csharp_source_generator_base.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc
index 04bc7bbb1bd..1a9fd1d893e 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc
@@ -28,18 +28,18 @@
// (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 <sstream>
+#include "google/protobuf/compiler/csharp/csharp_repeated_enum_field.h"
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/zero_copy_stream.h>
-#include <google/protobuf/wire_format.h>
+#include <sstream>
-#include <google/protobuf/compiler/csharp/csharp_doc_comment.h>
-#include <google/protobuf/compiler/csharp/csharp_helpers.h>
-#include <google/protobuf/compiler/csharp/csharp_repeated_enum_field.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/wire_format.h"
+#include "google/protobuf/compiler/csharp/csharp_doc_comment.h"
+#include "google/protobuf/compiler/csharp/csharp_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 {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h
index 6d6717cc022..448805b956d 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h
@@ -31,8 +31,8 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_ENUM_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_ENUM_FIELD_H__
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/compiler/csharp/csharp_field_base.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/compiler/csharp/csharp_field_base.h"
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc
index 8a93cd13cfc..6ac7e2d6a04 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc
@@ -28,19 +28,19 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#include "google/protobuf/compiler/csharp/csharp_repeated_message_field.h"
+
#include <sstream>
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/zero_copy_stream.h>
-
-#include <google/protobuf/compiler/csharp/csharp_doc_comment.h>
-#include <google/protobuf/compiler/csharp/csharp_helpers.h>
-#include <google/protobuf/compiler/csharp/csharp_repeated_message_field.h>
-#include <google/protobuf/compiler/csharp/csharp_message_field.h>
-#include <google/protobuf/compiler/csharp/csharp_wrapper_field.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/compiler/csharp/csharp_doc_comment.h"
+#include "google/protobuf/compiler/csharp/csharp_helpers.h"
+#include "google/protobuf/compiler/csharp/csharp_message_field.h"
+#include "google/protobuf/compiler/csharp/csharp_wrapper_field.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 {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h
index ea252ced34a..1acf10e09cd 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h
@@ -31,8 +31,8 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_MESSAGE_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_MESSAGE_FIELD_H__
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/compiler/csharp/csharp_field_base.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/compiler/csharp/csharp_field_base.h"
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc
index 0eacf91ce6c..df97ccf3db9 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc
@@ -28,18 +28,18 @@
// (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 <sstream>
+#include "google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h"
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/zero_copy_stream.h>
-#include <google/protobuf/wire_format.h>
+#include <sstream>
-#include <google/protobuf/compiler/csharp/csharp_doc_comment.h>
-#include <google/protobuf/compiler/csharp/csharp_helpers.h>
-#include <google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/wire_format.h"
+#include "google/protobuf/compiler/csharp/csharp_doc_comment.h"
+#include "google/protobuf/compiler/csharp/csharp_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 {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h
index 2b470e12c9d..3b5b1c035dd 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h
@@ -31,8 +31,8 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_PRIMITIVE_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_PRIMITIVE_FIELD_H__
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/compiler/csharp/csharp_field_base.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/compiler/csharp/csharp_field_base.h"
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc
index 91af159a7b7..f0fb30cceec 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc
@@ -28,18 +28,18 @@
// (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 <sstream>
+#include "google/protobuf/compiler/csharp/csharp_source_generator_base.h"
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/zero_copy_stream.h>
+#include <sstream>
-#include <google/protobuf/compiler/csharp/csharp_source_generator_base.h>
-#include <google/protobuf/compiler/csharp/csharp_helpers.h>
-#include <google/protobuf/compiler/csharp/csharp_names.h>
-#include <google/protobuf/compiler/csharp/csharp_options.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/compiler/csharp/csharp_helpers.h"
+#include "google/protobuf/compiler/csharp/names.h"
+#include "google/protobuf/compiler/csharp/csharp_options.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 {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h
index 9206cd33092..d719cb5b7ad 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h
@@ -33,8 +33,8 @@
#include <string>
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/io/printer.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc
index e638dd862ae..2dac8f52fd4 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc
@@ -28,18 +28,18 @@
// (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 <sstream>
+#include "google/protobuf/compiler/csharp/csharp_wrapper_field.h"
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/zero_copy_stream.h>
+#include <sstream>
-#include <google/protobuf/compiler/csharp/csharp_doc_comment.h>
-#include <google/protobuf/compiler/csharp/csharp_helpers.h>
-#include <google/protobuf/compiler/csharp/csharp_options.h>
-#include <google/protobuf/compiler/csharp/csharp_wrapper_field.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/compiler/csharp/csharp_doc_comment.h"
+#include "google/protobuf/compiler/csharp/csharp_helpers.h"
+#include "google/protobuf/compiler/csharp/csharp_options.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 {
@@ -49,8 +49,8 @@ namespace csharp {
WrapperFieldGenerator::WrapperFieldGenerator(const FieldDescriptor* descriptor,
int presenceIndex, const Options *options)
: FieldGeneratorBase(descriptor, presenceIndex, options) {
- variables_["has_property_check"] = name() + "_ != null";
- variables_["has_not_property_check"] = name() + "_ == null";
+ variables_["has_property_check"] = y_absl::StrCat(name(), "_ != null");
+ variables_["has_not_property_check"] = y_absl::StrCat(name(), "_ == null");
const FieldDescriptor* wrapped_field = descriptor->message_type()->field(0);
is_value_type = wrapped_field->type() != FieldDescriptor::TYPE_STRING &&
wrapped_field->type() != FieldDescriptor::TYPE_BYTES;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h
index cc8a3137d6e..6b15aa0eb08 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h
@@ -31,8 +31,8 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_WRAPPER_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_CSHARP_WRAPPER_FIELD_H__
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/compiler/csharp/csharp_field_base.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/compiler/csharp/csharp_field_base.h"
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/names.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/names.cc
new file mode 100644
index 00000000000..0caa5f3f4c7
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/names.cc
@@ -0,0 +1,223 @@
+// 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: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#include "google/protobuf/compiler/csharp/names.h"
+
+#include <string>
+
+#include "y_absl/strings/match.h"
+#include "y_absl/strings/str_replace.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/strings/strip.h"
+#include "google/protobuf/compiler/csharp/names.h"
+#include "google/protobuf/descriptor.pb.h"
+
+// Must be last.
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace csharp {
+
+namespace {
+
+y_absl::string_view StripDotProto(y_absl::string_view proto_file) {
+ int lastindex = proto_file.find_last_of('.');
+ return proto_file.substr(0, lastindex);
+}
+
+// Returns the Pascal-cased last part of the proto file. For example,
+// input of "google/protobuf/foo_bar.proto" would result in "FooBar".
+TProtoStringType GetFileNameBase(const FileDescriptor* descriptor) {
+ TProtoStringType proto_file = descriptor->name();
+ int lastslash = proto_file.find_last_of('/');
+ TProtoStringType base = proto_file.substr(lastslash + 1);
+ return UnderscoresToPascalCase(StripDotProto(base));
+}
+
+TProtoStringType ToCSharpName(y_absl::string_view name, const FileDescriptor* file) {
+ TProtoStringType result = GetFileNamespace(file);
+ if (!result.empty()) {
+ result += '.';
+ }
+ y_absl::string_view classname;
+ if (file->package().empty()) {
+ classname = name;
+ } else {
+ // Strip the proto package from full_name since we've replaced it with
+ // the C# namespace.
+ classname = name.substr(file->package().size() + 1);
+ }
+ return y_absl::StrCat("global::", result,
+ y_absl::StrReplaceAll(classname, {{".", ".Types."}}));
+}
+
+} // namespace
+
+TProtoStringType GetFileNamespace(const FileDescriptor* descriptor) {
+ if (descriptor->options().has_csharp_namespace()) {
+ return descriptor->options().csharp_namespace();
+ }
+ return UnderscoresToCamelCase(descriptor->package(), true, true);
+}
+
+TProtoStringType GetClassName(const Descriptor* descriptor) {
+ return ToCSharpName(descriptor->full_name(), descriptor->file());
+}
+
+TProtoStringType GetClassName(const EnumDescriptor* descriptor) {
+ return ToCSharpName(descriptor->full_name(), descriptor->file());
+}
+
+TProtoStringType GetReflectionClassUnqualifiedName(const FileDescriptor* descriptor) {
+ // TODO: Detect collisions with existing messages,
+ // and append an underscore if necessary.
+ return y_absl::StrCat(GetFileNameBase(descriptor), "Reflection");
+}
+
+TProtoStringType GetReflectionClassName(const FileDescriptor* descriptor) {
+ TProtoStringType result = GetFileNamespace(descriptor);
+ if (!result.empty()) {
+ result += '.';
+ }
+ return y_absl::StrCat("global::", result,
+ GetReflectionClassUnqualifiedName(descriptor));
+}
+
+TProtoStringType GetExtensionClassUnqualifiedName(const FileDescriptor* descriptor) {
+ // TODO: Detect collisions with existing messages,
+ // and append an underscore if necessary.
+ return y_absl::StrCat(GetFileNameBase(descriptor), "Extensions");
+}
+
+TProtoStringType GetOutputFile(const FileDescriptor* descriptor,
+ y_absl::string_view file_extension,
+ bool generate_directories,
+ y_absl::string_view base_namespace,
+ TProtoStringType* error) {
+ TProtoStringType relative_filename =
+ y_absl::StrCat(GetFileNameBase(descriptor), file_extension);
+ if (!generate_directories) {
+ return relative_filename;
+ }
+ TProtoStringType ns = GetFileNamespace(descriptor);
+ y_absl::string_view namespace_suffix = ns;
+ if (!base_namespace.empty()) {
+ // Check that the base_namespace is either equal to or a leading part of
+ // the file namespace. This isn't just a simple prefix; "Foo.B" shouldn't
+ // be regarded as a prefix of "Foo.Bar". The simplest option is to add "."
+ // to both.
+ if (!y_absl::ConsumePrefix(&namespace_suffix, base_namespace) ||
+ (!namespace_suffix.empty() &&
+ !y_absl::ConsumePrefix(&namespace_suffix, "."))) {
+ *error = y_absl::StrCat("Namespace ", ns,
+ " is not a prefix namespace of base namespace ",
+ base_namespace);
+ return ""; // This will be ignored, because we've set an error.
+ }
+ }
+
+ return y_absl::StrCat(y_absl::StrReplaceAll(namespace_suffix, {{".", "/"}}),
+ namespace_suffix.empty() ? "" : "/", relative_filename);
+}
+
+TProtoStringType UnderscoresToPascalCase(y_absl::string_view input) {
+ return UnderscoresToCamelCase(input, true);
+}
+
+// TODO(jtattermusch): can we reuse a utility function?
+TProtoStringType UnderscoresToCamelCase(y_absl::string_view input,
+ bool cap_next_letter, bool preserve_period) {
+ TProtoStringType result;
+
+ // Note: I distrust ctype.h due to locales.
+ for (int i = 0; i < input.size(); i++) {
+ if ('a' <= input[i] && input[i] <= 'z') {
+ if (cap_next_letter) {
+ result += input[i] + ('A' - 'a');
+ } else {
+ result += input[i];
+ }
+ cap_next_letter = false;
+ } else if ('A' <= input[i] && input[i] <= 'Z') {
+ if (i == 0 && !cap_next_letter) {
+ // Force first letter to lower-case unless explicitly told to
+ // capitalize it.
+ result += input[i] + ('a' - 'A');
+ } else {
+ // Capital letters after the first are left as-is.
+ result += input[i];
+ }
+ cap_next_letter = false;
+ } else if ('0' <= input[i] && input[i] <= '9') {
+ result += input[i];
+ cap_next_letter = true;
+ } else {
+ cap_next_letter = true;
+ if (input[i] == '.' && preserve_period) {
+ result += '.';
+ }
+ }
+ }
+ // Add a trailing "_" if the name should be altered.
+ if (input.size() > 0 && input[input.size() - 1] == '#') {
+ result += '_';
+ }
+
+ // https://github.com/protocolbuffers/protobuf/issues/8101
+ // To avoid generating invalid identifiers - if the input string
+ // starts with _<digit> (or multiple underscores then digit) then
+ // we need to preserve the underscore as an identifier cannot start
+ // with a digit.
+ // This check is being done after the loop rather than before
+ // to handle the case where there are multiple underscores before the
+ // first digit. We let them all be consumed so we can see if we would
+ // start with a digit.
+ // Note: not preserving leading underscores for all otherwise valid identifiers
+ // so as to not break anything that relies on the existing behaviour
+ if (result.size() > 0 && ('0' <= result[0] && result[0] <= '9')
+ && input.size() > 0 && input[0] == '_')
+ {
+ result.insert(static_cast<size_t>(0), 1, '_');
+ }
+ return result;
+}
+
+} // namespace csharp
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/names.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/names.h
new file mode 100644
index 00000000000..2adb32e5cd4
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/names.h
@@ -0,0 +1,150 @@
+// 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: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+//
+// Provides a mechanism for mapping a descriptor to the
+// fully-qualified name of the corresponding C# class.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__
+#define GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__
+
+#include <string>
+#include "util/generic/string.h"
+
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/port_def.inc"
+
+using TProtoStringType = TString;
+
+namespace google {
+namespace protobuf {
+
+class Descriptor;
+class EnumDescriptor;
+class FileDescriptor;
+class ServiceDescriptor;
+
+namespace compiler {
+namespace csharp {
+
+// Requires:
+// descriptor != NULL
+//
+// Returns:
+// The namespace to use for given file descriptor.
+TProtoStringType PROTOC_EXPORT GetFileNamespace(const FileDescriptor* descriptor);
+
+// Requires:
+// descriptor != NULL
+//
+// Returns:
+// The fully-qualified C# class name.
+TProtoStringType PROTOC_EXPORT GetClassName(const Descriptor* descriptor);
+
+// Requires:
+// descriptor != NULL
+//
+// Returns:
+// The fully-qualified C# enum class name.
+TProtoStringType GetClassName(const EnumDescriptor* descriptor);
+
+// Requires:
+// descriptor != NULL
+//
+// Returns:
+// The unqualified name of the C# class that provides access to the file
+// descriptor. Proto compiler generates
+// such class for each .proto file processed.
+TProtoStringType GetReflectionClassUnqualifiedName(const FileDescriptor* descriptor);
+
+// Gets unqualified name of the extension class
+// Requires:
+// descriptor != NULL
+//
+// Returns:
+// The unqualified name of the generated C# extensions class that provide
+// access to extensions. Proto compiler generates such class for each
+// .proto file processed that contains extensions.
+TProtoStringType GetExtensionClassUnqualifiedName(const FileDescriptor* descriptor);
+
+// Requires:
+// descriptor != NULL
+//
+// Returns:
+// The fully-qualified name of the C# class that provides access to the file
+// descriptor. Proto compiler generates such class for each .proto file
+// processed.
+TProtoStringType PROTOC_EXPORT
+GetReflectionClassName(const FileDescriptor* descriptor);
+
+// Generates output file name for given file descriptor. If generate_directories
+// is true, the output file will be put under directory corresponding to file's
+// namespace. base_namespace can be used to strip some of the top level
+// directories. E.g. for file with namespace "Bar.Foo" and base_namespace="Bar",
+// the resulting file will be put under directory "Foo" (and not "Bar/Foo").
+//
+// Requires:
+// descriptor != NULL
+// error != NULL
+//
+// Returns:
+// The file name to use as output file for given file descriptor. In case
+// of failure, this function will return empty string and error parameter
+// will contain the error message.
+TProtoStringType PROTOC_EXPORT GetOutputFile(const FileDescriptor* descriptor,
+ y_absl::string_view file_extension,
+ bool generate_directories,
+ y_absl::string_view base_namespace,
+ TProtoStringType* error);
+
+TProtoStringType UnderscoresToPascalCase(y_absl::string_view input);
+
+// Note that we wouldn't normally want to export this (we're not expecting
+// it to be used outside libprotoc itself) but this exposes it for testing.
+TProtoStringType PROTOC_EXPORT UnderscoresToCamelCase(y_absl::string_view input,
+ bool cap_next_letter,
+ bool preserve_period);
+
+inline TProtoStringType UnderscoresToCamelCase(y_absl::string_view input,
+ bool cap_next_letter) {
+ return UnderscoresToCamelCase(input, cap_next_letter, false);
+}
+
+} // namespace csharp
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/importer.cc b/contrib/libs/protoc/src/google/protobuf/compiler/importer.cc
index 80bb1270ef6..91f1caddb31 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/importer.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/importer.cc
@@ -32,6 +32,8 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
+#include "google/protobuf/compiler/importer.h"
+
#ifdef _MSC_VER
#include <direct.h>
#else
@@ -44,13 +46,18 @@
#include <algorithm>
#include <memory>
-
-#include <google/protobuf/compiler/importer.h>
-#include <google/protobuf/compiler/parser.h>
-#include <google/protobuf/io/tokenizer.h>
-#include <google/protobuf/io/zero_copy_stream_impl.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/io/io_win32.h>
+#include <vector>
+
+#include "y_absl/strings/match.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_join.h"
+#include "y_absl/strings/str_replace.h"
+#include "y_absl/strings/str_split.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/compiler/parser.h"
+#include "google/protobuf/io/io_win32.h"
+#include "google/protobuf/io/tokenizer.h"
+#include "google/protobuf/io/zero_copy_stream_impl.h"
#ifdef _WIN32
#include <ctype.h>
@@ -70,7 +77,7 @@ using google::protobuf::io::win32::open;
// Returns true if the text looks like a Windows-style absolute path, starting
// with a drive letter. Example: "C:\foo". TODO(kenton): Share this with
// copy in command_line_interface.cc?
-static bool IsWindowsAbsolutePath(const TProtoStringType& text) {
+static bool IsWindowsAbsolutePath(y_absl::string_view text) {
#if defined(_WIN32) || defined(__CYGWIN__)
return text.size() >= 3 && text[1] == ':' && isalpha(text[0]) &&
(text[2] == '/' || text[2] == '\\') && text.find_last_of(':') == 1;
@@ -98,9 +105,10 @@ class SourceTreeDescriptorDatabase::SingleFileErrorCollector
bool had_errors() { return had_errors_; }
// implements ErrorCollector ---------------------------------------
- void AddError(int line, int column, const TProtoStringType& message) override {
+ void RecordError(int line, int column, y_absl::string_view message) override {
if (multi_file_error_collector_ != nullptr) {
- multi_file_error_collector_->AddError(filename_, line, column, message);
+ multi_file_error_collector_->RecordError(filename_, line, column,
+ message);
}
had_errors_ = true;
}
@@ -140,8 +148,8 @@ bool SourceTreeDescriptorDatabase::FindFileByName(const TProtoStringType& filena
return true;
}
if (error_collector_ != nullptr) {
- error_collector_->AddError(filename, -1, 0,
- source_tree_->GetLastErrorMessage());
+ error_collector_->RecordError(filename, -1, 0,
+ source_tree_->GetLastErrorMessage());
}
return false;
}
@@ -183,10 +191,10 @@ SourceTreeDescriptorDatabase::ValidationErrorCollector::
SourceTreeDescriptorDatabase::ValidationErrorCollector::
~ValidationErrorCollector() {}
-void SourceTreeDescriptorDatabase::ValidationErrorCollector::AddError(
- const TProtoStringType& filename, const TProtoStringType& element_name,
+void SourceTreeDescriptorDatabase::ValidationErrorCollector::RecordError(
+ y_absl::string_view filename, y_absl::string_view element_name,
const Message* descriptor, ErrorLocation location,
- const TProtoStringType& message) {
+ y_absl::string_view message) {
if (owner_->error_collector_ == nullptr) return;
int line, column;
@@ -196,13 +204,13 @@ void SourceTreeDescriptorDatabase::ValidationErrorCollector::AddError(
} else {
owner_->source_locations_.Find(descriptor, location, &line, &column);
}
- owner_->error_collector_->AddError(filename, line, column, message);
+ owner_->error_collector_->RecordError(filename, line, column, message);
}
-void SourceTreeDescriptorDatabase::ValidationErrorCollector::AddWarning(
- const TProtoStringType& filename, const TProtoStringType& element_name,
+void SourceTreeDescriptorDatabase::ValidationErrorCollector::RecordWarning(
+ y_absl::string_view filename, y_absl::string_view element_name,
const Message* descriptor, ErrorLocation location,
- const TProtoStringType& message) {
+ y_absl::string_view message) {
if (owner_->error_collector_ == nullptr) return;
int line, column;
@@ -212,7 +220,7 @@ void SourceTreeDescriptorDatabase::ValidationErrorCollector::AddWarning(
} else {
owner_->source_locations_.Find(descriptor, location, &line, &column);
}
- owner_->error_collector_->AddWarning(filename, line, column, message);
+ owner_->error_collector_->RecordWarning(filename, line, column, message);
}
// ===================================================================
@@ -251,10 +259,6 @@ DiskSourceTree::DiskSourceTree() {}
DiskSourceTree::~DiskSourceTree() {}
-static inline char LastChar(const TProtoStringType& str) {
- return str[str.size() - 1];
-}
-
// Given a path, returns an equivalent path with these changes:
// - On Windows, any backslashes are replaced with forward slashes.
// - Any instances of the directory "." are removed.
@@ -274,45 +278,39 @@ static inline char LastChar(const TProtoStringType& str) {
// then if foo/bar is a symbolic link, foo/bar/baz.proto will canonicalize
// to a path which does not appear to be under foo, and thus the compiler
// will complain that baz.proto is not inside the --proto_path.
-static TProtoStringType CanonicalizePath(TProtoStringType path) {
+static TProtoStringType CanonicalizePath(y_absl::string_view path) {
#ifdef _WIN32
// The Win32 API accepts forward slashes as a path delimiter even though
// backslashes are standard. Let's avoid confusion and use only forward
// slashes.
- if (HasPrefixString(path, "\\\\")) {
+ TProtoStringType path_str;
+ if (y_absl::StartsWith(path, "\\\\")) {
// Avoid converting two leading backslashes.
- path = "\\\\" + StringReplace(path.substr(2), "\\", "/", true);
+ path_str = y_absl::StrCat("\\\\",
+ y_absl::StrReplaceAll(path.substr(2), {{"\\", "/"}}));
} else {
- path = StringReplace(path, "\\", "/", true);
+ path_str = y_absl::StrReplaceAll(path, {{"\\", "/"}});
}
+ path = path_str;
#endif
- std::vector<TProtoStringType> canonical_parts;
- std::vector<TProtoStringType> parts = Split(
- path, "/", true); // Note: Removes empty parts.
- for (const TProtoStringType& part : parts) {
+ std::vector<y_absl::string_view> canonical_parts;
+ if (!path.empty() && path.front() == '/') canonical_parts.push_back("");
+ for (y_absl::string_view part : y_absl::StrSplit(path, '/', y_absl::SkipEmpty())) {
if (part == ".") {
// Ignore.
} else {
canonical_parts.push_back(part);
}
}
- TProtoStringType result = Join(canonical_parts, "/");
- if (!path.empty() && path[0] == '/') {
- // Restore leading slash.
- result = '/' + result;
- }
- if (!path.empty() && LastChar(path) == '/' && !result.empty() &&
- LastChar(result) != '/') {
- // Restore trailing slash.
- result += '/';
- }
- return result;
+ if (!path.empty() && path.back() == '/') canonical_parts.push_back("");
+
+ return y_absl::StrJoin(canonical_parts, "/");
}
-static inline bool ContainsParentReference(const TProtoStringType& path) {
- return path == ".." || HasPrefixString(path, "../") ||
- HasSuffixString(path, "/..") || path.find("/../") != TProtoStringType::npos;
+static inline bool ContainsParentReference(y_absl::string_view path) {
+ return path == ".." || y_absl::StartsWith(path, "../") ||
+ y_absl::EndsWith(path, "/..") || y_absl::StrContains(path, "/../");
}
// Maps a file from an old location to a new one. Typically, old_prefix is
@@ -332,28 +330,28 @@ static inline bool ContainsParentReference(const TProtoStringType& path) {
// assert(!ApplyMapping("foo/bar", "baz", "qux", &result));
// assert(!ApplyMapping("foo/bar", "baz", "qux", &result));
// assert(!ApplyMapping("foobar", "foo", "baz", &result));
-static bool ApplyMapping(const TProtoStringType& filename,
- const TProtoStringType& old_prefix,
- const TProtoStringType& new_prefix, TProtoStringType* result) {
+static bool ApplyMapping(y_absl::string_view filename,
+ y_absl::string_view old_prefix,
+ y_absl::string_view new_prefix, TProtoStringType* result) {
if (old_prefix.empty()) {
// old_prefix matches any relative path.
if (ContainsParentReference(filename)) {
// We do not allow the file name to use "..".
return false;
}
- if (HasPrefixString(filename, "/") || IsWindowsAbsolutePath(filename)) {
+ if (y_absl::StartsWith(filename, "/") || IsWindowsAbsolutePath(filename)) {
// This is an absolute path, so it isn't matched by the empty string.
return false;
}
- result->assign(new_prefix);
+ result->assign(TProtoStringType(new_prefix));
if (!result->empty()) result->push_back('/');
- result->append(filename);
+ result->append(TProtoStringType(filename));
return true;
- } else if (HasPrefixString(filename, old_prefix)) {
+ } else if (y_absl::StartsWith(filename, old_prefix)) {
// old_prefix is a prefix of the filename. Is it the whole filename?
if (filename.size() == old_prefix.size()) {
// Yep, it's an exact match.
- *result = new_prefix;
+ *result = TProtoStringType(new_prefix);
return true;
} else {
// Not an exact match. Is the next character a '/'? Otherwise,
@@ -370,14 +368,14 @@ static bool ApplyMapping(const TProtoStringType& filename,
if (after_prefix_start != -1) {
// Yep. So the prefixes are directories and the filename is a file
// inside them.
- TProtoStringType after_prefix = filename.substr(after_prefix_start);
+ y_absl::string_view after_prefix = filename.substr(after_prefix_start);
if (ContainsParentReference(after_prefix)) {
// We do not allow the file name to use "..".
return false;
}
- result->assign(new_prefix);
+ result->assign(TProtoStringType(new_prefix));
if (!result->empty()) result->push_back('/');
- result->append(after_prefix);
+ result->append(TProtoStringType(after_prefix));
return true;
}
}
@@ -386,13 +384,14 @@ static bool ApplyMapping(const TProtoStringType& filename,
return false;
}
-void DiskSourceTree::MapPath(const TProtoStringType& virtual_path,
- const TProtoStringType& disk_path) {
- mappings_.push_back(Mapping(virtual_path, CanonicalizePath(disk_path)));
+void DiskSourceTree::MapPath(y_absl::string_view virtual_path,
+ y_absl::string_view disk_path) {
+ mappings_.push_back(
+ Mapping(TProtoStringType(virtual_path), CanonicalizePath(disk_path)));
}
DiskSourceTree::DiskFileToVirtualFileResult
-DiskSourceTree::DiskFileToVirtualFile(const TProtoStringType& disk_file,
+DiskSourceTree::DiskFileToVirtualFile(y_absl::string_view disk_file,
TProtoStringType* virtual_file,
TProtoStringType* shadowing_disk_file) {
int mapping_index = -1;
@@ -436,7 +435,7 @@ DiskSourceTree::DiskFileToVirtualFile(const TProtoStringType& disk_file,
return SUCCESS;
}
-bool DiskSourceTree::VirtualFileToDiskFile(const TProtoStringType& virtual_file,
+bool DiskSourceTree::VirtualFileToDiskFile(y_absl::string_view virtual_file,
TProtoStringType* disk_file) {
std::unique_ptr<io::ZeroCopyInputStream> stream(
OpenVirtualFile(virtual_file, disk_file));
@@ -452,7 +451,7 @@ TProtoStringType DiskSourceTree::GetLastErrorMessage() {
}
io::ZeroCopyInputStream* DiskSourceTree::OpenVirtualFile(
- const TProtoStringType& virtual_file, TProtoStringType* disk_file) {
+ y_absl::string_view virtual_file, TProtoStringType* disk_file) {
if (virtual_file != CanonicalizePath(virtual_file) ||
ContainsParentReference(virtual_file)) {
// We do not allow importing of paths containing things like ".." or
@@ -479,7 +478,7 @@ io::ZeroCopyInputStream* DiskSourceTree::OpenVirtualFile(
if (errno == EACCES) {
// The file exists but is not readable.
last_error_message_ =
- "Read access is denied for file: " + temp_disk_file;
+ y_absl::StrCat("Read access is denied for file: ", temp_disk_file);
return nullptr;
}
}
@@ -489,11 +488,11 @@ io::ZeroCopyInputStream* DiskSourceTree::OpenVirtualFile(
}
io::ZeroCopyInputStream* DiskSourceTree::OpenDiskFile(
- const TProtoStringType& filename) {
+ y_absl::string_view filename) {
struct stat sb;
int ret = 0;
do {
- ret = stat(filename.c_str(), &sb);
+ ret = stat(TProtoStringType(filename).c_str(), &sb);
} while (ret != 0 && errno == EINTR);
#if defined(_WIN32)
if (ret == 0 && sb.st_mode & S_IFDIR) {
@@ -508,7 +507,7 @@ io::ZeroCopyInputStream* DiskSourceTree::OpenDiskFile(
#endif
int file_descriptor;
do {
- file_descriptor = open(filename.c_str(), O_RDONLY);
+ file_descriptor = open(TProtoStringType(filename).c_str(), O_RDONLY);
} while (file_descriptor < 0 && errno == EINTR);
if (file_descriptor >= 0) {
io::FileInputStream* result = new io::FileInputStream(file_descriptor);
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/importer.h b/contrib/libs/protoc/src/google/protobuf/compiler/importer.h
index c13821a2430..64cbdb0d230 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/importer.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/importer.h
@@ -37,17 +37,17 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_IMPORTER_H__
#define GOOGLE_PROTOBUF_COMPILER_IMPORTER_H__
-#include <set>
#include <string>
#include <utility>
#include <vector>
-#include <google/protobuf/compiler/parser.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/descriptor_database.h>
+#include "y_absl/strings/string_view.h"
+#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>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -129,14 +129,14 @@ class PROTOBUF_EXPORT SourceTreeDescriptorDatabase : public DescriptorDatabase {
~ValidationErrorCollector() override;
// implements ErrorCollector ---------------------------------------
- void AddError(const TProtoStringType& filename, const TProtoStringType& element_name,
- const Message* descriptor, ErrorLocation location,
- const TProtoStringType& message) override;
+ void RecordError(y_absl::string_view filename, y_absl::string_view element_name,
+ const Message* descriptor, ErrorLocation location,
+ y_absl::string_view message) override;
- void AddWarning(const TProtoStringType& filename,
- const TProtoStringType& element_name, const Message* descriptor,
- ErrorLocation location,
- const TProtoStringType& message) override;
+ void RecordWarning(y_absl::string_view filename,
+ y_absl::string_view element_name,
+ const Message* descriptor, ErrorLocation location,
+ y_absl::string_view message) override;
private:
SourceTreeDescriptorDatabase* owner_;
@@ -159,6 +159,8 @@ class PROTOBUF_EXPORT SourceTreeDescriptorDatabase : public DescriptorDatabase {
class PROTOBUF_EXPORT Importer {
public:
Importer(SourceTree* source_tree, MultiFileErrorCollector* error_collector);
+ Importer(const Importer&) = delete;
+ Importer& operator=(const Importer&) = delete;
~Importer();
// Import the given file and build a FileDescriptor representing it. If
@@ -188,27 +190,43 @@ class PROTOBUF_EXPORT Importer {
private:
SourceTreeDescriptorDatabase database_;
DescriptorPool pool_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Importer);
};
// If the importer encounters problems while trying to import the proto files,
// it reports them to a MultiFileErrorCollector.
class PROTOBUF_EXPORT MultiFileErrorCollector {
public:
- inline MultiFileErrorCollector() {}
+ MultiFileErrorCollector() {}
+ MultiFileErrorCollector(const MultiFileErrorCollector&) = delete;
+ MultiFileErrorCollector& operator=(const MultiFileErrorCollector&) = delete;
virtual ~MultiFileErrorCollector();
// Line and column numbers are zero-based. A line number of -1 indicates
// an error with the entire file (e.g. "not found").
+ virtual void RecordError(y_absl::string_view filename, int line, int column,
+ y_absl::string_view message) {
+ PROTOBUF_IGNORE_DEPRECATION_START
+ AddError(TProtoStringType(filename), line, column, TProtoStringType(message));
+ PROTOBUF_IGNORE_DEPRECATION_STOP
+ }
+ virtual void RecordWarning(y_absl::string_view filename, int line, int column,
+ y_absl::string_view message) {
+ PROTOBUF_IGNORE_DEPRECATION_START
+ AddWarning(TProtoStringType(filename), line, column, TProtoStringType(message));
+ PROTOBUF_IGNORE_DEPRECATION_STOP
+ }
+
+ // These should never be called directly, but if a legacy class overrides
+ // them they'll get routed to by the Record* methods.
+
virtual void AddError(const TProtoStringType& filename, int line, int column,
- const TProtoStringType& message) = 0;
+ const TProtoStringType& message) {
+ Y_ABSL_LOG(FATAL) << "AddError or RecordError must be implemented.";
+ }
- virtual void AddWarning(const TProtoStringType& /* filename */, int /* line */,
- int /* column */, const TProtoStringType& /* message */) {}
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MultiFileErrorCollector);
+ virtual void AddWarning(const TProtoStringType& filename, int line, int column,
+ const TProtoStringType& message) {}
};
// Abstract interface which represents a directory tree containing proto files.
@@ -217,7 +235,9 @@ class PROTOBUF_EXPORT MultiFileErrorCollector {
// below.
class PROTOBUF_EXPORT SourceTree {
public:
- inline SourceTree() {}
+ SourceTree() {}
+ SourceTree(const SourceTree&) = delete;
+ SourceTree& operator=(const SourceTree&) = delete;
virtual ~SourceTree();
// Open the given file and return a stream that reads it, or NULL if not
@@ -232,9 +252,6 @@ class PROTOBUF_EXPORT SourceTree {
// better error reporting.
// TODO(xiaofeng): change this to a pure virtual function.
virtual TProtoStringType GetLastErrorMessage();
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SourceTree);
};
// An implementation of SourceTree which loads files from locations on disk.
@@ -243,6 +260,8 @@ class PROTOBUF_EXPORT SourceTree {
class PROTOBUF_EXPORT DiskSourceTree : public SourceTree {
public:
DiskSourceTree();
+ DiskSourceTree(const DiskSourceTree&) = delete;
+ DiskSourceTree& operator=(const DiskSourceTree&) = delete;
~DiskSourceTree() override;
// Map a path on disk to a location in the SourceTree. The path may be
@@ -261,7 +280,7 @@ class PROTOBUF_EXPORT DiskSourceTree : public SourceTree {
//
// disk_path may be an absolute path or relative to the current directory,
// just like a path you'd pass to open().
- void MapPath(const TProtoStringType& virtual_path, const TProtoStringType& disk_path);
+ void MapPath(y_absl::string_view virtual_path, y_absl::string_view disk_path);
// Return type for DiskFileToVirtualFile().
enum DiskFileToVirtualFileResult {
@@ -292,13 +311,13 @@ class PROTOBUF_EXPORT DiskSourceTree : public SourceTree {
// * NO_MAPPING: Indicates that no mapping was found which contains this
// file.
DiskFileToVirtualFileResult DiskFileToVirtualFile(
- const TProtoStringType& disk_file, TProtoStringType* virtual_file,
+ y_absl::string_view disk_file, TProtoStringType* virtual_file,
TProtoStringType* shadowing_disk_file);
// Given a virtual path, find the path to the file on disk.
// Return true and update disk_file with the on-disk path if the file exists.
// Return false and leave disk_file untouched if the file doesn't exist.
- bool VirtualFileToDiskFile(const TProtoStringType& virtual_file,
+ bool VirtualFileToDiskFile(y_absl::string_view virtual_file,
TProtoStringType* disk_file);
// implements SourceTree -------------------------------------------
@@ -311,28 +330,26 @@ class PROTOBUF_EXPORT DiskSourceTree : public SourceTree {
TProtoStringType virtual_path;
TProtoStringType disk_path;
- inline Mapping(const TProtoStringType& virtual_path_param,
- const TProtoStringType& disk_path_param)
- : virtual_path(virtual_path_param), disk_path(disk_path_param) {}
+ inline Mapping(TProtoStringType virtual_path_param, TProtoStringType disk_path_param)
+ : virtual_path(std::move(virtual_path_param)),
+ disk_path(std::move(disk_path_param)) {}
};
std::vector<Mapping> mappings_;
TProtoStringType last_error_message_;
// Like Open(), but returns the on-disk path in disk_file if disk_file is
// non-NULL and the file could be successfully opened.
- io::ZeroCopyInputStream* OpenVirtualFile(const TProtoStringType& virtual_file,
+ io::ZeroCopyInputStream* OpenVirtualFile(y_absl::string_view virtual_file,
TProtoStringType* disk_file);
// Like Open() but given the actual on-disk path.
- io::ZeroCopyInputStream* OpenDiskFile(const TProtoStringType& filename);
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DiskSourceTree);
+ io::ZeroCopyInputStream* OpenDiskFile(y_absl::string_view filename);
};
} // namespace compiler
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_IMPORTER_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/context.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/context.cc
index 463aa1f5abc..839fb6e2f59 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/context.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/context.cc
@@ -28,14 +28,18 @@
// (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/java/context.h>
+#include "google/protobuf/compiler/java/context.h"
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/java/field.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/name_resolver.h>
-#include <google/protobuf/stubs/map_util.h>
+#include <string>
+
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/strings/strip.h"
+#include "google/protobuf/compiler/java/field.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/name_resolver.h"
+#include "google/protobuf/descriptor.h"
namespace google {
namespace protobuf {
@@ -43,7 +47,7 @@ namespace compiler {
namespace java {
Context::Context(const FileDescriptor* file, const Options& options)
- : name_resolver_(new ClassNameResolver), options_(options) {
+ : name_resolver_(new ClassNameResolver(options)), options_(options) {
InitializeFieldGeneratorInfo(file);
}
@@ -54,11 +58,17 @@ ClassNameResolver* Context::GetNameResolver() const {
}
namespace {
+bool EqualWithSuffix(y_absl::string_view name1, y_absl::string_view suffix,
+ y_absl::string_view name2) {
+ if (!y_absl::ConsumeSuffix(&name2, suffix)) return false;
+ return name1 == name2;
+}
+
// Whether two fields have conflicting accessors (assuming name1 and name2
// are different). name1 and name2 are field1 and field2's camel-case name
// respectively.
-bool IsConflicting(const FieldDescriptor* field1, const TProtoStringType& name1,
- const FieldDescriptor* field2, const TProtoStringType& name2,
+bool IsConflicting(const FieldDescriptor* field1, y_absl::string_view name1,
+ const FieldDescriptor* field2, y_absl::string_view name2,
TProtoStringType* info) {
if (field1->is_repeated()) {
if (field2->is_repeated()) {
@@ -66,16 +76,18 @@ bool IsConflicting(const FieldDescriptor* field1, const TProtoStringType& name1,
return false;
} else {
// field1 is repeated, and field2 is not.
- if (name1 + "Count" == name2) {
- *info = "both repeated field \"" + field1->name() + "\" and singular " +
- "field \"" + field2->name() + "\" generate the method \"" +
- "get" + name1 + "Count()\"";
+ if (EqualWithSuffix(name1, "Count", name2)) {
+ *info = y_absl::StrCat("both repeated field \"", field1->name(),
+ "\" and singular ", "field \"", field2->name(),
+ "\" generate the method \"", "get", name1,
+ "Count()\"");
return true;
}
- if (name1 + "List" == name2) {
- *info = "both repeated field \"" + field1->name() + "\" and singular " +
- "field \"" + field2->name() + "\" generate the method \"" +
- "get" + name1 + "List()\"";
+ if (EqualWithSuffix(name1, "List", name2)) {
+ *info =
+ y_absl::StrCat("both repeated field \"", field1->name(),
+ "\" and singular ", "field \"", field2->name(),
+ "\" generate the method \"", "get", name1, "List()\"");
return true;
}
// Well, there are obviously many more conflicting cases, but it probably
@@ -131,15 +143,15 @@ void Context::InitializeFieldGeneratorInfoForFields(
std::vector<TProtoStringType> conflict_reason(fields.size());
for (int i = 0; i < fields.size(); ++i) {
const FieldDescriptor* field = fields[i];
- const TProtoStringType& name = UnderscoresToCapitalizedCamelCase(field);
+ const TProtoStringType& name = CapitalizedFieldName(field);
for (int j = i + 1; j < fields.size(); ++j) {
const FieldDescriptor* other = fields[j];
- const TProtoStringType& other_name = UnderscoresToCapitalizedCamelCase(other);
+ const TProtoStringType& other_name = CapitalizedFieldName(other);
if (name == other_name) {
is_conflict[i] = is_conflict[j] = true;
conflict_reason[i] = conflict_reason[j] =
- "capitalized name of field \"" + field->name() +
- "\" conflicts with field \"" + other->name() + "\"";
+ y_absl::StrCat("capitalized name of field \"", field->name(),
+ "\" conflicts with field \"", other->name(), "\"");
} else if (IsConflicting(field, name, other, other_name,
&conflict_reason[j])) {
is_conflict[i] = is_conflict[j] = true;
@@ -147,20 +159,21 @@ void Context::InitializeFieldGeneratorInfoForFields(
}
}
if (is_conflict[i]) {
- GOOGLE_LOG(WARNING) << "field \"" << field->full_name() << "\" is conflicting "
- << "with another field: " << conflict_reason[i];
+ Y_ABSL_LOG(WARNING) << "field \"" << field->full_name()
+ << "\" is conflicting "
+ << "with another field: " << conflict_reason[i];
}
}
for (int i = 0; i < fields.size(); ++i) {
const FieldDescriptor* field = fields[i];
FieldGeneratorInfo info;
info.name = CamelCaseFieldName(field);
- info.capitalized_name = UnderscoresToCapitalizedCamelCase(field);
+ info.capitalized_name = CapitalizedFieldName(field);
// For fields conflicting with some other fields, we append the field
// number to their field names in generated code to avoid conflicts.
if (is_conflict[i]) {
- info.name += StrCat(field->number());
- info.capitalized_name += StrCat(field->number());
+ y_absl::StrAppend(&info.name, field->number());
+ y_absl::StrAppend(&info.capitalized_name, field->number());
info.disambiguated_reason = conflict_reason[i];
}
field_generator_info_map_[field] = info;
@@ -169,24 +182,22 @@ void Context::InitializeFieldGeneratorInfoForFields(
const FieldGeneratorInfo* Context::GetFieldGeneratorInfo(
const FieldDescriptor* field) const {
- const FieldGeneratorInfo* result =
- FindOrNull(field_generator_info_map_, field);
- if (result == NULL) {
- GOOGLE_LOG(FATAL) << "Can not find FieldGeneratorInfo for field: "
- << field->full_name();
+ auto it = field_generator_info_map_.find(field);
+ if (it == field_generator_info_map_.end()) {
+ Y_ABSL_LOG(FATAL) << "Can not find FieldGeneratorInfo for field: "
+ << field->full_name();
}
- return result;
+ return &it->second;
}
const OneofGeneratorInfo* Context::GetOneofGeneratorInfo(
const OneofDescriptor* oneof) const {
- const OneofGeneratorInfo* result =
- FindOrNull(oneof_generator_info_map_, oneof);
- if (result == NULL) {
- GOOGLE_LOG(FATAL) << "Can not find OneofGeneratorInfo for oneof: "
- << oneof->name();
+ auto it = oneof_generator_info_map_.find(oneof);
+ if (it == oneof_generator_info_map_.end()) {
+ Y_ABSL_LOG(FATAL) << "Can not find OneofGeneratorInfo for oneof: "
+ << oneof->name();
}
- return result;
+ return &it->second;
}
// Does this message class have generated parsing, serialization, and other
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/context.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/context.h
index c224ab73f5e..57b994a8e33 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/context.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/context.h
@@ -31,12 +31,13 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_CONTEXT_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_CONTEXT_H__
-#include <map>
#include <memory>
#include <vector>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/compiler/java/options.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/options.h"
+#include "google/protobuf/port.h"
namespace google {
namespace protobuf {
@@ -65,6 +66,8 @@ struct OneofGeneratorInfo;
class Context {
public:
Context(const FileDescriptor* file, const Options& options);
+ Context(const Context&) = delete;
+ Context& operator=(const Context&) = delete;
~Context();
// Get the name resolver associated with this context. The resolver
@@ -97,14 +100,27 @@ class Context {
const std::vector<const FieldDescriptor*>& fields);
std::unique_ptr<ClassNameResolver> name_resolver_;
- std::map<const FieldDescriptor*, FieldGeneratorInfo>
+ y_absl::flat_hash_map<const FieldDescriptor*, FieldGeneratorInfo>
field_generator_info_map_;
- std::map<const OneofDescriptor*, OneofGeneratorInfo>
+ y_absl::flat_hash_map<const OneofDescriptor*, OneofGeneratorInfo>
oneof_generator_info_map_;
Options options_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Context);
};
+template <typename Descriptor>
+void MaybePrintGeneratedAnnotation(Context* context, io::Printer* printer,
+ Descriptor* descriptor, bool immutable,
+ const TProtoStringType& suffix = "") {
+ if (IsOwnFile(descriptor, immutable)) {
+ PrintGeneratedAnnotation(printer, '$',
+ context->options().annotate_code
+ ? AnnotationFileName(descriptor, suffix)
+ : "",
+ context->options());
+ }
+}
+
+
} // namespace java
} // namespace compiler
} // namespace protobuf
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/doc_comment.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/doc_comment.cc
index ec7dce7d34e..74fb087ccf8 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/doc_comment.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/doc_comment.cc
@@ -32,13 +32,14 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/doc_comment.h>
+#include "google/protobuf/compiler/java/doc_comment.h"
#include <vector>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/descriptor.pb.h>
+#include "y_absl/strings/str_split.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
@@ -103,26 +104,65 @@ TProtoStringType EscapeJavadoc(const TProtoStringType& input) {
return result;
}
+static TProtoStringType EscapeKdoc(const TProtoStringType& input) {
+ TProtoStringType result;
+ result.reserve(input.size() * 2);
+
+ char prev = 'a';
+
+ for (char c : input) {
+ switch (c) {
+ case '*':
+ // Avoid "/*".
+ if (prev == '/') {
+ result.append("&#42;");
+ } else {
+ result.push_back(c);
+ }
+ break;
+ case '/':
+ // Avoid "*/".
+ if (prev == '*') {
+ result.append("&#47;");
+ } else {
+ result.push_back(c);
+ }
+ break;
+ default:
+ result.push_back(c);
+ break;
+ }
+
+ prev = c;
+ }
+
+ return result;
+}
+
static void WriteDocCommentBodyForLocation(io::Printer* printer,
- const SourceLocation& location) {
+ const SourceLocation& location,
+ const bool kdoc) {
TProtoStringType comments = location.leading_comments.empty()
? location.trailing_comments
: location.leading_comments;
if (!comments.empty()) {
- // TODO(kenton): Ideally we should parse the comment text as Markdown and
- // write it back as HTML, but this requires a Markdown parser. For now
- // we just use <pre> to get fixed-width text formatting.
-
- // If the comment itself contains block comment start or end markers,
- // HTML-escape them so that they don't accidentally close the doc comment.
- comments = EscapeJavadoc(comments);
+ if (kdoc) {
+ comments = EscapeKdoc(comments);
+ } else {
+ comments = EscapeJavadoc(comments);
+ }
- std::vector<TProtoStringType> lines = Split(comments, "\n");
+ std::vector<TProtoStringType> lines = y_absl::StrSplit(comments, "\n");
while (!lines.empty() && lines.back().empty()) {
lines.pop_back();
}
- printer->Print(" * <pre>\n");
+ if (kdoc) {
+ printer->Print(" * ```\n");
+ } else {
+ printer->Print(" * <pre>\n");
+ }
+
for (int i = 0; i < lines.size(); i++) {
// Most lines should start with a space. Watch out for lines that start
// with a /, since putting that right after the leading asterisk will
@@ -133,18 +173,23 @@ static void WriteDocCommentBodyForLocation(io::Printer* printer,
printer->Print(" *$line$\n", "line", lines[i]);
}
}
- printer->Print(
- " * </pre>\n"
- " *\n");
+
+ if (kdoc) {
+ printer->Print(" * ```\n");
+ } else {
+ printer->Print(" * </pre>\n");
+ }
+ printer->Print(" *\n");
}
}
template <typename DescriptorType>
static void WriteDocCommentBody(io::Printer* printer,
- const DescriptorType* descriptor) {
+ const DescriptorType* descriptor,
+ const bool kdoc) {
SourceLocation location;
if (descriptor->GetSourceLocation(&location)) {
- WriteDocCommentBodyForLocation(printer, location);
+ WriteDocCommentBodyForLocation(printer, location, kdoc);
}
}
@@ -164,16 +209,36 @@ static TProtoStringType FirstLineOf(const TProtoStringType& value) {
return result;
}
-void WriteMessageDocComment(io::Printer* printer, const Descriptor* message) {
+static void WriteDebugString(io::Printer* printer, const FieldDescriptor* field,
+ const bool kdoc) {
+ if (kdoc) {
+ printer->Print(" * `$def$`\n", "def",
+ EscapeKdoc(FirstLineOf(field->DebugString())));
+ } else {
+ printer->Print(" * <code>$def$</code>\n", "def",
+ EscapeJavadoc(FirstLineOf(field->DebugString())));
+ }
+}
+
+void WriteMessageDocComment(io::Printer* printer, const Descriptor* message,
+ const bool kdoc) {
printer->Print("/**\n");
- WriteDocCommentBody(printer, message);
- printer->Print(
- " * Protobuf type {@code $fullname$}\n"
- " */\n",
- "fullname", EscapeJavadoc(message->full_name()));
+ WriteDocCommentBody(printer, message, kdoc);
+ if (kdoc) {
+ printer->Print(
+ " * Protobuf type `$fullname$`\n"
+ " */\n",
+ "fullname", EscapeKdoc(message->full_name()));
+ } else {
+ printer->Print(
+ " * Protobuf type {@code $fullname$}\n"
+ " */\n",
+ "fullname", EscapeJavadoc(message->full_name()));
+ }
}
-void WriteFieldDocComment(io::Printer* printer, const FieldDescriptor* field) {
+void WriteFieldDocComment(io::Printer* printer, const FieldDescriptor* field,
+ const bool kdoc) {
// We start the comment with the main body based on the comments from the
// .proto file (if present). We then continue with the field declaration,
// e.g.:
@@ -181,9 +246,14 @@ void WriteFieldDocComment(io::Printer* printer, const FieldDescriptor* field) {
// And then we end with the javadoc tags if applicable.
// If the field is a group, the debug string might end with {.
printer->Print("/**\n");
- WriteDocCommentBody(printer, field);
- printer->Print(" * <code>$def$</code>\n", "def",
- EscapeJavadoc(FirstLineOf(field->DebugString())));
+ WriteDocCommentBody(printer, field, kdoc);
+ if (kdoc) {
+ printer->Print(" * `$def$`\n", "def",
+ EscapeKdoc(FirstLineOf(field->DebugString())));
+ } else {
+ printer->Print(" * <code>$def$</code>\n", "def",
+ EscapeJavadoc(FirstLineOf(field->DebugString())));
+ }
printer->Print(" */\n");
}
@@ -214,12 +284,11 @@ void WriteDeprecatedJavadoc(io::Printer* printer, const FieldDescriptor* field,
void WriteFieldAccessorDocComment(io::Printer* printer,
const FieldDescriptor* field,
const FieldAccessorType type,
- const bool builder) {
+ const bool builder, const bool kdoc) {
printer->Print("/**\n");
- WriteDocCommentBody(printer, field);
- printer->Print(" * <code>$def$</code>\n", "def",
- EscapeJavadoc(FirstLineOf(field->DebugString())));
- WriteDeprecatedJavadoc(printer, field, type);
+ WriteDocCommentBody(printer, field, kdoc);
+ WriteDebugString(printer, field, kdoc);
+ if (!kdoc) WriteDeprecatedJavadoc(printer, field, type);
switch (type) {
case HAZZER:
printer->Print(" * @return Whether the $name$ field is set.\n", "name",
@@ -273,12 +342,12 @@ void WriteFieldAccessorDocComment(io::Printer* printer,
void WriteFieldEnumValueAccessorDocComment(io::Printer* printer,
const FieldDescriptor* field,
const FieldAccessorType type,
- const bool builder) {
+ const bool builder,
+ const bool kdoc) {
printer->Print("/**\n");
- WriteDocCommentBody(printer, field);
- printer->Print(" * <code>$def$</code>\n", "def",
- EscapeJavadoc(FirstLineOf(field->DebugString())));
- WriteDeprecatedJavadoc(printer, field, type);
+ WriteDocCommentBody(printer, field, kdoc);
+ WriteDebugString(printer, field, kdoc);
+ if (!kdoc) WriteDeprecatedJavadoc(printer, field, type);
switch (type) {
case HAZZER:
// Should never happen
@@ -343,12 +412,12 @@ void WriteFieldEnumValueAccessorDocComment(io::Printer* printer,
void WriteFieldStringBytesAccessorDocComment(io::Printer* printer,
const FieldDescriptor* field,
const FieldAccessorType type,
- const bool builder) {
+ const bool builder,
+ const bool kdoc) {
printer->Print("/**\n");
- WriteDocCommentBody(printer, field);
- printer->Print(" * <code>$def$</code>\n", "def",
- EscapeJavadoc(FirstLineOf(field->DebugString())));
- WriteDeprecatedJavadoc(printer, field, type);
+ WriteDocCommentBody(printer, field, kdoc);
+ WriteDebugString(printer, field, kdoc);
+ if (!kdoc) WriteDeprecatedJavadoc(printer, field, type);
switch (type) {
case HAZZER:
// Should never happen
@@ -399,19 +468,28 @@ void WriteFieldStringBytesAccessorDocComment(io::Printer* printer,
// Enum
-void WriteEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_) {
+void WriteEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_,
+ const bool kdoc) {
printer->Print("/**\n");
- WriteDocCommentBody(printer, enum_);
- printer->Print(
- " * Protobuf enum {@code $fullname$}\n"
- " */\n",
- "fullname", EscapeJavadoc(enum_->full_name()));
+ WriteDocCommentBody(printer, enum_, kdoc);
+ if (kdoc) {
+ printer->Print(
+ " * Protobuf enum `$fullname$`\n"
+ " */\n",
+ "fullname", EscapeKdoc(enum_->full_name()));
+ } else {
+ printer->Print(
+ " * Protobuf enum {@code $fullname$}\n"
+ " */\n",
+ "fullname", EscapeJavadoc(enum_->full_name()));
+ }
}
void WriteEnumValueDocComment(io::Printer* printer,
const EnumValueDescriptor* value) {
printer->Print("/**\n");
- WriteDocCommentBody(printer, value);
+ WriteDocCommentBody(printer, value, /* kdoc */ false);
+
printer->Print(
" * <code>$def$</code>\n"
" */\n",
@@ -421,7 +499,7 @@ void WriteEnumValueDocComment(io::Printer* printer,
void WriteServiceDocComment(io::Printer* printer,
const ServiceDescriptor* service) {
printer->Print("/**\n");
- WriteDocCommentBody(printer, service);
+ WriteDocCommentBody(printer, service, /* kdoc */ false);
printer->Print(
" * Protobuf service {@code $fullname$}\n"
" */\n",
@@ -431,7 +509,7 @@ void WriteServiceDocComment(io::Printer* printer,
void WriteMethodDocComment(io::Printer* printer,
const MethodDescriptor* method) {
printer->Print("/**\n");
- WriteDocCommentBody(printer, method);
+ WriteDocCommentBody(printer, method, /* kdoc */ false);
printer->Print(
" * <code>$def$</code>\n"
" */\n",
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/doc_comment.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/doc_comment.h
index 52d6f774745..2c8ecc4047e 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/doc_comment.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/doc_comment.h
@@ -35,10 +35,10 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_DOC_COMMENT_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_DOC_COMMENT_H__
-#include <google/protobuf/descriptor.h>
+#include "google/protobuf/descriptor.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -67,21 +67,27 @@ enum FieldAccessorType {
LIST_MULTI_ADDER
};
-void WriteMessageDocComment(io::Printer* printer, const Descriptor* message);
-void WriteFieldDocComment(io::Printer* printer, const FieldDescriptor* field);
+void WriteMessageDocComment(io::Printer* printer, const Descriptor* message,
+ const bool kdoc = false);
+void WriteFieldDocComment(io::Printer* printer, const FieldDescriptor* field,
+ const bool kdoc = false);
void WriteFieldAccessorDocComment(io::Printer* printer,
const FieldDescriptor* field,
const FieldAccessorType type,
- const bool builder = false);
+ const bool builder = false,
+ const bool kdoc = false);
void WriteFieldEnumValueAccessorDocComment(io::Printer* printer,
const FieldDescriptor* field,
const FieldAccessorType type,
- const bool builder = false);
+ const bool builder = false,
+ const bool kdoc = false);
void WriteFieldStringBytesAccessorDocComment(io::Printer* printer,
const FieldDescriptor* field,
const FieldAccessorType type,
- const bool builder = false);
-void WriteEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_);
+ const bool builder = false,
+ const bool kdoc = false);
+void WriteEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_,
+ const bool kdoc = false);
void WriteEnumValueDocComment(io::Printer* printer,
const EnumValueDescriptor* value);
void WriteServiceDocComment(io::Printer* printer,
@@ -90,6 +96,7 @@ void WriteMethodDocComment(io::Printer* printer,
const MethodDescriptor* method);
// Exposed for testing only.
+// Also called by proto1-Java code generator.
PROTOC_EXPORT TProtoStringType EscapeJavadoc(const TProtoStringType& input);
} // namespace java
@@ -97,6 +104,6 @@ PROTOC_EXPORT TProtoStringType EscapeJavadoc(const TProtoStringType& input);
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_DOC_COMMENT_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/enum.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum.cc
index 5ba5e630c05..000cd54882b 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/enum.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum.cc
@@ -32,21 +32,21 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/enum.h>
+#include "google/protobuf/compiler/java/enum.h"
-#include <map>
#include <string>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/java/context.h>
-#include <google/protobuf/compiler/java/doc_comment.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/name_resolver.h>
-#include <google/protobuf/descriptor.pb.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/java/context.h"
+#include "google/protobuf/compiler/java/doc_comment.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/name_resolver.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/printer.h"
// Must be last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -80,6 +80,10 @@ EnumGenerator::~EnumGenerator() {}
void EnumGenerator::Generate(io::Printer* printer) {
WriteEnumDocComment(printer, descriptor_);
MaybePrintGeneratedAnnotation(context_, printer, descriptor_, immutable_api_);
+
+ if (!context_->options().opensource_runtime) {
+ printer->Print("@com.google.protobuf.Internal.ProtoNonnullApi\n");
+ }
printer->Print(
"$deprecation$public enum $classname$\n"
" implements com.google.protobuf.ProtocolMessageEnum {\n",
@@ -99,10 +103,10 @@ void EnumGenerator::Generate(io::Printer* printer) {
}
for (int i = 0; i < canonical_values_.size(); i++) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
vars["name"] = canonical_values_[i]->name();
- vars["index"] = StrCat(canonical_values_[i]->index());
- vars["number"] = StrCat(canonical_values_[i]->number());
+ vars["index"] = y_absl::StrCat(canonical_values_[i]->index());
+ vars["number"] = y_absl::StrCat(canonical_values_[i]->number());
WriteEnumValueDocComment(printer, canonical_values_[i]);
if (canonical_values_[i]->options().deprecated()) {
printer->Print("@java.lang.Deprecated\n");
@@ -131,7 +135,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
// -----------------------------------------------------------------
for (int i = 0; i < aliases_.size(); i++) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
vars["classname"] = descriptor_->name();
vars["name"] = aliases_[i].value->name();
vars["canonical_name"] = aliases_[i].canonical_value->name();
@@ -142,9 +146,9 @@ void EnumGenerator::Generate(io::Printer* printer) {
}
for (int i = 0; i < descriptor_->value_count(); i++) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
vars["name"] = descriptor_->value(i)->name();
- vars["number"] = StrCat(descriptor_->value(i)->number());
+ vars["number"] = y_absl::StrCat(descriptor_->value(i)->number());
vars["{"] = "";
vars["}"] = "";
vars["deprecation"] = descriptor_->value(i)->options().deprecated()
@@ -181,23 +185,32 @@ void EnumGenerator::Generate(io::Printer* printer) {
printer->Print(
" return value;\n"
"}\n"
- "\n"
- "/**\n"
- " * @param value The numeric wire value of the corresponding enum "
- "entry.\n"
- " * @return The enum associated with the given numeric wire value.\n"
- " * @deprecated Use {@link #forNumber(int)} instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "public static $classname$ valueOf(int value) {\n"
- " return forNumber(value);\n"
- "}\n"
- "\n"
+ "\n");
+ if (context_->options().opensource_runtime) {
+ printer->Print(
+ "/**\n"
+ " * @param value The numeric wire value of the corresponding enum "
+ "entry.\n"
+ " * @return The enum associated with the given numeric wire value.\n"
+ " * @deprecated Use {@link #forNumber(int)} instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "public static $classname$ valueOf(int value) {\n"
+ " return forNumber(value);\n"
+ "}\n"
+ "\n",
+ "classname", descriptor_->name());
+ }
+ printer->Print(
"/**\n"
" * @param value The numeric wire value of the corresponding enum "
"entry.\n"
" * @return The enum associated with the given numeric wire value.\n"
- " */\n"
+ " */\n");
+ if (!context_->options().opensource_runtime) {
+ printer->Print("@com.google.protobuf.Internal.ProtoMethodMayReturnNull\n");
+ }
+ printer->Print(
"public static $classname$ forNumber(int value) {\n"
" switch (value) {\n",
"classname", descriptor_->name());
@@ -207,7 +220,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
for (int i = 0; i < canonical_values_.size(); i++) {
printer->Print("case $number$: return $name$;\n", "name",
canonical_values_[i]->name(), "number",
- StrCat(canonical_values_[i]->number()));
+ y_absl::StrCat(canonical_values_[i]->number()));
}
printer->Outdent();
@@ -277,7 +290,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
" return $file$.getDescriptor().getEnumTypes().get($index$);\n",
"file",
name_resolver_->GetClassName(descriptor_->file(), immutable_api_),
- "index", StrCat(descriptor_->index()));
+ "index", y_absl::StrCat(descriptor_->index()));
} else {
printer->Print(
" return $parent$.$descriptor$.getEnumTypes().get($index$);\n",
@@ -290,7 +303,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
.no_standard_descriptor_accessor()
? "getDefaultInstance().getDescriptorForType()"
: "getDescriptor()",
- "index", StrCat(descriptor_->index()));
+ "index", y_absl::StrCat(descriptor_->index()));
}
printer->Print(
@@ -394,4 +407,4 @@ bool EnumGenerator::CanUseEnumValues() {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/enum.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum.h
index 0a2c363b533..ae85b0c34c6 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/enum.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum.h
@@ -37,7 +37,8 @@
#include <string>
#include <vector>
-#include <google/protobuf/descriptor.h>
+
+#include "google/protobuf/descriptor.h"
namespace google {
namespace protobuf {
@@ -62,6 +63,8 @@ class EnumGenerator {
public:
EnumGenerator(const EnumDescriptor* descriptor, bool immutable_api,
Context* context);
+ EnumGenerator(const EnumGenerator&) = delete;
+ EnumGenerator& operator=(const EnumGenerator&) = delete;
~EnumGenerator();
void Generate(io::Printer* printer);
@@ -88,8 +91,6 @@ class EnumGenerator {
ClassNameResolver* name_resolver_;
bool CanUseEnumValues();
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator);
};
} // namespace java
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field.cc
index 97e1742cc90..33ed3ae00fa 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field.cc
@@ -32,24 +32,24 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/enum_field.h>
+#include "google/protobuf/compiler/java/enum_field.h"
#include <cstdint>
-#include <map>
#include <string>
-#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/context.h>
-#include <google/protobuf/compiler/java/doc_comment.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/name_resolver.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/java/context.h"
+#include "google/protobuf/compiler/java/doc_comment.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/name_resolver.h"
+#include "google/protobuf/io/printer.h"
+#include "google/protobuf/wire_format.h"
// Must be last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -58,62 +58,51 @@ namespace java {
namespace {
-void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex,
- int builderBitIndex, const FieldGeneratorInfo* info,
- ClassNameResolver* name_resolver,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+void SetEnumVariables(
+ const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
+ const FieldGeneratorInfo* info, ClassNameResolver* name_resolver,
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables,
+ Context* context) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["type"] =
name_resolver->GetImmutableClassName(descriptor->enum_type());
- (*variables)["kt_type"] = (*variables)["type"];
+ variables->insert({"kt_type", EscapeKotlinKeywords((*variables)["type"])});
(*variables)["mutable_type"] =
name_resolver->GetMutableClassName(descriptor->enum_type());
- (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
+ (*variables)["default"] =
+ ImmutableDefaultValue(descriptor, name_resolver, context->options());
(*variables)["default_number"] =
- StrCat(descriptor->default_value_enum()->number());
- (*variables)["tag"] = StrCat(
+ y_absl::StrCat(descriptor->default_value_enum()->number());
+ (*variables)["tag"] = y_absl::StrCat(
static_cast<arc_i32>(internal::WireFormat::MakeTag(descriptor)));
- (*variables)["tag_size"] = StrCat(
+ (*variables)["tag_size"] = y_absl::StrCat(
internal::WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
// TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
// by the proto compiler
(*variables)["deprecation"] =
descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
- (*variables)["kt_deprecation"] =
- descriptor->options().deprecated()
- ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
- " is deprecated\") "
- : "";
- (*variables)["on_changed"] = "onChanged();";
- // Use deprecated valueOf() method to be compatible with old generated code
- // for v2.5.0/v2.6.1.
- // TODO(xiaofeng): Use "forNumber" when we no longer support compatibility
- // with v2.5.0/v2.6.1, and remove the @SuppressWarnings annotations.
- (*variables)["for_number"] = "valueOf";
-
+ variables->insert(
+ {"kt_deprecation",
+ descriptor->options().deprecated()
+ ? y_absl::StrCat("@kotlin.Deprecated(message = \"Field ",
+ (*variables)["name"], " is deprecated\") ")
+ : ""});
if (HasHasbit(descriptor)) {
// For singular messages and builders, one bit is used for the hasField bit.
(*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
- (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex);
-
// Note that these have a trailing ";".
(*variables)["set_has_field_bit_message"] =
- GenerateSetBit(messageBitIndex) + ";";
- (*variables)["set_has_field_bit_builder"] =
- GenerateSetBit(builderBitIndex) + ";";
- (*variables)["clear_has_field_bit_builder"] =
- GenerateClearBit(builderBitIndex) + ";";
-
+ y_absl::StrCat(GenerateSetBit(messageBitIndex), ";");
+ (*variables)["set_has_field_bit_to_local"] =
+ GenerateSetBitToLocal(messageBitIndex);
(*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
} else {
(*variables)["set_has_field_bit_message"] = "";
- (*variables)["set_has_field_bit_builder"] = "";
- (*variables)["clear_has_field_bit_builder"] = "";
-
- (*variables)["is_field_present_message"] =
- (*variables)["name"] + "_ != " + (*variables)["default"] +
- ".getNumber()";
+ (*variables)["set_has_field_bit_to_local"] = "";
+ variables->insert({"is_field_present_message",
+ y_absl::StrCat((*variables)["name"], "_ != ",
+ (*variables)["default"], ".getNumber()")});
}
// For repeated builders, one bit is used for whether the array is immutable.
@@ -121,22 +110,21 @@ void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex,
(*variables)["set_mutable_bit_builder"] = GenerateSetBit(builderBitIndex);
(*variables)["clear_mutable_bit_builder"] = GenerateClearBit(builderBitIndex);
- // For repeated fields, one bit is used for whether the array is immutable
- // in the parsing constructor.
- (*variables)["get_mutable_bit_parser"] =
- GenerateGetBitMutableLocal(builderBitIndex);
- (*variables)["set_mutable_bit_parser"] =
- GenerateSetBitMutableLocal(builderBitIndex);
+ (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex);
+ // Note that these have a trailing ";".
+ (*variables)["set_has_field_bit_builder"] =
+ y_absl::StrCat(GenerateSetBit(builderBitIndex), ";");
+ (*variables)["clear_has_field_bit_builder"] =
+ y_absl::StrCat(GenerateClearBit(builderBitIndex), ";");
(*variables)["get_has_field_bit_from_local"] =
GenerateGetBitFromLocal(builderBitIndex);
- (*variables)["set_has_field_bit_to_local"] =
- GenerateSetBitToLocal(messageBitIndex);
if (SupportUnknownEnumValue(descriptor->file())) {
- (*variables)["unknown"] = (*variables)["type"] + ".UNRECOGNIZED";
+ variables->insert(
+ {"unknown", y_absl::StrCat((*variables)["type"], ".UNRECOGNIZED")});
} else {
- (*variables)["unknown"] = (*variables)["default"];
+ variables->insert({"unknown", (*variables)["default"]});
}
}
@@ -147,21 +135,30 @@ void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex,
ImmutableEnumFieldGenerator::ImmutableEnumFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
Context* context)
- : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
+ : descriptor_(descriptor),
+ message_bit_index_(messageBitIndex),
+ builder_bit_index_(builderBitIndex),
+ name_resolver_(context->GetNameResolver()) {
SetEnumVariables(descriptor, messageBitIndex, builderBitIndex,
context->GetFieldGeneratorInfo(descriptor), name_resolver_,
- &variables_);
+ &variables_, context);
}
ImmutableEnumFieldGenerator::~ImmutableEnumFieldGenerator() {}
+int ImmutableEnumFieldGenerator::GetMessageBitIndex() const {
+ return message_bit_index_;
+}
+
+int ImmutableEnumFieldGenerator::GetBuilderBitIndex() const {
+ return builder_bit_index_;
+}
+
int ImmutableEnumFieldGenerator::GetNumBitsForMessage() const {
return HasHasbit(descriptor_) ? 1 : 0;
}
-int ImmutableEnumFieldGenerator::GetNumBitsForBuilder() const {
- return GetNumBitsForMessage();
-}
+int ImmutableEnumFieldGenerator::GetNumBitsForBuilder() const { return 1; }
void ImmutableEnumFieldGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
@@ -180,7 +177,7 @@ void ImmutableEnumFieldGenerator::GenerateInterfaceMembers(
}
void ImmutableEnumFieldGenerator::GenerateMembers(io::Printer* printer) const {
- printer->Print(variables_, "private int $name$_;\n");
+ printer->Print(variables_, "private int $name$_ = $default_number$;\n");
PrintExtraFieldInfo(variables_, printer);
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
@@ -204,8 +201,7 @@ void ImmutableEnumFieldGenerator::GenerateMembers(io::Printer* printer) const {
printer->Print(variables_,
"@java.lang.Override $deprecation$public $type$ "
"${$get$capitalized_name$$}$() {\n"
- " @SuppressWarnings(\"deprecation\")\n"
- " $type$ result = $type$.$for_number$($name$_);\n"
+ " $type$ result = $type$.forNumber($name$_);\n"
" return result == null ? $unknown$ : result;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
@@ -236,9 +232,9 @@ void ImmutableEnumFieldGenerator::GenerateBuilderMembers(
printer->Print(variables_,
"$deprecation$public Builder "
"${$set$capitalized_name$Value$}$(int value) {\n"
- " $set_has_field_bit_builder$\n"
" $name$_ = value;\n"
- " $on_changed$\n"
+ " $set_has_field_bit_builder$\n"
+ " onChanged();\n"
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
@@ -247,8 +243,7 @@ void ImmutableEnumFieldGenerator::GenerateBuilderMembers(
printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " @SuppressWarnings(\"deprecation\")\n"
- " $type$ result = $type$.$for_number$($name$_);\n"
+ " $type$ result = $type$.forNumber($name$_);\n"
" return result == null ? $unknown$ : result;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
@@ -262,7 +257,7 @@ void ImmutableEnumFieldGenerator::GenerateBuilderMembers(
" }\n"
" $set_has_field_bit_builder$\n"
" $name$_ = value.getNumber();\n"
- " $on_changed$\n"
+ " onChanged();\n"
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
@@ -273,7 +268,7 @@ void ImmutableEnumFieldGenerator::GenerateBuilderMembers(
"$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
" $clear_has_field_bit_builder$\n"
" $name$_ = $default_number$;\n"
- " $on_changed$\n"
+ " onChanged();\n"
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
@@ -281,9 +276,9 @@ void ImmutableEnumFieldGenerator::GenerateBuilderMembers(
void ImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(variables_,
- "$kt_deprecation$ var $kt_name$: $kt_type$\n"
+ "$kt_deprecation$public var $kt_name$: $kt_type$\n"
" @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
" get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
" @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
@@ -291,18 +286,31 @@ void ImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
" $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
" }\n");
+ if (SupportUnknownEnumValue(descriptor_->file())) {
+ printer->Print(
+ variables_,
+ "$kt_deprecation$public var $kt_name$Value: kotlin.Int\n"
+ " @JvmName(\"${$get$kt_capitalized_name$Value$}$\")\n"
+ " get() = $kt_dsl_builder$.${$get$capitalized_name$Value$}$()\n"
+ " @JvmName(\"${$set$kt_capitalized_name$Value$}$\")\n"
+ " set(value) {\n"
+ " $kt_dsl_builder$.${$set$capitalized_name$Value$}$(value)\n"
+ " }\n");
+ }
+
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "public fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER,
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
" return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
"}\n");
}
@@ -320,9 +328,7 @@ void ImmutableEnumFieldGenerator::GenerateInitializationCode(
void ImmutableEnumFieldGenerator::GenerateBuilderClearCode(
io::Printer* printer) const {
- printer->Print(variables_,
- "$name$_ = $default_number$;\n"
- "$clear_has_field_bit_builder$\n");
+ printer->Print(variables_, "$name$_ = $default_number$;\n");
}
void ImmutableEnumFieldGenerator::GenerateMergingCode(
@@ -339,47 +345,41 @@ void ImmutableEnumFieldGenerator::GenerateMergingCode(
" set$capitalized_name$Value(other.get$capitalized_name$Value());\n"
"}\n");
} else {
- GOOGLE_LOG(FATAL) << "Can't reach here.";
+ Y_ABSL_LOG(FATAL) << "Can't reach here.";
}
}
void ImmutableEnumFieldGenerator::GenerateBuildingCode(
io::Printer* printer) const {
- if (HasHazzer(descriptor_)) {
- printer->Print(variables_,
- "if ($get_has_field_bit_from_local$) {\n"
- " $set_has_field_bit_to_local$;\n"
- "}\n");
+ printer->Print(variables_,
+ "if ($get_has_field_bit_from_local$) {\n"
+ " result.$name$_ = $name$_;\n");
+ if (GetNumBitsForMessage() > 0) {
+ printer->Print(variables_, " $set_has_field_bit_to_local$;\n");
}
- printer->Print(variables_, "result.$name$_ = $name$_;\n");
+ printer->Print("}\n");
}
-void ImmutableEnumFieldGenerator::GenerateParsingCode(
+void ImmutableEnumFieldGenerator::GenerateBuilderParsingCode(
io::Printer* printer) const {
if (SupportUnknownEnumValue(descriptor_->file())) {
printer->Print(variables_,
- "int rawValue = input.readEnum();\n"
- "$set_has_field_bit_message$\n"
- "$name$_ = rawValue;\n");
+ "$name$_ = input.readEnum();\n"
+ "$set_has_field_bit_builder$\n");
} else {
printer->Print(variables_,
- "int rawValue = input.readEnum();\n"
- " @SuppressWarnings(\"deprecation\")\n"
- "$type$ value = $type$.$for_number$(rawValue);\n"
- "if (value == null) {\n"
- " unknownFields.mergeVarintField($number$, rawValue);\n"
+ "int tmpRaw = input.readEnum();\n"
+ "$type$ tmpValue =\n"
+ " $type$.forNumber(tmpRaw);\n"
+ "if (tmpValue == null) {\n"
+ " mergeUnknownVarintField($number$, tmpRaw);\n"
"} else {\n"
- " $set_has_field_bit_message$\n"
- " $name$_ = rawValue;\n"
+ " $name$_ = tmpRaw;\n"
+ " $set_has_field_bit_builder$\n"
"}\n");
}
}
-void ImmutableEnumFieldGenerator::GenerateParsingDoneCode(
- io::Printer* printer) const {
- // noop for enums
-}
-
void ImmutableEnumFieldGenerator::GenerateSerializationCode(
io::Printer* printer) const {
printer->Print(variables_,
@@ -429,7 +429,7 @@ ImmutableEnumOneofFieldGenerator::~ImmutableEnumOneofFieldGenerator() {}
void ImmutableEnumOneofFieldGenerator::GenerateMembers(
io::Printer* printer) const {
PrintExtraFieldInfo(variables_, printer);
- GOOGLE_DCHECK(HasHazzer(descriptor_));
+ Y_ABSL_DCHECK(HasHazzer(descriptor_));
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
@@ -453,8 +453,7 @@ void ImmutableEnumOneofFieldGenerator::GenerateMembers(
printer->Print(variables_,
"$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
" if ($has_oneof_case_message$) {\n"
- " @SuppressWarnings(\"deprecation\")\n"
- " $type$ result = $type$.$for_number$(\n"
+ " $type$ result = $type$.forNumber(\n"
" (java.lang.Integer) $oneof_name$_);\n"
" return result == null ? $unknown$ : result;\n"
" }\n"
@@ -465,7 +464,7 @@ void ImmutableEnumOneofFieldGenerator::GenerateMembers(
void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
- GOOGLE_DCHECK(HasHazzer(descriptor_));
+ Y_ABSL_DCHECK(HasHazzer(descriptor_));
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
"@java.lang.Override\n"
@@ -493,7 +492,7 @@ void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers(
"${$set$capitalized_name$Value$}$(int value) {\n"
" $set_oneof_case_message$;\n"
" $oneof_name$_ = value;\n"
- " $on_changed$\n"
+ " onChanged();\n"
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
@@ -503,14 +502,14 @@ void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers(
"@java.lang.Override\n"
"$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
" if ($has_oneof_case_message$) {\n"
- " @SuppressWarnings(\"deprecation\")\n"
- " $type$ result = $type$.$for_number$(\n"
+ " $type$ result = $type$.forNumber(\n"
" (java.lang.Integer) $oneof_name$_);\n"
" return result == null ? $unknown$ : result;\n"
" }\n"
" return $default$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
+
WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
/* builder */ true);
printer->Print(variables_,
@@ -521,10 +520,11 @@ void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers(
" }\n"
" $set_oneof_case_message$;\n"
" $oneof_name$_ = value.getNumber();\n"
- " $on_changed$\n"
+ " onChanged();\n"
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
+
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
/* builder */ true);
printer->Print(
@@ -533,19 +533,21 @@ void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers(
" if ($has_oneof_case_message$) {\n"
" $clear_oneof_case_message$;\n"
" $oneof_name$_ = null;\n"
- " $on_changed$\n"
+ " onChanged();\n"
" }\n"
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
}
+void ImmutableEnumOneofFieldGenerator::GenerateBuilderClearCode(
+ io::Printer* printer) const {
+ // No-op: Enum fields in oneofs are correctly cleared by clearing the oneof
+}
+
void ImmutableEnumOneofFieldGenerator::GenerateBuildingCode(
io::Printer* printer) const {
- printer->Print(variables_,
- "if ($has_oneof_case_message$) {\n"
- " result.$oneof_name$_ = $oneof_name$_;\n"
- "}\n");
+ // No-Op: Handled by single statement for the oneof
}
void ImmutableEnumOneofFieldGenerator::GenerateMergingCode(
@@ -560,7 +562,7 @@ void ImmutableEnumOneofFieldGenerator::GenerateMergingCode(
}
}
-void ImmutableEnumOneofFieldGenerator::GenerateParsingCode(
+void ImmutableEnumOneofFieldGenerator::GenerateBuilderParsingCode(
io::Printer* printer) const {
if (SupportUnknownEnumValue(descriptor_->file())) {
printer->Print(variables_,
@@ -570,10 +572,10 @@ void ImmutableEnumOneofFieldGenerator::GenerateParsingCode(
} else {
printer->Print(variables_,
"int rawValue = input.readEnum();\n"
- "@SuppressWarnings(\"deprecation\")\n"
- "$type$ value = $type$.$for_number$(rawValue);\n"
+ "$type$ value =\n"
+ " $type$.forNumber(rawValue);\n"
"if (value == null) {\n"
- " unknownFields.mergeVarintField($number$, rawValue);\n"
+ " mergeUnknownVarintField($number$, rawValue);\n"
"} else {\n"
" $set_oneof_case_message$;\n"
" $oneof_name$_ = rawValue;\n"
@@ -634,11 +636,8 @@ void ImmutableEnumOneofFieldGenerator::GenerateHashCode(
RepeatedImmutableEnumFieldGenerator::RepeatedImmutableEnumFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
Context* context)
- : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
- SetEnumVariables(descriptor, messageBitIndex, builderBitIndex,
- context->GetFieldGeneratorInfo(descriptor), name_resolver_,
- &variables_);
-}
+ : ImmutableEnumFieldGenerator(descriptor, messageBitIndex, builderBitIndex,
+ context) {}
RepeatedImmutableEnumFieldGenerator::~RepeatedImmutableEnumFieldGenerator() {}
@@ -678,6 +677,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateMembers(
io::Printer* printer) const {
printer->Print(
variables_,
+ "@SuppressWarnings(\"serial\")\n"
"private java.util.List<java.lang.Integer> $name$_;\n"
"private static final "
"com.google.protobuf.Internal.ListAdapter.Converter<\n"
@@ -685,8 +685,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateMembers(
" new com.google.protobuf.Internal.ListAdapter.Converter<\n"
" java.lang.Integer, $type$>() {\n"
" public $type$ convert(java.lang.Integer from) {\n"
- " @SuppressWarnings(\"deprecation\")\n"
- " $type$ result = $type$.$for_number$(from);\n"
+ " $type$ result = $type$.forNumber(from);\n"
" return result == null ? $unknown$ : result;\n"
" }\n"
" };\n");
@@ -802,7 +801,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers(
" }\n"
" ensure$capitalized_name$IsMutable();\n"
" $name$_.set(index, value.getNumber());\n"
- " $on_changed$\n"
+ " onChanged();\n"
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
@@ -816,7 +815,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers(
" }\n"
" ensure$capitalized_name$IsMutable();\n"
" $name$_.add(value.getNumber());\n"
- " $on_changed$\n"
+ " onChanged();\n"
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
@@ -829,7 +828,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers(
" for ($type$ value : values) {\n"
" $name$_.add(value.getNumber());\n"
" }\n"
- " $on_changed$\n"
+ " onChanged();\n"
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
@@ -840,7 +839,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers(
"$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
" $name$_ = java.util.Collections.emptyList();\n"
" $clear_mutable_bit_builder$;\n"
- " $on_changed$\n"
+ " onChanged();\n"
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
@@ -870,7 +869,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers(
" int index, int value) {\n"
" ensure$capitalized_name$IsMutable();\n"
" $name$_.set(index, value);\n"
- " $on_changed$\n"
+ " onChanged();\n"
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
@@ -881,7 +880,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers(
"${$add$capitalized_name$Value$}$(int value) {\n"
" ensure$capitalized_name$IsMutable();\n"
" $name$_.add(value);\n"
- " $on_changed$\n"
+ " onChanged();\n"
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
@@ -895,7 +894,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers(
" for (int value : values) {\n"
" $name$_.add(value);\n"
" }\n"
- " $on_changed$\n"
+ " onChanged();\n"
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
@@ -935,7 +934,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateMergingCode(
" ensure$capitalized_name$IsMutable();\n"
" $name$_.addAll(other.$name$_);\n"
" }\n"
- " $on_changed$\n"
+ " onChanged();\n"
"}\n");
}
@@ -952,36 +951,29 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuildingCode(
"result.$name$_ = $name$_;\n");
}
-void RepeatedImmutableEnumFieldGenerator::GenerateParsingCode(
+void RepeatedImmutableEnumFieldGenerator::GenerateBuilderParsingCode(
io::Printer* printer) const {
// Read and store the enum
if (SupportUnknownEnumValue(descriptor_->file())) {
printer->Print(variables_,
- "int rawValue = input.readEnum();\n"
- "if (!$get_mutable_bit_parser$) {\n"
- " $name$_ = new java.util.ArrayList<java.lang.Integer>();\n"
- " $set_mutable_bit_parser$;\n"
- "}\n"
- "$name$_.add(rawValue);\n");
+ "int tmpRaw = input.readEnum();\n"
+ "ensure$capitalized_name$IsMutable();\n"
+ "$name$_.add(tmpRaw);\n");
} else {
- printer->Print(
- variables_,
- "int rawValue = input.readEnum();\n"
- "@SuppressWarnings(\"deprecation\")\n"
- "$type$ value = $type$.$for_number$(rawValue);\n"
- "if (value == null) {\n"
- " unknownFields.mergeVarintField($number$, rawValue);\n"
- "} else {\n"
- " if (!$get_mutable_bit_parser$) {\n"
- " $name$_ = new java.util.ArrayList<java.lang.Integer>();\n"
- " $set_mutable_bit_parser$;\n"
- " }\n"
- " $name$_.add(rawValue);\n"
- "}\n");
+ printer->Print(variables_,
+ "int tmpRaw = input.readEnum();\n"
+ "$type$ tmpValue =\n"
+ " $type$.forNumber(tmpRaw);\n"
+ "if (tmpValue == null) {\n"
+ " mergeUnknownVarintField($number$, tmpRaw);\n"
+ "} else {\n"
+ " ensure$capitalized_name$IsMutable();\n"
+ " $name$_.add(tmpRaw);\n"
+ "}\n");
}
}
-void RepeatedImmutableEnumFieldGenerator::GenerateParsingCodeFromPacked(
+void RepeatedImmutableEnumFieldGenerator::GenerateBuilderParsingCodeFromPacked(
io::Printer* printer) const {
// Wrap GenerateParsingCode's contents with a while loop.
@@ -991,23 +983,13 @@ void RepeatedImmutableEnumFieldGenerator::GenerateParsingCodeFromPacked(
"while(input.getBytesUntilLimit() > 0) {\n");
printer->Indent();
- GenerateParsingCode(printer);
+ GenerateBuilderParsingCode(printer);
printer->Outdent();
printer->Print(variables_,
"}\n"
"input.popLimit(oldLimit);\n");
}
-
-void RepeatedImmutableEnumFieldGenerator::GenerateParsingDoneCode(
- io::Printer* printer) const {
- printer->Print(
- variables_,
- "if ($get_mutable_bit_parser$) {\n"
- " $name$_ = java.util.Collections.unmodifiableList($name$_);\n"
- "}\n");
-}
-
void RepeatedImmutableEnumFieldGenerator::GenerateSerializationCode(
io::Printer* printer) const {
if (descriptor_->is_packed()) {
@@ -1085,12 +1067,12 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(variables_,
- "$kt_deprecation$ val $kt_name$: "
+ "$kt_deprecation$public val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -1099,70 +1081,70 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
" )\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"add(value: $kt_type$) {\n"
" $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
"}");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: $kt_type$) {\n"
" add(value)\n"
"}");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
"}");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" addAll(values)\n"
"}");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
+ "public operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"set(index: kotlin.Int, value: $kt_type$) {\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
"}");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
@@ -1178,4 +1160,4 @@ TProtoStringType RepeatedImmutableEnumFieldGenerator::GetBoxedType() const {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field.h
index 6cf28fb1261..60285493a37 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field.h
@@ -35,10 +35,10 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_H__
-#include <map>
#include <string>
-#include <google/protobuf/compiler/java/field.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "google/protobuf/compiler/java/field.h"
namespace google {
namespace protobuf {
@@ -61,10 +61,15 @@ class ImmutableEnumFieldGenerator : public ImmutableFieldGenerator {
explicit ImmutableEnumFieldGenerator(const FieldDescriptor* descriptor,
int messageBitIndex, int builderBitIndex,
Context* context);
+ ImmutableEnumFieldGenerator(const ImmutableEnumFieldGenerator&) = delete;
+ ImmutableEnumFieldGenerator& operator=(const ImmutableEnumFieldGenerator&) =
+ delete;
~ImmutableEnumFieldGenerator() override;
// implements ImmutableFieldGenerator
// ---------------------------------------
+ int GetMessageBitIndex() const override;
+ int GetBuilderBitIndex() const override;
int GetNumBitsForMessage() const override;
int GetNumBitsForBuilder() const override;
void GenerateInterfaceMembers(io::Printer* printer) const override;
@@ -72,10 +77,9 @@ class ImmutableEnumFieldGenerator : public ImmutableFieldGenerator {
void GenerateBuilderMembers(io::Printer* printer) const override;
void GenerateInitializationCode(io::Printer* printer) const override;
void GenerateBuilderClearCode(io::Printer* printer) const override;
+ void GenerateBuilderParsingCode(io::Printer* printer) const override;
void GenerateMergingCode(io::Printer* printer) const override;
void GenerateBuildingCode(io::Printer* printer) const override;
- void GenerateParsingCode(io::Printer* printer) const override;
- void GenerateParsingDoneCode(io::Printer* printer) const override;
void GenerateSerializationCode(io::Printer* printer) const override;
void GenerateSerializedSizeCode(io::Printer* printer) const override;
void GenerateFieldBuilderInitializationCode(
@@ -88,11 +92,10 @@ class ImmutableEnumFieldGenerator : public ImmutableFieldGenerator {
protected:
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ int message_bit_index_;
+ int builder_bit_index_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables_;
ClassNameResolver* name_resolver_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableEnumFieldGenerator);
};
class ImmutableEnumOneofFieldGenerator : public ImmutableEnumFieldGenerator {
@@ -100,27 +103,33 @@ class ImmutableEnumOneofFieldGenerator : public ImmutableEnumFieldGenerator {
ImmutableEnumOneofFieldGenerator(const FieldDescriptor* descriptor,
int messageBitIndex, int builderBitIndex,
Context* context);
+ ImmutableEnumOneofFieldGenerator(const ImmutableEnumOneofFieldGenerator&) =
+ delete;
+ ImmutableEnumOneofFieldGenerator& operator=(
+ const ImmutableEnumOneofFieldGenerator&) = delete;
~ImmutableEnumOneofFieldGenerator() override;
void GenerateMembers(io::Printer* printer) const override;
void GenerateBuilderMembers(io::Printer* printer) const override;
+ void GenerateBuilderClearCode(io::Printer* printer) const override;
void GenerateMergingCode(io::Printer* printer) const override;
void GenerateBuildingCode(io::Printer* printer) const override;
- void GenerateParsingCode(io::Printer* printer) const override;
+ void GenerateBuilderParsingCode(io::Printer* printer) const override;
void GenerateSerializationCode(io::Printer* printer) const override;
void GenerateSerializedSizeCode(io::Printer* printer) const override;
void GenerateEqualsCode(io::Printer* printer) const override;
void GenerateHashCode(io::Printer* printer) const override;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableEnumOneofFieldGenerator);
};
-class RepeatedImmutableEnumFieldGenerator : public ImmutableFieldGenerator {
+class RepeatedImmutableEnumFieldGenerator : public ImmutableEnumFieldGenerator {
public:
explicit RepeatedImmutableEnumFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex,
int builderBitIndex, Context* context);
+ RepeatedImmutableEnumFieldGenerator(
+ const RepeatedImmutableEnumFieldGenerator&) = delete;
+ RepeatedImmutableEnumFieldGenerator& operator=(
+ const RepeatedImmutableEnumFieldGenerator&) = delete;
~RepeatedImmutableEnumFieldGenerator() override;
// implements ImmutableFieldGenerator ---------------------------------------
@@ -133,9 +142,9 @@ class RepeatedImmutableEnumFieldGenerator : public ImmutableFieldGenerator {
void GenerateBuilderClearCode(io::Printer* printer) const override;
void GenerateMergingCode(io::Printer* printer) const override;
void GenerateBuildingCode(io::Printer* printer) const override;
- void GenerateParsingCode(io::Printer* printer) const override;
- void GenerateParsingCodeFromPacked(io::Printer* printer) const override;
- void GenerateParsingDoneCode(io::Printer* printer) const override;
+ void GenerateBuilderParsingCode(io::Printer* printer) const override;
+ void GenerateBuilderParsingCodeFromPacked(
+ io::Printer* printer) const override;
void GenerateSerializationCode(io::Printer* printer) const override;
void GenerateSerializedSizeCode(io::Printer* printer) const override;
void GenerateFieldBuilderInitializationCode(
@@ -145,13 +154,6 @@ class RepeatedImmutableEnumFieldGenerator : public ImmutableFieldGenerator {
void GenerateKotlinDslMembers(io::Printer* printer) const override;
TProtoStringType GetBoxedType() const override;
-
- private:
- const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
- ClassNameResolver* name_resolver_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableEnumFieldGenerator);
};
} // namespace java
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field_lite.cc
index c90939ada6c..0aa273c9908 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field_lite.cc
@@ -32,24 +32,24 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/enum_field_lite.h>
+#include "google/protobuf/compiler/java/enum_field_lite.h"
#include <cstdint>
-#include <map>
#include <string>
-#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/context.h>
-#include <google/protobuf/compiler/java/doc_comment.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/name_resolver.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_join.h"
+#include "google/protobuf/compiler/java/context.h"
+#include "google/protobuf/compiler/java/doc_comment.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/name_resolver.h"
+#include "google/protobuf/io/printer.h"
+#include "google/protobuf/wire_format.h"
// Must be last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -65,53 +65,62 @@ bool EnableExperimentalRuntimeForLite() {
#endif // !PROTOBUF_EXPERIMENT
}
-void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex,
- int builderBitIndex, const FieldGeneratorInfo* info,
- ClassNameResolver* name_resolver,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+void SetEnumVariables(
+ const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
+ const FieldGeneratorInfo* info, ClassNameResolver* name_resolver,
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables,
+ Context* context) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["type"] =
name_resolver->GetImmutableClassName(descriptor->enum_type());
- (*variables)["kt_type"] = (*variables)["type"];
+ variables->insert({"kt_type", EscapeKotlinKeywords((*variables)["type"])});
(*variables)["mutable_type"] =
name_resolver->GetMutableClassName(descriptor->enum_type());
- (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
+ (*variables)["default"] =
+ ImmutableDefaultValue(descriptor, name_resolver, context->options());
(*variables)["default_number"] =
- StrCat(descriptor->default_value_enum()->number());
- (*variables)["tag"] = StrCat(
+ y_absl::StrCat(descriptor->default_value_enum()->number());
+ (*variables)["tag"] = y_absl::StrCat(
static_cast<arc_i32>(internal::WireFormat::MakeTag(descriptor)));
- (*variables)["tag_size"] = StrCat(
+ (*variables)["tag_size"] = y_absl::StrCat(
internal::WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
// TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
// by the proto compiler
(*variables)["deprecation"] =
descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
- (*variables)["kt_deprecation"] =
- descriptor->options().deprecated()
- ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
- " is deprecated\") "
- : "";
+ variables->insert(
+ {"kt_deprecation",
+ descriptor->options().deprecated()
+ ? y_absl::StrCat("@kotlin.Deprecated(message = \"Field ",
+ (*variables)["name"], " is deprecated\") ")
+ : ""});
(*variables)["required"] = descriptor->is_required() ? "true" : "false";
if (HasHasbit(descriptor)) {
+ if (!context->options().opensource_runtime) {
+ (*variables)["bit_field_id"] = y_absl::StrCat(messageBitIndex / 32);
+ (*variables)["bit_field_name"] = GetBitFieldNameForBit(messageBitIndex);
+ (*variables)["bit_field_mask"] =
+ y_absl::StrCat(1 << (messageBitIndex % 32));
+ }
// For singular messages and builders, one bit is used for the hasField bit.
(*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
// Note that these have a trailing ";".
(*variables)["set_has_field_bit_message"] =
- GenerateSetBit(messageBitIndex) + ";";
+ y_absl::StrCat(GenerateSetBit(messageBitIndex), ";");
(*variables)["clear_has_field_bit_message"] =
- GenerateClearBit(messageBitIndex) + ";";
+ y_absl::StrCat(GenerateClearBit(messageBitIndex), ";");
(*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
} else {
(*variables)["set_has_field_bit_message"] = "";
(*variables)["clear_has_field_bit_message"] = "";
- (*variables)["is_field_present_message"] =
- (*variables)["name"] + "_ != " + (*variables)["default"] +
- ".getNumber()";
+ variables->insert({"is_field_present_message",
+ y_absl::StrCat((*variables)["name"], "_ != ",
+ (*variables)["default"], ".getNumber()")});
}
(*variables)["get_has_field_bit_from_local"] =
@@ -120,14 +129,18 @@ void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex,
GenerateSetBitToLocal(messageBitIndex);
if (SupportUnknownEnumValue(descriptor->file())) {
- (*variables)["unknown"] = (*variables)["type"] + ".UNRECOGNIZED";
+ variables->insert(
+ {"unknown", y_absl::StrCat((*variables)["type"], ".UNRECOGNIZED")});
} else {
- (*variables)["unknown"] = (*variables)["default"];
+ variables->insert({"unknown", (*variables)["default"]});
}
// We use `x.getClass()` as a null check because it generates less bytecode
// than an `if (x == null) { throw ... }` statement.
(*variables)["null_check"] = "value.getClass();\n";
+ // Calls to Annotate() use variable ranges to know which text to annotate.
+ (*variables)["{"] = "";
+ (*variables)["}"] = "";
}
} // namespace
@@ -142,7 +155,7 @@ ImmutableEnumFieldLiteGenerator::ImmutableEnumFieldLiteGenerator(
name_resolver_(context->GetNameResolver()) {
SetEnumVariables(descriptor, messageBitIndex, 0,
context->GetFieldGeneratorInfo(descriptor), name_resolver_,
- &variables_);
+ &variables_, context);
}
ImmutableEnumFieldLiteGenerator::~ImmutableEnumFieldLiteGenerator() {}
@@ -156,19 +169,37 @@ void ImmutableEnumFieldLiteGenerator::GenerateInterfaceMembers(
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
- "$deprecation$boolean has$capitalized_name$();\n");
+ "$deprecation$boolean ${$has$capitalized_name$$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
}
if (SupportUnknownEnumValue(descriptor_->file())) {
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "$deprecation$int get$capitalized_name$Value();\n");
+ "$deprecation$int ${$get$capitalized_name$Value$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
}
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_, "$deprecation$$type$ get$capitalized_name$();\n");
+ printer->Print(variables_,
+ "$deprecation$$type$ ${$get$capitalized_name$$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
}
void ImmutableEnumFieldLiteGenerator::GenerateMembers(
io::Printer* printer) const {
+ if (!context_->options().opensource_runtime) {
+ printer->Print(
+ variables_,
+ "@com.google.protobuf.ProtoField(\n"
+ " fieldNumber=$number$,\n"
+ " type=com.google.protobuf.FieldType.$annotation_field_type$,\n"
+ " isRequired=$required$)\n");
+ if (HasHazzer(descriptor_)) {
+ printer->Print(variables_,
+ "@com.google.protobuf.ProtoPresenceCheckedField(\n"
+ " presenceBitsId=$bit_field_id$,\n"
+ " mask=$bit_field_mask$)\n");
+ }
+ }
printer->Print(variables_, "private int $name$_;\n");
PrintExtraFieldInfo(variables_, printer);
if (HasHazzer(descriptor_)) {
@@ -286,9 +317,9 @@ void ImmutableEnumFieldLiteGenerator::GenerateBuilderMembers(
void ImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(variables_,
- "$kt_deprecation$var $kt_name$: $kt_type$\n"
+ "$kt_deprecation$public var $kt_name$: $kt_type$\n"
" @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
" get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
" @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
@@ -296,18 +327,31 @@ void ImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
" $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
" }\n");
+ if (SupportUnknownEnumValue(descriptor_->file())) {
+ printer->Print(
+ variables_,
+ "$kt_deprecation$public var $kt_name$Value: kotlin.Int\n"
+ " @JvmName(\"${$get$kt_capitalized_name$Value$}$\")\n"
+ " get() = $kt_dsl_builder$.${$get$capitalized_name$Value$}$()\n"
+ " @JvmName(\"${$set$kt_capitalized_name$Value$}$\")\n"
+ " set(value) {\n"
+ " $kt_dsl_builder$.${$set$capitalized_name$Value$}$(value)\n"
+ " }\n");
+ }
+
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "public fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER,
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
" return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
"}\n");
}
@@ -356,7 +400,7 @@ ImmutableEnumOneofFieldLiteGenerator::~ImmutableEnumOneofFieldLiteGenerator() {}
void ImmutableEnumOneofFieldLiteGenerator::GenerateMembers(
io::Printer* printer) const {
PrintExtraFieldInfo(variables_, printer);
- GOOGLE_DCHECK(HasHazzer(descriptor_));
+ Y_ABSL_DCHECK(HasHazzer(descriptor_));
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
"@java.lang.Override\n"
@@ -432,7 +476,7 @@ void ImmutableEnumOneofFieldLiteGenerator::GenerateFieldInfo(
void ImmutableEnumOneofFieldLiteGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
- GOOGLE_DCHECK(HasHazzer(descriptor_));
+ Y_ABSL_DCHECK(HasHazzer(descriptor_));
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
"@java.lang.Override\n"
@@ -501,7 +545,7 @@ RepeatedImmutableEnumFieldLiteGenerator::
name_resolver_(context->GetNameResolver()) {
SetEnumVariables(descriptor, messageBitIndex, 0,
context->GetFieldGeneratorInfo(descriptor), name_resolver_,
- &variables_);
+ &variables_, context);
}
RepeatedImmutableEnumFieldLiteGenerator::
@@ -514,29 +558,43 @@ int RepeatedImmutableEnumFieldLiteGenerator::GetNumBitsForMessage() const {
void RepeatedImmutableEnumFieldLiteGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(
- variables_,
- "$deprecation$java.util.List<$type$> get$capitalized_name$List();\n");
+ printer->Print(variables_,
+ "$deprecation$java.util.List<$type$> "
+ "${$get$capitalized_name$List$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
printer->Print(variables_,
- "$deprecation$int get$capitalized_name$Count();\n");
+ "$deprecation$int ${$get$capitalized_name$Count$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
- printer->Print(variables_,
- "$deprecation$$type$ get$capitalized_name$(int index);\n");
+ printer->Print(
+ variables_,
+ "$deprecation$$type$ ${$get$capitalized_name$$}$(int index);\n");
+ printer->Annotate("{", "}", descriptor_);
if (SupportUnknownEnumValue(descriptor_->file())) {
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(variables_,
"$deprecation$java.util.List<java.lang.Integer>\n"
- "get$capitalized_name$ValueList();\n");
+ "${$get$capitalized_name$ValueList$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
LIST_INDEXED_GETTER);
- printer->Print(variables_,
- "$deprecation$int get$capitalized_name$Value(int index);\n");
+ printer->Print(
+ variables_,
+ "$deprecation$int ${$get$capitalized_name$Value$}$(int index);\n");
+ printer->Annotate("{", "}", descriptor_);
}
}
void RepeatedImmutableEnumFieldLiteGenerator::GenerateMembers(
io::Printer* printer) const {
+ if (!context_->options().opensource_runtime) {
+ printer->Print(
+ variables_,
+ "@com.google.protobuf.ProtoField(\n"
+ " fieldNumber=$number$,\n"
+ " type=com.google.protobuf.FieldType.$annotation_field_type$)\n");
+ }
printer->Print(
variables_,
"private com.google.protobuf.Internal.IntList $name$_;\n"
@@ -793,6 +851,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers(
printer->Print(variables_,
"$deprecation$public Builder "
"${$add$capitalized_name$Value$}$(int value) {\n"
+ " copyOnWrite();\n"
" instance.add$capitalized_name$Value(value);\n"
" return this;\n"
"}\n");
@@ -827,12 +886,12 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(variables_,
- "$kt_deprecation$ val $kt_name$: "
+ "$kt_deprecation$ public val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -841,70 +900,70 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
" )\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"add(value: $kt_type$) {\n"
" $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
"}");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: $kt_type$) {\n"
" add(value)\n"
"}");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
"}");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" addAll(values)\n"
"}");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
+ "public operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"set(index: kotlin.Int, value: $kt_type$) {\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
"}");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
@@ -920,4 +979,4 @@ TProtoStringType RepeatedImmutableEnumFieldLiteGenerator::GetBoxedType() const {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field_lite.h
index df2f6fa10a7..824affda1e6 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field_lite.h
@@ -36,10 +36,10 @@
#define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_LITE_H__
#include <cstdint>
-#include <map>
#include <string>
-#include <google/protobuf/compiler/java/field.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "google/protobuf/compiler/java/field.h"
namespace google {
namespace protobuf {
@@ -62,6 +62,10 @@ class ImmutableEnumFieldLiteGenerator : public ImmutableFieldLiteGenerator {
explicit ImmutableEnumFieldLiteGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
Context* context);
+ ImmutableEnumFieldLiteGenerator(const ImmutableEnumFieldLiteGenerator&) =
+ delete;
+ ImmutableEnumFieldLiteGenerator& operator=(
+ const ImmutableEnumFieldLiteGenerator&) = delete;
~ImmutableEnumFieldLiteGenerator() override;
// implements ImmutableFieldLiteGenerator
@@ -79,13 +83,10 @@ class ImmutableEnumFieldLiteGenerator : public ImmutableFieldLiteGenerator {
protected:
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables_;
const int messageBitIndex_;
Context* context_;
ClassNameResolver* name_resolver_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableEnumFieldLiteGenerator);
};
class ImmutableEnumOneofFieldLiteGenerator
@@ -93,15 +94,16 @@ class ImmutableEnumOneofFieldLiteGenerator
public:
ImmutableEnumOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
int messageBitIndex, Context* context);
+ ImmutableEnumOneofFieldLiteGenerator(
+ const ImmutableEnumOneofFieldLiteGenerator&) = delete;
+ ImmutableEnumOneofFieldLiteGenerator& operator=(
+ const ImmutableEnumOneofFieldLiteGenerator&) = delete;
~ImmutableEnumOneofFieldLiteGenerator() override;
void GenerateMembers(io::Printer* printer) const override;
void GenerateBuilderMembers(io::Printer* printer) const override;
void GenerateFieldInfo(io::Printer* printer,
std::vector<uint16_t>* output) const override;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableEnumOneofFieldLiteGenerator);
};
class RepeatedImmutableEnumFieldLiteGenerator
@@ -109,6 +111,10 @@ class RepeatedImmutableEnumFieldLiteGenerator
public:
explicit RepeatedImmutableEnumFieldLiteGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
+ RepeatedImmutableEnumFieldLiteGenerator(
+ const RepeatedImmutableEnumFieldLiteGenerator&) = delete;
+ RepeatedImmutableEnumFieldLiteGenerator& operator=(
+ const RepeatedImmutableEnumFieldLiteGenerator&) = delete;
~RepeatedImmutableEnumFieldLiteGenerator() override;
// implements ImmutableFieldLiteGenerator ------------------------------------
@@ -125,11 +131,9 @@ class RepeatedImmutableEnumFieldLiteGenerator
private:
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables_;
Context* context_;
ClassNameResolver* name_resolver_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableEnumFieldLiteGenerator);
};
} // namespace java
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_lite.cc
index 7fdd4ab9b8b..ae07f8c66fd 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_lite.cc
@@ -32,19 +32,18 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/enum_lite.h>
+#include "google/protobuf/compiler/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/context.h>
-#include <google/protobuf/compiler/java/doc_comment.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/name_resolver.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/stubs/map_util.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/java/context.h"
+#include "google/protobuf/compiler/java/doc_comment.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/name_resolver.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
@@ -87,9 +86,9 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
printer->Indent();
for (int i = 0; i < canonical_values_.size(); i++) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
vars["name"] = canonical_values_[i]->name();
- vars["number"] = StrCat(canonical_values_[i]->number());
+ vars["number"] = y_absl::StrCat(canonical_values_[i]->number());
WriteEnumValueDocComment(printer, canonical_values_[i]);
if (canonical_values_[i]->options().deprecated()) {
printer->Print("@java.lang.Deprecated\n");
@@ -110,7 +109,7 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
// -----------------------------------------------------------------
for (int i = 0; i < aliases_.size(); i++) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
vars["classname"] = descriptor_->name();
vars["name"] = aliases_[i].value->name();
vars["canonical_name"] = aliases_[i].canonical_value->name();
@@ -121,9 +120,9 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
}
for (int i = 0; i < descriptor_->value_count(); i++) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
vars["name"] = descriptor_->value(i)->name();
- vars["number"] = StrCat(descriptor_->value(i)->number());
+ vars["number"] = y_absl::StrCat(descriptor_->value(i)->number());
vars["{"] = "";
vars["}"] = "";
vars["deprecation"] = descriptor_->value(i)->options().deprecated()
@@ -153,17 +152,26 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
printer->Print(
" return value;\n"
"}\n"
- "\n"
- "/**\n"
- " * @param value The number of the enum to look for.\n"
- " * @return The enum associated with the given number.\n"
- " * @deprecated Use {@link #forNumber(int)} instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "public static $classname$ valueOf(int value) {\n"
- " return forNumber(value);\n"
- "}\n"
- "\n"
+ "\n");
+ if (context_->options().opensource_runtime) {
+ printer->Print(
+ "/**\n"
+ " * @param value The number of the enum to look for.\n"
+ " * @return The enum associated with the given number.\n"
+ " * @deprecated Use {@link #forNumber(int)} instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "public static $classname$ valueOf(int value) {\n"
+ " return forNumber(value);\n"
+ "}\n"
+ "\n",
+ "classname", descriptor_->name());
+ }
+
+ if (!context_->options().opensource_runtime) {
+ printer->Print("@com.google.protobuf.Internal.ProtoMethodMayReturnNull\n");
+ }
+ printer->Print(
"public static $classname$ forNumber(int value) {\n"
" switch (value) {\n",
"classname", descriptor_->name());
@@ -173,7 +181,7 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
for (int i = 0; i < canonical_values_.size(); i++) {
printer->Print("case $number$: return $name$;\n", "name",
canonical_values_[i]->name(), "number",
- StrCat(canonical_values_[i]->number()));
+ y_absl::StrCat(canonical_values_[i]->number()));
}
printer->Outdent();
@@ -212,6 +220,35 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
" };\n"
"\n",
"classname", descriptor_->name());
+ if (!context_->options().opensource_runtime) {
+ printer->Print(
+ "/**\n"
+ " * Override of toString that prints the number and name.\n"
+ " * This is primarily intended as a developer aid.\n"
+ " *\n"
+ " * <p>NOTE: This implementation is liable to change in the future,\n"
+ " * and should not be relied on in code.\n"
+ " */\n"
+ "@java.lang.Override\n"
+ "public java.lang.String toString() {\n"
+ " StringBuilder result = new StringBuilder(\"<\");\n"
+ " result.append(getClass().getName()).append('@')\n"
+ " .append(java.lang.Integer.toHexString(\n"
+ " java.lang.System.identityHashCode(this)));\n");
+ if (SupportUnknownEnumValue(descriptor_->file())) {
+ printer->Print(
+ " if (this != UNRECOGNIZED) {\n"
+ " result.append(\" number=\").append(getNumber());\n"
+ " }\n");
+ } else {
+ printer->Print(" result.append(\" number=\").append(getNumber());\n");
+ }
+ printer->Print(
+ " return result.append(\" name=\")\n"
+ " .append(name()).append('>').toString();\n"
+ "}\n"
+ "\n");
+ }
printer->Print(
"private final int value;\n\n"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_lite.h
index 50f3fe7b1aa..309d539b2ea 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_lite.h
@@ -37,7 +37,8 @@
#include <string>
#include <vector>
-#include <google/protobuf/descriptor.h>
+
+#include "google/protobuf/descriptor.h"
namespace google {
namespace protobuf {
@@ -62,6 +63,8 @@ class EnumLiteGenerator {
public:
EnumLiteGenerator(const EnumDescriptor* descriptor, bool immutable_api,
Context* context);
+ EnumLiteGenerator(const EnumLiteGenerator&) = delete;
+ EnumLiteGenerator& operator=(const EnumLiteGenerator&) = delete;
~EnumLiteGenerator();
void Generate(io::Printer* printer);
@@ -86,8 +89,6 @@ class EnumLiteGenerator {
Context* context_;
ClassNameResolver* name_resolver_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumLiteGenerator);
};
} // namespace java
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/extension.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/extension.cc
index 0983366c4f8..dd9e6eab186 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/extension.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/extension.cc
@@ -32,17 +32,18 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/extension.h>
+#include "google/protobuf/compiler/java/extension.h"
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/java/context.h>
-#include <google/protobuf/compiler/java/doc_comment.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/name_resolver.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/java/context.h"
+#include "google/protobuf/compiler/java/doc_comment.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/name_resolver.h"
+#include "google/protobuf/io/printer.h"
// Must be last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -51,7 +52,9 @@ namespace java {
ImmutableExtensionGenerator::ImmutableExtensionGenerator(
const FieldDescriptor* descriptor, Context* context)
- : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
+ : descriptor_(descriptor),
+ name_resolver_(context->GetNameResolver()),
+ context_(context) {
if (descriptor_->extension_scope() != NULL) {
scope_ =
name_resolver_->GetImmutableClassName(descriptor_->extension_scope());
@@ -66,19 +69,21 @@ ImmutableExtensionGenerator::~ImmutableExtensionGenerator() {}
void ExtensionGenerator::InitTemplateVars(
const FieldDescriptor* descriptor, const TProtoStringType& scope, bool immutable,
ClassNameResolver* name_resolver,
- std::map<TProtoStringType, TProtoStringType>* vars_pointer) {
- std::map<TProtoStringType, TProtoStringType>& vars = *vars_pointer;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* vars_pointer,
+ Context* context) {
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>& vars = *vars_pointer;
vars["scope"] = scope;
vars["name"] = UnderscoresToCamelCaseCheckReserved(descriptor);
vars["containing_type"] =
name_resolver->GetClassName(descriptor->containing_type(), immutable);
- vars["number"] = StrCat(descriptor->number());
+ vars["number"] = y_absl::StrCat(descriptor->number());
vars["constant_name"] = FieldConstantName(descriptor);
- vars["index"] = StrCat(descriptor->index());
+ vars["index"] = y_absl::StrCat(descriptor->index());
vars["default"] = descriptor->is_repeated()
? ""
- : DefaultValue(descriptor, immutable, name_resolver);
- vars["type_constant"] = FieldTypeName(GetType(descriptor));
+ : DefaultValue(descriptor, immutable, name_resolver,
+ context->options());
+ vars["type_constant"] = TProtoStringType(FieldTypeName(GetType(descriptor)));
vars["packed"] = descriptor->is_packed() ? "true" : "false";
vars["enum_map"] = "null";
vars["prototype"] = "null";
@@ -89,12 +94,12 @@ void ExtensionGenerator::InitTemplateVars(
case JAVATYPE_MESSAGE:
singular_type =
name_resolver->GetClassName(descriptor->message_type(), immutable);
- vars["prototype"] = singular_type + ".getDefaultInstance()";
+ vars["prototype"] = y_absl::StrCat(singular_type, ".getDefaultInstance()");
break;
case JAVATYPE_ENUM:
singular_type =
name_resolver->GetClassName(descriptor->enum_type(), immutable);
- vars["enum_map"] = singular_type + ".internalGetValueMap()";
+ vars["enum_map"] = y_absl::StrCat(singular_type, ".internalGetValueMap()");
break;
case JAVATYPE_STRING:
singular_type = "java.lang.String";
@@ -103,20 +108,20 @@ void ExtensionGenerator::InitTemplateVars(
singular_type = immutable ? "com.google.protobuf.ByteString" : "byte[]";
break;
default:
- singular_type = BoxedPrimitiveTypeName(java_type);
+ singular_type = TProtoStringType(BoxedPrimitiveTypeName(java_type));
break;
}
vars["type"] = descriptor->is_repeated()
- ? "java.util.List<" + singular_type + ">"
+ ? y_absl::StrCat("java.util.List<", singular_type, ">")
: singular_type;
vars["singular_type"] = singular_type;
}
void ImmutableExtensionGenerator::Generate(io::Printer* printer) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
const bool kUseImmutableNames = true;
InitTemplateVars(descriptor_, scope_, kUseImmutableNames, name_resolver_,
- &vars);
+ &vars, context_);
printer->Print(vars, "public static final int $constant_name$ = $number$;\n");
WriteFieldDocComment(printer, descriptor_);
@@ -156,7 +161,7 @@ int ImmutableExtensionGenerator::GenerateNonNestedInitializationCode(
printer->Print(
"$name$.internalInit(descriptor.getExtensions().get($index$));\n",
"name", UnderscoresToCamelCaseCheckReserved(descriptor_), "index",
- StrCat(descriptor_->index()));
+ y_absl::StrCat(descriptor_->index()));
bytecode_estimate += 21;
}
return bytecode_estimate;
@@ -174,4 +179,4 @@ int ImmutableExtensionGenerator::GenerateRegistrationCode(
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/extension.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/extension.h
index f9bd326f9bd..752a2de8704 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/extension.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/extension.h
@@ -35,10 +35,10 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__
-#include <map>
#include <string>
-#include <google/protobuf/stubs/common.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "google/protobuf/port.h"
namespace google {
namespace protobuf {
@@ -66,6 +66,8 @@ namespace java {
class ExtensionGenerator {
public:
explicit ExtensionGenerator() {}
+ ExtensionGenerator(const ExtensionGenerator&) = delete;
+ ExtensionGenerator& operator=(const ExtensionGenerator&) = delete;
virtual ~ExtensionGenerator() {}
virtual void Generate(io::Printer* printer) = 0;
@@ -82,16 +84,17 @@ class ExtensionGenerator {
static void InitTemplateVars(
const FieldDescriptor* descriptor, const TProtoStringType& scope,
bool immutable, ClassNameResolver* name_resolver,
- std::map<TProtoStringType, TProtoStringType>* vars_pointer);
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator);
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* vars_pointer,
+ Context* context);
};
class ImmutableExtensionGenerator : public ExtensionGenerator {
public:
explicit ImmutableExtensionGenerator(const FieldDescriptor* descriptor,
Context* context);
+ ImmutableExtensionGenerator(const ImmutableExtensionGenerator&) = delete;
+ ImmutableExtensionGenerator& operator=(const ImmutableExtensionGenerator&) =
+ delete;
~ImmutableExtensionGenerator() override;
void Generate(io::Printer* printer) override;
@@ -102,9 +105,7 @@ class ImmutableExtensionGenerator : public ExtensionGenerator {
const FieldDescriptor* descriptor_;
ClassNameResolver* name_resolver_;
TProtoStringType scope_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableExtensionGenerator);
+ Context* context_;
};
} // namespace java
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/extension_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/extension_lite.cc
index d51d9d2ba8a..99345242a10 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/extension_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/extension_lite.cc
@@ -28,17 +28,19 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <google/protobuf/compiler/java/extension_lite.h>
+#include "google/protobuf/compiler/java/extension_lite.h"
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/java/context.h>
-#include <google/protobuf/compiler/java/doc_comment.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/name_resolver.h>
+#include <string>
+
+#include "y_absl/container/flat_hash_map.h"
+#include "google/protobuf/compiler/java/context.h"
+#include "google/protobuf/compiler/java/doc_comment.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/name_resolver.h"
+#include "google/protobuf/io/printer.h"
// Must be last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -47,7 +49,9 @@ namespace java {
ImmutableExtensionLiteGenerator::ImmutableExtensionLiteGenerator(
const FieldDescriptor* descriptor, Context* context)
- : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
+ : descriptor_(descriptor),
+ name_resolver_(context->GetNameResolver()),
+ context_(context) {
if (descriptor_->extension_scope() != NULL) {
scope_ =
name_resolver_->GetImmutableClassName(descriptor_->extension_scope());
@@ -59,10 +63,10 @@ ImmutableExtensionLiteGenerator::ImmutableExtensionLiteGenerator(
ImmutableExtensionLiteGenerator::~ImmutableExtensionLiteGenerator() {}
void ImmutableExtensionLiteGenerator::Generate(io::Printer* printer) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
const bool kUseImmutableNames = true;
InitTemplateVars(descriptor_, scope_, kUseImmutableNames, name_resolver_,
- &vars);
+ &vars, context_);
printer->Print(vars, "public static final int $constant_name$ = $number$;\n");
WriteFieldDocComment(printer, descriptor_);
@@ -117,4 +121,4 @@ int ImmutableExtensionLiteGenerator::GenerateRegistrationCode(
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/extension_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/extension_lite.h
index 0d013c862ce..0c74bc50955 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/extension_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/extension_lite.h
@@ -31,11 +31,10 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_LITE_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_LITE_H__
-#include <map>
#include <string>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/compiler/java/extension.h>
+#include "google/protobuf/compiler/java/extension.h"
+#include "google/protobuf/port.h"
namespace google {
namespace protobuf {
@@ -49,6 +48,10 @@ class ImmutableExtensionLiteGenerator : public ExtensionGenerator {
public:
explicit ImmutableExtensionLiteGenerator(const FieldDescriptor* descriptor,
Context* context);
+ ImmutableExtensionLiteGenerator(const ImmutableExtensionLiteGenerator&) =
+ delete;
+ ImmutableExtensionLiteGenerator& operator=(
+ const ImmutableExtensionLiteGenerator&) = delete;
~ImmutableExtensionLiteGenerator() override;
void Generate(io::Printer* printer) override;
@@ -63,8 +66,7 @@ class ImmutableExtensionLiteGenerator : public ExtensionGenerator {
const FieldDescriptor* descriptor_;
ClassNameResolver* name_resolver_;
TProtoStringType scope_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableExtensionLiteGenerator);
+ Context* context_;
};
} // namespace java
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/field.cc
index 84487ac7a11..4701dc63224 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/field.cc
@@ -32,27 +32,28 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/field.h>
+#include "google/protobuf/compiler/java/field.h"
#include <memory>
+#include <string>
-#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/context.h>
-#include <google/protobuf/compiler/java/enum_field.h>
-#include <google/protobuf/compiler/java/enum_field_lite.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/map_field.h>
-#include <google/protobuf/compiler/java/map_field_lite.h>
-#include <google/protobuf/compiler/java/message_field.h>
-#include <google/protobuf/compiler/java/message_field_lite.h>
-#include <google/protobuf/compiler/java/primitive_field.h>
-#include <google/protobuf/compiler/java/primitive_field_lite.h>
-#include <google/protobuf/compiler/java/string_field.h>
-#include <google/protobuf/compiler/java/string_field_lite.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/substitute.h"
+#include "google/protobuf/compiler/java/context.h"
+#include "google/protobuf/compiler/java/enum_field.h"
+#include "google/protobuf/compiler/java/enum_field_lite.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/map_field.h"
+#include "google/protobuf/compiler/java/map_field_lite.h"
+#include "google/protobuf/compiler/java/message_field.h"
+#include "google/protobuf/compiler/java/message_field_lite.h"
+#include "google/protobuf/compiler/java/primitive_field.h"
+#include "google/protobuf/compiler/java/primitive_field_lite.h"
+#include "google/protobuf/compiler/java/string_field.h"
+#include "google/protobuf/compiler/java/string_field_lite.h"
+#include "google/protobuf/io/printer.h"
namespace google {
@@ -185,15 +186,15 @@ static inline void ReportUnexpectedPackedFieldsCall(io::Printer* printer) {
// but this method should be overridden.
// - This FieldGenerator doesn't support packing, and this method
// should never have been called.
- GOOGLE_LOG(FATAL) << "GenerateParsingCodeFromPacked() "
- << "called on field generator that does not support packing.";
+ Y_ABSL_LOG(FATAL) << "GenerateBuilderParsingCodeFromPacked() "
+ << "called on field generator that does not support packing.";
}
} // namespace
ImmutableFieldGenerator::~ImmutableFieldGenerator() {}
-void ImmutableFieldGenerator::GenerateParsingCodeFromPacked(
+void ImmutableFieldGenerator::GenerateBuilderParsingCodeFromPacked(
io::Printer* printer) const {
ReportUnexpectedPackedFieldsCall(printer);
}
@@ -241,16 +242,16 @@ template <>
FieldGeneratorMap<ImmutableFieldLiteGenerator>::~FieldGeneratorMap() {}
-void SetCommonFieldVariables(const FieldDescriptor* descriptor,
- const FieldGeneratorInfo* info,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+void SetCommonFieldVariables(
+ const FieldDescriptor* descriptor, const FieldGeneratorInfo* info,
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables) {
(*variables)["field_name"] = descriptor->name();
(*variables)["name"] = info->name;
(*variables)["classname"] = descriptor->containing_type()->name();
(*variables)["capitalized_name"] = info->capitalized_name;
(*variables)["disambiguated_reason"] = info->disambiguated_reason;
(*variables)["constant_name"] = FieldConstantName(descriptor);
- (*variables)["number"] = StrCat(descriptor->number());
+ (*variables)["number"] = y_absl::StrCat(descriptor->number());
(*variables)["kt_dsl_builder"] = "_builder";
// These variables are placeholders to pick out the beginning and ends of
// identifiers for annotations (when doing so with existing variables would
@@ -258,46 +259,50 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
// empty string.
(*variables)["{"] = "";
(*variables)["}"] = "";
- (*variables)["kt_name"] =
- IsForbiddenKotlin(info->name) ? info->name + "_" : info->name;
- (*variables)["kt_capitalized_name"] = IsForbiddenKotlin(info->name)
- ? info->capitalized_name + "_"
- : info->capitalized_name;
+ (*variables)["kt_name"] = IsForbiddenKotlin(info->name)
+ ? y_absl::StrCat(info->name, "_")
+ : info->name;
+ (*variables)["kt_capitalized_name"] =
+ IsForbiddenKotlin(info->name) ? y_absl::StrCat(info->capitalized_name, "_")
+ : info->capitalized_name;
if (!descriptor->is_repeated()) {
- (*variables)["annotation_field_type"] = FieldTypeName(descriptor->type());
+ (*variables)["annotation_field_type"] =
+ TProtoStringType(FieldTypeName(descriptor->type()));
} else if (GetJavaType(descriptor) == JAVATYPE_MESSAGE &&
IsMapEntry(descriptor->message_type())) {
(*variables)["annotation_field_type"] =
- TProtoStringType(FieldTypeName(descriptor->type())) + "MAP";
+ y_absl::StrCat(FieldTypeName(descriptor->type()), "MAP");
} else {
(*variables)["annotation_field_type"] =
- TProtoStringType(FieldTypeName(descriptor->type())) + "_LIST";
+ y_absl::StrCat(FieldTypeName(descriptor->type()), "_LIST");
if (descriptor->is_packed()) {
- (*variables)["annotation_field_type"] =
- (*variables)["annotation_field_type"] + "_PACKED";
+ variables->insert(
+ {"annotation_field_type",
+ y_absl::StrCat(FieldTypeName(descriptor->type()), "_LIST_PACKED")});
}
}
}
-void SetCommonOneofVariables(const FieldDescriptor* descriptor,
- const OneofGeneratorInfo* info,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+void SetCommonOneofVariables(
+ const FieldDescriptor* descriptor, const OneofGeneratorInfo* info,
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables) {
(*variables)["oneof_name"] = info->name;
(*variables)["oneof_capitalized_name"] = info->capitalized_name;
(*variables)["oneof_index"] =
- StrCat(descriptor->containing_oneof()->index());
+ y_absl::StrCat(descriptor->containing_oneof()->index());
(*variables)["oneof_stored_type"] = GetOneofStoredType(descriptor);
(*variables)["set_oneof_case_message"] =
- info->name + "Case_ = " + StrCat(descriptor->number());
- (*variables)["clear_oneof_case_message"] = info->name + "Case_ = 0";
+ y_absl::StrCat(info->name, "Case_ = ", descriptor->number());
+ (*variables)["clear_oneof_case_message"] =
+ y_absl::StrCat(info->name, "Case_ = 0");
(*variables)["has_oneof_case_message"] =
- info->name + "Case_ == " + StrCat(descriptor->number());
+ y_absl::StrCat(info->name, "Case_ == ", descriptor->number());
}
-void PrintExtraFieldInfo(const std::map<TProtoStringType, TProtoStringType>& variables,
- io::Printer* printer) {
- const std::map<TProtoStringType, TProtoStringType>::const_iterator it =
- variables.find("disambiguated_reason");
+void PrintExtraFieldInfo(
+ const y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>& variables,
+ io::Printer* printer) {
+ auto it = variables.find("disambiguated_reason");
if (it != variables.end() && !it->second.empty()) {
printer->Print(
variables,
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/field.h
index 481fbdb4567..1229ce3a8a0 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/field.h
@@ -36,13 +36,13 @@
#define GOOGLE_PROTOBUF_COMPILER_JAVA_FIELD_H__
#include <cstdint>
-#include <map>
#include <memory>
#include <string>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/descriptor.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_check.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/port.h"
namespace google {
namespace protobuf {
@@ -66,8 +66,12 @@ namespace java {
class ImmutableFieldGenerator {
public:
ImmutableFieldGenerator() {}
+ ImmutableFieldGenerator(const ImmutableFieldGenerator&) = delete;
+ ImmutableFieldGenerator& operator=(const ImmutableFieldGenerator&) = delete;
virtual ~ImmutableFieldGenerator();
+ virtual int GetMessageBitIndex() const = 0;
+ virtual int GetBuilderBitIndex() const = 0;
virtual int GetNumBitsForMessage() const = 0;
virtual int GetNumBitsForBuilder() const = 0;
virtual void GenerateInterfaceMembers(io::Printer* printer) const = 0;
@@ -77,9 +81,8 @@ class ImmutableFieldGenerator {
virtual void GenerateBuilderClearCode(io::Printer* printer) const = 0;
virtual void GenerateMergingCode(io::Printer* printer) const = 0;
virtual void GenerateBuildingCode(io::Printer* printer) const = 0;
- virtual void GenerateParsingCode(io::Printer* printer) const = 0;
- virtual void GenerateParsingCodeFromPacked(io::Printer* printer) const;
- virtual void GenerateParsingDoneCode(io::Printer* printer) const = 0;
+ virtual void GenerateBuilderParsingCode(io::Printer* printer) const = 0;
+ virtual void GenerateBuilderParsingCodeFromPacked(io::Printer* printer) const;
virtual void GenerateSerializationCode(io::Printer* printer) const = 0;
virtual void GenerateSerializedSizeCode(io::Printer* printer) const = 0;
virtual void GenerateFieldBuilderInitializationCode(
@@ -90,14 +93,14 @@ class ImmutableFieldGenerator {
virtual void GenerateHashCode(io::Printer* printer) const = 0;
virtual TProtoStringType GetBoxedType() const = 0;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableFieldGenerator);
};
class ImmutableFieldLiteGenerator {
public:
ImmutableFieldLiteGenerator() {}
+ ImmutableFieldLiteGenerator(const ImmutableFieldLiteGenerator&) = delete;
+ ImmutableFieldLiteGenerator& operator=(const ImmutableFieldLiteGenerator&) =
+ delete;
virtual ~ImmutableFieldLiteGenerator();
virtual int GetNumBitsForMessage() const = 0;
@@ -110,9 +113,6 @@ class ImmutableFieldLiteGenerator {
virtual void GenerateKotlinDslMembers(io::Printer* printer) const = 0;
virtual TProtoStringType GetBoxedType() const = 0;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableFieldLiteGenerator);
};
@@ -121,6 +121,8 @@ template <typename FieldGeneratorType>
class FieldGeneratorMap {
public:
explicit FieldGeneratorMap(const Descriptor* descriptor, Context* context);
+ FieldGeneratorMap(const FieldGeneratorMap&) = delete;
+ FieldGeneratorMap& operator=(const FieldGeneratorMap&) = delete;
~FieldGeneratorMap();
const FieldGeneratorType& get(const FieldDescriptor* field) const;
@@ -128,14 +130,12 @@ class FieldGeneratorMap {
private:
const Descriptor* descriptor_;
std::vector<std::unique_ptr<FieldGeneratorType>> field_generators_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorMap);
};
template <typename FieldGeneratorType>
inline const FieldGeneratorType& FieldGeneratorMap<FieldGeneratorType>::get(
const FieldDescriptor* field) const {
- GOOGLE_CHECK_EQ(field->containing_type(), descriptor_);
+ Y_ABSL_CHECK_EQ(field->containing_type(), descriptor_);
return *field_generators_[field->index()];
}
@@ -170,18 +170,19 @@ struct OneofGeneratorInfo {
};
// Set some common variables used in variable FieldGenerators.
-void SetCommonFieldVariables(const FieldDescriptor* descriptor,
- const FieldGeneratorInfo* info,
- std::map<TProtoStringType, TProtoStringType>* variables);
+void SetCommonFieldVariables(
+ const FieldDescriptor* descriptor, const FieldGeneratorInfo* info,
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables);
// Set some common oneof variables used in OneofFieldGenerators.
-void SetCommonOneofVariables(const FieldDescriptor* descriptor,
- const OneofGeneratorInfo* info,
- std::map<TProtoStringType, TProtoStringType>* variables);
+void SetCommonOneofVariables(
+ const FieldDescriptor* descriptor, const OneofGeneratorInfo* info,
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables);
// Print useful comments before a field's accessors.
-void PrintExtraFieldInfo(const std::map<TProtoStringType, TProtoStringType>& variables,
- io::Printer* printer);
+void PrintExtraFieldInfo(
+ const y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>& variables,
+ io::Printer* printer);
} // namespace java
} // namespace compiler
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/file.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/file.cc
index 401599765bc..da961fc0886 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/file.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/file.cc
@@ -32,30 +32,32 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/file.h>
+#include "google/protobuf/compiler/java/file.h"
#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/context.h>
-#include <google/protobuf/compiler/java/enum.h>
-#include <google/protobuf/compiler/java/enum_lite.h>
-#include <google/protobuf/compiler/java/extension.h>
-#include <google/protobuf/compiler/java/generator_factory.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/message.h>
-#include <google/protobuf/compiler/java/name_resolver.h>
-#include <google/protobuf/compiler/java/service.h>
-#include <google/protobuf/compiler/java/shared_code_generator.h>
-#include <google/protobuf/descriptor.pb.h>
+#include <vector>
+
+#include "y_absl/container/btree_set.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/compiler/java/context.h"
+#include "google/protobuf/compiler/java/enum.h"
+#include "google/protobuf/compiler/java/enum_lite.h"
+#include "google/protobuf/compiler/java/extension.h"
+#include "google/protobuf/compiler/java/generator_factory.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/message.h"
+#include "google/protobuf/compiler/java/name_resolver.h"
+#include "google/protobuf/compiler/java/service.h"
+#include "google/protobuf/compiler/java/shared_code_generator.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/dynamic_message.h"
+#include "google/protobuf/io/printer.h"
+#include "google/protobuf/io/zero_copy_stream.h"
// Must be last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -76,8 +78,8 @@ struct FieldDescriptorCompare {
}
};
-typedef std::set<const FieldDescriptor*, FieldDescriptorCompare>
- FieldDescriptorSet;
+using FieldDescriptorSet =
+ y_absl::btree_set<const FieldDescriptor*, FieldDescriptorCompare>;
// Recursively searches the given message to collect extensions.
// Returns true if all the extensions can be recognized. The extensions will be
@@ -131,7 +133,7 @@ void CollectExtensions(const FileDescriptorProto& file_proto,
// builder-pool to find out all extensions.
const Descriptor* file_proto_desc = alternate_pool.FindMessageTypeByName(
file_proto.GetDescriptor()->full_name());
- GOOGLE_CHECK(file_proto_desc)
+ Y_ABSL_CHECK(file_proto_desc)
<< "Find unknown fields in FileDescriptorProto when building "
<< file_proto.name()
<< ". It's likely that those fields are custom options, however, "
@@ -140,14 +142,14 @@ void CollectExtensions(const FileDescriptorProto& file_proto,
DynamicMessageFactory factory;
std::unique_ptr<Message> dynamic_file_proto(
factory.GetPrototype(file_proto_desc)->New());
- GOOGLE_CHECK(dynamic_file_proto.get() != NULL);
- GOOGLE_CHECK(dynamic_file_proto->ParseFromString(file_data));
+ Y_ABSL_CHECK(dynamic_file_proto.get() != NULL);
+ Y_ABSL_CHECK(dynamic_file_proto->ParseFromString(file_data));
// Collect the extensions again from the dynamic message. There should be no
// more unknown fields this time, i.e. all the custom options should be
// parsed as extensions now.
extensions->clear();
- GOOGLE_CHECK(CollectExtensions(*dynamic_file_proto, extensions))
+ Y_ABSL_CHECK(CollectExtensions(*dynamic_file_proto, extensions))
<< "Find unknown fields in FileDescriptorProto when building "
<< file_proto.name()
<< ". It's likely that those fields are custom options, however, "
@@ -175,10 +177,10 @@ void MaybeRestartJavaMethod(io::Printer* printer, int* bytecode_estimate,
if ((*bytecode_estimate) > bytesPerMethod) {
++(*method_num);
- printer->Print(chain_statement, "method_num", StrCat(*method_num));
+ printer->Print(chain_statement, "method_num", y_absl::StrCat(*method_num));
printer->Outdent();
printer->Print("}\n");
- printer->Print(method_decl, "method_num", StrCat(*method_num));
+ printer->Print(method_decl, "method_num", y_absl::StrCat(*method_num));
printer->Indent();
*bytecode_estimate = 0;
}
@@ -188,7 +190,7 @@ void MaybeRestartJavaMethod(io::Printer* printer, int* bytecode_estimate,
FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options,
bool immutable_api)
: file_(file),
- java_package_(FileJavaPackage(file, immutable_api)),
+ java_package_(FileJavaPackage(file, immutable_api, options)),
message_generators_(file->message_type_count()),
extension_generators_(file->extension_count()),
context_(new Context(file, options)),
@@ -196,7 +198,7 @@ FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options,
options_(options),
immutable_api_(immutable_api) {
classname_ = name_resolver_->GetFileClassName(file, immutable_api);
- generator_factory_.reset(new ImmutableGeneratorFactory(context_.get()));
+ generator_factory_.reset(new ImmutableGeneratorFactory(context_.get()));
for (int i = 0; i < file_->message_type_count(); ++i) {
message_generators_[i].reset(
generator_factory_->NewMessageGenerator(file_->message_type(i)));
@@ -232,7 +234,7 @@ bool FileGenerator::Validate(TProtoStringType* error) {
// because filenames are case-insensitive on those platforms.
if (name_resolver_->HasConflictingClassName(
file_, classname_, NameEquality::EQUAL_IGNORE_CASE)) {
- GOOGLE_LOG(WARNING)
+ Y_ABSL_LOG(WARNING)
<< file_->name() << ": The file's outer class name, \"" << classname_
<< "\", matches the name of one of the types declared inside it when "
<< "case is ignored. This can cause compilation issues on Windows / "
@@ -244,7 +246,7 @@ bool FileGenerator::Validate(TProtoStringType* error) {
// Print a warning if optimize_for = LITE_RUNTIME is used.
if (file_->options().optimize_for() == FileOptions::LITE_RUNTIME &&
!options_.enforce_lite) {
- GOOGLE_LOG(WARNING)
+ Y_ABSL_LOG(WARNING)
<< "The optimize_for = LITE_RUNTIME option is no longer supported by "
<< "protobuf Java code generator and is ignored--protoc will always "
<< "generate full runtime code for Java. To use Java Lite runtime, "
@@ -271,8 +273,13 @@ void FileGenerator::Generate(io::Printer* printer) {
"package", java_package_);
}
PrintGeneratedAnnotation(
- printer, '$', options_.annotate_code ? classname_ + ".java.pb.meta" : "");
+ printer, '$',
+ options_.annotate_code ? y_absl::StrCat(classname_, ".java.pb.meta") : "",
+ options_);
+ if (!options_.opensource_runtime) {
+ printer->Print("@com.google.protobuf.Internal.ProtoNonnullApi\n");
+ }
printer->Print(
"$deprecation$public final class $classname$ {\n"
" private $ctor$() {}\n",
@@ -401,11 +408,14 @@ void FileGenerator::GenerateDescriptorInitializationCodeForImmutable(
" descriptor;\n"
"static {\n",
// TODO(dweis): Mark this as final.
- "final", "");
+ "final", options_.opensource_runtime ? "" : "final");
printer->Indent();
- SharedCodeGenerator shared_code_generator(file_, options_);
- shared_code_generator.GenerateDescriptors(printer);
+ if (options_.opensource_runtime) {
+ SharedCodeGenerator shared_code_generator(file_, options_);
+ shared_code_generator.GenerateDescriptors(printer);
+ } else {
+ }
int bytecode_estimate = 0;
int method_num = 0;
@@ -449,16 +459,16 @@ void FileGenerator::GenerateDescriptorInitializationCodeForImmutable(
FieldDescriptorSet extensions;
CollectExtensions(file_proto, *file_->pool(), &extensions, file_data);
- if (extensions.size() > 0) {
+ if (!extensions.empty()) {
// Must construct an ExtensionRegistry containing all existing extensions
// and use it to parse the descriptor data again to recognize extensions.
printer->Print(
"com.google.protobuf.ExtensionRegistry registry =\n"
" com.google.protobuf.ExtensionRegistry.newInstance();\n");
FieldDescriptorSet::iterator it;
- for (it = extensions.begin(); it != extensions.end(); it++) {
+ for (const FieldDescriptor* field : extensions) {
std::unique_ptr<ExtensionGenerator> generator(
- generator_factory_->NewExtensionGenerator(*it));
+ generator_factory_->NewExtensionGenerator(field));
bytecode_estimate += generator->GenerateRegistrationCode(printer);
MaybeRestartJavaMethod(
printer, &bytecode_estimate, &method_num,
@@ -499,8 +509,8 @@ void FileGenerator::GenerateDescriptorInitializationCodeForMutable(
printer->Print(
"descriptor = $immutable_package$.$descriptor_classname$.descriptor;\n",
- "immutable_package", FileJavaPackage(file_, true), "descriptor_classname",
- name_resolver_->GetDescriptorClassName(file_));
+ "immutable_package", FileJavaPackage(file_, true, options_),
+ "descriptor_classname", name_resolver_->GetDescriptorClassName(file_));
for (int i = 0; i < file_->message_type_count(); i++) {
message_generators_[i]->GenerateStaticVariableInitializers(printer);
@@ -518,7 +528,7 @@ void FileGenerator::GenerateDescriptorInitializationCodeForMutable(
FieldDescriptorSet extensions;
CollectExtensions(file_proto, *file_->pool(), &extensions, file_data);
- if (extensions.size() > 0) {
+ if (!extensions.empty()) {
// Try to load immutable messages' outer class. Its initialization code
// will take care of interpreting custom options.
printer->Print(
@@ -539,17 +549,18 @@ void FileGenerator::GenerateDescriptorInitializationCodeForMutable(
"com.google.protobuf.ExtensionRegistry registry =\n"
" com.google.protobuf.ExtensionRegistry.newInstance();\n"
"com.google.protobuf.MessageLite defaultExtensionInstance = null;\n");
- FieldDescriptorSet::iterator it;
- for (it = extensions.begin(); it != extensions.end(); it++) {
- const FieldDescriptor* field = *it;
+
+ for (const FieldDescriptor* field : extensions) {
TProtoStringType scope;
if (field->extension_scope() != NULL) {
- scope = name_resolver_->GetMutableClassName(field->extension_scope()) +
- ".getDescriptor()";
+ scope = y_absl::StrCat(
+ name_resolver_->GetMutableClassName(field->extension_scope()),
+ ".getDescriptor()");
} else {
- scope = FileJavaPackage(field->file(), true) + "." +
- name_resolver_->GetDescriptorClassName(field->file()) +
- ".descriptor";
+ scope =
+ y_absl::StrCat(FileJavaPackage(field->file(), true, options_), ".",
+ name_resolver_->GetDescriptorClassName(field->file()),
+ ".descriptor");
}
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
printer->Print(
@@ -560,11 +571,11 @@ void FileGenerator::GenerateDescriptorInitializationCodeForMutable(
" $scope$.getExtensions().get($index$),\n"
" (com.google.protobuf.Message) defaultExtensionInstance);\n"
"}\n",
- "scope", scope, "index", StrCat(field->index()), "class",
+ "scope", scope, "index", y_absl::StrCat(field->index()), "class",
name_resolver_->GetImmutableClassName(field->message_type()));
} else {
printer->Print("registry.add($scope$.getExtensions().get($index$));\n",
- "scope", scope, "index", StrCat(field->index()));
+ "scope", scope, "index", y_absl::StrCat(field->index()));
}
}
printer->Print(
@@ -598,9 +609,9 @@ static void GenerateSibling(
GeneratorClass* generator,
void (GeneratorClass::*pfn)(io::Printer* printer)) {
TProtoStringType filename =
- package_dir + descriptor->name() + name_suffix + ".java";
+ y_absl::StrCat(package_dir, descriptor->name(), name_suffix, ".java");
file_list->push_back(filename);
- TProtoStringType info_full_path = filename + ".pb.meta";
+ TProtoStringType info_full_path = y_absl::StrCat(filename, ".pb.meta");
GeneratedCodeInfo annotations;
io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
&annotations);
@@ -682,6 +693,23 @@ TProtoStringType FileGenerator::GetKotlinClassname() {
return name_resolver_->GetFileClassName(file_, immutable_api_, true);
}
+void FileGenerator::GenerateKotlin(io::Printer* printer) {
+ printer->Print(
+ "// Generated by the protocol buffer compiler. DO NOT EDIT!\n"
+ "// source: $filename$\n"
+ "\n",
+ "filename", file_->name());
+ printer->Print(
+ "// Generated files should ignore deprecation warnings\n"
+ "@file:Suppress(\"DEPRECATION\")\n");
+ if (!java_package_.empty()) {
+ printer->Print(
+ "package $package$;\n"
+ "\n",
+ "package", EscapeKotlinKeywords(java_package_));
+ }
+}
+
void FileGenerator::GenerateKotlinSiblings(
const TProtoStringType& package_dir, GeneratorContext* context,
std::vector<TProtoStringType>* file_list,
@@ -692,9 +720,10 @@ void FileGenerator::GenerateKotlinSiblings(
auto open_file = [context](const TProtoStringType& filename) {
return std::unique_ptr<io::ZeroCopyOutputStream>(context->Open(filename));
};
- TProtoStringType filename = package_dir + descriptor->name() + "Kt.kt";
+ TProtoStringType filename =
+ y_absl::StrCat(package_dir, descriptor->name(), "Kt.kt");
file_list->push_back(filename);
- TProtoStringType info_full_path = filename + ".pb.meta";
+ TProtoStringType info_full_path = y_absl::StrCat(filename, ".pb.meta");
GeneratedCodeInfo annotations;
io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
&annotations);
@@ -704,15 +733,18 @@ void FileGenerator::GenerateKotlinSiblings(
options_.annotate_code ? &annotation_collector : nullptr);
printer.Print(
- "//Generated by the protocol buffer compiler. DO NOT EDIT!\n"
+ "// Generated by the protocol buffer compiler. DO NOT EDIT!\n"
"// source: $filename$\n"
"\n",
"filename", descriptor->file()->name());
+ printer.Print(
+ "// Generated files should ignore deprecation warnings\n"
+ "@file:Suppress(\"DEPRECATION\")\n");
if (!java_package_.empty()) {
printer.Print(
"package $package$;\n"
"\n",
- "package", java_package_);
+ "package", EscapeKotlinKeywords(java_package_));
}
generator->GenerateKotlinMembers(&printer);
@@ -736,4 +768,4 @@ bool FileGenerator::ShouldIncludeDependency(const FileDescriptor* descriptor,
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/file.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/file.h
index 0063a18816a..c8934c4bfe2 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/file.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/file.h
@@ -39,8 +39,8 @@
#include <string>
#include <vector>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/compiler/java/options.h>
+#include "google/protobuf/compiler/java/options.h"
+#include "google/protobuf/port.h"
namespace google {
namespace protobuf {
@@ -70,6 +70,8 @@ class FileGenerator {
public:
FileGenerator(const FileDescriptor* file, const Options& options,
bool immutable_api = true);
+ FileGenerator(const FileGenerator&) = delete;
+ FileGenerator& operator=(const FileGenerator&) = delete;
~FileGenerator();
// Checks for problems that would otherwise lead to cryptic compile errors.
@@ -80,6 +82,7 @@ class FileGenerator {
void Generate(io::Printer* printer);
TProtoStringType GetKotlinClassname();
+ void GenerateKotlin(io::Printer* printer);
void GenerateKotlinSiblings(const TProtoStringType& package_dir,
GeneratorContext* generator_context,
std::vector<TProtoStringType>* file_list,
@@ -114,8 +117,6 @@ class FileGenerator {
ClassNameResolver* name_resolver_;
const Options options_;
bool immutable_api_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator);
};
} // namespace java
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/generator.cc
index 03be2a417eb..cac13d8cbce 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/generator.cc
@@ -32,23 +32,22 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/generator.h>
+#include "google/protobuf/compiler/java/generator.h"
+
+#include <utility>
+#include <vector>
#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/file.h>
-#include <google/protobuf/compiler/java/generator_factory.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/name_resolver.h>
-#include <google/protobuf/compiler/java/options.h>
-#include <google/protobuf/compiler/java/shared_code_generator.h>
-#include <google/protobuf/descriptor.pb.h>
+#include "y_absl/strings/str_format.h"
+#include "google/protobuf/compiler/java/file.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/name_resolver.h"
+#include "google/protobuf/compiler/java/options.h"
+#include "google/protobuf/compiler/java/shared_code_generator.h"
+#include "google/protobuf/descriptor.pb.h"
-#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
@@ -74,25 +73,27 @@ bool JavaGenerator::Generate(const FileDescriptor* file,
ParseGeneratorParameter(parameter, &options);
Options file_options;
- for (int i = 0; i < options.size(); i++) {
- if (options[i].first == "output_list_file") {
- file_options.output_list_file = options[i].second;
- } else if (options[i].first == "immutable") {
+ file_options.opensource_runtime = opensource_runtime_;
+
+ for (auto& option : options) {
+ if (option.first == "output_list_file") {
+ file_options.output_list_file = option.second;
+ } else if (option.first == "immutable") {
file_options.generate_immutable_code = true;
- } else if (options[i].first == "mutable") {
+ } else if (option.first == "mutable") {
file_options.generate_mutable_code = true;
- } else if (options[i].first == "shared") {
+ } else if (option.first == "shared") {
file_options.generate_shared_code = true;
- } else if (options[i].first == "lite") {
+ } else if (option.first == "lite") {
// Note: Java Lite does not guarantee API/ABI stability. We may choose to
// break existing API in order to boost performance / reduce code size.
file_options.enforce_lite = true;
- } else if (options[i].first == "annotate_code") {
+ } else if (option.first == "annotate_code") {
file_options.annotate_code = true;
- } else if (options[i].first == "annotation_list_file") {
- file_options.annotation_list_file = options[i].second;
+ } else if (option.first == "annotation_list_file") {
+ file_options.annotation_list_file = option.second;
} else {
- *error = "Unknown generator option: " + options[i].first;
+ *error = y_absl::StrCat("Unknown generator option: ", option.first);
return false;
}
}
@@ -117,35 +118,31 @@ bool JavaGenerator::Generate(const FileDescriptor* file,
std::vector<TProtoStringType> all_annotations;
- std::vector<FileGenerator*> file_generators;
+ std::vector<std::unique_ptr<FileGenerator>> file_generators;
if (file_options.generate_immutable_code) {
- file_generators.push_back(new FileGenerator(file, file_options,
- /* immutable = */ true));
+ file_generators.emplace_back(
+ std::make_unique<FileGenerator>(file, file_options,
+ /* immutable = */ true));
}
if (file_options.generate_mutable_code) {
- file_generators.push_back(new FileGenerator(file, file_options,
- /* mutable = */ false));
+ file_generators.emplace_back(
+ std::make_unique<FileGenerator>(file, file_options,
+ /* mutable = */ false));
}
- for (int i = 0; i < file_generators.size(); ++i) {
- if (!file_generators[i]->Validate(error)) {
- for (int j = 0; j < file_generators.size(); ++j) {
- delete file_generators[j];
- }
+ for (auto& file_generator : file_generators) {
+ if (!file_generator->Validate(error)) {
return false;
}
}
- for (int i = 0; i < file_generators.size(); ++i) {
- FileGenerator* file_generator = file_generators[i];
-
+ for (auto& file_generator : file_generators) {
TProtoStringType package_dir = JavaPackageToDir(file_generator->java_package());
- TProtoStringType java_filename = package_dir;
- java_filename += file_generator->classname();
- java_filename += ".java";
+ TProtoStringType java_filename =
+ y_absl::StrCat(package_dir, file_generator->classname(), ".java");
all_files.push_back(java_filename);
- TProtoStringType info_full_path = java_filename + ".pb.meta";
+ TProtoStringType info_full_path = y_absl::StrCat(java_filename, ".pb.meta");
if (file_options.annotate_code) {
all_annotations.push_back(info_full_path);
}
@@ -174,9 +171,6 @@ bool JavaGenerator::Generate(const FileDescriptor* file,
}
- for (int i = 0; i < file_generators.size(); ++i) {
- delete file_generators[i];
- }
file_generators.clear();
// Generate output list if requested.
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/generator.h
index e08c9807881..32225a07623 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/generator.h
@@ -38,10 +38,11 @@
#define GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__
#include <string>
-#include <google/protobuf/compiler/code_generator.h>
+
+#include "google/protobuf/compiler/code_generator.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -55,6 +56,8 @@ namespace java {
class PROTOC_EXPORT JavaGenerator : public CodeGenerator {
public:
JavaGenerator();
+ JavaGenerator(const JavaGenerator&) = delete;
+ JavaGenerator& operator=(const JavaGenerator&) = delete;
~JavaGenerator() override;
// implements CodeGenerator ----------------------------------------
@@ -63,8 +66,12 @@ class PROTOC_EXPORT JavaGenerator : public CodeGenerator {
uint64_t GetSupportedFeatures() const override;
+ void set_opensource_runtime(bool opensource) {
+ opensource_runtime_ = opensource;
+ }
+
private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(JavaGenerator);
+ bool opensource_runtime_ = PROTO2_IS_OSS;
};
} // namespace java
@@ -72,6 +79,6 @@ class PROTOC_EXPORT JavaGenerator : public CodeGenerator {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/generator_factory.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/generator_factory.cc
index dd526ba7c73..86baf0b06d2 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/generator_factory.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/generator_factory.cc
@@ -30,17 +30,17 @@
// Author: [email protected] (Pherl Liu)
-#include <google/protobuf/compiler/java/generator_factory.h>
+#include "google/protobuf/compiler/java/generator_factory.h"
-#include <google/protobuf/compiler/java/context.h>
-#include <google/protobuf/compiler/java/enum_field.h>
-#include <google/protobuf/compiler/java/extension.h>
-#include <google/protobuf/compiler/java/extension_lite.h>
-#include <google/protobuf/compiler/java/field.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/message.h>
-#include <google/protobuf/compiler/java/message_lite.h>
-#include <google/protobuf/compiler/java/service.h>
+#include "google/protobuf/compiler/java/context.h"
+#include "google/protobuf/compiler/java/enum_field.h"
+#include "google/protobuf/compiler/java/extension.h"
+#include "google/protobuf/compiler/java/extension_lite.h"
+#include "google/protobuf/compiler/java/field.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/message.h"
+#include "google/protobuf/compiler/java/message_lite.h"
+#include "google/protobuf/compiler/java/service.h"
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/generator_factory.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/generator_factory.h
index 807bca383a3..b2fb0546e99 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/generator_factory.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/generator_factory.h
@@ -33,7 +33,7 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_FACTORY_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_FACTORY_H__
-#include <google/protobuf/stubs/common.h>
+#include "google/protobuf/port.h"
namespace google {
namespace protobuf {
@@ -59,6 +59,8 @@ namespace java {
class GeneratorFactory {
public:
GeneratorFactory();
+ GeneratorFactory(const GeneratorFactory&) = delete;
+ GeneratorFactory& operator=(const GeneratorFactory&) = delete;
virtual ~GeneratorFactory();
virtual MessageGenerator* NewMessageGenerator(
@@ -69,15 +71,15 @@ class GeneratorFactory {
virtual ServiceGenerator* NewServiceGenerator(
const ServiceDescriptor* descriptor) const = 0;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratorFactory);
};
// Factory that creates generators for immutable-default messages.
class ImmutableGeneratorFactory : public GeneratorFactory {
public:
ImmutableGeneratorFactory(Context* context);
+ ImmutableGeneratorFactory(const ImmutableGeneratorFactory&) = delete;
+ ImmutableGeneratorFactory& operator=(const ImmutableGeneratorFactory&) =
+ delete;
~ImmutableGeneratorFactory() override;
MessageGenerator* NewMessageGenerator(
@@ -91,7 +93,6 @@ class ImmutableGeneratorFactory : public GeneratorFactory {
private:
Context* context_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableGeneratorFactory);
};
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/helpers.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/helpers.cc
index 96444c58fa3..ada6babab5b 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/helpers.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/helpers.cc
@@ -32,25 +32,31 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/helpers.h>
+#include "google/protobuf/compiler/java/helpers.h"
#include <algorithm>
#include <cstdint>
#include <limits>
-#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/name_resolver.h>
-#include <google/protobuf/compiler/java/names.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/stubs/hash.h> // for hash<T *>
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/escaping.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/str_replace.h"
+#include "y_absl/strings/str_split.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/strings/substitute.h"
+#include "google/protobuf/compiler/java/name_resolver.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/strtod.h"
+#include "google/protobuf/wire_format.h"
// Must be last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -65,78 +71,9 @@ const char kThickSeparator[] =
const char kThinSeparator[] =
"// -------------------------------------------------------------------\n";
-namespace {
-
-const char* kDefaultPackage = "";
-
-// 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[] = {
- // java.lang.Object:
- "Class",
- // com.google.protobuf.MessageLiteOrBuilder:
- "DefaultInstanceForType",
- // com.google.protobuf.MessageLite:
- "ParserForType",
- "SerializedSize",
- // com.google.protobuf.MessageOrBuilder:
- "AllFields",
- "DescriptorForType",
- "InitializationErrorString",
- "UnknownFields",
- // obsolete. kept for backwards compatibility of generated code
- "CachedSize",
-};
-
-const std::unordered_set<TProtoStringType>* kReservedNames =
- new std::unordered_set<TProtoStringType>({
- "abstract", "assert", "boolean", "break", "byte",
- "case", "catch", "char", "class", "const",
- "continue", "default", "do", "double", "else",
- "enum", "extends", "final", "finally", "float",
- "for", "goto", "if", "implements", "import",
- "instanceof", "int", "interface", "long", "native",
- "new", "package", "private", "protected", "public",
- "return", "short", "static", "strictfp", "super",
- "switch", "synchronized", "this", "throw", "throws",
- "transient", "try", "void", "volatile", "while",
- });
-
-bool IsForbidden(const TProtoStringType& field_name) {
- for (int i = 0; i < GOOGLE_ARRAYSIZE(kForbiddenWordList); ++i) {
- if (UnderscoresToCamelCase(field_name, true) == kForbiddenWordList[i]) {
- return true;
- }
- }
- return false;
-}
-
-TProtoStringType FieldName(const FieldDescriptor* field) {
- TProtoStringType field_name;
- // Groups are hacky: The name of the field is just the lower-cased name
- // of the group type. In Java, though, we would like to retain the original
- // capitalization of the type name.
- if (GetType(field) == FieldDescriptor::TYPE_GROUP) {
- field_name = field->message_type()->name();
- } else {
- field_name = field->name();
- }
- if (IsForbidden(field_name)) {
- // Append a trailing "#" to indicate that the name should be decorated to
- // avoid collision with other names.
- field_name += "#";
- }
- return field_name;
-}
-
-
-} // namespace
-
void PrintGeneratedAnnotation(io::Printer* printer, char delimiter,
- const TProtoStringType& annotation_file) {
+ y_absl::string_view annotation_file,
+ Options options) {
if (annotation_file.empty()) {
return;
}
@@ -149,14 +86,14 @@ void PrintGeneratedAnnotation(io::Printer* printer, char delimiter,
printer->Print(ptemplate.c_str(), "annotation_file", annotation_file);
}
-void PrintEnumVerifierLogic(io::Printer* printer,
- const FieldDescriptor* descriptor,
- const std::map<TProtoStringType, TProtoStringType>& variables,
- const char* var_name,
- const char* terminating_string, bool enforce_lite) {
+void PrintEnumVerifierLogic(
+ io::Printer* printer, const FieldDescriptor* descriptor,
+ const y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>& variables,
+ y_absl::string_view var_name, y_absl::string_view terminating_string,
+ bool enforce_lite) {
TProtoStringType enum_verifier_string =
- enforce_lite ? StrCat(var_name, ".internalGetVerifier()")
- : StrCat(
+ enforce_lite ? y_absl::StrCat(var_name, ".internalGetVerifier()")
+ : y_absl::StrCat(
"new com.google.protobuf.Internal.EnumVerifier() {\n"
" @java.lang.Override\n"
" public boolean isInRange(int number) {\n"
@@ -165,14 +102,13 @@ void PrintEnumVerifierLogic(io::Printer* printer,
".forNumber(number) != null;\n"
" }\n"
" }");
- printer->Print(
- variables,
- StrCat(enum_verifier_string, terminating_string).c_str());
+ printer->Print(variables,
+ y_absl::StrCat(enum_verifier_string, terminating_string));
}
-TProtoStringType UnderscoresToCamelCase(const TProtoStringType& input,
+TProtoStringType UnderscoresToCamelCase(y_absl::string_view input,
bool cap_next_letter) {
- GOOGLE_CHECK(!input.empty());
+ Y_ABSL_CHECK(!input.empty());
TProtoStringType result;
// Note: I distrust ctype.h due to locales.
for (int i = 0; i < input.size(); i++) {
@@ -207,7 +143,7 @@ TProtoStringType UnderscoresToCamelCase(const TProtoStringType& input,
return result;
}
-TProtoStringType ToCamelCase(const TProtoStringType& input, bool lower_first) {
+TProtoStringType ToCamelCase(y_absl::string_view input, bool lower_first) {
bool capitalize_next = !lower_first;
TProtoStringType result;
result.reserve(input.size());
@@ -216,7 +152,7 @@ TProtoStringType ToCamelCase(const TProtoStringType& input, bool lower_first) {
if (i == '_') {
capitalize_next = true;
} else if (capitalize_next) {
- result.push_back(ToUpperCh(i));
+ result.push_back(y_absl::ascii_toupper(i));
capitalize_next = false;
} else {
result.push_back(i);
@@ -225,146 +161,83 @@ TProtoStringType ToCamelCase(const TProtoStringType& input, bool lower_first) {
// Lower-case the first letter.
if (lower_first && !result.empty()) {
- result[0] = ToLowerCh(result[0]);
+ result[0] = y_absl::ascii_tolower(result[0]);
}
return result;
}
-char ToUpperCh(char ch) {
- return (ch >= 'a' && ch <= 'z') ? (ch - 'a' + 'A') : ch;
-}
-
-char ToLowerCh(char ch) {
- return (ch >= 'A' && ch <= 'Z') ? (ch - 'A' + 'a') : ch;
-}
-
-TProtoStringType UnderscoresToCamelCase(const FieldDescriptor* field) {
- return UnderscoresToCamelCase(FieldName(field), false);
-}
-
-TProtoStringType UnderscoresToCapitalizedCamelCase(const FieldDescriptor* field) {
- return UnderscoresToCamelCase(FieldName(field), true);
-}
-
-TProtoStringType CapitalizedFieldName(const FieldDescriptor* field) {
- return UnderscoresToCapitalizedCamelCase(field);
-}
-
-TProtoStringType UnderscoresToCamelCase(const MethodDescriptor* method) {
- return UnderscoresToCamelCase(method->name(), false);
-}
-
-TProtoStringType UnderscoresToCamelCaseCheckReserved(const FieldDescriptor* field) {
- TProtoStringType name = UnderscoresToCamelCase(field);
- if (kReservedNames->find(name) != kReservedNames->end()) {
- return name + "_";
- }
- return name;
-}
-
// Names that should be avoided as field names in Kotlin.
// All Kotlin hard keywords are in this list.
-const std::unordered_set<TProtoStringType>* kKotlinForbiddenNames =
- new std::unordered_set<TProtoStringType>({
- "as", "as?", "break", "class", "continue", "do", "else",
- "false", "for", "fun", "if", "in", "!in", "interface",
- "is", "!is", "null", "object", "package", "return", "super",
- "this", "throw", "true", "try", "typealias", "typeof", "val",
- "var", "when", "while",
- });
-
-bool IsForbiddenKotlin(const TProtoStringType& field_name) {
- return kKotlinForbiddenNames->find(field_name) !=
- kKotlinForbiddenNames->end();
+bool IsForbiddenKotlin(y_absl::string_view field_name) {
+ static const auto& kKotlinForbiddenNames =
+ *new y_absl::flat_hash_set<y_absl::string_view>({
+ "as", "as?", "break", "class", "continue", "do",
+ "else", "false", "for", "fun", "if", "in",
+ "!in", "interface", "is", "!is", "null", "object",
+ "package", "return", "super", "this", "throw", "true",
+ "try", "typealias", "typeof", "val", "var", "when",
+ "while",
+ });
+
+ return kKotlinForbiddenNames.contains(field_name);
+}
+
+TProtoStringType EscapeKotlinKeywords(TProtoStringType name) {
+ std::vector<TProtoStringType> escaped_packages;
+ std::vector<TProtoStringType> packages = y_absl::StrSplit(name, "."); // NOLINT
+ for (y_absl::string_view package : packages) {
+ if (IsForbiddenKotlin(package)) {
+ escaped_packages.push_back(y_absl::StrCat("`", package, "`"));
+ } else {
+ escaped_packages.emplace_back(package);
+ }
+ }
+ return y_absl::StrJoin(escaped_packages, ".");
}
TProtoStringType UniqueFileScopeIdentifier(const Descriptor* descriptor) {
- return "static_" + StringReplace(descriptor->full_name(), ".", "_", true);
+ return y_absl::StrCat(
+ "static_", y_absl::StrReplaceAll(descriptor->full_name(), {{".", "_"}}));
}
TProtoStringType CamelCaseFieldName(const FieldDescriptor* field) {
TProtoStringType fieldName = UnderscoresToCamelCase(field);
if ('0' <= fieldName[0] && fieldName[0] <= '9') {
- return '_' + fieldName;
+ return y_absl::StrCat("_", fieldName);
}
return fieldName;
}
TProtoStringType FileClassName(const FileDescriptor* file, bool immutable) {
- ClassNameResolver name_resolver;
- return name_resolver.GetFileClassName(file, immutable);
-}
-
-TProtoStringType FileJavaPackage(const FileDescriptor* file, bool immutable) {
- TProtoStringType result;
-
- if (file->options().has_java_package()) {
- result = file->options().java_package();
- } else {
- result = kDefaultPackage;
- if (!file->package().empty()) {
- if (!result.empty()) result += '.';
- result += file->package();
- }
- }
-
- return result;
-}
-
-TProtoStringType FileJavaPackage(const FileDescriptor* file) {
- return FileJavaPackage(file, true /* immutable */);
+ return ClassNameResolver().GetFileClassName(file, immutable);
}
TProtoStringType JavaPackageToDir(TProtoStringType package_name) {
- TProtoStringType package_dir = StringReplace(package_name, ".", "/", true);
- if (!package_dir.empty()) package_dir += "/";
+ TProtoStringType package_dir = y_absl::StrReplaceAll(package_name, {{".", "/"}});
+ if (!package_dir.empty()) y_absl::StrAppend(&package_dir, "/");
return package_dir;
}
-TProtoStringType ClassName(const Descriptor* descriptor) {
- ClassNameResolver name_resolver;
- return name_resolver.GetClassName(descriptor, true);
-}
-
-TProtoStringType ClassName(const EnumDescriptor* descriptor) {
- ClassNameResolver name_resolver;
- return name_resolver.GetClassName(descriptor, true);
-}
-
-TProtoStringType ClassName(const ServiceDescriptor* descriptor) {
- ClassNameResolver name_resolver;
- return name_resolver.GetClassName(descriptor, true);
-}
-
-TProtoStringType ClassName(const FileDescriptor* descriptor) {
- ClassNameResolver name_resolver;
- return name_resolver.GetClassName(descriptor, true);
-}
-
-
TProtoStringType ExtraMessageInterfaces(const Descriptor* descriptor) {
- TProtoStringType interfaces = "// @@protoc_insertion_point(message_implements:" +
- descriptor->full_name() + ")";
- return interfaces;
+ return y_absl::StrCat("// @@protoc_insertion_point(message_implements:",
+ descriptor->full_name(), ")");
}
TProtoStringType ExtraBuilderInterfaces(const Descriptor* descriptor) {
- TProtoStringType interfaces = "// @@protoc_insertion_point(builder_implements:" +
- descriptor->full_name() + ")";
- return interfaces;
+ return y_absl::StrCat("// @@protoc_insertion_point(builder_implements:",
+ descriptor->full_name(), ")");
}
TProtoStringType ExtraMessageOrBuilderInterfaces(const Descriptor* descriptor) {
- TProtoStringType interfaces = "// @@protoc_insertion_point(interface_extends:" +
- descriptor->full_name() + ")";
- return interfaces;
+ return y_absl::StrCat("// @@protoc_insertion_point(interface_extends:",
+ descriptor->full_name(), ")");
}
TProtoStringType FieldConstantName(const FieldDescriptor* field) {
- TProtoStringType name = field->name() + "_FIELD_NUMBER";
- ToUpper(&name);
+ TProtoStringType name = y_absl::StrCat(field->name(), "_FIELD_NUMBER");
+ y_absl::AsciiStrToUpper(&name);
return name;
}
@@ -414,11 +287,11 @@ JavaType GetJavaType(const FieldDescriptor* field) {
// types are added.
}
- GOOGLE_LOG(FATAL) << "Can't get here.";
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
return JAVATYPE_INT;
}
-const char* PrimitiveTypeName(JavaType type) {
+y_absl::string_view PrimitiveTypeName(JavaType type) {
switch (type) {
case JAVATYPE_INT:
return "int";
@@ -435,23 +308,23 @@ const char* PrimitiveTypeName(JavaType type) {
case JAVATYPE_BYTES:
return "com.google.protobuf.ByteString";
case JAVATYPE_ENUM:
- return NULL;
+ return {};
case JAVATYPE_MESSAGE:
- return NULL;
+ return {};
// No default because we want the compiler to complain if any new
// JavaTypes are added.
}
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return NULL;
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
+ return {};
}
-const char* PrimitiveTypeName(const FieldDescriptor* descriptor) {
+y_absl::string_view PrimitiveTypeName(const FieldDescriptor* descriptor) {
return PrimitiveTypeName(GetJavaType(descriptor));
}
-const char* BoxedPrimitiveTypeName(JavaType type) {
+y_absl::string_view BoxedPrimitiveTypeName(JavaType type) {
switch (type) {
case JAVATYPE_INT:
return "java.lang.Integer";
@@ -468,23 +341,23 @@ const char* BoxedPrimitiveTypeName(JavaType type) {
case JAVATYPE_BYTES:
return "com.google.protobuf.ByteString";
case JAVATYPE_ENUM:
- return NULL;
+ return {};
case JAVATYPE_MESSAGE:
- return NULL;
+ return {};
// No default because we want the compiler to complain if any new
// JavaTypes are added.
}
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return NULL;
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
+ return {};
}
-const char* BoxedPrimitiveTypeName(const FieldDescriptor* descriptor) {
+y_absl::string_view BoxedPrimitiveTypeName(const FieldDescriptor* descriptor) {
return BoxedPrimitiveTypeName(GetJavaType(descriptor));
}
-const char* KotlinTypeName(JavaType type) {
+y_absl::string_view KotlinTypeName(JavaType type) {
switch (type) {
case JAVATYPE_INT:
return "kotlin.Int";
@@ -501,16 +374,16 @@ const char* KotlinTypeName(JavaType type) {
case JAVATYPE_BYTES:
return "com.google.protobuf.ByteString";
case JAVATYPE_ENUM:
- return NULL;
+ return {};
case JAVATYPE_MESSAGE:
- return NULL;
+ return {};
// No default because we want the compiler to complain if any new
// JavaTypes are added.
}
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return NULL;
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
+ return {};
}
TProtoStringType GetOneofStoredType(const FieldDescriptor* field) {
@@ -519,13 +392,13 @@ TProtoStringType GetOneofStoredType(const FieldDescriptor* field) {
case JAVATYPE_ENUM:
return "java.lang.Integer";
case JAVATYPE_MESSAGE:
- return ClassName(field->message_type());
+ return ClassNameResolver().GetClassName(field->message_type(), true);
default:
- return BoxedPrimitiveTypeName(javaType);
+ return TProtoStringType(BoxedPrimitiveTypeName(javaType));
}
}
-const char* FieldTypeName(FieldDescriptor::Type field_type) {
+y_absl::string_view FieldTypeName(FieldDescriptor::Type field_type) {
switch (field_type) {
case FieldDescriptor::TYPE_INT32:
return "INT32";
@@ -568,11 +441,11 @@ const char* FieldTypeName(FieldDescriptor::Type field_type) {
// types are added.
}
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return NULL;
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
+ return {};
}
-bool AllAscii(const TProtoStringType& text) {
+bool AllAscii(y_absl::string_view text) {
for (int i = 0; i < text.size(); i++) {
if ((text[i] & 0x80) != 0) {
return false;
@@ -582,19 +455,19 @@ bool AllAscii(const TProtoStringType& text) {
}
TProtoStringType DefaultValue(const FieldDescriptor* field, bool immutable,
- ClassNameResolver* name_resolver) {
+ ClassNameResolver* name_resolver, Options options) {
// Switch on CppType since we need to know which default_value_* method
// of FieldDescriptor to call.
switch (field->cpp_type()) {
case FieldDescriptor::CPPTYPE_INT32:
- return StrCat(field->default_value_int32());
+ return y_absl::StrCat(field->default_value_int32());
case FieldDescriptor::CPPTYPE_UINT32:
// Need to print as a signed int since Java has no unsigned.
- return StrCat(static_cast<arc_i32>(field->default_value_uint32()));
+ return y_absl::StrCat(static_cast<arc_i32>(field->default_value_uint32()));
case FieldDescriptor::CPPTYPE_INT64:
- return StrCat(field->default_value_int64()) + "L";
+ return y_absl::StrCat(field->default_value_int64(), "L");
case FieldDescriptor::CPPTYPE_UINT64:
- return StrCat(static_cast<arc_i64>(field->default_value_uint64())) +
+ return y_absl::StrCat(static_cast<arc_i64>(field->default_value_uint64())) +
"L";
case FieldDescriptor::CPPTYPE_DOUBLE: {
double value = field->default_value_double();
@@ -605,7 +478,7 @@ TProtoStringType DefaultValue(const FieldDescriptor* field, bool immutable,
} else if (value != value) {
return "Double.NaN";
} else {
- return SimpleDtoa(value) + "D";
+ return y_absl::StrCat(io::SimpleDtoa(value), "D");
}
}
case FieldDescriptor::CPPTYPE_FLOAT: {
@@ -617,7 +490,7 @@ TProtoStringType DefaultValue(const FieldDescriptor* field, bool immutable,
} else if (value != value) {
return "Float.NaN";
} else {
- return SimpleFtoa(value) + "F";
+ return y_absl::StrCat(io::SimpleFtoa(value), "F");
}
}
case FieldDescriptor::CPPTYPE_BOOL:
@@ -626,37 +499,40 @@ TProtoStringType DefaultValue(const FieldDescriptor* field, bool immutable,
if (GetType(field) == FieldDescriptor::TYPE_BYTES) {
if (field->has_default_value()) {
// See comments in Internal.java for gory details.
- return strings::Substitute(
+ return y_absl::Substitute(
"com.google.protobuf.Internal.bytesDefaultValue(\"$0\")",
- CEscape(field->default_value_string()));
+ y_absl::CEscape(field->default_value_string()));
} else {
return "com.google.protobuf.ByteString.EMPTY";
}
} else {
if (AllAscii(field->default_value_string())) {
// All chars are ASCII. In this case CEscape() works fine.
- return "\"" + CEscape(field->default_value_string()) + "\"";
+ return y_absl::StrCat(
+ "\"", y_absl::CEscape(field->default_value_string()), "\"");
} else {
// See comments in Internal.java for gory details.
- return strings::Substitute(
+ return y_absl::Substitute(
"com.google.protobuf.Internal.stringDefaultValue(\"$0\")",
- CEscape(field->default_value_string()));
+ y_absl::CEscape(field->default_value_string()));
}
}
case FieldDescriptor::CPPTYPE_ENUM:
- return name_resolver->GetClassName(field->enum_type(), immutable) + "." +
- field->default_value_enum()->name();
+ return y_absl::StrCat(
+ name_resolver->GetClassName(field->enum_type(), immutable), ".",
+ field->default_value_enum()->name());
case FieldDescriptor::CPPTYPE_MESSAGE:
- return name_resolver->GetClassName(field->message_type(), immutable) +
- ".getDefaultInstance()";
+ return y_absl::StrCat(
+ name_resolver->GetClassName(field->message_type(), immutable),
+ ".getDefaultInstance()");
// No default because we want the compiler to complain if any new
// types are added.
}
- GOOGLE_LOG(FATAL) << "Can't get here.";
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
return "";
}
@@ -688,7 +564,7 @@ bool IsDefaultValueJavaDefault(const FieldDescriptor* field) {
// types are added.
}
- GOOGLE_LOG(FATAL) << "Can't get here.";
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
return false;
}
@@ -697,7 +573,7 @@ bool IsByteStringWithCustomDefaultValue(const FieldDescriptor* field) {
field->default_value_string() != "";
}
-const char* bit_masks[] = {
+constexpr y_absl::string_view bit_masks[] = {
"0x00000001", "0x00000002", "0x00000004", "0x00000008",
"0x00000010", "0x00000020", "0x00000040", "0x00000080",
@@ -712,10 +588,7 @@ const char* bit_masks[] = {
};
TProtoStringType GetBitFieldName(int index) {
- TProtoStringType varName = "bitField";
- varName += StrCat(index);
- varName += "_";
- return varName;
+ return y_absl::StrCat("bitField", index, "_");
}
TProtoStringType GetBitFieldNameForBit(int bitIndex) {
@@ -724,22 +597,19 @@ TProtoStringType GetBitFieldNameForBit(int bitIndex) {
namespace {
-TProtoStringType GenerateGetBitInternal(const TProtoStringType& prefix, int bitIndex) {
- TProtoStringType varName = prefix + GetBitFieldNameForBit(bitIndex);
+TProtoStringType GenerateGetBitInternal(y_absl::string_view prefix, int bitIndex) {
+ TProtoStringType varName = y_absl::StrCat(prefix, GetBitFieldNameForBit(bitIndex));
int bitInVarIndex = bitIndex % 32;
- TProtoStringType mask = bit_masks[bitInVarIndex];
- TProtoStringType result = "((" + varName + " & " + mask + ") != 0)";
- return result;
+ return y_absl::StrCat("((", varName, " & ", bit_masks[bitInVarIndex],
+ ") != 0)");
}
-TProtoStringType GenerateSetBitInternal(const TProtoStringType& prefix, int bitIndex) {
- TProtoStringType varName = prefix + GetBitFieldNameForBit(bitIndex);
+TProtoStringType GenerateSetBitInternal(y_absl::string_view prefix, int bitIndex) {
+ TProtoStringType varName = y_absl::StrCat(prefix, GetBitFieldNameForBit(bitIndex));
int bitInVarIndex = bitIndex % 32;
- TProtoStringType mask = bit_masks[bitInVarIndex];
- TProtoStringType result = varName + " |= " + mask;
- return result;
+ return y_absl::StrCat(varName, " |= ", bit_masks[bitInVarIndex]);
}
} // namespace
@@ -756,9 +626,8 @@ TProtoStringType GenerateClearBit(int bitIndex) {
TProtoStringType varName = GetBitFieldNameForBit(bitIndex);
int bitInVarIndex = bitIndex % 32;
- TProtoStringType mask = bit_masks[bitInVarIndex];
- TProtoStringType result = varName + " = (" + varName + " & ~" + mask + ")";
- return result;
+ return y_absl::StrCat(varName, " = (", varName, " & ~",
+ bit_masks[bitInVarIndex], ")");
}
TProtoStringType GenerateGetBitFromLocal(int bitIndex) {
@@ -802,11 +671,12 @@ bool IsReferenceType(JavaType type) {
// JavaTypes are added.
}
- GOOGLE_LOG(FATAL) << "Can't get here.";
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
return false;
}
-const char* GetCapitalizedType(const FieldDescriptor* field, bool immutable) {
+y_absl::string_view GetCapitalizedType(const FieldDescriptor* field,
+ bool immutable, Options options) {
switch (GetType(field)) {
case FieldDescriptor::TYPE_INT32:
return "Int32";
@@ -850,8 +720,8 @@ const char* GetCapitalizedType(const FieldDescriptor* field, bool immutable) {
// types are added.
}
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return NULL;
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
+ return {};
}
// For encodings with fixed sizes, returns that size in bytes. Otherwise
@@ -900,7 +770,7 @@ int FixedSize(FieldDescriptor::Type type) {
// No default because we want the compiler to complain if any new
// types are added.
}
- GOOGLE_LOG(FATAL) << "Can't get here.";
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
return -1;
}
@@ -923,7 +793,7 @@ const FieldDescriptor** SortFieldsByNumber(const Descriptor* descriptor) {
// already_seen is used to avoid checking the same type multiple times
// (and also to protect against recursion).
bool HasRequiredFields(const Descriptor* type,
- std::unordered_set<const Descriptor*>* already_seen) {
+ y_absl::flat_hash_set<const Descriptor*>* already_seen) {
if (already_seen->count(type) > 0) {
// The type is already in cache. This means that either:
// a. The type has no required fields.
@@ -958,7 +828,7 @@ bool HasRequiredFields(const Descriptor* type,
}
bool HasRequiredFields(const Descriptor* type) {
- std::unordered_set<const Descriptor*> already_seen;
+ y_absl::flat_hash_set<const Descriptor*> already_seen;
return HasRequiredFields(type, &already_seen);
}
@@ -1036,7 +906,7 @@ int GetExperimentalJavaFieldTypeForPacked(const FieldDescriptor* field) {
} else if (result > FieldDescriptor::TYPE_BYTES) {
return result + 30;
} else {
- GOOGLE_LOG(FATAL) << field->full_name() << " can't be packed.";
+ Y_ABSL_LOG(FATAL) << field->full_name() << " can't be packed.";
return 0;
}
}
@@ -1103,7 +973,7 @@ void EscapeUtf16ToString(uint16_t code, TProtoStringType* output) {
} else if (code >= 0x20 && code <= 0x7f) {
output->push_back(static_cast<char>(code));
} else {
- output->append(StringPrintf("\\u%04x", code));
+ output->append(y_absl::StrFormat("\\u%04x", code));
}
}
@@ -1112,4 +982,4 @@ void EscapeUtf16ToString(uint16_t code, TProtoStringType* output) {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/helpers.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/helpers.h
index 7f4c4aad144..e4fac634264 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/helpers.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/helpers.h
@@ -38,10 +38,15 @@
#include <cstdint>
#include <string>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/compiler/java/context.h>
-#include <google/protobuf/descriptor.pb.h>
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/compiler/java/names.h"
+#include "google/protobuf/compiler/java/options.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/printer.h"
+
+// Must be last.
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -53,7 +58,7 @@ namespace java {
extern const char kThickSeparator[];
extern const char kThinSeparator[];
-bool IsForbiddenKotlin(const TProtoStringType& field_name);
+bool IsForbiddenKotlin(y_absl::string_view field_name);
// If annotation_file is non-empty, prints a javax.annotation.Generated
// annotation to the given Printer. annotation_file will be referenced in the
@@ -64,38 +69,20 @@ bool IsForbiddenKotlin(const TProtoStringType& field_name);
// annotation_file should be generated from the filename of the source file
// being annotated (which in turn must be a Java identifier plus ".java").
void PrintGeneratedAnnotation(io::Printer* printer, char delimiter = '$',
- const TProtoStringType& annotation_file = "");
+ y_absl::string_view annotation_file = "",
+ Options options = {});
// If a GeneratedMessageLite contains non-lite enums, then its verifier
// must be instantiated inline, rather than retrieved from the enum class.
-void PrintEnumVerifierLogic(io::Printer* printer,
- const FieldDescriptor* descriptor,
- const std::map<TProtoStringType, TProtoStringType>& variables,
- const char* var_name,
- const char* terminating_string, bool enforce_lite);
-
-// Converts a name to camel-case. If cap_first_letter is true, capitalize the
-// first letter.
-TProtoStringType ToCamelCase(const TProtoStringType& input, bool lower_first);
-
-char ToUpperCh(char ch);
-char ToLowerCh(char ch);
+void PrintEnumVerifierLogic(
+ io::Printer* printer, const FieldDescriptor* descriptor,
+ const y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>& variables,
+ y_absl::string_view var_name, y_absl::string_view terminating_string,
+ bool enforce_lite);
// Converts a name to camel-case. If cap_first_letter is true, capitalize the
// first letter.
-TProtoStringType UnderscoresToCamelCase(const TProtoStringType& name,
- bool cap_first_letter);
-// Converts the field's name to camel-case, e.g. "foo_bar_baz" becomes
-// "fooBarBaz" or "FooBarBaz", respectively.
-TProtoStringType UnderscoresToCamelCase(const FieldDescriptor* field);
-TProtoStringType UnderscoresToCapitalizedCamelCase(const FieldDescriptor* field);
-
-// Similar, but for method names. (Typically, this merely has the effect
-// of lower-casing the first letter of the name.)
-TProtoStringType UnderscoresToCamelCase(const MethodDescriptor* method);
-
-// Same as UnderscoresToCamelCase, but checks for reserved keywords
-TProtoStringType UnderscoresToCamelCaseCheckReserved(const FieldDescriptor* field);
+TProtoStringType ToCamelCase(y_absl::string_view input, bool lower_first);
// Similar to UnderscoresToCamelCase, but guarantees that the result is a
// complete Java identifier by adding a _ if needed.
@@ -113,11 +100,15 @@ TProtoStringType UniqueFileScopeIdentifier(const Descriptor* descriptor);
TProtoStringType FileClassName(const FileDescriptor* file, bool immutable = true);
// Returns the file's Java package name.
-TProtoStringType FileJavaPackage(const FileDescriptor* file, bool immutable);
+TProtoStringType FileJavaPackage(const FileDescriptor* file, bool immutable,
+ Options options = {});
// Returns output directory for the given package name.
TProtoStringType JavaPackageToDir(TProtoStringType package_name);
+// Returns the name with Kotlin keywords enclosed in backticks
+TProtoStringType EscapeKotlinKeywords(TProtoStringType name);
+
// Comma-separate list of option-specified interfaces implemented by the
// Message, to follow the "implements" declaration of the Message definition.
TProtoStringType ExtraMessageInterfaces(const Descriptor* descriptor);
@@ -194,20 +185,8 @@ inline bool IsOwnFile(const ServiceDescriptor* descriptor, bool immutable) {
// (e.g.) be "OrBuilder" for some generated interfaces.
template <typename Descriptor>
TProtoStringType AnnotationFileName(const Descriptor* descriptor,
- const TProtoStringType& suffix) {
- return descriptor->name() + suffix + ".java.pb.meta";
-}
-
-template <typename Descriptor>
-void MaybePrintGeneratedAnnotation(Context* context, io::Printer* printer,
- Descriptor* descriptor, bool immutable,
- const TProtoStringType& suffix = "") {
- if (IsOwnFile(descriptor, immutable)) {
- PrintGeneratedAnnotation(printer, '$',
- context->options().annotate_code
- ? AnnotationFileName(descriptor, suffix)
- : "");
- }
+ y_absl::string_view suffix) {
+ return y_absl::StrCat(descriptor->name(), suffix, ".java.pb.meta");
}
// Get the unqualified name that should be used for a field's field
@@ -233,28 +212,30 @@ enum JavaType {
JavaType GetJavaType(const FieldDescriptor* field);
-const char* PrimitiveTypeName(JavaType type);
+y_absl::string_view PrimitiveTypeName(JavaType type);
// Get the fully-qualified class name for a boxed primitive type, e.g.
// "java.lang.Integer" for JAVATYPE_INT. Returns NULL for enum and message
// types.
-const char* BoxedPrimitiveTypeName(JavaType type);
+y_absl::string_view BoxedPrimitiveTypeName(JavaType type);
// Kotlin source does not distinguish between primitives and non-primitives,
// but does use Kotlin-specific qualified types for them.
-const char* KotlinTypeName(JavaType type);
+y_absl::string_view KotlinTypeName(JavaType type);
// Get the name of the java enum constant representing this type. E.g.,
// "INT32" for FieldDescriptor::TYPE_INT32. The enum constant's full
// name is "com.google.protobuf.WireFormat.FieldType.INT32".
-const char* FieldTypeName(const FieldDescriptor::Type field_type);
+y_absl::string_view FieldTypeName(const FieldDescriptor::Type field_type);
class ClassNameResolver;
TProtoStringType DefaultValue(const FieldDescriptor* field, bool immutable,
- ClassNameResolver* name_resolver);
+ ClassNameResolver* name_resolver,
+ Options options = {});
inline TProtoStringType ImmutableDefaultValue(const FieldDescriptor* field,
- ClassNameResolver* name_resolver) {
- return DefaultValue(field, true, name_resolver);
+ ClassNameResolver* name_resolver,
+ Options options = {}) {
+ return DefaultValue(field, true, name_resolver, options);
}
bool IsDefaultValueJavaDefault(const FieldDescriptor* field);
bool IsByteStringWithCustomDefaultValue(const FieldDescriptor* field);
@@ -333,7 +314,8 @@ bool IsReferenceType(JavaType type);
// Returns the capitalized name for calling relative functions in
// CodedInputStream
-const char* GetCapitalizedType(const FieldDescriptor* field, bool immutable);
+y_absl::string_view GetCapitalizedType(const FieldDescriptor* field,
+ bool immutable, Options options);
// For encodings with fixed sizes, returns that size in bytes. Otherwise
// returns -1.
@@ -471,4 +453,5 @@ std::pair<int, int> GetTableDrivenNumberOfEntriesAndLookUpStartFieldNumber(
} // namespace protobuf
} // namespace google
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_HELPERS_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/kotlin_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/kotlin_generator.cc
index 570840cfc13..90235f6cb8e 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/kotlin_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/kotlin_generator.cc
@@ -28,13 +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.
-#include <google/protobuf/compiler/java/kotlin_generator.h>
+#include "google/protobuf/compiler/java/kotlin_generator.h"
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/compiler/java/file.h>
-#include <google/protobuf/compiler/java/generator.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/options.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/compiler/java/file.h"
+#include "google/protobuf/compiler/java/generator.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/options.h"
namespace google {
namespace protobuf {
@@ -78,7 +78,7 @@ bool KotlinGenerator::Generate(const FileDescriptor* file,
} else if (option.first == "annotation_list_file") {
file_options.annotation_list_file = option.second;
} else {
- *error = "Unknown generator option: " + option.first;
+ *error = y_absl::StrCat("Unknown generator option: ", option.first);
return false;
}
}
@@ -101,11 +101,10 @@ bool KotlinGenerator::Generate(const FileDescriptor* file,
return std::unique_ptr<io::ZeroCopyOutputStream>(context->Open(filename));
};
TProtoStringType package_dir = JavaPackageToDir(file_generator->java_package());
- TProtoStringType kotlin_filename = package_dir;
- kotlin_filename += file_generator->GetKotlinClassname();
- kotlin_filename += ".kt";
+ TProtoStringType kotlin_filename =
+ y_absl::StrCat(package_dir, file_generator->GetKotlinClassname(), ".kt");
all_files.push_back(kotlin_filename);
- TProtoStringType info_full_path = kotlin_filename + ".pb.meta";
+ TProtoStringType info_full_path = y_absl::StrCat(kotlin_filename, ".pb.meta");
if (file_options.annotate_code) {
all_annotations.push_back(info_full_path);
}
@@ -119,6 +118,8 @@ bool KotlinGenerator::Generate(const FileDescriptor* file,
output.get(), '$',
file_options.annotate_code ? &annotation_collector : nullptr);
+ file_generator->GenerateKotlin(&printer);
+
file_generator->GenerateKotlinSiblings(package_dir, context, &all_files,
&all_annotations);
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/kotlin_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/kotlin_generator.h
index 195acb65375..91c4b836c55 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/kotlin_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/kotlin_generator.h
@@ -35,10 +35,10 @@
#include <string>
-#include <google/protobuf/compiler/code_generator.h>
+#include "google/protobuf/compiler/code_generator.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -52,6 +52,8 @@ namespace java {
class PROTOC_EXPORT KotlinGenerator : public CodeGenerator {
public:
KotlinGenerator();
+ KotlinGenerator(const KotlinGenerator&) = delete;
+ KotlinGenerator& operator=(const KotlinGenerator&) = delete;
~KotlinGenerator() override;
// implements CodeGenerator ----------------------------------------
@@ -59,9 +61,6 @@ class PROTOC_EXPORT KotlinGenerator : public CodeGenerator {
GeneratorContext* context, TProtoStringType* error) const override;
uint64_t GetSupportedFeatures() const override;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(KotlinGenerator);
};
} // namespace java
@@ -69,6 +68,6 @@ class PROTOC_EXPORT KotlinGenerator : public CodeGenerator {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_KOTLIN_GENERATOR_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/map_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/map_field.cc
index 37bad491c06..8c3be3c0966 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/map_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/map_field.cc
@@ -28,16 +28,17 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <google/protobuf/compiler/java/map_field.h>
+#include "google/protobuf/compiler/java/map_field.h"
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/compiler/java/context.h>
-#include <google/protobuf/compiler/java/doc_comment.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/name_resolver.h>
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/java/context.h"
+#include "google/protobuf/compiler/java/doc_comment.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/name_resolver.h"
+#include "google/protobuf/io/printer.h"
// Must be last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -47,16 +48,16 @@ namespace java {
namespace {
const FieldDescriptor* KeyField(const FieldDescriptor* descriptor) {
- GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());
+ Y_ABSL_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());
const Descriptor* message = descriptor->message_type();
- GOOGLE_CHECK(message->options().map_entry());
+ Y_ABSL_CHECK(message->options().map_entry());
return message->map_key();
}
const FieldDescriptor* ValueField(const FieldDescriptor* descriptor) {
- GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());
+ Y_ABSL_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());
const Descriptor* message = descriptor->message_type();
- GOOGLE_CHECK(message->options().map_entry());
+ Y_ABSL_CHECK(message->options().map_entry());
return message->map_value();
}
@@ -67,8 +68,8 @@ TProtoStringType TypeName(const FieldDescriptor* field,
} else if (GetJavaType(field) == JAVATYPE_ENUM) {
return name_resolver->GetImmutableClassName(field->enum_type());
} else {
- return boxed ? BoxedPrimitiveTypeName(GetJavaType(field))
- : PrimitiveTypeName(GetJavaType(field));
+ return TProtoStringType(boxed ? BoxedPrimitiveTypeName(GetJavaType(field))
+ : PrimitiveTypeName(GetJavaType(field)));
}
}
@@ -79,19 +80,19 @@ TProtoStringType KotlinTypeName(const FieldDescriptor* field,
} else if (GetJavaType(field) == JAVATYPE_ENUM) {
return name_resolver->GetImmutableClassName(field->enum_type());
} else {
- return KotlinTypeName(GetJavaType(field));
+ return TProtoStringType(KotlinTypeName(GetJavaType(field)));
}
}
TProtoStringType WireType(const FieldDescriptor* field) {
- return "com.google.protobuf.WireFormat.FieldType." +
- TProtoStringType(FieldTypeName(field->type()));
+ return y_absl::StrCat("com.google.protobuf.WireFormat.FieldType.",
+ FieldTypeName(field->type()));
}
-void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
- int builderBitIndex, const FieldGeneratorInfo* info,
- Context* context,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+void SetMessageVariables(
+ const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
+ const FieldGeneratorInfo* info, Context* context,
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
ClassNameResolver* name_resolver = context->GetNameResolver();
@@ -102,7 +103,12 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
const JavaType keyJavaType = GetJavaType(key);
const JavaType valueJavaType = GetJavaType(value);
- TProtoStringType pass_through_nullness = "/* nullable */\n";
+ // The code that generates the open-source version appears not to understand
+ // #else, so we have an #ifndef instead.
+ TProtoStringType pass_through_nullness =
+ context->options().opensource_runtime
+ ? "/* nullable */\n"
+ : "@com.google.protobuf.Internal.ProtoPassThroughNullness ";
(*variables)["key_type"] = TypeName(key, name_resolver, false);
TProtoStringType boxed_key_type = TypeName(key, name_resolver, true);
@@ -113,78 +119,89 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
(*variables)["short_key_type"] =
boxed_key_type.substr(boxed_key_type.rfind('.') + 1);
(*variables)["key_wire_type"] = WireType(key);
- (*variables)["key_default_value"] = DefaultValue(key, true, name_resolver);
+ (*variables)["key_default_value"] =
+ DefaultValue(key, true, name_resolver, context->options());
(*variables)["key_null_check"] =
IsReferenceType(keyJavaType)
? "if (key == null) { throw new NullPointerException(\"map key\"); }"
: "";
(*variables)["value_null_check"] =
valueJavaType != JAVATYPE_ENUM && IsReferenceType(valueJavaType)
- ? "if (value == null) {\n"
- " throw new NullPointerException(\"map value\");\n"
- "}\n"
+ ? "if (value == null) { "
+ "throw new NullPointerException(\"map value\"); }"
: "";
if (valueJavaType == JAVATYPE_ENUM) {
// We store enums as Integers internally.
(*variables)["value_type"] = "int";
+ variables->insert(
+ {"value_type_pass_through_nullness", (*variables)["value_type"]});
(*variables)["boxed_value_type"] = "java.lang.Integer";
(*variables)["value_wire_type"] = WireType(value);
(*variables)["value_default_value"] =
- DefaultValue(value, true, name_resolver) + ".getNumber()";
+ DefaultValue(value, true, name_resolver, context->options()) +
+ ".getNumber()";
(*variables)["value_enum_type"] = TypeName(value, name_resolver, false);
- (*variables)["value_enum_type_pass_through_nullness"] =
- pass_through_nullness + (*variables)["value_enum_type"];
+ variables->insert(
+ {"value_enum_type_pass_through_nullness",
+ y_absl::StrCat(pass_through_nullness, (*variables)["value_enum_type"])});
if (SupportUnknownEnumValue(descriptor->file())) {
// Map unknown values to a special UNRECOGNIZED value if supported.
- (*variables)["unrecognized_value"] =
- (*variables)["value_enum_type"] + ".UNRECOGNIZED";
+ variables->insert(
+ {"unrecognized_value",
+ y_absl::StrCat((*variables)["value_enum_type"], ".UNRECOGNIZED")});
} else {
// Map unknown values to the default value if we don't have UNRECOGNIZED.
(*variables)["unrecognized_value"] =
- DefaultValue(value, true, name_resolver);
+ DefaultValue(value, true, name_resolver, context->options());
}
} else {
(*variables)["value_type"] = TypeName(value, name_resolver, false);
- (*variables)["value_type_pass_through_nullness"] =
- (IsReferenceType(valueJavaType) ? pass_through_nullness : "") +
- (*variables)["value_type"];
+ variables->insert(
+ {"value_type_pass_through_nullness",
+ y_absl::StrCat(
+ (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"] =
- DefaultValue(value, true, name_resolver);
+ DefaultValue(value, true, name_resolver, context->options());
}
- (*variables)["type_parameters"] =
- (*variables)["boxed_key_type"] + ", " + (*variables)["boxed_value_type"];
+ variables->insert(
+ {"type_parameters", y_absl::StrCat((*variables)["boxed_key_type"], ", ",
+ (*variables)["boxed_value_type"])});
// TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
// by the proto compiler
(*variables)["deprecation"] =
descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
- (*variables)["kt_deprecation"] =
- descriptor->options().deprecated()
- ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
- " is deprecated\") "
- : "";
+ variables->insert(
+ {"kt_deprecation",
+ descriptor->options().deprecated()
+ ? y_absl::StrCat("@kotlin.Deprecated(message = \"Field ",
+ (*variables)["name"], " is deprecated\") ")
+ : ""});
(*variables)["on_changed"] = "onChanged();";
- // For repeated fields, one bit is used for whether the array is immutable
- // in the parsing constructor.
- (*variables)["get_mutable_bit_parser"] =
- GenerateGetBitMutableLocal(builderBitIndex);
- (*variables)["set_mutable_bit_parser"] =
- GenerateSetBitMutableLocal(builderBitIndex);
-
- (*variables)["default_entry"] =
- (*variables)["capitalized_name"] + "DefaultEntryHolder.defaultEntry";
- (*variables)["map_field_parameter"] = (*variables)["default_entry"];
- (*variables)["descriptor"] =
- name_resolver->GetImmutableClassName(descriptor->file()) + ".internal_" +
- UniqueFileScopeIdentifier(descriptor->message_type()) + "_descriptor, ";
+ variables->insert(
+ {"default_entry", y_absl::StrCat((*variables)["capitalized_name"],
+ "DefaultEntryHolder.defaultEntry")});
+ variables->insert({"map_field_parameter", (*variables)["default_entry"]});
+ (*variables)["descriptor"] = y_absl::StrCat(
+ name_resolver->GetImmutableClassName(descriptor->file()), ".internal_",
+ UniqueFileScopeIdentifier(descriptor->message_type()), "_descriptor, ");
(*variables)["ver"] = GeneratedCodeVersionSuffix();
+
+ (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex);
+ (*variables)["get_has_field_bit_from_local"] =
+ GenerateGetBitFromLocal(builderBitIndex);
+ (*variables)["set_has_field_bit_builder"] =
+ y_absl::StrCat(GenerateSetBit(builderBitIndex), ";");
+ (*variables)["clear_has_field_bit_builder"] =
+ y_absl::StrCat(GenerateClearBit(builderBitIndex), ";");
}
} // namespace
@@ -192,7 +209,11 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
ImmutableMapFieldGenerator::ImmutableMapFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
Context* context)
- : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
+ : descriptor_(descriptor),
+ message_bit_index_(messageBitIndex),
+ builder_bit_index_(builderBitIndex),
+ name_resolver_(context->GetNameResolver()),
+ context_(context) {
SetMessageVariables(descriptor, messageBitIndex, builderBitIndex,
context->GetFieldGeneratorInfo(descriptor), context,
&variables_);
@@ -200,6 +221,14 @@ ImmutableMapFieldGenerator::ImmutableMapFieldGenerator(
ImmutableMapFieldGenerator::~ImmutableMapFieldGenerator() {}
+int ImmutableMapFieldGenerator::GetMessageBitIndex() const {
+ return message_bit_index_;
+}
+
+int ImmutableMapFieldGenerator::GetBuilderBitIndex() const {
+ return builder_bit_index_;
+}
+
int ImmutableMapFieldGenerator::GetNumBitsForMessage() const { return 0; }
int ImmutableMapFieldGenerator::GetNumBitsForBuilder() const { return 1; }
@@ -216,14 +245,16 @@ void ImmutableMapFieldGenerator::GenerateInterfaceMembers(
" $key_type$ key);\n");
printer->Annotate("{", "}", descriptor_);
if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
- printer->Print(variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$Map()} instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
- "${$get$capitalized_name$$}$();\n");
- printer->Annotate("{", "}", descriptor_);
+ if (context_->options().opensource_runtime) {
+ printer->Print(variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$Map()} instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
+ "${$get$capitalized_name$$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
+ }
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
@@ -261,27 +292,29 @@ void ImmutableMapFieldGenerator::GenerateInterfaceMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$deprecation$\n"
- "$value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n"
+ "$deprecation$$value_type_pass_through_nullness$ "
+ "${$get$capitalized_name$ValueOrDefault$}$(\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_,
- "$deprecation$\n"
- "$value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n"
- " $key_type$ key);\n");
+ printer->Print(
+ variables_,
+ "$deprecation$$value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n"
+ " $key_type$ key);\n");
printer->Annotate("{", "}", descriptor_);
}
} else {
- printer->Print(variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$Map()} instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "java.util.Map<$type_parameters$>\n"
- "${$get$capitalized_name$$}$();\n");
- printer->Annotate("{", "}", descriptor_);
+ if (context_->options().opensource_runtime) {
+ printer->Print(variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$Map()} instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "java.util.Map<$type_parameters$>\n"
+ "${$get$capitalized_name$$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
+ }
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$java.util.Map<$type_parameters$>\n"
@@ -289,17 +322,16 @@ void ImmutableMapFieldGenerator::GenerateInterfaceMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$deprecation$\n"
- "$value_type_pass_through_nullness$ "
+ "$deprecation$$value_type_pass_through_nullness$ "
"${$get$capitalized_name$OrDefault$}$(\n"
" $key_type$ key,\n"
" $value_type_pass_through_nullness$ defaultValue);\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$deprecation$\n"
- "$value_type$ ${$get$capitalized_name$OrThrow$}$(\n"
- " $key_type$ key);\n");
+ printer->Print(
+ variables_,
+ "$deprecation$$value_type$ ${$get$capitalized_name$OrThrow$}$(\n"
+ " $key_type$ key);\n");
printer->Annotate("{", "}", descriptor_);
}
}
@@ -319,6 +351,7 @@ void ImmutableMapFieldGenerator::GenerateMembers(io::Printer* printer) const {
" $value_default_value$);\n"
"}\n");
printer->Print(variables_,
+ "@SuppressWarnings(\"serial\")\n"
"private com.google.protobuf.MapField<\n"
" $type_parameters$> $name$_;\n"
"private com.google.protobuf.MapField<$type_parameters$>\n"
@@ -354,42 +387,45 @@ void ImmutableMapFieldGenerator::GenerateMembers(io::Printer* printer) const {
void ImmutableMapFieldGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
- printer->Print(variables_,
- "private com.google.protobuf.MapField<\n"
- " $type_parameters$> $name$_;\n"
- "private com.google.protobuf.MapField<$type_parameters$>\n"
- "internalGet$capitalized_name$() {\n"
- " if ($name$_ == null) {\n"
- " return com.google.protobuf.MapField.emptyMapField(\n"
- " $map_field_parameter$);\n"
- " }\n"
- " return $name$_;\n"
- "}\n"
- "private com.google.protobuf.MapField<$type_parameters$>\n"
- "internalGetMutable$capitalized_name$() {\n"
- " $on_changed$;\n"
- " if ($name$_ == null) {\n"
- " $name$_ = com.google.protobuf.MapField.newMapField(\n"
- " $map_field_parameter$);\n"
- " }\n"
- " if (!$name$_.isMutable()) {\n"
- " $name$_ = $name$_.copy();\n"
- " }\n"
- " return $name$_;\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "private com.google.protobuf.MapField<\n"
+ " $type_parameters$> $name$_;\n"
+ "$deprecation$private com.google.protobuf.MapField<$type_parameters$>\n"
+ " internalGet$capitalized_name$() {\n"
+ " if ($name$_ == null) {\n"
+ " return com.google.protobuf.MapField.emptyMapField(\n"
+ " $map_field_parameter$);\n"
+ " }\n"
+ " return $name$_;\n"
+ "}\n"
+ "$deprecation$private com.google.protobuf.MapField<$type_parameters$>\n"
+ " internalGetMutable$capitalized_name$() {\n"
+ " if ($name$_ == null) {\n"
+ " $name$_ = com.google.protobuf.MapField.newMapField(\n"
+ " $map_field_parameter$);\n"
+ " }\n"
+ " if (!$name$_.isMutable()) {\n"
+ " $name$_ = $name$_.copy();\n"
+ " }\n"
+ " $set_has_field_bit_builder$\n"
+ " $on_changed$\n"
+ " return $name$_;\n"
+ "}\n");
GenerateMapGetters(printer);
- printer->Print(variables_,
- "$deprecation$\n"
- "public Builder ${$clear$capitalized_name$$}$() {\n"
- " internalGetMutable$capitalized_name$().getMutableMap()\n"
- " .clear();\n"
- " return this;\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
+ " $clear_has_field_bit_builder$\n"
+ " internalGetMutable$capitalized_name$().getMutableMap()\n"
+ " .clear();\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
+
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$deprecation$\n"
- "public Builder ${$remove$capitalized_name$$}$(\n"
+ "$deprecation$public Builder ${$remove$capitalized_name$$}$(\n"
" $key_type$ key) {\n"
" $key_null_check$\n"
" internalGetMutable$capitalized_name$().getMutableMap()\n"
@@ -397,19 +433,24 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
+
if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
- printer->Print(
- variables_,
- "/**\n"
- " * Use alternate mutation accessors instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
- "${$getMutable$capitalized_name$$}$() {\n"
- " return internalGetAdapted$capitalized_name$Map(\n"
- " internalGetMutable$capitalized_name$().getMutableMap());\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
+ if (context_->options().opensource_runtime) {
+ printer->Print(
+ variables_,
+ "/**\n"
+ " * Use alternate mutation accessors instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
+ " ${$getMutable$capitalized_name$$}$() {\n"
+ " $set_has_field_bit_builder$\n"
+ " return internalGetAdapted$capitalized_name$Map(\n"
+ " internalGetMutable$capitalized_name$().getMutableMap());\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+ }
+
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$public Builder ${$put$capitalized_name$$}$(\n"
@@ -419,9 +460,11 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers(
" $value_null_check$\n"
" internalGetMutable$capitalized_name$().getMutableMap()\n"
" .put(key, $name$ValueConverter.doBackward(value));\n"
+ " $set_has_field_bit_builder$\n"
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
+
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
@@ -430,21 +473,27 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers(
" internalGetAdapted$capitalized_name$Map(\n"
" internalGetMutable$capitalized_name$().getMutableMap())\n"
" .putAll(values);\n"
+ " $set_has_field_bit_builder$\n"
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
+
if (SupportUnknownEnumValue(descriptor_->file())) {
- printer->Print(
- variables_,
- "/**\n"
- " * Use alternate mutation accessors instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
- "${$getMutable$capitalized_name$Value$}$() {\n"
- " return internalGetMutable$capitalized_name$().getMutableMap();\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
+ if (context_->options().opensource_runtime) {
+ printer->Print(
+ variables_,
+ "/**\n"
+ " * Use alternate mutation accessors instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
+ "${$getMutable$capitalized_name$Value$}$() {\n"
+ " $set_has_field_bit_builder$\n"
+ " return internalGetMutable$capitalized_name$().getMutableMap();\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+ }
+
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
@@ -455,9 +504,11 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers(
" $value_null_check$\n"
" internalGetMutable$capitalized_name$().getMutableMap()\n"
" .put(key, value);\n"
+ " $set_has_field_bit_builder$\n"
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
+
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
@@ -465,95 +516,107 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers(
" java.util.Map<$boxed_key_type$, $boxed_value_type$> values) {\n"
" internalGetMutable$capitalized_name$().getMutableMap()\n"
" .putAll(values);\n"
+ " $set_has_field_bit_builder$\n"
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
}
} else {
- printer->Print(
- variables_,
- "/**\n"
- " * Use alternate mutation accessors instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "public java.util.Map<$type_parameters$>\n"
- "${$getMutable$capitalized_name$$}$() {\n"
- " return internalGetMutable$capitalized_name$().getMutableMap();\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
+ if (context_->options().opensource_runtime) {
+ printer->Print(
+ variables_,
+ "/**\n"
+ " * Use alternate mutation accessors instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "public java.util.Map<$type_parameters$>\n"
+ " ${$getMutable$capitalized_name$$}$() {\n"
+ " $set_has_field_bit_builder$\n"
+ " return internalGetMutable$capitalized_name$().getMutableMap();\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+ }
+
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$deprecation$"
- "public Builder ${$put$capitalized_name$$}$(\n"
+ "$deprecation$public Builder ${$put$capitalized_name$$}$(\n"
" $key_type$ key,\n"
" $value_type$ value) {\n"
" $key_null_check$\n"
" $value_null_check$\n"
" internalGetMutable$capitalized_name$().getMutableMap()\n"
" .put(key, value);\n"
+ " $set_has_field_bit_builder$\n"
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
+
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$deprecation$\n"
- "public Builder ${$putAll$capitalized_name$$}$(\n"
- " java.util.Map<$type_parameters$> values) {\n"
- " internalGetMutable$capitalized_name$().getMutableMap()\n"
- " .putAll(values);\n"
- " return this;\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$putAll$capitalized_name$$}$(\n"
+ " java.util.Map<$type_parameters$> values) {\n"
+ " internalGetMutable$capitalized_name$().getMutableMap()\n"
+ " .putAll(values);\n"
+ " $set_has_field_bit_builder$\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
}
void ImmutableMapFieldGenerator::GenerateMapGetters(
io::Printer* printer) const {
- printer->Print(variables_,
- "$deprecation$\n"
- "public int ${$get$capitalized_name$Count$}$() {\n"
- " return internalGet$capitalized_name$().getMap().size();\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
+ " return internalGet$capitalized_name$().getMap().size();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
+
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "$deprecation$\n"
"@java.lang.Override\n"
- "public boolean ${$contains$capitalized_name$$}$(\n"
+ "$deprecation$public boolean ${$contains$capitalized_name$$}$(\n"
" $key_type$ key) {\n"
" $key_null_check$\n"
" return internalGet$capitalized_name$().getMap().containsKey(key);\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
+
if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
- printer->Print(variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$Map()} instead.\n"
- " */\n"
- "@java.lang.Override\n"
- "@java.lang.Deprecated\n"
- "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
- "${$get$capitalized_name$$}$() {\n"
- " return get$capitalized_name$Map();\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
+ if (context_->options().opensource_runtime) {
+ printer->Print(
+ variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$Map()} instead.\n"
+ " */\n"
+ "@java.lang.Override\n"
+ "@java.lang.Deprecated\n"
+ "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
+ "${$get$capitalized_name$$}$() {\n"
+ " return get$capitalized_name$Map();\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+ }
+
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
- "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
+ "$deprecation$public java.util.Map<$boxed_key_type$, "
+ "$value_enum_type$>\n"
"${$get$capitalized_name$Map$}$() {\n"
" return internalGetAdapted$capitalized_name$Map(\n"
" internalGet$capitalized_name$().getMap());"
"}\n");
printer->Annotate("{", "}", descriptor_);
+
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
- "public $value_enum_type_pass_through_nullness$ "
+ "$deprecation$public $value_enum_type_pass_through_nullness$ "
"${$get$capitalized_name$OrDefault$}$(\n"
" $key_type$ key,\n"
" $value_enum_type_pass_through_nullness$ defaultValue) {\n"
@@ -565,12 +628,12 @@ void ImmutableMapFieldGenerator::GenerateMapGetters(
" : defaultValue;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
+
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
- "public $value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n"
+ "$deprecation$public $value_enum_type$ get$capitalized_name$OrThrow(\n"
" $key_type$ key) {\n"
" $key_null_check$\n"
" java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
@@ -581,6 +644,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters(
" return $name$ValueConverter.doForward(map.get(key));\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
+
if (SupportUnknownEnumValue(descriptor_->file())) {
printer->Print(
variables_,
@@ -595,23 +659,22 @@ void ImmutableMapFieldGenerator::GenerateMapGetters(
"}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$\n"
- "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
- "${$get$capitalized_name$ValueMap$}$() {\n"
- " return internalGet$capitalized_name$().getMap();\n"
- "}\n");
+ printer->Print(variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public java.util.Map<$boxed_key_type$, "
+ "$boxed_value_type$>\n"
+ "${$get$capitalized_name$ValueMap$}$() {\n"
+ " return internalGet$capitalized_name$().getMap();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
- "public $value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n"
+ "$deprecation$public $value_type_pass_through_nullness$ "
+ "${$get$capitalized_name$ValueOrDefault$}$(\n"
" $key_type$ key,\n"
- " $value_type$ defaultValue) {\n"
+ " $value_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"
@@ -622,8 +685,8 @@ void ImmutableMapFieldGenerator::GenerateMapGetters(
printer->Print(
variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
- "public $value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n"
+ "$deprecation$public $value_type$ "
+ "${$get$capitalized_name$ValueOrThrow$}$(\n"
" $key_type$ key) {\n"
" $key_null_check$\n"
" java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
@@ -636,22 +699,23 @@ void ImmutableMapFieldGenerator::GenerateMapGetters(
printer->Annotate("{", "}", descriptor_);
}
} else {
- printer->Print(variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$Map()} instead.\n"
- " */\n"
- "@java.lang.Override\n"
- "@java.lang.Deprecated\n"
- "public java.util.Map<$type_parameters$> "
- "${$get$capitalized_name$$}$() {\n"
- " return get$capitalized_name$Map();\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
+ if (context_->options().opensource_runtime) {
+ printer->Print(variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$Map()} instead.\n"
+ " */\n"
+ "@java.lang.Override\n"
+ "@java.lang.Deprecated\n"
+ "public java.util.Map<$type_parameters$> "
+ "${$get$capitalized_name$$}$() {\n"
+ " return get$capitalized_name$Map();\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+ }
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
- "public java.util.Map<$type_parameters$> "
+ "$deprecation$public java.util.Map<$type_parameters$> "
"${$get$capitalized_name$Map$}$() {\n"
" return internalGet$capitalized_name$().getMap();\n"
"}\n");
@@ -660,10 +724,10 @@ void ImmutableMapFieldGenerator::GenerateMapGetters(
printer->Print(
variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
- "public $value_type$ ${$get$capitalized_name$OrDefault$}$(\n"
+ "$deprecation$public $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"
" $key_null_check$\n"
" java.util.Map<$type_parameters$> map =\n"
" internalGet$capitalized_name$().getMap();\n"
@@ -671,19 +735,19 @@ void ImmutableMapFieldGenerator::GenerateMapGetters(
"}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$\n"
- "public $value_type$ ${$get$capitalized_name$OrThrow$}$(\n"
- " $key_type$ key) {\n"
- " $key_null_check$\n"
- " java.util.Map<$type_parameters$> map =\n"
- " internalGet$capitalized_name$().getMap();\n"
- " if (!map.containsKey(key)) {\n"
- " throw new java.lang.IllegalArgumentException();\n"
- " }\n"
- " return map.get(key);\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public $value_type$ ${$get$capitalized_name$OrThrow$}$(\n"
+ " $key_type$ key) {\n"
+ " $key_null_check$\n"
+ " java.util.Map<$type_parameters$> map =\n"
+ " internalGet$capitalized_name$().getMap();\n"
+ " if (!map.containsKey(key)) {\n"
+ " throw new java.lang.IllegalArgumentException();\n"
+ " }\n"
+ " return map.get(key);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
}
@@ -698,13 +762,13 @@ void ImmutableMapFieldGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(
variables_,
- "$kt_deprecation$ val $kt_name$: "
+ "$kt_deprecation$ public val $kt_name$: "
"com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -713,57 +777,57 @@ void ImmutableMapFieldGenerator::GenerateKotlinDslMembers(
" $kt_dsl_builder$.${$get$capitalized_name$Map$}$()\n"
" )\n");
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(
variables_,
"@JvmName(\"put$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
+ "public fun com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" .put(key: $kt_key_type$, value: $kt_value_type$) {\n"
" $kt_dsl_builder$.${$put$capitalized_name$$}$(key, value)\n"
" }\n");
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"set$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslMap"
+ "public inline operator fun com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" .set(key: $kt_key_type$, value: $kt_value_type$) {\n"
" put(key, value)\n"
" }\n");
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"remove$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
+ "public fun com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" .remove(key: $kt_key_type$) {\n"
" $kt_dsl_builder$.${$remove$capitalized_name$$}$(key)\n"
" }\n");
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"putAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
+ "public fun com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" .putAll(map: kotlin.collections.Map<$kt_key_type$, $kt_value_type$>) "
"{\n"
" $kt_dsl_builder$.${$putAll$capitalized_name$$}$(map)\n"
" }\n");
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
+ "public fun com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" .clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
@@ -782,6 +846,7 @@ void ImmutableMapFieldGenerator::GenerateInitializationCode(
void ImmutableMapFieldGenerator::GenerateBuilderClearCode(
io::Printer* printer) const {
+ // No need to clear the has-bit since we clear the bitField ints all at once.
printer->Print(variables_,
"internalGetMutable$capitalized_name$().clear();\n");
}
@@ -790,38 +855,34 @@ void ImmutableMapFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
printer->Print(variables_,
"internalGetMutable$capitalized_name$().mergeFrom(\n"
- " other.internalGet$capitalized_name$());\n");
+ " other.internalGet$capitalized_name$());\n"
+ "$set_has_field_bit_builder$\n");
}
void ImmutableMapFieldGenerator::GenerateBuildingCode(
io::Printer* printer) const {
printer->Print(variables_,
- "result.$name$_ = internalGet$capitalized_name$();\n"
- "result.$name$_.makeImmutable();\n");
+ "if ($get_has_field_bit_from_local$) {\n"
+ " result.$name$_ = internalGet$capitalized_name$();\n"
+ " result.$name$_.makeImmutable();\n"
+ "}\n");
}
-void ImmutableMapFieldGenerator::GenerateParsingCode(
+void ImmutableMapFieldGenerator::GenerateBuilderParsingCode(
io::Printer* printer) const {
- printer->Print(variables_,
- "if (!$get_mutable_bit_parser$) {\n"
- " $name$_ = com.google.protobuf.MapField.newMapField(\n"
- " $map_field_parameter$);\n"
- " $set_mutable_bit_parser$;\n"
- "}\n");
if (!SupportUnknownEnumValue(descriptor_->file()) &&
GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
printer->Print(
variables_,
"com.google.protobuf.ByteString bytes = input.readBytes();\n"
"com.google.protobuf.MapEntry<$type_parameters$>\n"
- "$name$__ = $default_entry$.getParserForType().parseFrom(bytes);\n");
- printer->Print(
- variables_,
+ "$name$__ = $default_entry$.getParserForType().parseFrom(bytes);\n"
"if ($value_enum_type$.forNumber($name$__.getValue()) == null) {\n"
- " unknownFields.mergeLengthDelimitedField($number$, bytes);\n"
+ " mergeUnknownLengthDelimitedField($number$, bytes);\n"
"} else {\n"
- " $name$_.getMutableMap().put(\n"
+ " internalGetMutable$capitalized_name$().getMutableMap().put(\n"
" $name$__.getKey(), $name$__.getValue());\n"
+ " $set_has_field_bit_builder$\n"
"}\n");
} else {
printer->Print(
@@ -829,16 +890,11 @@ void ImmutableMapFieldGenerator::GenerateParsingCode(
"com.google.protobuf.MapEntry<$type_parameters$>\n"
"$name$__ = input.readMessage(\n"
" $default_entry$.getParserForType(), extensionRegistry);\n"
- "$name$_.getMutableMap().put(\n"
- " $name$__.getKey(), $name$__.getValue());\n");
+ "internalGetMutable$capitalized_name$().getMutableMap().put(\n"
+ " $name$__.getKey(), $name$__.getValue());\n"
+ "$set_has_field_bit_builder$\n");
}
}
-
-void ImmutableMapFieldGenerator::GenerateParsingDoneCode(
- io::Printer* printer) const {
- // Nothing to do here.
-}
-
void ImmutableMapFieldGenerator::GenerateSerializationCode(
io::Printer* printer) const {
printer->Print(variables_,
@@ -891,4 +947,4 @@ TProtoStringType ImmutableMapFieldGenerator::GetBoxedType() const {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/map_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/map_field.h
index fe0a4819a92..697deff15af 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/map_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/map_field.h
@@ -31,7 +31,7 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_FIELD_H__
-#include <google/protobuf/compiler/java/field.h>
+#include "google/protobuf/compiler/java/field.h"
namespace google {
namespace protobuf {
@@ -46,6 +46,8 @@ class ImmutableMapFieldGenerator : public ImmutableFieldGenerator {
~ImmutableMapFieldGenerator() override;
// implements ImmutableFieldGenerator ---------------------------------------
+ int GetMessageBitIndex() const override;
+ int GetBuilderBitIndex() const override;
int GetNumBitsForMessage() const override;
int GetNumBitsForBuilder() const override;
void GenerateInterfaceMembers(io::Printer* printer) const override;
@@ -55,8 +57,7 @@ class ImmutableMapFieldGenerator : public ImmutableFieldGenerator {
void GenerateBuilderClearCode(io::Printer* printer) const override;
void GenerateMergingCode(io::Printer* printer) const override;
void GenerateBuildingCode(io::Printer* printer) const override;
- void GenerateParsingCode(io::Printer* printer) const override;
- void GenerateParsingDoneCode(io::Printer* printer) const override;
+ void GenerateBuilderParsingCode(io::Printer* printer) const override;
void GenerateSerializationCode(io::Printer* printer) const override;
void GenerateSerializedSizeCode(io::Printer* printer) const override;
void GenerateFieldBuilderInitializationCode(
@@ -69,8 +70,11 @@ class ImmutableMapFieldGenerator : public ImmutableFieldGenerator {
private:
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ int message_bit_index_;
+ int builder_bit_index_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables_;
ClassNameResolver* name_resolver_;
+ Context* context_;
void GenerateMapGetters(io::Printer* printer) const;
};
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/map_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/map_field_lite.cc
index 807743afcfc..22f4f6daf23 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/map_field_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/map_field_lite.cc
@@ -28,18 +28,19 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <google/protobuf/compiler/java/map_field_lite.h>
+#include "google/protobuf/compiler/java/map_field_lite.h"
#include <cstdint>
+#include <string>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/compiler/java/context.h>
-#include <google/protobuf/compiler/java/doc_comment.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/name_resolver.h>
+#include "google/protobuf/compiler/java/context.h"
+#include "google/protobuf/compiler/java/doc_comment.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/name_resolver.h"
+#include "google/protobuf/io/printer.h"
// Must be last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -49,16 +50,16 @@ namespace java {
namespace {
const FieldDescriptor* KeyField(const FieldDescriptor* descriptor) {
- GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());
+ Y_ABSL_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());
const Descriptor* message = descriptor->message_type();
- GOOGLE_CHECK(message->options().map_entry());
+ Y_ABSL_CHECK(message->options().map_entry());
return message->map_key();
}
const FieldDescriptor* ValueField(const FieldDescriptor* descriptor) {
- GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());
+ Y_ABSL_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());
const Descriptor* message = descriptor->message_type();
- GOOGLE_CHECK(message->options().map_entry());
+ Y_ABSL_CHECK(message->options().map_entry());
return message->map_value();
}
@@ -69,8 +70,8 @@ TProtoStringType TypeName(const FieldDescriptor* field,
} else if (GetJavaType(field) == JAVATYPE_ENUM) {
return name_resolver->GetImmutableClassName(field->enum_type());
} else {
- return boxed ? BoxedPrimitiveTypeName(GetJavaType(field))
- : PrimitiveTypeName(GetJavaType(field));
+ return TProtoStringType(boxed ? BoxedPrimitiveTypeName(GetJavaType(field))
+ : PrimitiveTypeName(GetJavaType(field)));
}
}
@@ -81,19 +82,19 @@ TProtoStringType KotlinTypeName(const FieldDescriptor* field,
} else if (GetJavaType(field) == JAVATYPE_ENUM) {
return name_resolver->GetImmutableClassName(field->enum_type());
} else {
- return KotlinTypeName(GetJavaType(field));
+ return TProtoStringType(KotlinTypeName(GetJavaType(field)));
}
}
TProtoStringType WireType(const FieldDescriptor* field) {
- return "com.google.protobuf.WireFormat.FieldType." +
- TProtoStringType(FieldTypeName(field->type()));
+ return y_absl::StrCat("com.google.protobuf.WireFormat.FieldType.",
+ FieldTypeName(field->type()));
}
-void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
- int builderBitIndex, const FieldGeneratorInfo* info,
- Context* context,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+void SetMessageVariables(
+ const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
+ const FieldGeneratorInfo* info, Context* context,
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
ClassNameResolver* name_resolver = context->GetNameResolver();
@@ -104,14 +105,18 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
const JavaType keyJavaType = GetJavaType(key);
const JavaType valueJavaType = GetJavaType(value);
- TProtoStringType pass_through_nullness = "/* nullable */\n";
+ TProtoStringType pass_through_nullness =
+ context->options().opensource_runtime
+ ? "/* nullable */\n"
+ : "@com.google.protobuf.Internal.ProtoPassThroughNullness ";
(*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);
(*variables)["kt_value_type"] = KotlinTypeName(value, name_resolver);
(*variables)["key_wire_type"] = WireType(key);
- (*variables)["key_default_value"] = DefaultValue(key, true, name_resolver);
+ (*variables)["key_default_value"] =
+ DefaultValue(key, true, name_resolver, context->options());
// We use `x.getClass()` as a null check because it generates less bytecode
// than an `if (x == null) { throw ... }` statement.
(*variables)["key_null_check"] =
@@ -126,51 +131,63 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
if (GetJavaType(value) == JAVATYPE_ENUM) {
// We store enums as Integers internally.
(*variables)["value_type"] = "int";
+ (*variables)["value_type_pass_through_nullness"] = "int";
(*variables)["boxed_value_type"] = "java.lang.Integer";
(*variables)["value_wire_type"] = WireType(value);
(*variables)["value_default_value"] =
- DefaultValue(value, true, name_resolver) + ".getNumber()";
+ DefaultValue(value, true, name_resolver, context->options()) +
+ ".getNumber()";
(*variables)["value_enum_type"] = TypeName(value, name_resolver, false);
- (*variables)["value_enum_type_pass_through_nullness"] =
- pass_through_nullness + (*variables)["value_enum_type"];
+ variables->insert(
+ {"value_enum_type_pass_through_nullness",
+ y_absl::StrCat(pass_through_nullness, (*variables)["value_enum_type"])});
if (SupportUnknownEnumValue(descriptor->file())) {
// Map unknown values to a special UNRECOGNIZED value if supported.
- (*variables)["unrecognized_value"] =
- (*variables)["value_enum_type"] + ".UNRECOGNIZED";
+ variables->insert(
+ {"unrecognized_value",
+ y_absl::StrCat((*variables)["value_enum_type"], ".UNRECOGNIZED")});
} else {
// Map unknown values to the default value if we don't have UNRECOGNIZED.
(*variables)["unrecognized_value"] =
- DefaultValue(value, true, name_resolver);
+ DefaultValue(value, true, name_resolver, context->options());
}
} else {
(*variables)["value_type"] = TypeName(value, name_resolver, false);
- (*variables)["value_type_pass_through_nullness"] =
- (IsReferenceType(valueJavaType) ? pass_through_nullness : "") +
- (*variables)["value_type"];
+ variables->insert(
+ {"value_type_pass_through_nullness",
+ y_absl::StrCat(
+ (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"] =
- DefaultValue(value, true, name_resolver);
+ DefaultValue(value, true, name_resolver, context->options());
}
- (*variables)["type_parameters"] =
- (*variables)["boxed_key_type"] + ", " + (*variables)["boxed_value_type"];
+ variables->insert(
+ {"type_parameters", y_absl::StrCat((*variables)["boxed_key_type"], ", ",
+ (*variables)["boxed_value_type"])});
// TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
// by the proto compiler
(*variables)["deprecation"] =
descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
- (*variables)["kt_deprecation"] =
- descriptor->options().deprecated()
- ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
- " is deprecated\") "
- : "";
-
- (*variables)["default_entry"] =
- (*variables)["capitalized_name"] + "DefaultEntryHolder.defaultEntry";
+ variables->insert(
+ {"kt_deprecation",
+ descriptor->options().deprecated()
+ ? y_absl::StrCat("@kotlin.Deprecated(message = \"Field ",
+ (*variables)["name"], " is deprecated\") ")
+ : ""});
+
+ variables->insert(
+ {"default_entry", y_absl::StrCat((*variables)["capitalized_name"],
+ "DefaultEntryHolder.defaultEntry")});
+ // { and } variables are used as delimiters when emitting annotations.
+ (*variables)["{"] = "";
+ (*variables)["}"] = "";
}
} // namespace
@@ -201,14 +218,16 @@ void ImmutableMapFieldLiteGenerator::GenerateInterfaceMembers(
" $key_type$ key);\n");
printer->Annotate("{", "}", descriptor_);
if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
- printer->Print(variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$Map()} instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
- "${$get$capitalized_name$$}$();\n");
- printer->Annotate("{", "}", descriptor_);
+ if (context_->options().opensource_runtime) {
+ printer->Print(variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$Map()} instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
+ "${$get$capitalized_name$$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
+ }
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
@@ -247,9 +266,10 @@ void ImmutableMapFieldLiteGenerator::GenerateInterfaceMembers(
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$\n"
- "$value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n"
+ "$value_type_pass_through_nullness$ "
+ "${$get$capitalized_name$ValueOrDefault$}$(\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_,
@@ -259,14 +279,16 @@ void ImmutableMapFieldLiteGenerator::GenerateInterfaceMembers(
printer->Annotate("{", "}", descriptor_);
}
} else {
- printer->Print(variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$Map()} instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "java.util.Map<$type_parameters$>\n"
- "${$get$capitalized_name$$}$();\n");
- printer->Annotate("{", "}", descriptor_);
+ if (context_->options().opensource_runtime) {
+ printer->Print(variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$Map()} instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "java.util.Map<$type_parameters$>\n"
+ "${$get$capitalized_name$$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
+ }
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$java.util.Map<$type_parameters$>\n"
@@ -303,6 +325,12 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
" $value_wire_type$,\n"
" $value_default_value$);\n"
"}\n");
+ if (!context_->options().opensource_runtime) {
+ printer->Print(variables_,
+ "@com.google.protobuf.ProtoField(\n"
+ " fieldNumber=$number$,\n"
+ " type=com.google.protobuf.FieldType.MAP)\n");
+ }
printer->Print(variables_,
"private com.google.protobuf.MapFieldLite<\n"
" $type_parameters$> $name$_ =\n"
@@ -344,16 +372,19 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
" com.google.protobuf.Internal.MapAdapter.newEnumConverter(\n"
" $value_enum_type$.internalGetValueMap(),\n"
" $unrecognized_value$);\n");
- printer->Print(variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$Map()} instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
- "${$get$capitalized_name$$}$() {\n"
- " return get$capitalized_name$Map();\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
+ if (context_->options().opensource_runtime) {
+ printer->Print(
+ variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$Map()} instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
+ "${$get$capitalized_name$$}$() {\n"
+ " return get$capitalized_name$Map();\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+ }
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
@@ -373,9 +404,10 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
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$();\n"
@@ -429,9 +461,10 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
variables_,
"@java.lang.Override\n"
"$deprecation$\n"
- "public $value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n"
+ "public $value_type_pass_through_nullness$ "
+ "${$get$capitalized_name$ValueOrDefault$}$(\n"
" $key_type$ key,\n"
- " $value_type$ defaultValue) {\n"
+ " $value_type_pass_through_nullness$ defaultValue) {\n"
" $key_null_check$\n"
" java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
" internalGet$capitalized_name$();\n"
@@ -456,17 +489,19 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
printer->Annotate("{", "}", descriptor_);
}
} else {
- printer->Print(variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$Map()} instead.\n"
- " */\n"
- "@java.lang.Override\n"
- "@java.lang.Deprecated\n"
- "public java.util.Map<$type_parameters$> "
- "${$get$capitalized_name$$}$() {\n"
- " return get$capitalized_name$Map();\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
+ if (context_->options().opensource_runtime) {
+ printer->Print(variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$Map()} instead.\n"
+ " */\n"
+ "@java.lang.Override\n"
+ "@java.lang.Deprecated\n"
+ "public java.util.Map<$type_parameters$> "
+ "${$get$capitalized_name$$}$() {\n"
+ " return get$capitalized_name$Map();\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+ }
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"@java.lang.Override\n"
@@ -482,9 +517,10 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
variables_,
"@java.lang.Override\n"
"$deprecation$\n"
- "public $value_type$ ${$get$capitalized_name$OrDefault$}$(\n"
+ "public $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"
" $key_null_check$\n"
" java.util.Map<$type_parameters$> map =\n"
" internalGet$capitalized_name$();\n"
@@ -596,16 +632,19 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
"}\n");
printer->Annotate("{", "}", descriptor_);
if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
- printer->Print(variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$Map()} instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
- "${$get$capitalized_name$$}$() {\n"
- " return get$capitalized_name$Map();\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
+ if (context_->options().opensource_runtime) {
+ printer->Print(
+ variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$Map()} instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
+ "${$get$capitalized_name$$}$() {\n"
+ " return get$capitalized_name$Map();\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+ }
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"@java.lang.Override\n"
@@ -701,9 +740,10 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
variables_,
"@java.lang.Override\n"
"$deprecation$\n"
- "public $value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n"
+ "public $value_type_pass_through_nullness$ "
+ "${$get$capitalized_name$ValueOrDefault$}$(\n"
" $key_type$ key,\n"
- " $value_type$ defaultValue) {\n"
+ " $value_type_pass_through_nullness$ defaultValue) {\n"
" $key_null_check$\n"
" java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
" instance.get$capitalized_name$ValueMap();\n"
@@ -750,17 +790,19 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
}
} else {
- printer->Print(variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$Map()} instead.\n"
- " */\n"
- "@java.lang.Override\n"
- "@java.lang.Deprecated\n"
- "public java.util.Map<$type_parameters$> "
- "${$get$capitalized_name$$}$() {\n"
- " return get$capitalized_name$Map();\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
+ if (context_->options().opensource_runtime) {
+ printer->Print(variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$Map()} instead.\n"
+ " */\n"
+ "@java.lang.Override\n"
+ "@java.lang.Deprecated\n"
+ "public java.util.Map<$type_parameters$> "
+ "${$get$capitalized_name$$}$() {\n"
+ " return get$capitalized_name$Map();\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+ }
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"@java.lang.Override\n"
@@ -776,9 +818,10 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
variables_,
"@java.lang.Override\n"
"$deprecation$\n"
- "public $value_type$ ${$get$capitalized_name$OrDefault$}$(\n"
+ "public $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"
" $key_null_check$\n"
" java.util.Map<$type_parameters$> map =\n"
" instance.get$capitalized_name$Map();\n"
@@ -838,13 +881,13 @@ void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(
variables_,
- "$kt_deprecation$ val $kt_name$: "
+ "$kt_deprecation$ public val $kt_name$: "
"com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -853,57 +896,57 @@ void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers(
" $kt_dsl_builder$.${$get$capitalized_name$Map$}$()\n"
" )\n");
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(
variables_,
"@JvmName(\"put$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
+ "public fun com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" .put(key: $kt_key_type$, value: $kt_value_type$) {\n"
" $kt_dsl_builder$.${$put$capitalized_name$$}$(key, value)\n"
" }\n");
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"set$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslMap"
+ "public inline operator fun com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" .set(key: $kt_key_type$, value: $kt_value_type$) {\n"
" put(key, value)\n"
" }\n");
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"remove$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
+ "public fun com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" .remove(key: $kt_key_type$) {\n"
" $kt_dsl_builder$.${$remove$capitalized_name$$}$(key)\n"
" }\n");
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"putAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
+ "public fun com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" .putAll(map: kotlin.collections.Map<$kt_key_type$, $kt_value_type$>) "
"{\n"
" $kt_dsl_builder$.${$putAll$capitalized_name$$}$(map)\n"
" }\n");
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
+ "public fun com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" .clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
@@ -924,4 +967,4 @@ TProtoStringType ImmutableMapFieldLiteGenerator::GetBoxedType() const {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/map_field_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/map_field_lite.h
index de2cc510575..4f5fb4d4ac8 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/map_field_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/map_field_lite.h
@@ -33,7 +33,7 @@
#include <cstdint>
-#include <google/protobuf/compiler/java/field.h>
+#include "google/protobuf/compiler/java/field.h"
namespace google {
namespace protobuf {
@@ -61,7 +61,7 @@ class ImmutableMapFieldLiteGenerator : public ImmutableFieldLiteGenerator {
private:
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables_;
Context* context_;
ClassNameResolver* name_resolver_;
};
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/message.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/message.cc
index bcd437821f3..e3a5e5e03dd 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/message.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message.cc
@@ -32,32 +32,34 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/message.h>
+#include "google/protobuf/compiler/java/message.h"
#include <algorithm>
#include <cstdint>
-#include <map>
#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/context.h>
-#include <google/protobuf/compiler/java/doc_comment.h>
-#include <google/protobuf/compiler/java/enum.h>
-#include <google/protobuf/compiler/java/extension.h>
-#include <google/protobuf/compiler/java/generator_factory.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/message_builder.h>
-#include <google/protobuf/compiler/java/message_builder_lite.h>
-#include <google/protobuf/compiler/java/name_resolver.h>
-#include <google/protobuf/descriptor.pb.h>
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/substitute.h"
+#include "google/protobuf/compiler/java/context.h"
+#include "google/protobuf/compiler/java/doc_comment.h"
+#include "google/protobuf/compiler/java/enum.h"
+#include "google/protobuf/compiler/java/extension.h"
+#include "google/protobuf/compiler/java/generator_factory.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/message_builder.h"
+#include "google/protobuf/compiler/java/message_builder_lite.h"
+#include "google/protobuf/compiler/java/message_serialization.h"
+#include "google/protobuf/compiler/java/name_resolver.h"
+#include "google/protobuf/descriptor.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"
// Must be last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -71,7 +73,7 @@ namespace {
TProtoStringType MapValueImmutableClassdName(const Descriptor* descriptor,
ClassNameResolver* name_resolver) {
const FieldDescriptor* value_field = descriptor->map_value();
- GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, value_field->type());
+ Y_ABSL_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, value_field->type());
return name_resolver->GetImmutableClassName(value_field->message_type());
}
} // namespace
@@ -82,7 +84,8 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor)
: descriptor_(descriptor) {
for (int i = 0; i < descriptor_->field_count(); i++) {
if (IsRealOneof(descriptor_->field(i))) {
- oneofs_.insert(descriptor_->field(i)->containing_oneof());
+ const OneofDescriptor* oneof = descriptor_->field(i)->containing_oneof();
+ Y_ABSL_CHECK(oneofs_.emplace(oneof->index(), oneof).first->second == oneof);
}
}
}
@@ -96,7 +99,7 @@ ImmutableMessageGenerator::ImmutableMessageGenerator(
context_(context),
name_resolver_(context->GetNameResolver()),
field_generators_(descriptor, context_) {
- GOOGLE_CHECK(HasDescriptorMethods(descriptor->file(), context->EnforceLite()))
+ Y_ABSL_CHECK(HasDescriptorMethods(descriptor->file(), context->EnforceLite()))
<< "Generator factory error: A non-lite message generator is used to "
"generate lite messages.";
}
@@ -112,9 +115,9 @@ void ImmutableMessageGenerator::GenerateStaticVariables(
// the outermost class in the file. This way, they will be initialized in
// a deterministic order.
- std::map<TProtoStringType, TProtoStringType> vars;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
vars["identifier"] = UniqueFileScopeIdentifier(descriptor_);
- vars["index"] = StrCat(descriptor_->index());
+ vars["index"] = y_absl::StrCat(descriptor_->index());
vars["classname"] = name_resolver_->GetImmutableClassName(descriptor_);
if (descriptor_->containing_type() != NULL) {
vars["parent"] = UniqueFileScopeIdentifier(descriptor_->containing_type());
@@ -156,9 +159,9 @@ void ImmutableMessageGenerator::GenerateStaticVariables(
int ImmutableMessageGenerator::GenerateStaticVariableInitializers(
io::Printer* printer) {
int bytecode_estimate = 0;
- std::map<TProtoStringType, TProtoStringType> vars;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
vars["identifier"] = UniqueFileScopeIdentifier(descriptor_);
- vars["index"] = StrCat(descriptor_->index());
+ vars["index"] = y_absl::StrCat(descriptor_->index());
vars["classname"] = name_resolver_->GetImmutableClassName(descriptor_);
if (descriptor_->containing_type() != NULL) {
vars["parent"] = UniqueFileScopeIdentifier(descriptor_->containing_type());
@@ -193,7 +196,7 @@ int ImmutableMessageGenerator::GenerateStaticVariableInitializers(
void ImmutableMessageGenerator::GenerateFieldAccessorTable(
io::Printer* printer, int* bytecode_estimate) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
vars["identifier"] = UniqueFileScopeIdentifier(descriptor_);
if (MultipleJavaFiles(descriptor_->file(), /* immutable = */ true)) {
// We can only make these package-private since the classes that use them
@@ -260,6 +263,9 @@ int ImmutableMessageGenerator::GenerateFieldAccessorTableInitializer(
void ImmutableMessageGenerator::GenerateInterface(io::Printer* printer) {
MaybePrintGeneratedAnnotation(context_, printer, descriptor_,
/* immutable = */ true, "OrBuilder");
+ if (!context_->options().opensource_runtime) {
+ printer->Print("@com.google.protobuf.Internal.ProtoNonnullApi\n");
+ }
if (descriptor_->extension_range_count() > 0) {
printer->Print(
"$deprecation$public interface ${$$classname$OrBuilder$}$ extends\n"
@@ -289,13 +295,14 @@ void ImmutableMessageGenerator::GenerateInterface(io::Printer* printer) {
field_generators_.get(descriptor_->field(i))
.GenerateInterfaceMembers(printer);
}
- for (auto oneof : oneofs_) {
+ for (auto& kv : oneofs_) {
printer->Print(
"\n"
- "public $classname$.$oneof_capitalized_name$Case "
+ "$classname$.$oneof_capitalized_name$Case "
"get$oneof_capitalized_name$Case();\n",
"oneof_capitalized_name",
- context_->GetOneofGeneratorInfo(oneof)->capitalized_name, "classname",
+ context_->GetOneofGeneratorInfo(kv.second)->capitalized_name,
+ "classname",
context_->GetNameResolver()->GetImmutableClassName(descriptor_));
}
printer->Outdent();
@@ -308,7 +315,7 @@ void ImmutableMessageGenerator::GenerateInterface(io::Printer* printer) {
void ImmutableMessageGenerator::Generate(io::Printer* printer) {
bool is_own_file = IsOwnFile(descriptor_, /* immutable = */ true);
- std::map<TProtoStringType, TProtoStringType> variables;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables;
variables["static"] = is_own_file ? "" : "static ";
variables["classname"] = descriptor_->name();
variables["extra_interfaces"] = ExtraMessageInterfaces(descriptor_);
@@ -319,6 +326,10 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
WriteMessageDocComment(printer, descriptor_);
MaybePrintGeneratedAnnotation(context_, printer, descriptor_,
/* immutable = */ true);
+ if (!context_->options().opensource_runtime) {
+ printer->Print("@com.google.protobuf.Internal.ProtoNonnullApi\n");
+ }
+
// The builder_type stores the super type name of the nested Builder class.
TProtoStringType builder_type;
if (descriptor_->extension_range_count() > 0) {
@@ -332,7 +343,7 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
" $classname$> implements\n"
" $extra_interfaces$\n"
" $classname$OrBuilder {\n");
- builder_type = strings::Substitute(
+ builder_type = y_absl::Substitute(
"com.google.protobuf.GeneratedMessage$1.ExtendableBuilder<$0, ?>",
name_resolver_->GetImmutableClassName(descriptor_),
GeneratedCodeVersionSuffix());
@@ -346,7 +357,7 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
" $extra_interfaces$\n"
" $classname$OrBuilder {\n");
builder_type =
- strings::Substitute("com.google.protobuf.GeneratedMessage$0.Builder<?>",
+ y_absl::Substitute("com.google.protobuf.GeneratedMessage$0.Builder<?>",
GeneratedCodeVersionSuffix());
}
printer->Print("private static final long serialVersionUID = 0L;\n");
@@ -379,17 +390,6 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
"}\n"
"\n");
- printer->Print(
- "@java.lang.Override\n"
- "public final com.google.protobuf.UnknownFieldSet\n"
- "getUnknownFields() {\n"
- " return this.unknownFields;\n"
- "}\n");
-
- if (context_->HasGeneratedMethods(descriptor_)) {
- GenerateParsingConstructor(printer);
- }
-
GenerateDescriptorMethods(printer);
// Nested types
@@ -419,59 +419,69 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
}
// oneof
- std::map<TProtoStringType, TProtoStringType> vars;
- for (auto oneof : oneofs_) {
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
+ for (auto& kv : oneofs_) {
+ const OneofDescriptor* oneof = kv.second;
vars["oneof_name"] = context_->GetOneofGeneratorInfo(oneof)->name;
vars["oneof_capitalized_name"] =
context_->GetOneofGeneratorInfo(oneof)->capitalized_name;
- vars["oneof_index"] = StrCat((oneof)->index());
+ vars["oneof_index"] = y_absl::StrCat((oneof)->index());
+ vars["{"] = "";
+ vars["}"] = "";
// oneofCase_ and oneof_
printer->Print(vars,
"private int $oneof_name$Case_ = 0;\n"
+ "@SuppressWarnings(\"serial\")\n"
"private java.lang.Object $oneof_name$_;\n");
// OneofCase enum
printer->Print(
vars,
- "public enum $oneof_capitalized_name$Case\n"
+ "public enum ${$$oneof_capitalized_name$Case$}$\n"
// TODO(dweis): Remove EnumLite when we want to break compatibility with
// 3.x users
" implements com.google.protobuf.Internal.EnumLite,\n"
" com.google.protobuf.AbstractMessage.InternalOneOfEnum {\n");
+ printer->Annotate("{", "}", oneof);
printer->Indent();
for (int j = 0; j < (oneof)->field_count(); j++) {
const FieldDescriptor* field = (oneof)->field(j);
printer->Print(
"$deprecation$$field_name$($field_number$),\n", "deprecation",
field->options().deprecated() ? "@java.lang.Deprecated " : "",
- "field_name", ToUpper(field->name()), "field_number",
- StrCat(field->number()));
+ "field_name", y_absl::AsciiStrToUpper(field->name()), "field_number",
+ y_absl::StrCat(field->number()));
+ printer->Annotate("field_name", field);
}
printer->Print("$cap_oneof_name$_NOT_SET(0);\n", "cap_oneof_name",
- ToUpper(vars["oneof_name"]));
+ y_absl::AsciiStrToUpper(vars["oneof_name"]));
printer->Print(vars,
"private final int value;\n"
"private $oneof_capitalized_name$Case(int value) {\n"
" this.value = value;\n"
"}\n");
+ if (context_->options().opensource_runtime) {
+ printer->Print(
+ vars,
+ "/**\n"
+ " * @param value The number of the enum to look for.\n"
+ " * @return The enum associated with the given number.\n"
+ " * @deprecated Use {@link #forNumber(int)} instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "public static $oneof_capitalized_name$Case valueOf(int value) {\n"
+ " return forNumber(value);\n"
+ "}\n"
+ "\n");
+ }
printer->Print(
vars,
- "/**\n"
- " * @param value The number of the enum to look for.\n"
- " * @return The enum associated with the given number.\n"
- " * @deprecated Use {@link #forNumber(int)} instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "public static $oneof_capitalized_name$Case valueOf(int value) {\n"
- " return forNumber(value);\n"
- "}\n"
- "\n"
"public static $oneof_capitalized_name$Case forNumber(int value) {\n"
" switch (value) {\n");
for (int j = 0; j < (oneof)->field_count(); j++) {
const FieldDescriptor* field = (oneof)->field(j);
printer->Print(" case $field_number$: return $field_name$;\n",
- "field_number", StrCat(field->number()),
- "field_name", ToUpper(field->name()));
+ "field_number", y_absl::StrCat(field->number()),
+ "field_name", y_absl::AsciiStrToUpper(field->name()));
}
printer->Print(
" case 0: return $cap_oneof_name$_NOT_SET;\n"
@@ -481,17 +491,18 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
"public int getNumber() {\n"
" return this.value;\n"
"}\n",
- "cap_oneof_name", ToUpper(vars["oneof_name"]));
+ "cap_oneof_name", y_absl::AsciiStrToUpper(vars["oneof_name"]));
printer->Outdent();
printer->Print("};\n\n");
// oneofCase()
printer->Print(vars,
"public $oneof_capitalized_name$Case\n"
- "get$oneof_capitalized_name$Case() {\n"
+ "${$get$oneof_capitalized_name$Case$}$() {\n"
" return $oneof_capitalized_name$Case.forNumber(\n"
" $oneof_name$Case_);\n"
"}\n"
"\n");
+ printer->Annotate("{", "}", oneof);
}
if (IsAnyMessage(descriptor_)) {
@@ -502,7 +513,7 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
for (int i = 0; i < descriptor_->field_count(); i++) {
printer->Print("public static final int $constant_name$ = $number$;\n",
"constant_name", FieldConstantName(descriptor_->field(i)),
- "number", StrCat(descriptor_->field(i)->number()));
+ "number", y_absl::StrCat(descriptor_->field(i)->number()));
printer->Annotate("constant_name", descriptor_->field(i));
field_generators_.get(descriptor_->field(i)).GenerateMembers(printer);
printer->Print("\n");
@@ -582,13 +593,6 @@ void ImmutableMessageGenerator::GenerateMessageSerializationMethods(
std::unique_ptr<const FieldDescriptor*[]> sorted_fields(
SortFieldsByNumber(descriptor_));
- 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(),
- ExtensionRangeOrdering());
printer->Print(
"@java.lang.Override\n"
"public void writeTo(com.google.protobuf.CodedOutputStream output)\n"
@@ -623,24 +627,13 @@ void ImmutableMessageGenerator::GenerateMessageSerializationMethods(
}
}
- // Merge the fields and the extension ranges, both sorted by field number.
- for (int i = 0, j = 0;
- i < descriptor_->field_count() || j < sorted_extensions.size();) {
- if (i == descriptor_->field_count()) {
- GenerateSerializeOneExtensionRange(printer, sorted_extensions[j++]);
- } else if (j == sorted_extensions.size()) {
- GenerateSerializeOneField(printer, sorted_fields[i++]);
- } else if (sorted_fields[i]->number() < sorted_extensions[j]->start) {
- GenerateSerializeOneField(printer, sorted_fields[i++]);
- } else {
- GenerateSerializeOneExtensionRange(printer, sorted_extensions[j++]);
- }
- }
+ GenerateSerializeFieldsAndExtensions(printer, field_generators_, descriptor_,
+ sorted_fields.get());
if (descriptor_->options().message_set_wire_format()) {
- printer->Print("unknownFields.writeAsMessageSetTo(output);\n");
+ printer->Print("getUnknownFields().writeAsMessageSetTo(output);\n");
} else {
- printer->Print("unknownFields.writeTo(output);\n");
+ printer->Print("getUnknownFields().writeTo(output);\n");
}
printer->Outdent();
@@ -669,9 +662,10 @@ void ImmutableMessageGenerator::GenerateMessageSerializationMethods(
}
if (descriptor_->options().message_set_wire_format()) {
- printer->Print("size += unknownFields.getSerializedSizeAsMessageSet();\n");
+ printer->Print(
+ "size += getUnknownFields().getSerializedSizeAsMessageSet();\n");
} else {
- printer->Print("size += unknownFields.getSerializedSize();\n");
+ printer->Print("size += getUnknownFields().getSerializedSize();\n");
}
printer->Print(
@@ -765,17 +759,6 @@ void ImmutableMessageGenerator::GenerateParseFromMethods(io::Printer* printer) {
GeneratedCodeVersionSuffix());
}
-void ImmutableMessageGenerator::GenerateSerializeOneField(
- io::Printer* printer, const FieldDescriptor* field) {
- field_generators_.get(field).GenerateSerializationCode(printer);
-}
-
-void ImmutableMessageGenerator::GenerateSerializeOneExtensionRange(
- io::Printer* printer, const Descriptor::ExtensionRange* range) {
- printer->Print("extensionWriter.writeUntil($end$, output);\n", "end",
- StrCat(range->end));
-}
-
// ===================================================================
void ImmutableMessageGenerator::GenerateBuilder(io::Printer* printer) {
@@ -847,7 +830,7 @@ void ImmutableMessageGenerator::GenerateDescriptorMethods(
printer->Print(
"case $number$:\n"
" return internalGet$capitalized_name$();\n",
- "number", StrCat(field->number()), "capitalized_name",
+ "number", y_absl::StrCat(field->number()), "capitalized_name",
info->capitalized_name);
}
printer->Print(
@@ -1005,6 +988,10 @@ void ImmutableMessageGenerator::GenerateEqualsAndHashCode(
printer->Print(
"@java.lang.Override\n"
"public boolean equals(");
+ if (!context_->options().opensource_runtime) {
+ printer->Print(
+ "@com.google.protobuf.Internal.ProtoMethodAcceptsNullParameter\n");
+ }
printer->Print("final java.lang.Object obj) {\n");
printer->Indent();
printer->Print(
@@ -1012,6 +999,8 @@ void ImmutableMessageGenerator::GenerateEqualsAndHashCode(
" return true;\n"
"}\n"
"if (!(obj instanceof $classname$)) {\n"
+ // don't simply return false because mutable and immutable types
+ // can be equal
" return super.equals(obj);\n"
"}\n"
"$classname$ other = ($classname$) obj;\n"
@@ -1039,7 +1028,8 @@ void ImmutableMessageGenerator::GenerateEqualsAndHashCode(
}
// Compare oneofs.
- for (auto oneof : oneofs_) {
+ for (auto& kv : oneofs_) {
+ const OneofDescriptor* oneof = kv.second;
printer->Print(
"if (!get$oneof_capitalized_name$Case().equals("
"other.get$oneof_capitalized_name$Case())) return false;\n",
@@ -1051,7 +1041,7 @@ void ImmutableMessageGenerator::GenerateEqualsAndHashCode(
for (int j = 0; j < (oneof)->field_count(); j++) {
const FieldDescriptor* field = (oneof)->field(j);
printer->Print("case $field_number$:\n", "field_number",
- StrCat(field->number()));
+ y_absl::StrCat(field->number()));
printer->Indent();
field_generators_.get(field).GenerateEqualsCode(printer);
printer->Print("break;\n");
@@ -1068,7 +1058,8 @@ void ImmutableMessageGenerator::GenerateEqualsAndHashCode(
// false for non-canonical ordering when running in LITE_RUNTIME but it's
// the best we can do.
printer->Print(
- "if (!unknownFields.equals(other.unknownFields)) return false;\n");
+ "if (!getUnknownFields().equals(other.getUnknownFields())) return "
+ "false;\n");
if (descriptor_->extension_range_count() > 0) {
printer->Print(
"if (!getExtensionFields().equals(other.getExtensionFields()))\n"
@@ -1118,14 +1109,15 @@ void ImmutableMessageGenerator::GenerateEqualsAndHashCode(
}
// hashCode oneofs.
- for (auto oneof : oneofs_) {
+ for (auto& kv : oneofs_) {
+ const OneofDescriptor* oneof = kv.second;
printer->Print("switch ($oneof_name$Case_) {\n", "oneof_name",
context_->GetOneofGeneratorInfo(oneof)->name);
printer->Indent();
for (int j = 0; j < (oneof)->field_count(); j++) {
const FieldDescriptor* field = (oneof)->field(j);
printer->Print("case $field_number$:\n", "field_number",
- StrCat(field->number()));
+ y_absl::StrCat(field->number()));
printer->Indent();
field_generators_.get(field).GenerateHashCode(printer);
printer->Print("break;\n");
@@ -1142,7 +1134,7 @@ void ImmutableMessageGenerator::GenerateEqualsAndHashCode(
printer->Print("hash = hashFields(hash, getExtensionFields());\n");
}
- printer->Print("hash = (29 * hash) + unknownFields.hashCode();\n");
+ printer->Print("hash = (29 * hash) + getUnknownFields().hashCode();\n");
printer->Print(
"memoizedHashCode = hash;\n"
"return hash;\n");
@@ -1168,188 +1160,32 @@ void ImmutableMessageGenerator::GenerateExtensionRegistrationCode(
}
// ===================================================================
-void ImmutableMessageGenerator::GenerateParsingConstructor(
- io::Printer* printer) {
- std::unique_ptr<const FieldDescriptor*[]> sorted_fields(
- SortFieldsByNumber(descriptor_));
-
- printer->Print(
- "private $classname$(\n"
- " com.google.protobuf.CodedInputStream input,\n"
- " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
- " throws com.google.protobuf.InvalidProtocolBufferException {\n",
- "classname", descriptor_->name());
- printer->Indent();
-
- // Initialize all fields to default.
- printer->Print(
- "this();\n"
- "if (extensionRegistry == null) {\n"
- " throw new java.lang.NullPointerException();\n"
- "}\n");
-
- // Use builder bits to track mutable repeated fields.
- int totalBuilderBits = 0;
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const ImmutableFieldGenerator& field =
- field_generators_.get(descriptor_->field(i));
- totalBuilderBits += field.GetNumBitsForBuilder();
- }
- int totalBuilderInts = (totalBuilderBits + 31) / 32;
- for (int i = 0; i < totalBuilderInts; i++) {
- printer->Print("int mutable_$bit_field_name$ = 0;\n", "bit_field_name",
- GetBitFieldName(i));
- }
-
- printer->Print(
- "com.google.protobuf.UnknownFieldSet.Builder unknownFields =\n"
- " com.google.protobuf.UnknownFieldSet.newBuilder();\n");
-
- printer->Print("try {\n");
- printer->Indent();
-
- printer->Print(
- "boolean done = false;\n"
- "while (!done) {\n");
- printer->Indent();
-
- printer->Print(
- "int tag = input.readTag();\n"
- "switch (tag) {\n");
- printer->Indent();
-
- printer->Print(
- "case 0:\n" // zero signals EOF / limit reached
- " done = true;\n"
- " break;\n");
-
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = sorted_fields[i];
- arc_ui32 tag = WireFormatLite::MakeTag(
- field->number(), WireFormat::WireTypeForFieldType(field->type()));
-
- printer->Print("case $tag$: {\n", "tag",
- StrCat(static_cast<arc_i32>(tag)));
- printer->Indent();
-
- field_generators_.get(field).GenerateParsingCode(printer);
-
- printer->Outdent();
- printer->Print(
- " break;\n"
- "}\n");
-
- if (field->is_packable()) {
- // To make packed = true wire compatible, we generate parsing code from a
- // packed version of this field regardless of field->options().packed().
- arc_ui32 packed_tag = WireFormatLite::MakeTag(
- field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED);
- printer->Print("case $tag$: {\n", "tag",
- StrCat(static_cast<arc_i32>(packed_tag)));
- printer->Indent();
-
- field_generators_.get(field).GenerateParsingCodeFromPacked(printer);
-
- printer->Outdent();
- printer->Print(
- " break;\n"
- "}\n");
- }
- }
-
- printer->Print(
- "default: {\n"
- " if (!parseUnknownField(\n"
- " input, unknownFields, extensionRegistry, tag)) {\n"
- " done = true;\n" // it's an endgroup tag
- " }\n"
- " break;\n"
- "}\n");
-
- printer->Outdent();
- printer->Outdent();
- printer->Print(
- " }\n" // switch (tag)
- "}\n"); // while (!done)
-
- printer->Outdent();
- 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"
- "} finally {\n");
- printer->Indent();
-
- // Make repeated field list immutable.
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = sorted_fields[i];
- field_generators_.get(field).GenerateParsingDoneCode(printer);
- }
-
- // Make unknown fields immutable.
- printer->Print("this.unknownFields = unknownFields.build();\n");
-
- // Make extensions immutable.
- printer->Print("makeExtensionsImmutable();\n");
-
- printer->Outdent();
- printer->Outdent();
- printer->Print(
- " }\n" // finally
- "}\n");
-}
-
-// ===================================================================
void ImmutableMessageGenerator::GenerateParser(io::Printer* printer) {
printer->Print(
"$visibility$ static final com.google.protobuf.Parser<$classname$>\n"
- " PARSER = new com.google.protobuf.AbstractParser<$classname$>() {\n",
- "visibility",
- ExposePublicParser(descriptor_->file()) ? "@java.lang.Deprecated public"
- : "private",
- "classname", descriptor_->name());
- printer->Indent();
- printer->Print(
- "@java.lang.Override\n"
- "public $classname$ parsePartialFrom(\n"
- " com.google.protobuf.CodedInputStream input,\n"
- " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
- " throws com.google.protobuf.InvalidProtocolBufferException {\n",
- "classname", descriptor_->name());
- if (context_->HasGeneratedMethods(descriptor_)) {
- printer->Print(" return new $classname$(input, extensionRegistry);\n",
- "classname", descriptor_->name());
- } else {
- // When parsing constructor isn't generated, use builder to parse
- // messages. Note, will fallback to use reflection based mergeFieldFrom()
- // in AbstractMessage.Builder.
- printer->Indent();
- printer->Print(
- "Builder builder = newBuilder();\n"
- "try {\n"
- " builder.mergeFrom(input, extensionRegistry);\n"
- "} catch (com.google.protobuf.InvalidProtocolBufferException e) {\n"
- " throw e.setUnfinishedMessage(builder.buildPartial());\n"
- "} catch (java.io.IOException e) {\n"
- " throw new com.google.protobuf.InvalidProtocolBufferException(\n"
- " e.getMessage()).setUnfinishedMessage(\n"
- " builder.buildPartial());\n"
- "}\n"
- "return builder.buildPartial();\n");
- printer->Outdent();
- }
- printer->Print("}\n");
- printer->Outdent();
- printer->Print(
+ " PARSER = new com.google.protobuf.AbstractParser<$classname$>() {\n"
+ " @java.lang.Override\n"
+ " public $classname$ parsePartialFrom(\n"
+ " com.google.protobuf.CodedInputStream input,\n"
+ " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
+ " throws com.google.protobuf.InvalidProtocolBufferException {\n"
+ " Builder builder = newBuilder();\n"
+ " try {\n"
+ " builder.mergeFrom(input, extensionRegistry);\n"
+ " } catch (com.google.protobuf.InvalidProtocolBufferException e) {\n"
+ " throw e.setUnfinishedMessage(builder.buildPartial());\n"
+ " } catch (com.google.protobuf.UninitializedMessageException e) {\n"
+ " throw "
+ "e.asInvalidProtocolBufferException().setUnfinishedMessage(builder."
+ "buildPartial());\n"
+ " } catch (java.io.IOException e) {\n"
+ " throw new com.google.protobuf.InvalidProtocolBufferException(e)\n"
+ " .setUnfinishedMessage(builder.buildPartial());\n"
+ " }\n"
+ " return builder.buildPartial();\n"
+ " }\n"
"};\n"
- "\n");
-
- printer->Print(
+ "\n"
"public static com.google.protobuf.Parser<$classname$> parser() {\n"
" return PARSER;\n"
"}\n"
@@ -1359,6 +1195,9 @@ void ImmutableMessageGenerator::GenerateParser(io::Printer* printer) {
" return PARSER;\n"
"}\n"
"\n",
+ "visibility",
+ ExposePublicParser(descriptor_->file()) ? "@java.lang.Deprecated public"
+ : "private",
"classname", descriptor_->name());
}
@@ -1413,10 +1252,10 @@ void ImmutableMessageGenerator::GenerateKotlinDsl(io::Printer* printer) const {
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
"@com.google.protobuf.kotlin.ProtoDslMarker\n");
printer->Print(
- "class Dsl private constructor(\n"
+ "public class Dsl private constructor(\n"
" private val _builder: $message$.Builder\n"
") {\n"
- " companion object {\n"
+ " public companion object {\n"
" @kotlin.jvm.JvmSynthetic\n"
" @kotlin.PublishedApi\n"
" internal fun _create(builder: $message$.Builder): Dsl = "
@@ -1426,7 +1265,8 @@ void ImmutableMessageGenerator::GenerateKotlinDsl(io::Printer* printer) const {
" @kotlin.jvm.JvmSynthetic\n"
" @kotlin.PublishedApi\n"
" internal fun _build(): $message$ = _builder.build()\n",
- "message", name_resolver_->GetClassName(descriptor_, true));
+ "message",
+ EscapeKotlinKeywords(name_resolver_->GetClassName(descriptor_, true)));
printer->Indent();
@@ -1436,18 +1276,19 @@ void ImmutableMessageGenerator::GenerateKotlinDsl(io::Printer* printer) const {
.GenerateKotlinDslMembers(printer);
}
- for (auto oneof : oneofs_) {
+ for (auto& kv : oneofs_) {
+ const OneofDescriptor* oneof = kv.second;
printer->Print(
- "val $oneof_name$Case: $message$.$oneof_capitalized_name$Case\n"
+ "public val $oneof_name$Case: $message$.$oneof_capitalized_name$Case\n"
" @JvmName(\"get$oneof_capitalized_name$Case\")\n"
" get() = _builder.get$oneof_capitalized_name$Case()\n\n"
- "fun clear$oneof_capitalized_name$() {\n"
+ "public fun clear$oneof_capitalized_name$() {\n"
" _builder.clear$oneof_capitalized_name$()\n"
"}\n",
"oneof_name", context_->GetOneofGeneratorInfo(oneof)->name,
"oneof_capitalized_name",
context_->GetOneofGeneratorInfo(oneof)->capitalized_name, "message",
- name_resolver_->GetClassName(descriptor_, true));
+ EscapeKotlinKeywords(name_resolver_->GetClassName(descriptor_, true)));
}
if (descriptor_->extension_range_count() > 0) {
@@ -1460,19 +1301,27 @@ void ImmutableMessageGenerator::GenerateKotlinDsl(io::Printer* printer) const {
void ImmutableMessageGenerator::GenerateKotlinMembers(
io::Printer* printer) const {
+ printer->Print("@kotlin.jvm.JvmName(\"-initialize$camelcase_name$\")\n",
+ "camelcase_name",
+ name_resolver_->GetKotlinFactoryName(descriptor_));
+
+
printer->Print(
- "@kotlin.jvm.JvmName(\"-initialize$camelcase_name$\")\n"
- "inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> "
+ "public inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> "
"kotlin.Unit): "
"$message$ "
"=\n"
" $message_kt$.Dsl._create($message$.newBuilder()).apply { block() "
"}._build()\n",
"camelcase_name", name_resolver_->GetKotlinFactoryName(descriptor_),
- "message_kt", name_resolver_->GetKotlinExtensionsClassName(descriptor_),
- "message", name_resolver_->GetClassName(descriptor_, true));
-
- printer->Print("object $name$Kt {\n", "name", descriptor_->name());
+ "message_kt",
+ EscapeKotlinKeywords(
+ name_resolver_->GetKotlinExtensionsClassName(descriptor_)),
+ "message",
+ EscapeKotlinKeywords(name_resolver_->GetClassName(descriptor_, true)));
+
+ WriteMessageDocComment(printer, descriptor_, /* kdoc */ true);
+ printer->Print("public object $name$Kt {\n", "name", descriptor_->name());
printer->Indent();
GenerateKotlinDsl(printer);
for (int i = 0; i < descriptor_->nested_type_count(); i++) {
@@ -1486,15 +1335,19 @@ void ImmutableMessageGenerator::GenerateKotlinMembers(
void ImmutableMessageGenerator::GenerateTopLevelKotlinMembers(
io::Printer* printer) const {
+ printer->Print("@kotlin.jvm.JvmSynthetic\n");
+
+
printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "inline fun $message$.copy(block: $message_kt$.Dsl.() -> "
- "kotlin.Unit): "
- "$message$ =\n"
+ "public inline fun $message$.copy(block: $message_kt$.Dsl.() -> "
+ "kotlin.Unit): $message$ =\n"
" $message_kt$.Dsl._create(this.toBuilder()).apply { block() "
"}._build()\n\n",
- "message", name_resolver_->GetClassName(descriptor_, true), "message_kt",
- name_resolver_->GetKotlinExtensionsClassName(descriptor_));
+ "message",
+ EscapeKotlinKeywords(name_resolver_->GetClassName(descriptor_, true)),
+ "message_kt",
+ EscapeKotlinKeywords(
+ name_resolver_->GetKotlinExtensionsClassName(descriptor_)));
for (int i = 0; i < descriptor_->nested_type_count(); i++) {
if (IsMapEntry(descriptor_->nested_type(i))) continue;
@@ -1505,34 +1358,39 @@ void ImmutableMessageGenerator::GenerateTopLevelKotlinMembers(
GenerateKotlinOrNull(printer);
}
-void ImmutableMessageGenerator::GenerateKotlinOrNull(io::Printer* printer) const {
+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"
+ "public 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),
+ "full_classname",
+ EscapeKotlinKeywords(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);
+ EscapeKotlinKeywords(
+ name_resolver_->GetImmutableClassName(field->message_type())),
+ "name", context_->GetFieldGeneratorInfo(field)->capitalized_name);
}
}
}
void ImmutableMessageGenerator::GenerateKotlinExtensions(
io::Printer* printer) const {
- TProtoStringType message_name = name_resolver_->GetClassName(descriptor_, true);
+ TProtoStringType message_name =
+ EscapeKotlinKeywords(name_resolver_->GetClassName(descriptor_, true));
printer->Print(
"@Suppress(\"UNCHECKED_CAST\")\n"
"@kotlin.jvm.JvmSynthetic\n"
- "operator fun <T : kotlin.Any> 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$, "
- "List<*>>) as T\n"
+ "kotlin.collections.List<*>>) as T\n"
" } else {\n"
" _builder.getExtension(extension)\n"
" }\n"
@@ -1544,8 +1402,9 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
"@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n"
- "operator fun <E : kotlin.Any> get(\n"
- " extension: com.google.protobuf.ExtensionLite<$message$, List<E>>\n"
+ "public operator fun <E : kotlin.Any> get(\n"
+ " extension: com.google.protobuf.ExtensionLite<$message$, "
+ "kotlin.collections.List<E>>\n"
"): com.google.protobuf.kotlin.ExtensionList<E, $message$> {\n"
" return com.google.protobuf.kotlin.ExtensionList(extension, "
"_builder.getExtension(extension))\n"
@@ -1554,7 +1413,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "operator fun contains(extension: "
+ "public operator fun contains(extension: "
"com.google.protobuf.ExtensionLite<$message$, *>): "
"Boolean {\n"
" return _builder.hasExtension(extension)\n"
@@ -1563,7 +1422,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "fun clear(extension: "
+ "public fun clear(extension: "
"com.google.protobuf.ExtensionLite<$message$, *>) "
"{\n"
" _builder.clearExtension(extension)\n"
@@ -1572,8 +1431,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.PublishedApi\n"
- "internal fun <T : kotlin.Any> setExtension(extension: "
+ "public fun <T : kotlin.Any> setExtension(extension: "
"com.google.protobuf.ExtensionLite<$message$, T>, "
"value: T) {\n"
" _builder.setExtension(extension, value)\n"
@@ -1583,7 +1441,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun <T : Comparable<T>> set(\n"
+ "public inline operator fun <T : Comparable<T>> set(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, T>,\n"
" value: T\n"
") {\n"
@@ -1594,7 +1452,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun set(\n"
+ "public inline operator fun set(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, "
"com.google.protobuf.ByteString>,\n"
" value: com.google.protobuf.ByteString\n"
@@ -1606,7 +1464,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun <T : com.google.protobuf.MessageLite> set(\n"
+ "public inline operator fun <T : com.google.protobuf.MessageLite> set(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, T>,\n"
" value: T\n"
") {\n"
@@ -1616,7 +1474,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "fun <E : kotlin.Any> 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",
@@ -1625,7 +1483,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun <E : kotlin.Any> "
+ "public inline operator fun <E : kotlin.Any> "
"com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.plusAssign"
"(value: E) {\n"
@@ -1635,7 +1493,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "fun <E : kotlin.Any> 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"
@@ -1646,7 +1504,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun <E : kotlin.Any> "
+ "public inline operator fun <E : kotlin.Any> "
"com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.plusAssign(values: "
"Iterable<E>) {\n"
@@ -1656,7 +1514,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "operator fun <E : kotlin.Any> "
+ "public operator fun <E : kotlin.Any> "
"com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.set(index: Int, value: "
"E) {\n"
@@ -1667,7 +1525,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline fun com.google.protobuf.kotlin.ExtensionList<*, "
+ "public inline fun com.google.protobuf.kotlin.ExtensionList<*, "
"$message$>.clear() {\n"
" clear(extension)\n"
"}\n\n",
@@ -1722,12 +1580,19 @@ void ImmutableMessageGenerator::GenerateAnyMethods(io::Printer* printer) {
" defaultInstance.getDescriptorForType().getFullName());\n"
"}\n"
"\n"
+ "public boolean isSameTypeAs(com.google.protobuf.Message message) {\n"
+ " return getTypeNameFromTypeUrl(getTypeUrl()).equals(\n"
+ " message.getDescriptorForType().getFullName());\n"
+ "}\n"
+ "\n"
+ "@SuppressWarnings(\"serial\")\n"
"private volatile com.google.protobuf.Message cachedUnpackValue;\n"
"\n"
"@java.lang.SuppressWarnings(\"unchecked\")\n"
"public <T extends com.google.protobuf.Message> T unpack(\n"
" java.lang.Class<T> clazz)\n"
- " throws com.google.protobuf.InvalidProtocolBufferException {\n"
+ " throws com.google.protobuf.InvalidProtocolBufferException {\n");
+ printer->Print(
" boolean invalidClazz = false;\n"
" if (cachedUnpackValue != null) {\n"
" if (cachedUnpackValue.getClass() == clazz) {\n"
@@ -1745,7 +1610,30 @@ void ImmutableMessageGenerator::GenerateAnyMethods(io::Printer* printer) {
" .parseFrom(getValue());\n"
" cachedUnpackValue = result;\n"
" return result;\n"
- "}\n");
+ "}\n"
+ "\n"
+ "@java.lang.SuppressWarnings(\"unchecked\")\n"
+ "public <T extends com.google.protobuf.Message> T unpackSameTypeAs("
+ "T message)\n"
+ " throws com.google.protobuf.InvalidProtocolBufferException {\n");
+ printer->Print(
+ " boolean invalidValue = false;\n"
+ " if (cachedUnpackValue != null) {\n"
+ " if (cachedUnpackValue.getClass() == message.getClass()) {\n"
+ " return (T) cachedUnpackValue;\n"
+ " }\n"
+ " invalidValue = true;\n"
+ " }\n"
+ " if (invalidValue || !isSameTypeAs(message)) {\n"
+ " throw new com.google.protobuf.InvalidProtocolBufferException(\n"
+ " \"Type of the Any message does not match the given "
+ "exemplar.\");\n"
+ " }\n"
+ " T result = (T) message.getParserForType().parseFrom(getValue());\n"
+ " cachedUnpackValue = result;\n"
+ " return result;\n"
+ "}\n"
+ "\n");
}
} // namespace java
@@ -1753,4 +1641,4 @@ void ImmutableMessageGenerator::GenerateAnyMethods(io::Printer* printer) {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/message.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/message.h
index 2dbd0dd9bc0..37263fa628f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/message.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message.h
@@ -35,10 +35,10 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__
-#include <map>
#include <string>
-#include <google/protobuf/compiler/java/field.h>
+#include "y_absl/container/btree_map.h"
+#include "google/protobuf/compiler/java/field.h"
namespace google {
namespace protobuf {
@@ -64,6 +64,8 @@ static const int kMaxStaticSize = 1 << 15; // aka 32k
class MessageGenerator {
public:
explicit MessageGenerator(const Descriptor* descriptor);
+ MessageGenerator(const MessageGenerator&) = delete;
+ MessageGenerator& operator=(const MessageGenerator&) = delete;
virtual ~MessageGenerator();
// All static variables have to be declared at the top-level of the file
@@ -92,15 +94,15 @@ class MessageGenerator {
protected:
const Descriptor* descriptor_;
- std::set<const OneofDescriptor*> oneofs_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator);
+ y_absl::btree_map<int, const OneofDescriptor*> oneofs_;
};
class ImmutableMessageGenerator : public MessageGenerator {
public:
ImmutableMessageGenerator(const Descriptor* descriptor, Context* context);
+ ImmutableMessageGenerator(const ImmutableMessageGenerator&) = delete;
+ ImmutableMessageGenerator& operator=(const ImmutableMessageGenerator&) =
+ delete;
~ImmutableMessageGenerator() override;
void Generate(io::Printer* printer) override;
@@ -123,10 +125,6 @@ class ImmutableMessageGenerator : public MessageGenerator {
void GenerateMessageSerializationMethods(io::Printer* printer);
void GenerateParseFromMethods(io::Printer* printer);
- void GenerateSerializeOneField(io::Printer* printer,
- const FieldDescriptor* field);
- void GenerateSerializeOneExtensionRange(
- io::Printer* printer, const Descriptor::ExtensionRange* range);
void GenerateBuilder(io::Printer* printer);
void GenerateIsInitialized(io::Printer* printer);
@@ -143,8 +141,6 @@ class ImmutableMessageGenerator : public MessageGenerator {
Context* context_;
ClassNameResolver* name_resolver_;
FieldGeneratorMap<ImmutableFieldGenerator> field_generators_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageGenerator);
};
} // namespace java
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder.cc
index 3bbb7ae3829..80064a9bf75 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder.cc
@@ -32,42 +32,64 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/message_builder.h>
+#include "google/protobuf/compiler/java/message_builder.h"
#include <algorithm>
-#include <map>
#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/context.h>
-#include <google/protobuf/compiler/java/doc_comment.h>
-#include <google/protobuf/compiler/java/enum.h>
-#include <google/protobuf/compiler/java/extension.h>
-#include <google/protobuf/compiler/java/generator_factory.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/name_resolver.h>
-#include <google/protobuf/descriptor.pb.h>
+#include "y_absl/container/btree_set.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/substitute.h"
+#include "google/protobuf/compiler/java/context.h"
+#include "google/protobuf/compiler/java/doc_comment.h"
+#include "google/protobuf/compiler/java/enum.h"
+#include "google/protobuf/compiler/java/extension.h"
+#include "google/protobuf/compiler/java/generator_factory.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/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"
// Must be last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
namespace compiler {
namespace java {
+using internal::WireFormat;
+using internal::WireFormatLite;
+
namespace {
TProtoStringType MapValueImmutableClassdName(const Descriptor* descriptor,
ClassNameResolver* name_resolver) {
const FieldDescriptor* value_field = descriptor->map_value();
- GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, value_field->type());
+ Y_ABSL_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, value_field->type());
return name_resolver->GetImmutableClassName(value_field->message_type());
}
+
+bool BitfieldTracksMutability(const FieldDescriptor* const descriptor) {
+ if (!descriptor->is_repeated() || IsMapField(descriptor)) {
+ return false;
+ }
+ // TODO(b/255468704): update this to migrate repeated fields to use
+ // ProtobufList (which tracks immutability internally). That allows us to use
+ // the presence bit to skip work on the repeated field if it is not populated.
+ // Once all repeated fields are held in ProtobufLists, this method shouldn't
+ // be needed.
+ switch (descriptor->type()) {
+ case FieldDescriptor::TYPE_STRING:
+ return false;
+ default:
+ return true;
+ }
+}
} // namespace
MessageBuilderGenerator::MessageBuilderGenerator(const Descriptor* descriptor,
@@ -76,12 +98,13 @@ MessageBuilderGenerator::MessageBuilderGenerator(const Descriptor* descriptor,
context_(context),
name_resolver_(context->GetNameResolver()),
field_generators_(descriptor, context_) {
- GOOGLE_CHECK(HasDescriptorMethods(descriptor->file(), context->EnforceLite()))
+ Y_ABSL_CHECK(HasDescriptorMethods(descriptor->file(), context->EnforceLite()))
<< "Generator factory error: A non-lite message generator is used to "
"generate lite messages.";
for (int i = 0; i < descriptor_->field_count(); i++) {
if (IsRealOneof(descriptor_->field(i))) {
- oneofs_.insert(descriptor_->field(i)->containing_oneof());
+ const OneofDescriptor* oneof = descriptor_->field(i)->containing_oneof();
+ Y_ABSL_CHECK(oneofs_.emplace(oneof->index(), oneof).first->second == oneof);
}
}
}
@@ -122,12 +145,13 @@ void MessageBuilderGenerator::Generate(io::Printer* printer) {
}
// oneof
- std::map<TProtoStringType, TProtoStringType> vars;
- for (auto oneof : oneofs_) {
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
+ for (auto& kv : oneofs_) {
+ const OneofDescriptor* oneof = kv.second;
vars["oneof_name"] = context_->GetOneofGeneratorInfo(oneof)->name;
vars["oneof_capitalized_name"] =
context_->GetOneofGeneratorInfo(oneof)->capitalized_name;
- vars["oneof_index"] = StrCat(oneof->index());
+ vars["oneof_index"] = y_absl::StrCat(oneof->index());
// oneofCase_ and oneof_
printer->Print(vars,
"private int $oneof_name$Case_ = 0;\n"
@@ -142,12 +166,11 @@ void MessageBuilderGenerator::Generate(io::Printer* printer) {
"\n"
"public Builder clear$oneof_capitalized_name$() {\n"
" $oneof_name$Case_ = 0;\n"
- " $oneof_name$_ = null;\n");
- printer->Print(" onChanged();\n");
- printer->Print(
- " return this;\n"
- "}\n"
- "\n");
+ " $oneof_name$_ = null;\n"
+ " onChanged();\n"
+ " return this;\n"
+ "}\n"
+ "\n");
}
// Integers for bit fields.
@@ -168,24 +191,26 @@ void MessageBuilderGenerator::Generate(io::Printer* printer) {
.GenerateBuilderMembers(printer);
}
- // Override methods declared in GeneratedMessage to return the concrete
- // generated type so callsites won't depend on GeneratedMessage. This
- // is needed to keep binary compatibility when we change generated code
- // to subclass a different GeneratedMessage class (e.g., in v3.0.0 release
- // we changed all generated code to subclass GeneratedMessageV3).
- printer->Print(
- "@java.lang.Override\n"
- "public final Builder setUnknownFields(\n"
- " final com.google.protobuf.UnknownFieldSet unknownFields) {\n"
- " return super.setUnknownFields(unknownFields);\n"
- "}\n"
- "\n"
- "@java.lang.Override\n"
- "public final Builder mergeUnknownFields(\n"
- " final com.google.protobuf.UnknownFieldSet unknownFields) {\n"
- " return super.mergeUnknownFields(unknownFields);\n"
- "}\n"
- "\n");
+ if (context_->options().opensource_runtime) {
+ // Override methods declared in GeneratedMessage to return the concrete
+ // generated type so callsites won't depend on GeneratedMessage. This
+ // is needed to keep binary compatibility when we change generated code
+ // to subclass a different GeneratedMessage class (e.g., in v3.0.0 release
+ // we changed all generated code to subclass GeneratedMessageV3).
+ printer->Print(
+ "@java.lang.Override\n"
+ "public final Builder setUnknownFields(\n"
+ " final com.google.protobuf.UnknownFieldSet unknownFields) {\n"
+ " return super.setUnknownFields(unknownFields);\n"
+ "}\n"
+ "\n"
+ "@java.lang.Override\n"
+ "public final Builder mergeUnknownFields(\n"
+ " final com.google.protobuf.UnknownFieldSet unknownFields) {\n"
+ " return super.mergeUnknownFields(unknownFields);\n"
+ "}\n"
+ "\n");
+ }
printer->Print(
"\n"
@@ -231,7 +256,7 @@ void MessageBuilderGenerator::GenerateDescriptorMethods(io::Printer* printer) {
printer->Print(
"case $number$:\n"
" return internalGet$capitalized_name$();\n",
- "number", StrCat(field->number()), "capitalized_name",
+ "number", y_absl::StrCat(field->number()), "capitalized_name",
info->capitalized_name);
}
printer->Print(
@@ -256,7 +281,7 @@ void MessageBuilderGenerator::GenerateDescriptorMethods(io::Printer* printer) {
printer->Print(
"case $number$:\n"
" return internalGetMutable$capitalized_name$();\n",
- "number", StrCat(field->number()), "capitalized_name",
+ "number", y_absl::StrCat(field->number()), "capitalized_name",
info->capitalized_name);
}
printer->Print(
@@ -288,43 +313,63 @@ void MessageBuilderGenerator::GenerateDescriptorMethods(io::Printer* printer) {
void MessageBuilderGenerator::GenerateCommonBuilderMethods(
io::Printer* printer) {
+ // Decide if we really need to have the "maybeForceBuilderInitialization()"
+ // method.
+ // TODO(b/249158148): Remove the need for this entirely
+ bool need_maybe_force_builder_init = false;
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ if (descriptor_->field(i)->message_type() != nullptr &&
+ !IsRealOneof(descriptor_->field(i)) &&
+ HasHasbit(descriptor_->field(i))) {
+ need_maybe_force_builder_init = true;
+ break;
+ }
+ }
+
+ const char* force_builder_init = need_maybe_force_builder_init
+ ? " maybeForceBuilderInitialization();"
+ : "";
+
printer->Print(
"// Construct using $classname$.newBuilder()\n"
"private Builder() {\n"
- " maybeForceBuilderInitialization();\n"
+ "$force_builder_init$\n"
"}\n"
"\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
+ "classname", name_resolver_->GetImmutableClassName(descriptor_),
+ "force_builder_init", force_builder_init);
printer->Print(
"private Builder(\n"
" com.google.protobuf.GeneratedMessage$ver$.BuilderParent parent) {\n"
" super(parent);\n"
- " maybeForceBuilderInitialization();\n"
+ "$force_builder_init$\n"
"}\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_), "ver",
- GeneratedCodeVersionSuffix());
+ GeneratedCodeVersionSuffix(), "force_builder_init", force_builder_init);
- printer->Print(
- "private void maybeForceBuilderInitialization() {\n"
- " if (com.google.protobuf.GeneratedMessage$ver$\n"
- " .alwaysUseFieldBuilders) {\n",
- "ver", GeneratedCodeVersionSuffix());
+ if (need_maybe_force_builder_init) {
+ printer->Print(
+ "private void maybeForceBuilderInitialization() {\n"
+ " if (com.google.protobuf.GeneratedMessage$ver$\n"
+ " .alwaysUseFieldBuilders) {\n",
+ "ver", GeneratedCodeVersionSuffix());
- printer->Indent();
- printer->Indent();
- for (int i = 0; i < descriptor_->field_count(); i++) {
- if (!IsRealOneof(descriptor_->field(i))) {
- field_generators_.get(descriptor_->field(i))
- .GenerateFieldBuilderInitializationCode(printer);
+ printer->Indent();
+ printer->Indent();
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ if (!IsRealOneof(descriptor_->field(i))) {
+ field_generators_.get(descriptor_->field(i))
+ .GenerateFieldBuilderInitializationCode(printer);
+ }
}
- }
- printer->Outdent();
- printer->Outdent();
+ printer->Outdent();
+ printer->Outdent();
- printer->Print(
- " }\n"
- "}\n");
+ printer->Print(
+ " }\n"
+ "}\n");
+ }
printer->Print(
"@java.lang.Override\n"
@@ -332,19 +377,22 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods(
" super.clear();\n");
printer->Indent();
+ int totalBuilderInts = (descriptor_->field_count() + 31) / 32;
+ for (int i = 0; i < totalBuilderInts; i++) {
+ printer->Print("$bit_field_name$ = 0;\n", "bit_field_name",
+ GetBitFieldName(i));
+ }
for (int i = 0; i < descriptor_->field_count(); i++) {
- if (!IsRealOneof(descriptor_->field(i))) {
- field_generators_.get(descriptor_->field(i))
- .GenerateBuilderClearCode(printer);
- }
+ field_generators_.get(descriptor_->field(i))
+ .GenerateBuilderClearCode(printer);
}
- for (auto oneof : oneofs_) {
+ for (auto& kv : oneofs_) {
printer->Print(
"$oneof_name$Case_ = 0;\n"
"$oneof_name$_ = null;\n",
- "oneof_name", context_->GetOneofGeneratorInfo(oneof)->name);
+ "oneof_name", context_->GetOneofGeneratorInfo(kv.second)->name);
}
printer->Outdent();
@@ -385,134 +433,7 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods(
"\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
- printer->Print(
- "@java.lang.Override\n"
- "public $classname$ buildPartial() {\n"
- " $classname$ result = new $classname$(this);\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
-
- printer->Indent();
-
- int totalBuilderBits = 0;
- int totalMessageBits = 0;
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const ImmutableFieldGenerator& field =
- field_generators_.get(descriptor_->field(i));
- totalBuilderBits += field.GetNumBitsForBuilder();
- totalMessageBits += field.GetNumBitsForMessage();
- }
- int totalBuilderInts = (totalBuilderBits + 31) / 32;
- int totalMessageInts = (totalMessageBits + 31) / 32;
-
- // Local vars for from and to bit fields to avoid accessing the builder and
- // message over and over for these fields. Seems to provide a slight
- // perforamance improvement in micro benchmark and this is also what proto1
- // code does.
- for (int i = 0; i < totalBuilderInts; i++) {
- printer->Print("int from_$bit_field_name$ = $bit_field_name$;\n",
- "bit_field_name", GetBitFieldName(i));
- }
- for (int i = 0; i < totalMessageInts; i++) {
- printer->Print("int to_$bit_field_name$ = 0;\n", "bit_field_name",
- GetBitFieldName(i));
- }
-
- // Output generation code for each field.
- for (int i = 0; i < descriptor_->field_count(); i++) {
- field_generators_.get(descriptor_->field(i)).GenerateBuildingCode(printer);
- }
-
- // Copy the bit field results to the generated message
- for (int i = 0; i < totalMessageInts; i++) {
- printer->Print("result.$bit_field_name$ = to_$bit_field_name$;\n",
- "bit_field_name", GetBitFieldName(i));
- }
-
- for (auto oneof : oneofs_) {
- printer->Print("result.$oneof_name$Case_ = $oneof_name$Case_;\n",
- "oneof_name", context_->GetOneofGeneratorInfo(oneof)->name);
- }
-
- printer->Outdent();
-
- printer->Print(" onBuilt();\n");
-
- printer->Print(
- " return result;\n"
- "}\n"
- "\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
-
- // Override methods declared in GeneratedMessage to return the concrete
- // generated type so callsites won't depend on GeneratedMessage. This
- // is needed to keep binary compatibility when we change generated code
- // to subclass a different GeneratedMessage class (e.g., in v3.0.0 release
- // we changed all generated code to subclass GeneratedMessageV3).
- printer->Print(
- "@java.lang.Override\n"
- "public Builder clone() {\n"
- " return super.clone();\n"
- "}\n"
- "@java.lang.Override\n"
- "public Builder setField(\n"
- " com.google.protobuf.Descriptors.FieldDescriptor field,\n"
- " java.lang.Object value) {\n"
- " return super.setField(field, value);\n"
- "}\n"
- "@java.lang.Override\n"
- "public Builder clearField(\n"
- " com.google.protobuf.Descriptors.FieldDescriptor field) {\n"
- " return super.clearField(field);\n"
- "}\n"
- "@java.lang.Override\n"
- "public Builder clearOneof(\n"
- " com.google.protobuf.Descriptors.OneofDescriptor oneof) {\n"
- " return super.clearOneof(oneof);\n"
- "}\n"
- "@java.lang.Override\n"
- "public Builder setRepeatedField(\n"
- " com.google.protobuf.Descriptors.FieldDescriptor field,\n"
- " int index, java.lang.Object value) {\n"
- " return super.setRepeatedField(field, index, value);\n"
- "}\n"
- "@java.lang.Override\n"
- "public Builder addRepeatedField(\n"
- " com.google.protobuf.Descriptors.FieldDescriptor field,\n"
- " java.lang.Object value) {\n"
- " return super.addRepeatedField(field, value);\n"
- "}\n");
-
- if (descriptor_->extension_range_count() > 0) {
- printer->Print(
- "@java.lang.Override\n"
- "public <Type> Builder setExtension(\n"
- " com.google.protobuf.GeneratedMessage.GeneratedExtension<\n"
- " $classname$, Type> extension,\n"
- " Type value) {\n"
- " return super.setExtension(extension, value);\n"
- "}\n"
- "@java.lang.Override\n"
- "public <Type> Builder setExtension(\n"
- " com.google.protobuf.GeneratedMessage.GeneratedExtension<\n"
- " $classname$, java.util.List<Type>> extension,\n"
- " int index, Type value) {\n"
- " return super.setExtension(extension, index, value);\n"
- "}\n"
- "@java.lang.Override\n"
- "public <Type> Builder addExtension(\n"
- " com.google.protobuf.GeneratedMessage.GeneratedExtension<\n"
- " $classname$, java.util.List<Type>> extension,\n"
- " Type value) {\n"
- " return super.addExtension(extension, value);\n"
- "}\n"
- "@java.lang.Override\n"
- "public <Type> Builder clearExtension(\n"
- " com.google.protobuf.GeneratedMessage.GeneratedExtension<\n"
- " $classname$, ?> extension) {\n"
- " return super.clearExtension(extension);\n"
- "}\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
- }
+ GenerateBuildPartial(printer);
// -----------------------------------------------------------------
@@ -546,7 +467,8 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods(
}
// Merge oneof fields.
- for (auto oneof : oneofs_) {
+ for (auto& kv : oneofs_) {
+ const OneofDescriptor* oneof = kv.second;
printer->Print("switch (other.get$oneof_capitalized_name$Case()) {\n",
"oneof_capitalized_name",
context_->GetOneofGeneratorInfo(oneof)->capitalized_name);
@@ -554,7 +476,7 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods(
for (int j = 0; j < oneof->field_count(); j++) {
const FieldDescriptor* field = oneof->field(j);
printer->Print("case $field_name$: {\n", "field_name",
- ToUpper(field->name()));
+ y_absl::AsciiStrToUpper(field->name()));
printer->Indent();
field_generators_.get(field).GenerateMergingCode(printer);
printer->Print("break;\n");
@@ -566,7 +488,7 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods(
" break;\n"
"}\n",
"cap_oneof_name",
- ToUpper(context_->GetOneofGeneratorInfo(oneof)->name));
+ y_absl::AsciiStrToUpper(context_->GetOneofGeneratorInfo(oneof)->name));
printer->Outdent();
printer->Print("}\n");
}
@@ -578,7 +500,7 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods(
printer->Print(" this.mergeExtensionFields(other);\n");
}
- printer->Print(" this.mergeUnknownFields(other.unknownFields);\n");
+ printer->Print(" this.mergeUnknownFields(other.getUnknownFields());\n");
printer->Print(" onChanged();\n");
@@ -589,6 +511,154 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods(
}
}
+void MessageBuilderGenerator::GenerateBuildPartial(io::Printer* printer) {
+ printer->Print(
+ "@java.lang.Override\n"
+ "public $classname$ buildPartial() {\n"
+ " $classname$ result = new $classname$(this);\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_));
+
+ printer->Indent();
+
+ // Handle the repeated fields first so that the "mutable bits" are cleared.
+ bool has_repeated_fields = false;
+ for (int i = 0; i < descriptor_->field_count(); ++i) {
+ if (BitfieldTracksMutability(descriptor_->field(i))) {
+ has_repeated_fields = true;
+ printer->Print("buildPartialRepeatedFields(result);\n");
+ break;
+ }
+ }
+
+ // One buildPartial#() per from_bit_field
+ int totalBuilderInts = (descriptor_->field_count() + 31) / 32;
+ if (totalBuilderInts > 0) {
+ for (int i = 0; i < totalBuilderInts; ++i) {
+ printer->Print(
+ "if ($bit_field_name$ != 0) { buildPartial$piece$(result); }\n",
+ "bit_field_name", GetBitFieldName(i), "piece", y_absl::StrCat(i));
+ }
+ }
+
+ if (!oneofs_.empty()) {
+ printer->Print("buildPartialOneofs(result);\n");
+ }
+
+ printer->Outdent();
+ printer->Print(
+ " onBuilt();\n"
+ " return result;\n"
+ "}\n"
+ "\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_));
+
+ // Build Repeated Fields
+ if (has_repeated_fields) {
+ printer->Print(
+ "private void buildPartialRepeatedFields($classname$ result) {\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_));
+ printer->Indent();
+ for (int i = 0; i < descriptor_->field_count(); ++i) {
+ if (BitfieldTracksMutability(descriptor_->field(i))) {
+ const ImmutableFieldGenerator& field =
+ field_generators_.get(descriptor_->field(i));
+ field.GenerateBuildingCode(printer);
+ }
+ }
+ printer->Outdent();
+ printer->Print("}\n\n");
+ }
+
+ // Build non-oneof fields
+ int start_field = 0;
+ for (int i = 0; i < totalBuilderInts; i++) {
+ start_field = GenerateBuildPartialPiece(printer, i, start_field);
+ }
+
+ // Build Oneofs
+ if (!oneofs_.empty()) {
+ printer->Print("private void buildPartialOneofs($classname$ result) {\n",
+ "classname",
+ name_resolver_->GetImmutableClassName(descriptor_));
+ printer->Indent();
+ for (auto& kv : oneofs_) {
+ const OneofDescriptor* oneof = kv.second;
+ printer->Print(
+ "result.$oneof_name$Case_ = $oneof_name$Case_;\n"
+ "result.$oneof_name$_ = this.$oneof_name$_;\n",
+ "oneof_name", context_->GetOneofGeneratorInfo(oneof)->name);
+ for (int i = 0; i < oneof->field_count(); ++i) {
+ if (oneof->field(i)->message_type() != nullptr) {
+ const ImmutableFieldGenerator& field =
+ field_generators_.get(oneof->field(i));
+ field.GenerateBuildingCode(printer);
+ }
+ }
+ }
+ printer->Outdent();
+ printer->Print("}\n\n");
+ }
+}
+
+int MessageBuilderGenerator::GenerateBuildPartialPiece(io::Printer* printer,
+ int piece,
+ int first_field) {
+ printer->Print(
+ "private void buildPartial$piece$($classname$ result) {\n"
+ " int from_$bit_field_name$ = $bit_field_name$;\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_), "piece",
+ y_absl::StrCat(piece), "bit_field_name", GetBitFieldName(piece));
+ printer->Indent();
+ y_absl::btree_set<int> declared_to_bitfields;
+
+ int bit = 0;
+ int next = first_field;
+ for (; bit < 32 && next < descriptor_->field_count(); ++next) {
+ const ImmutableFieldGenerator& field =
+ field_generators_.get(descriptor_->field(next));
+ bit += field.GetNumBitsForBuilder();
+
+ // Skip oneof fields that are handled separately
+ if (IsRealOneof(descriptor_->field(next))) {
+ continue;
+ }
+
+ // Skip repeated fields because they are currently handled
+ // in separate buildPartial sub-methods.
+ if (BitfieldTracksMutability(descriptor_->field(next))) {
+ continue;
+ }
+ // Skip fields without presence bits in the builder
+ if (field.GetNumBitsForBuilder() == 0) {
+ continue;
+ }
+
+ // Track message bits if necessary
+ if (field.GetNumBitsForMessage() > 0) {
+ int to_bitfield = field.GetMessageBitIndex() / 32;
+ if (declared_to_bitfields.count(to_bitfield) == 0) {
+ printer->Print("int to_$bit_field_name$ = 0;\n", "bit_field_name",
+ GetBitFieldName(to_bitfield));
+ declared_to_bitfields.insert(to_bitfield);
+ }
+ }
+
+ // Copy the field from the builder to the message
+ field.GenerateBuildingCode(printer);
+ }
+
+ // Copy the bit field results to the generated message
+ for (int to_bitfield : declared_to_bitfields) {
+ printer->Print("result.$bit_field_name$ |= to_$bit_field_name$;\n",
+ "bit_field_name", GetBitFieldName(to_bitfield));
+ }
+
+ printer->Outdent();
+ printer->Print("}\n\n");
+
+ return next;
+}
+
// ===================================================================
void MessageBuilderGenerator::GenerateBuilderParsingMethods(
@@ -599,20 +669,92 @@ void MessageBuilderGenerator::GenerateBuilderParsingMethods(
" com.google.protobuf.CodedInputStream input,\n"
" com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
" throws java.io.IOException {\n"
- " $classname$ parsedMessage = null;\n"
+ " if (extensionRegistry == null) {\n"
+ " throw new java.lang.NullPointerException();\n"
+ " }\n"
" try {\n"
- " parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);\n"
+ " boolean done = false;\n"
+ " while (!done) {\n"
+ " int tag = input.readTag();\n"
+ " switch (tag) {\n"
+ " case 0:\n" // zero signals EOF / limit reached
+ " done = true;\n"
+ " break;\n");
+ printer->Indent(); // method
+ printer->Indent(); // try
+ printer->Indent(); // while
+ printer->Indent(); // switch
+ GenerateBuilderFieldParsingCases(printer);
+ printer->Outdent(); // switch
+ printer->Outdent(); // while
+ printer->Outdent(); // try
+ printer->Outdent(); // method
+ printer->Print(
+ " default: {\n"
+ " if (!super.parseUnknownField(input, extensionRegistry, tag)) "
+ "{\n"
+ " done = true; // was an endgroup tag\n"
+ " }\n"
+ " break;\n"
+ " } // default:\n"
+ " } // switch (tag)\n"
+ " } // while (!done)\n"
" } catch (com.google.protobuf.InvalidProtocolBufferException e) {\n"
- " parsedMessage = ($classname$) e.getUnfinishedMessage();\n"
" throw e.unwrapIOException();\n"
" } finally {\n"
- " if (parsedMessage != null) {\n"
- " mergeFrom(parsedMessage);\n"
- " }\n"
- " }\n"
+ " onChanged();\n"
+ " } // finally\n"
" return this;\n"
- "}\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
+ "}\n");
+}
+
+void MessageBuilderGenerator::GenerateBuilderFieldParsingCases(
+ io::Printer* printer) {
+ std::unique_ptr<const FieldDescriptor*[]> sorted_fields(
+ SortFieldsByNumber(descriptor_));
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = sorted_fields[i];
+ GenerateBuilderFieldParsingCase(printer, field);
+ if (field->is_packable()) {
+ GenerateBuilderPackedFieldParsingCase(printer, field);
+ }
+ }
+}
+
+void MessageBuilderGenerator::GenerateBuilderFieldParsingCase(
+ io::Printer* printer, const FieldDescriptor* field) {
+ arc_ui32 tag = WireFormatLite::MakeTag(
+ field->number(), WireFormat::WireTypeForFieldType(field->type()));
+ TProtoStringType tagString = y_absl::StrCat(static_cast<arc_i32>(tag));
+ printer->Print("case $tag$: {\n", "tag", tagString);
+ printer->Indent();
+
+ field_generators_.get(field).GenerateBuilderParsingCode(printer);
+
+ printer->Outdent();
+ printer->Print(
+ " break;\n"
+ "} // case $tag$\n",
+ "tag", tagString);
+}
+
+void MessageBuilderGenerator::GenerateBuilderPackedFieldParsingCase(
+ io::Printer* printer, const FieldDescriptor* field) {
+ // To make packed = true wire compatible, we generate parsing code from a
+ // packed version of this field regardless of field->options().packed().
+ arc_ui32 tag = WireFormatLite::MakeTag(
+ field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED);
+ TProtoStringType tagString = y_absl::StrCat(static_cast<arc_i32>(tag));
+ printer->Print("case $tag$: {\n", "tag", tagString);
+ printer->Indent();
+
+ field_generators_.get(field).GenerateBuilderParsingCodeFromPacked(printer);
+
+ printer->Outdent();
+ printer->Print(
+ " break;\n"
+ "} // case $tag$\n",
+ "tag", tagString);
}
// ===================================================================
@@ -714,4 +856,4 @@ void MessageBuilderGenerator::GenerateIsInitialized(io::Printer* printer) {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder.h
index f9c9a00a0ca..16585da339c 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder.h
@@ -35,10 +35,10 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_H__
-#include <map>
#include <string>
-#include <google/protobuf/compiler/java/field.h>
+#include "y_absl/container/btree_map.h"
+#include "google/protobuf/compiler/java/field.h"
namespace google {
namespace protobuf {
@@ -63,23 +63,33 @@ class MessageBuilderGenerator {
public:
explicit MessageBuilderGenerator(const Descriptor* descriptor,
Context* context);
+ MessageBuilderGenerator(const MessageBuilderGenerator&) = delete;
+ MessageBuilderGenerator& operator=(const MessageBuilderGenerator&) = delete;
virtual ~MessageBuilderGenerator();
virtual void Generate(io::Printer* printer);
private:
void GenerateCommonBuilderMethods(io::Printer* printer);
+ void GenerateBuildPartial(io::Printer* printer);
+ int GenerateBuildPartialPiece(io::Printer* printer, int piece,
+ int first_field);
+ int GenerateBuildPartialPieceWithoutPresence(io::Printer* printer, int piece,
+ int first_field);
void GenerateDescriptorMethods(io::Printer* printer);
void GenerateBuilderParsingMethods(io::Printer* printer);
+ void GenerateBuilderFieldParsingCases(io::Printer* printer);
+ void GenerateBuilderFieldParsingCase(io::Printer* printer,
+ const FieldDescriptor* field);
+ void GenerateBuilderPackedFieldParsingCase(io::Printer* printer,
+ const FieldDescriptor* field);
void GenerateIsInitialized(io::Printer* printer);
const Descriptor* descriptor_;
Context* context_;
ClassNameResolver* name_resolver_;
FieldGeneratorMap<ImmutableFieldGenerator> field_generators_;
- std::set<const OneofDescriptor*> oneofs_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageBuilderGenerator);
+ y_absl::btree_map<int, const OneofDescriptor*> oneofs_;
};
} // namespace java
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder_lite.cc
index bf41a711075..f85341d9ce7 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder_lite.cc
@@ -32,29 +32,30 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/message_builder_lite.h>
+#include "google/protobuf/compiler/java/message_builder_lite.h"
#include <algorithm>
-#include <map>
#include <memory>
+#include <string>
#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/context.h>
-#include <google/protobuf/compiler/java/doc_comment.h>
-#include <google/protobuf/compiler/java/enum.h>
-#include <google/protobuf/compiler/java/extension.h>
-#include <google/protobuf/compiler/java/generator_factory.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/name_resolver.h>
-#include <google/protobuf/descriptor.pb.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/substitute.h"
+#include "google/protobuf/compiler/java/context.h"
+#include "google/protobuf/compiler/java/doc_comment.h"
+#include "google/protobuf/compiler/java/enum.h"
+#include "google/protobuf/compiler/java/extension.h"
+#include "google/protobuf/compiler/java/generator_factory.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/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"
// Must be last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -67,12 +68,13 @@ MessageBuilderLiteGenerator::MessageBuilderLiteGenerator(
context_(context),
name_resolver_(context->GetNameResolver()),
field_generators_(descriptor, context_) {
- GOOGLE_CHECK(!HasDescriptorMethods(descriptor->file(), context->EnforceLite()))
+ Y_ABSL_CHECK(!HasDescriptorMethods(descriptor->file(), context->EnforceLite()))
<< "Generator factory error: A lite message generator is used to "
"generate non-lite messages.";
for (int i = 0; i < descriptor_->field_count(); i++) {
if (IsRealOneof(descriptor_->field(i))) {
- oneofs_.insert(descriptor_->field(i)->containing_oneof());
+ const OneofDescriptor* oneof = descriptor_->field(i)->containing_oneof();
+ Y_ABSL_CHECK(oneofs_.emplace(oneof->index(), oneof).first->second == oneof);
}
}
}
@@ -81,41 +83,51 @@ MessageBuilderLiteGenerator::~MessageBuilderLiteGenerator() {}
void MessageBuilderLiteGenerator::Generate(io::Printer* printer) {
WriteMessageDocComment(printer, descriptor_);
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars = {
+ {"{", ""},
+ {"}", ""},
+ {"classname", name_resolver_->GetImmutableClassName(descriptor_)},
+ {"extra_interfaces", ExtraBuilderInterfaces(descriptor_)},
+ {"extendible",
+ descriptor_->extension_range_count() > 0 ? "Extendable" : ""},
+ };
printer->Print(
- "public static final class Builder extends\n"
+ vars,
+ "public static final class ${$Builder$}$ extends\n"
" com.google.protobuf.GeneratedMessageLite.$extendible$Builder<\n"
" $classname$, Builder> implements\n"
" $extra_interfaces$\n"
- " $classname$OrBuilder {\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_),
- "extra_interfaces", ExtraBuilderInterfaces(descriptor_), "extendible",
- descriptor_->extension_range_count() > 0 ? "Extendable" : "");
+ " $classname$OrBuilder {\n");
+ printer->Annotate("{", "}", descriptor_);
printer->Indent();
GenerateCommonBuilderMethods(printer);
// oneof
- std::map<TProtoStringType, TProtoStringType> vars;
- for (auto oneof : oneofs_) {
+ for (auto& kv : oneofs_) {
+ const OneofDescriptor* oneof = kv.second;
vars["oneof_name"] = context_->GetOneofGeneratorInfo(oneof)->name;
vars["oneof_capitalized_name"] =
context_->GetOneofGeneratorInfo(oneof)->capitalized_name;
- vars["oneof_index"] = StrCat(oneof->index());
+ vars["oneof_index"] = y_absl::StrCat(oneof->index());
// oneofCase() and clearOneof()
printer->Print(vars,
"@java.lang.Override\n"
"public $oneof_capitalized_name$Case\n"
- " get$oneof_capitalized_name$Case() {\n"
+ " ${$get$oneof_capitalized_name$Case$}$() {\n"
" return instance.get$oneof_capitalized_name$Case();\n"
- "}\n"
+ "}\n");
+ printer->Annotate("{", "}", oneof);
+ printer->Print(vars,
"\n"
- "public Builder clear$oneof_capitalized_name$() {\n"
+ "public Builder ${$clear$oneof_capitalized_name$$}$() {\n"
" copyOnWrite();\n"
" instance.clear$oneof_capitalized_name$();\n"
" return this;\n"
"}\n"
"\n");
+ printer->Annotate("{", "}", oneof);
}
for (int i = 0; i < descriptor_->field_count(); i++) {
@@ -153,4 +165,4 @@ void MessageBuilderLiteGenerator::GenerateCommonBuilderMethods(
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder_lite.h
index 0d895fcf05b..a0feece646d 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder_lite.h
@@ -35,10 +35,10 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_LITE_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_LITE_H__
-#include <map>
#include <string>
-#include <google/protobuf/compiler/java/field.h>
+#include "y_absl/container/btree_map.h"
+#include "google/protobuf/compiler/java/field.h"
namespace google {
namespace protobuf {
@@ -63,6 +63,9 @@ class MessageBuilderLiteGenerator {
public:
explicit MessageBuilderLiteGenerator(const Descriptor* descriptor,
Context* context);
+ MessageBuilderLiteGenerator(const MessageBuilderLiteGenerator&) = delete;
+ MessageBuilderLiteGenerator& operator=(const MessageBuilderLiteGenerator&) =
+ delete;
virtual ~MessageBuilderLiteGenerator();
virtual void Generate(io::Printer* printer);
@@ -74,9 +77,7 @@ class MessageBuilderLiteGenerator {
Context* context_;
ClassNameResolver* name_resolver_;
FieldGeneratorMap<ImmutableFieldLiteGenerator> field_generators_;
- std::set<const OneofDescriptor*> oneofs_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageBuilderLiteGenerator);
+ y_absl::btree_map<int, const OneofDescriptor*> oneofs_;
};
} // namespace java
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field.cc
index a16abfcb341..1a5efaa9386 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field.cc
@@ -32,21 +32,21 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/message_field.h>
+#include "google/protobuf/compiler/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/context.h>
-#include <google/protobuf/compiler/java/doc_comment.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/name_resolver.h>
+#include "y_absl/log/absl_check.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/java/context.h"
+#include "google/protobuf/compiler/java/doc_comment.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/name_resolver.h"
+#include "google/protobuf/io/printer.h"
+#include "google/protobuf/wire_format.h"
// Must be last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -56,15 +56,16 @@ namespace java {
namespace {
-void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
- int builderBitIndex, const FieldGeneratorInfo* info,
- ClassNameResolver* name_resolver,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+void SetMessageVariables(
+ const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
+ const FieldGeneratorInfo* info, ClassNameResolver* name_resolver,
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables,
+ Context* context) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["type"] =
name_resolver->GetImmutableClassName(descriptor->message_type());
- (*variables)["kt_type"] = (*variables)["type"];
+ variables->insert({"kt_type", EscapeKotlinKeywords((*variables)["type"])});
(*variables)["mutable_type"] =
name_resolver->GetMutableClassName(descriptor->message_type());
(*variables)["group_or_message"] =
@@ -74,38 +75,33 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
// by the proto compiler
(*variables)["deprecation"] =
descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
- (*variables)["kt_deprecation"] =
- descriptor->options().deprecated()
- ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
- " is deprecated\") "
- : "";
+ variables->insert(
+ {"kt_deprecation",
+ descriptor->options().deprecated()
+ ? y_absl::StrCat("@kotlin.Deprecated(message = \"Field ",
+ (*variables)["name"], " is deprecated\") ")
+ : ""});
(*variables)["on_changed"] = "onChanged();";
(*variables)["ver"] = GeneratedCodeVersionSuffix();
(*variables)["get_parser"] =
- ExposePublicParser(descriptor->message_type()->file()) ? "PARSER"
- : "parser()";
+ ExposePublicParser(descriptor->message_type()->file()) &&
+ context->options().opensource_runtime
+ ? "PARSER"
+ : "parser()";
if (HasHasbit(descriptor)) {
// For singular messages and builders, one bit is used for the hasField bit.
(*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
- (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex);
// Note that these have a trailing ";".
- (*variables)["set_has_field_bit_message"] =
- GenerateSetBit(messageBitIndex) + ";";
- (*variables)["set_has_field_bit_builder"] =
- GenerateSetBit(builderBitIndex) + ";";
- (*variables)["clear_has_field_bit_builder"] =
- GenerateClearBit(builderBitIndex) + ";";
+ (*variables)["set_has_field_bit_to_local"] =
+ GenerateSetBitToLocal(messageBitIndex);
(*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
} else {
- (*variables)["set_has_field_bit_message"] = "";
- (*variables)["set_has_field_bit_builder"] = "";
- (*variables)["clear_has_field_bit_builder"] = "";
-
- (*variables)["is_field_present_message"] =
- (*variables)["name"] + "_ != null";
+ (*variables)["set_has_field_bit_to_local"] = "";
+ variables->insert({"is_field_present_message",
+ y_absl::StrCat((*variables)["name"], "_ != null")});
}
// For repeated builders, one bit is used for whether the array is immutable.
@@ -113,17 +109,13 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
(*variables)["set_mutable_bit_builder"] = GenerateSetBit(builderBitIndex);
(*variables)["clear_mutable_bit_builder"] = GenerateClearBit(builderBitIndex);
- // For repeated fields, one bit is used for whether the array is immutable
- // in the parsing constructor.
- (*variables)["get_mutable_bit_parser"] =
- GenerateGetBitMutableLocal(builderBitIndex);
- (*variables)["set_mutable_bit_parser"] =
- GenerateSetBitMutableLocal(builderBitIndex);
-
+ (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex);
+ (*variables)["set_has_field_bit_builder"] =
+ y_absl::StrCat(GenerateSetBit(builderBitIndex), ";");
+ (*variables)["clear_has_field_bit_builder"] =
+ y_absl::StrCat(GenerateClearBit(builderBitIndex), ";");
(*variables)["get_has_field_bit_from_local"] =
GenerateGetBitFromLocal(builderBitIndex);
- (*variables)["set_has_field_bit_to_local"] =
- GenerateSetBitToLocal(messageBitIndex);
}
} // namespace
@@ -133,21 +125,31 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
ImmutableMessageFieldGenerator::ImmutableMessageFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
Context* context)
- : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
+ : descriptor_(descriptor),
+ message_bit_index_(messageBitIndex),
+ builder_bit_index_(builderBitIndex),
+ name_resolver_(context->GetNameResolver()),
+ context_(context) {
SetMessageVariables(descriptor, messageBitIndex, builderBitIndex,
context->GetFieldGeneratorInfo(descriptor),
- name_resolver_, &variables_);
+ name_resolver_, &variables_, context);
}
ImmutableMessageFieldGenerator::~ImmutableMessageFieldGenerator() {}
+int ImmutableMessageFieldGenerator::GetMessageBitIndex() const {
+ return message_bit_index_;
+}
+
+int ImmutableMessageFieldGenerator::GetBuilderBitIndex() const {
+ return builder_bit_index_;
+}
+
int ImmutableMessageFieldGenerator::GetNumBitsForMessage() const {
return HasHasbit(descriptor_) ? 1 : 0;
}
-int ImmutableMessageFieldGenerator::GetNumBitsForBuilder() const {
- return GetNumBitsForMessage();
-}
+int ImmutableMessageFieldGenerator::GetNumBitsForBuilder() const { return 1; }
void ImmutableMessageFieldGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
@@ -180,24 +182,6 @@ void ImmutableMessageFieldGenerator::GenerateMembers(
" return $get_has_field_bit_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$OrBuilder "
- "${$get$capitalized_name$OrBuilder$}$() {\n"
- " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
} else {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(
@@ -207,24 +191,25 @@ void ImmutableMessageFieldGenerator::GenerateMembers(
" return $name$_ != null;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$OrBuilder "
- "${$get$capitalized_name$OrBuilder$}$() {\n"
- " return get$capitalized_name$();\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
}
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
+ " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public $type$OrBuilder "
+ "${$get$capitalized_name$OrBuilder$}$() {\n"
+ " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
}
void ImmutableMessageFieldGenerator::PrintNestedBuilderCondition(
@@ -262,9 +247,6 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers(
// When using nested-builders, the code initially works just like the
// non-nested builder case. It only creates a nested builder lazily on
// demand and then forever delegates to it after creation.
-
- bool has_hasbit = HasHasbit(descriptor_);
-
printer->Print(variables_, "private $type$ $name$_;\n");
printer->Print(variables_,
@@ -279,21 +261,11 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers(
// boolean hasField()
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- if (has_hasbit) {
- printer->Print(
- variables_,
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $get_has_field_bit_builder$;\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
- } else {
- printer->Print(
- variables_,
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $name$Builder_ != null || $name$_ != null;\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
- }
+ printer->Print(variables_,
+ "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
+ " return $get_has_field_bit_builder$;\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
// Field getField()
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
@@ -311,12 +283,12 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers(
"if (value == null) {\n"
" throw new NullPointerException();\n"
"}\n"
- "$name$_ = value;\n"
- "$on_changed$\n",
+ "$name$_ = value;\n",
"$name$Builder_.setMessage(value);\n",
"$set_has_field_bit_builder$\n"
+ "$on_changed$\n"
"return this;\n");
// Field.Builder setField(Field.Builder builderForValue)
@@ -326,58 +298,48 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers(
"$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
" $type$.Builder builderForValue)",
- "$name$_ = builderForValue.build();\n"
- "$on_changed$\n",
+ "$name$_ = builderForValue.build();\n",
"$name$Builder_.setMessage(builderForValue.build());\n",
"$set_has_field_bit_builder$\n"
+ "$on_changed$\n"
"return this;\n");
- // Field.Builder mergeField(Field value)
+ // Message.Builder mergeField(Field value)
WriteFieldDocComment(printer, descriptor_);
PrintNestedBuilderFunction(
printer,
"$deprecation$public Builder ${$merge$capitalized_name$$}$($type$ value)",
-
- has_hasbit
- ? "if ($get_has_field_bit_builder$ &&\n"
- " $name$_ != null &&\n"
- " $name$_ != $type$.getDefaultInstance()) {\n"
- " $name$_ =\n"
- " $type$.newBuilder($name$_).mergeFrom(value).buildPartial();\n"
- "} else {\n"
- " $name$_ = value;\n"
- "}\n"
- "$on_changed$\n"
- : "if ($name$_ != null) {\n"
- " $name$_ =\n"
- " $type$.newBuilder($name$_).mergeFrom(value).buildPartial();\n"
- "} else {\n"
- " $name$_ = value;\n"
- "}\n"
- "$on_changed$\n",
+ "if ($get_has_field_bit_builder$ &&\n"
+ " $name$_ != null &&\n"
+ " $name$_ != $type$.getDefaultInstance()) {\n"
+ " get$capitalized_name$Builder().mergeFrom(value);\n"
+ "} else {\n"
+ " $name$_ = value;\n"
+ "}\n",
"$name$Builder_.mergeFrom(value);\n",
"$set_has_field_bit_builder$\n"
+ "$on_changed$\n"
"return this;\n");
- // Field.Builder clearField()
+ // Message.Builder clearField()
WriteFieldDocComment(printer, descriptor_);
- PrintNestedBuilderFunction(
- printer, "$deprecation$public Builder ${$clear$capitalized_name$$}$()",
-
- "$name$_ = null;\n"
- "$on_changed$\n",
-
- has_hasbit ? "$name$Builder_.clear();\n"
- : "$name$_ = null;\n"
- "$name$Builder_ = null;\n",
-
- "$clear_has_field_bit_builder$\n"
- "return this;\n");
+ printer->Print(variables_,
+ "$deprecation$public Builder clear$capitalized_name$() {\n"
+ " $clear_has_field_bit_builder$\n"
+ " $name$_ = null;\n"
+ " if ($name$Builder_ != null) {\n"
+ " $name$Builder_.dispose();\n"
+ " $name$Builder_ = null;\n"
+ " }\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
+ // Field.Builder getFieldBuilder()
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$public $type$.Builder "
@@ -387,6 +349,8 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers(
" return get$capitalized_name$FieldBuilder().getBuilder();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
+
+ // FieldOrBuilder getFieldOrBuilder()
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$public $type$OrBuilder "
@@ -399,6 +363,8 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers(
" }\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
+
+ // SingleFieldBuilder getFieldFieldBuilder
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
@@ -419,9 +385,9 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers(
void ImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(variables_,
- "$kt_deprecation$var $kt_name$: $kt_type$\n"
+ "$kt_deprecation$public var $kt_name$: $kt_type$\n"
" @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
" get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
" @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
@@ -430,16 +396,17 @@ void ImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
" }\n");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "public fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER,
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
" return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
"}\n");
@@ -449,16 +416,14 @@ void ImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
void ImmutableMessageFieldGenerator::GenerateKotlinOrNull(io::Printer* printer) const {
if (descriptor_->has_optional_keyword()) {
printer->Print(variables_,
- "val $classname$Kt.Dsl.$name$OrNull: $kt_type$?\n"
+ "public val $classname$Kt.Dsl.$name$OrNull: $kt_type$?\n"
" get() = $kt_dsl_builder$.$name$OrNull\n");
}
}
void ImmutableMessageFieldGenerator::GenerateFieldBuilderInitializationCode(
io::Printer* printer) const {
- if (HasHasbit(descriptor_)) {
- printer->Print(variables_, "get$capitalized_name$FieldBuilder();\n");
- }
+ printer->Print(variables_, "get$capitalized_name$FieldBuilder();\n");
}
void ImmutableMessageFieldGenerator::GenerateInitializationCode(
@@ -466,17 +431,13 @@ void ImmutableMessageFieldGenerator::GenerateInitializationCode(
void ImmutableMessageFieldGenerator::GenerateBuilderClearCode(
io::Printer* printer) const {
- if (HasHasbit(descriptor_)) {
- PrintNestedBuilderCondition(printer, "$name$_ = null;\n",
-
- "$name$Builder_.clear();\n");
- printer->Print(variables_, "$clear_has_field_bit_builder$\n");
- } else {
- PrintNestedBuilderCondition(printer, "$name$_ = null;\n",
-
- "$name$_ = null;\n"
- "$name$Builder_ = null;\n");
- }
+ // No need to clear the has-bit since we clear the bitField ints all at once.
+ printer->Print(variables_,
+ "$name$_ = null;\n"
+ "if ($name$Builder_ != null) {\n"
+ " $name$Builder_.dispose();\n"
+ " $name$Builder_ = null;\n"
+ "}\n");
}
void ImmutableMessageFieldGenerator::GenerateMergingCode(
@@ -489,50 +450,32 @@ void ImmutableMessageFieldGenerator::GenerateMergingCode(
void ImmutableMessageFieldGenerator::GenerateBuildingCode(
io::Printer* printer) const {
- if (HasHasbit(descriptor_)) {
- printer->Print(variables_, "if ($get_has_field_bit_from_local$) {\n");
- printer->Indent();
- PrintNestedBuilderCondition(printer, "result.$name$_ = $name$_;\n",
- "result.$name$_ = $name$Builder_.build();\n");
- printer->Outdent();
- printer->Print(variables_,
- " $set_has_field_bit_to_local$;\n"
- "}\n");
- } else {
- PrintNestedBuilderCondition(printer, "result.$name$_ = $name$_;\n",
- "result.$name$_ = $name$Builder_.build();\n");
+ printer->Print(variables_,
+ "if ($get_has_field_bit_from_local$) {\n"
+ " result.$name$_ = $name$Builder_ == null\n"
+ " ? $name$_\n"
+ " : $name$Builder_.build();\n");
+ if (GetNumBitsForMessage() > 0) {
+ printer->Print(variables_, " $set_has_field_bit_to_local$;\n");
}
+ printer->Print("}\n");
}
-void ImmutableMessageFieldGenerator::GenerateParsingCode(
+void ImmutableMessageFieldGenerator::GenerateBuilderParsingCode(
io::Printer* printer) const {
- printer->Print(variables_,
- "$type$.Builder subBuilder = null;\n"
- "if ($is_field_present_message$) {\n"
- " subBuilder = $name$_.toBuilder();\n"
- "}\n");
-
if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) {
printer->Print(variables_,
- "$name$_ = input.readGroup($number$, $type$.$get_parser$,\n"
- " extensionRegistry);\n");
+ "input.readGroup($number$,\n"
+ " get$capitalized_name$FieldBuilder().getBuilder(),\n"
+ " extensionRegistry);\n"
+ "$set_has_field_bit_builder$\n");
} else {
printer->Print(variables_,
- "$name$_ = input.readMessage($type$.$get_parser$, "
- "extensionRegistry);\n");
+ "input.readMessage(\n"
+ " get$capitalized_name$FieldBuilder().getBuilder(),\n"
+ " extensionRegistry);\n"
+ "$set_has_field_bit_builder$\n");
}
-
- printer->Print(variables_,
- "if (subBuilder != null) {\n"
- " subBuilder.mergeFrom($name$_);\n"
- " $name$_ = subBuilder.buildPartial();\n"
- "}\n"
- "$set_has_field_bit_message$\n");
-}
-
-void ImmutableMessageFieldGenerator::GenerateParsingDoneCode(
- io::Printer* printer) const {
- // noop for messages.
}
void ImmutableMessageFieldGenerator::GenerateSerializationCode(
@@ -596,6 +539,7 @@ void ImmutableMessageOneofFieldGenerator::GenerateMembers(
" return $has_oneof_case_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
+
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
"@java.lang.Override\n"
@@ -779,24 +723,28 @@ void ImmutableMessageOneofFieldGenerator::GenerateBuilderMembers(
" $oneof_name$_ = null;\n"
" }\n"
" $set_oneof_case_message$;\n"
- " $on_changed$;\n"
+ " $on_changed$\n"
" return $name$Builder_;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
}
-void ImmutableMessageOneofFieldGenerator::GenerateBuildingCode(
+void ImmutableMessageOneofFieldGenerator::GenerateBuilderClearCode(
io::Printer* printer) const {
- printer->Print(variables_, "if ($has_oneof_case_message$) {\n");
- printer->Indent();
-
- PrintNestedBuilderCondition(
- printer, "result.$oneof_name$_ = $oneof_name$_;\n",
-
- "result.$oneof_name$_ = $name$Builder_.build();\n");
+ // Make sure the builder gets cleared.
+ printer->Print(variables_,
+ "if ($name$Builder_ != null) {\n"
+ " $name$Builder_.clear();\n"
+ "}\n");
+}
- printer->Outdent();
- printer->Print("}\n");
+void ImmutableMessageOneofFieldGenerator::GenerateBuildingCode(
+ io::Printer* printer) const {
+ printer->Print(variables_,
+ "if ($has_oneof_case_message$ &&\n"
+ " $name$Builder_ != null) {\n"
+ " result.$oneof_name$_ = $name$Builder_.build();\n"
+ "}\n");
}
void ImmutableMessageOneofFieldGenerator::GenerateMergingCode(
@@ -805,32 +753,21 @@ void ImmutableMessageOneofFieldGenerator::GenerateMergingCode(
"merge$capitalized_name$(other.get$capitalized_name$());\n");
}
-void ImmutableMessageOneofFieldGenerator::GenerateParsingCode(
+void ImmutableMessageOneofFieldGenerator::GenerateBuilderParsingCode(
io::Printer* printer) const {
- printer->Print(variables_,
- "$type$.Builder subBuilder = null;\n"
- "if ($has_oneof_case_message$) {\n"
- " subBuilder = (($type$) $oneof_name$_).toBuilder();\n"
- "}\n");
-
if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) {
- printer->Print(
- variables_,
- "$oneof_name$_ = input.readGroup($number$, $type$.$get_parser$,\n"
- " extensionRegistry);\n");
+ printer->Print(variables_,
+ "input.readGroup($number$,\n"
+ " get$capitalized_name$FieldBuilder().getBuilder(),\n"
+ " extensionRegistry);\n"
+ "$set_oneof_case_message$;\n");
} else {
- printer->Print(
- variables_,
- "$oneof_name$_ =\n"
- " input.readMessage($type$.$get_parser$, extensionRegistry);\n");
+ printer->Print(variables_,
+ "input.readMessage(\n"
+ " get$capitalized_name$FieldBuilder().getBuilder(),\n"
+ " extensionRegistry);\n"
+ "$set_oneof_case_message$;\n");
}
-
- printer->Print(variables_,
- "if (subBuilder != null) {\n"
- " subBuilder.mergeFrom(($type$) $oneof_name$_);\n"
- " $oneof_name$_ = subBuilder.buildPartial();\n"
- "}\n");
- printer->Print(variables_, "$set_oneof_case_message$;\n");
}
void ImmutableMessageOneofFieldGenerator::GenerateSerializationCode(
@@ -857,11 +794,8 @@ void ImmutableMessageOneofFieldGenerator::GenerateSerializedSizeCode(
RepeatedImmutableMessageFieldGenerator::RepeatedImmutableMessageFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
Context* context)
- : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
- SetMessageVariables(descriptor, messageBitIndex, builderBitIndex,
- context->GetFieldGeneratorInfo(descriptor),
- name_resolver_, &variables_);
-}
+ : ImmutableMessageFieldGenerator(descriptor, messageBitIndex,
+ builderBitIndex, context) {}
RepeatedImmutableMessageFieldGenerator::
~RepeatedImmutableMessageFieldGenerator() {}
@@ -904,7 +838,8 @@ void RepeatedImmutableMessageFieldGenerator::GenerateInterfaceMembers(
void RepeatedImmutableMessageFieldGenerator::GenerateMembers(
io::Printer* printer) const {
- printer->Print(variables_, "private java.util.List<$type$> $name$_;\n");
+ printer->Print(variables_, "@SuppressWarnings(\"serial\")\n"
+ "private java.util.List<$type$> $name$_;\n");
PrintExtraFieldInfo(variables_, printer);
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
@@ -914,6 +849,8 @@ void RepeatedImmutableMessageFieldGenerator::GenerateMembers(
" return $name$_;\n" // note: unmodifiable list
"}\n");
printer->Annotate("{", "}", descriptor_);
+
+ // List<FieldOrBuilder> getFieldOrBuilderList()
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
@@ -923,6 +860,8 @@ void RepeatedImmutableMessageFieldGenerator::GenerateMembers(
" return $name$_;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
+
+ // int getFieldCount()
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
@@ -931,6 +870,8 @@ void RepeatedImmutableMessageFieldGenerator::GenerateMembers(
" return $name$_.size();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
+
+ // Field getField(int index)
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
@@ -939,6 +880,8 @@ void RepeatedImmutableMessageFieldGenerator::GenerateMembers(
" return $name$_.get(index);\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
+
+ // FieldOrBuilder getFieldOrBuilder(int index)
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"@java.lang.Override\n"
@@ -1164,7 +1107,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers(
"return this;\n");
- // Builder clearAllRepeatedField()
+ // Builder clearRepeatedField()
WriteFieldDocComment(printer, descriptor_);
PrintNestedBuilderFunction(
printer, "$deprecation$public Builder ${$clear$capitalized_name$$}$()",
@@ -1191,6 +1134,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers(
"return this;\n");
+ // Field.Builder getRepeatedFieldBuilder(int index)
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
@@ -1200,6 +1144,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers(
"}\n");
printer->Annotate("{", "}", descriptor_);
+ // FieldOrBuilder getRepeatedFieldOrBuilder(int index)
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$public $type$OrBuilder "
@@ -1213,6 +1158,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers(
"}\n");
printer->Annotate("{", "}", descriptor_);
+ // List<FieldOrBuilder> getRepeatedFieldOrBuilderList()
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
@@ -1226,6 +1172,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers(
"}\n");
printer->Annotate("{", "}", descriptor_);
+ // Field.Builder addRepeatedField()
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$public $type$.Builder "
@@ -1234,6 +1181,8 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers(
" $type$.getDefaultInstance());\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
+
+ // Field.Builder addRepeatedFieldBuilder(int index)
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
@@ -1243,6 +1192,8 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers(
" index, $type$.getDefaultInstance());\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
+
+ // List<Field.Builder> getRepeatedFieldBuilderList()
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
@@ -1281,10 +1232,12 @@ void RepeatedImmutableMessageFieldGenerator::GenerateInitializationCode(
void RepeatedImmutableMessageFieldGenerator::GenerateBuilderClearCode(
io::Printer* printer) const {
PrintNestedBuilderCondition(printer,
- "$name$_ = java.util.Collections.emptyList();\n"
- "$clear_mutable_bit_builder$;\n",
+ "$name$_ = java.util.Collections.emptyList();\n",
+ "$name$_ = null;\n"
"$name$Builder_.clear();\n");
+
+ printer->Print(variables_, "$clear_mutable_bit_builder$;\n");
}
void RepeatedImmutableMessageFieldGenerator::GenerateMergingCode(
@@ -1339,34 +1292,25 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuildingCode(
"result.$name$_ = $name$Builder_.build();\n");
}
-void RepeatedImmutableMessageFieldGenerator::GenerateParsingCode(
+void RepeatedImmutableMessageFieldGenerator::GenerateBuilderParsingCode(
io::Printer* printer) const {
- printer->Print(variables_,
- "if (!$get_mutable_bit_parser$) {\n"
- " $name$_ = new java.util.ArrayList<$type$>();\n"
- " $set_mutable_bit_parser$;\n"
- "}\n");
-
if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) {
- printer->Print(
- variables_,
- "$name$_.add(input.readGroup($number$, $type$.$get_parser$,\n"
- " extensionRegistry));\n");
+ printer->Print(variables_,
+ "$type$ m =\n"
+ " input.readGroup($number$,\n"
+ " $type$.$get_parser$,\n"
+ " extensionRegistry);\n");
} else {
- printer->Print(
- variables_,
- "$name$_.add(\n"
- " input.readMessage($type$.$get_parser$, extensionRegistry));\n");
+ printer->Print(variables_,
+ "$type$ m =\n"
+ " input.readMessage(\n"
+ " $type$.$get_parser$,\n"
+ " extensionRegistry);\n");
}
-}
-
-void RepeatedImmutableMessageFieldGenerator::GenerateParsingDoneCode(
- io::Printer* printer) const {
- printer->Print(
- variables_,
- "if ($get_mutable_bit_parser$) {\n"
- " $name$_ = java.util.Collections.unmodifiableList($name$_);\n"
- "}\n");
+ PrintNestedBuilderCondition(printer,
+ "ensure$capitalized_name$IsMutable();\n"
+ "$name$_.add(m);\n",
+ "$name$Builder_.addMessage(m);\n");
}
void RepeatedImmutableMessageFieldGenerator::GenerateSerializationCode(
@@ -1419,12 +1363,12 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(variables_,
- "$kt_deprecation$ val $kt_name$: "
+ "$kt_deprecation$ public val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -1433,70 +1377,70 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
" )\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$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);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: $kt_type$) {\n"
" add(value)\n"
"}\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$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);
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$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);
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
+ "public operator fun com.google.protobuf.kotlin.DslList"
"<$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);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
@@ -1508,4 +1452,4 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field.h
index 602612e4ada..6e3e2c479d0 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field.h
@@ -35,10 +35,9 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_H__
-#include <map>
#include <string>
-#include <google/protobuf/compiler/java/field.h>
+#include "google/protobuf/compiler/java/field.h"
namespace google {
namespace protobuf {
@@ -62,10 +61,16 @@ class ImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
int messageBitIndex,
int builderBitIndex,
Context* context);
+ ImmutableMessageFieldGenerator(const ImmutableMessageFieldGenerator&) =
+ delete;
+ ImmutableMessageFieldGenerator& operator=(
+ const ImmutableMessageFieldGenerator&) = delete;
~ImmutableMessageFieldGenerator() override;
// implements ImmutableFieldGenerator
// ---------------------------------------
+ int GetMessageBitIndex() const override;
+ int GetBuilderBitIndex() const override;
int GetNumBitsForMessage() const override;
int GetNumBitsForBuilder() const override;
void GenerateInterfaceMembers(io::Printer* printer) const override;
@@ -75,8 +80,7 @@ class ImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
void GenerateBuilderClearCode(io::Printer* printer) const override;
void GenerateMergingCode(io::Printer* printer) const override;
void GenerateBuildingCode(io::Printer* printer) const override;
- void GenerateParsingCode(io::Printer* printer) const override;
- void GenerateParsingDoneCode(io::Printer* printer) const override;
+ void GenerateBuilderParsingCode(io::Printer* printer) const override;
void GenerateSerializationCode(io::Printer* printer) const override;
void GenerateSerializedSizeCode(io::Printer* printer) const override;
void GenerateFieldBuilderInitializationCode(
@@ -89,20 +93,22 @@ class ImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
protected:
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ int message_bit_index_;
+ int builder_bit_index_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables_;
ClassNameResolver* name_resolver_;
+ Context* context_;
- void PrintNestedBuilderCondition(io::Printer* printer,
- const char* regular_case,
- const char* nested_builder_case) const;
- void PrintNestedBuilderFunction(io::Printer* printer,
- const char* method_prototype,
- const char* regular_case,
- const char* nested_builder_case,
- const char* trailing_code) const;
+ virtual void PrintNestedBuilderCondition(
+ io::Printer* printer, const char* regular_case,
+ const char* nested_builder_case) const;
+ virtual void PrintNestedBuilderFunction(io::Printer* printer,
+ const char* method_prototype,
+ const char* regular_case,
+ const char* nested_builder_case,
+ const char* trailing_code) const;
private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageFieldGenerator);
void GenerateKotlinOrNull(io::Printer* printer) const;
};
@@ -112,25 +118,32 @@ class ImmutableMessageOneofFieldGenerator
ImmutableMessageOneofFieldGenerator(const FieldDescriptor* descriptor,
int messageBitIndex, int builderBitIndex,
Context* context);
+ ImmutableMessageOneofFieldGenerator(
+ const ImmutableMessageOneofFieldGenerator&) = delete;
+ ImmutableMessageOneofFieldGenerator& operator=(
+ const ImmutableMessageOneofFieldGenerator&) = delete;
~ImmutableMessageOneofFieldGenerator() override;
void GenerateMembers(io::Printer* printer) const override;
void GenerateBuilderMembers(io::Printer* printer) const override;
+ void GenerateBuilderClearCode(io::Printer* printer) const override;
void GenerateBuildingCode(io::Printer* printer) const override;
void GenerateMergingCode(io::Printer* printer) const override;
- void GenerateParsingCode(io::Printer* printer) const override;
+ void GenerateBuilderParsingCode(io::Printer* printer) const override;
void GenerateSerializationCode(io::Printer* printer) const override;
void GenerateSerializedSizeCode(io::Printer* printer) const override;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageOneofFieldGenerator);
};
-class RepeatedImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
+class RepeatedImmutableMessageFieldGenerator
+ : public ImmutableMessageFieldGenerator {
public:
explicit RepeatedImmutableMessageFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex,
int builderBitIndex, Context* context);
+ RepeatedImmutableMessageFieldGenerator(
+ const RepeatedImmutableMessageFieldGenerator&) = delete;
+ RepeatedImmutableMessageFieldGenerator& operator=(
+ const RepeatedImmutableMessageFieldGenerator&) = delete;
~RepeatedImmutableMessageFieldGenerator() override;
// implements ImmutableFieldGenerator ---------------------------------------
@@ -143,8 +156,7 @@ class RepeatedImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
void GenerateBuilderClearCode(io::Printer* printer) const override;
void GenerateMergingCode(io::Printer* printer) const override;
void GenerateBuildingCode(io::Printer* printer) const override;
- void GenerateParsingCode(io::Printer* printer) const override;
- void GenerateParsingDoneCode(io::Printer* printer) const override;
+ void GenerateBuilderParsingCode(io::Printer* printer) const override;
void GenerateSerializationCode(io::Printer* printer) const override;
void GenerateSerializedSizeCode(io::Printer* printer) const override;
void GenerateFieldBuilderInitializationCode(
@@ -156,21 +168,14 @@ class RepeatedImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
TProtoStringType GetBoxedType() const override;
protected:
- const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
- ClassNameResolver* name_resolver_;
-
- void PrintNestedBuilderCondition(io::Printer* printer,
- const char* regular_case,
- const char* nested_builder_case) const;
+ void PrintNestedBuilderCondition(
+ io::Printer* printer, const char* regular_case,
+ const char* nested_builder_case) const override;
void PrintNestedBuilderFunction(io::Printer* printer,
const char* method_prototype,
const char* regular_case,
const char* nested_builder_case,
- const char* trailing_code) const;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableMessageFieldGenerator);
+ const char* trailing_code) const override;
};
} // namespace java
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field_lite.cc
index 23d3c410f6d..08cb34094ce 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field_lite.cc
@@ -32,22 +32,21 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/message_field_lite.h>
+#include "google/protobuf/compiler/java/message_field_lite.h"
#include <cstdint>
-#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/context.h>
-#include <google/protobuf/compiler/java/doc_comment.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/name_resolver.h>
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/java/context.h"
+#include "google/protobuf/compiler/java/doc_comment.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/name_resolver.h"
+#include "google/protobuf/io/printer.h"
+#include "google/protobuf/wire_format.h"
// Must be last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -56,15 +55,16 @@ namespace java {
namespace {
-void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
- int builderBitIndex, const FieldGeneratorInfo* info,
- ClassNameResolver* name_resolver,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+void SetMessageVariables(
+ const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
+ const FieldGeneratorInfo* info, ClassNameResolver* name_resolver,
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables,
+ Context* context) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["type"] =
name_resolver->GetImmutableClassName(descriptor->message_type());
- (*variables)["kt_type"] = (*variables)["type"];
+ variables->insert({"kt_type", EscapeKotlinKeywords((*variables)["type"])});
(*variables)["mutable_type"] =
name_resolver->GetMutableClassName(descriptor->message_type());
(*variables)["group_or_message"] =
@@ -74,11 +74,12 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
// by the proto compiler
(*variables)["deprecation"] =
descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
- (*variables)["kt_deprecation"] =
- descriptor->options().deprecated()
- ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
- " is deprecated\") "
- : "";
+ variables->insert(
+ {"kt_deprecation",
+ descriptor->options().deprecated()
+ ? y_absl::StrCat("@kotlin.Deprecated(message = \"Field ",
+ (*variables)["name"], " is deprecated\") ")
+ : ""});
(*variables)["required"] = descriptor->is_required() ? "true" : "false";
if (HasHasbit(descriptor)) {
@@ -87,17 +88,17 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
// Note that these have a trailing ";".
(*variables)["set_has_field_bit_message"] =
- GenerateSetBit(messageBitIndex) + ";";
+ y_absl::StrCat(GenerateSetBit(messageBitIndex), ";");
(*variables)["clear_has_field_bit_message"] =
- GenerateClearBit(messageBitIndex) + ";";
+ y_absl::StrCat(GenerateClearBit(messageBitIndex), ";");
(*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
} else {
(*variables)["set_has_field_bit_message"] = "";
(*variables)["clear_has_field_bit_message"] = "";
- (*variables)["is_field_present_message"] =
- (*variables)["name"] + "_ != null";
+ variables->insert({"is_field_present_message",
+ y_absl::StrCat((*variables)["name"], "_ != null")});
}
(*variables)["get_has_field_bit_from_local"] =
@@ -108,6 +109,9 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
// We use `x.getClass()` as a null check because it generates less bytecode
// than an `if (x == null) { throw ... }` statement.
(*variables)["null_check"] = "value.getClass();\n";
+ // Annotations often use { and } to determine ranges.
+ (*variables)["{"] = "";
+ (*variables)["}"] = "";
}
} // namespace
@@ -118,10 +122,11 @@ ImmutableMessageFieldLiteGenerator::ImmutableMessageFieldLiteGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, Context* context)
: descriptor_(descriptor),
messageBitIndex_(messageBitIndex),
- name_resolver_(context->GetNameResolver()) {
+ name_resolver_(context->GetNameResolver()),
+ context_(context) {
SetMessageVariables(descriptor, messageBitIndex, 0,
context->GetFieldGeneratorInfo(descriptor),
- name_resolver_, &variables_);
+ name_resolver_, &variables_, context);
}
ImmutableMessageFieldLiteGenerator::~ImmutableMessageFieldLiteGenerator() {}
@@ -137,9 +142,13 @@ int ImmutableMessageFieldLiteGenerator::GetNumBitsForMessage() const {
void ImmutableMessageFieldLiteGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_, "$deprecation$boolean has$capitalized_name$();\n");
+ printer->Print(variables_,
+ "$deprecation$boolean ${$has$capitalized_name$$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_, "$deprecation$$type$ get$capitalized_name$();\n");
+ printer->Print(variables_,
+ "$deprecation$$type$ ${$get$capitalized_name$$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
}
void ImmutableMessageFieldLiteGenerator::GenerateMembers(
@@ -288,9 +297,9 @@ void ImmutableMessageFieldLiteGenerator::GenerateBuilderMembers(
void ImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(variables_,
- "$kt_deprecation$var $kt_name$: $kt_type$\n"
+ "$kt_deprecation$public var $kt_name$: $kt_type$\n"
" @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
" get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
" @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
@@ -299,16 +308,17 @@ void ImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
" }\n");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "public fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER,
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
" return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
"}\n");
GenerateKotlinOrNull(printer);
@@ -317,7 +327,7 @@ void ImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
void ImmutableMessageFieldLiteGenerator::GenerateKotlinOrNull(io::Printer* printer) const {
if (descriptor_->has_optional_keyword()) {
printer->Print(variables_,
- "val $classname$Kt.Dsl.$name$OrNull: $kt_type$?\n"
+ "public val $classname$Kt.Dsl.$name$OrNull: $kt_type$?\n"
" get() = $kt_dsl_builder$.$name$OrNull\n");
}
}
@@ -495,10 +505,12 @@ RepeatedImmutableMessageFieldLiteGenerator::
RepeatedImmutableMessageFieldLiteGenerator(
const FieldDescriptor* descriptor, int messageBitIndex,
Context* context)
- : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
+ : descriptor_(descriptor),
+ name_resolver_(context->GetNameResolver()),
+ context_(context) {
SetMessageVariables(descriptor, messageBitIndex, 0,
context->GetFieldGeneratorInfo(descriptor),
- name_resolver_, &variables_);
+ name_resolver_, &variables_, context);
}
RepeatedImmutableMessageFieldLiteGenerator::
@@ -517,17 +529,28 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateInterfaceMembers(
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$java.util.List<$type$> \n"
- " get$capitalized_name$List();\n");
+ " ${$get$capitalized_name$List$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$deprecation$$type$ get$capitalized_name$(int index);\n");
+ printer->Print(
+ variables_,
+ "$deprecation$$type$ ${$get$capitalized_name$$}$(int index);\n");
+ printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$deprecation$int get$capitalized_name$Count();\n");
+ "$deprecation$int ${$get$capitalized_name$Count$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
}
void RepeatedImmutableMessageFieldLiteGenerator::GenerateMembers(
io::Printer* printer) const {
+ if (!context_->options().opensource_runtime) {
+ printer->Print(
+ variables_,
+ "@com.google.protobuf.ProtoField(\n"
+ " fieldNumber=$number$,\n"
+ " type=com.google.protobuf.FieldType.$annotation_field_type$)\n");
+ }
printer->Print(
variables_,
"private com.google.protobuf.Internal.ProtobufList<$type$> $name$_;\n");
@@ -806,12 +829,12 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(variables_,
- "$kt_deprecation$ val $kt_name$: "
+ "$kt_deprecation$ public val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -820,70 +843,70 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
" )\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$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);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: $kt_type$) {\n"
" add(value)\n"
"}\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$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);
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$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);
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
+ "public operator fun com.google.protobuf.kotlin.DslList"
"<$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);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
@@ -895,4 +918,4 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field_lite.h
index 5bf9607bc8e..8bcc550f47e 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field_lite.h
@@ -36,10 +36,9 @@
#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_LITE_H__
#include <cstdint>
-#include <map>
#include <string>
-#include <google/protobuf/compiler/java/field.h>
+#include "google/protobuf/compiler/java/field.h"
namespace google {
namespace protobuf {
@@ -62,6 +61,10 @@ class ImmutableMessageFieldLiteGenerator : public ImmutableFieldLiteGenerator {
explicit ImmutableMessageFieldLiteGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
Context* context);
+ ImmutableMessageFieldLiteGenerator(
+ const ImmutableMessageFieldLiteGenerator&) = delete;
+ ImmutableMessageFieldLiteGenerator& operator=(
+ const ImmutableMessageFieldLiteGenerator&) = delete;
~ImmutableMessageFieldLiteGenerator() override;
// implements ImmutableFieldLiteGenerator
@@ -79,12 +82,12 @@ class ImmutableMessageFieldLiteGenerator : public ImmutableFieldLiteGenerator {
protected:
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables_;
const int messageBitIndex_;
ClassNameResolver* name_resolver_;
+ Context* context_;
private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageFieldLiteGenerator);
void GenerateKotlinOrNull(io::Printer* printer) const;
};
@@ -94,6 +97,10 @@ class ImmutableMessageOneofFieldLiteGenerator
ImmutableMessageOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
Context* context);
+ ImmutableMessageOneofFieldLiteGenerator(
+ const ImmutableMessageOneofFieldLiteGenerator&) = delete;
+ ImmutableMessageOneofFieldLiteGenerator& operator=(
+ const ImmutableMessageOneofFieldLiteGenerator&) = delete;
~ImmutableMessageOneofFieldLiteGenerator() override;
void GenerateMembers(io::Printer* printer) const override;
@@ -101,8 +108,6 @@ class ImmutableMessageOneofFieldLiteGenerator
void GenerateFieldInfo(io::Printer* printer,
std::vector<uint16_t>* output) const override;
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageOneofFieldLiteGenerator);
};
class RepeatedImmutableMessageFieldLiteGenerator
@@ -110,6 +115,10 @@ class RepeatedImmutableMessageFieldLiteGenerator
public:
explicit RepeatedImmutableMessageFieldLiteGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
+ RepeatedImmutableMessageFieldLiteGenerator(
+ const RepeatedImmutableMessageFieldLiteGenerator&) = delete;
+ RepeatedImmutableMessageFieldLiteGenerator& operator=(
+ const RepeatedImmutableMessageFieldLiteGenerator&) = delete;
~RepeatedImmutableMessageFieldLiteGenerator() override;
// implements ImmutableFieldLiteGenerator ------------------------------------
@@ -126,11 +135,9 @@ class RepeatedImmutableMessageFieldLiteGenerator
protected:
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables_;
ClassNameResolver* name_resolver_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableMessageFieldLiteGenerator);
+ Context* context_;
};
} // namespace java
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/message_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_lite.cc
index 90bd4b2382a..83065115452 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/message_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_lite.cc
@@ -32,32 +32,34 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/message_lite.h>
+#include "google/protobuf/compiler/java/message_lite.h"
#include <algorithm>
#include <cstdint>
-#include <map>
#include <memory>
+#include <string>
#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/context.h>
-#include <google/protobuf/compiler/java/doc_comment.h>
-#include <google/protobuf/compiler/java/enum_lite.h>
-#include <google/protobuf/compiler/java/extension_lite.h>
-#include <google/protobuf/compiler/java/generator_factory.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/message_builder.h>
-#include <google/protobuf/compiler/java/message_builder_lite.h>
-#include <google/protobuf/compiler/java/name_resolver.h>
-#include <google/protobuf/descriptor.pb.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/substitute.h"
+#include "google/protobuf/compiler/java/context.h"
+#include "google/protobuf/compiler/java/doc_comment.h"
+#include "google/protobuf/compiler/java/enum_lite.h"
+#include "google/protobuf/compiler/java/extension_lite.h"
+#include "google/protobuf/compiler/java/generator_factory.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/message_builder.h"
+#include "google/protobuf/compiler/java/message_builder_lite.h"
+#include "google/protobuf/compiler/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"
// Must be last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -74,12 +76,13 @@ ImmutableMessageLiteGenerator::ImmutableMessageLiteGenerator(
context_(context),
name_resolver_(context->GetNameResolver()),
field_generators_(descriptor, context_) {
- GOOGLE_CHECK(!HasDescriptorMethods(descriptor->file(), context->EnforceLite()))
+ Y_ABSL_CHECK(!HasDescriptorMethods(descriptor->file(), context->EnforceLite()))
<< "Generator factory error: A lite message generator is used to "
"generate non-lite messages.";
for (int i = 0; i < descriptor_->field_count(); i++) {
if (IsRealOneof(descriptor_->field(i))) {
- oneofs_.insert(descriptor_->field(i)->containing_oneof());
+ const OneofDescriptor* oneof = descriptor_->field(i)->containing_oneof();
+ Y_ABSL_CHECK(oneofs_.emplace(oneof->index(), oneof).first->second == oneof);
}
}
}
@@ -114,26 +117,33 @@ int ImmutableMessageLiteGenerator::GenerateStaticVariableInitializers(
void ImmutableMessageLiteGenerator::GenerateInterface(io::Printer* printer) {
MaybePrintGeneratedAnnotation(context_, printer, descriptor_,
/* immutable = */ true, "OrBuilder");
+
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables = {
+ {"{", ""},
+ {"}", ""},
+ {"deprecation",
+ descriptor_->options().deprecated() ? "@java.lang.Deprecated " : ""},
+ {"extra_interfaces", ExtraMessageOrBuilderInterfaces(descriptor_)},
+ {"classname", descriptor_->name()},
+ };
+
+ if (!context_->options().opensource_runtime) {
+ printer->Print("@com.google.protobuf.Internal.ProtoNonnullApi\n");
+ }
if (descriptor_->extension_range_count() > 0) {
printer->Print(
+ variables,
"$deprecation$public interface ${$$classname$OrBuilder$}$ extends \n"
" $extra_interfaces$\n"
" com.google.protobuf.GeneratedMessageLite.\n"
" ExtendableMessageOrBuilder<\n"
- " $classname$, $classname$.Builder> {\n",
- "deprecation",
- descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "",
- "extra_interfaces", ExtraMessageOrBuilderInterfaces(descriptor_),
- "classname", descriptor_->name(), "{", "", "}", "");
+ " $classname$, $classname$.Builder> {\n");
} else {
printer->Print(
+ variables,
"$deprecation$public interface ${$$classname$OrBuilder$}$ extends\n"
" $extra_interfaces$\n"
- " com.google.protobuf.MessageLiteOrBuilder {\n",
- "deprecation",
- descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "",
- "extra_interfaces", ExtraMessageOrBuilderInterfaces(descriptor_),
- "classname", descriptor_->name(), "{", "", "}", "");
+ " com.google.protobuf.MessageLiteOrBuilder {\n");
}
printer->Annotate("{", "}", descriptor_);
@@ -143,14 +153,17 @@ void ImmutableMessageLiteGenerator::GenerateInterface(io::Printer* printer) {
field_generators_.get(descriptor_->field(i))
.GenerateInterfaceMembers(printer);
}
- for (auto oneof : oneofs_) {
- printer->Print(
- "\n"
- "public $classname$.$oneof_capitalized_name$Case "
- "get$oneof_capitalized_name$Case();\n",
- "oneof_capitalized_name",
- context_->GetOneofGeneratorInfo(oneof)->capitalized_name, "classname",
- context_->GetNameResolver()->GetImmutableClassName(descriptor_));
+ for (auto& kv : oneofs_) {
+ const OneofDescriptor* oneof = kv.second;
+ variables["oneof_capitalized_name"] =
+ context_->GetOneofGeneratorInfo(oneof)->capitalized_name;
+ variables["classname"] =
+ context_->GetNameResolver()->GetImmutableClassName(descriptor_);
+ printer->Print(variables,
+ "\n"
+ "public ${$$classname$.$oneof_capitalized_name$Case$}$ "
+ "get$oneof_capitalized_name$Case();\n");
+ printer->Annotate("{", "}", oneof);
}
printer->Outdent();
@@ -162,7 +175,8 @@ void ImmutableMessageLiteGenerator::GenerateInterface(io::Printer* printer) {
void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
bool is_own_file = IsOwnFile(descriptor_, /* immutable = */ true);
- std::map<TProtoStringType, TProtoStringType> variables;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables = {{"{", ""},
+ {"}", ""}};
variables["static"] = is_own_file ? " " : " static ";
variables["classname"] = descriptor_->name();
variables["extra_interfaces"] = ExtraMessageInterfaces(descriptor_);
@@ -179,18 +193,18 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
if (descriptor_->extension_range_count() > 0) {
printer->Print(
variables,
- "$deprecation$public $static$final class $classname$ extends\n"
+ "$deprecation$public $static$final class ${$$classname$$}$ extends\n"
" com.google.protobuf.GeneratedMessageLite.ExtendableMessage<\n"
" $classname$, $classname$.Builder> implements\n"
" $extra_interfaces$\n"
" $classname$OrBuilder {\n");
- builder_type = strings::Substitute(
+ builder_type = y_absl::Substitute(
"com.google.protobuf.GeneratedMessageLite.ExtendableBuilder<$0, ?>",
name_resolver_->GetImmutableClassName(descriptor_));
} else {
printer->Print(
variables,
- "$deprecation$public $static$final class $classname$ extends\n"
+ "$deprecation$public $static$final class ${$$classname$$}$ extends\n"
" com.google.protobuf.GeneratedMessageLite<\n"
" $classname$, $classname$.Builder> implements\n"
" $extra_interfaces$\n"
@@ -198,6 +212,7 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
builder_type = "com.google.protobuf.GeneratedMessageLite.Builder";
}
+ printer->Annotate("{", "}", descriptor_);
printer->Indent();
GenerateConstructor(printer);
@@ -230,49 +245,59 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
}
// oneof
- std::map<TProtoStringType, TProtoStringType> vars;
- for (auto oneof : oneofs_) {
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars = {{"{", ""},
+ {"}", ""}};
+ for (auto& kv : oneofs_) {
+ const OneofDescriptor* oneof = kv.second;
vars["oneof_name"] = context_->GetOneofGeneratorInfo(oneof)->name;
vars["oneof_capitalized_name"] =
context_->GetOneofGeneratorInfo(oneof)->capitalized_name;
- vars["oneof_index"] = StrCat((oneof)->index());
- // oneofCase_ and oneof_
- printer->Print(vars,
- "private int $oneof_name$Case_ = 0;\n"
- "private java.lang.Object $oneof_name$_;\n");
+ vars["oneof_index"] = y_absl::StrCat((oneof)->index());
+ if (context_->options().opensource_runtime) {
+ // oneofCase_ and oneof_
+ printer->Print(vars,
+ "private int $oneof_name$Case_ = 0;\n"
+ "private java.lang.Object $oneof_name$_;\n");
+ }
// OneofCase enum
- printer->Print(vars, "public enum $oneof_capitalized_name$Case {\n");
+ printer->Print(vars, "public enum ${$$oneof_capitalized_name$Case$}$ {\n");
+ printer->Annotate("{", "}", oneof);
printer->Indent();
for (int j = 0; j < (oneof)->field_count(); j++) {
const FieldDescriptor* field = (oneof)->field(j);
printer->Print("$field_name$($field_number$),\n", "field_name",
- ToUpper(field->name()), "field_number",
- StrCat(field->number()));
+ y_absl::AsciiStrToUpper(field->name()), "field_number",
+ y_absl::StrCat(field->number()));
+ printer->Annotate("field_name", field);
}
printer->Print("$cap_oneof_name$_NOT_SET(0);\n", "cap_oneof_name",
- ToUpper(vars["oneof_name"]));
+ y_absl::AsciiStrToUpper(vars["oneof_name"]));
printer->Print(vars,
"private final int value;\n"
"private $oneof_capitalized_name$Case(int value) {\n"
" this.value = value;\n"
"}\n");
+ if (context_->options().opensource_runtime) {
+ printer->Print(
+ vars,
+ "/**\n"
+ " * @deprecated Use {@link #forNumber(int)} instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "public static $oneof_capitalized_name$Case valueOf(int value) {\n"
+ " return forNumber(value);\n"
+ "}\n"
+ "\n");
+ }
printer->Print(
vars,
- "/**\n"
- " * @deprecated Use {@link #forNumber(int)} instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "public static $oneof_capitalized_name$Case valueOf(int value) {\n"
- " return forNumber(value);\n"
- "}\n"
- "\n"
"public static $oneof_capitalized_name$Case forNumber(int value) {\n"
" switch (value) {\n");
for (int j = 0; j < (oneof)->field_count(); j++) {
const FieldDescriptor* field = (oneof)->field(j);
printer->Print(" case $field_number$: return $field_name$;\n",
- "field_number", StrCat(field->number()),
- "field_name", ToUpper(field->name()));
+ "field_number", y_absl::StrCat(field->number()),
+ "field_name", y_absl::AsciiStrToUpper(field->name()));
}
printer->Print(
" case 0: return $cap_oneof_name$_NOT_SET;\n"
@@ -284,30 +309,34 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
"public int getNumber() {\n"
" return this.value;\n"
"}\n",
- "cap_oneof_name", ToUpper(vars["oneof_name"]));
+ "cap_oneof_name", y_absl::AsciiStrToUpper(vars["oneof_name"]));
printer->Outdent();
printer->Print("};\n\n");
// oneofCase()
printer->Print(vars,
"@java.lang.Override\n"
"public $oneof_capitalized_name$Case\n"
- "get$oneof_capitalized_name$Case() {\n"
+ "${$get$oneof_capitalized_name$Case$}$() {\n"
" return $oneof_capitalized_name$Case.forNumber(\n"
" $oneof_name$Case_);\n"
- "}\n"
+ "}\n");
+ printer->Annotate("{", "}", oneof);
+ printer->Print(vars,
"\n"
- "private void clear$oneof_capitalized_name$() {\n"
+ "private void ${$clear$oneof_capitalized_name$$}$() {\n"
" $oneof_name$Case_ = 0;\n"
" $oneof_name$_ = null;\n"
"}\n"
"\n");
+ printer->Annotate("{", "}", oneof);
}
// Fields
for (int i = 0; i < descriptor_->field_count(); i++) {
printer->Print("public static final int $constant_name$ = $number$;\n",
"constant_name", FieldConstantName(descriptor_->field(i)),
- "number", StrCat(descriptor_->field(i)->number()));
+ "number", y_absl::StrCat(descriptor_->field(i)->number()));
+ printer->Annotate("constant_name", descriptor_->field(i));
field_generators_.get(descriptor_->field(i)).GenerateMembers(printer);
printer->Print("\n");
}
@@ -496,11 +525,11 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodNewBuildMessageInfo(
// Record the number of oneofs.
WriteIntToUtf16CharSequence(oneofs_.size(), &chars);
- for (auto oneof : oneofs_) {
+ for (auto& kv : oneofs_) {
printer->Print(
"\"$oneof_name$_\",\n"
"\"$oneof_name$Case_\",\n",
- "oneof_name", context_->GetOneofGeneratorInfo(oneof)->name);
+ "oneof_name", context_->GetOneofGeneratorInfo(kv.second)->name);
}
// Integers for bit fields.
@@ -734,10 +763,10 @@ void ImmutableMessageLiteGenerator::GenerateKotlinDsl(
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
"@com.google.protobuf.kotlin.ProtoDslMarker\n");
printer->Print(
- "class Dsl private constructor(\n"
+ "public class Dsl private constructor(\n"
" private val _builder: $message$.Builder\n"
") {\n"
- " companion object {\n"
+ " public companion object {\n"
" @kotlin.jvm.JvmSynthetic\n"
" @kotlin.PublishedApi\n"
" internal fun _create(builder: $message$.Builder): Dsl = "
@@ -747,7 +776,8 @@ void ImmutableMessageLiteGenerator::GenerateKotlinDsl(
" @kotlin.jvm.JvmSynthetic\n"
" @kotlin.PublishedApi\n"
" internal fun _build(): $message$ = _builder.build()\n",
- "message", name_resolver_->GetClassName(descriptor_, true));
+ "message",
+ EscapeKotlinKeywords(name_resolver_->GetClassName(descriptor_, true)));
printer->Indent();
@@ -757,18 +787,19 @@ void ImmutableMessageLiteGenerator::GenerateKotlinDsl(
.GenerateKotlinDslMembers(printer);
}
- for (auto oneof : oneofs_) {
+ for (auto& kv : oneofs_) {
+ const OneofDescriptor* oneof = kv.second;
printer->Print(
- "val $oneof_name$Case: $message$.$oneof_capitalized_name$Case\n"
+ "public val $oneof_name$Case: $message$.$oneof_capitalized_name$Case\n"
" @JvmName(\"get$oneof_capitalized_name$Case\")\n"
" get() = _builder.get$oneof_capitalized_name$Case()\n\n"
- "fun clear$oneof_capitalized_name$() {\n"
+ "public fun clear$oneof_capitalized_name$() {\n"
" _builder.clear$oneof_capitalized_name$()\n"
"}\n",
"oneof_name", context_->GetOneofGeneratorInfo(oneof)->name,
"oneof_capitalized_name",
context_->GetOneofGeneratorInfo(oneof)->capitalized_name, "message",
- name_resolver_->GetClassName(descriptor_, true));
+ EscapeKotlinKeywords(name_resolver_->GetClassName(descriptor_, true)));
}
if (descriptor_->extension_range_count() > 0) {
@@ -781,18 +812,24 @@ void ImmutableMessageLiteGenerator::GenerateKotlinDsl(
void ImmutableMessageLiteGenerator::GenerateKotlinMembers(
io::Printer* printer) const {
+ printer->Print("@kotlin.jvm.JvmName(\"-initialize$camelcase_name$\")\n",
+ "camelcase_name",
+ name_resolver_->GetKotlinFactoryName(descriptor_));
+
printer->Print(
- "@kotlin.jvm.JvmName(\"-initialize$camelcase_name$\")\n"
- "inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> "
- "kotlin.Unit): "
- "$message$ =\n"
+ "public inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> "
+ "kotlin.Unit): $message$ =\n"
" $message_kt$.Dsl._create($message$.newBuilder()).apply { block() "
"}._build()\n",
"camelcase_name", name_resolver_->GetKotlinFactoryName(descriptor_),
- "message_kt", name_resolver_->GetKotlinExtensionsClassName(descriptor_),
- "message", name_resolver_->GetClassName(descriptor_, true));
-
- printer->Print("object $name$Kt {\n", "name", descriptor_->name());
+ "message_kt",
+ EscapeKotlinKeywords(
+ name_resolver_->GetKotlinExtensionsClassName(descriptor_)),
+ "message",
+ EscapeKotlinKeywords(name_resolver_->GetClassName(descriptor_, true)));
+
+ WriteMessageDocComment(printer, descriptor_, /* kdoc */ true);
+ printer->Print("public object $name$Kt {\n", "name", descriptor_->name());
printer->Indent();
GenerateKotlinDsl(printer);
for (int i = 0; i < descriptor_->nested_type_count(); i++) {
@@ -807,13 +844,15 @@ void ImmutableMessageLiteGenerator::GenerateKotlinMembers(
void ImmutableMessageLiteGenerator::GenerateTopLevelKotlinMembers(
io::Printer* printer) const {
printer->Print(
- "inline fun $message$.copy(block: $message_kt$.Dsl.() -> "
- "kotlin.Unit): "
- "$message$ =\n"
+ "public inline fun $message$.copy(block: $message_kt$.Dsl.() -> "
+ "kotlin.Unit): $message$ =\n"
" $message_kt$.Dsl._create(this.toBuilder()).apply { block() "
"}._build()\n\n",
- "message", name_resolver_->GetClassName(descriptor_, true), "message_kt",
- name_resolver_->GetKotlinExtensionsClassName(descriptor_));
+ "message",
+ EscapeKotlinKeywords(name_resolver_->GetClassName(descriptor_, true)),
+ "message_kt",
+ EscapeKotlinKeywords(
+ name_resolver_->GetKotlinExtensionsClassName(descriptor_)));
for (int i = 0; i < descriptor_->nested_type_count(); i++) {
if (IsMapEntry(descriptor_->nested_type(i))) continue;
@@ -830,30 +869,33 @@ void ImmutableMessageLiteGenerator::GenerateKotlinOrNull(io::Printer* printer) c
const FieldDescriptor* field = descriptor_->field(i);
if (field->has_presence() && GetJavaType(field) == JAVATYPE_MESSAGE) {
printer->Print(
- "val $full_classname$OrBuilder.$camelcase_name$OrNull: "
+ "public 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),
+ "full_classname",
+ EscapeKotlinKeywords(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);
+ EscapeKotlinKeywords(
+ name_resolver_->GetImmutableClassName(field->message_type())),
+ "name", context_->GetFieldGeneratorInfo(field)->capitalized_name);
}
}
}
void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
io::Printer* printer) const {
- TProtoStringType message_name = name_resolver_->GetClassName(descriptor_, true);
+ TProtoStringType message_name =
+ EscapeKotlinKeywords(name_resolver_->GetClassName(descriptor_, true));
printer->Print(
"@Suppress(\"UNCHECKED_CAST\")\n"
"@kotlin.jvm.JvmSynthetic\n"
- "operator fun <T : kotlin.Any> 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$, "
- "List<*>>) as T\n"
+ "kotlin.collections.List<*>>) as T\n"
" } else {\n"
" _builder.getExtension(extension)\n"
" }\n"
@@ -865,8 +907,9 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
"@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n"
- "operator fun <E : kotlin.Any> get(\n"
- " extension: com.google.protobuf.ExtensionLite<$message$, List<E>>\n"
+ "public operator fun <E : kotlin.Any> get(\n"
+ " extension: com.google.protobuf.ExtensionLite<$message$, "
+ "kotlin.collections.List<E>>\n"
"): com.google.protobuf.kotlin.ExtensionList<E, $message$> {\n"
" return com.google.protobuf.kotlin.ExtensionList(extension, "
"_builder.getExtension(extension))\n"
@@ -875,7 +918,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "operator fun contains(extension: "
+ "public operator fun contains(extension: "
"com.google.protobuf.ExtensionLite<$message$, *>): "
"Boolean {\n"
" return _builder.hasExtension(extension)\n"
@@ -884,7 +927,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "fun clear(extension: "
+ "public fun clear(extension: "
"com.google.protobuf.ExtensionLite<$message$, *>) "
"{\n"
" _builder.clearExtension(extension)\n"
@@ -893,8 +936,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.PublishedApi\n"
- "internal fun <T : kotlin.Any> setExtension(extension: "
+ "public fun <T : kotlin.Any> setExtension(extension: "
"com.google.protobuf.ExtensionLite<$message$, T>, "
"value: T) {\n"
" _builder.setExtension(extension, value)\n"
@@ -904,7 +946,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun <T : Comparable<T>> set(\n"
+ "public inline operator fun <T : Comparable<T>> set(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, T>,\n"
" value: T\n"
") {\n"
@@ -915,7 +957,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun set(\n"
+ "public inline operator fun set(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, "
"com.google.protobuf.ByteString>,\n"
" value: com.google.protobuf.ByteString\n"
@@ -927,7 +969,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun <T : com.google.protobuf.MessageLite> set(\n"
+ "public inline operator fun <T : com.google.protobuf.MessageLite> set(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, T>,\n"
" value: T\n"
") {\n"
@@ -937,7 +979,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "fun<E : kotlin.Any> 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",
@@ -946,7 +988,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun <E : kotlin.Any> "
+ "public inline operator fun <E : kotlin.Any> "
"com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.plusAssign"
"(value: E) {\n"
@@ -956,7 +998,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "fun<E : kotlin.Any> 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"
@@ -967,7 +1009,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun <E : kotlin.Any> "
+ "public inline operator fun <E : kotlin.Any> "
"com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.plusAssign(values: "
"Iterable<E>) {\n"
@@ -977,7 +1019,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "operator fun <E : kotlin.Any> "
+ "public operator fun <E : kotlin.Any> "
"com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.set(index: Int, value: "
"E) {\n"
@@ -988,7 +1030,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline fun com.google.protobuf.kotlin.ExtensionList<*, "
+ "public inline fun com.google.protobuf.kotlin.ExtensionList<*, "
"$message$>.clear() {\n"
" clear(extension)\n"
"}\n\n",
@@ -1000,4 +1042,4 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/message_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_lite.h
index d1e4b68949c..279404099ed 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/message_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_lite.h
@@ -35,8 +35,8 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_LITE_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_LITE_H__
-#include <google/protobuf/compiler/java/field.h>
-#include <google/protobuf/compiler/java/message.h>
+#include "google/protobuf/compiler/java/field.h"
+#include "google/protobuf/compiler/java/message.h"
namespace google {
namespace protobuf {
@@ -46,6 +46,9 @@ namespace java {
class ImmutableMessageLiteGenerator : public MessageGenerator {
public:
ImmutableMessageLiteGenerator(const Descriptor* descriptor, Context* context);
+ ImmutableMessageLiteGenerator(const ImmutableMessageLiteGenerator&) = delete;
+ ImmutableMessageLiteGenerator& operator=(
+ const ImmutableMessageLiteGenerator&) = delete;
~ImmutableMessageLiteGenerator() override;
void Generate(io::Printer* printer) override;
@@ -73,8 +76,6 @@ class ImmutableMessageLiteGenerator : public MessageGenerator {
Context* context_;
ClassNameResolver* name_resolver_;
FieldGeneratorMap<ImmutableFieldLiteGenerator> field_generators_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageLiteGenerator);
};
} // namespace java
diff --git a/contrib/libs/protobuf/src/google/protobuf/stubs/statusor.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_serialization.cc
index 9c0a1782a83..9ecfac21d05 100644
--- a/contrib/libs/protobuf/src/google/protobuf/stubs/statusor.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_serialization.cc
@@ -28,21 +28,24 @@
// (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/stubs/statusor.h>
+#include "google/protobuf/compiler/java/message_serialization.h"
-#include <google/protobuf/stubs/logging.h>
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
-namespace util {
-namespace statusor_internal {
+namespace compiler {
+namespace java {
-void StatusOrHelper::Crash(const Status& status) {
- GOOGLE_LOG(FATAL) << "Attempting to fetch value instead of handling error "
- << status.ToString();
+void GenerateSerializeExtensionRange(io::Printer* printer,
+ const Descriptor::ExtensionRange* range) {
+ printer->Print("extensionWriter.writeUntil($end$, output);\n", "end",
+ y_absl::StrCat(range->end));
}
-} // namespace statusor_internal
-} // namespace util
+} // namespace java
+} // namespace compiler
} // namespace protobuf
} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/message_serialization.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_serialization.h
new file mode 100644
index 00000000000..3b7c8461cb5
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_serialization.h
@@ -0,0 +1,103 @@
+// 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_JAVA_MESSAGE_SERIALIZATION_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_SERIALIZATION_H__
+
+#include <algorithm>
+#include <cstddef>
+#include <vector>
+
+#include "google/protobuf/compiler/java/field.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/io/printer.h"
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+// Generates code to serialize a single extension range.
+void GenerateSerializeExtensionRange(io::Printer* printer,
+ const Descriptor::ExtensionRange* range);
+
+// Generates code to serialize all fields and extension ranges for the specified
+// message descriptor, sorting serialization calls in increasing order by field
+// number.
+//
+// Templatized to support different field generator implementations.
+template <typename FieldGenerator>
+void GenerateSerializeFieldsAndExtensions(
+ io::Printer* printer,
+ const FieldGeneratorMap<FieldGenerator>& field_generators,
+ const Descriptor* descriptor, const FieldDescriptor** sorted_fields) {
+ 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(),
+ ExtensionRangeOrdering());
+
+ std::size_t range_idx = 0;
+
+ // Merge the fields and the extension ranges, both sorted by field number.
+ for (int i = 0; i < descriptor->field_count(); ++i) {
+ const FieldDescriptor* field = sorted_fields[i];
+
+ // Collapse all extension ranges up until the next field. This leads to
+ // shorter and more efficient codegen for messages containing a large
+ // number of extension ranges without fields in between them.
+ const Descriptor::ExtensionRange* range = nullptr;
+ while (range_idx < sorted_extensions.size() &&
+ sorted_extensions[range_idx]->end <= field->number()) {
+ range = sorted_extensions[range_idx++];
+ }
+
+ if (range != nullptr) {
+ GenerateSerializeExtensionRange(printer, range);
+ }
+ field_generators.get(field).GenerateSerializationCode(printer);
+ }
+
+ // After serializing all fields, serialize any remaining extensions via a
+ // single writeUntil call.
+ if (range_idx < sorted_extensions.size()) {
+ GenerateSerializeExtensionRange(printer, sorted_extensions.back());
+ }
+}
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_SERIALIZATION_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/name_resolver.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/name_resolver.cc
index 5cadecadf36..5959805240e 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/name_resolver.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/name_resolver.cc
@@ -28,18 +28,21 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <google/protobuf/compiler/java/name_resolver.h>
+#include "google/protobuf/compiler/java/name_resolver.h"
-#include <map>
#include <string>
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/stubs/substitute.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/names.h>
+#include "y_absl/log/absl_check.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/str_replace.h"
+#include "y_absl/strings/substitute.h"
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/names.h"
+
// Must be last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -56,8 +59,8 @@ const char* kOuterClassNameSuffix = "OuterClass";
// Full name : foo.Bar.Baz
// Package name: foo
// After strip : Bar.Baz
-TProtoStringType StripPackageName(const TProtoStringType& full_name,
- const FileDescriptor* file) {
+y_absl::string_view StripPackageName(y_absl::string_view full_name,
+ const FileDescriptor* file) {
if (file->package().empty()) {
return full_name;
} else {
@@ -69,7 +72,8 @@ TProtoStringType StripPackageName(const TProtoStringType& full_name,
// Get the name of a message's Java class without package name prefix.
TProtoStringType ClassNameWithoutPackage(const Descriptor* descriptor,
bool immutable) {
- return StripPackageName(descriptor->full_name(), descriptor->file());
+ return TProtoStringType(
+ StripPackageName(descriptor->full_name(), descriptor->file()));
}
TProtoStringType ClassNameWithoutPackageKotlin(const Descriptor* descriptor) {
@@ -77,7 +81,7 @@ TProtoStringType ClassNameWithoutPackageKotlin(const Descriptor* descriptor) {
const Descriptor* temp = descriptor->containing_type();
while (temp) {
- result = temp->name() + "Kt." + result;
+ result = y_absl::StrCat(temp->name(), "Kt.", result);
temp = temp->containing_type();
}
return result;
@@ -91,24 +95,24 @@ TProtoStringType ClassNameWithoutPackage(const EnumDescriptor* descriptor,
if (message_descriptor == NULL) {
return descriptor->name();
} else {
- return ClassNameWithoutPackage(message_descriptor, immutable) + "." +
- descriptor->name();
+ return y_absl::StrCat(ClassNameWithoutPackage(message_descriptor, immutable),
+ ".", descriptor->name());
}
}
// Get the name of a service's Java class without package name prefix.
TProtoStringType ClassNameWithoutPackage(const ServiceDescriptor* descriptor,
bool immutable) {
- TProtoStringType full_name =
+ y_absl::string_view full_name =
StripPackageName(descriptor->full_name(), descriptor->file());
// We don't allow nested service definitions.
- GOOGLE_CHECK(full_name.find('.') == TProtoStringType::npos);
- return full_name;
+ Y_ABSL_CHECK(!y_absl::StrContains(full_name, '.'));
+ return TProtoStringType(full_name);
}
// Return true if a and b are equals (case insensitive).
-NameEquality CheckNameEquality(const TProtoStringType& a, const TProtoStringType& b) {
- if (ToUpper(a) == ToUpper(b)) {
+NameEquality CheckNameEquality(y_absl::string_view a, y_absl::string_view b) {
+ if (y_absl::AsciiStrToUpper(a) == y_absl::AsciiStrToUpper(b)) {
if (a == b) {
return NameEquality::EXACT_EQUAL;
}
@@ -119,7 +123,7 @@ NameEquality CheckNameEquality(const TProtoStringType& a, const TProtoStringType
// Check whether a given message or its nested types has the given class name.
bool MessageHasConflictingClassName(const Descriptor* message,
- const TProtoStringType& classname,
+ y_absl::string_view classname,
NameEquality equality_mode) {
if (CheckNameEquality(message->name(), classname) == equality_mode) {
return true;
@@ -141,10 +145,6 @@ bool MessageHasConflictingClassName(const Descriptor* message,
} // namespace
-ClassNameResolver::ClassNameResolver() {}
-
-ClassNameResolver::~ClassNameResolver() {}
-
TProtoStringType ClassNameResolver::GetFileDefaultImmutableClassName(
const FileDescriptor* file) {
TProtoStringType basename;
@@ -182,18 +182,18 @@ TProtoStringType ClassNameResolver::GetFileClassName(const FileDescriptor* file,
TProtoStringType ClassNameResolver::GetFileClassName(const FileDescriptor* file,
bool immutable, bool kotlin) {
if (kotlin) {
- return GetFileImmutableClassName(file) + "Kt";
+ return y_absl::StrCat(GetFileImmutableClassName(file), "Kt");
} else if (immutable) {
return GetFileImmutableClassName(file);
} else {
- return "Mutable" + GetFileImmutableClassName(file);
+ return y_absl::StrCat("Mutable", GetFileImmutableClassName(file));
}
}
// Check whether there is any type defined in the proto file that has
// the given class name.
bool ClassNameResolver::HasConflictingClassName(const FileDescriptor* file,
- const TProtoStringType& classname,
+ y_absl::string_view classname,
NameEquality equality_mode) {
for (int i = 0; i < file->enum_type_count(); i++) {
if (CheckNameEquality(file->enum_type(i)->name(), classname) ==
@@ -217,8 +217,12 @@ bool ClassNameResolver::HasConflictingClassName(const FileDescriptor* file,
}
TProtoStringType ClassNameResolver::GetDescriptorClassName(
- const FileDescriptor* descriptor) {
- return GetFileImmutableClassName(descriptor);
+ const FileDescriptor* file) {
+ if (options_.opensource_runtime) {
+ return GetFileImmutableClassName(file);
+ } else {
+ return y_absl::StrCat(GetFileImmutableClassName(file), "InternalDescriptors");
+ }
}
TProtoStringType ClassNameResolver::GetClassName(const FileDescriptor* descriptor,
@@ -228,7 +232,7 @@ TProtoStringType ClassNameResolver::GetClassName(const FileDescriptor* descripto
TProtoStringType ClassNameResolver::GetClassName(const FileDescriptor* descriptor,
bool immutable, bool kotlin) {
- TProtoStringType result = FileJavaPackage(descriptor, immutable);
+ TProtoStringType result = FileJavaPackage(descriptor, immutable, options_);
if (!result.empty()) result += '.';
result += GetFileClassName(descriptor, immutable, kotlin);
return result;
@@ -237,26 +241,26 @@ TProtoStringType ClassNameResolver::GetClassName(const FileDescriptor* descripto
// Get the full name of a Java class by prepending the Java package name
// or outer class name.
TProtoStringType ClassNameResolver::GetClassFullName(
- const TProtoStringType& name_without_package, const FileDescriptor* file,
+ y_absl::string_view name_without_package, const FileDescriptor* file,
bool immutable, bool is_own_file) {
return GetClassFullName(name_without_package, file, immutable, is_own_file,
false);
}
TProtoStringType ClassNameResolver::GetClassFullName(
- const TProtoStringType& name_without_package, const FileDescriptor* file,
+ y_absl::string_view name_without_package, const FileDescriptor* file,
bool immutable, bool is_own_file, bool kotlin) {
TProtoStringType result;
if (is_own_file) {
- result = FileJavaPackage(file, immutable);
+ result = FileJavaPackage(file, immutable, options_);
} else {
result = GetClassName(file, immutable, kotlin);
}
if (!result.empty()) {
- result += '.';
+ y_absl::StrAppend(&result, ".");
}
- result += name_without_package;
- if (kotlin) result += "Kt";
+ y_absl::StrAppend(&result, name_without_package);
+ if (kotlin) y_absl::StrAppend(&result, "Kt");
return result;
}
@@ -298,23 +302,23 @@ TProtoStringType ClassNameResolver::GetClassName(const ServiceDescriptor* descri
// Get the Java Class style full name of a message.
TProtoStringType ClassNameResolver::GetJavaClassFullName(
- const TProtoStringType& name_without_package, const FileDescriptor* file,
+ y_absl::string_view name_without_package, const FileDescriptor* file,
bool immutable) {
return GetJavaClassFullName(name_without_package, file, immutable, false);
}
TProtoStringType ClassNameResolver::GetJavaClassFullName(
- const TProtoStringType& name_without_package, const FileDescriptor* file,
+ y_absl::string_view name_without_package, const FileDescriptor* file,
bool immutable, bool kotlin) {
TProtoStringType result;
if (MultipleJavaFiles(file, immutable)) {
- result = FileJavaPackage(file, immutable);
+ result = FileJavaPackage(file, immutable, options_);
if (!result.empty()) result += '.';
} else {
result = GetClassName(file, immutable, kotlin);
if (!result.empty()) result += '$';
}
- result += StringReplace(name_without_package, ".", "$", true);
+ result += y_absl::StrReplaceAll(name_without_package, {{".", "$"}});
return result;
}
@@ -325,14 +329,15 @@ TProtoStringType ClassNameResolver::GetExtensionIdentifierName(
TProtoStringType ClassNameResolver::GetExtensionIdentifierName(
const FieldDescriptor* descriptor, bool immutable, bool kotlin) {
- return GetClassName(descriptor->containing_type(), immutable, kotlin) + "." +
- descriptor->name();
+ return y_absl::StrCat(
+ GetClassName(descriptor->containing_type(), immutable, kotlin), ".",
+ descriptor->name());
}
TProtoStringType ClassNameResolver::GetKotlinFactoryName(
const Descriptor* descriptor) {
TProtoStringType name = ToCamelCase(descriptor->name(), /* lower_first = */ true);
- return IsForbiddenKotlin(name) ? name + "_" : name;
+ return IsForbiddenKotlin(name) ? y_absl::StrCat(name, "_") : name;
}
TProtoStringType ClassNameResolver::GetJavaImmutableClassName(
@@ -367,14 +372,14 @@ TProtoStringType ClassNameResolver::GetJavaMutableClassName(
TProtoStringType ClassNameResolver::GetDowngradedFileClassName(
const FileDescriptor* file) {
- return "Downgraded" + GetFileClassName(file, false);
+ return y_absl::StrCat("Downgraded", GetFileClassName(file, false));
}
TProtoStringType ClassNameResolver::GetDowngradedClassName(
const Descriptor* descriptor) {
- return FileJavaPackage(descriptor->file()) + "." +
- GetDowngradedFileClassName(descriptor->file()) + "." +
- ClassNameWithoutPackage(descriptor, false);
+ return y_absl::StrCat(FileJavaPackage(descriptor->file(), true, options_), ".",
+ GetDowngradedFileClassName(descriptor->file()), ".",
+ ClassNameWithoutPackage(descriptor, false));
}
} // namespace java
@@ -382,4 +387,4 @@ TProtoStringType ClassNameResolver::GetDowngradedClassName(
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/name_resolver.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/name_resolver.h
index 9744e8739f9..3fda3a076e3 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/name_resolver.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/name_resolver.h
@@ -31,13 +31,14 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_NAME_RESOLVER_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_NAME_RESOLVER_H__
-#include <map>
#include <string>
-#include <google/protobuf/stubs/common.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "google/protobuf/compiler/java/options.h"
+#include "google/protobuf/port.h"
// Must be last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -58,8 +59,11 @@ enum NameEquality { NO_MATCH, EXACT_EQUAL, EQUAL_IGNORE_CASE };
// Thread-safety note: This class is *not* thread-safe.
class ClassNameResolver {
public:
- ClassNameResolver();
- ~ClassNameResolver();
+ explicit ClassNameResolver(const Options& options = {}) : options_(options) {}
+ ~ClassNameResolver() = default;
+
+ ClassNameResolver(const ClassNameResolver&) = delete;
+ ClassNameResolver& operator=(const ClassNameResolver&) = delete;
// Gets the unqualified outer class name for the file.
TProtoStringType GetFileClassName(const FileDescriptor* file, bool immutable);
@@ -74,7 +78,7 @@ class ClassNameResolver {
// Check whether there is any type defined in the proto file that has
// the given class name.
bool HasConflictingClassName(const FileDescriptor* file,
- const TProtoStringType& classname,
+ y_absl::string_view classname,
NameEquality equality_mode);
// Gets the name of the outer class that holds descriptor information.
@@ -128,25 +132,25 @@ class ClassNameResolver {
// 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,
+ TProtoStringType GetClassFullName(y_absl::string_view name_without_package,
const FileDescriptor* file, bool immutable,
bool is_own_file);
- TProtoStringType GetClassFullName(const TProtoStringType& name_without_package,
+ TProtoStringType GetClassFullName(y_absl::string_view name_without_package,
const FileDescriptor* file, bool immutable,
bool is_own_file, bool kotlin);
+ Options options_;
+
private:
// Get the Java Class style full name of a message.
- TProtoStringType GetJavaClassFullName(const TProtoStringType& name_without_package,
+ TProtoStringType GetJavaClassFullName(y_absl::string_view name_without_package,
const FileDescriptor* file, bool immutable);
- TProtoStringType GetJavaClassFullName(const TProtoStringType& name_without_package,
+ TProtoStringType GetJavaClassFullName(y_absl::string_view name_without_package,
const FileDescriptor* file, bool immutable,
bool kotlin);
// Caches the result to provide better performance.
- std::map<const FileDescriptor*, TProtoStringType>
+ y_absl::flat_hash_map<const FileDescriptor*, TProtoStringType>
file_immutable_outer_class_names_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ClassNameResolver);
};
} // namespace java
@@ -154,6 +158,6 @@ class ClassNameResolver {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_NAME_RESOLVER_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/names.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/names.cc
new file mode 100644
index 00000000000..7b10ec5f17a
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/names.cc
@@ -0,0 +1,193 @@
+// 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: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#include "google/protobuf/compiler/java/names.h"
+
+#include <string>
+
+#include "y_absl/container/flat_hash_set.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/name_resolver.h"
+#include "google/protobuf/compiler/java/names.h"
+#include "google/protobuf/compiler/java/options.h"
+#include "google/protobuf/descriptor.pb.h"
+
+// Must be last.
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+namespace {
+
+const char* DefaultPackage(Options options) {
+ return options.opensource_runtime ? "" : "com.google.protos";
+}
+
+bool IsReservedName(y_absl::string_view name) {
+ static const auto& kReservedNames =
+ *new y_absl::flat_hash_set<y_absl::string_view>({
+ "abstract", "assert", "boolean", "break", "byte",
+ "case", "catch", "char", "class", "const",
+ "continue", "default", "do", "double", "else",
+ "enum", "extends", "final", "finally", "float",
+ "for", "goto", "if", "implements", "import",
+ "instanceof", "int", "interface", "long", "native",
+ "new", "package", "private", "protected", "public",
+ "return", "short", "static", "strictfp", "super",
+ "switch", "synchronized", "this", "throw", "throws",
+ "transient", "try", "void", "volatile", "while",
+ });
+ return kReservedNames.contains(name);
+}
+
+bool IsForbidden(y_absl::string_view field_name) {
+ // 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
+ static const auto& kForbiddenNames =
+ *new y_absl::flat_hash_set<y_absl::string_view>({
+ // java.lang.Object:
+ "Class",
+ // com.google.protobuf.MessageLiteOrBuilder:
+ "DefaultInstanceForType",
+ // com.google.protobuf.MessageLite:
+ "ParserForType",
+ "SerializedSize",
+ // com.google.protobuf.MessageOrBuilder:
+ "AllFields",
+ "DescriptorForType",
+ "InitializationErrorString",
+ "UnknownFields",
+ // obsolete. kept for backwards compatibility of generated code
+ "CachedSize",
+ });
+ return kForbiddenNames.contains(UnderscoresToCamelCase(field_name, true));
+}
+
+TProtoStringType FieldName(const FieldDescriptor* field) {
+ TProtoStringType field_name;
+ // Groups are hacky: The name of the field is just the lower-cased name
+ // of the group type. In Java, though, we would like to retain the original
+ // capitalization of the type name.
+ if (GetType(field) == FieldDescriptor::TYPE_GROUP) {
+ field_name = field->message_type()->name();
+ } else {
+ field_name = field->name();
+ }
+ if (IsForbidden(field_name)) {
+ // Append a trailing "#" to indicate that the name should be decorated to
+ // avoid collision with other names.
+ y_absl::StrAppend(&field_name, "#");
+ }
+ return field_name;
+}
+
+} // namespace
+
+TProtoStringType ClassName(const Descriptor* descriptor) {
+ ClassNameResolver name_resolver;
+ return name_resolver.GetClassName(descriptor, true);
+}
+
+TProtoStringType ClassName(const EnumDescriptor* descriptor) {
+ ClassNameResolver name_resolver;
+ return name_resolver.GetClassName(descriptor, true);
+}
+
+TProtoStringType ClassName(const ServiceDescriptor* descriptor) {
+ ClassNameResolver name_resolver;
+ return name_resolver.GetClassName(descriptor, true);
+}
+
+TProtoStringType ClassName(const FileDescriptor* descriptor) {
+ ClassNameResolver name_resolver;
+ return name_resolver.GetClassName(descriptor, true);
+}
+
+TProtoStringType FileJavaPackage(const FileDescriptor* file, bool immutable,
+ Options options) {
+ TProtoStringType result;
+
+ if (file->options().has_java_package()) {
+ result = file->options().java_package();
+ } else {
+ result = DefaultPackage(options);
+ if (!file->package().empty()) {
+ if (!result.empty()) result += '.';
+ result += file->package();
+ }
+ }
+
+ return result;
+}
+
+TProtoStringType FileJavaPackage(const FileDescriptor* file, Options options) {
+ return FileJavaPackage(file, true /* immutable */, options);
+}
+
+TProtoStringType CapitalizedFieldName(const FieldDescriptor* field) {
+ return UnderscoresToCamelCase(FieldName(field), true);
+}
+
+TProtoStringType UnderscoresToCamelCase(const FieldDescriptor* field) {
+ return UnderscoresToCamelCase(FieldName(field), false);
+}
+
+TProtoStringType UnderscoresToCapitalizedCamelCase(const FieldDescriptor* field) {
+ return UnderscoresToCamelCase(FieldName(field), true);
+}
+
+TProtoStringType UnderscoresToCamelCase(const MethodDescriptor* method) {
+ return UnderscoresToCamelCase(method->name(), false);
+}
+
+TProtoStringType UnderscoresToCamelCaseCheckReserved(const FieldDescriptor* field) {
+ TProtoStringType name = UnderscoresToCamelCase(field);
+ if (IsReservedName(name)) {
+ y_absl::StrAppend(&name, "_");
+ }
+ return name;
+}
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/names.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/names.h
index 9aeddc81cc2..2f7f1b802ed 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/names.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/names.h
@@ -40,6 +40,12 @@
#include <string>
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/compiler/java/options.h"
+
+// Must be last.
+#include "google/protobuf/port_def.inc"
+
namespace google {
namespace protobuf {
@@ -85,7 +91,8 @@ TProtoStringType ClassName(const ServiceDescriptor* descriptor);
//
// Returns:
// Java package name.
-TProtoStringType FileJavaPackage(const FileDescriptor* descriptor);
+TProtoStringType FileJavaPackage(const FileDescriptor* descriptor,
+ Options options = {});
// Requires:
// descriptor != NULL
@@ -93,8 +100,36 @@ TProtoStringType FileJavaPackage(const FileDescriptor* descriptor);
// Capitalized camel case name field name.
TProtoStringType CapitalizedFieldName(const FieldDescriptor* descriptor);
+// Returns:
+// Converts a name to camel-case. If cap_first_letter is true, capitalize the
+// first letter.
+TProtoStringType UnderscoresToCamelCase(y_absl::string_view input,
+ bool cap_next_letter);
+// Requires:
+// field != NULL
+// Returns:
+// Converts the field's name to camel-case, e.g. "foo_bar_baz" becomes
+// "fooBarBaz" or "FooBarBaz", respectively.
+TProtoStringType UnderscoresToCamelCase(const FieldDescriptor* field);
+
+// Requires:
+// method != NULL
+// Returns:
+// Similar, but for method names. (Typically, this merely has the effect
+// of lower-casing the first letter of the name.)
+TProtoStringType UnderscoresToCamelCase(const MethodDescriptor* method);
+
+// Requires:
+// field != NULL
+// Returns:
+// Same as UnderscoresToCamelCase, but checks for reserved keywords
+TProtoStringType UnderscoresToCamelCaseCheckReserved(const FieldDescriptor* field);
+
+
} // namespace java
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_NAMES_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/options.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/options.h
index 1454c232068..09364d72d70 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/options.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/options.h
@@ -32,6 +32,11 @@
#define GOOGLE_PROTOBUF_COMPILER_JAVA_OPTIONS_H__
#include <string>
+#include "util/generic/string.h"
+
+#include "google/protobuf/port_def.inc"
+
+using TProtoStringType = TString;
namespace google {
namespace protobuf {
@@ -54,6 +59,7 @@ struct Options {
// When set, the protoc will generate the current files and all the transitive
// dependencies as lite runtime.
bool enforce_lite;
+ bool opensource_runtime = PROTO2_IS_OSS;
// If true, we should build .meta files and emit @Generated annotations into
// generated code.
bool annotate_code;
@@ -70,4 +76,5 @@ struct Options {
} // namespace protobuf
} // namespace google
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_OPTIONS_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field.cc
index adb556a892a..d63cdb4ecaf 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field.cc
@@ -32,21 +32,20 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/primitive_field.h>
+#include "google/protobuf/compiler/java/primitive_field.h"
#include <cstdint>
-#include <map>
#include <string>
-#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/context.h>
-#include <google/protobuf/compiler/java/doc_comment.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/name_resolver.h>
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/java/context.h"
+#include "google/protobuf/compiler/java/doc_comment.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/name_resolver.h"
+#include "google/protobuf/io/printer.h"
+#include "google/protobuf/wire_format.h"
namespace google {
namespace protobuf {
@@ -57,71 +56,73 @@ using internal::WireFormat;
namespace {
-void SetPrimitiveVariables(const FieldDescriptor* descriptor,
- int messageBitIndex, int builderBitIndex,
- const FieldGeneratorInfo* info,
- ClassNameResolver* name_resolver,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+void SetPrimitiveVariables(
+ const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
+ const FieldGeneratorInfo* info, ClassNameResolver* name_resolver,
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables,
+ Context* context) {
SetCommonFieldVariables(descriptor, info, variables);
JavaType javaType = GetJavaType(descriptor);
- (*variables)["type"] = PrimitiveTypeName(javaType);
- (*variables)["boxed_type"] = BoxedPrimitiveTypeName(javaType);
- (*variables)["kt_type"] = KotlinTypeName(javaType);
- (*variables)["field_type"] = (*variables)["type"];
+ (*variables)["type"] = TProtoStringType(PrimitiveTypeName(javaType));
+ (*variables)["boxed_type"] = TProtoStringType(BoxedPrimitiveTypeName(javaType));
+ (*variables)["kt_type"] = TProtoStringType(KotlinTypeName(javaType));
+ variables->insert({"field_type", (*variables)["type"]});
+ TProtoStringType name = (*variables)["name"];
if (javaType == JAVATYPE_BOOLEAN || javaType == JAVATYPE_DOUBLE ||
javaType == JAVATYPE_FLOAT || javaType == JAVATYPE_INT ||
javaType == JAVATYPE_LONG) {
TProtoStringType capitalized_type = UnderscoresToCamelCase(
PrimitiveTypeName(javaType), /*cap_first_letter=*/true);
(*variables)["field_list_type"] =
- "com.google.protobuf.Internal." + capitalized_type + "List";
- (*variables)["empty_list"] = "empty" + capitalized_type + "List()";
- (*variables)["create_list"] = "new" + capitalized_type + "List()";
+ y_absl::StrCat("com.google.protobuf.Internal.", capitalized_type, "List");
+ (*variables)["empty_list"] =
+ y_absl::StrCat("empty", capitalized_type, "List()");
+ (*variables)["create_list"] =
+ y_absl::StrCat("new", capitalized_type, "List()");
(*variables)["mutable_copy_list"] =
- "mutableCopy(" + (*variables)["name"] + "_)";
+ y_absl::StrCat("mutableCopy(", name, "_)");
(*variables)["name_make_immutable"] =
- (*variables)["name"] + "_.makeImmutable()";
+ y_absl::StrCat(name, "_.makeImmutable()");
(*variables)["repeated_get"] =
- (*variables)["name"] + "_.get" + capitalized_type;
+ y_absl::StrCat(name, "_.get", capitalized_type);
(*variables)["repeated_add"] =
- (*variables)["name"] + "_.add" + capitalized_type;
+ y_absl::StrCat(name, "_.add", capitalized_type);
(*variables)["repeated_set"] =
- (*variables)["name"] + "_.set" + capitalized_type;
+ y_absl::StrCat(name, "_.set", capitalized_type);
} else {
+ TProtoStringType boxed_type = (*variables)["boxed_type"];
(*variables)["field_list_type"] =
- "java.util.List<" + (*variables)["boxed_type"] + ">";
+ y_absl::StrCat("java.util.List<", boxed_type, ">");
(*variables)["create_list"] =
- "new java.util.ArrayList<" + (*variables)["boxed_type"] + ">()";
- (*variables)["mutable_copy_list"] = "new java.util.ArrayList<" +
- (*variables)["boxed_type"] + ">(" +
- (*variables)["name"] + "_)";
+ y_absl::StrCat("new java.util.ArrayList<", boxed_type, ">()");
+ (*variables)["mutable_copy_list"] =
+ y_absl::StrCat("new java.util.ArrayList<", boxed_type, ">(", name, "_)");
(*variables)["empty_list"] = "java.util.Collections.emptyList()";
- (*variables)["name_make_immutable"] =
- (*variables)["name"] + "_ = java.util.Collections.unmodifiableList(" +
- (*variables)["name"] + "_)";
- (*variables)["repeated_get"] = (*variables)["name"] + "_.get";
- (*variables)["repeated_add"] = (*variables)["name"] + "_.add";
- (*variables)["repeated_set"] = (*variables)["name"] + "_.set";
+ (*variables)["name_make_immutable"] = y_absl::StrCat(
+ name, "_ = java.util.Collections.unmodifiableList(", name, "_)");
+ (*variables)["repeated_get"] = y_absl::StrCat(name, "_.get");
+ (*variables)["repeated_add"] = y_absl::StrCat(name, "_.add");
+ (*variables)["repeated_set"] = y_absl::StrCat(name, "_.set");
}
- (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
+ (*variables)["default"] =
+ ImmutableDefaultValue(descriptor, name_resolver, context->options());
(*variables)["default_init"] =
IsDefaultValueJavaDefault(descriptor)
? ""
- : ("= " + ImmutableDefaultValue(descriptor, name_resolver));
- (*variables)["capitalized_type"] =
- GetCapitalizedType(descriptor, /* immutable = */ true);
+ : y_absl::StrCat("= ", ImmutableDefaultValue(descriptor, name_resolver,
+ context->options()));
+ (*variables)["capitalized_type"] = TProtoStringType(GetCapitalizedType(
+ descriptor, /* immutable = */ true, context->options()));
(*variables)["tag"] =
- StrCat(static_cast<arc_i32>(WireFormat::MakeTag(descriptor)));
- (*variables)["tag_size"] = StrCat(
+ y_absl::StrCat(static_cast<arc_i32>(WireFormat::MakeTag(descriptor)));
+ (*variables)["tag_size"] = y_absl::StrCat(
WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
if (IsReferenceType(GetJavaType(descriptor))) {
(*variables)["null_check"] =
- " if (value == null) {\n"
- " throw new NullPointerException();\n"
- " }\n";
+ "if (value == null) { throw new NullPointerException(); }";
} else {
(*variables)["null_check"] = "";
}
@@ -131,52 +132,41 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
(*variables)["kt_deprecation"] =
descriptor->options().deprecated()
- ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
- " is deprecated\") "
+ ? y_absl::StrCat("@kotlin.Deprecated(message = \"Field ", name,
+ " is deprecated\") ")
: "";
int fixed_size = FixedSize(GetType(descriptor));
if (fixed_size != -1) {
- (*variables)["fixed_size"] = StrCat(fixed_size);
+ (*variables)["fixed_size"] = y_absl::StrCat(fixed_size);
}
(*variables)["on_changed"] = "onChanged();";
if (HasHasbit(descriptor)) {
// For singular messages and builders, one bit is used for the hasField bit.
(*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
- (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex);
-
// Note that these have a trailing ";".
- (*variables)["set_has_field_bit_message"] =
- GenerateSetBit(messageBitIndex) + ";";
- (*variables)["set_has_field_bit_builder"] =
- GenerateSetBit(builderBitIndex) + ";";
- (*variables)["clear_has_field_bit_builder"] =
- GenerateClearBit(builderBitIndex) + ";";
-
+ (*variables)["set_has_field_bit_to_local"] =
+ y_absl::StrCat(GenerateSetBitToLocal(messageBitIndex), ";");
(*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
} else {
- (*variables)["set_has_field_bit_message"] = "";
- (*variables)["set_has_field_bit_builder"] = "";
- (*variables)["clear_has_field_bit_builder"] = "";
-
+ (*variables)["set_has_field_bit_to_local"] = "";
switch (descriptor->type()) {
case FieldDescriptor::TYPE_BYTES:
(*variables)["is_field_present_message"] =
- "!" + (*variables)["name"] + "_.isEmpty()";
+ y_absl::StrCat("!", name, "_.isEmpty()");
break;
case FieldDescriptor::TYPE_FLOAT:
(*variables)["is_field_present_message"] =
- "java.lang.Float.floatToRawIntBits(" + (*variables)["name"] +
- "_) != 0";
+ y_absl::StrCat("java.lang.Float.floatToRawIntBits(", name, "_) != 0");
break;
case FieldDescriptor::TYPE_DOUBLE:
- (*variables)["is_field_present_message"] =
- "java.lang.Double.doubleToRawLongBits(" + (*variables)["name"] +
- "_) != 0";
+ (*variables)["is_field_present_message"] = y_absl::StrCat(
+ "java.lang.Double.doubleToRawLongBits(", name, "_) != 0");
break;
default:
- (*variables)["is_field_present_message"] =
- (*variables)["name"] + "_ != " + (*variables)["default"];
+ variables->insert(
+ {"is_field_present_message",
+ y_absl::StrCat(name, "_ != ", (*variables)["default"])});
break;
}
}
@@ -186,17 +176,15 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
(*variables)["set_mutable_bit_builder"] = GenerateSetBit(builderBitIndex);
(*variables)["clear_mutable_bit_builder"] = GenerateClearBit(builderBitIndex);
- // For repeated fields, one bit is used for whether the array is immutable
- // in the parsing constructor.
- (*variables)["get_mutable_bit_parser"] =
- GenerateGetBitMutableLocal(builderBitIndex);
- (*variables)["set_mutable_bit_parser"] =
- GenerateSetBitMutableLocal(builderBitIndex);
-
+ // Always track the presence of a field explicitly in the builder, regardless
+ // of syntax.
+ (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex);
(*variables)["get_has_field_bit_from_local"] =
GenerateGetBitFromLocal(builderBitIndex);
- (*variables)["set_has_field_bit_to_local"] =
- GenerateSetBitToLocal(messageBitIndex);
+ (*variables)["set_has_field_bit_builder"] =
+ y_absl::StrCat(GenerateSetBit(builderBitIndex), ";");
+ (*variables)["clear_has_field_bit_builder"] =
+ y_absl::StrCat(GenerateClearBit(builderBitIndex), ";");
}
} // namespace
@@ -206,21 +194,30 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
ImmutablePrimitiveFieldGenerator::ImmutablePrimitiveFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
Context* context)
- : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
+ : descriptor_(descriptor),
+ message_bit_index_(messageBitIndex),
+ builder_bit_index_(builderBitIndex),
+ name_resolver_(context->GetNameResolver()) {
SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex,
context->GetFieldGeneratorInfo(descriptor),
- name_resolver_, &variables_);
+ name_resolver_, &variables_, context);
}
ImmutablePrimitiveFieldGenerator::~ImmutablePrimitiveFieldGenerator() {}
+int ImmutablePrimitiveFieldGenerator::GetMessageBitIndex() const {
+ return message_bit_index_;
+}
+
+int ImmutablePrimitiveFieldGenerator::GetBuilderBitIndex() const {
+ return builder_bit_index_;
+}
+
int ImmutablePrimitiveFieldGenerator::GetNumBitsForMessage() const {
return HasHasbit(descriptor_) ? 1 : 0;
}
-int ImmutablePrimitiveFieldGenerator::GetNumBitsForBuilder() const {
- return GetNumBitsForMessage();
-}
+int ImmutablePrimitiveFieldGenerator::GetNumBitsForBuilder() const { return 1; }
void ImmutablePrimitiveFieldGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
@@ -235,7 +232,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateInterfaceMembers(
void ImmutablePrimitiveFieldGenerator::GenerateMembers(
io::Printer* printer) const {
- printer->Print(variables_, "private $field_type$ $name$_;\n");
+ printer->Print(variables_, "private $field_type$ $name$_ = $default$;\n");
PrintExtraFieldInfo(variables_, printer);
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
@@ -285,9 +282,9 @@ void ImmutablePrimitiveFieldGenerator::GenerateBuilderMembers(
printer->Print(variables_,
"$deprecation$public Builder "
"${$set$capitalized_name$$}$($type$ value) {\n"
- "$null_check$"
- " $set_has_field_bit_builder$\n"
+ " $null_check$\n"
" $name$_ = value;\n"
+ " $set_has_field_bit_builder$\n"
" $on_changed$\n"
" return this;\n"
"}\n");
@@ -318,9 +315,9 @@ void ImmutablePrimitiveFieldGenerator::GenerateBuilderMembers(
void ImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(variables_,
- "$kt_deprecation$var $kt_name$: $kt_type$\n"
+ "$kt_deprecation$public var $kt_name$: $kt_type$\n"
" @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
" get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
" @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
@@ -329,17 +326,18 @@ void ImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
" }\n");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "public fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER,
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
" return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
"}\n");
}
@@ -359,9 +357,8 @@ void ImmutablePrimitiveFieldGenerator::GenerateInitializationCode(
void ImmutablePrimitiveFieldGenerator::GenerateBuilderClearCode(
io::Printer* printer) const {
- printer->Print(variables_,
- "$name$_ = $default$;\n"
- "$clear_has_field_bit_builder$\n");
+ // No need to clear the has-bit since we clear the bitField ints all at once.
+ printer->Print(variables_, "$name$_ = $default$;\n");
}
void ImmutablePrimitiveFieldGenerator::GenerateMergingCode(
@@ -381,35 +378,20 @@ void ImmutablePrimitiveFieldGenerator::GenerateMergingCode(
void ImmutablePrimitiveFieldGenerator::GenerateBuildingCode(
io::Printer* printer) const {
- if (HasHazzer(descriptor_)) {
- if (IsDefaultValueJavaDefault(descriptor_)) {
- printer->Print(variables_,
- "if ($get_has_field_bit_from_local$) {\n"
- " result.$name$_ = $name$_;\n"
- " $set_has_field_bit_to_local$;\n"
- "}\n");
- } else {
- printer->Print(variables_,
- "if ($get_has_field_bit_from_local$) {\n"
- " $set_has_field_bit_to_local$;\n"
- "}\n"
- "result.$name$_ = $name$_;\n");
- }
- } else {
- printer->Print(variables_, "result.$name$_ = $name$_;\n");
+ printer->Print(variables_,
+ "if ($get_has_field_bit_from_local$) {\n"
+ " result.$name$_ = $name$_;\n");
+ if (GetNumBitsForMessage() > 0) {
+ printer->Print(variables_, " $set_has_field_bit_to_local$\n");
}
+ printer->Print("}\n");
}
-void ImmutablePrimitiveFieldGenerator::GenerateParsingCode(
+void ImmutablePrimitiveFieldGenerator::GenerateBuilderParsingCode(
io::Printer* printer) const {
printer->Print(variables_,
- "$set_has_field_bit_message$\n"
- "$name$_ = input.read$capitalized_type$();\n");
-}
-
-void ImmutablePrimitiveFieldGenerator::GenerateParsingDoneCode(
- io::Printer* printer) const {
- // noop for primitives.
+ "$name$_ = input.read$capitalized_type$();\n"
+ "$set_has_field_bit_builder$\n");
}
void ImmutablePrimitiveFieldGenerator::GenerateSerializationCode(
@@ -467,7 +449,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateEqualsCode(
case JAVATYPE_ENUM:
case JAVATYPE_MESSAGE:
default:
- GOOGLE_LOG(FATAL) << "Can't get here.";
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
break;
}
}
@@ -518,13 +500,13 @@ void ImmutablePrimitiveFieldGenerator::GenerateHashCode(
case JAVATYPE_ENUM:
case JAVATYPE_MESSAGE:
default:
- GOOGLE_LOG(FATAL) << "Can't get here.";
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
break;
}
}
TProtoStringType ImmutablePrimitiveFieldGenerator::GetBoxedType() const {
- return BoxedPrimitiveTypeName(GetJavaType(descriptor_));
+ return TProtoStringType(BoxedPrimitiveTypeName(GetJavaType(descriptor_)));
}
// ===================================================================
@@ -545,7 +527,7 @@ ImmutablePrimitiveOneofFieldGenerator::
void ImmutablePrimitiveOneofFieldGenerator::GenerateMembers(
io::Printer* printer) const {
PrintExtraFieldInfo(variables_, printer);
- GOOGLE_DCHECK(HasHazzer(descriptor_));
+ Y_ABSL_DCHECK(HasHazzer(descriptor_));
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
"@java.lang.Override\n"
@@ -568,7 +550,7 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateMembers(
void ImmutablePrimitiveOneofFieldGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
- GOOGLE_DCHECK(HasHazzer(descriptor_));
+ Y_ABSL_DCHECK(HasHazzer(descriptor_));
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
@@ -591,7 +573,7 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateBuilderMembers(
printer->Print(variables_,
"$deprecation$public Builder "
"${$set$capitalized_name$$}$($type$ value) {\n"
- "$null_check$"
+ " $null_check$\n"
" $set_oneof_case_message$;\n"
" $oneof_name$_ = value;\n"
" $on_changed$\n"
@@ -614,12 +596,15 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
}
+void ImmutablePrimitiveOneofFieldGenerator::GenerateBuilderClearCode(
+ io::Printer* printer) const {
+ // No-Op: When a primitive field is in a oneof, clearing the oneof clears that
+ // field.
+}
+
void ImmutablePrimitiveOneofFieldGenerator::GenerateBuildingCode(
io::Printer* printer) const {
- printer->Print(variables_,
- "if ($has_oneof_case_message$) {\n"
- " result.$oneof_name$_ = $oneof_name$_;\n"
- "}\n");
+ // no-op
}
void ImmutablePrimitiveOneofFieldGenerator::GenerateMergingCode(
@@ -628,7 +613,7 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateMergingCode(
"set$capitalized_name$(other.get$capitalized_name$());\n");
}
-void ImmutablePrimitiveOneofFieldGenerator::GenerateParsingCode(
+void ImmutablePrimitiveOneofFieldGenerator::GenerateBuilderParsingCode(
io::Printer* printer) const {
printer->Print(variables_,
"$oneof_name$_ = input.read$capitalized_type$();\n"
@@ -677,11 +662,8 @@ RepeatedImmutablePrimitiveFieldGenerator::
int messageBitIndex,
int builderBitIndex,
Context* context)
- : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
- SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex,
- context->GetFieldGeneratorInfo(descriptor),
- name_resolver_, &variables_);
-}
+ : ImmutablePrimitiveFieldGenerator(descriptor, messageBitIndex,
+ builderBitIndex, context) {}
RepeatedImmutablePrimitiveFieldGenerator::
~RepeatedImmutablePrimitiveFieldGenerator() {}
@@ -710,7 +692,8 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateInterfaceMembers(
void RepeatedImmutablePrimitiveFieldGenerator::GenerateMembers(
io::Printer* printer) const {
- printer->Print(variables_, "private $field_list_type$ $name$_;\n");
+ printer->Print(variables_, "@SuppressWarnings(\"serial\")\n"
+ "private $field_list_type$ $name$_;\n");
PrintExtraFieldInfo(variables_, printer);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(variables_,
@@ -760,7 +743,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderMembers(
" if (!$get_mutable_bit_builder$) {\n"
" $name$_ = $mutable_copy_list$;\n"
" $set_mutable_bit_builder$;\n"
- " }\n"
+ " }\n"
"}\n");
// Note: We return an unmodifiable list because otherwise the caller
@@ -795,7 +778,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderMembers(
printer->Print(variables_,
"$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
" int index, $type$ value) {\n"
- "$null_check$"
+ " $null_check$\n"
" ensure$capitalized_name$IsMutable();\n"
" $repeated_set$(index, value);\n"
" $on_changed$\n"
@@ -807,7 +790,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderMembers(
printer->Print(variables_,
"$deprecation$public Builder "
"${$add$capitalized_name$$}$($type$ value) {\n"
- "$null_check$"
+ " $null_check$\n"
" ensure$capitalized_name$IsMutable();\n"
" $repeated_add$(value);\n"
" $on_changed$\n"
@@ -849,12 +832,12 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(variables_,
- "$kt_deprecation$ val $kt_name$: "
+ "$kt_deprecation$ public val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -863,70 +846,70 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
" )\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"add(value: $kt_type$) {\n"
" $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
"}");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: $kt_type$) {\n"
" add(value)\n"
"}");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
"}");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" addAll(values)\n"
"}");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
+ "public operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"set(index: kotlin.Int, value: $kt_type$) {\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
"}");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
@@ -945,9 +928,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateInitializationCode(
void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderClearCode(
io::Printer* printer) const {
- printer->Print(variables_,
- "$name$_ = $empty_list$;\n"
- "$clear_mutable_bit_builder$;\n");
+ printer->Print(variables_, "$name$_ = $empty_list$;\n");
}
void RepeatedImmutablePrimitiveFieldGenerator::GenerateMergingCode(
@@ -982,38 +963,24 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuildingCode(
"result.$name$_ = $name$_;\n");
}
-void RepeatedImmutablePrimitiveFieldGenerator::GenerateParsingCode(
+void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderParsingCode(
io::Printer* printer) const {
printer->Print(variables_,
- "if (!$get_mutable_bit_parser$) {\n"
- " $name$_ = $create_list$;\n"
- " $set_mutable_bit_parser$;\n"
- "}\n"
- "$repeated_add$(input.read$capitalized_type$());\n");
+ "$type$ v = input.read$capitalized_type$();\n"
+ "ensure$capitalized_name$IsMutable();\n"
+ "$repeated_add$(v);\n");
}
-void RepeatedImmutablePrimitiveFieldGenerator::GenerateParsingCodeFromPacked(
- io::Printer* printer) const {
- printer->Print(
- variables_,
- "int length = input.readRawVarint32();\n"
- "int limit = input.pushLimit(length);\n"
- "if (!$get_mutable_bit_parser$ && input.getBytesUntilLimit() > 0) {\n"
- " $name$_ = $create_list$;\n"
- " $set_mutable_bit_parser$;\n"
- "}\n"
- "while (input.getBytesUntilLimit() > 0) {\n"
- " $repeated_add$(input.read$capitalized_type$());\n"
- "}\n"
- "input.popLimit(limit);\n");
-}
-
-void RepeatedImmutablePrimitiveFieldGenerator::GenerateParsingDoneCode(
- io::Printer* printer) const {
+void RepeatedImmutablePrimitiveFieldGenerator::
+ GenerateBuilderParsingCodeFromPacked(io::Printer* printer) const {
printer->Print(variables_,
- "if ($get_mutable_bit_parser$) {\n"
- " $name_make_immutable$; // C\n"
- "}\n");
+ "int length = input.readRawVarint32();\n"
+ "int limit = input.pushLimit(length);\n"
+ "ensure$capitalized_name$IsMutable();\n"
+ "while (input.getBytesUntilLimit() > 0) {\n"
+ " $repeated_add$(input.read$capitalized_type$());\n"
+ "}\n"
+ "input.popLimit(limit);\n");
}
void RepeatedImmutablePrimitiveFieldGenerator::GenerateSerializationCode(
@@ -1102,7 +1069,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateHashCode(
}
TProtoStringType RepeatedImmutablePrimitiveFieldGenerator::GetBoxedType() const {
- return BoxedPrimitiveTypeName(GetJavaType(descriptor_));
+ return TProtoStringType(BoxedPrimitiveTypeName(GetJavaType(descriptor_)));
}
} // namespace java
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field.h
index a2c00413889..dae385afa6b 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field.h
@@ -35,10 +35,9 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_H__
-#include <map>
#include <string>
-#include <google/protobuf/compiler/java/field.h>
+#include "google/protobuf/compiler/java/field.h"
namespace google {
namespace protobuf {
@@ -62,10 +61,16 @@ class ImmutablePrimitiveFieldGenerator : public ImmutableFieldGenerator {
int messageBitIndex,
int builderBitIndex,
Context* context);
+ ImmutablePrimitiveFieldGenerator(const ImmutablePrimitiveFieldGenerator&) =
+ delete;
+ ImmutablePrimitiveFieldGenerator& operator=(
+ const ImmutablePrimitiveFieldGenerator&) = delete;
~ImmutablePrimitiveFieldGenerator() override;
// implements ImmutableFieldGenerator
// ---------------------------------------
+ int GetMessageBitIndex() const override;
+ int GetBuilderBitIndex() const override;
int GetNumBitsForMessage() const override;
int GetNumBitsForBuilder() const override;
void GenerateInterfaceMembers(io::Printer* printer) const override;
@@ -75,8 +80,7 @@ class ImmutablePrimitiveFieldGenerator : public ImmutableFieldGenerator {
void GenerateBuilderClearCode(io::Printer* printer) const override;
void GenerateMergingCode(io::Printer* printer) const override;
void GenerateBuildingCode(io::Printer* printer) const override;
- void GenerateParsingCode(io::Printer* printer) const override;
- void GenerateParsingDoneCode(io::Printer* printer) const override;
+ void GenerateBuilderParsingCode(io::Printer* printer) const override;
void GenerateSerializationCode(io::Printer* printer) const override;
void GenerateSerializedSizeCode(io::Printer* printer) const override;
void GenerateFieldBuilderInitializationCode(
@@ -89,11 +93,10 @@ class ImmutablePrimitiveFieldGenerator : public ImmutableFieldGenerator {
protected:
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ int message_bit_index_;
+ int builder_bit_index_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables_;
ClassNameResolver* name_resolver_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutablePrimitiveFieldGenerator);
};
class ImmutablePrimitiveOneofFieldGenerator
@@ -102,26 +105,32 @@ class ImmutablePrimitiveOneofFieldGenerator
ImmutablePrimitiveOneofFieldGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
int builderBitIndex, Context* context);
+ ImmutablePrimitiveOneofFieldGenerator(
+ const ImmutablePrimitiveOneofFieldGenerator&) = delete;
+ ImmutablePrimitiveOneofFieldGenerator& operator=(
+ const ImmutablePrimitiveOneofFieldGenerator&) = delete;
~ImmutablePrimitiveOneofFieldGenerator() override;
void GenerateMembers(io::Printer* printer) const override;
void GenerateBuilderMembers(io::Printer* printer) const override;
+ void GenerateBuilderClearCode(io::Printer* printer) const override;
void GenerateBuildingCode(io::Printer* printer) const override;
void GenerateMergingCode(io::Printer* printer) const override;
- void GenerateParsingCode(io::Printer* printer) const override;
+ void GenerateBuilderParsingCode(io::Printer* printer) const override;
void GenerateSerializationCode(io::Printer* printer) const override;
void GenerateSerializedSizeCode(io::Printer* printer) const override;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutablePrimitiveOneofFieldGenerator);
};
class RepeatedImmutablePrimitiveFieldGenerator
- : public ImmutableFieldGenerator {
+ : public ImmutablePrimitiveFieldGenerator {
public:
explicit RepeatedImmutablePrimitiveFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex,
int builderBitIndex, Context* context);
+ RepeatedImmutablePrimitiveFieldGenerator(
+ const RepeatedImmutablePrimitiveFieldGenerator&) = delete;
+ RepeatedImmutablePrimitiveFieldGenerator& operator=(
+ const RepeatedImmutablePrimitiveFieldGenerator&) = delete;
~RepeatedImmutablePrimitiveFieldGenerator() override;
// implements ImmutableFieldGenerator ---------------------------------------
@@ -134,9 +143,9 @@ class RepeatedImmutablePrimitiveFieldGenerator
void GenerateBuilderClearCode(io::Printer* printer) const override;
void GenerateMergingCode(io::Printer* printer) const override;
void GenerateBuildingCode(io::Printer* printer) const override;
- void GenerateParsingCode(io::Printer* printer) const override;
- void GenerateParsingCodeFromPacked(io::Printer* printer) const override;
- void GenerateParsingDoneCode(io::Printer* printer) const override;
+ void GenerateBuilderParsingCode(io::Printer* printer) const override;
+ void GenerateBuilderParsingCodeFromPacked(
+ io::Printer* printer) const override;
void GenerateSerializationCode(io::Printer* printer) const override;
void GenerateSerializedSizeCode(io::Printer* printer) const override;
void GenerateFieldBuilderInitializationCode(
@@ -146,13 +155,6 @@ class RepeatedImmutablePrimitiveFieldGenerator
void GenerateKotlinDslMembers(io::Printer* printer) const override;
TProtoStringType GetBoxedType() const override;
-
- private:
- const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
- ClassNameResolver* name_resolver_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutablePrimitiveFieldGenerator);
};
} // namespace java
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field_lite.cc
index 5fd47c47e16..0d4c6334569 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field_lite.cc
@@ -32,21 +32,19 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/primitive_field_lite.h>
+#include "google/protobuf/compiler/java/primitive_field_lite.h"
#include <cstdint>
-#include <map>
#include <string>
-#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/context.h>
-#include <google/protobuf/compiler/java/doc_comment.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/name_resolver.h>
+#include "y_absl/log/absl_check.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/java/context.h"
+#include "google/protobuf/compiler/java/doc_comment.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/name_resolver.h"
+#include "google/protobuf/wire_format.h"
namespace google {
namespace protobuf {
@@ -65,65 +63,70 @@ bool EnableExperimentalRuntimeForLite() {
#endif // !PROTOBUF_EXPERIMENT
}
-void SetPrimitiveVariables(const FieldDescriptor* descriptor,
- int messageBitIndex, int builderBitIndex,
- const FieldGeneratorInfo* info,
- ClassNameResolver* name_resolver,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+void SetPrimitiveVariables(
+ const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
+ const FieldGeneratorInfo* info, ClassNameResolver* name_resolver,
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables,
+ Context* context) {
SetCommonFieldVariables(descriptor, info, variables);
JavaType javaType = GetJavaType(descriptor);
- (*variables)["type"] = PrimitiveTypeName(javaType);
- (*variables)["boxed_type"] = BoxedPrimitiveTypeName(javaType);
- (*variables)["kt_type"] = KotlinTypeName(javaType);
- (*variables)["field_type"] = (*variables)["type"];
- (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
- (*variables)["capitalized_type"] =
- GetCapitalizedType(descriptor, /* immutable = */ true);
+ (*variables)["type"] = TProtoStringType(PrimitiveTypeName(javaType));
+ (*variables)["boxed_type"] = TProtoStringType(BoxedPrimitiveTypeName(javaType));
+ (*variables)["kt_type"] = TProtoStringType(KotlinTypeName(javaType));
+ variables->insert({"field_type", (*variables)["type"]});
+ (*variables)["default"] =
+ ImmutableDefaultValue(descriptor, name_resolver, context->options());
+ (*variables)["capitalized_type"] = TProtoStringType(GetCapitalizedType(
+ descriptor, /* immutable = */ true, context->options()));
(*variables)["tag"] =
- StrCat(static_cast<arc_i32>(WireFormat::MakeTag(descriptor)));
- (*variables)["tag_size"] = StrCat(
+ y_absl::StrCat(static_cast<arc_i32>(WireFormat::MakeTag(descriptor)));
+ (*variables)["tag_size"] = y_absl::StrCat(
WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
(*variables)["required"] = descriptor->is_required() ? "true" : "false";
TProtoStringType capitalized_type = UnderscoresToCamelCase(
PrimitiveTypeName(javaType), true /* cap_next_letter */);
+ TProtoStringType name = (*variables)["name"];
switch (javaType) {
case JAVATYPE_INT:
case JAVATYPE_LONG:
case JAVATYPE_FLOAT:
case JAVATYPE_DOUBLE:
case JAVATYPE_BOOLEAN:
- (*variables)["field_list_type"] =
- "com.google.protobuf.Internal." + capitalized_type + "List";
- (*variables)["empty_list"] = "empty" + capitalized_type + "List()";
+ (*variables)["field_list_type"] = y_absl::StrCat(
+ "com.google.protobuf.Internal.", capitalized_type, "List");
+ (*variables)["empty_list"] =
+ y_absl::StrCat("empty", capitalized_type, "List()");
(*variables)["make_name_unmodifiable"] =
- (*variables)["name"] + "_.makeImmutable()";
+ y_absl::StrCat(name, "_.makeImmutable()");
(*variables)["repeated_get"] =
- (*variables)["name"] + "_.get" + capitalized_type;
+ y_absl::StrCat(name, "_.get", capitalized_type);
(*variables)["repeated_add"] =
- (*variables)["name"] + "_.add" + capitalized_type;
+ y_absl::StrCat(name, "_.add", capitalized_type);
(*variables)["repeated_set"] =
- (*variables)["name"] + "_.set" + capitalized_type;
+ y_absl::StrCat(name, "_.set", capitalized_type);
(*variables)["visit_type"] = capitalized_type;
- (*variables)["visit_type_list"] = "visit" + capitalized_type + "List";
+ (*variables)["visit_type_list"] =
+ y_absl::StrCat("visit", capitalized_type, "List");
break;
default:
- (*variables)["field_list_type"] =
- "com.google.protobuf.Internal.ProtobufList<" +
- (*variables)["boxed_type"] + ">";
+ variables->insert(
+ {"field_list_type",
+ y_absl::StrCat("com.google.protobuf.Internal.ProtobufList<",
+ (*variables)["boxed_type"], ">")});
(*variables)["empty_list"] = "emptyProtobufList()";
(*variables)["make_name_unmodifiable"] =
- (*variables)["name"] + "_.makeImmutable()";
- (*variables)["repeated_get"] = (*variables)["name"] + "_.get";
- (*variables)["repeated_add"] = (*variables)["name"] + "_.add";
- (*variables)["repeated_set"] = (*variables)["name"] + "_.set";
+ y_absl::StrCat(name, "_.makeImmutable()");
+ (*variables)["repeated_get"] = y_absl::StrCat(name, "_.get");
+ (*variables)["repeated_add"] = y_absl::StrCat(name, "_.add");
+ (*variables)["repeated_set"] = y_absl::StrCat(name, "_.set");
(*variables)["visit_type"] = "ByteString";
(*variables)["visit_type_list"] = "visitList";
}
if (javaType == JAVATYPE_BYTES) {
(*variables)["bytes_default"] =
- ToUpper((*variables)["name"]) + "_DEFAULT_VALUE";
+ y_absl::StrCat(y_absl::AsciiStrToUpper(name), "_DEFAULT_VALUE");
}
if (IsReferenceType(javaType)) {
@@ -140,12 +143,12 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
(*variables)["kt_deprecation"] =
descriptor->options().deprecated()
- ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
- " is deprecated\") "
+ ? y_absl::StrCat("@kotlin.Deprecated(message = \"Field ", name,
+ " is deprecated\") ")
: "";
int fixed_size = FixedSize(GetType(descriptor));
if (fixed_size != -1) {
- (*variables)["fixed_size"] = StrCat(fixed_size);
+ (*variables)["fixed_size"] = y_absl::StrCat(fixed_size);
}
if (HasHasbit(descriptor)) {
@@ -154,9 +157,9 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
// Note that these have a trailing ";".
(*variables)["set_has_field_bit_message"] =
- GenerateSetBit(messageBitIndex) + ";";
+ y_absl::StrCat(GenerateSetBit(messageBitIndex), ";");
(*variables)["clear_has_field_bit_message"] =
- GenerateClearBit(messageBitIndex) + ";";
+ y_absl::StrCat(GenerateClearBit(messageBitIndex), ";");
(*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
} else {
@@ -166,21 +169,20 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
switch (descriptor->type()) {
case FieldDescriptor::TYPE_BYTES:
(*variables)["is_field_present_message"] =
- "!" + (*variables)["name"] + "_.isEmpty()";
+ y_absl::StrCat("!", name, "_.isEmpty()");
break;
case FieldDescriptor::TYPE_FLOAT:
(*variables)["is_field_present_message"] =
- "java.lang.Float.floatToRawIntBits(" + (*variables)["name"] +
- "_) != 0";
+ y_absl::StrCat("java.lang.Float.floatToRawIntBits(", name, "_) != 0");
break;
case FieldDescriptor::TYPE_DOUBLE:
- (*variables)["is_field_present_message"] =
- "java.lang.Double.doubleToRawLongBits(" + (*variables)["name"] +
- "_) != 0";
+ (*variables)["is_field_present_message"] = y_absl::StrCat(
+ "java.lang.Double.doubleToRawLongBits(", name, "_) != 0");
break;
default:
- (*variables)["is_field_present_message"] =
- (*variables)["name"] + "_ != " + (*variables)["default"];
+ variables->insert(
+ {"is_field_present_message",
+ y_absl::StrCat(name, "_ != ", (*variables)["default"])});
break;
}
}
@@ -189,6 +191,9 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
GenerateGetBitFromLocal(builderBitIndex);
(*variables)["set_has_field_bit_to_local"] =
GenerateSetBitToLocal(messageBitIndex);
+ // Annotations often use { and } variables to denote ranges.
+ (*variables)["{"] = "";
+ (*variables)["}"] = "";
}
} // namespace
@@ -199,10 +204,11 @@ ImmutablePrimitiveFieldLiteGenerator::ImmutablePrimitiveFieldLiteGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, Context* context)
: descriptor_(descriptor),
messageBitIndex_(messageBitIndex),
+ context_(context),
name_resolver_(context->GetNameResolver()) {
SetPrimitiveVariables(descriptor, messageBitIndex, 0,
context->GetFieldGeneratorInfo(descriptor),
- name_resolver_, &variables_);
+ name_resolver_, &variables_, context);
}
ImmutablePrimitiveFieldLiteGenerator::~ImmutablePrimitiveFieldLiteGenerator() {}
@@ -219,7 +225,9 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateInterfaceMembers(
"$deprecation$boolean has$capitalized_name$();\n");
}
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_, "$deprecation$$type$ get$capitalized_name$();\n");
+ printer->Print(variables_,
+ "$deprecation$$type$ ${$get$capitalized_name$$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
}
void ImmutablePrimitiveFieldLiteGenerator::GenerateMembers(
@@ -231,6 +239,20 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateMembers(
variables_,
"private static final $field_type$ $bytes_default$ = $default$;\n");
}
+ if (!context_->options().opensource_runtime) {
+ printer->Print(
+ variables_,
+ "@com.google.protobuf.ProtoField(\n"
+ " fieldNumber=$number$,\n"
+ " type=com.google.protobuf.FieldType.$annotation_field_type$,\n"
+ " isRequired=$required$)\n");
+ if (HasHazzer(descriptor_)) {
+ printer->Print(variables_,
+ "@com.google.protobuf.ProtoPresenceCheckedField(\n"
+ " presenceBitsId=$bit_field_id$,\n"
+ " mask=$bit_field_mask$)\n");
+ }
+ }
printer->Print(variables_, "private $field_type$ $name$_;\n");
PrintExtraFieldInfo(variables_, printer);
if (HasHazzer(descriptor_)) {
@@ -325,7 +347,7 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$var $kt_name$: $kt_type$\n"
+ "$kt_deprecation$public var $kt_name$: $kt_type$\n"
" @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
" get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
" @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
@@ -334,17 +356,18 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
" }\n");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "public fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER,
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
" return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
"}\n");
}
@@ -371,7 +394,7 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateInitializationCode(
}
TProtoStringType ImmutablePrimitiveFieldLiteGenerator::GetBoxedType() const {
- return BoxedPrimitiveTypeName(GetJavaType(descriptor_));
+ return TProtoStringType(BoxedPrimitiveTypeName(GetJavaType(descriptor_)));
}
// ===================================================================
@@ -393,7 +416,7 @@ ImmutablePrimitiveOneofFieldLiteGenerator::
void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateMembers(
io::Printer* printer) const {
PrintExtraFieldInfo(variables_, printer);
- GOOGLE_DCHECK(HasHazzer(descriptor_));
+ Y_ABSL_DCHECK(HasHazzer(descriptor_));
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
"@java.lang.Override\n"
@@ -441,7 +464,7 @@ void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateFieldInfo(
void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
- GOOGLE_DCHECK(HasHazzer(descriptor_));
+ Y_ABSL_DCHECK(HasHazzer(descriptor_));
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
"@java.lang.Override\n"
@@ -492,7 +515,7 @@ RepeatedImmutablePrimitiveFieldLiteGenerator::
name_resolver_(context->GetNameResolver()) {
SetPrimitiveVariables(descriptor, messageBitIndex, 0,
context->GetFieldGeneratorInfo(descriptor),
- name_resolver_, &variables_);
+ name_resolver_, &variables_, context);
}
RepeatedImmutablePrimitiveFieldLiteGenerator::
@@ -507,13 +530,17 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateInterfaceMembers(
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(variables_,
"$deprecation$java.util.List<$boxed_type$> "
- "get$capitalized_name$List();\n");
+ "${$get$capitalized_name$List$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
printer->Print(variables_,
- "$deprecation$int get$capitalized_name$Count();\n");
+ "$deprecation$int ${$get$capitalized_name$Count$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
- printer->Print(variables_,
- "$deprecation$$type$ get$capitalized_name$(int index);\n");
+ printer->Print(
+ variables_,
+ "$deprecation$$type$ ${$get$capitalized_name$$}$(int index);\n");
+ printer->Annotate("{", "}", descriptor_);
}
void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateMembers(
@@ -671,12 +698,12 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$ val $kt_name$: "
+ "$kt_deprecation$ public val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -685,70 +712,70 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
" )\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"add(value: $kt_type$) {\n"
" $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
"}");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: $kt_type$) {\n"
" add(value)\n"
"}");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
"}");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" addAll(values)\n"
"}");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
+ "public operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"set(index: kotlin.Int, value: $kt_type$) {\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
"}");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
@@ -769,7 +796,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateInitializationCode(
}
TProtoStringType RepeatedImmutablePrimitiveFieldLiteGenerator::GetBoxedType() const {
- return BoxedPrimitiveTypeName(GetJavaType(descriptor_));
+ return TProtoStringType(BoxedPrimitiveTypeName(GetJavaType(descriptor_)));
}
} // namespace java
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field_lite.h
index 1eaf8d8e092..48090484ee4 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field_lite.h
@@ -36,10 +36,9 @@
#define GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_LITE_H__
#include <cstdint>
-#include <map>
#include <string>
-#include <google/protobuf/compiler/java/field.h>
+#include "google/protobuf/compiler/java/field.h"
namespace google {
namespace protobuf {
@@ -62,6 +61,10 @@ class ImmutablePrimitiveFieldLiteGenerator
public:
explicit ImmutablePrimitiveFieldLiteGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
+ ImmutablePrimitiveFieldLiteGenerator(
+ const ImmutablePrimitiveFieldLiteGenerator&) = delete;
+ ImmutablePrimitiveFieldLiteGenerator& operator=(
+ const ImmutablePrimitiveFieldLiteGenerator&) = delete;
~ImmutablePrimitiveFieldLiteGenerator() override;
// implements ImmutableFieldLiteGenerator
@@ -79,12 +82,10 @@ class ImmutablePrimitiveFieldLiteGenerator
protected:
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables_;
const int messageBitIndex_;
+ Context* context_;
ClassNameResolver* name_resolver_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutablePrimitiveFieldLiteGenerator);
};
class ImmutablePrimitiveOneofFieldLiteGenerator
@@ -93,6 +94,10 @@ class ImmutablePrimitiveOneofFieldLiteGenerator
ImmutablePrimitiveOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
Context* context);
+ ImmutablePrimitiveOneofFieldLiteGenerator(
+ const ImmutablePrimitiveOneofFieldLiteGenerator&) = delete;
+ ImmutablePrimitiveOneofFieldLiteGenerator& operator=(
+ const ImmutablePrimitiveOneofFieldLiteGenerator&) = delete;
~ImmutablePrimitiveOneofFieldLiteGenerator() override;
void GenerateMembers(io::Printer* printer) const override;
@@ -100,9 +105,6 @@ class ImmutablePrimitiveOneofFieldLiteGenerator
void GenerateFieldInfo(io::Printer* printer,
std::vector<uint16_t>* output) const override;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutablePrimitiveOneofFieldLiteGenerator);
};
class RepeatedImmutablePrimitiveFieldLiteGenerator
@@ -110,6 +112,10 @@ class RepeatedImmutablePrimitiveFieldLiteGenerator
public:
explicit RepeatedImmutablePrimitiveFieldLiteGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
+ RepeatedImmutablePrimitiveFieldLiteGenerator(
+ const RepeatedImmutablePrimitiveFieldLiteGenerator&) = delete;
+ RepeatedImmutablePrimitiveFieldLiteGenerator& operator=(
+ const RepeatedImmutablePrimitiveFieldLiteGenerator&) = delete;
~RepeatedImmutablePrimitiveFieldLiteGenerator() override;
// implements ImmutableFieldLiteGenerator ------------------------------------
@@ -126,11 +132,9 @@ class RepeatedImmutablePrimitiveFieldLiteGenerator
private:
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables_;
Context* context_;
ClassNameResolver* name_resolver_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutablePrimitiveFieldLiteGenerator);
};
} // namespace java
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/service.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/service.cc
index 602ab4c7b93..3f6d896c6d0 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/service.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/service.cc
@@ -32,17 +32,18 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/service.h>
+#include "google/protobuf/compiler/java/service.h"
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/java/context.h>
-#include <google/protobuf/compiler/java/doc_comment.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/name_resolver.h>
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/java/context.h"
+#include "google/protobuf/compiler/java/doc_comment.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/name_resolver.h"
+#include "google/protobuf/io/printer.h"
// Must be last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -68,6 +69,10 @@ void ImmutableServiceGenerator::Generate(io::Printer* printer) {
WriteServiceDocComment(printer, descriptor_);
MaybePrintGeneratedAnnotation(context_, printer, descriptor_,
/* immutable = */ true);
+ if (!context_->options().opensource_runtime) {
+ printer->Print("@com.google.protobuf.Internal.ProtoNonnullApi\n");
+ }
+
printer->Print(
"public $static$ abstract class $classname$\n"
" implements com.google.protobuf.Service {\n",
@@ -92,7 +97,7 @@ void ImmutableServiceGenerator::Generate(io::Printer* printer) {
" return $file$.getDescriptor().getServices().get($index$);\n"
"}\n",
"file", name_resolver_->GetImmutableClassName(descriptor_->file()),
- "index", StrCat(descriptor_->index()));
+ "index", y_absl::StrCat(descriptor_->index()));
GenerateGetDescriptorForType(printer);
// Generate more stuff.
@@ -211,8 +216,8 @@ void ImmutableServiceGenerator::GenerateCallMethod(io::Printer* printer) {
for (int i = 0; i < descriptor_->method_count(); i++) {
const MethodDescriptor* method = descriptor_->method(i);
- std::map<TProtoStringType, TProtoStringType> vars;
- vars["index"] = StrCat(i);
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
+ vars["index"] = y_absl::StrCat(i);
vars["method"] = UnderscoresToCamelCase(method);
vars["input"] = name_resolver_->GetImmutableClassName(method->input_type());
vars["output"] = GetOutput(method);
@@ -258,8 +263,8 @@ void ImmutableServiceGenerator::GenerateCallBlockingMethod(
for (int i = 0; i < descriptor_->method_count(); i++) {
const MethodDescriptor* method = descriptor_->method(i);
- std::map<TProtoStringType, TProtoStringType> vars;
- vars["index"] = StrCat(i);
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
+ vars["index"] = y_absl::StrCat(i);
vars["method"] = UnderscoresToCamelCase(method);
vars["input"] = name_resolver_->GetImmutableClassName(method->input_type());
vars["output"] = GetOutput(method);
@@ -303,8 +308,8 @@ void ImmutableServiceGenerator::GenerateGetPrototype(RequestOrResponse which,
for (int i = 0; i < descriptor_->method_count(); i++) {
const MethodDescriptor* method = descriptor_->method(i);
- std::map<TProtoStringType, TProtoStringType> vars;
- vars["index"] = StrCat(i);
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
+ vars["index"] = y_absl::StrCat(i);
vars["type"] =
(which == REQUEST)
? name_resolver_->GetImmutableClassName(method->input_type())
@@ -358,8 +363,8 @@ void ImmutableServiceGenerator::GenerateStub(io::Printer* printer) {
printer->Print(" {\n");
printer->Indent();
- std::map<TProtoStringType, TProtoStringType> vars;
- vars["index"] = StrCat(i);
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
+ vars["index"] = y_absl::StrCat(i);
vars["output"] = GetOutput(method);
printer->Print(vars,
"channel.callMethod(\n"
@@ -422,8 +427,8 @@ void ImmutableServiceGenerator::GenerateBlockingStub(io::Printer* printer) {
printer->Print(" {\n");
printer->Indent();
- std::map<TProtoStringType, TProtoStringType> vars;
- vars["index"] = StrCat(i);
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
+ vars["index"] = y_absl::StrCat(i);
vars["output"] = GetOutput(method);
printer->Print(vars,
"return ($output$) channel.callBlockingMethod(\n"
@@ -445,7 +450,7 @@ void ImmutableServiceGenerator::GenerateBlockingStub(io::Printer* printer) {
void ImmutableServiceGenerator::GenerateMethodSignature(
io::Printer* printer, const MethodDescriptor* method,
IsAbstract is_abstract) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
vars["name"] = UnderscoresToCamelCase(method);
vars["input"] = name_resolver_->GetImmutableClassName(method->input_type());
vars["output"] = GetOutput(method);
@@ -459,7 +464,7 @@ void ImmutableServiceGenerator::GenerateMethodSignature(
void ImmutableServiceGenerator::GenerateBlockingMethodSignature(
io::Printer* printer, const MethodDescriptor* method) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
vars["method"] = UnderscoresToCamelCase(method);
vars["input"] = name_resolver_->GetImmutableClassName(method->input_type());
vars["output"] = GetOutput(method);
@@ -476,4 +481,4 @@ void ImmutableServiceGenerator::GenerateBlockingMethodSignature(
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/service.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/service.h
index a03a3de561f..a59223c7cb9 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/service.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/service.h
@@ -35,8 +35,7 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_SERVICE_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_SERVICE_H__
-#include <map>
-#include <google/protobuf/descriptor.h>
+#include "google/protobuf/descriptor.h"
namespace google {
namespace protobuf {
@@ -60,6 +59,8 @@ namespace java {
class ServiceGenerator {
public:
explicit ServiceGenerator(const ServiceDescriptor* descriptor);
+ ServiceGenerator(const ServiceGenerator&) = delete;
+ ServiceGenerator& operator=(const ServiceGenerator&) = delete;
virtual ~ServiceGenerator();
virtual void Generate(io::Printer* printer) = 0;
@@ -69,15 +70,15 @@ class ServiceGenerator {
protected:
const ServiceDescriptor* descriptor_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceGenerator);
};
class ImmutableServiceGenerator : public ServiceGenerator {
public:
ImmutableServiceGenerator(const ServiceDescriptor* descriptor,
Context* context);
+ ImmutableServiceGenerator(const ImmutableServiceGenerator&) = delete;
+ ImmutableServiceGenerator& operator=(const ImmutableServiceGenerator&) =
+ delete;
~ImmutableServiceGenerator() override;
void Generate(io::Printer* printer) override;
@@ -128,7 +129,6 @@ class ImmutableServiceGenerator : public ServiceGenerator {
Context* context_;
ClassNameResolver* name_resolver_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableServiceGenerator);
};
} // namespace java
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/shared_code_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/shared_code_generator.cc
index 0a8b8edb012..79c6afab4ea 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/shared_code_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/shared_code_generator.cc
@@ -30,19 +30,20 @@
// Author: [email protected] (Feng Xiao)
-#include <google/protobuf/compiler/java/shared_code_generator.h>
+#include "google/protobuf/compiler/java/shared_code_generator.h"
#include <memory>
-#include <google/protobuf/compiler/code_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/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/name_resolver.h>
-#include <google/protobuf/compiler/java/names.h>
-#include <google/protobuf/descriptor.pb.h>
+#include "y_absl/strings/escaping.h"
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/name_resolver.h"
+#include "google/protobuf/compiler/java/names.h"
+#include "google/protobuf/compiler/retention.h"
+#include "google/protobuf/descriptor.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 {
@@ -51,20 +52,22 @@ namespace java {
SharedCodeGenerator::SharedCodeGenerator(const FileDescriptor* file,
const Options& options)
- : name_resolver_(new ClassNameResolver), file_(file), options_(options) {}
+ : name_resolver_(new ClassNameResolver(options)),
+ file_(file),
+ options_(options) {}
SharedCodeGenerator::~SharedCodeGenerator() {}
void SharedCodeGenerator::Generate(
GeneratorContext* context, std::vector<TProtoStringType>* file_list,
std::vector<TProtoStringType>* annotation_file_list) {
- TProtoStringType java_package = FileJavaPackage(file_);
+ TProtoStringType java_package = FileJavaPackage(file_, true, options_);
TProtoStringType package_dir = JavaPackageToDir(java_package);
if (HasDescriptorMethods(file_, options_.enforce_lite)) {
// Generate descriptors.
TProtoStringType classname = name_resolver_->GetDescriptorClassName(file_);
- TProtoStringType filename = package_dir + classname + ".java";
+ TProtoStringType filename = y_absl::StrCat(package_dir, classname, ".java");
file_list->push_back(filename);
std::unique_ptr<io::ZeroCopyOutputStream> output(context->Open(filename));
GeneratedCodeInfo annotations;
@@ -73,8 +76,8 @@ void SharedCodeGenerator::Generate(
std::unique_ptr<io::Printer> printer(
new io::Printer(output.get(), '$',
options_.annotate_code ? &annotation_collector : NULL));
- TProtoStringType info_relative_path = classname + ".java.pb.meta";
- TProtoStringType info_full_path = filename + ".pb.meta";
+ TProtoStringType info_relative_path = y_absl::StrCat(classname, ".java.pb.meta");
+ TProtoStringType info_full_path = y_absl::StrCat(filename, ".pb.meta");
printer->Print(
"// Generated by the protocol buffer compiler. DO NOT EDIT!\n"
"// source: $filename$\n"
@@ -87,7 +90,12 @@ void SharedCodeGenerator::Generate(
"package", java_package);
}
PrintGeneratedAnnotation(printer.get(), '$',
- options_.annotate_code ? info_relative_path : "");
+ options_.annotate_code ? info_relative_path : "",
+ options_);
+
+ if (!options_.opensource_runtime) {
+ printer->Print("@com.google.protobuf.Internal.ProtoNonnullApi\n");
+ }
printer->Print(
"public final class $classname$ {\n"
" public static com.google.protobuf.Descriptors.FileDescriptor\n"
@@ -127,8 +135,7 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) {
// This makes huge bytecode files and can easily hit the compiler's internal
// code size limits (error "code to large"). String literals are apparently
// embedded raw, which is what we want.
- FileDescriptorProto file_proto;
- file_->CopyTo(&file_proto);
+ FileDescriptorProto file_proto = StripSourceRetentionOptions(*file_);
TProtoStringType file_data;
file_proto.SerializeToString(&file_data);
@@ -152,7 +159,7 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) {
}
}
printer->Print("\"$data$\"", "data",
- CEscape(file_data.substr(i, kBytesPerLine)));
+ y_absl::CEscape(file_data.substr(i, kBytesPerLine)));
}
printer->Outdent();
@@ -163,14 +170,14 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) {
std::vector<std::pair<TProtoStringType, TProtoStringType> > dependencies;
for (int i = 0; i < file_->dependency_count(); i++) {
TProtoStringType filename = file_->dependency(i)->name();
- TProtoStringType package = FileJavaPackage(file_->dependency(i));
+ TProtoStringType package = FileJavaPackage(file_->dependency(i), true, options_);
TProtoStringType classname =
name_resolver_->GetDescriptorClassName(file_->dependency(i));
TProtoStringType full_name;
if (package.empty()) {
full_name = classname;
} else {
- full_name = package + "." + classname;
+ full_name = y_absl::StrCat(package, ".", classname);
}
dependencies.push_back(std::make_pair(filename, full_name));
}
@@ -180,13 +187,15 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) {
printer->Print(
"descriptor = com.google.protobuf.Descriptors.FileDescriptor\n"
" .internalBuildGeneratedFileFrom(descriptorData,\n");
- printer->Print(
- " new com.google.protobuf.Descriptors.FileDescriptor[] {\n");
+ if (options_.opensource_runtime) {
+ printer->Print(
+ " new com.google.protobuf.Descriptors.FileDescriptor[] {\n");
- for (int i = 0; i < dependencies.size(); i++) {
- const TProtoStringType& dependency = dependencies[i].second;
- printer->Print(" $dependency$.getDescriptor(),\n", "dependency",
- dependency);
+ for (int i = 0; i < dependencies.size(); i++) {
+ const TProtoStringType& dependency = dependencies[i].second;
+ printer->Print(" $dependency$.getDescriptor(),\n", "dependency",
+ dependency);
+ }
}
printer->Print(" });\n");
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/shared_code_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/shared_code_generator.h
index 026124715aa..b49214bc13f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/shared_code_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/shared_code_generator.h
@@ -39,8 +39,8 @@
#include <string>
#include <vector>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/compiler/java/options.h>
+#include "google/protobuf/compiler/java/options.h"
+#include "google/protobuf/port.h"
namespace google {
namespace protobuf {
@@ -67,6 +67,8 @@ namespace java {
class SharedCodeGenerator {
public:
SharedCodeGenerator(const FileDescriptor* file, const Options& options);
+ SharedCodeGenerator(const SharedCodeGenerator&) = delete;
+ SharedCodeGenerator& operator=(const SharedCodeGenerator&) = delete;
~SharedCodeGenerator();
void Generate(GeneratorContext* generator_context,
@@ -79,7 +81,6 @@ class SharedCodeGenerator {
std::unique_ptr<ClassNameResolver> name_resolver_;
const FileDescriptor* file_;
const Options options_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SharedCodeGenerator);
};
} // namespace java
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field.cc
index 066e3bd7015..62581f65b94 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field.cc
@@ -33,21 +33,20 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/string_field.h>
+#include "google/protobuf/compiler/java/string_field.h"
#include <cstdint>
-#include <map>
#include <string>
-#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/context.h>
-#include <google/protobuf/compiler/java/doc_comment.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/name_resolver.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/java/context.h"
+#include "google/protobuf/compiler/java/doc_comment.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/name_resolver.h"
+#include "google/protobuf/io/printer.h"
+#include "google/protobuf/wire_format.h"
namespace google {
namespace protobuf {
@@ -59,86 +58,78 @@ using internal::WireFormatLite;
namespace {
-void SetPrimitiveVariables(const FieldDescriptor* descriptor,
- int messageBitIndex, int builderBitIndex,
- const FieldGeneratorInfo* info,
- ClassNameResolver* name_resolver,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+void SetPrimitiveVariables(
+ const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
+ const FieldGeneratorInfo* info, ClassNameResolver* name_resolver,
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables,
+ Context* context) {
SetCommonFieldVariables(descriptor, info, variables);
- (*variables)["empty_list"] = "com.google.protobuf.LazyStringArrayList.EMPTY";
+ (*variables)["empty_list"] =
+ "com.google.protobuf.LazyStringArrayList.emptyList()";
- (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
- (*variables)["default_init"] =
- "= " + ImmutableDefaultValue(descriptor, name_resolver);
+ (*variables)["default"] =
+ ImmutableDefaultValue(descriptor, name_resolver, context->options());
+ (*variables)["default_init"] = y_absl::StrCat(
+ "= ",
+ ImmutableDefaultValue(descriptor, name_resolver, context->options()));
(*variables)["capitalized_type"] = "String";
(*variables)["tag"] =
- StrCat(static_cast<arc_i32>(WireFormat::MakeTag(descriptor)));
- (*variables)["tag_size"] = StrCat(
+ y_absl::StrCat(static_cast<arc_i32>(WireFormat::MakeTag(descriptor)));
+ (*variables)["tag_size"] = y_absl::StrCat(
WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
(*variables)["null_check"] =
- " if (value == null) {\n"
- " throw new NullPointerException();\n"
- " }\n";
- (*variables)["isStringEmpty"] = "com.google.protobuf.GeneratedMessage" +
- GeneratedCodeVersionSuffix() +
- ".isStringEmpty";
- (*variables)["writeString"] = "com.google.protobuf.GeneratedMessage" +
- GeneratedCodeVersionSuffix() + ".writeString";
- (*variables)["computeStringSize"] = "com.google.protobuf.GeneratedMessage" +
- GeneratedCodeVersionSuffix() +
- ".computeStringSize";
+ "if (value == null) { throw new NullPointerException(); }";
+ (*variables)["isStringEmpty"] =
+ y_absl::StrCat("com.google.protobuf.GeneratedMessage",
+ GeneratedCodeVersionSuffix(), ".isStringEmpty");
+ (*variables)["writeString"] =
+ y_absl::StrCat("com.google.protobuf.GeneratedMessage",
+ GeneratedCodeVersionSuffix(), ".writeString");
+ (*variables)["computeStringSize"] =
+ y_absl::StrCat("com.google.protobuf.GeneratedMessage",
+ GeneratedCodeVersionSuffix(), ".computeStringSize");
// TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
// by the proto compiler
(*variables)["deprecation"] =
descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
- (*variables)["kt_deprecation"] =
- descriptor->options().deprecated()
- ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
- " is deprecated\") "
- : "";
+ variables->insert(
+ {"kt_deprecation",
+ descriptor->options().deprecated()
+ ? y_absl::StrCat("@kotlin.Deprecated(message = \"Field ",
+ (*variables)["name"], " is deprecated\") ")
+ : ""});
(*variables)["on_changed"] = "onChanged();";
if (HasHasbit(descriptor)) {
// For singular messages and builders, one bit is used for the hasField bit.
(*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
- (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex);
+ (*variables)["set_has_field_bit_to_local"] =
+ GenerateSetBitToLocal(messageBitIndex);
// Note that these have a trailing ";".
(*variables)["set_has_field_bit_message"] =
- GenerateSetBit(messageBitIndex) + ";";
- (*variables)["set_has_field_bit_builder"] =
- GenerateSetBit(builderBitIndex) + ";";
- (*variables)["clear_has_field_bit_builder"] =
- GenerateClearBit(builderBitIndex) + ";";
+ y_absl::StrCat(GenerateSetBit(messageBitIndex), ";");
(*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
} else {
+ (*variables)["get_has_field_bit_message"] = "";
+ (*variables)["set_has_field_bit_to_local"] = "";
(*variables)["set_has_field_bit_message"] = "";
- (*variables)["set_has_field_bit_builder"] = "";
- (*variables)["clear_has_field_bit_builder"] = "";
- (*variables)["is_field_present_message"] =
- "!" + (*variables)["isStringEmpty"] + "(" + (*variables)["name"] + "_)";
+ variables->insert({"is_field_present_message",
+ y_absl::StrCat("!", (*variables)["isStringEmpty"], "(",
+ (*variables)["name"], "_)")});
}
- // For repeated builders, one bit is used for whether the array is immutable.
- (*variables)["get_mutable_bit_builder"] = GenerateGetBit(builderBitIndex);
- (*variables)["set_mutable_bit_builder"] = GenerateSetBit(builderBitIndex);
- (*variables)["clear_mutable_bit_builder"] = GenerateClearBit(builderBitIndex);
-
- // For repeated fields, one bit is used for whether the array is immutable
- // in the parsing constructor.
- (*variables)["get_mutable_bit_parser"] =
- GenerateGetBitMutableLocal(builderBitIndex);
- (*variables)["set_mutable_bit_parser"] =
- GenerateSetBitMutableLocal(builderBitIndex);
-
+ (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex);
(*variables)["get_has_field_bit_from_local"] =
GenerateGetBitFromLocal(builderBitIndex);
- (*variables)["set_has_field_bit_to_local"] =
- GenerateSetBitToLocal(messageBitIndex);
+ (*variables)["set_has_field_bit_builder"] =
+ y_absl::StrCat(GenerateSetBit(builderBitIndex), ";");
+ (*variables)["clear_has_field_bit_builder"] =
+ y_absl::StrCat(GenerateClearBit(builderBitIndex), ";");
}
} // namespace
@@ -148,21 +139,30 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
ImmutableStringFieldGenerator::ImmutableStringFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
Context* context)
- : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
+ : descriptor_(descriptor),
+ message_bit_index_(messageBitIndex),
+ builder_bit_index_(builderBitIndex),
+ name_resolver_(context->GetNameResolver()) {
SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex,
context->GetFieldGeneratorInfo(descriptor),
- name_resolver_, &variables_);
+ name_resolver_, &variables_, context);
}
ImmutableStringFieldGenerator::~ImmutableStringFieldGenerator() {}
+int ImmutableStringFieldGenerator::GetMessageBitIndex() const {
+ return message_bit_index_;
+}
+
+int ImmutableStringFieldGenerator::GetBuilderBitIndex() const {
+ return builder_bit_index_;
+}
+
int ImmutableStringFieldGenerator::GetNumBitsForMessage() const {
return HasHasbit(descriptor_) ? 1 : 0;
}
-int ImmutableStringFieldGenerator::GetNumBitsForBuilder() const {
- return GetNumBitsForMessage();
-}
+int ImmutableStringFieldGenerator::GetNumBitsForBuilder() const { return 1; }
// A note about how strings are handled. This code used to just store a String
// in the Message. This had two issues:
@@ -194,8 +194,7 @@ int ImmutableStringFieldGenerator::GetNumBitsForBuilder() const {
// separate fields but rather use dynamic type checking.
//
// For single fields, the logic for this is done inside the generated code. For
-// repeated fields, the logic is done in LazyStringArrayList and
-// UnmodifiableLazyStringList.
+// repeated fields, the logic is done in LazyStringArrayList.
void ImmutableStringFieldGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
if (HasHazzer(descriptor_)) {
@@ -214,7 +213,9 @@ void ImmutableStringFieldGenerator::GenerateInterfaceMembers(
void ImmutableStringFieldGenerator::GenerateMembers(
io::Printer* printer) const {
- printer->Print(variables_, "private volatile java.lang.Object $name$_;\n");
+ printer->Print(variables_,
+ "@SuppressWarnings(\"serial\")\n"
+ "private volatile java.lang.Object $name$_ = $default$;\n");
PrintExtraFieldInfo(variables_, printer);
if (HasHazzer(descriptor_)) {
@@ -333,9 +334,9 @@ void ImmutableStringFieldGenerator::GenerateBuilderMembers(
printer->Print(variables_,
"$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
" java.lang.String value) {\n"
- "$null_check$"
- " $set_has_field_bit_builder$\n"
+ " $null_check$\n"
" $name$_ = value;\n"
+ " $set_has_field_bit_builder$\n"
" $on_changed$\n"
" return this;\n"
"}\n");
@@ -344,14 +345,14 @@ void ImmutableStringFieldGenerator::GenerateBuilderMembers(
/* builder */ true);
printer->Print(
variables_,
- "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
- " $clear_has_field_bit_builder$\n");
+ "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n");
printer->Annotate("{", "}", descriptor_);
// The default value is not a simple literal so we want to avoid executing
// it multiple times. Instead, get the default out of the default instance.
printer->Print(variables_,
" $name$_ = getDefaultInstance().get$capitalized_name$();\n");
printer->Print(variables_,
+ " $clear_has_field_bit_builder$\n"
" $on_changed$\n"
" return this;\n"
"}\n");
@@ -362,14 +363,14 @@ void ImmutableStringFieldGenerator::GenerateBuilderMembers(
variables_,
"$deprecation$public Builder ${$set$capitalized_name$Bytes$}$(\n"
" com.google.protobuf.ByteString value) {\n"
- "$null_check$");
+ " $null_check$\n");
printer->Annotate("{", "}", descriptor_);
if (CheckUtf8(descriptor_)) {
printer->Print(variables_, " checkByteStringIsUtf8(value);\n");
}
printer->Print(variables_,
- " $set_has_field_bit_builder$\n"
" $name$_ = value;\n"
+ " $set_has_field_bit_builder$\n"
" $on_changed$\n"
" return this;\n"
"}\n");
@@ -377,9 +378,9 @@ void ImmutableStringFieldGenerator::GenerateBuilderMembers(
void ImmutableStringFieldGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(variables_,
- "$kt_deprecation$var $kt_name$: kotlin.String\n"
+ "$kt_deprecation$public var $kt_name$: kotlin.String\n"
" @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
" get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
" @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
@@ -388,17 +389,18 @@ void ImmutableStringFieldGenerator::GenerateKotlinDslMembers(
" }\n");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "public fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER,
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
" return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
"}\n");
}
@@ -416,9 +418,7 @@ void ImmutableStringFieldGenerator::GenerateInitializationCode(
void ImmutableStringFieldGenerator::GenerateBuilderClearCode(
io::Printer* printer) const {
- printer->Print(variables_,
- "$name$_ = $default$;\n"
- "$clear_has_field_bit_builder$\n");
+ printer->Print(variables_, "$name$_ = $default$;\n");
}
void ImmutableStringFieldGenerator::GenerateMergingCode(
@@ -428,14 +428,15 @@ void ImmutableStringFieldGenerator::GenerateMergingCode(
// all string fields to Strings when copying fields from a Message.
printer->Print(variables_,
"if (other.has$capitalized_name$()) {\n"
- " $set_has_field_bit_builder$\n"
" $name$_ = other.$name$_;\n"
+ " $set_has_field_bit_builder$\n"
" $on_changed$\n"
"}\n");
} else {
printer->Print(variables_,
"if (!other.get$capitalized_name$().isEmpty()) {\n"
" $name$_ = other.$name$_;\n"
+ " $set_has_field_bit_builder$\n"
" $on_changed$\n"
"}\n");
}
@@ -443,35 +444,28 @@ void ImmutableStringFieldGenerator::GenerateMergingCode(
void ImmutableStringFieldGenerator::GenerateBuildingCode(
io::Printer* printer) const {
- if (HasHazzer(descriptor_)) {
- printer->Print(variables_,
- "if ($get_has_field_bit_from_local$) {\n"
- " $set_has_field_bit_to_local$;\n"
- "}\n");
+ printer->Print(variables_,
+ "if ($get_has_field_bit_from_local$) {\n"
+ " result.$name$_ = $name$_;\n");
+ if (GetNumBitsForMessage() > 0) {
+ printer->Print(variables_, " $set_has_field_bit_to_local$;\n");
}
- printer->Print(variables_, "result.$name$_ = $name$_;\n");
+ printer->Print("}\n");
}
-void ImmutableStringFieldGenerator::GenerateParsingCode(
+void ImmutableStringFieldGenerator::GenerateBuilderParsingCode(
io::Printer* printer) const {
if (CheckUtf8(descriptor_)) {
printer->Print(variables_,
- "java.lang.String s = input.readStringRequireUtf8();\n"
- "$set_has_field_bit_message$\n"
- "$name$_ = s;\n");
+ "$name$_ = input.readStringRequireUtf8();\n"
+ "$set_has_field_bit_builder$\n");
} else {
printer->Print(variables_,
- "com.google.protobuf.ByteString bs = input.readBytes();\n"
- "$set_has_field_bit_message$\n"
- "$name$_ = bs;\n");
+ "$name$_ = input.readBytes();\n"
+ "$set_has_field_bit_builder$\n");
}
}
-void ImmutableStringFieldGenerator::GenerateParsingDoneCode(
- io::Printer* printer) const {
- // noop for strings.
-}
-
void ImmutableStringFieldGenerator::GenerateSerializationCode(
io::Printer* printer) const {
printer->Print(variables_,
@@ -523,7 +517,7 @@ ImmutableStringOneofFieldGenerator::~ImmutableStringOneofFieldGenerator() {}
void ImmutableStringOneofFieldGenerator::GenerateMembers(
io::Printer* printer) const {
PrintExtraFieldInfo(variables_, printer);
- GOOGLE_DCHECK(HasHazzer(descriptor_));
+ Y_ABSL_DCHECK(HasHazzer(descriptor_));
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
@@ -587,7 +581,7 @@ void ImmutableStringOneofFieldGenerator::GenerateMembers(
void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
- GOOGLE_DCHECK(HasHazzer(descriptor_));
+ Y_ABSL_DCHECK(HasHazzer(descriptor_));
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
"@java.lang.Override\n"
@@ -655,7 +649,7 @@ void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers(
printer->Print(variables_,
"$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
" java.lang.String value) {\n"
- "$null_check$"
+ " $null_check$\n"
" $set_oneof_case_message$;\n"
" $oneof_name$_ = value;\n"
" $on_changed$\n"
@@ -682,7 +676,7 @@ void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers(
variables_,
"$deprecation$public Builder ${$set$capitalized_name$Bytes$}$(\n"
" com.google.protobuf.ByteString value) {\n"
- "$null_check$");
+ " $null_check$\n");
printer->Annotate("{", "}", descriptor_);
if (CheckUtf8(descriptor_)) {
printer->Print(variables_, " checkByteStringIsUtf8(value);\n");
@@ -695,6 +689,11 @@ void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers(
"}\n");
}
+void ImmutableStringOneofFieldGenerator::GenerateBuilderClearCode(
+ io::Printer* printer) const {
+ // No-Op: String fields in oneofs are correctly cleared by clearing the oneof
+}
+
void ImmutableStringOneofFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
// Allow a slight breach of abstraction here in order to avoid forcing
@@ -707,13 +706,10 @@ void ImmutableStringOneofFieldGenerator::GenerateMergingCode(
void ImmutableStringOneofFieldGenerator::GenerateBuildingCode(
io::Printer* printer) const {
- printer->Print(variables_,
- "if ($has_oneof_case_message$) {\n"
- " result.$oneof_name$_ = $oneof_name$_;\n"
- "}\n");
+ // No-Op: oneof fields are built by a single statement
}
-void ImmutableStringOneofFieldGenerator::GenerateParsingCode(
+void ImmutableStringOneofFieldGenerator::GenerateBuilderParsingCode(
io::Printer* printer) const {
if (CheckUtf8(descriptor_)) {
printer->Print(variables_,
@@ -749,11 +745,8 @@ void ImmutableStringOneofFieldGenerator::GenerateSerializedSizeCode(
RepeatedImmutableStringFieldGenerator::RepeatedImmutableStringFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
Context* context)
- : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
- SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex,
- context->GetFieldGeneratorInfo(descriptor),
- name_resolver_, &variables_);
-}
+ : ImmutableStringFieldGenerator(descriptor, messageBitIndex,
+ builderBitIndex, context) {}
RepeatedImmutableStringFieldGenerator::
~RepeatedImmutableStringFieldGenerator() {}
@@ -796,7 +789,9 @@ void RepeatedImmutableStringFieldGenerator::GenerateInterfaceMembers(
void RepeatedImmutableStringFieldGenerator::GenerateMembers(
io::Printer* printer) const {
printer->Print(variables_,
- "private com.google.protobuf.LazyStringList $name$_;\n");
+ "@SuppressWarnings(\"serial\")\n"
+ "private com.google.protobuf.LazyStringArrayList $name$_ =\n"
+ " $empty_list$;\n");
PrintExtraFieldInfo(variables_, printer);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(variables_,
@@ -840,17 +835,17 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers(
// memory allocations. Note, immutable is a strong guarantee here -- not
// just that the list cannot be modified via the reference but that the
// list can never be modified.
- printer->Print(
- variables_,
- "private com.google.protobuf.LazyStringList $name$_ = $empty_list$;\n");
+ printer->Print(variables_,
+ "private com.google.protobuf.LazyStringArrayList $name$_ =\n"
+ " $empty_list$;\n");
printer->Print(
variables_,
"private void ensure$capitalized_name$IsMutable() {\n"
- " if (!$get_mutable_bit_builder$) {\n"
+ " if (!$name$_.isModifiable()) {\n"
" $name$_ = new com.google.protobuf.LazyStringArrayList($name$_);\n"
- " $set_mutable_bit_builder$;\n"
- " }\n"
+ " }\n"
+ " $set_has_field_bit_builder$\n"
"}\n");
// Note: We return an unmodifiable list because otherwise the caller
@@ -861,7 +856,8 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers(
printer->Print(variables_,
"$deprecation$public com.google.protobuf.ProtocolStringList\n"
" ${$get$capitalized_name$List$}$() {\n"
- " return $name$_.getUnmodifiableView();\n"
+ " $name$_.makeImmutable();\n"
+ " return $name$_;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
@@ -891,9 +887,10 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers(
printer->Print(variables_,
"$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
" int index, java.lang.String value) {\n"
- "$null_check$"
+ " $null_check$\n"
" ensure$capitalized_name$IsMutable();\n"
" $name$_.set(index, value);\n"
+ " $set_has_field_bit_builder$\n"
" $on_changed$\n"
" return this;\n"
"}\n");
@@ -903,9 +900,10 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers(
printer->Print(variables_,
"$deprecation$public Builder ${$add$capitalized_name$$}$(\n"
" java.lang.String value) {\n"
- "$null_check$"
+ " $null_check$\n"
" ensure$capitalized_name$IsMutable();\n"
" $name$_.add(value);\n"
+ " $set_has_field_bit_builder$\n"
" $on_changed$\n"
" return this;\n"
"}\n");
@@ -918,6 +916,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers(
" ensure$capitalized_name$IsMutable();\n"
" com.google.protobuf.AbstractMessageLite.Builder.addAll(\n"
" values, $name$_);\n"
+ " $set_has_field_bit_builder$\n"
" $on_changed$\n"
" return this;\n"
"}\n");
@@ -927,8 +926,9 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers(
printer->Print(
variables_,
"$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
- " $name$_ = $empty_list$;\n"
- " $clear_mutable_bit_builder$;\n"
+ " $name$_ =\n"
+ " $empty_list$;\n"
+ " $clear_has_field_bit_builder$;\n"
" $on_changed$\n"
" return this;\n"
"}\n");
@@ -940,7 +940,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers(
variables_,
"$deprecation$public Builder ${$add$capitalized_name$Bytes$}$(\n"
" com.google.protobuf.ByteString value) {\n"
- "$null_check$");
+ " $null_check$\n");
printer->Annotate("{", "}", descriptor_);
if (CheckUtf8(descriptor_)) {
printer->Print(variables_, " checkByteStringIsUtf8(value);\n");
@@ -948,6 +948,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers(
printer->Print(variables_,
" ensure$capitalized_name$IsMutable();\n"
" $name$_.add(value);\n"
+ " $set_has_field_bit_builder$\n"
" $on_changed$\n"
" return this;\n"
"}\n");
@@ -963,13 +964,14 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
// property for List<String>
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER,
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
- "$kt_deprecation$ val $kt_name$: "
+ "$kt_deprecation$public val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -979,11 +981,11 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
// List<String>.add(String)
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"add(value: kotlin.String) {\n"
" $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
@@ -991,12 +993,12 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
// List<String> += String
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: kotlin.String) {\n"
" add(value)\n"
@@ -1004,12 +1006,12 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
// List<String>.addAll(Iterable<String>)
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"addAll(values: kotlin.collections.Iterable<kotlin.String>) {\n"
" $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
@@ -1017,13 +1019,13 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
// List<String> += Iterable<String>
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(values: kotlin.collections.Iterable<kotlin.String>) {\n"
" addAll(values)\n"
@@ -1031,23 +1033,23 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
// List<String>[Int] = String
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
+ "public operator fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"set(index: kotlin.Int, value: kotlin.String) {\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
"}");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
@@ -1061,14 +1063,16 @@ void RepeatedImmutableStringFieldGenerator::
void RepeatedImmutableStringFieldGenerator::GenerateInitializationCode(
io::Printer* printer) const {
- printer->Print(variables_, "$name$_ = $empty_list$;\n");
+ printer->Print(variables_,
+ "$name$_ =\n"
+ " $empty_list$;\n");
}
void RepeatedImmutableStringFieldGenerator::GenerateBuilderClearCode(
io::Printer* printer) const {
printer->Print(variables_,
- "$name$_ = $empty_list$;\n"
- "$clear_mutable_bit_builder$;\n");
+ "$name$_ =\n"
+ " $empty_list$;\n");
}
void RepeatedImmutableStringFieldGenerator::GenerateMergingCode(
@@ -1082,7 +1086,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateMergingCode(
"if (!other.$name$_.isEmpty()) {\n"
" if ($name$_.isEmpty()) {\n"
" $name$_ = other.$name$_;\n"
- " $clear_mutable_bit_builder$;\n"
+ " $set_has_field_bit_builder$\n"
" } else {\n"
" ensure$capitalized_name$IsMutable();\n"
" $name$_.addAll(other.$name$_);\n"
@@ -1095,44 +1099,28 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuildingCode(
io::Printer* printer) const {
// The code below ensures that the result has an immutable list. If our
// list is immutable, we can just reuse it. If not, we make it immutable.
-
printer->Print(variables_,
- "if ($get_mutable_bit_builder$) {\n"
- " $name$_ = $name$_.getUnmodifiableView();\n"
- " $clear_mutable_bit_builder$;\n"
- "}\n"
- "result.$name$_ = $name$_;\n");
+ "if ($get_has_field_bit_from_local$) {\n"
+ " $name$_.makeImmutable();\n"
+ " result.$name$_ = $name$_;\n"
+ "}\n");
}
-void RepeatedImmutableStringFieldGenerator::GenerateParsingCode(
+void RepeatedImmutableStringFieldGenerator::GenerateBuilderParsingCode(
io::Printer* printer) const {
if (CheckUtf8(descriptor_)) {
printer->Print(variables_,
- "java.lang.String s = input.readStringRequireUtf8();\n");
+ "java.lang.String s = input.readStringRequireUtf8();\n"
+ "ensure$capitalized_name$IsMutable();\n"
+ "$name$_.add(s);\n");
} else {
printer->Print(variables_,
- "com.google.protobuf.ByteString bs = input.readBytes();\n");
- }
- printer->Print(variables_,
- "if (!$get_mutable_bit_parser$) {\n"
- " $name$_ = new com.google.protobuf.LazyStringArrayList();\n"
- " $set_mutable_bit_parser$;\n"
- "}\n");
- if (CheckUtf8(descriptor_)) {
- printer->Print(variables_, "$name$_.add(s);\n");
- } else {
- printer->Print(variables_, "$name$_.add(bs);\n");
+ "com.google.protobuf.ByteString bs = input.readBytes();\n"
+ "ensure$capitalized_name$IsMutable();\n"
+ "$name$_.add(bs);\n");
}
}
-void RepeatedImmutableStringFieldGenerator::GenerateParsingDoneCode(
- io::Printer* printer) const {
- printer->Print(variables_,
- "if ($get_mutable_bit_parser$) {\n"
- " $name$_ = $name$_.getUnmodifiableView();\n"
- "}\n");
-}
-
void RepeatedImmutableStringFieldGenerator::GenerateSerializationCode(
io::Printer* printer) const {
printer->Print(variables_,
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field.h
index 3a83f1fc2a6..e7ef4d7c061 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field.h
@@ -36,10 +36,9 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_H__
-#include <map>
#include <string>
-#include <google/protobuf/compiler/java/field.h>
+#include "google/protobuf/compiler/java/field.h"
namespace google {
namespace protobuf {
@@ -62,10 +61,15 @@ class ImmutableStringFieldGenerator : public ImmutableFieldGenerator {
explicit ImmutableStringFieldGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
int builderBitIndex, Context* context);
+ ImmutableStringFieldGenerator(const ImmutableStringFieldGenerator&) = delete;
+ ImmutableStringFieldGenerator& operator=(
+ const ImmutableStringFieldGenerator&) = delete;
~ImmutableStringFieldGenerator() override;
// implements ImmutableFieldGenerator
// ---------------------------------------
+ int GetMessageBitIndex() const override;
+ int GetBuilderBitIndex() const override;
int GetNumBitsForMessage() const override;
int GetNumBitsForBuilder() const override;
void GenerateInterfaceMembers(io::Printer* printer) const override;
@@ -75,8 +79,7 @@ class ImmutableStringFieldGenerator : public ImmutableFieldGenerator {
void GenerateBuilderClearCode(io::Printer* printer) const override;
void GenerateMergingCode(io::Printer* printer) const override;
void GenerateBuildingCode(io::Printer* printer) const override;
- void GenerateParsingCode(io::Printer* printer) const override;
- void GenerateParsingDoneCode(io::Printer* printer) const override;
+ void GenerateBuilderParsingCode(io::Printer* printer) const override;
void GenerateSerializationCode(io::Printer* printer) const override;
void GenerateSerializedSizeCode(io::Printer* printer) const override;
void GenerateFieldBuilderInitializationCode(
@@ -89,11 +92,10 @@ class ImmutableStringFieldGenerator : public ImmutableFieldGenerator {
protected:
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ int message_bit_index_;
+ int builder_bit_index_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables_;
ClassNameResolver* name_resolver_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableStringFieldGenerator);
};
class ImmutableStringOneofFieldGenerator
@@ -102,25 +104,33 @@ class ImmutableStringOneofFieldGenerator
ImmutableStringOneofFieldGenerator(const FieldDescriptor* descriptor,
int messageBitIndex, int builderBitIndex,
Context* context);
+ ImmutableStringOneofFieldGenerator(
+ const ImmutableStringOneofFieldGenerator&) = delete;
+ ImmutableStringOneofFieldGenerator& operator=(
+ const ImmutableStringOneofFieldGenerator&) = delete;
~ImmutableStringOneofFieldGenerator() override;
private:
void GenerateMembers(io::Printer* printer) const override;
void GenerateBuilderMembers(io::Printer* printer) const override;
+ void GenerateBuilderClearCode(io::Printer* printer) const override;
void GenerateMergingCode(io::Printer* printer) const override;
void GenerateBuildingCode(io::Printer* printer) const override;
- void GenerateParsingCode(io::Printer* printer) const override;
+ void GenerateBuilderParsingCode(io::Printer* printer) const override;
void GenerateSerializationCode(io::Printer* printer) const override;
void GenerateSerializedSizeCode(io::Printer* printer) const override;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableStringOneofFieldGenerator);
};
-class RepeatedImmutableStringFieldGenerator : public ImmutableFieldGenerator {
+class RepeatedImmutableStringFieldGenerator
+ : public ImmutableStringFieldGenerator {
public:
explicit RepeatedImmutableStringFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex,
int builderBitIndex, Context* context);
+ RepeatedImmutableStringFieldGenerator(
+ const RepeatedImmutableStringFieldGenerator&) = delete;
+ RepeatedImmutableStringFieldGenerator& operator=(
+ const RepeatedImmutableStringFieldGenerator&) = delete;
~RepeatedImmutableStringFieldGenerator() override;
// implements ImmutableFieldGenerator ---------------------------------------
@@ -133,8 +143,7 @@ class RepeatedImmutableStringFieldGenerator : public ImmutableFieldGenerator {
void GenerateBuilderClearCode(io::Printer* printer) const override;
void GenerateMergingCode(io::Printer* printer) const override;
void GenerateBuildingCode(io::Printer* printer) const override;
- void GenerateParsingCode(io::Printer* printer) const override;
- void GenerateParsingDoneCode(io::Printer* printer) const override;
+ void GenerateBuilderParsingCode(io::Printer* printer) const override;
void GenerateSerializationCode(io::Printer* printer) const override;
void GenerateSerializedSizeCode(io::Printer* printer) const override;
void GenerateFieldBuilderInitializationCode(
@@ -144,13 +153,6 @@ class RepeatedImmutableStringFieldGenerator : public ImmutableFieldGenerator {
void GenerateKotlinDslMembers(io::Printer* printer) const override;
TProtoStringType GetBoxedType() const override;
-
- private:
- const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
- ClassNameResolver* name_resolver_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableStringFieldGenerator);
};
} // namespace java
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field_lite.cc
index 91cb53d484f..6e57d1bbef4 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field_lite.cc
@@ -33,21 +33,19 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/string_field_lite.h>
+#include "google/protobuf/compiler/java/string_field_lite.h"
#include <cstdint>
-#include <map>
#include <string>
-#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/context.h>
-#include <google/protobuf/compiler/java/doc_comment.h>
-#include <google/protobuf/compiler/java/helpers.h>
-#include <google/protobuf/compiler/java/name_resolver.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/java/context.h"
+#include "google/protobuf/compiler/java/doc_comment.h"
+#include "google/protobuf/compiler/java/helpers.h"
+#include "google/protobuf/compiler/java/name_resolver.h"
+#include "google/protobuf/wire_format.h"
namespace google {
namespace protobuf {
@@ -59,23 +57,25 @@ using internal::WireFormatLite;
namespace {
-void SetPrimitiveVariables(const FieldDescriptor* descriptor,
- int messageBitIndex, int builderBitIndex,
- const FieldGeneratorInfo* info,
- ClassNameResolver* name_resolver,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+void SetPrimitiveVariables(
+ const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
+ const FieldGeneratorInfo* info, ClassNameResolver* name_resolver,
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables,
+ Context* context) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["empty_list"] =
"com.google.protobuf.GeneratedMessageLite.emptyProtobufList()";
- (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
- (*variables)["default_init"] =
- "= " + ImmutableDefaultValue(descriptor, name_resolver);
+ (*variables)["default"] =
+ ImmutableDefaultValue(descriptor, name_resolver, context->options());
+ (*variables)["default_init"] = y_absl::StrCat(
+ "= ",
+ ImmutableDefaultValue(descriptor, name_resolver, context->options()));
(*variables)["capitalized_type"] = "java.lang.String";
(*variables)["tag"] =
- StrCat(static_cast<arc_i32>(WireFormat::MakeTag(descriptor)));
- (*variables)["tag_size"] = StrCat(
+ y_absl::StrCat(static_cast<arc_i32>(WireFormat::MakeTag(descriptor)));
+ (*variables)["tag_size"] = y_absl::StrCat(
WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
// We use `x.getClass()` as a null check because it generates less bytecode
// than an `if (x == null) { throw ... }` statement.
@@ -86,36 +86,49 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
// by the proto compiler
(*variables)["deprecation"] =
descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
- (*variables)["kt_deprecation"] =
- descriptor->options().deprecated()
- ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
- " is deprecated\") "
- : "";
+ variables->insert(
+ {"kt_deprecation",
+ descriptor->options().deprecated()
+ ? y_absl::StrCat("@kotlin.Deprecated(message = \"Field ",
+ (*variables)["name"], " is deprecated\") ")
+ : ""});
(*variables)["required"] = descriptor->is_required() ? "true" : "false";
+ if (!context->options().opensource_runtime) {
+ (*variables)["enforce_utf8"] = CheckUtf8(descriptor) ? "true" : "false";
+ }
if (HasHasbit(descriptor)) {
+ if (!context->options().opensource_runtime) {
+ (*variables)["bit_field_id"] = y_absl::StrCat(messageBitIndex / 32);
+ (*variables)["bit_field_name"] = GetBitFieldNameForBit(messageBitIndex);
+ (*variables)["bit_field_mask"] =
+ y_absl::StrCat(1 << (messageBitIndex % 32));
+ }
// For singular messages and builders, one bit is used for the hasField bit.
(*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
// Note that these have a trailing ";".
(*variables)["set_has_field_bit_message"] =
- GenerateSetBit(messageBitIndex) + ";";
+ y_absl::StrCat(GenerateSetBit(messageBitIndex), ";");
(*variables)["clear_has_field_bit_message"] =
- GenerateClearBit(messageBitIndex) + ";";
+ y_absl::StrCat(GenerateClearBit(messageBitIndex), ";");
(*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
} else {
(*variables)["set_has_field_bit_message"] = "";
(*variables)["clear_has_field_bit_message"] = "";
- (*variables)["is_field_present_message"] =
- "!" + (*variables)["name"] + "_.isEmpty()";
+ variables->insert({"is_field_present_message",
+ y_absl::StrCat("!", (*variables)["name"], "_.isEmpty()")});
}
(*variables)["get_has_field_bit_from_local"] =
GenerateGetBitFromLocal(builderBitIndex);
(*variables)["set_has_field_bit_to_local"] =
GenerateSetBitToLocal(messageBitIndex);
+ // Annotations often use { and } variables to denote text ranges.
+ (*variables)["{"] = "";
+ (*variables)["}"] = "";
}
} // namespace
@@ -126,10 +139,11 @@ ImmutableStringFieldLiteGenerator::ImmutableStringFieldLiteGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, Context* context)
: descriptor_(descriptor),
messageBitIndex_(messageBitIndex),
- name_resolver_(context->GetNameResolver()) {
+ name_resolver_(context->GetNameResolver()),
+ context_(context) {
SetPrimitiveVariables(descriptor, messageBitIndex, 0,
context->GetFieldGeneratorInfo(descriptor),
- name_resolver_, &variables_);
+ name_resolver_, &variables_, context);
}
ImmutableStringFieldLiteGenerator::~ImmutableStringFieldLiteGenerator() {}
@@ -168,19 +182,38 @@ void ImmutableStringFieldLiteGenerator::GenerateInterfaceMembers(
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
- "$deprecation$boolean has$capitalized_name$();\n");
+ "$deprecation$boolean ${$has$capitalized_name$$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
}
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
- "$deprecation$java.lang.String get$capitalized_name$();\n");
+ printer->Print(
+ variables_,
+ "$deprecation$java.lang.String ${$get$capitalized_name$$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
"$deprecation$com.google.protobuf.ByteString\n"
- " get$capitalized_name$Bytes();\n");
+ " ${$get$capitalized_name$Bytes$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
}
void ImmutableStringFieldLiteGenerator::GenerateMembers(
io::Printer* printer) const {
+ if (!context_->options().opensource_runtime) {
+ printer->Print(
+ variables_,
+ "@com.google.protobuf.ProtoField(\n"
+ " fieldNumber=$number$,\n"
+ " type=com.google.protobuf.FieldType.$annotation_field_type$,\n"
+ " isRequired=$required$,\n"
+ " isEnforceUtf8=$enforce_utf8$)\n");
+ if (HasHazzer(descriptor_)) {
+ printer->Print(variables_,
+ "@com.google.protobuf.ProtoPresenceCheckedField(\n"
+ " presenceBitsId=$bit_field_id$,\n"
+ " mask=$bit_field_mask$)\n");
+ }
+ }
printer->Print(variables_, "private java.lang.String $name$_;\n");
PrintExtraFieldInfo(variables_, printer);
@@ -311,9 +344,9 @@ void ImmutableStringFieldLiteGenerator::GenerateBuilderMembers(
void ImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_, /* kdoc */ true);
printer->Print(variables_,
- "$kt_deprecation$var $kt_name$: kotlin.String\n"
+ "$kt_deprecation$public var $kt_name$: kotlin.String\n"
" @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
" get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
" @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
@@ -322,17 +355,18 @@ void ImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
" }\n");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "public fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER,
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
" return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
"}\n");
}
@@ -374,7 +408,7 @@ ImmutableStringOneofFieldLiteGenerator::
void ImmutableStringOneofFieldLiteGenerator::GenerateMembers(
io::Printer* printer) const {
PrintExtraFieldInfo(variables_, printer);
- GOOGLE_DCHECK(HasHazzer(descriptor_));
+ Y_ABSL_DCHECK(HasHazzer(descriptor_));
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
"@java.lang.Override\n"
@@ -452,7 +486,7 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateFieldInfo(
void ImmutableStringOneofFieldLiteGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
- GOOGLE_DCHECK(HasHazzer(descriptor_));
+ Y_ABSL_DCHECK(HasHazzer(descriptor_));
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
"@java.lang.Override\n"
@@ -519,10 +553,12 @@ RepeatedImmutableStringFieldLiteGenerator::
RepeatedImmutableStringFieldLiteGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
Context* context)
- : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
+ : descriptor_(descriptor),
+ name_resolver_(context->GetNameResolver()),
+ context_(context) {
SetPrimitiveVariables(descriptor, messageBitIndex, 0,
context->GetFieldGeneratorInfo(descriptor),
- name_resolver_, &variables_);
+ name_resolver_, &variables_, context);
}
RepeatedImmutableStringFieldLiteGenerator::
@@ -537,22 +573,34 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateInterfaceMembers(
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(variables_,
"$deprecation$java.util.List<java.lang.String>\n"
- " get$capitalized_name$List();\n");
+ " ${$get$capitalized_name$List$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
printer->Print(variables_,
- "$deprecation$int get$capitalized_name$Count();\n");
+ "$deprecation$int ${$get$capitalized_name$Count$}$();\n");
+ printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
- printer->Print(
- variables_,
- "$deprecation$java.lang.String get$capitalized_name$(int index);\n");
+ printer->Print(variables_,
+ "$deprecation$java.lang.String "
+ "${$get$capitalized_name$$}$(int index);\n");
+ printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
printer->Print(variables_,
"$deprecation$com.google.protobuf.ByteString\n"
- " get$capitalized_name$Bytes(int index);\n");
+ " ${$get$capitalized_name$Bytes$}$(int index);\n");
+ printer->Annotate("{", "}", descriptor_);
}
void RepeatedImmutableStringFieldLiteGenerator::GenerateMembers(
io::Printer* printer) const {
+ if (!context_->options().opensource_runtime) {
+ printer->Print(
+ variables_,
+ "@com.google.protobuf.ProtoField(\n"
+ " fieldNumber=$number$,\n"
+ " type=com.google.protobuf.FieldType.$annotation_field_type$,\n"
+ " isEnforceUtf8=$enforce_utf8$)\n");
+ }
printer->Print(
variables_,
"private com.google.protobuf.Internal.ProtobufList<java.lang.String> "
@@ -748,14 +796,15 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
// property for List<String>
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER,
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
- "$kt_deprecation$ val $kt_name$: "
+ "$kt_deprecation$public val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>\n"
"@kotlin.OptIn"
@@ -766,11 +815,11 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
// List<String>.add(String)
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"add(value: kotlin.String) {\n"
" $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
@@ -778,12 +827,12 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
// List<String> += String
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: kotlin.String) {\n"
" add(value)\n"
@@ -791,12 +840,12 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
// List<String>.addAll(Iterable<String>)
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"addAll(values: kotlin.collections.Iterable<kotlin.String>) {\n"
" $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
@@ -804,13 +853,13 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
// List<String> += Iterable<String>
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(values: kotlin.collections.Iterable<kotlin.String>) {\n"
" addAll(values)\n"
@@ -818,23 +867,23 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
// List<String>[Int] = String
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
+ "public operator fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"set(index: kotlin.Int, value: kotlin.String) {\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
"}");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
+ /* builder */ false, /* kdoc */ true);
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field_lite.h
index 73e51e32383..e65b9953d30 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field_lite.h
@@ -37,10 +37,9 @@
#define GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_LITE_H__
#include <cstdint>
-#include <map>
#include <string>
-#include <google/protobuf/compiler/java/field.h>
+#include "google/protobuf/compiler/java/field.h"
namespace google {
namespace protobuf {
@@ -63,6 +62,10 @@ class ImmutableStringFieldLiteGenerator : public ImmutableFieldLiteGenerator {
explicit ImmutableStringFieldLiteGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
Context* context);
+ ImmutableStringFieldLiteGenerator(const ImmutableStringFieldLiteGenerator&) =
+ delete;
+ ImmutableStringFieldLiteGenerator& operator=(
+ const ImmutableStringFieldLiteGenerator&) = delete;
~ImmutableStringFieldLiteGenerator() override;
// implements ImmutableFieldLiteGenerator
@@ -80,12 +83,10 @@ class ImmutableStringFieldLiteGenerator : public ImmutableFieldLiteGenerator {
protected:
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables_;
const int messageBitIndex_;
ClassNameResolver* name_resolver_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableStringFieldLiteGenerator);
+ Context* context_;
};
class ImmutableStringOneofFieldLiteGenerator
@@ -93,6 +94,10 @@ class ImmutableStringOneofFieldLiteGenerator
public:
ImmutableStringOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
int messageBitIndex, Context* context);
+ ImmutableStringOneofFieldLiteGenerator(
+ const ImmutableStringOneofFieldLiteGenerator&) = delete;
+ ImmutableStringOneofFieldLiteGenerator& operator=(
+ const ImmutableStringOneofFieldLiteGenerator&) = delete;
~ImmutableStringOneofFieldLiteGenerator() override;
private:
@@ -100,8 +105,6 @@ class ImmutableStringOneofFieldLiteGenerator
void GenerateBuilderMembers(io::Printer* printer) const override;
void GenerateFieldInfo(io::Printer* printer,
std::vector<uint16_t>* output) const override;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableStringOneofFieldLiteGenerator);
};
class RepeatedImmutableStringFieldLiteGenerator
@@ -109,6 +112,10 @@ class RepeatedImmutableStringFieldLiteGenerator
public:
explicit RepeatedImmutableStringFieldLiteGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
+ RepeatedImmutableStringFieldLiteGenerator(
+ const RepeatedImmutableStringFieldLiteGenerator&) = delete;
+ RepeatedImmutableStringFieldLiteGenerator& operator=(
+ const RepeatedImmutableStringFieldLiteGenerator&) = delete;
~RepeatedImmutableStringFieldLiteGenerator() override;
// implements ImmutableFieldLiteGenerator ------------------------------------
@@ -125,10 +132,9 @@ class RepeatedImmutableStringFieldLiteGenerator
private:
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables_;
ClassNameResolver* name_resolver_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableStringFieldLiteGenerator);
+ Context* context_;
};
} // namespace java
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/main.cc b/contrib/libs/protoc/src/google/protobuf/compiler/main.cc
index 39609468ab6..3f3817e4637 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/main.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/main.cc
@@ -28,25 +28,27 @@
// (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/cpp/generator.h>
-#include <google/protobuf/compiler/java/generator.h>
-#include <google/protobuf/compiler/java/kotlin_generator.h>
-#include <google/protobuf/compiler/command_line_interface.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/python/generator.h>
-#include <google/protobuf/compiler/python/pyi_generator.h>
-#include <google/protobuf/compiler/ruby/ruby_generator.h>
+#include "y_absl/log/initialize.h"
+#include "google/protobuf/compiler/command_line_interface.h"
+#include "google/protobuf/compiler/cpp/generator.h"
+#include "google/protobuf/compiler/csharp/csharp_generator.h"
+#include "google/protobuf/compiler/java/generator.h"
+#include "google/protobuf/compiler/java/kotlin_generator.h"
+#include "google/protobuf/compiler/objectivec/generator.h"
+#include "google/protobuf/compiler/php/php_generator.h"
+#include "google/protobuf/compiler/python/generator.h"
+#include "google/protobuf/compiler/python/pyi_generator.h"
+#include "google/protobuf/compiler/ruby/ruby_generator.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
namespace compiler {
int ProtobufMain(int argc, char* argv[]) {
+ y_absl::InitializeLog();
CommandLineInterface cli;
cli.AllowPlugins("protoc-");
@@ -66,6 +68,10 @@ int ProtobufMain(int argc, char* argv[]) {
cli.RegisterGenerator("--java_out", "--java_opt", &java_generator,
"Generate Java source file.");
+#ifdef GOOGLE_PROTOBUF_RUNTIME_INCLUDE_BASE
+ java_generator.set_opensource_runtime(true);
+#endif
+
// Proto2 Kotlin
java::KotlinGenerator kt_generator;
cli.RegisterGenerator("--kotlin_out", "--kotlin_opt", &kt_generator,
@@ -76,6 +82,11 @@ int ProtobufMain(int argc, char* argv[]) {
python::Generator py_generator;
cli.RegisterGenerator("--python_out", "--python_opt", &py_generator,
"Generate Python source file.");
+
+#ifdef GOOGLE_PROTOBUF_RUNTIME_INCLUDE_BASE
+ py_generator.set_opensource_runtime(true);
+#endif
+
// Python pyi
python::PyiGenerator pyi_generator;
cli.RegisterGenerator("--pyi_out", &pyi_generator,
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/enum.cc
index 39c78295768..5b23792af44 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/enum.cc
@@ -28,23 +28,38 @@
// (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 <map>
+#include "google/protobuf/compiler/objectivec/enum.h"
+
+#include <algorithm>
+#include <limits>
#include <string>
-#include <google/protobuf/compiler/objectivec/objectivec_enum.h>
-#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <algorithm> // std::find()
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/strings/escaping.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/objectivec/helpers.h"
+#include "google/protobuf/compiler/objectivec/names.h"
+#include "google/protobuf/compiler/objectivec/text_format_decode_data.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
namespace compiler {
namespace objectivec {
+namespace {
+TProtoStringType SafelyPrintIntToCode(int v) {
+ if (v == std::numeric_limits<int>::min()) {
+ // Some compilers try to parse -2147483648 as two tokens and then get spicy
+ // about the fact that +2147483648 cannot be represented as an int.
+ return y_absl::StrCat(v + 1, " - 1");
+ } else {
+ return y_absl::StrCat(v);
+ }
+}
+} // namespace
EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor)
- : descriptor_(descriptor),
- name_(EnumName(descriptor_)) {
+ : descriptor_(descriptor), name_(EnumName(descriptor_)) {
// Track the names for the enum values, and if an alias overlaps a base
// value, skip making a name for it. Likewise if two alias overlap, the
// first one wins.
@@ -54,7 +69,7 @@ EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor)
// compile error is just fine.
// The values are still tracked to support the reflection apis and
// TextFormat handing since they are different there.
- std::set<TProtoStringType> value_names;
+ y_absl::flat_hash_set<TProtoStringType> value_names;
for (int i = 0; i < descriptor_->value_count(); i++) {
const EnumValueDescriptor* value = descriptor_->value(i);
@@ -65,20 +80,15 @@ EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor)
base_values_.push_back(value);
value_names.insert(EnumValueName(value));
} else {
- TProtoStringType value_name(EnumValueName(value));
- if (value_names.find(value_name) != value_names.end()) {
+ if (!value_names.insert(EnumValueName(value)).second) {
alias_values_to_skip_.insert(value);
- } else {
- value_names.insert(value_name);
}
}
all_values_.push_back(value);
}
}
-EnumGenerator::~EnumGenerator() {}
-
-void EnumGenerator::GenerateHeader(io::Printer* printer) {
+void EnumGenerator::GenerateHeader(io::Printer* printer) const {
TProtoStringType enum_comments;
SourceLocation location;
if (descriptor_->GetSourceLocation(&location)) {
@@ -106,45 +116,49 @@ void EnumGenerator::GenerateHeader(io::Printer* printer) {
// doesn't have to bother with the `enum_extensibility` attribute, as the
// default will be what is needed.
- printer->Print("$comments$typedef$deprecated_attribute$ GPB_ENUM($name$) {\n",
- "comments", enum_comments,
- "deprecated_attribute", GetOptionalDeprecatedAttribute(descriptor_, descriptor_->file()),
- "name", name_);
+ printer->Print(
+ "$comments$typedef$deprecated_attribute$ GPB_ENUM($name$) {\n",
+ "comments", enum_comments, "deprecated_attribute",
+ GetOptionalDeprecatedAttribute(descriptor_, descriptor_->file()), "name",
+ name_);
printer->Indent();
- if (HasPreservingUnknownEnumSemantics(descriptor_->file())) {
+ if (!descriptor_->is_closed()) {
// Include the unknown value.
printer->Print(
- "/**\n"
- " * Value used if any message's field encounters a value that is not defined\n"
- " * by this enum. The message will also have C functions to get/set the rawValue\n"
- " * of the field.\n"
- " **/\n"
- "$name$_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,\n",
- "name", name_);
+ // clang-format off
+ "/**\n"
+ " * Value used if any message's field encounters a value that is not defined\n"
+ " * by this enum. The message will also have C functions to get/set the rawValue\n"
+ " * of the field.\n"
+ " **/\n"
+ "$name$_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,\n",
+ // clang-format on
+ "name", name_);
}
for (int i = 0; i < all_values_.size(); i++) {
- if (alias_values_to_skip_.find(all_values_[i]) != alias_values_to_skip_.end()) {
+ if (alias_values_to_skip_.find(all_values_[i]) !=
+ alias_values_to_skip_.end()) {
continue;
}
if (all_values_[i]->GetSourceLocation(&location)) {
- TProtoStringType comments = BuildCommentsString(location, true).c_str();
+ TProtoStringType comments = BuildCommentsString(location, true);
if (comments.length() > 0) {
if (i > 0) {
printer->Print("\n");
}
- printer->Print(comments.c_str());
+ printer->Print(comments);
}
}
- printer->Print(
- "$name$$deprecated_attribute$ = $value$,\n",
- "name", EnumValueName(all_values_[i]),
- "deprecated_attribute", GetOptionalDeprecatedAttribute(all_values_[i]),
- "value", StrCat(all_values_[i]->number()));
+ printer->Print("$name$$deprecated_attribute$ = $value$,\n", "name",
+ EnumValueName(all_values_[i]), "deprecated_attribute",
+ GetOptionalDeprecatedAttribute(all_values_[i]), "value",
+ SafelyPrintIntToCode(all_values_[i]->number()));
}
printer->Outdent();
printer->Print(
+ // clang-format off
"};\n"
"\n"
"GPBEnumDescriptor *$name$_EnumDescriptor(void);\n"
@@ -154,11 +168,12 @@ void EnumGenerator::GenerateHeader(io::Printer* printer) {
" * the time this source was generated.\n"
" **/\n"
"BOOL $name$_IsValidValue(arc_i32 value);\n"
+ // clang-format on
"\n",
"name", name_);
}
-void EnumGenerator::GenerateSource(io::Printer* printer) {
+void EnumGenerator::GenerateSource(io::Printer* printer) const {
printer->Print(
"#pragma mark - Enum $name$\n"
"\n",
@@ -184,38 +199,47 @@ void EnumGenerator::GenerateSource(io::Printer* printer) {
}
printer->Print(
+ // clang-format off
"GPBEnumDescriptor *$name$_EnumDescriptor(void) {\n"
" static _Atomic(GPBEnumDescriptor*) descriptor = nil;\n"
- " if (!descriptor) {\n",
+ " if (!descriptor) {\n"
+ " GPB_DEBUG_CHECK_RUNTIME_VERSIONS();\n",
+ // clang-format on
"name", name_);
static const int kBytesPerLine = 40; // allow for escaping
- printer->Print(
- " static const char *valueNames =");
+ printer->Print(" static const char *valueNames =");
for (int i = 0; i < text_blob.size(); i += kBytesPerLine) {
printer->Print(
- "\n \"$data$\"",
- "data", EscapeTrigraphs(CEscape(text_blob.substr(i, kBytesPerLine))));
+ "\n \"$data$\"", "data",
+ EscapeTrigraphs(y_absl::CEscape(text_blob.substr(i, kBytesPerLine))));
}
printer->Print(
";\n"
" static const arc_i32 values[] = {\n");
for (int i = 0; i < all_values_.size(); i++) {
- printer->Print(" $name$,\n", "name", EnumValueName(all_values_[i]));
+ printer->Print(" $name$,\n", "name", EnumValueName(all_values_[i]));
}
printer->Print(" };\n");
if (text_format_decode_data.num_entries() == 0) {
printer->Print(
+ // clang-format off
" GPBEnumDescriptor *worker =\n"
" [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol($name$)\n"
" valueNames:valueNames\n"
" values:values\n"
" count:(arc_ui32)(sizeof(values) / sizeof(arc_i32))\n"
- " enumVerifier:$name$_IsValidValue];\n",
- "name", name_);
- } else {
- printer->Print(
+ " enumVerifier:$name$_IsValidValue\n"
+ " flags:$flags$];\n",
+ // clang-format on
+ "name", name_, "flags",
+ (descriptor_->is_closed()
+ ? "GPBEnumDescriptorInitializationFlag_IsClosed"
+ : "GPBEnumDescriptorInitializationFlag_None"));
+ } else {
+ printer->Print(
+ // clang-format off
" static const char *extraTextFormatInfo = \"$extraTextFormatInfo$\";\n"
" GPBEnumDescriptor *worker =\n"
" [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol($name$)\n"
@@ -223,36 +247,46 @@ void EnumGenerator::GenerateSource(io::Printer* printer) {
" values:values\n"
" count:(arc_ui32)(sizeof(values) / sizeof(arc_i32))\n"
" enumVerifier:$name$_IsValidValue\n"
+ " flags:$flags$\n"
" extraTextFormatInfo:extraTextFormatInfo];\n",
- "name", name_,
- "extraTextFormatInfo", CEscape(text_format_decode_data.Data()));
- }
- printer->Print(
- " GPBEnumDescriptor *expected = nil;\n"
- " if (!atomic_compare_exchange_strong(&descriptor, &expected, worker)) {\n"
- " [worker release];\n"
- " }\n"
- " }\n"
- " return descriptor;\n"
- "}\n\n");
+ // clang-format on
+ "name", name_, "flags",
+ (descriptor_->is_closed()
+ ? "GPBEnumDescriptorInitializationFlag_IsClosed"
+ : "GPBEnumDescriptorInitializationFlag_None"),
+ "extraTextFormatInfo", y_absl::CEscape(text_format_decode_data.Data()));
+ }
+ // clang-format off
+ printer->Print(
+ " GPBEnumDescriptor *expected = nil;\n"
+ " if (!atomic_compare_exchange_strong(&descriptor, &expected, worker)) {\n"
+ " [worker release];\n"
+ " }\n"
+ " }\n"
+ " return descriptor;\n"
+ "}\n\n");
+ // clang-format on
printer->Print(
+ // clang-format off
"BOOL $name$_IsValidValue(arc_i32 value__) {\n"
" switch (value__) {\n",
+ // clang-format on
"name", name_);
for (int i = 0; i < base_values_.size(); i++) {
- printer->Print(
- " case $name$:\n",
- "name", EnumValueName(base_values_[i]));
+ printer->Print(" case $name$:\n", "name",
+ EnumValueName(base_values_[i]));
}
+ // clang-format off
printer->Print(
" return YES;\n"
" default:\n"
" return NO;\n"
" }\n"
"}\n\n");
+ // clang-format on
}
} // namespace objectivec
} // namespace compiler
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/enum.h
index 4d0404bcb32..962620febaf 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/enum.h
@@ -32,10 +32,11 @@
#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_ENUM_H__
#include <string>
-#include <set>
#include <vector>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/io/printer.h>
+
+#include "y_absl/container/flat_hash_set.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
@@ -45,13 +46,13 @@ namespace objectivec {
class EnumGenerator {
public:
explicit EnumGenerator(const EnumDescriptor* descriptor);
- ~EnumGenerator();
+ ~EnumGenerator() = default;
EnumGenerator(const EnumGenerator&) = delete;
EnumGenerator& operator=(const EnumGenerator&) = delete;
- void GenerateHeader(io::Printer* printer);
- void GenerateSource(io::Printer* printer);
+ void GenerateHeader(io::Printer* printer) const;
+ void GenerateSource(io::Printer* printer) const;
const TProtoStringType& name() const { return name_; }
@@ -59,7 +60,7 @@ class EnumGenerator {
const EnumDescriptor* descriptor_;
std::vector<const EnumValueDescriptor*> base_values_;
std::vector<const EnumValueDescriptor*> all_values_;
- std::set<const EnumValueDescriptor*> alias_values_to_skip_;
+ y_absl::flat_hash_set<const EnumValueDescriptor*> alias_values_to_skip_;
const TProtoStringType name_;
};
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/enum_field.cc
index bcecc7b3730..c470c241581 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/enum_field.cc
@@ -28,12 +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.
-#include <map>
+#include "google/protobuf/compiler/objectivec/enum_field.h"
+
#include <string>
-#include <google/protobuf/compiler/objectivec/objectivec_enum_field.h>
-#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
-#include <google/protobuf/io/printer.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "google/protobuf/compiler/objectivec/helpers.h"
+#include "google/protobuf/compiler/objectivec/names.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
@@ -42,22 +44,24 @@ namespace objectivec {
namespace {
-void SetEnumVariables(const FieldDescriptor* descriptor,
- std::map<TProtoStringType, TProtoStringType>* variables) {
- TProtoStringType type = EnumName(descriptor->enum_type());
+void SetEnumVariables(
+ const FieldDescriptor* descriptor,
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables) {
+ const TProtoStringType type = EnumName(descriptor->enum_type());
+ const TProtoStringType enum_desc_func = y_absl::StrCat(type, "_EnumDescriptor");
(*variables)["storage_type"] = type;
// For non repeated fields, if it was defined in a different file, the
// property decls need to use "enum NAME" rather than just "NAME" to support
// the forward declaration of the enums.
if (!descriptor->is_repeated() &&
(descriptor->file() != descriptor->enum_type()->file())) {
- (*variables)["property_type"] = "enum " + type;
+ (*variables)["property_type"] = y_absl::StrCat("enum ", type);
}
- (*variables)["enum_verifier"] = type + "_IsValidValue";
- (*variables)["enum_desc_func"] = type + "_EnumDescriptor";
+ (*variables)["enum_verifier"] = y_absl::StrCat(type, "_IsValidValue");
+ (*variables)["enum_desc_func"] = enum_desc_func;
(*variables)["dataTypeSpecific_name"] = "enumDescFunc";
- (*variables)["dataTypeSpecific_value"] = (*variables)["enum_desc_func"];
+ (*variables)["dataTypeSpecific_value"] = enum_desc_func;
const Descriptor* msg_descriptor = descriptor->containing_type();
(*variables)["owning_message_class"] = ClassName(msg_descriptor);
@@ -69,14 +73,13 @@ EnumFieldGenerator::EnumFieldGenerator(const FieldDescriptor* descriptor)
SetEnumVariables(descriptor, &variables_);
}
-EnumFieldGenerator::~EnumFieldGenerator() {}
-
void EnumFieldGenerator::GenerateCFunctionDeclarations(
io::Printer* printer) const {
- if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) {
+ if (descriptor_->enum_type()->is_closed()) {
return;
}
+ // clang-format off
printer->Print(
variables_,
"/**\n"
@@ -91,12 +94,16 @@ void EnumFieldGenerator::GenerateCFunctionDeclarations(
" **/\n"
"void Set$owning_message_class$_$capitalized_name$_RawValue($owning_message_class$ *message, arc_i32 value);\n"
"\n");
+ // clang-format on
}
void EnumFieldGenerator::GenerateCFunctionImplementations(
io::Printer* printer) const {
- if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) return;
+ if (descriptor_->enum_type()->is_closed()) {
+ return;
+ }
+ // clang-format off
printer->Print(
variables_,
"arc_i32 $owning_message_class$_$capitalized_name$_RawValue($owning_message_class$ *message) {\n"
@@ -111,13 +118,14 @@ void EnumFieldGenerator::GenerateCFunctionImplementations(
" GPBSetMessageRawEnumField(message, field, value);\n"
"}\n"
"\n");
+ // clang-format on
}
void EnumFieldGenerator::DetermineForwardDeclarations(
- std::set<TProtoStringType>* fwd_decls,
+ y_absl::btree_set<TProtoStringType>* fwd_decls,
bool include_external_types) const {
- SingleFieldGenerator::DetermineForwardDeclarations(
- fwd_decls, include_external_types);
+ 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.
@@ -126,7 +134,7 @@ void EnumFieldGenerator::DetermineForwardDeclarations(
!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 + ")");
+ fwd_decls->insert(y_absl::StrCat("GPB_ENUM_FWD_DECLARE(", name, ");"));
}
}
@@ -137,14 +145,18 @@ RepeatedEnumFieldGenerator::RepeatedEnumFieldGenerator(
variables_["array_storage_type"] = "GPBEnumArray";
}
-RepeatedEnumFieldGenerator::~RepeatedEnumFieldGenerator() {}
-
-void RepeatedEnumFieldGenerator::FinishInitialization(void) {
+void RepeatedEnumFieldGenerator::FinishInitialization() {
RepeatedFieldGenerator::FinishInitialization();
+ TProtoStringType name = variables_["name"];
+ TProtoStringType storage_type = variables_["storage_type"];
variables_["array_comment"] =
- "// |" + variables_["name"] + "| contains |" + variables_["storage_type"] + "|\n";
+ y_absl::StrCat("// |", name, "| contains |", storage_type, "|\n");
}
+// NOTE: RepeatedEnumFieldGenerator::DetermineForwardDeclarations isn't needed
+// because `GPBEnumArray` isn't generic (like `NSArray` would be for messages)
+// and thus doesn't reference the type in the header.
+
} // namespace objectivec
} // namespace compiler
} // namespace protobuf
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/enum_field.h
index fea75f7a848..3220df10464 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/enum_field.h
@@ -31,9 +31,10 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_ENUM_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_ENUM_FIELD_H__
-#include <map>
#include <string>
-#include <google/protobuf/compiler/objectivec/objectivec_field.h>
+
+#include "y_absl/container/btree_set.h"
+#include "google/protobuf/compiler/objectivec/field.h"
namespace google {
namespace protobuf {
@@ -47,28 +48,25 @@ class EnumFieldGenerator : public SingleFieldGenerator {
EnumFieldGenerator& operator=(const EnumFieldGenerator&) = delete;
public:
- virtual void GenerateCFunctionDeclarations(
- io::Printer* printer) const override;
- virtual void GenerateCFunctionImplementations(
- io::Printer* printer) const override;
- virtual void DetermineForwardDeclarations(
- std::set<TProtoStringType>* fwd_decls,
- bool include_external_types) const override;
+ void GenerateCFunctionDeclarations(io::Printer* printer) const override;
+ void GenerateCFunctionImplementations(io::Printer* printer) const override;
+ void DetermineForwardDeclarations(y_absl::btree_set<TProtoStringType>* fwd_decls,
+ bool include_external_types) const override;
protected:
explicit EnumFieldGenerator(const FieldDescriptor* descriptor);
- virtual ~EnumFieldGenerator();
+ ~EnumFieldGenerator() override = default;
};
class RepeatedEnumFieldGenerator : public RepeatedFieldGenerator {
friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field);
public:
- virtual void FinishInitialization() override;
+ void FinishInitialization() override;
protected:
explicit RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor);
- virtual ~RepeatedEnumFieldGenerator();
+ ~RepeatedEnumFieldGenerator() override = default;
};
} // namespace objectivec
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_extension.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/extension.cc
index dbbce48952b..4da745c9f69 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_extension.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/extension.cc
@@ -28,38 +28,39 @@
// (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/objectivec/extension.h"
+
#include <iostream>
+#include <ostream>
+#include <string>
+#include <vector>
-#include <google/protobuf/compiler/objectivec/objectivec_extension.h>
-#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/io/printer.h>
+#include "y_absl/container/btree_set.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/objectivec/helpers.h"
+#include "google/protobuf/compiler/objectivec/names.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
namespace compiler {
namespace objectivec {
-ExtensionGenerator::ExtensionGenerator(const TProtoStringType& root_class_name,
+ExtensionGenerator::ExtensionGenerator(y_absl::string_view root_class_name,
const FieldDescriptor* descriptor)
: method_name_(ExtensionMethodName(descriptor)),
- root_class_and_method_name_(root_class_name + "_" + method_name_),
+ root_class_and_method_name_(
+ y_absl::StrCat(root_class_name, "_", method_name_)),
descriptor_(descriptor) {
- if (descriptor->is_map()) {
- // 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 errors.
- std::cerr << "error: Extension is a map<>!"
- << " That used to be blocked by the compiler." << std::endl;
- std::cerr.flush();
- abort();
- }
+ Y_ABSL_CHECK(!descriptor->is_map())
+ << "error: Extension is a map<>!"
+ << " That used to be blocked by the compiler.";
}
-ExtensionGenerator::~ExtensionGenerator() {}
-
-void ExtensionGenerator::GenerateMembersHeader(io::Printer* printer) {
- std::map<TProtoStringType, TProtoStringType> vars;
+void ExtensionGenerator::GenerateMembersHeader(io::Printer* printer) const {
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
vars["method_name"] = method_name_;
if (IsRetainedName(method_name_)) {
vars["storage_attribute"] = " NS_RETURNS_NOT_RETAINED";
@@ -74,19 +75,23 @@ void ExtensionGenerator::GenerateMembersHeader(io::Printer* printer) {
}
// Unlike normal message fields, check if the file for the extension was
// deprecated.
- vars["deprecated_attribute"] = GetOptionalDeprecatedAttribute(descriptor_, descriptor_->file());
- printer->Print(vars,
- "$comments$"
- "+ (GPBExtensionDescriptor *)$method_name$$storage_attribute$$deprecated_attribute$;\n");
+ vars["deprecated_attribute"] =
+ GetOptionalDeprecatedAttribute(descriptor_, descriptor_->file());
+ // clang-format off
+ printer->Print(
+ vars,
+ "$comments$"
+ "+ (GPBExtensionDescriptor *)$method_name$$storage_attribute$$deprecated_attribute$;\n");
+ // clang-format on
}
void ExtensionGenerator::GenerateStaticVariablesInitialization(
- io::Printer* printer) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ io::Printer* printer) const {
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
vars["root_class_and_method_name"] = root_class_and_method_name_;
const TProtoStringType containing_type = ClassName(descriptor_->containing_type());
vars["extended_type"] = ObjCClass(containing_type);
- vars["number"] = StrCat(descriptor_->number());
+ vars["number"] = y_absl::StrCat(descriptor_->number());
std::vector<TProtoStringType> options;
if (descriptor_->is_repeated()) options.push_back("GPBExtensionRepeated");
@@ -111,30 +116,33 @@ void ExtensionGenerator::GenerateStaticVariablesInitialization(
vars["default"] = DefaultValue(descriptor_);
}
TProtoStringType type = GetCapitalizedType(descriptor_);
- vars["extension_type"] = TProtoStringType("GPBDataType") + type;
+ vars["extension_type"] = y_absl::StrCat("GPBDataType", type);
if (objc_type == OBJECTIVECTYPE_ENUM) {
vars["enum_desc_func_name"] =
- EnumName(descriptor_->enum_type()) + "_EnumDescriptor";
+ y_absl::StrCat(EnumName(descriptor_->enum_type()), "_EnumDescriptor");
} else {
vars["enum_desc_func_name"] = "NULL";
}
- printer->Print(vars,
- "{\n"
- " .defaultValue.$default_name$ = $default$,\n"
- " .singletonName = GPBStringifySymbol($root_class_and_method_name$),\n"
- " .extendedClass.clazz = $extended_type$,\n"
- " .messageOrGroupClass.clazz = $type$,\n"
- " .enumDescriptorFunc = $enum_desc_func_name$,\n"
- " .fieldNumber = $number$,\n"
- " .dataType = $extension_type$,\n"
- " .options = $options$,\n"
- "},\n");
+ // clang-format off
+ printer->Print(
+ vars,
+ "{\n"
+ " .defaultValue.$default_name$ = $default$,\n"
+ " .singletonName = GPBStringifySymbol($root_class_and_method_name$),\n"
+ " .extendedClass.clazz = $extended_type$,\n"
+ " .messageOrGroupClass.clazz = $type$,\n"
+ " .enumDescriptorFunc = $enum_desc_func_name$,\n"
+ " .fieldNumber = $number$,\n"
+ " .dataType = $extension_type$,\n"
+ " .options = $options$,\n"
+ "},\n");
+ // clang-format on
}
void ExtensionGenerator::DetermineObjectiveCClassDefinitions(
- std::set<TProtoStringType>* fwd_decls) {
+ y_absl::btree_set<TProtoStringType>* fwd_decls) const {
TProtoStringType extended_type = ClassName(descriptor_->containing_type());
fwd_decls->insert(ObjCClassDeclaration(extended_type));
ObjectiveCType objc_type = GetObjectiveCType(descriptor_);
@@ -144,10 +152,13 @@ void ExtensionGenerator::DetermineObjectiveCClassDefinitions(
}
}
-void ExtensionGenerator::GenerateRegistrationSource(io::Printer* printer) {
+void ExtensionGenerator::GenerateRegistrationSource(
+ io::Printer* printer) const {
+ // clang-format off
printer->Print(
"[registry addExtension:$root_class_and_method_name$];\n",
"root_class_and_method_name", root_class_and_method_name_);
+ // clang-format on
}
} // namespace objectivec
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_extension.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/extension.h
index 04e59f9284b..1f81d82e745 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_extension.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/extension.h
@@ -31,8 +31,11 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_EXTENSION_H__
#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_EXTENSION_H__
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/io/printer.h>
+#include <string>
+
+#include "y_absl/container/btree_set.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
@@ -41,17 +44,18 @@ namespace objectivec {
class ExtensionGenerator {
public:
- ExtensionGenerator(const TProtoStringType& root_class_name,
+ ExtensionGenerator(y_absl::string_view root_class_name,
const FieldDescriptor* descriptor);
- ~ExtensionGenerator();
+ ~ExtensionGenerator() = default;
ExtensionGenerator(const ExtensionGenerator&) = delete;
ExtensionGenerator& operator=(const ExtensionGenerator&) = delete;
- void GenerateMembersHeader(io::Printer* printer);
- void GenerateStaticVariablesInitialization(io::Printer* printer);
- void GenerateRegistrationSource(io::Printer* printer);
- void DetermineObjectiveCClassDefinitions(std::set<TProtoStringType>* fwd_decls);
+ void GenerateMembersHeader(io::Printer* printer) const;
+ void GenerateStaticVariablesInitialization(io::Printer* printer) const;
+ void GenerateRegistrationSource(io::Printer* printer) const;
+ void DetermineObjectiveCClassDefinitions(
+ y_absl::btree_set<TProtoStringType>* fwd_decls) const;
private:
TProtoStringType method_name_;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/field.cc
index e73a664db1a..e72185e7949 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/field.cc
@@ -28,16 +28,24 @@
// (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 <iostream>
+#include "google/protobuf/compiler/objectivec/field.h"
-#include <google/protobuf/compiler/objectivec/objectivec_field.h>
-#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
-#include <google/protobuf/compiler/objectivec/objectivec_enum_field.h>
-#include <google/protobuf/compiler/objectivec/objectivec_map_field.h>
-#include <google/protobuf/compiler/objectivec/objectivec_message_field.h>
-#include <google/protobuf/compiler/objectivec/objectivec_primitive_field.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
+#include <iostream>
+#include <ostream>
+#include <string>
+#include <vector>
+
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/objectivec/enum_field.h"
+#include "google/protobuf/compiler/objectivec/helpers.h"
+#include "google/protobuf/compiler/objectivec/map_field.h"
+#include "google/protobuf/compiler/objectivec/message_field.h"
+#include "google/protobuf/compiler/objectivec/names.h"
+#include "google/protobuf/compiler/objectivec/primitive_field.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
@@ -46,8 +54,9 @@ namespace objectivec {
namespace {
-void SetCommonFieldVariables(const FieldDescriptor* descriptor,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+void SetCommonFieldVariables(
+ const FieldDescriptor* descriptor,
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables) {
TProtoStringType camel_case_name = FieldName(descriptor);
TProtoStringType raw_field_name;
if (descriptor->type() == FieldDescriptor::TYPE_GROUP) {
@@ -73,10 +82,11 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
(*variables)["capitalized_name"] = capitalized_name;
(*variables)["raw_field_name"] = raw_field_name;
(*variables)["field_number_name"] =
- classname + "_FieldNumber_" + capitalized_name;
- (*variables)["field_number"] = StrCat(descriptor->number());
+ y_absl::StrCat(classname, "_FieldNumber_", capitalized_name);
+ (*variables)["field_number"] = y_absl::StrCat(descriptor->number());
(*variables)["field_type"] = GetCapitalizedType(descriptor);
- (*variables)["deprecated_attribute"] = GetOptionalDeprecatedAttribute(descriptor);
+ (*variables)["deprecated_attribute"] =
+ GetOptionalDeprecatedAttribute(descriptor);
std::vector<TProtoStringType> field_flags;
if (descriptor->is_repeated()) field_flags.push_back("GPBFieldRepeated");
if (descriptor->is_required()) field_flags.push_back("GPBFieldRequired");
@@ -89,6 +99,9 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
if (needs_custom_name) field_flags.push_back("GPBFieldTextFormatNameCustom");
if (descriptor->type() == FieldDescriptor::TYPE_ENUM) {
field_flags.push_back("GPBFieldHasEnumDescriptor");
+ if (descriptor->enum_type()->is_closed()) {
+ field_flags.push_back("GPBFieldClosedEnum");
+ }
}
// It will clear on a zero value if...
// - not repeated/map
@@ -107,18 +120,63 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
(*variables)["dataTypeSpecific_name"] = "clazz";
(*variables)["dataTypeSpecific_value"] = "Nil";
- (*variables)["storage_offset_value"] =
- "(arc_ui32)offsetof(" + classname + "__storage_, " + camel_case_name + ")";
+ (*variables)["storage_offset_value"] = y_absl::StrCat(
+ "(arc_ui32)offsetof(", classname, "__storage_, ", camel_case_name, ")");
(*variables)["storage_offset_comment"] = "";
// Clear some common things so they can be set just when needed.
(*variables)["storage_attribute"] = "";
}
+bool HasNonZeroDefaultValue(const FieldDescriptor* field) {
+ // Repeated fields don't have defaults.
+ if (field->is_repeated()) {
+ return false;
+ }
+
+ // As much as checking field->has_default_value() seems useful, it isn't
+ // because of enums. proto2 syntax allows the first item in an enum (the
+ // default) to be non zero. So checking field->has_default_value() would
+ // result in missing this non zero default. See MessageWithOneBasedEnum in
+ // objectivec/Tests/unittest_objc.proto for a test Message to confirm this.
+
+ // Some proto file set the default to the zero value, so make sure the value
+ // isn't the zero case.
+ switch (field->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_INT32:
+ return field->default_value_int32() != 0;
+ case FieldDescriptor::CPPTYPE_UINT32:
+ return field->default_value_uint32() != 0U;
+ case FieldDescriptor::CPPTYPE_INT64:
+ return field->default_value_int64() != 0LL;
+ case FieldDescriptor::CPPTYPE_UINT64:
+ return field->default_value_uint64() != 0ULL;
+ case FieldDescriptor::CPPTYPE_DOUBLE:
+ return field->default_value_double() != 0.0;
+ case FieldDescriptor::CPPTYPE_FLOAT:
+ return field->default_value_float() != 0.0f;
+ case FieldDescriptor::CPPTYPE_BOOL:
+ return field->default_value_bool();
+ case FieldDescriptor::CPPTYPE_STRING: {
+ const TProtoStringType& default_string = field->default_value_string();
+ return default_string.length() != 0;
+ }
+ case FieldDescriptor::CPPTYPE_ENUM:
+ return field->default_value_enum()->number() != 0;
+ case FieldDescriptor::CPPTYPE_MESSAGE:
+ return false;
+ }
+
+ // Some compilers report reaching end of function even though all cases of
+ // the enum are handed in the switch.
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
+ return false;
+}
+
} // namespace
FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field) {
- FieldGenerator* result = NULL;
+ FieldGenerator* result = nullptr;
if (field->is_repeated()) {
switch (GetObjectiveCType(field)) {
case OBJECTIVECTYPE_MESSAGE: {
@@ -163,16 +221,11 @@ FieldGenerator::FieldGenerator(const FieldDescriptor* descriptor)
SetCommonFieldVariables(descriptor, &variables_);
}
-FieldGenerator::~FieldGenerator() {}
-
void FieldGenerator::GenerateFieldNumberConstant(io::Printer* printer) const {
- printer->Print(
- variables_,
- "$field_number_name$ = $field_number$,\n");
+ printer->Print(variables_, "$field_number_name$ = $field_number$,\n");
}
-void FieldGenerator::GenerateCFunctionDeclarations(
- io::Printer* printer) const {
+void FieldGenerator::GenerateCFunctionDeclarations(io::Printer* printer) const {
// Nothing
}
@@ -182,20 +235,21 @@ void FieldGenerator::GenerateCFunctionImplementations(
}
void FieldGenerator::DetermineForwardDeclarations(
- std::set<TProtoStringType>* fwd_decls,
+ y_absl::btree_set<TProtoStringType>* fwd_decls,
bool include_external_types) const {
// Nothing
}
void FieldGenerator::DetermineObjectiveCClassDefinitions(
- std::set<TProtoStringType>* fwd_decls) const {
+ y_absl::btree_set<TProtoStringType>* fwd_decls) const {
// Nothing
}
-void FieldGenerator::GenerateFieldDescription(
- io::Printer* printer, bool include_default) const {
+void FieldGenerator::GenerateFieldDescription(io::Printer* printer,
+ bool include_default) const {
// Printed in the same order as the structure decl.
if (include_default) {
+ // clang-format off
printer->Print(
variables_,
"{\n"
@@ -208,7 +262,9 @@ void FieldGenerator::GenerateFieldDescription(
" .core.flags = $fieldflags$,\n"
" .core.dataType = GPBDataType$field_type$,\n"
"},\n");
+ // clang-format on
} else {
+ // clang-format off
printer->Print(
variables_,
"{\n"
@@ -220,43 +276,37 @@ void FieldGenerator::GenerateFieldDescription(
" .flags = $fieldflags$,\n"
" .dataType = GPBDataType$field_type$,\n"
"},\n");
+ // clang-format on
}
}
void FieldGenerator::SetRuntimeHasBit(int has_index) {
- variables_["has_index"] = StrCat(has_index);
+ variables_["has_index"] = y_absl::StrCat(has_index);
}
-void FieldGenerator::SetNoHasBit(void) {
- variables_["has_index"] = "GPBNoHasBit";
-}
+void FieldGenerator::SetNoHasBit() { variables_["has_index"] = "GPBNoHasBit"; }
-int FieldGenerator::ExtraRuntimeHasBitsNeeded(void) const {
- return 0;
-}
+int FieldGenerator::ExtraRuntimeHasBitsNeeded() const { return 0; }
void FieldGenerator::SetExtraRuntimeHasBitsBase(int index_base) {
- // 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 errors.
- std::cerr << "Error: should have overridden SetExtraRuntimeHasBitsBase()." << std::endl;
- std::cerr.flush();
- abort();
+ Y_ABSL_LOG(FATAL)
+ << "Error: should have overridden SetExtraRuntimeHasBitsBase().";
}
void FieldGenerator::SetOneofIndexBase(int index_base) {
const OneofDescriptor* oneof = descriptor_->real_containing_oneof();
- if (oneof != NULL) {
+ if (oneof != nullptr) {
int index = oneof->index() + index_base;
// Flip the sign to mark it as a oneof.
- variables_["has_index"] = StrCat(-index);
+ variables_["has_index"] = y_absl::StrCat(-index);
}
}
-bool FieldGenerator::WantsHasProperty(void) const {
+bool FieldGenerator::WantsHasProperty() const {
return descriptor_->has_presence() && !descriptor_->real_containing_oneof();
}
-void FieldGenerator::FinishInitialization(void) {
+void FieldGenerator::FinishInitialization() {
// If "property_type" wasn't set, make it "storage_type".
if ((variables_.find("property_type") == variables_.end()) &&
(variables_.find("storage_type") != variables_.end())) {
@@ -269,8 +319,6 @@ SingleFieldGenerator::SingleFieldGenerator(const FieldDescriptor* descriptor)
// Nothing
}
-SingleFieldGenerator::~SingleFieldGenerator() {}
-
void SingleFieldGenerator::GenerateFieldStorageDeclaration(
io::Printer* printer) const {
printer->Print(variables_, "$storage_type$ $name$;\n");
@@ -279,15 +327,19 @@ void SingleFieldGenerator::GenerateFieldStorageDeclaration(
void SingleFieldGenerator::GeneratePropertyDeclaration(
io::Printer* printer) const {
printer->Print(variables_, "$comments$");
+ // clang-format off
printer->Print(
variables_,
- "@property(nonatomic, readwrite) $property_type$ $name$$deprecated_attribute$;\n"
- "\n");
+ "@property(nonatomic, readwrite) $property_type$ $name$$deprecated_attribute$;\n");
+ // clang-format on
if (WantsHasProperty()) {
+ // clang-format off
printer->Print(
variables_,
"@property(nonatomic, readwrite) BOOL has$capitalized_name$$deprecated_attribute$;\n");
+ // clang-format on
}
+ printer->Print("\n");
}
void SingleFieldGenerator::GeneratePropertyImplementation(
@@ -299,7 +351,7 @@ void SingleFieldGenerator::GeneratePropertyImplementation(
}
}
-bool SingleFieldGenerator::RuntimeUsesHasBit(void) const {
+bool SingleFieldGenerator::RuntimeUsesHasBit() const {
if (descriptor_->real_containing_oneof()) {
// The oneof tracks what is set instead.
return false;
@@ -315,8 +367,6 @@ ObjCObjFieldGenerator::ObjCObjFieldGenerator(const FieldDescriptor* descriptor)
}
}
-ObjCObjFieldGenerator::~ObjCObjFieldGenerator() {}
-
void ObjCObjFieldGenerator::GenerateFieldStorageDeclaration(
io::Printer* printer) const {
printer->Print(variables_, "$storage_type$ *$name$;\n");
@@ -324,26 +374,30 @@ void ObjCObjFieldGenerator::GenerateFieldStorageDeclaration(
void ObjCObjFieldGenerator::GeneratePropertyDeclaration(
io::Printer* printer) const {
-
// Differs from SingleFieldGenerator::GeneratePropertyDeclaration() in that
- // it uses pointers and deals with Objective C's rules around storage name
+ // it uses pointers and deals with Objective-C's rules around storage name
// conventions (init*, new*, etc.)
printer->Print(variables_, "$comments$");
+ // clang-format off
printer->Print(
variables_,
"@property(nonatomic, readwrite, $property_storage_attribute$, null_resettable) $property_type$ *$name$$storage_attribute$$deprecated_attribute$;\n");
+ // clang-format on
if (WantsHasProperty()) {
+ // clang-format off
printer->Print(
variables_,
"/** Test to see if @c $name$ has been set. */\n"
"@property(nonatomic, readwrite) BOOL has$capitalized_name$$deprecated_attribute$;\n");
+ // clang-format on
}
if (IsInitName(variables_.find("name")->second)) {
// If property name starts with init we need to annotate it to get past ARC.
// http://stackoverflow.com/questions/18723226/how-do-i-annotate-an-objective-c-property-with-an-objc-method-family/18723227#18723227
printer->Print(variables_,
- "- ($property_type$ *)$name$ GPB_METHOD_FAMILY_NONE$deprecated_attribute$;\n");
+ "- ($property_type$ *)$name$ "
+ "GPB_METHOD_FAMILY_NONE$deprecated_attribute$;\n");
}
printer->Print("\n");
}
@@ -355,9 +409,7 @@ RepeatedFieldGenerator::RepeatedFieldGenerator(
variables_["array_comment"] = "";
}
-RepeatedFieldGenerator::~RepeatedFieldGenerator() {}
-
-void RepeatedFieldGenerator::FinishInitialization(void) {
+void RepeatedFieldGenerator::FinishInitialization() {
FieldGenerator::FinishInitialization();
if (variables_.find("array_property_type") == variables_.end()) {
variables_["array_property_type"] = variable("array_storage_type");
@@ -376,30 +428,33 @@ void RepeatedFieldGenerator::GeneratePropertyImplementation(
void RepeatedFieldGenerator::GeneratePropertyDeclaration(
io::Printer* printer) const {
-
// Repeated fields don't need the has* properties, but they do expose a
// *Count (to check without autocreation). So for the field property we need
// the same logic as ObjCObjFieldGenerator::GeneratePropertyDeclaration() for
- // dealing with needing Objective C's rules around storage name conventions
+ // dealing with needing Objective-C's rules around storage name conventions
// (init*, new*, etc.)
+ // clang-format off
printer->Print(
variables_,
"$comments$"
"$array_comment$"
"@property(nonatomic, readwrite, strong, null_resettable) $array_property_type$ *$name$$storage_attribute$$deprecated_attribute$;\n"
- "/** The number of items in @c $name$ without causing the array to be created. */\n"
+ "/** The number of items in @c $name$ without causing the container to be created. */\n"
"@property(nonatomic, readonly) NSUInteger $name$_Count$deprecated_attribute$;\n");
+ // clang-format on
if (IsInitName(variables_.find("name")->second)) {
// If property name starts with init we need to annotate it to get past ARC.
// http://stackoverflow.com/questions/18723226/how-do-i-annotate-an-objective-c-property-with-an-objc-method-family/18723227#18723227
+ // clang-format off
printer->Print(variables_,
"- ($array_property_type$ *)$name$ GPB_METHOD_FAMILY_NONE$deprecated_attribute$;\n");
+ // clang-format on
}
printer->Print("\n");
}
-bool RepeatedFieldGenerator::RuntimeUsesHasBit(void) const {
+bool RepeatedFieldGenerator::RuntimeUsesHasBit() const {
return false; // The array (or map/dict) having anything is what is used.
}
@@ -409,8 +464,7 @@ FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor)
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)));
+ field_generators_[i].reset(FieldGenerator::Make(descriptor->field(i)));
}
for (int i = 0; i < descriptor->extension_count(); i++) {
extension_generators_[i].reset(
@@ -418,11 +472,9 @@ FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor)
}
}
-FieldGeneratorMap::~FieldGeneratorMap() {}
-
const FieldGenerator& FieldGeneratorMap::get(
const FieldDescriptor* field) const {
- GOOGLE_CHECK_EQ(field->containing_type(), descriptor_);
+ Y_ABSL_CHECK_EQ(field->containing_type(), descriptor_);
return *field_generators_[field->index()];
}
@@ -430,7 +482,7 @@ const FieldGenerator& FieldGeneratorMap::get_extension(int index) const {
return *extension_generators_[index];
}
-int FieldGeneratorMap::CalculateHasBits(void) {
+int FieldGeneratorMap::CalculateHasBits() {
int total_bits = 0;
for (int i = 0; i < descriptor_->field_count(); i++) {
if (field_generators_[i]->RuntimeUsesHasBit()) {
@@ -454,7 +506,7 @@ void FieldGeneratorMap::SetOneofIndexBase(int index_base) {
}
}
-bool FieldGeneratorMap::DoesAnyFieldHaveNonZeroDefault(void) const {
+bool FieldGeneratorMap::DoesAnyFieldHaveNonZeroDefault() const {
for (int i = 0; i < descriptor_->field_count(); i++) {
if (HasNonZeroDefaultValue(descriptor_->field(i))) {
return true;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/field.h
index 3e968946fa2..04500651331 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/field.h
@@ -31,10 +31,15 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_FIELD_H__
-#include <map>
+#include <memory>
#include <string>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/io/printer.h>
+#include <vector>
+
+#include "y_absl/container/btree_set.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/strings/match.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
@@ -45,7 +50,7 @@ class FieldGenerator {
public:
static FieldGenerator* Make(const FieldDescriptor* field);
- virtual ~FieldGenerator();
+ virtual ~FieldGenerator() = default;
FieldGenerator(const FieldGenerator&) = delete;
FieldGenerator& operator=(const FieldGenerator&) = delete;
@@ -64,21 +69,21 @@ class FieldGenerator {
// Exposed for subclasses, should always call it on the parent class also.
virtual void DetermineForwardDeclarations(
- std::set<TProtoStringType>* fwd_decls,
+ y_absl::btree_set<TProtoStringType>* fwd_decls,
bool include_external_types) const;
virtual void DetermineObjectiveCClassDefinitions(
- std::set<TProtoStringType>* fwd_decls) const;
+ y_absl::btree_set<TProtoStringType>* fwd_decls) const;
// Used during generation, not intended to be extended by subclasses.
- void GenerateFieldDescription(
- io::Printer* printer, bool include_default) const;
+ void GenerateFieldDescription(io::Printer* printer,
+ bool include_default) const;
void GenerateFieldNumberConstant(io::Printer* printer) const;
// Exposed to get and set the has bits information.
- virtual bool RuntimeUsesHasBit(void) const = 0;
+ virtual bool RuntimeUsesHasBit() const = 0;
void SetRuntimeHasBit(int has_index);
- void SetNoHasBit(void);
- virtual int ExtraRuntimeHasBitsNeeded(void) const;
+ void SetNoHasBit();
+ virtual int ExtraRuntimeHasBitsNeeded() const;
virtual void SetExtraRuntimeHasBitsBase(int index_base);
void SetOneofIndexBase(int index_base);
@@ -88,8 +93,7 @@ class FieldGenerator {
bool needs_textformat_name_support() const {
const TProtoStringType& field_flags = variable("fieldflags");
- return field_flags.find("GPBFieldTextFormatNameCustom") !=
- TProtoStringType::npos;
+ return y_absl::StrContains(field_flags, "GPBFieldTextFormatNameCustom");
}
TProtoStringType generated_objc_name() const { return variable("name"); }
TProtoStringType raw_field_name() const { return variable("raw_field_name"); }
@@ -97,26 +101,26 @@ class FieldGenerator {
protected:
explicit FieldGenerator(const FieldDescriptor* descriptor);
- virtual void FinishInitialization(void);
- bool WantsHasProperty(void) const;
+ virtual void FinishInitialization();
+ bool WantsHasProperty() const;
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables_;
};
class SingleFieldGenerator : public FieldGenerator {
public:
- virtual ~SingleFieldGenerator();
+ ~SingleFieldGenerator() override = default;
SingleFieldGenerator(const SingleFieldGenerator&) = delete;
SingleFieldGenerator& operator=(const SingleFieldGenerator&) = delete;
- virtual void GenerateFieldStorageDeclaration(io::Printer* printer) const override;
- virtual void GeneratePropertyDeclaration(io::Printer* printer) const override;
+ void GenerateFieldStorageDeclaration(io::Printer* printer) const override;
+ void GeneratePropertyDeclaration(io::Printer* printer) const override;
- virtual void GeneratePropertyImplementation(io::Printer* printer) const override;
+ void GeneratePropertyImplementation(io::Printer* printer) const override;
- virtual bool RuntimeUsesHasBit(void) const override;
+ bool RuntimeUsesHasBit() const override;
protected:
explicit SingleFieldGenerator(const FieldDescriptor* descriptor);
@@ -125,13 +129,13 @@ class SingleFieldGenerator : public FieldGenerator {
// Subclass with common support for when the field ends up as an ObjC Object.
class ObjCObjFieldGenerator : public SingleFieldGenerator {
public:
- virtual ~ObjCObjFieldGenerator();
+ ~ObjCObjFieldGenerator() override = default;
ObjCObjFieldGenerator(const ObjCObjFieldGenerator&) = delete;
ObjCObjFieldGenerator& operator=(const ObjCObjFieldGenerator&) = delete;
- virtual void GenerateFieldStorageDeclaration(io::Printer* printer) const override;
- virtual void GeneratePropertyDeclaration(io::Printer* printer) const override;
+ void GenerateFieldStorageDeclaration(io::Printer* printer) const override;
+ void GeneratePropertyDeclaration(io::Printer* printer) const override;
protected:
explicit ObjCObjFieldGenerator(const FieldDescriptor* descriptor);
@@ -139,28 +143,28 @@ class ObjCObjFieldGenerator : public SingleFieldGenerator {
class RepeatedFieldGenerator : public ObjCObjFieldGenerator {
public:
- virtual ~RepeatedFieldGenerator();
+ ~RepeatedFieldGenerator() override = default;
RepeatedFieldGenerator(const RepeatedFieldGenerator&) = delete;
RepeatedFieldGenerator& operator=(const RepeatedFieldGenerator&) = delete;
- virtual void GenerateFieldStorageDeclaration(io::Printer* printer) const override;
- virtual void GeneratePropertyDeclaration(io::Printer* printer) const override;
+ void GenerateFieldStorageDeclaration(io::Printer* printer) const override;
+ void GeneratePropertyDeclaration(io::Printer* printer) const override;
- virtual void GeneratePropertyImplementation(io::Printer* printer) const override;
+ void GeneratePropertyImplementation(io::Printer* printer) const override;
- virtual bool RuntimeUsesHasBit(void) const override;
+ bool RuntimeUsesHasBit() const override;
protected:
explicit RepeatedFieldGenerator(const FieldDescriptor* descriptor);
- virtual void FinishInitialization(void) override;
+ void FinishInitialization() override;
};
// Convenience class which constructs FieldGenerators for a Descriptor.
class FieldGeneratorMap {
public:
explicit FieldGeneratorMap(const Descriptor* descriptor);
- ~FieldGeneratorMap();
+ ~FieldGeneratorMap() = default;
FieldGeneratorMap(const FieldGeneratorMap&) = delete;
FieldGeneratorMap& operator=(const FieldGeneratorMap&) = delete;
@@ -169,12 +173,12 @@ class FieldGeneratorMap {
const FieldGenerator& get_extension(int index) const;
// Assigns the has bits and returns the number of bits needed.
- int CalculateHasBits(void);
+ int CalculateHasBits();
void SetOneofIndexBase(int index_base);
// Check if any field of this message has a non zero default.
- bool DoesAnyFieldHaveNonZeroDefault(void) const;
+ bool DoesAnyFieldHaveNonZeroDefault() const;
private:
const Descriptor* descriptor_;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/file.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/file.cc
new file mode 100644
index 00000000000..06be7c9ceca
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/file.cc
@@ -0,0 +1,736 @@
+// 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/objectivec/file.h"
+
+#include <algorithm>
+#include <functional>
+#include <iostream>
+#include <iterator>
+#include <memory>
+#include <sstream>
+#include <string>
+#include <vector>
+
+#include "y_absl/container/btree_set.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_join.h"
+#include "google/protobuf/compiler/objectivec/enum.h"
+#include "google/protobuf/compiler/objectivec/extension.h"
+#include "google/protobuf/compiler/objectivec/import_writer.h"
+#include "google/protobuf/compiler/objectivec/message.h"
+#include "google/protobuf/compiler/objectivec/names.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/io/printer.h"
+
+// 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 errors.
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace objectivec {
+
+namespace {
+
+// This is also found in GPBBootstrap.h, and needs to be kept in sync.
+const arc_i32 GOOGLE_PROTOBUF_OBJC_VERSION = 30007;
+
+const char* kHeaderExtension = ".pbobjc.h";
+
+// Checks if a message contains any extension definitions (on the message or
+// a nested message under it).
+bool MessageContainsExtensions(const Descriptor* message) {
+ if (message->extension_count() > 0) {
+ return true;
+ }
+ for (int i = 0; i < message->nested_type_count(); i++) {
+ if (MessageContainsExtensions(message->nested_type(i))) {
+ return true;
+ }
+ }
+ return false;
+}
+
+// Checks if the file contains any extensions definitions (at the root or
+// nested under a message).
+bool FileContainsExtensions(const FileDescriptor* file) {
+ if (file->extension_count() > 0) {
+ return true;
+ }
+ for (int i = 0; i < file->message_type_count(); i++) {
+ if (MessageContainsExtensions(file->message_type(i))) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool IsDirectDependency(const FileDescriptor* dep, const FileDescriptor* file) {
+ for (int i = 0; i < file->dependency_count(); i++) {
+ if (dep == file->dependency(i)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+struct FileDescriptorsOrderedByName {
+ inline bool operator()(const FileDescriptor* a,
+ const FileDescriptor* b) const {
+ return a->name() < b->name();
+ }
+};
+
+void MakeDescriptors(
+ const Descriptor* descriptor, const TProtoStringType& file_description_name,
+ std::vector<std::unique_ptr<EnumGenerator>>* enum_generators,
+ std::vector<std::unique_ptr<ExtensionGenerator>>* extension_generators,
+ std::vector<std::unique_ptr<MessageGenerator>>* message_generators) {
+ for (int i = 0; i < descriptor->enum_type_count(); i++) {
+ enum_generators->emplace_back(
+ std::make_unique<EnumGenerator>(descriptor->enum_type(i)));
+ }
+ for (int i = 0; i < descriptor->nested_type_count(); i++) {
+ message_generators->emplace_back(std::make_unique<MessageGenerator>(
+ file_description_name, descriptor->nested_type(i)));
+ message_generators->back()->AddExtensionGenerators(extension_generators);
+ MakeDescriptors(descriptor->nested_type(i), file_description_name,
+ enum_generators, extension_generators, message_generators);
+ }
+}
+
+} // namespace
+
+const FileGenerator::CommonState::MinDepsEntry&
+FileGenerator::CommonState::CollectMinimalFileDepsContainingExtensionsInternal(
+ const FileDescriptor* file) {
+ auto it = deps_info_cache.find(file);
+ if (it != deps_info_cache.end()) {
+ return it->second;
+ }
+
+ y_absl::flat_hash_set<const FileDescriptor*> min_deps_collector;
+ y_absl::flat_hash_set<const FileDescriptor*> transitive_deps_collector;
+ y_absl::flat_hash_set<const FileDescriptor*> to_prune;
+ for (int i = 0; i < file->dependency_count(); i++) {
+ const FileDescriptor* dep = file->dependency(i);
+ MinDepsEntry dep_info =
+ CollectMinimalFileDepsContainingExtensionsInternal(dep);
+
+ // Everything the dep covered, this file will also cover.
+ transitive_deps_collector.insert(dep_info.transitive_deps.begin(),
+ dep_info.transitive_deps.end());
+ // Prune everything from the dep's covered list in case another dep lists it
+ // as a min dep.
+ to_prune.insert(dep_info.transitive_deps.begin(),
+ dep_info.transitive_deps.end());
+
+ // Does the dep have any extensions...
+ if (dep_info.has_extensions) {
+ // Yes -> Add this file, prune its min_deps and add them to the covered
+ // deps.
+ min_deps_collector.insert(dep);
+ to_prune.insert(dep_info.min_deps.begin(), dep_info.min_deps.end());
+ transitive_deps_collector.insert(dep_info.min_deps.begin(),
+ dep_info.min_deps.end());
+ } else {
+ // No -> Just use its min_deps.
+ min_deps_collector.insert(dep_info.min_deps.begin(),
+ dep_info.min_deps.end());
+ }
+ }
+
+ const bool file_has_exts = FileContainsExtensions(file);
+
+ // Fast path: if nothing to prune or there was only one dep, the prune work is
+ // a waste, skip it.
+ if (to_prune.empty() || file->dependency_count() == 1) {
+ return deps_info_cache
+ .insert(
+ {file,
+ {file_has_exts, min_deps_collector, transitive_deps_collector}})
+ .first->second;
+ }
+
+ y_absl::flat_hash_set<const FileDescriptor*> min_deps;
+ std::copy_if(min_deps_collector.begin(), min_deps_collector.end(),
+ std::inserter(min_deps, min_deps.begin()),
+ [&](const FileDescriptor* value) {
+ return to_prune.find(value) == to_prune.end();
+ });
+ return deps_info_cache
+ .insert({file, {file_has_exts, min_deps, transitive_deps_collector}})
+ .first->second;
+}
+
+// Collect the deps of the given file that contain extensions. This can be used
+// to create the chain of roots that need to be wired together.
+//
+// NOTE: If any changes are made to this and the supporting functions, you will
+// need to manually validate what the generated code is for the test files:
+// objectivec/Tests/unittest_extension_chain_*.proto
+// There are comments about what the expected code should be line and limited
+// testing objectivec/Tests/GPBUnittestProtos2.m around compilation (#imports
+// specifically).
+std::vector<const FileDescriptor*>
+FileGenerator::CommonState::CollectMinimalFileDepsContainingExtensions(
+ const FileDescriptor* file) {
+ y_absl::flat_hash_set<const FileDescriptor*> min_deps =
+ CollectMinimalFileDepsContainingExtensionsInternal(file).min_deps;
+ // Sort the list since pointer order isn't stable across runs.
+ std::vector<const FileDescriptor*> result(min_deps.begin(), min_deps.end());
+ std::sort(result.begin(), result.end(), FileDescriptorsOrderedByName());
+ return result;
+}
+
+FileGenerator::FileGenerator(const FileDescriptor* file,
+ const GenerationOptions& generation_options,
+ CommonState& common_state)
+ : file_(file),
+ generation_options_(generation_options),
+ common_state_(&common_state),
+ root_class_name_(FileClassName(file)),
+ file_description_name_(FileClassName(file) + "_FileDescription"),
+ is_bundled_proto_(IsProtobufLibraryBundledProtoFile(file)) {
+ for (int i = 0; i < file_->enum_type_count(); i++) {
+ enum_generators_.emplace_back(
+ std::make_unique<EnumGenerator>(file_->enum_type(i)));
+ }
+ for (int i = 0; i < file_->extension_count(); i++) {
+ extension_generators_.push_back(std::make_unique<ExtensionGenerator>(
+ root_class_name_, file_->extension(i)));
+ }
+ for (int i = 0; i < file_->message_type_count(); i++) {
+ message_generators_.emplace_back(std::make_unique<MessageGenerator>(
+ file_description_name_, file_->message_type(i)));
+ message_generators_.back()->AddExtensionGenerators(&extension_generators_);
+ MakeDescriptors(file_->message_type(i), file_description_name_,
+ &enum_generators_, &extension_generators_,
+ &message_generators_);
+ }
+}
+
+void FileGenerator::GenerateHeader(io::Printer* p) const {
+ GenerateFile(p, GeneratedFileType::kHeader, [&] {
+ p->Print("CF_EXTERN_C_BEGIN\n\n");
+
+ y_absl::btree_set<TProtoStringType> fwd_decls;
+ for (const auto& generator : message_generators_) {
+ generator->DetermineForwardDeclarations(&fwd_decls,
+ /* include_external_types = */
+ HeadersUseForwardDeclarations());
+ }
+ if (!fwd_decls.empty()) {
+ p->Print("$fwd_decls$\n\n", "fwd_decls", y_absl::StrJoin(fwd_decls, "\n"));
+ }
+
+ p->Print("NS_ASSUME_NONNULL_BEGIN\n\n");
+
+ for (const auto& generator : enum_generators_) {
+ generator->GenerateHeader(p);
+ }
+
+ // For extensions to chain together, the Root gets created even if there
+ // are no extensions.
+ p->Print(
+ // clang-format off
+ "#pragma mark - $root_class_name$\n"
+ "\n"
+ "/**\n"
+ " * Exposes the extension registry for this file.\n"
+ " *\n"
+ " * The base class provides:\n"
+ " * @code\n"
+ " * + (GPBExtensionRegistry *)extensionRegistry;\n"
+ " * @endcode\n"
+ " * which is a @c GPBExtensionRegistry that includes all the extensions defined by\n"
+ " * this file and all files that it depends on.\n"
+ " **/\n"
+ "GPB_FINAL @interface $root_class_name$ : GPBRootObject\n"
+ "@end\n"
+ "\n",
+ // clang-format on
+ "root_class_name", root_class_name_);
+
+ // The dynamic methods block is only needed if there are extensions that are
+ // file level scoped (not message scoped). The first
+ // file_->extension_count() of extension_generators_ are the file scoped
+ // ones.
+ if (file_->extension_count()) {
+ p->Print("@interface $root_class_name$ (DynamicMethods)\n",
+ "root_class_name", root_class_name_);
+
+ for (int i = 0; i < file_->extension_count(); i++) {
+ extension_generators_[i]->GenerateMembersHeader(p);
+ }
+
+ p->Print("@end\n\n");
+ } // file_->extension_count()
+
+ for (const auto& generator : message_generators_) {
+ generator->GenerateMessageHeader(p);
+ }
+
+ // clang-format off
+ p->Print(
+ "NS_ASSUME_NONNULL_END\n"
+ "\n"
+ "CF_EXTERN_C_END\n");
+ // clang-format on
+ });
+}
+
+void FileGenerator::GenerateSource(io::Printer* p) const {
+ std::vector<const FileDescriptor*> deps_with_extensions =
+ common_state_->CollectMinimalFileDepsContainingExtensions(file_);
+ GeneratedFileOptions file_options;
+
+ // If any indirect dependency provided extensions, it needs to be directly
+ // imported so it can get merged into the root's extensions registry.
+ // See the Note by CollectMinimalFileDepsContainingExtensions before
+ // changing this.
+ for (auto& dep : deps_with_extensions) {
+ if (!IsDirectDependency(dep, file_)) {
+ file_options.extra_files_to_import.push_back(dep);
+ }
+ }
+
+ y_absl::btree_set<TProtoStringType> fwd_decls;
+ for (const auto& generator : message_generators_) {
+ generator->DetermineObjectiveCClassDefinitions(&fwd_decls);
+ }
+ for (const auto& generator : extension_generators_) {
+ generator->DetermineObjectiveCClassDefinitions(&fwd_decls);
+ }
+
+ // The generated code for oneof's uses direct ivar access, suppress the
+ // warning in case developer turn that on in the context they compile the
+ // generated code.
+ for (const auto& generator : message_generators_) {
+ if (generator->IncludesOneOfDefinition()) {
+ file_options.ignored_warnings.push_back("direct-ivar-access");
+ break;
+ }
+ }
+ if (!fwd_decls.empty()) {
+ file_options.ignored_warnings.push_back("dollar-in-identifier-extension");
+ }
+
+ // Enum implementation uses atomic in the generated code, so add
+ // the system import as needed.
+ if (!enum_generators_.empty()) {
+ file_options.extra_system_headers.push_back("stdatomic.h");
+ }
+
+ GenerateFile(p, GeneratedFileType::kSource, file_options, [&] {
+ if (!fwd_decls.empty()) {
+ p->Print(
+ // clang-format off
+ "#pragma mark - Objective-C Class declarations\n"
+ "// Forward declarations of Objective-C classes that we can use as\n"
+ "// static values in struct initializers.\n"
+ "// We don't use [Foo class] because it is not a static value.\n"
+ "$fwd_decls$\n"
+ "\n",
+ // clang-format on
+ "fwd_decls", y_absl::StrJoin(fwd_decls, "\n"));
+ }
+
+ PrintRootImplementation(p, deps_with_extensions);
+ PrintFileDescription(p);
+
+ for (const auto& generator : enum_generators_) {
+ generator->GenerateSource(p);
+ }
+ for (const auto& generator : message_generators_) {
+ generator->GenerateSource(p);
+ }
+ });
+}
+
+void FileGenerator::GenerateGlobalSource(io::Printer* p) const {
+ std::vector<const FileDescriptor*> deps_with_extensions =
+ common_state_->CollectMinimalFileDepsContainingExtensions(file_);
+ GeneratedFileOptions file_options;
+
+ // If any indirect dependency provided extensions, it needs to be directly
+ // imported so it can get merged into the root's extensions registry.
+ // See the Note by CollectMinimalFileDepsContainingExtensions before
+ // changing this.
+ for (auto& dep : deps_with_extensions) {
+ if (!IsDirectDependency(dep, file_)) {
+ file_options.extra_files_to_import.push_back(dep);
+ }
+ }
+
+ y_absl::btree_set<TProtoStringType> fwd_decls;
+ for (const auto& generator : extension_generators_) {
+ generator->DetermineObjectiveCClassDefinitions(&fwd_decls);
+ }
+
+ if (!fwd_decls.empty()) {
+ file_options.ignored_warnings.push_back("dollar-in-identifier-extension");
+ }
+
+ GenerateFile(p, GeneratedFileType::kSource, file_options, [&] {
+ if (!fwd_decls.empty()) {
+ p->Print(
+ // clang-format off
+ "#pragma mark - Objective-C Class declarations\n"
+ "// Forward declarations of Objective-C classes that we can use as\n"
+ "// static values in struct initializers.\n"
+ "// We don't use [Foo class] because it is not a static value.\n"
+ "$fwd_decls$\n"
+ "\n",
+ // clang-format on
+ "fwd_decls", y_absl::StrJoin(fwd_decls, "\n"));
+ }
+
+ PrintRootImplementation(p, deps_with_extensions);
+ });
+}
+
+void FileGenerator::GenerateSourceForEnums(io::Printer* p) const {
+ // Enum implementation uses atomic in the generated code.
+ GeneratedFileOptions file_options;
+ file_options.extra_system_headers.push_back("stdatomic.h");
+
+ GenerateFile(p, GeneratedFileType::kSource, file_options, [&] {
+ for (const auto& generator : enum_generators_) {
+ generator->GenerateSource(p);
+ }
+ });
+}
+
+void FileGenerator::GenerateSourceForMessage(int idx, io::Printer* p) const {
+ const auto& generator = message_generators_[idx];
+
+ y_absl::btree_set<TProtoStringType> fwd_decls;
+ generator->DetermineObjectiveCClassDefinitions(&fwd_decls);
+
+ GeneratedFileOptions file_options;
+ // The generated code for oneof's uses direct ivar access, suppress the
+ // warning in case developer turn that on in the context they compile the
+ // generated code.
+ if (generator->IncludesOneOfDefinition()) {
+ file_options.ignored_warnings.push_back("direct-ivar-access");
+ }
+
+ GenerateFile(p, GeneratedFileType::kSource, file_options, [&] {
+ if (!fwd_decls.empty()) {
+ p->Print(
+ // clang-format off
+ "#pragma mark - Objective-C Class declarations\n"
+ "// Forward declarations of Objective-C classes that we can use as\n"
+ "// static values in struct initializers.\n"
+ "// We don't use [Foo class] because it is not a static value.\n"
+ "$fwd_decls$\n"
+ "\n",
+ // clang-format on
+ "fwd_decls", y_absl::StrJoin(fwd_decls, "\n"));
+ }
+
+ PrintFileDescription(p);
+ generator->GenerateSource(p);
+ });
+}
+
+void FileGenerator::GenerateFile(io::Printer* p, GeneratedFileType file_type,
+ const GeneratedFileOptions& file_options,
+ std::function<void()> body) const {
+ ImportWriter import_writer(
+ generation_options_.generate_for_named_framework,
+ generation_options_.named_framework_to_proto_path_mappings_path,
+ generation_options_.runtime_import_prefix,
+ /* for_bundled_proto = */ is_bundled_proto_);
+ const TProtoStringType header_extension(kHeaderExtension);
+
+ switch (file_type) {
+ case GeneratedFileType::kHeader:
+ // Generated files bundled with the library get minimal imports,
+ // everything else gets the wrapper so everything is usable.
+ if (is_bundled_proto_) {
+ import_writer.AddRuntimeImport("GPBDescriptor.h");
+ import_writer.AddRuntimeImport("GPBMessage.h");
+ import_writer.AddRuntimeImport("GPBRootObject.h");
+ } else {
+ import_writer.AddRuntimeImport("GPBProtocolBuffers.h");
+ }
+ if (HeadersUseForwardDeclarations()) {
+ // #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);
+ }
+ }
+ break;
+ case GeneratedFileType::kSource:
+ import_writer.AddRuntimeImport("GPBProtocolBuffers_RuntimeSupport.h");
+ import_writer.AddFile(file_, header_extension);
+ if (HeadersUseForwardDeclarations()) {
+ // #import the headers for anything that a plain dependency of this
+ // proto file (that means they were just an include, not a "public"
+ // include).
+ y_absl::flat_hash_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);
+ if (!public_import_names.contains(dep->name())) {
+ import_writer.AddFile(dep, header_extension);
+ }
+ }
+ }
+ break;
+ }
+
+ for (const auto& dep : file_options.extra_files_to_import) {
+ import_writer.AddFile(dep, header_extension);
+ }
+
+ p->Print(
+ "// Generated by the protocol buffer compiler. DO NOT EDIT!\n"
+ "// $clangfmt$ off\n"
+ "// source: $filename$\n"
+ "\n",
+ "filename", file_->name(), "clangfmt", "clang-format");
+
+ import_writer.PrintRuntimeImports(
+ p, /* default_cpp_symbol = */ !is_bundled_proto_);
+
+ p->Print("\n");
+
+ // Add some verification that the generated code matches the source the
+ // code is being compiled with.
+ // NOTE: This captures the raw numeric values at the time the generator was
+ // compiled, since that will be the versions for the ObjC runtime at that
+ // time. The constants in the generated code will then get their values at
+ // compile time (so checking against the headers being used to compile).
+ p->Print(
+ // clang-format off
+ "#if GOOGLE_PROTOBUF_OBJC_VERSION < $google_protobuf_objc_version$\n"
+ "#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.\n"
+ "#endif\n"
+ "#if $google_protobuf_objc_version$ < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION\n"
+ "#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.\n"
+ "#endif\n"
+ "\n",
+ // clang-format on
+ "google_protobuf_objc_version",
+ y_absl::StrCat(GOOGLE_PROTOBUF_OBJC_VERSION));
+
+ if (!file_options.extra_system_headers.empty()) {
+ for (const auto& system_header : file_options.extra_system_headers) {
+ p->Print("#import <$header$>\n", "header", system_header);
+ }
+ p->Print("\n");
+ }
+
+ import_writer.PrintFileImports(p);
+
+ // clang-format off
+ p->Print(
+ "// @@protoc_insertion_point(imports)\n"
+ "\n"
+ "#pragma clang diagnostic push\n"
+ "#pragma clang diagnostic ignored \"-Wdeprecated-declarations\"\n");
+ // clang-format on
+ for (const auto& warning : file_options.ignored_warnings) {
+ p->Print("#pragma clang diagnostic ignored \"-W$warning$\"\n", "warning",
+ warning);
+ }
+ p->Print("\n");
+
+ body();
+
+ p->Print(
+ "\n"
+ "#pragma clang diagnostic pop\n"
+ "\n"
+ "// @@protoc_insertion_point(global_scope)\n"
+ "\n"
+ "// $clangfmt$ on\n",
+ "clangfmt", "clang-format");
+}
+
+void FileGenerator::PrintRootImplementation(
+ io::Printer* p,
+ const std::vector<const FileDescriptor*>& deps_with_extensions) const {
+ p->Print(
+ // clang-format off
+ "#pragma mark - $root_class_name$\n"
+ "\n"
+ "@implementation $root_class_name$\n"
+ "\n",
+ // clang-format on
+ "root_class_name", root_class_name_);
+
+ // If there were any extensions or this file has any dependencies, output a
+ // registry to override to create the file specific registry.
+ if (extension_generators_.empty() && deps_with_extensions.empty()) {
+ if (file_->dependency_count() == 0) {
+ // clang-format off
+ p->Print(
+ "// No extensions in the file and no imports, so no need to generate\n"
+ "// +extensionRegistry.\n");
+ // clang-format on
+ } else {
+ // clang-format off
+ p->Print(
+ "// No extensions in the file and none of the imports (direct or indirect)\n"
+ "// defined extensions, so no need to generate +extensionRegistry.\n");
+ // clang-format on
+ }
+ } else {
+ PrintRootExtensionRegistryImplementation(p, deps_with_extensions);
+ }
+
+ p->Print("\n@end\n\n");
+}
+
+void FileGenerator::PrintRootExtensionRegistryImplementation(
+ io::Printer* p,
+ const std::vector<const FileDescriptor*>& deps_with_extensions) const {
+ // clang-format off
+ p->Print(
+ "+ (GPBExtensionRegistry*)extensionRegistry {\n"
+ " // This is called by +initialize so there is no need to worry\n"
+ " // about thread safety and initialization of registry.\n"
+ " static GPBExtensionRegistry* registry = nil;\n"
+ " if (!registry) {\n"
+ " GPB_DEBUG_CHECK_RUNTIME_VERSIONS();\n"
+ " registry = [[GPBExtensionRegistry alloc] init];\n");
+ // clang-format on
+
+ p->Indent();
+ p->Indent();
+
+ if (!extension_generators_.empty()) {
+ p->Print("static GPBExtensionDescription descriptions[] = {\n");
+ p->Indent();
+ for (const auto& generator : extension_generators_) {
+ generator->GenerateStaticVariablesInitialization(p);
+ }
+ p->Outdent();
+ // clang-format off
+ p->Print(
+ "};\n"
+ "for (size_t i = 0; i < sizeof(descriptions) / sizeof(descriptions[0]); ++i) {\n"
+ " GPBExtensionDescriptor *extension =\n"
+ " [[GPBExtensionDescriptor alloc] initWithExtensionDescription:&descriptions[i]\n"
+ " usesClassRefs:YES];\n"
+ " [registry addExtension:extension];\n"
+ " [self globallyRegisterExtension:extension];\n"
+ " [extension release];\n"
+ "}\n");
+ // clang-format on
+ }
+
+ if (deps_with_extensions.empty()) {
+ // clang-format off
+ p->Print(
+ "// None of the imports (direct or indirect) defined extensions, so no need to add\n"
+ "// them to this registry.\n");
+ // clang-format on
+ } else {
+ // clang-format off
+ p->Print(
+ "// Merge in the imports (direct or indirect) that defined extensions.\n");
+ // clang-format on
+ for (const auto& dep : deps_with_extensions) {
+ const TProtoStringType root_class_name(FileClassName((dep)));
+ p->Print("[registry addExtensions:[$dependency$ extensionRegistry]];\n",
+ "dependency", root_class_name);
+ }
+ }
+
+ p->Outdent();
+ p->Outdent();
+
+ // clang-format off
+ p->Print(
+ " }\n"
+ " return registry;\n"
+ "}\n");
+ // clang-format on
+}
+
+void FileGenerator::PrintFileDescription(io::Printer* p) const {
+ // File descriptor only needed if there are messages to use it.
+ if (message_generators_.empty()) {
+ return;
+ }
+
+ const TProtoStringType objc_prefix(FileClassPrefix(file_));
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
+ vars["file_description_name"] = file_description_name_;
+ vars["package_value"] = file_->package().empty()
+ ? "NULL"
+ : y_absl::StrCat("\"", file_->package(), "\"");
+ switch (file_->syntax()) {
+ case FileDescriptor::SYNTAX_UNKNOWN:
+ vars["syntax"] = "GPBFileSyntaxUnknown";
+ break;
+ case FileDescriptor::SYNTAX_PROTO2:
+ vars["syntax"] = "GPBFileSyntaxProto2";
+ break;
+ case FileDescriptor::SYNTAX_PROTO3:
+ vars["syntax"] = "GPBFileSyntaxProto3";
+ break;
+ }
+ if (objc_prefix.empty() && !file_->options().has_objc_class_prefix()) {
+ vars["prefix_value"] = "NULL";
+ } else {
+ vars["prefix_value"] = y_absl::StrCat("\"", objc_prefix, "\"");
+ }
+
+ // clang-format off
+ p->Print(
+ vars,
+ "static GPBFileDescription $file_description_name$ = {\n"
+ " .package = $package_value$,\n"
+ " .prefix = $prefix_value$,\n"
+ " .syntax = $syntax$\n"
+ "};\n"
+ "\n");
+ // clang-format on
+}
+
+} // namespace objectivec
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/file.h
index de37930eb39..e83c27c2eca 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/file.h
@@ -31,80 +31,108 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_FILE_H__
#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_FILE_H__
-#include <map>
-#include <set>
+#include <functional>
+#include <memory>
#include <string>
#include <vector>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/io/printer.h>
+
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/container/flat_hash_set.h"
+#include "google/protobuf/compiler/objectivec/enum.h"
+#include "google/protobuf/compiler/objectivec/extension.h"
+#include "google/protobuf/compiler/objectivec/message.h"
+#include "google/protobuf/compiler/objectivec/options.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
namespace compiler {
namespace objectivec {
-class EnumGenerator;
-class ExtensionGenerator;
-class MessageGenerator;
-
class FileGenerator {
public:
- 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;
- };
-
// Wrapper for some common state that is shared between file generations to
// improve performance when more than one file is generated at a time.
struct CommonState {
- CommonState();
+ CommonState() = default;
- const std::vector<const FileDescriptor*>
+ std::vector<const FileDescriptor*>
CollectMinimalFileDepsContainingExtensions(const FileDescriptor* file);
private:
struct MinDepsEntry {
bool has_extensions;
- std::set<const FileDescriptor*> min_deps;
- // `covered_deps` are the transtive deps of `min_deps_w_exts` that also
- // have extensions.
- std::set<const FileDescriptor*> covered_deps;
+ // The minimal dependencies that cover all the dependencies with
+ // extensions.
+ y_absl::flat_hash_set<const FileDescriptor*> min_deps;
+ y_absl::flat_hash_set<const FileDescriptor*> transitive_deps;
};
- const MinDepsEntry& CollectMinimalFileDepsContainingExtensionsInternal(const FileDescriptor* file);
- std::map<const FileDescriptor*, MinDepsEntry> deps_info_cache_;
+ const MinDepsEntry& CollectMinimalFileDepsContainingExtensionsInternal(
+ const FileDescriptor* file);
+ y_absl::flat_hash_map<const FileDescriptor*, MinDepsEntry> deps_info_cache;
};
FileGenerator(const FileDescriptor* file,
const GenerationOptions& generation_options,
CommonState& common_state);
- ~FileGenerator();
+ ~FileGenerator() = default;
FileGenerator(const FileGenerator&) = delete;
FileGenerator& operator=(const FileGenerator&) = delete;
- void GenerateSource(io::Printer* printer);
- void GenerateHeader(io::Printer* printer);
+ void GenerateHeader(io::Printer* p) const;
+ void GenerateSource(io::Printer* p) const;
+
+ int NumEnums() const { return enum_generators_.size(); }
+ int NumMessages() const { return message_generators_.size(); }
+
+ void GenerateGlobalSource(io::Printer* p) const;
+ void GenerateSourceForMessage(int idx, io::Printer* p) const;
+ void GenerateSourceForEnums(io::Printer* p) const;
private:
+ enum class GeneratedFileType : int { kHeader, kSource };
+ struct GeneratedFileOptions {
+ std::vector<TProtoStringType> ignored_warnings;
+ std::vector<const FileDescriptor*> extra_files_to_import;
+ std::vector<TProtoStringType> extra_system_headers;
+ };
+
+ void GenerateFile(io::Printer* p, GeneratedFileType file_type,
+ const GeneratedFileOptions& file_options,
+ std::function<void()> body) const;
+ void GenerateFile(io::Printer* p, GeneratedFileType file_type,
+ std::function<void()> body) const {
+ GeneratedFileOptions file_options;
+ GenerateFile(p, file_type, file_options, body);
+ }
+
+ void PrintRootImplementation(
+ io::Printer* p,
+ const std::vector<const FileDescriptor*>& deps_with_extensions) const;
+ void PrintRootExtensionRegistryImplementation(
+ io::Printer* p,
+ const std::vector<const FileDescriptor*>& deps_with_extensions) const;
+ void PrintFileDescription(io::Printer* p) const;
+
+ bool HeadersUseForwardDeclarations() const {
+ // The bundled protos (WKTs) don't make use of forward declarations.
+ return !is_bundled_proto_ &&
+ generation_options_.headers_use_forward_declarations;
+ }
+
const FileDescriptor* file_;
const GenerationOptions& generation_options_;
- CommonState& common_state_;
- TProtoStringType root_class_name_;
- bool is_bundled_proto_;
+ mutable CommonState* common_state_;
+ const TProtoStringType root_class_name_;
+ const TProtoStringType file_description_name_;
+ const bool is_bundled_proto_;
std::vector<std::unique_ptr<EnumGenerator>> enum_generators_;
std::vector<std::unique_ptr<MessageGenerator>> message_generators_;
+ // The first file_->extension_count() are the extensions at file level scope.
std::vector<std::unique_ptr<ExtensionGenerator>> extension_generators_;
-
- void PrintFileRuntimePreamble(
- io::Printer* printer,
- const std::vector<TProtoStringType>& headers_to_import) const;
};
} // namespace objectivec
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/generator.cc
index 586cdb025b2..31c99dba67a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/generator.cc
@@ -28,16 +28,24 @@
// (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/objectivec/generator.h"
+
#include <fstream>
#include <iostream>
+#include <memory>
#include <string>
-#include <unordered_set>
-#include <google/protobuf/compiler/objectivec/objectivec_generator.h>
-#include <google/protobuf/compiler/objectivec/objectivec_file.h>
-#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/zero_copy_stream.h>
-#include <google/protobuf/stubs/strutil.h>
+#include <utility>
+#include <vector>
+
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_split.h"
+#include "y_absl/strings/strip.h"
+#include "google/protobuf/compiler/objectivec/file.h"
+#include "google/protobuf/compiler/objectivec/names.h"
+#include "google/protobuf/io/printer.h"
+#include "google/protobuf/io/zero_copy_stream.h"
namespace google {
namespace protobuf {
@@ -47,16 +55,17 @@ namespace objectivec {
namespace {
// Convert a string with "yes"/"no" (case insensitive) to a boolean, returning
-// true/false for if the input string was a valid value. If the input string is
-// invalid, `result` is unchanged.
+// true/false for if the input string was a valid value. The empty string is
+// also treated as a true value. If the input string is invalid, `result` is
+// unchanged.
bool StringToBool(const TProtoStringType& value, bool* result) {
TProtoStringType upper_value(value);
- UpperString(&upper_value);
+ y_absl::AsciiStrToUpper(&upper_value);
if (upper_value == "NO") {
*result = false;
return true;
}
- if (upper_value == "YES") {
+ if (upper_value == "YES" || upper_value.empty()) {
*result = true;
return true;
}
@@ -64,15 +73,13 @@ bool StringToBool(const TProtoStringType& value, bool* result) {
return false;
}
-} // namespace
+TProtoStringType NumberedObjCMFileName(y_absl::string_view basename, int number) {
+ return y_absl::StrCat(basename, ".out/", number, ".pbobjc.m");
+}
-ObjectiveCGenerator::ObjectiveCGenerator() {}
+} // namespace
-ObjectiveCGenerator::~ObjectiveCGenerator() {}
-
-bool ObjectiveCGenerator::HasGenerateAll() const {
- return true;
-}
+bool ObjectiveCGenerator::HasGenerateAll() const { return true; }
bool ObjectiveCGenerator::Generate(const FileDescriptor* file,
const TProtoStringType& parameter,
@@ -92,14 +99,15 @@ bool ObjectiveCGenerator::GenerateAll(
// options along with their values. If the option appears multiple times, only
// the last value will be considered.
//
- // e.g. protoc ... --objc_opt=expected_prefixes=file.txt,generate_for_named_framework=MyFramework
+ // e.g. protoc ...
+ // --objc_opt=expected_prefixes=file.txt,generate_for_named_framework=MyFramework
Options validation_options;
- FileGenerator::GenerationOptions generation_options;
+ GenerationOptions generation_options;
std::vector<std::pair<TProtoStringType, TProtoStringType> > options;
ParseGeneratorParameter(parameter, &options);
- for (int i = 0; i < options.size(); i++) {
+ for (size_t i = 0; i < options.size(); i++) {
if (options[i].first == "expected_prefixes_path") {
// Path to find a file containing the expected prefixes
// (objc_class_prefix "PREFIX") for proto packages (package NAME). The
@@ -122,8 +130,8 @@ bool ObjectiveCGenerator::GenerateAll(
// 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)) {
+ for (y_absl::string_view split_piece :
+ y_absl::StrSplit(options[i].second, ';', y_absl::SkipEmpty())) {
validation_options.expected_prefixes_suppressions.push_back(
TProtoStringType(split_piece));
}
@@ -137,7 +145,9 @@ bool ObjectiveCGenerator::GenerateAll(
// Default is "no".
if (!StringToBool(options[i].second,
&validation_options.prefixes_must_be_registered)) {
- *error = "error: Unknown value for prefixes_must_be_registered: " + options[i].second;
+ *error = y_absl::StrCat(
+ "error: Unknown value for prefixes_must_be_registered: ",
+ options[i].second);
return false;
}
} else if (options[i].first == "require_prefixes") {
@@ -149,7 +159,8 @@ bool ObjectiveCGenerator::GenerateAll(
// Default is "no".
if (!StringToBool(options[i].second,
&validation_options.require_prefixes)) {
- *error = "error: Unknown value for require_prefixes: " + options[i].second;
+ *error = y_absl::StrCat("error: Unknown value for require_prefixes: ",
+ options[i].second);
return false;
}
} else if (options[i].first == "generate_for_named_framework") {
@@ -162,7 +173,8 @@ bool ObjectiveCGenerator::GenerateAll(
// the "default" framework name used for everything that wasn't mapped by
// the mapping file.
generation_options.generate_for_named_framework = options[i].second;
- } else if (options[i].first == "named_framework_to_proto_path_mappings_path") {
+ } else if (options[i].first ==
+ "named_framework_to_proto_path_mappings_path") {
// Path to find a file containing the list of framework names and proto
// files. The generator uses this to decide if a proto file
// referenced should use a framework style import vs. a user level import
@@ -183,17 +195,20 @@ bool ObjectiveCGenerator::GenerateAll(
// mappings file, it will use the default framework name if one was passed
// with generate_for_named_framework, or the relative path to it's include
// path otherwise.
- generation_options.named_framework_to_proto_path_mappings_path = options[i].second;
+ generation_options.named_framework_to_proto_path_mappings_path =
+ options[i].second;
} else if (options[i].first == "runtime_import_prefix") {
// Path to use as a prefix on #imports of runtime provided headers in the
// 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 =
+ TProtoStringType(y_absl::StripSuffix(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 `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".
@@ -215,7 +230,8 @@ bool ObjectiveCGenerator::GenerateAll(
if (StringToBool(options[i].second, &value)) {
SetUseProtoPackageAsDefaultPrefix(value);
} else {
- *error = "error: Unknown use_package_as_prefix: " + options[i].second;
+ *error = y_absl::StrCat("error: Unknown use_package_as_prefix: ",
+ options[i].second);
return false;
}
} else if (options[i].first == "proto_package_prefix_exceptions_path") {
@@ -230,25 +246,54 @@ 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 == "package_as_prefix_forced_prefix") {
+ // String to use as the prefix when deriving a prefix from the package
+ // name. So this only applies when use_package_as_prefix is also used.
+ SetForcedPackagePrefix(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;
+ *error = y_absl::StrCat(
+ "error: Unknown value for headers_use_forward_declarations: ",
+ options[i].second);
+ return false;
+ }
+ } else if (options[i].first == "experimental_multi_source_generation") {
+ // This is an experimental option, and could be removed or change at any
+ // time; it is not documented in the README.md for that reason.
+ //
+ // Enables a mode where each ObjC class (messages and roots) generates to
+ // a unique .m file; this is to explore impacts on code size when not
+ // compiling/linking with `-ObjC` as then only linker visible needs should
+ // be pulled into the builds.
+ if (!StringToBool(
+ options[i].second,
+ &generation_options.experimental_multi_source_generation)) {
+ *error = y_absl::StrCat(
+ "error: Unknown value for experimental_multi_source_generation: ",
+ options[i].second);
return false;
}
} else {
- *error = "error: Unknown generator option: " + options[i].first;
+ *error =
+ y_absl::StrCat("error: Unknown generator option: ", options[i].first);
return false;
}
}
+ // Multi source generation forces off the use of fwd decls in favor of
+ // imports.
+ if (generation_options.experimental_multi_source_generation) {
+ generation_options.headers_use_forward_declarations = false;
+ }
+
// -----------------------------------------------------------------
// These are not official generation options and could be removed/changed in
// the future and doing that won't count as a breaking change.
- bool headers_only = getenv("GPB_OBJC_HEADERS_ONLY") != NULL;
- std::unordered_set<TProtoStringType> skip_impls;
- if (getenv("GPB_OBJC_SKIP_IMPLS_FILE") != NULL) {
+ bool headers_only = getenv("GPB_OBJC_HEADERS_ONLY") != nullptr;
+ y_absl::flat_hash_set<TProtoStringType> skip_impls;
+ if (getenv("GPB_OBJC_SKIP_IMPLS_FILE") != nullptr) {
std::ifstream skip_file(getenv("GPB_OBJC_SKIP_IMPLS_FILE"));
if (skip_file.is_open()) {
std::string line;
@@ -270,27 +315,83 @@ bool ObjectiveCGenerator::GenerateAll(
}
FileGenerator::CommonState state;
- for (int i = 0; i < files.size(); i++) {
- const FileDescriptor* file = files[i];
- FileGenerator file_generator(file, generation_options, state);
+ for (const auto& file : files) {
+ const FileGenerator file_generator(file, generation_options, state);
TProtoStringType filepath = FilePath(file);
// Generate header.
{
- std::unique_ptr<io::ZeroCopyOutputStream> output(
- context->Open(filepath + ".pbobjc.h"));
- io::Printer printer(output.get(), '$');
+ auto output =
+ y_absl::WrapUnique(context->Open(y_absl::StrCat(filepath, ".pbobjc.h")));
+ io::Printer printer(output.get());
file_generator.GenerateHeader(&printer);
+ if (printer.failed()) {
+ *error = y_absl::StrCat("error: internal error generating a header: ",
+ file->name());
+ return false;
+ }
}
- // Generate m file.
+ // Generate m file(s).
if (!headers_only && skip_impls.count(file->name()) == 0) {
- std::unique_ptr<io::ZeroCopyOutputStream> output(
- context->Open(filepath + ".pbobjc.m"));
- io::Printer printer(output.get(), '$');
- file_generator.GenerateSource(&printer);
- }
- }
+ if (generation_options.experimental_multi_source_generation) {
+ int file_number = 0;
+
+ // Generate the Root and FileDescriptor (if needed).
+ {
+ std::unique_ptr<io::ZeroCopyOutputStream> output(
+ context->Open(NumberedObjCMFileName(filepath, file_number++)));
+ io::Printer printer(output.get());
+ file_generator.GenerateGlobalSource(&printer);
+ if (printer.failed()) {
+ *error = y_absl::StrCat(
+ "error: internal error generating an implementation:",
+ file->name());
+ return false;
+ }
+ }
+
+ // Enums only generate C functions, so they can all go in one file as
+ // dead stripping anything not used.
+ if (file_generator.NumEnums() > 0) {
+ std::unique_ptr<io::ZeroCopyOutputStream> output(
+ context->Open(NumberedObjCMFileName(filepath, file_number++)));
+ io::Printer printer(output.get());
+ file_generator.GenerateSourceForEnums(&printer);
+ if (printer.failed()) {
+ *error = y_absl::StrCat(
+ "error: internal error generating an enum implementation(s):",
+ file->name());
+ return false;
+ }
+ }
+
+ for (int i = 0; i < file_generator.NumMessages(); ++i) {
+ std::unique_ptr<io::ZeroCopyOutputStream> output(
+ context->Open(NumberedObjCMFileName(filepath, file_number++)));
+ io::Printer printer(output.get());
+ file_generator.GenerateSourceForMessage(i, &printer);
+ if (printer.failed()) {
+ *error = y_absl::StrCat(
+ "error: internal error generating an message implementation:",
+ file->name(), "::", i);
+ return false;
+ }
+ }
+ } else {
+ auto output = y_absl::WrapUnique(
+ context->Open(y_absl::StrCat(filepath, ".pbobjc.m")));
+ io::Printer printer(output.get());
+ file_generator.GenerateSource(&printer);
+ if (printer.failed()) {
+ *error = y_absl::StrCat(
+ "error: internal error generating an implementation:",
+ file->name());
+ return false;
+ }
+ }
+ } // if (!headers_only && skip_impls.count(file->name()) == 0)
+ } // for(file : files)
return true;
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/generator.h
index cdaac67c3ba..34767e45a6a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/generator.h
@@ -34,10 +34,13 @@
#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_GENERATOR_H__
#include <string>
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/descriptor.h>
+#include <vector>
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/descriptor.h"
+
+// Must be included last
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -50,8 +53,8 @@ namespace objectivec {
// CodeGenerator with the CommandLineInterface in your main() function.
class PROTOC_EXPORT ObjectiveCGenerator : public CodeGenerator {
public:
- ObjectiveCGenerator();
- ~ObjectiveCGenerator();
+ ObjectiveCGenerator() = default;
+ ~ObjectiveCGenerator() override = default;
ObjectiveCGenerator(const ObjectiveCGenerator&) = delete;
ObjectiveCGenerator& operator=(const ObjectiveCGenerator&) = delete;
@@ -74,6 +77,6 @@ class PROTOC_EXPORT ObjectiveCGenerator : public CodeGenerator {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_GENERATOR_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/helpers.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/helpers.cc
new file mode 100644
index 00000000000..4d90adeb7de
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/helpers.cc
@@ -0,0 +1,399 @@
+// 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/objectivec/helpers.h"
+
+#include <string>
+#include <vector>
+
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/escaping.h"
+#include "y_absl/strings/match.h"
+#include "y_absl/strings/str_replace.h"
+#include "y_absl/strings/str_split.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/compiler/objectivec/names.h"
+#include "google/protobuf/io/strtod.h"
+#include "google/protobuf/stubs/common.h"
+#include <google/protobuf/stubs/port.h>
+
+// 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 errors.
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace objectivec {
+
+TProtoStringType EscapeTrigraphs(y_absl::string_view to_escape) {
+ return y_absl::StrReplaceAll(to_escape, {{"?", "\\?"}});
+}
+
+namespace {
+
+TProtoStringType GetZeroEnumNameForFlagType(const FlagType flag_type) {
+ switch (flag_type) {
+ case FLAGTYPE_DESCRIPTOR_INITIALIZATION:
+ return "GPBDescriptorInitializationFlag_None";
+ case FLAGTYPE_EXTENSION:
+ return "GPBExtensionNone";
+ case FLAGTYPE_FIELD:
+ return "GPBFieldNone";
+ default:
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
+ return "0";
+ }
+}
+
+TProtoStringType GetEnumNameForFlagType(const FlagType flag_type) {
+ switch (flag_type) {
+ case FLAGTYPE_DESCRIPTOR_INITIALIZATION:
+ return "GPBDescriptorInitializationFlags";
+ case FLAGTYPE_EXTENSION:
+ return "GPBExtensionOptions";
+ case FLAGTYPE_FIELD:
+ return "GPBFieldFlags";
+ default:
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
+ return TProtoStringType();
+ }
+}
+
+TProtoStringType HandleExtremeFloatingPoint(TProtoStringType val, bool add_float_suffix) {
+ if (val == "nan") {
+ return "NAN";
+ } else if (val == "inf") {
+ return "INFINITY";
+ } else if (val == "-inf") {
+ return "-INFINITY";
+ } else {
+ // float strings with ., e or E need to have f appended
+ if (add_float_suffix &&
+ (y_absl::StrContains(val, '.') || y_absl::StrContains(val, 'e') ||
+ y_absl::StrContains(val, 'E'))) {
+ return y_absl::StrCat(val, "f");
+ }
+ return val;
+ }
+}
+
+} // namespace
+
+TProtoStringType GetCapitalizedType(const FieldDescriptor* field) {
+ switch (field->type()) {
+ case FieldDescriptor::TYPE_INT32:
+ return "Int32";
+ case FieldDescriptor::TYPE_UINT32:
+ return "UInt32";
+ case FieldDescriptor::TYPE_SINT32:
+ return "SInt32";
+ case FieldDescriptor::TYPE_FIXED32:
+ return "Fixed32";
+ case FieldDescriptor::TYPE_SFIXED32:
+ return "SFixed32";
+ case FieldDescriptor::TYPE_INT64:
+ return "Int64";
+ case FieldDescriptor::TYPE_UINT64:
+ return "UInt64";
+ case FieldDescriptor::TYPE_SINT64:
+ return "SInt64";
+ case FieldDescriptor::TYPE_FIXED64:
+ return "Fixed64";
+ case FieldDescriptor::TYPE_SFIXED64:
+ return "SFixed64";
+ case FieldDescriptor::TYPE_FLOAT:
+ return "Float";
+ case FieldDescriptor::TYPE_DOUBLE:
+ return "Double";
+ case FieldDescriptor::TYPE_BOOL:
+ return "Bool";
+ case FieldDescriptor::TYPE_STRING:
+ return "String";
+ case FieldDescriptor::TYPE_BYTES:
+ return "Bytes";
+ case FieldDescriptor::TYPE_ENUM:
+ return "Enum";
+ case FieldDescriptor::TYPE_GROUP:
+ return "Group";
+ case FieldDescriptor::TYPE_MESSAGE:
+ return "Message";
+ }
+
+ // Some compilers report reaching end of function even though all cases of
+ // the enum are handed in the switch.
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
+ return TProtoStringType();
+}
+
+ObjectiveCType GetObjectiveCType(FieldDescriptor::Type field_type) {
+ switch (field_type) {
+ case FieldDescriptor::TYPE_INT32:
+ case FieldDescriptor::TYPE_SINT32:
+ case FieldDescriptor::TYPE_SFIXED32:
+ return OBJECTIVECTYPE_INT32;
+
+ case FieldDescriptor::TYPE_UINT32:
+ case FieldDescriptor::TYPE_FIXED32:
+ return OBJECTIVECTYPE_UINT32;
+
+ case FieldDescriptor::TYPE_INT64:
+ case FieldDescriptor::TYPE_SINT64:
+ case FieldDescriptor::TYPE_SFIXED64:
+ return OBJECTIVECTYPE_INT64;
+
+ case FieldDescriptor::TYPE_UINT64:
+ case FieldDescriptor::TYPE_FIXED64:
+ return OBJECTIVECTYPE_UINT64;
+
+ case FieldDescriptor::TYPE_FLOAT:
+ return OBJECTIVECTYPE_FLOAT;
+
+ case FieldDescriptor::TYPE_DOUBLE:
+ return OBJECTIVECTYPE_DOUBLE;
+
+ case FieldDescriptor::TYPE_BOOL:
+ return OBJECTIVECTYPE_BOOLEAN;
+
+ case FieldDescriptor::TYPE_STRING:
+ return OBJECTIVECTYPE_STRING;
+
+ case FieldDescriptor::TYPE_BYTES:
+ return OBJECTIVECTYPE_DATA;
+
+ case FieldDescriptor::TYPE_ENUM:
+ return OBJECTIVECTYPE_ENUM;
+
+ case FieldDescriptor::TYPE_GROUP:
+ case FieldDescriptor::TYPE_MESSAGE:
+ return OBJECTIVECTYPE_MESSAGE;
+ }
+
+ // Some compilers report reaching end of function even though all cases of
+ // the enum are handed in the switch.
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
+ return OBJECTIVECTYPE_INT32;
+}
+
+TProtoStringType GPBGenericValueFieldName(const FieldDescriptor* field) {
+ // Returns the field within the GPBGenericValue union to use for the given
+ // field.
+ if (field->is_repeated()) {
+ return "valueMessage";
+ }
+ switch (field->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_INT32:
+ return "valueInt32";
+ case FieldDescriptor::CPPTYPE_UINT32:
+ return "valueUInt32";
+ case FieldDescriptor::CPPTYPE_INT64:
+ return "valueInt64";
+ case FieldDescriptor::CPPTYPE_UINT64:
+ return "valueUInt64";
+ case FieldDescriptor::CPPTYPE_FLOAT:
+ return "valueFloat";
+ case FieldDescriptor::CPPTYPE_DOUBLE:
+ return "valueDouble";
+ case FieldDescriptor::CPPTYPE_BOOL:
+ return "valueBool";
+ case FieldDescriptor::CPPTYPE_STRING:
+ if (field->type() == FieldDescriptor::TYPE_BYTES) {
+ return "valueData";
+ } else {
+ return "valueString";
+ }
+ case FieldDescriptor::CPPTYPE_ENUM:
+ return "valueEnum";
+ case FieldDescriptor::CPPTYPE_MESSAGE:
+ return "valueMessage";
+ }
+
+ // Some compilers report reaching end of function even though all cases of
+ // the enum are handed in the switch.
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
+ return TProtoStringType();
+}
+
+TProtoStringType DefaultValue(const FieldDescriptor* field) {
+ // Repeated fields don't have defaults.
+ if (field->is_repeated()) {
+ return "nil";
+ }
+
+ // Switch on cpp_type since we need to know which default_value_* method
+ // of FieldDescriptor to call.
+ switch (field->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_INT32:
+ // gcc and llvm reject the decimal form of kint32min and kint64min.
+ if (field->default_value_int32() == INT_MIN) {
+ return "-0x80000000";
+ }
+ return y_absl::StrCat(field->default_value_int32());
+ case FieldDescriptor::CPPTYPE_UINT32:
+ return y_absl::StrCat(field->default_value_uint32(), "U");
+ case FieldDescriptor::CPPTYPE_INT64:
+ // gcc and llvm reject the decimal form of kint32min and kint64min.
+ if (field->default_value_int64() == LLONG_MIN) {
+ return "-0x8000000000000000LL";
+ }
+ return y_absl::StrCat(field->default_value_int64(), "LL");
+ case FieldDescriptor::CPPTYPE_UINT64:
+ return y_absl::StrCat(field->default_value_uint64(), "ULL");
+ case FieldDescriptor::CPPTYPE_DOUBLE:
+ return HandleExtremeFloatingPoint(
+ io::SimpleDtoa(field->default_value_double()), false);
+ case FieldDescriptor::CPPTYPE_FLOAT:
+ return HandleExtremeFloatingPoint(
+ io::SimpleFtoa(field->default_value_float()), true);
+ case FieldDescriptor::CPPTYPE_BOOL:
+ return field->default_value_bool() ? "YES" : "NO";
+ case FieldDescriptor::CPPTYPE_STRING: {
+ const bool has_default_value = field->has_default_value();
+ y_absl::string_view default_string = field->default_value_string();
+ if (!has_default_value || default_string.length() == 0) {
+ // If the field is defined as being the empty string,
+ // then we will just assign to nil, as the empty string is the
+ // default for both strings and data.
+ return "nil";
+ }
+ if (field->type() == FieldDescriptor::TYPE_BYTES) {
+ // We want constant fields in our data structures so we can
+ // declare them as static. To achieve this we cheat and stuff
+ // a escaped c string (prefixed with a length) into the data
+ // field, and cast it to an (NSData*) so it will compile.
+ // The runtime library knows how to handle it.
+
+ // Must convert to a standard byte order for packing length into
+ // a cstring.
+ arc_ui32 length = ghtonl(default_string.length());
+ TProtoStringType bytes((const char*)&length, sizeof(length));
+ y_absl::StrAppend(&bytes, default_string);
+ return y_absl::StrCat("(NSData*)\"",
+ EscapeTrigraphs(y_absl::CEscape(bytes)), "\"");
+ } else {
+ return y_absl::StrCat(
+ "@\"", EscapeTrigraphs(y_absl::CEscape(default_string)), "\"");
+ }
+ }
+ case FieldDescriptor::CPPTYPE_ENUM:
+ return EnumValueName(field->default_value_enum());
+ case FieldDescriptor::CPPTYPE_MESSAGE:
+ return "nil";
+ }
+
+ // Some compilers report reaching end of function even though all cases of
+ // the enum are handed in the switch.
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
+ return TProtoStringType();
+}
+
+TProtoStringType BuildFlagsString(FlagType flag_type,
+ const std::vector<TProtoStringType>& strings) {
+ if (strings.empty()) {
+ return GetZeroEnumNameForFlagType(flag_type);
+ } else if (strings.size() == 1) {
+ return strings[0];
+ }
+ TProtoStringType string =
+ y_absl::StrCat("(", GetEnumNameForFlagType(flag_type), ")(");
+ for (size_t i = 0; i != strings.size(); ++i) {
+ if (i > 0) {
+ string.append(" | ");
+ }
+ string.append(strings[i]);
+ }
+ string.append(")");
+ return string;
+}
+
+TProtoStringType ObjCClass(y_absl::string_view class_name) {
+ return y_absl::StrCat("GPBObjCClass(", class_name, ")");
+}
+
+TProtoStringType ObjCClassDeclaration(y_absl::string_view class_name) {
+ return y_absl::StrCat("GPBObjCClassDeclaration(", class_name, ");");
+}
+
+TProtoStringType BuildCommentsString(const SourceLocation& location,
+ bool prefer_single_line) {
+ y_absl::string_view comments = location.leading_comments.empty()
+ ? location.trailing_comments
+ : location.leading_comments;
+ std::vector<y_absl::string_view> lines;
+ lines = y_absl::StrSplit(comments, '\n', y_absl::AllowEmpty());
+ while (!lines.empty() && lines.back().empty()) {
+ lines.pop_back();
+ }
+ // If there are no comments, just return an empty string.
+ if (lines.empty()) {
+ return "";
+ }
+
+ TProtoStringType prefix;
+ TProtoStringType suffix;
+ TProtoStringType final_comments;
+ TProtoStringType epilogue;
+
+ bool add_leading_space = false;
+
+ if (prefer_single_line && lines.size() == 1) {
+ prefix = "/** ";
+ suffix = " */\n";
+ } else {
+ prefix = "* ";
+ suffix = "\n";
+ y_absl::StrAppend(&final_comments, "/**\n");
+ epilogue = " **/\n";
+ add_leading_space = true;
+ }
+
+ for (size_t i = 0; i < lines.size(); i++) {
+ TProtoStringType line = y_absl::StrReplaceAll(
+ y_absl::StripPrefix(lines[i], " "),
+ {// HeaderDoc and appledoc use '\' and '@' for markers; escape them.
+ {"\\", "\\\\"},
+ {"@", "\\@"},
+ // Decouple / from * to not have inline comments inside comments.
+ {"/*", "/\\*"},
+ {"*/", "*\\/"}});
+ line = prefix + line;
+ y_absl::StripAsciiWhitespace(&line);
+ // If not a one line, need to add the first space before *, as
+ // y_absl::StripAsciiWhitespace would have removed it.
+ line = y_absl::StrCat(add_leading_space ? " " : "", line);
+ y_absl::StrAppend(&final_comments, line, suffix);
+ }
+ return y_absl::StrCat(final_comments, epilogue);
+}
+
+} // namespace objectivec
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/helpers.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/helpers.h
new file mode 100644
index 00000000000..73f67e13d72
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/helpers.h
@@ -0,0 +1,155 @@
+// 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.
+
+// Helper functions for generating ObjectiveC code.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_HELPERS_H__
+#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_HELPERS_H__
+
+#include <string>
+#include <vector>
+
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.h"
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace objectivec {
+
+// Escape C++ trigraphs by escaping question marks to "\?".
+TProtoStringType EscapeTrigraphs(y_absl::string_view to_escape);
+
+enum ObjectiveCType {
+ OBJECTIVECTYPE_INT32,
+ OBJECTIVECTYPE_UINT32,
+ OBJECTIVECTYPE_INT64,
+ OBJECTIVECTYPE_UINT64,
+ OBJECTIVECTYPE_FLOAT,
+ OBJECTIVECTYPE_DOUBLE,
+ OBJECTIVECTYPE_BOOLEAN,
+ OBJECTIVECTYPE_STRING,
+ OBJECTIVECTYPE_DATA,
+ OBJECTIVECTYPE_ENUM,
+ OBJECTIVECTYPE_MESSAGE
+};
+
+enum FlagType {
+ FLAGTYPE_DESCRIPTOR_INITIALIZATION,
+ FLAGTYPE_EXTENSION,
+ FLAGTYPE_FIELD
+};
+
+TProtoStringType GetCapitalizedType(const FieldDescriptor* field);
+
+ObjectiveCType GetObjectiveCType(FieldDescriptor::Type field_type);
+
+inline ObjectiveCType GetObjectiveCType(const FieldDescriptor* field) {
+ return GetObjectiveCType(field->type());
+}
+
+inline bool IsPrimitiveType(const FieldDescriptor* field) {
+ ObjectiveCType type = GetObjectiveCType(field);
+ switch (type) {
+ case OBJECTIVECTYPE_INT32:
+ case OBJECTIVECTYPE_UINT32:
+ case OBJECTIVECTYPE_INT64:
+ case OBJECTIVECTYPE_UINT64:
+ case OBJECTIVECTYPE_FLOAT:
+ case OBJECTIVECTYPE_DOUBLE:
+ case OBJECTIVECTYPE_BOOLEAN:
+ case OBJECTIVECTYPE_ENUM:
+ return true;
+ break;
+ default:
+ return false;
+ }
+}
+
+inline bool IsReferenceType(const FieldDescriptor* field) {
+ return !IsPrimitiveType(field);
+}
+
+TProtoStringType GPBGenericValueFieldName(const FieldDescriptor* field);
+TProtoStringType DefaultValue(const FieldDescriptor* field);
+
+TProtoStringType BuildFlagsString(FlagType type,
+ const std::vector<TProtoStringType>& strings);
+
+// Returns a symbol that can be used in C code to refer to an Objective-C
+// class without initializing the class.
+TProtoStringType ObjCClass(y_absl::string_view class_name);
+
+// Declares an Objective-C class without initializing the class so that it can
+// be refrerred to by ObjCClass.
+TProtoStringType ObjCClassDeclaration(y_absl::string_view class_name);
+
+// Builds HeaderDoc/appledoc style comments out of the comments in the .proto
+// file.
+TProtoStringType BuildCommentsString(const SourceLocation& location,
+ bool prefer_single_line);
+
+template <class TDescriptor>
+TProtoStringType GetOptionalDeprecatedAttribute(const TDescriptor* descriptor,
+ const FileDescriptor* file = nullptr,
+ bool preSpace = true,
+ bool postNewline = false) {
+ bool isDeprecated = descriptor->options().deprecated();
+ // The file is only passed when checking Messages & Enums, so those types
+ // get tagged. At the moment, it doesn't seem to make sense to tag every
+ // field or enum value with when the file is deprecated.
+ bool isFileLevelDeprecation = false;
+ if (!isDeprecated && file) {
+ isFileLevelDeprecation = file->options().deprecated();
+ isDeprecated = isFileLevelDeprecation;
+ }
+ if (isDeprecated) {
+ TProtoStringType message;
+ const FileDescriptor* sourceFile = descriptor->file();
+ if (isFileLevelDeprecation) {
+ message = y_absl::StrCat(sourceFile->name(), " is deprecated.");
+ } else {
+ message = y_absl::StrCat(descriptor->full_name(), " is deprecated (see ",
+ sourceFile->name(), ").");
+ }
+
+ return y_absl::StrCat(preSpace ? " " : "", "GPB_DEPRECATED_MSG(\"", message,
+ "\")", postNewline ? "\n" : "");
+ } else {
+ return "";
+ }
+}
+
+} // namespace objectivec
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+#endif // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_HELPERS_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/import_writer.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/import_writer.cc
new file mode 100644
index 00000000000..de6f6ab66c1
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/import_writer.cc
@@ -0,0 +1,255 @@
+// 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/objectivec/import_writer.h"
+
+#include <iostream>
+#include <ostream>
+#include <string>
+#include <vector>
+
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/match.h"
+#include "google/protobuf/compiler/objectivec/line_consumer.h"
+#include "google/protobuf/compiler/objectivec/names.h"
+#include "google/protobuf/io/printer.h"
+
+// 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 errors.
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace objectivec {
+
+namespace {
+
+class ProtoFrameworkCollector : public LineConsumer {
+ public:
+ explicit ProtoFrameworkCollector(
+ y_absl::flat_hash_map<TProtoStringType, TProtoStringType>*
+ inout_proto_file_to_framework_name)
+ : map_(inout_proto_file_to_framework_name) {}
+
+ bool ConsumeLine(y_absl::string_view line, TProtoStringType* out_error) override;
+
+ private:
+ y_absl::flat_hash_map<TProtoStringType, TProtoStringType>* map_;
+};
+
+bool ProtoFrameworkCollector::ConsumeLine(y_absl::string_view line,
+ TProtoStringType* out_error) {
+ int offset = line.find(':');
+ if (offset == y_absl::string_view::npos) {
+ *out_error = y_absl::StrCat(
+ "Framework/proto file mapping line without colon sign: '", line, "'.");
+ return false;
+ }
+ y_absl::string_view framework_name =
+ y_absl::StripAsciiWhitespace(line.substr(0, offset));
+ y_absl::string_view proto_file_list =
+ y_absl::StripAsciiWhitespace(line.substr(offset + 1));
+
+ int start = 0;
+ while (start < proto_file_list.length()) {
+ offset = proto_file_list.find(',', start);
+ if (offset == y_absl::string_view::npos) {
+ offset = proto_file_list.length();
+ }
+
+ y_absl::string_view proto_file = y_absl::StripAsciiWhitespace(
+ proto_file_list.substr(start, offset - start));
+ if (!proto_file.empty()) {
+ auto existing_entry = map_->find(proto_file);
+ if (existing_entry != map_->end()) {
+ std::cerr << "warning: duplicate proto file reference, replacing "
+ "framework entry for '"
+ << proto_file << "' with '" << framework_name << "' (was '"
+ << existing_entry->second << "')." << std::endl;
+ std::cerr.flush();
+ }
+
+ if (y_absl::StrContains(proto_file, ' ')) {
+ std::cerr << "note: framework mapping file had a proto file with a "
+ "space in, hopefully that isn't a missing comma: '"
+ << proto_file << "'" << std::endl;
+ std::cerr.flush();
+ }
+
+ (*map_)[proto_file] = TProtoStringType(framework_name);
+ }
+
+ start = offset + 1;
+ }
+
+ return true;
+}
+
+} // namespace
+
+ImportWriter::ImportWriter(
+ const TProtoStringType& generate_for_named_framework,
+ const TProtoStringType& named_framework_to_proto_path_mappings_path,
+ const TProtoStringType& runtime_import_prefix, bool for_bundled_proto)
+ : generate_for_named_framework_(generate_for_named_framework),
+ named_framework_to_proto_path_mappings_path_(
+ named_framework_to_proto_path_mappings_path),
+ runtime_import_prefix_(runtime_import_prefix),
+ for_bundled_proto_(for_bundled_proto),
+ need_to_parse_mapping_file_(true) {}
+
+void ImportWriter::AddFile(const FileDescriptor* file,
+ const TProtoStringType& header_extension) {
+ if (IsProtobufLibraryBundledProtoFile(file)) {
+ // The imports of the WKTs are only needed within the library itself,
+ // in other cases, they get skipped because the generated code already
+ // import GPBProtocolBuffers.h and hence proves them.
+ if (for_bundled_proto_) {
+ protobuf_imports_.emplace_back(
+ y_absl::StrCat("GPB", FilePathBasename(file), header_extension));
+ }
+ return;
+ }
+
+ // Lazy parse any mappings.
+ if (need_to_parse_mapping_file_) {
+ ParseFrameworkMappings();
+ }
+
+ auto proto_lookup = proto_file_to_framework_name_.find(file->name());
+ if (proto_lookup != proto_file_to_framework_name_.end()) {
+ other_framework_imports_.emplace_back(y_absl::StrCat(
+ proto_lookup->second, "/", FilePathBasename(file), header_extension));
+ return;
+ }
+
+ if (!generate_for_named_framework_.empty()) {
+ other_framework_imports_.push_back(
+ y_absl::StrCat(generate_for_named_framework_, "/", FilePathBasename(file),
+ header_extension));
+ return;
+ }
+
+ other_imports_.push_back(FilePath(file) + header_extension);
+}
+
+void ImportWriter::AddRuntimeImport(const TProtoStringType& header_name) {
+ protobuf_imports_.push_back(header_name);
+}
+
+void ImportWriter::PrintFileImports(io::Printer* p) const {
+ if (!other_framework_imports_.empty()) {
+ for (const auto& header : other_framework_imports_) {
+ p->Print("#import <$header$>\n", "header", header);
+ }
+ }
+
+ if (!other_imports_.empty()) {
+ if (!other_framework_imports_.empty()) {
+ p->Print("\n");
+ }
+
+ for (const auto& header : other_imports_) {
+ p->Print("#import \"$header$\"\n", "header", header);
+ }
+ }
+}
+
+void ImportWriter::PrintRuntimeImports(io::Printer* p,
+ bool default_cpp_symbol) const {
+ // Given an override, use that.
+ if (!runtime_import_prefix_.empty()) {
+ for (const auto& header : protobuf_imports_) {
+ p->Print("#import \"$import_prefix$/$header$\"\n", "header", header,
+ "import_prefix", runtime_import_prefix_);
+ }
+ return;
+ }
+
+ // If bundled, no need to do the framework support below.
+ if (for_bundled_proto_) {
+ Y_ABSL_DCHECK(!default_cpp_symbol);
+ for (const auto& header : protobuf_imports_) {
+ p->Print("#import \"$header$\"\n", "header", header);
+ }
+ return;
+ }
+
+ const TProtoStringType cpp_symbol(
+ ProtobufFrameworkImportSymbol(ProtobufLibraryFrameworkName));
+
+ if (default_cpp_symbol) {
+ p->Print(
+ // clang-format off
+ "// This CPP symbol can be defined to use imports that match up to the framework\n"
+ "// imports needed when using CocoaPods.\n"
+ "#if !defined($cpp_symbol$)\n"
+ " #define $cpp_symbol$ 0\n"
+ "#endif\n"
+ "\n",
+ // clang-format on
+ "cpp_symbol", cpp_symbol);
+ }
+
+ p->Print("#if $cpp_symbol$\n", "cpp_symbol", cpp_symbol);
+ for (const auto& header : protobuf_imports_) {
+ p->Print(" #import <$framework_name$/$header$>\n", "framework_name",
+ ProtobufLibraryFrameworkName, "header", header);
+ }
+ p->Print("#else\n");
+ for (const auto& header : protobuf_imports_) {
+ p->Print(" #import \"$header$\"\n", "header", header);
+ }
+ p->Print("#endif\n");
+}
+
+void ImportWriter::ParseFrameworkMappings() {
+ need_to_parse_mapping_file_ = false;
+ if (named_framework_to_proto_path_mappings_path_.empty()) {
+ return; // Nothing to do.
+ }
+
+ ProtoFrameworkCollector collector(&proto_file_to_framework_name_);
+ TProtoStringType parse_error;
+ if (!ParseSimpleFile(named_framework_to_proto_path_mappings_path_, &collector,
+ &parse_error)) {
+ std::cerr << "error parsing "
+ << named_framework_to_proto_path_mappings_path_ << " : "
+ << parse_error << std::endl;
+ std::cerr.flush();
+ }
+}
+
+} // namespace objectivec
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/import_writer.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/import_writer.h
new file mode 100644
index 00000000000..d4ed37d3a85
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/import_writer.h
@@ -0,0 +1,82 @@
+// 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_OBJECTIVEC_IMPORT_WRITER_H__
+#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_IMPORT_WRITER_H__
+
+#include <string>
+#include <vector>
+
+#include "y_absl/container/flat_hash_map.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.h"
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace objectivec {
+
+// Helper class for parsing framework import mappings and generating
+// import statements.
+class ImportWriter {
+ public:
+ ImportWriter(const TProtoStringType& generate_for_named_framework,
+ const TProtoStringType& named_framework_to_proto_path_mappings_path,
+ const TProtoStringType& runtime_import_prefix,
+ bool for_bundled_proto);
+ ~ImportWriter() = default;
+
+ void AddFile(const FileDescriptor* file, const TProtoStringType& header_extension);
+ void AddRuntimeImport(const TProtoStringType& header_name);
+
+ void PrintFileImports(io::Printer* p) const;
+ void PrintRuntimeImports(io::Printer* p, bool default_cpp_symbol) const;
+
+ private:
+ void ParseFrameworkMappings();
+
+ const TProtoStringType generate_for_named_framework_;
+ const TProtoStringType named_framework_to_proto_path_mappings_path_;
+ const TProtoStringType runtime_import_prefix_;
+ y_absl::flat_hash_map<TProtoStringType, TProtoStringType> proto_file_to_framework_name_;
+ bool for_bundled_proto_;
+ bool need_to_parse_mapping_file_;
+
+ std::vector<TProtoStringType> protobuf_imports_;
+ std::vector<TProtoStringType> other_framework_imports_;
+ std::vector<TProtoStringType> other_imports_;
+};
+
+} // namespace objectivec
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+#endif // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_IMPORT_WRITER_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/line_consumer.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/line_consumer.cc
new file mode 100644
index 00000000000..f47be8186e1
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/line_consumer.cc
@@ -0,0 +1,212 @@
+// 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 _MSC_VER
+#include <unistd.h>
+#endif
+#include <errno.h>
+#include <fcntl.h>
+#include <stdlib.h>
+
+#include <climits>
+#include <fstream>
+#include <iostream>
+#include <sstream>
+#include <string>
+#include <vector>
+
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/objectivec/line_consumer.h"
+#include "google/protobuf/io/zero_copy_stream_impl.h"
+
+#ifdef _WIN32
+#include "google/protobuf/io/io_win32.h"
+#endif
+
+// 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 errors.
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace objectivec {
+
+// <io.h> is transitively included in this file. Import the functions explicitly
+// in this port namespace to avoid ambiguous definition.
+namespace posix {
+#ifdef _WIN32
+using google::protobuf::io::win32::open;
+#else // !_WIN32
+using ::open;
+#endif // _WIN32
+} // namespace posix
+
+namespace {
+
+bool ascii_isnewline(char c) { return c == '\n' || c == '\r'; }
+
+bool ReadLine(y_absl::string_view* input, y_absl::string_view* line) {
+ for (int len = 0; len < input->size(); ++len) {
+ if (ascii_isnewline((*input)[len])) {
+ *line = y_absl::string_view(input->data(), len);
+ ++len; // advance over the newline
+ *input = y_absl::string_view(input->data() + len, input->size() - len);
+ return true;
+ }
+ }
+ return false; // Ran out of input with no newline.
+}
+
+void RemoveComment(y_absl::string_view* input) {
+ int offset = input->find('#');
+ if (offset != y_absl::string_view::npos) {
+ input->remove_suffix(input->length() - offset);
+ }
+}
+
+class Parser {
+ public:
+ explicit Parser(LineConsumer* line_consumer)
+ : line_consumer_(line_consumer), line_(0) {}
+
+ // Feeds in some input, parse what it can, returning success/failure. Calling
+ // again after an error is undefined.
+ bool ParseChunk(y_absl::string_view chunk, TProtoStringType* out_error);
+
+ // Should be called to finish parsing (after all input has been provided via
+ // successful calls to ParseChunk(), calling after a ParseChunk() failure is
+ // undefined). Returns success/failure.
+ bool Finish(TProtoStringType* out_error);
+
+ int last_line() const { return line_; }
+
+ private:
+ LineConsumer* line_consumer_;
+ int line_;
+ TProtoStringType leftover_;
+};
+
+bool Parser::ParseChunk(y_absl::string_view chunk, TProtoStringType* out_error) {
+ y_absl::string_view full_chunk;
+ if (!leftover_.empty()) {
+ leftover_ += TProtoStringType(chunk);
+ full_chunk = y_absl::string_view(leftover_);
+ } else {
+ full_chunk = chunk;
+ }
+
+ y_absl::string_view line;
+ while (ReadLine(&full_chunk, &line)) {
+ ++line_;
+ RemoveComment(&line);
+ line = y_absl::StripAsciiWhitespace(line);
+ if (!line.empty() && !line_consumer_->ConsumeLine(line, out_error)) {
+ if (out_error->empty()) {
+ *out_error = "ConsumeLine failed without setting an error.";
+ }
+ leftover_.clear();
+ return false;
+ }
+ }
+
+ if (full_chunk.empty()) {
+ leftover_.clear();
+ } else {
+ leftover_ = TProtoStringType(full_chunk);
+ }
+ return true;
+}
+
+bool Parser::Finish(TProtoStringType* out_error) {
+ // If there is still something to go, flush it with a newline.
+ if (!leftover_.empty() && !ParseChunk("\n", out_error)) {
+ return false;
+ }
+ // This really should never fail if ParseChunk succeeded, but check to be
+ // sure.
+ if (!leftover_.empty()) {
+ *out_error = "ParseSimple Internal error: finished with pending data.";
+ return false;
+ }
+ return true;
+}
+
+} // namespace
+
+bool ParseSimpleFile(y_absl::string_view path, LineConsumer* line_consumer,
+ TProtoStringType* out_error) {
+ int fd;
+ do {
+ fd = posix::open(TProtoStringType(path).c_str(), O_RDONLY);
+ } while (fd < 0 && errno == EINTR);
+ if (fd < 0) {
+ *out_error =
+ y_absl::StrCat("error: Unable to open \"", path, "\", ", strerror(errno));
+ return false;
+ }
+ io::FileInputStream file_stream(fd);
+ file_stream.SetCloseOnDelete(true);
+
+ return ParseSimpleStream(file_stream, path, line_consumer, out_error);
+}
+
+bool ParseSimpleStream(io::ZeroCopyInputStream& input_stream,
+ y_absl::string_view stream_name,
+ LineConsumer* line_consumer, TProtoStringType* out_error) {
+ TProtoStringType local_error;
+ Parser parser(line_consumer);
+ const void* buf;
+ int buf_len;
+ while (input_stream.Next(&buf, &buf_len)) {
+ if (buf_len == 0) {
+ continue;
+ }
+
+ if (!parser.ParseChunk(
+ y_absl::string_view(static_cast<const char*>(buf), buf_len),
+ &local_error)) {
+ *out_error = y_absl::StrCat("error: ", stream_name, " Line ",
+ parser.last_line(), ", ", local_error);
+ return false;
+ }
+ }
+ if (!parser.Finish(&local_error)) {
+ *out_error = y_absl::StrCat("error: ", stream_name, " Line ",
+ parser.last_line(), ", ", local_error);
+ return false;
+ }
+ return true;
+}
+
+} // namespace objectivec
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/line_consumer.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/line_consumer.h
new file mode 100644
index 00000000000..668fdb1d126
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/line_consumer.h
@@ -0,0 +1,74 @@
+// 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_OBJECTIVEC_LINE_CONSUMER_H__
+#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_LINE_CONSUMER_H__
+
+#include <string>
+#include <vector>
+
+#include "google/protobuf/io/zero_copy_stream.h"
+
+// Must be included last
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace objectivec {
+
+// TODO(b/250947994): PROTOC_EXPORT is only used to allow the CMake build to
+// find/link these in the unittest, this is not public api.
+
+// Helper for parsing simple files.
+class PROTOC_EXPORT LineConsumer {
+ public:
+ LineConsumer() = default;
+ virtual ~LineConsumer() = default;
+ virtual bool ConsumeLine(y_absl::string_view line, TProtoStringType* out_error) = 0;
+};
+
+bool PROTOC_EXPORT ParseSimpleFile(y_absl::string_view path,
+ LineConsumer* line_consumer,
+ TProtoStringType* out_error);
+
+bool PROTOC_EXPORT ParseSimpleStream(io::ZeroCopyInputStream& input_stream,
+ y_absl::string_view stream_name,
+ LineConsumer* line_consumer,
+ TProtoStringType* out_error);
+
+} // namespace objectivec
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_LINE_CONSUMER_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/map_field.cc
index 933f0ce73d1..96b777027c6 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/map_field.cc
@@ -28,12 +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.
-#include <map>
+#include "google/protobuf/compiler/objectivec/map_field.h"
+
#include <string>
+#include <vector>
-#include <google/protobuf/compiler/objectivec/objectivec_map_field.h>
-#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
-#include <google/protobuf/io/printer.h>
+#include "y_absl/container/btree_set.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/match.h"
+#include "google/protobuf/compiler/objectivec/helpers.h"
+#include "google/protobuf/compiler/objectivec/names.h"
namespace google {
namespace protobuf {
@@ -75,16 +79,15 @@ const char* MapEntryTypeName(const FieldDescriptor* descriptor, bool isKey) {
// Some compilers report reaching end of function even though all cases of
// the enum are handed in the switch.
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return NULL;
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
+ return nullptr;
}
} // namespace
MapFieldGenerator::MapFieldGenerator(const FieldDescriptor* descriptor)
: RepeatedFieldGenerator(descriptor) {
- const FieldDescriptor* key_descriptor =
- descriptor->message_type()->map_key();
+ 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));
@@ -96,21 +99,24 @@ MapFieldGenerator::MapFieldGenerator(const FieldDescriptor* descriptor)
// Build custom field flags.
std::vector<TProtoStringType> field_flags;
- field_flags.push_back("GPBFieldMapKey" + GetCapitalizedType(key_descriptor));
+ field_flags.push_back(
+ y_absl::StrCat("GPBFieldMapKey", GetCapitalizedType(key_descriptor)));
// Pull over the current text format custom name values that was calculated.
- if (variables_["fieldflags"].find("GPBFieldTextFormatNameCustom") !=
- TProtoStringType::npos) {
+ if (y_absl::StrContains(variables_["fieldflags"],
+ "GPBFieldTextFormatNameCustom")) {
field_flags.push_back("GPBFieldTextFormatNameCustom");
}
// Pull over some info from the value's flags.
const TProtoStringType& value_field_flags =
value_field_generator_->variable("fieldflags");
- if (value_field_flags.find("GPBFieldHasDefaultValue") != TProtoStringType::npos) {
+ if (y_absl::StrContains(value_field_flags, "GPBFieldHasDefaultValue")) {
field_flags.push_back("GPBFieldHasDefaultValue");
}
- if (value_field_flags.find("GPBFieldHasEnumDescriptor") !=
- TProtoStringType::npos) {
+ if (y_absl::StrContains(value_field_flags, "GPBFieldHasEnumDescriptor")) {
field_flags.push_back("GPBFieldHasEnumDescriptor");
+ if (y_absl::StrContains(value_field_flags, "GPBFieldClosedEnum")) {
+ field_flags.push_back("GPBFieldClosedEnum");
+ }
}
variables_["fieldflags"] = BuildFlagsString(FLAGTYPE_FIELD, field_flags);
@@ -124,18 +130,17 @@ MapFieldGenerator::MapFieldGenerator(const FieldDescriptor* descriptor)
value_is_object_type) {
variables_["array_storage_type"] = "NSMutableDictionary";
variables_["array_property_type"] =
- "NSMutableDictionary<NSString*, " +
- value_field_generator_->variable("storage_type") + "*>";
+ y_absl::StrCat("NSMutableDictionary<NSString*, ",
+ value_field_generator_->variable("storage_type"), "*>");
} else {
- TProtoStringType class_name("GPB");
- class_name += MapEntryTypeName(key_descriptor, true);
- class_name += MapEntryTypeName(value_descriptor, false);
- class_name += "Dictionary";
+ TProtoStringType class_name =
+ y_absl::StrCat("GPB", MapEntryTypeName(key_descriptor, true),
+ MapEntryTypeName(value_descriptor, false), "Dictionary");
variables_["array_storage_type"] = class_name;
if (value_is_object_type) {
variables_["array_property_type"] =
- class_name + "<" +
- value_field_generator_->variable("storage_type") + "*>";
+ y_absl::StrCat(class_name, "<",
+ value_field_generator_->variable("storage_type"), "*>");
}
}
@@ -145,48 +150,57 @@ MapFieldGenerator::MapFieldGenerator(const FieldDescriptor* descriptor)
value_field_generator_->variable("dataTypeSpecific_value");
}
-MapFieldGenerator::~MapFieldGenerator() {}
-
-void MapFieldGenerator::FinishInitialization(void) {
+void MapFieldGenerator::FinishInitialization() {
RepeatedFieldGenerator::FinishInitialization();
// Use the array_comment support in RepeatedFieldGenerator to output what the
// values in the map are.
const FieldDescriptor* value_descriptor =
descriptor_->message_type()->map_value();
if (GetObjectiveCType(value_descriptor) == OBJECTIVECTYPE_ENUM) {
+ TProtoStringType name = variables_["name"];
variables_["array_comment"] =
- "// |" + variables_["name"] + "| values are |" + value_field_generator_->variable("storage_type") + "|\n";
+ y_absl::StrCat("// |", name, "| values are |",
+ value_field_generator_->variable("storage_type"), "|\n");
}
}
void MapFieldGenerator::DetermineForwardDeclarations(
- std::set<TProtoStringType>* fwd_decls,
+ y_absl::btree_set<TProtoStringType>* fwd_decls,
bool include_external_types) const {
- RepeatedFieldGenerator::DetermineForwardDeclarations(
- fwd_decls, include_external_types);
+ RepeatedFieldGenerator::DetermineForwardDeclarations(fwd_decls,
+ include_external_types);
const FieldDescriptor* value_descriptor =
descriptor_->message_type()->map_value();
+ // NOTE: Maps with values of enums don't have to worry about adding the
+ // forward declaration because `GPB*EnumDictionary` isn't generic to the
+ // specific enum (like say `NSDictionary<String, MyMessage>`) and thus doesn't
+ // reference the type in the header.
+ if (GetObjectiveCType(value_descriptor) != OBJECTIVECTYPE_MESSAGE) {
+ return;
+ }
+
+ const Descriptor* value_msg_descriptor = value_descriptor->message_type();
+
// 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())) {
+ if ((include_external_types &&
+ !IsProtobufLibraryBundledProtoFile(value_msg_descriptor->file())) ||
+ descriptor_->file() == value_msg_descriptor->file()) {
const TProtoStringType& value_storage_type =
value_field_generator_->variable("storage_type");
- fwd_decls->insert("@class " + value_storage_type);
+ fwd_decls->insert(y_absl::StrCat("@class ", value_storage_type, ";"));
}
}
void MapFieldGenerator::DetermineObjectiveCClassDefinitions(
- std::set<TProtoStringType>* fwd_decls) const {
+ y_absl::btree_set<TProtoStringType>* fwd_decls) const {
// Class name is already in "storage_type".
const FieldDescriptor* value_descriptor =
descriptor_->message_type()->map_value();
if (GetObjectiveCType(value_descriptor) == OBJECTIVECTYPE_MESSAGE) {
- fwd_decls->insert(ObjCClassDeclaration(
- value_field_generator_->variable("storage_type")));
+ 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/map_field.h
index a75aa961d8f..d3ceb070d33 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_map_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/map_field.h
@@ -31,9 +31,11 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_MAP_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_MAP_FIELD_H__
-#include <map>
+#include <memory>
#include <string>
-#include <google/protobuf/compiler/objectivec/objectivec_field.h>
+
+#include "y_absl/container/btree_set.h"
+#include "google/protobuf/compiler/objectivec/field.h"
namespace google {
namespace protobuf {
@@ -44,20 +46,19 @@ class MapFieldGenerator : public RepeatedFieldGenerator {
friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field);
public:
- virtual void FinishInitialization(void) override;
+ void FinishInitialization() override;
MapFieldGenerator(const MapFieldGenerator&) = delete;
MapFieldGenerator& operator=(const MapFieldGenerator&) = delete;
protected:
explicit MapFieldGenerator(const FieldDescriptor* descriptor);
- virtual ~MapFieldGenerator();
+ ~MapFieldGenerator() override = default;
- virtual void DetermineObjectiveCClassDefinitions(
- std::set<TProtoStringType>* fwd_decls) const override;
- virtual void DetermineForwardDeclarations(
- std::set<TProtoStringType>* fwd_decls,
- bool include_external_types) const override;
+ void DetermineObjectiveCClassDefinitions(
+ y_absl::btree_set<TProtoStringType>* fwd_decls) const override;
+ void DetermineForwardDeclarations(y_absl::btree_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/message.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/message.cc
new file mode 100644
index 00000000000..089314d3611
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/message.cc
@@ -0,0 +1,631 @@
+// 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/objectivec/message.h"
+
+#include <algorithm>
+#include <iostream>
+#include <memory>
+#include <sstream>
+#include <string>
+#include <vector>
+
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/escaping.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/objectivec/extension.h"
+#include "google/protobuf/compiler/objectivec/helpers.h"
+#include "google/protobuf/compiler/objectivec/names.h"
+#include "google/protobuf/compiler/objectivec/oneof.h"
+#include "google/protobuf/compiler/objectivec/text_format_decode_data.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/printer.h"
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace objectivec {
+
+namespace {
+
+bool IsMapEntryMessage(const Descriptor* descriptor) {
+ return descriptor->options().map_entry();
+}
+
+struct FieldOrderingByNumber {
+ inline bool operator()(const FieldDescriptor* a,
+ const FieldDescriptor* b) const {
+ return a->number() < b->number();
+ }
+};
+
+int OrderGroupForFieldDescriptor(const FieldDescriptor* descriptor) {
+ // The first item in the object structure is our uint32[] for has bits.
+ // We then want to order things to make the instances as small as
+ // possible. So we follow the has bits with:
+ // 1. Anything always 4 bytes - float, *32, enums
+ // 2. Anything that is always a pointer (they will be 8 bytes on 64 bit
+ // builds and 4 bytes on 32bit builds.
+ // 3. Anything always 8 bytes - double, *64
+ //
+ // NOTE: Bools aren't listed, they were stored in the has bits.
+ //
+ // Why? Using 64bit builds as an example, this means worse case, we have
+ // enough bools that we overflow 1 byte from 4 byte alignment, so 3 bytes
+ // are wasted before the 4 byte values. Then if we have an odd number of
+ // those 4 byte values, the 8 byte values will be pushed down by 32bits to
+ // keep them aligned. But the structure will end 8 byte aligned, so no
+ // waste on the end. If you did the reverse order, you could waste 4 bytes
+ // before the first 8 byte value (after the has array), then a single
+ // bool on the end would need 7 bytes of padding to make the overall
+ // structure 8 byte aligned; so 11 bytes, wasted total.
+
+ // Anything repeated is a GPB*Array/NSArray, so pointer.
+ if (descriptor->is_repeated()) {
+ return 3;
+ }
+
+ switch (descriptor->type()) {
+ // All always 8 bytes.
+ case FieldDescriptor::TYPE_DOUBLE:
+ case FieldDescriptor::TYPE_INT64:
+ case FieldDescriptor::TYPE_SINT64:
+ case FieldDescriptor::TYPE_UINT64:
+ case FieldDescriptor::TYPE_SFIXED64:
+ case FieldDescriptor::TYPE_FIXED64:
+ return 4;
+
+ // Pointers (string and bytes are NSString and NSData); 8 or 4 bytes
+ // depending on the build architecture.
+ case FieldDescriptor::TYPE_GROUP:
+ case FieldDescriptor::TYPE_MESSAGE:
+ case FieldDescriptor::TYPE_STRING:
+ case FieldDescriptor::TYPE_BYTES:
+ return 3;
+
+ // All always 4 bytes (enums are int32s).
+ case FieldDescriptor::TYPE_FLOAT:
+ case FieldDescriptor::TYPE_INT32:
+ case FieldDescriptor::TYPE_SINT32:
+ case FieldDescriptor::TYPE_UINT32:
+ case FieldDescriptor::TYPE_SFIXED32:
+ case FieldDescriptor::TYPE_FIXED32:
+ case FieldDescriptor::TYPE_ENUM:
+ return 2;
+
+ // 0 bytes. Stored in the has bits.
+ case FieldDescriptor::TYPE_BOOL:
+ return 99; // End of the list (doesn't really matter).
+ }
+
+ // Some compilers report reaching end of function even though all cases of
+ // the enum are handed in the switch.
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
+ return 0;
+}
+
+struct FieldOrderingByStorageSize {
+ inline bool operator()(const FieldDescriptor* a,
+ const FieldDescriptor* b) const {
+ // Order by grouping.
+ const int order_group_a = OrderGroupForFieldDescriptor(a);
+ const int order_group_b = OrderGroupForFieldDescriptor(b);
+ if (order_group_a != order_group_b) {
+ return order_group_a < order_group_b;
+ }
+ // Within the group, order by field number (provides stable ordering).
+ return a->number() < b->number();
+ }
+};
+
+struct ExtensionRangeOrdering {
+ bool operator()(const Descriptor::ExtensionRange* a,
+ const Descriptor::ExtensionRange* b) const {
+ return a->start < b->start;
+ }
+};
+
+// This is a reduced case of Descriptor::ExtensionRange with just start and end.
+struct SimpleExtensionRange {
+ SimpleExtensionRange(int start, int end) : start(start), end(end){};
+ int start; // inclusive
+ int end; // exclusive
+
+ // Descriptors expose extension ranges in the order they were defined in the
+ // file, but this reorders and merges the ranges that are contiguous (i.e. -
+ // [(21,30),(10,20)] -> [(10,30)])
+ static std::vector<SimpleExtensionRange> Normalize(
+ const Descriptor* descriptor) {
+ 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(),
+ ExtensionRangeOrdering());
+
+ std::vector<SimpleExtensionRange> result;
+ result.reserve(sorted_extensions.size());
+ for (const auto ext : sorted_extensions) {
+ if (!result.empty() && result.back().end == ext->start) {
+ result.back().end = ext->end;
+ } else {
+ result.emplace_back(ext->start, ext->end);
+ }
+ }
+ return result;
+ }
+};
+
+// Sort the fields of the given Descriptor by number into a new[]'d array
+// and return it.
+const FieldDescriptor** SortFieldsByNumber(const Descriptor* descriptor) {
+ const FieldDescriptor** fields =
+ new const FieldDescriptor*[descriptor->field_count()];
+ for (int i = 0; i < descriptor->field_count(); i++) {
+ fields[i] = descriptor->field(i);
+ }
+ std::sort(fields, fields + descriptor->field_count(),
+ FieldOrderingByNumber());
+ return fields;
+}
+
+// Sort the fields of the given Descriptor by storage size into a new[]'d
+// array and return it.
+const FieldDescriptor** SortFieldsByStorageSize(const Descriptor* descriptor) {
+ const FieldDescriptor** fields =
+ new const FieldDescriptor*[descriptor->field_count()];
+ for (int i = 0; i < descriptor->field_count(); i++) {
+ fields[i] = descriptor->field(i);
+ }
+ std::sort(fields, fields + descriptor->field_count(),
+ FieldOrderingByStorageSize());
+ return fields;
+}
+
+} // namespace
+
+MessageGenerator::MessageGenerator(const TProtoStringType& file_description_name,
+ const Descriptor* descriptor)
+ : file_description_name_(file_description_name),
+ descriptor_(descriptor),
+ field_generators_(descriptor),
+ class_name_(ClassName(descriptor_)),
+ deprecated_attribute_(GetOptionalDeprecatedAttribute(
+ descriptor, descriptor->file(), false, true)) {
+ for (int i = 0; i < descriptor_->real_oneof_decl_count(); i++) {
+ oneof_generators_.push_back(
+ std::make_unique<OneofGenerator>(descriptor_->oneof_decl(i)));
+ }
+
+ // Assign has bits:
+ // 1. FieldGeneratorMap::CalculateHasBits() loops through the fields seeing
+ // who needs has bits and assigning them.
+ // 2. FieldGenerator::SetOneofIndexBase() overrides has_bit with a negative
+ // index that groups all the elements in the oneof.
+ size_t num_has_bits = field_generators_.CalculateHasBits();
+ size_t sizeof_has_storage = (num_has_bits + 31) / 32;
+ if (sizeof_has_storage == 0) {
+ // In the case where no field needs has bits, don't let the _has_storage_
+ // end up as zero length (zero length arrays are sort of a grey area
+ // since it has to be at the start of the struct). This also ensures a
+ // field with only oneofs keeps the required negative indices they need.
+ sizeof_has_storage = 1;
+ }
+ // Tell all the fields the oneof base.
+ for (const auto& generator : oneof_generators_) {
+ generator->SetOneofIndexBase(sizeof_has_storage);
+ }
+ field_generators_.SetOneofIndexBase(sizeof_has_storage);
+ // sizeof_has_storage needs enough bits for the single fields that aren't in
+ // any oneof, and then one int32 for each oneof (to store the field number).
+ sizeof_has_storage += oneof_generators_.size();
+
+ sizeof_has_storage_ = sizeof_has_storage;
+}
+
+void MessageGenerator::AddExtensionGenerators(
+ std::vector<std::unique_ptr<ExtensionGenerator>>* extension_generators) {
+ for (int i = 0; i < descriptor_->extension_count(); i++) {
+ extension_generators->push_back(std::make_unique<ExtensionGenerator>(
+ class_name_, descriptor_->extension(i)));
+ extension_generators_.push_back(extension_generators->back().get());
+ }
+}
+
+void MessageGenerator::DetermineForwardDeclarations(
+ y_absl::btree_set<TProtoStringType>* fwd_decls,
+ bool include_external_types) const {
+ if (IsMapEntryMessage(descriptor_)) {
+ return;
+ }
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* fieldDescriptor = descriptor_->field(i);
+ field_generators_.get(fieldDescriptor)
+ .DetermineForwardDeclarations(fwd_decls, include_external_types);
+ }
+}
+
+void MessageGenerator::DetermineObjectiveCClassDefinitions(
+ y_absl::btree_set<TProtoStringType>* fwd_decls) const {
+ if (!IsMapEntryMessage(descriptor_)) {
+ // Forward declare this class, as a linker symbol, so the symbol can be used
+ // to reference the class instead of calling +class later.
+ fwd_decls->insert(ObjCClassDeclaration(class_name_));
+
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* fieldDescriptor = descriptor_->field(i);
+ field_generators_.get(fieldDescriptor)
+ .DetermineObjectiveCClassDefinitions(fwd_decls);
+ }
+ }
+
+ const Descriptor* containing_descriptor = descriptor_->containing_type();
+ if (containing_descriptor != nullptr) {
+ TProtoStringType containing_class = ClassName(containing_descriptor);
+ fwd_decls->insert(ObjCClassDeclaration(containing_class));
+ }
+}
+
+void MessageGenerator::GenerateMessageHeader(io::Printer* printer) const {
+ // This a a map entry message, just recurse and do nothing directly.
+ if (IsMapEntryMessage(descriptor_)) {
+ return;
+ }
+
+ printer->Print(
+ // clang-format off
+ "#pragma mark - $classname$\n"
+ "\n",
+ // clang-format on
+ "classname", class_name_);
+
+ if (descriptor_->field_count()) {
+ std::unique_ptr<const FieldDescriptor*[]> sorted_fields(
+ SortFieldsByNumber(descriptor_));
+
+ printer->Print("typedef GPB_ENUM($classname$_FieldNumber) {\n", "classname",
+ class_name_);
+ printer->Indent();
+
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ field_generators_.get(sorted_fields[i])
+ .GenerateFieldNumberConstant(printer);
+ }
+
+ printer->Outdent();
+ printer->Print("};\n\n");
+ }
+
+ for (const auto& generator : oneof_generators_) {
+ generator->GenerateCaseEnum(printer);
+ }
+
+ TProtoStringType message_comments;
+ SourceLocation location;
+ if (descriptor_->GetSourceLocation(&location)) {
+ message_comments = BuildCommentsString(location, false);
+ } else {
+ message_comments = "";
+ }
+
+ printer->Print(
+ // clang-format off
+ "$comments$$deprecated_attribute$GPB_FINAL @interface $classname$ : GPBMessage\n\n",
+ // clang-format on
+ "classname", class_name_, "deprecated_attribute", deprecated_attribute_,
+ "comments", message_comments);
+
+ std::vector<char> seen_oneofs(oneof_generators_.size(), 0);
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = descriptor_->field(i);
+ const OneofDescriptor* oneof = field->real_containing_oneof();
+ if (oneof) {
+ const int oneof_index = oneof->index();
+ if (!seen_oneofs[oneof_index]) {
+ seen_oneofs[oneof_index] = 1;
+ oneof_generators_[oneof_index]->GeneratePublicCasePropertyDeclaration(
+ printer);
+ }
+ }
+ field_generators_.get(field).GeneratePropertyDeclaration(printer);
+ }
+
+ printer->Print("@end\n\n");
+
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ field_generators_.get(descriptor_->field(i))
+ .GenerateCFunctionDeclarations(printer);
+ }
+
+ if (!oneof_generators_.empty()) {
+ for (const auto& generator : oneof_generators_) {
+ generator->GenerateClearFunctionDeclaration(printer);
+ }
+ printer->Print("\n");
+ }
+
+ if (descriptor_->extension_count() > 0) {
+ printer->Print("@interface $classname$ (DynamicMethods)\n\n", "classname",
+ class_name_);
+ for (const auto generator : extension_generators_) {
+ generator->GenerateMembersHeader(printer);
+ }
+ printer->Print("@end\n\n");
+ }
+}
+
+void MessageGenerator::GenerateSource(io::Printer* printer) const {
+ if (IsMapEntryMessage(descriptor_)) {
+ return;
+ }
+ printer->Print(
+ // clang-format off
+ "#pragma mark - $classname$\n"
+ "\n",
+ // clang-format on
+ "classname", class_name_);
+
+ if (!deprecated_attribute_.empty()) {
+ // No warnings when compiling the impl of this deprecated class.
+ // clang-format off
+ printer->Print(
+ "#pragma clang diagnostic push\n"
+ "#pragma clang diagnostic ignored \"-Wdeprecated-implementations\"\n"
+ "\n");
+ // clang-format on
+ }
+
+ printer->Print("@implementation $classname$\n\n", "classname", class_name_);
+
+ for (const auto& generator : oneof_generators_) {
+ generator->GeneratePropertyImplementation(printer);
+ }
+
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ field_generators_.get(descriptor_->field(i))
+ .GeneratePropertyImplementation(printer);
+ }
+
+ std::unique_ptr<const FieldDescriptor*[]> sorted_fields(
+ SortFieldsByNumber(descriptor_));
+ std::unique_ptr<const FieldDescriptor*[]> size_order_fields(
+ SortFieldsByStorageSize(descriptor_));
+
+ std::vector<SimpleExtensionRange> sorted_extensions(
+ SimpleExtensionRange::Normalize(descriptor_));
+
+ printer->Print(
+ // clang-format off
+ "\n"
+ "typedef struct $classname$__storage_ {\n"
+ " arc_ui32 _has_storage_[$sizeof_has_storage$];\n",
+ // clang-format on
+ "classname", class_name_, "sizeof_has_storage",
+ y_absl::StrCat(sizeof_has_storage_));
+ printer->Indent();
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ field_generators_.get(size_order_fields[i])
+ .GenerateFieldStorageDeclaration(printer);
+ }
+ printer->Outdent();
+
+ printer->Print("} $classname$__storage_;\n\n", "classname", class_name_);
+
+ // clang-format off
+ printer->Print(
+ "// This method is threadsafe because it is initially called\n"
+ "// in +initialize for each subclass.\n"
+ "+ (GPBDescriptor *)descriptor {\n"
+ " static GPBDescriptor *descriptor = nil;\n"
+ " if (!descriptor) {\n");
+ // clang-format on
+
+ // If the message scopes extensions, trigger the root class
+ // +initialize/+extensionRegistry as that is where the runtime support for
+ // extensions lives.
+ if (descriptor_->extension_count() > 0) {
+ // clang-format off
+ printer->Print(
+ " // Start up the root class to support the scoped extensions.\n"
+ " __unused Class rootStartup = [$root_class_name$ class];\n",
+ "root_class_name", FileClassName(descriptor_->file()));
+ // clang-format on
+ } else {
+ // The Root class has a debug runtime check, so if not starting that
+ // up, add the check.
+ printer->Print(" GPB_DEBUG_CHECK_RUNTIME_VERSIONS();\n");
+ }
+
+ TextFormatDecodeData text_format_decode_data;
+ bool has_fields = descriptor_->field_count() > 0;
+ bool need_defaults = field_generators_.DoesAnyFieldHaveNonZeroDefault();
+ TProtoStringType field_description_type;
+ if (need_defaults) {
+ field_description_type = "GPBMessageFieldDescriptionWithDefault";
+ } else {
+ field_description_type = "GPBMessageFieldDescription";
+ }
+ if (has_fields) {
+ printer->Indent();
+ printer->Indent();
+ printer->Print("static $field_description_type$ fields[] = {\n",
+ "field_description_type", field_description_type);
+ printer->Indent();
+ for (int i = 0; i < descriptor_->field_count(); ++i) {
+ const FieldGenerator& field_generator =
+ field_generators_.get(sorted_fields[i]);
+ field_generator.GenerateFieldDescription(printer, need_defaults);
+ if (field_generator.needs_textformat_name_support()) {
+ text_format_decode_data.AddString(sorted_fields[i]->number(),
+ field_generator.generated_objc_name(),
+ field_generator.raw_field_name());
+ }
+ }
+ printer->Outdent();
+ printer->Print("};\n");
+ printer->Outdent();
+ printer->Outdent();
+ }
+
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars;
+ vars["classname"] = class_name_;
+ vars["message_name"] = descriptor_->name();
+ vars["class_reference"] = ObjCClass(class_name_);
+ vars["file_description_name"] = file_description_name_;
+ vars["fields"] = has_fields ? "fields" : "NULL";
+ if (has_fields) {
+ vars["fields_count"] = y_absl::StrCat("(arc_ui32)(sizeof(fields) / sizeof(",
+ field_description_type, "))");
+ } else {
+ vars["fields_count"] = "0";
+ }
+
+ std::vector<TProtoStringType> init_flags;
+ init_flags.push_back("GPBDescriptorInitializationFlag_UsesClassRefs");
+ init_flags.push_back("GPBDescriptorInitializationFlag_Proto3OptionalKnown");
+ init_flags.push_back(
+ "GPBDescriptorInitializationFlag_ClosedEnumSupportKnown");
+ if (need_defaults) {
+ init_flags.push_back("GPBDescriptorInitializationFlag_FieldsWithDefault");
+ }
+ if (descriptor_->options().message_set_wire_format()) {
+ init_flags.push_back("GPBDescriptorInitializationFlag_WireFormat");
+ }
+ vars["init_flags"] =
+ BuildFlagsString(FLAGTYPE_DESCRIPTOR_INITIALIZATION, init_flags);
+
+ // clang-format off
+ printer->Print(
+ vars,
+ " GPBDescriptor *localDescriptor =\n"
+ " [GPBDescriptor allocDescriptorForClass:$class_reference$\n"
+ " messageName:@\"$message_name$\"\n"
+ " fileDescription:&$file_description_name$\n"
+ " fields:$fields$\n"
+ " fieldCount:$fields_count$\n"
+ " storageSize:sizeof($classname$__storage_)\n"
+ " flags:$init_flags$];\n");
+ // clang-format on
+ if (!oneof_generators_.empty()) {
+ printer->Print(" static const char *oneofs[] = {\n");
+ for (const auto& generator : oneof_generators_) {
+ printer->Print(" \"$name$\",\n", "name",
+ generator->DescriptorName());
+ }
+ printer->Print(
+ // clang-format off
+ " };\n"
+ " [localDescriptor setupOneofs:oneofs\n"
+ " count:(arc_ui32)(sizeof(oneofs) / sizeof(char*))\n"
+ " firstHasIndex:$first_has_index$];\n",
+ // clang-format on
+ "first_has_index", oneof_generators_[0]->HasIndexAsString());
+ }
+ if (text_format_decode_data.num_entries() != 0) {
+ const TProtoStringType text_format_data_str(text_format_decode_data.Data());
+ // clang-format off
+ printer->Print(
+ "#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS\n"
+ " static const char *extraTextFormatInfo =");
+ // clang-format on
+ static const int kBytesPerLine = 40; // allow for escaping
+ for (int i = 0; i < text_format_data_str.size(); i += kBytesPerLine) {
+ printer->Print("\n \"$data$\"", "data",
+ EscapeTrigraphs(y_absl::CEscape(
+ text_format_data_str.substr(i, kBytesPerLine))));
+ }
+ // clang-format off
+ printer->Print(
+ ";\n"
+ " [localDescriptor setupExtraTextInfo:extraTextFormatInfo];\n"
+ "#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS\n");
+ // clang-format on
+ }
+ if (!sorted_extensions.empty()) {
+ printer->Print(" static const GPBExtensionRange ranges[] = {\n");
+ for (const auto& extension_range : sorted_extensions) {
+ printer->Print(" { .start = $start$, .end = $end$ },\n", "start",
+ y_absl::StrCat(extension_range.start), "end",
+ y_absl::StrCat(extension_range.end));
+ }
+ // clang-format off
+ printer->Print(
+ " };\n"
+ " [localDescriptor setupExtensionRanges:ranges\n"
+ " count:(arc_ui32)(sizeof(ranges) / sizeof(GPBExtensionRange))];\n");
+ // clang-format on
+ }
+ if (descriptor_->containing_type() != nullptr) {
+ TProtoStringType containing_class = ClassName(descriptor_->containing_type());
+ TProtoStringType parent_class_ref = ObjCClass(containing_class);
+ printer->Print(
+ // clang-format off
+ " [localDescriptor setupContainingMessageClass:$parent_class_ref$];\n",
+ // clang-format on
+ "parent_class_ref", parent_class_ref);
+ }
+ // clang-format off
+ printer->Print(
+ " #if defined(DEBUG) && DEBUG\n"
+ " NSAssert(descriptor == nil, @\"Startup recursed!\");\n"
+ " #endif // DEBUG\n"
+ " descriptor = localDescriptor;\n"
+ " }\n"
+ " return descriptor;\n"
+ "}\n\n"
+ "@end\n\n");
+ // clang-format on
+
+ if (!deprecated_attribute_.empty()) {
+ // clang-format off
+ printer->Print(
+ "#pragma clang diagnostic pop\n"
+ "\n");
+ // clang-format on
+ }
+
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ field_generators_.get(descriptor_->field(i))
+ .GenerateCFunctionImplementations(printer);
+ }
+
+ for (const auto& generator : oneof_generators_) {
+ generator->GenerateClearFunctionImplementation(printer);
+ }
+}
+
+} // namespace objectivec
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/message.h
index 71eec0d0c71..c4698371b7f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/message.h
@@ -31,13 +31,16 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_MESSAGE_H__
#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_MESSAGE_H__
+#include <cstddef>
+#include <memory>
#include <string>
-#include <set>
#include <vector>
-#include <google/protobuf/compiler/objectivec/objectivec_field.h>
-#include <google/protobuf/compiler/objectivec/objectivec_oneof.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/io/printer.h>
+
+#include "y_absl/container/btree_set.h"
+#include "google/protobuf/compiler/objectivec/field.h"
+#include "google/protobuf/compiler/objectivec/oneof.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
@@ -45,50 +48,39 @@ namespace compiler {
namespace objectivec {
class ExtensionGenerator;
-class EnumGenerator;
class MessageGenerator {
public:
- MessageGenerator(const TProtoStringType& root_classname,
+ MessageGenerator(const TProtoStringType& file_description_name,
const Descriptor* descriptor);
- ~MessageGenerator();
+ ~MessageGenerator() = default;
MessageGenerator(const MessageGenerator&) = delete;
MessageGenerator& operator=(const MessageGenerator&) = delete;
- void GenerateStaticVariablesInitialization(io::Printer* printer);
- void GenerateEnumHeader(io::Printer* printer);
- void GenerateMessageHeader(io::Printer* printer);
- void GenerateSource(io::Printer* printer);
- void GenerateExtensionRegistrationSource(io::Printer* printer);
- void DetermineObjectiveCClassDefinitions(std::set<TProtoStringType>* fwd_decls);
- void DetermineForwardDeclarations(std::set<TProtoStringType>* fwd_decls,
- bool include_external_types);
+ void AddExtensionGenerators(
+ std::vector<std::unique_ptr<ExtensionGenerator>>* extension_generators);
+
+ void GenerateMessageHeader(io::Printer* printer) const;
+ void GenerateSource(io::Printer* printer) const;
+ void DetermineObjectiveCClassDefinitions(
+ y_absl::btree_set<TProtoStringType>* fwd_decls) const;
+ void DetermineForwardDeclarations(y_absl::btree_set<TProtoStringType>* fwd_decls,
+ bool include_external_types) const;
// Checks if the message or a nested message includes a oneof definition.
- bool IncludesOneOfDefinition() const;
+ bool IncludesOneOfDefinition() const { return !oneof_generators_.empty(); }
private:
- void GenerateParseFromMethodsHeader(io::Printer* printer);
-
- void GenerateSerializeOneFieldSource(io::Printer* printer,
- const FieldDescriptor* field);
- void GenerateSerializeOneExtensionRangeSource(
- io::Printer* printer, const Descriptor::ExtensionRange* range);
-
- void GenerateMessageDescriptionSource(io::Printer* printer);
- void GenerateDescriptionOneFieldSource(io::Printer* printer,
- const FieldDescriptor* field);
-
const TProtoStringType root_classname_;
+ const TProtoStringType file_description_name_;
const Descriptor* descriptor_;
FieldGeneratorMap field_generators_;
const TProtoStringType class_name_;
const TProtoStringType deprecated_attribute_;
- std::vector<std::unique_ptr<ExtensionGenerator>> extension_generators_;
- std::vector<std::unique_ptr<EnumGenerator>> enum_generators_;
- std::vector<std::unique_ptr<MessageGenerator>> nested_message_generators_;
+ std::vector<const ExtensionGenerator*> extension_generators_;
std::vector<std::unique_ptr<OneofGenerator>> oneof_generators_;
+ size_t sizeof_has_storage_;
};
} // namespace objectivec
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/message_field.cc
index 8ae073a12ad..5156b4f21ff 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/message_field.cc
@@ -28,12 +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.
-#include <map>
+#include "google/protobuf/compiler/objectivec/message_field.h"
+
#include <string>
-#include <google/protobuf/compiler/objectivec/objectivec_message_field.h>
-#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
-#include <google/protobuf/io/printer.h>
+#include "y_absl/container/btree_set.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "google/protobuf/compiler/objectivec/helpers.h"
+#include "google/protobuf/compiler/objectivec/names.h"
namespace google {
namespace protobuf {
@@ -42,8 +44,9 @@ namespace objectivec {
namespace {
-void SetMessageVariables(const FieldDescriptor* descriptor,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+void SetMessageVariables(
+ const FieldDescriptor* descriptor,
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables) {
const TProtoStringType& message_type = ClassName(descriptor->message_type());
const TProtoStringType& containing_class =
ClassName(descriptor->containing_type());
@@ -62,26 +65,24 @@ MessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor)
SetMessageVariables(descriptor, &variables_);
}
-MessageFieldGenerator::~MessageFieldGenerator() {}
-
void MessageFieldGenerator::DetermineForwardDeclarations(
- std::set<TProtoStringType>* fwd_decls,
+ y_absl::btree_set<TProtoStringType>* fwd_decls,
bool include_external_types) const {
- ObjCObjFieldGenerator::DetermineForwardDeclarations(
- fwd_decls, include_external_types);
+ 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())) ||
+ 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"));
+ fwd_decls->insert(y_absl::StrCat("@class ", variable("storage_type"), ";"));
}
}
void MessageFieldGenerator::DetermineObjectiveCClassDefinitions(
- std::set<TProtoStringType>* fwd_decls) const {
+ y_absl::btree_set<TProtoStringType>* fwd_decls) const {
fwd_decls->insert(ObjCClassDeclaration(variable("storage_type")));
}
@@ -89,31 +90,30 @@ RepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator(
const FieldDescriptor* descriptor)
: RepeatedFieldGenerator(descriptor) {
SetMessageVariables(descriptor, &variables_);
+ TProtoStringType storage_type = variables_["storage_type"];
variables_["array_storage_type"] = "NSMutableArray";
variables_["array_property_type"] =
- "NSMutableArray<" + variables_["storage_type"] + "*>";
+ y_absl::StrCat("NSMutableArray<", storage_type, "*>");
}
-RepeatedMessageFieldGenerator::~RepeatedMessageFieldGenerator() {}
-
void RepeatedMessageFieldGenerator::DetermineForwardDeclarations(
- std::set<TProtoStringType>* fwd_decls,
+ y_absl::btree_set<TProtoStringType>* fwd_decls,
bool include_external_types) const {
- RepeatedFieldGenerator::DetermineForwardDeclarations(
- fwd_decls, include_external_types);
+ 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())) ||
+ 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"));
+ fwd_decls->insert(y_absl::StrCat("@class ", variable("storage_type"), ";"));
}
}
void RepeatedMessageFieldGenerator::DetermineObjectiveCClassDefinitions(
- std::set<TProtoStringType>* fwd_decls) const {
+ y_absl::btree_set<TProtoStringType>* fwd_decls) const {
fwd_decls->insert(ObjCClassDeclaration(variable("storage_type")));
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/message_field.h
index 50ddb633cc9..303b69a7c6c 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/message_field.h
@@ -31,9 +31,10 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_MESSAGE_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_MESSAGE_FIELD_H__
-#include <map>
#include <string>
-#include <google/protobuf/compiler/objectivec/objectivec_field.h>
+
+#include "y_absl/container/btree_set.h"
+#include "google/protobuf/compiler/objectivec/field.h"
namespace google {
namespace protobuf {
@@ -45,18 +46,16 @@ class MessageFieldGenerator : public ObjCObjFieldGenerator {
protected:
explicit MessageFieldGenerator(const FieldDescriptor* descriptor);
+ ~MessageFieldGenerator() override = default;
MessageFieldGenerator(const MessageFieldGenerator&) = delete;
MessageFieldGenerator& operator=(const MessageFieldGenerator&) = delete;
- virtual ~MessageFieldGenerator();
-
public:
- virtual void DetermineForwardDeclarations(
- std::set<TProtoStringType>* fwd_decls,
- bool include_external_types) const override;
- virtual void DetermineObjectiveCClassDefinitions(
- std::set<TProtoStringType>* fwd_decls) const override;
+ void DetermineForwardDeclarations(y_absl::btree_set<TProtoStringType>* fwd_decls,
+ bool include_external_types) const override;
+ void DetermineObjectiveCClassDefinitions(
+ y_absl::btree_set<TProtoStringType>* fwd_decls) const override;
};
class RepeatedMessageFieldGenerator : public RepeatedFieldGenerator {
@@ -64,17 +63,17 @@ class RepeatedMessageFieldGenerator : public RepeatedFieldGenerator {
protected:
explicit RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor);
- virtual ~RepeatedMessageFieldGenerator();
+ ~RepeatedMessageFieldGenerator() override = default;
RepeatedMessageFieldGenerator(const RepeatedMessageFieldGenerator&) = delete;
- RepeatedMessageFieldGenerator operator=(const RepeatedMessageFieldGenerator&) = delete;
+ RepeatedMessageFieldGenerator operator=(
+ const RepeatedMessageFieldGenerator&) = delete;
public:
- virtual void DetermineForwardDeclarations(
- std::set<TProtoStringType>* fwd_decls,
- bool include_external_types) const override;
- virtual void DetermineObjectiveCClassDefinitions(
- std::set<TProtoStringType>* fwd_decls) const override;
+ void DetermineForwardDeclarations(y_absl::btree_set<TProtoStringType>* fwd_decls,
+ bool include_external_types) const override;
+ void DetermineObjectiveCClassDefinitions(
+ y_absl::btree_set<TProtoStringType>* fwd_decls) const override;
};
} // namespace objectivec
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/names.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/names.cc
new file mode 100644
index 00000000000..3a3ee8ffd05
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/names.cc
@@ -0,0 +1,1247 @@
+// 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/objectivec/names.h"
+
+#include <algorithm>
+#include <climits>
+#include <fstream>
+#include <iostream>
+#include <ostream>
+#include <sstream>
+#include <string>
+#include <vector>
+
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_split.h"
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/compiler/objectivec/line_consumer.h"
+#include "google/protobuf/compiler/objectivec/nsobject_methods.h"
+#include "google/protobuf/descriptor.pb.h"
+
+// 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 errors.
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace objectivec {
+
+namespace {
+
+bool BoolFromEnvVar(const char* env_var, bool default_value) {
+ const char* value = getenv(env_var);
+ if (value) {
+ return TProtoStringType("YES") == y_absl::AsciiStrToUpper(value);
+ }
+ return default_value;
+}
+
+class SimpleLineCollector : public LineConsumer {
+ public:
+ explicit SimpleLineCollector(y_absl::flat_hash_set<TProtoStringType>* inout_set)
+ : set_(inout_set) {}
+
+ bool ConsumeLine(y_absl::string_view line, TProtoStringType* out_error) override {
+ set_->insert(TProtoStringType(line));
+ return true;
+ }
+
+ private:
+ y_absl::flat_hash_set<TProtoStringType>* set_;
+};
+
+class PackageToPrefixesCollector : public LineConsumer {
+ public:
+ PackageToPrefixesCollector(y_absl::string_view usage,
+ y_absl::flat_hash_map<TProtoStringType, TProtoStringType>*
+ inout_package_to_prefix_map)
+ : usage_(usage), prefix_map_(inout_package_to_prefix_map) {}
+
+ bool ConsumeLine(y_absl::string_view line, TProtoStringType* out_error) override;
+
+ private:
+ const TProtoStringType usage_;
+ y_absl::flat_hash_map<TProtoStringType, TProtoStringType>* prefix_map_;
+};
+
+class PrefixModeStorage {
+ public:
+ PrefixModeStorage();
+
+ y_absl::string_view package_to_prefix_mappings_path() const {
+ return package_to_prefix_mappings_path_;
+ }
+ void set_package_to_prefix_mappings_path(y_absl::string_view path) {
+ package_to_prefix_mappings_path_ = TProtoStringType(path);
+ package_to_prefix_map_.clear();
+ }
+
+ y_absl::string_view 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; }
+
+ y_absl::string_view exception_path() const { return exception_path_; }
+ void set_exception_path(y_absl::string_view path) {
+ exception_path_ = TProtoStringType(path);
+ exceptions_.clear();
+ }
+
+ bool is_package_exempted(y_absl::string_view package);
+
+ // When using a proto package as the prefix, this should be added as the
+ // prefix in front of it.
+ y_absl::string_view forced_package_prefix() const { return forced_prefix_; }
+ void set_forced_package_prefix(y_absl::string_view prefix) {
+ forced_prefix_ = TProtoStringType(prefix);
+ }
+
+ private:
+ bool use_package_name_;
+ y_absl::flat_hash_map<TProtoStringType, TProtoStringType> package_to_prefix_map_;
+ TProtoStringType package_to_prefix_mappings_path_;
+ TProtoStringType exception_path_;
+ TProtoStringType forced_prefix_;
+ y_absl::flat_hash_set<TProtoStringType> exceptions_;
+};
+
+PrefixModeStorage::PrefixModeStorage() {
+ // Even thought there are generation options, have an env back door since some
+ // of these helpers could be used in other plugins.
+
+ 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;
+ }
+
+ const char* prefix = getenv("GPB_OBJC_USE_PACKAGE_AS_PREFIX_PREFIX");
+ if (prefix) {
+ forced_prefix_ = prefix;
+ }
+}
+
+constexpr y_absl::string_view kNoPackagePrefix = "no_package:";
+
+y_absl::string_view 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 = y_absl::StrCat("protoc:0: warning: Failed to parse ",
+ "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.
+ const TProtoStringType lookup_key =
+ package.empty() ? y_absl::StrCat(kNoPackagePrefix, file->name()) : package;
+
+ auto 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(y_absl::string_view package) {
+ if (exceptions_.empty() && !exception_path_.empty()) {
+ TProtoStringType error_str;
+ SimpleLineCollector collector(&exceptions_);
+ if (!ParseSimpleFile(exception_path_, &collector, &error_str)) {
+ if (error_str.empty()) {
+ error_str = TProtoStringType("protoc:0: warning: Failed to parse") +
+ TProtoStringType(" package prefix exceptions file: ") +
+ exception_path_;
+ }
+ std::cerr << error_str << std::endl;
+ std::cerr.flush();
+ exceptions_.clear();
+ }
+
+ // If the file was empty put something in it so it doesn't get reloaded over
+ // and over.
+ if (exceptions_.empty()) {
+ exceptions_.insert("<not a real package>");
+ }
+ }
+
+ return exceptions_.contains(package);
+}
+
+PrefixModeStorage& g_prefix_mode = *new PrefixModeStorage();
+
+} // namespace
+
+y_absl::string_view GetPackageToPrefixMappingsPath() {
+ return g_prefix_mode.package_to_prefix_mappings_path();
+}
+
+void SetPackageToPrefixMappingsPath(y_absl::string_view file_path) {
+ g_prefix_mode.set_package_to_prefix_mappings_path(file_path);
+}
+
+bool UseProtoPackageAsDefaultPrefix() {
+ return g_prefix_mode.use_package_name();
+}
+
+void SetUseProtoPackageAsDefaultPrefix(bool on_or_off) {
+ g_prefix_mode.set_use_package_name(on_or_off);
+}
+
+y_absl::string_view GetProtoPackagePrefixExceptionList() {
+ return g_prefix_mode.exception_path();
+}
+
+void SetProtoPackagePrefixExceptionList(y_absl::string_view file_path) {
+ g_prefix_mode.set_exception_path(file_path);
+}
+
+y_absl::string_view GetForcedPackagePrefix() {
+ return g_prefix_mode.forced_package_prefix();
+}
+
+void SetForcedPackagePrefix(y_absl::string_view prefix) {
+ g_prefix_mode.set_forced_package_prefix(prefix);
+}
+
+namespace {
+
+const char* const kUpperSegmentsList[] = {"url", "http", "https"};
+
+const y_absl::flat_hash_set<y_absl::string_view>& UpperSegments() {
+ static const auto* words = [] {
+ auto* words = new y_absl::flat_hash_set<y_absl::string_view>();
+
+ for (const auto word : kUpperSegmentsList) {
+ words->emplace(word);
+ }
+ return words;
+ }();
+ return *words;
+}
+
+// Internal helper for name handing.
+// Do not expose this outside of helpers, stick to having functions for specific
+// cases (ClassName(), FieldName()), so there is always consistent suffix rules.
+TProtoStringType UnderscoresToCamelCase(y_absl::string_view input,
+ bool first_capitalized) {
+ std::vector<TProtoStringType> values;
+ TProtoStringType current;
+
+ bool last_char_was_number = false;
+ bool last_char_was_lower = false;
+ bool last_char_was_upper = false;
+ for (int i = 0; i < input.size(); i++) {
+ char c = input[i];
+ if (y_absl::ascii_isdigit(c)) {
+ if (!last_char_was_number) {
+ values.push_back(current);
+ current = "";
+ }
+ current += c;
+ last_char_was_number = last_char_was_lower = last_char_was_upper = false;
+ last_char_was_number = true;
+ } else if (y_absl::ascii_islower(c)) {
+ // lowercase letter can follow a lowercase or uppercase letter
+ if (!last_char_was_lower && !last_char_was_upper) {
+ values.push_back(current);
+ current = "";
+ }
+ current += c; // already lower
+ last_char_was_number = last_char_was_lower = last_char_was_upper = false;
+ last_char_was_lower = true;
+ } else if (y_absl::ascii_isupper(c)) {
+ if (!last_char_was_upper) {
+ values.push_back(current);
+ current = "";
+ }
+ current += y_absl::ascii_tolower(c);
+ last_char_was_number = last_char_was_lower = last_char_was_upper = false;
+ last_char_was_upper = true;
+ } else {
+ last_char_was_number = last_char_was_lower = last_char_was_upper = false;
+ }
+ }
+ values.push_back(current);
+
+ TProtoStringType result;
+ bool first_segment_forces_upper = false;
+ for (auto& value : values) {
+ bool all_upper = UpperSegments().contains(value);
+ if (all_upper && (result.length() == 0)) {
+ first_segment_forces_upper = true;
+ }
+ if (all_upper) {
+ y_absl::AsciiStrToUpper(&value);
+ } else {
+ value[0] = y_absl::ascii_toupper(value[0]);
+ }
+ result += value;
+ }
+ if ((result.length() != 0) && !first_capitalized &&
+ !first_segment_forces_upper) {
+ result[0] = y_absl::ascii_tolower(result[0]);
+ }
+ return result;
+}
+
+const char* const kReservedWordList[] = {
+ // Note NSObject Methods:
+ // These are brought in from nsobject_methods.h that is generated
+ // using method_dump.sh. See kNSObjectMethods below.
+
+ // Objective-C "keywords" that aren't in C
+ // From
+ // http://stackoverflow.com/questions/1873630/reserved-keywords-in-objective-c
+ // with some others added on.
+ "id",
+ "_cmd",
+ "super",
+ "in",
+ "out",
+ "inout",
+ "bycopy",
+ "byref",
+ "oneway",
+ "self",
+ "instancetype",
+ "nullable",
+ "nonnull",
+ "nil",
+ "Nil",
+ "YES",
+ "NO",
+ "weak",
+
+ // C/C++ keywords (Incl C++ 0x11)
+ // From http://en.cppreference.com/w/cpp/keywords
+ "and",
+ "and_eq",
+ "alignas",
+ "alignof",
+ "asm",
+ "auto",
+ "bitand",
+ "bitor",
+ "bool",
+ "break",
+ "case",
+ "catch",
+ "char",
+ "char16_t",
+ "char32_t",
+ "class",
+ "compl",
+ "const",
+ "constexpr",
+ "const_cast",
+ "continue",
+ "decltype",
+ "default",
+ "delete",
+ "double",
+ "dynamic_cast",
+ "else",
+ "enum",
+ "explicit",
+ "export",
+ "extern ",
+ "false",
+ "float",
+ "for",
+ "friend",
+ "goto",
+ "if",
+ "inline",
+ "int",
+ "long",
+ "mutable",
+ "namespace",
+ "new",
+ "noexcept",
+ "not",
+ "not_eq",
+ "nullptr",
+ "operator",
+ "or",
+ "or_eq",
+ "private",
+ "protected",
+ "public",
+ "register",
+ "reinterpret_cast",
+ "return",
+ "short",
+ "signed",
+ "sizeof",
+ "static",
+ "static_assert",
+ "static_cast",
+ "struct",
+ "switch",
+ "template",
+ "this",
+ "thread_local",
+ "throw",
+ "true",
+ "try",
+ "typedef",
+ "typeid",
+ "typename",
+ "union",
+ "unsigned",
+ "using",
+ "virtual",
+ "void",
+ "volatile",
+ "wchar_t",
+ "while",
+ "xor",
+ "xor_eq",
+
+ // C99 keywords
+ // From
+ // http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8l.doc%2Flanguage%2Fref%2Fkeyw.htm
+ "restrict",
+
+ // GCC/Clang extension
+ "typeof",
+
+ // Not a keyword, but will break you
+ "NULL",
+
+ // C88+ specs call for these to be macros, so depending on what they are
+ // defined to be it can lead to odd errors for some Xcode/SDK versions.
+ "stdin",
+ "stdout",
+ "stderr",
+
+ // Objective-C Runtime typedefs
+ // From <obc/runtime.h>
+ "Category",
+ "Ivar",
+ "Method",
+ "Protocol",
+
+ // GPBMessage Methods
+ // Only need to add instance methods that may conflict with
+ // method declared in protos. The main cases are methods
+ // that take no arguments, or setFoo:/hasFoo: type methods.
+ "clear",
+ "data",
+ "delimitedData",
+ "descriptor",
+ "extensionRegistry",
+ "extensionsCurrentlySet",
+ "initialized",
+ "isInitialized",
+ "serializedSize",
+ "sortedExtensionsInUse",
+ "unknownFields",
+
+ // MacTypes.h names
+ "Fixed",
+ "Fract",
+ "Size",
+ "LogicalAddress",
+ "PhysicalAddress",
+ "ByteCount",
+ "ByteOffset",
+ "Duration",
+ "AbsoluteTime",
+ "OptionBits",
+ "ItemCount",
+ "PBVersion",
+ "ScriptCode",
+ "LangCode",
+ "RegionCode",
+ "OSType",
+ "ProcessSerialNumber",
+ "Point",
+ "Rect",
+ "FixedPoint",
+ "FixedRect",
+ "Style",
+ "StyleParameter",
+ "StyleField",
+ "TimeScale",
+ "TimeBase",
+ "TimeRecord",
+};
+
+const y_absl::flat_hash_set<y_absl::string_view>& ReservedWords() {
+ static const auto* words = [] {
+ auto* words = new y_absl::flat_hash_set<y_absl::string_view>();
+
+ for (const auto word : kReservedWordList) {
+ words->emplace(word);
+ }
+ return words;
+ }();
+ return *words;
+}
+
+const y_absl::flat_hash_set<y_absl::string_view>& NSObjectMethods() {
+ static const auto* words = [] {
+ auto* words = new y_absl::flat_hash_set<y_absl::string_view>();
+
+ for (const auto word : kNSObjectMethodsList) {
+ words->emplace(word);
+ }
+ return words;
+ }();
+ return *words;
+}
+
+// returns true is input starts with __ or _[A-Z] which are reserved identifiers
+// in C/ C++. All calls should go through UnderscoresToCamelCase before getting
+// here but this verifies and allows for future expansion if we decide to
+// redefine what a reserved C identifier is (for example the GNU list
+// https://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html )
+bool IsReservedCIdentifier(y_absl::string_view input) {
+ if (input.length() > 2) {
+ if (input.at(0) == '_') {
+ if (isupper(input.at(1)) || input.at(1) == '_') {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+TProtoStringType SanitizeNameForObjC(y_absl::string_view prefix,
+ y_absl::string_view input,
+ y_absl::string_view extension,
+ TProtoStringType* out_suffix_added) {
+ TProtoStringType sanitized;
+ // We add the prefix in the cases where the string is missing a prefix.
+ // We define "missing a prefix" as where 'input':
+ // a) Doesn't start with the prefix or
+ // b) Isn't equivalent to the prefix or
+ // c) Has the prefix, but the letter after the prefix is lowercase
+ if (y_absl::StartsWith(input, prefix)) {
+ if (input.length() == prefix.length() ||
+ !y_absl::ascii_isupper(input[prefix.length()])) {
+ sanitized = y_absl::StrCat(prefix, input);
+ } else {
+ sanitized = TProtoStringType(input);
+ }
+ } else {
+ sanitized = y_absl::StrCat(prefix, input);
+ }
+ if (IsReservedCIdentifier(sanitized) || ReservedWords().contains(sanitized) ||
+ NSObjectMethods().contains(sanitized)) {
+ if (out_suffix_added) *out_suffix_added = TProtoStringType(extension);
+ return y_absl::StrCat(sanitized, extension);
+ }
+ if (out_suffix_added) out_suffix_added->clear();
+ return sanitized;
+}
+
+TProtoStringType NameFromFieldDescriptor(const FieldDescriptor* field) {
+ if (field->type() == FieldDescriptor::TYPE_GROUP) {
+ return field->message_type()->name();
+ } else {
+ return field->name();
+ }
+}
+
+void PathSplit(y_absl::string_view path, TProtoStringType* directory,
+ TProtoStringType* basename) {
+ y_absl::string_view::size_type last_slash = path.rfind('/');
+ if (last_slash == y_absl::string_view::npos) {
+ if (directory) {
+ *directory = "";
+ }
+ if (basename) {
+ *basename = TProtoStringType(path);
+ }
+ } else {
+ if (directory) {
+ *directory = TProtoStringType(path.substr(0, last_slash));
+ }
+ if (basename) {
+ *basename = TProtoStringType(path.substr(last_slash + 1));
+ }
+ }
+}
+
+bool IsSpecialNamePrefix(y_absl::string_view name,
+ const std::vector<TProtoStringType>& special_names) {
+ for (const auto& special_name : special_names) {
+ const size_t length = special_name.length();
+ if (name.compare(0, length, special_name) == 0) {
+ if (name.length() > length) {
+ // If name is longer than the special_name that it matches the next
+ // character must be not lower case (newton vs newTon vs new_ton).
+ return !y_absl::ascii_islower(name[length]);
+ } else {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+void MaybeUnQuote(y_absl::string_view* input) {
+ if ((input->length() >= 2) &&
+ ((*input->data() == '\'' || *input->data() == '"')) &&
+ ((*input)[input->length() - 1] == *input->data())) {
+ input->remove_prefix(1);
+ input->remove_suffix(1);
+ }
+}
+
+} // namespace
+
+bool IsRetainedName(y_absl::string_view name) {
+ // List of prefixes from
+ // http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html
+ static const std::vector<TProtoStringType>* retained_names =
+ new std::vector<TProtoStringType>({"new", "alloc", "copy", "mutableCopy"});
+ return IsSpecialNamePrefix(name, *retained_names);
+}
+
+bool IsInitName(y_absl::string_view name) {
+ static const std::vector<TProtoStringType>* init_names =
+ new std::vector<TProtoStringType>({"init"});
+ return IsSpecialNamePrefix(name, *init_names);
+}
+
+bool IsCreateName(y_absl::string_view name) {
+ // List of segments from
+ // https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html#//apple_ref/doc/uid/20001148-103029
+ static const std::vector<TProtoStringType>* create_names =
+ new std::vector<TProtoStringType>({"Create", "Copy"});
+
+ for (const auto& create_name : *create_names) {
+ const size_t length = create_name.length();
+ size_t pos = name.find(create_name);
+ if (pos != TProtoStringType::npos) {
+ // The above docs don't actually call out anything about the characters
+ // before the special words. So it's not clear if something like
+ // "FOOCreate" would or would not match the "The Create Rule", but by not
+ // checking, and claiming it does match, then callers will annotate with
+ // `cf_returns_not_retained` which will ensure things work as desired.
+ //
+ // The footnote here is the docs do have a passing reference to "NoCopy",
+ // but again, not looking for that and just returning `true` will cause
+ // callers to annotate the api as not being a Create Rule function.
+
+ // If name is longer than the create_names[i] that it matches the next
+ // character must be not lower case (Copyright vs CopyFoo vs Copy_Foo).
+ if (name.length() > pos + length) {
+ return !y_absl::ascii_islower(name[pos + length]);
+ } else {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+TProtoStringType BaseFileName(const FileDescriptor* file) {
+ TProtoStringType basename;
+ PathSplit(file->name(), nullptr, &basename);
+ return basename;
+}
+
+TProtoStringType FileClassPrefix(const FileDescriptor* file) {
+ // Always honor the file option.
+ if (file->options().has_objc_class_prefix()) {
+ return file->options().objc_class_prefix();
+ }
+
+ // If package prefix is specified in an prefix to proto mappings file then use
+ // that.
+ y_absl::string_view objc_class_prefix =
+ g_prefix_mode.prefix_from_proto_package_mappings(file);
+ if (!objc_class_prefix.empty()) {
+ return TProtoStringType(objc_class_prefix);
+ }
+
+ // If package prefix isn't enabled, done.
+ if (!g_prefix_mode.use_package_name()) {
+ return "";
+ }
+
+ // If the package is in the exceptions list, done.
+ if (g_prefix_mode.is_package_exempted(file->package())) {
+ return "";
+ }
+
+ // Transform the package into a prefix: use the dot segments as part,
+ // camelcase each one and then join them with underscores, and add an
+ // underscore at the end.
+ TProtoStringType result;
+ const std::vector<TProtoStringType> segments =
+ y_absl::StrSplit(file->package(), '.', y_absl::SkipEmpty());
+ for (const auto& segment : segments) {
+ const TProtoStringType part = UnderscoresToCamelCase(segment, true);
+ if (part.empty()) {
+ continue;
+ }
+ if (!result.empty()) {
+ result.append("_");
+ }
+ result.append(part);
+ }
+ if (!result.empty()) {
+ result.append("_");
+ }
+ return y_absl::StrCat(g_prefix_mode.forced_package_prefix(), result);
+}
+
+TProtoStringType FilePath(const FileDescriptor* file) {
+ TProtoStringType output;
+ TProtoStringType basename;
+ TProtoStringType directory;
+ PathSplit(file->name(), &directory, &basename);
+ if (directory.length() > 0) {
+ output = y_absl::StrCat(directory, "/");
+ }
+ basename = StripProto(basename);
+
+ // CamelCase to be more ObjC friendly.
+ basename = UnderscoresToCamelCase(basename, true);
+
+ return y_absl::StrCat(output, basename);
+}
+
+TProtoStringType FilePathBasename(const FileDescriptor* file) {
+ TProtoStringType output;
+ TProtoStringType basename;
+ TProtoStringType directory;
+ PathSplit(file->name(), &directory, &basename);
+ basename = StripProto(basename);
+
+ // CamelCase to be more ObjC friendly.
+ output = UnderscoresToCamelCase(basename, true);
+
+ return output;
+}
+
+TProtoStringType FileClassName(const FileDescriptor* file) {
+ const TProtoStringType prefix = FileClassPrefix(file);
+ const TProtoStringType name = y_absl::StrCat(
+ UnderscoresToCamelCase(StripProto(BaseFileName(file)), true), "Root");
+ // There aren't really any reserved words that end in "Root", but playing
+ // it safe and checking.
+ return SanitizeNameForObjC(prefix, name, "_RootClass", nullptr);
+}
+
+TProtoStringType ClassNameWorker(const Descriptor* descriptor) {
+ TProtoStringType name;
+ if (descriptor->containing_type() != nullptr) {
+ return y_absl::StrCat(ClassNameWorker(descriptor->containing_type()), "_",
+ descriptor->name());
+ }
+ return y_absl::StrCat(name, descriptor->name());
+}
+
+TProtoStringType ClassNameWorker(const EnumDescriptor* descriptor) {
+ TProtoStringType name;
+ if (descriptor->containing_type() != nullptr) {
+ return y_absl::StrCat(ClassNameWorker(descriptor->containing_type()), "_",
+ descriptor->name());
+ }
+ return y_absl::StrCat(name, descriptor->name());
+}
+
+TProtoStringType ClassName(const Descriptor* descriptor) {
+ return ClassName(descriptor, nullptr);
+}
+
+TProtoStringType ClassName(const Descriptor* descriptor,
+ TProtoStringType* out_suffix_added) {
+ // 1. Message names are used as is (style calls for CamelCase, trust it).
+ // 2. Check for reserved word at the very end and then suffix things.
+ const TProtoStringType prefix = FileClassPrefix(descriptor->file());
+ const TProtoStringType name = ClassNameWorker(descriptor);
+ return SanitizeNameForObjC(prefix, name, "_Class", out_suffix_added);
+}
+
+TProtoStringType EnumName(const EnumDescriptor* descriptor) {
+ // 1. Enum names are used as is (style calls for CamelCase, trust it).
+ // 2. Check for reserved word at the every end and then suffix things.
+ // message Fixed {
+ // message Size {...}
+ // enum Mumble {...}
+ // ...
+ // }
+ // yields Fixed_Class, Fixed_Size.
+ const TProtoStringType prefix = FileClassPrefix(descriptor->file());
+ const TProtoStringType name = ClassNameWorker(descriptor);
+ return SanitizeNameForObjC(prefix, name, "_Enum", nullptr);
+}
+
+TProtoStringType EnumValueName(const EnumValueDescriptor* descriptor) {
+ // Because of the Switch enum compatibility, the name on the enum has to have
+ // the suffix handing, so it slightly diverges from how nested classes work.
+ // enum Fixed {
+ // FOO = 1
+ // }
+ // yields Fixed_Enum and Fixed_Enum_Foo (not Fixed_Foo).
+ const TProtoStringType class_name = EnumName(descriptor->type());
+ const TProtoStringType value_str =
+ UnderscoresToCamelCase(descriptor->name(), true);
+ const TProtoStringType name = y_absl::StrCat(class_name, "_", value_str);
+ // There aren't really any reserved words with an underscore and a leading
+ // capital letter, but playing it safe and checking.
+ return SanitizeNameForObjC("", name, "_Value", nullptr);
+}
+
+TProtoStringType EnumValueShortName(const EnumValueDescriptor* descriptor) {
+ // Enum value names (EnumValueName above) are the enum name turned into
+ // a class name and then the value name is CamelCased and concatenated; the
+ // whole thing then gets sanitized for reserved words.
+ // The "short name" is intended to be the final leaf, the value name; but
+ // you can't simply send that off to sanitize as that could result in it
+ // getting modified when the full name didn't. For example enum
+ // "StorageModes" has a value "retain". So the full name is
+ // "StorageModes_Retain", but if we sanitize "retain" it would become
+ // "RetainValue".
+ // So the right way to get the short name is to take the full enum name
+ // and then strip off the enum name (leaving the value name and anything
+ // done by sanitize).
+ const TProtoStringType class_name = EnumName(descriptor->type());
+ const TProtoStringType long_name_prefix = y_absl::StrCat(class_name, "_");
+ const TProtoStringType long_name = EnumValueName(descriptor);
+ return TProtoStringType(y_absl::StripPrefix(long_name, long_name_prefix));
+}
+
+TProtoStringType UnCamelCaseEnumShortName(y_absl::string_view name) {
+ TProtoStringType result;
+ for (int i = 0; i < name.size(); i++) {
+ char c = name[i];
+ if (i > 0 && y_absl::ascii_isupper(c)) {
+ result += '_';
+ }
+ result += y_absl::ascii_toupper(c);
+ }
+ return result;
+}
+
+TProtoStringType ExtensionMethodName(const FieldDescriptor* descriptor) {
+ const TProtoStringType name = NameFromFieldDescriptor(descriptor);
+ const TProtoStringType result = UnderscoresToCamelCase(name, false);
+ return SanitizeNameForObjC("", result, "_Extension", nullptr);
+}
+
+TProtoStringType FieldName(const FieldDescriptor* field) {
+ const TProtoStringType name = NameFromFieldDescriptor(field);
+ TProtoStringType result = UnderscoresToCamelCase(name, false);
+ if (field->is_repeated() && !field->is_map()) {
+ // Add "Array" before do check for reserved worlds.
+ y_absl::StrAppend(&result, "Array");
+ } else {
+ // If it wasn't repeated, but ends in "Array", force on the _p suffix.
+ if (y_absl::EndsWith(result, "Array")) {
+ y_absl::StrAppend(&result, "_p");
+ }
+ }
+ return SanitizeNameForObjC("", result, "_p", nullptr);
+}
+
+TProtoStringType FieldNameCapitalized(const FieldDescriptor* field) {
+ // Want the same suffix handling, so upcase the first letter of the other
+ // name.
+ TProtoStringType result = FieldName(field);
+ if (result.length() > 0) {
+ result[0] = y_absl::ascii_toupper(result[0]);
+ }
+ return result;
+}
+
+TProtoStringType OneofEnumName(const OneofDescriptor* descriptor) {
+ const Descriptor* fieldDescriptor = descriptor->containing_type();
+ TProtoStringType name = y_absl::StrCat(
+ ClassName(fieldDescriptor), "_",
+ UnderscoresToCamelCase(descriptor->name(), true), "_OneOfCase");
+ // No sanitize needed because the OS never has names that end in _OneOfCase.
+ return name;
+}
+
+TProtoStringType OneofName(const OneofDescriptor* descriptor) {
+ TProtoStringType name = UnderscoresToCamelCase(descriptor->name(), false);
+ // No sanitize needed because it gets OneOfCase added and that shouldn't
+ // ever conflict.
+ return name;
+}
+
+TProtoStringType OneofNameCapitalized(const OneofDescriptor* descriptor) {
+ // Use the common handling and then up-case the first letter.
+ TProtoStringType result = OneofName(descriptor);
+ if (result.length() > 0) {
+ result[0] = y_absl::ascii_toupper(result[0]);
+ }
+ return result;
+}
+
+TProtoStringType UnCamelCaseFieldName(y_absl::string_view name,
+ const FieldDescriptor* field) {
+ y_absl::string_view worker(name);
+ if (y_absl::EndsWith(worker, "_p")) {
+ worker = y_absl::StripSuffix(worker, "_p");
+ }
+ if (field->is_repeated() && y_absl::EndsWith(worker, "Array")) {
+ worker = y_absl::StripSuffix(worker, "Array");
+ }
+ if (field->type() == FieldDescriptor::TYPE_GROUP) {
+ if (worker.length() > 0) {
+ if (y_absl::ascii_islower(worker[0])) {
+ TProtoStringType copy(worker);
+ copy[0] = y_absl::ascii_toupper(worker[0]);
+ return copy;
+ }
+ }
+ return TProtoStringType(worker);
+ } else {
+ TProtoStringType result;
+ for (int i = 0; i < worker.size(); i++) {
+ char c = worker[i];
+ if (y_absl::ascii_isupper(c)) {
+ if (i > 0) {
+ result += '_';
+ }
+ result += y_absl::ascii_tolower(c);
+ } else {
+ result += c;
+ }
+ }
+ return result;
+ }
+}
+
+// Making these a generator option for folks that don't use CocoaPods, but do
+// want to put the library in a framework is an interesting question. The
+// problem is it means changing sources shipped with the library to actually
+// use a different value; so it isn't as simple as a option.
+const char* const ProtobufLibraryFrameworkName = "Protobuf";
+
+TProtoStringType ProtobufFrameworkImportSymbol(y_absl::string_view framework_name) {
+ // GPB_USE_[framework_name]_FRAMEWORK_IMPORTS
+ return y_absl::StrCat("GPB_USE_", y_absl::AsciiStrToUpper(framework_name),
+ "_FRAMEWORK_IMPORTS");
+}
+
+bool IsProtobufLibraryBundledProtoFile(const FileDescriptor* file) {
+ // We don't check the name prefix or proto package because some files
+ // (descriptor.proto), aren't shipped generated by the library, so this
+ // seems to be the safest way to only catch the ones shipped.
+ const TProtoStringType name = file->name();
+ if (name == "google/protobuf/any.proto" ||
+ name == "google/protobuf/api.proto" ||
+ name == "google/protobuf/duration.proto" ||
+ name == "google/protobuf/empty.proto" ||
+ name == "google/protobuf/field_mask.proto" ||
+ name == "google/protobuf/source_context.proto" ||
+ name == "google/protobuf/struct.proto" ||
+ name == "google/protobuf/timestamp.proto" ||
+ name == "google/protobuf/type.proto" ||
+ name == "google/protobuf/wrappers.proto") {
+ return true;
+ }
+ return false;
+}
+
+namespace {
+
+bool PackageToPrefixesCollector::ConsumeLine(y_absl::string_view line,
+ TProtoStringType* out_error) {
+ int offset = line.find('=');
+ if (offset == y_absl::string_view::npos) {
+ *out_error =
+ y_absl::StrCat(usage_, " file line without equal sign: '", line, "'.");
+ return false;
+ }
+ y_absl::string_view package =
+ y_absl::StripAsciiWhitespace(line.substr(0, offset));
+ y_absl::string_view prefix =
+ y_absl::StripAsciiWhitespace(line.substr(offset + 1));
+ MaybeUnQuote(&prefix);
+ // Don't really worry about error checking the package/prefix for
+ // being valid. Assume the file is validated when it is created/edited.
+ (*prefix_map_)[package] = TProtoStringType(prefix);
+ return true;
+}
+
+bool LoadExpectedPackagePrefixes(
+ y_absl::string_view expected_prefixes_path,
+ y_absl::flat_hash_map<TProtoStringType, TProtoStringType>* prefix_map,
+ TProtoStringType* out_error) {
+ if (expected_prefixes_path.empty()) {
+ return true;
+ }
+
+ PackageToPrefixesCollector collector("Expected prefixes", prefix_map);
+ return ParseSimpleFile(expected_prefixes_path, &collector, out_error);
+}
+
+bool ValidateObjCClassPrefix(
+ const FileDescriptor* file, y_absl::string_view expected_prefixes_path,
+ const y_absl::flat_hash_map<TProtoStringType, TProtoStringType>&
+ expected_package_prefixes,
+ bool prefixes_must_be_registered, bool require_prefixes,
+ TProtoStringType* out_error) {
+ // Reminder: An explicit prefix option of "" is valid in case the default
+ // prefixing is set to use the proto package and a file needs to be generated
+ // without any prefix at all (for legacy reasons).
+
+ bool has_prefix = file->options().has_objc_class_prefix();
+ bool have_expected_prefix_file = !expected_prefixes_path.empty();
+
+ 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.
+ const TProtoStringType lookup_key =
+ package.empty() ? y_absl::StrCat(kNoPackagePrefix, 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.
+
+ // Check: Error - See if there was an expected prefix for the package and
+ // report if it doesn't match (wrong or missing).
+ auto package_match = 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) {
+ // ...it matches. All good, out of here!
+ return true;
+ } else {
+ // ...it didn't match!
+ *out_error =
+ y_absl::StrCat("error: Expected 'option objc_class_prefix = \"",
+ package_match->second, "\";'");
+ if (!package.empty()) {
+ y_absl::StrAppend(out_error, " for package '", package, "'");
+ }
+ y_absl::StrAppend(out_error, " in '", file->name(), "'");
+ if (has_prefix) {
+ y_absl::StrAppend(out_error, "; but found '", prefix, "' instead");
+ }
+ y_absl::StrAppend(out_error, ".");
+ return false;
+ }
+ }
+
+ // If there was no prefix option, we're done at this point.
+ if (!has_prefix) {
+ if (require_prefixes) {
+ *out_error = y_absl::StrCat("error: '", file->name(),
+ "' does not have a required 'option"
+ " objc_class_prefix'.");
+ return false;
+ }
+ return true;
+ }
+
+ // When the prefix is non empty, check it against the expected entries.
+ if (!prefix.empty() && have_expected_prefix_file) {
+ // For a non empty prefix, look for any other package that uses the prefix.
+ TProtoStringType other_package_for_prefix;
+ for (auto i = expected_package_prefixes.begin();
+ i != expected_package_prefixes.end(); ++i) {
+ if (i->second == prefix) {
+ other_package_for_prefix = i->first;
+ // 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 (!y_absl::StartsWith(other_package_for_prefix, kNoPackagePrefix)) {
+ break;
+ }
+ }
+ }
+
+ // Check: Error - Make sure the prefix wasn't expected for a different
+ // package (overlap is allowed, but it has to be listed as an expected
+ // overlap).
+ if (!other_package_for_prefix.empty()) {
+ *out_error = y_absl::StrCat("error: Found 'option objc_class_prefix = \"",
+ prefix, "\";' in '", file->name(),
+ "'; that prefix is already used for ");
+ if (y_absl::StartsWith(other_package_for_prefix, kNoPackagePrefix)) {
+ y_absl::StrAppend(
+ out_error, "file '",
+ y_absl::StripPrefix(other_package_for_prefix, kNoPackagePrefix),
+ "'.");
+ } else {
+ y_absl::StrAppend(out_error, "'package ", other_package_for_prefix,
+ ";'.");
+ }
+ y_absl::StrAppend(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() && 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
+ // doesn't meet these rules).
+ if (!prefix.empty() && !y_absl::ascii_isupper(prefix[0])) {
+ std::cerr << "protoc:0: warning: Invalid 'option objc_class_prefix = \""
+ << prefix << "\";' in '" << file->name() << "';"
+ << " it should start with a capital letter." << std::endl;
+ std::cerr.flush();
+ }
+ if (!prefix.empty() && prefix.length() < 3) {
+ // Apple reserves 2 character prefixes for themselves. They do use some
+ // 3 character prefixes, but they haven't updated the rules/docs.
+ std::cerr << "protoc:0: warning: Invalid 'option objc_class_prefix = \""
+ << prefix << "\";' in '" << file->name() << "';"
+ << " Apple recommends they should be at least 3 characters long."
+ << std::endl;
+ std::cerr.flush();
+ }
+
+ // Check: Error/Warning - If the given package/prefix pair wasn't expected,
+ // issue a error/warning to added to the file.
+ if (have_expected_prefix_file) {
+ if (prefixes_must_be_registered) {
+ *out_error = y_absl::StrCat(
+ "error: '", file->name(), "' has 'option objc_class_prefix = \"",
+ 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 '"
+ << lookup_key << " = " << (prefix.empty() ? "\"\"" : prefix)
+ << "' to the expected prefixes file (" << expected_prefixes_path << ")."
+ << std::endl;
+ std::cerr.flush();
+ }
+
+ return true;
+}
+
+} // namespace
+
+Options::Options() {
+ // 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;
+ }
+ const char* suppressions =
+ getenv("GPB_OBJC_EXPECTED_PACKAGE_PREFIXES_SUPPRESSIONS");
+ if (suppressions) {
+ expected_prefixes_suppressions =
+ y_absl::StrSplit(suppressions, ';', y_absl::SkipEmpty());
+ }
+ prefixes_must_be_registered =
+ BoolFromEnvVar("GPB_OBJC_PREFIXES_MUST_BE_REGISTERED", false);
+ require_prefixes = BoolFromEnvVar("GPB_OBJC_REQUIRE_PREFIXES", false);
+}
+
+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& validation_options,
+ TProtoStringType* out_error) {
+ // Allow a '-' as the path for the expected prefixes to completely disable
+ // even the most basic of checks.
+ if (validation_options.expected_prefixes_path == "-") {
+ return true;
+ }
+
+ // Load the expected package prefixes, if available, to validate against.
+ y_absl::flat_hash_map<TProtoStringType, TProtoStringType> expected_package_prefixes;
+ if (!LoadExpectedPackagePrefixes(validation_options.expected_prefixes_path,
+ &expected_package_prefixes, out_error)) {
+ return false;
+ }
+
+ for (auto file : files) {
+ bool should_skip =
+ (std::find(validation_options.expected_prefixes_suppressions.begin(),
+ validation_options.expected_prefixes_suppressions.end(),
+ file->name()) !=
+ validation_options.expected_prefixes_suppressions.end());
+ if (should_skip) {
+ continue;
+ }
+
+ bool is_valid =
+ ValidateObjCClassPrefix(file, validation_options.expected_prefixes_path,
+ expected_package_prefixes,
+ validation_options.prefixes_must_be_registered,
+ validation_options.require_prefixes, out_error);
+ if (!is_valid) {
+ return false;
+ }
+ }
+ return true;
+}
+
+} // namespace objectivec
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/names.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/names.h
new file mode 100644
index 00000000000..3ee2cd8e905
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/names.h
@@ -0,0 +1,179 @@
+// 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.
+
+// Helper functions for generating ObjectiveC code.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_NAMES_H__
+#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_NAMES_H__
+
+#include <string>
+#include <vector>
+
+#include "google/protobuf/descriptor.h"
+
+// Must be included last
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace objectivec {
+
+// Get/Set the path to a file to load for objc class prefix lookups.
+PROTOC_EXPORT y_absl::string_view GetPackageToPrefixMappingsPath();
+PROTOC_EXPORT void SetPackageToPrefixMappingsPath(y_absl::string_view 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
+// are exported.
+PROTOC_EXPORT bool UseProtoPackageAsDefaultPrefix();
+PROTOC_EXPORT void SetUseProtoPackageAsDefaultPrefix(bool on_or_off);
+// Get/Set the path to a file to load as exceptions when
+// `UseProtoPackageAsDefaultPrefix()` is `true`. An empty string means there
+// should be no exceptions.
+PROTOC_EXPORT y_absl::string_view GetProtoPackagePrefixExceptionList();
+PROTOC_EXPORT void SetProtoPackagePrefixExceptionList(
+ y_absl::string_view file_path);
+// Get/Set a prefix to add before the prefix generated from the package name.
+// This is only used when UseProtoPackageAsDefaultPrefix() is True.
+PROTOC_EXPORT y_absl::string_view GetForcedPackagePrefix();
+PROTOC_EXPORT void SetForcedPackagePrefix(y_absl::string_view prefix);
+
+// Returns true if the name requires a ns_returns_not_retained attribute applied
+// to it.
+PROTOC_EXPORT bool IsRetainedName(y_absl::string_view name);
+
+// Returns true if the name starts with "init" and will need to have special
+// handling under ARC.
+PROTOC_EXPORT bool IsInitName(y_absl::string_view name);
+
+// Returns true if the name requires a cf_returns_not_retained attribute applied
+// to it.
+PROTOC_EXPORT bool IsCreateName(y_absl::string_view name);
+
+// Gets the objc_class_prefix or the prefix made from the proto package.
+PROTOC_EXPORT TProtoStringType FileClassPrefix(const FileDescriptor* file);
+
+// Gets the path of the file we're going to generate (sans the .pb.h
+// extension). The path will be dependent on the objectivec package
+// declared in the proto package.
+PROTOC_EXPORT TProtoStringType FilePath(const FileDescriptor* file);
+
+// Just like FilePath(), but without the directory part.
+PROTOC_EXPORT TProtoStringType FilePathBasename(const FileDescriptor* file);
+
+// Gets the name of the root class we'll generate in the file. This class
+// is not meant for external consumption, but instead contains helpers that
+// the rest of the classes need
+PROTOC_EXPORT TProtoStringType FileClassName(const FileDescriptor* file);
+
+// These return the fully-qualified class name corresponding to the given
+// descriptor.
+PROTOC_EXPORT TProtoStringType ClassName(const Descriptor* descriptor);
+PROTOC_EXPORT TProtoStringType ClassName(const Descriptor* descriptor,
+ TProtoStringType* out_suffix_added);
+PROTOC_EXPORT TProtoStringType EnumName(const EnumDescriptor* descriptor);
+
+// Returns the fully-qualified name of the enum value corresponding to the
+// the descriptor.
+PROTOC_EXPORT TProtoStringType EnumValueName(const EnumValueDescriptor* descriptor);
+
+// Returns the name of the enum value corresponding to the descriptor.
+PROTOC_EXPORT TProtoStringType EnumValueShortName(
+ const EnumValueDescriptor* descriptor);
+
+// Reverse what an enum does.
+PROTOC_EXPORT TProtoStringType UnCamelCaseEnumShortName(y_absl::string_view name);
+
+// Returns the name to use for the extension (used as the method off the file's
+// Root class).
+PROTOC_EXPORT TProtoStringType ExtensionMethodName(
+ const FieldDescriptor* descriptor);
+
+// Returns the transformed field name.
+PROTOC_EXPORT TProtoStringType FieldName(const FieldDescriptor* field);
+PROTOC_EXPORT TProtoStringType FieldNameCapitalized(const FieldDescriptor* field);
+
+// Returns the transformed oneof name.
+PROTOC_EXPORT TProtoStringType OneofEnumName(const OneofDescriptor* descriptor);
+PROTOC_EXPORT TProtoStringType OneofName(const OneofDescriptor* descriptor);
+PROTOC_EXPORT TProtoStringType OneofNameCapitalized(
+ const OneofDescriptor* descriptor);
+
+// Reverse of the above.
+PROTOC_EXPORT TProtoStringType UnCamelCaseFieldName(y_absl::string_view name,
+ const FieldDescriptor* field);
+
+// The name the commonly used by the library when built as a framework.
+// This lines up to the name used in the CocoaPod.
+extern PROTOC_EXPORT const char* const ProtobufLibraryFrameworkName;
+// Returns the CPP symbol name to use as the gate for framework style imports
+// for the given framework name to use.
+PROTOC_EXPORT TProtoStringType ProtobufFrameworkImportSymbol(
+ y_absl::string_view framework_name);
+
+// ---------------------------------------------------------------------------
+
+// These aren't really "naming" related, but can be useful for something
+// building on top of ObjC Protos to be able to share the knowledge/enforcement.
+
+// Checks if the file is one of the proto's bundled with the library.
+PROTOC_EXPORT bool IsProtobufLibraryBundledProtoFile(
+ const FileDescriptor* file);
+
+// Generator Prefix Validation Options (see generator.cc for a
+// description of each):
+struct Options {
+ Options();
+ TProtoStringType expected_prefixes_path;
+ std::vector<TProtoStringType> expected_prefixes_suppressions;
+ bool prefixes_must_be_registered;
+ bool require_prefixes;
+};
+
+// Checks the prefix for the given files and outputs any warnings as needed. If
+// there are flat out errors, then out_error is filled in with the first error
+// and the result is false.
+PROTOC_EXPORT bool ValidateObjCClassPrefixes(
+ const std::vector<const FileDescriptor*>& files,
+ const Options& validation_options, TProtoStringType* out_error);
+// Same was the other ValidateObjCClassPrefixes() calls, but the options all
+// come from the environment variables.
+PROTOC_EXPORT bool ValidateObjCClassPrefixes(
+ const std::vector<const FileDescriptor*>& files, TProtoStringType* out_error);
+
+} // namespace objectivec
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_NAMES_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/nsobject_methods.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/nsobject_methods.h
new file mode 100644
index 00000000000..7a1b9ef2cdd
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/nsobject_methods.h
@@ -0,0 +1,227 @@
+// 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.
+
+// NSObject methods
+// Autogenerated by method_dump.sh. Do not edit by hand.
+// Date: Thu Nov 1 14:12:16 PDT 2018
+// macOS: MacOSX10.14.sdk
+// iOS: iPhoneSimulator12.1.sdk
+
+const char* const kNSObjectMethodsList[] = {
+ "CAMLType",
+ "CA_copyRenderValue",
+ "CA_prepareRenderValue",
+ "NS_copyCGImage",
+ "NS_tiledLayerVisibleRect",
+ "___tryRetain_OA",
+ "__autorelease_OA",
+ "__dealloc_zombie",
+ "__release_OA",
+ "__retain_OA",
+ "_accessibilityFinalize",
+ "_accessibilityIsTableViewDescendant",
+ "_accessibilityUIElementSpecifier",
+ "_accessibilityUseConvenienceAPI",
+ "_allowsDirectEncoding",
+ "_asScriptTerminologyNameArray",
+ "_asScriptTerminologyNameString",
+ "_bindingAdaptor",
+ "_cfTypeID",
+ "_copyDescription",
+ "_destroyObserverList",
+ "_didEndKeyValueObserving",
+ "_implicitObservationInfo",
+ "_internalAccessibilityAttributedHint",
+ "_internalAccessibilityAttributedLabel",
+ "_internalAccessibilityAttributedValue",
+ "_isAXConnector",
+ "_isAccessibilityContainerSectionCandidate",
+ "_isAccessibilityContentNavigatorSectionCandidate",
+ "_isAccessibilityContentSectionCandidate",
+ "_isAccessibilityTopLevelNavigatorSectionCandidate",
+ "_isDeallocating",
+ "_isKVOA",
+ "_isToManyChangeInformation",
+ "_ivarDescription",
+ "_localClassNameForClass",
+ "_methodDescription",
+ "_observerStorage",
+ "_overrideUseFastBlockObservers",
+ "_propertyDescription",
+ "_releaseBindingAdaptor",
+ "_scriptingCount",
+ "_scriptingCountNonrecursively",
+ "_scriptingDebugDescription",
+ "_scriptingExists",
+ "_scriptingShouldCheckObjectIndexes",
+ "_shortMethodDescription",
+ "_shouldSearchChildrenForSection",
+ "_traitStorageList",
+ "_tryRetain",
+ "_ui_descriptionBuilder",
+ "_uikit_variesByTraitCollections",
+ "_web_description",
+ "_webkit_invokeOnMainThread",
+ "_willBeginKeyValueObserving",
+ "accessibilityActivate",
+ "accessibilityActivationPoint",
+ "accessibilityAllowsOverriddenAttributesWhenIgnored",
+ "accessibilityAssistiveTechnologyFocusedIdentifiers",
+ "accessibilityAttributedHint",
+ "accessibilityAttributedLabel",
+ "accessibilityAttributedValue",
+ "accessibilityContainer",
+ "accessibilityContainerType",
+ "accessibilityCustomActions",
+ "accessibilityCustomRotors",
+ "accessibilityDecrement",
+ "accessibilityDragSourceDescriptors",
+ "accessibilityDropPointDescriptors",
+ "accessibilityElementCount",
+ "accessibilityElementDidBecomeFocused",
+ "accessibilityElementDidLoseFocus",
+ "accessibilityElementIsFocused",
+ "accessibilityElements",
+ "accessibilityElementsHidden",
+ "accessibilityFrame",
+ "accessibilityHeaderElements",
+ "accessibilityHint",
+ "accessibilityIdentification",
+ "accessibilityIdentifier",
+ "accessibilityIncrement",
+ "accessibilityLabel",
+ "accessibilityLanguage",
+ "accessibilityLocalizedStringKey",
+ "accessibilityNavigationStyle",
+ "accessibilityOverriddenAttributes",
+ "accessibilityParameterizedAttributeNames",
+ "accessibilityPath",
+ "accessibilityPerformEscape",
+ "accessibilityPerformMagicTap",
+ "accessibilityPresenterProcessIdentifier",
+ "accessibilityShouldUseUniqueId",
+ "accessibilitySupportsNotifications",
+ "accessibilitySupportsOverriddenAttributes",
+ "accessibilityTemporaryChildren",
+ "accessibilityTraits",
+ "accessibilityValue",
+ "accessibilityViewIsModal",
+ "accessibilityVisibleArea",
+ "allPropertyKeys",
+ "allowsWeakReference",
+ "attributeKeys",
+ "autoContentAccessingProxy",
+ "autorelease",
+ "awakeFromNib",
+ "boolValueSafe",
+ "bs_encoded",
+ "bs_isPlistableType",
+ "bs_secureEncoded",
+ "cl_json_serializeKey",
+ "class",
+ "classCode",
+ "classDescription",
+ "classForArchiver",
+ "classForCoder",
+ "classForKeyedArchiver",
+ "classForPortCoder",
+ "className",
+ "clearProperties",
+ "copy",
+ "dealloc",
+ "debugDescription",
+ "defaultAccessibilityTraits",
+ "description",
+ "doubleValueSafe",
+ "entityName",
+ "exposedBindings",
+ "finalize",
+ "finishObserving",
+ "flushKeyBindings",
+ "hash",
+ "init",
+ "int64ValueSafe",
+ "isAccessibilityElement",
+ "isAccessibilityElementByDefault",
+ "isElementAccessibilityExposedToInterfaceBuilder",
+ "isFault",
+ "isNSArray__",
+ "isNSCFConstantString__",
+ "isNSData__",
+ "isNSDate__",
+ "isNSDictionary__",
+ "isNSNumber__",
+ "isNSObject__",
+ "isNSOrderedSet__",
+ "isNSSet__",
+ "isNSString__",
+ "isNSTimeZone__",
+ "isNSValue__",
+ "isProxy",
+ "mutableCopy",
+ "nilValueForKey",
+ "objectSpecifier",
+ "observationInfo",
+ "pep_onDetachedThread",
+ "pep_onMainThread",
+ "pep_onMainThreadIfNecessary",
+ "prepareForInterfaceBuilder",
+ "release",
+ "releaseOnMainThread",
+ "retain",
+ "retainCount",
+ "retainWeakReference",
+ "scriptingProperties",
+ "self",
+ "shouldGroupAccessibilityChildren",
+ "storedAccessibilityActivationPoint",
+ "storedAccessibilityContainerType",
+ "storedAccessibilityElementsHidden",
+ "storedAccessibilityFrame",
+ "storedAccessibilityNavigationStyle",
+ "storedAccessibilityTraits",
+ "storedAccessibilityViewIsModal",
+ "storedIsAccessibilityElement",
+ "storedShouldGroupAccessibilityChildren",
+ "stringValueSafe",
+ "superclass",
+ "toManyRelationshipKeys",
+ "toOneRelationshipKeys",
+ "traitStorageList",
+ "un_safeBoolValue",
+ "userInterfaceItemIdentifier",
+ "utf8ValueSafe",
+ "valuesForKeysWithDictionary",
+ "zone",
+ // Protocol: CAAnimatableValue
+ // Protocol: CARenderValue
+ // Protocol: NSObject
+ // Protocol: ROCKRemoteInvocationInterface
+};
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
deleted file mode 100644
index e1bb09f9961..00000000000
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.cc
+++ /dev/null
@@ -1,681 +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/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>
-#include <google/protobuf/io/zero_copy_stream_impl.h>
-#include <google/protobuf/stubs/stl_util.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <algorithm> // std::find()
-#include <iostream>
-#include <sstream>
-
-// 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 errors.
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace objectivec {
-
-namespace {
-
-// This is also found in GPBBootstrap.h, and needs to be kept in sync.
-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) {
- if (message->enum_type_count() > 0) {
- return true;
- }
- for (int i = 0; i < message->nested_type_count(); i++) {
- if (MessageContainsEnums(message->nested_type(i))) {
- return true;
- }
- }
- return false;
-}
-
-// Checks if a message contains any extension definitions (on the message or
-// a nested message under it).
-bool MessageContainsExtensions(const Descriptor* message) {
- if (message->extension_count() > 0) {
- return true;
- }
- for (int i = 0; i < message->nested_type_count(); i++) {
- if (MessageContainsExtensions(message->nested_type(i))) {
- return true;
- }
- }
- return false;
-}
-
-// Checks if the file contains any enum definitions (at the root or
-// nested under a message).
-bool FileContainsEnums(const FileDescriptor* file) {
- if (file->enum_type_count() > 0) {
- return true;
- }
- for (int i = 0; i < file->message_type_count(); i++) {
- if (MessageContainsEnums(file->message_type(i))) {
- return true;
- }
- }
- return false;
-}
-
-// Checks if the file contains any extensions definitions (at the root or
-// nested under a message).
-bool FileContainsExtensions(const FileDescriptor* file) {
- if (file->extension_count() > 0) {
- return true;
- }
- for (int i = 0; i < file->message_type_count(); i++) {
- if (MessageContainsExtensions(file->message_type(i))) {
- return true;
- }
- }
- return false;
-}
-
-bool IsDirectDependency(const FileDescriptor* dep, const FileDescriptor* file) {
- for (int i = 0; i < file->dependency_count(); i++) {
- if (dep == file->dependency(i)) {
- return true;
- }
- }
- return false;
-}
-
-struct FileDescriptorsOrderedByName {
- inline bool operator()(const FileDescriptor* a,
- const FileDescriptor* b) const {
- return a->name() < b->name();
- }
-};
-
-} // namespace
-
-FileGenerator::CommonState::CommonState() { }
-
-const FileGenerator::CommonState::MinDepsEntry&
-FileGenerator::CommonState::CollectMinimalFileDepsContainingExtensionsInternal(
- const FileDescriptor* file) {
- auto it = deps_info_cache_.find(file);
- if (it != deps_info_cache_.end()) {
- return it->second;
- }
-
- std::set<const FileDescriptor*> min_deps_collector;
- std::set<const FileDescriptor*> covered_deps_collector;
- std::set<const FileDescriptor*> to_prune;
- for (int i = 0; i < file->dependency_count(); i++) {
- const FileDescriptor* dep = file->dependency(i);
- MinDepsEntry dep_info =
- CollectMinimalFileDepsContainingExtensionsInternal(dep);
-
- // Everything the dep covered, this file will also cover.
- covered_deps_collector.insert(dep_info.covered_deps.begin(), dep_info.covered_deps.end());
- // Prune everything from the dep's covered list in case another dep lists it
- // as a min dep.
- to_prune.insert(dep_info.covered_deps.begin(), dep_info.covered_deps.end());
-
- // Does the dep have any extensions...
- if (dep_info.has_extensions) {
- // Yes -> Add this file, prune its min_deps and add them to the covered deps.
- min_deps_collector.insert(dep);
- to_prune.insert(dep_info.min_deps.begin(), dep_info.min_deps.end());
- covered_deps_collector.insert(dep_info.min_deps.begin(), dep_info.min_deps.end());
- } else {
- // No -> Just use its min_deps.
- min_deps_collector.insert(dep_info.min_deps.begin(), dep_info.min_deps.end());
- }
- }
-
- const bool file_has_exts = FileContainsExtensions(file);
-
- // Fast path: if nothing to prune or there was only one dep, the prune work is
- // a waste, skip it.
- if (to_prune.empty() || file->dependency_count() == 1) {
- return deps_info_cache_.insert(
- {file, {file_has_exts, min_deps_collector, covered_deps_collector}}).first->second;
- }
-
- std::set<const FileDescriptor*> min_deps;
- std::copy_if(min_deps_collector.begin(), min_deps_collector.end(),
- std::inserter(min_deps, min_deps.end()),
- [&](const FileDescriptor* value){
- return to_prune.find(value) == to_prune.end();
- });
- return deps_info_cache_.insert(
- {file, {file_has_exts, min_deps, covered_deps_collector}}).first->second;
-}
-
-// Collect the deps of the given file that contain extensions. This can be used to
-// create the chain of roots that need to be wired together.
-//
-// NOTE: If any changes are made to this and the supporting functions, you will
-// need to manually validate what the generated code is for the test files:
-// objectivec/Tests/unittest_extension_chain_*.proto
-// There are comments about what the expected code should be line and limited
-// testing objectivec/Tests/GPBUnittestProtos2.m around compilation (#imports
-// specifically).
-const std::vector<const FileDescriptor*>
-FileGenerator::CommonState::CollectMinimalFileDepsContainingExtensions(
- const FileDescriptor* file) {
- std::set<const FileDescriptor*> min_deps =
- CollectMinimalFileDepsContainingExtensionsInternal(file).min_deps;
- // Sort the list since pointer order isn't stable across runs.
- std::vector<const FileDescriptor*> result(min_deps.begin(), min_deps.end());
- std::sort(result.begin(), result.end(), FileDescriptorsOrderedByName());
- return result;
-}
-
-FileGenerator::FileGenerator(const FileDescriptor* file,
- const GenerationOptions& generation_options,
- CommonState& common_state)
- : file_(file),
- generation_options_(generation_options),
- common_state_(common_state),
- root_class_name_(FileClassName(file)),
- 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));
- message_generators_.emplace_back(generator);
- }
- for (int i = 0; i < file_->extension_count(); i++) {
- ExtensionGenerator* generator =
- new ExtensionGenerator(root_class_name_, file_->extension(i));
- extension_generators_.emplace_back(generator);
- }
-}
-
-FileGenerator::~FileGenerator() {}
-
-void FileGenerator::GenerateHeader(io::Printer* printer) {
- std::vector<TProtoStringType> headers;
- // Generated files bundled with the library get minimal imports, everything
- // else gets the wrapper so everything is usable.
- if (is_bundled_proto_) {
- 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");
- }
- PrintFileRuntimePreamble(printer, headers);
-
- // Add some verification that the generated code matches the source the
- // code is being compiled with.
- // NOTE: This captures the raw numeric values at the time the generator was
- // compiled, since that will be the versions for the ObjC runtime at that
- // time. The constants in the generated code will then get their values at
- // at compile time (so checking against the headers being used to compile).
- printer->Print(
- "#if GOOGLE_PROTOBUF_OBJC_VERSION < $google_protobuf_objc_version$\n"
- "#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.\n"
- "#endif\n"
- "#if $google_protobuf_objc_version$ < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION\n"
- "#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.\n"
- "#endif\n"
- "\n",
- "google_protobuf_objc_version", StrCat(GOOGLE_PROTOBUF_OBJC_VERSION));
-
- // 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(
- 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);
- 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);
- }
-
- // Note:
- // deprecated-declarations suppression is only needed if some place in this
- // proto file is something deprecated or if it references something from
- // another file that is deprecated.
- printer->Print(
- "// @@protoc_insertion_point(imports)\n"
- "\n"
- "#pragma clang diagnostic push\n"
- "#pragma clang diagnostic ignored \"-Wdeprecated-declarations\"\n"
- "\n"
- "CF_EXTERN_C_BEGIN\n"
- "\n");
-
- std::set<TProtoStringType> fwd_decls;
- for (const auto& generator : message_generators_) {
- 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) {
- printer->Print("$value$;\n", "value", *i);
- }
- if (fwd_decls.begin() != fwd_decls.end()) {
- printer->Print("\n");
- }
-
- printer->Print(
- "NS_ASSUME_NONNULL_BEGIN\n"
- "\n");
-
- // need to write out all enums first
- for (const auto& generator : enum_generators_) {
- generator->GenerateHeader(printer);
- }
-
- for (const auto& generator : message_generators_) {
- generator->GenerateEnumHeader(printer);
- }
-
- // For extensions to chain together, the Root gets created even if there
- // are no extensions.
- printer->Print(
- "#pragma mark - $root_class_name$\n"
- "\n"
- "/**\n"
- " * Exposes the extension registry for this file.\n"
- " *\n"
- " * The base class provides:\n"
- " * @code\n"
- " * + (GPBExtensionRegistry *)extensionRegistry;\n"
- " * @endcode\n"
- " * which is a @c GPBExtensionRegistry that includes all the extensions defined by\n"
- " * this file and all files that it depends on.\n"
- " **/\n"
- "GPB_FINAL @interface $root_class_name$ : GPBRootObject\n"
- "@end\n"
- "\n",
- "root_class_name", root_class_name_);
-
- if (!extension_generators_.empty()) {
- // The dynamic methods block is only needed if there are extensions.
- printer->Print(
- "@interface $root_class_name$ (DynamicMethods)\n",
- "root_class_name", root_class_name_);
-
- for (const auto& generator : extension_generators_) {
- generator->GenerateMembersHeader(printer);
- }
-
- printer->Print("@end\n\n");
- } // !extension_generators_.empty()
-
- for (const auto& generator : message_generators_) {
- generator->GenerateMessageHeader(printer);
- }
-
- printer->Print(
- "NS_ASSUME_NONNULL_END\n"
- "\n"
- "CF_EXTERN_C_END\n"
- "\n"
- "#pragma clang diagnostic pop\n"
- "\n"
- "// @@protoc_insertion_point(global_scope)\n");
-}
-
-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.
- if (FileContainsEnums(file_)) {
- printer->Print(
- "#import <stdatomic.h>\n"
- "\n");
- }
-
- std::vector<const FileDescriptor*> deps_with_extensions =
- common_state_.CollectMinimalFileDepsContainingExtensions(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(
- 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);
-
- 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);
- }
- }
- }
-
- // If any indirect dependency provided extensions, it needs to be directly
- // imported so it can get merged into the root's extensions registry.
- // See the Note by CollectMinimalFileDepsContainingExtensions before
- // changing this.
- for (std::vector<const FileDescriptor*>::iterator iter =
- deps_with_extensions.begin();
- iter != deps_with_extensions.end(); ++iter) {
- if (!IsDirectDependency(*iter, file_)) {
- import_writer.AddFile(*iter, header_extension);
- }
- }
-
- import_writer.Print(printer);
- }
-
- bool includes_oneof = false;
- for (const auto& generator : message_generators_) {
- if (generator->IncludesOneOfDefinition()) {
- includes_oneof = true;
- break;
- }
- }
-
- std::set<TProtoStringType> fwd_decls;
- for (const auto& generator : message_generators_) {
- generator->DetermineObjectiveCClassDefinitions(&fwd_decls);
- }
- for (const auto& generator : extension_generators_) {
- generator->DetermineObjectiveCClassDefinitions(&fwd_decls);
- }
-
- // Note:
- // deprecated-declarations suppression is only needed if some place in this
- // proto file is something deprecated or if it references something from
- // another file that is deprecated.
- // dollar-in-identifier-extension is needed because we use references to
- // objc class names that have $ in identifiers.
- printer->Print(
- "// @@protoc_insertion_point(imports)\n"
- "\n"
- "#pragma clang diagnostic push\n"
- "#pragma clang diagnostic ignored \"-Wdeprecated-declarations\"\n");
- if (includes_oneof) {
- // The generated code for oneof's uses direct ivar access, suppress the
- // warning in case developer turn that on in the context they compile the
- // generated code.
- printer->Print(
- "#pragma clang diagnostic ignored \"-Wdirect-ivar-access\"\n");
- }
- if (!fwd_decls.empty()) {
- printer->Print(
- "#pragma clang diagnostic ignored \"-Wdollar-in-identifier-extension\"\n");
- }
- printer->Print(
- "\n");
- if (!fwd_decls.empty()) {
- printer->Print(
- "#pragma mark - Objective C Class declarations\n"
- "// Forward declarations of Objective C classes that we can use as\n"
- "// static values in struct initializers.\n"
- "// We don't use [Foo class] because it is not a static value.\n");
- }
- for (const auto& i : fwd_decls) {
- printer->Print("$value$\n", "value", i);
- }
- if (!fwd_decls.empty()) {
- printer->Print("\n");
- }
- printer->Print(
- "#pragma mark - $root_class_name$\n"
- "\n"
- "@implementation $root_class_name$\n\n",
- "root_class_name", root_class_name_);
-
- const bool file_contains_extensions = FileContainsExtensions(file_);
-
- // If there were any extensions or this file has any dependencies, output
- // a registry to override to create the file specific registry.
- if (file_contains_extensions || !deps_with_extensions.empty()) {
- printer->Print(
- "+ (GPBExtensionRegistry*)extensionRegistry {\n"
- " // This is called by +initialize so there is no need to worry\n"
- " // about thread safety and initialization of registry.\n"
- " static GPBExtensionRegistry* registry = nil;\n"
- " if (!registry) {\n"
- " GPB_DEBUG_CHECK_RUNTIME_VERSIONS();\n"
- " registry = [[GPBExtensionRegistry alloc] init];\n");
-
- printer->Indent();
- printer->Indent();
-
- if (file_contains_extensions) {
- printer->Print(
- "static GPBExtensionDescription descriptions[] = {\n");
- printer->Indent();
- for (const auto& generator : extension_generators_) {
- generator->GenerateStaticVariablesInitialization(printer);
- }
- for (const auto& generator : message_generators_) {
- generator->GenerateStaticVariablesInitialization(printer);
- }
- printer->Outdent();
- printer->Print(
- "};\n"
- "for (size_t i = 0; i < sizeof(descriptions) / sizeof(descriptions[0]); ++i) {\n"
- " GPBExtensionDescriptor *extension =\n"
- " [[GPBExtensionDescriptor alloc] initWithExtensionDescription:&descriptions[i]\n"
- " usesClassRefs:YES];\n"
- " [registry addExtension:extension];\n"
- " [self globallyRegisterExtension:extension];\n"
- " [extension release];\n"
- "}\n");
- }
-
- if (deps_with_extensions.empty()) {
- printer->Print(
- "// None of the imports (direct or indirect) defined extensions, so no need to add\n"
- "// them to this registry.\n");
- } else {
- printer->Print(
- "// Merge in the imports (direct or indirect) that defined extensions.\n");
- for (std::vector<const FileDescriptor*>::iterator iter =
- deps_with_extensions.begin();
- iter != deps_with_extensions.end(); ++iter) {
- const TProtoStringType root_class_name(FileClassName((*iter)));
- printer->Print(
- "[registry addExtensions:[$dependency$ extensionRegistry]];\n",
- "dependency", root_class_name);
- }
- }
-
- printer->Outdent();
- printer->Outdent();
-
- printer->Print(
- " }\n"
- " return registry;\n"
- "}\n");
- } else {
- if (file_->dependency_count() > 0) {
- printer->Print(
- "// No extensions in the file and none of the imports (direct or indirect)\n"
- "// defined extensions, so no need to generate +extensionRegistry.\n");
- } else {
- printer->Print(
- "// No extensions in the file and no imports, so no need to generate\n"
- "// +extensionRegistry.\n");
- }
- }
-
- printer->Print("\n@end\n\n");
-
- // File descriptor only needed if there are messages to use it.
- if (!message_generators_.empty()) {
- std::map<TProtoStringType, TProtoStringType> vars;
- vars["root_class_name"] = root_class_name_;
- vars["package"] = file_->package();
- vars["objc_prefix"] = FileClassPrefix(file_);
- switch (file_->syntax()) {
- case FileDescriptor::SYNTAX_UNKNOWN:
- vars["syntax"] = "GPBFileSyntaxUnknown";
- break;
- case FileDescriptor::SYNTAX_PROTO2:
- vars["syntax"] = "GPBFileSyntaxProto2";
- break;
- case FileDescriptor::SYNTAX_PROTO3:
- vars["syntax"] = "GPBFileSyntaxProto3";
- break;
- }
- printer->Print(vars,
- "#pragma mark - $root_class_name$_FileDescriptor\n"
- "\n"
- "static GPBFileDescriptor *$root_class_name$_FileDescriptor(void) {\n"
- " // This is called by +initialize so there is no need to worry\n"
- " // about thread safety of the singleton.\n"
- " static GPBFileDescriptor *descriptor = NULL;\n"
- " if (!descriptor) {\n"
- " GPB_DEBUG_CHECK_RUNTIME_VERSIONS();\n");
- if (!vars["objc_prefix"].empty()) {
- printer->Print(
- vars,
- " descriptor = [[GPBFileDescriptor alloc] initWithPackage:@\"$package$\"\n"
- " objcPrefix:@\"$objc_prefix$\"\n"
- " syntax:$syntax$];\n");
- } else {
- printer->Print(
- vars,
- " descriptor = [[GPBFileDescriptor alloc] initWithPackage:@\"$package$\"\n"
- " syntax:$syntax$];\n");
- }
- printer->Print(
- " }\n"
- " return descriptor;\n"
- "}\n"
- "\n");
- }
-
- for (const auto& generator : enum_generators_) {
- generator->GenerateSource(printer);
- }
- for (const auto& generator : message_generators_) {
- generator->GenerateSource(printer);
- }
-
- printer->Print(
- "\n"
- "#pragma clang diagnostic pop\n"
- "\n"
- "// @@protoc_insertion_point(global_scope)\n");
-}
-
-// Helper to print the import of the runtime support at the top of generated
-// files. This currently only supports the runtime coming from a framework
-// as defined by the official CocoaPod.
-void FileGenerator::PrintFileRuntimePreamble(
- io::Printer* printer,
- const std::vector<TProtoStringType>& headers_to_import) const {
- printer->Print(
- "// Generated by the protocol buffer compiler. DO NOT EDIT!\n"
- "// source: $filename$\n"
- "\n",
- "filename", file_->name());
-
- 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");
-}
-
-} // namespace objectivec
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
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
deleted file mode 100644
index 5122fa46c09..00000000000
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
+++ /dev/null
@@ -1,2044 +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 _MSC_VER
-#include <unistd.h>
-#endif
-#include <climits>
-#include <errno.h>
-#include <fcntl.h>
-#include <fstream>
-#include <iostream>
-#include <sstream>
-#include <stdlib.h>
-#include <unordered_set>
-#include <vector>
-
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
-#include <google/protobuf/compiler/objectivec/objectivec_nsobject_methods.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/zero_copy_stream_impl.h>
-#include <google/protobuf/io/io_win32.h>
-#include <google/protobuf/port.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/port.h>
-#include <google/protobuf/stubs/strutil.h>
-
-// 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 errors.
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace objectivec {
-
-// <io.h> is transitively included in this file. Import the functions explicitly
-// in this port namespace to avoid ambiguous definition.
-namespace posix {
-#ifdef _WIN32
-using ::google::protobuf::io::win32::open;
-#else
-using ::open;
-#endif
-} // namespace port
-
-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)
- : set_(inout_set) {}
-
- virtual bool ConsumeLine(const StringPiece& line, TProtoStringType* out_error) override {
- set_->insert(TProtoStringType(line));
- return true;
- }
-
- private:
- 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; }
-
- const TProtoStringType exception_path() const { return exception_path_; }
- void set_exception_path(const TProtoStringType& path) {
- exception_path_ = path;
- exceptions_.clear();
- }
-
- 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_;
-};
-
-PrefixModeStorage::PrefixModeStorage() {
- // Even thought there are generation options, have an env back door since some
- // of these helpers could be used in other plugins.
-
- 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) {
- if (exceptions_.empty() && !exception_path_.empty()) {
- TProtoStringType error_str;
- SimpleLineCollector collector(&exceptions_);
- if (!ParseSimpleFile(exception_path_, &collector, &error_str)) {
- if (error_str.empty()) {
- error_str = TProtoStringType("protoc:0: warning: Failed to parse")
- + TProtoStringType(" package prefix exceptions file: ")
- + exception_path_;
- }
- std::cerr << error_str << std::endl;
- std::cerr.flush();
- exceptions_.clear();
- }
-
- // If the file was empty put something in it so it doesn't get reloaded over
- // and over.
- if (exceptions_.empty()) {
- exceptions_.insert("<not a real package>");
- }
- }
-
- return exceptions_.count(package) != 0;
-}
-
-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();
-}
-
-void SetUseProtoPackageAsDefaultPrefix(bool on_or_off) {
- g_prefix_mode.set_use_package_name(on_or_off);
-}
-
-TProtoStringType GetProtoPackagePrefixExceptionList() {
- return g_prefix_mode.exception_path();
-}
-
-void SetProtoPackagePrefixExceptionList(const TProtoStringType& file_path) {
- g_prefix_mode.set_exception_path(file_path);
-}
-
-Options::Options() {
- // 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;
- }
- const char* suppressions = getenv("GPB_OBJC_EXPECTED_PACKAGE_PREFIXES_SUPPRESSIONS");
- if (suppressions) {
- expected_prefixes_suppressions =
- Split(suppressions, ";", true);
- }
- prefixes_must_be_registered =
- BoolFromEnvVar("GPB_OBJC_PREFIXES_MUST_BE_REGISTERED", false);
- require_prefixes = BoolFromEnvVar("GPB_OBJC_REQUIRE_PREFIXES", false);
-}
-
-namespace {
-
-std::unordered_set<TProtoStringType> MakeWordsMap(const char* const words[],
- size_t num_words) {
- std::unordered_set<TProtoStringType> result;
- for (int i = 0; i < num_words; i++) {
- result.insert(words[i]);
- }
- return result;
-}
-
-const char* const kUpperSegmentsList[] = {"url", "http", "https"};
-
-std::unordered_set<TProtoStringType> kUpperSegments =
- MakeWordsMap(kUpperSegmentsList, GOOGLE_ARRAYSIZE(kUpperSegmentsList));
-
-bool ascii_isnewline(char c) {
- return c == '\n' || c == '\r';
-}
-
-// Internal helper for name handing.
-// Do not expose this outside of helpers, stick to having functions for specific
-// cases (ClassName(), FieldName()), so there is always consistent suffix rules.
-TProtoStringType UnderscoresToCamelCase(const TProtoStringType& input,
- bool first_capitalized) {
- std::vector<TProtoStringType> values;
- TProtoStringType current;
-
- bool last_char_was_number = false;
- bool last_char_was_lower = false;
- bool last_char_was_upper = false;
- for (int i = 0; i < input.size(); i++) {
- char c = input[i];
- if (ascii_isdigit(c)) {
- if (!last_char_was_number) {
- values.push_back(current);
- current = "";
- }
- current += c;
- last_char_was_number = last_char_was_lower = last_char_was_upper = false;
- last_char_was_number = true;
- } else if (ascii_islower(c)) {
- // lowercase letter can follow a lowercase or uppercase letter
- if (!last_char_was_lower && !last_char_was_upper) {
- values.push_back(current);
- current = "";
- }
- current += c; // already lower
- last_char_was_number = last_char_was_lower = last_char_was_upper = false;
- last_char_was_lower = true;
- } else if (ascii_isupper(c)) {
- if (!last_char_was_upper) {
- values.push_back(current);
- current = "";
- }
- current += ascii_tolower(c);
- last_char_was_number = last_char_was_lower = last_char_was_upper = false;
- last_char_was_upper = true;
- } else {
- last_char_was_number = last_char_was_lower = last_char_was_upper = false;
- }
- }
- values.push_back(current);
-
- TProtoStringType result;
- bool first_segment_forces_upper = false;
- for (std::vector<TProtoStringType>::iterator i = values.begin(); i != values.end();
- ++i) {
- TProtoStringType value = *i;
- bool all_upper = (kUpperSegments.count(value) > 0);
- if (all_upper && (result.length() == 0)) {
- first_segment_forces_upper = true;
- }
- for (int j = 0; j < value.length(); j++) {
- if (j == 0 || all_upper) {
- value[j] = ascii_toupper(value[j]);
- } else {
- // Nothing, already in lower.
- }
- }
- result += value;
- }
- if ((result.length() != 0) &&
- !first_capitalized &&
- !first_segment_forces_upper) {
- result[0] = ascii_tolower(result[0]);
- }
- return result;
-}
-
-const char* const kReservedWordList[] = {
- // Note NSObject Methods:
- // These are brought in from objectivec_nsobject_methods.h that is generated
- // using method_dump.sh. See kNSObjectMethods below.
-
- // Objective C "keywords" that aren't in C
- // From
- // http://stackoverflow.com/questions/1873630/reserved-keywords-in-objective-c
- // with some others added on.
- "id", "_cmd", "super", "in", "out", "inout", "bycopy", "byref", "oneway",
- "self", "instancetype", "nullable", "nonnull", "nil", "Nil",
- "YES", "NO", "weak",
-
- // C/C++ keywords (Incl C++ 0x11)
- // From http://en.cppreference.com/w/cpp/keywords
- "and", "and_eq", "alignas", "alignof", "asm", "auto", "bitand", "bitor",
- "bool", "break", "case", "catch", "char", "char16_t", "char32_t", "class",
- "compl", "const", "constexpr", "const_cast", "continue", "decltype",
- "default", "delete", "double", "dynamic_cast", "else", "enum", "explicit",
- "export", "extern ", "false", "float", "for", "friend", "goto", "if",
- "inline", "int", "long", "mutable", "namespace", "new", "noexcept", "not",
- "not_eq", "nullptr", "operator", "or", "or_eq", "private", "protected",
- "public", "register", "reinterpret_cast", "return", "short", "signed",
- "sizeof", "static", "static_assert", "static_cast", "struct", "switch",
- "template", "this", "thread_local", "throw", "true", "try", "typedef",
- "typeid", "typename", "union", "unsigned", "using", "virtual", "void",
- "volatile", "wchar_t", "while", "xor", "xor_eq",
-
- // C99 keywords
- // From
- // http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8l.doc%2Flanguage%2Fref%2Fkeyw.htm
- "restrict",
-
- // GCC/Clang extension
- "typeof",
-
- // Not a keyword, but will break you
- "NULL",
-
- // C88+ specs call for these to be macros, so depending on what they are
- // defined to be it can lead to odd errors for some Xcode/SDK versions.
- "stdin", "stdout", "stderr",
-
- // Objective-C Runtime typedefs
- // From <obc/runtime.h>
- "Category", "Ivar", "Method", "Protocol",
-
- // GPBMessage Methods
- // Only need to add instance methods that may conflict with
- // method declared in protos. The main cases are methods
- // that take no arguments, or setFoo:/hasFoo: type methods.
- "clear", "data", "delimitedData", "descriptor", "extensionRegistry",
- "extensionsCurrentlySet", "initialized", "isInitialized", "serializedSize",
- "sortedExtensionsInUse", "unknownFields",
-
- // MacTypes.h names
- "Fixed", "Fract", "Size", "LogicalAddress", "PhysicalAddress", "ByteCount",
- "ByteOffset", "Duration", "AbsoluteTime", "OptionBits", "ItemCount",
- "PBVersion", "ScriptCode", "LangCode", "RegionCode", "OSType",
- "ProcessSerialNumber", "Point", "Rect", "FixedPoint", "FixedRect", "Style",
- "StyleParameter", "StyleField", "TimeScale", "TimeBase", "TimeRecord",
-};
-
-// returns true is input starts with __ or _[A-Z] which are reserved identifiers
-// in C/ C++. All calls should go through UnderscoresToCamelCase before getting here
-// but this verifies and allows for future expansion if we decide to redefine what a
-// reserved C identifier is (for example the GNU list
-// https://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html )
-bool IsReservedCIdentifier(const TProtoStringType& input) {
- if (input.length() > 2) {
- if (input.at(0) == '_') {
- if (isupper(input.at(1)) || input.at(1) == '_') {
- return true;
- }
- }
- }
- return false;
-}
-
-TProtoStringType SanitizeNameForObjC(const TProtoStringType& prefix,
- 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 =
- MakeWordsMap(kNSObjectMethodsList, GOOGLE_ARRAYSIZE(kNSObjectMethodsList));
- TProtoStringType sanitized;
- // We add the prefix in the cases where the string is missing a prefix.
- // We define "missing a prefix" as where 'input':
- // a) Doesn't start with the prefix or
- // b) Isn't equivalent to the prefix or
- // c) Has the prefix, but the letter after the prefix is lowercase
- if (HasPrefixString(input, prefix)) {
- if (input.length() == prefix.length() || !ascii_isupper(input[prefix.length()])) {
- sanitized = prefix + input;
- } else {
- sanitized = input;
- }
- } else {
- sanitized = prefix + input;
- }
- if (IsReservedCIdentifier(sanitized) ||
- (kReservedWords.count(sanitized) > 0) ||
- (kNSObjectMethods.count(sanitized) > 0)) {
- if (out_suffix_added) *out_suffix_added = extension;
- return sanitized + extension;
- }
- if (out_suffix_added) out_suffix_added->clear();
- return sanitized;
-}
-
-TProtoStringType NameFromFieldDescriptor(const FieldDescriptor* field) {
- if (field->type() == FieldDescriptor::TYPE_GROUP) {
- return field->message_type()->name();
- } else {
- return field->name();
- }
-}
-
-void PathSplit(const TProtoStringType& path, TProtoStringType* directory,
- TProtoStringType* basename) {
- TProtoStringType::size_type last_slash = path.rfind('/');
- if (last_slash == TProtoStringType::npos) {
- if (directory) {
- *directory = "";
- }
- if (basename) {
- *basename = path;
- }
- } else {
- if (directory) {
- *directory = path.substr(0, last_slash);
- }
- if (basename) {
- *basename = path.substr(last_slash + 1);
- }
- }
-}
-
-bool IsSpecialName(const TProtoStringType& name, const TProtoStringType* special_names,
- size_t count) {
- for (size_t i = 0; i < count; ++i) {
- size_t length = special_names[i].length();
- if (name.compare(0, length, special_names[i]) == 0) {
- if (name.length() > length) {
- // If name is longer than the retained_name[i] that it matches
- // the next character must be not lower case (newton vs newTon vs
- // new_ton).
- return !ascii_islower(name[length]);
- } else {
- return true;
- }
- }
- }
- return false;
-}
-
-TProtoStringType GetZeroEnumNameForFlagType(const FlagType flag_type) {
- switch(flag_type) {
- case FLAGTYPE_DESCRIPTOR_INITIALIZATION:
- return "GPBDescriptorInitializationFlag_None";
- case FLAGTYPE_EXTENSION:
- return "GPBExtensionNone";
- case FLAGTYPE_FIELD:
- return "GPBFieldNone";
- default:
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return "0";
- }
-}
-
-TProtoStringType GetEnumNameForFlagType(const FlagType flag_type) {
- switch(flag_type) {
- case FLAGTYPE_DESCRIPTOR_INITIALIZATION:
- return "GPBDescriptorInitializationFlags";
- case FLAGTYPE_EXTENSION:
- return "GPBExtensionOptions";
- case FLAGTYPE_FIELD:
- return "GPBFieldFlags";
- default:
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return TProtoStringType();
- }
-}
-
-void MaybeUnQuote(StringPiece* input) {
- if ((input->length() >= 2) &&
- ((*input->data() == '\'' || *input->data() == '"')) &&
- ((*input)[input->length() - 1] == *input->data())) {
- input->remove_prefix(1);
- input->remove_suffix(1);
- }
-}
-
-} // namespace
-
-// Escape C++ trigraphs by escaping question marks to \?
-TProtoStringType EscapeTrigraphs(const TProtoStringType& to_escape) {
- return StringReplace(to_escape, "?", "\\?", true);
-}
-
-void TrimWhitespace(StringPiece* input) {
- while (!input->empty() && ascii_isspace(*input->data())) {
- input->remove_prefix(1);
- }
- while (!input->empty() && ascii_isspace((*input)[input->length() - 1])) {
- input->remove_suffix(1);
- }
-}
-
-bool IsRetainedName(const TProtoStringType& name) {
- // List of prefixes from
- // http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html
- static const TProtoStringType retained_names[] = {"new", "alloc", "copy",
- "mutableCopy"};
- return IsSpecialName(name, retained_names,
- sizeof(retained_names) / sizeof(retained_names[0]));
-}
-
-bool IsInitName(const TProtoStringType& name) {
- static const TProtoStringType init_names[] = {"init"};
- return IsSpecialName(name, init_names,
- sizeof(init_names) / sizeof(init_names[0]));
-}
-
-TProtoStringType BaseFileName(const FileDescriptor* file) {
- TProtoStringType basename;
- PathSplit(file->name(), NULL, &basename);
- return basename;
-}
-
-TProtoStringType FileClassPrefix(const FileDescriptor* file) {
- // Always honor the file option.
- if (file->options().has_objc_class_prefix()) {
- return file->options().objc_class_prefix();
- }
-
- // 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 "";
- }
-
- // If the package is in the exceptions list, done.
- if (g_prefix_mode.is_package_exempted(file->package())) {
- return "";
- }
-
- // Transform the package into a prefix: use the dot segments as part,
- // camelcase each one and then join them with underscores, and add an
- // underscore at the end.
- TProtoStringType result;
- const std::vector<TProtoStringType> segments = Split(file->package(), ".", true);
- for (const auto& segment : segments) {
- const TProtoStringType part = UnderscoresToCamelCase(segment, true);
- if (part.empty()) {
- continue;
- }
- if (!result.empty()) {
- result.append("_");
- }
- result.append(part);
- }
- if (!result.empty()) {
- result.append("_");
- }
- return g_prefix_mode.forced_package_prefix() + result;
-}
-
-TProtoStringType FilePath(const FileDescriptor* file) {
- TProtoStringType output;
- TProtoStringType basename;
- TProtoStringType directory;
- PathSplit(file->name(), &directory, &basename);
- if (directory.length() > 0) {
- output = directory + "/";
- }
- basename = StripProto(basename);
-
- // CamelCase to be more ObjC friendly.
- basename = UnderscoresToCamelCase(basename, true);
-
- output += basename;
- return output;
-}
-
-TProtoStringType FilePathBasename(const FileDescriptor* file) {
- TProtoStringType output;
- TProtoStringType basename;
- TProtoStringType directory;
- PathSplit(file->name(), &directory, &basename);
- basename = StripProto(basename);
-
- // CamelCase to be more ObjC friendly.
- output = UnderscoresToCamelCase(basename, true);
-
- return output;
-}
-
-TProtoStringType FileClassName(const FileDescriptor* file) {
- const TProtoStringType prefix = FileClassPrefix(file);
- const TProtoStringType name =
- UnderscoresToCamelCase(StripProto(BaseFileName(file)), true) + "Root";
- // There aren't really any reserved words that end in "Root", but playing
- // it safe and checking.
- return SanitizeNameForObjC(prefix, name, "_RootClass", NULL);
-}
-
-TProtoStringType ClassNameWorker(const Descriptor* descriptor) {
- TProtoStringType name;
- if (descriptor->containing_type() != NULL) {
- name = ClassNameWorker(descriptor->containing_type());
- name += "_";
- }
- return name + descriptor->name();
-}
-
-TProtoStringType ClassNameWorker(const EnumDescriptor* descriptor) {
- TProtoStringType name;
- if (descriptor->containing_type() != NULL) {
- name = ClassNameWorker(descriptor->containing_type());
- name += "_";
- }
- return name + descriptor->name();
-}
-
-TProtoStringType ClassName(const Descriptor* descriptor) {
- return ClassName(descriptor, NULL);
-}
-
-TProtoStringType ClassName(const Descriptor* descriptor,
- TProtoStringType* out_suffix_added) {
- // 1. Message names are used as is (style calls for CamelCase, trust it).
- // 2. Check for reserved word at the very end and then suffix things.
- const TProtoStringType prefix = FileClassPrefix(descriptor->file());
- const TProtoStringType name = ClassNameWorker(descriptor);
- return SanitizeNameForObjC(prefix, name, "_Class", out_suffix_added);
-}
-
-TProtoStringType EnumName(const EnumDescriptor* descriptor) {
- // 1. Enum names are used as is (style calls for CamelCase, trust it).
- // 2. Check for reserved word at the every end and then suffix things.
- // message Fixed {
- // message Size {...}
- // enum Mumble {...}
- // ...
- // }
- // yields Fixed_Class, Fixed_Size.
- const TProtoStringType prefix = FileClassPrefix(descriptor->file());
- const TProtoStringType name = ClassNameWorker(descriptor);
- return SanitizeNameForObjC(prefix, name, "_Enum", NULL);
-}
-
-TProtoStringType EnumValueName(const EnumValueDescriptor* descriptor) {
- // Because of the Switch enum compatibility, the name on the enum has to have
- // the suffix handing, so it slightly diverges from how nested classes work.
- // enum Fixed {
- // FOO = 1
- // }
- // yields Fixed_Enum and Fixed_Enum_Foo (not Fixed_Foo).
- const TProtoStringType class_name = EnumName(descriptor->type());
- const TProtoStringType value_str =
- UnderscoresToCamelCase(descriptor->name(), true);
- const TProtoStringType name = class_name + "_" + value_str;
- // There aren't really any reserved words with an underscore and a leading
- // capital letter, but playing it safe and checking.
- return SanitizeNameForObjC("", name, "_Value", NULL);
-}
-
-TProtoStringType EnumValueShortName(const EnumValueDescriptor* descriptor) {
- // Enum value names (EnumValueName above) are the enum name turned into
- // a class name and then the value name is CamelCased and concatenated; the
- // whole thing then gets sanitized for reserved words.
- // The "short name" is intended to be the final leaf, the value name; but
- // you can't simply send that off to sanitize as that could result in it
- // getting modified when the full name didn't. For example enum
- // "StorageModes" has a value "retain". So the full name is
- // "StorageModes_Retain", but if we sanitize "retain" it would become
- // "RetainValue".
- // So the right way to get the short name is to take the full enum name
- // and then strip off the enum name (leaving the value name and anything
- // done by sanitize).
- const TProtoStringType class_name = EnumName(descriptor->type());
- const TProtoStringType long_name_prefix = class_name + "_";
- const TProtoStringType long_name = EnumValueName(descriptor);
- return StripPrefixString(long_name, long_name_prefix);
-}
-
-TProtoStringType UnCamelCaseEnumShortName(const TProtoStringType& name) {
- TProtoStringType result;
- for (int i = 0; i < name.size(); i++) {
- char c = name[i];
- if (i > 0 && ascii_isupper(c)) {
- result += '_';
- }
- result += ascii_toupper(c);
- }
- return result;
-}
-
-TProtoStringType ExtensionMethodName(const FieldDescriptor* descriptor) {
- const TProtoStringType name = NameFromFieldDescriptor(descriptor);
- const TProtoStringType result = UnderscoresToCamelCase(name, false);
- return SanitizeNameForObjC("", result, "_Extension", NULL);
-}
-
-TProtoStringType FieldName(const FieldDescriptor* field) {
- const TProtoStringType name = NameFromFieldDescriptor(field);
- TProtoStringType result = UnderscoresToCamelCase(name, false);
- if (field->is_repeated() && !field->is_map()) {
- // Add "Array" before do check for reserved worlds.
- result += "Array";
- } else {
- // If it wasn't repeated, but ends in "Array", force on the _p suffix.
- if (HasSuffixString(result, "Array")) {
- result += "_p";
- }
- }
- return SanitizeNameForObjC("", result, "_p", NULL);
-}
-
-TProtoStringType FieldNameCapitalized(const FieldDescriptor* field) {
- // Want the same suffix handling, so upcase the first letter of the other
- // name.
- TProtoStringType result = FieldName(field);
- if (result.length() > 0) {
- result[0] = ascii_toupper(result[0]);
- }
- return result;
-}
-
-TProtoStringType OneofEnumName(const OneofDescriptor* descriptor) {
- const Descriptor* fieldDescriptor = descriptor->containing_type();
- TProtoStringType name = ClassName(fieldDescriptor);
- name += "_" + UnderscoresToCamelCase(descriptor->name(), true) + "_OneOfCase";
- // No sanitize needed because the OS never has names that end in _OneOfCase.
- return name;
-}
-
-TProtoStringType OneofName(const OneofDescriptor* descriptor) {
- TProtoStringType name = UnderscoresToCamelCase(descriptor->name(), false);
- // No sanitize needed because it gets OneOfCase added and that shouldn't
- // ever conflict.
- return name;
-}
-
-TProtoStringType OneofNameCapitalized(const OneofDescriptor* descriptor) {
- // Use the common handling and then up-case the first letter.
- TProtoStringType result = OneofName(descriptor);
- if (result.length() > 0) {
- result[0] = ascii_toupper(result[0]);
- }
- return result;
-}
-
-TProtoStringType ObjCClass(const TProtoStringType& class_name) {
- return TProtoStringType("GPBObjCClass(") + class_name + ")";
-}
-
-TProtoStringType ObjCClassDeclaration(const TProtoStringType& class_name) {
- return TProtoStringType("GPBObjCClassDeclaration(") + class_name + ");";
-}
-
-TProtoStringType UnCamelCaseFieldName(const TProtoStringType& name, const FieldDescriptor* field) {
- TProtoStringType worker(name);
- if (HasSuffixString(worker, "_p")) {
- worker = StripSuffixString(worker, "_p");
- }
- if (field->is_repeated() && HasSuffixString(worker, "Array")) {
- worker = StripSuffixString(worker, "Array");
- }
- if (field->type() == FieldDescriptor::TYPE_GROUP) {
- if (worker.length() > 0) {
- if (ascii_islower(worker[0])) {
- worker[0] = ascii_toupper(worker[0]);
- }
- }
- return worker;
- } else {
- TProtoStringType result;
- for (int i = 0; i < worker.size(); i++) {
- char c = worker[i];
- if (ascii_isupper(c)) {
- if (i > 0) {
- result += '_';
- }
- result += ascii_tolower(c);
- } else {
- result += c;
- }
- }
- return result;
- }
-}
-
-TProtoStringType GetCapitalizedType(const FieldDescriptor* field) {
- switch (field->type()) {
- case FieldDescriptor::TYPE_INT32:
- return "Int32";
- case FieldDescriptor::TYPE_UINT32:
- return "UInt32";
- case FieldDescriptor::TYPE_SINT32:
- return "SInt32";
- case FieldDescriptor::TYPE_FIXED32:
- return "Fixed32";
- case FieldDescriptor::TYPE_SFIXED32:
- return "SFixed32";
- case FieldDescriptor::TYPE_INT64:
- return "Int64";
- case FieldDescriptor::TYPE_UINT64:
- return "UInt64";
- case FieldDescriptor::TYPE_SINT64:
- return "SInt64";
- case FieldDescriptor::TYPE_FIXED64:
- return "Fixed64";
- case FieldDescriptor::TYPE_SFIXED64:
- return "SFixed64";
- case FieldDescriptor::TYPE_FLOAT:
- return "Float";
- case FieldDescriptor::TYPE_DOUBLE:
- return "Double";
- case FieldDescriptor::TYPE_BOOL:
- return "Bool";
- case FieldDescriptor::TYPE_STRING:
- return "String";
- case FieldDescriptor::TYPE_BYTES:
- return "Bytes";
- case FieldDescriptor::TYPE_ENUM:
- return "Enum";
- case FieldDescriptor::TYPE_GROUP:
- return "Group";
- case FieldDescriptor::TYPE_MESSAGE:
- return "Message";
- }
-
- // Some compilers report reaching end of function even though all cases of
- // the enum are handed in the switch.
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return TProtoStringType();
-}
-
-ObjectiveCType GetObjectiveCType(FieldDescriptor::Type field_type) {
- switch (field_type) {
- case FieldDescriptor::TYPE_INT32:
- case FieldDescriptor::TYPE_SINT32:
- case FieldDescriptor::TYPE_SFIXED32:
- return OBJECTIVECTYPE_INT32;
-
- case FieldDescriptor::TYPE_UINT32:
- case FieldDescriptor::TYPE_FIXED32:
- return OBJECTIVECTYPE_UINT32;
-
- case FieldDescriptor::TYPE_INT64:
- case FieldDescriptor::TYPE_SINT64:
- case FieldDescriptor::TYPE_SFIXED64:
- return OBJECTIVECTYPE_INT64;
-
- case FieldDescriptor::TYPE_UINT64:
- case FieldDescriptor::TYPE_FIXED64:
- return OBJECTIVECTYPE_UINT64;
-
- case FieldDescriptor::TYPE_FLOAT:
- return OBJECTIVECTYPE_FLOAT;
-
- case FieldDescriptor::TYPE_DOUBLE:
- return OBJECTIVECTYPE_DOUBLE;
-
- case FieldDescriptor::TYPE_BOOL:
- return OBJECTIVECTYPE_BOOLEAN;
-
- case FieldDescriptor::TYPE_STRING:
- return OBJECTIVECTYPE_STRING;
-
- case FieldDescriptor::TYPE_BYTES:
- return OBJECTIVECTYPE_DATA;
-
- case FieldDescriptor::TYPE_ENUM:
- return OBJECTIVECTYPE_ENUM;
-
- case FieldDescriptor::TYPE_GROUP:
- case FieldDescriptor::TYPE_MESSAGE:
- return OBJECTIVECTYPE_MESSAGE;
- }
-
- // Some compilers report reaching end of function even though all cases of
- // the enum are handed in the switch.
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return OBJECTIVECTYPE_INT32;
-}
-
-bool IsPrimitiveType(const FieldDescriptor* field) {
- ObjectiveCType type = GetObjectiveCType(field);
- switch (type) {
- case OBJECTIVECTYPE_INT32:
- case OBJECTIVECTYPE_UINT32:
- case OBJECTIVECTYPE_INT64:
- case OBJECTIVECTYPE_UINT64:
- case OBJECTIVECTYPE_FLOAT:
- case OBJECTIVECTYPE_DOUBLE:
- case OBJECTIVECTYPE_BOOLEAN:
- case OBJECTIVECTYPE_ENUM:
- return true;
- break;
- default:
- return false;
- }
-}
-
-bool IsReferenceType(const FieldDescriptor* field) {
- return !IsPrimitiveType(field);
-}
-
-static TProtoStringType HandleExtremeFloatingPoint(TProtoStringType val,
- bool add_float_suffix) {
- if (val == "nan") {
- return "NAN";
- } else if (val == "inf") {
- return "INFINITY";
- } else if (val == "-inf") {
- return "-INFINITY";
- } else {
- // float strings with ., e or E need to have f appended
- if (add_float_suffix && (val.find(".") != TProtoStringType::npos ||
- val.find("e") != TProtoStringType::npos ||
- val.find("E") != TProtoStringType::npos)) {
- val += "f";
- }
- return val;
- }
-}
-
-TProtoStringType GPBGenericValueFieldName(const FieldDescriptor* field) {
- // Returns the field within the GPBGenericValue union to use for the given
- // field.
- if (field->is_repeated()) {
- return "valueMessage";
- }
- switch (field->cpp_type()) {
- case FieldDescriptor::CPPTYPE_INT32:
- return "valueInt32";
- case FieldDescriptor::CPPTYPE_UINT32:
- return "valueUInt32";
- case FieldDescriptor::CPPTYPE_INT64:
- return "valueInt64";
- case FieldDescriptor::CPPTYPE_UINT64:
- return "valueUInt64";
- case FieldDescriptor::CPPTYPE_FLOAT:
- return "valueFloat";
- case FieldDescriptor::CPPTYPE_DOUBLE:
- return "valueDouble";
- case FieldDescriptor::CPPTYPE_BOOL:
- return "valueBool";
- case FieldDescriptor::CPPTYPE_STRING:
- if (field->type() == FieldDescriptor::TYPE_BYTES) {
- return "valueData";
- } else {
- return "valueString";
- }
- case FieldDescriptor::CPPTYPE_ENUM:
- return "valueEnum";
- case FieldDescriptor::CPPTYPE_MESSAGE:
- return "valueMessage";
- }
-
- // Some compilers report reaching end of function even though all cases of
- // the enum are handed in the switch.
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return TProtoStringType();
-}
-
-
-TProtoStringType DefaultValue(const FieldDescriptor* field) {
- // Repeated fields don't have defaults.
- if (field->is_repeated()) {
- return "nil";
- }
-
- // Switch on cpp_type since we need to know which default_value_* method
- // of FieldDescriptor to call.
- switch (field->cpp_type()) {
- case FieldDescriptor::CPPTYPE_INT32:
- // gcc and llvm reject the decimal form of kint32min and kint64min.
- if (field->default_value_int32() == INT_MIN) {
- return "-0x80000000";
- }
- return StrCat(field->default_value_int32());
- case FieldDescriptor::CPPTYPE_UINT32:
- return StrCat(field->default_value_uint32()) + "U";
- case FieldDescriptor::CPPTYPE_INT64:
- // gcc and llvm reject the decimal form of kint32min and kint64min.
- if (field->default_value_int64() == LLONG_MIN) {
- return "-0x8000000000000000LL";
- }
- return StrCat(field->default_value_int64()) + "LL";
- case FieldDescriptor::CPPTYPE_UINT64:
- return StrCat(field->default_value_uint64()) + "ULL";
- case FieldDescriptor::CPPTYPE_DOUBLE:
- return HandleExtremeFloatingPoint(
- SimpleDtoa(field->default_value_double()), false);
- case FieldDescriptor::CPPTYPE_FLOAT:
- return HandleExtremeFloatingPoint(
- SimpleFtoa(field->default_value_float()), true);
- case FieldDescriptor::CPPTYPE_BOOL:
- return field->default_value_bool() ? "YES" : "NO";
- case FieldDescriptor::CPPTYPE_STRING: {
- const bool has_default_value = field->has_default_value();
- const TProtoStringType& default_string = field->default_value_string();
- if (!has_default_value || default_string.length() == 0) {
- // If the field is defined as being the empty string,
- // then we will just assign to nil, as the empty string is the
- // default for both strings and data.
- return "nil";
- }
- if (field->type() == FieldDescriptor::TYPE_BYTES) {
- // We want constant fields in our data structures so we can
- // declare them as static. To achieve this we cheat and stuff
- // a escaped c string (prefixed with a length) into the data
- // field, and cast it to an (NSData*) so it will compile.
- // The runtime library knows how to handle it.
-
- // Must convert to a standard byte order for packing length into
- // a cstring.
- arc_ui32 length = ghtonl(default_string.length());
- TProtoStringType bytes((const char*)&length, sizeof(length));
- bytes.append(default_string);
- return "(NSData*)\"" + EscapeTrigraphs(CEscape(bytes)) + "\"";
- } else {
- return "@\"" + EscapeTrigraphs(CEscape(default_string)) + "\"";
- }
- }
- case FieldDescriptor::CPPTYPE_ENUM:
- return EnumValueName(field->default_value_enum());
- case FieldDescriptor::CPPTYPE_MESSAGE:
- return "nil";
- }
-
- // Some compilers report reaching end of function even though all cases of
- // the enum are handed in the switch.
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return TProtoStringType();
-}
-
-bool HasNonZeroDefaultValue(const FieldDescriptor* field) {
- // Repeated fields don't have defaults.
- if (field->is_repeated()) {
- return false;
- }
-
- // As much as checking field->has_default_value() seems useful, it isn't
- // because of enums. proto2 syntax allows the first item in an enum (the
- // default) to be non zero. So checking field->has_default_value() would
- // result in missing this non zero default. See MessageWithOneBasedEnum in
- // objectivec/Tests/unittest_objc.proto for a test Message to confirm this.
-
- // Some proto file set the default to the zero value, so make sure the value
- // isn't the zero case.
- switch (field->cpp_type()) {
- case FieldDescriptor::CPPTYPE_INT32:
- return field->default_value_int32() != 0;
- case FieldDescriptor::CPPTYPE_UINT32:
- return field->default_value_uint32() != 0U;
- case FieldDescriptor::CPPTYPE_INT64:
- return field->default_value_int64() != 0LL;
- case FieldDescriptor::CPPTYPE_UINT64:
- return field->default_value_uint64() != 0ULL;
- case FieldDescriptor::CPPTYPE_DOUBLE:
- return field->default_value_double() != 0.0;
- case FieldDescriptor::CPPTYPE_FLOAT:
- return field->default_value_float() != 0.0f;
- case FieldDescriptor::CPPTYPE_BOOL:
- return field->default_value_bool();
- case FieldDescriptor::CPPTYPE_STRING: {
- const TProtoStringType& default_string = field->default_value_string();
- return default_string.length() != 0;
- }
- case FieldDescriptor::CPPTYPE_ENUM:
- return field->default_value_enum()->number() != 0;
- case FieldDescriptor::CPPTYPE_MESSAGE:
- return false;
- }
-
- // Some compilers report reaching end of function even though all cases of
- // the enum are handed in the switch.
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return false;
-}
-
-TProtoStringType BuildFlagsString(const FlagType flag_type,
- const std::vector<TProtoStringType>& strings) {
- if (strings.empty()) {
- return GetZeroEnumNameForFlagType(flag_type);
- } else if (strings.size() == 1) {
- return strings[0];
- }
- TProtoStringType string("(" + GetEnumNameForFlagType(flag_type) + ")(");
- for (size_t i = 0; i != strings.size(); ++i) {
- if (i > 0) {
- string.append(" | ");
- }
- string.append(strings[i]);
- }
- string.append(")");
- return string;
-}
-
-TProtoStringType BuildCommentsString(const SourceLocation& location,
- bool prefer_single_line) {
- const TProtoStringType& comments = location.leading_comments.empty()
- ? location.trailing_comments
- : location.leading_comments;
- std::vector<TProtoStringType> lines;
- lines = Split(comments, "\n", false);
- while (!lines.empty() && lines.back().empty()) {
- lines.pop_back();
- }
- // If there are no comments, just return an empty string.
- if (lines.empty()) {
- return "";
- }
-
- TProtoStringType prefix;
- TProtoStringType suffix;
- TProtoStringType final_comments;
- TProtoStringType epilogue;
-
- bool add_leading_space = false;
-
- if (prefer_single_line && lines.size() == 1) {
- prefix = "/** ";
- suffix = " */\n";
- } else {
- prefix = "* ";
- suffix = "\n";
- final_comments += "/**\n";
- epilogue = " **/\n";
- add_leading_space = true;
- }
-
- for (int i = 0; i < lines.size(); i++) {
- TProtoStringType line = StripPrefixString(lines[i], " ");
- // HeaderDoc and appledoc use '\' and '@' for markers; escape them.
- line = StringReplace(line, "\\", "\\\\", true);
- line = StringReplace(line, "@", "\\@", true);
- // Decouple / from * to not have inline comments inside comments.
- line = StringReplace(line, "/*", "/\\*", true);
- line = StringReplace(line, "*/", "*\\/", true);
- line = prefix + line;
- StripWhitespace(&line);
- // If not a one line, need to add the first space before *, as
- // StripWhitespace would have removed it.
- line = (add_leading_space ? " " : "") + line;
- final_comments += line + suffix;
- }
- final_comments += epilogue;
- return final_comments;
-}
-
-// Making these a generator option for folks that don't use CocoaPods, but do
-// want to put the library in a framework is an interesting question. The
-// problem is it means changing sources shipped with the library to actually
-// use a different value; so it isn't as simple as a option.
-const char* const ProtobufLibraryFrameworkName = "Protobuf";
-
-TProtoStringType ProtobufFrameworkImportSymbol(const TProtoStringType& framework_name) {
- // GPB_USE_[framework_name]_FRAMEWORK_IMPORTS
- TProtoStringType result = TProtoStringType("GPB_USE_");
- result += ToUpper(framework_name);
- result += "_FRAMEWORK_IMPORTS";
- return result;
-}
-
-bool IsProtobufLibraryBundledProtoFile(const FileDescriptor* file) {
- // We don't check the name prefix or proto package because some files
- // (descriptor.proto), aren't shipped generated by the library, so this
- // seems to be the safest way to only catch the ones shipped.
- const TProtoStringType name = file->name();
- if (name == "google/protobuf/any.proto" ||
- name == "google/protobuf/api.proto" ||
- name == "google/protobuf/duration.proto" ||
- name == "google/protobuf/empty.proto" ||
- name == "google/protobuf/field_mask.proto" ||
- name == "google/protobuf/source_context.proto" ||
- name == "google/protobuf/struct.proto" ||
- name == "google/protobuf/timestamp.proto" ||
- name == "google/protobuf/type.proto" ||
- name == "google/protobuf/wrappers.proto") {
- return true;
- }
- return false;
-}
-
-bool ReadLine(StringPiece* input, StringPiece* line) {
- for (int len = 0; len < input->size(); ++len) {
- if (ascii_isnewline((*input)[len])) {
- *line = StringPiece(input->data(), len);
- ++len; // advance over the newline
- *input = StringPiece(input->data() + len, input->size() - len);
- return true;
- }
- }
- return false; // Ran out of input with no newline.
-}
-
-void RemoveComment(StringPiece* input) {
- int offset = input->find('#');
- if (offset != StringPiece::npos) {
- input->remove_suffix(input->length() - offset);
- }
-}
-
-namespace {
-
-bool PackageToPrefixesCollector::ConsumeLine(
- const StringPiece& line, TProtoStringType* out_error) {
- int offset = line.find('=');
- if (offset == StringPiece::npos) {
- *out_error = usage_ + " file line without equal sign: '" + StrCat(line) + "'.";
- return false;
- }
- StringPiece package = line.substr(0, offset);
- StringPiece prefix = line.substr(offset + 1);
- TrimWhitespace(&package);
- TrimWhitespace(&prefix);
- MaybeUnQuote(&prefix);
- // Don't really worry about error checking the package/prefix for
- // being valid. Assume the file is validated when it is created/edited.
- (*prefix_map_)[TProtoStringType(package)] = TProtoStringType(prefix);
- return true;
-}
-
-bool LoadExpectedPackagePrefixes(const TProtoStringType& expected_prefixes_path,
- std::map<TProtoStringType, TProtoStringType>* prefix_map,
- TProtoStringType* out_error) {
- if (expected_prefixes_path.empty()) {
- return true;
- }
-
- PackageToPrefixesCollector collector("Expected prefixes", prefix_map);
- return ParseSimpleFile(
- expected_prefixes_path, &collector, out_error);
-}
-
-bool ValidateObjCClassPrefix(
- const FileDescriptor* file, const TProtoStringType& expected_prefixes_path,
- const std::map<TProtoStringType, TProtoStringType>& expected_package_prefixes,
- bool prefixes_must_be_registered, bool require_prefixes,
- TProtoStringType* out_error) {
- // Reminder: An explicit prefix option of "" is valid in case the default
- // prefixing is set to use the proto package and a file needs to be generated
- // without any prefix at all (for legacy reasons).
-
- bool has_prefix = file->options().has_objc_class_prefix();
- bool have_expected_prefix_file = !expected_prefixes_path.empty();
-
- 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.
-
- // 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(lookup_key);
- if (package_match != expected_package_prefixes.end()) {
- // There was an entry, and...
- if (has_prefix && package_match->second == prefix) {
- // ...it matches. All good, out of here!
- return true;
- } else {
- // ...it didn't match!
- *out_error = "error: Expected 'option objc_class_prefix = \"" +
- 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";
- }
- *out_error += ".";
- return false;
- }
- }
-
- // If there was no prefix option, we're done at this point.
- if (!has_prefix) {
- if (require_prefixes) {
- *out_error =
- "error: '" + file->name() + "' does not have a required 'option" +
- " objc_class_prefix'.";
- return false;
- }
- return true;
- }
-
- // When the prefix is non empty, check it against the expected entries.
- if (!prefix.empty() && have_expected_prefix_file) {
- // For a non empty prefix, look for any other package that uses the prefix.
- TProtoStringType other_package_for_prefix;
- for (std::map<TProtoStringType, TProtoStringType>::const_iterator i =
- expected_package_prefixes.begin();
- i != expected_package_prefixes.end(); ++i) {
- if (i->second == prefix) {
- other_package_for_prefix = i->first;
- // 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;
- }
- }
- }
-
- // Check: Error - Make sure the prefix wasn't expected for a different
- // package (overlap is allowed, but it has to be listed as an expected
- // overlap).
- if (!other_package_for_prefix.empty()) {
- *out_error =
- "error: Found 'option objc_class_prefix = \"" + prefix +
- "\";' 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() && 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
- // doesn't meet these rules).
- if (!prefix.empty() && !ascii_isupper(prefix[0])) {
- std::cerr
- << "protoc:0: warning: Invalid 'option objc_class_prefix = \""
- << prefix << "\";' in '" << file->name() << "';"
- << " it should start with a capital letter." << std::endl;
- std::cerr.flush();
- }
- if (!prefix.empty() && prefix.length() < 3) {
- // Apple reserves 2 character prefixes for themselves. They do use some
- // 3 character prefixes, but they haven't updated the rules/docs.
- std::cerr
- << "protoc:0: warning: Invalid 'option objc_class_prefix = \""
- << prefix << "\";' in '" << file->name() << "';"
- << " Apple recommends they should be at least 3 characters long."
- << std::endl;
- std::cerr.flush();
- }
-
- // Check: Error/Warning - If the given package/prefix pair wasn't expected,
- // issue a error/warning to added to the file.
- if (have_expected_prefix_file) {
- if (prefixes_must_be_registered) {
- *out_error =
- "error: '" + file->name() + "' has 'option objc_class_prefix = \"" +
- 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 '"
- << lookup_key << " = " << (prefix.empty() ? "\"\"" : prefix)
- << "' to the expected prefixes file (" << expected_prefixes_path
- << ")." << std::endl;
- std::cerr.flush();
- }
-
- return true;
-}
-
-} // 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
- // even the most basic of checks.
- if (generation_options.expected_prefixes_path == "-") {
- return true;
- }
-
- // Load the expected package prefixes, if available, to validate against.
- std::map<TProtoStringType, TProtoStringType> expected_package_prefixes;
- if (!LoadExpectedPackagePrefixes(generation_options.expected_prefixes_path,
- &expected_package_prefixes,
- out_error)) {
- return false;
- }
-
- for (int i = 0; i < files.size(); i++) {
- bool should_skip =
- (std::find(generation_options.expected_prefixes_suppressions.begin(),
- generation_options.expected_prefixes_suppressions.end(),
- files[i]->name())
- != generation_options.expected_prefixes_suppressions.end());
- if (should_skip) {
- continue;
- }
-
- bool is_valid =
- ValidateObjCClassPrefix(files[i],
- generation_options.expected_prefixes_path,
- expected_package_prefixes,
- generation_options.prefixes_must_be_registered,
- generation_options.require_prefixes,
- out_error);
- if (!is_valid) {
- return false;
- }
- }
- return true;
-}
-
-TextFormatDecodeData::TextFormatDecodeData() { }
-
-TextFormatDecodeData::~TextFormatDecodeData() { }
-
-void TextFormatDecodeData::AddString(arc_i32 key,
- const TProtoStringType& input_for_decode,
- const TProtoStringType& desired_output) {
- for (std::vector<DataEntry>::const_iterator i = entries_.begin();
- i != entries_.end(); ++i) {
- if (i->first == key) {
- std::cerr << "error: duplicate key (" << key
- << ") making TextFormat data, input: \"" << input_for_decode
- << "\", desired: \"" << desired_output << "\"." << std::endl;
- std::cerr.flush();
- abort();
- }
- }
-
- const TProtoStringType& data = TextFormatDecodeData::DecodeDataForString(
- input_for_decode, desired_output);
- entries_.push_back(DataEntry(key, data));
-}
-
-TProtoStringType TextFormatDecodeData::Data() const {
- std::ostringstream data_stringstream;
-
- if (num_entries() > 0) {
- io::OstreamOutputStream data_outputstream(&data_stringstream);
- io::CodedOutputStream output_stream(&data_outputstream);
-
- output_stream.WriteVarint32(num_entries());
- for (std::vector<DataEntry>::const_iterator i = entries_.begin();
- i != entries_.end(); ++i) {
- output_stream.WriteVarint32(i->first);
- output_stream.WriteString(i->second);
- }
- }
-
- data_stringstream.flush();
- return TProtoStringType{data_stringstream.str()};
-}
-
-namespace {
-
-// Helper to build up the decode data for a string.
-class DecodeDataBuilder {
- public:
- DecodeDataBuilder() { Reset(); }
-
- bool AddCharacter(const char desired, const char input);
- void AddUnderscore() {
- Push();
- need_underscore_ = true;
- }
- TProtoStringType Finish() {
- Push();
- return decode_data_;
- }
-
- private:
- static constexpr uint8_t kAddUnderscore = 0x80;
-
- static constexpr uint8_t kOpAsIs = 0x00;
- static constexpr uint8_t kOpFirstUpper = 0x40;
- static constexpr uint8_t kOpFirstLower = 0x20;
- static constexpr uint8_t kOpAllUpper = 0x60;
-
- static constexpr int kMaxSegmentLen = 0x1f;
-
- void AddChar(const char desired) {
- ++segment_len_;
- is_all_upper_ &= ascii_isupper(desired);
- }
-
- void Push() {
- uint8_t op = (op_ | segment_len_);
- if (need_underscore_) op |= kAddUnderscore;
- if (op != 0) {
- decode_data_ += (char)op;
- }
- Reset();
- }
-
- bool AddFirst(const char desired, const char input) {
- if (desired == input) {
- op_ = kOpAsIs;
- } else if (desired == ascii_toupper(input)) {
- op_ = kOpFirstUpper;
- } else if (desired == ascii_tolower(input)) {
- op_ = kOpFirstLower;
- } else {
- // Can't be transformed to match.
- return false;
- }
- AddChar(desired);
- return true;
- }
-
- void Reset() {
- need_underscore_ = false;
- op_ = 0;
- segment_len_ = 0;
- is_all_upper_ = true;
- }
-
- bool need_underscore_;
- bool is_all_upper_;
- uint8_t op_;
- int segment_len_;
-
- TProtoStringType decode_data_;
-};
-
-bool DecodeDataBuilder::AddCharacter(const char desired, const char input) {
- // If we've hit the max size, push to start a new segment.
- if (segment_len_ == kMaxSegmentLen) {
- Push();
- }
- if (segment_len_ == 0) {
- return AddFirst(desired, input);
- }
-
- // Desired and input match...
- if (desired == input) {
- // If we aren't transforming it, or we're upper casing it and it is
- // supposed to be uppercase; just add it to the segment.
- if ((op_ != kOpAllUpper) || ascii_isupper(desired)) {
- AddChar(desired);
- return true;
- }
-
- // Add the current segment, and start the next one.
- Push();
- return AddFirst(desired, input);
- }
-
- // If we need to uppercase, and everything so far has been uppercase,
- // promote op to AllUpper.
- if ((desired == ascii_toupper(input)) && is_all_upper_) {
- op_ = kOpAllUpper;
- AddChar(desired);
- return true;
- }
-
- // Give up, push and start a new segment.
- Push();
- return AddFirst(desired, input);
-}
-
-// If decode data can't be generated, a directive for the raw string
-// is used instead.
-TProtoStringType DirectDecodeString(const TProtoStringType& str) {
- TProtoStringType result;
- result += (char)'\0'; // Marker for full string.
- result += str;
- result += (char)'\0'; // End of string.
- return result;
-}
-
-} // namespace
-
-// static
-TProtoStringType TextFormatDecodeData::DecodeDataForString(
- const TProtoStringType& input_for_decode, const TProtoStringType& desired_output) {
- if (input_for_decode.empty() || desired_output.empty()) {
- std::cerr << "error: got empty string for making TextFormat data, input: \""
- << input_for_decode << "\", desired: \"" << desired_output << "\"."
- << std::endl;
- std::cerr.flush();
- abort();
- }
- if ((input_for_decode.find('\0') != TProtoStringType::npos) ||
- (desired_output.find('\0') != TProtoStringType::npos)) {
- std::cerr << "error: got a null char in a string for making TextFormat data,"
- << " input: \"" << CEscape(input_for_decode) << "\", desired: \""
- << CEscape(desired_output) << "\"." << std::endl;
- std::cerr.flush();
- abort();
- }
-
- DecodeDataBuilder builder;
-
- // Walk the output building it from the input.
- int x = 0;
- for (int y = 0; y < desired_output.size(); y++) {
- const char d = desired_output[y];
- if (d == '_') {
- builder.AddUnderscore();
- continue;
- }
-
- if (x >= input_for_decode.size()) {
- // Out of input, no way to encode it, just return a full decode.
- return DirectDecodeString(desired_output);
- }
- if (builder.AddCharacter(d, input_for_decode[x])) {
- ++x; // Consumed one input
- } else {
- // Couldn't transform for the next character, just return a full decode.
- return DirectDecodeString(desired_output);
- }
- }
-
- if (x != input_for_decode.size()) {
- // Extra input (suffix from name sanitizing?), just return a full decode.
- return DirectDecodeString(desired_output);
- }
-
- // Add the end marker.
- return builder.Finish() + (char)'\0';
-}
-
-namespace {
-
-class Parser {
- public:
- Parser(LineConsumer* line_consumer)
- : line_consumer_(line_consumer), line_(0) {}
-
- // Feeds in some input, parse what it can, returning success/failure. Calling
- // again after an error is undefined.
- bool ParseChunk(StringPiece chunk, TProtoStringType* out_error);
-
- // Should be called to finish parsing (after all input has been provided via
- // successful calls to ParseChunk(), calling after a ParseChunk() failure is
- // undefined). Returns success/failure.
- bool Finish(TProtoStringType* out_error);
-
- int last_line() const { return line_; }
-
- private:
- LineConsumer* line_consumer_;
- int line_;
- TProtoStringType leftover_;
-};
-
-bool Parser::ParseChunk(StringPiece chunk, TProtoStringType* out_error) {
- StringPiece full_chunk;
- if (!leftover_.empty()) {
- leftover_ += TProtoStringType(chunk);
- full_chunk = StringPiece(leftover_);
- } else {
- full_chunk = chunk;
- }
-
- StringPiece line;
- while (ReadLine(&full_chunk, &line)) {
- ++line_;
- RemoveComment(&line);
- TrimWhitespace(&line);
- if (!line.empty() && !line_consumer_->ConsumeLine(line, out_error)) {
- if (out_error->empty()) {
- *out_error = "ConsumeLine failed without setting an error.";
- }
- leftover_.clear();
- return false;
- }
- }
-
- if (full_chunk.empty()) {
- leftover_.clear();
- } else {
- leftover_ = TProtoStringType(full_chunk);
- }
- return true;
-}
-
-bool Parser::Finish(TProtoStringType* out_error) {
- // If there is still something to go, flush it with a newline.
- if (!leftover_.empty() && !ParseChunk("\n", out_error)) {
- return false;
- }
- // This really should never fail if ParseChunk succeeded, but check to be sure.
- if (!leftover_.empty()) {
- *out_error = "ParseSimple Internal error: finished with pending data.";
- return false;
- }
- return true;
-}
-
-TProtoStringType FullErrorString(const TProtoStringType& name, int line_num, const TProtoStringType& msg) {
- return TProtoStringType("error: ") + name + " Line " + StrCat(line_num) + ", " + msg;
-}
-
-} // namespace
-
-LineConsumer::LineConsumer() {}
-
-LineConsumer::~LineConsumer() {}
-
-bool ParseSimpleFile(const TProtoStringType& path, LineConsumer* line_consumer,
- TProtoStringType* out_error) {
- int fd;
- do {
- fd = posix::open(path.c_str(), O_RDONLY);
- } while (fd < 0 && errno == EINTR);
- if (fd < 0) {
- *out_error = TProtoStringType("error: Unable to open \"") + path + "\", " +
- strerror(errno);
- return false;
- }
- io::FileInputStream file_stream(fd);
- file_stream.SetCloseOnDelete(true);
-
- return ParseSimpleStream(file_stream, path, line_consumer, out_error);
-}
-
-bool ParseSimpleStream(io::ZeroCopyInputStream& input_stream,
- const TProtoStringType& stream_name,
- LineConsumer* line_consumer,
- TProtoStringType* out_error) {
- TProtoStringType local_error;
- Parser parser(line_consumer);
- const void* buf;
- int buf_len;
- while (input_stream.Next(&buf, &buf_len)) {
- if (buf_len == 0) {
- continue;
- }
-
- if (!parser.ParseChunk(StringPiece(static_cast<const char*>(buf), buf_len),
- &local_error)) {
- *out_error = FullErrorString(stream_name, parser.last_line(), local_error);
- return false;
- }
- }
- if (!parser.Finish(&local_error)) {
- *out_error = FullErrorString(stream_name, parser.last_line(), local_error);
- return false;
- }
- return true;
-}
-
-ImportWriter::ImportWriter(
- const TProtoStringType& generate_for_named_framework,
- const TProtoStringType& named_framework_to_proto_path_mappings_path,
- const TProtoStringType& runtime_import_prefix, bool include_wkt_imports)
- : generate_for_named_framework_(generate_for_named_framework),
- named_framework_to_proto_path_mappings_path_(
- named_framework_to_proto_path_mappings_path),
- runtime_import_prefix_(runtime_import_prefix),
- include_wkt_imports_(include_wkt_imports),
- need_to_parse_mapping_file_(true) {}
-
-ImportWriter::~ImportWriter() {}
-
-void ImportWriter::AddFile(const FileDescriptor* file,
- const TProtoStringType& header_extension) {
- if (IsProtobufLibraryBundledProtoFile(file)) {
- // The imports of the WKTs are only needed within the library itself,
- // in other cases, they get skipped because the generated code already
- // import GPBProtocolBuffers.h and hence proves them.
- if (include_wkt_imports_) {
- const TProtoStringType header_name =
- "GPB" + FilePathBasename(file) + header_extension;
- protobuf_imports_.push_back(header_name);
- }
- return;
- }
-
- // Lazy parse any mappings.
- if (need_to_parse_mapping_file_) {
- ParseFrameworkMappings();
- }
-
- std::map<TProtoStringType, TProtoStringType>::iterator proto_lookup =
- proto_file_to_framework_name_.find(file->name());
- if (proto_lookup != proto_file_to_framework_name_.end()) {
- other_framework_imports_.push_back(
- proto_lookup->second + "/" +
- FilePathBasename(file) + header_extension);
- return;
- }
-
- if (!generate_for_named_framework_.empty()) {
- other_framework_imports_.push_back(
- generate_for_named_framework_ + "/" +
- FilePathBasename(file) + header_extension);
- return;
- }
-
- other_imports_.push_back(FilePath(file) + header_extension);
-}
-
-void ImportWriter::Print(io::Printer* printer) const {
- bool add_blank_line = false;
-
- if (!protobuf_imports_.empty()) {
- PrintRuntimeImports(printer, protobuf_imports_, runtime_import_prefix_);
- add_blank_line = true;
- }
-
- if (!other_framework_imports_.empty()) {
- if (add_blank_line) {
- printer->Print("\n");
- }
-
- for (std::vector<TProtoStringType>::const_iterator iter =
- other_framework_imports_.begin();
- iter != other_framework_imports_.end(); ++iter) {
- printer->Print(
- "#import <$header$>\n",
- "header", *iter);
- }
-
- add_blank_line = true;
- }
-
- if (!other_imports_.empty()) {
- if (add_blank_line) {
- printer->Print("\n");
- }
-
- for (std::vector<TProtoStringType>::const_iterator iter = other_imports_.begin();
- iter != other_imports_.end(); ++iter) {
- printer->Print(
- "#import \"$header$\"\n",
- "header", *iter);
- }
- }
-}
-
-void ImportWriter::PrintRuntimeImports(
- io::Printer* printer, const std::vector<TProtoStringType>& header_to_import,
- const TProtoStringType& runtime_import_prefix, bool default_cpp_symbol) {
- // Given an override, use that.
- if (!runtime_import_prefix.empty()) {
- for (const auto& header : header_to_import) {
- printer->Print(
- " #import \"$import_prefix$/$header$\"\n",
- "import_prefix", runtime_import_prefix,
- "header", header);
- }
- return;
- }
-
- const TProtoStringType framework_name(ProtobufLibraryFrameworkName);
- const TProtoStringType cpp_symbol(ProtobufFrameworkImportSymbol(framework_name));
-
- if (default_cpp_symbol) {
- printer->Print(
- "// This CPP symbol can be defined to use imports that match up to the framework\n"
- "// imports needed when using CocoaPods.\n"
- "#if !defined($cpp_symbol$)\n"
- " #define $cpp_symbol$ 0\n"
- "#endif\n"
- "\n",
- "cpp_symbol", cpp_symbol);
- }
-
- printer->Print(
- "#if $cpp_symbol$\n",
- "cpp_symbol", cpp_symbol);
- for (const auto& header : header_to_import) {
- printer->Print(
- " #import <$framework_name$/$header$>\n",
- "framework_name", framework_name,
- "header", header);
- }
- printer->Print(
- "#else\n");
- for (const auto& header : header_to_import) {
- printer->Print(
- " #import \"$header$\"\n",
- "header", header);
- }
- printer->Print(
- "#endif\n");
-}
-
-void ImportWriter::ParseFrameworkMappings() {
- need_to_parse_mapping_file_ = false;
- if (named_framework_to_proto_path_mappings_path_.empty()) {
- return; // Nothing to do.
- }
-
- ProtoFrameworkCollector collector(&proto_file_to_framework_name_);
- TProtoStringType parse_error;
- if (!ParseSimpleFile(named_framework_to_proto_path_mappings_path_,
- &collector, &parse_error)) {
- std::cerr << "error parsing " << named_framework_to_proto_path_mappings_path_
- << " : " << parse_error << std::endl;
- std::cerr.flush();
- }
-}
-
-bool ImportWriter::ProtoFrameworkCollector::ConsumeLine(
- const StringPiece& line, TProtoStringType* out_error) {
- int offset = line.find(':');
- if (offset == StringPiece::npos) {
- *out_error =
- TProtoStringType("Framework/proto file mapping line without colon sign: '") +
- TProtoStringType(line) + "'.";
- return false;
- }
- StringPiece framework_name = line.substr(0, offset);
- StringPiece proto_file_list = line.substr(offset + 1);
- TrimWhitespace(&framework_name);
-
- int start = 0;
- while (start < proto_file_list.length()) {
- offset = proto_file_list.find(',', start);
- if (offset == StringPiece::npos) {
- offset = proto_file_list.length();
- }
-
- StringPiece proto_file = proto_file_list.substr(start, offset - start);
- TrimWhitespace(&proto_file);
- if (!proto_file.empty()) {
- std::map<TProtoStringType, TProtoStringType>::iterator existing_entry =
- map_->find(TProtoStringType(proto_file));
- if (existing_entry != map_->end()) {
- std::cerr << "warning: duplicate proto file reference, replacing "
- "framework entry for '"
- << TProtoStringType(proto_file) << "' with '" << TProtoStringType(framework_name)
- << "' (was '" << existing_entry->second << "')." << std::endl;
- std::cerr.flush();
- }
-
- if (proto_file.find(' ') != StringPiece::npos) {
- std::cerr << "note: framework mapping file had a proto file with a "
- "space in, hopefully that isn't a missing comma: '"
- << TProtoStringType(proto_file) << "'" << std::endl;
- std::cerr.flush();
- }
-
- (*map_)[TProtoStringType(proto_file)] = TProtoStringType(framework_name);
- }
-
- start = offset + 1;
- }
-
- return true;
-}
-
-} // namespace objectivec
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
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 afbf34b7adf..038fde59269 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
@@ -1,353 +1,2 @@
-// 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.
-
-// Helper functions for generating ObjectiveC code.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_HELPERS_H__
-#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_HELPERS_H__
-
-#include <string>
-#include <vector>
-
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/zero_copy_stream.h>
-
-#include <google/protobuf/port_def.inc>
-
-namespace google {
-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
-// are exported.
-bool PROTOC_EXPORT UseProtoPackageAsDefaultPrefix();
-void PROTOC_EXPORT SetUseProtoPackageAsDefaultPrefix(bool on_or_off);
-// Get/Set the path to a file to load as exceptions when
-// `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 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;
- bool prefixes_must_be_registered;
- bool require_prefixes;
-};
-
-// Escape C++ trigraphs by escaping question marks to "\?".
-TProtoStringType PROTOC_EXPORT EscapeTrigraphs(const TProtoStringType& to_escape);
-
-// Remove white space from either end of a StringPiece.
-void PROTOC_EXPORT TrimWhitespace(StringPiece* input);
-
-// Returns true if the name requires a ns_returns_not_retained attribute applied
-// to it.
-bool PROTOC_EXPORT IsRetainedName(const TProtoStringType& name);
-
-// Returns true if the name starts with "init" and will need to have special
-// handling under ARC.
-bool PROTOC_EXPORT IsInitName(const TProtoStringType& name);
-
-// Gets the objc_class_prefix or the prefix made from the proto package.
-TProtoStringType PROTOC_EXPORT FileClassPrefix(const FileDescriptor* file);
-
-// Gets the path of the file we're going to generate (sans the .pb.h
-// extension). The path will be dependent on the objectivec package
-// declared in the proto package.
-TProtoStringType PROTOC_EXPORT FilePath(const FileDescriptor* file);
-
-// Just like FilePath(), but without the directory part.
-TProtoStringType PROTOC_EXPORT FilePathBasename(const FileDescriptor* file);
-
-// Gets the name of the root class we'll generate in the file. This class
-// is not meant for external consumption, but instead contains helpers that
-// the rest of the classes need
-TProtoStringType PROTOC_EXPORT FileClassName(const FileDescriptor* file);
-
-// These return the fully-qualified class name corresponding to the given
-// descriptor.
-TProtoStringType PROTOC_EXPORT ClassName(const Descriptor* descriptor);
-TProtoStringType PROTOC_EXPORT ClassName(const Descriptor* descriptor,
- TProtoStringType* out_suffix_added);
-TProtoStringType PROTOC_EXPORT EnumName(const EnumDescriptor* descriptor);
-
-// Returns the fully-qualified name of the enum value corresponding to the
-// the descriptor.
-TProtoStringType PROTOC_EXPORT EnumValueName(const EnumValueDescriptor* descriptor);
-
-// Returns the name of the enum value corresponding to the descriptor.
-TProtoStringType PROTOC_EXPORT EnumValueShortName(const EnumValueDescriptor* descriptor);
-
-// Reverse what an enum does.
-TProtoStringType PROTOC_EXPORT UnCamelCaseEnumShortName(const TProtoStringType& name);
-
-// Returns the name to use for the extension (used as the method off the file's
-// Root class).
-TProtoStringType PROTOC_EXPORT ExtensionMethodName(const FieldDescriptor* descriptor);
-
-// Returns the transformed field name.
-TProtoStringType PROTOC_EXPORT FieldName(const FieldDescriptor* field);
-TProtoStringType PROTOC_EXPORT FieldNameCapitalized(const FieldDescriptor* field);
-
-// Returns the transformed oneof name.
-TProtoStringType PROTOC_EXPORT OneofEnumName(const OneofDescriptor* descriptor);
-TProtoStringType PROTOC_EXPORT OneofName(const OneofDescriptor* descriptor);
-TProtoStringType PROTOC_EXPORT OneofNameCapitalized(const OneofDescriptor* descriptor);
-
-// Returns a symbol that can be used in C code to refer to an Objective C
-// class without initializing the class.
-TProtoStringType PROTOC_EXPORT ObjCClass(const TProtoStringType& class_name);
-
-// Declares an Objective C class without initializing the class so that it can
-// be refrerred to by ObjCClass.
-TProtoStringType PROTOC_EXPORT ObjCClassDeclaration(const TProtoStringType& class_name);
-
-inline bool HasPreservingUnknownEnumSemantics(const FileDescriptor* file) {
- return file->syntax() == FileDescriptor::SYNTAX_PROTO3;
-}
-
-inline bool IsMapEntryMessage(const Descriptor* descriptor) {
- return descriptor->options().map_entry();
-}
-
-// Reverse of the above.
-TProtoStringType PROTOC_EXPORT UnCamelCaseFieldName(const TProtoStringType& name,
- const FieldDescriptor* field);
-
-enum ObjectiveCType {
- OBJECTIVECTYPE_INT32,
- OBJECTIVECTYPE_UINT32,
- OBJECTIVECTYPE_INT64,
- OBJECTIVECTYPE_UINT64,
- OBJECTIVECTYPE_FLOAT,
- OBJECTIVECTYPE_DOUBLE,
- OBJECTIVECTYPE_BOOLEAN,
- OBJECTIVECTYPE_STRING,
- OBJECTIVECTYPE_DATA,
- OBJECTIVECTYPE_ENUM,
- OBJECTIVECTYPE_MESSAGE
-};
-
-enum FlagType {
- FLAGTYPE_DESCRIPTOR_INITIALIZATION,
- FLAGTYPE_EXTENSION,
- FLAGTYPE_FIELD
-};
-
-template <class TDescriptor>
-TProtoStringType GetOptionalDeprecatedAttribute(const TDescriptor* descriptor,
- const FileDescriptor* file = NULL,
- bool preSpace = true,
- bool postNewline = false) {
- bool isDeprecated = descriptor->options().deprecated();
- // The file is only passed when checking Messages & Enums, so those types
- // get tagged. At the moment, it doesn't seem to make sense to tag every
- // field or enum value with when the file is deprecated.
- bool isFileLevelDeprecation = false;
- if (!isDeprecated && file) {
- isFileLevelDeprecation = file->options().deprecated();
- isDeprecated = isFileLevelDeprecation;
- }
- if (isDeprecated) {
- TProtoStringType message;
- const FileDescriptor* sourceFile = descriptor->file();
- if (isFileLevelDeprecation) {
- message = sourceFile->name() + " is deprecated.";
- } else {
- message = descriptor->full_name() + " is deprecated (see " +
- sourceFile->name() + ").";
- }
-
- TProtoStringType result = TProtoStringType("GPB_DEPRECATED_MSG(\"") + message + "\")";
- if (preSpace) {
- result.insert(0, " ");
- }
- if (postNewline) {
- result.append("\n");
- }
- return result;
- } else {
- return "";
- }
-}
-
-TProtoStringType PROTOC_EXPORT GetCapitalizedType(const FieldDescriptor* field);
-
-ObjectiveCType PROTOC_EXPORT
-GetObjectiveCType(FieldDescriptor::Type field_type);
-
-inline ObjectiveCType GetObjectiveCType(const FieldDescriptor* field) {
- return GetObjectiveCType(field->type());
-}
-
-bool PROTOC_EXPORT IsPrimitiveType(const FieldDescriptor* field);
-bool PROTOC_EXPORT IsReferenceType(const FieldDescriptor* field);
-
-TProtoStringType PROTOC_EXPORT
-GPBGenericValueFieldName(const FieldDescriptor* field);
-TProtoStringType PROTOC_EXPORT DefaultValue(const FieldDescriptor* field);
-bool PROTOC_EXPORT HasNonZeroDefaultValue(const FieldDescriptor* field);
-
-TProtoStringType PROTOC_EXPORT
-BuildFlagsString(const FlagType type, const std::vector<TProtoStringType>& strings);
-
-// Builds HeaderDoc/appledoc style comments out of the comments in the .proto
-// file.
-TProtoStringType PROTOC_EXPORT BuildCommentsString(const SourceLocation& location,
- bool prefer_single_line);
-
-// The name the commonly used by the library when built as a framework.
-// This lines up to the name used in the CocoaPod.
-extern PROTOC_EXPORT const char* const ProtobufLibraryFrameworkName;
-// Returns the CPP symbol name to use as the gate for framework style imports
-// for the given framework name to use.
-TProtoStringType PROTOC_EXPORT
-ProtobufFrameworkImportSymbol(const TProtoStringType& framework_name);
-
-// Checks if the file is one of the proto's bundled with the library.
-bool PROTOC_EXPORT
-IsProtobufLibraryBundledProtoFile(const FileDescriptor* file);
-
-// Checks the prefix for the given files and outputs any warnings as needed. If
-// there are flat out errors, then out_error is filled in with the first error
-// and the result is false.
-bool PROTOC_EXPORT ValidateObjCClassPrefixes(
- const std::vector<const FileDescriptor*>& files,
- 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.
-class PROTOC_EXPORT TextFormatDecodeData {
- public:
- TextFormatDecodeData();
- ~TextFormatDecodeData();
-
- TextFormatDecodeData(const TextFormatDecodeData&) = delete;
- TextFormatDecodeData& operator=(const TextFormatDecodeData&) = delete;
-
- void AddString(arc_i32 key, const TProtoStringType& input_for_decode,
- const TProtoStringType& desired_output);
- size_t num_entries() const { return entries_.size(); }
- TProtoStringType Data() const;
-
- static TProtoStringType DecodeDataForString(const TProtoStringType& input_for_decode,
- const TProtoStringType& desired_output);
-
- private:
- typedef std::pair<arc_i32, TProtoStringType> DataEntry;
- std::vector<DataEntry> entries_;
-};
-
-// Helper for parsing simple files.
-class PROTOC_EXPORT LineConsumer {
- public:
- LineConsumer();
- virtual ~LineConsumer();
- virtual bool ConsumeLine(const StringPiece& line, TProtoStringType* out_error) = 0;
-};
-
-bool PROTOC_EXPORT ParseSimpleFile(const TProtoStringType& path,
- LineConsumer* line_consumer,
- TProtoStringType* out_error);
-
-bool PROTOC_EXPORT ParseSimpleStream(io::ZeroCopyInputStream& input_stream,
- const TProtoStringType& stream_name,
- LineConsumer* line_consumer,
- TProtoStringType* out_error);
-
-// Helper class for parsing framework import mappings and generating
-// import statements.
-class PROTOC_EXPORT ImportWriter {
- public:
- ImportWriter(const TProtoStringType& generate_for_named_framework,
- const TProtoStringType& named_framework_to_proto_path_mappings_path,
- const TProtoStringType& runtime_import_prefix,
- bool include_wkt_imports);
- ~ImportWriter();
-
- void AddFile(const FileDescriptor* file, const TProtoStringType& header_extension);
- void Print(io::Printer* printer) const;
-
- static void PrintRuntimeImports(io::Printer* printer,
- const std::vector<TProtoStringType>& header_to_import,
- const TProtoStringType& runtime_import_prefix,
- bool default_cpp_symbol = false);
-
- private:
- class ProtoFrameworkCollector : public LineConsumer {
- public:
- ProtoFrameworkCollector(std::map<TProtoStringType, TProtoStringType>* inout_proto_file_to_framework_name)
- : map_(inout_proto_file_to_framework_name) {}
-
- virtual bool ConsumeLine(const StringPiece& line, TProtoStringType* out_error) override;
-
- private:
- std::map<TProtoStringType, TProtoStringType>* map_;
- };
-
- void ParseFrameworkMappings();
-
- const TProtoStringType generate_for_named_framework_;
- const TProtoStringType named_framework_to_proto_path_mappings_path_;
- const TProtoStringType runtime_import_prefix_;
- const bool include_wkt_imports_;
- std::map<TProtoStringType, TProtoStringType> proto_file_to_framework_name_;
- bool need_to_parse_mapping_file_;
-
- std::vector<TProtoStringType> protobuf_imports_;
- std::vector<TProtoStringType> other_framework_imports_;
- std::vector<TProtoStringType> other_imports_;
-};
-
-} // namespace objectivec
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#endif // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_HELPERS_H__
+#include "helpers.h"
+#include "names.h" \ No newline at end of file
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
deleted file mode 100644
index bf73592e566..00000000000
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message.cc
+++ /dev/null
@@ -1,633 +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 <algorithm>
-#include <iostream>
-#include <sstream>
-
-#include <google/protobuf/compiler/objectivec/objectivec_message.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/stubs/stl_util.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/zero_copy_stream_impl.h>
-#include <google/protobuf/descriptor.pb.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace objectivec {
-
-namespace {
-struct FieldOrderingByNumber {
- inline bool operator()(const FieldDescriptor* a,
- const FieldDescriptor* b) const {
- return a->number() < b->number();
- }
-};
-
-int OrderGroupForFieldDescriptor(const FieldDescriptor* descriptor) {
- // The first item in the object structure is our uint32[] for has bits.
- // We then want to order things to make the instances as small as
- // possible. So we follow the has bits with:
- // 1. Anything always 4 bytes - float, *32, enums
- // 2. Anything that is always a pointer (they will be 8 bytes on 64 bit
- // builds and 4 bytes on 32bit builds.
- // 3. Anything always 8 bytes - double, *64
- //
- // NOTE: Bools aren't listed, they were stored in the has bits.
- //
- // Why? Using 64bit builds as an example, this means worse case, we have
- // enough bools that we overflow 1 byte from 4 byte alignment, so 3 bytes
- // are wasted before the 4 byte values. Then if we have an odd number of
- // those 4 byte values, the 8 byte values will be pushed down by 32bits to
- // keep them aligned. But the structure will end 8 byte aligned, so no
- // waste on the end. If you did the reverse order, you could waste 4 bytes
- // before the first 8 byte value (after the has array), then a single
- // bool on the end would need 7 bytes of padding to make the overall
- // structure 8 byte aligned; so 11 bytes, wasted total.
-
- // Anything repeated is a GPB*Array/NSArray, so pointer.
- if (descriptor->is_repeated()) {
- return 3;
- }
-
- switch (descriptor->type()) {
- // All always 8 bytes.
- case FieldDescriptor::TYPE_DOUBLE:
- case FieldDescriptor::TYPE_INT64:
- case FieldDescriptor::TYPE_SINT64:
- case FieldDescriptor::TYPE_UINT64:
- case FieldDescriptor::TYPE_SFIXED64:
- case FieldDescriptor::TYPE_FIXED64:
- return 4;
-
- // Pointers (string and bytes are NSString and NSData); 8 or 4 bytes
- // depending on the build architecture.
- case FieldDescriptor::TYPE_GROUP:
- case FieldDescriptor::TYPE_MESSAGE:
- case FieldDescriptor::TYPE_STRING:
- case FieldDescriptor::TYPE_BYTES:
- return 3;
-
- // All always 4 bytes (enums are int32s).
- case FieldDescriptor::TYPE_FLOAT:
- case FieldDescriptor::TYPE_INT32:
- case FieldDescriptor::TYPE_SINT32:
- case FieldDescriptor::TYPE_UINT32:
- case FieldDescriptor::TYPE_SFIXED32:
- case FieldDescriptor::TYPE_FIXED32:
- case FieldDescriptor::TYPE_ENUM:
- return 2;
-
- // 0 bytes. Stored in the has bits.
- case FieldDescriptor::TYPE_BOOL:
- return 99; // End of the list (doesn't really matter).
- }
-
- // Some compilers report reaching end of function even though all cases of
- // the enum are handed in the switch.
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return 0;
-}
-
-struct FieldOrderingByStorageSize {
- inline bool operator()(const FieldDescriptor* a,
- const FieldDescriptor* b) const {
- // Order by grouping.
- const int order_group_a = OrderGroupForFieldDescriptor(a);
- const int order_group_b = OrderGroupForFieldDescriptor(b);
- if (order_group_a != order_group_b) {
- return order_group_a < order_group_b;
- }
- // Within the group, order by field number (provides stable ordering).
- return a->number() < b->number();
- }
-};
-
-struct ExtensionRangeOrdering {
- bool operator()(const Descriptor::ExtensionRange* a,
- const Descriptor::ExtensionRange* b) const {
- return a->start < b->start;
- }
-};
-
-// Sort the fields of the given Descriptor by number into a new[]'d array
-// and return it.
-const FieldDescriptor** SortFieldsByNumber(const Descriptor* descriptor) {
- const FieldDescriptor** fields =
- new const FieldDescriptor* [descriptor->field_count()];
- for (int i = 0; i < descriptor->field_count(); i++) {
- fields[i] = descriptor->field(i);
- }
- std::sort(fields, fields + descriptor->field_count(), FieldOrderingByNumber());
- return fields;
-}
-
-// Sort the fields of the given Descriptor by storage size into a new[]'d
-// array and return it.
-const FieldDescriptor** SortFieldsByStorageSize(const Descriptor* descriptor) {
- const FieldDescriptor** fields =
- new const FieldDescriptor* [descriptor->field_count()];
- for (int i = 0; i < descriptor->field_count(); i++) {
- fields[i] = descriptor->field(i);
- }
- std::sort(fields, fields + descriptor->field_count(),
- FieldOrderingByStorageSize());
- return fields;
-}
-} // namespace
-
-MessageGenerator::MessageGenerator(const TProtoStringType& root_classname,
- const Descriptor* descriptor)
- : root_classname_(root_classname),
- descriptor_(descriptor),
- field_generators_(descriptor),
- class_name_(ClassName(descriptor_)),
- deprecated_attribute_(GetOptionalDeprecatedAttribute(
- descriptor, descriptor->file(), false, true)) {
- for (int i = 0; i < descriptor_->extension_count(); i++) {
- extension_generators_.emplace_back(
- new ExtensionGenerator(class_name_, descriptor_->extension(i)));
- }
-
- for (int i = 0; i < descriptor_->real_oneof_decl_count(); i++) {
- OneofGenerator* generator = new OneofGenerator(descriptor_->oneof_decl(i));
- oneof_generators_.emplace_back(generator);
- }
-
- for (int i = 0; i < descriptor_->enum_type_count(); i++) {
- EnumGenerator* generator = new EnumGenerator(descriptor_->enum_type(i));
- enum_generators_.emplace_back(generator);
- }
-
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- MessageGenerator* generator =
- new MessageGenerator(root_classname_,
- descriptor_->nested_type(i));
- nested_message_generators_.emplace_back(generator);
- }
-}
-
-MessageGenerator::~MessageGenerator() {}
-
-void MessageGenerator::GenerateStaticVariablesInitialization(
- io::Printer* printer) {
- for (const auto& generator : extension_generators_) {
- generator->GenerateStaticVariablesInitialization(printer);
- }
-
- for (const auto& generator : nested_message_generators_) {
- generator->GenerateStaticVariablesInitialization(printer);
- }
-}
-
-void MessageGenerator::DetermineForwardDeclarations(
- 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, include_external_types);
- }
- }
-
- for (const auto& generator : nested_message_generators_) {
- generator->DetermineForwardDeclarations(fwd_decls, include_external_types);
- }
-}
-
-void MessageGenerator::DetermineObjectiveCClassDefinitions(
- std::set<TProtoStringType>* fwd_decls) {
- if (!IsMapEntryMessage(descriptor_)) {
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* fieldDescriptor = descriptor_->field(i);
- field_generators_.get(fieldDescriptor)
- .DetermineObjectiveCClassDefinitions(fwd_decls);
- }
- }
-
- for (const auto& generator : extension_generators_) {
- generator->DetermineObjectiveCClassDefinitions(fwd_decls);
- }
-
- for (const auto& generator : nested_message_generators_) {
- generator->DetermineObjectiveCClassDefinitions(fwd_decls);
- }
-
- const Descriptor* containing_descriptor = descriptor_->containing_type();
- if (containing_descriptor != NULL) {
- TProtoStringType containing_class = ClassName(containing_descriptor);
- fwd_decls->insert(ObjCClassDeclaration(containing_class));
- }
-}
-
-bool MessageGenerator::IncludesOneOfDefinition() const {
- if (!oneof_generators_.empty()) {
- return true;
- }
-
- for (const auto& generator : nested_message_generators_) {
- if (generator->IncludesOneOfDefinition()) {
- return true;
- }
- }
-
- return false;
-}
-
-void MessageGenerator::GenerateEnumHeader(io::Printer* printer) {
- for (const auto& generator : enum_generators_) {
- generator->GenerateHeader(printer);
- }
-
- for (const auto& generator : nested_message_generators_) {
- generator->GenerateEnumHeader(printer);
- }
-}
-
-void MessageGenerator::GenerateExtensionRegistrationSource(
- io::Printer* printer) {
- for (const auto& generator : extension_generators_) {
- generator->GenerateRegistrationSource(printer);
- }
-
- for (const auto& generator : nested_message_generators_) {
- generator->GenerateExtensionRegistrationSource(printer);
- }
-}
-
-void MessageGenerator::GenerateMessageHeader(io::Printer* printer) {
- // This a a map entry message, just recurse and do nothing directly.
- if (IsMapEntryMessage(descriptor_)) {
- for (const auto& generator : nested_message_generators_) {
- generator->GenerateMessageHeader(printer);
- }
- return;
- }
-
- printer->Print(
- "#pragma mark - $classname$\n"
- "\n",
- "classname", class_name_);
-
- if (descriptor_->field_count()) {
- std::unique_ptr<const FieldDescriptor*[]> sorted_fields(
- SortFieldsByNumber(descriptor_));
-
- printer->Print("typedef GPB_ENUM($classname$_FieldNumber) {\n",
- "classname", class_name_);
- printer->Indent();
-
- for (int i = 0; i < descriptor_->field_count(); i++) {
- field_generators_.get(sorted_fields[i])
- .GenerateFieldNumberConstant(printer);
- }
-
- printer->Outdent();
- printer->Print("};\n\n");
- }
-
- for (const auto& generator : oneof_generators_) {
- generator->GenerateCaseEnum(printer);
- }
-
- TProtoStringType message_comments;
- SourceLocation location;
- if (descriptor_->GetSourceLocation(&location)) {
- message_comments = BuildCommentsString(location, false);
- } else {
- message_comments = "";
- }
-
- printer->Print(
- "$comments$$deprecated_attribute$GPB_FINAL @interface $classname$ : GPBMessage\n\n",
- "classname", class_name_,
- "deprecated_attribute", deprecated_attribute_,
- "comments", message_comments);
-
- std::vector<char> seen_oneofs(oneof_generators_.size(), 0);
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = descriptor_->field(i);
- const OneofDescriptor* oneof = field->real_containing_oneof();
- if (oneof) {
- const int oneof_index = oneof->index();
- if (!seen_oneofs[oneof_index]) {
- seen_oneofs[oneof_index] = 1;
- oneof_generators_[oneof_index]->GeneratePublicCasePropertyDeclaration(
- printer);
- }
- }
- field_generators_.get(field).GeneratePropertyDeclaration(printer);
- }
-
- printer->Print("@end\n\n");
-
- for (int i = 0; i < descriptor_->field_count(); i++) {
- field_generators_.get(descriptor_->field(i))
- .GenerateCFunctionDeclarations(printer);
- }
-
- if (!oneof_generators_.empty()) {
- for (const auto& generator : oneof_generators_) {
- generator->GenerateClearFunctionDeclaration(printer);
- }
- printer->Print("\n");
- }
-
- if (descriptor_->extension_count() > 0) {
- printer->Print("@interface $classname$ (DynamicMethods)\n\n",
- "classname", class_name_);
- for (const auto& generator : extension_generators_) {
- generator->GenerateMembersHeader(printer);
- }
- printer->Print("@end\n\n");
- }
-
- for (const auto& generator : nested_message_generators_) {
- generator->GenerateMessageHeader(printer);
- }
-}
-
-void MessageGenerator::GenerateSource(io::Printer* printer) {
- if (!IsMapEntryMessage(descriptor_)) {
- printer->Print(
- "#pragma mark - $classname$\n"
- "\n",
- "classname", class_name_);
-
- if (!deprecated_attribute_.empty()) {
- // No warnings when compiling the impl of this deprecated class.
- printer->Print(
- "#pragma clang diagnostic push\n"
- "#pragma clang diagnostic ignored \"-Wdeprecated-implementations\"\n"
- "\n");
- }
-
- printer->Print("@implementation $classname$\n\n",
- "classname", class_name_);
-
- for (const auto& generator : oneof_generators_) {
- generator->GeneratePropertyImplementation(printer);
- }
-
- for (int i = 0; i < descriptor_->field_count(); i++) {
- field_generators_.get(descriptor_->field(i))
- .GeneratePropertyImplementation(printer);
- }
-
- std::unique_ptr<const FieldDescriptor*[]> sorted_fields(
- SortFieldsByNumber(descriptor_));
- std::unique_ptr<const FieldDescriptor*[]> size_order_fields(
- SortFieldsByStorageSize(descriptor_));
-
- 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(),
- ExtensionRangeOrdering());
-
- // Assign has bits:
- // 1. FieldGeneratorMap::CalculateHasBits() loops through the fields seeing
- // who needs has bits and assigning them.
- // 2. FieldGenerator::SetOneofIndexBase() overrides has_bit with a negative
- // index that groups all the elements in the oneof.
- size_t num_has_bits = field_generators_.CalculateHasBits();
- size_t sizeof_has_storage = (num_has_bits + 31) / 32;
- if (sizeof_has_storage == 0) {
- // In the case where no field needs has bits, don't let the _has_storage_
- // end up as zero length (zero length arrays are sort of a grey area
- // since it has to be at the start of the struct). This also ensures a
- // field with only oneofs keeps the required negative indices they need.
- sizeof_has_storage = 1;
- }
- // Tell all the fields the oneof base.
- for (const auto& generator : oneof_generators_) {
- generator->SetOneofIndexBase(sizeof_has_storage);
- }
- field_generators_.SetOneofIndexBase(sizeof_has_storage);
- // sizeof_has_storage needs enough bits for the single fields that aren't in
- // any oneof, and then one int32 for each oneof (to store the field number).
- sizeof_has_storage += oneof_generators_.size();
-
- printer->Print(
- "\n"
- "typedef struct $classname$__storage_ {\n"
- " arc_ui32 _has_storage_[$sizeof_has_storage$];\n",
- "classname", class_name_,
- "sizeof_has_storage", StrCat(sizeof_has_storage));
- printer->Indent();
-
- for (int i = 0; i < descriptor_->field_count(); i++) {
- field_generators_.get(size_order_fields[i])
- .GenerateFieldStorageDeclaration(printer);
- }
- printer->Outdent();
-
- printer->Print("} $classname$__storage_;\n\n", "classname", class_name_);
-
-
- printer->Print(
- "// This method is threadsafe because it is initially called\n"
- "// in +initialize for each subclass.\n"
- "+ (GPBDescriptor *)descriptor {\n"
- " static GPBDescriptor *descriptor = nil;\n"
- " if (!descriptor) {\n");
-
- TextFormatDecodeData text_format_decode_data;
- bool has_fields = descriptor_->field_count() > 0;
- bool need_defaults = field_generators_.DoesAnyFieldHaveNonZeroDefault();
- TProtoStringType field_description_type;
- if (need_defaults) {
- field_description_type = "GPBMessageFieldDescriptionWithDefault";
- } else {
- field_description_type = "GPBMessageFieldDescription";
- }
- if (has_fields) {
- printer->Indent();
- printer->Indent();
- printer->Print(
- "static $field_description_type$ fields[] = {\n",
- "field_description_type", field_description_type);
- printer->Indent();
- for (int i = 0; i < descriptor_->field_count(); ++i) {
- const FieldGenerator& field_generator =
- field_generators_.get(sorted_fields[i]);
- field_generator.GenerateFieldDescription(printer, need_defaults);
- if (field_generator.needs_textformat_name_support()) {
- text_format_decode_data.AddString(sorted_fields[i]->number(),
- field_generator.generated_objc_name(),
- field_generator.raw_field_name());
- }
- }
- printer->Outdent();
- printer->Print(
- "};\n");
- printer->Outdent();
- printer->Outdent();
- }
-
- std::map<TProtoStringType, TProtoStringType> vars;
- vars["classname"] = class_name_;
- vars["rootclassname"] = root_classname_;
- vars["fields"] = has_fields ? "fields" : "NULL";
- if (has_fields) {
- vars["fields_count"] =
- "(arc_ui32)(sizeof(fields) / sizeof(" + field_description_type + "))";
- } else {
- vars["fields_count"] = "0";
- }
-
- std::vector<TProtoStringType> init_flags;
- init_flags.push_back("GPBDescriptorInitializationFlag_UsesClassRefs");
- init_flags.push_back("GPBDescriptorInitializationFlag_Proto3OptionalKnown");
- if (need_defaults) {
- init_flags.push_back("GPBDescriptorInitializationFlag_FieldsWithDefault");
- }
- if (descriptor_->options().message_set_wire_format()) {
- init_flags.push_back("GPBDescriptorInitializationFlag_WireFormat");
- }
- vars["init_flags"] = BuildFlagsString(FLAGTYPE_DESCRIPTOR_INITIALIZATION,
- init_flags);
-
- printer->Print(
- vars,
- " GPBDescriptor *localDescriptor =\n"
- " [GPBDescriptor allocDescriptorForClass:[$classname$ class]\n"
- " rootClass:[$rootclassname$ class]\n"
- " file:$rootclassname$_FileDescriptor()\n"
- " fields:$fields$\n"
- " fieldCount:$fields_count$\n"
- " storageSize:sizeof($classname$__storage_)\n"
- " flags:$init_flags$];\n");
- if (!oneof_generators_.empty()) {
- printer->Print(
- " static const char *oneofs[] = {\n");
- for (const auto& generator : oneof_generators_) {
- printer->Print(" \"$name$\",\n", "name",
- generator->DescriptorName());
- }
- printer->Print(
- " };\n"
- " [localDescriptor setupOneofs:oneofs\n"
- " count:(arc_ui32)(sizeof(oneofs) / sizeof(char*))\n"
- " firstHasIndex:$first_has_index$];\n",
- "first_has_index", oneof_generators_[0]->HasIndexAsString());
- }
- if (text_format_decode_data.num_entries() != 0) {
- const TProtoStringType text_format_data_str(text_format_decode_data.Data());
- printer->Print(
- "#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS\n"
- " static const char *extraTextFormatInfo =");
- static const int kBytesPerLine = 40; // allow for escaping
- for (int i = 0; i < text_format_data_str.size(); i += kBytesPerLine) {
- printer->Print(
- "\n \"$data$\"",
- "data", EscapeTrigraphs(
- CEscape(text_format_data_str.substr(i, kBytesPerLine))));
- }
- printer->Print(
- ";\n"
- " [localDescriptor setupExtraTextInfo:extraTextFormatInfo];\n"
- "#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS\n");
- }
- if (!sorted_extensions.empty()) {
- printer->Print(
- " static const GPBExtensionRange ranges[] = {\n");
- for (int i = 0; i < sorted_extensions.size(); i++) {
- printer->Print(" { .start = $start$, .end = $end$ },\n",
- "start", StrCat(sorted_extensions[i]->start),
- "end", StrCat(sorted_extensions[i]->end));
- }
- printer->Print(
- " };\n"
- " [localDescriptor setupExtensionRanges:ranges\n"
- " count:(arc_ui32)(sizeof(ranges) / sizeof(GPBExtensionRange))];\n");
- }
- if (descriptor_->containing_type() != NULL) {
- TProtoStringType containing_class = ClassName(descriptor_->containing_type());
- TProtoStringType parent_class_ref = ObjCClass(containing_class);
- printer->Print(
- " [localDescriptor setupContainingMessageClass:$parent_class_ref$];\n",
- "parent_class_ref", parent_class_ref);
- }
- TProtoStringType suffix_added;
- ClassName(descriptor_, &suffix_added);
- if (!suffix_added.empty()) {
- printer->Print(
- " [localDescriptor setupMessageClassNameSuffix:@\"$suffix$\"];\n",
- "suffix", suffix_added);
- }
- printer->Print(
- " #if defined(DEBUG) && DEBUG\n"
- " NSAssert(descriptor == nil, @\"Startup recursed!\");\n"
- " #endif // DEBUG\n"
- " descriptor = localDescriptor;\n"
- " }\n"
- " return descriptor;\n"
- "}\n\n"
- "@end\n\n");
-
- if (!deprecated_attribute_.empty()) {
- printer->Print(
- "#pragma clang diagnostic pop\n"
- "\n");
- }
-
- for (int i = 0; i < descriptor_->field_count(); i++) {
- field_generators_.get(descriptor_->field(i))
- .GenerateCFunctionImplementations(printer);
- }
-
- for (const auto& generator : oneof_generators_) {
- generator->GenerateClearFunctionImplementation(printer);
- }
- }
-
- for (const auto& generator : enum_generators_) {
- generator->GenerateSource(printer);
- }
-
- for (const auto& generator : nested_message_generators_) {
- generator->GenerateSource(printer);
- }
-}
-
-} // namespace objectivec
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_nsobject_methods.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_nsobject_methods.h
deleted file mode 100644
index 163304665cb..00000000000
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_nsobject_methods.h
+++ /dev/null
@@ -1,197 +0,0 @@
-// NSObject methods
-// Autogenerated by method_dump.sh. Do not edit by hand.
-// Date: Thu Nov 1 14:12:16 PDT 2018
-// macOS: MacOSX10.14.sdk
-// iOS: iPhoneSimulator12.1.sdk
-
-const char* const kNSObjectMethodsList[] = {
- "CAMLType",
- "CA_copyRenderValue",
- "CA_prepareRenderValue",
- "NS_copyCGImage",
- "NS_tiledLayerVisibleRect",
- "___tryRetain_OA",
- "__autorelease_OA",
- "__dealloc_zombie",
- "__release_OA",
- "__retain_OA",
- "_accessibilityFinalize",
- "_accessibilityIsTableViewDescendant",
- "_accessibilityUIElementSpecifier",
- "_accessibilityUseConvenienceAPI",
- "_allowsDirectEncoding",
- "_asScriptTerminologyNameArray",
- "_asScriptTerminologyNameString",
- "_bindingAdaptor",
- "_cfTypeID",
- "_copyDescription",
- "_destroyObserverList",
- "_didEndKeyValueObserving",
- "_implicitObservationInfo",
- "_internalAccessibilityAttributedHint",
- "_internalAccessibilityAttributedLabel",
- "_internalAccessibilityAttributedValue",
- "_isAXConnector",
- "_isAccessibilityContainerSectionCandidate",
- "_isAccessibilityContentNavigatorSectionCandidate",
- "_isAccessibilityContentSectionCandidate",
- "_isAccessibilityTopLevelNavigatorSectionCandidate",
- "_isDeallocating",
- "_isKVOA",
- "_isToManyChangeInformation",
- "_ivarDescription",
- "_localClassNameForClass",
- "_methodDescription",
- "_observerStorage",
- "_overrideUseFastBlockObservers",
- "_propertyDescription",
- "_releaseBindingAdaptor",
- "_scriptingCount",
- "_scriptingCountNonrecursively",
- "_scriptingDebugDescription",
- "_scriptingExists",
- "_scriptingShouldCheckObjectIndexes",
- "_shortMethodDescription",
- "_shouldSearchChildrenForSection",
- "_traitStorageList",
- "_tryRetain",
- "_ui_descriptionBuilder",
- "_uikit_variesByTraitCollections",
- "_web_description",
- "_webkit_invokeOnMainThread",
- "_willBeginKeyValueObserving",
- "accessibilityActivate",
- "accessibilityActivationPoint",
- "accessibilityAllowsOverriddenAttributesWhenIgnored",
- "accessibilityAssistiveTechnologyFocusedIdentifiers",
- "accessibilityAttributedHint",
- "accessibilityAttributedLabel",
- "accessibilityAttributedValue",
- "accessibilityContainer",
- "accessibilityContainerType",
- "accessibilityCustomActions",
- "accessibilityCustomRotors",
- "accessibilityDecrement",
- "accessibilityDragSourceDescriptors",
- "accessibilityDropPointDescriptors",
- "accessibilityElementCount",
- "accessibilityElementDidBecomeFocused",
- "accessibilityElementDidLoseFocus",
- "accessibilityElementIsFocused",
- "accessibilityElements",
- "accessibilityElementsHidden",
- "accessibilityFrame",
- "accessibilityHeaderElements",
- "accessibilityHint",
- "accessibilityIdentification",
- "accessibilityIdentifier",
- "accessibilityIncrement",
- "accessibilityLabel",
- "accessibilityLanguage",
- "accessibilityLocalizedStringKey",
- "accessibilityNavigationStyle",
- "accessibilityOverriddenAttributes",
- "accessibilityParameterizedAttributeNames",
- "accessibilityPath",
- "accessibilityPerformEscape",
- "accessibilityPerformMagicTap",
- "accessibilityPresenterProcessIdentifier",
- "accessibilityShouldUseUniqueId",
- "accessibilitySupportsNotifications",
- "accessibilitySupportsOverriddenAttributes",
- "accessibilityTemporaryChildren",
- "accessibilityTraits",
- "accessibilityValue",
- "accessibilityViewIsModal",
- "accessibilityVisibleArea",
- "allPropertyKeys",
- "allowsWeakReference",
- "attributeKeys",
- "autoContentAccessingProxy",
- "autorelease",
- "awakeFromNib",
- "boolValueSafe",
- "bs_encoded",
- "bs_isPlistableType",
- "bs_secureEncoded",
- "cl_json_serializeKey",
- "class",
- "classCode",
- "classDescription",
- "classForArchiver",
- "classForCoder",
- "classForKeyedArchiver",
- "classForPortCoder",
- "className",
- "clearProperties",
- "copy",
- "dealloc",
- "debugDescription",
- "defaultAccessibilityTraits",
- "description",
- "doubleValueSafe",
- "entityName",
- "exposedBindings",
- "finalize",
- "finishObserving",
- "flushKeyBindings",
- "hash",
- "init",
- "int64ValueSafe",
- "isAccessibilityElement",
- "isAccessibilityElementByDefault",
- "isElementAccessibilityExposedToInterfaceBuilder",
- "isFault",
- "isNSArray__",
- "isNSCFConstantString__",
- "isNSData__",
- "isNSDate__",
- "isNSDictionary__",
- "isNSNumber__",
- "isNSObject__",
- "isNSOrderedSet__",
- "isNSSet__",
- "isNSString__",
- "isNSTimeZone__",
- "isNSValue__",
- "isProxy",
- "mutableCopy",
- "nilValueForKey",
- "objectSpecifier",
- "observationInfo",
- "pep_onDetachedThread",
- "pep_onMainThread",
- "pep_onMainThreadIfNecessary",
- "prepareForInterfaceBuilder",
- "release",
- "releaseOnMainThread",
- "retain",
- "retainCount",
- "retainWeakReference",
- "scriptingProperties",
- "self",
- "shouldGroupAccessibilityChildren",
- "storedAccessibilityActivationPoint",
- "storedAccessibilityContainerType",
- "storedAccessibilityElementsHidden",
- "storedAccessibilityFrame",
- "storedAccessibilityNavigationStyle",
- "storedAccessibilityTraits",
- "storedAccessibilityViewIsModal",
- "storedIsAccessibilityElement",
- "storedShouldGroupAccessibilityChildren",
- "stringValueSafe",
- "superclass",
- "toManyRelationshipKeys",
- "toOneRelationshipKeys",
- "traitStorageList",
- "un_safeBoolValue",
- "userInterfaceItemIdentifier",
- "utf8ValueSafe",
- "valuesForKeysWithDictionary",
- "zone",
-// Protocol: CAAnimatableValue
-// Protocol: CARenderValue
-// Protocol: NSObject
-// Protocol: ROCKRemoteInvocationInterface
-};
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/oneof.cc
index 5197ff63a37..aa534d32f7b 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/oneof.cc
@@ -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.
-#include <map>
+#include "google/protobuf/compiler/objectivec/oneof.h"
+
#include <string>
-#include <google/protobuf/compiler/objectivec/objectivec_oneof.h>
-#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/objectivec/helpers.h"
+#include "google/protobuf/compiler/objectivec/names.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
@@ -46,7 +47,7 @@ OneofGenerator::OneofGenerator(const OneofDescriptor* descriptor)
variables_["enum_name"] = OneofEnumName(descriptor_);
variables_["name"] = OneofName(descriptor_);
variables_["capitalized_name"] = OneofNameCapitalized(descriptor_);
- variables_["raw_index"] = StrCat(descriptor_->index());
+ variables_["raw_index"] = y_absl::StrCat(descriptor_->index());
const Descriptor* msg_descriptor = descriptor_->containing_type();
variables_["owning_message_class"] = ClassName(msg_descriptor);
@@ -60,63 +61,63 @@ OneofGenerator::OneofGenerator(const OneofDescriptor* descriptor)
variables_["comments"] = comments;
}
-OneofGenerator::~OneofGenerator() {}
-
void OneofGenerator::SetOneofIndexBase(int index_base) {
int index = descriptor_->index() + index_base;
// Flip the sign to mark it as a oneof.
- variables_["index"] = StrCat(-index);
+ variables_["index"] = y_absl::StrCat(-index);
}
-void OneofGenerator::GenerateCaseEnum(io::Printer* printer) {
- printer->Print(
- variables_,
- "typedef GPB_ENUM($enum_name$) {\n");
+void OneofGenerator::GenerateCaseEnum(io::Printer* printer) const {
+ printer->Print(variables_, "typedef GPB_ENUM($enum_name$) {\n");
printer->Indent();
- printer->Print(
- variables_,
- "$enum_name$_GPBUnsetOneOfCase = 0,\n");
- TProtoStringType enum_name = variables_["enum_name"];
+ printer->Print(variables_, "$enum_name$_GPBUnsetOneOfCase = 0,\n");
+ TProtoStringType enum_name = variables_.find("enum_name")->second;
for (int j = 0; j < descriptor_->field_count(); j++) {
const FieldDescriptor* field = descriptor_->field(j);
TProtoStringType field_name = FieldNameCapitalized(field);
- printer->Print(
- "$enum_name$_$field_name$ = $field_number$,\n",
- "enum_name", enum_name,
- "field_name", field_name,
- "field_number", StrCat(field->number()));
+ printer->Print("$enum_name$_$field_name$ = $field_number$,\n", "enum_name",
+ enum_name, "field_name", field_name, "field_number",
+ y_absl::StrCat(field->number()));
}
printer->Outdent();
+ // clang-format off
printer->Print(
"};\n"
"\n");
+ // clang-format on
}
void OneofGenerator::GeneratePublicCasePropertyDeclaration(
- io::Printer* printer) {
+ io::Printer* printer) const {
+ // clang-format off
printer->Print(
variables_,
"$comments$"
"@property(nonatomic, readonly) $enum_name$ $name$OneOfCase;\n"
"\n");
+ // clang-format on
}
-void OneofGenerator::GenerateClearFunctionDeclaration(io::Printer* printer) {
+void OneofGenerator::GenerateClearFunctionDeclaration(
+ io::Printer* printer) const {
+ // clang-format off
printer->Print(
variables_,
"/**\n"
" * Clears whatever value was set for the oneof '$name$'.\n"
" **/\n"
"void $owning_message_class$_Clear$capitalized_name$OneOfCase($owning_message_class$ *message);\n");
+ // clang-format on
}
-void OneofGenerator::GeneratePropertyImplementation(io::Printer* printer) {
- printer->Print(
- variables_,
- "@dynamic $name$OneOfCase;\n");
+void OneofGenerator::GeneratePropertyImplementation(
+ io::Printer* printer) const {
+ printer->Print(variables_, "@dynamic $name$OneOfCase;\n");
}
-void OneofGenerator::GenerateClearFunctionImplementation(io::Printer* printer) {
+void OneofGenerator::GenerateClearFunctionImplementation(
+ io::Printer* printer) const {
+ // clang-format off
printer->Print(
variables_,
"void $owning_message_class$_Clear$capitalized_name$OneOfCase($owning_message_class$ *message) {\n"
@@ -124,13 +125,14 @@ void OneofGenerator::GenerateClearFunctionImplementation(io::Printer* printer) {
" GPBOneofDescriptor *oneof = [descriptor.oneofs objectAtIndex:$raw_index$];\n"
" GPBClearOneof(message, oneof);\n"
"}\n");
+ // clang-format on
}
-TProtoStringType OneofGenerator::DescriptorName(void) const {
+TProtoStringType OneofGenerator::DescriptorName() const {
return variables_.find("name")->second;
}
-TProtoStringType OneofGenerator::HasIndexAsString(void) const {
+TProtoStringType OneofGenerator::HasIndexAsString() const {
return variables_.find("index")->second;
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_oneof.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/oneof.h
index 4173a0325cc..411f832f21e 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_oneof.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/oneof.h
@@ -32,10 +32,11 @@
#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_ONEOF_H__
#include <string>
-#include <set>
#include <vector>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/io/printer.h>
+
+#include "y_absl/container/flat_hash_map.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
@@ -45,27 +46,27 @@ namespace objectivec {
class OneofGenerator {
public:
explicit OneofGenerator(const OneofDescriptor* descriptor);
- ~OneofGenerator();
+ ~OneofGenerator() = default;
OneofGenerator(const OneofGenerator&) = delete;
OneofGenerator& operator=(const OneofGenerator&) = delete;
void SetOneofIndexBase(int index_base);
- void GenerateCaseEnum(io::Printer* printer);
+ void GenerateCaseEnum(io::Printer* printer) const;
- void GeneratePublicCasePropertyDeclaration(io::Printer* printer);
- void GenerateClearFunctionDeclaration(io::Printer* printer);
+ void GeneratePublicCasePropertyDeclaration(io::Printer* printer) const;
+ void GenerateClearFunctionDeclaration(io::Printer* printer) const;
- void GeneratePropertyImplementation(io::Printer* printer);
- void GenerateClearFunctionImplementation(io::Printer* printer);
+ void GeneratePropertyImplementation(io::Printer* printer) const;
+ void GenerateClearFunctionImplementation(io::Printer* printer) const;
- TProtoStringType DescriptorName(void) const;
- TProtoStringType HasIndexAsString(void) const;
+ TProtoStringType DescriptorName() const;
+ TProtoStringType HasIndexAsString() const;
private:
const OneofDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> variables_;
};
} // namespace objectivec
diff --git a/contrib/libs/protobuf/src/google/protobuf/util/internal/object_location_tracker.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/options.h
index ff99d04b899..d0f7ee0c763 100644
--- a/contrib/libs/protobuf/src/google/protobuf/util/internal/object_location_tracker.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/options.h
@@ -28,37 +28,30 @@
// (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_OBJECT_LOCATION_TRACKER_H__
-#define GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_LOCATION_TRACKER_H__
+#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_OPTIONS_H__
+#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_OPTIONS_H__
#include <string>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/util/internal/location_tracker.h>
-
namespace google {
namespace protobuf {
-namespace util {
-namespace converter {
-
-// An empty concrete implementation of LocationTrackerInterface.
-class ObjectLocationTracker : public LocationTrackerInterface {
- public:
- // Creates an empty location tracker.
- ObjectLocationTracker() {}
-
- ~ObjectLocationTracker() override {}
-
- // Returns empty because nothing is tracked.
- TProtoStringType ToString() const override { return ""; }
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ObjectLocationTracker);
+namespace compiler {
+namespace objectivec {
+
+// Generation options, documented within generator.cc.
+struct GenerationOptions {
+ TProtoStringType generate_for_named_framework;
+ TProtoStringType named_framework_to_proto_path_mappings_path;
+ TProtoStringType runtime_import_prefix;
+ // TODO(thomasvl): Eventually flip this default to false for better interop
+ // with Swift if proto usages span modules made from ObjC sources.
+ bool headers_use_forward_declarations = true;
+ bool experimental_multi_source_generation = false;
};
-} // namespace converter
-} // namespace util
+} // namespace objectivec
+} // namespace compiler
} // namespace protobuf
} // namespace google
-#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_LOCATION_TRACKER_H__
+#endif // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_OPTIONS_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/primitive_field.cc
index f83e2691aee..aa839ecf2b4 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/primitive_field.cc
@@ -28,22 +28,21 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <map>
+#include "google/protobuf/compiler/objectivec/primitive_field.h"
+
#include <string>
-#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
-#include <google/protobuf/compiler/objectivec/objectivec_primitive_field.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/str_cat.h"
+#include "google/protobuf/compiler/objectivec/helpers.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
namespace compiler {
namespace objectivec {
-using internal::WireFormat;
-using internal::WireFormatLite;
-
namespace {
const char* PrimitiveTypeName(const FieldDescriptor* descriptor) {
@@ -70,13 +69,13 @@ const char* PrimitiveTypeName(const FieldDescriptor* descriptor) {
case OBJECTIVECTYPE_ENUM:
return "arc_i32";
case OBJECTIVECTYPE_MESSAGE:
- return NULL; // Messages go through objectivec_message_field.cc|h.
+ return nullptr; // Messages go through message_field.cc|h.
}
// Some compilers report reaching end of function even though all cases of
// the enum are handed in the switch.
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return NULL;
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
+ return nullptr;
}
const char* PrimitiveArrayTypeName(const FieldDescriptor* descriptor) {
@@ -103,18 +102,19 @@ const char* PrimitiveArrayTypeName(const FieldDescriptor* descriptor) {
case OBJECTIVECTYPE_ENUM:
return "Enum";
case OBJECTIVECTYPE_MESSAGE:
- // Want NSArray (but goes through objectivec_message_field.cc|h).
+ // Want NSArray (but goes through message_field.cc|h).
return "";
}
// Some compilers report reaching end of function even though all cases of
// the enum are handed in the switch.
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return NULL;
+ Y_ABSL_LOG(FATAL) << "Can't get here.";
+ return nullptr;
}
-void SetPrimitiveVariables(const FieldDescriptor* descriptor,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+void SetPrimitiveVariables(
+ const FieldDescriptor* descriptor,
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType>* variables) {
TProtoStringType primitive_name = PrimitiveTypeName(descriptor);
(*variables)["type"] = primitive_name;
(*variables)["storage_type"] = primitive_name;
@@ -128,8 +128,6 @@ PrimitiveFieldGenerator::PrimitiveFieldGenerator(
SetPrimitiveVariables(descriptor, &variables_);
}
-PrimitiveFieldGenerator::~PrimitiveFieldGenerator() {}
-
void PrimitiveFieldGenerator::GenerateFieldStorageDeclaration(
io::Printer* printer) const {
if (GetObjectiveCType(descriptor_) == OBJECTIVECTYPE_BOOLEAN) {
@@ -139,7 +137,7 @@ void PrimitiveFieldGenerator::GenerateFieldStorageDeclaration(
}
}
-int PrimitiveFieldGenerator::ExtraRuntimeHasBitsNeeded(void) const {
+int PrimitiveFieldGenerator::ExtraRuntimeHasBitsNeeded() const {
if (GetObjectiveCType(descriptor_) == OBJECTIVECTYPE_BOOLEAN) {
// Reserve a bit for the storage of the boolean.
return 1;
@@ -147,10 +145,10 @@ int PrimitiveFieldGenerator::ExtraRuntimeHasBitsNeeded(void) const {
return 0;
}
-void PrimitiveFieldGenerator::SetExtraRuntimeHasBitsBase(int has_base) {
+void PrimitiveFieldGenerator::SetExtraRuntimeHasBitsBase(int index_base) {
if (GetObjectiveCType(descriptor_) == OBJECTIVECTYPE_BOOLEAN) {
// Set into the offset the has bit to use for the actual value.
- variables_["storage_offset_value"] = StrCat(has_base);
+ variables_["storage_offset_value"] = y_absl::StrCat(index_base);
variables_["storage_offset_comment"] =
" // Stored in _has_storage_ to save space.";
}
@@ -163,8 +161,6 @@ PrimitiveObjFieldGenerator::PrimitiveObjFieldGenerator(
variables_["property_storage_attribute"] = "copy";
}
-PrimitiveObjFieldGenerator::~PrimitiveObjFieldGenerator() {}
-
RepeatedPrimitiveFieldGenerator::RepeatedPrimitiveFieldGenerator(
const FieldDescriptor* descriptor)
: RepeatedFieldGenerator(descriptor) {
@@ -172,16 +168,15 @@ RepeatedPrimitiveFieldGenerator::RepeatedPrimitiveFieldGenerator(
TProtoStringType base_name = PrimitiveArrayTypeName(descriptor);
if (base_name.length()) {
- variables_["array_storage_type"] = "GPB" + base_name + "Array";
+ variables_["array_storage_type"] = y_absl::StrCat("GPB", base_name, "Array");
} else {
+ TProtoStringType storage_type = variables_["storage_type"];
variables_["array_storage_type"] = "NSMutableArray";
variables_["array_property_type"] =
- "NSMutableArray<" + variables_["storage_type"] + "*>";
+ y_absl::StrCat("NSMutableArray<", storage_type, "*>");
}
}
-RepeatedPrimitiveFieldGenerator::~RepeatedPrimitiveFieldGenerator() {}
-
} // namespace objectivec
} // namespace compiler
} // namespace protobuf
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/primitive_field.h
index 06a1528a82a..e6916055cd5 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/primitive_field.h
@@ -31,7 +31,7 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_PRIMITIVE_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_PRIMITIVE_FIELD_H__
-#include <google/protobuf/compiler/objectivec/objectivec_field.h>
+#include "google/protobuf/compiler/objectivec/field.h"
namespace google {
namespace protobuf {
@@ -43,15 +43,15 @@ class PrimitiveFieldGenerator : public SingleFieldGenerator {
protected:
explicit PrimitiveFieldGenerator(const FieldDescriptor* descriptor);
- virtual ~PrimitiveFieldGenerator();
+ ~PrimitiveFieldGenerator() override = default;
PrimitiveFieldGenerator(const PrimitiveFieldGenerator&) = delete;
PrimitiveFieldGenerator& operator=(const PrimitiveFieldGenerator&) = delete;
- virtual void GenerateFieldStorageDeclaration(io::Printer* printer) const override;
+ void GenerateFieldStorageDeclaration(io::Printer* printer) const override;
- virtual int ExtraRuntimeHasBitsNeeded(void) const override;
- virtual void SetExtraRuntimeHasBitsBase(int index_base) override;
+ int ExtraRuntimeHasBitsNeeded() const override;
+ void SetExtraRuntimeHasBitsBase(int index_base) override;
};
class PrimitiveObjFieldGenerator : public ObjCObjFieldGenerator {
@@ -59,7 +59,7 @@ class PrimitiveObjFieldGenerator : public ObjCObjFieldGenerator {
protected:
explicit PrimitiveObjFieldGenerator(const FieldDescriptor* descriptor);
- virtual ~PrimitiveObjFieldGenerator();
+ ~PrimitiveObjFieldGenerator() override = default;
PrimitiveObjFieldGenerator(const PrimitiveObjFieldGenerator&) = delete;
PrimitiveObjFieldGenerator& operator=(const PrimitiveObjFieldGenerator&) =
@@ -71,7 +71,7 @@ class RepeatedPrimitiveFieldGenerator : public RepeatedFieldGenerator {
protected:
explicit RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor);
- virtual ~RepeatedPrimitiveFieldGenerator();
+ ~RepeatedPrimitiveFieldGenerator() override = default;
RepeatedPrimitiveFieldGenerator(const RepeatedPrimitiveFieldGenerator&) =
delete;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/text_format_decode_data.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/text_format_decode_data.cc
new file mode 100644
index 00000000000..f254c6093f4
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/text_format_decode_data.cc
@@ -0,0 +1,254 @@
+// 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/objectivec/text_format_decode_data.h"
+
+#include <iostream>
+#include <ostream>
+#include <sstream>
+#include <string>
+#include <vector>
+
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/escaping.h"
+#include "y_absl/strings/match.h"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/io/zero_copy_stream_impl.h"
+
+// 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 errors.
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace objectivec {
+
+namespace {
+
+// Helper to build up the decode data for a string.
+class DecodeDataBuilder {
+ public:
+ DecodeDataBuilder() { Reset(); }
+
+ bool AddCharacter(char desired, char input);
+ void AddUnderscore() {
+ Push();
+ need_underscore_ = true;
+ }
+ TProtoStringType Finish() {
+ Push();
+ return decode_data_;
+ }
+
+ private:
+ static constexpr uint8_t kAddUnderscore = 0x80;
+
+ static constexpr uint8_t kOpAsIs = 0x00;
+ static constexpr uint8_t kOpFirstUpper = 0x40;
+ static constexpr uint8_t kOpFirstLower = 0x20;
+ static constexpr uint8_t kOpAllUpper = 0x60;
+
+ static constexpr int kMaxSegmentLen = 0x1f;
+
+ void AddChar(const char desired) {
+ ++segment_len_;
+ is_all_upper_ &= y_absl::ascii_isupper(desired);
+ }
+
+ void Push() {
+ uint8_t op = (op_ | segment_len_);
+ if (need_underscore_) op |= kAddUnderscore;
+ if (op != 0) {
+ decode_data_ += (char)op;
+ }
+ Reset();
+ }
+
+ bool AddFirst(const char desired, const char input) {
+ if (desired == input) {
+ op_ = kOpAsIs;
+ } else if (desired == y_absl::ascii_toupper(input)) {
+ op_ = kOpFirstUpper;
+ } else if (desired == y_absl::ascii_tolower(input)) {
+ op_ = kOpFirstLower;
+ } else {
+ // Can't be transformed to match.
+ return false;
+ }
+ AddChar(desired);
+ return true;
+ }
+
+ void Reset() {
+ need_underscore_ = false;
+ op_ = 0;
+ segment_len_ = 0;
+ is_all_upper_ = true;
+ }
+
+ bool need_underscore_;
+ bool is_all_upper_;
+ uint8_t op_;
+ int segment_len_;
+
+ TProtoStringType decode_data_;
+};
+
+bool DecodeDataBuilder::AddCharacter(char desired, char input) {
+ // If we've hit the max size, push to start a new segment.
+ if (segment_len_ == kMaxSegmentLen) {
+ Push();
+ }
+ if (segment_len_ == 0) {
+ return AddFirst(desired, input);
+ }
+
+ // Desired and input match...
+ if (desired == input) {
+ // If we aren't transforming it, or we're upper casing it and it is
+ // supposed to be uppercase; just add it to the segment.
+ if ((op_ != kOpAllUpper) || y_absl::ascii_isupper(desired)) {
+ AddChar(desired);
+ return true;
+ }
+
+ // Add the current segment, and start the next one.
+ Push();
+ return AddFirst(desired, input);
+ }
+
+ // If we need to uppercase, and everything so far has been uppercase,
+ // promote op to AllUpper.
+ if ((desired == y_absl::ascii_toupper(input)) && is_all_upper_) {
+ op_ = kOpAllUpper;
+ AddChar(desired);
+ return true;
+ }
+
+ // Give up, push and start a new segment.
+ Push();
+ return AddFirst(desired, input);
+}
+
+// If decode data can't be generated, a directive for the raw string
+// is used instead.
+TProtoStringType DirectDecodeString(const TProtoStringType& str) {
+ TProtoStringType result;
+ result += (char)'\0'; // Marker for full string.
+ result += str;
+ result += (char)'\0'; // End of string.
+ return result;
+}
+
+} // namespace
+
+void TextFormatDecodeData::AddString(arc_i32 key,
+ const TProtoStringType& input_for_decode,
+ const TProtoStringType& desired_output) {
+ for (std::vector<DataEntry>::const_iterator i = entries_.begin();
+ i != entries_.end(); ++i) {
+ Y_ABSL_CHECK(i->first != key)
+ << "error: duplicate key (" << key
+ << ") making TextFormat data, input: \"" << input_for_decode
+ << "\", desired: \"" << desired_output << "\".";
+ }
+
+ const TProtoStringType& data = TextFormatDecodeData::DecodeDataForString(
+ input_for_decode, desired_output);
+ entries_.push_back(DataEntry(key, data));
+}
+
+TProtoStringType TextFormatDecodeData::Data() const {
+ std::ostringstream data_stringstream;
+
+ if (num_entries() > 0) {
+ io::OstreamOutputStream data_outputstream(&data_stringstream);
+ io::CodedOutputStream output_stream(&data_outputstream);
+
+ output_stream.WriteVarint32(num_entries());
+ for (std::vector<DataEntry>::const_iterator i = entries_.begin();
+ i != entries_.end(); ++i) {
+ output_stream.WriteVarint32(i->first);
+ output_stream.WriteString(i->second);
+ }
+ }
+
+ data_stringstream.flush();
+ return data_stringstream.str();
+}
+
+// static
+TProtoStringType TextFormatDecodeData::DecodeDataForString(
+ const TProtoStringType& input_for_decode, const TProtoStringType& desired_output) {
+ Y_ABSL_CHECK(!input_for_decode.empty() && !desired_output.empty())
+ << "error: got empty string for making TextFormat data, input: \""
+ << input_for_decode << "\", desired: \"" << desired_output << "\".";
+ Y_ABSL_CHECK(!y_absl::StrContains(input_for_decode, '\0') &&
+ !y_absl::StrContains(desired_output, '\0'))
+ << "error: got a null char in a string for making TextFormat data,"
+ << " input: \"" << y_absl::CEscape(input_for_decode) << "\", desired: \""
+ << y_absl::CEscape(desired_output) << "\".";
+
+ DecodeDataBuilder builder;
+
+ // Walk the output building it from the input.
+ int x = 0;
+ for (int y = 0; y < desired_output.size(); y++) {
+ const char d = desired_output[y];
+ if (d == '_') {
+ builder.AddUnderscore();
+ continue;
+ }
+
+ if (x >= input_for_decode.size()) {
+ // Out of input, no way to encode it, just return a full decode.
+ return DirectDecodeString(desired_output);
+ }
+ if (builder.AddCharacter(d, input_for_decode[x])) {
+ ++x; // Consumed one input
+ } else {
+ // Couldn't transform for the next character, just return a full decode.
+ return DirectDecodeString(desired_output);
+ }
+ }
+
+ if (x != input_for_decode.size()) {
+ // Extra input (suffix from name sanitizing?), just return a full decode.
+ return DirectDecodeString(desired_output);
+ }
+
+ // Add the end marker.
+ return builder.Finish() + (char)'\0';
+}
+
+} // namespace objectivec
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/text_format_decode_data.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/text_format_decode_data.h
new file mode 100644
index 00000000000..135e4045b42
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/text_format_decode_data.h
@@ -0,0 +1,83 @@
+// 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_OBJECTIVEC_TEXT_FORMAT_DECODE_DATA_H__
+#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_TEXT_FORMAT_DECODE_DATA_H__
+
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "util/generic/string.h"
+
+// Must be included last
+#include "google/protobuf/port_def.inc"
+
+using TProtoStringType = TString;
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace objectivec {
+
+// TODO(b/250947994): PROTOC_EXPORT is only used to allow the CMake build to
+// find/link these in the unittest, this is not public api.
+
+// Generate decode data needed for ObjC's GPBDecodeTextFormatName() to transform
+// the input into the expected output.
+class PROTOC_EXPORT TextFormatDecodeData {
+ public:
+ TextFormatDecodeData() = default;
+ ~TextFormatDecodeData() = default;
+
+ TextFormatDecodeData(const TextFormatDecodeData&) = delete;
+ TextFormatDecodeData& operator=(const TextFormatDecodeData&) = delete;
+
+ void AddString(arc_i32 key, const TProtoStringType& input_for_decode,
+ const TProtoStringType& desired_output);
+ size_t num_entries() const { return entries_.size(); }
+ TProtoStringType Data() const;
+
+ static TProtoStringType DecodeDataForString(const TProtoStringType& input_for_decode,
+ const TProtoStringType& desired_output);
+
+ private:
+ typedef std::pair<arc_i32, TProtoStringType> DataEntry;
+ std::vector<DataEntry> entries_;
+};
+
+} // namespace objectivec
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_TEXT_FORMAT_DECODE_DATA_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc b/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc
index 2900d324d21..e244db96cc8 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc
@@ -34,35 +34,43 @@
//
// Recursive descent FTW.
-#include <google/protobuf/compiler/parser.h>
+#include "google/protobuf/compiler/parser.h"
#include <float.h>
#include <cstdint>
#include <limits>
-#include <unordered_map>
-#include <unordered_set>
-
-#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/wire_format.h>
-#include <google/protobuf/stubs/map_util.h>
-#include <google/protobuf/stubs/hash.h>
+#include <string>
+#include <tuple>
+#include <utility>
+#include <vector>
+
+#include "y_absl/base/casts.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/escaping.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/strtod.h"
+#include "google/protobuf/io/tokenizer.h"
+#include "google/protobuf/port.h"
+#include "google/protobuf/wire_format.h"
namespace google {
namespace protobuf {
namespace compiler {
-
-using internal::WireFormat;
-
namespace {
-typedef std::unordered_map<TProtoStringType, FieldDescriptorProto::Type> TypeNameMap;
+using ::google::protobuf::internal::DownCast;
+
+using TypeNameMap =
+ y_absl::flat_hash_map<y_absl::string_view, FieldDescriptorProto::Type>;
const TypeNameMap& GetTypeNameTable() {
static auto* table = new auto([]() {
@@ -93,7 +101,7 @@ const TypeNameMap& GetTypeNameTable() {
// Camel-case the field name and append "Entry" for generated map entry name.
// e.g. map<KeyType, ValueType> foo_map => FooMapEntry
-TProtoStringType MapEntryName(const TProtoStringType& field_name) {
+TProtoStringType MapEntryName(y_absl::string_view field_name) {
TProtoStringType result;
static const char kSuffix[] = "Entry";
result.reserve(field_name.size() + sizeof(kSuffix));
@@ -123,7 +131,7 @@ bool IsLowercase(char c) { return c >= 'a' && c <= 'z'; }
bool IsNumber(char c) { return c >= '0' && c <= '9'; }
-bool IsUpperCamelCase(const TProtoStringType& name) {
+bool IsUpperCamelCase(y_absl::string_view name) {
if (name.empty()) {
return true;
}
@@ -140,7 +148,7 @@ bool IsUpperCamelCase(const TProtoStringType& name) {
return true;
}
-bool IsUpperUnderscore(const TProtoStringType& name) {
+bool IsUpperUnderscore(y_absl::string_view name) {
for (const char c : name) {
if (!IsUppercase(c) && c != '_' && !IsNumber(c)) {
return false;
@@ -149,7 +157,7 @@ bool IsUpperUnderscore(const TProtoStringType& name) {
return true;
}
-bool IsLowerUnderscore(const TProtoStringType& name) {
+bool IsLowerUnderscore(y_absl::string_view name) {
for (const char c : name) {
if (!IsLowercase(c) && c != '_' && !IsNumber(c)) {
return false;
@@ -158,7 +166,7 @@ bool IsLowerUnderscore(const TProtoStringType& name) {
return true;
}
-bool IsNumberFollowUnderscore(const TProtoStringType& name) {
+bool IsNumberFollowUnderscore(y_absl::string_view name) {
for (int i = 1; i < name.length(); i++) {
const char c = name[i];
if (IsNumber(c) && name[i - 1] == '_') {
@@ -193,7 +201,7 @@ Parser::~Parser() {}
// ===================================================================
-inline bool Parser::LookingAt(const char* text) {
+inline bool Parser::LookingAt(y_absl::string_view text) {
return input_->current().text == text;
}
@@ -203,7 +211,7 @@ inline bool Parser::LookingAtType(io::Tokenizer::TokenType token_type) {
inline bool Parser::AtEnd() { return LookingAtType(io::Tokenizer::TYPE_END); }
-bool Parser::TryConsume(const char* text) {
+bool Parser::TryConsume(y_absl::string_view text) {
if (LookingAt(text)) {
input_->Next();
return true;
@@ -212,50 +220,49 @@ bool Parser::TryConsume(const char* text) {
}
}
-bool Parser::Consume(const char* text, const char* error) {
+bool Parser::Consume(y_absl::string_view text, y_absl::string_view error) {
if (TryConsume(text)) {
return true;
} else {
- AddError(error);
+ RecordError(error);
return false;
}
}
-bool Parser::Consume(const char* text) {
- TProtoStringType error = "Expected \"" + TProtoStringType(text) + "\".";
- return Consume(text, error.c_str());
+bool Parser::Consume(y_absl::string_view text) {
+ return Consume(text, y_absl::StrCat("Expected \"", text, "\"."));
}
-bool Parser::ConsumeIdentifier(TProtoStringType* output, const char* error) {
+bool Parser::ConsumeIdentifier(TProtoStringType* output, y_absl::string_view error) {
if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) {
*output = input_->current().text;
input_->Next();
return true;
} else {
- AddError(error);
+ RecordError(error);
return false;
}
}
-bool Parser::ConsumeInteger(int* output, const char* error) {
+bool Parser::ConsumeInteger(int* output, y_absl::string_view error) {
if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) {
arc_ui64 value = 0;
if (!io::Tokenizer::ParseInteger(input_->current().text,
std::numeric_limits<arc_i32>::max(),
&value)) {
- AddError("Integer out of range.");
+ RecordError("Integer out of range.");
// We still return true because we did, in fact, parse an integer.
}
*output = value;
input_->Next();
return true;
} else {
- AddError(error);
+ RecordError(error);
return false;
}
}
-bool Parser::ConsumeSignedInteger(int* output, const char* error) {
+bool Parser::ConsumeSignedInteger(int* output, y_absl::string_view error) {
bool is_negative = false;
arc_ui64 max_value = std::numeric_limits<arc_i32>::max();
if (TryConsume("-")) {
@@ -270,23 +277,32 @@ bool Parser::ConsumeSignedInteger(int* output, const char* error) {
}
bool Parser::ConsumeInteger64(arc_ui64 max_value, arc_ui64* output,
- const char* error) {
+ y_absl::string_view error) {
if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) {
if (!io::Tokenizer::ParseInteger(input_->current().text, max_value,
output)) {
- AddError("Integer out of range.");
+ RecordError("Integer out of range.");
// We still return true because we did, in fact, parse an integer.
*output = 0;
}
input_->Next();
return true;
} else {
- AddError(error);
+ RecordError(error);
return false;
}
}
-bool Parser::ConsumeNumber(double* output, const char* error) {
+bool Parser::TryConsumeInteger64(arc_ui64 max_value, arc_ui64* output) {
+ if (LookingAtType(io::Tokenizer::TYPE_INTEGER) &&
+ io::Tokenizer::ParseInteger(input_->current().text, max_value, output)) {
+ input_->Next();
+ return true;
+ }
+ return false;
+}
+
+bool Parser::ConsumeNumber(double* output, y_absl::string_view error) {
if (LookingAtType(io::Tokenizer::TYPE_FLOAT)) {
*output = io::Tokenizer::ParseFloat(input_->current().text);
input_->Next();
@@ -294,13 +310,19 @@ bool Parser::ConsumeNumber(double* output, const char* error) {
} else if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) {
// Also accept integers.
arc_ui64 value = 0;
- if (!io::Tokenizer::ParseInteger(input_->current().text,
- std::numeric_limits<arc_ui64>::max(),
- &value)) {
- AddError("Integer out of range.");
+ if (io::Tokenizer::ParseInteger(input_->current().text,
+ std::numeric_limits<arc_ui64>::max(),
+ &value)) {
+ *output = value;
+ } else if (input_->current().text[0] == '0') {
+ // octal or hexadecimal; don't bother parsing as float
+ RecordError("Integer out of range.");
+ // We still return true because we did, in fact, parse a number.
+ } else if (!io::Tokenizer::TryParseFloat(input_->current().text, output)) {
+ // out of int range, and not valid float? 🤷
+ RecordError("Integer out of range.");
// We still return true because we did, in fact, parse a number.
}
- *output = value;
input_->Next();
return true;
} else if (LookingAt("inf")) {
@@ -312,12 +334,12 @@ bool Parser::ConsumeNumber(double* output, const char* error) {
input_->Next();
return true;
} else {
- AddError(error);
+ RecordError(error);
return false;
}
}
-bool Parser::ConsumeString(TProtoStringType* output, const char* error) {
+bool Parser::ConsumeString(TProtoStringType* output, y_absl::string_view error) {
if (LookingAtType(io::Tokenizer::TYPE_STRING)) {
io::Tokenizer::ParseString(input_->current().text, output);
input_->Next();
@@ -328,12 +350,12 @@ bool Parser::ConsumeString(TProtoStringType* output, const char* error) {
}
return true;
} else {
- AddError(error);
+ RecordError(error);
return false;
}
}
-bool Parser::TryConsumeEndOfDeclaration(const char* text,
+bool Parser::TryConsumeEndOfDeclaration(y_absl::string_view text,
const LocationRecorder* location) {
if (LookingAt(text)) {
TProtoStringType leading, trailing;
@@ -347,7 +369,7 @@ bool Parser::TryConsumeEndOfDeclaration(const char* text,
if (location != nullptr) {
upcoming_detached_comments_.swap(detached);
location->AttachComments(&leading, &trailing, &detached);
- } else if (strcmp(text, "}") == 0) {
+ } else if (text == "}") {
// If the current location is null and we are finishing the current scope,
// drop pending upcoming detached comments.
upcoming_detached_comments_.swap(detached);
@@ -364,36 +386,39 @@ bool Parser::TryConsumeEndOfDeclaration(const char* text,
}
}
-bool Parser::ConsumeEndOfDeclaration(const char* text,
+bool Parser::ConsumeEndOfDeclaration(y_absl::string_view text,
const LocationRecorder* location) {
if (TryConsumeEndOfDeclaration(text, location)) {
return true;
} else {
- AddError("Expected \"" + TProtoStringType(text) + "\".");
+ RecordError(y_absl::StrCat("Expected \"", text, "\"."));
return false;
}
}
// -------------------------------------------------------------------
-void Parser::AddError(int line, int column, const TProtoStringType& error) {
+void Parser::RecordError(int line, int column, y_absl::string_view error) {
if (error_collector_ != nullptr) {
- error_collector_->AddError(line, column, error);
+ error_collector_->RecordError(line, column, error);
}
had_errors_ = true;
}
-void Parser::AddError(const TProtoStringType& error) {
- AddError(input_->current().line, input_->current().column, error);
+void Parser::RecordError(y_absl::string_view error) {
+ RecordError(input_->current().line, input_->current().column, error);
}
-void Parser::AddWarning(const TProtoStringType& warning) {
+void Parser::RecordWarning(int line, int column, y_absl::string_view warning) {
if (error_collector_ != nullptr) {
- error_collector_->AddWarning(input_->current().line,
- input_->current().column, warning);
+ error_collector_->RecordWarning(line, column, warning);
}
}
+void Parser::RecordWarning(y_absl::string_view warning) {
+ RecordWarning(input_->current().line, input_->current().column, warning);
+}
+
// -------------------------------------------------------------------
Parser::LocationRecorder::LocationRecorder(Parser* parser)
@@ -491,8 +516,8 @@ int Parser::LocationRecorder::CurrentPathSize() const {
void Parser::LocationRecorder::AttachComments(
TProtoStringType* leading, TProtoStringType* trailing,
std::vector<TProtoStringType>* detached_comments) const {
- GOOGLE_CHECK(!location_->has_leading_comments());
- GOOGLE_CHECK(!location_->has_trailing_comments());
+ Y_ABSL_CHECK(!location_->has_leading_comments());
+ Y_ABSL_CHECK(!location_->has_trailing_comments());
if (!leading->empty()) {
location_->mutable_leading_comments()->swap(*leading);
@@ -563,16 +588,16 @@ bool Parser::ValidateEnum(const EnumDescriptorProto* proto) {
}
if (has_allow_alias && !allow_alias) {
- TProtoStringType error =
- "\"" + proto->name() +
+ TProtoStringType error = y_absl::StrCat(
+ "\"", proto->name(),
"\" declares 'option allow_alias = false;' which has no effect. "
- "Please remove the declaration.";
+ "Please remove the declaration.");
// This needlessly clutters declarations with nops.
- AddError(error);
+ RecordError(error);
return false;
}
- std::set<int> used_values;
+ y_absl::flat_hash_set<int> used_values;
bool has_duplicates = false;
for (int i = 0; i < proto->value_size(); ++i) {
const EnumValueDescriptorProto& enum_value = proto->value(i);
@@ -584,14 +609,14 @@ bool Parser::ValidateEnum(const EnumDescriptorProto* proto) {
}
}
if (allow_alias && !has_duplicates) {
- TProtoStringType error =
- "\"" + proto->name() +
+ TProtoStringType error = y_absl::StrCat(
+ "\"", proto->name(),
"\" declares support for enum aliases but no enum values share field "
"numbers. Please remove the unnecessary 'option allow_alias = true;' "
- "declaration.";
+ "declaration.");
// Generate an error if an enum declares support for duplicate enum values
// and does not use it protect future authors.
- AddError(error);
+ RecordError(error);
return false;
}
@@ -600,10 +625,9 @@ bool Parser::ValidateEnum(const EnumDescriptorProto* proto) {
if (!allow_alias) {
for (const auto& enum_value : proto->value()) {
if (!IsUpperUnderscore(enum_value.name())) {
- AddWarning(
- "Enum constant should be in UPPER_CASE. Found: " +
- enum_value.name() +
- ". See https://developers.google.com/protocol-buffers/docs/style");
+ RecordWarning(y_absl::StrCat(
+ "Enum constant should be in UPPER_CASE. Found: ", enum_value.name(),
+ ". See https://developers.google.com/protocol-buffers/docs/style"));
}
}
}
@@ -634,14 +658,17 @@ bool Parser::Parse(io::Tokenizer* input, FileDescriptorProto* file) {
root_location.RecordLegacyLocation(file,
DescriptorPool::ErrorCollector::OTHER);
- if (require_syntax_identifier_ || LookingAt("syntax")) {
+ if (require_syntax_identifier_ || LookingAt("syntax")
+ ) {
if (!ParseSyntaxIdentifier(root_location)) {
// Don't attempt to parse the file if we didn't recognize the syntax
// identifier.
return false;
}
// Store the syntax into the file.
- if (file != nullptr) file->set_syntax(syntax_identifier_);
+ if (file != nullptr) {
+ file->set_syntax(syntax_identifier_);
+ }
} else if (!stop_after_syntax_identifier_) {
syntax_identifier_ = "proto2";
}
@@ -656,7 +683,7 @@ bool Parser::Parse(io::Tokenizer* input, FileDescriptorProto* file) {
SkipStatement();
if (LookingAt("}")) {
- AddError("Unmatched \"}\".");
+ RecordError("Unmatched \"}\".");
input_->NextWithComments(nullptr, &upcoming_detached_comments_,
&upcoming_doc_comments_);
}
@@ -674,9 +701,10 @@ bool Parser::Parse(io::Tokenizer* input, FileDescriptorProto* file) {
bool Parser::ParseSyntaxIdentifier(const LocationRecorder& parent) {
LocationRecorder syntax_location(parent,
FileDescriptorProto::kSyntaxFieldNumber);
- DO(Consume(
- "syntax",
- "File must begin with a syntax statement, e.g. 'syntax = \"proto2\";'."));
+ DO(Consume("syntax",
+ "File must begin with a syntax statement, e.g. 'syntax = "
+ "\"proto2\";'."));
+
DO(Consume("="));
io::Tokenizer::Token syntax_token = input_->current();
TProtoStringType syntax;
@@ -684,13 +712,12 @@ bool Parser::ParseSyntaxIdentifier(const LocationRecorder& parent) {
DO(ConsumeEndOfDeclaration(";", &syntax_location));
syntax_identifier_ = syntax;
-
if (syntax != "proto2" && syntax != "proto3" &&
!stop_after_syntax_identifier_) {
- AddError(syntax_token.line, syntax_token.column,
- "Unrecognized syntax identifier \"" + syntax +
- "\". This parser "
- "only recognizes \"proto2\" and \"proto3\".");
+ RecordError(syntax_token.line, syntax_token.column,
+ y_absl::StrCat("Unrecognized syntax identifier \"", syntax,
+ "\". This parser "
+ "only recognizes \"proto2\" and \"proto3\"."));
return false;
}
@@ -735,7 +762,7 @@ bool Parser::ParseTopLevelStatement(FileDescriptorProto* file,
return ParseOption(file->mutable_options(), location, file,
OPTION_STATEMENT);
} else {
- AddError("Expected top-level statement (e.g. \"message\").");
+ RecordError("Expected top-level statement (e.g. \"message\").");
return false;
}
}
@@ -754,10 +781,9 @@ bool Parser::ParseMessageDefinition(
DescriptorPool::ErrorCollector::NAME);
DO(ConsumeIdentifier(message->mutable_name(), "Expected message name."));
if (!IsUpperCamelCase(message->name())) {
- AddWarning(
- "Message name should be in UpperCamelCase. Found: " +
- message->name() +
- ". See https://developers.google.com/protocol-buffers/docs/style");
+ RecordWarning(y_absl::StrCat(
+ "Message name should be in UpperCamelCase. Found: ", message->name(),
+ ". See https://developers.google.com/protocol-buffers/docs/style"));
}
}
DO(ParseMessageBlock(message, message_location, containing_file));
@@ -768,7 +794,7 @@ bool Parser::ParseMessageDefinition(
//
// We have to make sure the oneof names don't conflict with any other
// field or oneof.
- std::unordered_set<TProtoStringType> names;
+ y_absl::flat_hash_set<TProtoStringType> names;
for (const auto& field : message->field()) {
names.insert(field.name());
}
@@ -793,7 +819,7 @@ bool Parser::ParseMessageDefinition(
names.insert(oneof_name);
field.set_oneof_index(message->oneof_decl_size());
OneofDescriptorProto* oneof = message->add_oneof_decl();
- oneof->set_name(oneof_name);
+ oneof->set_name(std::move(oneof_name));
}
}
}
@@ -857,7 +883,7 @@ bool Parser::ParseMessageBlock(DescriptorProto* message,
while (!TryConsumeEndOfDeclaration("}", nullptr)) {
if (AtEnd()) {
- AddError("Reached end of input in message definition (missing '}').");
+ RecordError("Reached end of input in message definition (missing '}').");
return false;
}
@@ -986,7 +1012,7 @@ bool Parser::ParseMessageFieldNoLabel(
field->set_label(FieldDescriptorProto::LABEL_OPTIONAL);
}
if (!field->has_label()) {
- AddError("Expected \"required\", \"optional\", or \"repeated\".");
+ RecordError("Expected \"required\", \"optional\", or \"repeated\".");
// We can actually reasonably recover here by just assuming the user
// forgot the label altogether.
field->set_label(FieldDescriptorProto::LABEL_OPTIONAL);
@@ -1016,15 +1042,15 @@ bool Parser::ParseMessageFieldNoLabel(
DO(ConsumeIdentifier(field->mutable_name(), "Expected field name."));
if (!IsLowerUnderscore(field->name())) {
- AddWarning(
- "Field name should be lowercase. Found: " + field->name() +
- ". See: https://developers.google.com/protocol-buffers/docs/style");
+ RecordWarning(y_absl::StrCat(
+ "Field name should be lowercase. Found: ", field->name(),
+ ". See: https://developers.google.com/protocol-buffers/docs/style"));
}
if (IsNumberFollowUnderscore(field->name())) {
- AddWarning(
- "Number should not come right after an underscore. Found: " +
- field->name() +
- ". See: https://developers.google.com/protocol-buffers/docs/style");
+ RecordWarning(y_absl::StrCat(
+ "Number should not come right after an underscore. Found: ",
+ field->name(),
+ ". See: https://developers.google.com/protocol-buffers/docs/style"));
}
}
DO(Consume("=", "Missing field number."));
@@ -1077,16 +1103,16 @@ bool Parser::ParseMessageFieldNoLabel(
// with a capital letter and lower-case the field name. New code should
// not use groups; it should use nested messages.
if (group->name()[0] < 'A' || 'Z' < group->name()[0]) {
- AddError(name_token.line, name_token.column,
- "Group names must start with a capital letter.");
+ RecordError(name_token.line, name_token.column,
+ "Group names must start with a capital letter.");
}
- LowerString(field->mutable_name());
+ y_absl::AsciiStrToLower(field->mutable_name());
field->set_type_name(group->name());
if (LookingAt("{")) {
DO(ParseMessageBlock(group, group_location, containing_file));
} else {
- AddError("Missing group body.");
+ RecordError("Missing group body.");
return false;
}
} else {
@@ -1104,17 +1130,17 @@ bool Parser::ParseMessageFieldNoLabel(
bool Parser::ParseMapType(MapField* map_field, FieldDescriptorProto* field,
LocationRecorder& type_name_location) {
if (field->has_oneof_index()) {
- AddError("Map fields are not allowed in oneofs.");
+ RecordError("Map fields are not allowed in oneofs.");
return false;
}
if (field->has_label()) {
- AddError(
+ RecordError(
"Field labels (required/optional/repeated) are not allowed on "
"map fields.");
return false;
}
if (field->has_extendee()) {
- AddError("Map fields are not allowed to be extensions.");
+ RecordError("Map fields are not allowed to be extensions.");
return false;
}
field->set_label(FieldDescriptorProto::LABEL_REPEATED);
@@ -1226,7 +1252,7 @@ bool Parser::ParseDefaultAssignment(
FieldDescriptorProto* field, const LocationRecorder& field_location,
const FileDescriptorProto* containing_file) {
if (field->has_default_value()) {
- AddError("Already set option \"default\".");
+ RecordError("Already set option \"default\".");
field->clear_default_value();
}
@@ -1279,7 +1305,7 @@ bool Parser::ParseDefaultAssignment(
DO(ConsumeInteger64(max_value, &value,
"Expected integer for field default value."));
// And stringify it again.
- default_value->append(StrCat(value));
+ default_value->append(y_absl::StrCat(value));
break;
}
@@ -1295,38 +1321,38 @@ bool Parser::ParseDefaultAssignment(
// Numeric, not negative.
if (TryConsume("-")) {
- AddError("Unsigned field can't have negative default value.");
+ RecordError("Unsigned field can't have negative default value.");
}
// Parse the integer to verify that it is not out-of-range.
arc_ui64 value;
DO(ConsumeInteger64(max_value, &value,
"Expected integer for field default value."));
// And stringify it again.
- default_value->append(StrCat(value));
+ default_value->append(y_absl::StrCat(value));
break;
}
case FieldDescriptorProto::TYPE_FLOAT:
- case FieldDescriptorProto::TYPE_DOUBLE:
+ case FieldDescriptorProto::TYPE_DOUBLE: {
// These types can be negative.
if (TryConsume("-")) {
default_value->append("-");
}
// Parse the integer because we have to convert hex integers to decimal
// floats.
- double value;
+ double value = 0.0;
DO(ConsumeNumber(&value, "Expected number."));
// And stringify it again.
- default_value->append(SimpleDtoa(value));
+ default_value->append(io::SimpleDtoa(value));
break;
-
+ }
case FieldDescriptorProto::TYPE_BOOL:
if (TryConsume("true")) {
default_value->assign("true");
} else if (TryConsume("false")) {
default_value->assign("false");
} else {
- AddError("Expected \"true\" or \"false\".");
+ RecordError("Expected \"true\" or \"false\".");
return false;
}
break;
@@ -1342,7 +1368,7 @@ bool Parser::ParseDefaultAssignment(
case FieldDescriptorProto::TYPE_BYTES:
DO(ConsumeString(default_value, "Expected string."));
- *default_value = CEscape(*default_value);
+ *default_value = y_absl::CEscape(*default_value);
break;
case FieldDescriptorProto::TYPE_ENUM:
@@ -1353,7 +1379,7 @@ bool Parser::ParseDefaultAssignment(
case FieldDescriptorProto::TYPE_MESSAGE:
case FieldDescriptorProto::TYPE_GROUP:
- AddError("Messages can't have default values.");
+ RecordError("Messages can't have default values.");
return false;
}
@@ -1364,7 +1390,7 @@ bool Parser::ParseJsonName(FieldDescriptorProto* field,
const LocationRecorder& field_location,
const FileDescriptorProto* containing_file) {
if (field->has_json_name()) {
- AddError("Already set option \"json_name\".");
+ RecordError("Already set option \"json_name\".");
field->clear_json_name();
}
@@ -1443,7 +1469,7 @@ bool Parser::ParseUninterpretedBlock(TProtoStringType* value) {
value->append(input_->current().text);
input_->Next();
}
- AddError("Unexpected end of stream while parsing aggregate value.");
+ RecordError("Unexpected end of stream while parsing aggregate value.");
return false;
}
@@ -1456,7 +1482,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 != nullptr)
+ Y_ABSL_CHECK(uninterpreted_option_field != nullptr)
<< "No field named \"uninterpreted_option\" in the Options proto.";
const Reflection* reflection = options->GetReflection();
@@ -1470,7 +1496,7 @@ bool Parser::ParseOption(Message* options,
}
UninterpretedOption* uninterpreted_option =
- down_cast<UninterpretedOption*>(options->GetReflection()->AddMessage(
+ DownCast<UninterpretedOption*>(options->GetReflection()->AddMessage(
options, uninterpreted_option_field));
// Parse dot-separated name.
@@ -1509,25 +1535,26 @@ bool Parser::ParseOption(Message* options,
switch (input_->current().type) {
case io::Tokenizer::TYPE_START:
- GOOGLE_LOG(FATAL) << "Trying to read value before any tokens have been read.";
+ Y_ABSL_LOG(FATAL)
+ << "Trying to read value before any tokens have been read.";
return false;
case io::Tokenizer::TYPE_END:
- AddError("Unexpected end of stream while parsing option value.");
+ RecordError("Unexpected end of stream while parsing option value.");
return false;
case io::Tokenizer::TYPE_WHITESPACE:
case io::Tokenizer::TYPE_NEWLINE:
- GOOGLE_CHECK(!input_->report_whitespace() && !input_->report_newlines())
+ Y_ABSL_CHECK(!input_->report_whitespace() && !input_->report_newlines())
<< "Whitespace tokens were not requested.";
- GOOGLE_LOG(FATAL) << "Tokenizer reported whitespace.";
+ Y_ABSL_LOG(FATAL) << "Tokenizer reported whitespace.";
return false;
case io::Tokenizer::TYPE_IDENTIFIER: {
value_location.AddPath(
UninterpretedOption::kIdentifierValueFieldNumber);
if (is_negative) {
- AddError("Invalid '-' symbol before identifier.");
+ RecordError("Invalid '-' symbol before identifier.");
return false;
}
TProtoStringType value;
@@ -1542,23 +1569,27 @@ bool Parser::ParseOption(Message* options,
is_negative
? static_cast<arc_ui64>(std::numeric_limits<arc_i64>::max()) + 1
: std::numeric_limits<arc_ui64>::max();
- DO(ConsumeInteger64(max_value, &value, "Expected integer."));
- if (is_negative) {
- value_location.AddPath(
- UninterpretedOption::kNegativeIntValueFieldNumber);
- uninterpreted_option->set_negative_int_value(
- static_cast<arc_i64>(0 - value));
- } else {
- value_location.AddPath(
- UninterpretedOption::kPositiveIntValueFieldNumber);
- uninterpreted_option->set_positive_int_value(value);
+ if (TryConsumeInteger64(max_value, &value)) {
+ if (is_negative) {
+ value_location.AddPath(
+ UninterpretedOption::kNegativeIntValueFieldNumber);
+ uninterpreted_option->set_negative_int_value(
+ static_cast<arc_i64>(0 - value));
+ } else {
+ value_location.AddPath(
+ UninterpretedOption::kPositiveIntValueFieldNumber);
+ uninterpreted_option->set_positive_int_value(value);
+ }
+ break;
}
- break;
+ // value too large for an integer; fall through below to treat as
+ // floating point
+ Y_ABSL_FALLTHROUGH_INTENDED;
}
case io::Tokenizer::TYPE_FLOAT: {
value_location.AddPath(UninterpretedOption::kDoubleValueFieldNumber);
- double value;
+ double value = 0.0;
DO(ConsumeNumber(&value, "Expected number."));
uninterpreted_option->set_double_value(is_negative ? -value : value);
break;
@@ -1567,7 +1598,7 @@ bool Parser::ParseOption(Message* options,
case io::Tokenizer::TYPE_STRING: {
value_location.AddPath(UninterpretedOption::kStringValueFieldNumber);
if (is_negative) {
- AddError("Invalid '-' symbol before string.");
+ RecordError("Invalid '-' symbol before string.");
return false;
}
TProtoStringType value;
@@ -1583,7 +1614,7 @@ bool Parser::ParseOption(Message* options,
DO(ParseUninterpretedBlock(
uninterpreted_option->mutable_aggregate_value()));
} else {
- AddError("Expected option value.");
+ RecordError("Expected option value.");
return false;
}
break;
@@ -1719,11 +1750,27 @@ bool Parser::ParseReserved(DescriptorProto* message,
}
}
+bool Parser::ParseReservedName(TProtoStringType* name,
+ y_absl::string_view error_message) {
+ // Capture the position of the token, in case we have to report an
+ // error after it is consumed.
+ int line = input_->current().line;
+ int col = input_->current().column;
+ DO(ConsumeString(name, error_message));
+ if (!io::Tokenizer::IsIdentifier(*name)) {
+ RecordWarning(
+ line, col,
+ y_absl::StrFormat("Reserved name \"%s\" is not a valid identifier.",
+ *name));
+ }
+ return true;
+}
+
bool Parser::ParseReservedNames(DescriptorProto* message,
const LocationRecorder& parent_location) {
do {
LocationRecorder location(parent_location, message->reserved_name_size());
- DO(ConsumeString(message->add_reserved_name(), "Expected field name."));
+ DO(ParseReservedName(message->add_reserved_name(), "Expected field name."));
} while (TryConsume(","));
DO(ConsumeEndOfDeclaration(";", &parent_location));
return true;
@@ -1778,42 +1825,41 @@ bool Parser::ParseReservedNumbers(DescriptorProto* message,
return true;
}
-bool Parser::ParseReserved(EnumDescriptorProto* message,
- const LocationRecorder& message_location) {
+bool Parser::ParseReserved(EnumDescriptorProto* proto,
+ const LocationRecorder& enum_location) {
io::Tokenizer::Token start_token = input_->current();
// Parse the declaration.
DO(Consume("reserved"));
if (LookingAtType(io::Tokenizer::TYPE_STRING)) {
- LocationRecorder location(message_location,
+ LocationRecorder location(enum_location,
EnumDescriptorProto::kReservedNameFieldNumber);
location.StartAt(start_token);
- return ParseReservedNames(message, location);
+ return ParseReservedNames(proto, location);
} else {
- LocationRecorder location(message_location,
+ LocationRecorder location(enum_location,
EnumDescriptorProto::kReservedRangeFieldNumber);
location.StartAt(start_token);
- return ParseReservedNumbers(message, location);
+ return ParseReservedNumbers(proto, location);
}
}
-bool Parser::ParseReservedNames(EnumDescriptorProto* message,
+bool Parser::ParseReservedNames(EnumDescriptorProto* proto,
const LocationRecorder& parent_location) {
do {
- LocationRecorder location(parent_location, message->reserved_name_size());
- DO(ConsumeString(message->add_reserved_name(), "Expected enum value."));
+ LocationRecorder location(parent_location, proto->reserved_name_size());
+ DO(ParseReservedName(proto->add_reserved_name(), "Expected enum value."));
} while (TryConsume(","));
DO(ConsumeEndOfDeclaration(";", &parent_location));
return true;
}
-bool Parser::ParseReservedNumbers(EnumDescriptorProto* message,
+bool Parser::ParseReservedNumbers(EnumDescriptorProto* proto,
const LocationRecorder& parent_location) {
bool first = true;
do {
- LocationRecorder location(parent_location, message->reserved_range_size());
+ LocationRecorder location(parent_location, proto->reserved_range_size());
- EnumDescriptorProto::EnumReservedRange* range =
- message->add_reserved_range();
+ EnumDescriptorProto::EnumReservedRange* range = proto->add_reserved_range();
int start, end;
io::Tokenizer::Token start_token;
{
@@ -1873,7 +1919,7 @@ bool Parser::ParseExtend(RepeatedPtrField<FieldDescriptorProto>* extensions,
do {
if (AtEnd()) {
- AddError("Reached end of input in extend definition (missing '}').");
+ RecordError("Reached end of input in extend definition (missing '}').");
return false;
}
@@ -1926,7 +1972,7 @@ bool Parser::ParseOneof(OneofDescriptorProto* oneof_decl,
do {
if (AtEnd()) {
- AddError("Reached end of input in oneof definition (missing '}').");
+ RecordError("Reached end of input in oneof definition (missing '}').");
return false;
}
@@ -1944,7 +1990,7 @@ bool Parser::ParseOneof(OneofDescriptorProto* oneof_decl,
// on an individual member of a oneof.
if (LookingAt("required") || LookingAt("optional") ||
LookingAt("repeated")) {
- AddError(
+ RecordError(
"Fields in oneofs must not have labels (required / optional "
"/ repeated).");
// We can continue parsing here because we understand what the user
@@ -2003,7 +2049,7 @@ bool Parser::ParseEnumBlock(EnumDescriptorProto* enum_type,
while (!TryConsumeEndOfDeclaration("}", nullptr)) {
if (AtEnd()) {
- AddError("Reached end of input in enum definition (missing '}').");
+ RecordError("Reached end of input in enum definition (missing '}').");
return false;
}
@@ -2120,7 +2166,7 @@ bool Parser::ParseServiceBlock(ServiceDescriptorProto* service,
while (!TryConsumeEndOfDeclaration("}", nullptr)) {
if (AtEnd()) {
- AddError("Reached end of input in service definition (missing '}').");
+ RecordError("Reached end of input in service definition (missing '}').");
return false;
}
@@ -2224,7 +2270,7 @@ bool Parser::ParseMethodOptions(const LocationRecorder& parent_location,
ConsumeEndOfDeclaration("{", &parent_location);
while (!TryConsumeEndOfDeclaration("}", nullptr)) {
if (AtEnd()) {
- AddError("Reached end of input in method options (missing '}').");
+ RecordError("Reached end of input in method options (missing '}').");
return false;
}
@@ -2288,7 +2334,7 @@ bool Parser::ParseUserDefinedType(TProtoStringType* type_name) {
// if we are parsing a field type then we would not get here because
// primitives are allowed there as well. So this error message doesn't
// need to account for enums.
- AddError("Expected message type.");
+ RecordError("Expected message type.");
// Pretend to accept this type so that we can go on parsing.
*type_name = input_->current().text;
@@ -2320,7 +2366,7 @@ bool Parser::ParsePackage(FileDescriptorProto* file,
const LocationRecorder& root_location,
const FileDescriptorProto* containing_file) {
if (file->has_package()) {
- AddError("Multiple package definitions.");
+ RecordError("Multiple package definitions.");
// Don't append the new package to the old one. Just replace it. Not
// that it really matters since this is an error anyway.
file->clear_package();
@@ -2391,33 +2437,27 @@ bool SourceLocationTable::Find(
const Message* descriptor,
DescriptorPool::ErrorCollector::ErrorLocation location, int* line,
int* column) const {
- const std::pair<int, int>* result =
- FindOrNull(location_map_, std::make_pair(descriptor, location));
- if (result == nullptr) {
+ auto it = location_map_.find({descriptor, location});
+ if (it == location_map_.end()) {
*line = -1;
*column = 0;
return false;
- } else {
- *line = result->first;
- *column = result->second;
- return true;
}
+ std::tie(*line, *column) = it->second;
+ return true;
}
bool SourceLocationTable::FindImport(const Message* descriptor,
- const TProtoStringType& name, int* line,
+ y_absl::string_view name, int* line,
int* column) const {
- const std::pair<int, int>* result =
- FindOrNull(import_location_map_, std::make_pair(descriptor, name));
- if (result == nullptr) {
+ auto it = import_location_map_.find({descriptor, TProtoStringType(name)});
+ if (it == import_location_map_.end()) {
*line = -1;
*column = 0;
return false;
- } else {
- *line = result->first;
- *column = result->second;
- return true;
}
+ std::tie(*line, *column) = it->second;
+ return true;
}
void SourceLocationTable::Add(
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/parser.h b/contrib/libs/protoc/src/google/protobuf/compiler/parser.h
index c92b5f28f4c..72db054327d 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/parser.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/parser.h
@@ -38,17 +38,18 @@
#define GOOGLE_PROTOBUF_COMPILER_PARSER_H__
#include <cstdint>
-#include <map>
#include <string>
#include <utility>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/tokenizer.h>
-#include <google/protobuf/repeated_field.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/tokenizer.h"
+#include "google/protobuf/repeated_field.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -71,6 +72,8 @@ class SourceLocationTable;
class PROTOBUF_EXPORT Parser {
public:
Parser();
+ Parser(const Parser&) = delete;
+ Parser& operator=(const Parser&) = delete;
~Parser();
// Parse the entire input and construct a FileDescriptorProto representing
@@ -98,7 +101,7 @@ class PROTOBUF_EXPORT Parser {
// Returns the identifier used in the "syntax = " declaration, if one was
// seen during the last call to Parse(), or the empty string otherwise.
- const TProtoStringType& GetSyntaxIdentifier() { return syntax_identifier_; }
+ y_absl::string_view GetSyntaxIdentifier() { return syntax_identifier_; }
// If set true, input files will be required to begin with a syntax
// identifier. Otherwise, files may omit this. If a syntax identifier
@@ -151,38 +154,41 @@ class PROTOBUF_EXPORT Parser {
inline bool AtEnd();
// True if the next token matches the given text.
- inline bool LookingAt(const char* text);
+ inline bool LookingAt(y_absl::string_view text);
// True if the next token is of the given type.
inline bool LookingAtType(io::Tokenizer::TokenType token_type);
// If the next token exactly matches the text given, consume it and return
// true. Otherwise, return false without logging an error.
- bool TryConsume(const char* text);
+ bool TryConsume(y_absl::string_view text);
// These attempt to read some kind of token from the input. If successful,
// they return true. Otherwise they return false and add the given error
// to the error list.
// Consume a token with the exact text given.
- bool Consume(const char* text, const char* error);
+ bool Consume(y_absl::string_view text, y_absl::string_view error);
// Same as above, but automatically generates the error "Expected \"text\".",
// where "text" is the expected token text.
- bool Consume(const char* text);
+ bool Consume(y_absl::string_view text);
// Consume a token of type IDENTIFIER and store its text in "output".
- bool ConsumeIdentifier(TProtoStringType* output, const char* error);
+ bool ConsumeIdentifier(TProtoStringType* output, y_absl::string_view error);
// Consume an integer and store its value in "output".
- bool ConsumeInteger(int* output, const char* error);
+ bool ConsumeInteger(int* output, y_absl::string_view error);
// Consume a signed integer and store its value in "output".
- bool ConsumeSignedInteger(int* output, const char* error);
+ bool ConsumeSignedInteger(int* output, y_absl::string_view error);
// Consume a 64-bit integer and store its value in "output". If the value
// is greater than max_value, an error will be reported.
bool ConsumeInteger64(arc_ui64 max_value, arc_ui64* output,
- const char* error);
+ y_absl::string_view error);
+ // Try to consume a 64-bit integer and store its value in "output". No
+ // error is reported on failure, allowing caller to consume token another way.
+ bool TryConsumeInteger64(arc_ui64 max_value, arc_ui64* output);
// Consume a number and store its value in "output". This will accept
// tokens of either INTEGER or FLOAT type.
- bool ConsumeNumber(double* output, const char* error);
+ bool ConsumeNumber(double* output, y_absl::string_view error);
// Consume a string literal and store its (unescaped) value in "output".
- bool ConsumeString(TProtoStringType* output, const char* error);
+ bool ConsumeString(TProtoStringType* output, y_absl::string_view error);
// Consume a token representing the end of the statement. Comments between
// this token and the next will be harvested for documentation. The given
@@ -193,27 +199,30 @@ class PROTOBUF_EXPORT Parser {
// have been passed around by const reference, for no particularly good
// reason. We should probably go through and change them all to mutable
// pointer to make this more intuitive.
- bool TryConsumeEndOfDeclaration(const char* text,
+ bool TryConsumeEndOfDeclaration(y_absl::string_view text,
const LocationRecorder* location);
- bool TryConsumeEndOfDeclarationFinishScope(const char* text,
+ bool TryConsumeEndOfDeclarationFinishScope(y_absl::string_view text,
const LocationRecorder* location);
- bool ConsumeEndOfDeclaration(const char* text,
+ bool ConsumeEndOfDeclaration(y_absl::string_view text,
const LocationRecorder* location);
// -----------------------------------------------------------------
// Error logging helpers
- // Invokes error_collector_->AddError(), if error_collector_ is not NULL.
- void AddError(int line, int column, const TProtoStringType& error);
+ // Invokes error_collector_->RecordError(), if error_collector_ is not NULL.
+ void RecordError(int line, int column, y_absl::string_view error);
- // Invokes error_collector_->AddError() with the line and column number
+ // Invokes error_collector_->RecordError() with the line and column number
// of the current token.
- void AddError(const TProtoStringType& error);
+ void RecordError(y_absl::string_view error);
- // Invokes error_collector_->AddWarning() with the line and column number
+ // Invokes error_collector_->RecordWarning(), if error_collector_ is not NULL.
+ void RecordWarning(int line, int column, y_absl::string_view warning);
+
+ // Invokes error_collector_->RecordWarning() with the line and column number
// of the current token.
- void AddWarning(const TProtoStringType& warning);
+ void RecordWarning(y_absl::string_view warning);
// Records a location in the SourceCodeInfo.location table (see
// descriptor.proto). We use RAII to ensure that the start and end locations
@@ -304,7 +313,7 @@ class PROTOBUF_EXPORT Parser {
// were no errors; only that there were no *syntax* errors. For instance,
// if a service method is defined using proper syntax but uses a primitive
// type as its input or output, ParseMethodField() still returns true
- // and only reports the error by calling AddError(). In practice, this
+ // and only reports the error by calling RecordError(). In practice, this
// makes logic much simpler for the caller.
// Parse a top-level message, enum, service, etc.
@@ -392,6 +401,7 @@ class PROTOBUF_EXPORT Parser {
const LocationRecorder& message_location);
bool ParseReservedNames(DescriptorProto* message,
const LocationRecorder& parent_location);
+ bool ParseReservedName(TProtoStringType* name, y_absl::string_view error_message);
bool ParseReservedNumbers(DescriptorProto* message,
const LocationRecorder& parent_location);
bool ParseReserved(EnumDescriptorProto* message,
@@ -545,8 +555,6 @@ class PROTOBUF_EXPORT Parser {
// the next element (See SourceCodeInfo.Location in descriptor.proto), when
// ConsumeEndOfDeclaration() is called.
std::vector<TProtoStringType> upcoming_detached_comments_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Parser);
};
// A table mapping (descriptor, ErrorLocation) pairs -- as reported by
@@ -570,7 +578,7 @@ class PROTOBUF_EXPORT SourceLocationTable {
bool Find(const Message* descriptor,
DescriptorPool::ErrorCollector::ErrorLocation location, int* line,
int* column) const;
- bool FindImport(const Message* descriptor, const TProtoStringType& name, int* line,
+ bool FindImport(const Message* descriptor, y_absl::string_view name, int* line,
int* column) const;
// Adds a location to the table.
@@ -584,12 +592,12 @@ class PROTOBUF_EXPORT SourceLocationTable {
void Clear();
private:
- typedef std::map<
+ using LocationMap = y_absl::flat_hash_map<
std::pair<const Message*, DescriptorPool::ErrorCollector::ErrorLocation>,
- std::pair<int, int> >
- LocationMap;
+ std::pair<int, int>>;
LocationMap location_map_;
- std::map<std::pair<const Message*, TProtoStringType>, std::pair<int, int> >
+ y_absl::flat_hash_map<std::pair<const Message*, TProtoStringType>,
+ std::pair<int, int>>
import_location_map_;
};
@@ -597,6 +605,6 @@ class PROTOBUF_EXPORT SourceLocationTable {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_PARSER_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/php/names.cc b/contrib/libs/protoc/src/google/protobuf/compiler/php/names.cc
new file mode 100644
index 00000000000..e6fc0145f03
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/php/names.cc
@@ -0,0 +1,144 @@
+// 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/php/names.h"
+
+#include <string>
+
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/compiler/plugin.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.h"
+
+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",
+ "parent", "print", "private", "protected", "public",
+ "readonly", "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 int kReservedNamesSize = 80;
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace php {
+
+bool IsReservedName(y_absl::string_view name) {
+ TProtoStringType lower(name);
+ lower.to_lower();
+ for (int i = 0; i < kReservedNamesSize; i++) {
+ if (lower == kReservedNames[i]) {
+ return true;
+ }
+ }
+ return false;
+}
+
+TProtoStringType ReservedNamePrefix(const TProtoStringType& classname,
+ const FileDescriptor* file) {
+ if (IsReservedName(classname)) {
+ if (file->package() == "google.protobuf") {
+ return "GPB";
+ } else {
+ return "PB";
+ }
+ }
+
+ return "";
+}
+
+namespace {
+
+template <typename DescriptorType>
+TProtoStringType ClassNamePrefixImpl(const TProtoStringType& classname,
+ const DescriptorType* desc) {
+ const TProtoStringType& prefix = (desc->file()->options()).php_class_prefix();
+ if (!prefix.empty()) {
+ return prefix;
+ }
+
+ return ReservedNamePrefix(classname, desc->file());
+}
+
+template <typename DescriptorType>
+TProtoStringType GeneratedClassNameImpl(const DescriptorType* desc) {
+ TProtoStringType classname = ClassNamePrefixImpl(desc->name(), desc) + desc->name();
+ const Descriptor* containing = desc->containing_type();
+ while (containing != NULL) {
+ classname = ClassNamePrefixImpl(containing->name(), desc) + containing->name()
+ + '\\' + classname;
+ containing = containing->containing_type();
+ }
+ return classname;
+}
+
+TProtoStringType GeneratedClassNameImpl(const ServiceDescriptor* desc) {
+ TProtoStringType classname = desc->name();
+ return ClassNamePrefixImpl(classname, desc) + classname;
+}
+
+} // namespace
+
+TProtoStringType ClassNamePrefix(const TProtoStringType& classname,
+ const Descriptor* desc) {
+ return ClassNamePrefixImpl(classname, desc);
+}
+TProtoStringType ClassNamePrefix(const TProtoStringType& classname,
+ const EnumDescriptor* desc) {
+ return ClassNamePrefixImpl(classname, desc);
+}
+
+TProtoStringType GeneratedClassName(const Descriptor* desc) {
+ return GeneratedClassNameImpl(desc);
+}
+
+TProtoStringType GeneratedClassName(const EnumDescriptor* desc) {
+ return GeneratedClassNameImpl(desc);
+}
+
+TProtoStringType GeneratedClassName(const ServiceDescriptor* desc) {
+ return GeneratedClassNameImpl(desc);
+}
+
+} // namespace php
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/php/names.h b/contrib/libs/protoc/src/google/protobuf/compiler/php/names.h
new file mode 100644
index 00000000000..62d7bc5e6c3
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/php/names.h
@@ -0,0 +1,73 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_PHP_NAMES_H__
+#define GOOGLE_PROTOBUF_COMPILER_PHP_NAMES_H__
+
+#include "google/protobuf/descriptor.h"
+
+#include <string>
+
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace php {
+
+// Whether or not a name is reserved.
+PROTOC_EXPORT bool IsReservedName(y_absl::string_view name);
+
+// A prefix to stick in front of reserved names to avoid clashes.
+PROTOC_EXPORT TProtoStringType ReservedNamePrefix(const TProtoStringType& classname,
+ const FileDescriptor* file);
+
+// A prefix to stick in front of all class names.
+PROTOC_EXPORT TProtoStringType ClassNamePrefix(const TProtoStringType& classname,
+ const Descriptor* desc);
+PROTOC_EXPORT TProtoStringType ClassNamePrefix(const TProtoStringType& classname,
+ const EnumDescriptor* desc);
+
+// To skip reserved keywords in php, some generated classname are prefixed.
+// Other code generators may need following API to figure out the actual
+// classname.
+PROTOC_EXPORT TProtoStringType GeneratedClassName(const Descriptor* desc);
+PROTOC_EXPORT TProtoStringType GeneratedClassName(const EnumDescriptor* desc);
+PROTOC_EXPORT TProtoStringType GeneratedClassName(const ServiceDescriptor* desc);
+
+} // namespace php
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_COMPILER_PHP_NAMES_H__
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 ecaccec3391..a39a9c5c0ee 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
@@ -28,50 +28,43 @@
// (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/php/php_generator.h>
-
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/compiler/plugin.h>
-#include <google/protobuf/descriptor.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/port.h>
-#include <google/protobuf/stubs/strutil.h>
+#include "google/protobuf/compiler/php/php_generator.h"
+#include <algorithm>
#include <sstream>
+#include <string>
+#include <vector>
+
+#include "google/protobuf/compiler/code_generator.h"
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/escaping.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_replace.h"
+#include "y_absl/strings/str_split.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/descriptor.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/port.h>
+
#include <util/string/cast.h>
-const TProtoStringType kDescriptorFile = "google/protobuf/descriptor.proto";
-const TProtoStringType kEmptyFile = "google/protobuf/empty.proto";
-const TProtoStringType kEmptyMetadataFile = "GPBMetadata/Google/Protobuf/GPBEmpty.php";
-const TProtoStringType kDescriptorMetadataFile =
+constexpr y_absl::string_view kDescriptorFile =
+ "google/protobuf/descriptor.proto";
+constexpr y_absl::string_view kEmptyFile = "google/protobuf/empty.proto";
+constexpr y_absl::string_view kEmptyMetadataFile =
+ "GPBMetadata/Google/Protobuf/GPBEmpty.php";
+constexpr y_absl::string_view kDescriptorMetadataFile =
"GPBMetadata/Google/Protobuf/Internal/Descriptor.php";
-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",
- "parent", "print", "private", "protected", "public",
- "readonly", "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", "parent",
- "self", "readonly"
-};
-const int kReservedNamesSize = 80;
+constexpr y_absl::string_view kDescriptorPackageName =
+ "Google\\Protobuf\\Internal";
+constexpr y_absl::string_view kValidConstantNames[] = {
+ "int", "float", "bool", "string", "true", "false",
+ "null", "void", "iterable", "parent", "self", "readonly"};
const int kValidConstantNamesSize = 12;
const int kFieldSetter = 1;
const int kFieldGetter = 2;
@@ -86,18 +79,18 @@ struct Options {
bool is_descriptor = false;
bool aggregate_metadata = false;
bool gen_c_wkt = false;
- std::set<TProtoStringType> aggregate_metadata_prefixes;
+ y_absl::flat_hash_set<TProtoStringType> aggregate_metadata_prefixes;
};
namespace {
// Forward decls.
-TProtoStringType PhpName(const TProtoStringType& full_name, const Options& options);
+TProtoStringType PhpName(y_absl::string_view full_name, const Options& options);
TProtoStringType IntToString(arc_i32 value);
-TProtoStringType FilenameToClassname(const TProtoStringType& filename);
+TProtoStringType FilenameToClassname(y_absl::string_view filename);
TProtoStringType GeneratedMetadataFileName(const FileDescriptor* file,
const Options& options);
-TProtoStringType UnderscoresToCamelCase(const TProtoStringType& name,
+TProtoStringType UnderscoresToCamelCase(y_absl::string_view name,
bool cap_first_letter);
void Indent(io::Printer* printer);
void Outdent(io::Printer* printer);
@@ -123,68 +116,19 @@ void GenerateServiceDocComment(io::Printer* printer,
void GenerateServiceMethodDocComment(io::Printer* printer,
const MethodDescriptor* method);
-TProtoStringType ReservedNamePrefix(const TProtoStringType& classname,
- const FileDescriptor* file) {
- bool is_reserved = false;
-
- TProtoStringType lower = classname;
- lower.to_lower();
-
- for (int i = 0; i < kReservedNamesSize; i++) {
- if (lower == kReservedNames[i]) {
- is_reserved = true;
- break;
- }
- }
-
- if (is_reserved) {
- if (file->package() == "google.protobuf") {
- return "GPB";
- } else {
- return "PB";
- }
- }
-
- return "";
-}
-
template <typename DescriptorType>
TProtoStringType DescriptorFullName(const DescriptorType* desc, bool is_internal) {
+ y_absl::string_view full_name = desc->full_name();
if (is_internal) {
- return StringReplace(desc->full_name(),
- "google.protobuf",
- "google.protobuf.internal", false);
- } else {
- return desc->full_name();
- }
-}
-
-template <typename DescriptorType>
-TProtoStringType ClassNamePrefix(const TProtoStringType& classname,
- const DescriptorType* desc) {
- const TProtoStringType& prefix = (desc->file()->options()).php_class_prefix();
- if (!prefix.empty()) {
- return prefix;
- }
-
- return ReservedNamePrefix(classname, desc->file());
-}
-
-template <typename DescriptorType>
-TProtoStringType GeneratedClassNameImpl(const DescriptorType* desc) {
- TProtoStringType classname = ClassNamePrefix(desc->name(), desc) + desc->name();
- const Descriptor* containing = desc->containing_type();
- while (containing != NULL) {
- classname = ClassNamePrefix(containing->name(), desc) + containing->name()
- + '\\' + classname;
- containing = containing->containing_type();
+ constexpr y_absl::string_view replace = "google.protobuf";
+ size_t index = full_name.find(replace);
+ if (index != TProtoStringType::npos) {
+ return y_absl::StrCat(full_name.substr(0, index),
+ "google.protobuf.internal",
+ full_name.substr(index + replace.size()));
+ }
}
- return classname;
-}
-
-TProtoStringType GeneratedClassNameImpl(const ServiceDescriptor* desc) {
- TProtoStringType classname = desc->name();
- return ClassNamePrefix(classname, desc) + classname;
+ return TProtoStringType(full_name);
}
template <typename DescriptorType>
@@ -198,31 +142,13 @@ TProtoStringType LegacyGeneratedClassName(const DescriptorType* desc) {
return ClassNamePrefix(classname, desc) + classname;
}
-TProtoStringType ClassNamePrefix(const TProtoStringType& classname) {
- TProtoStringType lower = classname;
- lower.to_lower();
-
- for (int i = 0; i < kReservedNamesSize; i++) {
- if (lower == kReservedNames[i]) {
- return "PB";
- }
- }
-
- return "";
-}
-
-TProtoStringType ConstantNamePrefix(const TProtoStringType& classname) {
+TProtoStringType ConstantNamePrefix(y_absl::string_view classname) {
bool is_reserved = false;
- TProtoStringType lower = classname;
+ TProtoStringType lower(classname);
lower.to_lower();
- for (int i = 0; i < kReservedNamesSize; i++) {
- if (lower == kReservedNames[i]) {
- is_reserved = true;
- break;
- }
- }
+ is_reserved = IsReservedName(lower);
for (int i = 0; i < kValidConstantNamesSize; i++) {
if (lower == kValidConstantNames[i]) {
@@ -242,9 +168,9 @@ template <typename DescriptorType>
TProtoStringType RootPhpNamespace(const DescriptorType* desc,
const Options& options) {
if (desc->file()->options().has_php_namespace()) {
- const TProtoStringType& php_namespace = desc->file()->options().php_namespace();
+ y_absl::string_view php_namespace = desc->file()->options().php_namespace();
if (!php_namespace.empty()) {
- return php_namespace;
+ return TProtoStringType(php_namespace);
}
return "";
}
@@ -257,10 +183,10 @@ TProtoStringType RootPhpNamespace(const DescriptorType* desc,
template <typename DescriptorType>
TProtoStringType FullClassName(const DescriptorType* desc, const Options& options) {
- TProtoStringType classname = GeneratedClassNameImpl(desc);
+ TProtoStringType classname = GeneratedClassName(desc);
TProtoStringType php_namespace = RootPhpNamespace(desc, options);
if (!php_namespace.empty()) {
- return php_namespace + "\\" + classname;
+ return y_absl::StrCat(php_namespace, "\\", classname);
}
return classname;
}
@@ -278,14 +204,19 @@ TProtoStringType LegacyFullClassName(const DescriptorType* desc,
TProtoStringType classname = LegacyGeneratedClassName(desc);
TProtoStringType php_namespace = RootPhpNamespace(desc, options);
if (!php_namespace.empty()) {
- return php_namespace + "\\" + classname;
+ return y_absl::StrCat(php_namespace, "\\", classname);
}
return classname;
}
-TProtoStringType PhpName(const TProtoStringType& full_name, const Options& options) {
+TProtoStringType PhpNamePrefix(y_absl::string_view classname) {
+ if (IsReservedName(classname)) return "PB";
+ return "";
+}
+
+TProtoStringType PhpName(y_absl::string_view full_name, const Options& options) {
if (options.is_descriptor) {
- return kDescriptorPackageName;
+ return TProtoStringType(kDescriptorPackageName);
}
TProtoStringType segment;
@@ -296,7 +227,7 @@ TProtoStringType PhpName(const TProtoStringType& full_name, const Options& optio
segment += full_name[i] + ('A' - 'a');
cap_next_letter = false;
} else if (full_name[i] == '.') {
- result += ClassNamePrefix(segment) + segment + '\\';
+ result += PhpNamePrefix(segment) + segment + '\\';
segment = "";
cap_next_letter = true;
} else {
@@ -304,7 +235,7 @@ TProtoStringType PhpName(const TProtoStringType& full_name, const Options& optio
cap_next_letter = false;
}
}
- result += ClassNamePrefix(segment) + segment;
+ result += PhpNamePrefix(segment) + segment;
return result;
}
@@ -334,51 +265,51 @@ TProtoStringType DefaultForField(const FieldDescriptor* field) {
TProtoStringType GeneratedMetadataFileName(const FileDescriptor* file,
const Options& options) {
- const TProtoStringType& proto_file = file->name();
+ y_absl::string_view proto_file = file->name();
int start_index = 0;
- int first_index = proto_file.find_first_of("/", start_index);
+ int first_index = proto_file.find_first_of('/', start_index);
TProtoStringType result = "";
TProtoStringType segment = "";
if (proto_file == kEmptyFile) {
- return kEmptyMetadataFile;
+ return TProtoStringType(kEmptyMetadataFile);
}
if (options.is_descriptor) {
- return kDescriptorMetadataFile;
+ return TProtoStringType(kDescriptorMetadataFile);
}
// Append directory name.
- TProtoStringType file_no_suffix;
- int lastindex = proto_file.find_last_of(".");
+ y_absl::string_view file_no_suffix;
+ int lastindex = proto_file.find_last_of('.');
if (proto_file == kEmptyFile) {
- return kEmptyMetadataFile;
+ return TProtoStringType(kEmptyMetadataFile);
} else {
file_no_suffix = proto_file.substr(0, lastindex);
}
if (file->options().has_php_metadata_namespace()) {
- const TProtoStringType& php_metadata_namespace =
+ y_absl::string_view php_metadata_namespace =
file->options().php_metadata_namespace();
if (!php_metadata_namespace.empty() && php_metadata_namespace != "\\") {
- result += php_metadata_namespace;
+ y_absl::StrAppend(&result, php_metadata_namespace);
std::replace(result.begin(), result.vend(), '\\', '/');
if (result.at(result.size() - 1) != '/') {
- result += "/";
+ y_absl::StrAppend(&result, "/");
}
}
} else {
- result += "GPBMetadata/";
+ y_absl::StrAppend(&result, "GPBMetadata/");
while (first_index != TProtoStringType::npos) {
segment = UnderscoresToCamelCase(
file_no_suffix.substr(start_index, first_index - start_index), true);
- result += ReservedNamePrefix(segment, file) + segment + "/";
+ y_absl::StrAppend(&result, ReservedNamePrefix(segment, file), segment, "/");
start_index = first_index + 1;
- first_index = file_no_suffix.find_first_of("/", start_index);
+ first_index = file_no_suffix.find_first_of('/', start_index);
}
}
// Append file name.
- int file_name_start = file_no_suffix.find_last_of("/");
+ int file_name_start = file_no_suffix.find_last_of('/');
if (file_name_start == TProtoStringType::npos) {
file_name_start = 0;
} else {
@@ -387,7 +318,8 @@ TProtoStringType GeneratedMetadataFileName(const FileDescriptor* file,
segment = UnderscoresToCamelCase(
file_no_suffix.substr(file_name_start, first_index - file_name_start), true);
- return result + ReservedNamePrefix(segment, file) + segment + ".php";
+ return y_absl::StrCat(result, ReservedNamePrefix(segment, file), segment,
+ ".php");
}
TProtoStringType GeneratedMetadataFileName(const FileDescriptor* file,
@@ -406,7 +338,7 @@ TProtoStringType GeneratedClassFileName(const DescriptorType* desc,
result[i] = '/';
}
}
- return result + ".php";
+ return y_absl::StrCat(result, ".php");
}
template <typename DescriptorType>
@@ -419,28 +351,33 @@ TProtoStringType LegacyGeneratedClassFileName(const DescriptorType* desc,
result[i] = '/';
}
}
- return result + ".php";
+ return y_absl::StrCat(result, ".php");
}
template <typename DescriptorType>
-TProtoStringType LegacyReadOnlyGeneratedClassFileName(const DescriptorType* desc,
- const Options& options) {
- TProtoStringType php_namespace = RootPhpNamespace(desc, options);
+TProtoStringType LegacyReadOnlyGeneratedClassFileName(TProtoStringType php_namespace,
+ const DescriptorType* desc) {
if (!php_namespace.empty()) {
- return php_namespace + "/" + desc->name() + ".php";
+ for (int i = 0; i < php_namespace.size(); i++) {
+ if (php_namespace[i] == '\\') {
+ php_namespace[i] = '/';
+ }
+ }
+ return y_absl::StrCat(php_namespace, "/", desc->name(), ".php");
}
- return desc->name() + ".php";
+
+ return y_absl::StrCat(desc->name(), ".php");
}
TProtoStringType GeneratedServiceFileName(const ServiceDescriptor* service,
const Options& options) {
- TProtoStringType result = FullClassName(service, options) + "Interface";
+ TProtoStringType result = FullClassName(service, options);
for (int i = 0; i < result.size(); i++) {
if (result[i] == '\\') {
result[i] = '/';
}
}
- return result + ".php";
+ return y_absl::StrCat(result, "Interface", ".php");
}
TProtoStringType IntToString(arc_i32 value) {
@@ -492,7 +429,7 @@ TProtoStringType PhpSetterTypeName(const FieldDescriptor* field,
type = "string";
break;
case FieldDescriptor::TYPE_MESSAGE:
- type = "\\" + FullClassName(field->message_type(), options);
+ type = y_absl::StrCat("\\", FullClassName(field->message_type(), options));
break;
case FieldDescriptor::TYPE_GROUP:
return "null";
@@ -500,11 +437,12 @@ TProtoStringType PhpSetterTypeName(const FieldDescriptor* field,
}
if (field->is_repeated()) {
// accommodate for edge case with multiple types.
- size_t start_pos = type.find("|");
+ size_t start_pos = type.find('|');
if (start_pos != TProtoStringType::npos) {
type.replace(start_pos, 1, ">|array<");
}
- type = "array<" + type + ">|\\Google\\Protobuf\\Internal\\RepeatedField";
+ type = y_absl::StrCat("array<", type,
+ ">|\\Google\\Protobuf\\Internal\\RepeatedField");
}
return type;
}
@@ -542,7 +480,7 @@ TProtoStringType PhpGetterTypeName(const FieldDescriptor* field,
case FieldDescriptor::TYPE_STRING:
case FieldDescriptor::TYPE_BYTES: return "string";
case FieldDescriptor::TYPE_MESSAGE:
- return "\\" + FullClassName(field->message_type(), options);
+ return y_absl::StrCat("\\", FullClassName(field->message_type(), options));
case FieldDescriptor::TYPE_GROUP: return "null";
default: assert(false); return "";
}
@@ -558,13 +496,14 @@ TProtoStringType PhpGetterTypeName(const FieldDescriptor* field,
TProtoStringType EnumOrMessageSuffix(const FieldDescriptor* field,
const Options& options) {
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- return ", '" +
- DescriptorFullName(field->message_type(), options.is_descriptor) +
- "'";
+ return y_absl::StrCat(
+ ", '", DescriptorFullName(field->message_type(), options.is_descriptor),
+ "'");
}
if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {
- return ", '" +
- DescriptorFullName(field->enum_type(), options.is_descriptor) + "'";
+ return y_absl::StrCat(
+ ", '", DescriptorFullName(field->enum_type(), options.is_descriptor),
+ "'");
}
return "";
}
@@ -578,7 +517,7 @@ TProtoStringType EnumOrMessageSuffix(const FieldDescriptor* field,
// Converts a name to camel-case. If cap_first_letter is true, capitalize the
// first letter.
-TProtoStringType UnderscoresToCamelCase(const TProtoStringType& name,
+TProtoStringType UnderscoresToCamelCase(y_absl::string_view name,
bool cap_first_letter) {
TProtoStringType result;
for (int i = 0; i < name.size(); i++) {
@@ -659,8 +598,11 @@ void GenerateFieldAccessor(const FieldDescriptor* field, const Options& options,
GenerateFieldDocComment(printer, field, options, kFieldGetter);
// deprecation
- TProtoStringType deprecation_trigger = (field->options().deprecated()) ? "@trigger_error('" +
- field->name() + " is deprecated.', E_USER_DEPRECATED);\n " : "";
+ TProtoStringType deprecation_trigger =
+ (field->options().deprecated())
+ ? y_absl::StrCat("@trigger_error('", field->name(),
+ " is deprecated.', E_USER_DEPRECATED);\n ")
+ : "";
// Emit getter.
if (oneof != NULL) {
@@ -760,18 +702,16 @@ void GenerateFieldAccessor(const FieldDescriptor* field, const Options& options,
"$arr = GPBUtil::checkMapField($var, "
"\\Google\\Protobuf\\Internal\\GPBType::^key_type^, "
"\\Google\\Protobuf\\Internal\\GPBType::^value_type^",
- "key_type", ToUpper(key->type_name()),
- "value_type", ToUpper(value->type_name()));
+ "key_type", y_absl::AsciiStrToUpper(key->type_name()),
+ "value_type", y_absl::AsciiStrToUpper(value->type_name()));
if (value->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- printer->Print(
- ", \\^class_name^);\n",
- "class_name",
- FullClassName(value->message_type(), options) + "::class");
+ printer->Print(", \\^class_name^);\n", "class_name",
+ y_absl::StrCat(FullClassName(value->message_type(), options),
+ "::class"));
} else if (value->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {
printer->Print(
- ", \\^class_name^);\n",
- "class_name",
- FullClassName(value->enum_type(), options) + "::class");
+ ", \\^class_name^);\n", "class_name",
+ y_absl::StrCat(FullClassName(value->enum_type(), options), "::class"));
} else {
printer->Print(");\n");
}
@@ -779,17 +719,15 @@ void GenerateFieldAccessor(const FieldDescriptor* field, const Options& options,
printer->Print(
"$arr = GPBUtil::checkRepeatedField($var, "
"\\Google\\Protobuf\\Internal\\GPBType::^type^",
- "type", ToUpper(field->type_name()));
+ "type", y_absl::AsciiStrToUpper(field->type_name()));
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- printer->Print(
- ", \\^class_name^);\n",
- "class_name",
- FullClassName(field->message_type(), options) + "::class");
+ printer->Print(", \\^class_name^);\n", "class_name",
+ y_absl::StrCat(FullClassName(field->message_type(), options),
+ "::class"));
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {
printer->Print(
- ", \\^class_name^);\n",
- "class_name",
- FullClassName(field->enum_type(), options) + "::class");
+ ", \\^class_name^);\n", "class_name",
+ y_absl::StrCat(FullClassName(field->enum_type(), options), "::class"));
} else {
printer->Print(");\n");
}
@@ -879,16 +817,16 @@ void GenerateServiceMethod(const MethodDescriptor* method,
);
}
-void GenerateMessageToPool(const TProtoStringType& name_prefix,
+void GenerateMessageToPool(y_absl::string_view name_prefix,
const Descriptor* message, io::Printer* printer) {
// Don't generate MapEntry messages -- we use the PHP extension's native
// support for map fields instead.
if (message->options().map_entry()) {
return;
}
- TProtoStringType class_name =
- (name_prefix.empty() ? "" : name_prefix + "\\") +
- ReservedNamePrefix(message->name(), message->file()) + message->name();
+ TProtoStringType class_name = y_absl::StrCat(
+ name_prefix.empty() ? "" : y_absl::StrCat(name_prefix, "\\"),
+ ReservedNamePrefix(message->name(), message->file()), message->name());
printer->Print(
"$pool->addMessage('^message^', "
@@ -909,9 +847,9 @@ void GenerateMessageToPool(const TProtoStringType& name_prefix,
"->map('^field^', \\Google\\Protobuf\\Internal\\GPBType::^key^, "
"\\Google\\Protobuf\\Internal\\GPBType::^value^, ^number^^other^)\n",
"field", field->name(),
- "key", ToUpper(key->type_name()),
- "value", ToUpper(val->type_name()),
- "number", StrCat(field->number()),
+ "key", y_absl::AsciiStrToUpper(key->type_name()),
+ "value", y_absl::AsciiStrToUpper(val->type_name()),
+ "number", y_absl::StrCat(field->number()),
"other", EnumOrMessageSuffix(val, true));
} else if (!field->real_containing_oneof()) {
printer->Print(
@@ -919,8 +857,8 @@ void GenerateMessageToPool(const TProtoStringType& name_prefix,
"\\Google\\Protobuf\\Internal\\GPBType::^type^, ^number^^other^)\n",
"field", field->name(),
"label", LabelForField(field),
- "type", ToUpper(field->type_name()),
- "number", StrCat(field->number()),
+ "type", y_absl::AsciiStrToUpper(field->type_name()),
+ "number", y_absl::StrCat(field->number()),
"other", EnumOrMessageSuffix(field, true));
}
}
@@ -937,8 +875,8 @@ void GenerateMessageToPool(const TProtoStringType& name_prefix,
"->value('^field^', "
"\\Google\\Protobuf\\Internal\\GPBType::^type^, ^number^^other^)\n",
"field", field->name(),
- "type", ToUpper(field->type_name()),
- "number", StrCat(field->number()),
+ "type", y_absl::AsciiStrToUpper(field->type_name()),
+ "number", y_absl::StrCat(field->number()),
"other", EnumOrMessageSuffix(field, true));
}
printer->Print("->finish()\n");
@@ -990,7 +928,7 @@ void GenerateAddFileToPool(const FileDescriptor* file, const Options& options,
"$pool->finish();\n");
} else {
for (int i = 0; i < file->dependency_count(); i++) {
- const TProtoStringType& name = file->dependency(i)->name();
+ y_absl::string_view name = file->dependency(i)->name();
// Currently, descriptor.proto is not ready for external usage. Skip to
// import it for now, so that its dependencies can still work as long as
// they don't use protos defined in descriptor.proto.
@@ -1065,9 +1003,10 @@ void GenerateAddFileToPool(const FileDescriptor* file, const Options& options,
static void AnalyzeDependencyForFile(
const FileDescriptor* file,
- std::set<const FileDescriptor*>* nodes_without_dependency,
- std::map<const FileDescriptor*, std::set<const FileDescriptor*>>* deps,
- std::map<const FileDescriptor*, int>* dependency_count) {
+ y_absl::flat_hash_set<const FileDescriptor*>* nodes_without_dependency,
+ y_absl::flat_hash_map<const FileDescriptor*,
+ y_absl::flat_hash_set<const FileDescriptor*>>* deps,
+ y_absl::flat_hash_map<const FileDescriptor*, int>* dependency_count) {
int count = file->dependency_count();
for (int i = 0; i < file->dependency_count(); i++) {
const FileDescriptor* dependency = file->dependency(i);
@@ -1087,7 +1026,7 @@ static void AnalyzeDependencyForFile(
continue;
}
if (deps->find(dependency) == deps->end()) {
- (*deps)[dependency] = std::set<const FileDescriptor*>();
+ (*deps)[dependency] = {};
}
(*deps)[dependency].insert(file);
AnalyzeDependencyForFile(
@@ -1103,7 +1042,7 @@ static bool NeedsUnwrapping(const FileDescriptor* file,
has_aggregate_metadata_prefix = true;
} else {
for (const auto& prefix : options.aggregate_metadata_prefixes) {
- if (HasPrefixString(file->package(), prefix)) {
+ if (y_absl::StartsWith(file->package(), prefix)) {
has_aggregate_metadata_prefix = true;
break;
}
@@ -1123,9 +1062,11 @@ void GenerateAddFilesToPool(const FileDescriptor* file, const Options& options,
"}\n");
// Sort files according to dependency
- std::map<const FileDescriptor*, std::set<const FileDescriptor*>> deps;
- std::map<const FileDescriptor*, int> dependency_count;
- std::set<const FileDescriptor*> nodes_without_dependency;
+ y_absl::flat_hash_map<const FileDescriptor*,
+ y_absl::flat_hash_set<const FileDescriptor*>>
+ deps;
+ y_absl::flat_hash_map<const FileDescriptor*, int> dependency_count;
+ y_absl::flat_hash_set<const FileDescriptor*> nodes_without_dependency;
FileDescriptorSet sorted_file_set;
AnalyzeDependencyForFile(
@@ -1231,10 +1172,10 @@ void GenerateHead(const FileDescriptor* file, io::Printer* printer) {
"filename", file->name());
}
-TProtoStringType FilenameToClassname(const TProtoStringType& filename) {
- int lastindex = filename.find_last_of(".");
- TProtoStringType result = filename.substr(0, lastindex);
- for (int i = 0; i < result.size(); i++) {
+TProtoStringType FilenameToClassname(y_absl::string_view filename) {
+ size_t lastindex = filename.find_last_of('.');
+ TProtoStringType result(filename.substr(0, lastindex));
+ for (size_t i = 0; i < result.size(); i++) {
if (result[i] == '/') {
result[i] = '\\';
}
@@ -1252,7 +1193,7 @@ void GenerateMetadataFile(const FileDescriptor* file, const Options& options,
GenerateHead(file, &printer);
TProtoStringType fullname = FilenameToClassname(filename);
- int lastindex = fullname.find_last_of("\\");
+ int lastindex = fullname.find_last_of('\\');
if (lastindex != TProtoStringType::npos) {
printer.Print(
@@ -1307,7 +1248,7 @@ void LegacyGenerateClassFile(const FileDescriptor* file,
Outdent(&printer);
printer.Print("}\n");
printer.Print("class_exists(^new^::class);\n",
- "new", GeneratedClassNameImpl(desc));
+ "new", GeneratedClassName(desc));
printer.Print("@trigger_error('^old^ is deprecated and will be removed in "
"the next major release. Use ^fullname^ instead', E_USER_DEPRECATED);\n\n",
"old", LegacyFullClassName(desc, options),
@@ -1318,27 +1259,39 @@ template <typename DescriptorType>
void LegacyReadOnlyGenerateClassFile(const FileDescriptor* file,
const DescriptorType* desc, const Options& options,
GeneratorContext* generator_context) {
- TProtoStringType filename = LegacyReadOnlyGeneratedClassFileName(desc, options);
+ TProtoStringType fullname = FullClassName(desc, options);
+ TProtoStringType php_namespace;
+ TProtoStringType classname;
+ int lastindex = fullname.find_last_of("\\");
+
+ if (lastindex != TProtoStringType::npos) {
+ php_namespace = fullname.substr(0, lastindex);
+ classname = fullname.substr(lastindex + 1);
+ } else {
+ php_namespace = "";
+ classname = fullname;
+ }
+
+ TProtoStringType filename = LegacyReadOnlyGeneratedClassFileName(php_namespace, desc);
std::unique_ptr<io::ZeroCopyOutputStream> output(
generator_context->Open(filename));
io::Printer printer(output.get(), '^');
GenerateHead(file, &printer);
- TProtoStringType php_namespace = RootPhpNamespace(desc, options);
if (!php_namespace.empty()) {
printer.Print(
"namespace ^name^;\n\n",
"name", php_namespace);
}
- TProtoStringType newname = FullClassName(desc, options);
+
printer.Print("class_exists(^new^::class); // autoload the new class, which "
"will also create an alias to the deprecated class\n",
- "new", GeneratedClassNameImpl(desc));
+ "new", classname);
printer.Print("@trigger_error(__NAMESPACE__ . '\\^old^ is deprecated and will be removed in "
"the next major release. Use ^fullname^ instead', E_USER_DEPRECATED);\n\n",
"old", desc->name(),
- "fullname", newname);
+ "fullname", classname);
}
void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en,
@@ -1352,7 +1305,7 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en,
GenerateHead(file, &printer);
TProtoStringType fullname = FilenameToClassname(filename);
- int lastindex = fullname.find_last_of("\\");
+ int lastindex = fullname.find_last_of('\\');
if (lastindex != TProtoStringType::npos) {
printer.Print(
@@ -1452,7 +1405,7 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en,
Outdent(&printer);
printer.Print("}\n\n");
- // write legacy file for backwards compatibility with nested messages and enums
+ // write legacy alias for backwards compatibility with nested messages and enums
if (en->containing_type() != NULL) {
printer.Print(
"// Adding a class alias for backwards compatibility with the previous class name.\n");
@@ -1460,7 +1413,6 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en,
"class_alias(^new^::class, \\^old^::class);\n\n",
"new", fullname,
"old", LegacyFullClassName(en, options));
- LegacyGenerateClassFile(file, en, options, generator_context);
}
// Write legacy file for backwards compatibility with "readonly" keywword
@@ -1494,7 +1446,7 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message,
GenerateHead(file, &printer);
TProtoStringType fullname = FilenameToClassname(filename);
- int lastindex = fullname.find_last_of("\\");
+ int lastindex = fullname.find_last_of('\\');
if (lastindex != TProtoStringType::npos) {
printer.Print(
@@ -1580,7 +1532,7 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message,
Outdent(&printer);
printer.Print("}\n\n");
- // write legacy file for backwards compatibility with nested messages and enums
+ // write legacy alias for backwards compatibility with nested messages and enums
if (message->containing_type() != NULL) {
printer.Print(
"// Adding a class alias for backwards compatibility with the previous class name.\n");
@@ -1588,7 +1540,6 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message,
"class_alias(^new^::class, \\^old^::class);\n\n",
"new", fullname,
"old", LegacyFullClassName(message, options));
- LegacyGenerateClassFile(file, message, options, generator_context);
}
// Write legacy file for backwards compatibility with "readonly" keywword
@@ -1625,7 +1576,7 @@ void GenerateServiceFile(
GenerateHead(file, &printer);
TProtoStringType fullname = FilenameToClassname(filename);
- int lastindex = fullname.find_last_of("\\");
+ int lastindex = fullname.find_last_of('\\');
if (!file->options().php_namespace().empty() ||
(!file->options().has_php_namespace() && !file->package().empty()) ||
@@ -1679,7 +1630,7 @@ void GenerateFile(const FileDescriptor* file, const Options& options,
}
}
-static TProtoStringType EscapePhpdoc(const TProtoStringType& input) {
+static TProtoStringType EscapePhpdoc(y_absl::string_view input) {
TProtoStringType result;
result.reserve(input.size() * 2);
@@ -1736,7 +1687,8 @@ static void GenerateDocCommentBodyForLocation(
// HTML-escape them so that they don't accidentally close the doc comment.
comments = EscapePhpdoc(comments);
- std::vector<TProtoStringType> lines = Split(comments, "\n", true);
+ std::vector<y_absl::string_view> lines =
+ y_absl::StrSplit(comments, '\n', y_absl::SkipEmpty());
while (!lines.empty() && lines.back().empty()) {
lines.pop_back();
}
@@ -1767,8 +1719,8 @@ static void GenerateDocCommentBody(
}
}
-static TProtoStringType FirstLineOf(const TProtoStringType& value) {
- TProtoStringType result = value;
+static TProtoStringType FirstLineOf(y_absl::string_view value) {
+ TProtoStringType result(value);
TProtoStringType::size_type pos = result.find_first_of('\n');
if (pos != TProtoStringType::npos) {
@@ -1935,17 +1887,13 @@ void GenerateServiceMethodDocComment(io::Printer* printer,
}
TProtoStringType FilenameCName(const FileDescriptor* file) {
- TProtoStringType c_name = file->name();
- c_name = StringReplace(c_name, ".", "_", true);
- c_name = StringReplace(c_name, "/", "_", true);
- return c_name;
+ return y_absl::StrReplaceAll(file->name(), {{".", "_"}, {"/", "_"}});
}
void GenerateCEnum(const EnumDescriptor* desc, io::Printer* printer) {
- TProtoStringType c_name = desc->full_name();
- c_name = StringReplace(c_name, ".", "_", true);
- TProtoStringType php_name = FullClassName(desc, Options());
- php_name = StringReplace(php_name, "\\", "\\\\", true);
+ TProtoStringType c_name = y_absl::StrReplaceAll(desc->full_name(), {{".", "_"}});
+ TProtoStringType php_name =
+ y_absl::StrReplaceAll(FullClassName(desc, Options()), {{"\\", "\\\\"}});
printer->Print(
"/* $c_name$ */\n"
"\n"
@@ -2028,10 +1976,9 @@ void GenerateCEnum(const EnumDescriptor* desc, io::Printer* printer) {
}
void GenerateCMessage(const Descriptor* message, io::Printer* printer) {
- TProtoStringType c_name = message->full_name();
- c_name = StringReplace(c_name, ".", "_", true);
- TProtoStringType php_name = FullClassName(message, Options());
- php_name = StringReplace(php_name, "\\", "\\\\", true);
+ TProtoStringType c_name = y_absl::StrReplaceAll(message->full_name(), {{".", "_"}});
+ TProtoStringType php_name =
+ y_absl::StrReplaceAll(FullClassName(message, Options()), {{"\\", "\\\\"}});
printer->Print(
"/* $c_name$ */\n"
"\n"
@@ -2181,8 +2128,7 @@ void GenerateCMessage(const Descriptor* message, io::Printer* printer) {
}
void GenerateEnumCInit(const EnumDescriptor* desc, io::Printer* printer) {
- TProtoStringType c_name = desc->full_name();
- c_name = StringReplace(c_name, ".", "_", true);
+ TProtoStringType c_name = y_absl::StrReplaceAll(desc->full_name(), {{".", "_"}});
printer->Print(
" $c_name$_ModuleInit();\n",
@@ -2190,8 +2136,7 @@ void GenerateEnumCInit(const EnumDescriptor* desc, io::Printer* printer) {
}
void GenerateCInit(const Descriptor* message, io::Printer* printer) {
- TProtoStringType c_name = message->full_name();
- c_name = StringReplace(c_name, ".", "_", true);
+ TProtoStringType c_name = y_absl::StrReplaceAll(message->full_name(), {{".", "_"}});
printer->Print(
" $c_name$_ModuleInit();\n",
@@ -2233,8 +2178,9 @@ void GenerateCWellKnownTypes(const std::vector<const FileDescriptor*>& files,
TProtoStringType metadata_filename = GeneratedMetadataFileName(file, Options());
TProtoStringType metadata_classname = FilenameToClassname(metadata_filename);
TProtoStringType metadata_c_name =
- StringReplace(metadata_classname, "\\", "_", true);
- metadata_classname = StringReplace(metadata_classname, "\\", "\\\\", true);
+ y_absl::StrReplaceAll(metadata_classname, {{"\\", "_"}});
+ metadata_classname =
+ y_absl::StrReplaceAll(metadata_classname, {{"\\", "\\\\"}});
FileDescriptorProto file_proto;
file->CopyTo(&file_proto);
TProtoStringType serialized;
@@ -2252,7 +2198,7 @@ void GenerateCWellKnownTypes(const std::vector<const FileDescriptor*>& files,
for (size_t i = 0; i < serialized.size();) {
for (size_t j = 0; j < 25 && i < serialized.size(); ++i, ++j) {
- printer.Print("'$ch$', ", "ch", CEscape(serialized.substr(i, 1)));
+ printer.Print("'$ch$', ", "ch", y_absl::CEscape(serialized.substr(i, 1)));
}
printer.Print("\n");
}
@@ -2315,7 +2261,7 @@ void GenerateCWellKnownTypes(const std::vector<const FileDescriptor*>& files,
TProtoStringType metadata_filename = GeneratedMetadataFileName(file, Options());
TProtoStringType metadata_classname = FilenameToClassname(metadata_filename);
TProtoStringType metadata_c_name =
- StringReplace(metadata_classname, "\\", "_", true);
+ y_absl::StrReplaceAll(metadata_classname, {{"\\", "_"}});
printer.Print(
" $metadata_c_name$_ModuleInit();\n",
"metadata_c_name", metadata_c_name);
@@ -2333,18 +2279,6 @@ void GenerateCWellKnownTypes(const std::vector<const FileDescriptor*>& files,
} // namespace
-TProtoStringType GeneratedClassName(const Descriptor* desc) {
- return GeneratedClassNameImpl(desc);
-}
-
-TProtoStringType GeneratedClassName(const EnumDescriptor* desc) {
- return GeneratedClassNameImpl(desc);
-}
-
-TProtoStringType GeneratedClassName(const ServiceDescriptor* desc) {
- return GeneratedClassNameImpl(desc);
-}
-
bool Generator::Generate(const FileDescriptor* file,
const TProtoStringType& parameter,
GeneratorContext* generator_context,
@@ -2379,20 +2313,20 @@ bool Generator::GenerateAll(const std::vector<const FileDescriptor*>& files,
TProtoStringType* error) const {
Options options;
- for (const auto& option : Split(parameter, ",", true)) {
- const std::vector<TProtoStringType> option_pair = Split(option, "=", true);
- if (HasPrefixString(option_pair[0], "aggregate_metadata")) {
+ for (const auto& option : y_absl::StrSplit(parameter, ",", y_absl::SkipEmpty())) {
+ const std::vector<TProtoStringType> option_pair = y_absl::StrSplit(option, "=", y_absl::SkipEmpty());
+ if (y_absl::StartsWith(option_pair[0], "aggregate_metadata")) {
options.aggregate_metadata = true;
- for (const auto& prefix : Split(option_pair[1], "#", false)) {
+ for (const auto& prefix : y_absl::StrSplit(option_pair[1], "#", y_absl::AllowEmpty())) {
options.aggregate_metadata_prefixes.emplace(prefix);
- GOOGLE_LOG(INFO) << prefix;
+ Y_ABSL_LOG(INFO) << prefix;
}
} else if (option_pair[0] == "internal") {
options.is_descriptor = true;
} else if (option_pair[0] == "internal_generate_c_wkt") {
GenerateCWellKnownTypes(files, generator_context);
} else {
- GOOGLE_LOG(FATAL) << "Unknown codegen option: " << option_pair[0];
+ Y_ABSL_LOG(FATAL) << "Unknown codegen option: " << option_pair[0];
}
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/php/php_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/php/php_generator.h
index 0247afaa560..66fa0034f58 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/php/php_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/php/php_generator.h
@@ -31,12 +31,13 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_PHP_GENERATOR_H__
#define GOOGLE_PROTOBUF_COMPILER_PHP_GENERATOR_H__
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/descriptor.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/compiler/php/names.h"
+#include "google/protobuf/descriptor.h"
#include <string>
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -70,13 +71,6 @@ class PROTOC_EXPORT Generator : public CodeGenerator {
TProtoStringType* error) const;
};
-// To skip reserved keywords in php, some generated classname are prefixed.
-// Other code generators may need following API to figure out the actual
-// classname.
-PROTOC_EXPORT TProtoStringType GeneratedClassName(const Descriptor* desc);
-PROTOC_EXPORT TProtoStringType GeneratedClassName(const EnumDescriptor* desc);
-PROTOC_EXPORT TProtoStringType GeneratedClassName(const ServiceDescriptor* desc);
-
inline bool IsWrapperType(const FieldDescriptor* descriptor) {
return descriptor->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
descriptor->message_type()->file()->name() == "google/protobuf/wrappers.proto";
@@ -87,6 +81,6 @@ inline bool IsWrapperType(const FieldDescriptor* descriptor) {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_PHP_GENERATOR_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc
index 68e23498c1d..b1dfde1088f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc
@@ -30,25 +30,21 @@
// Author: [email protected] (Kenton Varda)
-#include <google/protobuf/compiler/plugin.h>
+#include "google/protobuf/compiler/plugin.h"
#include <iostream>
-#include <set>
-
#ifdef _WIN32
#include <fcntl.h>
#else
#include <unistd.h>
#endif
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/compiler/plugin.pb.h>
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/io_win32.h>
-#include <google/protobuf/io/zero_copy_stream_impl.h>
+#include "google/protobuf/compiler/plugin.pb.h"
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/io_win32.h"
+#include "google/protobuf/io/zero_copy_stream_impl.h"
namespace google {
@@ -128,10 +124,10 @@ bool GenerateCode(const CodeGeneratorRequest& request,
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() == nullptr) {
- *error_msg =
+ *error_msg = y_absl::StrCat(
"protoc asked plugin to generate a file but "
- "did not provide a descriptor for the file: " +
- request.file_to_generate(i);
+ "did not provide a descriptor for the file: ",
+ request.file_to_generate(i));
return false;
}
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.h b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.h
index 65af26e0f74..516fbedcece 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.h
@@ -66,7 +66,7 @@
#include <google/protobuf/stubs/port.h>
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -92,6 +92,6 @@ bool GenerateCode(const CodeGeneratorRequest& request,
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_PLUGIN_H__
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 55fa2a69812..b43ab534898 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc
@@ -1,210 +1,266 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/compiler/plugin.proto
-#include <google/protobuf/compiler/plugin.pb.h>
+#include "google/protobuf/compiler/plugin.pb.h"
#include <algorithm>
-
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/extension_set.h>
-#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/reflection_ops.h>
-#include <google/protobuf/wire_format.h>
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/extension_set.h"
+#include "google/protobuf/wire_format_lite.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/reflection_ops.h"
+#include "google/protobuf/wire_format.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+// Must be included last.
+#include "google/protobuf/port_def.inc"
PROTOBUF_PRAGMA_INIT_SEG
-
namespace _pb = ::PROTOBUF_NAMESPACE_ID;
-namespace _pbi = _pb::internal;
-
+namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal;
PROTOBUF_NAMESPACE_OPEN
namespace compiler {
PROTOBUF_CONSTEXPR Version::Version(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
- , /*decltype(_impl_.suffix_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.major_)*/0
- , /*decltype(_impl_.minor_)*/0
- , /*decltype(_impl_.patch_)*/0} {}
+ , /*decltype(_impl_.suffix_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.major_)*/ 0
+
+ , /*decltype(_impl_.minor_)*/ 0
+
+ , /*decltype(_impl_.patch_)*/ 0
+} {}
struct VersionDefaultTypeInternal {
- PROTOBUF_CONSTEXPR VersionDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR VersionDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~VersionDefaultTypeInternal() {}
union {
Version _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 VersionDefaultTypeInternal _Version_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 VersionDefaultTypeInternal _Version_default_instance_;
PROTOBUF_CONSTEXPR CodeGeneratorRequest::CodeGeneratorRequest(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
, /*decltype(_impl_.file_to_generate_)*/{}
, /*decltype(_impl_.proto_file_)*/{}
- , /*decltype(_impl_.parameter_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
+ , /*decltype(_impl_.parameter_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
, /*decltype(_impl_.compiler_version_)*/nullptr} {}
struct CodeGeneratorRequestDefaultTypeInternal {
- PROTOBUF_CONSTEXPR CodeGeneratorRequestDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR CodeGeneratorRequestDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~CodeGeneratorRequestDefaultTypeInternal() {}
union {
CodeGeneratorRequest _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_;
PROTOBUF_CONSTEXPR CodeGeneratorResponse_File::CodeGeneratorResponse_File(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
- , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.insertion_point_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.content_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
+ , /*decltype(_impl_.name_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.insertion_point_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.content_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
, /*decltype(_impl_.generated_code_info_)*/nullptr} {}
struct CodeGeneratorResponse_FileDefaultTypeInternal {
- PROTOBUF_CONSTEXPR CodeGeneratorResponse_FileDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR CodeGeneratorResponse_FileDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~CodeGeneratorResponse_FileDefaultTypeInternal() {}
union {
CodeGeneratorResponse_File _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_;
PROTOBUF_CONSTEXPR CodeGeneratorResponse::CodeGeneratorResponse(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
, /*decltype(_impl_.file_)*/{}
- , /*decltype(_impl_.error_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
- , /*decltype(_impl_.supported_features_)*/arc_ui64{0u}} {}
+ , /*decltype(_impl_.error_)*/ {
+ &::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
+ }
+
+ , /*decltype(_impl_.supported_features_)*/ ::arc_ui64{0u}
+} {}
struct CodeGeneratorResponseDefaultTypeInternal {
- PROTOBUF_CONSTEXPR CodeGeneratorResponseDefaultTypeInternal()
- : _instance(::_pbi::ConstantInitialized{}) {}
+ PROTOBUF_CONSTEXPR CodeGeneratorResponseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~CodeGeneratorResponseDefaultTypeInternal() {}
union {
CodeGeneratorResponse _instance;
};
};
-PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_;
+
+PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_;
} // namespace compiler
PROTOBUF_NAMESPACE_CLOSE
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, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.major_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.minor_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.patch_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.suffix_),
- 1,
- 2,
- 3,
- 0,
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.file_to_generate_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.parameter_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.proto_file_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.compiler_version_),
- ~0u,
- 0,
- ~0u,
- 1,
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.name_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.insertion_point_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.content_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.generated_code_info_),
- 0,
- 1,
- 2,
- 3,
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_._has_bits_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _internal_metadata_),
- ~0u, // no _extensions_
- ~0u, // no _oneof_case_
- ~0u, // no _weak_field_map_
- ~0u, // no _inlined_string_donated_
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.error_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.supported_features_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.file_),
- 0,
- 1,
- ~0u,
+static constexpr const ::_pb::ServiceDescriptor**
+ 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, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.major_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.minor_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.patch_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.suffix_),
+ 1,
+ 2,
+ 3,
+ 0,
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.file_to_generate_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.parameter_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.proto_file_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.compiler_version_),
+ ~0u,
+ 0,
+ ~0u,
+ 1,
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.name_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.insertion_point_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.content_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.generated_code_info_),
+ 0,
+ 1,
+ 2,
+ 3,
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_._has_bits_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ ~0u, // no _inlined_string_donated_
+ ~0u, // no _split_
+ ~0u, // no sizeof(Split)
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.error_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.supported_features_),
+ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.file_),
+ 0,
+ 1,
+ ~0u,
};
-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 const ::_pbi::MigrationSchema
+ schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ { 0, 12, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::Version)},
+ { 16, 28, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest)},
+ { 32, 44, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File)},
+ { 48, 59, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse)},
};
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,
+ &::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) =
- "\n%google/protobuf/compiler/plugin.proto\022"
- "\030google.protobuf.compiler\032 google/protob"
- "uf/descriptor.proto\"F\n\007Version\022\r\n\005major\030"
- "\001 \001(\005\022\r\n\005minor\030\002 \001(\005\022\r\n\005patch\030\003 \001(\005\022\016\n\006s"
- "uffix\030\004 \001(\t\"\272\001\n\024CodeGeneratorRequest\022\030\n\020"
- "file_to_generate\030\001 \003(\t\022\021\n\tparameter\030\002 \001("
- "\t\0228\n\nproto_file\030\017 \003(\0132$.google.protobuf."
- "FileDescriptorProto\022;\n\020compiler_version\030"
- "\003 \001(\0132!.google.protobuf.compiler.Version"
- "\"\301\002\n\025CodeGeneratorResponse\022\r\n\005error\030\001 \001("
- "\t\022\032\n\022supported_features\030\002 \001(\004\022B\n\004file\030\017 "
- "\003(\01324.google.protobuf.compiler.CodeGener"
- "atorResponse.File\032\177\n\004File\022\014\n\004name\030\001 \001(\t\022"
- "\027\n\017insertion_point\030\002 \001(\t\022\017\n\007content\030\017 \001("
- "\t\022\?\n\023generated_code_info\030\020 \001(\0132\".google."
- "protobuf.GeneratedCodeInfo\"8\n\007Feature\022\020\n"
- "\014FEATURE_NONE\020\000\022\033\n\027FEATURE_PROTO3_OPTION"
- "AL\020\001BW\n\034com.google.protobuf.compilerB\014Pl"
- "uginProtosZ)google.golang.org/protobuf/t"
- "ypes/pluginpb"
- ;
-static const ::_pbi::DescriptorTable* const descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps[1] = {
- &::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto,
+const char descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
+ "\n%google/protobuf/compiler/plugin.proto\022"
+ "\030google.protobuf.compiler\032 google/protob"
+ "uf/descriptor.proto\"F\n\007Version\022\r\n\005major\030"
+ "\001 \001(\005\022\r\n\005minor\030\002 \001(\005\022\r\n\005patch\030\003 \001(\005\022\016\n\006s"
+ "uffix\030\004 \001(\t\"\272\001\n\024CodeGeneratorRequest\022\030\n\020"
+ "file_to_generate\030\001 \003(\t\022\021\n\tparameter\030\002 \001("
+ "\t\0228\n\nproto_file\030\017 \003(\0132$.google.protobuf."
+ "FileDescriptorProto\022;\n\020compiler_version\030"
+ "\003 \001(\0132!.google.protobuf.compiler.Version"
+ "\"\301\002\n\025CodeGeneratorResponse\022\r\n\005error\030\001 \001("
+ "\t\022\032\n\022supported_features\030\002 \001(\004\022B\n\004file\030\017 "
+ "\003(\01324.google.protobuf.compiler.CodeGener"
+ "atorResponse.File\032\177\n\004File\022\014\n\004name\030\001 \001(\t\022"
+ "\027\n\017insertion_point\030\002 \001(\t\022\017\n\007content\030\017 \001("
+ "\t\022\?\n\023generated_code_info\030\020 \001(\0132\".google."
+ "protobuf.GeneratedCodeInfo\"8\n\007Feature\022\020\n"
+ "\014FEATURE_NONE\020\000\022\033\n\027FEATURE_PROTO3_OPTION"
+ "AL\020\001Br\n\034com.google.protobuf.compilerB\014Pl"
+ "uginProtosZ)google.golang.org/protobuf/t"
+ "ypes/pluginpb\252\002\030Google.Protobuf.Compiler"
+};
+static const ::_pbi::DescriptorTable* const descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps[1] =
+ {
+ &::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto,
};
-static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once;
+static ::y_absl::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,
+ false,
+ false,
+ 800,
+ 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,
+ &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,
};
+
+// This function exists to be marked as weak.
+// It can significantly speed up compilation by breaking up LLVM's SCC
+// in the .pb.cc translation units. Large translation units see a
+// reduction of more than 35% of walltime for optimized builds. Without
+// the weak attribute all the messages in the file, including all the
+// vtables and everything they use become part of the same SCC through
+// a cycle like:
+// GetMetadata -> descriptor table -> default instances ->
+// 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 ::_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_PRIORITY2 static ::_pbi::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() {
@@ -220,20 +276,24 @@ bool CodeGeneratorResponse_Feature_IsValid(int value) {
return false;
}
}
+#if (__cplusplus < 201703) && \
+ (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
-#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse::FEATURE_NONE;
constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse::FEATURE_PROTO3_OPTIONAL;
constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse::Feature_MIN;
constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse::Feature_MAX;
constexpr int CodeGeneratorResponse::Feature_ARRAYSIZE;
-#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
+#endif // (__cplusplus < 201703) &&
+ // (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
// ===================================================================
class Version::_Internal {
public:
using HasBits = decltype(std::declval<Version>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(Version, _impl_._has_bits_);
static void set_has_major(HasBits* has_bits) {
(*has_bits)[0] |= 2u;
}
@@ -248,10 +308,9 @@ class Version::_Internal {
}
};
-Version::Version(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+Version::Version(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.Version)
}
Version::Version(const Version& from)
@@ -260,42 +319,47 @@ Version::Version(const Version& from)
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){from._impl_._has_bits_}
, /*decltype(_impl_._cached_size_)*/{}
- , decltype(_impl_.suffix_){}
- , decltype(_impl_.major_){}
- , decltype(_impl_.minor_){}
- , decltype(_impl_.patch_){}};
+ , decltype(_impl_.suffix_) {}
+
+ , decltype(_impl_.major_) {}
+
+ , decltype(_impl_.minor_) {}
+
+ , decltype(_impl_.patch_) {}
+ };
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.suffix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.suffix_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_suffix()) {
- _this->_impl_.suffix_.Set(from._internal_suffix(),
- _this->GetArenaForAllocation());
+ _impl_.suffix_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
+ _this->_impl_.suffix_.Set(from._internal_suffix(), _this->GetArenaForAllocation());
}
::memcpy(&_impl_.major_, &from._impl_.major_,
- static_cast<size_t>(reinterpret_cast<char*>(&_impl_.patch_) -
+ static_cast<::size_t>(reinterpret_cast<char*>(&_impl_.patch_) -
reinterpret_cast<char*>(&_impl_.major_)) + sizeof(_impl_.patch_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.Version)
}
-inline void Version::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void Version::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
- , decltype(_impl_.suffix_){}
- , decltype(_impl_.major_){0}
- , decltype(_impl_.minor_){0}
- , decltype(_impl_.patch_){0}
+ , decltype(_impl_.suffix_) {}
+
+ , decltype(_impl_.major_) { 0 }
+
+ , decltype(_impl_.minor_) { 0 }
+
+ , decltype(_impl_.patch_) { 0 }
+
};
_impl_.suffix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.suffix_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.suffix_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
Version::~Version() {
@@ -308,7 +372,7 @@ Version::~Version() {
}
inline void Version::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.suffix_.Destroy();
}
@@ -318,7 +382,7 @@ void Version::SetCachedSize(int size) const {
void Version::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.Version)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -327,7 +391,7 @@ void Version::Clear() {
_impl_.suffix_.ClearNonDefaultToEmpty();
}
if (cached_has_bits & 0x0000000eu) {
- ::memset(&_impl_.major_, 0, static_cast<size_t>(
+ ::memset(&_impl_.major_, 0, static_cast<::size_t>(
reinterpret_cast<char*>(&_impl_.patch_) -
reinterpret_cast<char*>(&_impl_.major_)) + sizeof(_impl_.patch_));
}
@@ -339,47 +403,51 @@ 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;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional int32 major = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) {
_Internal::set_has_major(&has_bits);
_impl_.major_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional int32 minor = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 16)) {
_Internal::set_has_minor(&has_bits);
_impl_.minor_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional int32 patch = 3;
case 3:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 24)) {
_Internal::set_has_patch(&has_bits);
_impl_.patch_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string suffix = 4;
case 4:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 34)) {
auto str = _internal_mutable_suffix();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.compiler.Version.suffix");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -405,39 +473,40 @@ failure:
#undef CHK_
}
-uint8_t* Version::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* Version::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.Version)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
// optional int32 major = 1;
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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 = ::_pbi::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 = ::_pbi::WireFormatLite::WriteInt32ToArray(3, this->_internal_patch(), target);
+ target = ::_pbi::WireFormatLite::WriteInt32ToArray(
+ 3, this->_internal_patch(), target);
}
// optional string suffix = 4;
if (cached_has_bits & 0x00000001u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_suffix().data(), static_cast<int>(this->_internal_suffix().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.compiler.Version.suffix");
- target = stream->WriteStringMaybeAliased(
- 4, this->_internal_suffix(), target);
+ const TProtoStringType& _s = this->_internal_suffix();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.compiler.Version.suffix");
+ target = stream->WriteStringMaybeAliased(4, _s, target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
@@ -448,11 +517,11 @@ uint8_t* Version::_InternalSerialize(
return target;
}
-size_t Version::ByteSizeLong() const {
+::size_t Version::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.Version)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -460,24 +529,26 @@ size_t Version::ByteSizeLong() const {
if (cached_has_bits & 0x0000000fu) {
// optional string suffix = 4;
if (cached_has_bits & 0x00000001u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_suffix());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_suffix());
}
// optional int32 major = 1;
if (cached_has_bits & 0x00000002u) {
- total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_major());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(
+ this->_internal_major());
}
// optional int32 minor = 2;
if (cached_has_bits & 0x00000004u) {
- total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_minor());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(
+ this->_internal_minor());
}
// optional int32 patch = 3;
if (cached_has_bits & 0x00000008u) {
- total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_patch());
+ total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(
+ this->_internal_patch());
}
}
@@ -495,8 +566,8 @@ void Version::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOB
auto* const _this = static_cast<Version*>(&to_msg);
auto& from = static_cast<const Version&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.Version)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._impl_._has_bits_[0];
@@ -535,10 +606,8 @@ void Version::InternalSwap(Version* other) {
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.suffix_, lhs_arena,
- &other->_impl_.suffix_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.suffix_, lhs_arena,
+ &other->_impl_.suffix_, rhs_arena);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(Version, _impl_.patch_)
+ sizeof(Version::_impl_.patch_)
@@ -552,12 +621,13 @@ void Version::InternalSwap(Version* other) {
&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]);
}
-
// ===================================================================
class CodeGeneratorRequest::_Internal {
public:
using HasBits = decltype(std::declval<CodeGeneratorRequest>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(CodeGeneratorRequest, _impl_._has_bits_);
static void set_has_parameter(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -574,10 +644,9 @@ CodeGeneratorRequest::_Internal::compiler_version(const CodeGeneratorRequest* ms
void CodeGeneratorRequest::clear_proto_file() {
_impl_.proto_file_.Clear();
}
-CodeGeneratorRequest::CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+CodeGeneratorRequest::CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.CodeGeneratorRequest)
}
CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from)
@@ -588,40 +657,39 @@ CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from)
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.file_to_generate_){from._impl_.file_to_generate_}
, decltype(_impl_.proto_file_){from._impl_.proto_file_}
- , decltype(_impl_.parameter_){}
+ , decltype(_impl_.parameter_) {}
+
, decltype(_impl_.compiler_version_){nullptr}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.parameter_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.parameter_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_parameter()) {
- _this->_impl_.parameter_.Set(from._internal_parameter(),
- _this->GetArenaForAllocation());
+ _impl_.parameter_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
+ _this->_impl_.parameter_.Set(from._internal_parameter(), _this->GetArenaForAllocation());
}
- if (from._internal_has_compiler_version()) {
+ if ((from._impl_._has_bits_[0] & 0x00000002u) != 0) {
_this->_impl_.compiler_version_ = new ::PROTOBUF_NAMESPACE_ID::compiler::Version(*from._impl_.compiler_version_);
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorRequest)
}
-inline void CodeGeneratorRequest::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void CodeGeneratorRequest::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.file_to_generate_){arena}
, decltype(_impl_.proto_file_){arena}
- , decltype(_impl_.parameter_){}
+ , decltype(_impl_.parameter_) {}
+
, decltype(_impl_.compiler_version_){nullptr}
};
_impl_.parameter_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.parameter_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.parameter_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
CodeGeneratorRequest::~CodeGeneratorRequest() {
@@ -634,7 +702,7 @@ CodeGeneratorRequest::~CodeGeneratorRequest() {
}
inline void CodeGeneratorRequest::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.file_to_generate_.~RepeatedPtrField();
_impl_.proto_file_.~RepeatedPtrField();
_impl_.parameter_.Destroy();
@@ -647,7 +715,7 @@ void CodeGeneratorRequest::SetCachedSize(int size) const {
void CodeGeneratorRequest::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorRequest)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -659,7 +727,7 @@ void CodeGeneratorRequest::Clear() {
_impl_.parameter_.ClearNonDefaultToEmpty();
}
if (cached_has_bits & 0x00000002u) {
- GOOGLE_DCHECK(_impl_.compiler_version_ != nullptr);
+ Y_ABSL_DCHECK(_impl_.compiler_version_ != nullptr);
_impl_.compiler_version_->Clear();
}
}
@@ -671,12 +739,12 @@ const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::_pbi::ParseC
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated string file_to_generate = 1;
case 1:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
ptr -= 1;
do {
ptr += 1;
@@ -688,32 +756,35 @@ const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::_pbi::ParseC
#endif // !NDEBUG
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string parameter = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) {
auto str = _internal_mutable_parameter();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorRequest.parameter");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional .google.protobuf.compiler.Version compiler_version = 3;
case 3:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 26)) {
ptr = ctx->ParseMessage(_internal_mutable_compiler_version(), ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.FileDescriptorProto proto_file = 15;
case 15:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 122)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 122)) {
ptr -= 1;
do {
ptr += 1;
@@ -721,8 +792,9 @@ const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::_pbi::ParseC
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<122>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -748,31 +820,27 @@ failure:
#undef CHK_
}
-uint8_t* CodeGeneratorRequest::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* CodeGeneratorRequest::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorRequest)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated string file_to_generate = 1;
- for (int i = 0, n = this->_internal_file_to_generate_size(); i < n; i++) {
+ for (int i = 0, n = this->_internal_file_to_generate_size(); i < n; ++i) {
const auto& s = this->_internal_file_to_generate(i);
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- s.data(), static_cast<int>(s.length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.compiler.CodeGeneratorRequest.file_to_generate");
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(s.data(), static_cast<int>(s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.compiler.CodeGeneratorRequest.file_to_generate");
target = stream->WriteString(1, s, target);
}
cached_has_bits = _impl_._has_bits_[0];
// optional string parameter = 2;
if (cached_has_bits & 0x00000001u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_parameter().data(), static_cast<int>(this->_internal_parameter().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.compiler.CodeGeneratorRequest.parameter");
- target = stream->WriteStringMaybeAliased(
- 2, this->_internal_parameter(), target);
+ const TProtoStringType& _s = this->_internal_parameter();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.compiler.CodeGeneratorRequest.parameter");
+ target = stream->WriteStringMaybeAliased(2, _s, target);
}
// optional .google.protobuf.compiler.Version compiler_version = 3;
@@ -798,20 +866,18 @@ uint8_t* CodeGeneratorRequest::_InternalSerialize(
return target;
}
-size_t CodeGeneratorRequest::ByteSizeLong() const {
+::size_t CodeGeneratorRequest::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorRequest)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// repeated string file_to_generate = 1;
- total_size += 1 *
- ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.file_to_generate_.size());
- for (int i = 0, n = _impl_.file_to_generate_.size(); i < n; i++) {
- total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- _impl_.file_to_generate_.Get(i));
+ total_size += 1 * ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.file_to_generate_.size());
+ for (int i = 0, n = _impl_.file_to_generate_.size(); i < n; ++i) {
+ total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(_impl_.file_to_generate_.Get(i));
}
// repeated .google.protobuf.FileDescriptorProto proto_file = 15;
@@ -825,9 +891,8 @@ size_t CodeGeneratorRequest::ByteSizeLong() const {
if (cached_has_bits & 0x00000003u) {
// optional string parameter = 2;
if (cached_has_bits & 0x00000001u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_parameter());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_parameter());
}
// optional .google.protobuf.compiler.Version compiler_version = 3;
@@ -852,8 +917,8 @@ void CodeGeneratorRequest::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, c
auto* const _this = static_cast<CodeGeneratorRequest*>(&to_msg);
auto& from = static_cast<const CodeGeneratorRequest&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorRequest)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.file_to_generate_.MergeFrom(from._impl_.file_to_generate_);
@@ -892,10 +957,8 @@ void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) {
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
_impl_.file_to_generate_.InternalSwap(&other->_impl_.file_to_generate_);
_impl_.proto_file_.InternalSwap(&other->_impl_.proto_file_);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.parameter_, lhs_arena,
- &other->_impl_.parameter_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.parameter_, lhs_arena,
+ &other->_impl_.parameter_, rhs_arena);
swap(_impl_.compiler_version_, other->_impl_.compiler_version_);
}
@@ -904,12 +967,13 @@ void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) {
&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]);
}
-
// ===================================================================
class CodeGeneratorResponse_File::_Internal {
public:
using HasBits = decltype(std::declval<CodeGeneratorResponse_File>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(CodeGeneratorResponse_File, _impl_._has_bits_);
static void set_has_name(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -933,10 +997,9 @@ void CodeGeneratorResponse_File::clear_generated_code_info() {
if (_impl_.generated_code_info_ != nullptr) _impl_.generated_code_info_->Clear();
_impl_._has_bits_[0] &= ~0x00000008u;
}
-CodeGeneratorResponse_File::CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+CodeGeneratorResponse_File::CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.CodeGeneratorResponse.File)
}
CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorResponse_File& from)
@@ -945,66 +1008,67 @@ CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorRespon
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){from._impl_._has_bits_}
, /*decltype(_impl_._cached_size_)*/{}
- , decltype(_impl_.name_){}
- , decltype(_impl_.insertion_point_){}
- , decltype(_impl_.content_){}
+ , decltype(_impl_.name_) {}
+
+ , decltype(_impl_.insertion_point_) {}
+
+ , decltype(_impl_.content_) {}
+
, decltype(_impl_.generated_code_info_){nullptr}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_name()) {
- _this->_impl_.name_.Set(from._internal_name(),
- _this->GetArenaForAllocation());
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
+ _this->_impl_.name_.Set(from._internal_name(), _this->GetArenaForAllocation());
}
_impl_.insertion_point_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.insertion_point_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_insertion_point()) {
- _this->_impl_.insertion_point_.Set(from._internal_insertion_point(),
- _this->GetArenaForAllocation());
+ _impl_.insertion_point_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000002u) != 0) {
+ _this->_impl_.insertion_point_.Set(from._internal_insertion_point(), _this->GetArenaForAllocation());
}
_impl_.content_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.content_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_content()) {
- _this->_impl_.content_.Set(from._internal_content(),
- _this->GetArenaForAllocation());
+ _impl_.content_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000004u) != 0) {
+ _this->_impl_.content_.Set(from._internal_content(), _this->GetArenaForAllocation());
}
- if (from._internal_has_generated_code_info()) {
+ if ((from._impl_._has_bits_[0] & 0x00000008u) != 0) {
_this->_impl_.generated_code_info_ = new ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo(*from._impl_.generated_code_info_);
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse.File)
}
-inline void CodeGeneratorResponse_File::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void CodeGeneratorResponse_File::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
- , decltype(_impl_.name_){}
- , decltype(_impl_.insertion_point_){}
- , decltype(_impl_.content_){}
+ , decltype(_impl_.name_) {}
+
+ , decltype(_impl_.insertion_point_) {}
+
+ , decltype(_impl_.content_) {}
+
, decltype(_impl_.generated_code_info_){nullptr}
};
_impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.name_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.insertion_point_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.insertion_point_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.insertion_point_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.content_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.content_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.content_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
CodeGeneratorResponse_File::~CodeGeneratorResponse_File() {
@@ -1017,7 +1081,7 @@ CodeGeneratorResponse_File::~CodeGeneratorResponse_File() {
}
inline void CodeGeneratorResponse_File::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.name_.Destroy();
_impl_.insertion_point_.Destroy();
_impl_.content_.Destroy();
@@ -1030,7 +1094,7 @@ void CodeGeneratorResponse_File::SetCachedSize(int size) const {
void CodeGeneratorResponse_File::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse.File)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -1046,7 +1110,7 @@ void CodeGeneratorResponse_File::Clear() {
_impl_.content_.ClearNonDefaultToEmpty();
}
if (cached_has_bits & 0x00000008u) {
- GOOGLE_DCHECK(_impl_.generated_code_info_ != nullptr);
+ Y_ABSL_DCHECK(_impl_.generated_code_info_ != nullptr);
_impl_.generated_code_info_->Clear();
}
}
@@ -1058,52 +1122,56 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::_pbi::
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 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)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorResponse.File.name");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string insertion_point = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) {
auto str = _internal_mutable_insertion_point();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional string content = 15;
case 15:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 122)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 122)) {
auto str = _internal_mutable_content();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorResponse.File.content");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional .google.protobuf.GeneratedCodeInfo generated_code_info = 16;
case 16:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 130)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 130)) {
ptr = ctx->ParseMessage(_internal_mutable_generated_code_info(), ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -1129,41 +1197,35 @@ failure:
#undef CHK_
}
-uint8_t* CodeGeneratorResponse_File::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* CodeGeneratorResponse_File::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse.File)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.compiler.CodeGeneratorResponse.File.name");
- target = stream->WriteStringMaybeAliased(
- 1, this->_internal_name(), target);
+ const TProtoStringType& _s = this->_internal_name();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.compiler.CodeGeneratorResponse.File.name");
+ target = stream->WriteStringMaybeAliased(1, _s, target);
}
// optional string insertion_point = 2;
if (cached_has_bits & 0x00000002u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_insertion_point().data(), static_cast<int>(this->_internal_insertion_point().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point");
- target = stream->WriteStringMaybeAliased(
- 2, this->_internal_insertion_point(), target);
+ const TProtoStringType& _s = this->_internal_insertion_point();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point");
+ target = stream->WriteStringMaybeAliased(2, _s, target);
}
// optional string content = 15;
if (cached_has_bits & 0x00000004u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_content().data(), static_cast<int>(this->_internal_content().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.compiler.CodeGeneratorResponse.File.content");
- target = stream->WriteStringMaybeAliased(
- 15, this->_internal_content(), target);
+ const TProtoStringType& _s = this->_internal_content();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.compiler.CodeGeneratorResponse.File.content");
+ target = stream->WriteStringMaybeAliased(15, _s, target);
}
// optional .google.protobuf.GeneratedCodeInfo generated_code_info = 16;
@@ -1181,11 +1243,11 @@ uint8_t* CodeGeneratorResponse_File::_InternalSerialize(
return target;
}
-size_t CodeGeneratorResponse_File::ByteSizeLong() const {
+::size_t CodeGeneratorResponse_File::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse.File)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -1193,23 +1255,20 @@ size_t CodeGeneratorResponse_File::ByteSizeLong() const {
if (cached_has_bits & 0x0000000fu) {
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_name());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_name());
}
// optional string insertion_point = 2;
if (cached_has_bits & 0x00000002u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_insertion_point());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_insertion_point());
}
// optional string content = 15;
if (cached_has_bits & 0x00000004u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_content());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_content());
}
// optional .google.protobuf.GeneratedCodeInfo generated_code_info = 16;
@@ -1234,8 +1293,8 @@ void CodeGeneratorResponse_File::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_
auto* const _this = static_cast<CodeGeneratorResponse_File*>(&to_msg);
auto& from = static_cast<const CodeGeneratorResponse_File&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse.File)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._impl_._has_bits_[0];
@@ -1274,18 +1333,12 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other)
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.name_, lhs_arena,
- &other->_impl_.name_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.insertion_point_, lhs_arena,
- &other->_impl_.insertion_point_, rhs_arena
- );
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.content_, lhs_arena,
- &other->_impl_.content_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, lhs_arena,
+ &other->_impl_.name_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.insertion_point_, lhs_arena,
+ &other->_impl_.insertion_point_, rhs_arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.content_, lhs_arena,
+ &other->_impl_.content_, rhs_arena);
swap(_impl_.generated_code_info_, other->_impl_.generated_code_info_);
}
@@ -1294,12 +1347,13 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other)
&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]);
}
-
// ===================================================================
class CodeGeneratorResponse::_Internal {
public:
using HasBits = decltype(std::declval<CodeGeneratorResponse>()._impl_._has_bits_);
+ static constexpr ::arc_i32 kHasBitsOffset =
+ 8 * PROTOBUF_FIELD_OFFSET(CodeGeneratorResponse, _impl_._has_bits_);
static void set_has_error(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -1308,10 +1362,9 @@ class CodeGeneratorResponse::_Internal {
}
};
-CodeGeneratorResponse::CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor(arena, is_message_owned);
+CodeGeneratorResponse::CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena)
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
+ SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.CodeGeneratorResponse)
}
CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from)
@@ -1321,37 +1374,38 @@ CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from)
decltype(_impl_._has_bits_){from._impl_._has_bits_}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.file_){from._impl_.file_}
- , decltype(_impl_.error_){}
- , decltype(_impl_.supported_features_){}};
+ , decltype(_impl_.error_) {}
+
+ , decltype(_impl_.supported_features_) {}
+ };
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.error_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.error_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (from._internal_has_error()) {
- _this->_impl_.error_.Set(from._internal_error(),
- _this->GetArenaForAllocation());
+ _impl_.error_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
+ _this->_impl_.error_.Set(from._internal_error(), _this->GetArenaForAllocation());
}
_this->_impl_.supported_features_ = from._impl_.supported_features_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse)
}
-inline void CodeGeneratorResponse::SharedCtor(
- ::_pb::Arena* arena, bool is_message_owned) {
+inline void CodeGeneratorResponse::SharedCtor(::_pb::Arena* arena) {
(void)arena;
- (void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.file_){arena}
- , decltype(_impl_.error_){}
- , decltype(_impl_.supported_features_){arc_ui64{0u}}
+ , decltype(_impl_.error_) {}
+
+ , decltype(_impl_.supported_features_) { ::arc_ui64{0u} }
+
};
_impl_.error_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- _impl_.error_.Set("", GetArenaForAllocation());
- #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.error_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
CodeGeneratorResponse::~CodeGeneratorResponse() {
@@ -1364,7 +1418,7 @@ CodeGeneratorResponse::~CodeGeneratorResponse() {
}
inline void CodeGeneratorResponse::SharedDtor() {
- GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
+ Y_ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.file_.~RepeatedPtrField();
_impl_.error_.Destroy();
}
@@ -1375,7 +1429,7 @@ void CodeGeneratorResponse::SetCachedSize(int size) const {
void CodeGeneratorResponse::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -1384,7 +1438,7 @@ void CodeGeneratorResponse::Clear() {
if (cached_has_bits & 0x00000001u) {
_impl_.error_.ClearNonDefaultToEmpty();
}
- _impl_.supported_features_ = arc_ui64{0u};
+ _impl_.supported_features_ = ::arc_ui64{0u};
_impl_._has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
@@ -1393,33 +1447,35 @@ const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::_pbi::Parse
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
- arc_ui32 tag;
+ ::arc_ui32 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)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_error();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
#ifndef NDEBUG
::_pbi::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorResponse.error");
#endif // !NDEBUG
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// optional uint64 supported_features = 2;
case 2:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 16)) {
_Internal::set_has_supported_features(&has_bits);
_impl_.supported_features_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
- } else
+ } else {
goto handle_unusual;
+ }
continue;
// repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15;
case 15:
- if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 122)) {
+ if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 122)) {
ptr -= 1;
do {
ptr += 1;
@@ -1427,8 +1483,9 @@ const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::_pbi::Parse
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<122>(ptr));
- } else
+ } else {
goto handle_unusual;
+ }
continue;
default:
goto handle_unusual;
@@ -1454,27 +1511,26 @@ failure:
#undef CHK_
}
-uint8_t* CodeGeneratorResponse::_InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
+::uint8_t* CodeGeneratorResponse::_InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse)
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
// optional string error = 1;
if (cached_has_bits & 0x00000001u) {
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
- this->_internal_error().data(), static_cast<int>(this->_internal_error().length()),
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.compiler.CodeGeneratorResponse.error");
- target = stream->WriteStringMaybeAliased(
- 1, this->_internal_error(), target);
+ const TProtoStringType& _s = this->_internal_error();
+ ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
+ "google.protobuf.compiler.CodeGeneratorResponse.error");
+ target = stream->WriteStringMaybeAliased(1, _s, target);
}
// optional uint64 supported_features = 2;
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
- target = ::_pbi::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;
@@ -1493,11 +1549,11 @@ uint8_t* CodeGeneratorResponse::_InternalSerialize(
return target;
}
-size_t CodeGeneratorResponse::ByteSizeLong() const {
+::size_t CodeGeneratorResponse::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse)
- size_t total_size = 0;
+ ::size_t total_size = 0;
- arc_ui32 cached_has_bits = 0;
+ ::arc_ui32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -1512,14 +1568,14 @@ size_t CodeGeneratorResponse::ByteSizeLong() const {
if (cached_has_bits & 0x00000003u) {
// optional string error = 1;
if (cached_has_bits & 0x00000001u) {
- total_size += 1 +
- ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
- this->_internal_error());
+ total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
+ this->_internal_error());
}
// optional uint64 supported_features = 2;
if (cached_has_bits & 0x00000002u) {
- total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_supported_features());
+ total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(
+ this->_internal_supported_features());
}
}
@@ -1537,8 +1593,8 @@ void CodeGeneratorResponse::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg,
auto* const _this = static_cast<CodeGeneratorResponse*>(&to_msg);
auto& from = static_cast<const CodeGeneratorResponse&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse)
- GOOGLE_DCHECK_NE(&from, _this);
- arc_ui32 cached_has_bits = 0;
+ Y_ABSL_DCHECK_NE(&from, _this);
+ ::arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.file_.MergeFrom(from._impl_.file_);
@@ -1573,10 +1629,9 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) {
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
_impl_.file_.InternalSwap(&other->_impl_.file_);
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &_impl_.error_, lhs_arena,
- &other->_impl_.error_, rhs_arena
- );
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.error_, lhs_arena,
+ &other->_impl_.error_, rhs_arena);
+
swap(_impl_.supported_features_, other->_impl_.supported_features_);
}
@@ -1585,7 +1640,6 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) {
&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]);
}
-
// @@protoc_insertion_point(namespace_scope)
} // namespace compiler
PROTOBUF_NAMESPACE_CLOSE
@@ -1607,6 +1661,5 @@ Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRespo
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
-
// @@protoc_insertion_point(global_scope)
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
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 ac9253cc58b..fb83d68d30e 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h
@@ -1,46 +1,51 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/compiler/plugin.proto
-#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fcompiler_2fplugin_2eproto
-#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fcompiler_2fplugin_2eproto
+#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fcompiler_2fplugin_2eproto_2epb_2eh
+#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fcompiler_2fplugin_2eproto_2epb_2eh
#include <limits>
#include <string>
-
-#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3021000
-#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 3021003 < 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.
-#endif
-
-#include <google/protobuf/port_undef.inc>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/arena.h>
-#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_util.h>
-#include <google/protobuf/metadata_lite.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h> // IWYU pragma: export
-#include <google/protobuf/extension_set.h> // IWYU pragma: export
-#include <google/protobuf/generated_enum_reflection.h>
-#include <google/protobuf/unknown_field_set.h>
-#include <google/protobuf/descriptor.pb.h>
+#include <type_traits>
+
+#include "google/protobuf/port_def.inc"
+#if PROTOBUF_VERSION < 4022000
+#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 // PROTOBUF_VERSION
+
+#if 4022005 < 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."
+#endif // PROTOBUF_MIN_PROTOC_VERSION
+#include "google/protobuf/port_undef.inc"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/arena.h"
+#include "google/protobuf/arenastring.h"
+#include "google/protobuf/generated_message_util.h"
+#include "google/protobuf/metadata_lite.h"
+#include "google/protobuf/generated_message_reflection.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/repeated_field.h" // IWYU pragma: export
+#include "google/protobuf/extension_set.h" // IWYU pragma: export
+#include "google/protobuf/generated_enum_reflection.h"
+#include "google/protobuf/unknown_field_set.h"
+#include "google/protobuf/descriptor.pb.h"
// @@protoc_insertion_point(includes)
-#include <google/protobuf/port_def.inc>
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
+
#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fcompiler_2fplugin_2eproto PROTOC_EXPORT
#ifdef major
#undef major
-#endif
+#endif // major
#ifdef minor
#undef minor
-#endif
+#endif // minor
+
PROTOBUF_NAMESPACE_OPEN
namespace internal {
class AnyMetadata;
@@ -49,9 +54,10 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOC_EXPORT TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto {
- static const arc_ui32 offsets[];
+ static const ::arc_ui32 offsets[];
};
-PROTOC_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto;
+PROTOC_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable
+ descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto;
PROTOBUF_NAMESPACE_OPEN
namespace compiler {
class CodeGeneratorRequest;
@@ -67,41 +73,52 @@ class Version;
struct VersionDefaultTypeInternal;
PROTOC_EXPORT extern VersionDefaultTypeInternal _Version_default_instance_;
} // namespace compiler
+template <>
+PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest>(Arena*);
+template <>
+PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse>(Arena*);
+template <>
+PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File>(Arena*);
+template <>
+PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::Version* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::Version>(Arena*);
PROTOBUF_NAMESPACE_CLOSE
-PROTOBUF_NAMESPACE_OPEN
-template<> PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest>(Arena*);
-template<> PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse>(Arena*);
-template<> PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File>(Arena*);
-template<> PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::Version* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::Version>(Arena*);
-PROTOBUF_NAMESPACE_CLOSE
+
PROTOBUF_NAMESPACE_OPEN
namespace compiler {
-
enum CodeGeneratorResponse_Feature : int {
CodeGeneratorResponse_Feature_FEATURE_NONE = 0,
- CodeGeneratorResponse_Feature_FEATURE_PROTO3_OPTIONAL = 1
+ CodeGeneratorResponse_Feature_FEATURE_PROTO3_OPTIONAL = 1,
};
+
PROTOC_EXPORT bool CodeGeneratorResponse_Feature_IsValid(int value);
-constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse_Feature_Feature_MIN = CodeGeneratorResponse_Feature_FEATURE_NONE;
-constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse_Feature_Feature_MAX = CodeGeneratorResponse_Feature_FEATURE_PROTO3_OPTIONAL;
-constexpr int CodeGeneratorResponse_Feature_Feature_ARRAYSIZE = CodeGeneratorResponse_Feature_Feature_MAX + 1;
-
-PROTOC_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* CodeGeneratorResponse_Feature_descriptor();
-template<typename T>
-inline const TProtoStringType& CodeGeneratorResponse_Feature_Name(T enum_t_value) {
- static_assert(::std::is_same<T, CodeGeneratorResponse_Feature>::value ||
- ::std::is_integral<T>::value,
- "Incorrect type passed to function CodeGeneratorResponse_Feature_Name.");
- return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum(
- CodeGeneratorResponse_Feature_descriptor(), enum_t_value);
-}
-inline bool CodeGeneratorResponse_Feature_Parse(
- ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, CodeGeneratorResponse_Feature* value) {
+constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse_Feature_Feature_MIN = static_cast<CodeGeneratorResponse_Feature>(0);
+constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse_Feature_Feature_MAX = static_cast<CodeGeneratorResponse_Feature>(1);
+constexpr int CodeGeneratorResponse_Feature_Feature_ARRAYSIZE = 1 + 1;
+PROTOC_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
+CodeGeneratorResponse_Feature_descriptor();
+template <typename T>
+const TProtoStringType& CodeGeneratorResponse_Feature_Name(T value) {
+ static_assert(std::is_same<T, CodeGeneratorResponse_Feature>::value ||
+ std::is_integral<T>::value,
+ "Incorrect type passed to Feature_Name().");
+ return CodeGeneratorResponse_Feature_Name(static_cast<CodeGeneratorResponse_Feature>(value));
+}
+template <>
+inline const TProtoStringType& CodeGeneratorResponse_Feature_Name(CodeGeneratorResponse_Feature value) {
+ return ::PROTOBUF_NAMESPACE_ID::internal::NameOfDenseEnum<CodeGeneratorResponse_Feature_descriptor,
+ 0, 1>(
+ static_cast<int>(value));
+}
+inline bool CodeGeneratorResponse_Feature_Parse(y_absl::string_view name, CodeGeneratorResponse_Feature* value) {
return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum<CodeGeneratorResponse_Feature>(
- CodeGeneratorResponse_Feature_descriptor(), name, value);
+ CodeGeneratorResponse_Feature_descriptor(), name, value);
}
+
// ===================================================================
+
+// -------------------------------------------------------------------
+
class PROTOC_EXPORT Version final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.Version) */ {
public:
@@ -177,7 +194,7 @@ class PROTOC_EXPORT Version final :
}
void UnsafeArenaSwap(Version* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -198,26 +215,25 @@ class PROTOC_EXPORT Version final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(Version* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.compiler.Version";
}
protected:
- explicit Version(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit Version(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -237,61 +253,58 @@ class PROTOC_EXPORT Version final :
};
// optional string suffix = 4;
bool has_suffix() const;
- private:
- bool _internal_has_suffix() const;
- public:
- void clear_suffix();
+ void clear_suffix() ;
const TProtoStringType& suffix() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_suffix(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_suffix(Arg_&& arg, Args_... args);
TProtoStringType* mutable_suffix();
PROTOBUF_NODISCARD TProtoStringType* release_suffix();
- void set_allocated_suffix(TProtoStringType* suffix);
+ void set_allocated_suffix(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_suffix() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_suffix(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_suffix(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_suffix();
- public:
+ public:
// optional int32 major = 1;
bool has_major() const;
+ void clear_major() ;
+ ::arc_i32 major() const;
+ void set_major(::arc_i32 value);
+
private:
- bool _internal_has_major() const;
- public:
- void clear_major();
- arc_i32 major() const;
- void set_major(arc_i32 value);
- private:
- arc_i32 _internal_major() const;
- void _internal_set_major(arc_i32 value);
- public:
+ ::arc_i32 _internal_major() const;
+ void _internal_set_major(::arc_i32 value);
+ public:
// optional int32 minor = 2;
bool has_minor() const;
+ void clear_minor() ;
+ ::arc_i32 minor() const;
+ void set_minor(::arc_i32 value);
+
private:
- bool _internal_has_minor() const;
- public:
- void clear_minor();
- arc_i32 minor() const;
- void set_minor(arc_i32 value);
- private:
- arc_i32 _internal_minor() const;
- void _internal_set_minor(arc_i32 value);
- public:
+ ::arc_i32 _internal_minor() const;
+ void _internal_set_minor(::arc_i32 value);
+ public:
// optional int32 patch = 3;
bool has_patch() const;
+ void clear_patch() ;
+ ::arc_i32 patch() const;
+ void set_patch(::arc_i32 value);
+
private:
- bool _internal_has_patch() const;
- public:
- void clear_patch();
- arc_i32 patch() const;
- void set_patch(arc_i32 value);
- private:
- arc_i32 _internal_patch() const;
- void _internal_set_patch(arc_i32 value);
- public:
+ ::arc_i32 _internal_patch() const;
+ void _internal_set_patch(::arc_i32 value);
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.compiler.Version)
private:
class _Internal;
@@ -303,14 +316,13 @@ class PROTOC_EXPORT Version final :
::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr suffix_;
- arc_i32 major_;
- arc_i32 minor_;
- arc_i32 patch_;
+ ::arc_i32 major_;
+ ::arc_i32 minor_;
+ ::arc_i32 patch_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOC_EXPORT CodeGeneratorRequest final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorRequest) */ {
@@ -387,7 +399,7 @@ class PROTOC_EXPORT CodeGeneratorRequest final :
}
void UnsafeArenaSwap(CodeGeneratorRequest* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -408,26 +420,25 @@ class PROTOC_EXPORT CodeGeneratorRequest final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(CodeGeneratorRequest* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.compiler.CodeGeneratorRequest";
}
protected:
- explicit CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -449,32 +460,37 @@ class PROTOC_EXPORT CodeGeneratorRequest final :
int file_to_generate_size() const;
private:
int _internal_file_to_generate_size() const;
+
public:
- void clear_file_to_generate();
+ void clear_file_to_generate() ;
const TProtoStringType& file_to_generate(int index) const;
TProtoStringType* mutable_file_to_generate(int index);
void set_file_to_generate(int index, const TProtoStringType& value);
void set_file_to_generate(int index, TProtoStringType&& value);
void set_file_to_generate(int index, const char* value);
- void set_file_to_generate(int index, const char* value, size_t size);
+ void set_file_to_generate(int index, const char* value, std::size_t size);
+ void set_file_to_generate(int index, y_absl::string_view value);
TProtoStringType* add_file_to_generate();
void add_file_to_generate(const TProtoStringType& value);
void add_file_to_generate(TProtoStringType&& value);
void add_file_to_generate(const char* value);
- void add_file_to_generate(const char* value, size_t size);
+ void add_file_to_generate(const char* value, std::size_t size);
+ void add_file_to_generate(y_absl::string_view value);
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>& file_to_generate() const;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>* mutable_file_to_generate();
+
private:
const TProtoStringType& _internal_file_to_generate(int index) const;
TProtoStringType* _internal_add_file_to_generate();
- public:
+ public:
// repeated .google.protobuf.FileDescriptorProto proto_file = 15;
int proto_file_size() const;
private:
int _internal_proto_file_size() const;
+
public:
- void clear_proto_file();
+ void clear_proto_file() ;
::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* mutable_proto_file(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto >*
mutable_proto_file();
@@ -486,31 +502,30 @@ class PROTOC_EXPORT CodeGeneratorRequest final :
::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* add_proto_file();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto >&
proto_file() const;
-
// optional string parameter = 2;
bool has_parameter() const;
- private:
- bool _internal_has_parameter() const;
- public:
- void clear_parameter();
+ void clear_parameter() ;
const TProtoStringType& parameter() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_parameter(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_parameter(Arg_&& arg, Args_... args);
TProtoStringType* mutable_parameter();
PROTOBUF_NODISCARD TProtoStringType* release_parameter();
- void set_allocated_parameter(TProtoStringType* parameter);
+ void set_allocated_parameter(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_parameter() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_parameter(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_parameter(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_parameter();
- public:
+ public:
// optional .google.protobuf.compiler.Version compiler_version = 3;
bool has_compiler_version() const;
- private:
- bool _internal_has_compiler_version() const;
- public:
- void clear_compiler_version();
+ void clear_compiler_version() ;
const ::PROTOBUF_NAMESPACE_ID::compiler::Version& compiler_version() const;
PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::compiler::Version* release_compiler_version();
::PROTOBUF_NAMESPACE_ID::compiler::Version* mutable_compiler_version();
@@ -522,7 +537,6 @@ class PROTOC_EXPORT CodeGeneratorRequest final :
void unsafe_arena_set_allocated_compiler_version(
::PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version);
::PROTOBUF_NAMESPACE_ID::compiler::Version* unsafe_arena_release_compiler_version();
-
// @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorRequest)
private:
class _Internal;
@@ -540,8 +554,7 @@ class PROTOC_EXPORT CodeGeneratorRequest final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOC_EXPORT CodeGeneratorResponse_File final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse.File) */ {
@@ -618,7 +631,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final :
}
void UnsafeArenaSwap(CodeGeneratorResponse_File* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -639,26 +652,25 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(CodeGeneratorResponse_File* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.compiler.CodeGeneratorResponse.File";
}
protected:
- explicit CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -678,64 +690,70 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final :
};
// optional string name = 1;
bool has_name() const;
- private:
- bool _internal_has_name() const;
- public:
- void clear_name();
+ void clear_name() ;
const TProtoStringType& name() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_name(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_name(Arg_&& arg, Args_... args);
TProtoStringType* mutable_name();
PROTOBUF_NODISCARD TProtoStringType* release_name();
- void set_allocated_name(TProtoStringType* name);
+ void set_allocated_name(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_name() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_name();
- public:
+ public:
// optional string insertion_point = 2;
bool has_insertion_point() const;
- private:
- bool _internal_has_insertion_point() const;
- public:
- void clear_insertion_point();
+ void clear_insertion_point() ;
const TProtoStringType& insertion_point() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_insertion_point(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_insertion_point(Arg_&& arg, Args_... args);
TProtoStringType* mutable_insertion_point();
PROTOBUF_NODISCARD TProtoStringType* release_insertion_point();
- void set_allocated_insertion_point(TProtoStringType* insertion_point);
+ void set_allocated_insertion_point(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_insertion_point() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_insertion_point(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_insertion_point(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_insertion_point();
- public:
+ public:
// optional string content = 15;
bool has_content() const;
- private:
- bool _internal_has_content() const;
- public:
- void clear_content();
+ void clear_content() ;
const TProtoStringType& content() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_content(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_content(Arg_&& arg, Args_... args);
TProtoStringType* mutable_content();
PROTOBUF_NODISCARD TProtoStringType* release_content();
- void set_allocated_content(TProtoStringType* content);
+ void set_allocated_content(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_content() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_content(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_content(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_content();
- public:
+ public:
// optional .google.protobuf.GeneratedCodeInfo generated_code_info = 16;
bool has_generated_code_info() const;
- private:
- bool _internal_has_generated_code_info() const;
- public:
- void clear_generated_code_info();
+ void clear_generated_code_info() ;
const ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo& generated_code_info() const;
PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* release_generated_code_info();
::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* mutable_generated_code_info();
@@ -747,7 +765,6 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final :
void unsafe_arena_set_allocated_generated_code_info(
::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info);
::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* unsafe_arena_release_generated_code_info();
-
// @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse.File)
private:
class _Internal;
@@ -765,8 +782,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final :
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto;
-};
-// -------------------------------------------------------------------
+};// -------------------------------------------------------------------
class PROTOC_EXPORT CodeGeneratorResponse final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse) */ {
@@ -843,7 +859,7 @@ class PROTOC_EXPORT CodeGeneratorResponse final :
}
void UnsafeArenaSwap(CodeGeneratorResponse* other) {
if (other == this) return;
- GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+ Y_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
@@ -864,26 +880,25 @@ class PROTOC_EXPORT CodeGeneratorResponse final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
- size_t ByteSizeLong() const final;
+ ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
- uint8_t* _InternalSerialize(
- uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+ ::uint8_t* _InternalSerialize(
+ ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(CodeGeneratorResponse* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
- static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+ static ::y_absl::string_view FullMessageName() {
return "google.protobuf.compiler.CodeGeneratorResponse";
}
protected:
- explicit CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena,
- bool is_message_owned = false);
+ explicit CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
@@ -895,33 +910,23 @@ class PROTOC_EXPORT CodeGeneratorResponse final :
typedef CodeGeneratorResponse_File File;
- typedef CodeGeneratorResponse_Feature Feature;
- static constexpr Feature FEATURE_NONE =
- CodeGeneratorResponse_Feature_FEATURE_NONE;
- static constexpr Feature FEATURE_PROTO3_OPTIONAL =
- CodeGeneratorResponse_Feature_FEATURE_PROTO3_OPTIONAL;
+ using Feature = CodeGeneratorResponse_Feature;
+ static constexpr Feature FEATURE_NONE = CodeGeneratorResponse_Feature_FEATURE_NONE;
+ static constexpr Feature FEATURE_PROTO3_OPTIONAL = CodeGeneratorResponse_Feature_FEATURE_PROTO3_OPTIONAL;
static inline bool Feature_IsValid(int value) {
return CodeGeneratorResponse_Feature_IsValid(value);
}
- static constexpr Feature Feature_MIN =
- CodeGeneratorResponse_Feature_Feature_MIN;
- static constexpr Feature Feature_MAX =
- CodeGeneratorResponse_Feature_Feature_MAX;
- static constexpr int Feature_ARRAYSIZE =
- CodeGeneratorResponse_Feature_Feature_ARRAYSIZE;
- static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
- Feature_descriptor() {
+ static constexpr Feature Feature_MIN = CodeGeneratorResponse_Feature_Feature_MIN;
+ static constexpr Feature Feature_MAX = CodeGeneratorResponse_Feature_Feature_MAX;
+ static constexpr int Feature_ARRAYSIZE = CodeGeneratorResponse_Feature_Feature_ARRAYSIZE;
+ static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Feature_descriptor() {
return CodeGeneratorResponse_Feature_descriptor();
}
- template<typename T>
- static inline const TProtoStringType& Feature_Name(T enum_t_value) {
- static_assert(::std::is_same<T, Feature>::value ||
- ::std::is_integral<T>::value,
- "Incorrect type passed to function Feature_Name.");
- return CodeGeneratorResponse_Feature_Name(enum_t_value);
+ template <typename T>
+ static inline const TProtoStringType& Feature_Name(T value) {
+ return CodeGeneratorResponse_Feature_Name(value);
}
- static inline bool Feature_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name,
- Feature* value) {
+ static inline bool Feature_Parse(y_absl::string_view name, Feature* value) {
return CodeGeneratorResponse_Feature_Parse(name, value);
}
@@ -936,8 +941,9 @@ class PROTOC_EXPORT CodeGeneratorResponse final :
int file_size() const;
private:
int _internal_file_size() const;
+
public:
- void clear_file();
+ void clear_file() ;
::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* mutable_file(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >*
mutable_file();
@@ -949,38 +955,38 @@ class PROTOC_EXPORT CodeGeneratorResponse final :
::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* add_file();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >&
file() const;
-
// optional string error = 1;
bool has_error() const;
- private:
- bool _internal_has_error() const;
- public:
- void clear_error();
+ void clear_error() ;
const TProtoStringType& error() const;
- template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
- void set_error(ArgT0&& arg0, ArgT... args);
+
+
+
+
+ template <typename Arg_ = const TProtoStringType&, typename... Args_>
+ void set_error(Arg_&& arg, Args_... args);
TProtoStringType* mutable_error();
PROTOBUF_NODISCARD TProtoStringType* release_error();
- void set_allocated_error(TProtoStringType* error);
+ void set_allocated_error(TProtoStringType* ptr);
+
private:
const TProtoStringType& _internal_error() const;
- inline PROTOBUF_ALWAYS_INLINE void _internal_set_error(const TProtoStringType& value);
+ inline PROTOBUF_ALWAYS_INLINE void _internal_set_error(
+ const TProtoStringType& value);
TProtoStringType* _internal_mutable_error();
- public:
+ public:
// optional uint64 supported_features = 2;
bool has_supported_features() const;
+ void clear_supported_features() ;
+ ::arc_ui64 supported_features() const;
+ void set_supported_features(::arc_ui64 value);
+
private:
- bool _internal_has_supported_features() const;
- public:
- void clear_supported_features();
- arc_ui64 supported_features() const;
- void set_supported_features(arc_ui64 value);
- private:
- arc_ui64 _internal_supported_features() const;
- void _internal_set_supported_features(arc_ui64 value);
- public:
+ ::arc_ui64 _internal_supported_features() const;
+ void _internal_set_supported_features(::arc_ui64 value);
+ public:
// @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse)
private:
class _Internal;
@@ -993,114 +999,108 @@ class PROTOC_EXPORT CodeGeneratorResponse final :
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File > file_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr error_;
- arc_ui64 supported_features_;
+ ::arc_ui64 supported_features_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto;
};
+
// ===================================================================
+
+
// ===================================================================
+
#ifdef __GNUC__
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
+// -------------------------------------------------------------------
+
// Version
// optional int32 major = 1;
-inline bool Version::_internal_has_major() const {
+inline bool Version::has_major() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
return value;
}
-inline bool Version::has_major() const {
- return _internal_has_major();
-}
inline void Version::clear_major() {
_impl_.major_ = 0;
_impl_._has_bits_[0] &= ~0x00000002u;
}
-inline arc_i32 Version::_internal_major() const {
- return _impl_.major_;
-}
-inline arc_i32 Version::major() const {
+inline ::arc_i32 Version::major() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.major)
return _internal_major();
}
-inline void Version::_internal_set_major(arc_i32 value) {
- _impl_._has_bits_[0] |= 0x00000002u;
- _impl_.major_ = value;
-}
-inline void Version::set_major(arc_i32 value) {
+inline void Version::set_major(::arc_i32 value) {
_internal_set_major(value);
// @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.major)
}
+inline ::arc_i32 Version::_internal_major() const {
+ return _impl_.major_;
+}
+inline void Version::_internal_set_major(::arc_i32 value) {
+ _impl_._has_bits_[0] |= 0x00000002u;
+ _impl_.major_ = value;
+}
// optional int32 minor = 2;
-inline bool Version::_internal_has_minor() const {
+inline bool Version::has_minor() const {
bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0;
return value;
}
-inline bool Version::has_minor() const {
- return _internal_has_minor();
-}
inline void Version::clear_minor() {
_impl_.minor_ = 0;
_impl_._has_bits_[0] &= ~0x00000004u;
}
-inline arc_i32 Version::_internal_minor() const {
- return _impl_.minor_;
-}
-inline arc_i32 Version::minor() const {
+inline ::arc_i32 Version::minor() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.minor)
return _internal_minor();
}
-inline void Version::_internal_set_minor(arc_i32 value) {
- _impl_._has_bits_[0] |= 0x00000004u;
- _impl_.minor_ = value;
-}
-inline void Version::set_minor(arc_i32 value) {
+inline void Version::set_minor(::arc_i32 value) {
_internal_set_minor(value);
// @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.minor)
}
+inline ::arc_i32 Version::_internal_minor() const {
+ return _impl_.minor_;
+}
+inline void Version::_internal_set_minor(::arc_i32 value) {
+ _impl_._has_bits_[0] |= 0x00000004u;
+ _impl_.minor_ = value;
+}
// optional int32 patch = 3;
-inline bool Version::_internal_has_patch() const {
+inline bool Version::has_patch() const {
bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0;
return value;
}
-inline bool Version::has_patch() const {
- return _internal_has_patch();
-}
inline void Version::clear_patch() {
_impl_.patch_ = 0;
_impl_._has_bits_[0] &= ~0x00000008u;
}
-inline arc_i32 Version::_internal_patch() const {
- return _impl_.patch_;
-}
-inline arc_i32 Version::patch() const {
+inline ::arc_i32 Version::patch() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.patch)
return _internal_patch();
}
-inline void Version::_internal_set_patch(arc_i32 value) {
- _impl_._has_bits_[0] |= 0x00000008u;
- _impl_.patch_ = value;
-}
-inline void Version::set_patch(arc_i32 value) {
+inline void Version::set_patch(::arc_i32 value) {
_internal_set_patch(value);
// @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.patch)
}
+inline ::arc_i32 Version::_internal_patch() const {
+ return _impl_.patch_;
+}
+inline void Version::_internal_set_patch(::arc_i32 value) {
+ _impl_._has_bits_[0] |= 0x00000008u;
+ _impl_.patch_ = value;
+}
// optional string suffix = 4;
-inline bool Version::_internal_has_suffix() const {
+inline bool Version::has_suffix() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool Version::has_suffix() const {
- return _internal_has_suffix();
-}
inline void Version::clear_suffix() {
_impl_.suffix_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000001u;
@@ -1109,11 +1109,11 @@ inline const TProtoStringType& Version::suffix() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.suffix)
return _internal_suffix();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void Version::set_suffix(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.suffix_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void Version::set_suffix(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.suffix_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix)
}
inline TProtoStringType* Version::mutable_suffix() {
@@ -1126,38 +1126,38 @@ inline const TProtoStringType& Version::_internal_suffix() const {
}
inline void Version::_internal_set_suffix(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000001u;
+
+
_impl_.suffix_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Version::_internal_mutable_suffix() {
_impl_._has_bits_[0] |= 0x00000001u;
- return _impl_.suffix_.Mutable(GetArenaForAllocation());
+ return _impl_.suffix_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* Version::release_suffix() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.Version.suffix)
- if (!_internal_has_suffix()) {
+ if ((_impl_._has_bits_[0] & 0x00000001u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000001u;
- auto* p = _impl_.suffix_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.suffix_.IsDefault()) {
- _impl_.suffix_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void Version::set_allocated_suffix(TProtoStringType* suffix) {
- if (suffix != nullptr) {
+ auto* released = _impl_.suffix_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.suffix_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void Version::set_allocated_suffix(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000001u;
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
- _impl_.suffix_.SetAllocated(suffix, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.suffix_.IsDefault()) {
- _impl_.suffix_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.suffix_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.suffix_.IsDefault()) {
+ _impl_.suffix_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.Version.suffix)
}
@@ -1200,18 +1200,20 @@ inline void CodeGeneratorRequest::set_file_to_generate(int index, TProtoStringTy
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
}
inline void CodeGeneratorRequest::set_file_to_generate(int index, const char* value) {
- GOOGLE_DCHECK(value != nullptr);
+ Y_ABSL_DCHECK(value != nullptr);
_impl_.file_to_generate_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
}
-inline void CodeGeneratorRequest::set_file_to_generate(int index, const char* value, size_t size) {
- _impl_.file_to_generate_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
+inline void CodeGeneratorRequest::set_file_to_generate(int index, const char* value,
+ std::size_t size) {
+ _impl_.file_to_generate_.Mutable(index)->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
}
-inline TProtoStringType* CodeGeneratorRequest::_internal_add_file_to_generate() {
- return _impl_.file_to_generate_.Add();
+inline void CodeGeneratorRequest::set_file_to_generate(int index, y_absl::string_view value) {
+ _impl_.file_to_generate_.Mutable(index)->assign(value.data(), value.size());
+ // @@protoc_insertion_point(field_set_string_piece:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
}
+inline TProtoStringType* CodeGeneratorRequest::_internal_add_file_to_generate() { return _impl_.file_to_generate_.Add(); }
inline void CodeGeneratorRequest::add_file_to_generate(const TProtoStringType& value) {
_impl_.file_to_generate_.Add()->assign(value);
// @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
@@ -1221,33 +1223,33 @@ inline void CodeGeneratorRequest::add_file_to_generate(TProtoStringType&& value)
// @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
}
inline void CodeGeneratorRequest::add_file_to_generate(const char* value) {
- GOOGLE_DCHECK(value != nullptr);
+ Y_ABSL_DCHECK(value != nullptr);
_impl_.file_to_generate_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
}
-inline void CodeGeneratorRequest::add_file_to_generate(const char* value, size_t size) {
+inline void CodeGeneratorRequest::add_file_to_generate(const char* value, std::size_t size) {
_impl_.file_to_generate_.Add()->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_add_pointer:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
}
+inline void CodeGeneratorRequest::add_file_to_generate(y_absl::string_view value) {
+ _impl_.file_to_generate_.Add()->assign(value.data(), value.size());
+ // @@protoc_insertion_point(field_add_string_piece:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
+}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>&
CodeGeneratorRequest::file_to_generate() const {
// @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
return _impl_.file_to_generate_;
}
-inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>*
-CodeGeneratorRequest::mutable_file_to_generate() {
+inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>* CodeGeneratorRequest::mutable_file_to_generate() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
return &_impl_.file_to_generate_;
}
// optional string parameter = 2;
-inline bool CodeGeneratorRequest::_internal_has_parameter() const {
+inline bool CodeGeneratorRequest::has_parameter() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool CodeGeneratorRequest::has_parameter() const {
- return _internal_has_parameter();
-}
inline void CodeGeneratorRequest::clear_parameter() {
_impl_.parameter_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000001u;
@@ -1256,11 +1258,11 @@ inline const TProtoStringType& CodeGeneratorRequest::parameter() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.parameter)
return _internal_parameter();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void CodeGeneratorRequest::set_parameter(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.parameter_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void CodeGeneratorRequest::set_parameter(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.parameter_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter)
}
inline TProtoStringType* CodeGeneratorRequest::mutable_parameter() {
@@ -1273,38 +1275,38 @@ inline const TProtoStringType& CodeGeneratorRequest::_internal_parameter() const
}
inline void CodeGeneratorRequest::_internal_set_parameter(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000001u;
+
+
_impl_.parameter_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorRequest::_internal_mutable_parameter() {
_impl_._has_bits_[0] |= 0x00000001u;
- return _impl_.parameter_.Mutable(GetArenaForAllocation());
+ return _impl_.parameter_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorRequest::release_parameter() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.parameter)
- if (!_internal_has_parameter()) {
+ if ((_impl_._has_bits_[0] & 0x00000001u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000001u;
- auto* p = _impl_.parameter_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.parameter_.IsDefault()) {
- _impl_.parameter_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void CodeGeneratorRequest::set_allocated_parameter(TProtoStringType* parameter) {
- if (parameter != nullptr) {
+ auto* released = _impl_.parameter_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.parameter_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void CodeGeneratorRequest::set_allocated_parameter(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000001u;
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
- _impl_.parameter_.SetAllocated(parameter, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.parameter_.IsDefault()) {
- _impl_.parameter_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.parameter_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.parameter_.IsDefault()) {
+ _impl_.parameter_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.parameter)
}
@@ -1346,14 +1348,11 @@ CodeGeneratorRequest::proto_file() const {
}
// optional .google.protobuf.compiler.Version compiler_version = 3;
-inline bool CodeGeneratorRequest::_internal_has_compiler_version() const {
+inline bool CodeGeneratorRequest::has_compiler_version() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
PROTOBUF_ASSUME(!value || _impl_.compiler_version_ != nullptr);
return value;
}
-inline bool CodeGeneratorRequest::has_compiler_version() const {
- return _internal_has_compiler_version();
-}
inline void CodeGeneratorRequest::clear_compiler_version() {
if (_impl_.compiler_version_ != nullptr) _impl_.compiler_version_->Clear();
_impl_._has_bits_[0] &= ~0x00000002u;
@@ -1440,13 +1439,10 @@ inline void CodeGeneratorRequest::set_allocated_compiler_version(::PROTOBUF_NAME
// CodeGeneratorResponse_File
// optional string name = 1;
-inline bool CodeGeneratorResponse_File::_internal_has_name() const {
+inline bool CodeGeneratorResponse_File::has_name() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool CodeGeneratorResponse_File::has_name() const {
- return _internal_has_name();
-}
inline void CodeGeneratorResponse_File::clear_name() {
_impl_.name_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000001u;
@@ -1455,11 +1451,11 @@ inline const TProtoStringType& CodeGeneratorResponse_File::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.name)
return _internal_name();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void CodeGeneratorResponse_File::set_name(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void CodeGeneratorResponse_File::set_name(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.name_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name)
}
inline TProtoStringType* CodeGeneratorResponse_File::mutable_name() {
@@ -1472,49 +1468,46 @@ inline const TProtoStringType& CodeGeneratorResponse_File::_internal_name() cons
}
inline void CodeGeneratorResponse_File::_internal_set_name(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000001u;
+
+
_impl_.name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorResponse_File::_internal_mutable_name() {
_impl_._has_bits_[0] |= 0x00000001u;
- return _impl_.name_.Mutable(GetArenaForAllocation());
+ return _impl_.name_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorResponse_File::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.name)
- if (!_internal_has_name()) {
+ if ((_impl_._has_bits_[0] & 0x00000001u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000001u;
- auto* p = _impl_.name_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void CodeGeneratorResponse_File::set_allocated_name(TProtoStringType* name) {
- if (name != nullptr) {
+ auto* released = _impl_.name_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void CodeGeneratorResponse_File::set_allocated_name(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000001u;
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
- _impl_.name_.SetAllocated(name, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.name_.IsDefault()) {
- _impl_.name_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.name_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.name_.IsDefault()) {
+ _impl_.name_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name)
}
// optional string insertion_point = 2;
-inline bool CodeGeneratorResponse_File::_internal_has_insertion_point() const {
+inline bool CodeGeneratorResponse_File::has_insertion_point() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
return value;
}
-inline bool CodeGeneratorResponse_File::has_insertion_point() const {
- return _internal_has_insertion_point();
-}
inline void CodeGeneratorResponse_File::clear_insertion_point() {
_impl_.insertion_point_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000002u;
@@ -1523,11 +1516,11 @@ inline const TProtoStringType& CodeGeneratorResponse_File::insertion_point() con
// @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
return _internal_insertion_point();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void CodeGeneratorResponse_File::set_insertion_point(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000002u;
- _impl_.insertion_point_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void CodeGeneratorResponse_File::set_insertion_point(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000002u;
+ _impl_.insertion_point_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
}
inline TProtoStringType* CodeGeneratorResponse_File::mutable_insertion_point() {
@@ -1540,49 +1533,46 @@ inline const TProtoStringType& CodeGeneratorResponse_File::_internal_insertion_p
}
inline void CodeGeneratorResponse_File::_internal_set_insertion_point(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000002u;
+
+
_impl_.insertion_point_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorResponse_File::_internal_mutable_insertion_point() {
_impl_._has_bits_[0] |= 0x00000002u;
- return _impl_.insertion_point_.Mutable(GetArenaForAllocation());
+ return _impl_.insertion_point_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorResponse_File::release_insertion_point() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
- if (!_internal_has_insertion_point()) {
+ if ((_impl_._has_bits_[0] & 0x00000002u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000002u;
- auto* p = _impl_.insertion_point_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.insertion_point_.IsDefault()) {
- _impl_.insertion_point_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void CodeGeneratorResponse_File::set_allocated_insertion_point(TProtoStringType* insertion_point) {
- if (insertion_point != nullptr) {
+ auto* released = _impl_.insertion_point_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.insertion_point_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void CodeGeneratorResponse_File::set_allocated_insertion_point(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000002u;
} else {
_impl_._has_bits_[0] &= ~0x00000002u;
}
- _impl_.insertion_point_.SetAllocated(insertion_point, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.insertion_point_.IsDefault()) {
- _impl_.insertion_point_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.insertion_point_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.insertion_point_.IsDefault()) {
+ _impl_.insertion_point_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
}
// optional string content = 15;
-inline bool CodeGeneratorResponse_File::_internal_has_content() const {
+inline bool CodeGeneratorResponse_File::has_content() const {
bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0;
return value;
}
-inline bool CodeGeneratorResponse_File::has_content() const {
- return _internal_has_content();
-}
inline void CodeGeneratorResponse_File::clear_content() {
_impl_.content_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000004u;
@@ -1591,11 +1581,11 @@ inline const TProtoStringType& CodeGeneratorResponse_File::content() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.content)
return _internal_content();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void CodeGeneratorResponse_File::set_content(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000004u;
- _impl_.content_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void CodeGeneratorResponse_File::set_content(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000004u;
+ _impl_.content_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content)
}
inline TProtoStringType* CodeGeneratorResponse_File::mutable_content() {
@@ -1608,50 +1598,47 @@ inline const TProtoStringType& CodeGeneratorResponse_File::_internal_content() c
}
inline void CodeGeneratorResponse_File::_internal_set_content(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000004u;
+
+
_impl_.content_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorResponse_File::_internal_mutable_content() {
_impl_._has_bits_[0] |= 0x00000004u;
- return _impl_.content_.Mutable(GetArenaForAllocation());
+ return _impl_.content_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorResponse_File::release_content() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.content)
- if (!_internal_has_content()) {
+ if ((_impl_._has_bits_[0] & 0x00000004u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000004u;
- auto* p = _impl_.content_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.content_.IsDefault()) {
- _impl_.content_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void CodeGeneratorResponse_File::set_allocated_content(TProtoStringType* content) {
- if (content != nullptr) {
+ auto* released = _impl_.content_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.content_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void CodeGeneratorResponse_File::set_allocated_content(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000004u;
} else {
_impl_._has_bits_[0] &= ~0x00000004u;
}
- _impl_.content_.SetAllocated(content, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.content_.IsDefault()) {
- _impl_.content_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.content_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.content_.IsDefault()) {
+ _impl_.content_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content)
}
// optional .google.protobuf.GeneratedCodeInfo generated_code_info = 16;
-inline bool CodeGeneratorResponse_File::_internal_has_generated_code_info() const {
+inline bool CodeGeneratorResponse_File::has_generated_code_info() const {
bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0;
PROTOBUF_ASSUME(!value || _impl_.generated_code_info_ != nullptr);
return value;
}
-inline bool CodeGeneratorResponse_File::has_generated_code_info() const {
- return _internal_has_generated_code_info();
-}
inline const ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo& CodeGeneratorResponse_File::_internal_generated_code_info() const {
const ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* p = _impl_.generated_code_info_;
return p != nullptr ? *p : reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo&>(
@@ -1735,13 +1722,10 @@ inline void CodeGeneratorResponse_File::set_allocated_generated_code_info(::PROT
// CodeGeneratorResponse
// optional string error = 1;
-inline bool CodeGeneratorResponse::_internal_has_error() const {
+inline bool CodeGeneratorResponse::has_error() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool CodeGeneratorResponse::has_error() const {
- return _internal_has_error();
-}
inline void CodeGeneratorResponse::clear_error() {
_impl_.error_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000001u;
@@ -1750,11 +1734,11 @@ inline const TProtoStringType& CodeGeneratorResponse::error() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.error)
return _internal_error();
}
-template <typename ArgT0, typename... ArgT>
-inline PROTOBUF_ALWAYS_INLINE
-void CodeGeneratorResponse::set_error(ArgT0&& arg0, ArgT... args) {
- _impl_._has_bits_[0] |= 0x00000001u;
- _impl_.error_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+template <typename Arg_, typename... Args_>
+inline PROTOBUF_ALWAYS_INLINE void CodeGeneratorResponse::set_error(Arg_&& arg,
+ Args_... args) {
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.error_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error)
}
inline TProtoStringType* CodeGeneratorResponse::mutable_error() {
@@ -1767,68 +1751,65 @@ inline const TProtoStringType& CodeGeneratorResponse::_internal_error() const {
}
inline void CodeGeneratorResponse::_internal_set_error(const TProtoStringType& value) {
_impl_._has_bits_[0] |= 0x00000001u;
+
+
_impl_.error_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorResponse::_internal_mutable_error() {
_impl_._has_bits_[0] |= 0x00000001u;
- return _impl_.error_.Mutable(GetArenaForAllocation());
+ return _impl_.error_.Mutable( GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorResponse::release_error() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.error)
- if (!_internal_has_error()) {
+ if ((_impl_._has_bits_[0] & 0x00000001u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000001u;
- auto* p = _impl_.error_.Release();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.error_.IsDefault()) {
- _impl_.error_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
- return p;
-}
-inline void CodeGeneratorResponse::set_allocated_error(TProtoStringType* error) {
- if (error != nullptr) {
+ auto* released = _impl_.error_.Release();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.error_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ return released;
+}
+inline void CodeGeneratorResponse::set_allocated_error(TProtoStringType* value) {
+ if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000001u;
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
- _impl_.error_.SetAllocated(error, GetArenaForAllocation());
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (_impl_.error_.IsDefault()) {
- _impl_.error_.Set("", GetArenaForAllocation());
- }
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.error_.SetAllocated(value, GetArenaForAllocation());
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ if (_impl_.error_.IsDefault()) {
+ _impl_.error_.Set("", GetArenaForAllocation());
+ }
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.error)
}
// optional uint64 supported_features = 2;
-inline bool CodeGeneratorResponse::_internal_has_supported_features() const {
+inline bool CodeGeneratorResponse::has_supported_features() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
return value;
}
-inline bool CodeGeneratorResponse::has_supported_features() const {
- return _internal_has_supported_features();
-}
inline void CodeGeneratorResponse::clear_supported_features() {
- _impl_.supported_features_ = arc_ui64{0u};
+ _impl_.supported_features_ = ::arc_ui64{0u};
_impl_._has_bits_[0] &= ~0x00000002u;
}
-inline arc_ui64 CodeGeneratorResponse::_internal_supported_features() const {
- return _impl_.supported_features_;
-}
-inline arc_ui64 CodeGeneratorResponse::supported_features() const {
+inline ::arc_ui64 CodeGeneratorResponse::supported_features() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.supported_features)
return _internal_supported_features();
}
-inline void CodeGeneratorResponse::_internal_set_supported_features(arc_ui64 value) {
- _impl_._has_bits_[0] |= 0x00000002u;
- _impl_.supported_features_ = value;
-}
-inline void CodeGeneratorResponse::set_supported_features(arc_ui64 value) {
+inline void CodeGeneratorResponse::set_supported_features(::arc_ui64 value) {
_internal_set_supported_features(value);
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.supported_features)
}
+inline ::arc_ui64 CodeGeneratorResponse::_internal_supported_features() const {
+ return _impl_.supported_features_;
+}
+inline void CodeGeneratorResponse::_internal_set_supported_features(::arc_ui64 value) {
+ _impl_._has_bits_[0] |= 0x00000002u;
+ _impl_.supported_features_ = value;
+}
// repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15;
inline int CodeGeneratorResponse::_internal_file_size() const {
@@ -1871,25 +1852,20 @@ CodeGeneratorResponse::file() const {
}
#ifdef __GNUC__
- #pragma GCC diagnostic pop
+#pragma GCC diagnostic pop
#endif // __GNUC__
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
// @@protoc_insertion_point(namespace_scope)
-
} // namespace compiler
PROTOBUF_NAMESPACE_CLOSE
+
PROTOBUF_NAMESPACE_OPEN
-template <> struct is_proto_enum< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_Feature> : ::std::true_type {};
template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_Feature>() {
+struct is_proto_enum<::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_Feature> : std::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor<::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_Feature>() {
return ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_Feature_descriptor();
}
@@ -1897,5 +1873,6 @@ PROTOBUF_NAMESPACE_CLOSE
// @@protoc_insertion_point(global_scope)
-#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fcompiler_2fplugin_2eproto
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fcompiler_2fplugin_2eproto_2epb_2eh
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.proto b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.proto
index 9242aacc5bd..7ab6dffd730 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.proto
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.proto
@@ -30,9 +30,6 @@
// Author: [email protected] (Kenton Varda)
//
-// WARNING: The plugin interface is currently EXPERIMENTAL and is subject to
-// change.
-//
// protoc (aka the Protocol Compiler) can be extended via plugins. A plugin is
// just a program that reads a CodeGeneratorRequest from stdin and writes a
// CodeGeneratorResponse to stdout.
@@ -50,6 +47,7 @@ package google.protobuf.compiler;
option java_package = "com.google.protobuf.compiler";
option java_outer_classname = "PluginProtos";
+option csharp_namespace = "Google.Protobuf.Compiler";
option go_package = "google.golang.org/protobuf/types/pluginpb";
import "google/protobuf/descriptor.proto";
@@ -92,7 +90,6 @@ message CodeGeneratorRequest {
// The version number of protocol compiler.
optional Version compiler_version = 3;
-
}
// The plugin writes an encoded CodeGeneratorResponse to stdout.
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/python/generator.cc
index d1e4de467b9..aaf5e3f8cb8 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/python/generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/generator.cc
@@ -42,27 +42,33 @@
// performance-minded Python code leverage the fast C++ implementation
// directly.
-#include <google/protobuf/compiler/python/generator.h>
+#include "google/protobuf/compiler/python/generator.h"
#include <algorithm>
#include <limits>
-#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/stringprintf.h>
-#include <google/protobuf/stubs/substitute.h>
-#include <google/protobuf/compiler/python/helpers.h>
-#include <google/protobuf/compiler/python/pyi_generator.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/zero_copy_stream.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/escaping.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/str_replace.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/strings/strip.h"
+#include "y_absl/strings/substitute.h"
+#include "google/protobuf/compiler/python/helpers.h"
+#include "google/protobuf/compiler/python/pyi_generator.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/printer.h"
+#include "google/protobuf/io/strtod.h"
+#include "google/protobuf/io/zero_copy_stream.h"
namespace google {
namespace protobuf {
@@ -72,15 +78,15 @@ namespace python {
namespace {
// 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
+// third_party/py/google/protobuf/internal/reflection_test.py
// to see why we need the alias.
-TProtoStringType ModuleAlias(const TProtoStringType& filename) {
+TProtoStringType ModuleAlias(y_absl::string_view filename) {
TProtoStringType module_name = ModuleName(filename);
// We can't have dots in the module name, so we replace each with _dot_.
// But that could lead to a collision between a.b and a_dot_b, so we also
// duplicate each underscore.
- GlobalReplaceSubstring("_", "__", &module_name);
- GlobalReplaceSubstring(".", "_dot_", &module_name);
+ y_absl::StrReplaceAll({{"_", "__"}}, &module_name);
+ y_absl::StrReplaceAll({{".", "_dot_"}}, &module_name);
return module_name;
}
@@ -90,29 +96,7 @@ TProtoStringType ModuleAlias(const TProtoStringType& filename) {
// in proto2/public/reflection.py.
const char kDescriptorKey[] = "DESCRIPTOR";
-
-// file output by this generator.
-void PrintTopBoilerplate(io::Printer* printer, const FileDescriptor* file,
- bool descriptor_proto) {
- // TODO(robinson): Allow parameterization of Python version?
- printer->Print(
- "# -*- coding: utf-8 -*-\n"
- "# Generated by the protocol buffer compiler. DO NOT EDIT!\n"
- "# source: $filename$\n"
- "\"\"\"Generated protocol buffer code.\"\"\"\n",
- "filename", file->name());
- 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 symbol_database as "
- "_symbol_database\n");
-
- printer->Print("# @@protoc_insertion_point(imports)\n\n");
- printer->Print("_sym_db = _symbol_database.Default()\n");
- printer->Print("\n\n");
-}
+const char kThirdPartyPrefix[] = "google3.third_party.py.";
// Returns a Python literal giving the default value for a field.
// If the field specifies no explicit default value, we'll return
@@ -131,13 +115,13 @@ TProtoStringType StringifyDefaultValue(const FieldDescriptor& field) {
switch (field.cpp_type()) {
case FieldDescriptor::CPPTYPE_INT32:
- return StrCat(field.default_value_int32());
+ return y_absl::StrCat(field.default_value_int32());
case FieldDescriptor::CPPTYPE_UINT32:
- return StrCat(field.default_value_uint32());
+ return y_absl::StrCat(field.default_value_uint32());
case FieldDescriptor::CPPTYPE_INT64:
- return StrCat(field.default_value_int64());
+ return y_absl::StrCat(field.default_value_int64());
case FieldDescriptor::CPPTYPE_UINT64:
- return StrCat(field.default_value_uint64());
+ return y_absl::StrCat(field.default_value_uint64());
case FieldDescriptor::CPPTYPE_DOUBLE: {
double value = field.default_value_double();
if (value == std::numeric_limits<double>::infinity()) {
@@ -151,7 +135,7 @@ TProtoStringType StringifyDefaultValue(const FieldDescriptor& field) {
// infinity * 0 = nan
return "(1e10000 * 0)";
} else {
- return "float(" + SimpleDtoa(value) + ")";
+ return y_absl::StrCat("float(", io::SimpleDtoa(value), ")");
}
}
case FieldDescriptor::CPPTYPE_FLOAT: {
@@ -167,24 +151,24 @@ TProtoStringType StringifyDefaultValue(const FieldDescriptor& field) {
// infinity - infinity = nan
return "(1e10000 * 0)";
} else {
- return "float(" + SimpleFtoa(value) + ")";
+ return y_absl::StrCat("float(", io::SimpleFtoa(value), ")");
}
}
case FieldDescriptor::CPPTYPE_BOOL:
return field.default_value_bool() ? "True" : "False";
case FieldDescriptor::CPPTYPE_ENUM:
- return StrCat(field.default_value_enum()->number());
+ return y_absl::StrCat(field.default_value_enum()->number());
case FieldDescriptor::CPPTYPE_STRING:
- return "b\"" + CEscape(field.default_value_string()) +
- (field.type() != FieldDescriptor::TYPE_STRING
- ? "\""
- : "\".decode('utf-8')");
+ return y_absl::StrCat("b\"", y_absl::CEscape(field.default_value_string()),
+ (field.type() != FieldDescriptor::TYPE_STRING
+ ? "\""
+ : "\".decode('utf-8')"));
case FieldDescriptor::CPPTYPE_MESSAGE:
return "None";
}
// (We could add a default case above but then we wouldn't get the nice
// compiler warning when a new type is added.)
- GOOGLE_LOG(FATAL) << "Not reached.";
+ Y_ABSL_LOG(FATAL) << "Not reached.";
return "";
}
@@ -196,8 +180,9 @@ TProtoStringType StringifySyntax(FileDescriptor::Syntax syntax) {
return "proto3";
case FileDescriptor::SYNTAX_UNKNOWN:
default:
- GOOGLE_LOG(FATAL) << "Unsupported syntax; this generator only supports proto2 "
- "and proto3 syntax.";
+ Y_ABSL_LOG(FATAL)
+ << "Unsupported syntax; this generator only supports proto2 "
+ "and proto3 syntax.";
return "";
}
}
@@ -212,26 +197,42 @@ uint64_t Generator::GetSupportedFeatures() const {
return CodeGenerator::Feature::FEATURE_PROTO3_OPTIONAL;
}
+GeneratorOptions Generator::ParseParameter(y_absl::string_view parameter,
+ TProtoStringType* error) const {
+ GeneratorOptions options;
+
+ std::vector<std::pair<TProtoStringType, TProtoStringType> > option_pairs;
+ ParseGeneratorParameter(parameter, &option_pairs);
+
+ for (const std::pair<TProtoStringType, TProtoStringType>& option : option_pairs) {
+ if (!opensource_runtime_ &&
+ option.first == "no_enforce_api_compatibility") {
+ // TODO(b/241584880): remove this legacy option, it has no effect.
+ } else if (!opensource_runtime_ && option.first == "bootstrap") {
+ options.bootstrap = true;
+ } else if (option.first == "pyi_out") {
+ options.generate_pyi = true;
+ } else if (option.first == "annotate_code") {
+ options.annotate_pyi = true;
+ } else {
+ *error = y_absl::StrCat("Unknown generator option: ", option.first);
+ }
+ }
+ return options;
+}
+
bool Generator::Generate(const FileDescriptor* file,
const TProtoStringType& parameter,
GeneratorContext* context, TProtoStringType* error) const {
// -----------------------------------------------------------------
- // parse generator options
- bool cpp_generated_lib_linked = false;
-
- std::vector<std::pair<TProtoStringType, TProtoStringType> > options;
- ParseGeneratorParameter(parameter, &options);
-
- 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;
+ GeneratorOptions options = ParseParameter(parameter, error);
+ if (!error->empty()) return false;
+
+ // Generate pyi typing information
+ if (options.generate_pyi) {
+ python::PyiGenerator pyi_generator;
+ TProtoStringType pyi_options = options.annotate_pyi ? "annotate_code" : "";
+ if (!pyi_generator.Generate(file, pyi_options, context, error)) {
return false;
}
}
@@ -243,78 +244,110 @@ bool Generator::Generate(const FileDescriptor* file,
// TODO(kenton): The proper thing to do would be to allocate any state on
// the stack and use that, so that the Generator class itself does not need
// to have any mutable members. Then it is implicitly thread-safe.
- MutexLock lock(&mutex_);
+ y_absl::MutexLock lock(&mutex_);
file_ = file;
TProtoStringType filename = GetFileName(file, ".py");
- pure_python_workable_ = !cpp_generated_lib_linked;
- if (HasPrefixString(file->name(), "google/protobuf/")) {
- pure_python_workable_ = true;
- }
FileDescriptorProto fdp;
file_->CopyTo(&fdp);
fdp.SerializeToString(&file_descriptor_serialized_);
+ if (!opensource_runtime_ && GeneratingDescriptorProto()) {
+ TProtoStringType bootstrap_filename =
+ "net/proto2/python/internal/descriptor_pb2.py";
+ if (options.bootstrap) {
+ filename = bootstrap_filename;
+ } else {
+ std::unique_ptr<io::ZeroCopyOutputStream> output(context->Open(filename));
+ io::Printer printer(output.get(), '$');
+ printer.Print(
+ "from $internal_package$ import descriptor_pb2\n"
+ "\n",
+ "internal_package", InternalPackage());
+
+ // For static checkers, we need to explicitly assign to the symbols we
+ // publicly export.
+ for (int i = 0; i < file_->message_type_count(); i++) {
+ const Descriptor* message = file_->message_type(i);
+ printer.Print("$name$ = descriptor_pb2.$name$\n", "name",
+ message->name());
+ }
+
+ // Sadly some clients access our internal variables (starting with "_").
+ // To support them, we iterate over *all* symbols to expose even the
+ // private ones. Statically type-checked code should (especially) never
+ // use these, so we don't worry about making them available to pytype
+ // checks.
+ printer.Print(
+ "\n"
+ "globals().update(descriptor_pb2.__dict__)\n"
+ "\n");
+
+ printer.Print(
+ "# @@protoc_insertion_point(module_scope)\n"
+ "\n");
+ return true;
+ }
+ }
std::unique_ptr<io::ZeroCopyOutputStream> output(context->Open(filename));
- GOOGLE_CHECK(output.get());
+ Y_ABSL_CHECK(output.get());
io::Printer printer(output.get(), '$');
printer_ = &printer;
- PrintTopBoilerplate(printer_, file_, GeneratingDescriptorProto());
- if (pure_python_workable_) {
- PrintImports();
- }
+ PrintTopBoilerplate();
+ PrintImports();
PrintFileDescriptor();
- if (pure_python_workable_) {
- if (GeneratingDescriptorProto()) {
- printer_->Print("if _descriptor._USE_C_DESCRIPTORS == False:\n");
- printer_->Indent();
- // Create enums before message descriptors
- PrintAllNestedEnumsInFile();
- PrintMessageDescriptors();
- FixForeignFieldsInDescriptors();
- printer_->Outdent();
- printer_->Print("else:\n");
- printer_->Indent();
- }
- // Find the message descriptors first and then use the message
- // descriptor to find enums.
- printer_->Print(
- "_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())\n");
- if (GeneratingDescriptorProto()) {
- printer_->Outdent();
- }
+ printer_->Print("_globals = globals()\n");
+ if (GeneratingDescriptorProto()) {
+ printer_->Print("if _descriptor._USE_C_DESCRIPTORS == False:\n");
+ printer_->Indent();
+ // Create enums before message descriptors
+ PrintAllNestedEnumsInFile();
+ PrintMessageDescriptors();
+ FixForeignFieldsInDescriptors();
+ printer_->Outdent();
+ printer_->Print("else:\n");
+ printer_->Indent();
+ }
+ // Find the message descriptors first and then use the message
+ // descriptor to find enums.
+ printer_->Print(
+ "_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)\n");
+ if (GeneratingDescriptorProto()) {
+ printer_->Outdent();
}
TProtoStringType module_name = ModuleName(file->name());
+ if (!opensource_runtime_) {
+ module_name =
+ TProtoStringType(y_absl::StripPrefix(module_name, kThirdPartyPrefix));
+ }
printer_->Print(
"_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, '$module_name$', "
- "globals())\n",
+ "_globals)\n",
"module_name", module_name);
- if (pure_python_workable_) {
- printer.Print("if _descriptor._USE_C_DESCRIPTORS == False:\n");
- printer_->Indent();
+ printer.Print("if _descriptor._USE_C_DESCRIPTORS == False:\n");
+ printer_->Indent();
- // We have to fix up the extensions after the message classes themselves,
- // since they need to call static RegisterExtension() methods on these
- // classes.
- FixForeignFieldsInExtensions();
- // Descriptor options may have custom extensions. These custom options
- // can only be successfully parsed after we register corresponding
- // extensions. Therefore we parse all options again here to recognize
- // custom options that may be unknown when we define the descriptors.
- // This does not apply to services because they are not used by extensions.
- FixAllDescriptorOptions();
+ // We have to fix up the extensions after the message classes themselves,
+ // since they need to call static RegisterExtension() methods on these
+ // classes.
+ FixForeignFieldsInExtensions();
+ // Descriptor options may have custom extensions. These custom options
+ // can only be successfully parsed after we register corresponding
+ // extensions. Therefore we parse all options again here to recognize
+ // custom options that may be unknown when we define the descriptors.
+ // This does not apply to services because they are not used by extensions.
+ FixAllDescriptorOptions();
- // Set serialized_start and serialized_end.
- SetSerializedPbInterval();
+ // Set serialized_start and serialized_end.
+ SetSerializedPbInterval();
- printer_->Outdent();
- }
+ printer_->Outdent();
if (HasGenericServices(file)) {
printer_->Print(
- "_builder.BuildServices(DESCRIPTOR, '$module_name$', globals())\n",
+ "_builder.BuildServices(DESCRIPTOR, '$module_name$', _globals)\n",
"module_name", module_name);
}
@@ -323,13 +356,45 @@ bool Generator::Generate(const FileDescriptor* file,
return !printer.failed();
}
+// file output by this generator.
+void Generator::PrintTopBoilerplate() const {
+ // TODO(robinson): Allow parameterization of Python version?
+ printer_->Print(
+ "# -*- coding: utf-8 -*-\n"
+ "# Generated by the protocol buffer compiler. DO NOT EDIT!\n"
+ "# source: $filename$\n"
+ "\"\"\"Generated protocol buffer code.\"\"\"\n",
+ "filename", file_->name());
+ if (!opensource_runtime_) {
+ // This import is needed so that compatibility proto1 compiler output
+ // inserted at protoc_insertion_point can refer to other protos like
+ // google3.a.b.c. Code generated by proto2 compiler doesn't do it, and
+ // instead uses aliases assigned when importing modules.
+ printer_->Print("import google3\n");
+ }
+ printer_->Print(
+ "from $internal_package$ import builder as _builder\n"
+ "from $public_package$ import descriptor as _descriptor\n"
+ "from $public_package$ import descriptor_pool as _descriptor_pool\n"
+ "from $public_package$ import symbol_database as _symbol_database\n",
+ "internal_package", InternalPackage(), "public_package", PublicPackage());
+
+ printer_->Print("# @@protoc_insertion_point(imports)\n\n");
+ printer_->Print("_sym_db = _symbol_database.Default()\n");
+ printer_->Print("\n\n");
+}
+
// Prints Python imports for all modules imported by |file|.
void Generator::PrintImports() const {
for (int i = 0; i < file_->dependency_count(); ++i) {
- const TProtoStringType& filename = file_->dependency(i)->name();
+ y_absl::string_view filename = file_->dependency(i)->name();
TProtoStringType module_name = ModuleName(filename);
TProtoStringType module_alias = ModuleAlias(filename);
+ if (!opensource_runtime_) {
+ module_name =
+ TProtoStringType(y_absl::StripPrefix(module_name, kThirdPartyPrefix));
+ }
if (ContainsPythonKeyword(module_name)) {
// If the module path contains a Python keyword, we have to quote the
// module name and import it using importlib. Otherwise the usual kind of
@@ -339,15 +404,16 @@ void Generator::PrintImports() const {
printer_->Print("$alias$ = importlib.import_module('$name$')\n", "alias",
module_alias, "name", module_name);
} else {
- int last_dot_pos = module_name.rfind('.');
+ size_t last_dot_pos = module_name.rfind('.');
TProtoStringType import_statement;
if (last_dot_pos == TProtoStringType::npos) {
// NOTE(petya): this is not tested as it would require a protocol buffer
// outside of any package, and I don't think that is easily achievable.
- import_statement = "import " + module_name;
+ import_statement = y_absl::StrCat("import ", module_name);
} else {
- import_statement = "from " + module_name.substr(0, last_dot_pos) +
- " import " + module_name.substr(last_dot_pos + 1);
+ import_statement =
+ y_absl::StrCat("from ", module_name.substr(0, last_dot_pos),
+ " import ", module_name.substr(last_dot_pos + 1));
}
printer_->Print("$statement$ as $alias$\n", "statement", import_statement,
"alias", module_alias);
@@ -360,6 +426,10 @@ void Generator::PrintImports() const {
// Print public imports.
for (int i = 0; i < file_->public_dependency_count(); ++i) {
TProtoStringType module_name = ModuleName(file_->public_dependency(i)->name());
+ if (!opensource_runtime_) {
+ module_name =
+ TProtoStringType(y_absl::StripPrefix(module_name, kThirdPartyPrefix));
+ }
printer_->Print("from $module$ import *\n", "module", module_name);
}
printer_->Print("\n");
@@ -367,13 +437,13 @@ void Generator::PrintImports() const {
// Prints the single file descriptor for this file.
void Generator::PrintFileDescriptor() const {
- std::map<TProtoStringType, TProtoStringType> m;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> m;
m["descriptor_name"] = kDescriptorKey;
m["name"] = file_->name();
m["package"] = file_->package();
m["syntax"] = StringifySyntax(file_->syntax());
m["options"] = OptionsValue(file_->options().SerializeAsString());
- m["serialized_descriptor"] = strings::CHexEscape(file_descriptor_serialized_);
+ m["serialized_descriptor"] = y_absl::CHexEscape(file_descriptor_serialized_);
if (GeneratingDescriptorProto()) {
printer_->Print("if _descriptor._USE_C_DESCRIPTORS == False:\n");
printer_->Indent();
@@ -389,30 +459,26 @@ void Generator::PrintFileDescriptor() const {
" create_key=_descriptor._internal_create_key,\n";
printer_->Print(m, file_descriptor_template);
printer_->Indent();
- if (pure_python_workable_) {
- printer_->Print("serialized_pb=b'$value$'\n", "value",
- strings::CHexEscape(file_descriptor_serialized_));
- if (file_->dependency_count() != 0) {
- printer_->Print(",\ndependencies=[");
- for (int i = 0; i < file_->dependency_count(); ++i) {
- TProtoStringType module_alias = ModuleAlias(file_->dependency(i)->name());
- printer_->Print("$module_alias$.DESCRIPTOR,", "module_alias",
- module_alias);
- }
- printer_->Print("]");
+ printer_->Print("serialized_pb=b'$value$'\n", "value",
+ y_absl::CHexEscape(file_descriptor_serialized_));
+ if (file_->dependency_count() != 0) {
+ printer_->Print(",\ndependencies=[");
+ for (int i = 0; i < file_->dependency_count(); ++i) {
+ TProtoStringType module_alias = ModuleAlias(file_->dependency(i)->name());
+ printer_->Print("$module_alias$.DESCRIPTOR,", "module_alias",
+ module_alias);
}
- if (file_->public_dependency_count() > 0) {
- printer_->Print(",\npublic_dependencies=[");
- for (int i = 0; i < file_->public_dependency_count(); ++i) {
- TProtoStringType module_alias =
- ModuleAlias(file_->public_dependency(i)->name());
- printer_->Print("$module_alias$.DESCRIPTOR,", "module_alias",
- module_alias);
- }
- printer_->Print("]");
+ printer_->Print("]");
+ }
+ if (file_->public_dependency_count() > 0) {
+ printer_->Print(",\npublic_dependencies=[");
+ for (int i = 0; i < file_->public_dependency_count(); ++i) {
+ TProtoStringType module_alias =
+ ModuleAlias(file_->public_dependency(i)->name());
+ printer_->Print("$module_alias$.DESCRIPTOR,", "module_alias",
+ module_alias);
}
- } else {
- printer_->Print("serialized_pb=''\n");
+ printer_->Print("]");
}
// TODO(falk): Also print options and fix the message_type, enum_type,
@@ -446,7 +512,7 @@ void Generator::PrintAllNestedEnumsInFile() const {
// enum name to a Python EnumDescriptor object equivalent to
// enum_descriptor.
void Generator::PrintEnum(const EnumDescriptor& enum_descriptor) const {
- std::map<TProtoStringType, TProtoStringType> m;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> m;
TProtoStringType module_level_descriptor_name =
ModuleLevelDescriptorName(enum_descriptor);
m["descriptor_name"] = module_level_descriptor_name;
@@ -467,11 +533,9 @@ void Generator::PrintEnum(const EnumDescriptor& enum_descriptor) const {
printer_->Indent();
printer_->Indent();
- if (pure_python_workable_) {
- for (int i = 0; i < enum_descriptor.value_count(); ++i) {
- PrintEnumValueDescriptor(*enum_descriptor.value(i));
- printer_->Print(",\n");
- }
+ for (int i = 0; i < enum_descriptor.value_count(); ++i) {
+ PrintEnumValueDescriptor(*enum_descriptor.value(i));
+ printer_->Print(",\n");
}
printer_->Outdent();
@@ -482,10 +546,8 @@ void Generator::PrintEnum(const EnumDescriptor& enum_descriptor) const {
EnumDescriptorProto edp;
printer_->Outdent();
printer_->Print(")\n");
- if (pure_python_workable_) {
- printer_->Print("_sym_db.RegisterEnumDescriptor($name$)\n", "name",
- module_level_descriptor_name);
- }
+ printer_->Print("_sym_db.RegisterEnumDescriptor($name$)\n", "name",
+ module_level_descriptor_name);
printer_->Print("\n");
}
@@ -525,7 +587,7 @@ void Generator::PrintServices() const {
void Generator::PrintServiceDescriptor(
const ServiceDescriptor& descriptor) const {
- std::map<TProtoStringType, TProtoStringType> m;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> m;
m["service_name"] = ModuleLevelServiceDescriptorName(descriptor);
m["name"] = descriptor.name();
m["file"] = kDescriptorKey;
@@ -535,13 +597,13 @@ void Generator::PrintServiceDescriptor(
void Generator::PrintDescriptorKeyAndModuleName(
const ServiceDescriptor& descriptor) const {
TProtoStringType name = ModuleLevelServiceDescriptorName(descriptor);
- if (!pure_python_workable_) {
- name = "_descriptor.ServiceDescriptor(full_name='" +
- descriptor.full_name() + "')";
- }
printer_->Print("$descriptor_key$ = $descriptor_name$,\n", "descriptor_key",
kDescriptorKey, "descriptor_name", name);
TProtoStringType module_name = ModuleName(file_->name());
+ if (!opensource_runtime_) {
+ module_name =
+ TProtoStringType(y_absl::StripPrefix(module_name, kThirdPartyPrefix));
+ }
printer_->Print("__module__ = '$module_name$'\n", "module_name", module_name);
}
@@ -575,7 +637,7 @@ void Generator::PrintServiceStub(const ServiceDescriptor& descriptor) const {
//
// Mutually recursive with PrintNestedDescriptors().
void Generator::PrintDescriptor(const Descriptor& message_descriptor) const {
- std::map<TProtoStringType, TProtoStringType> m;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> m;
m["name"] = message_descriptor.name();
m["full_name"] = message_descriptor.full_name();
m["file"] = kDescriptorKey;
@@ -634,8 +696,8 @@ void Generator::PrintDescriptor(const Descriptor& message_descriptor) const {
for (int i = 0; i < message_descriptor.extension_range_count(); ++i) {
const Descriptor::ExtensionRange* range =
message_descriptor.extension_range(i);
- printer_->Print("($start$, $end$), ", "start", StrCat(range->start),
- "end", StrCat(range->end));
+ printer_->Print("($start$, $end$), ", "start", y_absl::StrCat(range->start),
+ "end", y_absl::StrCat(range->end));
}
printer_->Print("],\n");
printer_->Print("oneofs=[\n");
@@ -645,12 +707,13 @@ void Generator::PrintDescriptor(const Descriptor& message_descriptor) const {
m.clear();
m["name"] = desc->name();
m["full_name"] = desc->full_name();
- m["index"] = StrCat(desc->index());
+ m["index"] = y_absl::StrCat(desc->index());
options_string = OptionsValue(desc->options().SerializeAsString());
if (options_string == "None") {
m["serialized_options"] = "";
} else {
- m["serialized_options"] = ", serialized_options=" + options_string;
+ m["serialized_options"] =
+ y_absl::StrCat(", serialized_options=", options_string);
}
printer_->Print(m,
"_descriptor.OneofDescriptor(\n"
@@ -699,16 +762,16 @@ void Generator::PrintMessages() const {
// Mutually recursive with PrintNestedMessages().
// Collect nested message names to_register for the symbol_database.
void Generator::PrintMessage(const Descriptor& message_descriptor,
- const TProtoStringType& prefix,
+ y_absl::string_view prefix,
std::vector<TProtoStringType>* to_register,
bool is_nested) const {
TProtoStringType qualified_name;
if (is_nested) {
if (IsPythonKeyword(message_descriptor.name())) {
- qualified_name =
- "getattr(" + prefix + ", '" + message_descriptor.name() + "')";
+ qualified_name = y_absl::StrCat("getattr(", prefix, ", '",
+ message_descriptor.name(), "')");
} else {
- qualified_name = prefix + "." + message_descriptor.name();
+ qualified_name = y_absl::StrCat(prefix, ".", message_descriptor.name());
}
printer_->Print(
"'$name$' : _reflection.GeneratedProtocolMessageType('$name$', "
@@ -726,16 +789,15 @@ void Generator::PrintMessage(const Descriptor& message_descriptor,
to_register->push_back(qualified_name);
PrintNestedMessages(message_descriptor, qualified_name, to_register);
- std::map<TProtoStringType, TProtoStringType> m;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> m;
m["descriptor_key"] = kDescriptorKey;
- if (pure_python_workable_) {
- m["descriptor_name"] = ModuleLevelDescriptorName(message_descriptor);
- } else {
- m["descriptor_name"] = "_descriptor.Descriptor(full_name='" +
- message_descriptor.full_name() + "')";
- }
+ m["descriptor_name"] = ModuleLevelDescriptorName(message_descriptor);
printer_->Print(m, "'$descriptor_key$' : $descriptor_name$,\n");
TProtoStringType module_name = ModuleName(file_->name());
+ if (!opensource_runtime_) {
+ module_name =
+ TProtoStringType(y_absl::StripPrefix(module_name, kThirdPartyPrefix));
+ }
printer_->Print("'__module__' : '$module_name$'\n", "module_name",
module_name);
printer_->Print("# @@protoc_insertion_point(class_scope:$full_name$)\n",
@@ -747,7 +809,7 @@ void Generator::PrintMessage(const Descriptor& message_descriptor,
// Prints all nested messages within |containing_descriptor|.
// Mutually recursive with PrintMessage().
void Generator::PrintNestedMessages(
- const Descriptor& containing_descriptor, const TProtoStringType& prefix,
+ const Descriptor& containing_descriptor, y_absl::string_view prefix,
std::vector<TProtoStringType>* to_register) const {
for (int i = 0; i < containing_descriptor.nested_type_count(); ++i) {
printer_->Print("\n");
@@ -782,7 +844,7 @@ void Generator::FixForeignFieldsInDescriptor(
FixContainingTypeInDescriptor(enum_descriptor, &descriptor);
}
for (int i = 0; i < descriptor.oneof_decl_count(); ++i) {
- std::map<TProtoStringType, TProtoStringType> m;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> m;
const OneofDescriptor* oneof = descriptor.oneof_decl(i);
m["descriptor_name"] = ModuleLevelDescriptorName(descriptor);
m["oneof_name"] = oneof->name();
@@ -801,7 +863,7 @@ void Generator::FixForeignFieldsInDescriptor(
}
void Generator::AddMessageToFileDescriptor(const Descriptor& descriptor) const {
- std::map<TProtoStringType, TProtoStringType> m;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> m;
m["descriptor_name"] = kDescriptorKey;
m["message_name"] = descriptor.name();
m["message_descriptor_name"] = ModuleLevelDescriptorName(descriptor);
@@ -813,7 +875,7 @@ void Generator::AddMessageToFileDescriptor(const Descriptor& descriptor) const {
void Generator::AddServiceToFileDescriptor(
const ServiceDescriptor& descriptor) const {
- std::map<TProtoStringType, TProtoStringType> m;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> m;
m["descriptor_name"] = kDescriptorKey;
m["service_name"] = descriptor.name();
m["service_descriptor_name"] = ModuleLevelServiceDescriptorName(descriptor);
@@ -825,7 +887,7 @@ void Generator::AddServiceToFileDescriptor(
void Generator::AddEnumToFileDescriptor(
const EnumDescriptor& descriptor) const {
- std::map<TProtoStringType, TProtoStringType> m;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> m;
m["descriptor_name"] = kDescriptorKey;
m["enum_name"] = descriptor.name();
m["enum_descriptor_name"] = ModuleLevelDescriptorName(descriptor);
@@ -837,7 +899,7 @@ void Generator::AddEnumToFileDescriptor(
void Generator::AddExtensionToFileDescriptor(
const FieldDescriptor& descriptor) const {
- std::map<TProtoStringType, TProtoStringType> m;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> m;
m["descriptor_name"] = kDescriptorKey;
m["field_name"] = descriptor.name();
m["resolved_name"] = ResolveKeyword(descriptor.name());
@@ -858,10 +920,10 @@ void Generator::AddExtensionToFileDescriptor(
// is NULL.
void Generator::FixForeignFieldsInField(
const Descriptor* containing_type, const FieldDescriptor& field,
- const TProtoStringType& python_dict_name) const {
+ y_absl::string_view python_dict_name) const {
const TProtoStringType field_referencing_expression =
FieldReferencingExpression(containing_type, field, python_dict_name);
- std::map<TProtoStringType, TProtoStringType> m;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> m;
m["field_ref"] = field_referencing_expression;
const Descriptor* foreign_message_type = field.message_type();
if (foreign_message_type) {
@@ -886,15 +948,15 @@ void Generator::FixForeignFieldsInField(
// is NULL.
TProtoStringType Generator::FieldReferencingExpression(
const Descriptor* containing_type, const FieldDescriptor& field,
- const TProtoStringType& python_dict_name) const {
+ y_absl::string_view python_dict_name) const {
// We should only ever be looking up fields in the current file.
// The only things we refer to from other files are message descriptors.
- GOOGLE_CHECK_EQ(field.file(), file_)
+ Y_ABSL_CHECK_EQ(field.file(), file_)
<< field.file()->name() << " vs. " << file_->name();
if (!containing_type) {
return ResolveKeyword(field.name());
}
- return strings::Substitute("$0.$1['$2']",
+ return y_absl::Substitute("$0.$1['$2']",
ModuleLevelDescriptorName(*containing_type),
python_dict_name, field.name());
}
@@ -955,9 +1017,9 @@ void Generator::FixForeignFieldsInExtensions() const {
void Generator::FixForeignFieldsInExtension(
const FieldDescriptor& extension_field) const {
- GOOGLE_CHECK(extension_field.is_extension());
+ Y_ABSL_CHECK(extension_field.is_extension());
- std::map<TProtoStringType, TProtoStringType> m;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> m;
// Confusingly, for FieldDescriptors that happen to be extensions,
// containing_type() means "extended type."
// On the other hand, extension_scope() will give us what we normally
@@ -989,10 +1051,10 @@ void Generator::PrintEnumValueDescriptor(
// More circular references. ::sigh::
TProtoStringType options_string;
descriptor.options().SerializeToString(&options_string);
- std::map<TProtoStringType, TProtoStringType> m;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> m;
m["name"] = descriptor.name();
- m["index"] = StrCat(descriptor.index());
- m["number"] = StrCat(descriptor.number());
+ m["index"] = y_absl::StrCat(descriptor.index());
+ m["number"] = y_absl::StrCat(descriptor.number());
m["options"] = OptionsValue(options_string);
printer_->Print(m,
"_descriptor.EnumValueDescriptor(\n"
@@ -1004,11 +1066,11 @@ void Generator::PrintEnumValueDescriptor(
// Returns a CEscaped string of serialized_options.
TProtoStringType Generator::OptionsValue(
- const TProtoStringType& serialized_options) const {
+ y_absl::string_view serialized_options) const {
if (serialized_options.length() == 0 || GeneratingDescriptorProto()) {
return "None";
} else {
- return "b'" + CEscape(serialized_options) + "'";
+ return y_absl::StrCat("b'", y_absl::CEscape(serialized_options), "'");
}
}
@@ -1017,20 +1079,21 @@ void Generator::PrintFieldDescriptor(const FieldDescriptor& field,
bool is_extension) const {
TProtoStringType options_string;
field.options().SerializeToString(&options_string);
- std::map<TProtoStringType, TProtoStringType> m;
+ y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> m;
m["name"] = field.name();
m["full_name"] = field.full_name();
- m["index"] = StrCat(field.index());
- m["number"] = StrCat(field.number());
- m["type"] = StrCat(field.type());
- m["cpp_type"] = StrCat(field.cpp_type());
- m["label"] = StrCat(field.label());
+ m["index"] = y_absl::StrCat(field.index());
+ m["number"] = y_absl::StrCat(field.number());
+ m["type"] = y_absl::StrCat(field.type());
+ m["cpp_type"] = y_absl::StrCat(field.cpp_type());
+ m["label"] = y_absl::StrCat(field.label());
m["has_default_value"] = field.has_default_value() ? "True" : "False";
m["default_value"] = StringifyDefaultValue(field);
m["is_extension"] = is_extension ? "True" : "False";
m["serialized_options"] = OptionsValue(options_string);
- m["json_name"] =
- field.has_json_name() ? ", json_name='" + field.json_name() + "'" : "";
+ m["json_name"] = field.has_json_name()
+ ? y_absl::StrCat(", json_name='", field.json_name(), "'")
+ : "";
// We always set message_type and enum_type to None at this point, and then
// these fields in correctly after all referenced descriptors have been
// defined and/or imported (see FixForeignFieldsInDescriptors()).
@@ -1050,8 +1113,8 @@ void Generator::PrintFieldDescriptor(const FieldDescriptor& field,
// Helper for Print{Fields,Extensions}InDescriptor().
void Generator::PrintFieldDescriptorsInDescriptor(
const Descriptor& message_descriptor, bool is_extension,
- const TProtoStringType& list_variable_name, int (Descriptor::*CountFn)() const,
- const FieldDescriptor* (Descriptor::*GetterFn)(int)const) const {
+ y_absl::string_view list_variable_name, int (Descriptor::*CountFn)() const,
+ const FieldDescriptor* (Descriptor::*GetterFn)(int) const) const {
printer_->Print("$list$=[\n", "list", list_variable_name);
printer_->Indent();
for (int i = 0; i < (message_descriptor.*CountFn)(); ++i) {
@@ -1106,14 +1169,14 @@ TProtoStringType Generator::ModuleLevelDescriptorName(
// The C++ implementation doesn't guard against this either. Leaving
// it for now...
TProtoStringType name = NamePrefixedWithNestedTypes(descriptor, "_");
- ToUpper(&name);
+ y_absl::AsciiStrToUpper(&name);
// Module-private for now. Easy to make public later; almost impossible
// to make private later.
- name = "_" + name;
+ name = y_absl::StrCat("_", name);
// We now have the name relative to its own module. Also qualify with
// the module name iff this descriptor is from a different .proto file.
if (descriptor.file() != file_) {
- name = ModuleAlias(descriptor.file()->name()) + "." + name;
+ name = y_absl::StrCat(ModuleAlias(descriptor.file()->name()), ".", name);
}
return name;
}
@@ -1126,7 +1189,7 @@ TProtoStringType Generator::ModuleLevelMessageName(
const Descriptor& descriptor) const {
TProtoStringType name = NamePrefixedWithNestedTypes(descriptor, ".");
if (descriptor.file() != file_) {
- name = ModuleAlias(descriptor.file()->name()) + "." + name;
+ name = y_absl::StrCat(ModuleAlias(descriptor.file()->name()), ".", name);
}
return name;
}
@@ -1135,15 +1198,24 @@ TProtoStringType Generator::ModuleLevelMessageName(
// descriptor.
TProtoStringType Generator::ModuleLevelServiceDescriptorName(
const ServiceDescriptor& descriptor) const {
- TProtoStringType name = descriptor.name();
- ToUpper(&name);
- name = "_" + name;
+ TProtoStringType name = y_absl::StrCat("_", descriptor.name());
+ y_absl::AsciiStrToUpper(&name);
if (descriptor.file() != file_) {
- name = ModuleAlias(descriptor.file()->name()) + "." + name;
+ name = y_absl::StrCat(ModuleAlias(descriptor.file()->name()), ".", name);
}
return name;
}
+TProtoStringType Generator::PublicPackage() const {
+ return opensource_runtime_ ? "google.protobuf"
+ : "google3.net.google.protobuf.python.public";
+}
+
+TProtoStringType Generator::InternalPackage() const {
+ return opensource_runtime_ ? "google.protobuf.internal"
+ : "google3.net.google.protobuf.python.internal";
+}
+
// Prints standard constructor arguments serialized_start and serialized_end.
// Args:
// descriptor: The cpp descriptor to have a serialized reference.
@@ -1155,23 +1227,23 @@ TProtoStringType Generator::ModuleLevelServiceDescriptorName(
template <typename DescriptorT, typename DescriptorProtoT>
void Generator::PrintSerializedPbInterval(const DescriptorT& descriptor,
DescriptorProtoT& proto,
- const TProtoStringType& name) const {
+ y_absl::string_view name) const {
descriptor.CopyTo(&proto);
TProtoStringType sp;
proto.SerializeToString(&sp);
int offset = file_descriptor_serialized_.find(sp);
- GOOGLE_CHECK_GE(offset, 0);
+ Y_ABSL_CHECK_GE(offset, 0);
printer_->Print(
- "$name$._serialized_start=$serialized_start$\n"
- "$name$._serialized_end=$serialized_end$\n",
- "name", name, "serialized_start", StrCat(offset), "serialized_end",
- StrCat(offset + sp.size()));
+ "_globals['$name$']._serialized_start=$serialized_start$\n"
+ "_globals['$name$']._serialized_end=$serialized_end$\n",
+ "name", name, "serialized_start", y_absl::StrCat(offset), "serialized_end",
+ y_absl::StrCat(offset + sp.size()));
}
namespace {
-void PrintDescriptorOptionsFixingCode(const TProtoStringType& descriptor,
- const TProtoStringType& options,
+void PrintDescriptorOptionsFixingCode(y_absl::string_view descriptor,
+ y_absl::string_view options,
io::Printer* printer) {
// Reset the _options to None thus DescriptorBase.GetOptions() can
// parse _options again after extensions are registered.
@@ -1256,7 +1328,7 @@ void Generator::FixAllDescriptorOptions() const {
void Generator::FixOptionsForOneof(const OneofDescriptor& oneof) const {
TProtoStringType oneof_options = OptionsValue(oneof.options().SerializeAsString());
if (oneof_options != "None") {
- TProtoStringType oneof_name = strings::Substitute(
+ TProtoStringType oneof_name = y_absl::Substitute(
"$0.$1['$2']", ModuleLevelDescriptorName(*oneof.containing_type()),
"oneofs_by_name", oneof.name());
PrintDescriptorOptionsFixingCode(oneof_name, oneof_options, printer_);
@@ -1278,7 +1350,7 @@ void Generator::FixOptionsForEnum(const EnumDescriptor& enum_descriptor) const {
OptionsValue(value_descriptor.options().SerializeAsString());
if (value_options != "None") {
PrintDescriptorOptionsFixingCode(
- StringPrintf("%s.values_by_name[\"%s\"]", descriptor_name.c_str(),
+ y_absl::StrFormat("%s.values_by_name[\"%s\"]", descriptor_name.c_str(),
value_descriptor.name().c_str()),
value_options, printer_);
}
@@ -1303,8 +1375,8 @@ void Generator::FixOptionsForService(
TProtoStringType method_options =
OptionsValue(method->options().SerializeAsString());
if (method_options != "None") {
- TProtoStringType method_name =
- descriptor_name + ".methods_by_name['" + method->name() + "']";
+ TProtoStringType method_name = y_absl::StrCat(
+ descriptor_name, ".methods_by_name['", method->name(), "']");
PrintDescriptorOptionsFixingCode(method_name, method_options, printer_);
}
}
@@ -1370,7 +1442,7 @@ void Generator::FixOptionsForMessage(const Descriptor& descriptor) const {
// If a dependency forwards other files through public dependencies, let's
// copy over the corresponding module aliases.
void Generator::CopyPublicDependenciesAliases(
- const TProtoStringType& copy_from, const FileDescriptor* file) const {
+ y_absl::string_view copy_from, const FileDescriptor* file) const {
for (int i = 0; i < file->public_dependency_count(); ++i) {
TProtoStringType module_name = ModuleName(file->public_dependency(i)->name());
TProtoStringType module_alias = ModuleAlias(file->public_dependency(i)->name());
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/python/generator.h
index 8111bf733fc..8691b552219 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/python/generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/generator.h
@@ -36,12 +36,14 @@
#define GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__
#include <string>
+#include <vector>
-#include <google/protobuf/stubs/mutex.h>
-#include <google/protobuf/compiler/code_generator.h>
+#include "y_absl/strings/string_view.h"
+#include "y_absl/synchronization/mutex.h"
+#include "google/protobuf/compiler/code_generator.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -64,9 +66,18 @@ namespace python {
// 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
// CodeGenerator with the CommandLineInterface in your main() function.
+
+struct GeneratorOptions {
+ bool generate_pyi = false;
+ bool annotate_pyi = false;
+ bool bootstrap = false;
+};
+
class PROTOC_EXPORT Generator : public CodeGenerator {
public:
Generator();
+ Generator(const Generator&) = delete;
+ Generator& operator=(const Generator&) = delete;
~Generator() override;
// CodeGenerator methods.
@@ -76,7 +87,13 @@ class PROTOC_EXPORT Generator : public CodeGenerator {
uint64_t GetSupportedFeatures() const override;
+ void set_opensource_runtime(bool opensource) {
+ opensource_runtime_ = opensource;
+ }
+
private:
+ GeneratorOptions ParseParameter(y_absl::string_view parameter,
+ TProtoStringType* error) const;
void PrintImports() const;
void PrintFileDescriptor() const;
void PrintAllNestedEnumsInFile() const;
@@ -87,8 +104,8 @@ class PROTOC_EXPORT Generator : public CodeGenerator {
bool is_extension) const;
void PrintFieldDescriptorsInDescriptor(
const Descriptor& message_descriptor, bool is_extension,
- const TProtoStringType& list_variable_name, int (Descriptor::*CountFn)() const,
- const FieldDescriptor* (Descriptor::*GetterFn)(int)const) const;
+ y_absl::string_view list_variable_name, int (Descriptor::*CountFn)() const,
+ const FieldDescriptor* (Descriptor::*GetterFn)(int) const) const;
void PrintFieldsInDescriptor(const Descriptor& message_descriptor) const;
void PrintExtensionsInDescriptor(const Descriptor& message_descriptor) const;
void PrintMessageDescriptors() const;
@@ -97,11 +114,11 @@ class PROTOC_EXPORT Generator : public CodeGenerator {
void PrintMessages() const;
void PrintMessage(const Descriptor& message_descriptor,
- const TProtoStringType& prefix,
+ y_absl::string_view prefix,
std::vector<TProtoStringType>* to_register,
bool is_nested) const;
void PrintNestedMessages(const Descriptor& containing_descriptor,
- const TProtoStringType& prefix,
+ y_absl::string_view prefix,
std::vector<TProtoStringType>* to_register) const;
void FixForeignFieldsInDescriptors() const;
@@ -110,14 +127,14 @@ class PROTOC_EXPORT Generator : public CodeGenerator {
const Descriptor* containing_descriptor) const;
void FixForeignFieldsInField(const Descriptor* containing_type,
const FieldDescriptor& field,
- const TProtoStringType& python_dict_name) const;
+ y_absl::string_view python_dict_name) const;
void AddMessageToFileDescriptor(const Descriptor& descriptor) const;
void AddEnumToFileDescriptor(const EnumDescriptor& descriptor) const;
void AddExtensionToFileDescriptor(const FieldDescriptor& descriptor) const;
void AddServiceToFileDescriptor(const ServiceDescriptor& descriptor) const;
TProtoStringType FieldReferencingExpression(
const Descriptor* containing_type, const FieldDescriptor& field,
- const TProtoStringType& python_dict_name) const;
+ y_absl::string_view python_dict_name) const;
template <typename DescriptorT>
void FixContainingTypeInDescriptor(
const DescriptorT& descriptor,
@@ -128,6 +145,7 @@ class PROTOC_EXPORT Generator : public CodeGenerator {
const FieldDescriptor& extension_field) const;
void FixForeignFieldsInNestedExtensions(const Descriptor& descriptor) const;
+ void PrintTopBoilerplate() const;
void PrintServices() const;
void PrintServiceDescriptors() const;
void PrintServiceDescriptor(const ServiceDescriptor& descriptor) const;
@@ -137,7 +155,7 @@ class PROTOC_EXPORT Generator : public CodeGenerator {
const ServiceDescriptor& descriptor) const;
void PrintEnumValueDescriptor(const EnumValueDescriptor& descriptor) const;
- TProtoStringType OptionsValue(const TProtoStringType& serialized_options) const;
+ TProtoStringType OptionsValue(y_absl::string_view serialized_options) const;
bool GeneratingDescriptorProto() const;
template <typename DescriptorT>
@@ -145,11 +163,13 @@ class PROTOC_EXPORT Generator : public CodeGenerator {
TProtoStringType ModuleLevelMessageName(const Descriptor& descriptor) const;
TProtoStringType ModuleLevelServiceDescriptorName(
const ServiceDescriptor& descriptor) const;
+ TProtoStringType PublicPackage() const;
+ TProtoStringType InternalPackage() const;
template <typename DescriptorT, typename DescriptorProtoT>
void PrintSerializedPbInterval(const DescriptorT& descriptor,
DescriptorProtoT& proto,
- const TProtoStringType& name) const;
+ y_absl::string_view name) const;
void FixAllDescriptorOptions() const;
void FixOptionsForField(const FieldDescriptor& field) const;
@@ -161,18 +181,17 @@ class PROTOC_EXPORT Generator : public CodeGenerator {
void SetSerializedPbInterval() const;
void SetMessagePbInterval(const Descriptor& descriptor) const;
- void CopyPublicDependenciesAliases(const TProtoStringType& copy_from,
+ void CopyPublicDependenciesAliases(y_absl::string_view copy_from,
const FileDescriptor* file) const;
// Very coarse-grained lock to ensure that Generate() is reentrant.
// Guards file_, printer_ and file_descriptor_serialized_.
- mutable Mutex mutex_;
+ mutable y_absl::Mutex mutex_;
mutable const FileDescriptor* file_; // Set in Generate(). Under mutex_.
mutable TProtoStringType file_descriptor_serialized_;
mutable io::Printer* printer_; // Set in Generate(). Under mutex_.
- mutable bool pure_python_workable_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Generator);
+ bool opensource_runtime_ = true;
};
} // namespace python
@@ -180,6 +199,6 @@ class PROTOC_EXPORT Generator : public CodeGenerator {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/helpers.cc b/contrib/libs/protoc/src/google/protobuf/compiler/python/helpers.cc
index ee7461bc83c..f41603420cc 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/python/helpers.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/helpers.cc
@@ -28,36 +28,45 @@
// (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/helpers.h>
+#include "google/protobuf/compiler/python/helpers.h"
#include <algorithm>
-
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/descriptor.pb.h>
+#include <string>
+#include <vector>
+
+#include "y_absl/log/absl_check.h"
+#include "y_absl/strings/escaping.h"
+#include "y_absl/strings/match.h"
+#include "y_absl/strings/str_replace.h"
+#include "y_absl/strings/str_split.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/strings/strip.h"
+#include "google/protobuf/compiler/code_generator.h"
+#include "google/protobuf/descriptor.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;
+TProtoStringType FixEv(TProtoStringType filename) {
+ constexpr auto kSuffixLen = 3;
+ if (filename.EndsWith(".ev")) {
+ return filename.substr(0, filename.length() - kSuffixLen) + "_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 ModuleName(y_absl::string_view filename) {
+ TProtoStringType str(std::string{filename});
+ TProtoStringType basename = StripProto(FixEv(str));
+ y_absl::StrReplaceAll({{"-", "_"}, {"/", "."}}, &basename);
+ return y_absl::StrCat(basename, "_pb2");
}
-TProtoStringType StrippedModuleName(const TProtoStringType& filename) {
+TProtoStringType StrippedModuleName(y_absl::string_view filename) {
TProtoStringType module_name = ModuleName(filename);
return module_name;
}
@@ -74,8 +83,8 @@ const char* const kKeywords[] = {
const char* const* kKeywordsEnd =
kKeywords + (sizeof(kKeywords) / sizeof(kKeywords[0]));
-bool ContainsPythonKeyword(const TProtoStringType& module_name) {
- std::vector<TProtoStringType> tokens = Split(module_name, ".");
+bool ContainsPythonKeyword(y_absl::string_view module_name) {
+ std::vector<y_absl::string_view> tokens = y_absl::StrSplit(module_name, '.');
for (int i = 0; i < static_cast<int>(tokens.size()); ++i) {
if (std::find(kKeywords, kKeywordsEnd, tokens[i]) != kKeywordsEnd) {
return true;
@@ -84,23 +93,23 @@ bool ContainsPythonKeyword(const TProtoStringType& module_name) {
return false;
}
-bool IsPythonKeyword(const TProtoStringType& name) {
+bool IsPythonKeyword(y_absl::string_view name) {
return (std::find(kKeywords, kKeywordsEnd, name) != kKeywordsEnd);
}
-TProtoStringType ResolveKeyword(const TProtoStringType& name) {
+TProtoStringType ResolveKeyword(y_absl::string_view name) {
if (IsPythonKeyword(name)) {
- return "globals()['" + name + "']";
+ return y_absl::StrCat("globals()['", name, "']");
}
- return name;
+ return TProtoStringType(name);
}
TProtoStringType GetFileName(const FileDescriptor* file_des,
- const TProtoStringType& suffix) {
+ y_absl::string_view suffix) {
TProtoStringType module_name = ModuleName(file_des->name());
TProtoStringType filename = module_name;
- ReplaceCharacters(&filename, ".", '/');
- filename += suffix;
+ y_absl::StrReplaceAll({{".", "/"}}, &filename);
+ y_absl::StrAppend(&filename, suffix);
return filename;
}
@@ -108,17 +117,23 @@ bool HasGenericServices(const FileDescriptor* file) {
return file->service_count() > 0 && file->options().py_generic_services();
}
+TProtoStringType GeneratedCodeToBase64(const GeneratedCodeInfo& annotations) {
+ TProtoStringType result;
+ y_absl::Base64Escape(annotations.SerializeAsString(), &result);
+ return result;
+}
+
template <typename DescriptorT>
TProtoStringType NamePrefixedWithNestedTypes(const DescriptorT& descriptor,
- const TProtoStringType& separator) {
+ y_absl::string_view 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 + "')";
+ return y_absl::StrCat("getattr(", prefix, ", '", name, "')");
} else {
- return prefix + separator + name;
+ return y_absl::StrCat(prefix, separator, name);
}
}
if (separator == ".") {
@@ -128,9 +143,9 @@ TProtoStringType NamePrefixedWithNestedTypes(const DescriptorT& descriptor,
}
template TProtoStringType NamePrefixedWithNestedTypes<Descriptor>(
- const Descriptor& descriptor, const TProtoStringType& separator);
+ const Descriptor& descriptor, y_absl::string_view separator);
template TProtoStringType NamePrefixedWithNestedTypes<EnumDescriptor>(
- const EnumDescriptor& descriptor, const TProtoStringType& separator);
+ const EnumDescriptor& descriptor, y_absl::string_view separator);
} // namespace python
} // namespace compiler
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/helpers.h b/contrib/libs/protoc/src/google/protobuf/compiler/python/helpers.h
index 8745698acf6..5d77d73394f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/python/helpers.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/helpers.h
@@ -33,26 +33,29 @@
#include <string>
-#include <google/protobuf/descriptor.h>
+#include "y_absl/strings/str_replace.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.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 ModuleName(y_absl::string_view filename);
+TProtoStringType StrippedModuleName(y_absl::string_view filename);
+bool ContainsPythonKeyword(y_absl::string_view module_name);
+bool IsPythonKeyword(y_absl::string_view name);
+TProtoStringType ResolveKeyword(y_absl::string_view name);
TProtoStringType GetFileName(const FileDescriptor* file_des,
- const TProtoStringType& suffix);
+ y_absl::string_view suffix);
bool HasGenericServices(const FileDescriptor* file);
+TProtoStringType GeneratedCodeToBase64(const GeneratedCodeInfo& annotations);
template <typename DescriptorT>
TProtoStringType NamePrefixedWithNestedTypes(const DescriptorT& descriptor,
- const TProtoStringType& separator);
+ y_absl::string_view separator);
} // namespace python
} // namespace compiler
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/pyi_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/python/pyi_generator.cc
index 242cdd71f2c..3e7c2538958 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/python/pyi_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/pyi_generator.cc
@@ -28,61 +28,61 @@
// (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/pyi_generator.h>
+#include "google/protobuf/compiler/python/pyi_generator.h"
#include <string>
-
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/python/helpers.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/zero_copy_stream.h>
+#include <utility>
+#include <vector>
+
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/ascii.h"
+#include "y_absl/strings/match.h"
+#include "y_absl/strings/str_split.h"
+#include "google/protobuf/compiler/python/helpers.h"
+#include "google/protobuf/descriptor.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 {
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 std::map<TProtoStringType, TProtoStringType>& import_map) const {
+TProtoStringType PyiGenerator::ModuleLevelName(const DescriptorT& descriptor) const {
TProtoStringType name = NamePrefixedWithNestedTypes(descriptor, ".");
if (descriptor.file() != file_) {
TProtoStringType module_alias;
TProtoStringType filename = descriptor.file()->name();
- if (import_map.find(filename) == import_map.end()) {
+ if (import_map_.find(filename) == import_map_.end()) {
TProtoStringType module_name = ModuleName(descriptor.file()->name());
- std::vector<TProtoStringType> tokens = Split(module_name, ".");
- module_alias = "_" + tokens.back();
+ std::vector<y_absl::string_view> tokens = y_absl::StrSplit(module_name, '.');
+ module_alias = y_absl::StrCat("_", tokens.back());
} else {
- module_alias = import_map.at(filename);
+ module_alias = import_map_.at(filename);
}
- name = module_alias + "." + name;
+ name = y_absl::StrCat(module_alias, ".", name);
}
return name;
}
+TProtoStringType PyiGenerator::PublicPackage() const {
+ return opensource_runtime_ ? "google.protobuf"
+ : "google3.net.google.protobuf.python.public";
+}
+
+TProtoStringType PyiGenerator::InternalPackage() const {
+ return opensource_runtime_ ? "google.protobuf.internal"
+ : "google3.net.google.protobuf.python.internal";
+}
+
struct ImportModules {
bool has_repeated = false; // _containers
bool has_iterable = false; // typing.Iterable
@@ -156,41 +156,40 @@ void CheckImportModules(const Descriptor* descriptor,
void PyiGenerator::PrintImportForDescriptor(
const FileDescriptor& desc,
- std::map<TProtoStringType, TProtoStringType>* import_map,
- std::set<TProtoStringType>* seen_aliases) const {
+ y_absl::flat_hash_set<TProtoStringType>* seen_aliases) const {
const TProtoStringType& filename = desc.name();
- TProtoStringType module_name = StrippedModuleName(filename);
+ TProtoStringType module_name_owned = StrippedModuleName(filename);
+ y_absl::string_view module_name(module_name_owned);
size_t last_dot_pos = module_name.rfind('.');
TProtoStringType import_statement;
if (last_dot_pos == TProtoStringType::npos) {
- import_statement = "import " + module_name;
+ import_statement = y_absl::StrCat("import ", module_name);
} else {
- import_statement = "from " + module_name.substr(0, last_dot_pos) +
- " import " + module_name.substr(last_dot_pos + 1);
+ import_statement =
+ y_absl::StrCat("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);
}
- TProtoStringType alias = "_" + module_name;
+ TProtoStringType alias = y_absl::StrCat("_", module_name);
// Generate a unique alias by adding _1 suffixes until we get an unused alias.
while (seen_aliases->find(alias) != seen_aliases->end()) {
- alias = alias + "_1";
+ y_absl::StrAppend(&alias, "_1");
}
printer_->Print("$statement$ as $alias$\n", "statement",
import_statement, "alias", alias);
- (*import_map)[filename] = alias;
+ import_map_[filename] = alias;
seen_aliases->insert(alias);
}
-void PyiGenerator::PrintImports(
- std::map<TProtoStringType, TProtoStringType>* item_map,
- std::map<TProtoStringType, TProtoStringType>* import_map) const {
+void PyiGenerator::PrintImports() const {
// Prints imported dependent _pb2 files.
- std::set<TProtoStringType> seen_aliases;
+ y_absl::flat_hash_set<TProtoStringType> seen_aliases;
for (int i = 0; i < file_->dependency_count(); ++i) {
const FileDescriptor* dep = file_->dependency(i);
- PrintImportForDescriptor(*dep, import_map, &seen_aliases);
+ PrintImportForDescriptor(*dep, &seen_aliases);
for (int j = 0; j < dep->public_dependency_count(); ++j) {
PrintImportForDescriptor(
- *dep->public_dependency(j), import_map, &seen_aliases);
+ *dep->public_dependency(j), &seen_aliases);
}
}
@@ -202,6 +201,10 @@ void PyiGenerator::PrintImports(
if (file_->enum_type_count() > 0) {
import_modules.has_enums = true;
}
+ if (!opensource_runtime_ && file_->service_count() > 0) {
+ import_modules.has_optional = true;
+ import_modules.has_union = true;
+ }
for (int i = 0; i < file_->message_type_count(); i++) {
CheckImportModules(file_->message_type(i), &import_modules);
}
@@ -210,37 +213,50 @@ void PyiGenerator::PrintImports(
// required in the proto file.
if (import_modules.has_repeated) {
printer_->Print(
- "from google.protobuf.internal import containers as "
- "_containers\n");
+ "from $internal_package$ import containers as _containers\n",
+ "internal_package", InternalPackage());
}
if (import_modules.has_enums) {
printer_->Print(
- "from google.protobuf.internal import enum_type_wrapper"
- " as _enum_type_wrapper\n");
+ "from $internal_package$ import enum_type_wrapper as "
+ "_enum_type_wrapper\n",
+ "internal_package", InternalPackage());
}
if (import_modules.has_extendable) {
printer_->Print(
- "from google.protobuf.internal import python_message"
- " as _python_message\n");
+ "from $internal_package$ import python_message as _python_message\n",
+ "internal_package", InternalPackage());
}
if (import_modules.has_well_known_type) {
printer_->Print(
- "from google.protobuf.internal import well_known_types"
- " as _well_known_types\n");
+ "from $internal_package$ import well_known_types as "
+ "_well_known_types\n",
+ "internal_package", InternalPackage());
}
- printer_->Print(
- "from google.protobuf import"
- " descriptor as _descriptor\n");
+ printer_->Print("from $public_package$ import descriptor as _descriptor\n",
+ "public_package", PublicPackage());
if (import_modules.has_messages) {
- printer_->Print(
- "from google.protobuf import message as _message\n");
+ printer_->Print("from $public_package$ import message as _message\n",
+ "public_package", PublicPackage());
}
- if (HasGenericServices(file_)) {
- printer_->Print(
- "from google.protobuf import service as"
- " _service\n");
+ if (opensource_runtime_) {
+ if (HasGenericServices(file_)) {
+ printer_->Print("from $public_package$ import service as _service\n",
+ "public_package", PublicPackage());
+ }
+ } else {
+ if (file_->service_count() > 0) {
+ printer_->Print(
+ "from google3.net.rpc.python import proto_python_api_2_stub as "
+ "_proto_python_api_2_stub\n"
+ "from google3.net.rpc.python import pywraprpc as _pywraprpc\n"
+ "from google3.net.rpc.python import rpcserver as _rpcserver\n");
+ }
}
printer_->Print("from typing import ");
+ if (!opensource_runtime_ && file_->service_count() > 0) {
+ printer_->Print("Any as _Any, ");
+ }
printer_->Print("ClassVar as _ClassVar");
if (import_modules.has_iterable) {
printer_->Print(", Iterable as _Iterable");
@@ -254,7 +270,7 @@ void PyiGenerator::PrintImports(
if (import_modules.has_union) {
printer_->Print(", Union as _Union");
}
- printer_->Print("\n\n");
+ printer_->Print("\n");
// Public imports
for (int i = 0; i < file_->public_dependency_count(); ++i) {
@@ -272,17 +288,16 @@ void PyiGenerator::PrintImports(
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, *import_map);
- }
- }
- // Top level extensions for public imports
- AddExtensions(*public_dep, item_map);
}
+printer_->Print("\n");
+}
+
+// Annotate wrapper for debugging purposes
+// Print a message after Annotate to see what is annotated.
+template <typename DescriptorT>
+void PyiGenerator::Annotate(const TProtoStringType& label,
+ const DescriptorT* descriptor) const {
+printer_->Annotate(label.c_str(), descriptor);
}
void PyiGenerator::PrintEnum(const EnumDescriptor& enum_descriptor) const {
@@ -291,22 +306,31 @@ void PyiGenerator::PrintEnum(const EnumDescriptor& enum_descriptor) const {
"class $enum_name$(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):\n"
" __slots__ = []\n",
"enum_name", enum_name);
+ Annotate("enum_name", &enum_descriptor);
+ printer_->Indent();
+ PrintEnumValues(enum_descriptor, /* is_classvar = */ true);
+ printer_->Outdent();
}
-// 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 std::map<TProtoStringType, TProtoStringType>& import_map) const {
+void PyiGenerator::PrintEnumValues(const EnumDescriptor& enum_descriptor,
+ bool is_classvar) const {
// enum values
- TProtoStringType module_enum_name = ModuleLevelName(enum_descriptor, import_map);
+ 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;
+ if (is_classvar) {
+ printer_->Print("$name$: _ClassVar[$module_enum_name$]\n", "name",
+ value_descriptor->name(), "module_enum_name",
+ module_enum_name);
+ } else {
+ printer_->Print("$name$: $module_enum_name$\n", "name",
+ value_descriptor->name(), "module_enum_name",
+ module_enum_name);
+ }
+ Annotate("name", value_descriptor);
}
}
-// Prints top level enums
void PyiGenerator::PrintTopLevelEnums() const {
for (int i = 0; i < file_->enum_type_count(); ++i) {
printer_->Print("\n");
@@ -314,25 +338,24 @@ void PyiGenerator::PrintTopLevelEnums() const {
}
}
-// 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 {
+void PyiGenerator::PrintExtensions(const DescriptorT& descriptor) 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";
+ TProtoStringType constant_name =
+ y_absl::StrCat(extension_field->name(), "_FIELD_NUMBER");
+ y_absl::AsciiStrToUpper(&constant_name);
+ printer_->Print("$constant_name$: _ClassVar[int]\n",
+ "constant_name", constant_name);
+ printer_->Print("$name$: _descriptor.FieldDescriptor\n",
+ "name", extension_field->name());
+ Annotate("name", extension_field);
}
}
// Returns the string format of a field's cpp_type
TProtoStringType PyiGenerator::GetFieldType(
- const FieldDescriptor& field_des, const Descriptor& containing_des,
- const std::map<TProtoStringType, TProtoStringType>& import_map) const {
+ const FieldDescriptor& field_des, const Descriptor& containing_des) const {
switch (field_des.cpp_type()) {
case FieldDescriptor::CPPTYPE_INT32:
case FieldDescriptor::CPPTYPE_UINT32:
@@ -345,7 +368,7 @@ TProtoStringType PyiGenerator::GetFieldType(
case FieldDescriptor::CPPTYPE_BOOL:
return "bool";
case FieldDescriptor::CPPTYPE_ENUM:
- return ModuleLevelName(*field_des.enum_type(), import_map);
+ return ModuleLevelName(*field_des.enum_type());
case FieldDescriptor::CPPTYPE_STRING:
if (field_des.type() == FieldDescriptor::TYPE_STRING) {
return "str";
@@ -356,23 +379,22 @@ TProtoStringType PyiGenerator::GetFieldType(
// If the field is inside a nested message and the nested message has the
// same name as a top-level message, then we need to prefix the field type
// with the module name for disambiguation.
- TProtoStringType name = ModuleLevelName(*field_des.message_type(), import_map);
+ TProtoStringType name = ModuleLevelName(*field_des.message_type());
if ((containing_des.containing_type() != nullptr &&
name == containing_des.name())) {
TProtoStringType module = ModuleName(field_des.file()->name());
- name = module + "." + name;
+ name = y_absl::StrCat(module, ".", name);
}
return name;
}
default:
- GOOGLE_LOG(FATAL) << "Unsupported field type.";
+ Y_ABSL_LOG(FATAL) << "Unsupported field type.";
}
return "";
}
void PyiGenerator::PrintMessage(
- const Descriptor& message_descriptor, bool is_nested,
- const std::map<TProtoStringType, TProtoStringType>& import_map) const {
+ const Descriptor& message_descriptor, bool is_nested) const {
if (!is_nested) {
printer_->Print("\n");
}
@@ -381,26 +403,21 @@ void PyiGenerator::PrintMessage(
// A well-known type needs to inherit from its corresponding base class in
// net/proto2/python/internal/well_known_types.
if (IsWellKnownType(message_descriptor.full_name())) {
- extra_base = ", _well_known_types." + message_descriptor.name();
+ extra_base =
+ y_absl::StrCat(", _well_known_types.", message_descriptor.name());
} else {
extra_base = "";
}
printer_->Print("class $class_name$(_message.Message$extra_base$):\n",
"class_name", class_name, "extra_base", extra_base);
+ Annotate("class_name", &message_descriptor);
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) {
+ for (int i = 0; i < message_descriptor.field_count(); ++i) {
+ const FieldDescriptor* field_des = message_descriptor.field(i);
if (IsPythonKeyword(field_des->name())) {
continue;
}
@@ -413,48 +430,34 @@ void PyiGenerator::PrintMessage(
}
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";
+ printer_->Print("Extensions: _python_message._ExtensionDict\n");
}
// 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, import_map);
+ PrintEnum(*message_descriptor.enum_type(i));
+ PrintEnumValues(*message_descriptor.enum_type(i));
}
// 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));
+ PrintMessage(*message_descriptor.nested_type(i), true);
}
- std::sort(nested_messages.begin(), nested_messages.end(),
- SortByName<Descriptor>());
- for (const auto& entry : nested_messages) {
- PrintMessage(*entry, true, import_map);
- }
-
- // Adds extensions to item_map which will be ordered and printed later
- AddExtensions(message_descriptor, &item_map);
+ PrintExtensions(message_descriptor);
- // Adds field number and field descriptor to item_map
+ // Prints field number
+ for (int i = 0; i < message_descriptor.field_count(); ++i) {
+ const FieldDescriptor& field_des = *message_descriptor.field(i);
+ printer_->Print(
+ "$field_number_name$: _ClassVar[int]\n", "field_number_name",
+ y_absl::StrCat(y_absl::AsciiStrToUpper(field_des.name()), "_FIELD_NUMBER"));
+ }
+ // Prints field name and type
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;
}
@@ -462,30 +465,29 @@ void PyiGenerator::PrintMessage(
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, message_descriptor, import_map);
- field_type += ", ";
- field_type += GetFieldType(*value_des, message_descriptor, import_map);
+ field_type =
+ y_absl::StrCat(value_des->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE
+ ? "_containers.MessageMap["
+ : "_containers.ScalarMap[",
+ GetFieldType(*key_des, message_descriptor), ", ",
+ GetFieldType(*value_des, message_descriptor));
} else {
if (field_des.is_repeated()) {
field_type = (field_des.cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE
? "_containers.RepeatedCompositeFieldContainer["
: "_containers.RepeatedScalarFieldContainer[");
}
- field_type += GetFieldType(field_des, message_descriptor, import_map);
+ field_type += GetFieldType(field_des, message_descriptor);
}
if (field_des.is_repeated()) {
- field_type += "]";
+ y_absl::StrAppend(&field_type, "]");
}
- item_map[field_des.name()] = field_type;
+ printer_->Print("$name$: $type$\n",
+ "name", field_des.name(), "type", field_type);
+ Annotate("name", &field_des);
}
- // Prints all items in item_map
- PrintItemMap(item_map);
-
// Prints __init__
printer_->Print("def __init__(self");
bool has_key_words = false;
@@ -505,6 +507,7 @@ void PyiGenerator::PrintMessage(
}
is_first = false;
printer_->Print(", $field_name$: ", "field_name", field_name);
+ Annotate("field_name", field_des);
if (field_des->is_repeated() ||
field_des->cpp_type() != FieldDescriptor::CPPTYPE_BOOL) {
printer_->Print("_Optional[");
@@ -513,9 +516,9 @@ void PyiGenerator::PrintMessage(
const Descriptor* map_entry = field_des->message_type();
printer_->Print(
"_Mapping[$key_type$, $value_type$]", "key_type",
- GetFieldType(*map_entry->field(0), message_descriptor, import_map),
+ GetFieldType(*map_entry->field(0), message_descriptor),
"value_type",
- GetFieldType(*map_entry->field(1), message_descriptor, import_map));
+ GetFieldType(*map_entry->field(1), message_descriptor));
} else {
if (field_des->is_repeated()) {
printer_->Print("_Iterable[");
@@ -523,15 +526,15 @@ void PyiGenerator::PrintMessage(
if (field_des->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
printer_->Print(
"_Union[$type_name$, _Mapping]", "type_name",
- GetFieldType(*field_des, message_descriptor, import_map));
+ GetFieldType(*field_des, message_descriptor));
} else {
if (field_des->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {
printer_->Print("_Union[$type_name$, str]", "type_name",
- ModuleLevelName(*field_des->enum_type(), import_map));
+ ModuleLevelName(*field_des->enum_type()));
} else {
printer_->Print(
"$type_name$", "type_name",
- GetFieldType(*field_des, message_descriptor, import_map));
+ GetFieldType(*field_des, message_descriptor));
}
}
if (field_des->is_repeated()) {
@@ -548,83 +551,92 @@ void PyiGenerator::PrintMessage(
printer_->Print(", **kwargs");
}
printer_->Print(") -> None: ...\n");
-
- printer_->Outdent();
printer_->Outdent();
}
-void PyiGenerator::PrintMessages(
- const std::map<TProtoStringType, TProtoStringType>& import_map) const {
+void PyiGenerator::PrintMessages() const {
// Deterministically order the descriptors.
- 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, import_map);
+ PrintMessage(*file_->message_type(i), 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) {
+ for (int i = 0; i < file_->service_count(); ++i) {
printer_->Print("\n");
printer_->Print(
"class $service_name$(_service.service): ...\n\n"
"class $service_name$_Stub($service_name$): ...\n",
- "service_name", entry->name());
+ "service_name", file_->service(i)->name());
}
}
+
bool PyiGenerator::Generate(const FileDescriptor* file,
const TProtoStringType& parameter,
GeneratorContext* context,
TProtoStringType* error) const {
- MutexLock lock(&mutex_);
+ y_absl::MutexLock lock(&mutex_);
+ import_map_.clear();
// Calculate file name.
file_ = file;
- TProtoStringType filename =
- parameter.empty() ? GetFileName(file, ".pyi") : parameter;
+ // In google3, devtools/python/blaze/pytype/pytype_impl.bzl uses --pyi_out to
+ // directly set the output file name.
+ std::vector<std::pair<TProtoStringType, TProtoStringType> > options;
+ ParseGeneratorParameter(parameter, &options);
+
+ TProtoStringType filename;
+ bool annotate_code = false;
+ for (const std::pair<TProtoStringType, TProtoStringType>& option : options) {
+ if (option.first == "annotate_code") {
+ annotate_code = true;
+ } else if (y_absl::EndsWith(option.first, ".pyi")) {
+ filename = option.first;
+ } else {
+ *error = y_absl::StrCat("Unknown generator option: ", option.first);
+ return false;
+ }
+ }
+
+ if (filename.empty()) {
+ filename = GetFileName(file, ".pyi");
+ }
std::unique_ptr<io::ZeroCopyOutputStream> output(context->Open(filename));
- GOOGLE_CHECK(output.get());
- io::Printer printer(output.get(), '$');
+ Y_ABSL_CHECK(output.get());
+ GeneratedCodeInfo annotations;
+ io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
+ &annotations);
+ io::Printer::Options printer_opt(
+ '$', annotate_code ? &annotation_collector : nullptr);
+ printer_opt.spaces_per_indent = 4;
+ io::Printer printer(output.get(), printer_opt);
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();
+ printer_->Print("DESCRIPTOR: _descriptor.FileDescriptor\n");
- // import_map will be a mapping from filename to module alias, e.g.
- // "google3/foo/bar.py" -> "_bar"
- std::map<TProtoStringType, TProtoStringType> import_map;
+ // Prints extensions and enums from imports.
+ for (int i = 0; i < file_->public_dependency_count(); ++i) {
+ const FileDescriptor* public_dep = file_->public_dependency(i);
+ PrintExtensions(*public_dep);
+ for (int i = 0; i < public_dep->enum_type_count(); ++i) {
+ const EnumDescriptor* enum_descriptor = public_dep->enum_type(i);
+ PrintEnumValues(*enum_descriptor);
+ }
+ }
- PrintImports(&item_map, &import_map);
- // Adds top level enum values to item_map.
+ PrintTopLevelEnums();
+ // Prints top level enum values
for (int i = 0; i < file_->enum_type_count(); ++i) {
- AddEnumValue(*file_->enum_type(i), &item_map, import_map);
+ PrintEnumValues(*file_->enum_type(i));
}
- // Adds top level extensions to item_map.
- AddExtensions(*file_, &item_map);
- // Prints item map
- PrintItemMap(item_map);
+ // Prints top level Extensions
+ PrintExtensions(*file_);
+ PrintMessages();
- PrintMessages(import_map);
- PrintTopLevelEnums();
- if (HasGenericServices(file)) {
+ if (opensource_runtime_ && HasGenericServices(file)) {
PrintServices();
}
return true;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/pyi_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/python/pyi_generator.h
index c9bf2961665..091a252c4bd 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/python/pyi_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/pyi_generator.h
@@ -35,15 +35,15 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_PYTHON_PYI_GENERATOR_H__
#define GOOGLE_PROTOBUF_COMPILER_PYTHON_PYI_GENERATOR_H__
-#include <map>
-#include <set>
#include <string>
-#include <google/protobuf/stubs/mutex.h>
-#include <google/protobuf/compiler/code_generator.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/synchronization/mutex.h"
+#include "google/protobuf/compiler/code_generator.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -63,6 +63,8 @@ namespace python {
class PROTOC_EXPORT PyiGenerator : public google::protobuf::compiler::CodeGenerator {
public:
PyiGenerator();
+ PyiGenerator(const PyiGenerator&) = delete;
+ PyiGenerator& operator=(const PyiGenerator&) = delete;
~PyiGenerator() override;
// CodeGenerator methods.
@@ -75,39 +77,38 @@ class PROTOC_EXPORT PyiGenerator : public google::protobuf::compiler::CodeGenera
TProtoStringType* error) const override;
private:
- void PrintImportForDescriptor(const FileDescriptor& desc,
- std::map<TProtoStringType, TProtoStringType>* import_map,
- std::set<TProtoStringType>* seen_aliases) const;
- void PrintImports(std::map<TProtoStringType, TProtoStringType>* item_map,
- std::map<TProtoStringType, TProtoStringType>* import_map) const;
- void PrintEnum(const EnumDescriptor& enum_descriptor) const;
- void AddEnumValue(const EnumDescriptor& enum_descriptor,
- std::map<TProtoStringType, TProtoStringType>* item_map,
- const std::map<TProtoStringType, TProtoStringType>& import_map) const;
+ void PrintImportForDescriptor(
+ const FileDescriptor& desc,
+ y_absl::flat_hash_set<TProtoStringType>* seen_aliases) const;
+ template <typename DescriptorT>
+ void Annotate(const TProtoStringType& label, const DescriptorT* descriptor) const;
+ void PrintImports() const;
void PrintTopLevelEnums() const;
+ void PrintEnum(const EnumDescriptor& enum_descriptor) const;
+ void PrintEnumValues(const EnumDescriptor& enum_descriptor,
+ bool is_classvar = false) const;
template <typename DescriptorT>
- void AddExtensions(const DescriptorT& descriptor,
- std::map<TProtoStringType, TProtoStringType>* item_map) const;
- void PrintMessages(
- const std::map<TProtoStringType, TProtoStringType>& import_map) const;
- void PrintMessage(const Descriptor& message_descriptor, bool is_nested,
- const std::map<TProtoStringType, TProtoStringType>& import_map) const;
+ void PrintExtensions(const DescriptorT& descriptor) 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 Descriptor& containing_des,
- const std::map<TProtoStringType, TProtoStringType>& import_map) const;
+ const FieldDescriptor& field_des, const Descriptor& containing_des) const;
template <typename DescriptorT>
- TProtoStringType ModuleLevelName(
- const DescriptorT& descriptor,
- const std::map<TProtoStringType, TProtoStringType>& import_map) const;
+ TProtoStringType ModuleLevelName(const DescriptorT& descriptor) const;
+ TProtoStringType PublicPackage() const;
+ TProtoStringType InternalPackage() const;
+
+ bool opensource_runtime_ = true;
// Very coarse-grained lock to ensure that Generate() is reentrant.
- // Guards file_ and printer_.
- mutable Mutex mutex_;
+ // Guards file_, printer_, and import_map_.
+ mutable y_absl::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);
+ // import_map will be a mapping from filename to module alias, e.g.
+ // "google3/foo/bar.py" -> "_bar"
+ mutable y_absl::flat_hash_map<TProtoStringType, TProtoStringType> import_map_;
};
} // namespace python
@@ -115,6 +116,6 @@ class PROTOC_EXPORT PyiGenerator : public google::protobuf::compiler::CodeGenera
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_PYTHON_PYI_GENERATOR_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/retention.cc b/contrib/libs/protoc/src/google/protobuf/compiler/retention.cc
new file mode 100644
index 00000000000..f49971a7e3d
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/retention.cc
@@ -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.
+
+#include "google/protobuf/compiler/retention.h"
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/dynamic_message.h"
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+
+namespace {
+// Recursively strips any options with source retention from the message.
+void StripMessage(Message& m) {
+ const Reflection* reflection = m.GetReflection();
+ std::vector<const FieldDescriptor*> fields;
+ reflection->ListFields(m, &fields);
+ for (const FieldDescriptor* field : fields) {
+ if (field->options().retention() == FieldOptions::RETENTION_SOURCE) {
+ reflection->ClearField(&m, field);
+ } else if (field->type() == FieldDescriptor::TYPE_MESSAGE) {
+ if (field->is_repeated()) {
+ int field_size = reflection->FieldSize(m, field);
+ for (int i = 0; i < field_size; ++i) {
+ StripMessage(*reflection->MutableRepeatedMessage(&m, field, i));
+ }
+ } else {
+ StripMessage(*reflection->MutableMessage(&m, field));
+ }
+ }
+ }
+}
+} // namespace
+
+FileDescriptorProto StripSourceRetentionOptions(const FileDescriptor& file) {
+ FileDescriptorProto file_proto;
+ file.CopyTo(&file_proto);
+
+ // We need to look up the descriptor in file.pool() so that we can get a
+ // descriptor which knows about any custom options that were used in the
+ // .proto file.
+ const Descriptor* descriptor =
+ file.pool()->FindMessageTypeByName(FileDescriptorProto().GetTypeName());
+
+ if (descriptor == nullptr) {
+ // If the pool does not contain the descriptor for FileDescriptorProto,
+ // then this proto file does not transitively depend on descriptor.proto,
+ // in which case we know there are no custom options to worry about.
+ StripMessage(file_proto);
+ } else {
+ // The options message may have custom options set on it, and these would
+ // ordinarily appear as unknown fields since they are not linked into
+ // protoc. Using a dynamic message allows us to see these custom options.
+ // To convert back and forth between the generated type and the dynamic
+ // message, we have to serialize one and parse that into the other.
+ DynamicMessageFactory factory;
+ std::unique_ptr<Message> dynamic_message(
+ factory.GetPrototype(descriptor)->New());
+ TProtoStringType serialized;
+ Y_ABSL_CHECK(file_proto.SerializeToString(&serialized));
+ Y_ABSL_CHECK(dynamic_message->ParseFromString(serialized));
+ StripMessage(*dynamic_message);
+ Y_ABSL_CHECK(dynamic_message->SerializeToString(&serialized));
+ Y_ABSL_CHECK(file_proto.ParseFromString(serialized));
+ }
+
+ return file_proto;
+}
+
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/retention.h b/contrib/libs/protoc/src/google/protobuf/compiler/retention.h
new file mode 100644
index 00000000000..b97ab1e73a9
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/retention.h
@@ -0,0 +1,55 @@
+// 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_RETENTION_H__
+#define GOOGLE_PROTOBUF_COMPILER_RETENTION_H__
+
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/descriptor.pb.h"
+
+// Must appear last
+#include "google/protobuf/port_def.inc"
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+
+// Returns a FileDescriptorProto for this file, with all RETENTION_SOURCE
+// options stripped out.
+PROTOC_EXPORT FileDescriptorProto
+StripSourceRetentionOptions(const FileDescriptor& file);
+
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
+
+#endif // GOOGLE_PROTOBUF_COMPILER_RETENTION_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 4a26b6d951f..bf02333ed48 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
@@ -28,17 +28,19 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#include "google/protobuf/compiler/ruby/ruby_generator.h"
+
#include <iomanip>
+#include <memory>
#include <sstream>
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/compiler/plugin.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/zero_copy_stream.h>
-
-#include <google/protobuf/compiler/ruby/ruby_generator.h>
+#include "google/protobuf/compiler/code_generator.h"
+#include "y_absl/log/absl_log.h"
+#include "google/protobuf/compiler/plugin.h"
+#include "google/protobuf/descriptor.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 {
@@ -48,15 +50,15 @@ namespace ruby {
// Forward decls.
template <class numeric_type>
TProtoStringType NumberToString(numeric_type value);
-TProtoStringType GetRequireName(const TProtoStringType& proto_file);
+TProtoStringType GetRequireName(y_absl::string_view proto_file);
TProtoStringType LabelForField(FieldDescriptor* field);
TProtoStringType TypeName(FieldDescriptor* field);
bool GenerateMessage(const Descriptor* message, io::Printer* printer,
TProtoStringType* error);
void GenerateEnum(const EnumDescriptor* en, io::Printer* printer);
-void GenerateMessageAssignment(const TProtoStringType& prefix,
+void GenerateMessageAssignment(y_absl::string_view prefix,
const Descriptor* message, io::Printer* printer);
-void GenerateEnumAssignment(const TProtoStringType& prefix, const EnumDescriptor* en,
+void GenerateEnumAssignment(y_absl::string_view prefix, const EnumDescriptor* en,
io::Printer* printer);
TProtoStringType DefaultValueForField(const FieldDescriptor* field);
@@ -67,13 +69,13 @@ TProtoStringType NumberToString(numeric_type value) {
return TProtoStringType{os.str()};
}
-TProtoStringType GetRequireName(const TProtoStringType& proto_file) {
- int lastindex = proto_file.find_last_of(".");
- return proto_file.substr(0, lastindex) + "_pb";
+TProtoStringType GetRequireName(y_absl::string_view proto_file) {
+ size_t lastindex = proto_file.find_last_of('.');
+ return y_absl::StrCat(proto_file.substr(0, lastindex), "_pb");
}
-TProtoStringType GetOutputFilename(const TProtoStringType& proto_file) {
- return GetRequireName(proto_file) + ".rb";
+TProtoStringType GetOutputFilename(y_absl::string_view proto_file) {
+ return y_absl::StrCat(GetRequireName(proto_file), ".rb");
}
TProtoStringType LabelForField(const FieldDescriptor* field) {
@@ -121,8 +123,8 @@ TProtoStringType StringifySyntax(FileDescriptor::Syntax syntax) {
return "proto3";
case FileDescriptor::SYNTAX_UNKNOWN:
default:
- GOOGLE_LOG(FATAL) << "Unsupported syntax; this generator only supports "
- "proto2 and proto3 syntax.";
+ Y_ABSL_LOG(FATAL) << "Unsupported syntax; this generator only supports "
+ "proto2 and proto3 syntax.";
return "";
}
}
@@ -247,7 +249,8 @@ void GenerateOneof(const OneofDescriptor* oneof, io::Printer* printer) {
bool GenerateMessage(const Descriptor* message, io::Printer* printer,
TProtoStringType* error) {
if (message->extension_range_count() > 0 || message->extension_count() > 0) {
- GOOGLE_LOG(WARNING) << "Extensions are not yet supported for proto2 .proto files.";
+ Y_ABSL_LOG(WARNING)
+ << "Extensions are not yet supported for proto2 .proto files.";
}
// Don't generate MapEntry messages -- we use the Ruby extension's native
@@ -321,7 +324,7 @@ char UpperChar(char ch) { return IsLower(ch) ? (ch - 'a' + 'A') : ch; }
// names must be PascalCased.
//
// foo_bar_baz -> FooBarBaz
-TProtoStringType PackageToModule(const TProtoStringType& name) {
+TProtoStringType PackageToModule(y_absl::string_view name) {
bool next_upper = true;
TProtoStringType result;
result.reserve(name.size());
@@ -346,8 +349,8 @@ TProtoStringType PackageToModule(const TProtoStringType& name) {
// since there is nothing enforcing this we need to ensure that they are valid
// Ruby constants. That mainly means making sure that the first character is
// an upper-case letter.
-TProtoStringType RubifyConstant(const TProtoStringType& name) {
- TProtoStringType ret = name;
+TProtoStringType RubifyConstant(y_absl::string_view name) {
+ TProtoStringType ret(name);
if (!ret.empty()) {
if (IsLower(ret[0])) {
// If it starts with a lowercase letter, capitalize it.
@@ -358,14 +361,14 @@ TProtoStringType RubifyConstant(const TProtoStringType& name) {
// here, e.g. try to strip leading underscores, but this may cause other
// problems if the user really intended the name. So let's just prepend a
// well-known suffix.
- ret = "PB_" + ret;
+ return y_absl::StrCat("PB_", ret);
}
}
return ret;
}
-void GenerateMessageAssignment(const TProtoStringType& prefix,
+void GenerateMessageAssignment(y_absl::string_view prefix,
const Descriptor* message,
io::Printer* printer) {
// Don't generate MapEntry messages -- we use the Ruby extension's native
@@ -383,7 +386,8 @@ void GenerateMessageAssignment(const TProtoStringType& prefix,
"lookup(\"$full_name$\").msgclass\n",
"full_name", message->full_name());
- TProtoStringType nested_prefix = prefix + RubifyConstant(message->name()) + "::";
+ TProtoStringType nested_prefix =
+ y_absl::StrCat(prefix, RubifyConstant(message->name()), "::");
for (int i = 0; i < message->nested_type_count(); i++) {
GenerateMessageAssignment(nested_prefix, message->nested_type(i), printer);
}
@@ -392,7 +396,7 @@ void GenerateMessageAssignment(const TProtoStringType& prefix,
}
}
-void GenerateEnumAssignment(const TProtoStringType& prefix, const EnumDescriptor* en,
+void GenerateEnumAssignment(y_absl::string_view prefix, const EnumDescriptor* en,
io::Printer* printer) {
printer->Print(
"$prefix$$name$ = ",
@@ -421,9 +425,9 @@ int GeneratePackageModules(const FileDescriptor* file, io::Printer* printer) {
// -> A.B.C
if (package_name.find("::") != TProtoStringType::npos) {
need_change_to_module = false;
- } 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'";
+ } else if (package_name.find('.') != TProtoStringType::npos) {
+ Y_ABSL_LOG(WARNING) << "ruby_package option should be in the form of:"
+ << " 'A::B::C' and not 'A.B.C'";
}
} else {
package_name = file->package();
@@ -519,7 +523,8 @@ bool GenerateFile(const FileDescriptor* file, io::Printer* printer,
// TODO: Remove this when ruby supports extensions for proto2 syntax.
if (file->syntax() == FileDescriptor::SYNTAX_PROTO2 &&
file->extension_count() > 0) {
- GOOGLE_LOG(WARNING) << "Extensions are not yet supported for proto2 .proto files.";
+ Y_ABSL_LOG(WARNING)
+ << "Extensions are not yet supported for proto2 .proto files.";
}
bool use_raw_descriptor = file->name() == "google/protobuf/descriptor.proto";
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/ruby/ruby_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/ruby/ruby_generator.h
index 4bda18da2d5..0559413e322 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/ruby/ruby_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/ruby/ruby_generator.h
@@ -35,9 +35,9 @@
#include <string>
-#include <google/protobuf/compiler/code_generator.h>
+#include "google/protobuf/compiler/code_generator.h"
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -62,6 +62,6 @@ class PROTOC_EXPORT Generator : public CodeGenerator {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_RUBY_GENERATOR_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/scc.h b/contrib/libs/protoc/src/google/protobuf/compiler/scc.h
index 7b95689d7ac..87c3f9fa8fe 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/scc.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/scc.h
@@ -31,14 +31,16 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_SCC_H__
#define GOOGLE_PROTOBUF_COMPILER_SCC_H__
-#include <map>
+#include <memory>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/descriptor.h>
+#include "y_absl/container/flat_hash_map.h"
+#include "y_absl/container/flat_hash_set.h"
+#include "y_absl/log/absl_check.h"
+#include "y_absl/memory/memory.h"
+#include "google/protobuf/descriptor.h"
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -64,10 +66,15 @@ template <class DepsGenerator>
class PROTOC_EXPORT SCCAnalyzer {
public:
explicit SCCAnalyzer() : index_(0) {}
+ SCCAnalyzer(const SCCAnalyzer&) = delete;
+ SCCAnalyzer& operator=(const SCCAnalyzer&) = delete;
const SCC* GetSCC(const Descriptor* descriptor) {
- if (cache_.count(descriptor)) return cache_[descriptor].scc;
- return DFS(descriptor).scc;
+ auto it = cache_.find(descriptor);
+ if (it == cache_.end()) {
+ return DFS(descriptor).scc;
+ }
+ return it->second->scc;
}
private:
@@ -77,7 +84,7 @@ class PROTOC_EXPORT SCCAnalyzer {
int lowlink;
};
- std::map<const Descriptor*, NodeData> cache_;
+ y_absl::flat_hash_map<const Descriptor*, std::unique_ptr<NodeData>> cache_;
std::vector<const Descriptor*> stack_;
int index_;
std::vector<std::unique_ptr<SCC>> garbage_bin_;
@@ -89,24 +96,25 @@ class PROTOC_EXPORT SCCAnalyzer {
// Tarjan's Strongly Connected Components algo
NodeData DFS(const Descriptor* descriptor) {
- // Must not have visited already.
- GOOGLE_DCHECK_EQ(cache_.count(descriptor), 0);
-
// Mark visited by inserting in map.
- NodeData& result = cache_[descriptor];
+ auto ins = cache_.try_emplace(descriptor, y_absl::make_unique<NodeData>());
+ // Must not have visited already.
+ Y_ABSL_DCHECK(ins.second);
+ NodeData& result = *ins.first->second;
// Initialize data structures.
result.index = result.lowlink = index_++;
stack_.push_back(descriptor);
// Recurse the fields / nodes in graph
- for (auto dep : DepsGenerator()(descriptor)) {
- GOOGLE_CHECK(dep);
- if (cache_.count(dep) == 0) {
+ for (const auto* dep : DepsGenerator()(descriptor)) {
+ Y_ABSL_CHECK(dep);
+ auto it = cache_.find(dep);
+ if (it == cache_.end()) {
// unexplored node
NodeData child_data = DFS(dep);
result.lowlink = std::min(result.lowlink, child_data.lowlink);
} else {
- NodeData child_data = cache_[dep];
+ NodeData& child_data = *it->second;
if (child_data.scc == nullptr) {
// Still in the stack_ so we found a back edge
result.lowlink = std::min(result.lowlink, child_data.index);
@@ -121,7 +129,7 @@ class PROTOC_EXPORT SCCAnalyzer {
scc->descriptors.push_back(scc_desc);
// Remove from stack
stack_.pop_back();
- cache_[scc_desc].scc = scc;
+ cache_[scc_desc]->scc = scc;
if (scc_desc == descriptor) break;
}
@@ -139,10 +147,10 @@ class PROTOC_EXPORT SCCAnalyzer {
// Add the SCC's that are children of this SCC to its children.
void AddChildren(SCC* scc) {
- std::set<const SCC*> seen;
+ y_absl::flat_hash_set<const SCC*> seen;
for (auto descriptor : scc->descriptors) {
for (auto child_msg : DepsGenerator()(descriptor)) {
- GOOGLE_CHECK(child_msg);
+ Y_ABSL_CHECK(child_msg);
const SCC* child = GetSCC(child_msg);
if (child == scc) continue;
if (seen.insert(child).second) {
@@ -151,15 +159,12 @@ class PROTOC_EXPORT SCCAnalyzer {
}
}
}
-
- // This is necessary for compiler bug in msvc2015.
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SCCAnalyzer);
};
} // namespace compiler
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_SCC_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.cc b/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.cc
index d09ceed9dc2..639f01b734e 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.cc
@@ -30,7 +30,7 @@
// Author: [email protected] (Kenton Varda)
-#include <google/protobuf/compiler/subprocess.h>
+#include "google/protobuf/compiler/subprocess.h"
#include <algorithm>
#include <cstring>
@@ -43,31 +43,24 @@
#include <sys/wait.h>
#endif
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/substitute.h>
-#include <google/protobuf/message.h>
+#include "y_absl/log/absl_check.h"
+#include "y_absl/log/absl_log.h"
+#include "y_absl/strings/escaping.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/substitute.h"
+#include "google/protobuf/io/io_win32.h"
+#include "google/protobuf/message.h"
namespace google {
namespace protobuf {
namespace compiler {
-namespace {
-char* portable_strdup(const char* s) {
- char* ns = (char*)malloc(strlen(s) + 1);
- if (ns != nullptr) {
- strcpy(ns, s);
- }
- return ns;
-}
-} // namespace
-
#ifdef _WIN32
static void CloseHandleOrDie(HANDLE handle) {
if (!CloseHandle(handle)) {
- GOOGLE_LOG(FATAL) << "CloseHandle: "
- << Subprocess::Win32ErrorMessage(GetLastError());
+ Y_ABSL_LOG(FATAL) << "CloseHandle: "
+ << Subprocess::Win32ErrorMessage(GetLastError());
}
}
@@ -94,26 +87,26 @@ void Subprocess::Start(const TProtoStringType& program, SearchMode search_mode)
HANDLE stdout_pipe_write;
if (!CreatePipe(&stdin_pipe_read, &stdin_pipe_write, nullptr, 0)) {
- GOOGLE_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError());
+ Y_ABSL_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError());
}
if (!CreatePipe(&stdout_pipe_read, &stdout_pipe_write, nullptr, 0)) {
- GOOGLE_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError());
+ Y_ABSL_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError());
}
// Make child side of the pipes inheritable.
if (!SetHandleInformation(stdin_pipe_read, HANDLE_FLAG_INHERIT,
HANDLE_FLAG_INHERIT)) {
- GOOGLE_LOG(FATAL) << "SetHandleInformation: "
- << Win32ErrorMessage(GetLastError());
+ Y_ABSL_LOG(FATAL) << "SetHandleInformation: "
+ << Win32ErrorMessage(GetLastError());
}
if (!SetHandleInformation(stdout_pipe_write, HANDLE_FLAG_INHERIT,
HANDLE_FLAG_INHERIT)) {
- GOOGLE_LOG(FATAL) << "SetHandleInformation: "
- << Win32ErrorMessage(GetLastError());
+ Y_ABSL_LOG(FATAL) << "SetHandleInformation: "
+ << Win32ErrorMessage(GetLastError());
}
// Setup STARTUPINFO to redirect handles.
- STARTUPINFOA startup_info;
+ STARTUPINFOW startup_info;
ZeroMemory(&startup_info, sizeof(startup_info));
startup_info.cb = sizeof(startup_info);
startup_info.dwFlags = STARTF_USESTDHANDLES;
@@ -122,20 +115,33 @@ void Subprocess::Start(const TProtoStringType& program, SearchMode search_mode)
startup_info.hStdError = GetStdHandle(STD_ERROR_HANDLE);
if (startup_info.hStdError == INVALID_HANDLE_VALUE) {
- GOOGLE_LOG(FATAL) << "GetStdHandle: " << Win32ErrorMessage(GetLastError());
+ Y_ABSL_LOG(FATAL) << "GetStdHandle: " << Win32ErrorMessage(GetLastError());
+ }
+
+ // get wide string version of program as the path may contain non-ascii characters
+ std::wstring wprogram;
+ if (!io::win32::strings::utf8_to_wcs(program.c_str(), &wprogram)) {
+ Y_ABSL_LOG(FATAL) << "utf8_to_wcs: " << Win32ErrorMessage(GetLastError());
}
// Invoking cmd.exe allows for '.bat' files from the path as well as '.exe'.
+ TProtoStringType command_line = y_absl::StrCat("cmd.exe /c \"", program, "\"");
+
+ // get wide string version of command line as the path may contain non-ascii characters
+ std::wstring wcommand_line;
+ if (!io::win32::strings::utf8_to_wcs(command_line.c_str(), &wcommand_line)) {
+ Y_ABSL_LOG(FATAL) << "utf8_to_wcs: " << Win32ErrorMessage(GetLastError());
+ }
+
// Using a malloc'ed string because CreateProcess() can mutate its second
// parameter.
- char* command_line =
- portable_strdup(("cmd.exe /c \"" + program + "\"").c_str());
+ wchar_t *wcommand_line_copy = _wcsdup(wcommand_line.c_str());
// Create the process.
PROCESS_INFORMATION process_info;
- if (CreateProcessA((search_mode == SEARCH_PATH) ? nullptr : program.c_str(),
- (search_mode == SEARCH_PATH) ? command_line : nullptr,
+ if (CreateProcessW((search_mode == SEARCH_PATH) ? nullptr : wprogram.c_str(),
+ (search_mode == SEARCH_PATH) ? wcommand_line_copy : NULL,
nullptr, // process security attributes
nullptr, // thread security attributes
TRUE, // inherit handles?
@@ -155,7 +161,7 @@ void Subprocess::Start(const TProtoStringType& program, SearchMode search_mode)
CloseHandleOrDie(stdin_pipe_read);
CloseHandleOrDie(stdout_pipe_write);
- free(command_line);
+ free(wcommand_line_copy);
}
bool Subprocess::Communicate(const Message& input, Message* output,
@@ -165,7 +171,7 @@ bool Subprocess::Communicate(const Message& input, Message* output,
return false;
}
- GOOGLE_CHECK(child_handle_ != nullptr) << "Must call Start() first.";
+ Y_ABSL_CHECK(child_handle_ != nullptr) << "Must call Start() first.";
TProtoStringType input_data;
if (!input.SerializeToString(&input_data)) {
@@ -195,11 +201,11 @@ bool Subprocess::Communicate(const Message& input, Message* output,
wait_result < WAIT_OBJECT_0 + handle_count) {
signaled_handle = handles[wait_result - WAIT_OBJECT_0];
} else if (wait_result == WAIT_FAILED) {
- GOOGLE_LOG(FATAL) << "WaitForMultipleObjects: "
- << Win32ErrorMessage(GetLastError());
+ Y_ABSL_LOG(FATAL) << "WaitForMultipleObjects: "
+ << Win32ErrorMessage(GetLastError());
} else {
- GOOGLE_LOG(FATAL) << "WaitForMultipleObjects: Unexpected return code: "
- << wait_result;
+ Y_ABSL_LOG(FATAL) << "WaitForMultipleObjects: Unexpected return code: "
+ << wait_result;
}
if (signaled_handle == child_stdin_) {
@@ -242,29 +248,30 @@ bool Subprocess::Communicate(const Message& input, Message* output,
DWORD wait_result = WaitForSingleObject(child_handle_, INFINITE);
if (wait_result == WAIT_FAILED) {
- GOOGLE_LOG(FATAL) << "WaitForSingleObject: "
- << Win32ErrorMessage(GetLastError());
+ Y_ABSL_LOG(FATAL) << "WaitForSingleObject: "
+ << Win32ErrorMessage(GetLastError());
} else if (wait_result != WAIT_OBJECT_0) {
- GOOGLE_LOG(FATAL) << "WaitForSingleObject: Unexpected return code: "
- << wait_result;
+ Y_ABSL_LOG(FATAL) << "WaitForSingleObject: Unexpected return code: "
+ << wait_result;
}
DWORD exit_code;
if (!GetExitCodeProcess(child_handle_, &exit_code)) {
- GOOGLE_LOG(FATAL) << "GetExitCodeProcess: "
- << Win32ErrorMessage(GetLastError());
+ Y_ABSL_LOG(FATAL) << "GetExitCodeProcess: "
+ << Win32ErrorMessage(GetLastError());
}
CloseHandleOrDie(child_handle_);
child_handle_ = nullptr;
if (exit_code != 0) {
- *error = strings::Substitute("Plugin failed with status code $0.", exit_code);
+ *error = y_absl::Substitute("Plugin failed with status code $0.", exit_code);
return false;
}
if (!output->ParseFromString(output_data)) {
- *error = "Plugin output is unparseable: " + CEscape(output_data);
+ *error = y_absl::StrCat("Plugin output is unparseable: ",
+ y_absl::CEscape(output_data));
return false;
}
@@ -303,6 +310,16 @@ Subprocess::~Subprocess() {
}
}
+namespace {
+char* portable_strdup(const char* s) {
+ char* ns = (char*)malloc(strlen(s) + 1);
+ if (ns != nullptr) {
+ strcpy(ns, s);
+ }
+ return ns;
+}
+} // namespace
+
void Subprocess::Start(const TProtoStringType& program, SearchMode search_mode) {
// Note that we assume that there are no other threads, thus we don't have to
// do crazy stuff like using socket pairs or avoiding libc locks.
@@ -311,14 +328,14 @@ void Subprocess::Start(const TProtoStringType& program, SearchMode search_mode)
int stdin_pipe[2];
int stdout_pipe[2];
- GOOGLE_CHECK(pipe(stdin_pipe) != -1);
- GOOGLE_CHECK(pipe(stdout_pipe) != -1);
+ Y_ABSL_CHECK(pipe(stdin_pipe) != -1);
+ Y_ABSL_CHECK(pipe(stdout_pipe) != -1);
char* argv[2] = {portable_strdup(program.c_str()), nullptr};
child_pid_ = fork();
if (child_pid_ == -1) {
- GOOGLE_LOG(FATAL) << "fork: " << strerror(errno);
+ Y_ABSL_LOG(FATAL) << "fork: " << strerror(errno);
} else if (child_pid_ == 0) {
// We are the child.
dup2(stdin_pipe[0], STDIN_FILENO);
@@ -365,7 +382,7 @@ void Subprocess::Start(const TProtoStringType& program, SearchMode search_mode)
bool Subprocess::Communicate(const Message& input, Message* output,
TProtoStringType* error) {
- GOOGLE_CHECK_NE(child_stdin_, -1) << "Must call Start() first.";
+ Y_ABSL_CHECK_NE(child_stdin_, -1) << "Must call Start() first.";
// The "sighandler_t" typedef is GNU-specific, so define our own.
typedef void SignalHandler(int);
@@ -400,7 +417,7 @@ bool Subprocess::Communicate(const Message& input, Message* output,
// Interrupted by signal. Try again.
continue;
} else {
- GOOGLE_LOG(FATAL) << "select: " << strerror(errno);
+ Y_ABSL_LOG(FATAL) << "select: " << strerror(errno);
}
}
@@ -446,7 +463,7 @@ bool Subprocess::Communicate(const Message& input, Message* output,
int status;
while (waitpid(child_pid_, &status, 0) == -1) {
if (errno != EINTR) {
- GOOGLE_LOG(FATAL) << "waitpid: " << strerror(errno);
+ Y_ABSL_LOG(FATAL) << "waitpid: " << strerror(errno);
}
}
@@ -457,12 +474,12 @@ bool Subprocess::Communicate(const Message& input, Message* output,
if (WEXITSTATUS(status) != 0) {
int error_code = WEXITSTATUS(status);
*error =
- strings::Substitute("Plugin failed with status code $0.", error_code);
+ y_absl::Substitute("Plugin failed with status code $0.", error_code);
return false;
}
} else if (WIFSIGNALED(status)) {
int signal = WTERMSIG(status);
- *error = strings::Substitute("Plugin killed by signal $0.", signal);
+ *error = y_absl::Substitute("Plugin killed by signal $0.", signal);
return false;
} else {
*error = "Neither WEXITSTATUS nor WTERMSIG is true?";
@@ -470,7 +487,8 @@ bool Subprocess::Communicate(const Message& input, Message* output,
}
if (!output->ParseFromString(output_data)) {
- *error = "Plugin output is unparseable: " + CEscape(output_data);
+ *error = y_absl::StrCat("Plugin output is unparseable: ",
+ y_absl::CEscape(output_data));
return false;
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.h b/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.h
index a6a320ab47a..6289462e98f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.h
@@ -42,12 +42,12 @@
#include <sys/types.h>
#include <unistd.h>
#endif // !_WIN32
-#include <google/protobuf/stubs/common.h>
-
#include <string>
+#include "google/protobuf/port.h"
+
// Must be included last.
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
namespace google {
namespace protobuf {
@@ -109,6 +109,6 @@ class PROTOC_EXPORT Subprocess {
} // namespace protobuf
} // namespace google
-#include <google/protobuf/port_undef.inc>
+#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_COMPILER_SUBPROCESS_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.cc b/contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.cc
index 37feced21f8..415eb94f86e 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.cc
@@ -33,11 +33,11 @@
//
// Based on http://www.pkware.com/documents/casestudies/APPNOTE.TXT
-#include <google/protobuf/compiler/zip_writer.h>
+#include "google/protobuf/compiler/zip_writer.h"
#include <cstdint>
-#include <google/protobuf/io/coded_stream.h>
+#include "google/protobuf/io/coded_stream.h"
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.h b/contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.h
index c25a1e096aa..1adc578539a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.h
@@ -35,8 +35,8 @@
#include <cstdint>
#include <vector>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/io/zero_copy_stream.h>
+#include "google/protobuf/stubs/common.h"
+#include "google/protobuf/io/zero_copy_stream.h"
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/ya.make b/contrib/libs/protoc/ya.make
index 5af83f2258b..e735366ab4e 100644
--- a/contrib/libs/protoc/ya.make
+++ b/contrib/libs/protoc/ya.make
@@ -9,9 +9,9 @@ LICENSE(
PROVIDES(protoc)
-VERSION(3.21.3)
+VERSION(3.22.5)
-ORIGINAL_SOURCE(https://github.com/protocolbuffers/protobuf/archive/v3.21.3.tar.gz)
+ORIGINAL_SOURCE(https://github.com/protocolbuffers/protobuf/archive/v3.22.5.tar.gz)
IF (OPENSOURCE_REPLACE_PROTOBUF AND EXPORT_CMAKE)
OPENSOURCE_EXPORT_REPLACEMENT(
@@ -41,6 +41,10 @@ PEERDIR(
contrib/libs/protobuf
)
+ADDINCL(
+ contrib/libs/protobuf/third_party/utf8_range
+)
+
NO_COMPILER_WARNINGS()
NO_UTIL()
@@ -54,20 +58,21 @@ SRCS(
src/google/protobuf/compiler/code_generator.cc
src/google/protobuf/compiler/command_line_interface.cc
src/google/protobuf/compiler/cpp/enum.cc
- src/google/protobuf/compiler/cpp/enum_field.cc
src/google/protobuf/compiler/cpp/extension.cc
src/google/protobuf/compiler/cpp/field.cc
+ src/google/protobuf/compiler/cpp/field_generators/enum_field.cc
+ src/google/protobuf/compiler/cpp/field_generators/map_field.cc
+ src/google/protobuf/compiler/cpp/field_generators/message_field.cc
+ src/google/protobuf/compiler/cpp/field_generators/primitive_field.cc
+ src/google/protobuf/compiler/cpp/field_generators/string_field.cc
src/google/protobuf/compiler/cpp/file.cc
src/google/protobuf/compiler/cpp/generator.cc
src/google/protobuf/compiler/cpp/helpers.cc
- src/google/protobuf/compiler/cpp/map_field.cc
src/google/protobuf/compiler/cpp/message.cc
- src/google/protobuf/compiler/cpp/message_field.cc
src/google/protobuf/compiler/cpp/padding_optimizer.cc
src/google/protobuf/compiler/cpp/parse_function_generator.cc
- src/google/protobuf/compiler/cpp/primitive_field.cc
src/google/protobuf/compiler/cpp/service.cc
- src/google/protobuf/compiler/cpp/string_field.cc
+ src/google/protobuf/compiler/cpp/tracker.cc
src/google/protobuf/compiler/csharp/csharp_doc_comment.cc
src/google/protobuf/compiler/csharp/csharp_enum.cc
src/google/protobuf/compiler/csharp/csharp_enum_field.cc
@@ -84,6 +89,7 @@ SRCS(
src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc
src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc
src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc
+ src/google/protobuf/compiler/csharp/names.cc
src/google/protobuf/compiler/importer.cc
src/google/protobuf/compiler/java/context.cc
src/google/protobuf/compiler/java/doc_comment.cc
@@ -107,32 +113,40 @@ SRCS(
src/google/protobuf/compiler/java/message_field.cc
src/google/protobuf/compiler/java/message_field_lite.cc
src/google/protobuf/compiler/java/message_lite.cc
+ src/google/protobuf/compiler/java/message_serialization.cc
src/google/protobuf/compiler/java/name_resolver.cc
+ src/google/protobuf/compiler/java/names.cc
src/google/protobuf/compiler/java/primitive_field.cc
src/google/protobuf/compiler/java/primitive_field_lite.cc
src/google/protobuf/compiler/java/service.cc
src/google/protobuf/compiler/java/shared_code_generator.cc
src/google/protobuf/compiler/java/string_field.cc
src/google/protobuf/compiler/java/string_field_lite.cc
- src/google/protobuf/compiler/objectivec/objectivec_enum.cc
- src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc
- src/google/protobuf/compiler/objectivec/objectivec_extension.cc
- src/google/protobuf/compiler/objectivec/objectivec_field.cc
- src/google/protobuf/compiler/objectivec/objectivec_file.cc
- src/google/protobuf/compiler/objectivec/objectivec_generator.cc
- src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
- src/google/protobuf/compiler/objectivec/objectivec_map_field.cc
- src/google/protobuf/compiler/objectivec/objectivec_message.cc
- src/google/protobuf/compiler/objectivec/objectivec_message_field.cc
- src/google/protobuf/compiler/objectivec/objectivec_oneof.cc
- src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc
+ src/google/protobuf/compiler/objectivec/enum.cc
+ src/google/protobuf/compiler/objectivec/enum_field.cc
+ src/google/protobuf/compiler/objectivec/extension.cc
+ src/google/protobuf/compiler/objectivec/field.cc
+ src/google/protobuf/compiler/objectivec/file.cc
+ src/google/protobuf/compiler/objectivec/generator.cc
+ src/google/protobuf/compiler/objectivec/helpers.cc
+ src/google/protobuf/compiler/objectivec/import_writer.cc
+ src/google/protobuf/compiler/objectivec/line_consumer.cc
+ src/google/protobuf/compiler/objectivec/map_field.cc
+ src/google/protobuf/compiler/objectivec/message.cc
+ src/google/protobuf/compiler/objectivec/message_field.cc
+ src/google/protobuf/compiler/objectivec/names.cc
+ src/google/protobuf/compiler/objectivec/oneof.cc
+ src/google/protobuf/compiler/objectivec/primitive_field.cc
+ src/google/protobuf/compiler/objectivec/text_format_decode_data.cc
src/google/protobuf/compiler/parser.cc
+ src/google/protobuf/compiler/php/names.cc
src/google/protobuf/compiler/php/php_generator.cc
src/google/protobuf/compiler/plugin.cc
src/google/protobuf/compiler/plugin.pb.cc
src/google/protobuf/compiler/python/generator.cc
src/google/protobuf/compiler/python/helpers.cc
src/google/protobuf/compiler/python/pyi_generator.cc
+ src/google/protobuf/compiler/retention.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
deleted file mode 100644
index 11099f6d547..00000000000
--- a/contrib/python/protobuf/py3/.dist-info/METADATA
+++ /dev/null
@@ -1,21 +0,0 @@
-Metadata-Version: 2.1
-Name: protobuf
-Version: 4.21.7
-Summary: Protocol Buffers
-Home-page: https://developers.google.com/protocol-buffers/
-Download-URL: https://github.com/protocolbuffers/protobuf/releases
-Maintainer: [email protected]
-Maintainer-email: [email protected]
-License: BSD-3-Clause
-Platform: UNKNOWN
-Classifier: Programming Language :: Python
-Classifier: Programming Language :: Python :: 3
-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.7
-License-File: LICENSE
-
-Protocol Buffers are Google's data interchange format
-
diff --git a/contrib/python/protobuf/py3/.dist-info/top_level.txt b/contrib/python/protobuf/py3/.dist-info/top_level.txt
deleted file mode 100644
index cb429113e0f..00000000000
--- a/contrib/python/protobuf/py3/.dist-info/top_level.txt
+++ /dev/null
@@ -1 +0,0 @@
-google
diff --git a/contrib/python/protobuf/py3/CODE_OF_CONDUCT.md b/contrib/python/protobuf/py3/CODE_OF_CONDUCT.md
new file mode 100644
index 00000000000..ba190630834
--- /dev/null
+++ b/contrib/python/protobuf/py3/CODE_OF_CONDUCT.md
@@ -0,0 +1,3 @@
+This project is governed by
+[Protobuf's Code of Conduct](https://github.com/protocolbuffers/.github/blob/main/profile/CODE_OF_CONDUCT.md).
+
diff --git a/contrib/python/protobuf/py3/CONTRIBUTING.md b/contrib/python/protobuf/py3/CONTRIBUTING.md
new file mode 100644
index 00000000000..a16d63c65f3
--- /dev/null
+++ b/contrib/python/protobuf/py3/CONTRIBUTING.md
@@ -0,0 +1,120 @@
+# Contributing to Protocol Buffers
+
+We welcome some types of contributions to protocol buffers. This doc describes the
+process to contribute patches to protobuf and the general guidelines we
+expect contributors to follow.
+
+## What We Accept
+
+* Bug fixes with unit tests demonstrating the problem are very welcome.
+ We also appreciate bug reports, even when they don't come with a patch.
+ Bug fixes without tests are usually not accepted.
+* New APIs and features with adequate test coverage and documentation
+ may be accepted if they do not compromise backwards
+ compatibility. However there's a fairly high bar of usefulness a new public
+ method must clear before it will be accepted. Features that are fine in
+ isolation are often rejected because they don't have enough impact to justify the
+ conceptual burden and ongoing maintenance cost. It's best to file an issue
+ and get agreement from maintainers on the value of a new feature before
+ working on a PR.
+* Performance optimizations may be accepted if they have convincing benchmarks that demonstrate
+ an improvement and they do not significantly increase complexity.
+* Changes to existing APIs are almost never accepted. Stability and
+ backwards compatibility are paramount. In the unlikely event a breaking change
+ is required, it must usually be implemented in google3 first.
+* Changes to the wire and text formats are never accepted. Any breaking change
+ to these formats would have to be implemented as a completely new format.
+ We cannot begin generating protos that cannot be parsed by existing code.
+
+## Before You Start
+
+We accept patches in the form of github pull requests. If you are new to
+github, please read [How to create github pull requests](https://help.github.com/articles/about-pull-requests/)
+first.
+
+### Contributor License Agreements
+
+Contributions to this project must be accompanied by a Contributor License
+Agreement. You (or your employer) retain the copyright to your contribution,
+this simply gives us permission to use and redistribute your contributions
+as part of the project.
+
+* If you are an individual writing original source code and you're sure you
+ own the intellectual property, then you'll need to sign an [individual CLA](https://cla.developers.google.com/about/google-individual?csw=1).
+* If you work for a company that wants to allow you to contribute your work,
+ then you'll need to sign a [corporate CLA](https://cla.developers.google.com/about/google-corporate?csw=1).
+
+### Coding Style
+
+This project follows [Google’s Coding Style Guides](https://github.com/google/styleguide).
+Before sending out your pull request, please familiarize yourself with the
+corresponding style guides and make sure the proposed code change is style
+conforming.
+
+## Contributing Process
+
+Most pull requests should go to the main branch and the change will be
+included in the next major/minor version release (e.g., 3.6.0 release). If you
+need to include a bug fix in a patch release (e.g., 3.5.2), make sure it’s
+already merged to main, and then create a pull request cherry-picking the
+commits from main branch to the release branch (e.g., branch 3.5.x).
+
+For each pull request, a protobuf team member will be assigned to review the
+pull request. For minor cleanups, the pull request may be merged right away
+after an initial review. For larger changes, you will likely receive multiple
+rounds of comments and it may take some time to complete. We will try to keep
+our response time within 7-days but if you don’t get any response in a few
+days, feel free to comment on the threads to get our attention. We also expect
+you to respond to our comments within a reasonable amount of time. If we don’t
+hear from you for 2 weeks or longer, we may close the pull request. You can
+still send the pull request again once you have time to work on it.
+
+Once a pull request is merged, we will take care of the rest and get it into
+the final release.
+
+## Pull Request Guidelines
+
+* If you are a Googler, it is preferable to first create an internal CL and
+ have it reviewed and submitted. The code propagation process will deliver the
+ change to GitHub.
+* Create small PRs that are narrowly focused on addressing a single concern.
+ We often receive PRs that are trying to fix several things at a time, but if
+ only one fix is considered acceptable, nothing gets merged and both author's
+ & reviewer's time is wasted. Create more PRs to address different concerns and
+ everyone will be happy.
+* For speculative changes, consider opening an issue and discussing it first.
+ If you are suggesting a behavioral or API change, make sure you get explicit
+ support from a protobuf team member before sending us the pull request.
+* Provide a good PR description as a record of what change is being made and
+ why it was made. Link to a GitHub issue if it exists.
+* Don't fix code style and formatting unless you are already changing that
+ line to address an issue. PRs with irrelevant changes won't be merged. If
+ you do want to fix formatting or style, do that in a separate PR.
+* Unless your PR is trivial, you should expect there will be reviewer comments
+ that you'll need to address before merging. We expect you to be reasonably
+ responsive to those comments, otherwise the PR will be closed after 2-3 weeks
+ of inactivity.
+* Maintain clean commit history and use meaningful commit messages. PRs with
+ messy commit history are difficult to review and won't be merged. Use rebase
+ -i upstream/main to curate your commit history and/or to bring in latest
+ changes from main (but avoid rebasing in the middle of a code review).
+* Keep your PR up to date with upstream/main (if there are merge conflicts,
+ we can't really merge your change).
+* All tests need to be passing before your change can be merged. We recommend
+ you run tests locally before creating your PR to catch breakages early on.
+ Ultimately, the green signal will be provided by our testing infrastructure.
+ The reviewer will help you if there are test failures that seem not related
+ to the change you are making.
+
+## Reviewer Guidelines
+
+* Make sure that all tests are passing before approval.
+* Apply the "release notes: yes" label if the pull request's description should
+ be included in the next release (e.g., any new feature / bug fix).
+ Apply the "release notes: no" label if the pull request's description should
+ not be included in the next release (e.g., refactoring changes that does not
+ change behavior, integration from Google internal, updating tests, etc.).
+* Apply the appropriate language label (e.g., C++, Java, Python, etc.) to the
+ pull request. This will make it easier to identify which languages the pull
+ request affects, allowing us to better identify appropriate reviewer, create
+ a better release note, and make it easier to identify issues in the future.
diff --git a/contrib/python/protobuf/py3/CONTRIBUTORS.txt b/contrib/python/protobuf/py3/CONTRIBUTORS.txt
new file mode 100644
index 00000000000..c2da98f2c6c
--- /dev/null
+++ b/contrib/python/protobuf/py3/CONTRIBUTORS.txt
@@ -0,0 +1,107 @@
+This file contains a list of people who have made large contributions
+to the public version of Protocol Buffers.
+
+Original Protocol Buffers design and implementation:
+ Sanjay Ghemawat <[email protected]>
+ Jeff Dean <[email protected]>
+ Daniel Dulitz <[email protected]>
+ Craig Silverstein
+ Paul Haahr <[email protected]>
+ Corey Anderson <[email protected]>
+ (and many others)
+
+Proto2 C++ and Java primary author:
+ Kenton Varda <[email protected]>
+
+Proto2 Python primary authors:
+ Will Robinson <[email protected]>
+ Petar Petrov <[email protected]>
+
+Java Nano primary authors:
+ Brian Duff <[email protected]>
+ Tom Chao <[email protected]>
+ Max Cai <[email protected]>
+ Ulas Kirazci <[email protected]>
+
+Large code contributions:
+ Jason Hsueh <[email protected]>
+ Joseph Schorr <[email protected]>
+ Wenbo Zhu <[email protected]>
+
+Large quantity of code reviews:
+ Scott Bruce <[email protected]>
+ Frank Yellin
+ Neal Norwitz <[email protected]>
+ Jeffrey Yasskin <[email protected]>
+ Ambrose Feinstein <[email protected]>
+
+Documentation:
+ Lisa Carey <[email protected]>
+
+Maven packaging:
+ Gregory Kick <[email protected]>
+
+Patch contributors:
+ Kevin Ko <[email protected]>
+ * Small patch to handle trailing slashes in --proto_path flag.
+ Johan Euphrosine <[email protected]>
+ * Small patch to fix Python CallMethod().
+ Ulrich Kunitz <[email protected]>
+ * Small optimizations to Python serialization.
+ Leandro Lucarella <[email protected]>
+ * VI syntax highlighting tweaks.
+ * Fix compiler to not make output executable.
+ Dilip Joseph <[email protected]>
+ * Heuristic detection of sub-messages when printing unknown fields in
+ text format.
+ Brian Atkinson <[email protected]>
+ * Added @Override annotation to generated Java code where appropriate.
+ Vincent Choinière <[email protected]>
+ * Tru64 support.
+ Monty Taylor <[email protected]>
+ * Solaris 10 + Sun Studio fixes.
+ Alek Storm <[email protected]>
+ * Slicing support for repeated scalar fields for the Python API.
+ Oleg Smolsky <[email protected]>
+ * MS Visual Studio error format option.
+ * Detect unordered_map in stl_hash.m4.
+ Brian Olson <[email protected]>
+ * gzip/zlib I/O support.
+ Michael Poole <[email protected]>
+ * Fixed warnings about generated constructors not explicitly initializing
+ all fields (only present with certain compiler settings).
+ * Added generation of field number constants.
+ Wink Saville <[email protected]>
+ * Fixed initialization ordering problem in logging code.
+ Will Pierce <[email protected]>
+ * Small patch improving performance of in Python serialization.
+ Alexandre Vassalotti <[email protected]>
+ * Emacs mode for Protocol Buffers (editors/protobuf-mode.el).
+ Scott Stafford <[email protected]>
+ * Added Swap(), SwapElements(), and RemoveLast() to Reflection interface.
+ Alexander Melnikov <[email protected]>
+ * HPUX support.
+ Oliver Jowett <[email protected]>
+ * Detect whether zlib is new enough in configure script.
+ * Fixes for Solaris 10 32/64-bit confusion.
+ Evan Jones <[email protected]>
+ * Optimize Java serialization code when writing a small message to a stream.
+ * Optimize Java serialization of strings so that UTF-8 encoding happens only
+ once per string per serialization call.
+ * Clean up some Java warnings.
+ * Fix bug with permanent callbacks that delete themselves when run.
+ Michael Kucharski <[email protected]>
+ * Added CodedInputStream.getTotalBytesRead().
+ Kacper Kowalik <[email protected]>
+ * Fixed m4/acx_pthread.m4 problem for some Linux distributions.
+ William Orr <[email protected]>
+ * Fixed detection of sched_yield on Solaris.
+ * Added atomicops for Solaris
+ Andrew Paprocki <[email protected]>
+ * Fixed minor IBM xlC compiler build issues
+ * Added atomicops for AIX (POWER)
+ Nipunn Koorapati <[email protected]>
+ * Provide a type alias field ValueType on EnumTypeWrapper
+ * Match service argument names to abstract interface
+
+
diff --git a/contrib/python/protobuf/py3/README.md b/contrib/python/protobuf/py3/README.md
index 27f22c82c08..3bfeb0f1690 100644
--- a/contrib/python/protobuf/py3/README.md
+++ b/contrib/python/protobuf/py3/README.md
@@ -3,128 +3,80 @@ Protocol Buffers - Google's data interchange format
Copyright 2008 Google Inc.
-This directory contains the Python Protocol Buffers runtime library.
+[Protocol Buffers documentation](https://developers.google.com/protocol-buffers/)
-Normally, this directory comes as part of the protobuf package, available
-from:
+Overview
+--------
- https://developers.google.com/protocol-buffers/
+Protocol Buffers (a.k.a., protobuf) are Google's language-neutral,
+platform-neutral, extensible mechanism for serializing structured data. You
+can find [protobuf's documentation on the Google Developers site](https://developers.google.com/protocol-buffers/).
-The complete package includes the C++ source code, which includes the
-Protocol Compiler (protoc). If you downloaded this package from PyPI
-or some other Python-specific source, you may have received only the
-Python part of the code. In this case, you will need to obtain the
-Protocol Compiler from some other source before you can use this
-package.
+This README file contains protobuf installation instructions. To install
+protobuf, you need to install the protocol compiler (used to compile .proto
+files) and the protobuf runtime for your chosen programming language.
-Development Warning
-===================
+Protocol Compiler Installation
+------------------------------
-The pure python performance is slow. For better performance please
-use python c++ implementation.
+The protocol compiler is written in C++. If you are using C++, please follow
+the [C++ Installation Instructions](src/README.md) to install protoc along
+with the C++ runtime.
-Installation
-============
+For non-C++ users, the simplest way to install the protocol compiler is to
+download a pre-built binary from our [GitHub release page](https://github.com/protocolbuffers/protobuf/releases).
-1) Make sure you have Python 3.7 or newer. If in doubt, run:
+In the downloads section of each release, you can find pre-built binaries in
+zip packages: `protoc-$VERSION-$PLATFORM.zip`. It contains the protoc binary
+as well as a set of standard `.proto` files distributed along with protobuf.
- $ python -V
+If you are looking for an old version that is not available in the release
+page, check out the [Maven repository](https://repo1.maven.org/maven2/com/google/protobuf/protoc/).
-2) If you do not have setuptools installed, note that it will be
- downloaded and installed automatically as soon as you run `setup.py`.
- If you would rather install it manually, you may do so by following
- the instructions on [this page](https://packaging.python.org/en/latest/installing.html#setup-for-installing-packages).
+These pre-built binaries are only provided for released versions. If you want
+to use the github main version at HEAD, or you need to modify protobuf code,
+or you are using C++, it's recommended to build your own protoc binary from
+source.
-3) Build the C++ code, or install a binary distribution of `protoc`. If
- you install a binary distribution, make sure that it is the same
- version as this package. If in doubt, run:
+If you would like to build protoc binary from source, see the [C++ Installation Instructions](src/README.md).
- $ protoc --version
+Protobuf Runtime Installation
+-----------------------------
-4) Build and run the tests:
+Protobuf supports several different programming languages. For each programming
+language, you can find instructions in the corresponding source directory about
+how to install protobuf runtime for that specific language:
- $ python setup.py build
- $ python setup.py test
+| Language | Source |
+|--------------------------------------|-------------------------------------------------------------|
+| C++ (include C++ runtime and protoc) | [src](src) |
+| Java | [java](java) |
+| Python | [python](python) |
+| Objective-C | [objectivec](objectivec) |
+| C# | [csharp](csharp) |
+| Ruby | [ruby](ruby) |
+| Go | [protocolbuffers/protobuf-go](https://github.com/protocolbuffers/protobuf-go)|
+| PHP | [php](php) |
+| Dart | [dart-lang/protobuf](https://github.com/dart-lang/protobuf) |
+| Javascript | [protocolbuffers/protobuf-javascript](https://github.com/protocolbuffers/protobuf-javascript)|
- To build, test, and use the C++ implementation, you must first compile
- `libprotobuf.so`:
+Quick Start
+-----------
- $ (cd .. && make)
+The best way to learn how to use protobuf is to follow the [tutorials in our
+developer guide](https://developers.google.com/protocol-buffers/docs/tutorials).
- On OS X:
+If you want to learn from code examples, take a look at the examples in the
+[examples](examples) directory.
- If you are running a Homebrew-provided Python, you must make sure another
- version of protobuf is not already installed, as Homebrew's Python will
- search `/usr/local/lib` for `libprotobuf.so` before it searches
- `../src/.libs`.
+Documentation
+-------------
- You can either unlink Homebrew's protobuf or install the `libprotobuf` you
- built earlier:
+The complete documentation is available via the [Protocol Buffers documentation](https://developers.google.com/protocol-buffers/).
- $ brew unlink protobuf
+Developer Community
+-------------------
- or
+To be alerted to upcoming changes in Protocol Buffers and connect with protobuf developers and users,
+[join the Google Group](https://groups.google.com/g/protobuf).
- $ (cd .. && make install)
-
- On other *nix:
-
- You must make `libprotobuf.so` dynamically available. You can either
- install libprotobuf you built earlier, or set `LD_LIBRARY_PATH`:
-
- $ export LD_LIBRARY_PATH=../src/.libs
-
- or
-
- $ (cd .. && make install)
-
- To build the C++ implementation run:
-
- $ python setup.py build --cpp_implementation
-
- Then run the tests like so:
-
- $ python setup.py test --cpp_implementation
-
- If some tests fail, this library may not work correctly on your
- system. Continue at your own risk.
-
- Please note that there is a known problem with some versions of
- Python on Cygwin which causes the tests to fail after printing the
- error: `sem_init: Resource temporarily unavailable`. This appears
- to be a [bug either in Cygwin or in
- Python](http://www.cygwin.com/ml/cygwin/2005-07/msg01378.html).
-
- We do not know if or when it might be fixed. We also do not know
- how likely it is that this bug will affect users in practice.
-
-5) Install:
-
- $ python setup.py install
-
- or:
-
- $ (cd .. && make install)
- $ python setup.py install --cpp_implementation
-
- This step may require superuser privileges.
- NOTE: To use C++ implementation, you need to export an environment
- variable before running your program. See the "C++ Implementation"
- section below for more details.
-
-Usage
-=====
-
-The complete documentation for Protocol Buffers is available via the
-web at:
-
- https://developers.google.com/protocol-buffers/
-
-C++ Implementation
-==================
-
-The C++ implementation for Python messages is built as a Python extension to
-improve the overall protobuf Python performance.
-
-To use the C++ implementation, you need to install the C++ protobuf runtime
-library, please see instructions in the parent directory.
diff --git a/contrib/python/protobuf/py3/SECURITY.md b/contrib/python/protobuf/py3/SECURITY.md
new file mode 100644
index 00000000000..76a40ee066a
--- /dev/null
+++ b/contrib/python/protobuf/py3/SECURITY.md
@@ -0,0 +1,4 @@
+To report security concerns or vulnerabilities within protobuf, please use
+Google's official channel for reporting these.
+
+https://www.google.com/appserve/security-bugs/m2/new
diff --git a/contrib/python/protobuf/py3/google/protobuf/__init__.py b/contrib/python/protobuf/py3/google/protobuf/__init__.py
index 70d564a90aa..43ce1a25eba 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__ = '4.21.7'
+__version__ = '4.22.5'
diff --git a/contrib/python/protobuf/py3/google/protobuf/descriptor.py b/contrib/python/protobuf/py3/google/protobuf/descriptor.py
index f5a0caa6bda..fcb87cab558 100644
--- a/contrib/python/protobuf/py3/google/protobuf/descriptor.py
+++ b/contrib/python/protobuf/py3/google/protobuf/descriptor.py
@@ -66,6 +66,7 @@ if _USE_C_DESCRIPTORS:
# and make it return True when the descriptor is an instance of the extension
# type written in C++.
class DescriptorMetaclass(type):
+
def __instancecheck__(cls, obj):
if super(DescriptorMetaclass, cls).__instancecheck__(obj):
return True
@@ -633,13 +634,29 @@ class FieldDescriptor(DescriptorBase):
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)
+ # self.containing_type is used here instead of self.file for legacy
+ # compatibility. FieldDescriptor.file was added in cl/153110619
+ # Some old/generated code didn't link file to FieldDescriptor.
+ # TODO(jieluo): remove syntax usage b/240619313
+ return self.containing_type.syntax == 'proto2'
+
+ @property
+ def is_packed(self):
+ """Returns if the field is packed."""
+ if self.label != FieldDescriptor.LABEL_REPEATED:
+ return False
+ field_type = self.type
+ if (field_type == FieldDescriptor.TYPE_STRING or
+ field_type == FieldDescriptor.TYPE_GROUP or
+ field_type == FieldDescriptor.TYPE_MESSAGE or
+ field_type == FieldDescriptor.TYPE_BYTES):
+ return False
+ if self.containing_type.syntax == 'proto2':
+ return self.has_options and self.GetOptions().packed
+ else:
+ return (not self.has_options or
+ not self.GetOptions().HasField('packed') or
+ self.GetOptions().packed)
@staticmethod
def ProtoTypeToCppProtoType(proto_type):
@@ -720,6 +737,30 @@ class EnumDescriptor(_NestedDescriptorBase):
# Values are reversed to ensure that the first alias is retained.
self.values_by_number = dict((v.number, v) for v in reversed(values))
+ @property
+ def is_closed(self):
+ """Returns true whether this is a "closed" enum.
+
+ This means that it:
+ - Has a fixed set of values, rather than being equivalent to an int32.
+ - Encountering values not in this set causes them to be treated as unknown
+ fields.
+ - The first value (i.e., the default) may be nonzero.
+
+ WARNING: Some runtimes currently have a quirk where non-closed enums are
+ treated as closed when used as the type of fields defined in a
+ `syntax = proto2;` file. This quirk is not present in all runtimes; as of
+ writing, we know that:
+
+ - C++, Java, and C++-based Python share this quirk.
+ - UPB and UPB-based Python do not.
+ - PHP and Ruby treat all enums as open regardless of declaration.
+
+ Care should be taken when using this function to respect the target
+ runtime's enum handling quirks.
+ """
+ return self.file.syntax == 'proto2'
+
def CopyToProto(self, proto):
"""Copies this to a descriptor_pb2.EnumDescriptorProto.
@@ -873,11 +914,14 @@ class ServiceDescriptor(_NestedDescriptorBase):
Args:
name (str): Name of the method.
+
Returns:
- MethodDescriptor or None: the descriptor for the requested method, if
- found.
+ MethodDescriptor: The descriptor for the requested method.
+
+ Raises:
+ KeyError: if the method cannot be found in the service.
"""
- return self.methods_by_name.get(name, None)
+ return self.methods_by_name[name]
def CopyToProto(self, proto):
"""Copies this to a descriptor_pb2.ServiceDescriptorProto.
@@ -1018,13 +1062,7 @@ class FileDescriptor(DescriptorBase):
# FileDescriptor() is called from various places, not only from generated
# files, to register dynamic proto files and messages.
# pylint: disable=g-explicit-bool-comparison
- if serialized_pb == b'':
- # Cpp generated code must be linked in if serialized_pb is ''
- try:
- return _message.default_pool.FindFileByName(name)
- except KeyError:
- raise RuntimeError('Please link in cpp generated lib for %s' % (name))
- elif serialized_pb:
+ if serialized_pb:
return _message.default_pool.AddSerializedFile(serialized_pb)
else:
return super(FileDescriptor, cls).__new__(cls)
diff --git a/contrib/python/protobuf/py3/google/protobuf/descriptor_pool.py b/contrib/python/protobuf/py3/google/protobuf/descriptor_pool.py
index 911372a8b00..1ebf11834a2 100644
--- a/contrib/python/protobuf/py3/google/protobuf/descriptor_pool.py
+++ b/contrib/python/protobuf/py3/google/protobuf/descriptor_pool.py
@@ -120,11 +120,13 @@ class DescriptorPool(object):
if _USE_C_DESCRIPTORS:
- def __new__(cls, descriptor_db=None):
- # pylint: disable=protected-access
- return descriptor._message.DescriptorPool(descriptor_db)
+ def __new__(cls, descriptor_db=None):
+ # pylint: disable=protected-access
+ return descriptor._message.DescriptorPool(descriptor_db)
- def __init__(self, descriptor_db=None):
+ def __init__(
+ self, descriptor_db=None, use_deprecated_legacy_json_field_conflicts=False
+ ):
"""Initializes a Pool of proto buffs.
The descriptor_db argument to the constructor is provided to allow
@@ -135,6 +137,8 @@ class DescriptorPool(object):
Args:
descriptor_db: A secondary source of file descriptors.
+ use_deprecated_legacy_json_field_conflicts: Unused, for compatibility with
+ C++.
"""
self._internal_db = descriptor_database.DescriptorDatabase()
@@ -144,9 +148,6 @@ class DescriptorPool(object):
self._service_descriptors = {}
self._file_descriptors = {}
self._toplevel_extensions = {}
- # TODO(jieluo): Remove _file_desc_by_toplevel_extension after
- # maybe year 2020 for compatibility issue (with 3.4.1 only).
- self._file_desc_by_toplevel_extension = {}
self._top_enum_values = {}
# We store extensions in two two-level mappings: The first key is the
# descriptor of the message being extended, the second key is the extension
@@ -220,7 +221,7 @@ class DescriptorPool(object):
file_desc.serialized_pb = serialized_file_desc_proto
return file_desc
- # Add Descriptor to descriptor pool is dreprecated. Please use Add()
+ # Add Descriptor to descriptor pool is deprecated. Please use Add()
# or AddSerializedFile() to add a FileDescriptorProto instead.
@_Deprecated
def AddDescriptor(self, desc):
@@ -245,7 +246,7 @@ class DescriptorPool(object):
self._descriptors[desc.full_name] = desc
self._AddFileDescriptor(desc.file)
- # Add EnumDescriptor to descriptor pool is dreprecated. Please use Add()
+ # Add EnumDescriptor to descriptor pool is deprecated. Please use Add()
# or AddSerializedFile() to add a FileDescriptorProto instead.
@_Deprecated
def AddEnumDescriptor(self, enum_desc):
@@ -286,7 +287,7 @@ class DescriptorPool(object):
self._top_enum_values[full_name] = enum_value
self._AddFileDescriptor(enum_desc.file)
- # Add ServiceDescriptor to descriptor pool is dreprecated. Please use Add()
+ # Add ServiceDescriptor to descriptor pool is deprecated. Please use Add()
# or AddSerializedFile() to add a FileDescriptorProto instead.
@_Deprecated
def AddServiceDescriptor(self, service_desc):
@@ -307,7 +308,7 @@ class DescriptorPool(object):
service_desc.file.name)
self._service_descriptors[service_desc.full_name] = service_desc
- # Add ExtensionDescriptor to descriptor pool is dreprecated. Please use Add()
+ # Add ExtensionDescriptor to descriptor pool is deprecated. Please use Add()
# or AddSerializedFile() to add a FileDescriptorProto instead.
@_Deprecated
def AddExtensionDescriptor(self, extension):
@@ -331,6 +332,8 @@ class DescriptorPool(object):
raise TypeError('Expected an extension descriptor.')
if extension.extension_scope is None:
+ self._CheckConflictRegister(
+ extension, extension.full_name, extension.file.name)
self._toplevel_extensions[extension.full_name] = extension
try:
@@ -372,12 +375,6 @@ class DescriptorPool(object):
"""
self._AddFileDescriptor(file_desc)
- # TODO(jieluo): This is a temporary solution for FieldDescriptor.file.
- # FieldDescriptor.file is added in code gen. Remove this solution after
- # maybe 2020 for compatibility reason (with 3.4.1 only).
- for extension in file_desc.extensions_by_name.values():
- self._file_desc_by_toplevel_extension[
- extension.full_name] = file_desc
def _AddFileDescriptor(self, file_desc):
"""Adds a FileDescriptor to the pool, non-recursively.
@@ -483,7 +480,7 @@ class DescriptorPool(object):
pass
try:
- return self._file_desc_by_toplevel_extension[symbol]
+ return self._toplevel_extensions[symbol].file
except KeyError:
pass
@@ -792,8 +789,6 @@ class DescriptorPool(object):
file_descriptor.package, scope)
file_descriptor.extensions_by_name[extension_desc.name] = (
extension_desc)
- self._file_desc_by_toplevel_extension[extension_desc.full_name] = (
- file_descriptor)
for desc_proto in file_proto.message_type:
self._SetAllFieldTypes(file_proto.package, desc_proto, scope)
diff --git a/contrib/python/protobuf/py3/google/protobuf/internal/__init__.py b/contrib/python/protobuf/py3/google/protobuf/internal/__init__.py
index e69de29bb2d..7d2e571a143 100644
--- a/contrib/python/protobuf/py3/google/protobuf/internal/__init__.py
+++ b/contrib/python/protobuf/py3/google/protobuf/internal/__init__.py
@@ -0,0 +1,30 @@
+# 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.
+
diff --git a/contrib/python/protobuf/py3/google/protobuf/internal/_parameterized.py b/contrib/python/protobuf/py3/google/protobuf/internal/_parameterized.py
new file mode 100644
index 00000000000..2f4a3b6b734
--- /dev/null
+++ b/contrib/python/protobuf/py3/google/protobuf/internal/_parameterized.py
@@ -0,0 +1,443 @@
+#! /usr/bin/env python
+#
+# 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.
+
+"""Adds support for parameterized tests to Python's unittest TestCase class.
+
+A parameterized test is a method in a test case that is invoked with different
+argument tuples.
+
+A simple example:
+
+ class AdditionExample(_parameterized.TestCase):
+ @_parameterized.parameters(
+ (1, 2, 3),
+ (4, 5, 9),
+ (1, 1, 3))
+ def testAddition(self, op1, op2, result):
+ self.assertEqual(result, op1 + op2)
+
+
+Each invocation is a separate test case and properly isolated just
+like a normal test method, with its own setUp/tearDown cycle. In the
+example above, there are three separate testcases, one of which will
+fail due to an assertion error (1 + 1 != 3).
+
+Parameters for individual test cases can be tuples (with positional parameters)
+or dictionaries (with named parameters):
+
+ class AdditionExample(_parameterized.TestCase):
+ @_parameterized.parameters(
+ {'op1': 1, 'op2': 2, 'result': 3},
+ {'op1': 4, 'op2': 5, 'result': 9},
+ )
+ def testAddition(self, op1, op2, result):
+ self.assertEqual(result, op1 + op2)
+
+If a parameterized test fails, the error message will show the
+original test name (which is modified internally) and the arguments
+for the specific invocation, which are part of the string returned by
+the shortDescription() method on test cases.
+
+The id method of the test, used internally by the unittest framework,
+is also modified to show the arguments. To make sure that test names
+stay the same across several invocations, object representations like
+
+ >>> class Foo(object):
+ ... pass
+ >>> repr(Foo())
+ '<__main__.Foo object at 0x23d8610>'
+
+are turned into '<__main__.Foo>'. For even more descriptive names,
+especially in test logs, you can use the named_parameters decorator. In
+this case, only tuples are supported, and the first parameters has to
+be a string (or an object that returns an apt name when converted via
+str()):
+
+ class NamedExample(_parameterized.TestCase):
+ @_parameterized.named_parameters(
+ ('Normal', 'aa', 'aaa', True),
+ ('EmptyPrefix', '', 'abc', True),
+ ('BothEmpty', '', '', True))
+ def testStartsWith(self, prefix, string, result):
+ self.assertEqual(result, strings.startswith(prefix))
+
+Named tests also have the benefit that they can be run individually
+from the command line:
+
+ $ testmodule.py NamedExample.testStartsWithNormal
+ .
+ --------------------------------------------------------------------
+ Ran 1 test in 0.000s
+
+ OK
+
+Parameterized Classes
+=====================
+If invocation arguments are shared across test methods in a single
+TestCase class, instead of decorating all test methods
+individually, the class itself can be decorated:
+
+ @_parameterized.parameters(
+ (1, 2, 3)
+ (4, 5, 9))
+ class ArithmeticTest(_parameterized.TestCase):
+ def testAdd(self, arg1, arg2, result):
+ self.assertEqual(arg1 + arg2, result)
+
+ def testSubtract(self, arg2, arg2, result):
+ self.assertEqual(result - arg1, arg2)
+
+Inputs from Iterables
+=====================
+If parameters should be shared across several test cases, or are dynamically
+created from other sources, a single non-tuple iterable can be passed into
+the decorator. This iterable will be used to obtain the test cases:
+
+ class AdditionExample(_parameterized.TestCase):
+ @_parameterized.parameters(
+ c.op1, c.op2, c.result for c in testcases
+ )
+ def testAddition(self, op1, op2, result):
+ self.assertEqual(result, op1 + op2)
+
+
+Single-Argument Test Methods
+============================
+If a test method takes only one argument, the single argument does not need to
+be wrapped into a tuple:
+
+ class NegativeNumberExample(_parameterized.TestCase):
+ @_parameterized.parameters(
+ -1, -3, -4, -5
+ )
+ def testIsNegative(self, arg):
+ self.assertTrue(IsNegative(arg))
+"""
+
+__author__ = '[email protected] (Torsten Marek)'
+
+import functools
+import re
+import types
+import unittest
+import uuid
+
+try:
+ # Since python 3
+ import collections.abc as collections_abc
+except ImportError:
+ # Won't work after python 3.8
+ import collections as collections_abc
+
+ADDR_RE = re.compile(r'\<([a-zA-Z0-9_\-\.]+) object at 0x[a-fA-F0-9]+\>')
+_SEPARATOR = uuid.uuid1().hex
+_FIRST_ARG = object()
+_ARGUMENT_REPR = object()
+
+
+def _CleanRepr(obj):
+ return ADDR_RE.sub(r'<\1>', repr(obj))
+
+
+# Helper function formerly from the unittest module, removed from it in
+# Python 2.7.
+def _StrClass(cls):
+ return '%s.%s' % (cls.__module__, cls.__name__)
+
+
+def _NonStringIterable(obj):
+ return (isinstance(obj, collections_abc.Iterable) and
+ not isinstance(obj, str))
+
+
+def _FormatParameterList(testcase_params):
+ if isinstance(testcase_params, collections_abc.Mapping):
+ return ', '.join('%s=%s' % (argname, _CleanRepr(value))
+ for argname, value in testcase_params.items())
+ elif _NonStringIterable(testcase_params):
+ return ', '.join(map(_CleanRepr, testcase_params))
+ else:
+ return _FormatParameterList((testcase_params,))
+
+
+class _ParameterizedTestIter(object):
+ """Callable and iterable class for producing new test cases."""
+
+ def __init__(self, test_method, testcases, naming_type):
+ """Returns concrete test functions for a test and a list of parameters.
+
+ The naming_type is used to determine the name of the concrete
+ functions as reported by the unittest framework. If naming_type is
+ _FIRST_ARG, the testcases must be tuples, and the first element must
+ have a string representation that is a valid Python identifier.
+
+ Args:
+ test_method: The decorated test method.
+ testcases: (list of tuple/dict) A list of parameter
+ tuples/dicts for individual test invocations.
+ naming_type: The test naming type, either _NAMED or _ARGUMENT_REPR.
+ """
+ self._test_method = test_method
+ self.testcases = testcases
+ self._naming_type = naming_type
+
+ def __call__(self, *args, **kwargs):
+ raise RuntimeError('You appear to be running a parameterized test case '
+ 'without having inherited from parameterized.'
+ 'TestCase. This is bad because none of '
+ 'your test cases are actually being run.')
+
+ def __iter__(self):
+ test_method = self._test_method
+ naming_type = self._naming_type
+
+ def MakeBoundParamTest(testcase_params):
+ @functools.wraps(test_method)
+ def BoundParamTest(self):
+ if isinstance(testcase_params, collections_abc.Mapping):
+ test_method(self, **testcase_params)
+ elif _NonStringIterable(testcase_params):
+ test_method(self, *testcase_params)
+ else:
+ test_method(self, testcase_params)
+
+ if naming_type is _FIRST_ARG:
+ # Signal the metaclass that the name of the test function is unique
+ # and descriptive.
+ BoundParamTest.__x_use_name__ = True
+ BoundParamTest.__name__ += str(testcase_params[0])
+ testcase_params = testcase_params[1:]
+ elif naming_type is _ARGUMENT_REPR:
+ # __x_extra_id__ is used to pass naming information to the __new__
+ # method of TestGeneratorMetaclass.
+ # The metaclass will make sure to create a unique, but nondescriptive
+ # name for this test.
+ BoundParamTest.__x_extra_id__ = '(%s)' % (
+ _FormatParameterList(testcase_params),)
+ else:
+ raise RuntimeError('%s is not a valid naming type.' % (naming_type,))
+
+ BoundParamTest.__doc__ = '%s(%s)' % (
+ BoundParamTest.__name__, _FormatParameterList(testcase_params))
+ if test_method.__doc__:
+ BoundParamTest.__doc__ += '\n%s' % (test_method.__doc__,)
+ return BoundParamTest
+ return (MakeBoundParamTest(c) for c in self.testcases)
+
+
+def _IsSingletonList(testcases):
+ """True iff testcases contains only a single non-tuple element."""
+ return len(testcases) == 1 and not isinstance(testcases[0], tuple)
+
+
+def _ModifyClass(class_object, testcases, naming_type):
+ assert not getattr(class_object, '_id_suffix', None), (
+ 'Cannot add parameters to %s,'
+ ' which already has parameterized methods.' % (class_object,))
+ class_object._id_suffix = id_suffix = {}
+ # We change the size of __dict__ while we iterate over it,
+ # which Python 3.x will complain about, so use copy().
+ for name, obj in class_object.__dict__.copy().items():
+ if (name.startswith(unittest.TestLoader.testMethodPrefix)
+ and isinstance(obj, types.FunctionType)):
+ delattr(class_object, name)
+ methods = {}
+ _UpdateClassDictForParamTestCase(
+ methods, id_suffix, name,
+ _ParameterizedTestIter(obj, testcases, naming_type))
+ for name, meth in methods.items():
+ setattr(class_object, name, meth)
+
+
+def _ParameterDecorator(naming_type, testcases):
+ """Implementation of the parameterization decorators.
+
+ Args:
+ naming_type: The naming type.
+ testcases: Testcase parameters.
+
+ Returns:
+ A function for modifying the decorated object.
+ """
+ def _Apply(obj):
+ if isinstance(obj, type):
+ _ModifyClass(
+ obj,
+ list(testcases) if not isinstance(testcases, collections_abc.Sequence)
+ else testcases,
+ naming_type)
+ return obj
+ else:
+ return _ParameterizedTestIter(obj, testcases, naming_type)
+
+ if _IsSingletonList(testcases):
+ assert _NonStringIterable(testcases[0]), (
+ 'Single parameter argument must be a non-string iterable')
+ testcases = testcases[0]
+
+ return _Apply
+
+
+def parameters(*testcases): # pylint: disable=invalid-name
+ """A decorator for creating parameterized tests.
+
+ See the module docstring for a usage example.
+ Args:
+ *testcases: Parameters for the decorated method, either a single
+ iterable, or a list of tuples/dicts/objects (for tests
+ with only one argument).
+
+ Returns:
+ A test generator to be handled by TestGeneratorMetaclass.
+ """
+ return _ParameterDecorator(_ARGUMENT_REPR, testcases)
+
+
+def named_parameters(*testcases): # pylint: disable=invalid-name
+ """A decorator for creating parameterized tests.
+
+ See the module docstring for a usage example. The first element of
+ each parameter tuple should be a string and will be appended to the
+ name of the test method.
+
+ Args:
+ *testcases: Parameters for the decorated method, either a single
+ iterable, or a list of tuples.
+
+ Returns:
+ A test generator to be handled by TestGeneratorMetaclass.
+ """
+ return _ParameterDecorator(_FIRST_ARG, testcases)
+
+
+class TestGeneratorMetaclass(type):
+ """Metaclass for test cases with test generators.
+
+ A test generator is an iterable in a testcase that produces callables. These
+ callables must be single-argument methods. These methods are injected into
+ the class namespace and the original iterable is removed. If the name of the
+ iterable conforms to the test pattern, the injected methods will be picked
+ up as tests by the unittest framework.
+
+ In general, it is supposed to be used in conjunction with the
+ parameters decorator.
+ """
+
+ def __new__(mcs, class_name, bases, dct):
+ dct['_id_suffix'] = id_suffix = {}
+ for name, obj in dct.copy().items():
+ if (name.startswith(unittest.TestLoader.testMethodPrefix) and
+ _NonStringIterable(obj)):
+ iterator = iter(obj)
+ dct.pop(name)
+ _UpdateClassDictForParamTestCase(dct, id_suffix, name, iterator)
+
+ return type.__new__(mcs, class_name, bases, dct)
+
+
+def _UpdateClassDictForParamTestCase(dct, id_suffix, name, iterator):
+ """Adds individual test cases to a dictionary.
+
+ Args:
+ dct: The target dictionary.
+ id_suffix: The dictionary for mapping names to test IDs.
+ name: The original name of the test case.
+ iterator: The iterator generating the individual test cases.
+ """
+ for idx, func in enumerate(iterator):
+ assert callable(func), 'Test generators must yield callables, got %r' % (
+ func,)
+ if getattr(func, '__x_use_name__', False):
+ new_name = func.__name__
+ else:
+ new_name = '%s%s%d' % (name, _SEPARATOR, idx)
+ assert new_name not in dct, (
+ 'Name of parameterized test case "%s" not unique' % (new_name,))
+ dct[new_name] = func
+ id_suffix[new_name] = getattr(func, '__x_extra_id__', '')
+
+
+class TestCase(unittest.TestCase, metaclass=TestGeneratorMetaclass):
+ """Base class for test cases using the parameters decorator."""
+
+ def _OriginalName(self):
+ return self._testMethodName.split(_SEPARATOR)[0]
+
+ def __str__(self):
+ return '%s (%s)' % (self._OriginalName(), _StrClass(self.__class__))
+
+ def id(self): # pylint: disable=invalid-name
+ """Returns the descriptive ID of the test.
+
+ This is used internally by the unittesting framework to get a name
+ for the test to be used in reports.
+
+ Returns:
+ The test id.
+ """
+ return '%s.%s%s' % (_StrClass(self.__class__),
+ self._OriginalName(),
+ self._id_suffix.get(self._testMethodName, ''))
+
+
+def CoopTestCase(other_base_class):
+ """Returns a new base class with a cooperative metaclass base.
+
+ This enables the TestCase to be used in combination
+ with other base classes that have custom metaclasses, such as
+ mox.MoxTestBase.
+
+ Only works with metaclasses that do not override type.__new__.
+
+ Example:
+
+ import google3
+ import mox
+
+ from google.protobuf.internal import _parameterized
+
+ class ExampleTest(parameterized.CoopTestCase(mox.MoxTestBase)):
+ ...
+
+ Args:
+ other_base_class: (class) A test case base class.
+
+ Returns:
+ A new class object.
+ """
+ metaclass = type(
+ 'CoopMetaclass',
+ (other_base_class.__metaclass__,
+ TestGeneratorMetaclass), {})
+ return metaclass(
+ 'CoopTestCase',
+ (other_base_class, TestCase), {})
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 33f5b04f49b..6db12e8dc67 100644
--- a/contrib/python/protobuf/py3/google/protobuf/internal/api_implementation.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/internal/api_implementation.cc
@@ -28,7 +28,6 @@
// (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 {
@@ -70,40 +69,59 @@ static const char* kImplVersionName = "api_version";
static const char* kModuleName = "_api_implementation";
static const char kModuleDocstring[] =
- "_api_implementation is a module that exposes compile-time constants that\n"
- "determine the default API implementation to use for Python proto2.\n"
- "\n"
- "It complements api_implementation.py by setting defaults using "
- "compile-time\n"
- "constants defined in C, such that one can set defaults at compilation\n"
- "(e.g. with blaze flag --copt=-DPYTHON_PROTO2_CPP_IMPL_V2).";
+"_api_implementation is a module that exposes compile-time constants that\n"
+"determine the default API implementation to use for Python proto2.\n"
+"\n"
+"It complements api_implementation.py by setting defaults using compile-time\n"
+"constants defined in C, such that one can set defaults at compilation\n"
+"(e.g. with blaze flag --copt=-DPYTHON_PROTO2_CPP_IMPL_V2).";
-static struct PyModuleDef _module = {PyModuleDef_HEAD_INIT,
- kModuleName,
- kModuleDocstring,
- -1,
- nullptr,
- nullptr,
- nullptr,
- nullptr,
- nullptr};
+#if PY_MAJOR_VERSION >= 3
+static struct PyModuleDef _module = {
+ PyModuleDef_HEAD_INIT,
+ kModuleName,
+ kModuleDocstring,
+ -1,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+#define INITFUNC PyInit__api_implementation
+#define INITFUNC_ERRORVAL NULL
+#else
+#define INITFUNC init_api_implementation
+#define INITFUNC_ERRORVAL
+#endif
extern "C" {
-PyMODINIT_FUNC PyInit__api_implementation() {
- PyObject* module = PyModule_Create(&_module);
- if (module == nullptr) {
- return nullptr;
- }
+ PyMODINIT_FUNC INITFUNC() {
+#if PY_MAJOR_VERSION >= 3
+ PyObject *module = PyModule_Create(&_module);
+#else
+ PyObject *module = Py_InitModule3(
+ const_cast<char*>(kModuleName),
+ NULL,
+ const_cast<char*>(kModuleDocstring));
+#endif
+ if (module == NULL) {
+ return INITFUNC_ERRORVAL;
+ }
- // Adds the module variable "api_version".
- if (PyModule_AddIntConstant(module, const_cast<char*>(kImplVersionName),
- kImplVersion)) {
- Py_DECREF(module);
- return nullptr;
- }
+ // Adds the module variable "api_version".
+ if (PyModule_AddIntConstant(
+ module,
+ const_cast<char*>(kImplVersionName),
+ kImplVersion))
+#if PY_MAJOR_VERSION < 3
+ return;
+#else
+ { Py_DECREF(module); return NULL; }
- return module;
-}
+ return module;
+#endif
+ }
}
} // namespace python
diff --git a/contrib/python/protobuf/py3/google/protobuf/internal/api_implementation.py b/contrib/python/protobuf/py3/google/protobuf/internal/api_implementation.py
index 74586487a8b..7d20bd2212b 100644
--- a/contrib/python/protobuf/py3/google/protobuf/internal/api_implementation.py
+++ b/contrib/python/protobuf/py3/google/protobuf/internal/api_implementation.py
@@ -102,6 +102,7 @@ if _implementation_type == 'cpp':
try:
# pylint: disable=g-import-not-at-top
from google.protobuf.pyext import _message
+ sys.modules['google3.net.proto2.python.internal.cpp._message'] = _message
_c_module = _message
del _message
except ImportError:
@@ -151,12 +152,6 @@ def Type():
return _implementation_type
-def _SetType(implementation_type):
- """Never use! Only for protobuf benchmark."""
- global _implementation_type
- _implementation_type = implementation_type
-
-
# See comment on 'Type' above.
# TODO(jieluo): Remove the API, it returns a constant. b/228102101
def Version():
diff --git a/contrib/python/protobuf/py3/google/protobuf/internal/decoder.py b/contrib/python/protobuf/py3/google/protobuf/internal/decoder.py
index a916276319b..8ff549381e7 100644
--- a/contrib/python/protobuf/py3/google/protobuf/internal/decoder.py
+++ b/contrib/python/protobuf/py3/google/protobuf/internal/decoder.py
@@ -806,8 +806,7 @@ def MessageSetItemDecoder(descriptor):
if value is None:
message_type = extension.message_type
if not hasattr(message_type, '_concrete_class'):
- # pylint: disable=protected-access
- message._FACTORY.GetPrototype(message_type)
+ message_factory.GetMessageClass(message_type)
value = field_dict.setdefault(
extension, message_type._concrete_class())
if value._InternalParse(buffer, message_start,message_end) != message_end:
diff --git a/contrib/python/protobuf/py3/google/protobuf/internal/extension_dict.py b/contrib/python/protobuf/py3/google/protobuf/internal/extension_dict.py
index b346cf283e2..83c4cb5dc65 100644
--- a/contrib/python/protobuf/py3/google/protobuf/internal/extension_dict.py
+++ b/contrib/python/protobuf/py3/google/protobuf/internal/extension_dict.py
@@ -89,8 +89,9 @@ class _ExtensionDict(object):
elif extension_handle.cpp_type == FieldDescriptor.CPPTYPE_MESSAGE:
message_type = extension_handle.message_type
if not hasattr(message_type, '_concrete_class'):
- # pylint: disable=protected-access
- self._extended_message._FACTORY.GetPrototype(message_type)
+ # pylint: disable=g-import-not-at-top
+ from google.protobuf import message_factory
+ message_factory.GetMessageClass(message_type)
assert getattr(extension_handle.message_type, '_concrete_class', None), (
'Uninitialized concrete class found for field %r (message type %r)'
% (extension_handle.full_name,
diff --git a/contrib/python/protobuf/py3/google/protobuf/internal/field_mask.py b/contrib/python/protobuf/py3/google/protobuf/internal/field_mask.py
new file mode 100644
index 00000000000..489769901e7
--- /dev/null
+++ b/contrib/python/protobuf/py3/google/protobuf/internal/field_mask.py
@@ -0,0 +1,333 @@
+# 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.
+
+"""Contains FieldMask class."""
+
+from google.protobuf.descriptor import FieldDescriptor
+
+
+class FieldMask(object):
+ """Class for FieldMask message type."""
+
+ __slots__ = ()
+
+ def ToJsonString(self):
+ """Converts FieldMask to string according to proto3 JSON spec."""
+ camelcase_paths = []
+ for path in self.paths:
+ camelcase_paths.append(_SnakeCaseToCamelCase(path))
+ return ','.join(camelcase_paths)
+
+ def FromJsonString(self, value):
+ """Converts string to FieldMask according to proto3 JSON spec."""
+ if not isinstance(value, str):
+ raise ValueError('FieldMask JSON value not a string: {!r}'.format(value))
+ self.Clear()
+ if value:
+ for path in value.split(','):
+ self.paths.append(_CamelCaseToSnakeCase(path))
+
+ def IsValidForDescriptor(self, message_descriptor):
+ """Checks whether the FieldMask is valid for Message Descriptor."""
+ for path in self.paths:
+ if not _IsValidPath(message_descriptor, path):
+ return False
+ return True
+
+ def AllFieldsFromDescriptor(self, message_descriptor):
+ """Gets all direct fields of Message Descriptor to FieldMask."""
+ self.Clear()
+ for field in message_descriptor.fields:
+ self.paths.append(field.name)
+
+ def CanonicalFormFromMask(self, mask):
+ """Converts a FieldMask to the canonical form.
+
+ Removes paths that are covered by another path. For example,
+ "foo.bar" is covered by "foo" and will be removed if "foo"
+ is also in the FieldMask. Then sorts all paths in alphabetical order.
+
+ Args:
+ mask: The original FieldMask to be converted.
+ """
+ tree = _FieldMaskTree(mask)
+ tree.ToFieldMask(self)
+
+ def Union(self, mask1, mask2):
+ """Merges mask1 and mask2 into this FieldMask."""
+ _CheckFieldMaskMessage(mask1)
+ _CheckFieldMaskMessage(mask2)
+ tree = _FieldMaskTree(mask1)
+ tree.MergeFromFieldMask(mask2)
+ tree.ToFieldMask(self)
+
+ def Intersect(self, mask1, mask2):
+ """Intersects mask1 and mask2 into this FieldMask."""
+ _CheckFieldMaskMessage(mask1)
+ _CheckFieldMaskMessage(mask2)
+ tree = _FieldMaskTree(mask1)
+ intersection = _FieldMaskTree()
+ for path in mask2.paths:
+ tree.IntersectPath(path, intersection)
+ intersection.ToFieldMask(self)
+
+ def MergeMessage(
+ self, source, destination,
+ replace_message_field=False, replace_repeated_field=False):
+ """Merges fields specified in FieldMask from source to destination.
+
+ Args:
+ source: Source message.
+ destination: The destination message to be merged into.
+ replace_message_field: Replace message field if True. Merge message
+ field if False.
+ replace_repeated_field: Replace repeated field if True. Append
+ elements of repeated field if False.
+ """
+ tree = _FieldMaskTree(self)
+ tree.MergeMessage(
+ source, destination, replace_message_field, replace_repeated_field)
+
+
+def _IsValidPath(message_descriptor, path):
+ """Checks whether the path is valid for Message Descriptor."""
+ parts = path.split('.')
+ last = parts.pop()
+ for name in parts:
+ field = message_descriptor.fields_by_name.get(name)
+ if (field is None or
+ field.label == FieldDescriptor.LABEL_REPEATED or
+ field.type != FieldDescriptor.TYPE_MESSAGE):
+ return False
+ message_descriptor = field.message_type
+ return last in message_descriptor.fields_by_name
+
+
+def _CheckFieldMaskMessage(message):
+ """Raises ValueError if message is not a FieldMask."""
+ message_descriptor = message.DESCRIPTOR
+ if (message_descriptor.name != 'FieldMask' or
+ message_descriptor.file.name != 'google/protobuf/field_mask.proto'):
+ raise ValueError('Message {0} is not a FieldMask.'.format(
+ message_descriptor.full_name))
+
+
+def _SnakeCaseToCamelCase(path_name):
+ """Converts a path name from snake_case to camelCase."""
+ result = []
+ after_underscore = False
+ for c in path_name:
+ if c.isupper():
+ raise ValueError(
+ 'Fail to print FieldMask to Json string: Path name '
+ '{0} must not contain uppercase letters.'.format(path_name))
+ if after_underscore:
+ if c.islower():
+ result.append(c.upper())
+ after_underscore = False
+ else:
+ raise ValueError(
+ 'Fail to print FieldMask to Json string: The '
+ 'character after a "_" must be a lowercase letter '
+ 'in path name {0}.'.format(path_name))
+ elif c == '_':
+ after_underscore = True
+ else:
+ result += c
+
+ if after_underscore:
+ raise ValueError('Fail to print FieldMask to Json string: Trailing "_" '
+ 'in path name {0}.'.format(path_name))
+ return ''.join(result)
+
+
+def _CamelCaseToSnakeCase(path_name):
+ """Converts a field name from camelCase to snake_case."""
+ result = []
+ for c in path_name:
+ if c == '_':
+ raise ValueError('Fail to parse FieldMask: Path name '
+ '{0} must not contain "_"s.'.format(path_name))
+ if c.isupper():
+ result += '_'
+ result += c.lower()
+ else:
+ result += c
+ return ''.join(result)
+
+
+class _FieldMaskTree(object):
+ """Represents a FieldMask in a tree structure.
+
+ For example, given a FieldMask "foo.bar,foo.baz,bar.baz",
+ the FieldMaskTree will be:
+ [_root] -+- foo -+- bar
+ | |
+ | +- baz
+ |
+ +- bar --- baz
+ In the tree, each leaf node represents a field path.
+ """
+
+ __slots__ = ('_root',)
+
+ def __init__(self, field_mask=None):
+ """Initializes the tree by FieldMask."""
+ self._root = {}
+ if field_mask:
+ self.MergeFromFieldMask(field_mask)
+
+ def MergeFromFieldMask(self, field_mask):
+ """Merges a FieldMask to the tree."""
+ for path in field_mask.paths:
+ self.AddPath(path)
+
+ def AddPath(self, path):
+ """Adds a field path into the tree.
+
+ If the field path to add is a sub-path of an existing field path
+ in the tree (i.e., a leaf node), it means the tree already matches
+ the given path so nothing will be added to the tree. If the path
+ matches an existing non-leaf node in the tree, that non-leaf node
+ will be turned into a leaf node with all its children removed because
+ the path matches all the node's children. Otherwise, a new path will
+ be added.
+
+ Args:
+ path: The field path to add.
+ """
+ node = self._root
+ for name in path.split('.'):
+ if name not in node:
+ node[name] = {}
+ elif not node[name]:
+ # Pre-existing empty node implies we already have this entire tree.
+ return
+ node = node[name]
+ # Remove any sub-trees we might have had.
+ node.clear()
+
+ def ToFieldMask(self, field_mask):
+ """Converts the tree to a FieldMask."""
+ field_mask.Clear()
+ _AddFieldPaths(self._root, '', field_mask)
+
+ def IntersectPath(self, path, intersection):
+ """Calculates the intersection part of a field path with this tree.
+
+ Args:
+ path: The field path to calculates.
+ intersection: The out tree to record the intersection part.
+ """
+ node = self._root
+ for name in path.split('.'):
+ if name not in node:
+ return
+ elif not node[name]:
+ intersection.AddPath(path)
+ return
+ node = node[name]
+ intersection.AddLeafNodes(path, node)
+
+ def AddLeafNodes(self, prefix, node):
+ """Adds leaf nodes begin with prefix to this tree."""
+ if not node:
+ self.AddPath(prefix)
+ for name in node:
+ child_path = prefix + '.' + name
+ self.AddLeafNodes(child_path, node[name])
+
+ def MergeMessage(
+ self, source, destination,
+ replace_message, replace_repeated):
+ """Merge all fields specified by this tree from source to destination."""
+ _MergeMessage(
+ self._root, source, destination, replace_message, replace_repeated)
+
+
+def _StrConvert(value):
+ """Converts value to str if it is not."""
+ # This file is imported by c extension and some methods like ClearField
+ # requires string for the field name. py2/py3 has different text
+ # type and may use unicode.
+ if not isinstance(value, str):
+ return value.encode('utf-8')
+ return value
+
+
+def _MergeMessage(
+ node, source, destination, replace_message, replace_repeated):
+ """Merge all fields specified by a sub-tree from source to destination."""
+ source_descriptor = source.DESCRIPTOR
+ for name in node:
+ child = node[name]
+ field = source_descriptor.fields_by_name[name]
+ if field is None:
+ raise ValueError('Error: Can\'t find field {0} in message {1}.'.format(
+ name, source_descriptor.full_name))
+ if child:
+ # Sub-paths are only allowed for singular message fields.
+ if (field.label == FieldDescriptor.LABEL_REPEATED or
+ field.cpp_type != FieldDescriptor.CPPTYPE_MESSAGE):
+ raise ValueError('Error: Field {0} in message {1} is not a singular '
+ 'message field and cannot have sub-fields.'.format(
+ name, source_descriptor.full_name))
+ if source.HasField(name):
+ _MergeMessage(
+ child, getattr(source, name), getattr(destination, name),
+ replace_message, replace_repeated)
+ continue
+ if field.label == FieldDescriptor.LABEL_REPEATED:
+ if replace_repeated:
+ destination.ClearField(_StrConvert(name))
+ repeated_source = getattr(source, name)
+ repeated_destination = getattr(destination, name)
+ repeated_destination.MergeFrom(repeated_source)
+ else:
+ if field.cpp_type == FieldDescriptor.CPPTYPE_MESSAGE:
+ if replace_message:
+ destination.ClearField(_StrConvert(name))
+ if source.HasField(name):
+ getattr(destination, name).MergeFrom(getattr(source, name))
+ else:
+ setattr(destination, name, getattr(source, name))
+
+
+def _AddFieldPaths(node, prefix, field_mask):
+ """Adds the field paths descended from node to field_mask."""
+ if not node and prefix:
+ field_mask.paths.append(prefix)
+ return
+ for name in sorted(node):
+ if prefix:
+ child_path = prefix + '.' + name
+ else:
+ child_path = name
+ _AddFieldPaths(node[name], child_path, field_mask)
diff --git a/contrib/python/protobuf/py3/google/protobuf/internal/python_message.py b/contrib/python/protobuf/py3/google/protobuf/internal/python_message.py
index 5550b425c49..bf9acefd2a3 100644
--- a/contrib/python/protobuf/py3/google/protobuf/internal/python_message.py
+++ b/contrib/python/protobuf/py3/google/protobuf/internal/python_message.py
@@ -283,20 +283,8 @@ def _IsMessageMapField(field):
def _AttachFieldHelpers(cls, field_descriptor):
is_repeated = (field_descriptor.label == _FieldDescriptor.LABEL_REPEATED)
- is_packable = (is_repeated and
- wire_format.IsTypePackable(field_descriptor.type))
- is_proto3 = field_descriptor.containing_type.syntax == 'proto3'
- if not is_packable:
- is_packed = False
- elif field_descriptor.containing_type.syntax == 'proto2':
- is_packed = (field_descriptor.has_options and
- field_descriptor.GetOptions().packed)
- else:
- has_packed_false = (field_descriptor.has_options and
- field_descriptor.GetOptions().HasField('packed') and
- field_descriptor.GetOptions().packed == False)
- is_packed = not has_packed_false
is_map_entry = _IsMapField(field_descriptor)
+ is_packed = field_descriptor.is_packed
if is_map_entry:
field_encoder = encoder.MapEncoder(field_descriptor)
@@ -320,16 +308,12 @@ def _AttachFieldHelpers(cls, field_descriptor):
tag_bytes = encoder.TagBytes(field_descriptor.number, wiretype)
decode_type = field_descriptor.type
if (decode_type == _FieldDescriptor.TYPE_ENUM and
- type_checkers.SupportsOpenEnums(field_descriptor)):
+ not field_descriptor.enum_type.is_closed):
decode_type = _FieldDescriptor.TYPE_INT32
oneof_descriptor = None
- clear_if_default = False
if field_descriptor.containing_oneof is not None:
oneof_descriptor = field_descriptor
- elif (is_proto3 and not is_repeated and
- field_descriptor.cpp_type != _FieldDescriptor.CPPTYPE_MESSAGE):
- clear_if_default = True
if is_map_entry:
is_message_map = _IsMessageMapField(field_descriptor)
@@ -341,7 +325,7 @@ def _AttachFieldHelpers(cls, field_descriptor):
field_decoder = decoder.StringDecoder(
field_descriptor.number, is_repeated, is_packed,
field_descriptor, field_descriptor._default_constructor,
- clear_if_default)
+ not field_descriptor.has_presence)
elif field_descriptor.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
field_decoder = type_checkers.TYPE_TO_DECODER[decode_type](
field_descriptor.number, is_repeated, is_packed,
@@ -351,7 +335,7 @@ def _AttachFieldHelpers(cls, field_descriptor):
field_descriptor.number, is_repeated, is_packed,
# pylint: disable=protected-access
field_descriptor, field_descriptor._default_constructor,
- clear_if_default)
+ not field_descriptor.has_presence)
cls._decoders_by_tag[tag_bytes] = (field_decoder, oneof_descriptor)
@@ -683,7 +667,6 @@ def _AddPropertiesForNonRepeatedScalarField(field, cls):
property_name = _PropertyName(proto_field_name)
type_checker = type_checkers.GetTypeChecker(field)
default_value = field.default_value
- is_proto3 = field.containing_type.syntax == 'proto3'
def getter(self):
# TODO(protobuf-team): This may be broken since there may not be
@@ -692,8 +675,6 @@ def _AddPropertiesForNonRepeatedScalarField(field, cls):
getter.__module__ = None
getter.__doc__ = 'Getter for %s.' % proto_field_name
- clear_when_set_to_default = is_proto3 and not field.containing_oneof
-
def field_setter(self, new_value):
# pylint: disable=protected-access
# Testing the value for truthiness captures all of the proto3 defaults
@@ -703,7 +684,7 @@ def _AddPropertiesForNonRepeatedScalarField(field, cls):
except TypeError as e:
raise TypeError(
'Cannot set %s to %.1024r: %s' % (field.full_name, new_value, e))
- if clear_when_set_to_default and not new_value:
+ if not field.has_presence and not new_value:
self._fields.pop(field, None)
else:
self._fields[field] = new_value
@@ -788,12 +769,12 @@ def _AddPropertiesForExtensions(descriptor, cls):
def _AddStaticMethods(cls):
# TODO(robinson): This probably needs to be thread-safe(?)
- def RegisterExtension(extension_handle):
- extension_handle.containing_type = cls.DESCRIPTOR
+ def RegisterExtension(field_descriptor):
+ field_descriptor.containing_type = cls.DESCRIPTOR
# TODO(amauryfa): Use cls.MESSAGE_FACTORY.pool when available.
# pylint: disable=protected-access
- cls.DESCRIPTOR.file.pool._AddExtensionDescriptor(extension_handle)
- _AttachFieldHelpers(cls, extension_handle)
+ cls.DESCRIPTOR.file.pool._AddExtensionDescriptor(field_descriptor)
+ _AttachFieldHelpers(cls, field_descriptor)
cls.RegisterExtension = staticmethod(RegisterExtension)
def FromString(s):
@@ -825,24 +806,16 @@ def _AddListFieldsMethod(message_descriptor, cls):
cls.ListFields = ListFields
-_PROTO3_ERROR_TEMPLATE = \
- ('Protocol message %s has no non-repeated submessage field "%s" '
- 'nor marked as optional')
-_PROTO2_ERROR_TEMPLATE = 'Protocol message %s has no non-repeated field "%s"'
def _AddHasFieldMethod(message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
- is_proto3 = (message_descriptor.syntax == "proto3")
- error_msg = _PROTO3_ERROR_TEMPLATE if is_proto3 else _PROTO2_ERROR_TEMPLATE
-
hassable_fields = {}
for field in message_descriptor.fields:
if field.label == _FieldDescriptor.LABEL_REPEATED:
continue
# For proto3, only submessages and fields inside a oneof have presence.
- if (is_proto3 and field.cpp_type != _FieldDescriptor.CPPTYPE_MESSAGE and
- not field.containing_oneof):
+ if not field.has_presence:
continue
hassable_fields[field.name] = field
@@ -853,8 +826,10 @@ def _AddHasFieldMethod(message_descriptor, cls):
def HasField(self, field_name):
try:
field = hassable_fields[field_name]
- except KeyError:
- raise ValueError(error_msg % (message_descriptor.full_name, field_name))
+ except KeyError as exc:
+ raise ValueError('Protocol message %s has no non-repeated field "%s" '
+ 'nor has presence is not available for this field.' % (
+ message_descriptor.full_name, field_name)) from exc
if isinstance(field, descriptor_mod.OneofDescriptor):
try:
@@ -911,28 +886,28 @@ def _AddClearFieldMethod(message_descriptor, cls):
def _AddClearExtensionMethod(cls):
"""Helper for _AddMessageMethods()."""
- def ClearExtension(self, extension_handle):
- extension_dict._VerifyExtensionHandle(self, extension_handle)
+ def ClearExtension(self, field_descriptor):
+ extension_dict._VerifyExtensionHandle(self, field_descriptor)
# Similar to ClearField(), above.
- if extension_handle in self._fields:
- del self._fields[extension_handle]
+ if field_descriptor in self._fields:
+ del self._fields[field_descriptor]
self._Modified()
cls.ClearExtension = ClearExtension
def _AddHasExtensionMethod(cls):
"""Helper for _AddMessageMethods()."""
- def HasExtension(self, extension_handle):
- extension_dict._VerifyExtensionHandle(self, extension_handle)
- if extension_handle.label == _FieldDescriptor.LABEL_REPEATED:
- raise KeyError('"%s" is repeated.' % extension_handle.full_name)
+ def HasExtension(self, field_descriptor):
+ extension_dict._VerifyExtensionHandle(self, field_descriptor)
+ if field_descriptor.label == _FieldDescriptor.LABEL_REPEATED:
+ raise KeyError('"%s" is repeated.' % field_descriptor.full_name)
- if extension_handle.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
- value = self._fields.get(extension_handle)
+ if field_descriptor.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
+ value = self._fields.get(field_descriptor)
return value is not None and value._is_present_in_parent
else:
- return extension_handle in self._fields
+ return field_descriptor in self._fields
cls.HasExtension = HasExtension
def _InternalUnpackAny(msg):
diff --git a/contrib/python/protobuf/py3/google/protobuf/internal/python_protobuf.cc b/contrib/python/protobuf/py3/google/protobuf/internal/python_protobuf.cc
new file mode 100644
index 00000000000..bbef7159aaf
--- /dev/null
+++ b/contrib/python/protobuf/py3/google/protobuf/internal/python_protobuf.cc
@@ -0,0 +1,63 @@
+// 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: [email protected] (Marcin Kowalczyk)
+
+#include "google/protobuf/python_protobuf.h"
+
+namespace google {
+namespace protobuf {
+namespace python {
+
+static const Message* GetCProtoInsidePyProtoStub(PyObject* msg) {
+ return nullptr;
+}
+static Message* MutableCProtoInsidePyProtoStub(PyObject* msg) {
+ return nullptr;
+}
+
+// This is initialized with a default, stub implementation.
+// If python-google.protobuf.cc is loaded, the function pointer is overridden
+// with a full implementation.
+const Message* (*GetCProtoInsidePyProtoPtr)(PyObject* msg) =
+ GetCProtoInsidePyProtoStub;
+Message* (*MutableCProtoInsidePyProtoPtr)(PyObject* msg) =
+ MutableCProtoInsidePyProtoStub;
+
+const Message* GetCProtoInsidePyProto(PyObject* msg) {
+ return GetCProtoInsidePyProtoPtr(msg);
+}
+Message* MutableCProtoInsidePyProto(PyObject* msg) {
+ return MutableCProtoInsidePyProtoPtr(msg);
+}
+
+} // namespace python
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/python/protobuf/py3/google/protobuf/internal/testing_refleaks.py b/contrib/python/protobuf/py3/google/protobuf/internal/testing_refleaks.py
new file mode 100644
index 00000000000..5f19c46fd5f
--- /dev/null
+++ b/contrib/python/protobuf/py3/google/protobuf/internal/testing_refleaks.py
@@ -0,0 +1,142 @@
+# 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.
+
+"""A subclass of unittest.TestCase which checks for reference leaks.
+
+To use:
+- Use testing_refleak.BaseTestCase instead of unittest.TestCase
+- Configure and compile Python with --with-pydebug
+
+If sys.gettotalrefcount() is not available (because Python was built without
+the Py_DEBUG option), then this module is a no-op and tests will run normally.
+"""
+
+import copyreg
+import gc
+import sys
+import unittest
+
+
+class LocalTestResult(unittest.TestResult):
+ """A TestResult which forwards events to a parent object, except for Skips."""
+
+ def __init__(self, parent_result):
+ unittest.TestResult.__init__(self)
+ self.parent_result = parent_result
+
+ def addError(self, test, error):
+ self.parent_result.addError(test, error)
+
+ def addFailure(self, test, error):
+ self.parent_result.addFailure(test, error)
+
+ def addSkip(self, test, reason):
+ pass
+
+
+class ReferenceLeakCheckerMixin(object):
+ """A mixin class for TestCase, which checks reference counts."""
+
+ NB_RUNS = 3
+
+ def run(self, result=None):
+ testMethod = getattr(self, self._testMethodName)
+ expecting_failure_method = getattr(testMethod, "__unittest_expecting_failure__", False)
+ expecting_failure_class = getattr(self, "__unittest_expecting_failure__", False)
+ if expecting_failure_class or expecting_failure_method:
+ return
+
+ # python_message.py registers all Message classes to some pickle global
+ # registry, which makes the classes immortal.
+ # We save a copy of this registry, and reset it before we could references.
+ self._saved_pickle_registry = copyreg.dispatch_table.copy()
+
+ # Run the test twice, to warm up the instance attributes.
+ super(ReferenceLeakCheckerMixin, self).run(result=result)
+ super(ReferenceLeakCheckerMixin, self).run(result=result)
+
+ oldrefcount = 0
+ local_result = LocalTestResult(result)
+ num_flakes = 0
+
+ refcount_deltas = []
+ while len(refcount_deltas) < self.NB_RUNS:
+ oldrefcount = self._getRefcounts()
+ super(ReferenceLeakCheckerMixin, self).run(result=local_result)
+ newrefcount = self._getRefcounts()
+ # If the GC was able to collect some objects after the call to run() that
+ # it could not collect before the call, then the counts won't match.
+ if newrefcount < oldrefcount and num_flakes < 2:
+ # This result is (probably) a flake -- garbage collectors aren't very
+ # predictable, but a lower ending refcount is the opposite of the
+ # failure we are testing for. If the result is repeatable, then we will
+ # eventually report it, but not after trying to eliminate it.
+ num_flakes += 1
+ continue
+ num_flakes = 0
+ refcount_deltas.append(newrefcount - oldrefcount)
+ print(refcount_deltas, self)
+
+ try:
+ self.assertEqual(refcount_deltas, [0] * self.NB_RUNS)
+ except Exception: # pylint: disable=broad-except
+ result.addError(self, sys.exc_info())
+
+ def _getRefcounts(self):
+ copyreg.dispatch_table.clear()
+ copyreg.dispatch_table.update(self._saved_pickle_registry)
+ # It is sometimes necessary to gc.collect() multiple times, to ensure
+ # that all objects can be collected.
+ gc.collect()
+ gc.collect()
+ gc.collect()
+ return sys.gettotalrefcount()
+
+
+if hasattr(sys, 'gettotalrefcount'):
+
+ def TestCase(test_class):
+ new_bases = (ReferenceLeakCheckerMixin,) + test_class.__bases__
+ new_class = type(test_class)(
+ test_class.__name__, new_bases, dict(test_class.__dict__))
+ return new_class
+ SkipReferenceLeakChecker = unittest.skip
+
+else:
+ # When PyDEBUG is not enabled, run the tests normally.
+
+ def TestCase(test_class):
+ return test_class
+
+ def SkipReferenceLeakChecker(reason):
+ del reason # Don't skip, so don't need a reason.
+ def Same(func):
+ return func
+ return Same
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 a53e71fe8e5..165dcd8c2e8 100644
--- a/contrib/python/protobuf/py3/google/protobuf/internal/type_checkers.py
+++ b/contrib/python/protobuf/py3/google/protobuf/internal/type_checkers.py
@@ -75,10 +75,6 @@ def ToShortestFloat(original):
return rounded
-def SupportsOpenEnums(field_descriptor):
- return field_descriptor.containing_type.syntax == 'proto3'
-
-
def GetTypeChecker(field):
"""Returns a type checker for a message field of the specified types.
@@ -93,11 +89,11 @@ def GetTypeChecker(field):
field.type == _FieldDescriptor.TYPE_STRING):
return UnicodeValueChecker()
if field.cpp_type == _FieldDescriptor.CPPTYPE_ENUM:
- if SupportsOpenEnums(field):
+ if field.enum_type.is_closed:
+ return EnumValueChecker(field.enum_type)
+ else:
# When open enums are supported, any int32 can be assigned.
return _VALUE_CHECKERS[_FieldDescriptor.CPPTYPE_INT32]
- else:
- return EnumValueChecker(field.enum_type)
return _VALUE_CHECKERS[field.cpp_type]
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 3cc97f6a55d..ff6929effa6 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
@@ -44,7 +44,9 @@ import calendar
import collections.abc
import datetime
-from google.protobuf.descriptor import FieldDescriptor
+from google.protobuf.internal import field_mask
+
+FieldMask = field_mask.FieldMask
_TIMESTAMPFOMAT = '%Y-%m-%dT%H:%M:%S'
_NANOS_PER_SECOND = 1000000000
@@ -430,306 +432,6 @@ def _RoundTowardZero(value, divider):
return result
-class FieldMask(object):
- """Class for FieldMask message type."""
-
- __slots__ = ()
-
- def ToJsonString(self):
- """Converts FieldMask to string according to proto3 JSON spec."""
- camelcase_paths = []
- for path in self.paths:
- camelcase_paths.append(_SnakeCaseToCamelCase(path))
- return ','.join(camelcase_paths)
-
- def FromJsonString(self, value):
- """Converts string to FieldMask according to proto3 JSON spec."""
- if not isinstance(value, str):
- raise ValueError('FieldMask JSON value not a string: {!r}'.format(value))
- self.Clear()
- if value:
- for path in value.split(','):
- self.paths.append(_CamelCaseToSnakeCase(path))
-
- def IsValidForDescriptor(self, message_descriptor):
- """Checks whether the FieldMask is valid for Message Descriptor."""
- for path in self.paths:
- if not _IsValidPath(message_descriptor, path):
- return False
- return True
-
- def AllFieldsFromDescriptor(self, message_descriptor):
- """Gets all direct fields of Message Descriptor to FieldMask."""
- self.Clear()
- for field in message_descriptor.fields:
- self.paths.append(field.name)
-
- def CanonicalFormFromMask(self, mask):
- """Converts a FieldMask to the canonical form.
-
- Removes paths that are covered by another path. For example,
- "foo.bar" is covered by "foo" and will be removed if "foo"
- is also in the FieldMask. Then sorts all paths in alphabetical order.
-
- Args:
- mask: The original FieldMask to be converted.
- """
- tree = _FieldMaskTree(mask)
- tree.ToFieldMask(self)
-
- def Union(self, mask1, mask2):
- """Merges mask1 and mask2 into this FieldMask."""
- _CheckFieldMaskMessage(mask1)
- _CheckFieldMaskMessage(mask2)
- tree = _FieldMaskTree(mask1)
- tree.MergeFromFieldMask(mask2)
- tree.ToFieldMask(self)
-
- def Intersect(self, mask1, mask2):
- """Intersects mask1 and mask2 into this FieldMask."""
- _CheckFieldMaskMessage(mask1)
- _CheckFieldMaskMessage(mask2)
- tree = _FieldMaskTree(mask1)
- intersection = _FieldMaskTree()
- for path in mask2.paths:
- tree.IntersectPath(path, intersection)
- intersection.ToFieldMask(self)
-
- def MergeMessage(
- self, source, destination,
- replace_message_field=False, replace_repeated_field=False):
- """Merges fields specified in FieldMask from source to destination.
-
- Args:
- source: Source message.
- destination: The destination message to be merged into.
- replace_message_field: Replace message field if True. Merge message
- field if False.
- replace_repeated_field: Replace repeated field if True. Append
- elements of repeated field if False.
- """
- tree = _FieldMaskTree(self)
- tree.MergeMessage(
- source, destination, replace_message_field, replace_repeated_field)
-
-
-def _IsValidPath(message_descriptor, path):
- """Checks whether the path is valid for Message Descriptor."""
- parts = path.split('.')
- last = parts.pop()
- for name in parts:
- field = message_descriptor.fields_by_name.get(name)
- if (field is None or
- field.label == FieldDescriptor.LABEL_REPEATED or
- field.type != FieldDescriptor.TYPE_MESSAGE):
- return False
- message_descriptor = field.message_type
- return last in message_descriptor.fields_by_name
-
-
-def _CheckFieldMaskMessage(message):
- """Raises ValueError if message is not a FieldMask."""
- message_descriptor = message.DESCRIPTOR
- if (message_descriptor.name != 'FieldMask' or
- message_descriptor.file.name != 'google/protobuf/field_mask.proto'):
- raise ValueError('Message {0} is not a FieldMask.'.format(
- message_descriptor.full_name))
-
-
-def _SnakeCaseToCamelCase(path_name):
- """Converts a path name from snake_case to camelCase."""
- result = []
- after_underscore = False
- for c in path_name:
- if c.isupper():
- raise ValueError(
- 'Fail to print FieldMask to Json string: Path name '
- '{0} must not contain uppercase letters.'.format(path_name))
- if after_underscore:
- if c.islower():
- result.append(c.upper())
- after_underscore = False
- else:
- raise ValueError(
- 'Fail to print FieldMask to Json string: The '
- 'character after a "_" must be a lowercase letter '
- 'in path name {0}.'.format(path_name))
- elif c == '_':
- after_underscore = True
- else:
- result += c
-
- if after_underscore:
- raise ValueError('Fail to print FieldMask to Json string: Trailing "_" '
- 'in path name {0}.'.format(path_name))
- return ''.join(result)
-
-
-def _CamelCaseToSnakeCase(path_name):
- """Converts a field name from camelCase to snake_case."""
- result = []
- for c in path_name:
- if c == '_':
- raise ValueError('Fail to parse FieldMask: Path name '
- '{0} must not contain "_"s.'.format(path_name))
- if c.isupper():
- result += '_'
- result += c.lower()
- else:
- result += c
- return ''.join(result)
-
-
-class _FieldMaskTree(object):
- """Represents a FieldMask in a tree structure.
-
- For example, given a FieldMask "foo.bar,foo.baz,bar.baz",
- the FieldMaskTree will be:
- [_root] -+- foo -+- bar
- | |
- | +- baz
- |
- +- bar --- baz
- In the tree, each leaf node represents a field path.
- """
-
- __slots__ = ('_root',)
-
- def __init__(self, field_mask=None):
- """Initializes the tree by FieldMask."""
- self._root = {}
- if field_mask:
- self.MergeFromFieldMask(field_mask)
-
- def MergeFromFieldMask(self, field_mask):
- """Merges a FieldMask to the tree."""
- for path in field_mask.paths:
- self.AddPath(path)
-
- def AddPath(self, path):
- """Adds a field path into the tree.
-
- If the field path to add is a sub-path of an existing field path
- in the tree (i.e., a leaf node), it means the tree already matches
- the given path so nothing will be added to the tree. If the path
- matches an existing non-leaf node in the tree, that non-leaf node
- will be turned into a leaf node with all its children removed because
- the path matches all the node's children. Otherwise, a new path will
- be added.
-
- Args:
- path: The field path to add.
- """
- node = self._root
- for name in path.split('.'):
- if name not in node:
- node[name] = {}
- elif not node[name]:
- # Pre-existing empty node implies we already have this entire tree.
- return
- node = node[name]
- # Remove any sub-trees we might have had.
- node.clear()
-
- def ToFieldMask(self, field_mask):
- """Converts the tree to a FieldMask."""
- field_mask.Clear()
- _AddFieldPaths(self._root, '', field_mask)
-
- def IntersectPath(self, path, intersection):
- """Calculates the intersection part of a field path with this tree.
-
- Args:
- path: The field path to calculates.
- intersection: The out tree to record the intersection part.
- """
- node = self._root
- for name in path.split('.'):
- if name not in node:
- return
- elif not node[name]:
- intersection.AddPath(path)
- return
- node = node[name]
- intersection.AddLeafNodes(path, node)
-
- def AddLeafNodes(self, prefix, node):
- """Adds leaf nodes begin with prefix to this tree."""
- if not node:
- self.AddPath(prefix)
- for name in node:
- child_path = prefix + '.' + name
- self.AddLeafNodes(child_path, node[name])
-
- def MergeMessage(
- self, source, destination,
- replace_message, replace_repeated):
- """Merge all fields specified by this tree from source to destination."""
- _MergeMessage(
- self._root, source, destination, replace_message, replace_repeated)
-
-
-def _StrConvert(value):
- """Converts value to str if it is not."""
- # This file is imported by c extension and some methods like ClearField
- # requires string for the field name. py2/py3 has different text
- # type and may use unicode.
- if not isinstance(value, str):
- return value.encode('utf-8')
- return value
-
-
-def _MergeMessage(
- node, source, destination, replace_message, replace_repeated):
- """Merge all fields specified by a sub-tree from source to destination."""
- source_descriptor = source.DESCRIPTOR
- for name in node:
- child = node[name]
- field = source_descriptor.fields_by_name[name]
- if field is None:
- raise ValueError('Error: Can\'t find field {0} in message {1}.'.format(
- name, source_descriptor.full_name))
- if child:
- # Sub-paths are only allowed for singular message fields.
- if (field.label == FieldDescriptor.LABEL_REPEATED or
- field.cpp_type != FieldDescriptor.CPPTYPE_MESSAGE):
- raise ValueError('Error: Field {0} in message {1} is not a singular '
- 'message field and cannot have sub-fields.'.format(
- name, source_descriptor.full_name))
- if source.HasField(name):
- _MergeMessage(
- child, getattr(source, name), getattr(destination, name),
- replace_message, replace_repeated)
- continue
- if field.label == FieldDescriptor.LABEL_REPEATED:
- if replace_repeated:
- destination.ClearField(_StrConvert(name))
- repeated_source = getattr(source, name)
- repeated_destination = getattr(destination, name)
- repeated_destination.MergeFrom(repeated_source)
- else:
- if field.cpp_type == FieldDescriptor.CPPTYPE_MESSAGE:
- if replace_message:
- destination.ClearField(_StrConvert(name))
- if source.HasField(name):
- getattr(destination, name).MergeFrom(getattr(source, name))
- else:
- setattr(destination, name, getattr(source, name))
-
-
-def _AddFieldPaths(node, prefix, field_mask):
- """Adds the field paths descended from node to field_mask."""
- if not node and prefix:
- field_mask.paths.append(prefix)
- return
- for name in sorted(node):
- if prefix:
- child_path = prefix + '.' + name
- else:
- child_path = name
- _AddFieldPaths(node[name], child_path, field_mask)
-
-
def _SetStructValue(struct_value, value):
if value is None:
struct_value.null_value = 0
diff --git a/contrib/python/protobuf/py3/google/protobuf/internal/wire_format.py b/contrib/python/protobuf/py3/google/protobuf/internal/wire_format.py
index 883f5255851..1f54414b1aa 100644
--- a/contrib/python/protobuf/py3/google/protobuf/internal/wire_format.py
+++ b/contrib/python/protobuf/py3/google/protobuf/internal/wire_format.py
@@ -43,7 +43,7 @@ TAG_TYPE_MASK = (1 << TAG_TYPE_BITS) - 1 # 0x7
# These numbers identify the wire type of a protocol buffer value.
# We use the least-significant TAG_TYPE_BITS bits of the varint-encoded
# tag-and-type to store one of these WIRETYPE_* constants.
-# These values must match WireType enum in google/protobuf/wire_format.h.
+# These values must match WireType enum in //google/protobuf/wire_format.h.
WIRETYPE_VARINT = 0
WIRETYPE_FIXED64 = 1
WIRETYPE_LENGTH_DELIMITED = 2
diff --git a/contrib/python/protobuf/py3/google/protobuf/json_format.py b/contrib/python/protobuf/py3/google/protobuf/json_format.py
index 5024ed89d7d..a04e8aef133 100644
--- a/contrib/python/protobuf/py3/google/protobuf/json_format.py
+++ b/contrib/python/protobuf/py3/google/protobuf/json_format.py
@@ -53,6 +53,7 @@ import sys
from google.protobuf.internal import type_checkers
from google.protobuf import descriptor
+from google.protobuf import message_factory
from google.protobuf import symbol_database
@@ -109,7 +110,8 @@ def MessageToJson(
names as defined in the .proto file. If False, convert the field
names to lowerCamelCase.
indent: The JSON object will be pretty-printed with this indent level.
- An indent level of 0 or negative will only insert newlines.
+ An indent level of 0 or negative will only insert newlines. If the
+ indent level is None, no newlines will be inserted.
sort_keys: If True, then the output will be sorted by field names.
use_integers_for_enums: If true, print integers instead of enum names.
descriptor_pool: A Descriptor Pool for resolving types. If None use the
@@ -269,7 +271,7 @@ class _Printer(object):
except ValueError as e:
raise SerializeToJsonError(
- 'Failed to serialize {0} field: {1}.'.format(field.name, e))
+ 'Failed to serialize {0} field: {1}.'.format(field.name, e)) from e
return js
@@ -286,10 +288,11 @@ class _Printer(object):
if enum_value is not None:
return enum_value.name
else:
- if field.file.syntax == 'proto3':
+ if field.enum_type.is_closed:
+ raise SerializeToJsonError('Enum field contains an integer value '
+ 'which can not mapped to an enum value.')
+ else:
return value
- raise SerializeToJsonError('Enum field contains an integer value '
- 'which can not mapped to an enum value.')
elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_STRING:
if field.type == descriptor.FieldDescriptor.TYPE_BYTES:
# Use base64 Data encoding for bytes
@@ -352,8 +355,14 @@ class _Printer(object):
return None
if which == 'list_value':
return self._ListValueMessageToJsonObject(message.list_value)
- if which == 'struct_value':
- value = message.struct_value
+ if which == 'number_value':
+ value = message.number_value
+ if math.isinf(value):
+ raise ValueError('Fail to serialize Infinity for Value.number_value, '
+ 'which would parse as string_value')
+ if math.isnan(value):
+ raise ValueError('Fail to serialize NaN for Value.number_value, '
+ 'which would parse as string_value')
else:
value = getattr(message, which)
oneof_descriptor = message.DESCRIPTOR.fields_by_name[which]
@@ -397,10 +406,11 @@ def _CreateMessageFromTypeUrl(type_url, descriptor_pool):
type_name = type_url.split('/')[-1]
try:
message_descriptor = pool.FindMessageTypeByName(type_name)
- except KeyError:
+ except KeyError as e:
raise TypeError(
- 'Can not find message descriptor by type_url: {0}'.format(type_url))
- message_class = db.GetPrototype(message_descriptor)
+ 'Can not find message descriptor by type_url: {0}'.format(type_url)
+ ) from e
+ message_class = message_factory.GetMessageClass(message_descriptor)
return message_class()
@@ -432,7 +442,7 @@ def Parse(text,
try:
js = json.loads(text, object_pairs_hook=_DuplicateChecker)
except ValueError as e:
- raise ParseError('Failed to load JSON: {0}.'.format(str(e)))
+ raise ParseError('Failed to load JSON: {0}.'.format(str(e))) from e
return ParseDict(js, message, ignore_unknown_fields, descriptor_pool,
max_recursion_depth)
@@ -624,13 +634,19 @@ class _Parser(object):
'{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))
+ raise ParseError(
+ 'Failed to parse {0} field: {1}.'.format(name, e)
+ ) from e
else:
- raise ParseError(str(e))
+ raise ParseError(str(e)) from e
except ValueError as e:
- raise ParseError('Failed to parse {0} field: {1}.'.format(name, e))
+ raise ParseError(
+ 'Failed to parse {0} field: {1}.'.format(name, e)
+ ) from e
except TypeError as e:
- raise ParseError('Failed to parse {0} field: {1}.'.format(name, e))
+ raise ParseError(
+ 'Failed to parse {0} field: {1}.'.format(name, e)
+ ) from e
def _ConvertAnyMessage(self, value, message, path):
"""Convert a JSON representation into Any message."""
@@ -638,14 +654,15 @@ class _Parser(object):
return
try:
type_url = value['@type']
- except KeyError:
+ except KeyError as e:
raise ParseError(
- '@type is missing when parsing any message at {0}'.format(path))
+ '@type is missing when parsing any message at {0}'.format(path)
+ ) from e
try:
sub_message = _CreateMessageFromTypeUrl(type_url, self.descriptor_pool)
except TypeError as e:
- raise ParseError('{0} at {1}'.format(e, path))
+ raise ParseError('{0} at {1}'.format(e, path)) from e
message_descriptor = sub_message.DESCRIPTOR
full_name = message_descriptor.full_name
if _IsWrapperMessage(message_descriptor):
@@ -670,7 +687,7 @@ class _Parser(object):
try:
message.FromJsonString(value)
except ValueError as e:
- raise ParseError('{0} at {1}'.format(e, path))
+ raise ParseError('{0} at {1}'.format(e, path)) from e
def _ConvertValueMessage(self, value, message, path):
"""Convert a JSON representation into Value message."""
@@ -794,18 +811,18 @@ def _ConvertScalarFieldValue(value, field, path, require_str=False):
try:
number = int(value)
enum_value = field.enum_type.values_by_number.get(number, None)
- except ValueError:
+ except ValueError as e:
raise ParseError('Invalid enum value {0} for enum type {1}'.format(
- value, field.enum_type.full_name))
+ value, field.enum_type.full_name)) from e
if enum_value is None:
- if field.file.syntax == 'proto3':
- # Proto3 accepts unknown enums.
+ if field.enum_type.is_closed:
+ raise ParseError('Invalid enum value {0} for enum type {1}'.format(
+ value, field.enum_type.full_name))
+ else:
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))
+ raise ParseError('{0} at {1}'.format(e, path)) from e
def _ConvertInteger(value):
@@ -857,7 +874,7 @@ def _ConvertFloat(value, field):
try:
# Assume Python compatible syntax.
return float(value)
- except ValueError:
+ except ValueError as e:
# Check alternative spellings.
if value == _NEG_INFINITY:
return float('-inf')
@@ -866,7 +883,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)) from e
def _ConvertBool(value, require_str):
diff --git a/contrib/python/protobuf/py3/google/protobuf/message.py b/contrib/python/protobuf/py3/google/protobuf/message.py
index 76c6802f709..37b9c4054e9 100644
--- a/contrib/python/protobuf/py3/google/protobuf/message.py
+++ b/contrib/python/protobuf/py3/google/protobuf/message.py
@@ -74,7 +74,8 @@ class Message(object):
__slots__ = []
- #: The :class:`google.protobuf.descriptor.Descriptor` for this message type.
+ #: The :class:`google.protobuf.Descriptor`
+ # for this message type.
DESCRIPTOR = None
def __deepcopy__(self, memo=None):
@@ -191,7 +192,7 @@ class Message(object):
raise NotImplementedError
def ParseFromString(self, serialized):
- """Parse serialized protocol buffer data into this message.
+ """Parse serialized protocol buffer data in binary form into this message.
Like :func:`MergeFromString()`, except we clear the object first.
@@ -311,13 +312,13 @@ class Message(object):
"""
raise NotImplementedError
- def HasExtension(self, extension_handle):
+ def HasExtension(self, field_descriptor):
"""Checks if a certain extension is present for this message.
Extensions are retrieved using the :attr:`Extensions` mapping (if present).
Args:
- extension_handle: The handle for the extension to check.
+ field_descriptor: The field descriptor for the extension to check.
Returns:
bool: Whether the extension is present for this message.
@@ -329,11 +330,11 @@ class Message(object):
"""
raise NotImplementedError
- def ClearExtension(self, extension_handle):
+ def ClearExtension(self, field_descriptor):
"""Clears the contents of a given extension.
Args:
- extension_handle: The handle for the extension to clear.
+ field_descriptor: The field descriptor for the extension to clear.
"""
raise NotImplementedError
@@ -367,7 +368,7 @@ class Message(object):
raise NotImplementedError
@staticmethod
- def RegisterExtension(extension_handle):
+ def RegisterExtension(field_descriptor):
raise NotImplementedError
def _SetListener(self, message_listener):
diff --git a/contrib/python/protobuf/py3/google/protobuf/message_factory.py b/contrib/python/protobuf/py3/google/protobuf/message_factory.py
index 8d652045816..fac1165c517 100644
--- a/contrib/python/protobuf/py3/google/protobuf/message_factory.py
+++ b/contrib/python/protobuf/py3/google/protobuf/message_factory.py
@@ -39,6 +39,8 @@ my_proto_instance = message_classes['some.proto.package.MessageName']()
__author__ = '[email protected] (Matt Toia)'
+import warnings
+
from google.protobuf.internal import api_implementation
from google.protobuf import descriptor_pool
from google.protobuf import message
@@ -53,6 +55,95 @@ else:
_GENERATED_PROTOCOL_MESSAGE_TYPE = message_impl.GeneratedProtocolMessageType
+def GetMessageClass(descriptor):
+ """Obtains a proto2 message class based on the passed in descriptor.
+
+ Passing a descriptor with a fully qualified name matching a previous
+ invocation will cause the same class to be returned.
+
+ Args:
+ descriptor: The descriptor to build from.
+
+ Returns:
+ A class describing the passed in descriptor.
+ """
+ concrete_class = getattr(descriptor, '_concrete_class', None)
+ if concrete_class:
+ return concrete_class
+ return _InternalCreateMessageClass(descriptor)
+
+
+def GetMessageClassesForFiles(files, pool):
+ """Gets all the messages from specified files.
+
+ This will find and resolve dependencies, failing if the descriptor
+ pool cannot satisfy them.
+
+ Args:
+ files: The file names to extract messages from.
+ pool: The descriptor pool to find the files including the dependent
+ files.
+
+ Returns:
+ A dictionary mapping proto names to the message classes.
+ """
+ result = {}
+ for file_name in files:
+ file_desc = pool.FindFileByName(file_name)
+ for desc in file_desc.message_types_by_name.values():
+ result[desc.full_name] = GetMessageClass(desc)
+
+ # While the extension FieldDescriptors are created by the descriptor pool,
+ # the python classes created in the factory need them to be registered
+ # explicitly, which is done below.
+ #
+ # The call to RegisterExtension will specifically check if the
+ # extension was already registered on the object and either
+ # ignore the registration if the original was the same, or raise
+ # an error if they were different.
+
+ for extension in file_desc.extensions_by_name.values():
+ extended_class = GetMessageClass(extension.containing_type)
+ extended_class.RegisterExtension(extension)
+ # Recursively load protos for extension field, in order to be able to
+ # fully represent the extension. This matches the behavior for regular
+ # fields too.
+ if extension.message_type:
+ GetMessageClass(extension.message_type)
+ return result
+
+
+def _InternalCreateMessageClass(descriptor):
+ """Builds a proto2 message class based on the passed in descriptor.
+
+ Args:
+ descriptor: The descriptor to build from.
+
+ Returns:
+ A class describing the passed in descriptor.
+ """
+ descriptor_name = descriptor.name
+ result_class = _GENERATED_PROTOCOL_MESSAGE_TYPE(
+ descriptor_name,
+ (message.Message,),
+ {
+ 'DESCRIPTOR': descriptor,
+ # If module not set, it wrongly points to message_factory module.
+ '__module__': None,
+ })
+ for field in descriptor.fields:
+ if field.message_type:
+ GetMessageClass(field.message_type)
+ for extension in result_class.DESCRIPTOR.extensions:
+ extended_class = GetMessageClass(extension.containing_type)
+ extended_class.RegisterExtension(extension)
+ if extension.message_type:
+ GetMessageClass(extension.message_type)
+ return result_class
+
+
+# Deprecated. Please use GetMessageClass() or GetMessageClassesForFiles()
+# method above instead.
class MessageFactory(object):
"""Factory for creating Proto2 messages from descriptors in a pool."""
@@ -60,9 +151,6 @@ class MessageFactory(object):
"""Initializes a new factory."""
self.pool = pool or descriptor_pool.DescriptorPool()
- # local cache of all classes built from protobuf descriptors
- self._classes = {}
-
def GetPrototype(self, descriptor):
"""Obtains a proto2 message class based on the passed in descriptor.
@@ -75,21 +163,17 @@ class MessageFactory(object):
Returns:
A class describing the passed in descriptor.
"""
- if descriptor not in self._classes:
- result_class = self.CreatePrototype(descriptor)
- # The assignment to _classes is redundant for the base implementation, but
- # might avoid confusion in cases where CreatePrototype gets overridden and
- # does not call the base implementation.
- self._classes[descriptor] = result_class
- return result_class
- return self._classes[descriptor]
+ # TODO(b/258832141): add this warning
+ # warnings.warn('MessageFactory class is deprecated. Please use '
+ # 'GetMessageClass() instead of MessageFactory.GetPrototype. '
+ # 'MessageFactory class will be removed after 2024.')
+ return GetMessageClass(descriptor)
def CreatePrototype(self, descriptor):
"""Builds a proto2 message class based on the passed in descriptor.
Don't call this function directly, it always creates a new class. Call
- GetPrototype() instead. This method is meant to be overridden in subblasses
- to perform additional operations on the newly constructed class.
+ GetMessageClass() instead.
Args:
descriptor: The descriptor to build from.
@@ -97,30 +181,11 @@ class MessageFactory(object):
Returns:
A class describing the passed in descriptor.
"""
- descriptor_name = descriptor.name
- result_class = _GENERATED_PROTOCOL_MESSAGE_TYPE(
- descriptor_name,
- (message.Message,),
- {
- 'DESCRIPTOR': descriptor,
- # If module not set, it wrongly points to message_factory module.
- '__module__': None,
- })
- result_class._FACTORY = self # pylint: disable=protected-access
- # Assign in _classes before doing recursive calls to avoid infinite
- # recursion.
- self._classes[descriptor] = result_class
- for field in descriptor.fields:
- if field.message_type:
- self.GetPrototype(field.message_type)
- for extension in result_class.DESCRIPTOR.extensions:
- if extension.containing_type not in self._classes:
- self.GetPrototype(extension.containing_type)
- extended_class = self._classes[extension.containing_type]
- extended_class.RegisterExtension(extension)
- if extension.message_type:
- self.GetPrototype(extension.message_type)
- return result_class
+ # TODO(b/258832141): add this warning
+ # warnings.warn('Directly call CreatePrototype is wrong. Please use '
+ # 'GetMessageClass() method instead. Directly use '
+ # 'CreatePrototype will raise error after July 2023.')
+ return _InternalCreateMessageClass(descriptor)
def GetMessages(self, files):
"""Gets all the messages from a specified file.
@@ -136,39 +201,20 @@ class MessageFactory(object):
any dependent messages as well as any messages defined in the same file as
a specified message.
"""
- result = {}
- for file_name in files:
- file_desc = self.pool.FindFileByName(file_name)
- for desc in file_desc.message_types_by_name.values():
- result[desc.full_name] = self.GetPrototype(desc)
-
- # While the extension FieldDescriptors are created by the descriptor pool,
- # the python classes created in the factory need them to be registered
- # explicitly, which is done below.
- #
- # The call to RegisterExtension will specifically check if the
- # extension was already registered on the object and either
- # ignore the registration if the original was the same, or raise
- # an error if they were different.
-
- for extension in file_desc.extensions_by_name.values():
- if extension.containing_type not in self._classes:
- self.GetPrototype(extension.containing_type)
- extended_class = self._classes[extension.containing_type]
- extended_class.RegisterExtension(extension)
- if extension.message_type:
- self.GetPrototype(extension.message_type)
- return result
-
-
-_FACTORY = MessageFactory()
-
-
-def GetMessages(file_protos):
+ # TODO(b/258832141): add this warning
+ # warnings.warn('MessageFactory class is deprecated. Please use '
+ # 'GetMessageClassesForFiles() instead of '
+ # 'MessageFactory.GetMessages(). MessageFactory class '
+ # 'will be removed after 2024.')
+ return GetMessageClassesForFiles(files, self.pool)
+
+
+def GetMessages(file_protos, pool=None):
"""Builds a dictionary of all the messages available in a set of files.
Args:
file_protos: Iterable of FileDescriptorProto to build messages out of.
+ pool: The descriptor pool to add the file protos.
Returns:
A dictionary mapping proto names to the message classes. This will include
@@ -177,13 +223,15 @@ def GetMessages(file_protos):
"""
# The cpp implementation of the protocol buffer library requires to add the
# message in topological order of the dependency graph.
+ des_pool = pool or descriptor_pool.DescriptorPool()
file_by_name = {file_proto.name: file_proto for file_proto in file_protos}
def _AddFile(file_proto):
for dependency in file_proto.dependency:
if dependency in file_by_name:
# Remove from elements to be visited, in order to cut cycles.
_AddFile(file_by_name.pop(dependency))
- _FACTORY.pool.Add(file_proto)
+ des_pool.Add(file_proto)
while file_by_name:
_AddFile(file_by_name.popitem()[1])
- return _FACTORY.GetMessages([file_proto.name for file_proto in file_protos])
+ return GetMessageClassesForFiles(
+ [file_proto.name for file_proto in file_protos], des_pool)
diff --git a/contrib/python/protobuf/py3/google/protobuf/proto_api.h b/contrib/python/protobuf/py3/google/protobuf/proto_api.h
index 9969a91f446..4e910e07cb1 100644
--- a/contrib/python/protobuf/py3/google/protobuf/proto_api.h
+++ b/contrib/python/protobuf/py3/google/protobuf/proto_api.h
@@ -48,8 +48,8 @@
#define PY_SSIZE_T_CLEAN
#include <Python.h>
-#include <google/protobuf/descriptor_database.h>
-#include <google/protobuf/message.h>
+#include "google/protobuf/descriptor_database.h"
+#include "google/protobuf/message.h"
namespace google {
namespace protobuf {
@@ -133,8 +133,7 @@ struct PyProto_API {
};
inline const char* PyProtoAPICapsuleName() {
- static const char kCapsuleName[] =
- "google.protobuf.pyext._message.proto_API";
+ static const char kCapsuleName[] = "google.protobuf.pyext._message.proto_API";
return kCapsuleName;
}
diff --git a/contrib/python/protobuf/py3/google/protobuf/proto_builder.py b/contrib/python/protobuf/py3/google/protobuf/proto_builder.py
index a4667ce63ec..8dab8b3ee08 100644
--- a/contrib/python/protobuf/py3/google/protobuf/proto_builder.py
+++ b/contrib/python/protobuf/py3/google/protobuf/proto_builder.py
@@ -36,22 +36,23 @@ import os
from google.protobuf import descriptor_pb2
from google.protobuf import descriptor
+from google.protobuf import descriptor_pool
from google.protobuf import message_factory
-def _GetMessageFromFactory(factory, full_name):
+def _GetMessageFromFactory(pool, full_name):
"""Get a proto class from the MessageFactory by name.
Args:
- factory: a MessageFactory instance.
+ pool: a descriptor pool.
full_name: str, the fully qualified name of the proto type.
Returns:
A class, for the type identified by full_name.
Raises:
KeyError, if the proto is not found in the factory's descriptor pool.
"""
- proto_descriptor = factory.pool.FindMessageTypeByName(full_name)
- proto_cls = factory.GetPrototype(proto_descriptor)
+ proto_descriptor = pool.FindMessageTypeByName(full_name)
+ proto_cls = message_factory.GetMessageClass(proto_descriptor)
return proto_cls
@@ -69,11 +70,10 @@ def MakeSimpleProtoClass(fields, full_name=None, pool=None):
Returns:
a class, the new protobuf class with a FileDescriptor.
"""
- factory = message_factory.MessageFactory(pool=pool)
-
+ pool_instance = pool or descriptor_pool.DescriptorPool()
if full_name is not None:
try:
- proto_cls = _GetMessageFromFactory(factory, full_name)
+ proto_cls = _GetMessageFromFactory(pool_instance, full_name)
return proto_cls
except KeyError:
# The factory's DescriptorPool doesn't know about this class yet.
@@ -99,16 +99,16 @@ def MakeSimpleProtoClass(fields, full_name=None, pool=None):
full_name = ('net.proto2.python.public.proto_builder.AnonymousProto_' +
fields_hash.hexdigest())
try:
- proto_cls = _GetMessageFromFactory(factory, full_name)
+ proto_cls = _GetMessageFromFactory(pool_instance, full_name)
return proto_cls
except KeyError:
# The factory's DescriptorPool doesn't know about this class yet.
pass
# This is the first time we see this proto: add a new descriptor to the pool.
- factory.pool.Add(
+ pool_instance.Add(
_MakeFileDescriptorProto(proto_file_name, full_name, field_items))
- return _GetMessageFromFactory(factory, full_name)
+ return _GetMessageFromFactory(pool_instance, full_name)
def _MakeFileDescriptorProto(proto_file_name, full_name, field_items):
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/__init__.py b/contrib/python/protobuf/py3/google/protobuf/pyext/__init__.py
index 0cb9329b2c4..e69de29bb2d 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/__init__.py
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/__init__.py
@@ -1,4 +0,0 @@
-import warnings
-
-with warnings.catch_warnings(action="ignore", category=DeprecationWarning):
- import google.protobuf.pyext._message
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor.cc b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor.cc
index a5254ce97bf..acb907a3e93 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor.cc
@@ -30,7 +30,9 @@
// Author: [email protected] (Petar Petrov)
-#include <google/protobuf/pyext/descriptor.h>
+#include "google/protobuf/pyext/descriptor.h"
+
+#include "y_absl/log/absl_check.h"
#define PY_SSIZE_T_CLEAN
#include <Python.h>
@@ -40,15 +42,15 @@
#include <string>
#include <unordered_map>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/dynamic_message.h>
-#include <google/protobuf/pyext/descriptor_containers.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/stubs/hash.h>
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/dynamic_message.h"
+#include "google/protobuf/pyext/descriptor_containers.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 "y_absl/strings/string_view.h"
+#include "google/protobuf/io/coded_stream.h"
#define PyString_AsStringAndSize(ob, charpp, sizep) \
(PyUnicode_Check(ob) \
@@ -404,7 +406,7 @@ PyObject* NewInternedDescriptor(PyTypeObject* type,
std::unordered_map<const void*, PyObject*>::iterator it =
interned_descriptors->find(descriptor);
if (it != interned_descriptors->end()) {
- GOOGLE_DCHECK(Py_TYPE(it->second) == type);
+ Y_ABSL_DCHECK(Py_TYPE(it->second) == type);
Py_INCREF(it->second);
return it->second;
}
@@ -542,6 +544,12 @@ static PyObject* GetConcreteClass(PyBaseDescriptor* self, void *closure) {
GetDescriptorPool_FromPool(
_GetDescriptor(self)->file()->pool())->py_message_factory,
_GetDescriptor(self)));
+
+ if (concrete_class == nullptr) {
+ PyErr_Clear();
+ return nullptr;
+ }
+
Py_XINCREF(concrete_class);
return concrete_class->AsPyObject();
}
@@ -1179,6 +1187,11 @@ static PyObject* GetHasOptions(PyBaseDescriptor *self, void *closure) {
Py_RETURN_FALSE;
}
}
+
+static PyObject* GetIsClosed(PyBaseDescriptor* self, void* closure) {
+ return PyBool_FromLong(_GetDescriptor(self)->is_closed());
+}
+
static int SetHasOptions(PyBaseDescriptor *self, PyObject *value,
void *closure) {
return CheckCalledFromGeneratedFile("has_options");
@@ -1222,6 +1235,7 @@ static PyGetSetDef Getters[] = {
"Containing type"},
{"has_options", (getter)GetHasOptions, (setter)SetHasOptions,
"Has Options"},
+ {"is_closed", (getter)GetIsClosed, nullptr, "If the enum is closed"},
{"_options", (getter) nullptr, (setter)SetOptions, "Options"},
{"_serialized_options", (getter) nullptr, (setter)SetSerializedOptions,
"Serialized Options"},
@@ -1793,7 +1807,8 @@ static PyObject* FindMethodByName(PyBaseDescriptor *self, PyObject* arg) {
}
const MethodDescriptor* method_descriptor =
- _GetDescriptor(self)->FindMethodByName(StringParam(name, name_size));
+ _GetDescriptor(self)->FindMethodByName(
+ y_absl::string_view(name, name_size));
if (method_descriptor == nullptr) {
PyErr_Format(PyExc_KeyError, "Couldn't find method %.200s", name);
return nullptr;
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor.h b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor.h
index a383a7927a9..8559c660e67 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor.h
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor.h
@@ -36,15 +36,12 @@
#define PY_SSIZE_T_CLEAN
#include <Python.h>
-#include <google/protobuf/descriptor.h>
+#include "google/protobuf/descriptor.h"
namespace google {
namespace protobuf {
namespace python {
-// Should match the type of ConstStringParam.
-using StringParam = TProtoStringType;
-
extern PyTypeObject PyMessageDescriptor_Type;
extern PyTypeObject PyFieldDescriptor_Type;
extern PyTypeObject PyEnumDescriptor_Type;
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 b17d8348bf1..b1b1f157333 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_containers.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_containers.cc
@@ -49,14 +49,21 @@
// because the Python API is based on C, and does not play well with C++
// inheritance.
+// clang-format off
#define PY_SSIZE_T_CLEAN
+// This inclusion must appear before all the others.
#include <Python.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/pyext/descriptor_containers.h>
-#include <google/protobuf/pyext/descriptor_pool.h>
-#include <google/protobuf/pyext/descriptor.h>
-#include <google/protobuf/pyext/scoped_pyobject_ptr.h>
+#include <string>
+
+#include "google/protobuf/pyext/descriptor_containers.h"
+// clang-format on
+
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/pyext/descriptor.h"
+#include "google/protobuf/pyext/descriptor_pool.h"
+#include "google/protobuf/pyext/scoped_pyobject_ptr.h"
+#include "y_absl/strings/string_view.h"
#define PyString_AsStringAndSize(ob, charpp, sizep) \
(PyUnicode_Check(ob) \
@@ -75,9 +82,9 @@ struct PyContainer;
typedef int (*CountMethod)(PyContainer* self);
typedef const void* (*GetByIndexMethod)(PyContainer* self, int index);
typedef const void* (*GetByNameMethod)(PyContainer* self,
- ConstStringParam name);
+ y_absl::string_view name);
typedef const void* (*GetByCamelcaseNameMethod)(PyContainer* self,
- ConstStringParam name);
+ y_absl::string_view name);
typedef const void* (*GetByNumberMethod)(PyContainer* self, int index);
typedef PyObject* (*NewObjectFromItemMethod)(const void* descriptor);
typedef const TProtoStringType& (*GetItemNameMethod)(const void* descriptor);
@@ -175,8 +182,8 @@ static bool _GetItemByKey(PyContainer* self, PyObject* key, const void** item) {
}
return false;
}
- *item = self->container_def->get_by_name_fn(self,
- StringParam(name, name_size));
+ *item = self->container_def->get_by_name_fn(
+ self, y_absl::string_view(name, name_size));
return true;
}
case PyContainer::KIND_BYCAMELCASENAME: {
@@ -192,7 +199,7 @@ static bool _GetItemByKey(PyContainer* self, PyObject* key, const void** item) {
return false;
}
*item = self->container_def->get_by_camelcase_name_fn(
- self, StringParam(camelcase_name, name_size));
+ self, y_absl::string_view(camelcase_name, name_size));
return true;
}
case PyContainer::KIND_BYNUMBER: {
@@ -958,12 +965,12 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->field_count();
}
-static const void* GetByName(PyContainer* self, ConstStringParam name) {
+static const void* GetByName(PyContainer* self, y_absl::string_view name) {
return GetDescriptor(self)->FindFieldByName(name);
}
static const void* GetByCamelcaseName(PyContainer* self,
- ConstStringParam name) {
+ y_absl::string_view name) {
return GetDescriptor(self)->FindFieldByCamelcaseName(name);
}
@@ -1028,7 +1035,7 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->nested_type_count();
}
-static const void* GetByName(PyContainer* self, ConstStringParam name) {
+static const void* GetByName(PyContainer* self, y_absl::string_view name) {
return GetDescriptor(self)->FindNestedTypeByName(name);
}
@@ -1080,7 +1087,7 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->enum_type_count();
}
-static const void* GetByName(PyContainer* self, ConstStringParam name) {
+static const void* GetByName(PyContainer* self, y_absl::string_view name) {
return GetDescriptor(self)->FindEnumTypeByName(name);
}
@@ -1143,7 +1150,7 @@ static int Count(PyContainer* self) {
return count;
}
-static const void* GetByName(PyContainer* self, ConstStringParam name) {
+static const void* GetByName(PyContainer* self, y_absl::string_view name) {
return GetDescriptor(self)->FindEnumValueByName(name);
}
@@ -1194,7 +1201,7 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->extension_count();
}
-static const void* GetByName(PyContainer* self, ConstStringParam name) {
+static const void* GetByName(PyContainer* self, y_absl::string_view name) {
return GetDescriptor(self)->FindExtensionByName(name);
}
@@ -1246,7 +1253,7 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->oneof_decl_count();
}
-static const void* GetByName(PyContainer* self, ConstStringParam name) {
+static const void* GetByName(PyContainer* self, y_absl::string_view name) {
return GetDescriptor(self)->FindOneofByName(name);
}
@@ -1304,7 +1311,7 @@ static const void* GetByIndex(PyContainer* self, int index) {
return GetDescriptor(self)->value(index);
}
-static const void* GetByName(PyContainer* self, ConstStringParam name) {
+static const void* GetByName(PyContainer* self, y_absl::string_view name) {
return GetDescriptor(self)->FindValueByName(name);
}
@@ -1408,7 +1415,7 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->method_count();
}
-static const void* GetByName(PyContainer* self, ConstStringParam name) {
+static const void* GetByName(PyContainer* self, y_absl::string_view name) {
return GetDescriptor(self)->FindMethodByName(name);
}
@@ -1462,7 +1469,7 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->message_type_count();
}
-static const void* GetByName(PyContainer* self, ConstStringParam name) {
+static const void* GetByName(PyContainer* self, y_absl::string_view name) {
return GetDescriptor(self)->FindMessageTypeByName(name);
}
@@ -1502,7 +1509,7 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->enum_type_count();
}
-static const void* GetByName(PyContainer* self, ConstStringParam name) {
+static const void* GetByName(PyContainer* self, y_absl::string_view name) {
return GetDescriptor(self)->FindEnumTypeByName(name);
}
@@ -1542,7 +1549,7 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->extension_count();
}
-static const void* GetByName(PyContainer* self, ConstStringParam name) {
+static const void* GetByName(PyContainer* self, y_absl::string_view name) {
return GetDescriptor(self)->FindExtensionByName(name);
}
@@ -1582,7 +1589,7 @@ static int Count(PyContainer* self) {
return GetDescriptor(self)->service_count();
}
-static const void* GetByName(PyContainer* self, ConstStringParam name) {
+static const void* GetByName(PyContainer* self, y_absl::string_view name) {
return GetDescriptor(self)->FindServiceByName(name);
}
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 14f5bf22301..abd1269efc0 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_database.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_database.cc
@@ -31,15 +31,16 @@
// This file defines a C++ DescriptorDatabase, which wraps a Python Database
// and delegate all its operations to Python methods.
-#include <google/protobuf/pyext/descriptor_database.h>
+#include "google/protobuf/pyext/descriptor_database.h"
#include <cstdint>
+#include <string>
+#include <vector>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/pyext/message.h>
-#include <google/protobuf/pyext/scoped_pyobject_ptr.h>
+#include "google/protobuf/descriptor.pb.h"
+#include "y_absl/log/absl_log.h"
+#include "google/protobuf/pyext/message.h"
+#include "google/protobuf/pyext/scoped_pyobject_ptr.h"
namespace google {
namespace protobuf {
@@ -61,7 +62,7 @@ static bool GetFileDescriptorProto(PyObject* py_descriptor,
// Expected error: item was simply not found.
PyErr_Clear();
} else {
- GOOGLE_LOG(ERROR) << "DescriptorDatabase method raised an error";
+ Y_ABSL_LOG(ERROR) << "DescriptorDatabase method raised an error";
PyErr_Print();
}
return false;
@@ -85,7 +86,7 @@ static bool GetFileDescriptorProto(PyObject* py_descriptor,
ScopedPyObjectPtr serialized_pb(
PyObject_CallMethod(py_descriptor, "SerializeToString", nullptr));
if (serialized_pb == nullptr) {
- GOOGLE_LOG(ERROR)
+ Y_ABSL_LOG(ERROR)
<< "DescriptorDatabase method did not return a FileDescriptorProto";
PyErr_Print();
return false;
@@ -93,14 +94,14 @@ static bool GetFileDescriptorProto(PyObject* py_descriptor,
char* str;
Py_ssize_t len;
if (PyBytes_AsStringAndSize(serialized_pb.get(), &str, &len) < 0) {
- GOOGLE_LOG(ERROR)
+ Y_ABSL_LOG(ERROR)
<< "DescriptorDatabase method did not return a FileDescriptorProto";
PyErr_Print();
return false;
}
FileDescriptorProto file_proto;
if (!file_proto.ParseFromArray(str, len)) {
- GOOGLE_LOG(ERROR)
+ Y_ABSL_LOG(ERROR)
<< "DescriptorDatabase method did not return a FileDescriptorProto";
return false;
}
@@ -171,9 +172,8 @@ bool PyDescriptorDatabase::FindAllExtensionNumbers(
ScopedPyObjectPtr item(PySequence_GetItem(py_list.get(), i));
item_value = PyLong_AsLong(item.get());
if (item_value < 0) {
- GOOGLE_LOG(ERROR)
- << "FindAllExtensionNumbers method did not return "
- << "valid extension numbers.";
+ Y_ABSL_LOG(ERROR) << "FindAllExtensionNumbers method did not return "
+ << "valid extension numbers.";
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 08318ff98fd..81040b21729 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_database.h
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_database.h
@@ -34,7 +34,10 @@
#define PY_SSIZE_T_CLEAN
#include <Python.h>
-#include <google/protobuf/descriptor_database.h>
+#include <string>
+#include <vector>
+
+#include "google/protobuf/descriptor_database.h"
namespace google {
namespace protobuf {
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 2dd47bdb235..4ab1f9bd197 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_pool.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_pool.cc
@@ -30,19 +30,27 @@
// Implements the DescriptorPool, which collects all descriptors.
+#include <string>
#include <unordered_map>
+#include <utility>
+#include <vector>
#define PY_SSIZE_T_CLEAN
#include <Python.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/pyext/descriptor.h>
-#include <google/protobuf/pyext/descriptor_database.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/stubs/hash.h>
+#include "google/protobuf/descriptor.pb.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_replace.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/pyext/descriptor.h"
+#include "google/protobuf/pyext/descriptor_database.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"
+
+// Must be included last.
+#include "google/protobuf/port_def.inc"
#define PyString_AsStringAndSize(ob, charpp, sizep) \
(PyUnicode_Check(ob) \
@@ -69,19 +77,19 @@ class BuildFileErrorCollector : public DescriptorPool::ErrorCollector {
public:
BuildFileErrorCollector() : error_message(""), had_errors_(false) {}
- void AddError(const TProtoStringType& filename, const TProtoStringType& element_name,
- const Message* descriptor, ErrorLocation location,
- const TProtoStringType& message) override {
+ void RecordError(y_absl::string_view filename, y_absl::string_view element_name,
+ const Message* descriptor, ErrorLocation location,
+ y_absl::string_view message) override {
// Replicates the logging behavior that happens in the C++ implementation
// when an error collector is not passed in.
if (!had_errors_) {
- error_message +=
- ("Invalid proto descriptor for file \"" + filename + "\":\n");
+ y_absl::StrAppend(&error_message, "Invalid proto descriptor for file \"",
+ filename, "\":\n");
had_errors_ = true;
}
// As this only happens on failure and will result in the program not
// running at all, no effort is made to optimize this string manipulation.
- error_message += (" " + element_name + ": " + message + "\n");
+ y_absl::StrAppend(&error_message, " ", element_name, ": ", message, "\n");
}
void Clear() {
@@ -151,20 +159,28 @@ static PyDescriptorPool* PyDescriptorPool_NewWithUnderlay(
}
static PyDescriptorPool* PyDescriptorPool_NewWithDatabase(
- DescriptorDatabase* database) {
+ DescriptorDatabase* database,
+ bool use_deprecated_legacy_json_field_conflicts) {
PyDescriptorPool* cpool = _CreateDescriptorPool();
if (cpool == nullptr) {
return nullptr;
}
+ DescriptorPool* pool;
if (database != nullptr) {
cpool->error_collector = new BuildFileErrorCollector();
- cpool->pool = new DescriptorPool(database, cpool->error_collector);
+ pool = new DescriptorPool(database, cpool->error_collector);
cpool->is_mutable = false;
cpool->database = database;
} else {
- cpool->pool = new DescriptorPool();
+ pool = new DescriptorPool();
cpool->is_mutable = true;
}
+ if (use_deprecated_legacy_json_field_conflicts) {
+ PROTOBUF_IGNORE_DEPRECATION_START
+ pool->UseDeprecatedLegacyJsonFieldConflicts();
+ PROTOBUF_IGNORE_DEPRECATION_STOP
+ }
+ cpool->pool = pool;
cpool->is_owned = true;
if (!descriptor_pool_map->insert(std::make_pair(cpool->pool, cpool)).second) {
@@ -179,6 +195,7 @@ static PyDescriptorPool* PyDescriptorPool_NewWithDatabase(
// The public DescriptorPool constructor.
static PyObject* New(PyTypeObject* type,
PyObject* args, PyObject* kwargs) {
+ int use_deprecated_legacy_json_field_conflicts = 0;
static const char* kwlist[] = {"descriptor_db", nullptr};
PyObject* py_database = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O",
@@ -189,8 +206,8 @@ static PyObject* New(PyTypeObject* type,
if (py_database && py_database != Py_None) {
database = new PyDescriptorDatabase(py_database);
}
- return reinterpret_cast<PyObject*>(
- PyDescriptorPool_NewWithDatabase(database));
+ return reinterpret_cast<PyObject*>(PyDescriptorPool_NewWithDatabase(
+ database, use_deprecated_legacy_json_field_conflicts));
}
static void Dealloc(PyObject* pself) {
@@ -249,7 +266,7 @@ static PyObject* FindMessageByName(PyObject* self, PyObject* arg) {
const Descriptor* message_descriptor =
reinterpret_cast<PyDescriptorPool*>(self)->pool->FindMessageTypeByName(
- StringParam(name, name_size));
+ y_absl::string_view(name, name_size));
if (message_descriptor == nullptr) {
return SetErrorFromCollector(
@@ -273,7 +290,7 @@ static PyObject* FindFileByName(PyObject* self, PyObject* arg) {
PyDescriptorPool* py_pool = reinterpret_cast<PyDescriptorPool*>(self);
const FileDescriptor* file_descriptor =
- py_pool->pool->FindFileByName(StringParam(name, name_size));
+ py_pool->pool->FindFileByName(y_absl::string_view(name, name_size));
if (file_descriptor == nullptr) {
return SetErrorFromCollector(py_pool->error_collector, name, "file");
@@ -289,7 +306,7 @@ PyObject* FindFieldByName(PyDescriptorPool* self, PyObject* arg) {
}
const FieldDescriptor* field_descriptor =
- self->pool->FindFieldByName(StringParam(name, name_size));
+ self->pool->FindFieldByName(y_absl::string_view(name, name_size));
if (field_descriptor == nullptr) {
return SetErrorFromCollector(self->error_collector, name, "field");
}
@@ -310,7 +327,7 @@ PyObject* FindExtensionByName(PyDescriptorPool* self, PyObject* arg) {
}
const FieldDescriptor* field_descriptor =
- self->pool->FindExtensionByName(StringParam(name, name_size));
+ self->pool->FindExtensionByName(y_absl::string_view(name, name_size));
if (field_descriptor == nullptr) {
return SetErrorFromCollector(self->error_collector, name,
"extension field");
@@ -332,7 +349,7 @@ PyObject* FindEnumTypeByName(PyDescriptorPool* self, PyObject* arg) {
}
const EnumDescriptor* enum_descriptor =
- self->pool->FindEnumTypeByName(StringParam(name, name_size));
+ self->pool->FindEnumTypeByName(y_absl::string_view(name, name_size));
if (enum_descriptor == nullptr) {
return SetErrorFromCollector(self->error_collector, name, "enum");
}
@@ -353,7 +370,7 @@ PyObject* FindOneofByName(PyDescriptorPool* self, PyObject* arg) {
}
const OneofDescriptor* oneof_descriptor =
- self->pool->FindOneofByName(StringParam(name, name_size));
+ self->pool->FindOneofByName(y_absl::string_view(name, name_size));
if (oneof_descriptor == nullptr) {
return SetErrorFromCollector(self->error_collector, name, "oneof");
}
@@ -375,7 +392,7 @@ static PyObject* FindServiceByName(PyObject* self, PyObject* arg) {
const ServiceDescriptor* service_descriptor =
reinterpret_cast<PyDescriptorPool*>(self)->pool->FindServiceByName(
- StringParam(name, name_size));
+ y_absl::string_view(name, name_size));
if (service_descriptor == nullptr) {
return SetErrorFromCollector(
reinterpret_cast<PyDescriptorPool*>(self)->error_collector, name,
@@ -395,7 +412,7 @@ static PyObject* FindMethodByName(PyObject* self, PyObject* arg) {
const MethodDescriptor* method_descriptor =
reinterpret_cast<PyDescriptorPool*>(self)->pool->FindMethodByName(
- StringParam(name, name_size));
+ y_absl::string_view(name, name_size));
if (method_descriptor == nullptr) {
return SetErrorFromCollector(
reinterpret_cast<PyDescriptorPool*>(self)->error_collector, name,
@@ -415,7 +432,7 @@ static PyObject* FindFileContainingSymbol(PyObject* self, PyObject* arg) {
const FileDescriptor* file_descriptor =
reinterpret_cast<PyDescriptorPool*>(self)->pool->FindFileContainingSymbol(
- StringParam(name, name_size));
+ y_absl::string_view(name, name_size));
if (file_descriptor == nullptr) {
return SetErrorFromCollector(
reinterpret_cast<PyDescriptorPool*>(self)->error_collector, name,
@@ -818,3 +835,5 @@ PyObject* PyDescriptorPool_FromPool(const DescriptorPool* pool) {
} // namespace python
} // namespace protobuf
} // namespace google
+
+#include "google/protobuf/port_undef.inc"
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 5d3c3a95cc6..851cf31e870 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_pool.h
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/descriptor_pool.h
@@ -35,7 +35,7 @@
#include <Python.h>
#include <unordered_map>
-#include <google/protobuf/descriptor.h>
+#include "google/protobuf/descriptor.h"
namespace google {
namespace protobuf {
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 66703da898d..4fe68636790 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/extension_dict.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/extension_dict.cc
@@ -31,23 +31,23 @@
// Author: [email protected] (Anuraag Agrawal)
// Author: [email protected] (Johan Tibell)
-#include <google/protobuf/pyext/extension_dict.h>
+#include "google/protobuf/pyext/extension_dict.h"
#include <cstdint>
#include <memory>
-
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/dynamic_message.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/pyext/descriptor.h>
-#include <google/protobuf/pyext/message.h>
-#include <google/protobuf/pyext/message_factory.h>
-#include <google/protobuf/pyext/repeated_composite_container.h>
-#include <google/protobuf/pyext/repeated_scalar_container.h>
-#include <google/protobuf/pyext/scoped_pyobject_ptr.h>
+#include <vector>
+
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/dynamic_message.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/pyext/descriptor.h"
+#include "google/protobuf/pyext/message.h"
+#include "google/protobuf/pyext/message_factory.h"
+#include "google/protobuf/pyext/repeated_composite_container.h"
+#include "google/protobuf/pyext/repeated_scalar_container.h"
+#include "google/protobuf/pyext/scoped_pyobject_ptr.h"
+#include "y_absl/strings/string_view.h"
#define PyString_AsStringAndSize(ob, charpp, sizep) \
(PyUnicode_Check(ob) \
@@ -125,8 +125,9 @@ static void DeallocExtensionIterator(PyObject* _self) {
ExtensionIterator* self = reinterpret_cast<ExtensionIterator*>(_self);
self->fields.clear();
Py_XDECREF(self->extension_dict);
+ freefunc tp_free = Py_TYPE(_self)->tp_free;
self->~ExtensionIterator();
- Py_TYPE(_self)->tp_free(_self);
+ (*tp_free)(_self);
}
PyObject* subscript(ExtensionDict* self, PyObject* key) {
@@ -238,11 +239,11 @@ PyObject* _FindExtensionByName(ExtensionDict* self, PyObject* arg) {
PyDescriptorPool* pool = cmessage::GetFactoryForMessage(self->parent)->pool;
const FieldDescriptor* message_extension =
- pool->pool->FindExtensionByName(StringParam(name, name_size));
+ pool->pool->FindExtensionByName(y_absl::string_view(name, name_size));
if (message_extension == nullptr) {
// Is is the name of a message set extension?
const Descriptor* message_descriptor =
- pool->pool->FindMessageTypeByName(StringParam(name, name_size));
+ pool->pool->FindMessageTypeByName(y_absl::string_view(name, name_size));
if (message_descriptor && message_descriptor->extension_count() > 0) {
const FieldDescriptor* extension = message_descriptor->extension(0);
if (extension->is_extension() &&
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 86d2451a007..c5c2875936d 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/extension_dict.h
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/extension_dict.h
@@ -37,7 +37,7 @@
#define PY_SSIZE_T_CLEAN
#include <Python.h>
-#include <google/protobuf/pyext/message.h>
+#include "google/protobuf/pyext/message.h"
namespace google {
namespace protobuf {
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/field.cc b/contrib/python/protobuf/py3/google/protobuf/pyext/field.cc
index 0d3b0b96071..daa95d0069c 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/field.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/field.cc
@@ -28,11 +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/pyext/field.h>
+#include "google/protobuf/pyext/field.h"
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/pyext/descriptor.h>
-#include <google/protobuf/pyext/message.h>
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/pyext/descriptor.h"
+#include "google/protobuf/pyext/message.h"
namespace google {
namespace protobuf {
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 17bf0988edc..032cfa8577a 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/map_container.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/map_container.cc
@@ -30,21 +30,19 @@
// Author: [email protected] (Josh Haberman)
-#include <google/protobuf/pyext/map_container.h>
+#include "google/protobuf/pyext/map_container.h"
#include <cstdint>
#include <memory>
+#include <string>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/map.h>
-#include <google/protobuf/map_field.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/pyext/message.h>
-#include <google/protobuf/pyext/message_factory.h>
-#include <google/protobuf/pyext/repeated_composite_container.h>
-#include <google/protobuf/pyext/scoped_pyobject_ptr.h>
-#include <google/protobuf/stubs/map_util.h>
+#include "google/protobuf/map.h"
+#include "google/protobuf/map_field.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/pyext/message.h"
+#include "google/protobuf/pyext/message_factory.h"
+#include "google/protobuf/pyext/repeated_composite_container.h"
+#include "google/protobuf/pyext/scoped_pyobject_ptr.h"
namespace google {
namespace protobuf {
@@ -55,7 +53,7 @@ namespace python {
class MapReflectionFriend {
public:
// Methods that are in common between the map types.
- static PyObject* Contains(PyObject* _self, PyObject* key);
+ static int Contains(PyObject* _self, PyObject* key);
static Py_ssize_t Length(PyObject* _self);
static PyObject* GetIterator(PyObject *_self);
static PyObject* IterNext(PyObject* _self);
@@ -126,27 +124,27 @@ static bool PythonToMapKey(MapContainer* self, PyObject* obj, MapKey* key) {
self->parent_field_descriptor->message_type()->map_key();
switch (field_descriptor->cpp_type()) {
case FieldDescriptor::CPPTYPE_INT32: {
- GOOGLE_CHECK_GET_INT32(obj, value, false);
+ PROTOBUF_CHECK_GET_INT32(obj, value, false);
key->SetInt32Value(value);
break;
}
case FieldDescriptor::CPPTYPE_INT64: {
- GOOGLE_CHECK_GET_INT64(obj, value, false);
+ PROTOBUF_CHECK_GET_INT64(obj, value, false);
key->SetInt64Value(value);
break;
}
case FieldDescriptor::CPPTYPE_UINT32: {
- GOOGLE_CHECK_GET_UINT32(obj, value, false);
+ PROTOBUF_CHECK_GET_UINT32(obj, value, false);
key->SetUInt32Value(value);
break;
}
case FieldDescriptor::CPPTYPE_UINT64: {
- GOOGLE_CHECK_GET_UINT64(obj, value, false);
+ PROTOBUF_CHECK_GET_UINT64(obj, value, false);
key->SetUInt64Value(value);
break;
}
case FieldDescriptor::CPPTYPE_BOOL: {
- GOOGLE_CHECK_GET_BOOL(obj, value, false);
+ PROTOBUF_CHECK_GET_BOOL(obj, value, false);
key->SetBoolValue(value);
break;
}
@@ -232,37 +230,37 @@ static bool PythonToMapValueRef(MapContainer* self, PyObject* obj,
self->parent_field_descriptor->message_type()->map_value();
switch (field_descriptor->cpp_type()) {
case FieldDescriptor::CPPTYPE_INT32: {
- GOOGLE_CHECK_GET_INT32(obj, value, false);
+ PROTOBUF_CHECK_GET_INT32(obj, value, false);
value_ref->SetInt32Value(value);
return true;
}
case FieldDescriptor::CPPTYPE_INT64: {
- GOOGLE_CHECK_GET_INT64(obj, value, false);
+ PROTOBUF_CHECK_GET_INT64(obj, value, false);
value_ref->SetInt64Value(value);
return true;
}
case FieldDescriptor::CPPTYPE_UINT32: {
- GOOGLE_CHECK_GET_UINT32(obj, value, false);
+ PROTOBUF_CHECK_GET_UINT32(obj, value, false);
value_ref->SetUInt32Value(value);
return true;
}
case FieldDescriptor::CPPTYPE_UINT64: {
- GOOGLE_CHECK_GET_UINT64(obj, value, false);
+ PROTOBUF_CHECK_GET_UINT64(obj, value, false);
value_ref->SetUInt64Value(value);
return true;
}
case FieldDescriptor::CPPTYPE_FLOAT: {
- GOOGLE_CHECK_GET_FLOAT(obj, value, false);
+ PROTOBUF_CHECK_GET_FLOAT(obj, value, false);
value_ref->SetFloatValue(value);
return true;
}
case FieldDescriptor::CPPTYPE_DOUBLE: {
- GOOGLE_CHECK_GET_DOUBLE(obj, value, false);
+ PROTOBUF_CHECK_GET_DOUBLE(obj, value, false);
value_ref->SetDoubleValue(value);
return true;
}
case FieldDescriptor::CPPTYPE_BOOL: {
- GOOGLE_CHECK_GET_BOOL(obj, value, false);
+ PROTOBUF_CHECK_GET_BOOL(obj, value, false);
value_ref->SetBoolValue(value);
return true;
}
@@ -275,7 +273,7 @@ static bool PythonToMapValueRef(MapContainer* self, PyObject* obj,
return true;
}
case FieldDescriptor::CPPTYPE_ENUM: {
- GOOGLE_CHECK_GET_INT32(obj, value, false);
+ PROTOBUF_CHECK_GET_INT32(obj, value, false);
if (allow_unknown_enum_values) {
value_ref->SetEnumValue(value);
return true;
@@ -354,7 +352,7 @@ PyObject* MapReflectionFriend::MergeFrom(PyObject* _self, PyObject* arg) {
Py_RETURN_NONE;
}
-PyObject* MapReflectionFriend::Contains(PyObject* _self, PyObject* key) {
+int MapReflectionFriend::Contains(PyObject* _self, PyObject* key) {
MapContainer* self = GetMap(_self);
const Message* message = self->parent->message;
@@ -362,14 +360,14 @@ PyObject* MapReflectionFriend::Contains(PyObject* _self, PyObject* key) {
MapKey map_key;
if (!PythonToMapKey(self, key, &map_key)) {
- return nullptr;
+ return -1;
}
if (reflection->ContainsMapKey(*message, self->parent_field_descriptor,
map_key)) {
- Py_RETURN_TRUE;
+ return 1;
} else {
- Py_RETURN_FALSE;
+ return 0;
}
}
@@ -468,12 +466,12 @@ static PyObject* ScalarMapGet(PyObject* self, PyObject* args,
return nullptr;
}
- ScopedPyObjectPtr is_present(MapReflectionFriend::Contains(self, key));
- if (is_present.get() == nullptr) {
+ auto is_present = MapReflectionFriend::Contains(self, key);
+ if (is_present < 0) {
return nullptr;
}
- if (PyObject_IsTrue(is_present.get())) {
+ if (is_present == 1) {
return MapReflectionFriend::ScalarMapGetItem(self, key);
} else {
if (default_value != nullptr) {
@@ -530,8 +528,6 @@ static void ScalarMapDealloc(PyObject* _self) {
}
static PyMethodDef ScalarMapMethods[] = {
- {"__contains__", MapReflectionFriend::Contains, METH_O,
- "Tests whether a key is a member of the map."},
{"clear", (PyCFunction)Clear, METH_NOARGS,
"Removes all elements from the map."},
{"get", (PyCFunction)ScalarMapGet, METH_VARARGS | METH_KEYWORDS,
@@ -556,6 +552,7 @@ static PyType_Slot ScalarMapContainer_Type_slots[] = {
{Py_mp_subscript, (void*)MapReflectionFriend::ScalarMapGetItem},
{Py_mp_ass_subscript, (void*)MapReflectionFriend::ScalarMapSetItem},
{Py_tp_methods, (void*)ScalarMapMethods},
+ {Py_sq_contains, (void*)MapReflectionFriend::Contains},
{Py_tp_iter, (void*)MapReflectionFriend::GetIterator},
{Py_tp_repr, (void*)MapReflectionFriend::ScalarMapToStr},
{0, nullptr},
@@ -715,12 +712,12 @@ PyObject* MessageMapGet(PyObject* self, PyObject* args, PyObject* kwargs) {
return nullptr;
}
- ScopedPyObjectPtr is_present(MapReflectionFriend::Contains(self, key));
- if (is_present.get() == nullptr) {
+ auto is_present = MapReflectionFriend::Contains(self, key);
+ if (is_present < 0) {
return nullptr;
}
- if (PyObject_IsTrue(is_present.get())) {
+ if (is_present == 1) {
return MapReflectionFriend::MessageMapGetItem(self, key);
} else {
if (default_value != nullptr) {
@@ -748,8 +745,6 @@ static void MessageMapDealloc(PyObject* _self) {
}
static PyMethodDef MessageMapMethods[] = {
- {"__contains__", (PyCFunction)MapReflectionFriend::Contains, METH_O,
- "Tests whether the map contains this element."},
{"clear", (PyCFunction)Clear, METH_NOARGS,
"Removes all elements from the map."},
{"get", (PyCFunction)MessageMapGet, METH_VARARGS | METH_KEYWORDS,
@@ -776,6 +771,7 @@ static PyType_Slot MessageMapContainer_Type_slots[] = {
{Py_mp_subscript, (void*)MapReflectionFriend::MessageMapGetItem},
{Py_mp_ass_subscript, (void*)MapReflectionFriend::MessageMapSetItem},
{Py_tp_methods, (void*)MessageMapMethods},
+ {Py_sq_contains, (void*)MapReflectionFriend::Contains},
{Py_tp_iter, (void*)MapReflectionFriend::GetIterator},
{Py_tp_repr, (void*)MapReflectionFriend::MessageMapToStr},
{0, nullptr}};
@@ -901,6 +897,33 @@ PyTypeObject MapIterator_Type = {
nullptr, // tp_init
};
+
+PyTypeObject* PyUpb_AddClassWithRegister(PyType_Spec* spec,
+ PyObject* virtual_base,
+ const char** methods) {
+ PyObject* type = PyType_FromSpec(spec);
+ PyObject* ret1 = PyObject_CallMethod(virtual_base, "register", "O", type);
+ if (!ret1) {
+ Py_XDECREF(type);
+ return NULL;
+ }
+ for (size_t i = 0; methods[i] != NULL; i++) {
+ PyObject* method = PyObject_GetAttrString(virtual_base, methods[i]);
+ if (!method) {
+ Py_XDECREF(type);
+ return NULL;
+ }
+ int ret2 = PyObject_SetAttrString(type, methods[i], method);
+ if (ret2 < 0) {
+ Py_XDECREF(type);
+ return NULL;
+ }
+ }
+
+ return (PyTypeObject*)type;
+}
+
+
bool InitMapContainers() {
// ScalarMapContainer_Type derives from our MutableMapping type.
ScopedPyObjectPtr abc(PyImport_ImportModule("collections.abc"));
@@ -915,20 +938,23 @@ bool InitMapContainers() {
}
Py_INCREF(mutable_mapping.get());
- ScopedPyObjectPtr bases(PyTuple_Pack(1, mutable_mapping.get()));
+ ScopedPyObjectPtr bases(Py_BuildValue("O", mutable_mapping.get()));
if (bases == nullptr) {
return false;
}
+ const char* methods[] = {"keys", "items", "values", "__eq__", "__ne__",
+ "pop", "popitem", "update", "setdefault", NULL};
+
ScalarMapContainer_Type = reinterpret_cast<PyTypeObject*>(
- PyType_FromSpecWithBases(&ScalarMapContainer_Type_spec, bases.get()));
+ PyUpb_AddClassWithRegister(&ScalarMapContainer_Type_spec, bases.get(), methods));
if (PyType_Ready(&MapIterator_Type) < 0) {
return false;
}
MessageMapContainer_Type = reinterpret_cast<PyTypeObject*>(
- PyType_FromSpecWithBases(&MessageMapContainer_Type_spec, bases.get()));
+ PyUpb_AddClassWithRegister(&MessageMapContainer_Type_spec, bases.get(), methods));
return true;
}
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 af334d2e773..d90d3a554a4 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/map_container.h
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/map_container.h
@@ -36,9 +36,9 @@
#include <cstdint>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/pyext/message.h>
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/pyext/message.h"
namespace google {
namespace protobuf {
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/message.cc b/contrib/python/protobuf/py3/google/protobuf/pyext/message.cc
index 0a1474a2335..fc0257acdd0 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/message.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/message.cc
@@ -31,17 +31,19 @@
// Author: [email protected] (Anuraag Agrawal)
// Author: [email protected] (Johan Tibell)
-#include <google/protobuf/pyext/message.h>
+#include "google/protobuf/pyext/message.h"
#include <structmember.h> // A Python header file.
#include <cstdint>
#include <map>
#include <memory>
+#include <set>
#include <string>
#include <vector>
-#include <google/protobuf/stubs/strutil.h>
+#include "y_absl/log/absl_check.h"
+#include "y_absl/strings/match.h"
#ifndef PyVarObject_HEAD_INIT
#define PyVarObject_HEAD_INIT(type, size) PyObject_HEAD_INIT(type) size,
@@ -49,33 +51,32 @@
#ifndef Py_TYPE
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
#endif
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/text_format.h>
-#include <google/protobuf/unknown_field_set.h>
-#include <google/protobuf/pyext/descriptor.h>
-#include <google/protobuf/pyext/descriptor_pool.h>
-#include <google/protobuf/pyext/extension_dict.h>
-#include <google/protobuf/pyext/field.h>
-#include <google/protobuf/pyext/map_container.h>
-#include <google/protobuf/pyext/message_factory.h>
-#include <google/protobuf/pyext/repeated_composite_container.h>
-#include <google/protobuf/pyext/repeated_scalar_container.h>
-#include <google/protobuf/pyext/safe_numerics.h>
-#include <google/protobuf/pyext/scoped_pyobject_ptr.h>
-#include <google/protobuf/pyext/unknown_field_set.h>
-#include <google/protobuf/pyext/unknown_fields.h>
-#include <google/protobuf/util/message_differencer.h>
-#include <google/protobuf/io/strtod.h>
-#include <google/protobuf/stubs/map_util.h>
+#include "google/protobuf/stubs/common.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/text_format.h"
+#include "google/protobuf/unknown_field_set.h"
+#include "google/protobuf/pyext/descriptor.h"
+#include "google/protobuf/pyext/descriptor_pool.h"
+#include "google/protobuf/pyext/extension_dict.h"
+#include "google/protobuf/pyext/field.h"
+#include "google/protobuf/pyext/map_container.h"
+#include "google/protobuf/pyext/message_factory.h"
+#include "google/protobuf/pyext/repeated_composite_container.h"
+#include "google/protobuf/pyext/repeated_scalar_container.h"
+#include "google/protobuf/pyext/safe_numerics.h"
+#include "google/protobuf/pyext/scoped_pyobject_ptr.h"
+#include "google/protobuf/pyext/unknown_field_set.h"
+#include "google/protobuf/pyext/unknown_fields.h"
+#include "google/protobuf/util/message_differencer.h"
+#include "y_absl/strings/string_view.h"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/io/strtod.h"
+#include "google/protobuf/io/zero_copy_stream_impl_lite.h"
// clang-format off
-#include <google/protobuf/port_def.inc>
+#include "google/protobuf/port_def.inc"
// clang-format on
#define PyString_AsString(ob) \
@@ -88,6 +89,9 @@
: 0) \
: PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
+#define PROTOBUF_PYTHON_PUBLIC "google.protobuf"
+#define PROTOBUF_PYTHON_INTERNAL "google.protobuf.internal"
+
namespace google {
namespace protobuf {
namespace python {
@@ -242,12 +246,12 @@ static PyObject* New(PyTypeObject* type, PyObject* args, PyObject* kwargs) {
ScopedPyObjectPtr new_args;
if (WKT_classes == nullptr) {
- ScopedPyObjectPtr well_known_types(PyImport_ImportModule(
- "google.protobuf.internal.well_known_types"));
- GOOGLE_DCHECK(well_known_types != nullptr);
+ ScopedPyObjectPtr well_known_types(
+ PyImport_ImportModule(PROTOBUF_PYTHON_INTERNAL ".well_known_types"));
+ Y_ABSL_DCHECK(well_known_types != nullptr);
WKT_classes = PyObject_GetAttrString(well_known_types.get(), "WKTBASES");
- GOOGLE_DCHECK(WKT_classes != nullptr);
+ Y_ABSL_DCHECK(WKT_classes != nullptr);
}
PyObject* well_known_class = PyDict_GetItemString(
@@ -401,7 +405,7 @@ static PyObject* GetClassAttribute(CMessageClass *self, PyObject* name) {
Py_ssize_t attr_size;
static const char kSuffix[] = "_FIELD_NUMBER";
if (PyString_AsStringAndSize(name, &attr, &attr_size) >= 0 &&
- HasSuffixString(StringPiece(attr, attr_size), kSuffix)) {
+ y_absl::EndsWith(y_absl::string_view(attr, attr_size), kSuffix)) {
TProtoStringType field_name(attr, attr_size - sizeof(kSuffix) + 1);
LowerString(&field_name);
@@ -672,8 +676,8 @@ bool IsValidUTF8(PyObject* obj) {
bool AllowInvalidUTF8(const FieldDescriptor* field) { return false; }
PyObject* CheckString(PyObject* arg, const FieldDescriptor* descriptor) {
- GOOGLE_DCHECK(descriptor->type() == FieldDescriptor::TYPE_STRING ||
- descriptor->type() == FieldDescriptor::TYPE_BYTES);
+ Y_ABSL_DCHECK(descriptor->type() == FieldDescriptor::TYPE_STRING ||
+ descriptor->type() == FieldDescriptor::TYPE_BYTES);
if (descriptor->type() == FieldDescriptor::TYPE_STRING) {
if (!PyBytes_Check(arg) && !PyUnicode_Check(arg)) {
FormatTypeError(arg, "bytes, unicode");
@@ -776,7 +780,7 @@ bool CheckFieldBelongsToMessage(const FieldDescriptor* field_descriptor,
namespace cmessage {
PyMessageFactory* GetFactoryForMessage(CMessage* message) {
- GOOGLE_DCHECK(PyObject_TypeCheck(message, CMessage_Type));
+ Y_ABSL_DCHECK(PyObject_TypeCheck(message, CMessage_Type));
return reinterpret_cast<CMessageClass*>(Py_TYPE(message))->py_message_factory;
}
@@ -848,7 +852,7 @@ int AssureWritable(CMessage* self) {
}
// Toplevel messages are always mutable.
- GOOGLE_DCHECK(self->parent);
+ Y_ABSL_DCHECK(self->parent);
if (AssureWritable(self->parent) == -1) {
return -1;
@@ -906,7 +910,7 @@ static PyObject* GetIntegerEnumValue(const FieldDescriptor& descriptor,
return nullptr;
}
const EnumValueDescriptor* enum_value_descriptor =
- enum_descriptor->FindValueByName(StringParam(enum_label, size));
+ enum_descriptor->FindValueByName(y_absl::string_view(enum_label, size));
if (enum_value_descriptor == nullptr) {
PyErr_Format(PyExc_ValueError, "unknown enum label \"%s\"", enum_label);
return nullptr;
@@ -980,7 +984,7 @@ int DeleteRepeatedField(
}
Arena* arena = Arena::InternalGetArenaForAllocation(message);
- GOOGLE_DCHECK_EQ(arena, nullptr)
+ Y_ABSL_DCHECK_EQ(arena, nullptr)
<< "python protobuf is expected to be allocated from heap";
// Remove items, starting from the end.
for (; length > to; length--) {
@@ -993,9 +997,10 @@ int DeleteRepeatedField(
//
// To work around a debug hardening (PROTOBUF_FORCE_COPY_IN_RELEASE),
// explicitly use UnsafeArenaReleaseLast. To not break rare use cases where
- // arena is used, we fallback to ReleaseLast (but GOOGLE_DCHECK to find/fix it).
+ // arena is used, we fallback to ReleaseLast (but Y_ABSL_DCHECK to find/fix
+ // it).
//
- // Note that arena is likely null and GOOGLE_DCHECK and ReleaesLast might be
+ // Note that arena is likely null and Y_ABSL_DCHECK and ReleaesLast might be
// redundant. The current approach takes extra cautious path not to disrupt
// production.
Message* sub_message =
@@ -1092,7 +1097,8 @@ int InitAttributes(CMessage* self, PyObject* args, PyObject* kwargs) {
reinterpret_cast<RepeatedCompositeContainer*>(container.get());
ScopedPyObjectPtr iter(PyObject_GetIter(value));
if (iter == nullptr) {
- PyErr_SetString(PyExc_TypeError, "Value must be iterable");
+ PyErr_Format(PyExc_TypeError, "Value of field '%s' must be iterable",
+ descriptor->name().c_str());
return -1;
}
ScopedPyObjectPtr next;
@@ -1121,7 +1127,8 @@ int InitAttributes(CMessage* self, PyObject* args, PyObject* kwargs) {
reinterpret_cast<RepeatedScalarContainer*>(container.get());
ScopedPyObjectPtr iter(PyObject_GetIter(value));
if (iter == nullptr) {
- PyErr_SetString(PyExc_TypeError, "Value must be iterable");
+ PyErr_Format(PyExc_TypeError, "Value of field '%s' must be iterable",
+ descriptor->name().c_str());
return -1;
}
ScopedPyObjectPtr next;
@@ -1258,8 +1265,8 @@ static void Dealloc(CMessage* self) {
PyObject_ClearWeakRefs(reinterpret_cast<PyObject*>(self));
}
// At this point all dependent objects have been removed.
- GOOGLE_DCHECK(!self->child_submessages || self->child_submessages->empty());
- GOOGLE_DCHECK(!self->composite_fields || self->composite_fields->empty());
+ Y_ABSL_DCHECK(!self->child_submessages || self->child_submessages->empty());
+ Y_ABSL_DCHECK(!self->composite_fields || self->composite_fields->empty());
delete self->child_submessages;
delete self->composite_fields;
if (self->unknown_field_set) {
@@ -1333,7 +1340,7 @@ int HasFieldByDescriptor(CMessage* self,
}
const FieldDescriptor* FindFieldWithOneofs(const Message* message,
- ConstStringParam field_name,
+ y_absl::string_view field_name,
bool* in_oneof) {
*in_oneof = false;
const Descriptor* descriptor = message->GetDescriptor();
@@ -1382,8 +1389,8 @@ PyObject* HasField(CMessage* self, PyObject* arg) {
Message* message = self->message;
bool is_in_oneof;
- const FieldDescriptor* field_descriptor =
- FindFieldWithOneofs(message, StringParam(field_name, size), &is_in_oneof);
+ const FieldDescriptor* field_descriptor = FindFieldWithOneofs(
+ message, y_absl::string_view(field_name, size), &is_in_oneof);
if (field_descriptor == nullptr) {
if (!is_in_oneof) {
PyErr_Format(PyExc_ValueError, "Protocol message %s has no field %s.",
@@ -1567,7 +1574,7 @@ PyObject* ClearField(CMessage* self, PyObject* arg) {
AssureWritable(self);
bool is_in_oneof;
const FieldDescriptor* field_descriptor = FindFieldWithOneofs(
- self->message, StringParam(field_name, field_size), &is_in_oneof);
+ self->message, y_absl::string_view(field_name, field_size), &is_in_oneof);
if (field_descriptor == nullptr) {
if (is_in_oneof) {
// We gave the name of a oneof, and none of its fields are set.
@@ -1704,7 +1711,7 @@ static PyObject* InternalSerializeToString(
coded_out.SetSerializationDeterministic(deterministic);
}
self->message->SerializeWithCachedSizes(&coded_out);
- GOOGLE_CHECK(!coded_out.HadError());
+ Y_ABSL_CHECK(!coded_out.HadError());
return result;
}
@@ -1877,7 +1884,7 @@ static PyObject* MergeFromString(CMessage* self, PyObject* arg) {
const char* ptr;
internal::ParseContext ctx(
depth, false, &ptr,
- StringPiece(static_cast<const char*>(data.buf), data.len));
+ y_absl::string_view(static_cast<const char*>(data.buf), data.len));
PyBuffer_Release(&data);
ctx.data().pool = factory->pool->pool;
ctx.data().factory = factory->message_factory;
@@ -1967,7 +1974,7 @@ static PyObject* WhichOneof(CMessage* self, PyObject* arg) {
if (PyString_AsStringAndSize(arg, &name_data, &name_size) < 0) return nullptr;
const OneofDescriptor* oneof_desc =
self->message->GetDescriptor()->FindOneofByName(
- StringParam(name_data, name_size));
+ y_absl::string_view(name_data, name_size));
if (oneof_desc == nullptr) {
PyErr_Format(PyExc_ValueError,
"Protocol message has no oneof \"%s\" field.", name_data);
@@ -2244,37 +2251,37 @@ int InternalSetNonOneofScalar(
switch (field_descriptor->cpp_type()) {
case FieldDescriptor::CPPTYPE_INT32: {
- GOOGLE_CHECK_GET_INT32(arg, value, -1);
+ PROTOBUF_CHECK_GET_INT32(arg, value, -1);
reflection->SetInt32(message, field_descriptor, value);
break;
}
case FieldDescriptor::CPPTYPE_INT64: {
- GOOGLE_CHECK_GET_INT64(arg, value, -1);
+ PROTOBUF_CHECK_GET_INT64(arg, value, -1);
reflection->SetInt64(message, field_descriptor, value);
break;
}
case FieldDescriptor::CPPTYPE_UINT32: {
- GOOGLE_CHECK_GET_UINT32(arg, value, -1);
+ PROTOBUF_CHECK_GET_UINT32(arg, value, -1);
reflection->SetUInt32(message, field_descriptor, value);
break;
}
case FieldDescriptor::CPPTYPE_UINT64: {
- GOOGLE_CHECK_GET_UINT64(arg, value, -1);
+ PROTOBUF_CHECK_GET_UINT64(arg, value, -1);
reflection->SetUInt64(message, field_descriptor, value);
break;
}
case FieldDescriptor::CPPTYPE_FLOAT: {
- GOOGLE_CHECK_GET_FLOAT(arg, value, -1);
+ PROTOBUF_CHECK_GET_FLOAT(arg, value, -1);
reflection->SetFloat(message, field_descriptor, value);
break;
}
case FieldDescriptor::CPPTYPE_DOUBLE: {
- GOOGLE_CHECK_GET_DOUBLE(arg, value, -1);
+ PROTOBUF_CHECK_GET_DOUBLE(arg, value, -1);
reflection->SetDouble(message, field_descriptor, value);
break;
}
case FieldDescriptor::CPPTYPE_BOOL: {
- GOOGLE_CHECK_GET_BOOL(arg, value, -1);
+ PROTOBUF_CHECK_GET_BOOL(arg, value, -1);
reflection->SetBool(message, field_descriptor, value);
break;
}
@@ -2286,7 +2293,7 @@ int InternalSetNonOneofScalar(
break;
}
case FieldDescriptor::CPPTYPE_ENUM: {
- GOOGLE_CHECK_GET_INT32(arg, value, -1);
+ PROTOBUF_CHECK_GET_INT32(arg, value, -1);
if (reflection->SupportsUnknownEnumValues()) {
reflection->SetEnumValue(message, field_descriptor, value);
} else {
@@ -2366,7 +2373,7 @@ PyObject* DeepCopy(CMessage* self, PyObject* arg) {
PyObject* ToUnicode(CMessage* self) {
// Lazy import to prevent circular dependencies
ScopedPyObjectPtr text_format(
- PyImport_ImportModule("google.protobuf.text_format"));
+ PyImport_ImportModule(PROTOBUF_PYTHON_PUBLIC ".text_format"));
if (text_format == nullptr) {
return nullptr;
}
@@ -2667,22 +2674,22 @@ CMessage* CMessage::BuildSubMessageFromPointer(
if (!this->child_submessages) {
this->child_submessages = new CMessage::SubMessagesMap();
}
- CMessage* cmsg = FindPtrOrNull(
- *this->child_submessages, sub_message);
- if (cmsg) {
- Py_INCREF(cmsg);
- } else {
- cmsg = cmessage::NewEmptyMessage(message_class);
+ auto it = this->child_submessages->find(sub_message);
+ if (it != this->child_submessages->end()) {
+ Py_INCREF(it->second);
+ return it->second;
+ }
- if (cmsg == nullptr) {
- return nullptr;
- }
- cmsg->message = sub_message;
- Py_INCREF(this);
- cmsg->parent = this;
- cmsg->parent_field_descriptor = field_descriptor;
- cmessage::SetSubmessage(this, cmsg);
+ CMessage* cmsg = cmessage::NewEmptyMessage(message_class);
+
+ if (cmsg == nullptr) {
+ return nullptr;
}
+ cmsg->message = sub_message;
+ Py_INCREF(this);
+ cmsg->parent = this;
+ cmsg->parent_field_descriptor = field_descriptor;
+ cmessage::SetSubmessage(this, cmsg);
return cmsg;
}
@@ -2690,11 +2697,10 @@ CMessage* CMessage::MaybeReleaseSubMessage(Message* sub_message) {
if (!this->child_submessages) {
return nullptr;
}
- CMessage* released = FindPtrOrNull(
- *this->child_submessages, sub_message);
- if (!released) {
- return nullptr;
- }
+ auto it = this->child_submessages->find(sub_message);
+ if (it == this->child_submessages->end()) return nullptr;
+ CMessage* released = it->second;
+
// The target message will now own its content.
Py_CLEAR(released->parent);
released->parent_field_descriptor = nullptr;
@@ -3028,8 +3034,8 @@ bool InitProto2MessageModule(PyObject *m) {
PyModule_AddObject(m, "MethodDescriptor",
reinterpret_cast<PyObject*>(&PyMethodDescriptor_Type));
- PyObject* enum_type_wrapper = PyImport_ImportModule(
- "google.protobuf.internal.enum_type_wrapper");
+ PyObject* enum_type_wrapper =
+ PyImport_ImportModule(PROTOBUF_PYTHON_INTERNAL ".enum_type_wrapper");
if (enum_type_wrapper == nullptr) {
return false;
}
@@ -3037,8 +3043,8 @@ bool InitProto2MessageModule(PyObject *m) {
PyObject_GetAttrString(enum_type_wrapper, "EnumTypeWrapper");
Py_DECREF(enum_type_wrapper);
- PyObject* message_module = PyImport_ImportModule(
- "google.protobuf.message");
+ PyObject* message_module =
+ PyImport_ImportModule(PROTOBUF_PYTHON_PUBLIC ".message");
if (message_module == nullptr) {
return false;
}
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/message.h b/contrib/python/protobuf/py3/google/protobuf/pyext/message.h
index 28dbda6798f..474f2a99ca8 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/message.h
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/message.h
@@ -42,7 +42,7 @@
#include <string>
#include <unordered_map>
-#include <google/protobuf/stubs/common.h>
+#include "google/protobuf/stubs/common.h"
namespace google {
namespace protobuf {
@@ -287,46 +287,46 @@ PyObject* SetAllowOversizeProtos(PyObject* m, PyObject* arg);
#define FIELD_IS_REPEATED(field_descriptor) \
((field_descriptor)->label() == FieldDescriptor::LABEL_REPEATED)
-#define GOOGLE_CHECK_GET_INT32(arg, value, err) \
- int32_t value; \
- if (!CheckAndGetInteger(arg, &value)) { \
- return err; \
+#define PROTOBUF_CHECK_GET_INT32(arg, value, err) \
+ int32_t value; \
+ if (!CheckAndGetInteger(arg, &value)) { \
+ return err; \
}
-#define GOOGLE_CHECK_GET_INT64(arg, value, err) \
- int64_t value; \
- if (!CheckAndGetInteger(arg, &value)) { \
- return err; \
+#define PROTOBUF_CHECK_GET_INT64(arg, value, err) \
+ int64_t value; \
+ if (!CheckAndGetInteger(arg, &value)) { \
+ return err; \
}
-#define GOOGLE_CHECK_GET_UINT32(arg, value, err) \
- uint32_t value; \
- if (!CheckAndGetInteger(arg, &value)) { \
- return err; \
+#define PROTOBUF_CHECK_GET_UINT32(arg, value, err) \
+ uint32_t value; \
+ if (!CheckAndGetInteger(arg, &value)) { \
+ return err; \
}
-#define GOOGLE_CHECK_GET_UINT64(arg, value, err) \
- uint64_t value; \
- if (!CheckAndGetInteger(arg, &value)) { \
- return err; \
+#define PROTOBUF_CHECK_GET_UINT64(arg, value, err) \
+ uint64_t value; \
+ if (!CheckAndGetInteger(arg, &value)) { \
+ return err; \
}
-#define GOOGLE_CHECK_GET_FLOAT(arg, value, err) \
- float value; \
- if (!CheckAndGetFloat(arg, &value)) { \
- return err; \
+#define PROTOBUF_CHECK_GET_FLOAT(arg, value, err) \
+ float value; \
+ if (!CheckAndGetFloat(arg, &value)) { \
+ return err; \
}
-#define GOOGLE_CHECK_GET_DOUBLE(arg, value, err) \
- double value; \
- if (!CheckAndGetDouble(arg, &value)) { \
- return err; \
+#define PROTOBUF_CHECK_GET_DOUBLE(arg, value, err) \
+ double value; \
+ if (!CheckAndGetDouble(arg, &value)) { \
+ return err; \
}
-#define GOOGLE_CHECK_GET_BOOL(arg, value, err) \
- bool value; \
- if (!CheckAndGetBool(arg, &value)) { \
- return err; \
+#define PROTOBUF_CHECK_GET_BOOL(arg, value, err) \
+ bool value; \
+ if (!CheckAndGetBool(arg, &value)) { \
+ return err; \
}
#define FULL_MODULE_NAME "google.protobuf.pyext._message"
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 35d6214d7d7..060cc767fda 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/message_factory.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/message_factory.cc
@@ -29,15 +29,16 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <unordered_map>
+#include <utility>
#define PY_SSIZE_T_CLEAN
#include <Python.h>
-#include <google/protobuf/dynamic_message.h>
-#include <google/protobuf/pyext/descriptor.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/dynamic_message.h"
+#include "google/protobuf/pyext/descriptor.h"
+#include "google/protobuf/pyext/message.h"
+#include "google/protobuf/pyext/message_factory.h"
+#include "google/protobuf/pyext/scoped_pyobject_ptr.h"
#define PyString_AsStringAndSize(ob, charpp, sizep) \
(PyUnicode_Check(ob) \
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 7dfe425dd57..1d911a827db 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/message_factory.h
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/message_factory.h
@@ -35,8 +35,8 @@
#include <Python.h>
#include <unordered_map>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/pyext/descriptor_pool.h>
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/pyext/descriptor_pool.h"
namespace google {
namespace protobuf {
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 2d3c1d20874..f4692066d8d 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/message_module.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/message_module.cc
@@ -31,12 +31,12 @@
#define PY_SSIZE_T_CLEAN
#include <Python.h>
-#include <google/protobuf/message_lite.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/proto_api.h>
+#include "google/protobuf/message_lite.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/proto_api.h"
namespace {
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 0b63f822566..cac8f1af696 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
@@ -31,22 +31,19 @@
// Author: [email protected] (Anuraag Agrawal)
// Author: [email protected] (Johan Tibell)
-#include <google/protobuf/pyext/repeated_composite_container.h>
+#include "google/protobuf/pyext/repeated_composite_container.h"
#include <memory>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-#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/stubs/map_util.h>
+#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"
namespace google {
namespace protobuf {
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 6fa6e176f1b..8964374dbc4 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
@@ -37,7 +37,7 @@
#define PY_SSIZE_T_CLEAN
#include <Python.h>
-#include <google/protobuf/pyext/message.h>
+#include "google/protobuf/pyext/message.h"
namespace google {
namespace protobuf {
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 a9d96f03a07..9d5fab40654 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
@@ -31,20 +31,20 @@
// Author: [email protected] (Anuraag Agrawal)
// Author: [email protected] (Johan Tibell)
-#include <google/protobuf/pyext/repeated_scalar_container.h>
+#include "google/protobuf/pyext/repeated_scalar_container.h"
#include <cstdint>
#include <memory>
+#include <string>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/dynamic_message.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/pyext/descriptor.h>
-#include <google/protobuf/pyext/descriptor_pool.h>
-#include <google/protobuf/pyext/message.h>
-#include <google/protobuf/pyext/scoped_pyobject_ptr.h>
+#include "google/protobuf/stubs/common.h"
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/dynamic_message.h"
+#include "google/protobuf/message.h"
+#include "google/protobuf/pyext/descriptor.h"
+#include "google/protobuf/pyext/descriptor_pool.h"
+#include "google/protobuf/pyext/message.h"
+#include "google/protobuf/pyext/scoped_pyobject_ptr.h"
#define PyString_AsString(ob) \
(PyUnicode_Check(ob) ? PyUnicode_AsUTF8(ob) : PyBytes_AsString(ob))
@@ -108,37 +108,37 @@ static int AssignItem(PyObject* pself, Py_ssize_t index, PyObject* arg) {
switch (field_descriptor->cpp_type()) {
case FieldDescriptor::CPPTYPE_INT32: {
- GOOGLE_CHECK_GET_INT32(arg, value, -1);
+ PROTOBUF_CHECK_GET_INT32(arg, value, -1);
reflection->SetRepeatedInt32(message, field_descriptor, index, value);
break;
}
case FieldDescriptor::CPPTYPE_INT64: {
- GOOGLE_CHECK_GET_INT64(arg, value, -1);
+ PROTOBUF_CHECK_GET_INT64(arg, value, -1);
reflection->SetRepeatedInt64(message, field_descriptor, index, value);
break;
}
case FieldDescriptor::CPPTYPE_UINT32: {
- GOOGLE_CHECK_GET_UINT32(arg, value, -1);
+ PROTOBUF_CHECK_GET_UINT32(arg, value, -1);
reflection->SetRepeatedUInt32(message, field_descriptor, index, value);
break;
}
case FieldDescriptor::CPPTYPE_UINT64: {
- GOOGLE_CHECK_GET_UINT64(arg, value, -1);
+ PROTOBUF_CHECK_GET_UINT64(arg, value, -1);
reflection->SetRepeatedUInt64(message, field_descriptor, index, value);
break;
}
case FieldDescriptor::CPPTYPE_FLOAT: {
- GOOGLE_CHECK_GET_FLOAT(arg, value, -1);
+ PROTOBUF_CHECK_GET_FLOAT(arg, value, -1);
reflection->SetRepeatedFloat(message, field_descriptor, index, value);
break;
}
case FieldDescriptor::CPPTYPE_DOUBLE: {
- GOOGLE_CHECK_GET_DOUBLE(arg, value, -1);
+ PROTOBUF_CHECK_GET_DOUBLE(arg, value, -1);
reflection->SetRepeatedDouble(message, field_descriptor, index, value);
break;
}
case FieldDescriptor::CPPTYPE_BOOL: {
- GOOGLE_CHECK_GET_BOOL(arg, value, -1);
+ PROTOBUF_CHECK_GET_BOOL(arg, value, -1);
reflection->SetRepeatedBool(message, field_descriptor, index, value);
break;
}
@@ -150,7 +150,7 @@ static int AssignItem(PyObject* pself, Py_ssize_t index, PyObject* arg) {
break;
}
case FieldDescriptor::CPPTYPE_ENUM: {
- GOOGLE_CHECK_GET_INT32(arg, value, -1);
+ PROTOBUF_CHECK_GET_INT32(arg, value, -1);
if (reflection->SupportsUnknownEnumValues()) {
reflection->SetRepeatedEnumValue(message, field_descriptor, index,
value);
@@ -333,37 +333,37 @@ PyObject* Append(RepeatedScalarContainer* self, PyObject* item) {
const Reflection* reflection = message->GetReflection();
switch (field_descriptor->cpp_type()) {
case FieldDescriptor::CPPTYPE_INT32: {
- GOOGLE_CHECK_GET_INT32(item, value, nullptr);
+ PROTOBUF_CHECK_GET_INT32(item, value, nullptr);
reflection->AddInt32(message, field_descriptor, value);
break;
}
case FieldDescriptor::CPPTYPE_INT64: {
- GOOGLE_CHECK_GET_INT64(item, value, nullptr);
+ PROTOBUF_CHECK_GET_INT64(item, value, nullptr);
reflection->AddInt64(message, field_descriptor, value);
break;
}
case FieldDescriptor::CPPTYPE_UINT32: {
- GOOGLE_CHECK_GET_UINT32(item, value, nullptr);
+ PROTOBUF_CHECK_GET_UINT32(item, value, nullptr);
reflection->AddUInt32(message, field_descriptor, value);
break;
}
case FieldDescriptor::CPPTYPE_UINT64: {
- GOOGLE_CHECK_GET_UINT64(item, value, nullptr);
+ PROTOBUF_CHECK_GET_UINT64(item, value, nullptr);
reflection->AddUInt64(message, field_descriptor, value);
break;
}
case FieldDescriptor::CPPTYPE_FLOAT: {
- GOOGLE_CHECK_GET_FLOAT(item, value, nullptr);
+ PROTOBUF_CHECK_GET_FLOAT(item, value, nullptr);
reflection->AddFloat(message, field_descriptor, value);
break;
}
case FieldDescriptor::CPPTYPE_DOUBLE: {
- GOOGLE_CHECK_GET_DOUBLE(item, value, nullptr);
+ PROTOBUF_CHECK_GET_DOUBLE(item, value, nullptr);
reflection->AddDouble(message, field_descriptor, value);
break;
}
case FieldDescriptor::CPPTYPE_BOOL: {
- GOOGLE_CHECK_GET_BOOL(item, value, nullptr);
+ PROTOBUF_CHECK_GET_BOOL(item, value, nullptr);
reflection->AddBool(message, field_descriptor, value);
break;
}
@@ -375,7 +375,7 @@ PyObject* Append(RepeatedScalarContainer* self, PyObject* item) {
break;
}
case FieldDescriptor::CPPTYPE_ENUM: {
- GOOGLE_CHECK_GET_INT32(item, value, nullptr);
+ PROTOBUF_CHECK_GET_INT32(item, value, nullptr);
if (reflection->SupportsUnknownEnumValues()) {
reflection->AddEnumValue(message, field_descriptor, value);
} else {
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 67423ab4ce0..0189886c521 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
@@ -37,8 +37,8 @@
#define PY_SSIZE_T_CLEAN
#include <Python.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/pyext/message.h>
+#include "google/protobuf/descriptor.h"
+#include "google/protobuf/pyext/message.h"
namespace google {
namespace protobuf {
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/safe_numerics.h b/contrib/python/protobuf/py3/google/protobuf/pyext/safe_numerics.h
index 93ae640e8b7..a6368768def 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/safe_numerics.h
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/safe_numerics.h
@@ -34,8 +34,7 @@
#include <limits>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
+#include "y_absl/log/absl_check.h"
namespace google {
namespace protobuf {
@@ -153,7 +152,7 @@ inline bool IsValidNumericCast(Source source) {
// (this is static_asserted), though this could be supported if necessary.
template <class Dest, class Source>
inline Dest checked_numeric_cast(Source source) {
- GOOGLE_CHECK(IsValidNumericCast<Dest>(source));
+ Y_ABSL_CHECK(IsValidNumericCast<Dest>(source));
return static_cast<Dest>(source);
}
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 ad3fa9462d4..d39a4d13fea 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
@@ -33,8 +33,6 @@
#ifndef GOOGLE_PROTOBUF_PYTHON_CPP_SCOPED_PYOBJECT_PTR_H__
#define GOOGLE_PROTOBUF_PYTHON_CPP_SCOPED_PYOBJECT_PTR_H__
-#include <google/protobuf/stubs/common.h>
-
#define PY_SSIZE_T_CLEAN
#include <Python.h>
namespace google {
@@ -50,6 +48,8 @@ class ScopedPythonPtr {
// The reference count of the specified py_object is not incremented.
explicit ScopedPythonPtr(PyObjectStruct* py_object = nullptr)
: ptr_(py_object) {}
+ ScopedPythonPtr(const ScopedPythonPtr&) = delete;
+ ScopedPythonPtr& operator=(const ScopedPythonPtr&) = delete;
// If a PyObject is owned, decrement its reference count.
~ScopedPythonPtr() { Py_XDECREF(ptr_); }
@@ -89,8 +89,6 @@ class ScopedPythonPtr {
private:
PyObjectStruct* ptr_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ScopedPythonPtr);
};
typedef ScopedPythonPtr<PyObject> ScopedPyObjectPtr;
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/unknown_field_set.cc b/contrib/python/protobuf/py3/google/protobuf/pyext/unknown_field_set.cc
index 42f9bbcb042..59d1d0bb655 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/unknown_field_set.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/unknown_field_set.cc
@@ -28,7 +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.
-#include <google/protobuf/pyext/unknown_field_set.h>
+#include "google/protobuf/pyext/unknown_field_set.h"
#define PY_SSIZE_T_CLEAN
#include <Python.h>
@@ -36,11 +36,11 @@
#include <memory>
#include <set>
-#include <google/protobuf/message.h>
-#include <google/protobuf/unknown_field_set.h>
-#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/pyext/message.h>
-#include <google/protobuf/pyext/scoped_pyobject_ptr.h>
+#include "google/protobuf/message.h"
+#include "google/protobuf/unknown_field_set.h"
+#include "google/protobuf/pyext/message.h"
+#include "google/protobuf/pyext/scoped_pyobject_ptr.h"
+#include "google/protobuf/wire_format_lite.h"
namespace google {
namespace protobuf {
diff --git a/contrib/python/protobuf/py3/google/protobuf/pyext/unknown_field_set.h b/contrib/python/protobuf/py3/google/protobuf/pyext/unknown_field_set.h
index 3fa764d01e0..92a889dc596 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/unknown_field_set.h
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/unknown_field_set.h
@@ -37,7 +37,7 @@
#include <memory>
#include <set>
-#include <google/protobuf/pyext/message.h>
+#include "google/protobuf/pyext/message.h"
namespace google {
namespace protobuf {
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 dcd63b2e29a..bb6549d33a0 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/unknown_fields.cc
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/unknown_fields.cc
@@ -28,18 +28,19 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <google/protobuf/pyext/unknown_fields.h>
+#include "google/protobuf/pyext/unknown_fields.h"
#define PY_SSIZE_T_CLEAN
#include <Python.h>
-#include <set>
+
#include <memory>
+#include <set>
-#include <google/protobuf/message.h>
-#include <google/protobuf/pyext/message.h>
-#include <google/protobuf/pyext/scoped_pyobject_ptr.h>
-#include <google/protobuf/unknown_field_set.h>
-#include <google/protobuf/wire_format_lite.h>
+#include "google/protobuf/message.h"
+#include "google/protobuf/unknown_field_set.h"
+#include "google/protobuf/pyext/message.h"
+#include "google/protobuf/pyext/scoped_pyobject_ptr.h"
+#include "google/protobuf/wire_format_lite.h"
namespace google {
namespace protobuf {
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 e7b0b35c41c..81ee1a9139e 100644
--- a/contrib/python/protobuf/py3/google/protobuf/pyext/unknown_fields.h
+++ b/contrib/python/protobuf/py3/google/protobuf/pyext/unknown_fields.h
@@ -37,7 +37,7 @@
#include <memory>
#include <set>
-#include <google/protobuf/pyext/message.h>
+#include "google/protobuf/pyext/message.h"
namespace google {
namespace protobuf {
diff --git a/contrib/python/protobuf/py3/google/protobuf/python_protobuf.h b/contrib/python/protobuf/py3/google/protobuf/python_protobuf.h
new file mode 100644
index 00000000000..4fcf0654047
--- /dev/null
+++ b/contrib/python/protobuf/py3/google/protobuf/python_protobuf.h
@@ -0,0 +1,58 @@
+// 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: [email protected] (Marcin Kowalczyk)
+//
+// This module exposes the C proto inside the given Python proto, in
+// case the Python proto is implemented with a C proto.
+
+#ifndef GOOGLE_PROTOBUF_PYTHON_PYTHON_PROTOBUF_H__
+#define GOOGLE_PROTOBUF_PYTHON_PYTHON_PROTOBUF_H__
+
+#define PY_SSIZE_T_CLEAN
+#include <Python.h>
+
+namespace google {
+namespace protobuf {
+
+class Message;
+
+namespace python {
+
+// Return the pointer to the C proto inside the given Python proto,
+// or NULL when this is not a Python proto implemented with a C proto.
+const Message* GetCProtoInsidePyProto(PyObject* msg);
+Message* MutableCProtoInsidePyProto(PyObject* msg);
+
+} // namespace python
+} // namespace protobuf
+} // namespace google
+
+#endif // GOOGLE_PROTOBUF_PYTHON_PYTHON_PROTOBUF_H__
diff --git a/contrib/python/protobuf/py3/google/protobuf/reflection.py b/contrib/python/protobuf/py3/google/protobuf/reflection.py
index 81e18859a80..1627669b955 100644
--- a/contrib/python/protobuf/py3/google/protobuf/reflection.py
+++ b/contrib/python/protobuf/py3/google/protobuf/reflection.py
@@ -92,4 +92,4 @@ def MakeClass(descriptor):
# Original implementation leads to duplicate message classes, which won't play
# well with extensions. Message factory info is also missing.
# Redirect to message_factory.
- return symbol_database.Default().GetPrototype(descriptor)
+ return message_factory.GetMessageClass(descriptor)
diff --git a/contrib/python/protobuf/py3/google/protobuf/symbol_database.py b/contrib/python/protobuf/py3/google/protobuf/symbol_database.py
index fdcf8cf06ce..390c49810df 100644
--- a/contrib/python/protobuf/py3/google/protobuf/symbol_database.py
+++ b/contrib/python/protobuf/py3/google/protobuf/symbol_database.py
@@ -57,15 +57,41 @@ Example usage::
my_message_instance = db.GetSymbol('MyMessage')()
"""
+import warnings
from google.protobuf.internal import api_implementation
from google.protobuf import descriptor_pool
from google.protobuf import message_factory
-class SymbolDatabase(message_factory.MessageFactory):
+class SymbolDatabase():
"""A database of Python generated symbols."""
+ # local cache of registered classes.
+ _classes = {}
+
+ def __init__(self, pool=None):
+ """Initializes a new SymbolDatabase."""
+ self.pool = pool or descriptor_pool.DescriptorPool()
+
+ def GetPrototype(self, descriptor):
+ warnings.warn('SymbolDatabase.GetPrototype() is deprecated. Please '
+ 'use message_factory.GetMessageClass() instead. '
+ 'SymbolDatabase.GetPrototype() will be removed soon.')
+ return message_factory.GetMessageClass(descriptor)
+
+ def CreatePrototype(self, descriptor):
+ warnings.warn('Directly call CreatePrototype() is wrong. Please use '
+ 'message_factory.GetMessageClass() instead. '
+ 'SymbolDatabase.CreatePrototype() will be removed soon.')
+ return message_factory._InternalCreateMessageClass(descriptor)
+
+ def GetMessages(self, files):
+ warnings.warn('SymbolDatabase.GetMessages() is deprecated. Please use '
+ 'message_factory.GetMessageClassedForFiles() instead. '
+ 'SymbolDatabase.GetMessages() will be removed soon.')
+ return message_factory.GetMessageClassedForFiles(files, self.pool)
+
def RegisterMessage(self, message):
"""Registers the given message type in the local database.
diff --git a/contrib/python/protobuf/py3/google/protobuf/text_encoding.py b/contrib/python/protobuf/py3/google/protobuf/text_encoding.py
index 759cf11f62b..1955b6a3c0f 100644
--- a/contrib/python/protobuf/py3/google/protobuf/text_encoding.py
+++ b/contrib/python/protobuf/py3/google/protobuf/text_encoding.py
@@ -53,8 +53,7 @@ for byte, string in _cescape_chr_to_symbol_map.items():
del byte, string
-def CEscape(text, as_utf8):
- # type: (...) -> str
+def CEscape(text, as_utf8) -> str:
"""Escape a bytes string for use in an text protocol buffer.
Args:
@@ -83,8 +82,7 @@ def CEscape(text, as_utf8):
_CUNESCAPE_HEX = re.compile(r'(\\+)x([0-9a-fA-F])(?![0-9a-fA-F])')
-def CUnescape(text):
- # type: (str) -> bytes
+def CUnescape(text: str) -> bytes:
"""Unescape a text string with C-style escape sequences to UTF-8 bytes.
Args:
diff --git a/contrib/python/protobuf/py3/google/protobuf/text_format.py b/contrib/python/protobuf/py3/google/protobuf/text_format.py
index a6d8bcf6482..e1a5ad54492 100644
--- a/contrib/python/protobuf/py3/google/protobuf/text_format.py
+++ b/contrib/python/protobuf/py3/google/protobuf/text_format.py
@@ -67,6 +67,7 @@ _FLOAT_INFINITY = re.compile('-?inf(?:inity)?f?$', re.IGNORECASE)
_FLOAT_NAN = re.compile('nanf?$', re.IGNORECASE)
_QUOTES = frozenset(("'", '"'))
_ANY_FULL_TYPE_NAME = 'google.protobuf.Any'
+_DEBUG_STRING_SILENT_MARKER = '\t '
class Error(Exception):
@@ -125,8 +126,7 @@ def MessageToString(
indent=0,
message_formatter=None,
print_unknown_fields=False,
- force_colon=False):
- # type: (...) -> str
+ force_colon=False) -> str:
"""Convert protobuf message to text format.
Double values can be formatted compactly with 15 digits of
@@ -191,8 +191,7 @@ def MessageToString(
return result
-def MessageToBytes(message, **kwargs):
- # type: (...) -> bytes
+def MessageToBytes(message, **kwargs) -> bytes:
"""Convert protobuf message to encoded text format. See MessageToString."""
text = MessageToString(message, **kwargs)
if isinstance(text, bytes):
@@ -331,17 +330,16 @@ def _BuildMessageFromTypeName(type_name, descriptor_pool):
if descriptor_pool is None:
from google.protobuf import descriptor_pool as pool_mod
descriptor_pool = pool_mod.Default()
- from google.protobuf import symbol_database
- database = symbol_database.Default()
+ from google.protobuf import message_factory
try:
message_descriptor = descriptor_pool.FindMessageTypeByName(type_name)
except KeyError:
return None
- message_type = database.GetPrototype(message_descriptor)
+ message_type = message_factory.GetMessageClass(message_descriptor)
return message_type()
-# These values must match WireType enum in google/protobuf/wire_format.h.
+# These values must match WireType enum in //google/protobuf/wire_format.h.
WIRETYPE_LENGTH_DELIMITED = 2
WIRETYPE_START_GROUP = 3
@@ -558,7 +556,7 @@ class _Printer(object):
# For groups, use the capitalized name.
out.write(field.message_type.name)
else:
- out.write(field.name)
+ out.write(field.name)
if (self.force_colon or
field.cpp_type != descriptor.FieldDescriptor.CPPTYPE_MESSAGE):
@@ -856,10 +854,15 @@ class _Parser(object):
ParseError: On text parsing problems.
"""
# Tokenize expects native str lines.
- str_lines = (
- line if isinstance(line, str) else line.decode('utf-8')
- for line in lines)
- tokenizer = Tokenizer(str_lines)
+ try:
+ str_lines = (
+ line if isinstance(line, str) else line.decode('utf-8')
+ for line in lines)
+ tokenizer = Tokenizer(str_lines)
+ except UnicodeDecodeError as e:
+ raise ParseError from e
+ if message:
+ self.root_type = message.DESCRIPTOR.full_name
while not tokenizer.AtEnd():
self._MergeField(tokenizer, message)
@@ -879,6 +882,8 @@ class _Parser(object):
type_url_prefix, packed_type_name = self._ConsumeAnyTypeUrl(tokenizer)
tokenizer.Consume(']')
tokenizer.TryConsume(':')
+ self._DetectSilentMarker(tokenizer, message_descriptor.full_name,
+ type_url_prefix + '/' + packed_type_name)
if tokenizer.TryConsume('<'):
expanded_any_end_token = '>'
else:
@@ -917,8 +922,6 @@ class _Parser(object):
# pylint: disable=protected-access
field = message.Extensions._FindExtensionByName(name)
# pylint: enable=protected-access
-
-
if not field:
if self.allow_unknown_extension:
field = None
@@ -978,9 +981,13 @@ class _Parser(object):
if field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_MESSAGE:
tokenizer.TryConsume(':')
+ self._DetectSilentMarker(tokenizer, message_descriptor.full_name,
+ field.full_name)
merger = self._MergeMessageField
else:
tokenizer.Consume(':')
+ self._DetectSilentMarker(tokenizer, message_descriptor.full_name,
+ field.full_name)
merger = self._MergeScalarField
if (field.label == descriptor.FieldDescriptor.LABEL_REPEATED and
@@ -998,13 +1005,19 @@ class _Parser(object):
else: # Proto field is unknown.
assert (self.allow_unknown_extension or self.allow_unknown_field)
- _SkipFieldContents(tokenizer)
+ self._SkipFieldContents(tokenizer, name, message_descriptor.full_name)
# For historical reasons, fields may optionally be separated by commas or
# semicolons.
if not tokenizer.TryConsume(','):
tokenizer.TryConsume(';')
+ def _LogSilentMarker(self, immediate_message_type, field_name):
+ pass
+
+ def _DetectSilentMarker(self, tokenizer, immediate_message_type, field_name):
+ if tokenizer.contains_silent_marker_before_current_token:
+ self._LogSilentMarker(immediate_message_type, field_name)
def _ConsumeAnyTypeUrl(self, tokenizer):
"""Consumes a google.protobuf.Any type URL and returns the type name."""
@@ -1079,12 +1092,6 @@ class _Parser(object):
else:
getattr(message, field.name)[sub_message.key] = sub_message.value
- @staticmethod
- def _IsProto3Syntax(message):
- message_descriptor = message.DESCRIPTOR
- return (hasattr(message_descriptor, 'syntax') and
- message_descriptor.syntax == 'proto3')
-
def _MergeScalarField(self, tokenizer, message, field):
"""Merges a single scalar field into a message.
@@ -1136,7 +1143,7 @@ class _Parser(object):
else:
if field.is_extension:
if (not self._allow_multiple_scalars and
- not self._IsProto3Syntax(message) and
+ field.has_presence and
message.HasExtension(field)):
raise tokenizer.ParseErrorPreviousToken(
'Message type "%s" should not have multiple "%s" extensions.' %
@@ -1146,12 +1153,12 @@ class _Parser(object):
else:
duplicate_error = False
if not self._allow_multiple_scalars:
- if self._IsProto3Syntax(message):
- # Proto3 doesn't represent presence so we try best effort to check
- # multiple scalars by compare to default values.
- duplicate_error = bool(getattr(message, field.name))
- else:
+ if field.has_presence:
duplicate_error = message.HasField(field.name)
+ else:
+ # For field that doesn't represent presence, try best effort to
+ # check multiple scalars by compare to default values.
+ duplicate_error = bool(getattr(message, field.name))
if duplicate_error:
raise tokenizer.ParseErrorPreviousToken(
@@ -1160,105 +1167,117 @@ class _Parser(object):
else:
setattr(message, field.name, value)
+ def _SkipFieldContents(self, tokenizer, field_name, immediate_message_type):
+ """Skips over contents (value or message) of a field.
-def _SkipFieldContents(tokenizer):
- """Skips over contents (value or message) of a field.
-
- Args:
- tokenizer: A tokenizer to parse the field name and values.
- """
- # Try to guess the type of this field.
- # If this field is not a message, there should be a ":" between the
- # field name and the field value and also the field value should not
- # start with "{" or "<" which indicates the beginning of a message body.
- # If there is no ":" or there is a "{" or "<" after ":", this field has
- # to be a message or the input is ill-formed.
- if tokenizer.TryConsume(
- ':') and not tokenizer.LookingAt('{') and not tokenizer.LookingAt('<'):
- if tokenizer.LookingAt('['):
- _SkipRepeatedFieldValue(tokenizer)
+ Args:
+ tokenizer: A tokenizer to parse the field name and values.
+ field_name: The field name currently being parsed.
+ immediate_message_type: The type of the message immediately containing
+ the silent marker.
+ """
+ # Try to guess the type of this field.
+ # If this field is not a message, there should be a ":" between the
+ # field name and the field value and also the field value should not
+ # start with "{" or "<" which indicates the beginning of a message body.
+ # If there is no ":" or there is a "{" or "<" after ":", this field has
+ # to be a message or the input is ill-formed.
+ if tokenizer.TryConsume(
+ ':') and not tokenizer.LookingAt('{') and not tokenizer.LookingAt('<'):
+ self._DetectSilentMarker(tokenizer, immediate_message_type, field_name)
+ if tokenizer.LookingAt('['):
+ self._SkipRepeatedFieldValue(tokenizer)
+ else:
+ self._SkipFieldValue(tokenizer)
else:
- _SkipFieldValue(tokenizer)
- else:
- _SkipFieldMessage(tokenizer)
-
-
-def _SkipField(tokenizer):
- """Skips over a complete field (name and value/message).
-
- Args:
- tokenizer: A tokenizer to parse the field name and values.
- """
- if tokenizer.TryConsume('['):
- # Consume extension name.
- tokenizer.ConsumeIdentifier()
- while tokenizer.TryConsume('.'):
- tokenizer.ConsumeIdentifier()
- tokenizer.Consume(']')
- else:
- tokenizer.ConsumeIdentifierOrNumber()
-
- _SkipFieldContents(tokenizer)
+ self._DetectSilentMarker(tokenizer, immediate_message_type, field_name)
+ self._SkipFieldMessage(tokenizer, immediate_message_type)
- # For historical reasons, fields may optionally be separated by commas or
- # semicolons.
- if not tokenizer.TryConsume(','):
- tokenizer.TryConsume(';')
+ def _SkipField(self, tokenizer, immediate_message_type):
+ """Skips over a complete field (name and value/message).
+ Args:
+ tokenizer: A tokenizer to parse the field name and values.
+ immediate_message_type: The type of the message immediately containing
+ the silent marker.
+ """
+ field_name = ''
+ if tokenizer.TryConsume('['):
+ # Consume extension or google.protobuf.Any type URL
+ field_name += '[' + tokenizer.ConsumeIdentifier()
+ num_identifiers = 1
+ while tokenizer.TryConsume('.'):
+ field_name += '.' + tokenizer.ConsumeIdentifier()
+ num_identifiers += 1
+ # This is possibly a type URL for an Any message.
+ if num_identifiers == 3 and tokenizer.TryConsume('/'):
+ field_name += '/' + tokenizer.ConsumeIdentifier()
+ while tokenizer.TryConsume('.'):
+ field_name += '.' + tokenizer.ConsumeIdentifier()
+ tokenizer.Consume(']')
+ field_name += ']'
+ else:
+ field_name += tokenizer.ConsumeIdentifierOrNumber()
-def _SkipFieldMessage(tokenizer):
- """Skips over a field message.
-
- Args:
- tokenizer: A tokenizer to parse the field name and values.
- """
+ self._SkipFieldContents(tokenizer, field_name, immediate_message_type)
- if tokenizer.TryConsume('<'):
- delimiter = '>'
- else:
- tokenizer.Consume('{')
- delimiter = '}'
+ # For historical reasons, fields may optionally be separated by commas or
+ # semicolons.
+ if not tokenizer.TryConsume(','):
+ tokenizer.TryConsume(';')
- while not tokenizer.LookingAt('>') and not tokenizer.LookingAt('}'):
- _SkipField(tokenizer)
+ def _SkipFieldMessage(self, tokenizer, immediate_message_type):
+ """Skips over a field message.
- tokenizer.Consume(delimiter)
+ Args:
+ tokenizer: A tokenizer to parse the field name and values.
+ immediate_message_type: The type of the message immediately containing
+ the silent marker
+ """
+ if tokenizer.TryConsume('<'):
+ delimiter = '>'
+ else:
+ tokenizer.Consume('{')
+ delimiter = '}'
+ while not tokenizer.LookingAt('>') and not tokenizer.LookingAt('}'):
+ self._SkipField(tokenizer, immediate_message_type)
-def _SkipFieldValue(tokenizer):
- """Skips over a field value.
+ tokenizer.Consume(delimiter)
- Args:
- tokenizer: A tokenizer to parse the field name and values.
+ def _SkipFieldValue(self, tokenizer):
+ """Skips over a field value.
- Raises:
- ParseError: In case an invalid field value is found.
- """
- # String/bytes tokens can come in multiple adjacent string literals.
- # If we can consume one, consume as many as we can.
- if tokenizer.TryConsumeByteString():
- while tokenizer.TryConsumeByteString():
- pass
- return
+ Args:
+ tokenizer: A tokenizer to parse the field name and values.
- if (not tokenizer.TryConsumeIdentifier() and
- not _TryConsumeInt64(tokenizer) and not _TryConsumeUint64(tokenizer) and
- not tokenizer.TryConsumeFloat()):
- raise ParseError('Invalid field value: ' + tokenizer.token)
+ Raises:
+ ParseError: In case an invalid field value is found.
+ """
+ # String/bytes tokens can come in multiple adjacent string literals.
+ # If we can consume one, consume as many as we can.
+ if tokenizer.TryConsumeByteString():
+ while tokenizer.TryConsumeByteString():
+ pass
+ return
+ if (not tokenizer.TryConsumeIdentifier() and
+ not _TryConsumeInt64(tokenizer) and not _TryConsumeUint64(tokenizer) and
+ not tokenizer.TryConsumeFloat()):
+ raise ParseError('Invalid field value: ' + tokenizer.token)
-def _SkipRepeatedFieldValue(tokenizer):
- """Skips over a repeated field value.
+ def _SkipRepeatedFieldValue(self, tokenizer):
+ """Skips over a repeated field value.
- Args:
- tokenizer: A tokenizer to parse the field value.
- """
- tokenizer.Consume('[')
- if not tokenizer.LookingAt(']'):
- _SkipFieldValue(tokenizer)
- while tokenizer.TryConsume(','):
- _SkipFieldValue(tokenizer)
- tokenizer.Consume(']')
+ Args:
+ tokenizer: A tokenizer to parse the field value.
+ """
+ tokenizer.Consume('[')
+ if not tokenizer.LookingAt(']'):
+ self._SkipFieldValue(tokenizer)
+ while tokenizer.TryConsume(','):
+ self._SkipFieldValue(tokenizer)
+ tokenizer.Consume(']')
class Tokenizer(object):
@@ -1299,6 +1318,8 @@ class Tokenizer(object):
self._skip_comments = skip_comments
self._whitespace_pattern = (skip_comments and self._WHITESPACE_OR_COMMENT
or self._WHITESPACE)
+ self.contains_silent_marker_before_current_token = False
+
self._SkipWhitespace()
self.NextToken()
@@ -1331,6 +1352,8 @@ class Tokenizer(object):
match = self._whitespace_pattern.match(self._current_line, self._column)
if not match:
break
+ self.contains_silent_marker_before_current_token = match.group(0) == (
+ ' ' + _DEBUG_STRING_SILENT_MARKER)
length = len(match.group(0))
self._column += length
@@ -1583,6 +1606,7 @@ class Tokenizer(object):
"""Reads the next meaningful token."""
self._previous_line = self._line
self._previous_column = self._column
+ self.contains_silent_marker_before_current_token = False
self._column += len(self.token)
self._SkipWhitespace()
@@ -1829,12 +1853,8 @@ def ParseEnum(field, value):
raise ValueError('Enum type "%s" has no value named %s.' %
(enum_descriptor.full_name, value))
else:
- # Numeric value.
- if hasattr(field.file, 'syntax'):
- # Attribute is checked for compatibility.
- if field.file.syntax == 'proto3':
- # Proto3 accept numeric unknown enums.
- return number
+ if not field.enum_type.is_closed:
+ return number
enum_value = enum_descriptor.values_by_number.get(number, None)
if enum_value is None:
raise ValueError('Enum type "%s" has no value with number %d.' %
diff --git a/contrib/python/protobuf/py3/ya.make b/contrib/python/protobuf/py3/ya.make
index c00e01b8128..da1daa078e2 100644
--- a/contrib/python/protobuf/py3/ya.make
+++ b/contrib/python/protobuf/py3/ya.make
@@ -1,4 +1,4 @@
-# Generated by devtools/yamaker from nixpkgs 22.05.
+# Generated by devtools/yamaker/ym2
PY3_LIBRARY()
@@ -9,93 +9,36 @@ LICENSE(
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-VERSION(4.21.7)
+VERSION(4.22.5)
-ORIGINAL_SOURCE(mirror://pypi/p/protobuf/protobuf-4.21.7.tar.gz)
+ORIGINAL_SOURCE(https://github.com/protocolbuffers/protobuf/archive/refs/tags/v4.22.5.tar.gz)
+
+NO_COMPILER_WARNINGS()
PEERDIR(
contrib/libs/protobuf
contrib/libs/protobuf/builtin_proto/protos_from_protobuf
contrib/libs/protobuf/builtin_proto/protos_from_protoc
contrib/libs/python
+ contrib/restricted/abseil-cpp-tstring/y_absl/strings
+ contrib/restricted/abseil-cpp-tstring/y_absl/log
)
+NO_LINT()
+
ADDINCL(
contrib/python/protobuf/py3
)
-NO_COMPILER_WARNINGS()
-
-NO_LINT()
-
CFLAGS(
-DPYTHON_PROTO2_CPP_IMPL_V2
)
-SRCS(
- google/protobuf/internal/api_implementation.cc
- google/protobuf/pyext/descriptor.cc
- google/protobuf/pyext/descriptor_containers.cc
- google/protobuf/pyext/descriptor_database.cc
- google/protobuf/pyext/descriptor_pool.cc
- google/protobuf/pyext/extension_dict.cc
- google/protobuf/pyext/field.cc
- google/protobuf/pyext/map_container.cc
- google/protobuf/pyext/message.cc
- google/protobuf/pyext/message_factory.cc
- google/protobuf/pyext/message_module.cc
- google/protobuf/pyext/repeated_composite_container.cc
- google/protobuf/pyext/repeated_scalar_container.cc
- google/protobuf/pyext/unknown_field_set.cc
- google/protobuf/pyext/unknown_fields.cc
-)
+INCLUDE(ya.make.inc)
PY_REGISTER(
google.protobuf.internal._api_implementation
google.protobuf.pyext._message
)
-PY_SRCS(
- TOP_LEVEL
- google/__init__.py
- google/protobuf/__init__.py
- google/protobuf/compiler/__init__.py
- google/protobuf/descriptor.py
- google/protobuf/descriptor_database.py
- 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
- google/protobuf/internal/enum_type_wrapper.py
- google/protobuf/internal/extension_dict.py
- google/protobuf/internal/message_listener.py
- google/protobuf/internal/python_message.py
- google/protobuf/internal/type_checkers.py
- google/protobuf/internal/well_known_types.py
- google/protobuf/internal/wire_format.py
- google/protobuf/json_format.py
- google/protobuf/message.py
- google/protobuf/message_factory.py
- google/protobuf/proto_builder.py
- google/protobuf/pyext/__init__.py
- google/protobuf/pyext/cpp_message.py
- google/protobuf/reflection.py
- google/protobuf/service.py
- google/protobuf/service_reflection.py
- google/protobuf/symbol_database.py
- google/protobuf/text_encoding.py
- google/protobuf/text_format.py
- google/protobuf/unknown_fields.py
- google/protobuf/util/__init__.py
-)
-
-RESOURCE_FILES(
- PREFIX contrib/python/protobuf/py3/
- .dist-info/METADATA
- .dist-info/top_level.txt
-)
-
END()
diff --git a/contrib/python/protobuf/py3/ya.make.inc b/contrib/python/protobuf/py3/ya.make.inc
new file mode 100644
index 00000000000..a6e45bc1fe2
--- /dev/null
+++ b/contrib/python/protobuf/py3/ya.make.inc
@@ -0,0 +1,57 @@
+PY_SRCS(
+ TOP_LEVEL
+ google/__init__.py
+ google/protobuf/__init__.py
+ google/protobuf/compiler/__init__.py
+ google/protobuf/descriptor.py
+ google/protobuf/descriptor_database.py
+ google/protobuf/descriptor_pool.py
+ google/protobuf/internal/__init__.py
+ google/protobuf/internal/_parameterized.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
+ google/protobuf/internal/enum_type_wrapper.py
+ google/protobuf/internal/extension_dict.py
+ google/protobuf/internal/field_mask.py
+ google/protobuf/internal/message_listener.py
+ google/protobuf/internal/python_message.py
+ google/protobuf/internal/testing_refleaks.py
+ google/protobuf/internal/type_checkers.py
+ google/protobuf/internal/well_known_types.py
+ google/protobuf/internal/wire_format.py
+ google/protobuf/json_format.py
+ google/protobuf/message.py
+ google/protobuf/message_factory.py
+ google/protobuf/proto_builder.py
+ google/protobuf/pyext/__init__.py
+ google/protobuf/pyext/cpp_message.py
+ google/protobuf/reflection.py
+ google/protobuf/service.py
+ google/protobuf/service_reflection.py
+ google/protobuf/symbol_database.py
+ google/protobuf/text_encoding.py
+ google/protobuf/text_format.py
+ google/protobuf/unknown_fields.py
+ google/protobuf/util/__init__.py
+)
+SRCS(
+ google/protobuf/internal/api_implementation.cc
+ google/protobuf/internal/python_protobuf.cc
+ google/protobuf/pyext/descriptor.cc
+ google/protobuf/pyext/descriptor_containers.cc
+ google/protobuf/pyext/descriptor_database.cc
+ google/protobuf/pyext/descriptor_pool.cc
+ google/protobuf/pyext/extension_dict.cc
+ google/protobuf/pyext/field.cc
+ google/protobuf/pyext/map_container.cc
+ google/protobuf/pyext/message.cc
+ google/protobuf/pyext/message_factory.cc
+ google/protobuf/pyext/message_module.cc
+ google/protobuf/pyext/repeated_composite_container.cc
+ google/protobuf/pyext/repeated_scalar_container.cc
+ google/protobuf/pyext/unknown_field_set.cc
+ google/protobuf/pyext/unknown_fields.cc
+)
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/config.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/config.h
index 58bafcd8290..527b6181a2f 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/config.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/config.h
@@ -917,6 +917,12 @@ static_assert(Y_ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
#define Y_ABSL_INTERNAL_HAVE_SSSE3 1
#endif
+#ifdef __NVCC__
+#undef Y_ABSL_INTERNAL_HAVE_SSE
+#undef Y_ABSL_INTERNAL_HAVE_SSE2
+#undef Y_ABSL_INTERNAL_HAVE_SSSE3
+#endif
+
// Y_ABSL_INTERNAL_HAVE_ARM_NEON is used for compile-time detection of NEON (ARM
// SIMD).
//
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_map.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_map.h
new file mode 100644
index 00000000000..dfe06ec5647
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_map.h
@@ -0,0 +1,889 @@
+// Copyright 2018 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: btree_map.h
+// -----------------------------------------------------------------------------
+//
+// This header file defines B-tree maps: sorted associative containers mapping
+// keys to values.
+//
+// * `y_absl::btree_map<>`
+// * `y_absl::btree_multimap<>`
+//
+// These B-tree types are similar to the corresponding types in the STL
+// (`std::map` and `std::multimap`) and generally conform to the STL interfaces
+// of those types. However, because they are implemented using B-trees, they
+// are more efficient in most situations.
+//
+// Unlike `std::map` and `std::multimap`, which are commonly implemented using
+// red-black tree nodes, B-tree maps use more generic B-tree nodes able to hold
+// multiple values per node. Holding multiple values per node often makes
+// B-tree maps perform better than their `std::map` counterparts, because
+// multiple entries can be checked within the same cache hit.
+//
+// However, these types should not be considered drop-in replacements for
+// `std::map` and `std::multimap` as there are some API differences, which are
+// noted in this header file. The most consequential differences with respect to
+// migrating to b-tree from the STL types are listed in the next paragraph.
+// Other API differences are minor.
+//
+// Importantly, insertions and deletions may invalidate outstanding iterators,
+// pointers, and references to elements. Such invalidations are typically only
+// an issue if insertion and deletion operations are interleaved with the use of
+// more than one iterator, pointer, or reference simultaneously. For this
+// reason, `insert()`, `erase()`, and `extract_and_get_next()` return a valid
+// iterator at the current position. Another important difference is that
+// key-types must be copy-constructible.
+//
+// Another API difference is that btree iterators can be subtracted, and this
+// is faster than using std::distance.
+//
+// B-tree maps are not exception-safe.
+
+#ifndef Y_ABSL_CONTAINER_BTREE_MAP_H_
+#define Y_ABSL_CONTAINER_BTREE_MAP_H_
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/container/internal/btree.h" // IWYU pragma: export
+#include "y_absl/container/internal/btree_container.h" // IWYU pragma: export
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+
+namespace container_internal {
+
+template <typename Key, typename Data, typename Compare, typename Alloc,
+ int TargetNodeSize, bool IsMulti>
+struct map_params;
+
+} // namespace container_internal
+
+// y_absl::btree_map<>
+//
+// An `y_absl::btree_map<K, V>` is an ordered associative container of
+// unique keys and associated values designed to be a more efficient replacement
+// for `std::map` (in most cases).
+//
+// Keys are sorted using an (optional) comparison function, which defaults to
+// `std::less<K>`.
+//
+// An `y_absl::btree_map<K, V>` uses a default allocator of
+// `std::allocator<std::pair<const K, V>>` to allocate (and deallocate)
+// nodes, and construct and destruct values within those nodes. You may
+// instead specify a custom allocator `A` (which in turn requires specifying a
+// custom comparator `C`) as in `y_absl::btree_map<K, V, C, A>`.
+//
+template <typename Key, typename Value, typename Compare = std::less<Key>,
+ typename Alloc = std::allocator<std::pair<const Key, Value>>>
+class Y_ABSL_INTERNAL_ATTRIBUTE_OWNER btree_map
+ : public container_internal::btree_map_container<
+ container_internal::btree<container_internal::map_params<
+ Key, Value, Compare, Alloc, /*TargetNodeSize=*/256,
+ /*IsMulti=*/false>>> {
+ using Base = typename btree_map::btree_map_container;
+
+ public:
+ // Constructors and Assignment Operators
+ //
+ // A `btree_map` supports the same overload set as `std::map`
+ // for construction and assignment:
+ //
+ // * Default constructor
+ //
+ // y_absl::btree_map<int, TString> map1;
+ //
+ // * Initializer List constructor
+ //
+ // y_absl::btree_map<int, TString> map2 =
+ // {{1, "huey"}, {2, "dewey"}, {3, "louie"},};
+ //
+ // * Copy constructor
+ //
+ // y_absl::btree_map<int, TString> map3(map2);
+ //
+ // * Copy assignment operator
+ //
+ // y_absl::btree_map<int, TString> map4;
+ // map4 = map3;
+ //
+ // * Move constructor
+ //
+ // // Move is guaranteed efficient
+ // y_absl::btree_map<int, TString> map5(std::move(map4));
+ //
+ // * Move assignment operator
+ //
+ // // May be efficient if allocators are compatible
+ // y_absl::btree_map<int, TString> map6;
+ // map6 = std::move(map5);
+ //
+ // * Range constructor
+ //
+ // std::vector<std::pair<int, TString>> v = {{1, "a"}, {2, "b"}};
+ // y_absl::btree_map<int, TString> map7(v.begin(), v.end());
+ btree_map() {}
+ using Base::Base;
+
+ // btree_map::begin()
+ //
+ // Returns an iterator to the beginning of the `btree_map`.
+ using Base::begin;
+
+ // btree_map::cbegin()
+ //
+ // Returns a const iterator to the beginning of the `btree_map`.
+ using Base::cbegin;
+
+ // btree_map::end()
+ //
+ // Returns an iterator to the end of the `btree_map`.
+ using Base::end;
+
+ // btree_map::cend()
+ //
+ // Returns a const iterator to the end of the `btree_map`.
+ using Base::cend;
+
+ // btree_map::empty()
+ //
+ // Returns whether or not the `btree_map` is empty.
+ using Base::empty;
+
+ // btree_map::max_size()
+ //
+ // Returns the largest theoretical possible number of elements within a
+ // `btree_map` under current memory constraints. This value can be thought
+ // of as the largest value of `std::distance(begin(), end())` for a
+ // `btree_map<Key, T>`.
+ using Base::max_size;
+
+ // btree_map::size()
+ //
+ // Returns the number of elements currently within the `btree_map`.
+ using Base::size;
+
+ // btree_map::clear()
+ //
+ // Removes all elements from the `btree_map`. Invalidates any references,
+ // pointers, or iterators referring to contained elements.
+ using Base::clear;
+
+ // btree_map::erase()
+ //
+ // Erases elements within the `btree_map`. If an erase occurs, any references,
+ // pointers, or iterators are invalidated.
+ // Overloads are listed below.
+ //
+ // iterator erase(iterator position):
+ // iterator erase(const_iterator position):
+ //
+ // Erases the element at `position` of the `btree_map`, returning
+ // the iterator pointing to the element after the one that was erased
+ // (or end() if none exists).
+ //
+ // iterator erase(const_iterator first, const_iterator last):
+ //
+ // Erases the elements in the open interval [`first`, `last`), returning
+ // the iterator pointing to the element after the interval that was erased
+ // (or end() if none exists).
+ //
+ // template <typename K> size_type erase(const K& key):
+ //
+ // Erases the element with the matching key, if it exists, returning the
+ // number of elements erased (0 or 1).
+ using Base::erase;
+
+ // btree_map::insert()
+ //
+ // Inserts an element of the specified value into the `btree_map`,
+ // returning an iterator pointing to the newly inserted element, provided that
+ // an element with the given key does not already exist. If an insertion
+ // occurs, any references, pointers, or iterators are invalidated.
+ // Overloads are listed below.
+ //
+ // std::pair<iterator,bool> insert(const value_type& value):
+ //
+ // Inserts a value into the `btree_map`. Returns a pair consisting of an
+ // iterator to the inserted element (or to the element that prevented the
+ // insertion) and a bool denoting whether the insertion took place.
+ //
+ // std::pair<iterator,bool> insert(value_type&& value):
+ //
+ // Inserts a moveable value into the `btree_map`. Returns a pair
+ // consisting of an iterator to the inserted element (or to the element that
+ // prevented the insertion) and a bool denoting whether the insertion took
+ // place.
+ //
+ // iterator insert(const_iterator hint, const value_type& value):
+ // iterator insert(const_iterator hint, value_type&& value):
+ //
+ // Inserts a value, using the position of `hint` as a non-binding suggestion
+ // for where to begin the insertion search. Returns an iterator to the
+ // inserted element, or to the existing element that prevented the
+ // insertion.
+ //
+ // void insert(InputIterator first, InputIterator last):
+ //
+ // Inserts a range of values [`first`, `last`).
+ //
+ // void insert(std::initializer_list<init_type> ilist):
+ //
+ // Inserts the elements within the initializer list `ilist`.
+ using Base::insert;
+
+ // btree_map::insert_or_assign()
+ //
+ // Inserts an element of the specified value into the `btree_map` provided
+ // that a value with the given key does not already exist, or replaces the
+ // corresponding mapped type with the forwarded `obj` argument if a key for
+ // that value already exists, returning an iterator pointing to the newly
+ // inserted element. Overloads are listed below.
+ //
+ // pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj):
+ // pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj):
+ //
+ // Inserts/Assigns (or moves) the element of the specified key into the
+ // `btree_map`. If the returned bool is true, insertion took place, and if
+ // it's false, assignment took place.
+ //
+ // iterator insert_or_assign(const_iterator hint,
+ // const key_type& k, M&& obj):
+ // iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj):
+ //
+ // Inserts/Assigns (or moves) the element of the specified key into the
+ // `btree_map` using the position of `hint` as a non-binding suggestion
+ // for where to begin the insertion search.
+ using Base::insert_or_assign;
+
+ // btree_map::emplace()
+ //
+ // Inserts an element of the specified value by constructing it in-place
+ // within the `btree_map`, provided that no element with the given key
+ // already exists.
+ //
+ // The element may be constructed even if there already is an element with the
+ // key in the container, in which case the newly constructed element will be
+ // destroyed immediately. Prefer `try_emplace()` unless your key is not
+ // copyable or moveable.
+ //
+ // If an insertion occurs, any references, pointers, or iterators are
+ // invalidated.
+ using Base::emplace;
+
+ // btree_map::emplace_hint()
+ //
+ // Inserts an element of the specified value by constructing it in-place
+ // within the `btree_map`, using the position of `hint` as a non-binding
+ // suggestion for where to begin the insertion search, and only inserts
+ // provided that no element with the given key already exists.
+ //
+ // The element may be constructed even if there already is an element with the
+ // key in the container, in which case the newly constructed element will be
+ // destroyed immediately. Prefer `try_emplace()` unless your key is not
+ // copyable or moveable.
+ //
+ // If an insertion occurs, any references, pointers, or iterators are
+ // invalidated.
+ using Base::emplace_hint;
+
+ // btree_map::try_emplace()
+ //
+ // Inserts an element of the specified value by constructing it in-place
+ // within the `btree_map`, provided that no element with the given key
+ // already exists. Unlike `emplace()`, if an element with the given key
+ // already exists, we guarantee that no element is constructed.
+ //
+ // If an insertion occurs, any references, pointers, or iterators are
+ // invalidated.
+ //
+ // Overloads are listed below.
+ //
+ // std::pair<iterator, bool> try_emplace(const key_type& k, Args&&... args):
+ // std::pair<iterator, bool> try_emplace(key_type&& k, Args&&... args):
+ //
+ // Inserts (via copy or move) the element of the specified key into the
+ // `btree_map`.
+ //
+ // iterator try_emplace(const_iterator hint,
+ // const key_type& k, Args&&... args):
+ // iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args):
+ //
+ // Inserts (via copy or move) the element of the specified key into the
+ // `btree_map` using the position of `hint` as a non-binding suggestion
+ // for where to begin the insertion search.
+ using Base::try_emplace;
+
+ // btree_map::extract()
+ //
+ // Extracts the indicated element, erasing it in the process, and returns it
+ // as a C++17-compatible node handle. Any references, pointers, or iterators
+ // are invalidated. Overloads are listed below.
+ //
+ // node_type extract(const_iterator position):
+ //
+ // Extracts the element at the indicated position and returns a node handle
+ // owning that extracted data.
+ //
+ // template <typename K> node_type extract(const K& k):
+ //
+ // Extracts the element with the key matching the passed key value and
+ // returns a node handle owning that extracted data. If the `btree_map`
+ // does not contain an element with a matching key, this function returns an
+ // empty node handle.
+ //
+ // NOTE: when compiled in an earlier version of C++ than C++17,
+ // `node_type::key()` returns a const reference to the key instead of a
+ // mutable reference. We cannot safely return a mutable reference without
+ // std::launder (which is not available before C++17).
+ //
+ // NOTE: In this context, `node_type` refers to the C++17 concept of a
+ // move-only type that owns and provides access to the elements in associative
+ // containers (https://en.cppreference.com/w/cpp/container/node_handle).
+ // It does NOT refer to the data layout of the underlying btree.
+ using Base::extract;
+
+ // btree_map::extract_and_get_next()
+ //
+ // Extracts the indicated element, erasing it in the process, and returns it
+ // as a C++17-compatible node handle along with an iterator to the next
+ // element.
+ //
+ // extract_and_get_next_return_type extract_and_get_next(
+ // const_iterator position):
+ //
+ // Extracts the element at the indicated position, returns a struct
+ // containing a member named `node`: a node handle owning that extracted
+ // data and a member named `next`: an iterator pointing to the next element
+ // in the btree.
+ using Base::extract_and_get_next;
+
+ // btree_map::merge()
+ //
+ // Extracts elements from a given `source` btree_map into this
+ // `btree_map`. If the destination `btree_map` already contains an
+ // element with an equivalent key, that element is not extracted.
+ using Base::merge;
+
+ // btree_map::swap(btree_map& other)
+ //
+ // Exchanges the contents of this `btree_map` with those of the `other`
+ // btree_map, avoiding invocation of any move, copy, or swap operations on
+ // individual elements.
+ //
+ // All iterators and references on the `btree_map` remain valid, excepting
+ // for the past-the-end iterator, which is invalidated.
+ using Base::swap;
+
+ // btree_map::at()
+ //
+ // Returns a reference to the mapped value of the element with key equivalent
+ // to the passed key.
+ using Base::at;
+
+ // btree_map::contains()
+ //
+ // template <typename K> bool contains(const K& key) const:
+ //
+ // Determines whether an element comparing equal to the given `key` exists
+ // within the `btree_map`, returning `true` if so or `false` otherwise.
+ //
+ // Supports heterogeneous lookup, provided that the map has a compatible
+ // heterogeneous comparator.
+ using Base::contains;
+
+ // btree_map::count()
+ //
+ // template <typename K> size_type count(const K& key) const:
+ //
+ // Returns the number of elements comparing equal to the given `key` within
+ // the `btree_map`. Note that this function will return either `1` or `0`
+ // since duplicate elements are not allowed within a `btree_map`.
+ //
+ // Supports heterogeneous lookup, provided that the map has a compatible
+ // heterogeneous comparator.
+ using Base::count;
+
+ // btree_map::equal_range()
+ //
+ // Returns a half-open range [first, last), defined by a `std::pair` of two
+ // iterators, containing all elements with the passed key in the `btree_map`.
+ using Base::equal_range;
+
+ // btree_map::find()
+ //
+ // template <typename K> iterator find(const K& key):
+ // template <typename K> const_iterator find(const K& key) const:
+ //
+ // Finds an element with the passed `key` within the `btree_map`.
+ //
+ // Supports heterogeneous lookup, provided that the map has a compatible
+ // heterogeneous comparator.
+ using Base::find;
+
+ // btree_map::lower_bound()
+ //
+ // template <typename K> iterator lower_bound(const K& key):
+ // template <typename K> const_iterator lower_bound(const K& key) const:
+ //
+ // Finds the first element with a key that is not less than `key` within the
+ // `btree_map`.
+ //
+ // Supports heterogeneous lookup, provided that the map has a compatible
+ // heterogeneous comparator.
+ using Base::lower_bound;
+
+ // btree_map::upper_bound()
+ //
+ // template <typename K> iterator upper_bound(const K& key):
+ // template <typename K> const_iterator upper_bound(const K& key) const:
+ //
+ // Finds the first element with a key that is greater than `key` within the
+ // `btree_map`.
+ //
+ // Supports heterogeneous lookup, provided that the map has a compatible
+ // heterogeneous comparator.
+ using Base::upper_bound;
+
+ // btree_map::operator[]()
+ //
+ // Returns a reference to the value mapped to the passed key within the
+ // `btree_map`, performing an `insert()` if the key does not already
+ // exist.
+ //
+ // If an insertion occurs, any references, pointers, or iterators are
+ // invalidated. Otherwise iterators are not affected and references are not
+ // invalidated. Overloads are listed below.
+ //
+ // T& operator[](key_type&& key):
+ // T& operator[](const key_type& key):
+ //
+ // Inserts a value_type object constructed in-place if the element with the
+ // given key does not exist.
+ using Base::operator[];
+
+ // btree_map::get_allocator()
+ //
+ // Returns the allocator function associated with this `btree_map`.
+ using Base::get_allocator;
+
+ // btree_map::key_comp();
+ //
+ // Returns the key comparator associated with this `btree_map`.
+ using Base::key_comp;
+
+ // btree_map::value_comp();
+ //
+ // Returns the value comparator associated with this `btree_map`.
+ using Base::value_comp;
+};
+
+// y_absl::swap(y_absl::btree_map<>, y_absl::btree_map<>)
+//
+// Swaps the contents of two `y_absl::btree_map` containers.
+template <typename K, typename V, typename C, typename A>
+void swap(btree_map<K, V, C, A> &x, btree_map<K, V, C, A> &y) {
+ return x.swap(y);
+}
+
+// y_absl::erase_if(y_absl::btree_map<>, Pred)
+//
+// Erases all elements that satisfy the predicate pred from the container.
+// Returns the number of erased elements.
+template <typename K, typename V, typename C, typename A, typename Pred>
+typename btree_map<K, V, C, A>::size_type erase_if(
+ btree_map<K, V, C, A> &map, Pred pred) {
+ return container_internal::btree_access::erase_if(map, std::move(pred));
+}
+
+// y_absl::btree_multimap
+//
+// An `y_absl::btree_multimap<K, V>` is an ordered associative container of
+// keys and associated values designed to be a more efficient replacement for
+// `std::multimap` (in most cases). Unlike `y_absl::btree_map`, a B-tree multimap
+// allows multiple elements with equivalent keys.
+//
+// Keys are sorted using an (optional) comparison function, which defaults to
+// `std::less<K>`.
+//
+// An `y_absl::btree_multimap<K, V>` uses a default allocator of
+// `std::allocator<std::pair<const K, V>>` to allocate (and deallocate)
+// nodes, and construct and destruct values within those nodes. You may
+// instead specify a custom allocator `A` (which in turn requires specifying a
+// custom comparator `C`) as in `y_absl::btree_multimap<K, V, C, A>`.
+//
+template <typename Key, typename Value, typename Compare = std::less<Key>,
+ typename Alloc = std::allocator<std::pair<const Key, Value>>>
+class Y_ABSL_INTERNAL_ATTRIBUTE_OWNER btree_multimap
+ : public container_internal::btree_multimap_container<
+ container_internal::btree<container_internal::map_params<
+ Key, Value, Compare, Alloc, /*TargetNodeSize=*/256,
+ /*IsMulti=*/true>>> {
+ using Base = typename btree_multimap::btree_multimap_container;
+
+ public:
+ // Constructors and Assignment Operators
+ //
+ // A `btree_multimap` supports the same overload set as `std::multimap`
+ // for construction and assignment:
+ //
+ // * Default constructor
+ //
+ // y_absl::btree_multimap<int, TString> map1;
+ //
+ // * Initializer List constructor
+ //
+ // y_absl::btree_multimap<int, TString> map2 =
+ // {{1, "huey"}, {2, "dewey"}, {3, "louie"},};
+ //
+ // * Copy constructor
+ //
+ // y_absl::btree_multimap<int, TString> map3(map2);
+ //
+ // * Copy assignment operator
+ //
+ // y_absl::btree_multimap<int, TString> map4;
+ // map4 = map3;
+ //
+ // * Move constructor
+ //
+ // // Move is guaranteed efficient
+ // y_absl::btree_multimap<int, TString> map5(std::move(map4));
+ //
+ // * Move assignment operator
+ //
+ // // May be efficient if allocators are compatible
+ // y_absl::btree_multimap<int, TString> map6;
+ // map6 = std::move(map5);
+ //
+ // * Range constructor
+ //
+ // std::vector<std::pair<int, TString>> v = {{1, "a"}, {2, "b"}};
+ // y_absl::btree_multimap<int, TString> map7(v.begin(), v.end());
+ btree_multimap() {}
+ using Base::Base;
+
+ // btree_multimap::begin()
+ //
+ // Returns an iterator to the beginning of the `btree_multimap`.
+ using Base::begin;
+
+ // btree_multimap::cbegin()
+ //
+ // Returns a const iterator to the beginning of the `btree_multimap`.
+ using Base::cbegin;
+
+ // btree_multimap::end()
+ //
+ // Returns an iterator to the end of the `btree_multimap`.
+ using Base::end;
+
+ // btree_multimap::cend()
+ //
+ // Returns a const iterator to the end of the `btree_multimap`.
+ using Base::cend;
+
+ // btree_multimap::empty()
+ //
+ // Returns whether or not the `btree_multimap` is empty.
+ using Base::empty;
+
+ // btree_multimap::max_size()
+ //
+ // Returns the largest theoretical possible number of elements within a
+ // `btree_multimap` under current memory constraints. This value can be
+ // thought of as the largest value of `std::distance(begin(), end())` for a
+ // `btree_multimap<Key, T>`.
+ using Base::max_size;
+
+ // btree_multimap::size()
+ //
+ // Returns the number of elements currently within the `btree_multimap`.
+ using Base::size;
+
+ // btree_multimap::clear()
+ //
+ // Removes all elements from the `btree_multimap`. Invalidates any references,
+ // pointers, or iterators referring to contained elements.
+ using Base::clear;
+
+ // btree_multimap::erase()
+ //
+ // Erases elements within the `btree_multimap`. If an erase occurs, any
+ // references, pointers, or iterators are invalidated.
+ // Overloads are listed below.
+ //
+ // iterator erase(iterator position):
+ // iterator erase(const_iterator position):
+ //
+ // Erases the element at `position` of the `btree_multimap`, returning
+ // the iterator pointing to the element after the one that was erased
+ // (or end() if none exists).
+ //
+ // iterator erase(const_iterator first, const_iterator last):
+ //
+ // Erases the elements in the open interval [`first`, `last`), returning
+ // the iterator pointing to the element after the interval that was erased
+ // (or end() if none exists).
+ //
+ // template <typename K> size_type erase(const K& key):
+ //
+ // Erases the elements matching the key, if any exist, returning the
+ // number of elements erased.
+ using Base::erase;
+
+ // btree_multimap::insert()
+ //
+ // Inserts an element of the specified value into the `btree_multimap`,
+ // returning an iterator pointing to the newly inserted element.
+ // Any references, pointers, or iterators are invalidated. Overloads are
+ // listed below.
+ //
+ // iterator insert(const value_type& value):
+ //
+ // Inserts a value into the `btree_multimap`, returning an iterator to the
+ // inserted element.
+ //
+ // iterator insert(value_type&& value):
+ //
+ // Inserts a moveable value into the `btree_multimap`, returning an iterator
+ // to the inserted element.
+ //
+ // iterator insert(const_iterator hint, const value_type& value):
+ // iterator insert(const_iterator hint, value_type&& value):
+ //
+ // Inserts a value, using the position of `hint` as a non-binding suggestion
+ // for where to begin the insertion search. Returns an iterator to the
+ // inserted element.
+ //
+ // void insert(InputIterator first, InputIterator last):
+ //
+ // Inserts a range of values [`first`, `last`).
+ //
+ // void insert(std::initializer_list<init_type> ilist):
+ //
+ // Inserts the elements within the initializer list `ilist`.
+ using Base::insert;
+
+ // btree_multimap::emplace()
+ //
+ // Inserts an element of the specified value by constructing it in-place
+ // within the `btree_multimap`. Any references, pointers, or iterators are
+ // invalidated.
+ using Base::emplace;
+
+ // btree_multimap::emplace_hint()
+ //
+ // Inserts an element of the specified value by constructing it in-place
+ // within the `btree_multimap`, using the position of `hint` as a non-binding
+ // suggestion for where to begin the insertion search.
+ //
+ // Any references, pointers, or iterators are invalidated.
+ using Base::emplace_hint;
+
+ // btree_multimap::extract()
+ //
+ // Extracts the indicated element, erasing it in the process, and returns it
+ // as a C++17-compatible node handle. Overloads are listed below.
+ //
+ // node_type extract(const_iterator position):
+ //
+ // Extracts the element at the indicated position and returns a node handle
+ // owning that extracted data.
+ //
+ // template <typename K> node_type extract(const K& k):
+ //
+ // Extracts the element with the key matching the passed key value and
+ // returns a node handle owning that extracted data. If the `btree_multimap`
+ // does not contain an element with a matching key, this function returns an
+ // empty node handle.
+ //
+ // NOTE: when compiled in an earlier version of C++ than C++17,
+ // `node_type::key()` returns a const reference to the key instead of a
+ // mutable reference. We cannot safely return a mutable reference without
+ // std::launder (which is not available before C++17).
+ //
+ // NOTE: In this context, `node_type` refers to the C++17 concept of a
+ // move-only type that owns and provides access to the elements in associative
+ // containers (https://en.cppreference.com/w/cpp/container/node_handle).
+ // It does NOT refer to the data layout of the underlying btree.
+ using Base::extract;
+
+ // btree_multimap::extract_and_get_next()
+ //
+ // Extracts the indicated element, erasing it in the process, and returns it
+ // as a C++17-compatible node handle along with an iterator to the next
+ // element.
+ //
+ // extract_and_get_next_return_type extract_and_get_next(
+ // const_iterator position):
+ //
+ // Extracts the element at the indicated position, returns a struct
+ // containing a member named `node`: a node handle owning that extracted
+ // data and a member named `next`: an iterator pointing to the next element
+ // in the btree.
+ using Base::extract_and_get_next;
+
+ // btree_multimap::merge()
+ //
+ // Extracts all elements from a given `source` btree_multimap into this
+ // `btree_multimap`.
+ using Base::merge;
+
+ // btree_multimap::swap(btree_multimap& other)
+ //
+ // Exchanges the contents of this `btree_multimap` with those of the `other`
+ // btree_multimap, avoiding invocation of any move, copy, or swap operations
+ // on individual elements.
+ //
+ // All iterators and references on the `btree_multimap` remain valid,
+ // excepting for the past-the-end iterator, which is invalidated.
+ using Base::swap;
+
+ // btree_multimap::contains()
+ //
+ // template <typename K> bool contains(const K& key) const:
+ //
+ // Determines whether an element comparing equal to the given `key` exists
+ // within the `btree_multimap`, returning `true` if so or `false` otherwise.
+ //
+ // Supports heterogeneous lookup, provided that the map has a compatible
+ // heterogeneous comparator.
+ using Base::contains;
+
+ // btree_multimap::count()
+ //
+ // template <typename K> size_type count(const K& key) const:
+ //
+ // Returns the number of elements comparing equal to the given `key` within
+ // the `btree_multimap`.
+ //
+ // Supports heterogeneous lookup, provided that the map has a compatible
+ // heterogeneous comparator.
+ using Base::count;
+
+ // btree_multimap::equal_range()
+ //
+ // Returns a half-open range [first, last), defined by a `std::pair` of two
+ // iterators, containing all elements with the passed key in the
+ // `btree_multimap`.
+ using Base::equal_range;
+
+ // btree_multimap::find()
+ //
+ // template <typename K> iterator find(const K& key):
+ // template <typename K> const_iterator find(const K& key) const:
+ //
+ // Finds an element with the passed `key` within the `btree_multimap`.
+ //
+ // Supports heterogeneous lookup, provided that the map has a compatible
+ // heterogeneous comparator.
+ using Base::find;
+
+ // btree_multimap::lower_bound()
+ //
+ // template <typename K> iterator lower_bound(const K& key):
+ // template <typename K> const_iterator lower_bound(const K& key) const:
+ //
+ // Finds the first element with a key that is not less than `key` within the
+ // `btree_multimap`.
+ //
+ // Supports heterogeneous lookup, provided that the map has a compatible
+ // heterogeneous comparator.
+ using Base::lower_bound;
+
+ // btree_multimap::upper_bound()
+ //
+ // template <typename K> iterator upper_bound(const K& key):
+ // template <typename K> const_iterator upper_bound(const K& key) const:
+ //
+ // Finds the first element with a key that is greater than `key` within the
+ // `btree_multimap`.
+ //
+ // Supports heterogeneous lookup, provided that the map has a compatible
+ // heterogeneous comparator.
+ using Base::upper_bound;
+
+ // btree_multimap::get_allocator()
+ //
+ // Returns the allocator function associated with this `btree_multimap`.
+ using Base::get_allocator;
+
+ // btree_multimap::key_comp();
+ //
+ // Returns the key comparator associated with this `btree_multimap`.
+ using Base::key_comp;
+
+ // btree_multimap::value_comp();
+ //
+ // Returns the value comparator associated with this `btree_multimap`.
+ using Base::value_comp;
+};
+
+// y_absl::swap(y_absl::btree_multimap<>, y_absl::btree_multimap<>)
+//
+// Swaps the contents of two `y_absl::btree_multimap` containers.
+template <typename K, typename V, typename C, typename A>
+void swap(btree_multimap<K, V, C, A> &x, btree_multimap<K, V, C, A> &y) {
+ return x.swap(y);
+}
+
+// y_absl::erase_if(y_absl::btree_multimap<>, Pred)
+//
+// Erases all elements that satisfy the predicate pred from the container.
+// Returns the number of erased elements.
+template <typename K, typename V, typename C, typename A, typename Pred>
+typename btree_multimap<K, V, C, A>::size_type erase_if(
+ btree_multimap<K, V, C, A> &map, Pred pred) {
+ return container_internal::btree_access::erase_if(map, std::move(pred));
+}
+
+namespace container_internal {
+
+// A parameters structure for holding the type parameters for a btree_map.
+// Compare and Alloc should be nothrow copy-constructible.
+template <typename Key, typename Data, typename Compare, typename Alloc,
+ int TargetNodeSize, bool IsMulti>
+struct map_params : common_params<Key, Compare, Alloc, TargetNodeSize, IsMulti,
+ /*IsMap=*/true, map_slot_policy<Key, Data>> {
+ using super_type = typename map_params::common_params;
+ using mapped_type = Data;
+ // This type allows us to move keys when it is safe to do so. It is safe
+ // for maps in which value_type and mutable_value_type are layout compatible.
+ using slot_policy = typename super_type::slot_policy;
+ using slot_type = typename super_type::slot_type;
+ using value_type = typename super_type::value_type;
+ using init_type = typename super_type::init_type;
+
+ template <typename V>
+ static auto key(const V &value Y_ABSL_ATTRIBUTE_LIFETIME_BOUND)
+ -> decltype((value.first)) {
+ return value.first;
+ }
+ static const Key &key(const slot_type *s) { return slot_policy::key(s); }
+ static const Key &key(slot_type *s) { return slot_policy::key(s); }
+ // For use in node handle.
+ static auto mutable_key(slot_type *s)
+ -> decltype(slot_policy::mutable_key(s)) {
+ return slot_policy::mutable_key(s);
+ }
+ static mapped_type &value(value_type *value) { return value->second; }
+};
+
+} // namespace container_internal
+
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_CONTAINER_BTREE_MAP_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_set.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_set.h
new file mode 100644
index 00000000000..4f0d5107839
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_set.h
@@ -0,0 +1,824 @@
+// Copyright 2018 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: btree_set.h
+// -----------------------------------------------------------------------------
+//
+// This header file defines B-tree sets: sorted associative containers of
+// values.
+//
+// * `y_absl::btree_set<>`
+// * `y_absl::btree_multiset<>`
+//
+// These B-tree types are similar to the corresponding types in the STL
+// (`std::set` and `std::multiset`) and generally conform to the STL interfaces
+// of those types. However, because they are implemented using B-trees, they
+// are more efficient in most situations.
+//
+// Unlike `std::set` and `std::multiset`, which are commonly implemented using
+// red-black tree nodes, B-tree sets use more generic B-tree nodes able to hold
+// multiple values per node. Holding multiple values per node often makes
+// B-tree sets perform better than their `std::set` counterparts, because
+// multiple entries can be checked within the same cache hit.
+//
+// However, these types should not be considered drop-in replacements for
+// `std::set` and `std::multiset` as there are some API differences, which are
+// noted in this header file. The most consequential differences with respect to
+// migrating to b-tree from the STL types are listed in the next paragraph.
+// Other API differences are minor.
+//
+// Importantly, insertions and deletions may invalidate outstanding iterators,
+// pointers, and references to elements. Such invalidations are typically only
+// an issue if insertion and deletion operations are interleaved with the use of
+// more than one iterator, pointer, or reference simultaneously. For this
+// reason, `insert()`, `erase()`, and `extract_and_get_next()` return a valid
+// iterator at the current position.
+//
+// Another API difference is that btree iterators can be subtracted, and this
+// is faster than using std::distance.
+//
+// B-tree sets are not exception-safe.
+
+#ifndef Y_ABSL_CONTAINER_BTREE_SET_H_
+#define Y_ABSL_CONTAINER_BTREE_SET_H_
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/container/internal/btree.h" // IWYU pragma: export
+#include "y_absl/container/internal/btree_container.h" // IWYU pragma: export
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+
+namespace container_internal {
+
+template <typename Key>
+struct set_slot_policy;
+
+template <typename Key, typename Compare, typename Alloc, int TargetNodeSize,
+ bool IsMulti>
+struct set_params;
+
+} // namespace container_internal
+
+// y_absl::btree_set<>
+//
+// An `y_absl::btree_set<K>` is an ordered associative container of unique key
+// values designed to be a more efficient replacement for `std::set` (in most
+// cases).
+//
+// Keys are sorted using an (optional) comparison function, which defaults to
+// `std::less<K>`.
+//
+// An `y_absl::btree_set<K>` uses a default allocator of `std::allocator<K>` to
+// allocate (and deallocate) nodes, and construct and destruct values within
+// those nodes. You may instead specify a custom allocator `A` (which in turn
+// requires specifying a custom comparator `C`) as in
+// `y_absl::btree_set<K, C, A>`.
+//
+template <typename Key, typename Compare = std::less<Key>,
+ typename Alloc = std::allocator<Key>>
+class Y_ABSL_INTERNAL_ATTRIBUTE_OWNER btree_set
+ : public container_internal::btree_set_container<
+ container_internal::btree<container_internal::set_params<
+ Key, Compare, Alloc, /*TargetNodeSize=*/256,
+ /*IsMulti=*/false>>> {
+ using Base = typename btree_set::btree_set_container;
+
+ public:
+ // Constructors and Assignment Operators
+ //
+ // A `btree_set` supports the same overload set as `std::set`
+ // for construction and assignment:
+ //
+ // * Default constructor
+ //
+ // y_absl::btree_set<TString> set1;
+ //
+ // * Initializer List constructor
+ //
+ // y_absl::btree_set<TString> set2 =
+ // {{"huey"}, {"dewey"}, {"louie"},};
+ //
+ // * Copy constructor
+ //
+ // y_absl::btree_set<TString> set3(set2);
+ //
+ // * Copy assignment operator
+ //
+ // y_absl::btree_set<TString> set4;
+ // set4 = set3;
+ //
+ // * Move constructor
+ //
+ // // Move is guaranteed efficient
+ // y_absl::btree_set<TString> set5(std::move(set4));
+ //
+ // * Move assignment operator
+ //
+ // // May be efficient if allocators are compatible
+ // y_absl::btree_set<TString> set6;
+ // set6 = std::move(set5);
+ //
+ // * Range constructor
+ //
+ // std::vector<TString> v = {"a", "b"};
+ // y_absl::btree_set<TString> set7(v.begin(), v.end());
+ btree_set() {}
+ using Base::Base;
+
+ // btree_set::begin()
+ //
+ // Returns an iterator to the beginning of the `btree_set`.
+ using Base::begin;
+
+ // btree_set::cbegin()
+ //
+ // Returns a const iterator to the beginning of the `btree_set`.
+ using Base::cbegin;
+
+ // btree_set::end()
+ //
+ // Returns an iterator to the end of the `btree_set`.
+ using Base::end;
+
+ // btree_set::cend()
+ //
+ // Returns a const iterator to the end of the `btree_set`.
+ using Base::cend;
+
+ // btree_set::empty()
+ //
+ // Returns whether or not the `btree_set` is empty.
+ using Base::empty;
+
+ // btree_set::max_size()
+ //
+ // Returns the largest theoretical possible number of elements within a
+ // `btree_set` under current memory constraints. This value can be thought
+ // of as the largest value of `std::distance(begin(), end())` for a
+ // `btree_set<Key>`.
+ using Base::max_size;
+
+ // btree_set::size()
+ //
+ // Returns the number of elements currently within the `btree_set`.
+ using Base::size;
+
+ // btree_set::clear()
+ //
+ // Removes all elements from the `btree_set`. Invalidates any references,
+ // pointers, or iterators referring to contained elements.
+ using Base::clear;
+
+ // btree_set::erase()
+ //
+ // Erases elements within the `btree_set`. Overloads are listed below.
+ //
+ // iterator erase(iterator position):
+ // iterator erase(const_iterator position):
+ //
+ // Erases the element at `position` of the `btree_set`, returning
+ // the iterator pointing to the element after the one that was erased
+ // (or end() if none exists).
+ //
+ // iterator erase(const_iterator first, const_iterator last):
+ //
+ // Erases the elements in the open interval [`first`, `last`), returning
+ // the iterator pointing to the element after the interval that was erased
+ // (or end() if none exists).
+ //
+ // template <typename K> size_type erase(const K& key):
+ //
+ // Erases the element with the matching key, if it exists, returning the
+ // number of elements erased (0 or 1).
+ using Base::erase;
+
+ // btree_set::insert()
+ //
+ // Inserts an element of the specified value into the `btree_set`,
+ // returning an iterator pointing to the newly inserted element, provided that
+ // an element with the given key does not already exist. If an insertion
+ // occurs, any references, pointers, or iterators are invalidated.
+ // Overloads are listed below.
+ //
+ // std::pair<iterator,bool> insert(const value_type& value):
+ //
+ // Inserts a value into the `btree_set`. Returns a pair consisting of an
+ // iterator to the inserted element (or to the element that prevented the
+ // insertion) and a bool denoting whether the insertion took place.
+ //
+ // std::pair<iterator,bool> insert(value_type&& value):
+ //
+ // Inserts a moveable value into the `btree_set`. Returns a pair
+ // consisting of an iterator to the inserted element (or to the element that
+ // prevented the insertion) and a bool denoting whether the insertion took
+ // place.
+ //
+ // iterator insert(const_iterator hint, const value_type& value):
+ // iterator insert(const_iterator hint, value_type&& value):
+ //
+ // Inserts a value, using the position of `hint` as a non-binding suggestion
+ // for where to begin the insertion search. Returns an iterator to the
+ // inserted element, or to the existing element that prevented the
+ // insertion.
+ //
+ // void insert(InputIterator first, InputIterator last):
+ //
+ // Inserts a range of values [`first`, `last`).
+ //
+ // void insert(std::initializer_list<init_type> ilist):
+ //
+ // Inserts the elements within the initializer list `ilist`.
+ using Base::insert;
+
+ // btree_set::emplace()
+ //
+ // Inserts an element of the specified value by constructing it in-place
+ // within the `btree_set`, provided that no element with the given key
+ // already exists.
+ //
+ // The element may be constructed even if there already is an element with the
+ // key in the container, in which case the newly constructed element will be
+ // destroyed immediately.
+ //
+ // If an insertion occurs, any references, pointers, or iterators are
+ // invalidated.
+ using Base::emplace;
+
+ // btree_set::emplace_hint()
+ //
+ // Inserts an element of the specified value by constructing it in-place
+ // within the `btree_set`, using the position of `hint` as a non-binding
+ // suggestion for where to begin the insertion search, and only inserts
+ // provided that no element with the given key already exists.
+ //
+ // The element may be constructed even if there already is an element with the
+ // key in the container, in which case the newly constructed element will be
+ // destroyed immediately.
+ //
+ // If an insertion occurs, any references, pointers, or iterators are
+ // invalidated.
+ using Base::emplace_hint;
+
+ // btree_set::extract()
+ //
+ // Extracts the indicated element, erasing it in the process, and returns it
+ // as a C++17-compatible node handle. Any references, pointers, or iterators
+ // are invalidated. Overloads are listed below.
+ //
+ // node_type extract(const_iterator position):
+ //
+ // Extracts the element at the indicated position and returns a node handle
+ // owning that extracted data.
+ //
+ // template <typename K> node_type extract(const K& k):
+ //
+ // Extracts the element with the key matching the passed key value and
+ // returns a node handle owning that extracted data. If the `btree_set`
+ // does not contain an element with a matching key, this function returns an
+ // empty node handle.
+ //
+ // NOTE: In this context, `node_type` refers to the C++17 concept of a
+ // move-only type that owns and provides access to the elements in associative
+ // containers (https://en.cppreference.com/w/cpp/container/node_handle).
+ // It does NOT refer to the data layout of the underlying btree.
+ using Base::extract;
+
+ // btree_set::extract_and_get_next()
+ //
+ // Extracts the indicated element, erasing it in the process, and returns it
+ // as a C++17-compatible node handle along with an iterator to the next
+ // element.
+ //
+ // extract_and_get_next_return_type extract_and_get_next(
+ // const_iterator position):
+ //
+ // Extracts the element at the indicated position, returns a struct
+ // containing a member named `node`: a node handle owning that extracted
+ // data and a member named `next`: an iterator pointing to the next element
+ // in the btree.
+ using Base::extract_and_get_next;
+
+ // btree_set::merge()
+ //
+ // Extracts elements from a given `source` btree_set into this
+ // `btree_set`. If the destination `btree_set` already contains an
+ // element with an equivalent key, that element is not extracted.
+ using Base::merge;
+
+ // btree_set::swap(btree_set& other)
+ //
+ // Exchanges the contents of this `btree_set` with those of the `other`
+ // btree_set, avoiding invocation of any move, copy, or swap operations on
+ // individual elements.
+ //
+ // All iterators and references on the `btree_set` remain valid, excepting
+ // for the past-the-end iterator, which is invalidated.
+ using Base::swap;
+
+ // btree_set::contains()
+ //
+ // template <typename K> bool contains(const K& key) const:
+ //
+ // Determines whether an element comparing equal to the given `key` exists
+ // within the `btree_set`, returning `true` if so or `false` otherwise.
+ //
+ // Supports heterogeneous lookup, provided that the set has a compatible
+ // heterogeneous comparator.
+ using Base::contains;
+
+ // btree_set::count()
+ //
+ // template <typename K> size_type count(const K& key) const:
+ //
+ // Returns the number of elements comparing equal to the given `key` within
+ // the `btree_set`. Note that this function will return either `1` or `0`
+ // since duplicate elements are not allowed within a `btree_set`.
+ //
+ // Supports heterogeneous lookup, provided that the set has a compatible
+ // heterogeneous comparator.
+ using Base::count;
+
+ // btree_set::equal_range()
+ //
+ // Returns a closed range [first, last], defined by a `std::pair` of two
+ // iterators, containing all elements with the passed key in the
+ // `btree_set`.
+ using Base::equal_range;
+
+ // btree_set::find()
+ //
+ // template <typename K> iterator find(const K& key):
+ // template <typename K> const_iterator find(const K& key) const:
+ //
+ // Finds an element with the passed `key` within the `btree_set`.
+ //
+ // Supports heterogeneous lookup, provided that the set has a compatible
+ // heterogeneous comparator.
+ using Base::find;
+
+ // btree_set::lower_bound()
+ //
+ // template <typename K> iterator lower_bound(const K& key):
+ // template <typename K> const_iterator lower_bound(const K& key) const:
+ //
+ // Finds the first element that is not less than `key` within the `btree_set`.
+ //
+ // Supports heterogeneous lookup, provided that the set has a compatible
+ // heterogeneous comparator.
+ using Base::lower_bound;
+
+ // btree_set::upper_bound()
+ //
+ // template <typename K> iterator upper_bound(const K& key):
+ // template <typename K> const_iterator upper_bound(const K& key) const:
+ //
+ // Finds the first element that is greater than `key` within the `btree_set`.
+ //
+ // Supports heterogeneous lookup, provided that the set has a compatible
+ // heterogeneous comparator.
+ using Base::upper_bound;
+
+ // btree_set::get_allocator()
+ //
+ // Returns the allocator function associated with this `btree_set`.
+ using Base::get_allocator;
+
+ // btree_set::key_comp();
+ //
+ // Returns the key comparator associated with this `btree_set`.
+ using Base::key_comp;
+
+ // btree_set::value_comp();
+ //
+ // Returns the value comparator associated with this `btree_set`. The keys to
+ // sort the elements are the values themselves, therefore `value_comp` and its
+ // sibling member function `key_comp` are equivalent.
+ using Base::value_comp;
+};
+
+// y_absl::swap(y_absl::btree_set<>, y_absl::btree_set<>)
+//
+// Swaps the contents of two `y_absl::btree_set` containers.
+template <typename K, typename C, typename A>
+void swap(btree_set<K, C, A> &x, btree_set<K, C, A> &y) {
+ return x.swap(y);
+}
+
+// y_absl::erase_if(y_absl::btree_set<>, Pred)
+//
+// Erases all elements that satisfy the predicate pred from the container.
+// Returns the number of erased elements.
+template <typename K, typename C, typename A, typename Pred>
+typename btree_set<K, C, A>::size_type erase_if(btree_set<K, C, A> &set,
+ Pred pred) {
+ return container_internal::btree_access::erase_if(set, std::move(pred));
+}
+
+// y_absl::btree_multiset<>
+//
+// An `y_absl::btree_multiset<K>` is an ordered associative container of
+// keys and associated values designed to be a more efficient replacement
+// for `std::multiset` (in most cases). Unlike `y_absl::btree_set`, a B-tree
+// multiset allows equivalent elements.
+//
+// Keys are sorted using an (optional) comparison function, which defaults to
+// `std::less<K>`.
+//
+// An `y_absl::btree_multiset<K>` uses a default allocator of `std::allocator<K>`
+// to allocate (and deallocate) nodes, and construct and destruct values within
+// those nodes. You may instead specify a custom allocator `A` (which in turn
+// requires specifying a custom comparator `C`) as in
+// `y_absl::btree_multiset<K, C, A>`.
+//
+template <typename Key, typename Compare = std::less<Key>,
+ typename Alloc = std::allocator<Key>>
+class Y_ABSL_INTERNAL_ATTRIBUTE_OWNER btree_multiset
+ : public container_internal::btree_multiset_container<
+ container_internal::btree<container_internal::set_params<
+ Key, Compare, Alloc, /*TargetNodeSize=*/256,
+ /*IsMulti=*/true>>> {
+ using Base = typename btree_multiset::btree_multiset_container;
+
+ public:
+ // Constructors and Assignment Operators
+ //
+ // A `btree_multiset` supports the same overload set as `std::set`
+ // for construction and assignment:
+ //
+ // * Default constructor
+ //
+ // y_absl::btree_multiset<TString> set1;
+ //
+ // * Initializer List constructor
+ //
+ // y_absl::btree_multiset<TString> set2 =
+ // {{"huey"}, {"dewey"}, {"louie"},};
+ //
+ // * Copy constructor
+ //
+ // y_absl::btree_multiset<TString> set3(set2);
+ //
+ // * Copy assignment operator
+ //
+ // y_absl::btree_multiset<TString> set4;
+ // set4 = set3;
+ //
+ // * Move constructor
+ //
+ // // Move is guaranteed efficient
+ // y_absl::btree_multiset<TString> set5(std::move(set4));
+ //
+ // * Move assignment operator
+ //
+ // // May be efficient if allocators are compatible
+ // y_absl::btree_multiset<TString> set6;
+ // set6 = std::move(set5);
+ //
+ // * Range constructor
+ //
+ // std::vector<TString> v = {"a", "b"};
+ // y_absl::btree_multiset<TString> set7(v.begin(), v.end());
+ btree_multiset() {}
+ using Base::Base;
+
+ // btree_multiset::begin()
+ //
+ // Returns an iterator to the beginning of the `btree_multiset`.
+ using Base::begin;
+
+ // btree_multiset::cbegin()
+ //
+ // Returns a const iterator to the beginning of the `btree_multiset`.
+ using Base::cbegin;
+
+ // btree_multiset::end()
+ //
+ // Returns an iterator to the end of the `btree_multiset`.
+ using Base::end;
+
+ // btree_multiset::cend()
+ //
+ // Returns a const iterator to the end of the `btree_multiset`.
+ using Base::cend;
+
+ // btree_multiset::empty()
+ //
+ // Returns whether or not the `btree_multiset` is empty.
+ using Base::empty;
+
+ // btree_multiset::max_size()
+ //
+ // Returns the largest theoretical possible number of elements within a
+ // `btree_multiset` under current memory constraints. This value can be
+ // thought of as the largest value of `std::distance(begin(), end())` for a
+ // `btree_multiset<Key>`.
+ using Base::max_size;
+
+ // btree_multiset::size()
+ //
+ // Returns the number of elements currently within the `btree_multiset`.
+ using Base::size;
+
+ // btree_multiset::clear()
+ //
+ // Removes all elements from the `btree_multiset`. Invalidates any references,
+ // pointers, or iterators referring to contained elements.
+ using Base::clear;
+
+ // btree_multiset::erase()
+ //
+ // Erases elements within the `btree_multiset`. Overloads are listed below.
+ //
+ // iterator erase(iterator position):
+ // iterator erase(const_iterator position):
+ //
+ // Erases the element at `position` of the `btree_multiset`, returning
+ // the iterator pointing to the element after the one that was erased
+ // (or end() if none exists).
+ //
+ // iterator erase(const_iterator first, const_iterator last):
+ //
+ // Erases the elements in the open interval [`first`, `last`), returning
+ // the iterator pointing to the element after the interval that was erased
+ // (or end() if none exists).
+ //
+ // template <typename K> size_type erase(const K& key):
+ //
+ // Erases the elements matching the key, if any exist, returning the
+ // number of elements erased.
+ using Base::erase;
+
+ // btree_multiset::insert()
+ //
+ // Inserts an element of the specified value into the `btree_multiset`,
+ // returning an iterator pointing to the newly inserted element.
+ // Any references, pointers, or iterators are invalidated. Overloads are
+ // listed below.
+ //
+ // iterator insert(const value_type& value):
+ //
+ // Inserts a value into the `btree_multiset`, returning an iterator to the
+ // inserted element.
+ //
+ // iterator insert(value_type&& value):
+ //
+ // Inserts a moveable value into the `btree_multiset`, returning an iterator
+ // to the inserted element.
+ //
+ // iterator insert(const_iterator hint, const value_type& value):
+ // iterator insert(const_iterator hint, value_type&& value):
+ //
+ // Inserts a value, using the position of `hint` as a non-binding suggestion
+ // for where to begin the insertion search. Returns an iterator to the
+ // inserted element.
+ //
+ // void insert(InputIterator first, InputIterator last):
+ //
+ // Inserts a range of values [`first`, `last`).
+ //
+ // void insert(std::initializer_list<init_type> ilist):
+ //
+ // Inserts the elements within the initializer list `ilist`.
+ using Base::insert;
+
+ // btree_multiset::emplace()
+ //
+ // Inserts an element of the specified value by constructing it in-place
+ // within the `btree_multiset`. Any references, pointers, or iterators are
+ // invalidated.
+ using Base::emplace;
+
+ // btree_multiset::emplace_hint()
+ //
+ // Inserts an element of the specified value by constructing it in-place
+ // within the `btree_multiset`, using the position of `hint` as a non-binding
+ // suggestion for where to begin the insertion search.
+ //
+ // Any references, pointers, or iterators are invalidated.
+ using Base::emplace_hint;
+
+ // btree_multiset::extract()
+ //
+ // Extracts the indicated element, erasing it in the process, and returns it
+ // as a C++17-compatible node handle. Overloads are listed below.
+ //
+ // node_type extract(const_iterator position):
+ //
+ // Extracts the element at the indicated position and returns a node handle
+ // owning that extracted data.
+ //
+ // template <typename K> node_type extract(const K& k):
+ //
+ // Extracts the element with the key matching the passed key value and
+ // returns a node handle owning that extracted data. If the `btree_multiset`
+ // does not contain an element with a matching key, this function returns an
+ // empty node handle.
+ //
+ // NOTE: In this context, `node_type` refers to the C++17 concept of a
+ // move-only type that owns and provides access to the elements in associative
+ // containers (https://en.cppreference.com/w/cpp/container/node_handle).
+ // It does NOT refer to the data layout of the underlying btree.
+ using Base::extract;
+
+ // btree_multiset::extract_and_get_next()
+ //
+ // Extracts the indicated element, erasing it in the process, and returns it
+ // as a C++17-compatible node handle along with an iterator to the next
+ // element.
+ //
+ // extract_and_get_next_return_type extract_and_get_next(
+ // const_iterator position):
+ //
+ // Extracts the element at the indicated position, returns a struct
+ // containing a member named `node`: a node handle owning that extracted
+ // data and a member named `next`: an iterator pointing to the next element
+ // in the btree.
+ using Base::extract_and_get_next;
+
+ // btree_multiset::merge()
+ //
+ // Extracts all elements from a given `source` btree_multiset into this
+ // `btree_multiset`.
+ using Base::merge;
+
+ // btree_multiset::swap(btree_multiset& other)
+ //
+ // Exchanges the contents of this `btree_multiset` with those of the `other`
+ // btree_multiset, avoiding invocation of any move, copy, or swap operations
+ // on individual elements.
+ //
+ // All iterators and references on the `btree_multiset` remain valid,
+ // excepting for the past-the-end iterator, which is invalidated.
+ using Base::swap;
+
+ // btree_multiset::contains()
+ //
+ // template <typename K> bool contains(const K& key) const:
+ //
+ // Determines whether an element comparing equal to the given `key` exists
+ // within the `btree_multiset`, returning `true` if so or `false` otherwise.
+ //
+ // Supports heterogeneous lookup, provided that the set has a compatible
+ // heterogeneous comparator.
+ using Base::contains;
+
+ // btree_multiset::count()
+ //
+ // template <typename K> size_type count(const K& key) const:
+ //
+ // Returns the number of elements comparing equal to the given `key` within
+ // the `btree_multiset`.
+ //
+ // Supports heterogeneous lookup, provided that the set has a compatible
+ // heterogeneous comparator.
+ using Base::count;
+
+ // btree_multiset::equal_range()
+ //
+ // Returns a closed range [first, last], defined by a `std::pair` of two
+ // iterators, containing all elements with the passed key in the
+ // `btree_multiset`.
+ using Base::equal_range;
+
+ // btree_multiset::find()
+ //
+ // template <typename K> iterator find(const K& key):
+ // template <typename K> const_iterator find(const K& key) const:
+ //
+ // Finds an element with the passed `key` within the `btree_multiset`.
+ //
+ // Supports heterogeneous lookup, provided that the set has a compatible
+ // heterogeneous comparator.
+ using Base::find;
+
+ // btree_multiset::lower_bound()
+ //
+ // template <typename K> iterator lower_bound(const K& key):
+ // template <typename K> const_iterator lower_bound(const K& key) const:
+ //
+ // Finds the first element that is not less than `key` within the
+ // `btree_multiset`.
+ //
+ // Supports heterogeneous lookup, provided that the set has a compatible
+ // heterogeneous comparator.
+ using Base::lower_bound;
+
+ // btree_multiset::upper_bound()
+ //
+ // template <typename K> iterator upper_bound(const K& key):
+ // template <typename K> const_iterator upper_bound(const K& key) const:
+ //
+ // Finds the first element that is greater than `key` within the
+ // `btree_multiset`.
+ //
+ // Supports heterogeneous lookup, provided that the set has a compatible
+ // heterogeneous comparator.
+ using Base::upper_bound;
+
+ // btree_multiset::get_allocator()
+ //
+ // Returns the allocator function associated with this `btree_multiset`.
+ using Base::get_allocator;
+
+ // btree_multiset::key_comp();
+ //
+ // Returns the key comparator associated with this `btree_multiset`.
+ using Base::key_comp;
+
+ // btree_multiset::value_comp();
+ //
+ // Returns the value comparator associated with this `btree_multiset`. The
+ // keys to sort the elements are the values themselves, therefore `value_comp`
+ // and its sibling member function `key_comp` are equivalent.
+ using Base::value_comp;
+};
+
+// y_absl::swap(y_absl::btree_multiset<>, y_absl::btree_multiset<>)
+//
+// Swaps the contents of two `y_absl::btree_multiset` containers.
+template <typename K, typename C, typename A>
+void swap(btree_multiset<K, C, A> &x, btree_multiset<K, C, A> &y) {
+ return x.swap(y);
+}
+
+// y_absl::erase_if(y_absl::btree_multiset<>, Pred)
+//
+// Erases all elements that satisfy the predicate pred from the container.
+// Returns the number of erased elements.
+template <typename K, typename C, typename A, typename Pred>
+typename btree_multiset<K, C, A>::size_type erase_if(
+ btree_multiset<K, C, A> & set, Pred pred) {
+ return container_internal::btree_access::erase_if(set, std::move(pred));
+}
+
+namespace container_internal {
+
+// This type implements the necessary functions from the
+// y_absl::container_internal::slot_type interface for btree_(multi)set.
+template <typename Key>
+struct set_slot_policy {
+ using slot_type = Key;
+ using value_type = Key;
+ using mutable_value_type = Key;
+
+ static value_type &element(slot_type *slot) { return *slot; }
+ static const value_type &element(const slot_type *slot) { return *slot; }
+
+ template <typename Alloc, class... Args>
+ static void construct(Alloc *alloc, slot_type *slot, Args &&...args) {
+ y_absl::allocator_traits<Alloc>::construct(*alloc, slot,
+ std::forward<Args>(args)...);
+ }
+
+ template <typename Alloc>
+ static void construct(Alloc *alloc, slot_type *slot, slot_type *other) {
+ y_absl::allocator_traits<Alloc>::construct(*alloc, slot, std::move(*other));
+ }
+
+ template <typename Alloc>
+ static void construct(Alloc *alloc, slot_type *slot, const slot_type *other) {
+ y_absl::allocator_traits<Alloc>::construct(*alloc, slot, *other);
+ }
+
+ template <typename Alloc>
+ static void destroy(Alloc *alloc, slot_type *slot) {
+ y_absl::allocator_traits<Alloc>::destroy(*alloc, slot);
+ }
+};
+
+// A parameters structure for holding the type parameters for a btree_set.
+// Compare and Alloc should be nothrow copy-constructible.
+template <typename Key, typename Compare, typename Alloc, int TargetNodeSize,
+ bool IsMulti>
+struct set_params : common_params<Key, Compare, Alloc, TargetNodeSize, IsMulti,
+ /*IsMap=*/false, set_slot_policy<Key>> {
+ using value_type = Key;
+ using slot_type = typename set_params::common_params::slot_type;
+
+ template <typename V>
+ static const V &key(const V &value) {
+ return value;
+ }
+ static const Key &key(const slot_type *slot) { return *slot; }
+ static const Key &key(slot_type *slot) { return *slot; }
+};
+
+} // namespace container_internal
+
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_CONTAINER_BTREE_SET_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree.h
new file mode 100644
index 00000000000..64f7a068b18
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree.h
@@ -0,0 +1,3048 @@
+// Copyright 2018 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// A btree implementation of the STL set and map interfaces. A btree is smaller
+// and generally also faster than STL set/map (refer to the benchmarks below).
+// The red-black tree implementation of STL set/map has an overhead of 3
+// pointers (left, right and parent) plus the node color information for each
+// stored value. So a set<int32_t> consumes 40 bytes for each value stored in
+// 64-bit mode. This btree implementation stores multiple values on fixed
+// size nodes (usually 256 bytes) and doesn't store child pointers for leaf
+// nodes. The result is that a btree_set<int32_t> may use much less memory per
+// stored value. For the random insertion benchmark in btree_bench.cc, a
+// btree_set<int32_t> with node-size of 256 uses 5.1 bytes per stored value.
+//
+// The packing of multiple values on to each node of a btree has another effect
+// besides better space utilization: better cache locality due to fewer cache
+// lines being accessed. Better cache locality translates into faster
+// operations.
+//
+// CAVEATS
+//
+// Insertions and deletions on a btree can cause splitting, merging or
+// rebalancing of btree nodes. And even without these operations, insertions
+// and deletions on a btree will move values around within a node. In both
+// cases, the result is that insertions and deletions can invalidate iterators
+// pointing to values other than the one being inserted/deleted. Therefore, this
+// container does not provide pointer stability. This is notably different from
+// STL set/map which takes care to not invalidate iterators on insert/erase
+// except, of course, for iterators pointing to the value being erased. A
+// partial workaround when erasing is available: erase() returns an iterator
+// pointing to the item just after the one that was erased (or end() if none
+// exists).
+
+#ifndef Y_ABSL_CONTAINER_INTERNAL_BTREE_H_
+#define Y_ABSL_CONTAINER_INTERNAL_BTREE_H_
+
+#include <algorithm>
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
+#include <cstring>
+#include <functional>
+#include <iterator>
+#include <limits>
+#include <util/generic/string.h>
+#include <type_traits>
+#include <utility>
+
+#include "y_absl/base/config.h"
+#include "y_absl/base/internal/raw_logging.h"
+#include "y_absl/base/macros.h"
+#include "y_absl/container/internal/common.h"
+#include "y_absl/container/internal/common_policy_traits.h"
+#include "y_absl/container/internal/compressed_tuple.h"
+#include "y_absl/container/internal/container_memory.h"
+#include "y_absl/container/internal/layout.h"
+#include "y_absl/memory/memory.h"
+#include "y_absl/meta/type_traits.h"
+#include "y_absl/strings/cord.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/types/compare.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace container_internal {
+
+#ifdef Y_ABSL_BTREE_ENABLE_GENERATIONS
+#error Y_ABSL_BTREE_ENABLE_GENERATIONS cannot be directly set
+#elif (defined(Y_ABSL_HAVE_ADDRESS_SANITIZER) || \
+ defined(Y_ABSL_HAVE_HWADDRESS_SANITIZER) || \
+ defined(Y_ABSL_HAVE_MEMORY_SANITIZER)) && \
+ !defined(NDEBUG_SANITIZER) // If defined, performance is important.
+// When compiled in sanitizer mode, we add generation integers to the nodes and
+// iterators. When iterators are used, we validate that the container has not
+// been mutated since the iterator was constructed.
+#define Y_ABSL_BTREE_ENABLE_GENERATIONS
+#endif
+
+#ifdef Y_ABSL_BTREE_ENABLE_GENERATIONS
+constexpr bool BtreeGenerationsEnabled() { return true; }
+#else
+constexpr bool BtreeGenerationsEnabled() { return false; }
+#endif
+
+template <typename Compare, typename T, typename U>
+using compare_result_t = y_absl::result_of_t<const Compare(const T &, const U &)>;
+
+// A helper class that indicates if the Compare parameter is a key-compare-to
+// comparator.
+template <typename Compare, typename T>
+using btree_is_key_compare_to =
+ std::is_convertible<compare_result_t<Compare, T, T>, y_absl::weak_ordering>;
+
+struct StringBtreeDefaultLess {
+ using is_transparent = void;
+
+ StringBtreeDefaultLess() = default;
+
+ // Compatibility constructor.
+ StringBtreeDefaultLess(std::less<TString>) {} // NOLINT
+ StringBtreeDefaultLess(std::less<y_absl::string_view>) {} // NOLINT
+
+ // Allow converting to std::less for use in key_comp()/value_comp().
+ explicit operator std::less<TString>() const { return {}; }
+ explicit operator std::less<y_absl::string_view>() const { return {}; }
+ explicit operator std::less<y_absl::Cord>() const { return {}; }
+
+ y_absl::weak_ordering operator()(y_absl::string_view lhs,
+ y_absl::string_view rhs) const {
+ return compare_internal::compare_result_as_ordering(lhs.compare(rhs));
+ }
+ StringBtreeDefaultLess(std::less<y_absl::Cord>) {} // NOLINT
+ y_absl::weak_ordering operator()(const y_absl::Cord &lhs,
+ const y_absl::Cord &rhs) const {
+ return compare_internal::compare_result_as_ordering(lhs.Compare(rhs));
+ }
+ y_absl::weak_ordering operator()(const y_absl::Cord &lhs,
+ y_absl::string_view rhs) const {
+ return compare_internal::compare_result_as_ordering(lhs.Compare(rhs));
+ }
+ y_absl::weak_ordering operator()(y_absl::string_view lhs,
+ const y_absl::Cord &rhs) const {
+ return compare_internal::compare_result_as_ordering(-rhs.Compare(lhs));
+ }
+};
+
+struct StringBtreeDefaultGreater {
+ using is_transparent = void;
+
+ StringBtreeDefaultGreater() = default;
+
+ StringBtreeDefaultGreater(std::greater<TString>) {} // NOLINT
+ StringBtreeDefaultGreater(std::greater<y_absl::string_view>) {} // NOLINT
+
+ // Allow converting to std::greater for use in key_comp()/value_comp().
+ explicit operator std::greater<TString>() const { return {}; }
+ explicit operator std::greater<y_absl::string_view>() const { return {}; }
+ explicit operator std::greater<y_absl::Cord>() const { return {}; }
+
+ y_absl::weak_ordering operator()(y_absl::string_view lhs,
+ y_absl::string_view rhs) const {
+ return compare_internal::compare_result_as_ordering(rhs.compare(lhs));
+ }
+ StringBtreeDefaultGreater(std::greater<y_absl::Cord>) {} // NOLINT
+ y_absl::weak_ordering operator()(const y_absl::Cord &lhs,
+ const y_absl::Cord &rhs) const {
+ return compare_internal::compare_result_as_ordering(rhs.Compare(lhs));
+ }
+ y_absl::weak_ordering operator()(const y_absl::Cord &lhs,
+ y_absl::string_view rhs) const {
+ return compare_internal::compare_result_as_ordering(-lhs.Compare(rhs));
+ }
+ y_absl::weak_ordering operator()(y_absl::string_view lhs,
+ const y_absl::Cord &rhs) const {
+ return compare_internal::compare_result_as_ordering(rhs.Compare(lhs));
+ }
+};
+
+// See below comments for checked_compare.
+template <typename Compare, bool is_class = std::is_class<Compare>::value>
+struct checked_compare_base : Compare {
+ using Compare::Compare;
+ explicit checked_compare_base(Compare c) : Compare(std::move(c)) {}
+ const Compare &comp() const { return *this; }
+};
+template <typename Compare>
+struct checked_compare_base<Compare, false> {
+ explicit checked_compare_base(Compare c) : compare(std::move(c)) {}
+ const Compare &comp() const { return compare; }
+ Compare compare;
+};
+
+// A mechanism for opting out of checked_compare for use only in btree_test.cc.
+struct BtreeTestOnlyCheckedCompareOptOutBase {};
+
+// A helper class to adapt the specified comparator for two use cases:
+// (1) When using common Abseil string types with common comparison functors,
+// convert a boolean comparison into a three-way comparison that returns an
+// `y_absl::weak_ordering`. This helper class is specialized for
+// less<TString>, greater<TString>, less<string_view>,
+// greater<string_view>, less<y_absl::Cord>, and greater<y_absl::Cord>.
+// (2) Adapt the comparator to diagnose cases of non-strict-weak-ordering (see
+// https://en.cppreference.com/w/cpp/named_req/Compare) in debug mode. Whenever
+// a comparison is made, we will make assertions to verify that the comparator
+// is valid.
+template <typename Compare, typename Key>
+struct key_compare_adapter {
+ // Inherit from checked_compare_base to support function pointers and also
+ // keep empty-base-optimization (EBO) support for classes.
+ // Note: we can't use CompressedTuple here because that would interfere
+ // with the EBO for `btree::rightmost_`. `btree::rightmost_` is itself a
+ // CompressedTuple and nested `CompressedTuple`s don't support EBO.
+ // TODO(b/214288561): use CompressedTuple instead once it supports EBO for
+ // nested `CompressedTuple`s.
+ struct checked_compare : checked_compare_base<Compare> {
+ private:
+ using Base = typename checked_compare::checked_compare_base;
+ using Base::comp;
+
+ // If possible, returns whether `t` is equivalent to itself. We can only do
+ // this for `Key`s because we can't be sure that it's safe to call
+ // `comp()(k, k)` otherwise. Even if SFINAE allows it, there could be a
+ // compilation failure inside the implementation of the comparison operator.
+ bool is_self_equivalent(const Key &k) const {
+ // Note: this works for both boolean and three-way comparators.
+ return comp()(k, k) == 0;
+ }
+ // If we can't compare `t` with itself, returns true unconditionally.
+ template <typename T>
+ bool is_self_equivalent(const T &) const {
+ return true;
+ }
+
+ public:
+ using Base::Base;
+ checked_compare(Compare comp) : Base(std::move(comp)) {} // NOLINT
+
+ // Allow converting to Compare for use in key_comp()/value_comp().
+ explicit operator Compare() const { return comp(); }
+
+ template <typename T, typename U,
+ y_absl::enable_if_t<
+ std::is_same<bool, compare_result_t<Compare, T, U>>::value,
+ int> = 0>
+ bool operator()(const T &lhs, const U &rhs) const {
+ // NOTE: if any of these assertions fail, then the comparator does not
+ // establish a strict-weak-ordering (see
+ // https://en.cppreference.com/w/cpp/named_req/Compare).
+ assert(is_self_equivalent(lhs));
+ assert(is_self_equivalent(rhs));
+ const bool lhs_comp_rhs = comp()(lhs, rhs);
+ assert(!lhs_comp_rhs || !comp()(rhs, lhs));
+ return lhs_comp_rhs;
+ }
+
+ template <
+ typename T, typename U,
+ y_absl::enable_if_t<std::is_convertible<compare_result_t<Compare, T, U>,
+ y_absl::weak_ordering>::value,
+ int> = 0>
+ y_absl::weak_ordering operator()(const T &lhs, const U &rhs) const {
+ // NOTE: if any of these assertions fail, then the comparator does not
+ // establish a strict-weak-ordering (see
+ // https://en.cppreference.com/w/cpp/named_req/Compare).
+ assert(is_self_equivalent(lhs));
+ assert(is_self_equivalent(rhs));
+ const y_absl::weak_ordering lhs_comp_rhs = comp()(lhs, rhs);
+#ifndef NDEBUG
+ const y_absl::weak_ordering rhs_comp_lhs = comp()(rhs, lhs);
+ if (lhs_comp_rhs > 0) {
+ assert(rhs_comp_lhs < 0 && "lhs_comp_rhs > 0 -> rhs_comp_lhs < 0");
+ } else if (lhs_comp_rhs == 0) {
+ assert(rhs_comp_lhs == 0 && "lhs_comp_rhs == 0 -> rhs_comp_lhs == 0");
+ } else {
+ assert(rhs_comp_lhs > 0 && "lhs_comp_rhs < 0 -> rhs_comp_lhs > 0");
+ }
+#endif
+ return lhs_comp_rhs;
+ }
+ };
+ using type = y_absl::conditional_t<
+ std::is_base_of<BtreeTestOnlyCheckedCompareOptOutBase, Compare>::value,
+ Compare, checked_compare>;
+};
+
+template <>
+struct key_compare_adapter<std::less<TString>, TString> {
+ using type = StringBtreeDefaultLess;
+};
+
+template <>
+struct key_compare_adapter<std::greater<TString>, TString> {
+ using type = StringBtreeDefaultGreater;
+};
+
+template <>
+struct key_compare_adapter<std::less<y_absl::string_view>, y_absl::string_view> {
+ using type = StringBtreeDefaultLess;
+};
+
+template <>
+struct key_compare_adapter<std::greater<y_absl::string_view>, y_absl::string_view> {
+ using type = StringBtreeDefaultGreater;
+};
+
+template <>
+struct key_compare_adapter<std::less<y_absl::Cord>, y_absl::Cord> {
+ using type = StringBtreeDefaultLess;
+};
+
+template <>
+struct key_compare_adapter<std::greater<y_absl::Cord>, y_absl::Cord> {
+ using type = StringBtreeDefaultGreater;
+};
+
+// Detects an 'absl_btree_prefer_linear_node_search' member. This is
+// a protocol used as an opt-in or opt-out of linear search.
+//
+// For example, this would be useful for key types that wrap an integer
+// and define their own cheap operator<(). For example:
+//
+// class K {
+// public:
+// using absl_btree_prefer_linear_node_search = std::true_type;
+// ...
+// private:
+// friend bool operator<(K a, K b) { return a.k_ < b.k_; }
+// int k_;
+// };
+//
+// btree_map<K, V> m; // Uses linear search
+//
+// If T has the preference tag, then it has a preference.
+// Btree will use the tag's truth value.
+template <typename T, typename = void>
+struct has_linear_node_search_preference : std::false_type {};
+template <typename T, typename = void>
+struct prefers_linear_node_search : std::false_type {};
+template <typename T>
+struct has_linear_node_search_preference<
+ T, y_absl::void_t<typename T::absl_btree_prefer_linear_node_search>>
+ : std::true_type {};
+template <typename T>
+struct prefers_linear_node_search<
+ T, y_absl::void_t<typename T::absl_btree_prefer_linear_node_search>>
+ : T::absl_btree_prefer_linear_node_search {};
+
+template <typename Compare, typename Key>
+constexpr bool compare_has_valid_result_type() {
+ using compare_result_type = compare_result_t<Compare, Key, Key>;
+ return std::is_same<compare_result_type, bool>::value ||
+ std::is_convertible<compare_result_type, y_absl::weak_ordering>::value;
+}
+
+template <typename original_key_compare, typename value_type>
+class map_value_compare {
+ template <typename Params>
+ friend class btree;
+
+ // Note: this `protected` is part of the API of std::map::value_compare. See
+ // https://en.cppreference.com/w/cpp/container/map/value_compare.
+ protected:
+ explicit map_value_compare(original_key_compare c) : comp(std::move(c)) {}
+
+ original_key_compare comp; // NOLINT
+
+ public:
+ auto operator()(const value_type &lhs, const value_type &rhs) const
+ -> decltype(comp(lhs.first, rhs.first)) {
+ return comp(lhs.first, rhs.first);
+ }
+};
+
+template <typename Key, typename Compare, typename Alloc, int TargetNodeSize,
+ bool IsMulti, bool IsMap, typename SlotPolicy>
+struct common_params : common_policy_traits<SlotPolicy> {
+ using original_key_compare = Compare;
+
+ // If Compare is a common comparator for a string-like type, then we adapt it
+ // to use heterogeneous lookup and to be a key-compare-to comparator.
+ // We also adapt the comparator to diagnose invalid comparators in debug mode.
+ // We disable this when `Compare` is invalid in a way that will cause
+ // adaptation to fail (having invalid return type) so that we can give a
+ // better compilation failure in static_assert_validation. If we don't do
+ // this, then there will be cascading compilation failures that are confusing
+ // for users.
+ using key_compare =
+ y_absl::conditional_t<!compare_has_valid_result_type<Compare, Key>(),
+ Compare,
+ typename key_compare_adapter<Compare, Key>::type>;
+
+ static constexpr bool kIsKeyCompareStringAdapted =
+ std::is_same<key_compare, StringBtreeDefaultLess>::value ||
+ std::is_same<key_compare, StringBtreeDefaultGreater>::value;
+ static constexpr bool kIsKeyCompareTransparent =
+ IsTransparent<original_key_compare>::value || kIsKeyCompareStringAdapted;
+
+ // A type which indicates if we have a key-compare-to functor or a plain old
+ // key-compare functor.
+ using is_key_compare_to = btree_is_key_compare_to<key_compare, Key>;
+
+ using allocator_type = Alloc;
+ using key_type = Key;
+ using size_type = size_t;
+ using difference_type = ptrdiff_t;
+
+ using slot_policy = SlotPolicy;
+ using slot_type = typename slot_policy::slot_type;
+ using value_type = typename slot_policy::value_type;
+ using init_type = typename slot_policy::mutable_value_type;
+ using pointer = value_type *;
+ using const_pointer = const value_type *;
+ using reference = value_type &;
+ using const_reference = const value_type &;
+
+ using value_compare =
+ y_absl::conditional_t<IsMap,
+ map_value_compare<original_key_compare, value_type>,
+ original_key_compare>;
+ using is_map_container = std::integral_constant<bool, IsMap>;
+
+ // For the given lookup key type, returns whether we can have multiple
+ // equivalent keys in the btree. If this is a multi-container, then we can.
+ // Otherwise, we can have multiple equivalent keys only if all of the
+ // following conditions are met:
+ // - The comparator is transparent.
+ // - The lookup key type is not the same as key_type.
+ // - The comparator is not a StringBtreeDefault{Less,Greater} comparator
+ // that we know has the same equivalence classes for all lookup types.
+ template <typename LookupKey>
+ constexpr static bool can_have_multiple_equivalent_keys() {
+ return IsMulti || (IsTransparent<key_compare>::value &&
+ !std::is_same<LookupKey, Key>::value &&
+ !kIsKeyCompareStringAdapted);
+ }
+
+ enum {
+ kTargetNodeSize = TargetNodeSize,
+
+ // Upper bound for the available space for slots. This is largest for leaf
+ // nodes, which have overhead of at least a pointer + 4 bytes (for storing
+ // 3 field_types and an enum).
+ kNodeSlotSpace = TargetNodeSize - /*minimum overhead=*/(sizeof(void *) + 4),
+ };
+
+ // This is an integral type large enough to hold as many slots as will fit a
+ // node of TargetNodeSize bytes.
+ using node_count_type =
+ y_absl::conditional_t<(kNodeSlotSpace / sizeof(slot_type) >
+ (std::numeric_limits<uint8_t>::max)()),
+ uint16_t, uint8_t>; // NOLINT
+};
+
+// An adapter class that converts a lower-bound compare into an upper-bound
+// compare. Note: there is no need to make a version of this adapter specialized
+// for key-compare-to functors because the upper-bound (the first value greater
+// than the input) is never an exact match.
+template <typename Compare>
+struct upper_bound_adapter {
+ explicit upper_bound_adapter(const Compare &c) : comp(c) {}
+ template <typename K1, typename K2>
+ bool operator()(const K1 &a, const K2 &b) const {
+ // Returns true when a is not greater than b.
+ return !compare_internal::compare_result_as_less_than(comp(b, a));
+ }
+
+ private:
+ Compare comp;
+};
+
+enum class MatchKind : uint8_t { kEq, kNe };
+
+template <typename V, bool IsCompareTo>
+struct SearchResult {
+ V value;
+ MatchKind match;
+
+ static constexpr bool HasMatch() { return true; }
+ bool IsEq() const { return match == MatchKind::kEq; }
+};
+
+// When we don't use CompareTo, `match` is not present.
+// This ensures that callers can't use it accidentally when it provides no
+// useful information.
+template <typename V>
+struct SearchResult<V, false> {
+ SearchResult() = default;
+ explicit SearchResult(V v) : value(v) {}
+ SearchResult(V v, MatchKind /*match*/) : value(v) {}
+
+ V value;
+
+ static constexpr bool HasMatch() { return false; }
+ static constexpr bool IsEq() { return false; }
+};
+
+// A node in the btree holding. The same node type is used for both internal
+// and leaf nodes in the btree, though the nodes are allocated in such a way
+// that the children array is only valid in internal nodes.
+template <typename Params>
+class btree_node {
+ using is_key_compare_to = typename Params::is_key_compare_to;
+ using field_type = typename Params::node_count_type;
+ using allocator_type = typename Params::allocator_type;
+ using slot_type = typename Params::slot_type;
+ using original_key_compare = typename Params::original_key_compare;
+
+ public:
+ using params_type = Params;
+ using key_type = typename Params::key_type;
+ using value_type = typename Params::value_type;
+ using pointer = typename Params::pointer;
+ using const_pointer = typename Params::const_pointer;
+ using reference = typename Params::reference;
+ using const_reference = typename Params::const_reference;
+ using key_compare = typename Params::key_compare;
+ using size_type = typename Params::size_type;
+ using difference_type = typename Params::difference_type;
+
+ // Btree decides whether to use linear node search as follows:
+ // - If the comparator expresses a preference, use that.
+ // - If the key expresses a preference, use that.
+ // - If the key is arithmetic and the comparator is std::less or
+ // std::greater, choose linear.
+ // - Otherwise, choose binary.
+ // TODO(ezb): Might make sense to add condition(s) based on node-size.
+ using use_linear_search = std::integral_constant<
+ bool, has_linear_node_search_preference<original_key_compare>::value
+ ? prefers_linear_node_search<original_key_compare>::value
+ : has_linear_node_search_preference<key_type>::value
+ ? prefers_linear_node_search<key_type>::value
+ : std::is_arithmetic<key_type>::value &&
+ (std::is_same<std::less<key_type>,
+ original_key_compare>::value ||
+ std::is_same<std::greater<key_type>,
+ original_key_compare>::value)>;
+
+ // This class is organized by y_absl::container_internal::Layout as if it had
+ // the following structure:
+ // // A pointer to the node's parent.
+ // btree_node *parent;
+ //
+ // // When Y_ABSL_BTREE_ENABLE_GENERATIONS is defined, we also have a
+ // // generation integer in order to check that when iterators are
+ // // used, they haven't been invalidated already. Only the generation on
+ // // the root is used, but we have one on each node because whether a node
+ // // is root or not can change.
+ // uint32_t generation;
+ //
+ // // The position of the node in the node's parent.
+ // field_type position;
+ // // The index of the first populated value in `values`.
+ // // TODO(ezb): right now, `start` is always 0. Update insertion/merge
+ // // logic to allow for floating storage within nodes.
+ // field_type start;
+ // // The index after the last populated value in `values`. Currently, this
+ // // is the same as the count of values.
+ // field_type finish;
+ // // The maximum number of values the node can hold. This is an integer in
+ // // [1, kNodeSlots] for root leaf nodes, kNodeSlots for non-root leaf
+ // // nodes, and kInternalNodeMaxCount (as a sentinel value) for internal
+ // // nodes (even though there are still kNodeSlots values in the node).
+ // // TODO(ezb): make max_count use only 4 bits and record log2(capacity)
+ // // to free extra bits for is_root, etc.
+ // field_type max_count;
+ //
+ // // The array of values. The capacity is `max_count` for leaf nodes and
+ // // kNodeSlots for internal nodes. Only the values in
+ // // [start, finish) have been initialized and are valid.
+ // slot_type values[max_count];
+ //
+ // // The array of child pointers. The keys in children[i] are all less
+ // // than key(i). The keys in children[i + 1] are all greater than key(i).
+ // // There are 0 children for leaf nodes and kNodeSlots + 1 children for
+ // // internal nodes.
+ // btree_node *children[kNodeSlots + 1];
+ //
+ // This class is only constructed by EmptyNodeType. Normally, pointers to the
+ // layout above are allocated, cast to btree_node*, and de-allocated within
+ // the btree implementation.
+ ~btree_node() = default;
+ btree_node(btree_node const &) = delete;
+ btree_node &operator=(btree_node const &) = delete;
+
+ protected:
+ btree_node() = default;
+
+ private:
+ using layout_type =
+ y_absl::container_internal::Layout<btree_node *, uint32_t, field_type,
+ slot_type, btree_node *>;
+ using leaf_layout_type = typename layout_type::template WithStaticSizes<
+ /*parent*/ 1,
+ /*generation*/ BtreeGenerationsEnabled() ? 1 : 0,
+ /*position, start, finish, max_count*/ 4>;
+ constexpr static size_type SizeWithNSlots(size_type n) {
+ return leaf_layout_type(/*slots*/ n, /*children*/ 0).AllocSize();
+ }
+ // A lower bound for the overhead of fields other than slots in a leaf node.
+ constexpr static size_type MinimumOverhead() {
+ return SizeWithNSlots(1) - sizeof(slot_type);
+ }
+
+ // Compute how many values we can fit onto a leaf node taking into account
+ // padding.
+ constexpr static size_type NodeTargetSlots(const size_type begin,
+ const size_type end) {
+ return begin == end ? begin
+ : SizeWithNSlots((begin + end) / 2 + 1) >
+ params_type::kTargetNodeSize
+ ? NodeTargetSlots(begin, (begin + end) / 2)
+ : NodeTargetSlots((begin + end) / 2 + 1, end);
+ }
+
+ constexpr static size_type kTargetNodeSize = params_type::kTargetNodeSize;
+ constexpr static size_type kNodeTargetSlots =
+ NodeTargetSlots(0, kTargetNodeSize);
+
+ // We need a minimum of 3 slots per internal node in order to perform
+ // splitting (1 value for the two nodes involved in the split and 1 value
+ // propagated to the parent as the delimiter for the split). For performance
+ // reasons, we don't allow 3 slots-per-node due to bad worst case occupancy of
+ // 1/3 (for a node, not a b-tree).
+ constexpr static size_type kMinNodeSlots = 4;
+
+ constexpr static size_type kNodeSlots =
+ kNodeTargetSlots >= kMinNodeSlots ? kNodeTargetSlots : kMinNodeSlots;
+
+ using internal_layout_type = typename layout_type::template WithStaticSizes<
+ /*parent*/ 1,
+ /*generation*/ BtreeGenerationsEnabled() ? 1 : 0,
+ /*position, start, finish, max_count*/ 4, /*slots*/ kNodeSlots,
+ /*children*/ kNodeSlots + 1>;
+
+ // The node is internal (i.e. is not a leaf node) if and only if `max_count`
+ // has this value.
+ constexpr static field_type kInternalNodeMaxCount = 0;
+
+ // Leaves can have less than kNodeSlots values.
+ constexpr static leaf_layout_type LeafLayout(
+ const size_type slot_count = kNodeSlots) {
+ return leaf_layout_type(slot_count, 0);
+ }
+ constexpr static auto InternalLayout() { return internal_layout_type(); }
+ constexpr static size_type LeafSize(const size_type slot_count = kNodeSlots) {
+ return LeafLayout(slot_count).AllocSize();
+ }
+ constexpr static size_type InternalSize() {
+ return InternalLayout().AllocSize();
+ }
+
+ constexpr static size_type Alignment() {
+ static_assert(LeafLayout(1).Alignment() == InternalLayout().Alignment(),
+ "Alignment of all nodes must be equal.");
+ return InternalLayout().Alignment();
+ }
+
+ // N is the index of the type in the Layout definition.
+ // ElementType<N> is the Nth type in the Layout definition.
+ template <size_type N>
+ inline typename layout_type::template ElementType<N> *GetField() {
+ // We assert that we don't read from values that aren't there.
+ assert(N < 4 || is_internal());
+ return InternalLayout().template Pointer<N>(reinterpret_cast<char *>(this));
+ }
+ template <size_type N>
+ inline const typename layout_type::template ElementType<N> *GetField() const {
+ assert(N < 4 || is_internal());
+ return InternalLayout().template Pointer<N>(
+ reinterpret_cast<const char *>(this));
+ }
+ void set_parent(btree_node *p) { *GetField<0>() = p; }
+ field_type &mutable_finish() { return GetField<2>()[2]; }
+ slot_type *slot(size_type i) { return &GetField<3>()[i]; }
+ slot_type *start_slot() { return slot(start()); }
+ slot_type *finish_slot() { return slot(finish()); }
+ const slot_type *slot(size_type i) const { return &GetField<3>()[i]; }
+ void set_position(field_type v) { GetField<2>()[0] = v; }
+ void set_start(field_type v) { GetField<2>()[1] = v; }
+ void set_finish(field_type v) { GetField<2>()[2] = v; }
+ // This method is only called by the node init methods.
+ void set_max_count(field_type v) { GetField<2>()[3] = v; }
+
+ public:
+ // Whether this is a leaf node or not. This value doesn't change after the
+ // node is created.
+ bool is_leaf() const { return GetField<2>()[3] != kInternalNodeMaxCount; }
+ // Whether this is an internal node or not. This value doesn't change after
+ // the node is created.
+ bool is_internal() const { return !is_leaf(); }
+
+ // Getter for the position of this node in its parent.
+ field_type position() const { return GetField<2>()[0]; }
+
+ // Getter for the offset of the first value in the `values` array.
+ field_type start() const {
+ // TODO(ezb): when floating storage is implemented, return GetField<2>()[1];
+ assert(GetField<2>()[1] == 0);
+ return 0;
+ }
+
+ // Getter for the offset after the last value in the `values` array.
+ field_type finish() const { return GetField<2>()[2]; }
+
+ // Getters for the number of values stored in this node.
+ field_type count() const {
+ assert(finish() >= start());
+ return finish() - start();
+ }
+ field_type max_count() const {
+ // Internal nodes have max_count==kInternalNodeMaxCount.
+ // Leaf nodes have max_count in [1, kNodeSlots].
+ const field_type max_count = GetField<2>()[3];
+ return max_count == field_type{kInternalNodeMaxCount}
+ ? field_type{kNodeSlots}
+ : max_count;
+ }
+
+ // Getter for the parent of this node.
+ btree_node *parent() const { return *GetField<0>(); }
+ // Getter for whether the node is the root of the tree. The parent of the
+ // root of the tree is the leftmost node in the tree which is guaranteed to
+ // be a leaf.
+ bool is_root() const { return parent()->is_leaf(); }
+ void make_root() {
+ assert(parent()->is_root());
+ set_generation(parent()->generation());
+ set_parent(parent()->parent());
+ }
+
+ // Gets the root node's generation integer, which is the one used by the tree.
+ uint32_t *get_root_generation() const {
+ assert(BtreeGenerationsEnabled());
+ const btree_node *curr = this;
+ for (; !curr->is_root(); curr = curr->parent()) continue;
+ return const_cast<uint32_t *>(&curr->GetField<1>()[0]);
+ }
+
+ // Returns the generation for iterator validation.
+ uint32_t generation() const {
+ return BtreeGenerationsEnabled() ? *get_root_generation() : 0;
+ }
+ // Updates generation. Should only be called on a root node or during node
+ // initialization.
+ void set_generation(uint32_t generation) {
+ if (BtreeGenerationsEnabled()) GetField<1>()[0] = generation;
+ }
+ // Updates the generation. We do this whenever the node is mutated.
+ void next_generation() {
+ if (BtreeGenerationsEnabled()) ++*get_root_generation();
+ }
+
+ // Getters for the key/value at position i in the node.
+ const key_type &key(size_type i) const { return params_type::key(slot(i)); }
+ reference value(size_type i) { return params_type::element(slot(i)); }
+ const_reference value(size_type i) const {
+ return params_type::element(slot(i));
+ }
+
+ // Getters/setter for the child at position i in the node.
+ btree_node *child(field_type i) const { return GetField<4>()[i]; }
+ btree_node *start_child() const { return child(start()); }
+ btree_node *&mutable_child(field_type i) { return GetField<4>()[i]; }
+ void clear_child(field_type i) {
+ y_absl::container_internal::SanitizerPoisonObject(&mutable_child(i));
+ }
+ void set_child_noupdate_position(field_type i, btree_node *c) {
+ y_absl::container_internal::SanitizerUnpoisonObject(&mutable_child(i));
+ mutable_child(i) = c;
+ }
+ void set_child(field_type i, btree_node *c) {
+ set_child_noupdate_position(i, c);
+ c->set_position(i);
+ }
+ void init_child(field_type i, btree_node *c) {
+ set_child(i, c);
+ c->set_parent(this);
+ }
+
+ // Returns the position of the first value whose key is not less than k.
+ template <typename K>
+ SearchResult<size_type, is_key_compare_to::value> lower_bound(
+ const K &k, const key_compare &comp) const {
+ return use_linear_search::value ? linear_search(k, comp)
+ : binary_search(k, comp);
+ }
+ // Returns the position of the first value whose key is greater than k.
+ template <typename K>
+ size_type upper_bound(const K &k, const key_compare &comp) const {
+ auto upper_compare = upper_bound_adapter<key_compare>(comp);
+ return use_linear_search::value ? linear_search(k, upper_compare).value
+ : binary_search(k, upper_compare).value;
+ }
+
+ template <typename K, typename Compare>
+ SearchResult<size_type, btree_is_key_compare_to<Compare, key_type>::value>
+ linear_search(const K &k, const Compare &comp) const {
+ return linear_search_impl(k, start(), finish(), comp,
+ btree_is_key_compare_to<Compare, key_type>());
+ }
+
+ template <typename K, typename Compare>
+ SearchResult<size_type, btree_is_key_compare_to<Compare, key_type>::value>
+ binary_search(const K &k, const Compare &comp) const {
+ return binary_search_impl(k, start(), finish(), comp,
+ btree_is_key_compare_to<Compare, key_type>());
+ }
+
+ // Returns the position of the first value whose key is not less than k using
+ // linear search performed using plain compare.
+ template <typename K, typename Compare>
+ SearchResult<size_type, false> linear_search_impl(
+ const K &k, size_type s, const size_type e, const Compare &comp,
+ std::false_type /* IsCompareTo */) const {
+ while (s < e) {
+ if (!comp(key(s), k)) {
+ break;
+ }
+ ++s;
+ }
+ return SearchResult<size_type, false>{s};
+ }
+
+ // Returns the position of the first value whose key is not less than k using
+ // linear search performed using compare-to.
+ template <typename K, typename Compare>
+ SearchResult<size_type, true> linear_search_impl(
+ const K &k, size_type s, const size_type e, const Compare &comp,
+ std::true_type /* IsCompareTo */) const {
+ while (s < e) {
+ const y_absl::weak_ordering c = comp(key(s), k);
+ if (c == 0) {
+ return {s, MatchKind::kEq};
+ } else if (c > 0) {
+ break;
+ }
+ ++s;
+ }
+ return {s, MatchKind::kNe};
+ }
+
+ // Returns the position of the first value whose key is not less than k using
+ // binary search performed using plain compare.
+ template <typename K, typename Compare>
+ SearchResult<size_type, false> binary_search_impl(
+ const K &k, size_type s, size_type e, const Compare &comp,
+ std::false_type /* IsCompareTo */) const {
+ while (s != e) {
+ const size_type mid = (s + e) >> 1;
+ if (comp(key(mid), k)) {
+ s = mid + 1;
+ } else {
+ e = mid;
+ }
+ }
+ return SearchResult<size_type, false>{s};
+ }
+
+ // Returns the position of the first value whose key is not less than k using
+ // binary search performed using compare-to.
+ template <typename K, typename CompareTo>
+ SearchResult<size_type, true> binary_search_impl(
+ const K &k, size_type s, size_type e, const CompareTo &comp,
+ std::true_type /* IsCompareTo */) const {
+ if (params_type::template can_have_multiple_equivalent_keys<K>()) {
+ MatchKind exact_match = MatchKind::kNe;
+ while (s != e) {
+ const size_type mid = (s + e) >> 1;
+ const y_absl::weak_ordering c = comp(key(mid), k);
+ if (c < 0) {
+ s = mid + 1;
+ } else {
+ e = mid;
+ if (c == 0) {
+ // Need to return the first value whose key is not less than k,
+ // which requires continuing the binary search if there could be
+ // multiple equivalent keys.
+ exact_match = MatchKind::kEq;
+ }
+ }
+ }
+ return {s, exact_match};
+ } else { // Can't have multiple equivalent keys.
+ while (s != e) {
+ const size_type mid = (s + e) >> 1;
+ const y_absl::weak_ordering c = comp(key(mid), k);
+ if (c < 0) {
+ s = mid + 1;
+ } else if (c > 0) {
+ e = mid;
+ } else {
+ return {mid, MatchKind::kEq};
+ }
+ }
+ return {s, MatchKind::kNe};
+ }
+ }
+
+ // Returns whether key i is ordered correctly with respect to the other keys
+ // in the node. The motivation here is to detect comparators that violate
+ // transitivity. Note: we only do comparisons of keys on this node rather than
+ // the whole tree so that this is constant time.
+ template <typename Compare>
+ bool is_ordered_correctly(field_type i, const Compare &comp) const {
+ if (std::is_base_of<BtreeTestOnlyCheckedCompareOptOutBase,
+ Compare>::value ||
+ params_type::kIsKeyCompareStringAdapted) {
+ return true;
+ }
+
+ const auto compare = [&](field_type a, field_type b) {
+ const y_absl::weak_ordering cmp =
+ compare_internal::do_three_way_comparison(comp, key(a), key(b));
+ return cmp < 0 ? -1 : cmp > 0 ? 1 : 0;
+ };
+ int cmp = -1;
+ constexpr bool kCanHaveEquivKeys =
+ params_type::template can_have_multiple_equivalent_keys<key_type>();
+ for (field_type j = start(); j < finish(); ++j) {
+ if (j == i) {
+ if (cmp > 0) return false;
+ continue;
+ }
+ int new_cmp = compare(j, i);
+ if (new_cmp < cmp || (!kCanHaveEquivKeys && new_cmp == 0)) return false;
+ cmp = new_cmp;
+ }
+ return true;
+ }
+
+ // Emplaces a value at position i, shifting all existing values and
+ // children at positions >= i to the right by 1.
+ template <typename... Args>
+ void emplace_value(field_type i, allocator_type *alloc, Args &&...args);
+
+ // Removes the values at positions [i, i + to_erase), shifting all existing
+ // values and children after that range to the left by to_erase. Clears all
+ // children between [i, i + to_erase).
+ void remove_values(field_type i, field_type to_erase, allocator_type *alloc);
+
+ // Rebalances a node with its right sibling.
+ void rebalance_right_to_left(field_type to_move, btree_node *right,
+ allocator_type *alloc);
+ void rebalance_left_to_right(field_type to_move, btree_node *right,
+ allocator_type *alloc);
+
+ // Splits a node, moving a portion of the node's values to its right sibling.
+ void split(int insert_position, btree_node *dest, allocator_type *alloc);
+
+ // Merges a node with its right sibling, moving all of the values and the
+ // delimiting key in the parent node onto itself, and deleting the src node.
+ void merge(btree_node *src, allocator_type *alloc);
+
+ // Node allocation/deletion routines.
+ void init_leaf(field_type position, field_type max_count,
+ btree_node *parent) {
+ set_generation(0);
+ set_parent(parent);
+ set_position(position);
+ set_start(0);
+ set_finish(0);
+ set_max_count(max_count);
+ y_absl::container_internal::SanitizerPoisonMemoryRegion(
+ start_slot(), max_count * sizeof(slot_type));
+ }
+ void init_internal(field_type position, btree_node *parent) {
+ init_leaf(position, kNodeSlots, parent);
+ // Set `max_count` to a sentinel value to indicate that this node is
+ // internal.
+ set_max_count(kInternalNodeMaxCount);
+ y_absl::container_internal::SanitizerPoisonMemoryRegion(
+ &mutable_child(start()), (kNodeSlots + 1) * sizeof(btree_node *));
+ }
+
+ static void deallocate(const size_type size, btree_node *node,
+ allocator_type *alloc) {
+ y_absl::container_internal::SanitizerUnpoisonMemoryRegion(node, size);
+ y_absl::container_internal::Deallocate<Alignment()>(alloc, node, size);
+ }
+
+ // Deletes a node and all of its children.
+ static void clear_and_delete(btree_node *node, allocator_type *alloc);
+
+ private:
+ template <typename... Args>
+ void value_init(const field_type i, allocator_type *alloc, Args &&...args) {
+ next_generation();
+ y_absl::container_internal::SanitizerUnpoisonObject(slot(i));
+ params_type::construct(alloc, slot(i), std::forward<Args>(args)...);
+ }
+ void value_destroy(const field_type i, allocator_type *alloc) {
+ next_generation();
+ params_type::destroy(alloc, slot(i));
+ y_absl::container_internal::SanitizerPoisonObject(slot(i));
+ }
+ void value_destroy_n(const field_type i, const field_type n,
+ allocator_type *alloc) {
+ next_generation();
+ for (slot_type *s = slot(i), *end = slot(i + n); s != end; ++s) {
+ params_type::destroy(alloc, s);
+ y_absl::container_internal::SanitizerPoisonObject(s);
+ }
+ }
+
+ static void transfer(slot_type *dest, slot_type *src, allocator_type *alloc) {
+ y_absl::container_internal::SanitizerUnpoisonObject(dest);
+ params_type::transfer(alloc, dest, src);
+ y_absl::container_internal::SanitizerPoisonObject(src);
+ }
+
+ // Transfers value from slot `src_i` in `src_node` to slot `dest_i` in `this`.
+ void transfer(const size_type dest_i, const size_type src_i,
+ btree_node *src_node, allocator_type *alloc) {
+ next_generation();
+ transfer(slot(dest_i), src_node->slot(src_i), alloc);
+ }
+
+ // Transfers `n` values starting at value `src_i` in `src_node` into the
+ // values starting at value `dest_i` in `this`.
+ void transfer_n(const size_type n, const size_type dest_i,
+ const size_type src_i, btree_node *src_node,
+ allocator_type *alloc) {
+ next_generation();
+ for (slot_type *src = src_node->slot(src_i), *end = src + n,
+ *dest = slot(dest_i);
+ src != end; ++src, ++dest) {
+ transfer(dest, src, alloc);
+ }
+ }
+
+ // Same as above, except that we start at the end and work our way to the
+ // beginning.
+ void transfer_n_backward(const size_type n, const size_type dest_i,
+ const size_type src_i, btree_node *src_node,
+ allocator_type *alloc) {
+ next_generation();
+ for (slot_type *src = src_node->slot(src_i + n), *end = src - n,
+ *dest = slot(dest_i + n);
+ src != end; --src, --dest) {
+ // If we modified the loop index calculations above to avoid the -1s here,
+ // it would result in UB in the computation of `end` (and possibly `src`
+ // as well, if n == 0), since slot() is effectively an array index and it
+ // is UB to compute the address of any out-of-bounds array element except
+ // for one-past-the-end.
+ transfer(dest - 1, src - 1, alloc);
+ }
+ }
+
+ template <typename P>
+ friend class btree;
+ template <typename N, typename R, typename P>
+ friend class btree_iterator;
+ friend class BtreeNodePeer;
+ friend struct btree_access;
+};
+
+template <typename Node>
+bool AreNodesFromSameContainer(const Node *node_a, const Node *node_b) {
+ // If either node is null, then give up on checking whether they're from the
+ // same container. (If exactly one is null, then we'll trigger the
+ // default-constructed assert in Equals.)
+ if (node_a == nullptr || node_b == nullptr) return true;
+ while (!node_a->is_root()) node_a = node_a->parent();
+ while (!node_b->is_root()) node_b = node_b->parent();
+ return node_a == node_b;
+}
+
+class btree_iterator_generation_info_enabled {
+ public:
+ explicit btree_iterator_generation_info_enabled(uint32_t g)
+ : generation_(g) {}
+
+ // Updates the generation. For use internally right before we return an
+ // iterator to the user.
+ template <typename Node>
+ void update_generation(const Node *node) {
+ if (node != nullptr) generation_ = node->generation();
+ }
+ uint32_t generation() const { return generation_; }
+
+ template <typename Node>
+ void assert_valid_generation(const Node *node) const {
+ if (node != nullptr && node->generation() != generation_) {
+ Y_ABSL_INTERNAL_LOG(
+ FATAL,
+ "Attempting to use an invalidated iterator. The corresponding b-tree "
+ "container has been mutated since this iterator was constructed.");
+ }
+ }
+
+ private:
+ // Used to check that the iterator hasn't been invalidated.
+ uint32_t generation_;
+};
+
+class btree_iterator_generation_info_disabled {
+ public:
+ explicit btree_iterator_generation_info_disabled(uint32_t) {}
+ static void update_generation(const void *) {}
+ static uint32_t generation() { return 0; }
+ static void assert_valid_generation(const void *) {}
+};
+
+#ifdef Y_ABSL_BTREE_ENABLE_GENERATIONS
+using btree_iterator_generation_info = btree_iterator_generation_info_enabled;
+#else
+using btree_iterator_generation_info = btree_iterator_generation_info_disabled;
+#endif
+
+template <typename Node, typename Reference, typename Pointer>
+class btree_iterator : private btree_iterator_generation_info {
+ using field_type = typename Node::field_type;
+ using key_type = typename Node::key_type;
+ using size_type = typename Node::size_type;
+ using params_type = typename Node::params_type;
+ using is_map_container = typename params_type::is_map_container;
+
+ using node_type = Node;
+ using normal_node = typename std::remove_const<Node>::type;
+ using const_node = const Node;
+ using normal_pointer = typename params_type::pointer;
+ using normal_reference = typename params_type::reference;
+ using const_pointer = typename params_type::const_pointer;
+ using const_reference = typename params_type::const_reference;
+ using slot_type = typename params_type::slot_type;
+
+ // In sets, all iterators are const.
+ using iterator = y_absl::conditional_t<
+ is_map_container::value,
+ btree_iterator<normal_node, normal_reference, normal_pointer>,
+ btree_iterator<normal_node, const_reference, const_pointer>>;
+ using const_iterator =
+ btree_iterator<const_node, const_reference, const_pointer>;
+
+ public:
+ // These aliases are public for std::iterator_traits.
+ using difference_type = typename Node::difference_type;
+ using value_type = typename params_type::value_type;
+ using pointer = Pointer;
+ using reference = Reference;
+ using iterator_category = std::bidirectional_iterator_tag;
+
+ btree_iterator() : btree_iterator(nullptr, -1) {}
+ explicit btree_iterator(Node *n) : btree_iterator(n, n->start()) {}
+ btree_iterator(Node *n, int p)
+ : btree_iterator_generation_info(n != nullptr ? n->generation()
+ : ~uint32_t{}),
+ node_(n),
+ position_(p) {}
+
+ // NOTE: this SFINAE allows for implicit conversions from iterator to
+ // const_iterator, but it specifically avoids hiding the copy constructor so
+ // that the trivial one will be used when possible.
+ template <typename N, typename R, typename P,
+ y_absl::enable_if_t<
+ std::is_same<btree_iterator<N, R, P>, iterator>::value &&
+ std::is_same<btree_iterator, const_iterator>::value,
+ int> = 0>
+ btree_iterator(const btree_iterator<N, R, P> other) // NOLINT
+ : btree_iterator_generation_info(other),
+ node_(other.node_),
+ position_(other.position_) {}
+
+ bool operator==(const iterator &other) const {
+ return Equals(other);
+ }
+ bool operator==(const const_iterator &other) const {
+ return Equals(other);
+ }
+ bool operator!=(const iterator &other) const {
+ return !Equals(other);
+ }
+ bool operator!=(const const_iterator &other) const {
+ return !Equals(other);
+ }
+
+ // Returns n such that n calls to ++other yields *this.
+ // Precondition: n exists.
+ difference_type operator-(const_iterator other) const {
+ if (node_ == other.node_) {
+ if (node_->is_leaf()) return position_ - other.position_;
+ if (position_ == other.position_) return 0;
+ }
+ return distance_slow(other);
+ }
+
+ // Accessors for the key/value the iterator is pointing at.
+ reference operator*() const {
+ Y_ABSL_HARDENING_ASSERT(node_ != nullptr);
+ assert_valid_generation(node_);
+ Y_ABSL_HARDENING_ASSERT(position_ >= node_->start());
+ if (position_ >= node_->finish()) {
+ Y_ABSL_HARDENING_ASSERT(!IsEndIterator() && "Dereferencing end() iterator");
+ Y_ABSL_HARDENING_ASSERT(position_ < node_->finish());
+ }
+ return node_->value(static_cast<field_type>(position_));
+ }
+ pointer operator->() const { return &operator*(); }
+
+ btree_iterator &operator++() {
+ increment();
+ return *this;
+ }
+ btree_iterator &operator--() {
+ decrement();
+ return *this;
+ }
+ btree_iterator operator++(int) {
+ btree_iterator tmp = *this;
+ ++*this;
+ return tmp;
+ }
+ btree_iterator operator--(int) {
+ btree_iterator tmp = *this;
+ --*this;
+ return tmp;
+ }
+
+ private:
+ #ifndef __NVCC__
+ friend iterator;
+ #endif
+ friend const_iterator;
+ template <typename Params>
+ friend class btree;
+ template <typename Tree>
+ friend class btree_container;
+ template <typename Tree>
+ friend class btree_set_container;
+ template <typename Tree>
+ friend class btree_map_container;
+ template <typename Tree>
+ friend class btree_multiset_container;
+ template <typename TreeType, typename CheckerType>
+ friend class base_checker;
+ friend struct btree_access;
+
+ // This SFINAE allows explicit conversions from const_iterator to
+ // iterator, but also avoids hiding the copy constructor.
+ // NOTE: the const_cast is safe because this constructor is only called by
+ // non-const methods and the container owns the nodes.
+ template <typename N, typename R, typename P,
+ y_absl::enable_if_t<
+ std::is_same<btree_iterator<N, R, P>, const_iterator>::value &&
+ std::is_same<btree_iterator, iterator>::value,
+ int> = 0>
+ explicit btree_iterator(const btree_iterator<N, R, P> other)
+ : btree_iterator_generation_info(other.generation()),
+ node_(const_cast<node_type *>(other.node_)),
+ position_(other.position_) {}
+
+ bool Equals(const const_iterator other) const {
+ Y_ABSL_HARDENING_ASSERT(((node_ == nullptr && other.node_ == nullptr) ||
+ (node_ != nullptr && other.node_ != nullptr)) &&
+ "Comparing default-constructed iterator with "
+ "non-default-constructed iterator.");
+ // Note: we use assert instead of Y_ABSL_HARDENING_ASSERT here because this
+ // changes the complexity of Equals from O(1) to O(log(N) + log(M)) where
+ // N/M are sizes of the containers containing node_/other.node_.
+ assert(AreNodesFromSameContainer(node_, other.node_) &&
+ "Comparing iterators from different containers.");
+ assert_valid_generation(node_);
+ other.assert_valid_generation(other.node_);
+ return node_ == other.node_ && position_ == other.position_;
+ }
+
+ bool IsEndIterator() const {
+ if (position_ != node_->finish()) return false;
+ node_type *node = node_;
+ while (!node->is_root()) {
+ if (node->position() != node->parent()->finish()) return false;
+ node = node->parent();
+ }
+ return true;
+ }
+
+ // Returns n such that n calls to ++other yields *this.
+ // Precondition: n exists && (this->node_ != other.node_ ||
+ // !this->node_->is_leaf() || this->position_ != other.position_).
+ difference_type distance_slow(const_iterator other) const;
+
+ // Increment/decrement the iterator.
+ void increment() {
+ assert_valid_generation(node_);
+ if (node_->is_leaf() && ++position_ < node_->finish()) {
+ return;
+ }
+ increment_slow();
+ }
+ void increment_slow();
+
+ void decrement() {
+ assert_valid_generation(node_);
+ if (node_->is_leaf() && --position_ >= node_->start()) {
+ return;
+ }
+ decrement_slow();
+ }
+ void decrement_slow();
+
+ const key_type &key() const {
+ return node_->key(static_cast<size_type>(position_));
+ }
+ decltype(std::declval<Node *>()->slot(0)) slot() {
+ return node_->slot(static_cast<size_type>(position_));
+ }
+
+ void update_generation() {
+ btree_iterator_generation_info::update_generation(node_);
+ }
+
+ // The node in the tree the iterator is pointing at.
+ Node *node_;
+ // The position within the node of the tree the iterator is pointing at.
+ // NOTE: this is an int rather than a field_type because iterators can point
+ // to invalid positions (such as -1) in certain circumstances.
+ int position_;
+};
+
+template <typename Params>
+class btree {
+ using node_type = btree_node<Params>;
+ using is_key_compare_to = typename Params::is_key_compare_to;
+ using field_type = typename node_type::field_type;
+
+ // We use a static empty node for the root/leftmost/rightmost of empty btrees
+ // in order to avoid branching in begin()/end().
+ struct EmptyNodeType : node_type {
+ using field_type = typename node_type::field_type;
+ btree_node<Params> *parent;
+#ifdef Y_ABSL_BTREE_ENABLE_GENERATIONS
+ uint32_t generation = 0;
+#endif
+ field_type position = 0;
+ field_type start = 0;
+ field_type finish = 0;
+ // max_count must be != kInternalNodeMaxCount (so that this node is regarded
+ // as a leaf node). max_count() is never called when the tree is empty.
+ field_type max_count = node_type::kInternalNodeMaxCount + 1;
+
+ constexpr EmptyNodeType() : parent(this) {}
+ };
+
+ static node_type *EmptyNode() {
+ alignas(node_type::Alignment()) static constexpr EmptyNodeType empty_node;
+ return const_cast<EmptyNodeType *>(&empty_node);
+ }
+
+ enum : uint32_t {
+ kNodeSlots = node_type::kNodeSlots,
+ kMinNodeValues = kNodeSlots / 2,
+ };
+
+ struct node_stats {
+ using size_type = typename Params::size_type;
+
+ node_stats(size_type l, size_type i) : leaf_nodes(l), internal_nodes(i) {}
+
+ node_stats &operator+=(const node_stats &other) {
+ leaf_nodes += other.leaf_nodes;
+ internal_nodes += other.internal_nodes;
+ return *this;
+ }
+
+ size_type leaf_nodes;
+ size_type internal_nodes;
+ };
+
+ public:
+ using key_type = typename Params::key_type;
+ using value_type = typename Params::value_type;
+ using size_type = typename Params::size_type;
+ using difference_type = typename Params::difference_type;
+ using key_compare = typename Params::key_compare;
+ using original_key_compare = typename Params::original_key_compare;
+ using value_compare = typename Params::value_compare;
+ using allocator_type = typename Params::allocator_type;
+ using reference = typename Params::reference;
+ using const_reference = typename Params::const_reference;
+ using pointer = typename Params::pointer;
+ using const_pointer = typename Params::const_pointer;
+ using iterator =
+ typename btree_iterator<node_type, reference, pointer>::iterator;
+ using const_iterator = typename iterator::const_iterator;
+ using reverse_iterator = std::reverse_iterator<iterator>;
+ using const_reverse_iterator = std::reverse_iterator<const_iterator>;
+ using node_handle_type = node_handle<Params, Params, allocator_type>;
+
+ // Internal types made public for use by btree_container types.
+ using params_type = Params;
+ using slot_type = typename Params::slot_type;
+
+ private:
+ // Copies or moves (depending on the template parameter) the values in
+ // other into this btree in their order in other. This btree must be empty
+ // before this method is called. This method is used in copy construction,
+ // copy assignment, and move assignment.
+ template <typename Btree>
+ void copy_or_move_values_in_order(Btree &other);
+
+ // Validates that various assumptions/requirements are true at compile time.
+ constexpr static bool static_assert_validation();
+
+ public:
+ btree(const key_compare &comp, const allocator_type &alloc)
+ : root_(EmptyNode()), rightmost_(comp, alloc, EmptyNode()), size_(0) {}
+
+ btree(const btree &other) : btree(other, other.allocator()) {}
+ btree(const btree &other, const allocator_type &alloc)
+ : btree(other.key_comp(), alloc) {
+ copy_or_move_values_in_order(other);
+ }
+ btree(btree &&other) noexcept
+ : root_(std::exchange(other.root_, EmptyNode())),
+ rightmost_(std::move(other.rightmost_)),
+ size_(std::exchange(other.size_, 0u)) {
+ other.mutable_rightmost() = EmptyNode();
+ }
+ btree(btree &&other, const allocator_type &alloc)
+ : btree(other.key_comp(), alloc) {
+ if (alloc == other.allocator()) {
+ swap(other);
+ } else {
+ // Move values from `other` one at a time when allocators are different.
+ copy_or_move_values_in_order(other);
+ }
+ }
+
+ ~btree() {
+ // Put static_asserts in destructor to avoid triggering them before the type
+ // is complete.
+ static_assert(static_assert_validation(), "This call must be elided.");
+ clear();
+ }
+
+ // Assign the contents of other to *this.
+ btree &operator=(const btree &other);
+ btree &operator=(btree &&other) noexcept;
+
+ iterator begin() { return iterator(leftmost()); }
+ const_iterator begin() const { return const_iterator(leftmost()); }
+ iterator end() { return iterator(rightmost(), rightmost()->finish()); }
+ const_iterator end() const {
+ return const_iterator(rightmost(), rightmost()->finish());
+ }
+ reverse_iterator rbegin() { return reverse_iterator(end()); }
+ const_reverse_iterator rbegin() const {
+ return const_reverse_iterator(end());
+ }
+ reverse_iterator rend() { return reverse_iterator(begin()); }
+ const_reverse_iterator rend() const {
+ return const_reverse_iterator(begin());
+ }
+
+ // Finds the first element whose key is not less than `key`.
+ template <typename K>
+ iterator lower_bound(const K &key) {
+ return internal_end(internal_lower_bound(key).value);
+ }
+ template <typename K>
+ const_iterator lower_bound(const K &key) const {
+ return internal_end(internal_lower_bound(key).value);
+ }
+
+ // Finds the first element whose key is not less than `key` and also returns
+ // whether that element is equal to `key`.
+ template <typename K>
+ std::pair<iterator, bool> lower_bound_equal(const K &key) const;
+
+ // Finds the first element whose key is greater than `key`.
+ template <typename K>
+ iterator upper_bound(const K &key) {
+ return internal_end(internal_upper_bound(key));
+ }
+ template <typename K>
+ const_iterator upper_bound(const K &key) const {
+ return internal_end(internal_upper_bound(key));
+ }
+
+ // Finds the range of values which compare equal to key. The first member of
+ // the returned pair is equal to lower_bound(key). The second member of the
+ // pair is equal to upper_bound(key).
+ template <typename K>
+ std::pair<iterator, iterator> equal_range(const K &key);
+ template <typename K>
+ std::pair<const_iterator, const_iterator> equal_range(const K &key) const {
+ return const_cast<btree *>(this)->equal_range(key);
+ }
+
+ // Inserts a value into the btree only if it does not already exist. The
+ // boolean return value indicates whether insertion succeeded or failed.
+ // Requirement: if `key` already exists in the btree, does not consume `args`.
+ // Requirement: `key` is never referenced after consuming `args`.
+ template <typename K, typename... Args>
+ std::pair<iterator, bool> insert_unique(const K &key, Args &&...args);
+
+ // Inserts with hint. Checks to see if the value should be placed immediately
+ // before `position` in the tree. If so, then the insertion will take
+ // amortized constant time. If not, the insertion will take amortized
+ // logarithmic time as if a call to insert_unique() were made.
+ // Requirement: if `key` already exists in the btree, does not consume `args`.
+ // Requirement: `key` is never referenced after consuming `args`.
+ template <typename K, typename... Args>
+ std::pair<iterator, bool> insert_hint_unique(iterator position, const K &key,
+ Args &&...args);
+
+ // Insert a range of values into the btree.
+ // Note: the first overload avoids constructing a value_type if the key
+ // already exists in the btree.
+ template <typename InputIterator,
+ typename = decltype(std::declval<const key_compare &>()(
+ params_type::key(*std::declval<InputIterator>()),
+ std::declval<const key_type &>()))>
+ void insert_iterator_unique(InputIterator b, InputIterator e, int);
+ // We need the second overload for cases in which we need to construct a
+ // value_type in order to compare it with the keys already in the btree.
+ template <typename InputIterator>
+ void insert_iterator_unique(InputIterator b, InputIterator e, char);
+
+ // Inserts a value into the btree.
+ template <typename ValueType>
+ iterator insert_multi(const key_type &key, ValueType &&v);
+
+ // Inserts a value into the btree.
+ template <typename ValueType>
+ iterator insert_multi(ValueType &&v) {
+ return insert_multi(params_type::key(v), std::forward<ValueType>(v));
+ }
+
+ // Insert with hint. Check to see if the value should be placed immediately
+ // before position in the tree. If it does, then the insertion will take
+ // amortized constant time. If not, the insertion will take amortized
+ // logarithmic time as if a call to insert_multi(v) were made.
+ template <typename ValueType>
+ iterator insert_hint_multi(iterator position, ValueType &&v);
+
+ // Insert a range of values into the btree.
+ template <typename InputIterator>
+ void insert_iterator_multi(InputIterator b,
+ InputIterator e);
+
+ // Erase the specified iterator from the btree. The iterator must be valid
+ // (i.e. not equal to end()). Return an iterator pointing to the node after
+ // the one that was erased (or end() if none exists).
+ // Requirement: does not read the value at `*iter`.
+ iterator erase(iterator iter);
+
+ // Erases range. Returns the number of keys erased and an iterator pointing
+ // to the element after the last erased element.
+ std::pair<size_type, iterator> erase_range(iterator begin, iterator end);
+
+ // Finds an element with key equivalent to `key` or returns `end()` if `key`
+ // is not present.
+ template <typename K>
+ iterator find(const K &key) {
+ return internal_end(internal_find(key));
+ }
+ template <typename K>
+ const_iterator find(const K &key) const {
+ return internal_end(internal_find(key));
+ }
+
+ // Clear the btree, deleting all of the values it contains.
+ void clear();
+
+ // Swaps the contents of `this` and `other`.
+ void swap(btree &other);
+
+ const key_compare &key_comp() const noexcept {
+ return rightmost_.template get<0>();
+ }
+ template <typename K1, typename K2>
+ bool compare_keys(const K1 &a, const K2 &b) const {
+ return compare_internal::compare_result_as_less_than(key_comp()(a, b));
+ }
+
+ value_compare value_comp() const {
+ return value_compare(original_key_compare(key_comp()));
+ }
+
+ // Verifies the structure of the btree.
+ void verify() const;
+
+ // Size routines.
+ size_type size() const { return size_; }
+ size_type max_size() const { return (std::numeric_limits<size_type>::max)(); }
+ bool empty() const { return size_ == 0; }
+
+ // The height of the btree. An empty tree will have height 0.
+ size_type height() const {
+ size_type h = 0;
+ if (!empty()) {
+ // Count the length of the chain from the leftmost node up to the
+ // root. We actually count from the root back around to the level below
+ // the root, but the calculation is the same because of the circularity
+ // of that traversal.
+ const node_type *n = root();
+ do {
+ ++h;
+ n = n->parent();
+ } while (n != root());
+ }
+ return h;
+ }
+
+ // The number of internal, leaf and total nodes used by the btree.
+ size_type leaf_nodes() const { return internal_stats(root()).leaf_nodes; }
+ size_type internal_nodes() const {
+ return internal_stats(root()).internal_nodes;
+ }
+ size_type nodes() const {
+ node_stats stats = internal_stats(root());
+ return stats.leaf_nodes + stats.internal_nodes;
+ }
+
+ // The total number of bytes used by the btree.
+ // TODO(b/169338300): update to support node_btree_*.
+ size_type bytes_used() const {
+ node_stats stats = internal_stats(root());
+ if (stats.leaf_nodes == 1 && stats.internal_nodes == 0) {
+ return sizeof(*this) + node_type::LeafSize(root()->max_count());
+ } else {
+ return sizeof(*this) + stats.leaf_nodes * node_type::LeafSize() +
+ stats.internal_nodes * node_type::InternalSize();
+ }
+ }
+
+ // The average number of bytes used per value stored in the btree assuming
+ // random insertion order.
+ static double average_bytes_per_value() {
+ // The expected number of values per node with random insertion order is the
+ // average of the maximum and minimum numbers of values per node.
+ const double expected_values_per_node = (kNodeSlots + kMinNodeValues) / 2.0;
+ return node_type::LeafSize() / expected_values_per_node;
+ }
+
+ // The fullness of the btree. Computed as the number of elements in the btree
+ // divided by the maximum number of elements a tree with the current number
+ // of nodes could hold. A value of 1 indicates perfect space
+ // utilization. Smaller values indicate space wastage.
+ // Returns 0 for empty trees.
+ double fullness() const {
+ if (empty()) return 0.0;
+ return static_cast<double>(size()) / (nodes() * kNodeSlots);
+ }
+ // The overhead of the btree structure in bytes per node. Computed as the
+ // total number of bytes used by the btree minus the number of bytes used for
+ // storing elements divided by the number of elements.
+ // Returns 0 for empty trees.
+ double overhead() const {
+ if (empty()) return 0.0;
+ return (bytes_used() - size() * sizeof(value_type)) /
+ static_cast<double>(size());
+ }
+
+ // The allocator used by the btree.
+ allocator_type get_allocator() const { return allocator(); }
+
+ private:
+ friend struct btree_access;
+
+ // Internal accessor routines.
+ node_type *root() { return root_; }
+ const node_type *root() const { return root_; }
+ node_type *&mutable_root() noexcept { return root_; }
+ node_type *rightmost() { return rightmost_.template get<2>(); }
+ const node_type *rightmost() const { return rightmost_.template get<2>(); }
+ node_type *&mutable_rightmost() noexcept {
+ return rightmost_.template get<2>();
+ }
+ key_compare *mutable_key_comp() noexcept {
+ return &rightmost_.template get<0>();
+ }
+
+ // The leftmost node is stored as the parent of the root node.
+ node_type *leftmost() { return root()->parent(); }
+ const node_type *leftmost() const { return root()->parent(); }
+
+ // Allocator routines.
+ allocator_type *mutable_allocator() noexcept {
+ return &rightmost_.template get<1>();
+ }
+ const allocator_type &allocator() const noexcept {
+ return rightmost_.template get<1>();
+ }
+
+ // Allocates a correctly aligned node of at least size bytes using the
+ // allocator.
+ node_type *allocate(size_type size) {
+ return reinterpret_cast<node_type *>(
+ y_absl::container_internal::Allocate<node_type::Alignment()>(
+ mutable_allocator(), size));
+ }
+
+ // Node creation/deletion routines.
+ node_type *new_internal_node(field_type position, node_type *parent) {
+ node_type *n = allocate(node_type::InternalSize());
+ n->init_internal(position, parent);
+ return n;
+ }
+ node_type *new_leaf_node(field_type position, node_type *parent) {
+ node_type *n = allocate(node_type::LeafSize());
+ n->init_leaf(position, kNodeSlots, parent);
+ return n;
+ }
+ node_type *new_leaf_root_node(field_type max_count) {
+ node_type *n = allocate(node_type::LeafSize(max_count));
+ n->init_leaf(/*position=*/0, max_count, /*parent=*/n);
+ return n;
+ }
+
+ // Deletion helper routines.
+ iterator rebalance_after_delete(iterator iter);
+
+ // Rebalances or splits the node iter points to.
+ void rebalance_or_split(iterator *iter);
+
+ // Merges the values of left, right and the delimiting key on their parent
+ // onto left, removing the delimiting key and deleting right.
+ void merge_nodes(node_type *left, node_type *right);
+
+ // Tries to merge node with its left or right sibling, and failing that,
+ // rebalance with its left or right sibling. Returns true if a merge
+ // occurred, at which point it is no longer valid to access node. Returns
+ // false if no merging took place.
+ bool try_merge_or_rebalance(iterator *iter);
+
+ // Tries to shrink the height of the tree by 1.
+ void try_shrink();
+
+ iterator internal_end(iterator iter) {
+ return iter.node_ != nullptr ? iter : end();
+ }
+ const_iterator internal_end(const_iterator iter) const {
+ return iter.node_ != nullptr ? iter : end();
+ }
+
+ // Emplaces a value into the btree immediately before iter. Requires that
+ // key(v) <= iter.key() and (--iter).key() <= key(v).
+ template <typename... Args>
+ iterator internal_emplace(iterator iter, Args &&...args);
+
+ // Returns an iterator pointing to the first value >= the value "iter" is
+ // pointing at. Note that "iter" might be pointing to an invalid location such
+ // as iter.position_ == iter.node_->finish(). This routine simply moves iter
+ // up in the tree to a valid location. Requires: iter.node_ is non-null.
+ template <typename IterType>
+ static IterType internal_last(IterType iter);
+
+ // Returns an iterator pointing to the leaf position at which key would
+ // reside in the tree, unless there is an exact match - in which case, the
+ // result may not be on a leaf. When there's a three-way comparator, we can
+ // return whether there was an exact match. This allows the caller to avoid a
+ // subsequent comparison to determine if an exact match was made, which is
+ // important for keys with expensive comparison, such as strings.
+ template <typename K>
+ SearchResult<iterator, is_key_compare_to::value> internal_locate(
+ const K &key) const;
+
+ // Internal routine which implements lower_bound().
+ template <typename K>
+ SearchResult<iterator, is_key_compare_to::value> internal_lower_bound(
+ const K &key) const;
+
+ // Internal routine which implements upper_bound().
+ template <typename K>
+ iterator internal_upper_bound(const K &key) const;
+
+ // Internal routine which implements find().
+ template <typename K>
+ iterator internal_find(const K &key) const;
+
+ // Verifies the tree structure of node.
+ size_type internal_verify(const node_type *node, const key_type *lo,
+ const key_type *hi) const;
+
+ node_stats internal_stats(const node_type *node) const {
+ // The root can be a static empty node.
+ if (node == nullptr || (node == root() && empty())) {
+ return node_stats(0, 0);
+ }
+ if (node->is_leaf()) {
+ return node_stats(1, 0);
+ }
+ node_stats res(0, 1);
+ for (int i = node->start(); i <= node->finish(); ++i) {
+ res += internal_stats(node->child(i));
+ }
+ return res;
+ }
+
+ node_type *root_;
+
+ // A pointer to the rightmost node. Note that the leftmost node is stored as
+ // the root's parent. We use compressed tuple in order to save space because
+ // key_compare and allocator_type are usually empty.
+ y_absl::container_internal::CompressedTuple<key_compare, allocator_type,
+ node_type *>
+ rightmost_;
+
+ // Number of values.
+ size_type size_;
+};
+
+////
+// btree_node methods
+template <typename P>
+template <typename... Args>
+inline void btree_node<P>::emplace_value(const field_type i,
+ allocator_type *alloc,
+ Args &&...args) {
+ assert(i >= start());
+ assert(i <= finish());
+ // Shift old values to create space for new value and then construct it in
+ // place.
+ if (i < finish()) {
+ transfer_n_backward(finish() - i, /*dest_i=*/i + 1, /*src_i=*/i, this,
+ alloc);
+ }
+ value_init(static_cast<field_type>(i), alloc, std::forward<Args>(args)...);
+ set_finish(finish() + 1);
+
+ if (is_internal() && finish() > i + 1) {
+ for (field_type j = finish(); j > i + 1; --j) {
+ set_child(j, child(j - 1));
+ }
+ clear_child(i + 1);
+ }
+}
+
+template <typename P>
+inline void btree_node<P>::remove_values(const field_type i,
+ const field_type to_erase,
+ allocator_type *alloc) {
+ // Transfer values after the removed range into their new places.
+ value_destroy_n(i, to_erase, alloc);
+ const field_type orig_finish = finish();
+ const field_type src_i = i + to_erase;
+ transfer_n(orig_finish - src_i, i, src_i, this, alloc);
+
+ if (is_internal()) {
+ // Delete all children between begin and end.
+ for (field_type j = 0; j < to_erase; ++j) {
+ clear_and_delete(child(i + j + 1), alloc);
+ }
+ // Rotate children after end into new positions.
+ for (field_type j = i + to_erase + 1; j <= orig_finish; ++j) {
+ set_child(j - to_erase, child(j));
+ clear_child(j);
+ }
+ }
+ set_finish(orig_finish - to_erase);
+}
+
+template <typename P>
+void btree_node<P>::rebalance_right_to_left(field_type to_move,
+ btree_node *right,
+ allocator_type *alloc) {
+ assert(parent() == right->parent());
+ assert(position() + 1 == right->position());
+ assert(right->count() >= count());
+ assert(to_move >= 1);
+ assert(to_move <= right->count());
+
+ // 1) Move the delimiting value in the parent to the left node.
+ transfer(finish(), position(), parent(), alloc);
+
+ // 2) Move the (to_move - 1) values from the right node to the left node.
+ transfer_n(to_move - 1, finish() + 1, right->start(), right, alloc);
+
+ // 3) Move the new delimiting value to the parent from the right node.
+ parent()->transfer(position(), right->start() + to_move - 1, right, alloc);
+
+ // 4) Shift the values in the right node to their correct positions.
+ right->transfer_n(right->count() - to_move, right->start(),
+ right->start() + to_move, right, alloc);
+
+ if (is_internal()) {
+ // Move the child pointers from the right to the left node.
+ for (field_type i = 0; i < to_move; ++i) {
+ init_child(finish() + i + 1, right->child(i));
+ }
+ for (field_type i = right->start(); i <= right->finish() - to_move; ++i) {
+ assert(i + to_move <= right->max_count());
+ right->init_child(i, right->child(i + to_move));
+ right->clear_child(i + to_move);
+ }
+ }
+
+ // Fixup `finish` on the left and right nodes.
+ set_finish(finish() + to_move);
+ right->set_finish(right->finish() - to_move);
+}
+
+template <typename P>
+void btree_node<P>::rebalance_left_to_right(field_type to_move,
+ btree_node *right,
+ allocator_type *alloc) {
+ assert(parent() == right->parent());
+ assert(position() + 1 == right->position());
+ assert(count() >= right->count());
+ assert(to_move >= 1);
+ assert(to_move <= count());
+
+ // Values in the right node are shifted to the right to make room for the
+ // new to_move values. Then, the delimiting value in the parent and the
+ // other (to_move - 1) values in the left node are moved into the right node.
+ // Lastly, a new delimiting value is moved from the left node into the
+ // parent, and the remaining empty left node entries are destroyed.
+
+ // 1) Shift existing values in the right node to their correct positions.
+ right->transfer_n_backward(right->count(), right->start() + to_move,
+ right->start(), right, alloc);
+
+ // 2) Move the delimiting value in the parent to the right node.
+ right->transfer(right->start() + to_move - 1, position(), parent(), alloc);
+
+ // 3) Move the (to_move - 1) values from the left node to the right node.
+ right->transfer_n(to_move - 1, right->start(), finish() - (to_move - 1), this,
+ alloc);
+
+ // 4) Move the new delimiting value to the parent from the left node.
+ parent()->transfer(position(), finish() - to_move, this, alloc);
+
+ if (is_internal()) {
+ // Move the child pointers from the left to the right node.
+ for (field_type i = right->finish() + 1; i > right->start(); --i) {
+ right->init_child(i - 1 + to_move, right->child(i - 1));
+ right->clear_child(i - 1);
+ }
+ for (field_type i = 1; i <= to_move; ++i) {
+ right->init_child(i - 1, child(finish() - to_move + i));
+ clear_child(finish() - to_move + i);
+ }
+ }
+
+ // Fixup the counts on the left and right nodes.
+ set_finish(finish() - to_move);
+ right->set_finish(right->finish() + to_move);
+}
+
+template <typename P>
+void btree_node<P>::split(const int insert_position, btree_node *dest,
+ allocator_type *alloc) {
+ assert(dest->count() == 0);
+ assert(max_count() == kNodeSlots);
+ assert(position() + 1 == dest->position());
+ assert(parent() == dest->parent());
+
+ // We bias the split based on the position being inserted. If we're
+ // inserting at the beginning of the left node then bias the split to put
+ // more values on the right node. If we're inserting at the end of the
+ // right node then bias the split to put more values on the left node.
+ if (insert_position == start()) {
+ dest->set_finish(dest->start() + finish() - 1);
+ } else if (insert_position == kNodeSlots) {
+ dest->set_finish(dest->start());
+ } else {
+ dest->set_finish(dest->start() + count() / 2);
+ }
+ set_finish(finish() - dest->count());
+ assert(count() >= 1);
+
+ // Move values from the left sibling to the right sibling.
+ dest->transfer_n(dest->count(), dest->start(), finish(), this, alloc);
+
+ // The split key is the largest value in the left sibling.
+ --mutable_finish();
+ parent()->emplace_value(position(), alloc, finish_slot());
+ value_destroy(finish(), alloc);
+ parent()->set_child_noupdate_position(position() + 1, dest);
+
+ if (is_internal()) {
+ for (field_type i = dest->start(), j = finish() + 1; i <= dest->finish();
+ ++i, ++j) {
+ assert(child(j) != nullptr);
+ dest->init_child(i, child(j));
+ clear_child(j);
+ }
+ }
+}
+
+template <typename P>
+void btree_node<P>::merge(btree_node *src, allocator_type *alloc) {
+ assert(parent() == src->parent());
+ assert(position() + 1 == src->position());
+
+ // Move the delimiting value to the left node.
+ value_init(finish(), alloc, parent()->slot(position()));
+
+ // Move the values from the right to the left node.
+ transfer_n(src->count(), finish() + 1, src->start(), src, alloc);
+
+ if (is_internal()) {
+ // Move the child pointers from the right to the left node.
+ for (field_type i = src->start(), j = finish() + 1; i <= src->finish();
+ ++i, ++j) {
+ init_child(j, src->child(i));
+ src->clear_child(i);
+ }
+ }
+
+ // Fixup `finish` on the src and dest nodes.
+ set_finish(start() + 1 + count() + src->count());
+ src->set_finish(src->start());
+
+ // Remove the value on the parent node and delete the src node.
+ parent()->remove_values(position(), /*to_erase=*/1, alloc);
+}
+
+template <typename P>
+void btree_node<P>::clear_and_delete(btree_node *node, allocator_type *alloc) {
+ if (node->is_leaf()) {
+ node->value_destroy_n(node->start(), node->count(), alloc);
+ deallocate(LeafSize(node->max_count()), node, alloc);
+ return;
+ }
+ if (node->count() == 0) {
+ deallocate(InternalSize(), node, alloc);
+ return;
+ }
+
+ // The parent of the root of the subtree we are deleting.
+ btree_node *delete_root_parent = node->parent();
+
+ // Navigate to the leftmost leaf under node, and then delete upwards.
+ while (node->is_internal()) node = node->start_child();
+#ifdef Y_ABSL_BTREE_ENABLE_GENERATIONS
+ // When generations are enabled, we delete the leftmost leaf last in case it's
+ // the parent of the root and we need to check whether it's a leaf before we
+ // can update the root's generation.
+ // TODO(ezb): if we change btree_node::is_root to check a bool inside the node
+ // instead of checking whether the parent is a leaf, we can remove this logic.
+ btree_node *leftmost_leaf = node;
+#endif
+ // Use `size_type` because `pos` needs to be able to hold `kNodeSlots+1`,
+ // which isn't guaranteed to be a valid `field_type`.
+ size_type pos = node->position();
+ btree_node *parent = node->parent();
+ for (;;) {
+ // In each iteration of the next loop, we delete one leaf node and go right.
+ assert(pos <= parent->finish());
+ do {
+ node = parent->child(static_cast<field_type>(pos));
+ if (node->is_internal()) {
+ // Navigate to the leftmost leaf under node.
+ while (node->is_internal()) node = node->start_child();
+ pos = node->position();
+ parent = node->parent();
+ }
+ node->value_destroy_n(node->start(), node->count(), alloc);
+#ifdef Y_ABSL_BTREE_ENABLE_GENERATIONS
+ if (leftmost_leaf != node)
+#endif
+ deallocate(LeafSize(node->max_count()), node, alloc);
+ ++pos;
+ } while (pos <= parent->finish());
+
+ // Once we've deleted all children of parent, delete parent and go up/right.
+ assert(pos > parent->finish());
+ do {
+ node = parent;
+ pos = node->position();
+ parent = node->parent();
+ node->value_destroy_n(node->start(), node->count(), alloc);
+ deallocate(InternalSize(), node, alloc);
+ if (parent == delete_root_parent) {
+#ifdef Y_ABSL_BTREE_ENABLE_GENERATIONS
+ deallocate(LeafSize(leftmost_leaf->max_count()), leftmost_leaf, alloc);
+#endif
+ return;
+ }
+ ++pos;
+ } while (pos > parent->finish());
+ }
+}
+
+////
+// btree_iterator methods
+
+// Note: the implementation here is based on btree_node::clear_and_delete.
+template <typename N, typename R, typename P>
+auto btree_iterator<N, R, P>::distance_slow(const_iterator other) const
+ -> difference_type {
+ const_iterator begin = other;
+ const_iterator end = *this;
+ assert(begin.node_ != end.node_ || !begin.node_->is_leaf() ||
+ begin.position_ != end.position_);
+
+ const node_type *node = begin.node_;
+ // We need to compensate for double counting if begin.node_ is a leaf node.
+ difference_type count = node->is_leaf() ? -begin.position_ : 0;
+
+ // First navigate to the leftmost leaf node past begin.
+ if (node->is_internal()) {
+ ++count;
+ node = node->child(begin.position_ + 1);
+ }
+ while (node->is_internal()) node = node->start_child();
+
+ // Use `size_type` because `pos` needs to be able to hold `kNodeSlots+1`,
+ // which isn't guaranteed to be a valid `field_type`.
+ size_type pos = node->position();
+ const node_type *parent = node->parent();
+ for (;;) {
+ // In each iteration of the next loop, we count one leaf node and go right.
+ assert(pos <= parent->finish());
+ do {
+ node = parent->child(static_cast<field_type>(pos));
+ if (node->is_internal()) {
+ // Navigate to the leftmost leaf under node.
+ while (node->is_internal()) node = node->start_child();
+ pos = node->position();
+ parent = node->parent();
+ }
+ if (node == end.node_) return count + end.position_;
+ if (parent == end.node_ && pos == static_cast<size_type>(end.position_))
+ return count + node->count();
+ // +1 is for the next internal node value.
+ count += node->count() + 1;
+ ++pos;
+ } while (pos <= parent->finish());
+
+ // Once we've counted all children of parent, go up/right.
+ assert(pos > parent->finish());
+ do {
+ node = parent;
+ pos = node->position();
+ parent = node->parent();
+ // -1 because we counted the value at end and shouldn't.
+ if (parent == end.node_ && pos == static_cast<size_type>(end.position_))
+ return count - 1;
+ ++pos;
+ } while (pos > parent->finish());
+ }
+}
+
+template <typename N, typename R, typename P>
+void btree_iterator<N, R, P>::increment_slow() {
+ if (node_->is_leaf()) {
+ assert(position_ >= node_->finish());
+ btree_iterator save(*this);
+ while (position_ == node_->finish() && !node_->is_root()) {
+ assert(node_->parent()->child(node_->position()) == node_);
+ position_ = node_->position();
+ node_ = node_->parent();
+ }
+ // TODO(ezb): assert we aren't incrementing end() instead of handling.
+ if (position_ == node_->finish()) {
+ *this = save;
+ }
+ } else {
+ assert(position_ < node_->finish());
+ node_ = node_->child(static_cast<field_type>(position_ + 1));
+ while (node_->is_internal()) {
+ node_ = node_->start_child();
+ }
+ position_ = node_->start();
+ }
+}
+
+template <typename N, typename R, typename P>
+void btree_iterator<N, R, P>::decrement_slow() {
+ if (node_->is_leaf()) {
+ assert(position_ <= -1);
+ btree_iterator save(*this);
+ while (position_ < node_->start() && !node_->is_root()) {
+ assert(node_->parent()->child(node_->position()) == node_);
+ position_ = node_->position() - 1;
+ node_ = node_->parent();
+ }
+ // TODO(ezb): assert we aren't decrementing begin() instead of handling.
+ if (position_ < node_->start()) {
+ *this = save;
+ }
+ } else {
+ assert(position_ >= node_->start());
+ node_ = node_->child(static_cast<field_type>(position_));
+ while (node_->is_internal()) {
+ node_ = node_->child(node_->finish());
+ }
+ position_ = node_->finish() - 1;
+ }
+}
+
+////
+// btree methods
+template <typename P>
+template <typename Btree>
+void btree<P>::copy_or_move_values_in_order(Btree &other) {
+ static_assert(std::is_same<btree, Btree>::value ||
+ std::is_same<const btree, Btree>::value,
+ "Btree type must be same or const.");
+ assert(empty());
+
+ // We can avoid key comparisons because we know the order of the
+ // values is the same order we'll store them in.
+ auto iter = other.begin();
+ if (iter == other.end()) return;
+ insert_multi(iter.slot());
+ ++iter;
+ for (; iter != other.end(); ++iter) {
+ // If the btree is not empty, we can just insert the new value at the end
+ // of the tree.
+ internal_emplace(end(), iter.slot());
+ }
+}
+
+template <typename P>
+constexpr bool btree<P>::static_assert_validation() {
+ static_assert(std::is_nothrow_copy_constructible<key_compare>::value,
+ "Key comparison must be nothrow copy constructible");
+ static_assert(std::is_nothrow_copy_constructible<allocator_type>::value,
+ "Allocator must be nothrow copy constructible");
+ static_assert(std::is_trivially_copyable<iterator>::value,
+ "iterator not trivially copyable.");
+
+ // Note: We assert that kTargetValues, which is computed from
+ // Params::kTargetNodeSize, must fit the node_type::field_type.
+ static_assert(
+ kNodeSlots < (1 << (8 * sizeof(typename node_type::field_type))),
+ "target node size too large");
+
+ // Verify that key_compare returns an y_absl::{weak,strong}_ordering or bool.
+ static_assert(
+ compare_has_valid_result_type<key_compare, key_type>(),
+ "key comparison function must return y_absl::{weak,strong}_ordering or "
+ "bool.");
+
+ // Test the assumption made in setting kNodeSlotSpace.
+ static_assert(node_type::MinimumOverhead() >= sizeof(void *) + 4,
+ "node space assumption incorrect");
+
+ return true;
+}
+
+template <typename P>
+template <typename K>
+auto btree<P>::lower_bound_equal(const K &key) const
+ -> std::pair<iterator, bool> {
+ const SearchResult<iterator, is_key_compare_to::value> res =
+ internal_lower_bound(key);
+ const iterator lower = iterator(internal_end(res.value));
+ const bool equal = res.HasMatch()
+ ? res.IsEq()
+ : lower != end() && !compare_keys(key, lower.key());
+ return {lower, equal};
+}
+
+template <typename P>
+template <typename K>
+auto btree<P>::equal_range(const K &key) -> std::pair<iterator, iterator> {
+ const std::pair<iterator, bool> lower_and_equal = lower_bound_equal(key);
+ const iterator lower = lower_and_equal.first;
+ if (!lower_and_equal.second) {
+ return {lower, lower};
+ }
+
+ const iterator next = std::next(lower);
+ if (!params_type::template can_have_multiple_equivalent_keys<K>()) {
+ // The next iterator after lower must point to a key greater than `key`.
+ // Note: if this assert fails, then it may indicate that the comparator does
+ // not meet the equivalence requirements for Compare
+ // (see https://en.cppreference.com/w/cpp/named_req/Compare).
+ assert(next == end() || compare_keys(key, next.key()));
+ return {lower, next};
+ }
+ // Try once more to avoid the call to upper_bound() if there's only one
+ // equivalent key. This should prevent all calls to upper_bound() in cases of
+ // unique-containers with heterogeneous comparators in which all comparison
+ // operators have the same equivalence classes.
+ if (next == end() || compare_keys(key, next.key())) return {lower, next};
+
+ // In this case, we need to call upper_bound() to avoid worst case O(N)
+ // behavior if we were to iterate over equal keys.
+ return {lower, upper_bound(key)};
+}
+
+template <typename P>
+template <typename K, typename... Args>
+auto btree<P>::insert_unique(const K &key, Args &&...args)
+ -> std::pair<iterator, bool> {
+ if (empty()) {
+ mutable_root() = mutable_rightmost() = new_leaf_root_node(1);
+ }
+
+ SearchResult<iterator, is_key_compare_to::value> res = internal_locate(key);
+ iterator iter = res.value;
+
+ if (res.HasMatch()) {
+ if (res.IsEq()) {
+ // The key already exists in the tree, do nothing.
+ return {iter, false};
+ }
+ } else {
+ iterator last = internal_last(iter);
+ if (last.node_ && !compare_keys(key, last.key())) {
+ // The key already exists in the tree, do nothing.
+ return {last, false};
+ }
+ }
+ return {internal_emplace(iter, std::forward<Args>(args)...), true};
+}
+
+template <typename P>
+template <typename K, typename... Args>
+inline auto btree<P>::insert_hint_unique(iterator position, const K &key,
+ Args &&...args)
+ -> std::pair<iterator, bool> {
+ if (!empty()) {
+ if (position == end() || compare_keys(key, position.key())) {
+ if (position == begin() || compare_keys(std::prev(position).key(), key)) {
+ // prev.key() < key < position.key()
+ return {internal_emplace(position, std::forward<Args>(args)...), true};
+ }
+ } else if (compare_keys(position.key(), key)) {
+ ++position;
+ if (position == end() || compare_keys(key, position.key())) {
+ // {original `position`}.key() < key < {current `position`}.key()
+ return {internal_emplace(position, std::forward<Args>(args)...), true};
+ }
+ } else {
+ // position.key() == key
+ return {position, false};
+ }
+ }
+ return insert_unique(key, std::forward<Args>(args)...);
+}
+
+template <typename P>
+template <typename InputIterator, typename>
+void btree<P>::insert_iterator_unique(InputIterator b, InputIterator e, int) {
+ for (; b != e; ++b) {
+ insert_hint_unique(end(), params_type::key(*b), *b);
+ }
+}
+
+template <typename P>
+template <typename InputIterator>
+void btree<P>::insert_iterator_unique(InputIterator b, InputIterator e, char) {
+ for (; b != e; ++b) {
+ // Use a node handle to manage a temp slot.
+ auto node_handle =
+ CommonAccess::Construct<node_handle_type>(get_allocator(), *b);
+ slot_type *slot = CommonAccess::GetSlot(node_handle);
+ insert_hint_unique(end(), params_type::key(slot), slot);
+ }
+}
+
+template <typename P>
+template <typename ValueType>
+auto btree<P>::insert_multi(const key_type &key, ValueType &&v) -> iterator {
+ if (empty()) {
+ mutable_root() = mutable_rightmost() = new_leaf_root_node(1);
+ }
+
+ iterator iter = internal_upper_bound(key);
+ if (iter.node_ == nullptr) {
+ iter = end();
+ }
+ return internal_emplace(iter, std::forward<ValueType>(v));
+}
+
+template <typename P>
+template <typename ValueType>
+auto btree<P>::insert_hint_multi(iterator position, ValueType &&v) -> iterator {
+ if (!empty()) {
+ const key_type &key = params_type::key(v);
+ if (position == end() || !compare_keys(position.key(), key)) {
+ if (position == begin() ||
+ !compare_keys(key, std::prev(position).key())) {
+ // prev.key() <= key <= position.key()
+ return internal_emplace(position, std::forward<ValueType>(v));
+ }
+ } else {
+ ++position;
+ if (position == end() || !compare_keys(position.key(), key)) {
+ // {original `position`}.key() < key < {current `position`}.key()
+ return internal_emplace(position, std::forward<ValueType>(v));
+ }
+ }
+ }
+ return insert_multi(std::forward<ValueType>(v));
+}
+
+template <typename P>
+template <typename InputIterator>
+void btree<P>::insert_iterator_multi(InputIterator b, InputIterator e) {
+ for (; b != e; ++b) {
+ insert_hint_multi(end(), *b);
+ }
+}
+
+template <typename P>
+auto btree<P>::operator=(const btree &other) -> btree & {
+ if (this != &other) {
+ clear();
+
+ *mutable_key_comp() = other.key_comp();
+ if (y_absl::allocator_traits<
+ allocator_type>::propagate_on_container_copy_assignment::value) {
+ *mutable_allocator() = other.allocator();
+ }
+
+ copy_or_move_values_in_order(other);
+ }
+ return *this;
+}
+
+template <typename P>
+auto btree<P>::operator=(btree &&other) noexcept -> btree & {
+ if (this != &other) {
+ clear();
+
+ using std::swap;
+ if (y_absl::allocator_traits<
+ allocator_type>::propagate_on_container_move_assignment::value) {
+ swap(root_, other.root_);
+ // Note: `rightmost_` also contains the allocator and the key comparator.
+ swap(rightmost_, other.rightmost_);
+ swap(size_, other.size_);
+ } else {
+ if (allocator() == other.allocator()) {
+ swap(mutable_root(), other.mutable_root());
+ swap(*mutable_key_comp(), *other.mutable_key_comp());
+ swap(mutable_rightmost(), other.mutable_rightmost());
+ swap(size_, other.size_);
+ } else {
+ // We aren't allowed to propagate the allocator and the allocator is
+ // different so we can't take over its memory. We must move each element
+ // individually. We need both `other` and `this` to have `other`s key
+ // comparator while moving the values so we can't swap the key
+ // comparators.
+ *mutable_key_comp() = other.key_comp();
+ copy_or_move_values_in_order(other);
+ }
+ }
+ }
+ return *this;
+}
+
+template <typename P>
+auto btree<P>::erase(iterator iter) -> iterator {
+ iter.node_->value_destroy(static_cast<field_type>(iter.position_),
+ mutable_allocator());
+ iter.update_generation();
+
+ const bool internal_delete = iter.node_->is_internal();
+ if (internal_delete) {
+ // Deletion of a value on an internal node. First, transfer the largest
+ // value from our left child here, then erase/rebalance from that position.
+ // We can get to the largest value from our left child by decrementing iter.
+ iterator internal_iter(iter);
+ --iter;
+ assert(iter.node_->is_leaf());
+ internal_iter.node_->transfer(
+ static_cast<size_type>(internal_iter.position_),
+ static_cast<size_type>(iter.position_), iter.node_,
+ mutable_allocator());
+ } else {
+ // Shift values after erased position in leaf. In the internal case, we
+ // don't need to do this because the leaf position is the end of the node.
+ const field_type transfer_from =
+ static_cast<field_type>(iter.position_ + 1);
+ const field_type num_to_transfer = iter.node_->finish() - transfer_from;
+ iter.node_->transfer_n(num_to_transfer,
+ static_cast<size_type>(iter.position_),
+ transfer_from, iter.node_, mutable_allocator());
+ }
+ // Update node finish and container size.
+ iter.node_->set_finish(iter.node_->finish() - 1);
+ --size_;
+
+ // We want to return the next value after the one we just erased. If we
+ // erased from an internal node (internal_delete == true), then the next
+ // value is ++(++iter). If we erased from a leaf node (internal_delete ==
+ // false) then the next value is ++iter. Note that ++iter may point to an
+ // internal node and the value in the internal node may move to a leaf node
+ // (iter.node_) when rebalancing is performed at the leaf level.
+
+ iterator res = rebalance_after_delete(iter);
+
+ // If we erased from an internal node, advance the iterator.
+ if (internal_delete) {
+ ++res;
+ }
+ return res;
+}
+
+template <typename P>
+auto btree<P>::rebalance_after_delete(iterator iter) -> iterator {
+ // Merge/rebalance as we walk back up the tree.
+ iterator res(iter);
+ bool first_iteration = true;
+ for (;;) {
+ if (iter.node_ == root()) {
+ try_shrink();
+ if (empty()) {
+ return end();
+ }
+ break;
+ }
+ if (iter.node_->count() >= kMinNodeValues) {
+ break;
+ }
+ bool merged = try_merge_or_rebalance(&iter);
+ // On the first iteration, we should update `res` with `iter` because `res`
+ // may have been invalidated.
+ if (first_iteration) {
+ res = iter;
+ first_iteration = false;
+ }
+ if (!merged) {
+ break;
+ }
+ iter.position_ = iter.node_->position();
+ iter.node_ = iter.node_->parent();
+ }
+ res.update_generation();
+
+ // Adjust our return value. If we're pointing at the end of a node, advance
+ // the iterator.
+ if (res.position_ == res.node_->finish()) {
+ res.position_ = res.node_->finish() - 1;
+ ++res;
+ }
+
+ return res;
+}
+
+// Note: we tried implementing this more efficiently by erasing all of the
+// elements in [begin, end) at once and then doing rebalancing once at the end
+// (rather than interleaving deletion and rebalancing), but that adds a lot of
+// complexity, which seems to outweigh the performance win.
+template <typename P>
+auto btree<P>::erase_range(iterator begin, iterator end)
+ -> std::pair<size_type, iterator> {
+ size_type count = static_cast<size_type>(end - begin);
+ assert(count >= 0);
+
+ if (count == 0) {
+ return {0, begin};
+ }
+
+ if (static_cast<size_type>(count) == size_) {
+ clear();
+ return {count, this->end()};
+ }
+
+ if (begin.node_ == end.node_) {
+ assert(end.position_ > begin.position_);
+ begin.node_->remove_values(
+ static_cast<field_type>(begin.position_),
+ static_cast<field_type>(end.position_ - begin.position_),
+ mutable_allocator());
+ size_ -= count;
+ return {count, rebalance_after_delete(begin)};
+ }
+
+ const size_type target_size = size_ - count;
+ while (size_ > target_size) {
+ if (begin.node_->is_leaf()) {
+ const size_type remaining_to_erase = size_ - target_size;
+ const size_type remaining_in_node =
+ static_cast<size_type>(begin.node_->finish() - begin.position_);
+ const field_type to_erase = static_cast<field_type>(
+ (std::min)(remaining_to_erase, remaining_in_node));
+ begin.node_->remove_values(static_cast<field_type>(begin.position_),
+ to_erase, mutable_allocator());
+ size_ -= to_erase;
+ begin = rebalance_after_delete(begin);
+ } else {
+ begin = erase(begin);
+ }
+ }
+ begin.update_generation();
+ return {count, begin};
+}
+
+template <typename P>
+void btree<P>::clear() {
+ if (!empty()) {
+ node_type::clear_and_delete(root(), mutable_allocator());
+ }
+ mutable_root() = mutable_rightmost() = EmptyNode();
+ size_ = 0;
+}
+
+template <typename P>
+void btree<P>::swap(btree &other) {
+ using std::swap;
+ if (y_absl::allocator_traits<
+ allocator_type>::propagate_on_container_swap::value) {
+ // Note: `rightmost_` also contains the allocator and the key comparator.
+ swap(rightmost_, other.rightmost_);
+ } else {
+ // It's undefined behavior if the allocators are unequal here.
+ assert(allocator() == other.allocator());
+ swap(mutable_rightmost(), other.mutable_rightmost());
+ swap(*mutable_key_comp(), *other.mutable_key_comp());
+ }
+ swap(mutable_root(), other.mutable_root());
+ swap(size_, other.size_);
+}
+
+template <typename P>
+void btree<P>::verify() const {
+ assert(root() != nullptr);
+ assert(leftmost() != nullptr);
+ assert(rightmost() != nullptr);
+ assert(empty() || size() == internal_verify(root(), nullptr, nullptr));
+ assert(leftmost() == (++const_iterator(root(), -1)).node_);
+ assert(rightmost() == (--const_iterator(root(), root()->finish())).node_);
+ assert(leftmost()->is_leaf());
+ assert(rightmost()->is_leaf());
+}
+
+template <typename P>
+void btree<P>::rebalance_or_split(iterator *iter) {
+ node_type *&node = iter->node_;
+ int &insert_position = iter->position_;
+ assert(node->count() == node->max_count());
+ assert(kNodeSlots == node->max_count());
+
+ // First try to make room on the node by rebalancing.
+ node_type *parent = node->parent();
+ if (node != root()) {
+ if (node->position() > parent->start()) {
+ // Try rebalancing with our left sibling.
+ node_type *left = parent->child(node->position() - 1);
+ assert(left->max_count() == kNodeSlots);
+ if (left->count() < kNodeSlots) {
+ // We bias rebalancing based on the position being inserted. If we're
+ // inserting at the end of the right node then we bias rebalancing to
+ // fill up the left node.
+ field_type to_move =
+ (kNodeSlots - left->count()) /
+ (1 + (static_cast<field_type>(insert_position) < kNodeSlots));
+ to_move = (std::max)(field_type{1}, to_move);
+
+ if (static_cast<field_type>(insert_position) - to_move >=
+ node->start() ||
+ left->count() + to_move < kNodeSlots) {
+ left->rebalance_right_to_left(to_move, node, mutable_allocator());
+
+ assert(node->max_count() - node->count() == to_move);
+ insert_position = static_cast<int>(
+ static_cast<field_type>(insert_position) - to_move);
+ if (insert_position < node->start()) {
+ insert_position = insert_position + left->count() + 1;
+ node = left;
+ }
+
+ assert(node->count() < node->max_count());
+ return;
+ }
+ }
+ }
+
+ if (node->position() < parent->finish()) {
+ // Try rebalancing with our right sibling.
+ node_type *right = parent->child(node->position() + 1);
+ assert(right->max_count() == kNodeSlots);
+ if (right->count() < kNodeSlots) {
+ // We bias rebalancing based on the position being inserted. If we're
+ // inserting at the beginning of the left node then we bias rebalancing
+ // to fill up the right node.
+ field_type to_move = (kNodeSlots - right->count()) /
+ (1 + (insert_position > node->start()));
+ to_move = (std::max)(field_type{1}, to_move);
+
+ if (static_cast<field_type>(insert_position) <=
+ node->finish() - to_move ||
+ right->count() + to_move < kNodeSlots) {
+ node->rebalance_left_to_right(to_move, right, mutable_allocator());
+
+ if (insert_position > node->finish()) {
+ insert_position = insert_position - node->count() - 1;
+ node = right;
+ }
+
+ assert(node->count() < node->max_count());
+ return;
+ }
+ }
+ }
+
+ // Rebalancing failed, make sure there is room on the parent node for a new
+ // value.
+ assert(parent->max_count() == kNodeSlots);
+ if (parent->count() == kNodeSlots) {
+ iterator parent_iter(parent, node->position());
+ rebalance_or_split(&parent_iter);
+ parent = node->parent();
+ }
+ } else {
+ // Rebalancing not possible because this is the root node.
+ // Create a new root node and set the current root node as the child of the
+ // new root.
+ parent = new_internal_node(/*position=*/0, parent);
+ parent->set_generation(root()->generation());
+ parent->init_child(parent->start(), node);
+ mutable_root() = parent;
+ // If the former root was a leaf node, then it's now the rightmost node.
+ assert(parent->start_child()->is_internal() ||
+ parent->start_child() == rightmost());
+ }
+
+ // Split the node.
+ node_type *split_node;
+ if (node->is_leaf()) {
+ split_node = new_leaf_node(node->position() + 1, parent);
+ node->split(insert_position, split_node, mutable_allocator());
+ if (rightmost() == node) mutable_rightmost() = split_node;
+ } else {
+ split_node = new_internal_node(node->position() + 1, parent);
+ node->split(insert_position, split_node, mutable_allocator());
+ }
+
+ if (insert_position > node->finish()) {
+ insert_position = insert_position - node->count() - 1;
+ node = split_node;
+ }
+}
+
+template <typename P>
+void btree<P>::merge_nodes(node_type *left, node_type *right) {
+ left->merge(right, mutable_allocator());
+ if (rightmost() == right) mutable_rightmost() = left;
+}
+
+template <typename P>
+bool btree<P>::try_merge_or_rebalance(iterator *iter) {
+ node_type *parent = iter->node_->parent();
+ if (iter->node_->position() > parent->start()) {
+ // Try merging with our left sibling.
+ node_type *left = parent->child(iter->node_->position() - 1);
+ assert(left->max_count() == kNodeSlots);
+ if (1U + left->count() + iter->node_->count() <= kNodeSlots) {
+ iter->position_ += 1 + left->count();
+ merge_nodes(left, iter->node_);
+ iter->node_ = left;
+ return true;
+ }
+ }
+ if (iter->node_->position() < parent->finish()) {
+ // Try merging with our right sibling.
+ node_type *right = parent->child(iter->node_->position() + 1);
+ assert(right->max_count() == kNodeSlots);
+ if (1U + iter->node_->count() + right->count() <= kNodeSlots) {
+ merge_nodes(iter->node_, right);
+ return true;
+ }
+ // Try rebalancing with our right sibling. We don't perform rebalancing if
+ // we deleted the first element from iter->node_ and the node is not
+ // empty. This is a small optimization for the common pattern of deleting
+ // from the front of the tree.
+ if (right->count() > kMinNodeValues &&
+ (iter->node_->count() == 0 || iter->position_ > iter->node_->start())) {
+ field_type to_move = (right->count() - iter->node_->count()) / 2;
+ to_move =
+ (std::min)(to_move, static_cast<field_type>(right->count() - 1));
+ iter->node_->rebalance_right_to_left(to_move, right, mutable_allocator());
+ return false;
+ }
+ }
+ if (iter->node_->position() > parent->start()) {
+ // Try rebalancing with our left sibling. We don't perform rebalancing if
+ // we deleted the last element from iter->node_ and the node is not
+ // empty. This is a small optimization for the common pattern of deleting
+ // from the back of the tree.
+ node_type *left = parent->child(iter->node_->position() - 1);
+ if (left->count() > kMinNodeValues &&
+ (iter->node_->count() == 0 ||
+ iter->position_ < iter->node_->finish())) {
+ field_type to_move = (left->count() - iter->node_->count()) / 2;
+ to_move = (std::min)(to_move, static_cast<field_type>(left->count() - 1));
+ left->rebalance_left_to_right(to_move, iter->node_, mutable_allocator());
+ iter->position_ += to_move;
+ return false;
+ }
+ }
+ return false;
+}
+
+template <typename P>
+void btree<P>::try_shrink() {
+ node_type *orig_root = root();
+ if (orig_root->count() > 0) {
+ return;
+ }
+ // Deleted the last item on the root node, shrink the height of the tree.
+ if (orig_root->is_leaf()) {
+ assert(size() == 0);
+ mutable_root() = mutable_rightmost() = EmptyNode();
+ } else {
+ node_type *child = orig_root->start_child();
+ child->make_root();
+ mutable_root() = child;
+ }
+ node_type::clear_and_delete(orig_root, mutable_allocator());
+}
+
+template <typename P>
+template <typename IterType>
+inline IterType btree<P>::internal_last(IterType iter) {
+ assert(iter.node_ != nullptr);
+ while (iter.position_ == iter.node_->finish()) {
+ iter.position_ = iter.node_->position();
+ iter.node_ = iter.node_->parent();
+ if (iter.node_->is_leaf()) {
+ iter.node_ = nullptr;
+ break;
+ }
+ }
+ iter.update_generation();
+ return iter;
+}
+
+template <typename P>
+template <typename... Args>
+inline auto btree<P>::internal_emplace(iterator iter, Args &&...args)
+ -> iterator {
+ if (iter.node_->is_internal()) {
+ // We can't insert on an internal node. Instead, we'll insert after the
+ // previous value which is guaranteed to be on a leaf node.
+ --iter;
+ ++iter.position_;
+ }
+ const field_type max_count = iter.node_->max_count();
+ allocator_type *alloc = mutable_allocator();
+
+ const auto transfer_and_delete = [&](node_type *old_node,
+ node_type *new_node) {
+ new_node->transfer_n(old_node->count(), new_node->start(),
+ old_node->start(), old_node, alloc);
+ new_node->set_finish(old_node->finish());
+ old_node->set_finish(old_node->start());
+ new_node->set_generation(old_node->generation());
+ node_type::clear_and_delete(old_node, alloc);
+ };
+ const auto replace_leaf_root_node = [&](field_type new_node_size) {
+ assert(iter.node_ == root());
+ node_type *old_root = iter.node_;
+ node_type *new_root = iter.node_ = new_leaf_root_node(new_node_size);
+ transfer_and_delete(old_root, new_root);
+ mutable_root() = mutable_rightmost() = new_root;
+ };
+
+ bool replaced_node = false;
+ if (iter.node_->count() == max_count) {
+ // Make room in the leaf for the new item.
+ if (max_count < kNodeSlots) {
+ // Insertion into the root where the root is smaller than the full node
+ // size. Simply grow the size of the root node.
+ replace_leaf_root_node(static_cast<field_type>(
+ (std::min)(static_cast<int>(kNodeSlots), 2 * max_count)));
+ replaced_node = true;
+ } else {
+ rebalance_or_split(&iter);
+ }
+ }
+ (void)replaced_node;
+#if defined(Y_ABSL_HAVE_ADDRESS_SANITIZER) || \
+ defined(Y_ABSL_HAVE_HWADDRESS_SANITIZER)
+ if (!replaced_node) {
+ assert(iter.node_->is_leaf());
+ if (iter.node_->is_root()) {
+ replace_leaf_root_node(max_count);
+ } else {
+ node_type *old_node = iter.node_;
+ const bool was_rightmost = rightmost() == old_node;
+ const bool was_leftmost = leftmost() == old_node;
+ node_type *parent = old_node->parent();
+ const field_type position = old_node->position();
+ node_type *new_node = iter.node_ = new_leaf_node(position, parent);
+ parent->set_child_noupdate_position(position, new_node);
+ transfer_and_delete(old_node, new_node);
+ if (was_rightmost) mutable_rightmost() = new_node;
+ // The leftmost node is stored as the parent of the root node.
+ if (was_leftmost) root()->set_parent(new_node);
+ }
+ }
+#endif
+ iter.node_->emplace_value(static_cast<field_type>(iter.position_), alloc,
+ std::forward<Args>(args)...);
+ assert(
+ iter.node_->is_ordered_correctly(static_cast<field_type>(iter.position_),
+ original_key_compare(key_comp())) &&
+ "If this assert fails, then either (1) the comparator may violate "
+ "transitivity, i.e. comp(a,b) && comp(b,c) -> comp(a,c) (see "
+ "https://en.cppreference.com/w/cpp/named_req/Compare), or (2) a "
+ "key may have been mutated after it was inserted into the tree.");
+ ++size_;
+ iter.update_generation();
+ return iter;
+}
+
+template <typename P>
+template <typename K>
+inline auto btree<P>::internal_locate(const K &key) const
+ -> SearchResult<iterator, is_key_compare_to::value> {
+ iterator iter(const_cast<node_type *>(root()));
+ for (;;) {
+ SearchResult<size_type, is_key_compare_to::value> res =
+ iter.node_->lower_bound(key, key_comp());
+ iter.position_ = static_cast<int>(res.value);
+ if (res.IsEq()) {
+ return {iter, MatchKind::kEq};
+ }
+ // Note: in the non-key-compare-to case, we don't need to walk all the way
+ // down the tree if the keys are equal, but determining equality would
+ // require doing an extra comparison on each node on the way down, and we
+ // will need to go all the way to the leaf node in the expected case.
+ if (iter.node_->is_leaf()) {
+ break;
+ }
+ iter.node_ = iter.node_->child(static_cast<field_type>(iter.position_));
+ }
+ // Note: in the non-key-compare-to case, the key may actually be equivalent
+ // here (and the MatchKind::kNe is ignored).
+ return {iter, MatchKind::kNe};
+}
+
+template <typename P>
+template <typename K>
+auto btree<P>::internal_lower_bound(const K &key) const
+ -> SearchResult<iterator, is_key_compare_to::value> {
+ if (!params_type::template can_have_multiple_equivalent_keys<K>()) {
+ SearchResult<iterator, is_key_compare_to::value> ret = internal_locate(key);
+ ret.value = internal_last(ret.value);
+ return ret;
+ }
+ iterator iter(const_cast<node_type *>(root()));
+ SearchResult<size_type, is_key_compare_to::value> res;
+ bool seen_eq = false;
+ for (;;) {
+ res = iter.node_->lower_bound(key, key_comp());
+ iter.position_ = static_cast<int>(res.value);
+ if (iter.node_->is_leaf()) {
+ break;
+ }
+ seen_eq = seen_eq || res.IsEq();
+ iter.node_ = iter.node_->child(static_cast<field_type>(iter.position_));
+ }
+ if (res.IsEq()) return {iter, MatchKind::kEq};
+ return {internal_last(iter), seen_eq ? MatchKind::kEq : MatchKind::kNe};
+}
+
+template <typename P>
+template <typename K>
+auto btree<P>::internal_upper_bound(const K &key) const -> iterator {
+ iterator iter(const_cast<node_type *>(root()));
+ for (;;) {
+ iter.position_ = static_cast<int>(iter.node_->upper_bound(key, key_comp()));
+ if (iter.node_->is_leaf()) {
+ break;
+ }
+ iter.node_ = iter.node_->child(static_cast<field_type>(iter.position_));
+ }
+ return internal_last(iter);
+}
+
+template <typename P>
+template <typename K>
+auto btree<P>::internal_find(const K &key) const -> iterator {
+ SearchResult<iterator, is_key_compare_to::value> res = internal_locate(key);
+ if (res.HasMatch()) {
+ if (res.IsEq()) {
+ return res.value;
+ }
+ } else {
+ const iterator iter = internal_last(res.value);
+ if (iter.node_ != nullptr && !compare_keys(key, iter.key())) {
+ return iter;
+ }
+ }
+ return {nullptr, 0};
+}
+
+template <typename P>
+typename btree<P>::size_type btree<P>::internal_verify(
+ const node_type *node, const key_type *lo, const key_type *hi) const {
+ assert(node->count() > 0);
+ assert(node->count() <= node->max_count());
+ if (lo) {
+ assert(!compare_keys(node->key(node->start()), *lo));
+ }
+ if (hi) {
+ assert(!compare_keys(*hi, node->key(node->finish() - 1)));
+ }
+ for (int i = node->start() + 1; i < node->finish(); ++i) {
+ assert(!compare_keys(node->key(i), node->key(i - 1)));
+ }
+ size_type count = node->count();
+ if (node->is_internal()) {
+ for (field_type i = node->start(); i <= node->finish(); ++i) {
+ assert(node->child(i) != nullptr);
+ assert(node->child(i)->parent() == node);
+ assert(node->child(i)->position() == i);
+ count += internal_verify(node->child(i),
+ i == node->start() ? lo : &node->key(i - 1),
+ i == node->finish() ? hi : &node->key(i));
+ }
+ }
+ return count;
+}
+
+struct btree_access {
+ template <typename BtreeContainer, typename Pred>
+ static auto erase_if(BtreeContainer &container, Pred pred) ->
+ typename BtreeContainer::size_type {
+ const auto initial_size = container.size();
+ auto &tree = container.tree_;
+ auto *alloc = tree.mutable_allocator();
+ for (auto it = container.begin(); it != container.end();) {
+ if (!pred(*it)) {
+ ++it;
+ continue;
+ }
+ auto *node = it.node_;
+ if (node->is_internal()) {
+ // Handle internal nodes normally.
+ it = container.erase(it);
+ continue;
+ }
+ // If this is a leaf node, then we do all the erases from this node
+ // at once before doing rebalancing.
+
+ // The current position to transfer slots to.
+ int to_pos = it.position_;
+ node->value_destroy(it.position_, alloc);
+ while (++it.position_ < node->finish()) {
+ it.update_generation();
+ if (pred(*it)) {
+ node->value_destroy(it.position_, alloc);
+ } else {
+ node->transfer(node->slot(to_pos++), node->slot(it.position_), alloc);
+ }
+ }
+ const int num_deleted = node->finish() - to_pos;
+ tree.size_ -= num_deleted;
+ node->set_finish(to_pos);
+ it.position_ = to_pos;
+ it = tree.rebalance_after_delete(it);
+ }
+ return initial_size - container.size();
+ }
+};
+
+#undef Y_ABSL_BTREE_ENABLE_GENERATIONS
+
+} // namespace container_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_CONTAINER_INTERNAL_BTREE_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree_container.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree_container.h
new file mode 100644
index 00000000000..a2ec3ad025c
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree_container.h
@@ -0,0 +1,763 @@
+// Copyright 2018 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef Y_ABSL_CONTAINER_INTERNAL_BTREE_CONTAINER_H_
+#define Y_ABSL_CONTAINER_INTERNAL_BTREE_CONTAINER_H_
+
+#include <algorithm>
+#include <initializer_list>
+#include <iterator>
+#include <utility>
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/base/internal/throw_delegate.h"
+#include "y_absl/container/internal/btree.h" // IWYU pragma: export
+#include "y_absl/container/internal/common.h"
+#include "y_absl/memory/memory.h"
+#include "y_absl/meta/type_traits.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace container_internal {
+
+// A common base class for btree_set, btree_map, btree_multiset, and
+// btree_multimap.
+template <typename Tree>
+class btree_container {
+ using params_type = typename Tree::params_type;
+
+ protected:
+ // Alias used for heterogeneous lookup functions.
+ // `key_arg<K>` evaluates to `K` when the functors are transparent and to
+ // `key_type` otherwise. It permits template argument deduction on `K` for the
+ // transparent case.
+ template <class K>
+ using key_arg =
+ typename KeyArg<params_type::kIsKeyCompareTransparent>::template type<
+ K, typename Tree::key_type>;
+
+ public:
+ using key_type = typename Tree::key_type;
+ using value_type = typename Tree::value_type;
+ using size_type = typename Tree::size_type;
+ using difference_type = typename Tree::difference_type;
+ using key_compare = typename Tree::original_key_compare;
+ using value_compare = typename Tree::value_compare;
+ using allocator_type = typename Tree::allocator_type;
+ using reference = typename Tree::reference;
+ using const_reference = typename Tree::const_reference;
+ using pointer = typename Tree::pointer;
+ using const_pointer = typename Tree::const_pointer;
+ using iterator = typename Tree::iterator;
+ using const_iterator = typename Tree::const_iterator;
+ using reverse_iterator = typename Tree::reverse_iterator;
+ using const_reverse_iterator = typename Tree::const_reverse_iterator;
+ using node_type = typename Tree::node_handle_type;
+
+ struct extract_and_get_next_return_type {
+ node_type node;
+ iterator next;
+ };
+
+ // Constructors/assignments.
+ btree_container() : tree_(key_compare(), allocator_type()) {}
+ explicit btree_container(const key_compare &comp,
+ const allocator_type &alloc = allocator_type())
+ : tree_(comp, alloc) {}
+ explicit btree_container(const allocator_type &alloc)
+ : tree_(key_compare(), alloc) {}
+
+ btree_container(const btree_container &other)
+ : btree_container(other, y_absl::allocator_traits<allocator_type>::
+ select_on_container_copy_construction(
+ other.get_allocator())) {}
+ btree_container(const btree_container &other, const allocator_type &alloc)
+ : tree_(other.tree_, alloc) {}
+
+ btree_container(btree_container &&other) noexcept(
+ std::is_nothrow_move_constructible<Tree>::value) = default;
+ btree_container(btree_container &&other, const allocator_type &alloc)
+ : tree_(std::move(other.tree_), alloc) {}
+
+ btree_container &operator=(const btree_container &other) = default;
+ btree_container &operator=(btree_container &&other) noexcept(
+ std::is_nothrow_move_assignable<Tree>::value) = default;
+
+ // Iterator routines.
+ iterator begin() Y_ABSL_ATTRIBUTE_LIFETIME_BOUND { return tree_.begin(); }
+ const_iterator begin() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return tree_.begin();
+ }
+ const_iterator cbegin() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return tree_.begin();
+ }
+ iterator end() Y_ABSL_ATTRIBUTE_LIFETIME_BOUND { return tree_.end(); }
+ const_iterator end() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return tree_.end();
+ }
+ const_iterator cend() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return tree_.end();
+ }
+ reverse_iterator rbegin() Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return tree_.rbegin();
+ }
+ const_reverse_iterator rbegin() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return tree_.rbegin();
+ }
+ const_reverse_iterator crbegin() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return tree_.rbegin();
+ }
+ reverse_iterator rend() Y_ABSL_ATTRIBUTE_LIFETIME_BOUND { return tree_.rend(); }
+ const_reverse_iterator rend() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return tree_.rend();
+ }
+ const_reverse_iterator crend() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return tree_.rend();
+ }
+
+ // Lookup routines.
+ template <typename K = key_type>
+ size_type count(const key_arg<K> &key) const {
+ auto equal_range = this->equal_range(key);
+ return equal_range.second - equal_range.first;
+ }
+ template <typename K = key_type>
+ iterator find(const key_arg<K> &key) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return tree_.find(key);
+ }
+ template <typename K = key_type>
+ const_iterator find(const key_arg<K> &key) const
+ Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return tree_.find(key);
+ }
+ template <typename K = key_type>
+ bool contains(const key_arg<K> &key) const {
+ return find(key) != end();
+ }
+ template <typename K = key_type>
+ iterator lower_bound(const key_arg<K> &key) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return tree_.lower_bound(key);
+ }
+ template <typename K = key_type>
+ const_iterator lower_bound(const key_arg<K> &key) const
+ Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return tree_.lower_bound(key);
+ }
+ template <typename K = key_type>
+ iterator upper_bound(const key_arg<K> &key) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return tree_.upper_bound(key);
+ }
+ template <typename K = key_type>
+ const_iterator upper_bound(const key_arg<K> &key) const
+ Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return tree_.upper_bound(key);
+ }
+ template <typename K = key_type>
+ std::pair<iterator, iterator> equal_range(const key_arg<K> &key)
+ Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return tree_.equal_range(key);
+ }
+ template <typename K = key_type>
+ std::pair<const_iterator, const_iterator> equal_range(
+ const key_arg<K> &key) const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return tree_.equal_range(key);
+ }
+
+ // Deletion routines. Note that there is also a deletion routine that is
+ // specific to btree_set_container/btree_multiset_container.
+
+ // Erase the specified iterator from the btree. The iterator must be valid
+ // (i.e. not equal to end()). Return an iterator pointing to the node after
+ // the one that was erased (or end() if none exists).
+ iterator erase(const_iterator iter) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return tree_.erase(iterator(iter));
+ }
+ iterator erase(iterator iter) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return tree_.erase(iter);
+ }
+ iterator erase(const_iterator first,
+ const_iterator last) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return tree_.erase_range(iterator(first), iterator(last)).second;
+ }
+ template <typename K = key_type>
+ size_type erase(const key_arg<K> &key) {
+ auto equal_range = this->equal_range(key);
+ return tree_.erase_range(equal_range.first, equal_range.second).first;
+ }
+
+ // Extract routines.
+ extract_and_get_next_return_type extract_and_get_next(const_iterator position)
+ Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ // Use Construct instead of Transfer because the rebalancing code will
+ // destroy the slot later.
+ // Note: we rely on erase() taking place after Construct().
+ return {CommonAccess::Construct<node_type>(get_allocator(),
+ iterator(position).slot()),
+ erase(position)};
+ }
+ node_type extract(iterator position) {
+ // Use Construct instead of Transfer because the rebalancing code will
+ // destroy the slot later.
+ auto node =
+ CommonAccess::Construct<node_type>(get_allocator(), position.slot());
+ erase(position);
+ return node;
+ }
+ node_type extract(const_iterator position) {
+ return extract(iterator(position));
+ }
+
+ // Utility routines.
+ Y_ABSL_ATTRIBUTE_REINITIALIZES void clear() { tree_.clear(); }
+ void swap(btree_container &other) { tree_.swap(other.tree_); }
+ void verify() const { tree_.verify(); }
+
+ // Size routines.
+ size_type size() const { return tree_.size(); }
+ size_type max_size() const { return tree_.max_size(); }
+ bool empty() const { return tree_.empty(); }
+
+ friend bool operator==(const btree_container &x, const btree_container &y) {
+ if (x.size() != y.size()) return false;
+ return std::equal(x.begin(), x.end(), y.begin());
+ }
+
+ friend bool operator!=(const btree_container &x, const btree_container &y) {
+ return !(x == y);
+ }
+
+ friend bool operator<(const btree_container &x, const btree_container &y) {
+ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
+ }
+
+ friend bool operator>(const btree_container &x, const btree_container &y) {
+ return y < x;
+ }
+
+ friend bool operator<=(const btree_container &x, const btree_container &y) {
+ return !(y < x);
+ }
+
+ friend bool operator>=(const btree_container &x, const btree_container &y) {
+ return !(x < y);
+ }
+
+ // The allocator used by the btree.
+ allocator_type get_allocator() const { return tree_.get_allocator(); }
+
+ // The key comparator used by the btree.
+ key_compare key_comp() const { return key_compare(tree_.key_comp()); }
+ value_compare value_comp() const { return tree_.value_comp(); }
+
+ // Support y_absl::Hash.
+ template <typename State>
+ friend State AbslHashValue(State h, const btree_container &b) {
+ for (const auto &v : b) {
+ h = State::combine(std::move(h), v);
+ }
+ return State::combine(std::move(h), b.size());
+ }
+
+ protected:
+ friend struct btree_access;
+ Tree tree_;
+};
+
+// A common base class for btree_set and btree_map.
+template <typename Tree>
+class btree_set_container : public btree_container<Tree> {
+ using super_type = btree_container<Tree>;
+ using params_type = typename Tree::params_type;
+ using init_type = typename params_type::init_type;
+ using is_key_compare_to = typename params_type::is_key_compare_to;
+ friend class BtreeNodePeer;
+
+ protected:
+ template <class K>
+ using key_arg = typename super_type::template key_arg<K>;
+
+ public:
+ using key_type = typename Tree::key_type;
+ using value_type = typename Tree::value_type;
+ using size_type = typename Tree::size_type;
+ using key_compare = typename Tree::original_key_compare;
+ using allocator_type = typename Tree::allocator_type;
+ using iterator = typename Tree::iterator;
+ using const_iterator = typename Tree::const_iterator;
+ using node_type = typename super_type::node_type;
+ using insert_return_type = InsertReturnType<iterator, node_type>;
+
+ // Inherit constructors.
+ using super_type::super_type;
+ btree_set_container() {}
+
+ // Range constructors.
+ template <class InputIterator>
+ btree_set_container(InputIterator b, InputIterator e,
+ const key_compare &comp = key_compare(),
+ const allocator_type &alloc = allocator_type())
+ : super_type(comp, alloc) {
+ insert(b, e);
+ }
+ template <class InputIterator>
+ btree_set_container(InputIterator b, InputIterator e,
+ const allocator_type &alloc)
+ : btree_set_container(b, e, key_compare(), alloc) {}
+
+ // Initializer list constructors.
+ btree_set_container(std::initializer_list<init_type> init,
+ const key_compare &comp = key_compare(),
+ const allocator_type &alloc = allocator_type())
+ : btree_set_container(init.begin(), init.end(), comp, alloc) {}
+ btree_set_container(std::initializer_list<init_type> init,
+ const allocator_type &alloc)
+ : btree_set_container(init.begin(), init.end(), alloc) {}
+
+ // Insertion routines.
+ std::pair<iterator, bool> insert(const value_type &v)
+ Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return this->tree_.insert_unique(params_type::key(v), v);
+ }
+ std::pair<iterator, bool> insert(value_type &&v)
+ Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return this->tree_.insert_unique(params_type::key(v), std::move(v));
+ }
+ template <typename... Args>
+ std::pair<iterator, bool> emplace(Args &&...args)
+ Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ // Use a node handle to manage a temp slot.
+ auto node = CommonAccess::Construct<node_type>(this->get_allocator(),
+ std::forward<Args>(args)...);
+ auto *slot = CommonAccess::GetSlot(node);
+ return this->tree_.insert_unique(params_type::key(slot), slot);
+ }
+ iterator insert(const_iterator hint,
+ const value_type &v) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return this->tree_
+ .insert_hint_unique(iterator(hint), params_type::key(v), v)
+ .first;
+ }
+ iterator insert(const_iterator hint,
+ value_type &&v) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return this->tree_
+ .insert_hint_unique(iterator(hint), params_type::key(v), std::move(v))
+ .first;
+ }
+ template <typename... Args>
+ iterator emplace_hint(const_iterator hint,
+ Args &&...args) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ // Use a node handle to manage a temp slot.
+ auto node = CommonAccess::Construct<node_type>(this->get_allocator(),
+ std::forward<Args>(args)...);
+ auto *slot = CommonAccess::GetSlot(node);
+ return this->tree_
+ .insert_hint_unique(iterator(hint), params_type::key(slot), slot)
+ .first;
+ }
+ template <typename InputIterator>
+ void insert(InputIterator b, InputIterator e) {
+ this->tree_.insert_iterator_unique(b, e, 0);
+ }
+ void insert(std::initializer_list<init_type> init) {
+ this->tree_.insert_iterator_unique(init.begin(), init.end(), 0);
+ }
+ insert_return_type insert(node_type &&node) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ if (!node) return {this->end(), false, node_type()};
+ std::pair<iterator, bool> res =
+ this->tree_.insert_unique(params_type::key(CommonAccess::GetSlot(node)),
+ CommonAccess::GetSlot(node));
+ if (res.second) {
+ CommonAccess::Destroy(&node);
+ return {res.first, true, node_type()};
+ } else {
+ return {res.first, false, std::move(node)};
+ }
+ }
+ iterator insert(const_iterator hint,
+ node_type &&node) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ if (!node) return this->end();
+ std::pair<iterator, bool> res = this->tree_.insert_hint_unique(
+ iterator(hint), params_type::key(CommonAccess::GetSlot(node)),
+ CommonAccess::GetSlot(node));
+ if (res.second) CommonAccess::Destroy(&node);
+ return res.first;
+ }
+
+ // Node extraction routines.
+ template <typename K = key_type>
+ node_type extract(const key_arg<K> &key) {
+ const std::pair<iterator, bool> lower_and_equal =
+ this->tree_.lower_bound_equal(key);
+ return lower_and_equal.second ? extract(lower_and_equal.first)
+ : node_type();
+ }
+ using super_type::extract;
+
+ // Merge routines.
+ // Moves elements from `src` into `this`. If the element already exists in
+ // `this`, it is left unmodified in `src`.
+ template <
+ typename T,
+ typename y_absl::enable_if_t<
+ y_absl::conjunction<
+ std::is_same<value_type, typename T::value_type>,
+ std::is_same<allocator_type, typename T::allocator_type>,
+ std::is_same<typename params_type::is_map_container,
+ typename T::params_type::is_map_container>>::value,
+ int> = 0>
+ void merge(btree_container<T> &src) { // NOLINT
+ for (auto src_it = src.begin(); src_it != src.end();) {
+ if (insert(std::move(params_type::element(src_it.slot()))).second) {
+ src_it = src.erase(src_it);
+ } else {
+ ++src_it;
+ }
+ }
+ }
+
+ template <
+ typename T,
+ typename y_absl::enable_if_t<
+ y_absl::conjunction<
+ std::is_same<value_type, typename T::value_type>,
+ std::is_same<allocator_type, typename T::allocator_type>,
+ std::is_same<typename params_type::is_map_container,
+ typename T::params_type::is_map_container>>::value,
+ int> = 0>
+ void merge(btree_container<T> &&src) {
+ merge(src);
+ }
+};
+
+// Base class for btree_map.
+template <typename Tree>
+class btree_map_container : public btree_set_container<Tree> {
+ using super_type = btree_set_container<Tree>;
+ using params_type = typename Tree::params_type;
+ friend class BtreeNodePeer;
+
+ private:
+ template <class K>
+ using key_arg = typename super_type::template key_arg<K>;
+
+ public:
+ using key_type = typename Tree::key_type;
+ using mapped_type = typename params_type::mapped_type;
+ using value_type = typename Tree::value_type;
+ using key_compare = typename Tree::original_key_compare;
+ using allocator_type = typename Tree::allocator_type;
+ using iterator = typename Tree::iterator;
+ using const_iterator = typename Tree::const_iterator;
+
+ // Inherit constructors.
+ using super_type::super_type;
+ btree_map_container() {}
+
+ // Insertion routines.
+ // Note: the nullptr template arguments and extra `const M&` overloads allow
+ // for supporting bitfield arguments.
+ template <typename K = key_type, class M>
+ std::pair<iterator, bool> insert_or_assign(const key_arg<K> &k, const M &obj)
+ Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return insert_or_assign_impl(k, obj);
+ }
+ template <typename K = key_type, class M, K * = nullptr>
+ std::pair<iterator, bool> insert_or_assign(key_arg<K> &&k, const M &obj)
+ Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return insert_or_assign_impl(std::forward<K>(k), obj);
+ }
+ template <typename K = key_type, class M, M * = nullptr>
+ std::pair<iterator, bool> insert_or_assign(const key_arg<K> &k, M &&obj)
+ Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return insert_or_assign_impl(k, std::forward<M>(obj));
+ }
+ template <typename K = key_type, class M, K * = nullptr, M * = nullptr>
+ std::pair<iterator, bool> insert_or_assign(key_arg<K> &&k, M &&obj)
+ Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return insert_or_assign_impl(std::forward<K>(k), std::forward<M>(obj));
+ }
+ template <typename K = key_type, class M>
+ iterator insert_or_assign(const_iterator hint, const key_arg<K> &k,
+ const M &obj) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return insert_or_assign_hint_impl(hint, k, obj);
+ }
+ template <typename K = key_type, class M, K * = nullptr>
+ iterator insert_or_assign(const_iterator hint, key_arg<K> &&k,
+ const M &obj) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return insert_or_assign_hint_impl(hint, std::forward<K>(k), obj);
+ }
+ template <typename K = key_type, class M, M * = nullptr>
+ iterator insert_or_assign(const_iterator hint, const key_arg<K> &k,
+ M &&obj) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return insert_or_assign_hint_impl(hint, k, std::forward<M>(obj));
+ }
+ template <typename K = key_type, class M, K * = nullptr, M * = nullptr>
+ iterator insert_or_assign(const_iterator hint, key_arg<K> &&k,
+ M &&obj) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return insert_or_assign_hint_impl(hint, std::forward<K>(k),
+ std::forward<M>(obj));
+ }
+
+ template <typename K = key_type, typename... Args,
+ typename y_absl::enable_if_t<
+ !std::is_convertible<K, const_iterator>::value, int> = 0>
+ std::pair<iterator, bool> try_emplace(const key_arg<K> &k, Args &&...args)
+ Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return try_emplace_impl(k, std::forward<Args>(args)...);
+ }
+ template <typename K = key_type, typename... Args,
+ typename y_absl::enable_if_t<
+ !std::is_convertible<K, const_iterator>::value, int> = 0>
+ std::pair<iterator, bool> try_emplace(key_arg<K> &&k, Args &&...args)
+ Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return try_emplace_impl(std::forward<K>(k), std::forward<Args>(args)...);
+ }
+ template <typename K = key_type, typename... Args>
+ iterator try_emplace(const_iterator hint, const key_arg<K> &k,
+ Args &&...args) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return try_emplace_hint_impl(hint, k, std::forward<Args>(args)...);
+ }
+ template <typename K = key_type, typename... Args>
+ iterator try_emplace(const_iterator hint, key_arg<K> &&k,
+ Args &&...args) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return try_emplace_hint_impl(hint, std::forward<K>(k),
+ std::forward<Args>(args)...);
+ }
+
+ template <typename K = key_type>
+ mapped_type &operator[](const key_arg<K> &k) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return try_emplace(k).first->second;
+ }
+ template <typename K = key_type>
+ mapped_type &operator[](key_arg<K> &&k) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return try_emplace(std::forward<K>(k)).first->second;
+ }
+
+ template <typename K = key_type>
+ mapped_type &at(const key_arg<K> &key) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ auto it = this->find(key);
+ if (it == this->end())
+ base_internal::ThrowStdOutOfRange("y_absl::btree_map::at");
+ return it->second;
+ }
+ template <typename K = key_type>
+ const mapped_type &at(const key_arg<K> &key) const
+ Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ auto it = this->find(key);
+ if (it == this->end())
+ base_internal::ThrowStdOutOfRange("y_absl::btree_map::at");
+ return it->second;
+ }
+
+ private:
+ // Note: when we call `std::forward<M>(obj)` twice, it's safe because
+ // insert_unique/insert_hint_unique are guaranteed to not consume `obj` when
+ // `ret.second` is false.
+ template <class K, class M>
+ std::pair<iterator, bool> insert_or_assign_impl(K &&k, M &&obj) {
+ const std::pair<iterator, bool> ret =
+ this->tree_.insert_unique(k, std::forward<K>(k), std::forward<M>(obj));
+ if (!ret.second) ret.first->second = std::forward<M>(obj);
+ return ret;
+ }
+ template <class K, class M>
+ iterator insert_or_assign_hint_impl(const_iterator hint, K &&k, M &&obj) {
+ const std::pair<iterator, bool> ret = this->tree_.insert_hint_unique(
+ iterator(hint), k, std::forward<K>(k), std::forward<M>(obj));
+ if (!ret.second) ret.first->second = std::forward<M>(obj);
+ return ret.first;
+ }
+
+ template <class K, class... Args>
+ std::pair<iterator, bool> try_emplace_impl(K &&k, Args &&... args) {
+ return this->tree_.insert_unique(
+ k, std::piecewise_construct, std::forward_as_tuple(std::forward<K>(k)),
+ std::forward_as_tuple(std::forward<Args>(args)...));
+ }
+ template <class K, class... Args>
+ iterator try_emplace_hint_impl(const_iterator hint, K &&k, Args &&... args) {
+ return this->tree_
+ .insert_hint_unique(iterator(hint), k, std::piecewise_construct,
+ std::forward_as_tuple(std::forward<K>(k)),
+ std::forward_as_tuple(std::forward<Args>(args)...))
+ .first;
+ }
+};
+
+// A common base class for btree_multiset and btree_multimap.
+template <typename Tree>
+class btree_multiset_container : public btree_container<Tree> {
+ using super_type = btree_container<Tree>;
+ using params_type = typename Tree::params_type;
+ using init_type = typename params_type::init_type;
+ using is_key_compare_to = typename params_type::is_key_compare_to;
+ friend class BtreeNodePeer;
+
+ template <class K>
+ using key_arg = typename super_type::template key_arg<K>;
+
+ public:
+ using key_type = typename Tree::key_type;
+ using value_type = typename Tree::value_type;
+ using size_type = typename Tree::size_type;
+ using key_compare = typename Tree::original_key_compare;
+ using allocator_type = typename Tree::allocator_type;
+ using iterator = typename Tree::iterator;
+ using const_iterator = typename Tree::const_iterator;
+ using node_type = typename super_type::node_type;
+
+ // Inherit constructors.
+ using super_type::super_type;
+ btree_multiset_container() {}
+
+ // Range constructors.
+ template <class InputIterator>
+ btree_multiset_container(InputIterator b, InputIterator e,
+ const key_compare &comp = key_compare(),
+ const allocator_type &alloc = allocator_type())
+ : super_type(comp, alloc) {
+ insert(b, e);
+ }
+ template <class InputIterator>
+ btree_multiset_container(InputIterator b, InputIterator e,
+ const allocator_type &alloc)
+ : btree_multiset_container(b, e, key_compare(), alloc) {}
+
+ // Initializer list constructors.
+ btree_multiset_container(std::initializer_list<init_type> init,
+ const key_compare &comp = key_compare(),
+ const allocator_type &alloc = allocator_type())
+ : btree_multiset_container(init.begin(), init.end(), comp, alloc) {}
+ btree_multiset_container(std::initializer_list<init_type> init,
+ const allocator_type &alloc)
+ : btree_multiset_container(init.begin(), init.end(), alloc) {}
+
+ // Insertion routines.
+ iterator insert(const value_type &v) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return this->tree_.insert_multi(v);
+ }
+ iterator insert(value_type &&v) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return this->tree_.insert_multi(std::move(v));
+ }
+ iterator insert(const_iterator hint,
+ const value_type &v) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return this->tree_.insert_hint_multi(iterator(hint), v);
+ }
+ iterator insert(const_iterator hint,
+ value_type &&v) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return this->tree_.insert_hint_multi(iterator(hint), std::move(v));
+ }
+ template <typename InputIterator>
+ void insert(InputIterator b, InputIterator e) {
+ this->tree_.insert_iterator_multi(b, e);
+ }
+ void insert(std::initializer_list<init_type> init) {
+ this->tree_.insert_iterator_multi(init.begin(), init.end());
+ }
+ template <typename... Args>
+ iterator emplace(Args &&...args) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ // Use a node handle to manage a temp slot.
+ auto node = CommonAccess::Construct<node_type>(this->get_allocator(),
+ std::forward<Args>(args)...);
+ return this->tree_.insert_multi(CommonAccess::GetSlot(node));
+ }
+ template <typename... Args>
+ iterator emplace_hint(const_iterator hint,
+ Args &&...args) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ // Use a node handle to manage a temp slot.
+ auto node = CommonAccess::Construct<node_type>(this->get_allocator(),
+ std::forward<Args>(args)...);
+ return this->tree_.insert_hint_multi(iterator(hint),
+ CommonAccess::GetSlot(node));
+ }
+ iterator insert(node_type &&node) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ if (!node) return this->end();
+ iterator res =
+ this->tree_.insert_multi(params_type::key(CommonAccess::GetSlot(node)),
+ CommonAccess::GetSlot(node));
+ CommonAccess::Destroy(&node);
+ return res;
+ }
+ iterator insert(const_iterator hint,
+ node_type &&node) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ if (!node) return this->end();
+ iterator res = this->tree_.insert_hint_multi(
+ iterator(hint),
+ std::move(params_type::element(CommonAccess::GetSlot(node))));
+ CommonAccess::Destroy(&node);
+ return res;
+ }
+
+ // Node extraction routines.
+ template <typename K = key_type>
+ node_type extract(const key_arg<K> &key) {
+ const std::pair<iterator, bool> lower_and_equal =
+ this->tree_.lower_bound_equal(key);
+ return lower_and_equal.second ? extract(lower_and_equal.first)
+ : node_type();
+ }
+ using super_type::extract;
+
+ // Merge routines.
+ // Moves all elements from `src` into `this`.
+ template <
+ typename T,
+ typename y_absl::enable_if_t<
+ y_absl::conjunction<
+ std::is_same<value_type, typename T::value_type>,
+ std::is_same<allocator_type, typename T::allocator_type>,
+ std::is_same<typename params_type::is_map_container,
+ typename T::params_type::is_map_container>>::value,
+ int> = 0>
+ void merge(btree_container<T> &src) { // NOLINT
+ for (auto src_it = src.begin(), end = src.end(); src_it != end; ++src_it) {
+ insert(std::move(params_type::element(src_it.slot())));
+ }
+ src.clear();
+ }
+
+ template <
+ typename T,
+ typename y_absl::enable_if_t<
+ y_absl::conjunction<
+ std::is_same<value_type, typename T::value_type>,
+ std::is_same<allocator_type, typename T::allocator_type>,
+ std::is_same<typename params_type::is_map_container,
+ typename T::params_type::is_map_container>>::value,
+ int> = 0>
+ void merge(btree_container<T> &&src) {
+ merge(src);
+ }
+};
+
+// A base class for btree_multimap.
+template <typename Tree>
+class btree_multimap_container : public btree_multiset_container<Tree> {
+ using super_type = btree_multiset_container<Tree>;
+ using params_type = typename Tree::params_type;
+ friend class BtreeNodePeer;
+
+ public:
+ using mapped_type = typename params_type::mapped_type;
+
+ // Inherit constructors.
+ using super_type::super_type;
+ btree_multimap_container() {}
+};
+
+} // namespace container_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_CONTAINER_INTERNAL_BTREE_CONTAINER_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/layout.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/layout.h
new file mode 100644
index 00000000000..c0ab1527fac
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/layout.h
@@ -0,0 +1,839 @@
+// Copyright 2018 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// MOTIVATION AND TUTORIAL
+//
+// If you want to put in a single heap allocation N doubles followed by M ints,
+// it's easy if N and M are known at compile time.
+//
+// struct S {
+// double a[N];
+// int b[M];
+// };
+//
+// S* p = new S;
+//
+// But what if N and M are known only in run time? Class template Layout to the
+// rescue! It's a portable generalization of the technique known as struct hack.
+//
+// // This object will tell us everything we need to know about the memory
+// // layout of double[N] followed by int[M]. It's structurally identical to
+// // size_t[2] that stores N and M. It's very cheap to create.
+// const Layout<double, int> layout(N, M);
+//
+// // Allocate enough memory for both arrays. `AllocSize()` tells us how much
+// // memory is needed. We are free to use any allocation function we want as
+// // long as it returns aligned memory.
+// std::unique_ptr<unsigned char[]> p(new unsigned char[layout.AllocSize()]);
+//
+// // Obtain the pointer to the array of doubles.
+// // Equivalent to `reinterpret_cast<double*>(p.get())`.
+// //
+// // We could have written layout.Pointer<0>(p) instead. If all the types are
+// // unique you can use either form, but if some types are repeated you must
+// // use the index form.
+// double* a = layout.Pointer<double>(p.get());
+//
+// // Obtain the pointer to the array of ints.
+// // Equivalent to `reinterpret_cast<int*>(p.get() + N * 8)`.
+// int* b = layout.Pointer<int>(p);
+//
+// If we are unable to specify sizes of all fields, we can pass as many sizes as
+// we can to `Partial()`. In return, it'll allow us to access the fields whose
+// locations and sizes can be computed from the provided information.
+// `Partial()` comes in handy when the array sizes are embedded into the
+// allocation.
+//
+// // size_t[0] containing N, size_t[1] containing M, double[N], int[M].
+// using L = Layout<size_t, size_t, double, int>;
+//
+// unsigned char* Allocate(size_t n, size_t m) {
+// const L layout(1, 1, n, m);
+// unsigned char* p = new unsigned char[layout.AllocSize()];
+// *layout.Pointer<0>(p) = n;
+// *layout.Pointer<1>(p) = m;
+// return p;
+// }
+//
+// void Use(unsigned char* p) {
+// // First, extract N and M.
+// // Specify that the first array has only one element. Using `prefix` we
+// // can access the first two arrays but not more.
+// constexpr auto prefix = L::Partial(1);
+// size_t n = *prefix.Pointer<0>(p);
+// size_t m = *prefix.Pointer<1>(p);
+//
+// // Now we can get pointers to the payload.
+// const L layout(1, 1, n, m);
+// double* a = layout.Pointer<double>(p);
+// int* b = layout.Pointer<int>(p);
+// }
+//
+// The layout we used above combines fixed-size with dynamically-sized fields.
+// This is quite common. Layout is optimized for this use case and attempts to
+// generate optimal code. To help the compiler do that in more cases, you can
+// specify the fixed sizes using `WithStaticSizes`. This ensures that all
+// computations that can be performed at compile time are indeed performed at
+// compile time. Note that sometimes the `template` keyword is needed. E.g.:
+//
+// using SL = L::template WithStaticSizes<1, 1>;
+//
+// void Use(unsigned char* p) {
+// // First, extract N and M.
+// // Using `prefix` we can access the first three arrays but not more.
+// //
+// // More details: The first element always has offset 0. `SL`
+// // has offsets for the second and third array based on sizes of
+// // the first and second array, specified via `WithStaticSizes`.
+// constexpr auto prefix = SL::Partial();
+// size_t n = *prefix.Pointer<0>(p);
+// size_t m = *prefix.Pointer<1>(p);
+//
+// // Now we can get a pointer to the final payload.
+// const SL layout(n, m);
+// double* a = layout.Pointer<double>(p);
+// int* b = layout.Pointer<int>(p);
+// }
+//
+// Efficiency tip: The order of fields matters. In `Layout<T1, ..., TN>` try to
+// ensure that `alignof(T1) >= ... >= alignof(TN)`. This way you'll have no
+// padding in between arrays.
+//
+// You can manually override the alignment of an array by wrapping the type in
+// `Aligned<T, N>`. `Layout<..., Aligned<T, N>, ...>` has exactly the same API
+// and behavior as `Layout<..., T, ...>` except that the first element of the
+// array of `T` is aligned to `N` (the rest of the elements follow without
+// padding). `N` cannot be less than `alignof(T)`.
+//
+// `AllocSize()` and `Pointer()` are the most basic methods for dealing with
+// memory layouts. Check out the reference or code below to discover more.
+//
+// EXAMPLE
+//
+// // Immutable move-only string with sizeof equal to sizeof(void*). The
+// // string size and the characters are kept in the same heap allocation.
+// class CompactString {
+// public:
+// CompactString(const char* s = "") {
+// const size_t size = strlen(s);
+// // size_t[1] followed by char[size + 1].
+// const L layout(size + 1);
+// p_.reset(new unsigned char[layout.AllocSize()]);
+// // If running under ASAN, mark the padding bytes, if any, to catch
+// // memory errors.
+// layout.PoisonPadding(p_.get());
+// // Store the size in the allocation.
+// *layout.Pointer<size_t>(p_.get()) = size;
+// // Store the characters in the allocation.
+// memcpy(layout.Pointer<char>(p_.get()), s, size + 1);
+// }
+//
+// size_t size() const {
+// // Equivalent to reinterpret_cast<size_t&>(*p).
+// return *L::Partial().Pointer<size_t>(p_.get());
+// }
+//
+// const char* c_str() const {
+// // Equivalent to reinterpret_cast<char*>(p.get() + sizeof(size_t)).
+// return L::Partial().Pointer<char>(p_.get());
+// }
+//
+// private:
+// // Our heap allocation contains a single size_t followed by an array of
+// // chars.
+// using L = Layout<size_t, char>::WithStaticSizes<1>;
+// std::unique_ptr<unsigned char[]> p_;
+// };
+//
+// int main() {
+// CompactString s = "hello";
+// assert(s.size() == 5);
+// assert(strcmp(s.c_str(), "hello") == 0);
+// }
+//
+// DOCUMENTATION
+//
+// The interface exported by this file consists of:
+// - class `Layout<>` and its public members.
+// - The public members of classes `internal_layout::LayoutWithStaticSizes<>`
+// and `internal_layout::LayoutImpl<>`. Those classes aren't intended to be
+// used directly, and their name and template parameter list are internal
+// implementation details, but the classes themselves provide most of the
+// functionality in this file. See comments on their members for detailed
+// documentation.
+//
+// `Layout<T1,... Tn>::Partial(count1,..., countm)` (where `m` <= `n`) returns a
+// `LayoutImpl<>` object. `Layout<T1,..., Tn> layout(count1,..., countn)`
+// creates a `Layout` object, which exposes the same functionality by inheriting
+// from `LayoutImpl<>`.
+
+#ifndef Y_ABSL_CONTAINER_INTERNAL_LAYOUT_H_
+#define Y_ABSL_CONTAINER_INTERNAL_LAYOUT_H_
+
+#include <assert.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#include <array>
+#include <util/generic/string.h>
+#include <tuple>
+#include <type_traits>
+#include <typeinfo>
+#include <utility>
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/base/config.h"
+#include "y_absl/debugging/internal/demangle.h"
+#include "y_absl/meta/type_traits.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/types/span.h"
+#include "y_absl/utility/utility.h"
+
+#ifdef Y_ABSL_HAVE_ADDRESS_SANITIZER
+#include <sanitizer/asan_interface.h>
+#endif
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace container_internal {
+
+// A type wrapper that instructs `Layout` to use the specific alignment for the
+// array. `Layout<..., Aligned<T, N>, ...>` has exactly the same API
+// and behavior as `Layout<..., T, ...>` except that the first element of the
+// array of `T` is aligned to `N` (the rest of the elements follow without
+// padding).
+//
+// Requires: `N >= alignof(T)` and `N` is a power of 2.
+template <class T, size_t N>
+struct Aligned;
+
+namespace internal_layout {
+
+template <class T>
+struct NotAligned {};
+
+template <class T, size_t N>
+struct NotAligned<const Aligned<T, N>> {
+ static_assert(sizeof(T) == 0, "Aligned<T, N> cannot be const-qualified");
+};
+
+template <size_t>
+using IntToSize = size_t;
+
+template <class T>
+struct Type : NotAligned<T> {
+ using type = T;
+};
+
+template <class T, size_t N>
+struct Type<Aligned<T, N>> {
+ using type = T;
+};
+
+template <class T>
+struct SizeOf : NotAligned<T>, std::integral_constant<size_t, sizeof(T)> {};
+
+template <class T, size_t N>
+struct SizeOf<Aligned<T, N>> : std::integral_constant<size_t, sizeof(T)> {};
+
+// Note: workaround for https://gcc.gnu.org/PR88115
+template <class T>
+struct AlignOf : NotAligned<T> {
+ static constexpr size_t value = alignof(T);
+};
+
+template <class T, size_t N>
+struct AlignOf<Aligned<T, N>> {
+ static_assert(N % alignof(T) == 0,
+ "Custom alignment can't be lower than the type's alignment");
+ static constexpr size_t value = N;
+};
+
+// Does `Ts...` contain `T`?
+template <class T, class... Ts>
+using Contains = y_absl::disjunction<std::is_same<T, Ts>...>;
+
+template <class From, class To>
+using CopyConst =
+ typename std::conditional<std::is_const<From>::value, const To, To>::type;
+
+// Note: We're not qualifying this with y_absl:: because it doesn't compile under
+// MSVC.
+template <class T>
+using SliceType = Span<T>;
+
+// This namespace contains no types. It prevents functions defined in it from
+// being found by ADL.
+namespace adl_barrier {
+
+template <class Needle, class... Ts>
+constexpr size_t Find(Needle, Needle, Ts...) {
+ static_assert(!Contains<Needle, Ts...>(), "Duplicate element type");
+ return 0;
+}
+
+template <class Needle, class T, class... Ts>
+constexpr size_t Find(Needle, T, Ts...) {
+ return adl_barrier::Find(Needle(), Ts()...) + 1;
+}
+
+constexpr bool IsPow2(size_t n) { return !(n & (n - 1)); }
+
+// Returns `q * m` for the smallest `q` such that `q * m >= n`.
+// Requires: `m` is a power of two. It's enforced by IsLegalElementType below.
+constexpr size_t Align(size_t n, size_t m) { return (n + m - 1) & ~(m - 1); }
+
+constexpr size_t Min(size_t a, size_t b) { return b < a ? b : a; }
+
+constexpr size_t Max(size_t a) { return a; }
+
+template <class... Ts>
+constexpr size_t Max(size_t a, size_t b, Ts... rest) {
+ return adl_barrier::Max(b < a ? a : b, rest...);
+}
+
+template <class T>
+TString TypeName() {
+ TString out;
+ return out;
+}
+
+} // namespace adl_barrier
+
+template <bool C>
+using EnableIf = typename std::enable_if<C, int>::type;
+
+// Can `T` be a template argument of `Layout`?
+template <class T>
+using IsLegalElementType = std::integral_constant<
+ bool, !std::is_reference<T>::value && !std::is_volatile<T>::value &&
+ !std::is_reference<typename Type<T>::type>::value &&
+ !std::is_volatile<typename Type<T>::type>::value &&
+ adl_barrier::IsPow2(AlignOf<T>::value)>;
+
+template <class Elements, class StaticSizeSeq, class RuntimeSizeSeq,
+ class SizeSeq, class OffsetSeq>
+class LayoutImpl;
+
+// Public base class of `Layout` and the result type of `Layout::Partial()`.
+//
+// `Elements...` contains all template arguments of `Layout` that created this
+// instance.
+//
+// `StaticSizeSeq...` is an index_sequence containing the sizes specified at
+// compile-time.
+//
+// `RuntimeSizeSeq...` is `[0, NumRuntimeSizes)`, where `NumRuntimeSizes` is the
+// number of arguments passed to `Layout::Partial()` or `Layout::Layout()`.
+//
+// `SizeSeq...` is `[0, NumSizes)` where `NumSizes` is `NumRuntimeSizes` plus
+// the number of sizes in `StaticSizeSeq`.
+//
+// `OffsetSeq...` is `[0, NumOffsets)` where `NumOffsets` is
+// `Min(sizeof...(Elements), NumSizes + 1)` (the number of arrays for which we
+// can compute offsets).
+template <class... Elements, size_t... StaticSizeSeq, size_t... RuntimeSizeSeq,
+ size_t... SizeSeq, size_t... OffsetSeq>
+class LayoutImpl<
+ std::tuple<Elements...>, y_absl::index_sequence<StaticSizeSeq...>,
+ y_absl::index_sequence<RuntimeSizeSeq...>, y_absl::index_sequence<SizeSeq...>,
+ y_absl::index_sequence<OffsetSeq...>> {
+ private:
+ static_assert(sizeof...(Elements) > 0, "At least one field is required");
+ static_assert(y_absl::conjunction<IsLegalElementType<Elements>...>::value,
+ "Invalid element type (see IsLegalElementType)");
+ static_assert(sizeof...(StaticSizeSeq) <= sizeof...(Elements),
+ "Too many static sizes specified");
+
+ enum {
+ NumTypes = sizeof...(Elements),
+ NumStaticSizes = sizeof...(StaticSizeSeq),
+ NumRuntimeSizes = sizeof...(RuntimeSizeSeq),
+ NumSizes = sizeof...(SizeSeq),
+ NumOffsets = sizeof...(OffsetSeq),
+ };
+
+ // These are guaranteed by `Layout`.
+ static_assert(NumStaticSizes + NumRuntimeSizes == NumSizes, "Internal error");
+ static_assert(NumSizes <= NumTypes, "Internal error");
+ static_assert(NumOffsets == adl_barrier::Min(NumTypes, NumSizes + 1),
+ "Internal error");
+ static_assert(NumTypes > 0, "Internal error");
+
+ static constexpr std::array<size_t, sizeof...(StaticSizeSeq)> kStaticSizes = {
+ StaticSizeSeq...};
+
+ // Returns the index of `T` in `Elements...`. Results in a compilation error
+ // if `Elements...` doesn't contain exactly one instance of `T`.
+ template <class T>
+ static constexpr size_t ElementIndex() {
+ static_assert(Contains<Type<T>, Type<typename Type<Elements>::type>...>(),
+ "Type not found");
+ return adl_barrier::Find(Type<T>(),
+ Type<typename Type<Elements>::type>()...);
+ }
+
+ template <size_t N>
+ using ElementAlignment =
+ AlignOf<typename std::tuple_element<N, std::tuple<Elements...>>::type>;
+
+ public:
+ // Element types of all arrays packed in a tuple.
+ using ElementTypes = std::tuple<typename Type<Elements>::type...>;
+
+ // Element type of the Nth array.
+ template <size_t N>
+ using ElementType = typename std::tuple_element<N, ElementTypes>::type;
+
+ constexpr explicit LayoutImpl(IntToSize<RuntimeSizeSeq>... sizes)
+ : size_{sizes...} {}
+
+ // Alignment of the layout, equal to the strictest alignment of all elements.
+ // All pointers passed to the methods of layout must be aligned to this value.
+ static constexpr size_t Alignment() {
+ return adl_barrier::Max(AlignOf<Elements>::value...);
+ }
+
+ // Offset in bytes of the Nth array.
+ //
+ // // int[3], 4 bytes of padding, double[4].
+ // Layout<int, double> x(3, 4);
+ // assert(x.Offset<0>() == 0); // The ints starts from 0.
+ // assert(x.Offset<1>() == 16); // The doubles starts from 16.
+ //
+ // Requires: `N <= NumSizes && N < sizeof...(Ts)`.
+ template <size_t N, EnableIf<N == 0> = 0>
+ constexpr size_t Offset() const {
+ return 0;
+ }
+
+ template <size_t N, EnableIf<N != 0> = 0>
+ constexpr size_t Offset() const {
+ static_assert(N < NumOffsets, "Index out of bounds");
+ return adl_barrier::Align(
+ Offset<N - 1>() + SizeOf<ElementType<N - 1>>::value * Size<N - 1>(),
+ ElementAlignment<N>::value);
+ }
+
+ // Offset in bytes of the array with the specified element type. There must
+ // be exactly one such array and its zero-based index must be at most
+ // `NumSizes`.
+ //
+ // // int[3], 4 bytes of padding, double[4].
+ // Layout<int, double> x(3, 4);
+ // assert(x.Offset<int>() == 0); // The ints starts from 0.
+ // assert(x.Offset<double>() == 16); // The doubles starts from 16.
+ template <class T>
+ constexpr size_t Offset() const {
+ return Offset<ElementIndex<T>()>();
+ }
+
+ // Offsets in bytes of all arrays for which the offsets are known.
+ constexpr std::array<size_t, NumOffsets> Offsets() const {
+ return {{Offset<OffsetSeq>()...}};
+ }
+
+ // The number of elements in the Nth array (zero-based).
+ //
+ // // int[3], 4 bytes of padding, double[4].
+ // Layout<int, double> x(3, 4);
+ // assert(x.Size<0>() == 3);
+ // assert(x.Size<1>() == 4);
+ //
+ // Requires: `N < NumSizes`.
+ template <size_t N, EnableIf<(N < NumStaticSizes)> = 0>
+ constexpr size_t Size() const {
+ return kStaticSizes[N];
+ }
+
+ template <size_t N, EnableIf<(N >= NumStaticSizes)> = 0>
+ constexpr size_t Size() const {
+ static_assert(N < NumSizes, "Index out of bounds");
+ return size_[N - NumStaticSizes];
+ }
+
+ // The number of elements in the array with the specified element type.
+ // There must be exactly one such array and its zero-based index must be
+ // at most `NumSizes`.
+ //
+ // // int[3], 4 bytes of padding, double[4].
+ // Layout<int, double> x(3, 4);
+ // assert(x.Size<int>() == 3);
+ // assert(x.Size<double>() == 4);
+ template <class T>
+ constexpr size_t Size() const {
+ return Size<ElementIndex<T>()>();
+ }
+
+ // The number of elements of all arrays for which they are known.
+ constexpr std::array<size_t, NumSizes> Sizes() const {
+ return {{Size<SizeSeq>()...}};
+ }
+
+ // Pointer to the beginning of the Nth array.
+ //
+ // `Char` must be `[const] [signed|unsigned] char`.
+ //
+ // // int[3], 4 bytes of padding, double[4].
+ // Layout<int, double> x(3, 4);
+ // unsigned char* p = new unsigned char[x.AllocSize()];
+ // int* ints = x.Pointer<0>(p);
+ // double* doubles = x.Pointer<1>(p);
+ //
+ // Requires: `N <= NumSizes && N < sizeof...(Ts)`.
+ // Requires: `p` is aligned to `Alignment()`.
+ template <size_t N, class Char>
+ CopyConst<Char, ElementType<N>>* Pointer(Char* p) const {
+ using C = typename std::remove_const<Char>::type;
+ static_assert(
+ std::is_same<C, char>() || std::is_same<C, unsigned char>() ||
+ std::is_same<C, signed char>(),
+ "The argument must be a pointer to [const] [signed|unsigned] char");
+ constexpr size_t alignment = Alignment();
+ (void)alignment;
+ assert(reinterpret_cast<uintptr_t>(p) % alignment == 0);
+ return reinterpret_cast<CopyConst<Char, ElementType<N>>*>(p + Offset<N>());
+ }
+
+ // Pointer to the beginning of the array with the specified element type.
+ // There must be exactly one such array and its zero-based index must be at
+ // most `NumSizes`.
+ //
+ // `Char` must be `[const] [signed|unsigned] char`.
+ //
+ // // int[3], 4 bytes of padding, double[4].
+ // Layout<int, double> x(3, 4);
+ // unsigned char* p = new unsigned char[x.AllocSize()];
+ // int* ints = x.Pointer<int>(p);
+ // double* doubles = x.Pointer<double>(p);
+ //
+ // Requires: `p` is aligned to `Alignment()`.
+ template <class T, class Char>
+ CopyConst<Char, T>* Pointer(Char* p) const {
+ return Pointer<ElementIndex<T>()>(p);
+ }
+
+ // Pointers to all arrays for which pointers are known.
+ //
+ // `Char` must be `[const] [signed|unsigned] char`.
+ //
+ // // int[3], 4 bytes of padding, double[4].
+ // Layout<int, double> x(3, 4);
+ // unsigned char* p = new unsigned char[x.AllocSize()];
+ //
+ // int* ints;
+ // double* doubles;
+ // std::tie(ints, doubles) = x.Pointers(p);
+ //
+ // Requires: `p` is aligned to `Alignment()`.
+ template <class Char>
+ auto Pointers(Char* p) const {
+ return std::tuple<CopyConst<Char, ElementType<OffsetSeq>>*...>(
+ Pointer<OffsetSeq>(p)...);
+ }
+
+ // The Nth array.
+ //
+ // `Char` must be `[const] [signed|unsigned] char`.
+ //
+ // // int[3], 4 bytes of padding, double[4].
+ // Layout<int, double> x(3, 4);
+ // unsigned char* p = new unsigned char[x.AllocSize()];
+ // Span<int> ints = x.Slice<0>(p);
+ // Span<double> doubles = x.Slice<1>(p);
+ //
+ // Requires: `N < NumSizes`.
+ // Requires: `p` is aligned to `Alignment()`.
+ template <size_t N, class Char>
+ SliceType<CopyConst<Char, ElementType<N>>> Slice(Char* p) const {
+ return SliceType<CopyConst<Char, ElementType<N>>>(Pointer<N>(p), Size<N>());
+ }
+
+ // The array with the specified element type. There must be exactly one
+ // such array and its zero-based index must be less than `NumSizes`.
+ //
+ // `Char` must be `[const] [signed|unsigned] char`.
+ //
+ // // int[3], 4 bytes of padding, double[4].
+ // Layout<int, double> x(3, 4);
+ // unsigned char* p = new unsigned char[x.AllocSize()];
+ // Span<int> ints = x.Slice<int>(p);
+ // Span<double> doubles = x.Slice<double>(p);
+ //
+ // Requires: `p` is aligned to `Alignment()`.
+ template <class T, class Char>
+ SliceType<CopyConst<Char, T>> Slice(Char* p) const {
+ return Slice<ElementIndex<T>()>(p);
+ }
+
+ // All arrays with known sizes.
+ //
+ // `Char` must be `[const] [signed|unsigned] char`.
+ //
+ // // int[3], 4 bytes of padding, double[4].
+ // Layout<int, double> x(3, 4);
+ // unsigned char* p = new unsigned char[x.AllocSize()];
+ //
+ // Span<int> ints;
+ // Span<double> doubles;
+ // std::tie(ints, doubles) = x.Slices(p);
+ //
+ // Requires: `p` is aligned to `Alignment()`.
+ //
+ // Note: We mark the parameter as unused because GCC detects it is not used
+ // when `SizeSeq` is empty [-Werror=unused-but-set-parameter].
+ template <class Char>
+ auto Slices(Y_ABSL_ATTRIBUTE_UNUSED Char* p) const {
+ return std::tuple<SliceType<CopyConst<Char, ElementType<SizeSeq>>>...>(
+ Slice<SizeSeq>(p)...);
+ }
+
+ // The size of the allocation that fits all arrays.
+ //
+ // // int[3], 4 bytes of padding, double[4].
+ // Layout<int, double> x(3, 4);
+ // unsigned char* p = new unsigned char[x.AllocSize()]; // 48 bytes
+ //
+ // Requires: `NumSizes == sizeof...(Ts)`.
+ constexpr size_t AllocSize() const {
+ static_assert(NumTypes == NumSizes, "You must specify sizes of all fields");
+ return Offset<NumTypes - 1>() +
+ SizeOf<ElementType<NumTypes - 1>>::value * Size<NumTypes - 1>();
+ }
+
+ // If built with --config=asan, poisons padding bytes (if any) in the
+ // allocation. The pointer must point to a memory block at least
+ // `AllocSize()` bytes in length.
+ //
+ // `Char` must be `[const] [signed|unsigned] char`.
+ //
+ // Requires: `p` is aligned to `Alignment()`.
+ template <class Char, size_t N = NumOffsets - 1, EnableIf<N == 0> = 0>
+ void PoisonPadding(const Char* p) const {
+ Pointer<0>(p); // verify the requirements on `Char` and `p`
+ }
+
+ template <class Char, size_t N = NumOffsets - 1, EnableIf<N != 0> = 0>
+ void PoisonPadding(const Char* p) const {
+ static_assert(N < NumOffsets, "Index out of bounds");
+ (void)p;
+#ifdef Y_ABSL_HAVE_ADDRESS_SANITIZER
+ PoisonPadding<Char, N - 1>(p);
+ // The `if` is an optimization. It doesn't affect the observable behaviour.
+ if (ElementAlignment<N - 1>::value % ElementAlignment<N>::value) {
+ size_t start =
+ Offset<N - 1>() + SizeOf<ElementType<N - 1>>::value * Size<N - 1>();
+ ASAN_POISON_MEMORY_REGION(p + start, Offset<N>() - start);
+ }
+#endif
+ }
+
+ // Human-readable description of the memory layout. Useful for debugging.
+ // Slow.
+ //
+ // // char[5], 3 bytes of padding, int[3], 4 bytes of padding, followed
+ // // by an unknown number of doubles.
+ // auto x = Layout<char, int, double>::Partial(5, 3);
+ // assert(x.DebugString() ==
+ // "@0<char>(1)[5]; @8<int>(4)[3]; @24<double>(8)");
+ //
+ // Each field is in the following format: @offset<type>(sizeof)[size] (<type>
+ // may be missing depending on the target platform). For example,
+ // @8<int>(4)[3] means that at offset 8 we have an array of ints, where each
+ // int is 4 bytes, and we have 3 of those ints. The size of the last field may
+ // be missing (as in the example above). Only fields with known offsets are
+ // described. Type names may differ across platforms: one compiler might
+ // produce "unsigned*" where another produces "unsigned int *".
+ TString DebugString() const {
+ const auto offsets = Offsets();
+ const size_t sizes[] = {SizeOf<ElementType<OffsetSeq>>::value...};
+ const TString types[] = {
+ adl_barrier::TypeName<ElementType<OffsetSeq>>()...};
+ TString res = y_absl::StrCat("@0", types[0], "(", sizes[0], ")");
+ for (size_t i = 0; i != NumOffsets - 1; ++i) {
+ y_absl::StrAppend(&res, "[", DebugSize(i), "]; @", offsets[i + 1],
+ types[i + 1], "(", sizes[i + 1], ")");
+ }
+ // NumSizes is a constant that may be zero. Some compilers cannot see that
+ // inside the if statement "size_[NumSizes - 1]" must be valid.
+ int last = static_cast<int>(NumSizes) - 1;
+ if (NumTypes == NumSizes && last >= 0) {
+ y_absl::StrAppend(&res, "[", DebugSize(static_cast<size_t>(last)), "]");
+ }
+ return res;
+ }
+
+ private:
+ size_t DebugSize(size_t n) const {
+ if (n < NumStaticSizes) {
+ return kStaticSizes[n];
+ } else {
+ return size_[n - NumStaticSizes];
+ }
+ }
+
+ // Arguments of `Layout::Partial()` or `Layout::Layout()`.
+ size_t size_[NumRuntimeSizes > 0 ? NumRuntimeSizes : 1];
+};
+
+// Defining a constexpr static class member variable is redundant and deprecated
+// in C++17, but required in C++14.
+template <class... Elements, size_t... StaticSizeSeq, size_t... RuntimeSizeSeq,
+ size_t... SizeSeq, size_t... OffsetSeq>
+constexpr std::array<size_t, sizeof...(StaticSizeSeq)> LayoutImpl<
+ std::tuple<Elements...>, y_absl::index_sequence<StaticSizeSeq...>,
+ y_absl::index_sequence<RuntimeSizeSeq...>, y_absl::index_sequence<SizeSeq...>,
+ y_absl::index_sequence<OffsetSeq...>>::kStaticSizes;
+
+template <class StaticSizeSeq, size_t NumRuntimeSizes, class... Ts>
+using LayoutType = LayoutImpl<
+ std::tuple<Ts...>, StaticSizeSeq,
+ y_absl::make_index_sequence<NumRuntimeSizes>,
+ y_absl::make_index_sequence<NumRuntimeSizes + StaticSizeSeq::size()>,
+ y_absl::make_index_sequence<adl_barrier::Min(
+ sizeof...(Ts), NumRuntimeSizes + StaticSizeSeq::size() + 1)>>;
+
+template <class StaticSizeSeq, class... Ts>
+class LayoutWithStaticSizes
+ : public LayoutType<StaticSizeSeq,
+ sizeof...(Ts) - adl_barrier::Min(sizeof...(Ts),
+ StaticSizeSeq::size()),
+ Ts...> {
+ private:
+ using Super =
+ LayoutType<StaticSizeSeq,
+ sizeof...(Ts) -
+ adl_barrier::Min(sizeof...(Ts), StaticSizeSeq::size()),
+ Ts...>;
+
+ public:
+ // The result type of `Partial()` with `NumSizes` arguments.
+ template <size_t NumSizes>
+ using PartialType =
+ internal_layout::LayoutType<StaticSizeSeq, NumSizes, Ts...>;
+
+ // `Layout` knows the element types of the arrays we want to lay out in
+ // memory but not the number of elements in each array.
+ // `Partial(size1, ..., sizeN)` allows us to specify the latter. The
+ // resulting immutable object can be used to obtain pointers to the
+ // individual arrays.
+ //
+ // It's allowed to pass fewer array sizes than the number of arrays. E.g.,
+ // if all you need is to the offset of the second array, you only need to
+ // pass one argument -- the number of elements in the first array.
+ //
+ // // int[3] followed by 4 bytes of padding and an unknown number of
+ // // doubles.
+ // auto x = Layout<int, double>::Partial(3);
+ // // doubles start at byte 16.
+ // assert(x.Offset<1>() == 16);
+ //
+ // If you know the number of elements in all arrays, you can still call
+ // `Partial()` but it's more convenient to use the constructor of `Layout`.
+ //
+ // Layout<int, double> x(3, 5);
+ //
+ // Note: The sizes of the arrays must be specified in number of elements,
+ // not in bytes.
+ //
+ // Requires: `sizeof...(Sizes) + NumStaticSizes <= sizeof...(Ts)`.
+ // Requires: all arguments are convertible to `size_t`.
+ template <class... Sizes>
+ static constexpr PartialType<sizeof...(Sizes)> Partial(Sizes&&... sizes) {
+ static_assert(sizeof...(Sizes) + StaticSizeSeq::size() <= sizeof...(Ts),
+ "");
+ return PartialType<sizeof...(Sizes)>(
+ static_cast<size_t>(std::forward<Sizes>(sizes))...);
+ }
+
+ // Inherit LayoutType's constructor.
+ //
+ // Creates a layout with the sizes of all arrays specified. If you know
+ // only the sizes of the first N arrays (where N can be zero), you can use
+ // `Partial()` defined above. The constructor is essentially equivalent to
+ // calling `Partial()` and passing in all array sizes; the constructor is
+ // provided as a convenient abbreviation.
+ //
+ // Note: The sizes of the arrays must be specified in number of elements,
+ // not in bytes.
+ //
+ // Implementation note: we do this via a `using` declaration instead of
+ // defining our own explicit constructor because the signature of LayoutType's
+ // constructor depends on RuntimeSizeSeq, which we don't have access to here.
+ // If we defined our own constructor here, it would have to use a parameter
+ // pack and then cast the arguments to size_t when calling the superclass
+ // constructor, similar to what Partial() does. But that would suffer from the
+ // same problem that Partial() has, which is that the parameter types are
+ // inferred from the arguments, which may be signed types, which must then be
+ // cast to size_t. This can lead to negative values being silently (i.e. with
+ // no compiler warnings) cast to an unsigned type. Having a constructor with
+ // size_t parameters helps the compiler generate better warnings about
+ // potential bad casts, while avoiding false warnings when positive literal
+ // arguments are used. If an argument is a positive literal integer (e.g.
+ // `1`), the compiler will understand that it can be safely converted to
+ // size_t, and hence not generate a warning. But if a negative literal (e.g.
+ // `-1`) or a variable with signed type is used, then it can generate a
+ // warning about a potentially unsafe implicit cast. It would be great if we
+ // could do this for Partial() too, but unfortunately as of C++23 there seems
+ // to be no way to define a function with a variable number of parameters of a
+ // certain type, a.k.a. homogeneous function parameter packs. So we're forced
+ // to choose between explicitly casting the arguments to size_t, which
+ // suppresses all warnings, even potentially valid ones, or implicitly casting
+ // them to size_t, which generates bogus warnings whenever literal arguments
+ // are used, even if they're positive.
+ using Super::Super;
+};
+
+} // namespace internal_layout
+
+// Descriptor of arrays of various types and sizes laid out in memory one after
+// another. See the top of the file for documentation.
+//
+// Check out the public API of internal_layout::LayoutWithStaticSizes and
+// internal_layout::LayoutImpl above. Those types are internal to the library
+// but their methods are public, and they are inherited by `Layout`.
+template <class... Ts>
+class Layout : public internal_layout::LayoutWithStaticSizes<
+ y_absl::make_index_sequence<0>, Ts...> {
+ private:
+ using Super =
+ internal_layout::LayoutWithStaticSizes<y_absl::make_index_sequence<0>,
+ Ts...>;
+
+ public:
+ // If you know the sizes of some or all of the arrays at compile time, you can
+ // use `WithStaticSizes` or `WithStaticSizeSequence` to create a `Layout` type
+ // with those sizes baked in. This can help the compiler generate optimal code
+ // for calculating array offsets and AllocSize().
+ //
+ // Like `Partial()`, the N sizes you specify are for the first N arrays, and
+ // they specify the number of elements in each array, not the number of bytes.
+ template <class StaticSizeSeq>
+ using WithStaticSizeSequence =
+ internal_layout::LayoutWithStaticSizes<StaticSizeSeq, Ts...>;
+
+ template <size_t... StaticSizes>
+ using WithStaticSizes =
+ WithStaticSizeSequence<std::index_sequence<StaticSizes...>>;
+
+ // Inherit LayoutWithStaticSizes's constructor, which requires you to specify
+ // all the array sizes.
+ using Super::Super;
+};
+
+} // namespace container_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_CONTAINER_INTERNAL_LAYOUT_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/crc/crc32c.h b/contrib/restricted/abseil-cpp-tstring/y_absl/crc/crc32c.h
index bcd5b96a3c9..e59964737ec 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/crc/crc32c.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/crc/crc32c.h
@@ -180,9 +180,11 @@ crc32c_t RemoveCrc32cSuffix(crc32c_t full_string_crc, crc32c_t suffix_crc,
// operator<<
//
// Streams the CRC32C value `crc` to the stream `os`.
+#ifndef __NVCC__
inline std::ostream& operator<<(std::ostream& os, crc32c_t crc) {
return os << y_absl::StreamFormat("%08x", static_cast<uint32_t>(crc));
}
+#endif
Y_ABSL_NAMESPACE_END
} // namespace y_absl
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/ya.make
index 5616819583e..b4b02674490 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/ya.make
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/ya.make
@@ -19,6 +19,7 @@ ADDINCL(
NO_COMPILER_WARNINGS()
+IF(NOT Y_ABSL_DONT_USE_DEBUG)
SRCS(
failure_signal_handler.cc
internal/address_is_readable.cc
@@ -33,5 +34,6 @@ SRCS(
stacktrace.cc
symbolize.cc
)
+ENDIF()
END()
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/absl_check.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/absl_check.h
new file mode 100644
index 00000000000..1b4a92956d7
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/absl_check.h
@@ -0,0 +1,117 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: log/absl_check.h
+// -----------------------------------------------------------------------------
+//
+// This header declares a family of `Y_ABSL_CHECK` macros as alternative spellings
+// for `CHECK` macros in `check.h`.
+//
+// Except for those whose names begin with `Y_ABSL_DCHECK`, these macros are not
+// controlled by `NDEBUG` (cf. `assert`), so the check will be executed
+// regardless of compilation mode. `Y_ABSL_CHECK` and friends are thus useful for
+// confirming invariants in situations where continuing to run would be worse
+// than terminating, e.g., due to risk of data corruption or security
+// compromise. It is also more robust and portable to deliberately terminate
+// at a particular place with a useful message and backtrace than to assume some
+// ultimately unspecified and unreliable crashing behavior (such as a
+// "segmentation fault").
+//
+// For full documentation of each macro, see comments in `check.h`, which has an
+// identical set of macros without the Y_ABSL_* prefix.
+
+#ifndef Y_ABSL_LOG_ABSL_CHECK_H_
+#define Y_ABSL_LOG_ABSL_CHECK_H_
+
+#include "y_absl/log/internal/check_impl.h"
+
+#define Y_ABSL_CHECK(condition) \
+ Y_ABSL_LOG_INTERNAL_CHECK_IMPL((condition), #condition)
+#define Y_ABSL_QCHECK(condition) \
+ Y_ABSL_LOG_INTERNAL_QCHECK_IMPL((condition), #condition)
+#define Y_ABSL_PCHECK(condition) \
+ Y_ABSL_LOG_INTERNAL_PCHECK_IMPL((condition), #condition)
+#define Y_ABSL_DCHECK(condition) \
+ Y_ABSL_LOG_INTERNAL_DCHECK_IMPL((condition), #condition)
+
+#define Y_ABSL_CHECK_EQ(val1, val2) \
+ Y_ABSL_LOG_INTERNAL_CHECK_EQ_IMPL((val1), #val1, (val2), #val2)
+#define Y_ABSL_CHECK_NE(val1, val2) \
+ Y_ABSL_LOG_INTERNAL_CHECK_NE_IMPL((val1), #val1, (val2), #val2)
+#define Y_ABSL_CHECK_LE(val1, val2) \
+ Y_ABSL_LOG_INTERNAL_CHECK_LE_IMPL((val1), #val1, (val2), #val2)
+#define Y_ABSL_CHECK_LT(val1, val2) \
+ Y_ABSL_LOG_INTERNAL_CHECK_LT_IMPL((val1), #val1, (val2), #val2)
+#define Y_ABSL_CHECK_GE(val1, val2) \
+ Y_ABSL_LOG_INTERNAL_CHECK_GE_IMPL((val1), #val1, (val2), #val2)
+#define Y_ABSL_CHECK_GT(val1, val2) \
+ Y_ABSL_LOG_INTERNAL_CHECK_GT_IMPL((val1), #val1, (val2), #val2)
+#define Y_ABSL_QCHECK_EQ(val1, val2) \
+ Y_ABSL_LOG_INTERNAL_QCHECK_EQ_IMPL((val1), #val1, (val2), #val2)
+#define Y_ABSL_QCHECK_NE(val1, val2) \
+ Y_ABSL_LOG_INTERNAL_QCHECK_NE_IMPL((val1), #val1, (val2), #val2)
+#define Y_ABSL_QCHECK_LE(val1, val2) \
+ Y_ABSL_LOG_INTERNAL_QCHECK_LE_IMPL((val1), #val1, (val2), #val2)
+#define Y_ABSL_QCHECK_LT(val1, val2) \
+ Y_ABSL_LOG_INTERNAL_QCHECK_LT_IMPL((val1), #val1, (val2), #val2)
+#define Y_ABSL_QCHECK_GE(val1, val2) \
+ Y_ABSL_LOG_INTERNAL_QCHECK_GE_IMPL((val1), #val1, (val2), #val2)
+#define Y_ABSL_QCHECK_GT(val1, val2) \
+ Y_ABSL_LOG_INTERNAL_QCHECK_GT_IMPL((val1), #val1, (val2), #val2)
+#define Y_ABSL_DCHECK_EQ(val1, val2) \
+ Y_ABSL_LOG_INTERNAL_DCHECK_EQ_IMPL((val1), #val1, (val2), #val2)
+#define Y_ABSL_DCHECK_NE(val1, val2) \
+ Y_ABSL_LOG_INTERNAL_DCHECK_NE_IMPL((val1), #val1, (val2), #val2)
+#define Y_ABSL_DCHECK_LE(val1, val2) \
+ Y_ABSL_LOG_INTERNAL_DCHECK_LE_IMPL((val1), #val1, (val2), #val2)
+#define Y_ABSL_DCHECK_LT(val1, val2) \
+ Y_ABSL_LOG_INTERNAL_DCHECK_LT_IMPL((val1), #val1, (val2), #val2)
+#define Y_ABSL_DCHECK_GE(val1, val2) \
+ Y_ABSL_LOG_INTERNAL_DCHECK_GE_IMPL((val1), #val1, (val2), #val2)
+#define Y_ABSL_DCHECK_GT(val1, val2) \
+ Y_ABSL_LOG_INTERNAL_DCHECK_GT_IMPL((val1), #val1, (val2), #val2)
+
+#define Y_ABSL_CHECK_OK(status) Y_ABSL_LOG_INTERNAL_CHECK_OK_IMPL((status), #status)
+#define Y_ABSL_QCHECK_OK(status) \
+ Y_ABSL_LOG_INTERNAL_QCHECK_OK_IMPL((status), #status)
+#define Y_ABSL_DCHECK_OK(status) \
+ Y_ABSL_LOG_INTERNAL_DCHECK_OK_IMPL((status), #status)
+
+#define Y_ABSL_CHECK_STREQ(s1, s2) \
+ Y_ABSL_LOG_INTERNAL_CHECK_STREQ_IMPL((s1), #s1, (s2), #s2)
+#define Y_ABSL_CHECK_STRNE(s1, s2) \
+ Y_ABSL_LOG_INTERNAL_CHECK_STRNE_IMPL((s1), #s1, (s2), #s2)
+#define Y_ABSL_CHECK_STRCASEEQ(s1, s2) \
+ Y_ABSL_LOG_INTERNAL_CHECK_STRCASEEQ_IMPL((s1), #s1, (s2), #s2)
+#define Y_ABSL_CHECK_STRCASENE(s1, s2) \
+ Y_ABSL_LOG_INTERNAL_CHECK_STRCASENE_IMPL((s1), #s1, (s2), #s2)
+#define Y_ABSL_QCHECK_STREQ(s1, s2) \
+ Y_ABSL_LOG_INTERNAL_QCHECK_STREQ_IMPL((s1), #s1, (s2), #s2)
+#define Y_ABSL_QCHECK_STRNE(s1, s2) \
+ Y_ABSL_LOG_INTERNAL_QCHECK_STRNE_IMPL((s1), #s1, (s2), #s2)
+#define Y_ABSL_QCHECK_STRCASEEQ(s1, s2) \
+ Y_ABSL_LOG_INTERNAL_QCHECK_STRCASEEQ_IMPL((s1), #s1, (s2), #s2)
+#define Y_ABSL_QCHECK_STRCASENE(s1, s2) \
+ Y_ABSL_LOG_INTERNAL_QCHECK_STRCASENE_IMPL((s1), #s1, (s2), #s2)
+#define Y_ABSL_DCHECK_STREQ(s1, s2) \
+ Y_ABSL_LOG_INTERNAL_DCHECK_STREQ_IMPL((s1), #s1, (s2), #s2)
+#define Y_ABSL_DCHECK_STRNE(s1, s2) \
+ Y_ABSL_LOG_INTERNAL_DCHECK_STRNE_IMPL((s1), #s1, (s2), #s2)
+#define Y_ABSL_DCHECK_STRCASEEQ(s1, s2) \
+ Y_ABSL_LOG_INTERNAL_DCHECK_STRCASEEQ_IMPL((s1), #s1, (s2), #s2)
+#define Y_ABSL_DCHECK_STRCASENE(s1, s2) \
+ Y_ABSL_LOG_INTERNAL_DCHECK_STRCASENE_IMPL((s1), #s1, (s2), #s2)
+
+#endif // Y_ABSL_LOG_ABSL_CHECK_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/absl_log.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/absl_log.h
new file mode 100644
index 00000000000..9f85aede812
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/absl_log.h
@@ -0,0 +1,115 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: log/absl_log.h
+// -----------------------------------------------------------------------------
+//
+// This header declares a family of `Y_ABSL_LOG` macros as alternative spellings
+// for macros in `log.h`.
+//
+// Basic invocation looks like this:
+//
+// Y_ABSL_LOG(INFO) << "Found " << num_cookies << " cookies";
+//
+// Most `Y_ABSL_LOG` macros take a severity level argument. The severity levels
+// are `INFO`, `WARNING`, `ERROR`, and `FATAL`.
+//
+// For full documentation, see comments in `log.h`, which includes full
+// reference documentation on use of the equivalent `LOG` macro and has an
+// identical set of macros without the Y_ABSL_* prefix.
+
+#ifndef Y_ABSL_LOG_ABSL_LOG_H_
+#define Y_ABSL_LOG_ABSL_LOG_H_
+
+#include "y_absl/log/internal/log_impl.h"
+
+#define Y_ABSL_LOG(severity) Y_ABSL_LOG_INTERNAL_LOG_IMPL(_##severity)
+#define Y_ABSL_PLOG(severity) Y_ABSL_LOG_INTERNAL_PLOG_IMPL(_##severity)
+#define Y_ABSL_DLOG(severity) Y_ABSL_LOG_INTERNAL_DLOG_IMPL(_##severity)
+
+#define Y_ABSL_VLOG(verbose_level) Y_ABSL_LOG_INTERNAL_VLOG_IMPL(verbose_level)
+#define Y_ABSL_DVLOG(verbose_level) Y_ABSL_LOG_INTERNAL_DVLOG_IMPL(verbose_level)
+
+#define Y_ABSL_LOG_IF(severity, condition) \
+ Y_ABSL_LOG_INTERNAL_LOG_IF_IMPL(_##severity, condition)
+#define Y_ABSL_PLOG_IF(severity, condition) \
+ Y_ABSL_LOG_INTERNAL_PLOG_IF_IMPL(_##severity, condition)
+#define Y_ABSL_DLOG_IF(severity, condition) \
+ Y_ABSL_LOG_INTERNAL_DLOG_IF_IMPL(_##severity, condition)
+
+#define Y_ABSL_LOG_EVERY_N(severity, n) \
+ Y_ABSL_LOG_INTERNAL_LOG_EVERY_N_IMPL(_##severity, n)
+#define Y_ABSL_LOG_FIRST_N(severity, n) \
+ Y_ABSL_LOG_INTERNAL_LOG_FIRST_N_IMPL(_##severity, n)
+#define Y_ABSL_LOG_EVERY_POW_2(severity) \
+ Y_ABSL_LOG_INTERNAL_LOG_EVERY_POW_2_IMPL(_##severity)
+#define Y_ABSL_LOG_EVERY_N_SEC(severity, n_seconds) \
+ Y_ABSL_LOG_INTERNAL_LOG_EVERY_N_SEC_IMPL(_##severity, n_seconds)
+
+#define Y_ABSL_PLOG_EVERY_N(severity, n) \
+ Y_ABSL_LOG_INTERNAL_PLOG_EVERY_N_IMPL(_##severity, n)
+#define Y_ABSL_PLOG_FIRST_N(severity, n) \
+ Y_ABSL_LOG_INTERNAL_PLOG_FIRST_N_IMPL(_##severity, n)
+#define Y_ABSL_PLOG_EVERY_POW_2(severity) \
+ Y_ABSL_LOG_INTERNAL_PLOG_EVERY_POW_2_IMPL(_##severity)
+#define Y_ABSL_PLOG_EVERY_N_SEC(severity, n_seconds) \
+ Y_ABSL_LOG_INTERNAL_PLOG_EVERY_N_SEC_IMPL(_##severity, n_seconds)
+
+#define Y_ABSL_DLOG_EVERY_N(severity, n) \
+ Y_ABSL_LOG_INTERNAL_DLOG_EVERY_N_IMPL(_##severity, n)
+#define Y_ABSL_DLOG_FIRST_N(severity, n) \
+ Y_ABSL_LOG_INTERNAL_DLOG_FIRST_N_IMPL(_##severity, n)
+#define Y_ABSL_DLOG_EVERY_POW_2(severity) \
+ Y_ABSL_LOG_INTERNAL_DLOG_EVERY_POW_2_IMPL(_##severity)
+#define Y_ABSL_DLOG_EVERY_N_SEC(severity, n_seconds) \
+ Y_ABSL_LOG_INTERNAL_DLOG_EVERY_N_SEC_IMPL(_##severity, n_seconds)
+
+#define Y_ABSL_VLOG_EVERY_N(verbose_level, n) \
+ Y_ABSL_LOG_INTERNAL_VLOG_EVERY_N_IMPL(verbose_level, n)
+#define Y_ABSL_VLOG_FIRST_N(verbose_level, n) \
+ Y_ABSL_LOG_INTERNAL_VLOG_FIRST_N_IMPL(verbose_level, n)
+#define Y_ABSL_VLOG_EVERY_POW_2(verbose_level, n) \
+ Y_ABSL_LOG_INTERNAL_VLOG_EVERY_POW_2_IMPL(verbose_level, n)
+#define Y_ABSL_VLOG_EVERY_N_SEC(verbose_level, n) \
+ Y_ABSL_LOG_INTERNAL_VLOG_EVERY_N_SEC_IMPL(verbose_level, n)
+
+#define Y_ABSL_LOG_IF_EVERY_N(severity, condition, n) \
+ Y_ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_IMPL(_##severity, condition, n)
+#define Y_ABSL_LOG_IF_FIRST_N(severity, condition, n) \
+ Y_ABSL_LOG_INTERNAL_LOG_IF_FIRST_N_IMPL(_##severity, condition, n)
+#define Y_ABSL_LOG_IF_EVERY_POW_2(severity, condition) \
+ Y_ABSL_LOG_INTERNAL_LOG_IF_EVERY_POW_2_IMPL(_##severity, condition)
+#define Y_ABSL_LOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \
+ Y_ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds)
+
+#define Y_ABSL_PLOG_IF_EVERY_N(severity, condition, n) \
+ Y_ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_IMPL(_##severity, condition, n)
+#define Y_ABSL_PLOG_IF_FIRST_N(severity, condition, n) \
+ Y_ABSL_LOG_INTERNAL_PLOG_IF_FIRST_N_IMPL(_##severity, condition, n)
+#define Y_ABSL_PLOG_IF_EVERY_POW_2(severity, condition) \
+ Y_ABSL_LOG_INTERNAL_PLOG_IF_EVERY_POW_2_IMPL(_##severity, condition)
+#define Y_ABSL_PLOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \
+ Y_ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds)
+
+#define Y_ABSL_DLOG_IF_EVERY_N(severity, condition, n) \
+ Y_ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_IMPL(_##severity, condition, n)
+#define Y_ABSL_DLOG_IF_FIRST_N(severity, condition, n) \
+ Y_ABSL_LOG_INTERNAL_DLOG_IF_FIRST_N_IMPL(_##severity, condition, n)
+#define Y_ABSL_DLOG_IF_EVERY_POW_2(severity, condition) \
+ Y_ABSL_LOG_INTERNAL_DLOG_IF_EVERY_POW_2_IMPL(_##severity, condition)
+#define Y_ABSL_DLOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \
+ Y_ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds)
+
+#endif // Y_ABSL_LOG_ABSL_LOG_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/absl_vlog_is_on.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/absl_vlog_is_on.h
new file mode 100644
index 00000000000..5d925d4b55a
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/absl_vlog_is_on.h
@@ -0,0 +1,93 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: log/absl_vlog_is_on.h
+// -----------------------------------------------------------------------------
+//
+// This header defines the `Y_ABSL_VLOG_IS_ON()` macro that controls the
+// variable-verbosity conditional logging.
+//
+// It's used by `VLOG` in log.h, or it can also be used directly like this:
+//
+// if (Y_ABSL_VLOG_IS_ON(2)) {
+// foo_server.RecomputeStatisticsExpensive();
+// LOG(INFO) << foo_server.LastStatisticsAsString();
+// }
+//
+// Each source file has an effective verbosity level that's a non-negative
+// integer computed from the `--vmodule` and `--v` flags.
+// `Y_ABSL_VLOG_IS_ON(n)` is true, and `VLOG(n)` logs, if that effective verbosity
+// level is greater than or equal to `n`.
+//
+// `--vmodule` takes a comma-delimited list of key=value pairs. Each key is a
+// pattern matched against filenames, and the values give the effective severity
+// level applied to matching files. '?' and '*' characters in patterns are
+// interpreted as single-character and zero-or-more-character wildcards.
+// Patterns including a slash character are matched against full pathnames,
+// while those without are matched against basenames only. One suffix (i.e. the
+// last . and everything after it) is stripped from each filename prior to
+// matching, as is the special suffix "-inl".
+//
+// Files are matched against globs in `--vmodule` in order, and the first match
+// determines the verbosity level.
+//
+// Files which do not match any pattern in `--vmodule` use the value of `--v` as
+// their effective verbosity level. The default is 0.
+//
+// SetVLogLevel helper function is provided to do limited dynamic control over
+// V-logging by appending to `--vmodule`. Because these go at the beginning of
+// the list, they take priority over any globs previously added.
+//
+// Resetting --vmodule will override all previous modifications to `--vmodule`,
+// including via SetVLogLevel.
+
+#ifndef Y_ABSL_LOG_ABSL_VLOG_IS_ON_H_
+#define Y_ABSL_LOG_ABSL_VLOG_IS_ON_H_
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/base/config.h"
+#include "y_absl/log/internal/vlog_config.h" // IWYU pragma: export
+#include "y_absl/strings/string_view.h"
+
+// IWYU pragma: private, include "y_absl/log/log.h"
+
+// This is expanded at the callsite to allow the compiler to optimize
+// always-false cases out of the build.
+// An Y_ABSL_MAX_VLOG_VERBOSITY of 2 means that VLOG(3) and above should never
+// log.
+#ifdef Y_ABSL_MAX_VLOG_VERBOSITY
+#define Y_ABSL_LOG_INTERNAL_MAX_LOG_VERBOSITY_CHECK(x) \
+ ((x) <= Y_ABSL_MAX_VLOG_VERBOSITY)&&
+#else
+#define Y_ABSL_LOG_INTERNAL_MAX_LOG_VERBOSITY_CHECK(x)
+#endif
+
+// Each Y_ABSL_VLOG_IS_ON call site gets its own VLogSite that registers with the
+// global linked list of sites to asynchronously update its verbosity level on
+// changes to --v or --vmodule. The verbosity can also be set by manually
+// calling SetVLogLevel.
+//
+// Y_ABSL_VLOG_IS_ON is not async signal safe, but it is guaranteed not to
+// allocate new memory.
+#define Y_ABSL_VLOG_IS_ON(verbose_level) \
+ (Y_ABSL_LOG_INTERNAL_MAX_LOG_VERBOSITY_CHECK(verbose_level)[]() \
+ ->::y_absl::log_internal::VLogSite * \
+ { \
+ Y_ABSL_CONST_INIT static ::y_absl::log_internal::VLogSite site(__FILE__); \
+ return &site; \
+ }() \
+ ->IsEnabled(verbose_level))
+
+#endif // Y_ABSL_LOG_ABSL_VLOG_IS_ON_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/die_if_null.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/log/die_if_null.cc
new file mode 100644
index 00000000000..a9c81f130ad
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/die_if_null.cc
@@ -0,0 +1,32 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "y_absl/log/die_if_null.h"
+
+#include "y_absl/base/config.h"
+#include "y_absl/log/log.h"
+#include "y_absl/strings/str_cat.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+
+void DieBecauseNull(const char* file, int line, const char* exprtext) {
+ LOG(FATAL).AtLocation(file, line)
+ << y_absl::StrCat("Check failed: '", exprtext, "' Must be non-null");
+}
+
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/die_if_null.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/die_if_null.h
new file mode 100644
index 00000000000..75a2cb73d67
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/die_if_null.h
@@ -0,0 +1,76 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: log/die_if_null.h
+// -----------------------------------------------------------------------------
+//
+// This header declares macro `Y_ABSL_DIE_IF_NULL`.
+
+#ifndef Y_ABSL_LOG_DIE_IF_NULL_H_
+#define Y_ABSL_LOG_DIE_IF_NULL_H_
+
+#include <stdint.h>
+
+#include <utility>
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/base/config.h"
+#include "y_absl/base/optimization.h"
+
+// Y_ABSL_DIE_IF_NULL()
+//
+// `Y_ABSL_DIE_IF_NULL` behaves as `CHECK_NE` against `nullptr` but *also*
+// "returns" its argument. It is useful in initializers where statements (like
+// `CHECK_NE`) can't be used. Outside initializers, prefer `CHECK` or
+// `CHECK_NE`. `Y_ABSL_DIE_IF_NULL` works for both raw pointers and (compatible)
+// smart pointers including `std::unique_ptr` and `std::shared_ptr`; more
+// generally, it works for any type that can be compared to nullptr_t. For
+// types that aren't raw pointers, `Y_ABSL_DIE_IF_NULL` returns a reference to
+// its argument, preserving the value category. Example:
+//
+// Foo() : bar_(Y_ABSL_DIE_IF_NULL(MethodReturningUniquePtr())) {}
+//
+// Use `CHECK(ptr)` or `CHECK(ptr != nullptr)` if the returned pointer is
+// unused.
+#define Y_ABSL_DIE_IF_NULL(val) \
+ ::y_absl::log_internal::DieIfNull(__FILE__, __LINE__, #val, (val))
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+
+// Crashes the process after logging `exprtext` annotated at the `file` and
+// `line` location. Called when `Y_ABSL_DIE_IF_NULL` fails. Calling this function
+// generates less code than its implementation would if inlined, for a slight
+// code size reduction each time `Y_ABSL_DIE_IF_NULL` is called.
+[[noreturn]] Y_ABSL_ATTRIBUTE_NOINLINE void DieBecauseNull(
+ const char* file, int line, const char* exprtext);
+
+// Helper for `Y_ABSL_DIE_IF_NULL`.
+template <typename T>
+Y_ABSL_MUST_USE_RESULT T DieIfNull(const char* file, int line,
+ const char* exprtext, T&& t) {
+ if (Y_ABSL_PREDICT_FALSE(t == nullptr)) {
+ // Call a non-inline helper function for a small code size improvement.
+ DieBecauseNull(file, line, exprtext);
+ }
+ return std::forward<T>(t);
+}
+
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_LOG_DIE_IF_NULL_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/flags.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/log/flags.cc
new file mode 100644
index 00000000000..25586b7462e
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/flags.cc
@@ -0,0 +1,143 @@
+//
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "y_absl/log/internal/flags.h"
+
+#include <stddef.h>
+
+#include <algorithm>
+#include <cstdlib>
+#include <util/generic/string.h>
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/base/config.h"
+#include "y_absl/base/log_severity.h"
+#include "y_absl/flags/flag.h"
+#include "y_absl/flags/marshalling.h"
+#include "y_absl/log/globals.h"
+#include "y_absl/log/internal/config.h"
+#include "y_absl/log/internal/vlog_config.h"
+#include "y_absl/strings/numbers.h"
+#include "y_absl/strings/string_view.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+namespace {
+
+void SyncLoggingFlags() {
+ y_absl::SetFlag(&FLAGS_minloglevel, static_cast<int>(y_absl::MinLogLevel()));
+ y_absl::SetFlag(&FLAGS_log_prefix, y_absl::ShouldPrependLogPrefix());
+}
+
+bool RegisterSyncLoggingFlags() {
+ log_internal::SetLoggingGlobalsListener(&SyncLoggingFlags);
+ return true;
+}
+
+Y_ABSL_ATTRIBUTE_UNUSED const bool unused = RegisterSyncLoggingFlags();
+
+template <typename T>
+T GetFromEnv(const char* varname, T dflt) {
+ const char* val = ::getenv(varname);
+ if (val != nullptr) {
+ TString err;
+ Y_ABSL_INTERNAL_CHECK(y_absl::ParseFlag(val, &dflt, &err), err.c_str());
+ }
+ return dflt;
+}
+
+constexpr y_absl::LogSeverityAtLeast StderrThresholdDefault() {
+ return y_absl::LogSeverityAtLeast::kError;
+}
+
+} // namespace
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+Y_ABSL_FLAG(int, stderrthreshold,
+ static_cast<int>(y_absl::log_internal::StderrThresholdDefault()),
+ "Log messages at or above this threshold level are copied to stderr.")
+ .OnUpdate([] {
+ y_absl::log_internal::RawSetStderrThreshold(
+ static_cast<y_absl::LogSeverityAtLeast>(
+ y_absl::GetFlag(FLAGS_stderrthreshold)));
+ });
+
+Y_ABSL_FLAG(int, minloglevel, static_cast<int>(y_absl::LogSeverityAtLeast::kInfo),
+ "Messages logged at a lower level than this don't actually "
+ "get logged anywhere")
+ .OnUpdate([] {
+ y_absl::log_internal::RawSetMinLogLevel(
+ static_cast<y_absl::LogSeverityAtLeast>(
+ y_absl::GetFlag(FLAGS_minloglevel)));
+ });
+
+Y_ABSL_FLAG(TString, log_backtrace_at, "",
+ "Emit a backtrace when logging at file:linenum.")
+ .OnUpdate([] {
+ const TString log_backtrace_at =
+ y_absl::GetFlag(FLAGS_log_backtrace_at);
+ if (log_backtrace_at.empty()) {
+ y_absl::ClearLogBacktraceLocation();
+ return;
+ }
+
+ const size_t last_colon = log_backtrace_at.rfind(':');
+ if (last_colon == log_backtrace_at.npos) {
+ y_absl::ClearLogBacktraceLocation();
+ return;
+ }
+
+ const y_absl::string_view file =
+ y_absl::string_view(log_backtrace_at).substr(0, last_colon);
+ int line;
+ if (!y_absl::SimpleAtoi(
+ y_absl::string_view(log_backtrace_at).substr(last_colon + 1),
+ &line)) {
+ y_absl::ClearLogBacktraceLocation();
+ return;
+ }
+ y_absl::SetLogBacktraceLocation(file, line);
+ });
+
+Y_ABSL_FLAG(bool, log_prefix, true,
+ "Prepend the log prefix to the start of each log line")
+ .OnUpdate([] {
+ y_absl::log_internal::RawEnableLogPrefix(y_absl::GetFlag(FLAGS_log_prefix));
+ });
+
+Y_ABSL_FLAG(int, v, 0,
+ "Show all VLOG(m) messages for m <= this. Overridable by --vmodule.")
+ .OnUpdate([] {
+ y_absl::log_internal::UpdateGlobalVLogLevel(y_absl::GetFlag(FLAGS_v));
+ });
+
+Y_ABSL_FLAG(
+ TString, vmodule, "",
+ "per-module log verbosity level."
+ " Argument is a comma-separated list of <module name>=<log level>."
+ " <module name> is a glob pattern, matched against the filename base"
+ " (that is, name ignoring .cc/.h./-inl.h)."
+ " A pattern without slashes matches just the file name portion, otherwise"
+ " the whole file path below the workspace root"
+ " (still without .cc/.h./-inl.h) is matched."
+ " ? and * in the glob pattern match any single or sequence of characters"
+ " respectively including slashes."
+ " <log level> overrides any value given by --v.")
+ .OnUpdate([] {
+ y_absl::log_internal::UpdateVModule(y_absl::GetFlag(FLAGS_vmodule));
+ });
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/globals.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/log/globals.cc
new file mode 100644
index 00000000000..7d3cb5e3dd0
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/globals.cc
@@ -0,0 +1,178 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "y_absl/log/globals.h"
+
+#include <atomic>
+#include <cstddef>
+#include <cstdint>
+#include <cstdlib>
+#include <cstring>
+#include <util/generic/string.h>
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/base/config.h"
+#include "y_absl/base/internal/atomic_hook.h"
+#include "y_absl/base/internal/raw_logging.h"
+#include "y_absl/base/log_severity.h"
+#include "y_absl/hash/hash.h"
+#include "y_absl/strings/string_view.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace {
+
+// These atomics represent logging library configuration.
+// Integer types are used instead of y_absl::LogSeverity to ensure that a
+// lock-free std::atomic is used when possible.
+Y_ABSL_CONST_INIT std::atomic<int> min_log_level{
+ static_cast<int>(y_absl::LogSeverityAtLeast::kInfo)};
+Y_ABSL_CONST_INIT std::atomic<int> stderrthreshold{
+ static_cast<int>(y_absl::LogSeverityAtLeast::kError)};
+// We evaluate this value as a hash comparison to avoid having to
+// hold a mutex or make a copy (to access the value of a string-typed flag) in
+// very hot codepath.
+Y_ABSL_CONST_INIT std::atomic<size_t> log_backtrace_at_hash{0};
+Y_ABSL_CONST_INIT std::atomic<bool> prepend_log_prefix{true};
+
+constexpr char kDefaultAndroidTag[] = "native";
+Y_ABSL_CONST_INIT std::atomic<const char*> android_log_tag{kDefaultAndroidTag};
+
+Y_ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES
+y_absl::base_internal::AtomicHook<log_internal::LoggingGlobalsListener>
+ logging_globals_listener;
+
+size_t HashSiteForLogBacktraceAt(y_absl::string_view file, int line) {
+ return y_absl::HashOf(file, line);
+}
+
+void TriggerLoggingGlobalsListener() {
+ auto* listener = logging_globals_listener.Load();
+ if (listener != nullptr) listener();
+}
+
+} // namespace
+
+namespace log_internal {
+
+void RawSetMinLogLevel(y_absl::LogSeverityAtLeast severity) {
+ min_log_level.store(static_cast<int>(severity), std::memory_order_release);
+}
+
+void RawSetStderrThreshold(y_absl::LogSeverityAtLeast severity) {
+ stderrthreshold.store(static_cast<int>(severity), std::memory_order_release);
+}
+
+void RawEnableLogPrefix(bool on_off) {
+ prepend_log_prefix.store(on_off, std::memory_order_release);
+}
+
+void SetLoggingGlobalsListener(LoggingGlobalsListener l) {
+ logging_globals_listener.Store(l);
+}
+
+} // namespace log_internal
+
+y_absl::LogSeverityAtLeast MinLogLevel() {
+ return static_cast<y_absl::LogSeverityAtLeast>(
+ min_log_level.load(std::memory_order_acquire));
+}
+
+void SetMinLogLevel(y_absl::LogSeverityAtLeast severity) {
+ log_internal::RawSetMinLogLevel(severity);
+ TriggerLoggingGlobalsListener();
+}
+
+namespace log_internal {
+
+ScopedMinLogLevel::ScopedMinLogLevel(y_absl::LogSeverityAtLeast severity)
+ : saved_severity_(y_absl::MinLogLevel()) {
+ y_absl::SetMinLogLevel(severity);
+}
+ScopedMinLogLevel::~ScopedMinLogLevel() {
+ y_absl::SetMinLogLevel(saved_severity_);
+}
+
+} // namespace log_internal
+
+y_absl::LogSeverityAtLeast StderrThreshold() {
+ return static_cast<y_absl::LogSeverityAtLeast>(
+ stderrthreshold.load(std::memory_order_acquire));
+}
+
+void SetStderrThreshold(y_absl::LogSeverityAtLeast severity) {
+ log_internal::RawSetStderrThreshold(severity);
+ TriggerLoggingGlobalsListener();
+}
+
+ScopedStderrThreshold::ScopedStderrThreshold(y_absl::LogSeverityAtLeast severity)
+ : saved_severity_(y_absl::StderrThreshold()) {
+ y_absl::SetStderrThreshold(severity);
+}
+
+ScopedStderrThreshold::~ScopedStderrThreshold() {
+ y_absl::SetStderrThreshold(saved_severity_);
+}
+
+namespace log_internal {
+
+const char* GetAndroidNativeTag() {
+ return android_log_tag.load(std::memory_order_acquire);
+}
+
+} // namespace log_internal
+
+void SetAndroidNativeTag(const char* tag) {
+ Y_ABSL_CONST_INIT static std::atomic<const TString*> user_log_tag(nullptr);
+ Y_ABSL_INTERNAL_CHECK(tag, "tag must be non-null.");
+
+ const TString* tag_str = new TString(tag);
+ Y_ABSL_INTERNAL_CHECK(
+ android_log_tag.exchange(tag_str->c_str(), std::memory_order_acq_rel) ==
+ kDefaultAndroidTag,
+ "SetAndroidNativeTag() must only be called once per process!");
+ user_log_tag.store(tag_str, std::memory_order_relaxed);
+}
+
+namespace log_internal {
+
+bool ShouldLogBacktraceAt(y_absl::string_view file, int line) {
+ const size_t flag_hash =
+ log_backtrace_at_hash.load(std::memory_order_relaxed);
+
+ return flag_hash != 0 && flag_hash == HashSiteForLogBacktraceAt(file, line);
+}
+
+} // namespace log_internal
+
+void SetLogBacktraceLocation(y_absl::string_view file, int line) {
+ log_backtrace_at_hash.store(HashSiteForLogBacktraceAt(file, line),
+ std::memory_order_relaxed);
+}
+
+void ClearLogBacktraceLocation() {
+ log_backtrace_at_hash.store(0, std::memory_order_relaxed);
+}
+
+bool ShouldPrependLogPrefix() {
+ return prepend_log_prefix.load(std::memory_order_acquire);
+}
+
+void EnableLogPrefix(bool on_off) {
+ log_internal::RawEnableLogPrefix(on_off);
+ TriggerLoggingGlobalsListener();
+}
+
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/globals.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/globals.h
new file mode 100644
index 00000000000..c1337c5472d
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/globals.h
@@ -0,0 +1,231 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: log/globals.h
+// -----------------------------------------------------------------------------
+//
+// This header declares global logging library configuration knobs.
+
+#ifndef Y_ABSL_LOG_GLOBALS_H_
+#define Y_ABSL_LOG_GLOBALS_H_
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/base/config.h"
+#include "y_absl/base/log_severity.h"
+#include "y_absl/log/internal/vlog_config.h"
+#include "y_absl/strings/string_view.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+
+//------------------------------------------------------------------------------
+// Minimum Log Level
+//------------------------------------------------------------------------------
+//
+// Messages logged at or above this severity are directed to all registered log
+// sinks or skipped otherwise. This parameter can also be modified using
+// command line flag --minloglevel.
+// See y_absl/base/log_severity.h for descriptions of severity levels.
+
+// MinLogLevel()
+//
+// Returns the value of the Minimum Log Level parameter.
+// This function is async-signal-safe.
+Y_ABSL_MUST_USE_RESULT y_absl::LogSeverityAtLeast MinLogLevel();
+
+// SetMinLogLevel()
+//
+// Updates the value of Minimum Log Level parameter.
+// This function is async-signal-safe.
+void SetMinLogLevel(y_absl::LogSeverityAtLeast severity);
+
+namespace log_internal {
+
+// ScopedMinLogLevel
+//
+// RAII type used to temporarily update the Min Log Level parameter.
+class ScopedMinLogLevel final {
+ public:
+ explicit ScopedMinLogLevel(y_absl::LogSeverityAtLeast severity);
+ ScopedMinLogLevel(const ScopedMinLogLevel&) = delete;
+ ScopedMinLogLevel& operator=(const ScopedMinLogLevel&) = delete;
+ ~ScopedMinLogLevel();
+
+ private:
+ y_absl::LogSeverityAtLeast saved_severity_;
+};
+
+} // namespace log_internal
+
+//------------------------------------------------------------------------------
+// Stderr Threshold
+//------------------------------------------------------------------------------
+//
+// Messages logged at or above this level are directed to stderr in
+// addition to other registered log sinks. This parameter can also be modified
+// using command line flag --stderrthreshold.
+// See y_absl/base/log_severity.h for descriptions of severity levels.
+
+// StderrThreshold()
+//
+// Returns the value of the Stderr Threshold parameter.
+// This function is async-signal-safe.
+Y_ABSL_MUST_USE_RESULT y_absl::LogSeverityAtLeast StderrThreshold();
+
+// SetStderrThreshold()
+//
+// Updates the Stderr Threshold parameter.
+// This function is async-signal-safe.
+void SetStderrThreshold(y_absl::LogSeverityAtLeast severity);
+inline void SetStderrThreshold(y_absl::LogSeverity severity) {
+ y_absl::SetStderrThreshold(static_cast<y_absl::LogSeverityAtLeast>(severity));
+}
+
+// ScopedStderrThreshold
+//
+// RAII type used to temporarily update the Stderr Threshold parameter.
+class ScopedStderrThreshold final {
+ public:
+ explicit ScopedStderrThreshold(y_absl::LogSeverityAtLeast severity);
+ ScopedStderrThreshold(const ScopedStderrThreshold&) = delete;
+ ScopedStderrThreshold& operator=(const ScopedStderrThreshold&) = delete;
+ ~ScopedStderrThreshold();
+
+ private:
+ y_absl::LogSeverityAtLeast saved_severity_;
+};
+
+//------------------------------------------------------------------------------
+// Log Backtrace At
+//------------------------------------------------------------------------------
+//
+// Users can request an existing `LOG` statement, specified by file and line
+// number, to also include a backtrace when logged.
+
+// ShouldLogBacktraceAt()
+//
+// Returns true if we should log a backtrace at the specified location.
+namespace log_internal {
+Y_ABSL_MUST_USE_RESULT bool ShouldLogBacktraceAt(y_absl::string_view file,
+ int line);
+} // namespace log_internal
+
+// SetLogBacktraceLocation()
+//
+// Sets the location the backtrace should be logged at. If the specified
+// location isn't a `LOG` statement, the effect will be the same as
+// `ClearLogBacktraceLocation` (but less efficient).
+void SetLogBacktraceLocation(y_absl::string_view file, int line);
+
+// ClearLogBacktraceLocation()
+//
+// Clears the set location so that backtraces will no longer be logged at it.
+void ClearLogBacktraceLocation();
+
+//------------------------------------------------------------------------------
+// Prepend Log Prefix
+//------------------------------------------------------------------------------
+//
+// This option tells the logging library that every logged message
+// should include the prefix (severity, date, time, PID, etc.)
+//
+// ShouldPrependLogPrefix()
+//
+// Returns the value of the Prepend Log Prefix option.
+// This function is async-signal-safe.
+Y_ABSL_MUST_USE_RESULT bool ShouldPrependLogPrefix();
+
+// EnableLogPrefix()
+//
+// Updates the value of the Prepend Log Prefix option.
+// This function is async-signal-safe.
+void EnableLogPrefix(bool on_off);
+
+//------------------------------------------------------------------------------
+// `VLOG` Configuration
+//------------------------------------------------------------------------------
+//
+// These methods set the `(Y_ABSL_)VLOG(_IS_ON)` threshold. They allow
+// programmatic control of the thresholds set by the --v and --vmodule flags.
+//
+// Only `VLOG`s with a severity level LESS THAN OR EQUAL TO the threshold will
+// be evaluated.
+//
+// For example, if the threshold is 2, then:
+//
+// VLOG(2) << "This message will be logged.";
+// VLOG(3) << "This message will NOT be logged.";
+//
+// The default threshold is 0. Since `VLOG` levels must not be negative, a
+// negative threshold value will turn off all VLOGs.
+
+// SetGlobalVLogLevel()
+//
+// Sets the global `VLOG` level to threshold. Returns the previous global
+// threshold.
+inline int SetGlobalVLogLevel(int threshold) {
+ return y_absl::log_internal::UpdateGlobalVLogLevel(threshold);
+}
+
+// SetVLogLevel()
+//
+// Sets the `VLOG` threshold for all files that match `module_pattern`,
+// overwriting any prior value. Files that don't match aren't affected.
+// Returns the threshold that previously applied to `module_pattern`.
+inline int SetVLogLevel(y_absl::string_view module_pattern, int threshold) {
+ return y_absl::log_internal::PrependVModule(module_pattern, threshold);
+}
+
+//------------------------------------------------------------------------------
+// Configure Android Native Log Tag
+//------------------------------------------------------------------------------
+//
+// The logging library forwards to the Android system log API when built for
+// Android. That API takes a string "tag" value in addition to a message and
+// severity level. The tag is used to identify the source of messages and to
+// filter them. This library uses the tag "native" by default.
+
+// SetAndroidNativeTag()
+//
+// Stores a copy of the string pointed to by `tag` and uses it as the Android
+// logging tag thereafter. `tag` must not be null.
+// This function must not be called more than once!
+void SetAndroidNativeTag(const char* tag);
+
+namespace log_internal {
+// GetAndroidNativeTag()
+//
+// Returns the configured Android logging tag.
+const char* GetAndroidNativeTag();
+} // namespace log_internal
+
+namespace log_internal {
+
+using LoggingGlobalsListener = void (*)();
+void SetLoggingGlobalsListener(LoggingGlobalsListener l);
+
+// Internal implementation for the setter routines. These are used
+// to break circular dependencies between flags and globals. Each "Raw"
+// routine corresponds to the non-"Raw" counterpart and used to set the
+// configuration parameter directly without calling back to the listener.
+void RawSetMinLogLevel(y_absl::LogSeverityAtLeast severity);
+void RawSetStderrThreshold(y_absl::LogSeverityAtLeast severity);
+void RawEnableLogPrefix(bool on_off);
+
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_LOG_GLOBALS_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/initialize.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/log/initialize.cc
new file mode 100644
index 00000000000..d547b9a044c
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/initialize.cc
@@ -0,0 +1,38 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "y_absl/log/initialize.h"
+
+#include "y_absl/base/config.h"
+#include "y_absl/log/internal/globals.h"
+#include "y_absl/time/time.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+
+namespace {
+void InitializeLogImpl(y_absl::TimeZone time_zone) {
+ // This comes first since it is used by RAW_LOG.
+ y_absl::log_internal::SetTimeZone(time_zone);
+
+ // Note that initialization is complete, so logs can now be sent to their
+ // proper destinations rather than stderr.
+ log_internal::SetInitialized();
+}
+} // namespace
+
+void InitializeLog() { InitializeLogImpl(y_absl::LocalTimeZone()); }
+
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/initialize.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/initialize.h
new file mode 100644
index 00000000000..88f73c657e1
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/initialize.h
@@ -0,0 +1,45 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: log/initialize.h
+// -----------------------------------------------------------------------------
+//
+// This header declares the Abseil Log initialization routine InitializeLog().
+
+#ifndef Y_ABSL_LOG_INITIALIZE_H_
+#define Y_ABSL_LOG_INITIALIZE_H_
+
+#include "y_absl/base/config.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+
+// InitializeLog()
+//
+// Initializes the Abseil logging library.
+//
+// Before this function is called, all log messages are directed only to stderr.
+// After initialization is finished, log messages are directed to all registered
+// `LogSink`s.
+//
+// It is an error to call this function twice.
+//
+// There is no corresponding function to shut down the logging library.
+void InitializeLog();
+
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_LOG_INITIALIZE_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/append_truncated.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/append_truncated.h
new file mode 100644
index 00000000000..efc4f447809
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/append_truncated.h
@@ -0,0 +1,47 @@
+// Copyright 2022 The Abseil Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef Y_ABSL_LOG_INTERNAL_APPEND_TRUNCATED_H_
+#define Y_ABSL_LOG_INTERNAL_APPEND_TRUNCATED_H_
+
+#include <cstddef>
+#include <cstring>
+
+#include "y_absl/base/config.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/types/span.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+// Copies into `dst` as many bytes of `src` as will fit, then truncates the
+// copied bytes from the front of `dst` and returns the number of bytes written.
+inline size_t AppendTruncated(y_absl::string_view src, y_absl::Span<char> &dst) {
+ if (src.size() > dst.size()) src = src.substr(0, dst.size());
+ memcpy(dst.data(), src.data(), src.size());
+ dst.remove_prefix(src.size());
+ return src.size();
+}
+// Likewise, but `n` copies of `c`.
+inline size_t AppendTruncated(char c, size_t n, y_absl::Span<char> &dst) {
+ if (n > dst.size()) n = dst.size();
+ memset(dst.data(), c, n);
+ dst.remove_prefix(n);
+ return n;
+}
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_LOG_INTERNAL_APPEND_TRUNCATED_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/check_impl.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/check_impl.h
new file mode 100644
index 00000000000..700c2bce655
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/check_impl.h
@@ -0,0 +1,150 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef Y_ABSL_LOG_INTERNAL_CHECK_IMPL_H_
+#define Y_ABSL_LOG_INTERNAL_CHECK_IMPL_H_
+
+#include "y_absl/base/optimization.h"
+#include "y_absl/log/internal/check_op.h"
+#include "y_absl/log/internal/conditions.h"
+#include "y_absl/log/internal/log_message.h"
+#include "y_absl/log/internal/strip.h"
+
+// CHECK
+#define Y_ABSL_LOG_INTERNAL_CHECK_IMPL(condition, condition_text) \
+ Y_ABSL_LOG_INTERNAL_CONDITION_FATAL(STATELESS, \
+ Y_ABSL_PREDICT_FALSE(!(condition))) \
+ Y_ABSL_LOG_INTERNAL_CHECK(condition_text).InternalStream()
+
+#define Y_ABSL_LOG_INTERNAL_QCHECK_IMPL(condition, condition_text) \
+ Y_ABSL_LOG_INTERNAL_CONDITION_QFATAL(STATELESS, \
+ Y_ABSL_PREDICT_FALSE(!(condition))) \
+ Y_ABSL_LOG_INTERNAL_QCHECK(condition_text).InternalStream()
+
+#define Y_ABSL_LOG_INTERNAL_PCHECK_IMPL(condition, condition_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_IMPL(condition, condition_text).WithPerror()
+
+#ifndef NDEBUG
+#define Y_ABSL_LOG_INTERNAL_DCHECK_IMPL(condition, condition_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_IMPL(condition, condition_text)
+#else
+#define Y_ABSL_LOG_INTERNAL_DCHECK_IMPL(condition, condition_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_IMPL(true || (condition), "true")
+#endif
+
+// CHECK_EQ
+#define Y_ABSL_LOG_INTERNAL_CHECK_EQ_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_OP(Check_EQ, ==, val1, val1_text, val2, val2_text)
+#define Y_ABSL_LOG_INTERNAL_CHECK_NE_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_OP(Check_NE, !=, val1, val1_text, val2, val2_text)
+#define Y_ABSL_LOG_INTERNAL_CHECK_LE_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_OP(Check_LE, <=, val1, val1_text, val2, val2_text)
+#define Y_ABSL_LOG_INTERNAL_CHECK_LT_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_OP(Check_LT, <, val1, val1_text, val2, val2_text)
+#define Y_ABSL_LOG_INTERNAL_CHECK_GE_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_OP(Check_GE, >=, val1, val1_text, val2, val2_text)
+#define Y_ABSL_LOG_INTERNAL_CHECK_GT_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_OP(Check_GT, >, val1, val1_text, val2, val2_text)
+#define Y_ABSL_LOG_INTERNAL_QCHECK_EQ_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_QCHECK_OP(Check_EQ, ==, val1, val1_text, val2, val2_text)
+#define Y_ABSL_LOG_INTERNAL_QCHECK_NE_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_QCHECK_OP(Check_NE, !=, val1, val1_text, val2, val2_text)
+#define Y_ABSL_LOG_INTERNAL_QCHECK_LE_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_QCHECK_OP(Check_LE, <=, val1, val1_text, val2, val2_text)
+#define Y_ABSL_LOG_INTERNAL_QCHECK_LT_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_QCHECK_OP(Check_LT, <, val1, val1_text, val2, val2_text)
+#define Y_ABSL_LOG_INTERNAL_QCHECK_GE_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_QCHECK_OP(Check_GE, >=, val1, val1_text, val2, val2_text)
+#define Y_ABSL_LOG_INTERNAL_QCHECK_GT_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_QCHECK_OP(Check_GT, >, val1, val1_text, val2, val2_text)
+#ifndef NDEBUG
+#define Y_ABSL_LOG_INTERNAL_DCHECK_EQ_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_EQ_IMPL(val1, val1_text, val2, val2_text)
+#define Y_ABSL_LOG_INTERNAL_DCHECK_NE_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_NE_IMPL(val1, val1_text, val2, val2_text)
+#define Y_ABSL_LOG_INTERNAL_DCHECK_LE_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_LE_IMPL(val1, val1_text, val2, val2_text)
+#define Y_ABSL_LOG_INTERNAL_DCHECK_LT_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_LT_IMPL(val1, val1_text, val2, val2_text)
+#define Y_ABSL_LOG_INTERNAL_DCHECK_GE_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_GE_IMPL(val1, val1_text, val2, val2_text)
+#define Y_ABSL_LOG_INTERNAL_DCHECK_GT_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_GT_IMPL(val1, val1_text, val2, val2_text)
+#else // ndef NDEBUG
+#define Y_ABSL_LOG_INTERNAL_DCHECK_EQ_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_DCHECK_NOP(val1, val2)
+#define Y_ABSL_LOG_INTERNAL_DCHECK_NE_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_DCHECK_NOP(val1, val2)
+#define Y_ABSL_LOG_INTERNAL_DCHECK_LE_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_DCHECK_NOP(val1, val2)
+#define Y_ABSL_LOG_INTERNAL_DCHECK_LT_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_DCHECK_NOP(val1, val2)
+#define Y_ABSL_LOG_INTERNAL_DCHECK_GE_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_DCHECK_NOP(val1, val2)
+#define Y_ABSL_LOG_INTERNAL_DCHECK_GT_IMPL(val1, val1_text, val2, val2_text) \
+ Y_ABSL_LOG_INTERNAL_DCHECK_NOP(val1, val2)
+#endif // def NDEBUG
+
+// CHECK_OK
+#define Y_ABSL_LOG_INTERNAL_CHECK_OK_IMPL(status, status_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_OK(status, status_text)
+#define Y_ABSL_LOG_INTERNAL_QCHECK_OK_IMPL(status, status_text) \
+ Y_ABSL_LOG_INTERNAL_QCHECK_OK(status, status_text)
+#ifndef NDEBUG
+#define Y_ABSL_LOG_INTERNAL_DCHECK_OK_IMPL(status, status_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_OK(status, status_text)
+#else
+#define Y_ABSL_LOG_INTERNAL_DCHECK_OK_IMPL(status, status_text) \
+ Y_ABSL_LOG_INTERNAL_DCHECK_NOP(status, nullptr)
+#endif
+
+// CHECK_STREQ
+#define Y_ABSL_LOG_INTERNAL_CHECK_STREQ_IMPL(s1, s1_text, s2, s2_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_STROP(strcmp, ==, true, s1, s1_text, s2, s2_text)
+#define Y_ABSL_LOG_INTERNAL_CHECK_STRNE_IMPL(s1, s1_text, s2, s2_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_STROP(strcmp, !=, false, s1, s1_text, s2, s2_text)
+#define Y_ABSL_LOG_INTERNAL_CHECK_STRCASEEQ_IMPL(s1, s1_text, s2, s2_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_STROP(strcasecmp, ==, true, s1, s1_text, s2, s2_text)
+#define Y_ABSL_LOG_INTERNAL_CHECK_STRCASENE_IMPL(s1, s1_text, s2, s2_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_STROP(strcasecmp, !=, false, s1, s1_text, s2, s2_text)
+#define Y_ABSL_LOG_INTERNAL_QCHECK_STREQ_IMPL(s1, s1_text, s2, s2_text) \
+ Y_ABSL_LOG_INTERNAL_QCHECK_STROP(strcmp, ==, true, s1, s1_text, s2, s2_text)
+#define Y_ABSL_LOG_INTERNAL_QCHECK_STRNE_IMPL(s1, s1_text, s2, s2_text) \
+ Y_ABSL_LOG_INTERNAL_QCHECK_STROP(strcmp, !=, false, s1, s1_text, s2, s2_text)
+#define Y_ABSL_LOG_INTERNAL_QCHECK_STRCASEEQ_IMPL(s1, s1_text, s2, s2_text) \
+ Y_ABSL_LOG_INTERNAL_QCHECK_STROP(strcasecmp, ==, true, s1, s1_text, s2, s2_text)
+#define Y_ABSL_LOG_INTERNAL_QCHECK_STRCASENE_IMPL(s1, s1_text, s2, s2_text) \
+ Y_ABSL_LOG_INTERNAL_QCHECK_STROP(strcasecmp, !=, false, s1, s1_text, s2, \
+ s2_text)
+#ifndef NDEBUG
+#define Y_ABSL_LOG_INTERNAL_DCHECK_STREQ_IMPL(s1, s1_text, s2, s2_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_STREQ_IMPL(s1, s1_text, s2, s2_text)
+#define Y_ABSL_LOG_INTERNAL_DCHECK_STRCASEEQ_IMPL(s1, s1_text, s2, s2_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_STRCASEEQ_IMPL(s1, s1_text, s2, s2_text)
+#define Y_ABSL_LOG_INTERNAL_DCHECK_STRNE_IMPL(s1, s1_text, s2, s2_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_STRNE_IMPL(s1, s1_text, s2, s2_text)
+#define Y_ABSL_LOG_INTERNAL_DCHECK_STRCASENE_IMPL(s1, s1_text, s2, s2_text) \
+ Y_ABSL_LOG_INTERNAL_CHECK_STRCASENE_IMPL(s1, s1_text, s2, s2_text)
+#else // ndef NDEBUG
+#define Y_ABSL_LOG_INTERNAL_DCHECK_STREQ_IMPL(s1, s1_text, s2, s2_text) \
+ Y_ABSL_LOG_INTERNAL_DCHECK_NOP(s1, s2)
+#define Y_ABSL_LOG_INTERNAL_DCHECK_STRCASEEQ_IMPL(s1, s1_text, s2, s2_text) \
+ Y_ABSL_LOG_INTERNAL_DCHECK_NOP(s1, s2)
+#define Y_ABSL_LOG_INTERNAL_DCHECK_STRNE_IMPL(s1, s1_text, s2, s2_text) \
+ Y_ABSL_LOG_INTERNAL_DCHECK_NOP(s1, s2)
+#define Y_ABSL_LOG_INTERNAL_DCHECK_STRCASENE_IMPL(s1, s1_text, s2, s2_text) \
+ Y_ABSL_LOG_INTERNAL_DCHECK_NOP(s1, s2)
+#endif // def NDEBUG
+
+#endif // Y_ABSL_LOG_INTERNAL_CHECK_IMPL_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/check_op.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/check_op.cc
new file mode 100644
index 00000000000..26a3cc2869f
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/check_op.cc
@@ -0,0 +1,138 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "y_absl/log/internal/check_op.h"
+
+#include <string.h>
+
+#include <ostream>
+
+#include "y_absl/strings/string_view.h"
+
+#ifdef _MSC_VER
+#define strcasecmp _stricmp
+#else
+#include <strings.h> // for strcasecmp, but msvc does not have this header
+#endif
+
+#include <sstream>
+#include <util/generic/string.h>
+
+#include "y_absl/base/config.h"
+#include "y_absl/strings/str_cat.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+
+#define Y_ABSL_LOGGING_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(x) \
+ template TString* MakeCheckOpString(x, x, const char*)
+Y_ABSL_LOGGING_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(bool);
+Y_ABSL_LOGGING_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(int64_t);
+Y_ABSL_LOGGING_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(uint64_t);
+Y_ABSL_LOGGING_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(float);
+Y_ABSL_LOGGING_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(double);
+Y_ABSL_LOGGING_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(char);
+Y_ABSL_LOGGING_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(unsigned char);
+Y_ABSL_LOGGING_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(const TString&);
+Y_ABSL_LOGGING_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(const y_absl::string_view&);
+Y_ABSL_LOGGING_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(const char*);
+Y_ABSL_LOGGING_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(const signed char*);
+Y_ABSL_LOGGING_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(const unsigned char*);
+Y_ABSL_LOGGING_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(const void*);
+#undef Y_ABSL_LOGGING_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING
+
+CheckOpMessageBuilder::CheckOpMessageBuilder(const char* exprtext) {
+ stream_ << exprtext << " (";
+}
+
+std::ostream& CheckOpMessageBuilder::ForVar2() {
+ stream_ << " vs. ";
+ return stream_;
+}
+
+TString* CheckOpMessageBuilder::NewString() {
+ stream_ << ")";
+ return new TString(stream_.str());
+}
+
+void MakeCheckOpValueString(std::ostream& os, const char v) {
+ if (v >= 32 && v <= 126) {
+ os << "'" << v << "'";
+ } else {
+ os << "char value " << int{v};
+ }
+}
+
+void MakeCheckOpValueString(std::ostream& os, const signed char v) {
+ if (v >= 32 && v <= 126) {
+ os << "'" << v << "'";
+ } else {
+ os << "signed char value " << int{v};
+ }
+}
+
+void MakeCheckOpValueString(std::ostream& os, const unsigned char v) {
+ if (v >= 32 && v <= 126) {
+ os << "'" << v << "'";
+ } else {
+ os << "unsigned char value " << int{v};
+ }
+}
+
+void MakeCheckOpValueString(std::ostream& os, const void* p) {
+ if (p == nullptr) {
+ os << "(null)";
+ } else {
+ os << p;
+ }
+}
+
+// Helper functions for string comparisons.
+#define DEFINE_CHECK_STROP_IMPL(name, func, expected) \
+ TString* Check##func##expected##Impl(const char* s1, const char* s2, \
+ const char* exprtext) { \
+ bool equal = s1 == s2 || (s1 && s2 && !func(s1, s2)); \
+ if (equal == expected) { \
+ return nullptr; \
+ } else { \
+ return new TString( \
+ y_absl::StrCat(exprtext, " (", s1, " vs. ", s2, ")")); \
+ } \
+ }
+DEFINE_CHECK_STROP_IMPL(CHECK_STREQ, strcmp, true)
+DEFINE_CHECK_STROP_IMPL(CHECK_STRNE, strcmp, false)
+DEFINE_CHECK_STROP_IMPL(CHECK_STRCASEEQ, strcasecmp, true)
+DEFINE_CHECK_STROP_IMPL(CHECK_STRCASENE, strcasecmp, false)
+#undef DEFINE_CHECK_STROP_IMPL
+
+namespace detect_specialization {
+
+StringifySink::StringifySink(std::ostream& os) : os_(os) {}
+
+void StringifySink::Append(y_absl::string_view text) { os_ << text; }
+
+void StringifySink::Append(size_t length, char ch) {
+ for (size_t i = 0; i < length; ++i) os_.put(ch);
+}
+
+void AbslFormatFlush(StringifySink* sink, y_absl::string_view text) {
+ sink->Append(text);
+}
+
+} // namespace detect_specialization
+
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/check_op.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/check_op.h
new file mode 100644
index 00000000000..8021ef57997
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/check_op.h
@@ -0,0 +1,462 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: log/internal/check_op.h
+// -----------------------------------------------------------------------------
+//
+// This file declares helpers routines and macros used to implement `CHECK`
+// macros.
+
+#ifndef Y_ABSL_LOG_INTERNAL_CHECK_OP_H_
+#define Y_ABSL_LOG_INTERNAL_CHECK_OP_H_
+
+#include <stdint.h>
+
+#include <cstddef>
+#include <ostream>
+#include <sstream>
+#include <util/generic/string.h>
+#include <type_traits>
+#include <utility>
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/base/config.h"
+#include "y_absl/base/optimization.h"
+#include "y_absl/log/internal/nullguard.h"
+#include "y_absl/log/internal/nullstream.h"
+#include "y_absl/log/internal/strip.h"
+#include "y_absl/strings/has_absl_stringify.h"
+#include "y_absl/strings/string_view.h"
+
+// `Y_ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL` wraps string literals that
+// should be stripped when `Y_ABSL_MIN_LOG_LEVEL` exceeds `kFatal`.
+#ifdef Y_ABSL_MIN_LOG_LEVEL
+#define Y_ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL(literal) \
+ (::y_absl::LogSeverity::kFatal >= \
+ static_cast<::y_absl::LogSeverity>(Y_ABSL_MIN_LOG_LEVEL) \
+ ? (literal) \
+ : "")
+#else
+#define Y_ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL(literal) (literal)
+#endif
+
+#ifdef NDEBUG
+// `NDEBUG` is defined, so `DCHECK_EQ(x, y)` and so on do nothing. However, we
+// still want the compiler to parse `x` and `y`, because we don't want to lose
+// potentially useful errors and warnings.
+#define Y_ABSL_LOG_INTERNAL_DCHECK_NOP(x, y) \
+ while (false && ((void)(x), (void)(y), 0)) \
+ ::y_absl::log_internal::NullStream().InternalStream()
+#endif
+
+#define Y_ABSL_LOG_INTERNAL_CHECK_OP(name, op, val1, val1_text, val2, val2_text) \
+ while (::TString* absl_log_internal_check_op_result \
+ Y_ABSL_LOG_INTERNAL_ATTRIBUTE_UNUSED_IF_STRIP_LOG = \
+ ::y_absl::log_internal::name##Impl( \
+ ::y_absl::log_internal::GetReferenceableValue(val1), \
+ ::y_absl::log_internal::GetReferenceableValue(val2), \
+ Y_ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL( \
+ val1_text " " #op " " val2_text))) \
+ Y_ABSL_LOG_INTERNAL_CONDITION_FATAL(STATELESS, true) \
+ Y_ABSL_LOG_INTERNAL_CHECK(*absl_log_internal_check_op_result).InternalStream()
+#define Y_ABSL_LOG_INTERNAL_QCHECK_OP(name, op, val1, val1_text, val2, \
+ val2_text) \
+ while (::TString* absl_log_internal_qcheck_op_result = \
+ ::y_absl::log_internal::name##Impl( \
+ ::y_absl::log_internal::GetReferenceableValue(val1), \
+ ::y_absl::log_internal::GetReferenceableValue(val2), \
+ Y_ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL( \
+ val1_text " " #op " " val2_text))) \
+ Y_ABSL_LOG_INTERNAL_CONDITION_QFATAL(STATELESS, true) \
+ Y_ABSL_LOG_INTERNAL_QCHECK(*absl_log_internal_qcheck_op_result).InternalStream()
+#define Y_ABSL_LOG_INTERNAL_CHECK_STROP(func, op, expected, s1, s1_text, s2, \
+ s2_text) \
+ while (::TString* absl_log_internal_check_strop_result = \
+ ::y_absl::log_internal::Check##func##expected##Impl( \
+ (s1), (s2), \
+ Y_ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL(s1_text " " #op \
+ " " s2_text))) \
+ Y_ABSL_LOG_INTERNAL_CONDITION_FATAL(STATELESS, true) \
+ Y_ABSL_LOG_INTERNAL_CHECK(*absl_log_internal_check_strop_result) \
+ .InternalStream()
+#define Y_ABSL_LOG_INTERNAL_QCHECK_STROP(func, op, expected, s1, s1_text, s2, \
+ s2_text) \
+ while (::TString* absl_log_internal_qcheck_strop_result = \
+ ::y_absl::log_internal::Check##func##expected##Impl( \
+ (s1), (s2), \
+ Y_ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL(s1_text " " #op \
+ " " s2_text))) \
+ Y_ABSL_LOG_INTERNAL_CONDITION_QFATAL(STATELESS, true) \
+ Y_ABSL_LOG_INTERNAL_QCHECK(*absl_log_internal_qcheck_strop_result) \
+ .InternalStream()
+// This one is tricky:
+// * We must evaluate `val` exactly once, yet we need to do two things with it:
+// evaluate `.ok()` and (sometimes) `.ToString()`.
+// * `val` might be an `y_absl::Status` or some `y_absl::StatusOr<T>`.
+// * `val` might be e.g. `ATemporary().GetStatus()`, which may return a
+// reference to a member of `ATemporary` that is only valid until the end of
+// the full expression.
+// * We don't want this file to depend on `y_absl::Status` `#include`s or linkage,
+// nor do we want to move the definition to status and introduce a dependency
+// in the other direction. We can be assured that callers must already have a
+// `Status` and the necessary `#include`s and linkage.
+// * Callsites should be small and fast (at least when `val.ok()`): one branch,
+// minimal stack footprint.
+// * In particular, the string concat stuff should be out-of-line and emitted
+// in only one TU to save linker input size
+// * We want the `val.ok()` check inline so static analyzers and optimizers can
+// see it.
+// * As usual, no braces so we can stream into the expansion with `operator<<`.
+// * Also as usual, it must expand to a single (partial) statement with no
+// ambiguous-else problems.
+// * When stripped by `Y_ABSL_MIN_LOG_LEVEL`, we must discard the `<expr> is OK`
+// string literal and abort without doing any streaming. We don't need to
+// strip the call to stringify the non-ok `Status` as long as we don't log it;
+// dropping the `Status`'s message text is out of scope.
+#define Y_ABSL_LOG_INTERNAL_CHECK_OK(val, val_text) \
+ for (::std::pair<const ::y_absl::Status*, ::TString*> \
+ absl_log_internal_check_ok_goo; \
+ absl_log_internal_check_ok_goo.first = \
+ ::y_absl::log_internal::AsStatus(val), \
+ absl_log_internal_check_ok_goo.second = \
+ Y_ABSL_PREDICT_TRUE(absl_log_internal_check_ok_goo.first->ok()) \
+ ? nullptr \
+ : ::y_absl::status_internal::MakeCheckFailString( \
+ absl_log_internal_check_ok_goo.first, \
+ Y_ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL(val_text \
+ " is OK")), \
+ !Y_ABSL_PREDICT_TRUE(absl_log_internal_check_ok_goo.first->ok());) \
+ Y_ABSL_LOG_INTERNAL_CONDITION_FATAL(STATELESS, true) \
+ Y_ABSL_LOG_INTERNAL_CHECK(*absl_log_internal_check_ok_goo.second) \
+ .InternalStream()
+#define Y_ABSL_LOG_INTERNAL_QCHECK_OK(val, val_text) \
+ for (::std::pair<const ::y_absl::Status*, ::TString*> \
+ absl_log_internal_qcheck_ok_goo; \
+ absl_log_internal_qcheck_ok_goo.first = \
+ ::y_absl::log_internal::AsStatus(val), \
+ absl_log_internal_qcheck_ok_goo.second = \
+ Y_ABSL_PREDICT_TRUE(absl_log_internal_qcheck_ok_goo.first->ok()) \
+ ? nullptr \
+ : ::y_absl::status_internal::MakeCheckFailString( \
+ absl_log_internal_qcheck_ok_goo.first, \
+ Y_ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL(val_text \
+ " is OK")), \
+ !Y_ABSL_PREDICT_TRUE(absl_log_internal_qcheck_ok_goo.first->ok());) \
+ Y_ABSL_LOG_INTERNAL_CONDITION_QFATAL(STATELESS, true) \
+ Y_ABSL_LOG_INTERNAL_QCHECK(*absl_log_internal_qcheck_ok_goo.second) \
+ .InternalStream()
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+
+class Status;
+template <typename T>
+class StatusOr;
+
+namespace status_internal {
+Y_ABSL_ATTRIBUTE_PURE_FUNCTION TString* MakeCheckFailString(
+ const y_absl::Status* status, const char* prefix);
+} // namespace status_internal
+
+namespace log_internal {
+
+// Convert a Status or a StatusOr to its underlying status value.
+//
+// (This implementation does not require a dep on y_absl::Status to work.)
+inline const y_absl::Status* AsStatus(const y_absl::Status& s) { return &s; }
+template <typename T>
+const y_absl::Status* AsStatus(const y_absl::StatusOr<T>& s) {
+ return &s.status();
+}
+
+// A helper class for formatting `expr (V1 vs. V2)` in a `CHECK_XX` statement.
+// See `MakeCheckOpString` for sample usage.
+class CheckOpMessageBuilder final {
+ public:
+ // Inserts `exprtext` and ` (` to the stream.
+ explicit CheckOpMessageBuilder(const char* exprtext);
+ ~CheckOpMessageBuilder() = default;
+ // For inserting the first variable.
+ std::ostream& ForVar1() { return stream_; }
+ // For inserting the second variable (adds an intermediate ` vs. `).
+ std::ostream& ForVar2();
+ // Get the result (inserts the closing `)`).
+ TString* NewString();
+
+ private:
+ std::ostringstream stream_;
+};
+
+// This formats a value for a failing `CHECK_XX` statement. Ordinarily, it uses
+// the definition for `operator<<`, with a few special cases below.
+template <typename T>
+inline void MakeCheckOpValueString(std::ostream& os, const T& v) {
+ os << log_internal::NullGuard<T>::Guard(v);
+}
+
+// Overloads for char types provide readable values for unprintable characters.
+void MakeCheckOpValueString(std::ostream& os, char v);
+void MakeCheckOpValueString(std::ostream& os, signed char v);
+void MakeCheckOpValueString(std::ostream& os, unsigned char v);
+void MakeCheckOpValueString(std::ostream& os, const void* p);
+
+namespace detect_specialization {
+
+// MakeCheckOpString is being specialized for every T and U pair that is being
+// passed to the CHECK_op macros. However, there is a lot of redundancy in these
+// specializations that creates unnecessary library and binary bloat.
+// The number of instantiations tends to be O(n^2) because we have two
+// independent inputs. This technique works by reducing `n`.
+//
+// Most user-defined types being passed to CHECK_op end up being printed as a
+// builtin type. For example, enums tend to be implicitly converted to its
+// underlying type when calling operator<<, and pointers are printed with the
+// `const void*` overload.
+// To reduce the number of instantiations we coerce these values before calling
+// MakeCheckOpString instead of inside it.
+//
+// To detect if this coercion is needed, we duplicate all the relevant
+// operator<< overloads as specified in the standard, just in a different
+// namespace. If the call to `stream << value` becomes ambiguous, it means that
+// one of these overloads is the one selected by overload resolution. We then
+// do overload resolution again just with our overload set to see which one gets
+// selected. That tells us which type to coerce to.
+// If the augmented call was not ambiguous, it means that none of these were
+// selected and we can't coerce the input.
+//
+// As a secondary step to reduce code duplication, we promote integral types to
+// their 64-bit variant. This does not change the printed value, but reduces the
+// number of instantiations even further. Promoting an integer is very cheap at
+// the call site.
+int64_t operator<<(std::ostream&, short value); // NOLINT
+int64_t operator<<(std::ostream&, unsigned short value); // NOLINT
+int64_t operator<<(std::ostream&, int value);
+int64_t operator<<(std::ostream&, unsigned int value);
+int64_t operator<<(std::ostream&, long value); // NOLINT
+uint64_t operator<<(std::ostream&, unsigned long value); // NOLINT
+int64_t operator<<(std::ostream&, long long value); // NOLINT
+uint64_t operator<<(std::ostream&, unsigned long long value); // NOLINT
+float operator<<(std::ostream&, float value);
+double operator<<(std::ostream&, double value);
+long double operator<<(std::ostream&, long double value);
+bool operator<<(std::ostream&, bool value);
+const void* operator<<(std::ostream&, const void* value);
+const void* operator<<(std::ostream&, std::nullptr_t);
+
+// These `char` overloads are specified like this in the standard, so we have to
+// write them exactly the same to ensure the call is ambiguous.
+// If we wrote it in a different way (eg taking std::ostream instead of the
+// template) then one call might have a higher rank than the other and it would
+// not be ambiguous.
+template <typename Traits>
+char operator<<(std::basic_ostream<char, Traits>&, char);
+template <typename Traits>
+signed char operator<<(std::basic_ostream<char, Traits>&, signed char);
+template <typename Traits>
+unsigned char operator<<(std::basic_ostream<char, Traits>&, unsigned char);
+template <typename Traits>
+const char* operator<<(std::basic_ostream<char, Traits>&, const char*);
+template <typename Traits>
+const signed char* operator<<(std::basic_ostream<char, Traits>&,
+ const signed char*);
+template <typename Traits>
+const unsigned char* operator<<(std::basic_ostream<char, Traits>&,
+ const unsigned char*);
+
+// This overload triggers when the call is not ambiguous.
+// It means that T is being printed with some overload not on this list.
+// We keep the value as `const T&`.
+template <typename T, typename = decltype(std::declval<std::ostream&>()
+ << std::declval<const T&>())>
+const T& Detect(int);
+
+// This overload triggers when the call is ambiguous.
+// It means that T is either one from this list or printed as one from this
+// list. Eg an enum that decays to `int` for printing.
+// We ask the overload set to give us the type we want to convert it to.
+template <typename T>
+decltype(detect_specialization::operator<<(std::declval<std::ostream&>(),
+ std::declval<const T&>()))
+Detect(char);
+
+// A sink for AbslStringify which redirects everything to a std::ostream.
+class StringifySink {
+ public:
+ explicit StringifySink(std::ostream& os Y_ABSL_ATTRIBUTE_LIFETIME_BOUND);
+
+ void Append(y_absl::string_view text);
+ void Append(size_t length, char ch);
+ friend void AbslFormatFlush(StringifySink* sink, y_absl::string_view text);
+
+ private:
+ std::ostream& os_;
+};
+
+// Wraps a type implementing AbslStringify, and implements operator<<.
+template <typename T>
+class StringifyToStreamWrapper {
+ public:
+ explicit StringifyToStreamWrapper(const T& v Y_ABSL_ATTRIBUTE_LIFETIME_BOUND)
+ : v_(v) {}
+
+ friend std::ostream& operator<<(std::ostream& os,
+ const StringifyToStreamWrapper& wrapper) {
+ StringifySink sink(os);
+ AbslStringify(sink, wrapper.v_);
+ return os;
+ }
+
+ private:
+ const T& v_;
+};
+
+// This overload triggers when T implements AbslStringify.
+// StringifyToStreamWrapper is used to allow MakeCheckOpString to use
+// operator<<.
+template <typename T>
+std::enable_if_t<HasAbslStringify<T>::value,
+ StringifyToStreamWrapper<T>>
+Detect(...); // Ellipsis has lowest preference when int passed.
+} // namespace detect_specialization
+
+template <typename T>
+using CheckOpStreamType = decltype(detect_specialization::Detect<T>(0));
+
+// Build the error message string. Specify no inlining for code size.
+template <typename T1, typename T2>
+Y_ABSL_ATTRIBUTE_RETURNS_NONNULL TString* MakeCheckOpString(
+ T1 v1, T2 v2, const char* exprtext) Y_ABSL_ATTRIBUTE_NOINLINE;
+
+template <typename T1, typename T2>
+TString* MakeCheckOpString(T1 v1, T2 v2, const char* exprtext) {
+ CheckOpMessageBuilder comb(exprtext);
+ MakeCheckOpValueString(comb.ForVar1(), v1);
+ MakeCheckOpValueString(comb.ForVar2(), v2);
+ return comb.NewString();
+}
+
+// Add a few commonly used instantiations as extern to reduce size of objects
+// files.
+#define Y_ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(x) \
+ extern template TString* MakeCheckOpString(x, x, const char*)
+Y_ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(bool);
+Y_ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(int64_t);
+Y_ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(uint64_t);
+Y_ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(float);
+Y_ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(double);
+Y_ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(char);
+Y_ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(unsigned char);
+Y_ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(const TString&);
+Y_ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(const y_absl::string_view&);
+Y_ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(const char*);
+Y_ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(const signed char*);
+Y_ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(const unsigned char*);
+Y_ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(const void*);
+#undef Y_ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN
+
+// `Y_ABSL_LOG_INTERNAL_CHECK_OP_IMPL_RESULT` skips formatting the Check_OP result
+// string iff `Y_ABSL_MIN_LOG_LEVEL` exceeds `kFatal`, instead returning an empty
+// string.
+#ifdef Y_ABSL_MIN_LOG_LEVEL
+#define Y_ABSL_LOG_INTERNAL_CHECK_OP_IMPL_RESULT(U1, U2, v1, v2, exprtext) \
+ ((::y_absl::LogSeverity::kFatal >= \
+ static_cast<::y_absl::LogSeverity>(Y_ABSL_MIN_LOG_LEVEL)) \
+ ? MakeCheckOpString<U1, U2>(v1, v2, exprtext) \
+ : new TString())
+#else
+#define Y_ABSL_LOG_INTERNAL_CHECK_OP_IMPL_RESULT(U1, U2, v1, v2, exprtext) \
+ MakeCheckOpString<U1, U2>(v1, v2, exprtext)
+#endif
+
+// Helper functions for `Y_ABSL_LOG_INTERNAL_CHECK_OP` macro family. The
+// `(int, int)` override works around the issue that the compiler will not
+// instantiate the template version of the function on values of unnamed enum
+// type.
+#define Y_ABSL_LOG_INTERNAL_CHECK_OP_IMPL(name, op) \
+ template <typename T1, typename T2> \
+ inline constexpr ::TString* name##Impl(const T1& v1, const T2& v2, \
+ const char* exprtext) { \
+ using U1 = CheckOpStreamType<T1>; \
+ using U2 = CheckOpStreamType<T2>; \
+ return Y_ABSL_PREDICT_TRUE(v1 op v2) \
+ ? nullptr \
+ : Y_ABSL_LOG_INTERNAL_CHECK_OP_IMPL_RESULT(U1, U2, U1(v1), \
+ U2(v2), exprtext); \
+ } \
+ inline constexpr ::TString* name##Impl(int v1, int v2, \
+ const char* exprtext) { \
+ return name##Impl<int, int>(v1, v2, exprtext); \
+ }
+
+Y_ABSL_LOG_INTERNAL_CHECK_OP_IMPL(Check_EQ, ==)
+Y_ABSL_LOG_INTERNAL_CHECK_OP_IMPL(Check_NE, !=)
+Y_ABSL_LOG_INTERNAL_CHECK_OP_IMPL(Check_LE, <=)
+Y_ABSL_LOG_INTERNAL_CHECK_OP_IMPL(Check_LT, <)
+Y_ABSL_LOG_INTERNAL_CHECK_OP_IMPL(Check_GE, >=)
+Y_ABSL_LOG_INTERNAL_CHECK_OP_IMPL(Check_GT, >)
+#undef Y_ABSL_LOG_INTERNAL_CHECK_OP_IMPL_RESULT
+#undef Y_ABSL_LOG_INTERNAL_CHECK_OP_IMPL
+
+TString* CheckstrcmptrueImpl(const char* s1, const char* s2,
+ const char* exprtext);
+TString* CheckstrcmpfalseImpl(const char* s1, const char* s2,
+ const char* exprtext);
+TString* CheckstrcasecmptrueImpl(const char* s1, const char* s2,
+ const char* exprtext);
+TString* CheckstrcasecmpfalseImpl(const char* s1, const char* s2,
+ const char* exprtext);
+
+// `CHECK_EQ` and friends want to pass their arguments by reference, however
+// this winds up exposing lots of cases where people have defined and
+// initialized static const data members but never declared them (i.e. in a .cc
+// file), meaning they are not referenceable. This function avoids that problem
+// for integers (the most common cases) by overloading for every primitive
+// integer type, even the ones we discourage, and returning them by value.
+template <typename T>
+inline constexpr const T& GetReferenceableValue(const T& t) {
+ return t;
+}
+inline constexpr char GetReferenceableValue(char t) { return t; }
+inline constexpr unsigned char GetReferenceableValue(unsigned char t) {
+ return t;
+}
+inline constexpr signed char GetReferenceableValue(signed char t) { return t; }
+inline constexpr short GetReferenceableValue(short t) { return t; } // NOLINT
+inline constexpr unsigned short GetReferenceableValue( // NOLINT
+ unsigned short t) { // NOLINT
+ return t;
+}
+inline constexpr int GetReferenceableValue(int t) { return t; }
+inline constexpr unsigned int GetReferenceableValue(unsigned int t) {
+ return t;
+}
+inline constexpr long GetReferenceableValue(long t) { return t; } // NOLINT
+inline constexpr unsigned long GetReferenceableValue( // NOLINT
+ unsigned long t) { // NOLINT
+ return t;
+}
+inline constexpr long long GetReferenceableValue(long long t) { // NOLINT
+ return t;
+}
+inline constexpr unsigned long long GetReferenceableValue( // NOLINT
+ unsigned long long t) { // NOLINT
+ return t;
+}
+
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_LOG_INTERNAL_CHECK_OP_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/conditions.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/conditions.cc
new file mode 100644
index 00000000000..c021bd2da63
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/conditions.cc
@@ -0,0 +1,83 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "y_absl/log/internal/conditions.h"
+
+#include <atomic>
+#include <cstdint>
+
+#include "y_absl/base/config.h"
+#include "y_absl/base/internal/cycleclock.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+namespace {
+
+// The following code behaves like AtomicStatsCounter::LossyAdd() for
+// speed since it is fine to lose occasional updates.
+// Returns old value of *counter.
+uint32_t LossyIncrement(std::atomic<uint32_t>* counter) {
+ const uint32_t value = counter->load(std::memory_order_relaxed);
+ counter->store(value + 1, std::memory_order_relaxed);
+ return value;
+}
+
+} // namespace
+
+bool LogEveryNState::ShouldLog(int n) {
+ return n > 0 && (LossyIncrement(&counter_) % static_cast<uint32_t>(n)) == 0;
+}
+
+bool LogFirstNState::ShouldLog(int n) {
+ const uint32_t counter_value = counter_.load(std::memory_order_relaxed);
+ if (static_cast<int64_t>(counter_value) < n) {
+ counter_.store(counter_value + 1, std::memory_order_relaxed);
+ return true;
+ }
+ return false;
+}
+
+bool LogEveryPow2State::ShouldLog() {
+ const uint32_t new_value = LossyIncrement(&counter_) + 1;
+ return (new_value & (new_value - 1)) == 0;
+}
+
+bool LogEveryNSecState::ShouldLog(double seconds) {
+ using y_absl::base_internal::CycleClock;
+ LossyIncrement(&counter_);
+ const int64_t now_cycles = CycleClock::Now();
+ int64_t next_cycles = next_log_time_cycles_.load(std::memory_order_relaxed);
+#if defined(__myriad2__)
+ // myriad2 does not have 8-byte compare and exchange. Use a racy version that
+ // is "good enough" but will over-log in the face of concurrent logging.
+ if (now_cycles > next_cycles) {
+ next_log_time_cycles_.store(now_cycles + seconds * CycleClock::Frequency(),
+ std::memory_order_relaxed);
+ return true;
+ }
+ return false;
+#else
+ do {
+ if (now_cycles <= next_cycles) return false;
+ } while (!next_log_time_cycles_.compare_exchange_weak(
+ next_cycles, now_cycles + seconds * CycleClock::Frequency(),
+ std::memory_order_relaxed, std::memory_order_relaxed));
+ return true;
+#endif
+}
+
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/conditions.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/conditions.h
new file mode 100644
index 00000000000..19c8f7f1cee
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/conditions.h
@@ -0,0 +1,239 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: log/internal/conditions.h
+// -----------------------------------------------------------------------------
+//
+// This file contains implementation of conditional log statements, like LOG_IF
+// including all the Y_ABSL_LOG_INTERNAL_..._CONDITION_... macros and
+// various condition classes like LogEveryNState.
+
+#ifndef Y_ABSL_LOG_INTERNAL_CONDITIONS_H_
+#define Y_ABSL_LOG_INTERNAL_CONDITIONS_H_
+
+#if defined(_WIN32) || defined(__hexagon__)
+#include <cstdlib>
+#else
+#include <unistd.h>
+#endif
+#include <stdlib.h>
+
+#include <atomic>
+#include <cstdint>
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/base/config.h"
+#include "y_absl/log/internal/voidify.h"
+
+// `Y_ABSL_LOG_INTERNAL_CONDITION` prefixes another macro that expands to a
+// temporary `LogMessage` instantiation followed by zero or more streamed
+// expressions. This definition is tricky to read correctly. It evaluates to
+// either
+//
+// (void)0;
+//
+// or
+//
+// ::y_absl::log_internal::Voidify() &&
+// ::y_absl::log_internal::LogMessage(...) << "the user's message";
+//
+// If the condition is evaluable at compile time, as is often the case, it
+// compiles away to just one side or the other.
+//
+// Although this is not used anywhere a statement (e.g. `if`) could not go,
+// the ternary expression does a better job avoiding spurious diagnostics
+// (dangling else, missing switch case) and preserving noreturn semantics (e.g.
+// on `LOG(FATAL)`) without requiring braces.
+//
+// The `switch` ensures that this expansion is the beginning of a statement (as
+// opposed to an expression) and prevents shenanigans like
+// `AFunction(LOG(INFO))` and `decltype(LOG(INFO))`. The apparently-redundant
+// `default` case makes the condition more amenable to Clang dataflow analysis.
+#define Y_ABSL_LOG_INTERNAL_STATELESS_CONDITION(condition) \
+ switch (0) \
+ case 0: \
+ default: \
+ !(condition) ? (void)0 : ::y_absl::log_internal::Voidify()&&
+
+// `Y_ABSL_LOG_INTERNAL_STATEFUL_CONDITION` applies a condition like
+// `Y_ABSL_LOG_INTERNAL_STATELESS_CONDITION` but adds to that a series of variable
+// declarations, including a local static object which stores the state needed
+// to implement the stateful macros like `LOG_EVERY_N`.
+//
+// `for`-loops are used to declare scoped variables without braces (to permit
+// streaming into the macro's expansion) and without the dangling-`else`
+// problems/diagnostics that come with `if`.
+//
+// Two more variables are declared in separate `for`-loops:
+//
+// * `COUNTER` implements a streamable token whose value when streamed is the
+// number of times execution has passed through the macro.
+// * A boolean flag is used to prevent any of the `for`-loops from ever actually
+// looping.
+#define Y_ABSL_LOG_INTERNAL_STATEFUL_CONDITION(condition) \
+ for (bool absl_log_internal_stateful_condition_do_log(condition); \
+ absl_log_internal_stateful_condition_do_log; \
+ absl_log_internal_stateful_condition_do_log = false) \
+ Y_ABSL_LOG_INTERNAL_STATEFUL_CONDITION_IMPL
+#define Y_ABSL_LOG_INTERNAL_STATEFUL_CONDITION_IMPL(kind, ...) \
+ for (static ::y_absl::log_internal::Log##kind##State \
+ absl_log_internal_stateful_condition_state; \
+ absl_log_internal_stateful_condition_do_log && \
+ absl_log_internal_stateful_condition_state.ShouldLog(__VA_ARGS__); \
+ absl_log_internal_stateful_condition_do_log = false) \
+ for (const uint32_t COUNTER Y_ABSL_ATTRIBUTE_UNUSED = \
+ absl_log_internal_stateful_condition_state.counter(); \
+ absl_log_internal_stateful_condition_do_log; \
+ absl_log_internal_stateful_condition_do_log = false)
+
+// `Y_ABSL_LOG_INTERNAL_CONDITION_*` serve to combine any conditions from the
+// macro (e.g. `LOG_IF` or `VLOG`) with inherent conditions (e.g.
+// `Y_ABSL_MIN_LOG_LEVEL`) into a single boolean expression. We could chain
+// ternary operators instead, however some versions of Clang sometimes issue
+// spurious diagnostics after such expressions due to a control flow analysis
+// bug.
+#ifdef Y_ABSL_MIN_LOG_LEVEL
+#define Y_ABSL_LOG_INTERNAL_CONDITION_INFO(type, condition) \
+ Y_ABSL_LOG_INTERNAL_##type##_CONDITION( \
+ (condition) && ::y_absl::LogSeverity::kInfo >= \
+ static_cast<::y_absl::LogSeverity>(Y_ABSL_MIN_LOG_LEVEL))
+#define Y_ABSL_LOG_INTERNAL_CONDITION_WARNING(type, condition) \
+ Y_ABSL_LOG_INTERNAL_##type##_CONDITION( \
+ (condition) && ::y_absl::LogSeverity::kWarning >= \
+ static_cast<::y_absl::LogSeverity>(Y_ABSL_MIN_LOG_LEVEL))
+#define Y_ABSL_LOG_INTERNAL_CONDITION_ERROR(type, condition) \
+ Y_ABSL_LOG_INTERNAL_##type##_CONDITION( \
+ (condition) && ::y_absl::LogSeverity::kError >= \
+ static_cast<::y_absl::LogSeverity>(Y_ABSL_MIN_LOG_LEVEL))
+// NOTE: Use ternary operators instead of short-circuiting to mitigate
+// https://bugs.llvm.org/show_bug.cgi?id=51928.
+#define Y_ABSL_LOG_INTERNAL_CONDITION_FATAL(type, condition) \
+ Y_ABSL_LOG_INTERNAL_##type##_CONDITION( \
+ ((condition) \
+ ? (::y_absl::LogSeverity::kFatal >= \
+ static_cast<::y_absl::LogSeverity>(Y_ABSL_MIN_LOG_LEVEL) \
+ ? true \
+ : (::y_absl::log_internal::AbortQuietly(), false)) \
+ : false))
+// NOTE: Use ternary operators instead of short-circuiting to mitigate
+// https://bugs.llvm.org/show_bug.cgi?id=51928.
+#define Y_ABSL_LOG_INTERNAL_CONDITION_QFATAL(type, condition) \
+ Y_ABSL_LOG_INTERNAL_##type##_CONDITION( \
+ ((condition) \
+ ? (::y_absl::LogSeverity::kFatal >= \
+ static_cast<::y_absl::LogSeverity>(Y_ABSL_MIN_LOG_LEVEL) \
+ ? true \
+ : (::y_absl::log_internal::ExitQuietly(), false)) \
+ : false))
+#define Y_ABSL_LOG_INTERNAL_CONDITION_DFATAL(type, condition) \
+ Y_ABSL_LOG_INTERNAL_##type##_CONDITION( \
+ (Y_ABSL_ASSUME(y_absl::kLogDebugFatal == y_absl::LogSeverity::kError || \
+ y_absl::kLogDebugFatal == y_absl::LogSeverity::kFatal), \
+ (condition) && \
+ (::y_absl::kLogDebugFatal >= \
+ static_cast<::y_absl::LogSeverity>(Y_ABSL_MIN_LOG_LEVEL) || \
+ (::y_absl::kLogDebugFatal == ::y_absl::LogSeverity::kFatal && \
+ (::y_absl::log_internal::AbortQuietly(), false)))))
+
+#define Y_ABSL_LOG_INTERNAL_CONDITION_LEVEL(severity) \
+ for (int absl_log_internal_severity_loop = 1; \
+ absl_log_internal_severity_loop; absl_log_internal_severity_loop = 0) \
+ for (const y_absl::LogSeverity absl_log_internal_severity = \
+ ::y_absl::NormalizeLogSeverity(severity); \
+ absl_log_internal_severity_loop; absl_log_internal_severity_loop = 0) \
+ Y_ABSL_LOG_INTERNAL_CONDITION_LEVEL_IMPL
+#define Y_ABSL_LOG_INTERNAL_CONDITION_LEVEL_IMPL(type, condition) \
+ Y_ABSL_LOG_INTERNAL_##type##_CONDITION(( \
+ (condition) && \
+ (absl_log_internal_severity >= \
+ static_cast<::y_absl::LogSeverity>(Y_ABSL_MIN_LOG_LEVEL) || \
+ (absl_log_internal_severity == ::y_absl::LogSeverity::kFatal && \
+ (::y_absl::log_internal::AbortQuietly(), false)))))
+#else // ndef Y_ABSL_MIN_LOG_LEVEL
+#define Y_ABSL_LOG_INTERNAL_CONDITION_INFO(type, condition) \
+ Y_ABSL_LOG_INTERNAL_##type##_CONDITION(condition)
+#define Y_ABSL_LOG_INTERNAL_CONDITION_WARNING(type, condition) \
+ Y_ABSL_LOG_INTERNAL_##type##_CONDITION(condition)
+#define Y_ABSL_LOG_INTERNAL_CONDITION_ERROR(type, condition) \
+ Y_ABSL_LOG_INTERNAL_##type##_CONDITION(condition)
+#define Y_ABSL_LOG_INTERNAL_CONDITION_FATAL(type, condition) \
+ Y_ABSL_LOG_INTERNAL_##type##_CONDITION(condition)
+#define Y_ABSL_LOG_INTERNAL_CONDITION_QFATAL(type, condition) \
+ Y_ABSL_LOG_INTERNAL_##type##_CONDITION(condition)
+#define Y_ABSL_LOG_INTERNAL_CONDITION_DFATAL(type, condition) \
+ Y_ABSL_LOG_INTERNAL_##type##_CONDITION(condition)
+#define Y_ABSL_LOG_INTERNAL_CONDITION_LEVEL(severity) \
+ for (int absl_log_internal_severity_loop = 1; \
+ absl_log_internal_severity_loop; absl_log_internal_severity_loop = 0) \
+ for (const y_absl::LogSeverity absl_log_internal_severity = \
+ ::y_absl::NormalizeLogSeverity(severity); \
+ absl_log_internal_severity_loop; absl_log_internal_severity_loop = 0) \
+ Y_ABSL_LOG_INTERNAL_CONDITION_LEVEL_IMPL
+#define Y_ABSL_LOG_INTERNAL_CONDITION_LEVEL_IMPL(type, condition) \
+ Y_ABSL_LOG_INTERNAL_##type##_CONDITION(condition)
+#endif // ndef Y_ABSL_MIN_LOG_LEVEL
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+
+// Stateful condition class name should be "Log" + name + "State".
+class LogEveryNState final {
+ public:
+ bool ShouldLog(int n);
+ uint32_t counter() { return counter_.load(std::memory_order_relaxed); }
+
+ private:
+ std::atomic<uint32_t> counter_{0};
+};
+
+class LogFirstNState final {
+ public:
+ bool ShouldLog(int n);
+ uint32_t counter() { return counter_.load(std::memory_order_relaxed); }
+
+ private:
+ std::atomic<uint32_t> counter_{0};
+};
+
+class LogEveryPow2State final {
+ public:
+ bool ShouldLog();
+ uint32_t counter() { return counter_.load(std::memory_order_relaxed); }
+
+ private:
+ std::atomic<uint32_t> counter_{0};
+};
+
+class LogEveryNSecState final {
+ public:
+ bool ShouldLog(double seconds);
+ uint32_t counter() { return counter_.load(std::memory_order_relaxed); }
+
+ private:
+ std::atomic<uint32_t> counter_{0};
+ // Cycle count according to CycleClock that we should next log at.
+ std::atomic<int64_t> next_log_time_cycles_{0};
+};
+
+// Helper routines to abort the application quietly
+
+[[noreturn]] inline void AbortQuietly() { abort(); }
+[[noreturn]] inline void ExitQuietly() { _exit(1); }
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_LOG_INTERNAL_CONDITIONS_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/config.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/config.h
new file mode 100644
index 00000000000..4e0febdb4eb
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/config.h
@@ -0,0 +1,45 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: log/internal/config.h
+// -----------------------------------------------------------------------------
+//
+
+#ifndef Y_ABSL_LOG_INTERNAL_CONFIG_H_
+#define Y_ABSL_LOG_INTERNAL_CONFIG_H_
+
+#include "y_absl/base/config.h"
+
+#ifdef _WIN32
+#include <cstdint>
+#else
+#include <sys/types.h>
+#endif
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+
+#ifdef _WIN32
+using Tid = uint32_t;
+#else
+using Tid = pid_t;
+#endif
+
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_LOG_INTERNAL_CONFIG_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/flags.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/flags.h
new file mode 100644
index 00000000000..e1bbcc0fabe
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/flags.h
@@ -0,0 +1,59 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: log/log_flags.h
+// -----------------------------------------------------------------------------
+//
+// This header declares set of flags which can be used to configure Abseil
+// Logging library behaviour at runtime.
+
+#ifndef Y_ABSL_LOG_INTERNAL_FLAGS_H_
+#define Y_ABSL_LOG_INTERNAL_FLAGS_H_
+
+#include <util/generic/string.h>
+
+#include "y_absl/flags/declare.h"
+
+// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+// These flags should not be used in C++ code to access logging library
+// configuration knobs. Use interfaces defined in y_absl/log/globals.h
+// instead. It is still ok to use these flags on a command line.
+// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+// Log messages at this severity or above are sent to stderr in *addition* to
+// `LogSink`s. Defaults to `ERROR`. See log_severity.h for numeric values of
+// severity levels.
+Y_ABSL_DECLARE_FLAG(int, stderrthreshold);
+
+// Log messages at this severity or above are logged; others are discarded.
+// Defaults to `INFO`, i.e. log all severities. See log_severity.h for numeric
+// values of severity levels.
+Y_ABSL_DECLARE_FLAG(int, minloglevel);
+
+// If specified in the form file:linenum, any messages logged from a matching
+// location will also include a backtrace.
+Y_ABSL_DECLARE_FLAG(TString, log_backtrace_at);
+
+// If true, the log prefix (severity, date, time, PID, etc.) is prepended to
+// each message logged. Defaults to true.
+Y_ABSL_DECLARE_FLAG(bool, log_prefix);
+
+// Global log verbosity level. Default is 0.
+Y_ABSL_DECLARE_FLAG(int, v);
+
+// Per-module log verbosity level. By default is empty and is unused.
+Y_ABSL_DECLARE_FLAG(TString, vmodule);
+
+#endif // Y_ABSL_LOG_INTERNAL_FLAGS_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/fnmatch.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/fnmatch.cc
new file mode 100644
index 00000000000..3316ab686c4
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/fnmatch.cc
@@ -0,0 +1,73 @@
+// Copyright 2023 The Abseil Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "y_absl/log/internal/fnmatch.h"
+
+#include <cstddef>
+
+#include "y_absl/base/config.h"
+#include "y_absl/strings/string_view.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+bool FNMatch(y_absl::string_view pattern, y_absl::string_view str) {
+ bool in_wildcard_match = false;
+ while (true) {
+ if (pattern.empty()) {
+ // `pattern` is exhausted; succeed if all of `str` was consumed matching
+ // it.
+ return in_wildcard_match || str.empty();
+ }
+ if (str.empty()) {
+ // `str` is exhausted; succeed if `pattern` is empty or all '*'s.
+ return pattern.find_first_not_of('*') == pattern.npos;
+ }
+ switch (pattern.front()) {
+ case '*':
+ pattern.remove_prefix(1);
+ in_wildcard_match = true;
+ break;
+ case '?':
+ pattern.remove_prefix(1);
+ str.remove_prefix(1);
+ break;
+ default:
+ if (in_wildcard_match) {
+ y_absl::string_view fixed_portion = pattern;
+ const size_t end = fixed_portion.find_first_of("*?");
+ if (end != fixed_portion.npos) {
+ fixed_portion = fixed_portion.substr(0, end);
+ }
+ const size_t match = str.find(fixed_portion);
+ if (match == str.npos) {
+ return false;
+ }
+ pattern.remove_prefix(fixed_portion.size());
+ str.remove_prefix(match + fixed_portion.size());
+ in_wildcard_match = false;
+ } else {
+ if (pattern.front() != str.front()) {
+ return false;
+ }
+ pattern.remove_prefix(1);
+ str.remove_prefix(1);
+ }
+ break;
+ }
+ }
+}
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/fnmatch.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/fnmatch.h
new file mode 100644
index 00000000000..8532535e0c1
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/fnmatch.h
@@ -0,0 +1,35 @@
+// Copyright 2023 The Abseil Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef Y_ABSL_LOG_INTERNAL_FNMATCH_H_
+#define Y_ABSL_LOG_INTERNAL_FNMATCH_H_
+
+#include "y_absl/base/config.h"
+#include "y_absl/strings/string_view.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+// Like POSIX `fnmatch`, but:
+// * accepts `string_view`
+// * does not allocate any dynamic memory
+// * only supports * and ? wildcards and not bracket expressions [...]
+// * wildcards may match /
+// * no backslash-escaping
+bool FNMatch(y_absl::string_view pattern, y_absl::string_view str);
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_LOG_INTERNAL_FNMATCH_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/globals.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/globals.cc
new file mode 100644
index 00000000000..5ee68c2f45a
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/globals.cc
@@ -0,0 +1,145 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "y_absl/log/internal/globals.h"
+
+#include <atomic>
+#include <cstdio>
+
+#if defined(__EMSCRIPTEN__)
+#error #include <emscripten/console.h>
+#endif
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/base/config.h"
+#include "y_absl/base/internal/raw_logging.h"
+#include "y_absl/base/log_severity.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/strings/strip.h"
+#include "y_absl/time/time.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+
+namespace {
+// Keeps track of whether Logging initialization is finalized.
+// Log messages generated before that will go to stderr.
+Y_ABSL_CONST_INIT std::atomic<bool> logging_initialized(false);
+
+// The TimeZone used for logging. This may only be set once.
+Y_ABSL_CONST_INIT std::atomic<y_absl::TimeZone*> timezone_ptr{nullptr};
+
+// If true, the logging library will symbolize stack in fatal messages
+Y_ABSL_CONST_INIT std::atomic<bool> symbolize_stack_trace(true);
+
+// Specifies maximum number of stack frames to report in fatal messages.
+Y_ABSL_CONST_INIT std::atomic<int> max_frames_in_stack_trace(64);
+
+Y_ABSL_CONST_INIT std::atomic<bool> exit_on_dfatal(true);
+Y_ABSL_CONST_INIT std::atomic<bool> suppress_sigabort_trace(false);
+} // namespace
+
+bool IsInitialized() {
+ return logging_initialized.load(std::memory_order_acquire);
+}
+
+void SetInitialized() {
+ logging_initialized.store(true, std::memory_order_release);
+}
+
+void WriteToStderr(y_absl::string_view message, y_absl::LogSeverity severity) {
+ if (message.empty()) return;
+#if defined(__EMSCRIPTEN__)
+ // In WebAssembly, bypass filesystem emulation via fwrite.
+ // Skip a trailing newline character as emscripten_errn adds one itself.
+ const auto message_minus_newline = y_absl::StripSuffix(message, "\n");
+ // emscripten_errn was introduced in 3.1.41 but broken in standalone mode
+ // until 3.1.43.
+#if Y_ABSL_INTERNAL_EMSCRIPTEN_VERSION >= 3001043
+ emscripten_errn(message_minus_newline.data(), message_minus_newline.size());
+#else
+ TString null_terminated_message(message_minus_newline);
+ _emscripten_err(null_terminated_message.c_str());
+#endif
+#else
+ // Avoid using std::cerr from this module since we may get called during
+ // exit code, and cerr may be partially or fully destroyed by then.
+ std::fwrite(message.data(), message.size(), 1, stderr);
+#endif
+
+#if defined(_WIN64) || defined(_WIN32) || defined(_WIN16)
+ // C99 requires stderr to not be fully-buffered by default (7.19.3.7), but
+ // MS CRT buffers it anyway, so we must `fflush` to ensure the string hits
+ // the console/file before the program dies (and takes the libc buffers
+ // with it).
+ // https://docs.microsoft.com/en-us/cpp/c-runtime-library/stream-i-o
+ if (severity >= y_absl::LogSeverity::kWarning) {
+ std::fflush(stderr);
+ }
+#else
+ // Avoid unused parameter warning in this branch.
+ (void)severity;
+#endif
+}
+
+void SetTimeZone(y_absl::TimeZone tz) {
+ y_absl::TimeZone* expected = nullptr;
+ y_absl::TimeZone* new_tz = new y_absl::TimeZone(tz);
+ // timezone_ptr can only be set once, otherwise new_tz is leaked.
+ if (!timezone_ptr.compare_exchange_strong(expected, new_tz,
+ std::memory_order_release,
+ std::memory_order_relaxed)) {
+ Y_ABSL_RAW_LOG(FATAL,
+ "y_absl::log_internal::SetTimeZone() has already been called");
+ }
+}
+
+const y_absl::TimeZone* TimeZone() {
+ return timezone_ptr.load(std::memory_order_acquire);
+}
+
+bool ShouldSymbolizeLogStackTrace() {
+ return symbolize_stack_trace.load(std::memory_order_acquire);
+}
+
+void EnableSymbolizeLogStackTrace(bool on_off) {
+ symbolize_stack_trace.store(on_off, std::memory_order_release);
+}
+
+int MaxFramesInLogStackTrace() {
+ return max_frames_in_stack_trace.load(std::memory_order_acquire);
+}
+
+void SetMaxFramesInLogStackTrace(int max_num_frames) {
+ max_frames_in_stack_trace.store(max_num_frames, std::memory_order_release);
+}
+
+bool ExitOnDFatal() { return exit_on_dfatal.load(std::memory_order_acquire); }
+
+void SetExitOnDFatal(bool on_off) {
+ exit_on_dfatal.store(on_off, std::memory_order_release);
+}
+
+bool SuppressSigabortTrace() {
+ return suppress_sigabort_trace.load(std::memory_order_acquire);
+}
+
+bool SetSuppressSigabortTrace(bool on_off) {
+ return suppress_sigabort_trace.exchange(on_off);
+}
+
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/globals.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/globals.h
new file mode 100644
index 00000000000..5d5a811704c
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/globals.h
@@ -0,0 +1,101 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: log/internal/globals.h
+// -----------------------------------------------------------------------------
+//
+// This header file contains various global objects and static helper routines
+// use in logging implementation.
+
+#ifndef Y_ABSL_LOG_INTERNAL_GLOBALS_H_
+#define Y_ABSL_LOG_INTERNAL_GLOBALS_H_
+
+#include "y_absl/base/config.h"
+#include "y_absl/base/log_severity.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/time/time.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+
+// IsInitialized returns true if the logging library is initialized.
+// This function is async-signal-safe
+bool IsInitialized();
+
+// SetLoggingInitialized is called once after logging initialization is done.
+void SetInitialized();
+
+// Unconditionally write a `message` to stderr. If `severity` exceeds kInfo
+// we also flush the stderr stream.
+void WriteToStderr(y_absl::string_view message, y_absl::LogSeverity severity);
+
+// Set the TimeZone used for human-friendly times (for example, the log message
+// prefix) printed by the logging library. This may only be called once.
+void SetTimeZone(y_absl::TimeZone tz);
+
+// Returns the TimeZone used for human-friendly times (for example, the log
+// message prefix) printed by the logging library Returns nullptr prior to
+// initialization.
+const y_absl::TimeZone* TimeZone();
+
+// Returns true if stack traces emitted by the logging library should be
+// symbolized. This function is async-signal-safe.
+bool ShouldSymbolizeLogStackTrace();
+
+// Enables or disables symbolization of stack traces emitted by the
+// logging library. This function is async-signal-safe.
+void EnableSymbolizeLogStackTrace(bool on_off);
+
+// Returns the maximum number of frames that appear in stack traces
+// emitted by the logging library. This function is async-signal-safe.
+int MaxFramesInLogStackTrace();
+
+// Sets the maximum number of frames that appear in stack traces emitted by
+// the logging library. This function is async-signal-safe.
+void SetMaxFramesInLogStackTrace(int max_num_frames);
+
+// Determines whether we exit the program for a LOG(DFATAL) message in
+// debug mode. It does this by skipping the call to Fail/FailQuietly.
+// This is intended for testing only.
+//
+// This can have some effects on LOG(FATAL) as well. Failure messages
+// are always allocated (rather than sharing a buffer), the crash
+// reason is not recorded, the "gwq" status message is not updated,
+// and the stack trace is not recorded. The LOG(FATAL) *will* still
+// exit the program. Since this function is used only in testing,
+// these differences are acceptable.
+//
+// Additionally, LOG(LEVEL(FATAL)) is indistinguishable from LOG(DFATAL) and
+// will not terminate the program if SetExitOnDFatal(false) has been called.
+bool ExitOnDFatal();
+
+// SetExitOnDFatal() sets the ExitOnDFatal() status
+void SetExitOnDFatal(bool on_off);
+
+// Determines if the logging library should suppress logging of stacktraces in
+// the `SIGABRT` handler, typically because we just logged a stacktrace as part
+// of `LOG(FATAL)` and are about to send ourselves a `SIGABRT` to end the
+// program.
+bool SuppressSigabortTrace();
+
+// Sets the SuppressSigabortTrace() status and returns the previous state.
+bool SetSuppressSigabortTrace(bool on_off);
+
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_LOG_INTERNAL_GLOBALS_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_format.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_format.cc
new file mode 100644
index 00000000000..a7292c3737b
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_format.cc
@@ -0,0 +1,205 @@
+//
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "y_absl/log/internal/log_format.h"
+
+#include <string.h>
+
+#ifdef _MSC_VER
+#include <winsock2.h> // For timeval
+#else
+#include <sys/time.h>
+#endif
+
+#include <cstddef>
+#include <cstdint>
+#include <limits>
+#include <util/generic/string.h>
+#include <type_traits>
+
+#include "y_absl/base/config.h"
+#include "y_absl/base/log_severity.h"
+#include "y_absl/base/optimization.h"
+#include "y_absl/log/internal/append_truncated.h"
+#include "y_absl/log/internal/config.h"
+#include "y_absl/log/internal/globals.h"
+#include "y_absl/strings/numbers.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/time/civil_time.h"
+#include "y_absl/time/time.h"
+#include "y_absl/types/span.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+namespace {
+
+// This templated function avoids compiler warnings about tautological
+// comparisons when log_internal::Tid is unsigned. It can be replaced with a
+// constexpr if once the minimum C++ version Abseil supports is C++17.
+template <typename T>
+inline std::enable_if_t<!std::is_signed<T>::value>
+PutLeadingWhitespace(T tid, char*& p) {
+ if (tid < 10) *p++ = ' ';
+ if (tid < 100) *p++ = ' ';
+ if (tid < 1000) *p++ = ' ';
+ if (tid < 10000) *p++ = ' ';
+ if (tid < 100000) *p++ = ' ';
+ if (tid < 1000000) *p++ = ' ';
+}
+
+template <typename T>
+inline std::enable_if_t<std::is_signed<T>::value>
+PutLeadingWhitespace(T tid, char*& p) {
+ if (tid >= 0 && tid < 10) *p++ = ' ';
+ if (tid > -10 && tid < 100) *p++ = ' ';
+ if (tid > -100 && tid < 1000) *p++ = ' ';
+ if (tid > -1000 && tid < 10000) *p++ = ' ';
+ if (tid > -10000 && tid < 100000) *p++ = ' ';
+ if (tid > -100000 && tid < 1000000) *p++ = ' ';
+}
+
+// The fields before the filename are all fixed-width except for the thread ID,
+// which is of bounded width.
+size_t FormatBoundedFields(y_absl::LogSeverity severity, y_absl::Time timestamp,
+ log_internal::Tid tid, y_absl::Span<char>& buf) {
+ constexpr size_t kBoundedFieldsMaxLen =
+ sizeof("SMMDD HH:MM:SS.NNNNNN ") +
+ (1 + std::numeric_limits<log_internal::Tid>::digits10 + 1) - sizeof("");
+ if (Y_ABSL_PREDICT_FALSE(buf.size() < kBoundedFieldsMaxLen)) {
+ // We don't bother trying to truncate these fields if the buffer is too
+ // short (or almost too short) because it would require doing a lot more
+ // length checking (slow) and it should never happen. A 15kB buffer should
+ // be enough for anyone. Instead we mark `buf` full without writing
+ // anything.
+ buf.remove_suffix(buf.size());
+ return 0;
+ }
+
+ // We can't call y_absl::LocalTime(), localtime_r(), or anything else here that
+ // isn't async-signal-safe. We can only use the time zone if it has already
+ // been loaded.
+ const y_absl::TimeZone* tz = y_absl::log_internal::TimeZone();
+ if (Y_ABSL_PREDICT_FALSE(tz == nullptr)) {
+ // If a time zone hasn't been set yet because we are logging before the
+ // logging library has been initialized, we fallback to a simpler, slower
+ // method. Just report the raw Unix time in seconds. We cram this into the
+ // normal time format for the benefit of parsers.
+ auto tv = y_absl::ToTimeval(timestamp);
+ int snprintf_result = y_absl::SNPrintF(
+ buf.data(), buf.size(), "%c0000 00:00:%02d.%06d %7d ",
+ y_absl::LogSeverityName(severity)[0], static_cast<int>(tv.tv_sec),
+ static_cast<int>(tv.tv_usec), static_cast<int>(tid));
+ if (snprintf_result >= 0) {
+ buf.remove_prefix(static_cast<size_t>(snprintf_result));
+ return static_cast<size_t>(snprintf_result);
+ }
+ return 0;
+ }
+
+ char* p = buf.data();
+ *p++ = y_absl::LogSeverityName(severity)[0];
+ const y_absl::TimeZone::CivilInfo ci = tz->At(timestamp);
+ y_absl::numbers_internal::PutTwoDigits(static_cast<uint32_t>(ci.cs.month()), p);
+ p += 2;
+ y_absl::numbers_internal::PutTwoDigits(static_cast<uint32_t>(ci.cs.day()), p);
+ p += 2;
+ *p++ = ' ';
+ y_absl::numbers_internal::PutTwoDigits(static_cast<uint32_t>(ci.cs.hour()), p);
+ p += 2;
+ *p++ = ':';
+ y_absl::numbers_internal::PutTwoDigits(static_cast<uint32_t>(ci.cs.minute()),
+ p);
+ p += 2;
+ *p++ = ':';
+ y_absl::numbers_internal::PutTwoDigits(static_cast<uint32_t>(ci.cs.second()),
+ p);
+ p += 2;
+ *p++ = '.';
+ const int64_t usecs = y_absl::ToInt64Microseconds(ci.subsecond);
+ y_absl::numbers_internal::PutTwoDigits(static_cast<uint32_t>(usecs / 10000), p);
+ p += 2;
+ y_absl::numbers_internal::PutTwoDigits(static_cast<uint32_t>(usecs / 100 % 100),
+ p);
+ p += 2;
+ y_absl::numbers_internal::PutTwoDigits(static_cast<uint32_t>(usecs % 100), p);
+ p += 2;
+ *p++ = ' ';
+ PutLeadingWhitespace(tid, p);
+ p = y_absl::numbers_internal::FastIntToBuffer(tid, p);
+ *p++ = ' ';
+ const size_t bytes_formatted = static_cast<size_t>(p - buf.data());
+ buf.remove_prefix(bytes_formatted);
+ return bytes_formatted;
+}
+
+size_t FormatLineNumber(int line, y_absl::Span<char>& buf) {
+ constexpr size_t kLineFieldMaxLen =
+ sizeof(":] ") + (1 + std::numeric_limits<int>::digits10 + 1) - sizeof("");
+ if (Y_ABSL_PREDICT_FALSE(buf.size() < kLineFieldMaxLen)) {
+ // As above, we don't bother trying to truncate this if the buffer is too
+ // short and it should never happen.
+ buf.remove_suffix(buf.size());
+ return 0;
+ }
+ char* p = buf.data();
+ *p++ = ':';
+ p = y_absl::numbers_internal::FastIntToBuffer(line, p);
+ *p++ = ']';
+ *p++ = ' ';
+ const size_t bytes_formatted = static_cast<size_t>(p - buf.data());
+ buf.remove_prefix(bytes_formatted);
+ return bytes_formatted;
+}
+
+} // namespace
+
+TString FormatLogMessage(y_absl::LogSeverity severity,
+ y_absl::CivilSecond civil_second,
+ y_absl::Duration subsecond, log_internal::Tid tid,
+ y_absl::string_view basename, int line,
+ PrefixFormat format, y_absl::string_view message) {
+ return y_absl::StrFormat(
+ "%c%02d%02d %02d:%02d:%02d.%06d %7d %s:%d] %s%s",
+ y_absl::LogSeverityName(severity)[0], civil_second.month(),
+ civil_second.day(), civil_second.hour(), civil_second.minute(),
+ civil_second.second(), y_absl::ToInt64Microseconds(subsecond), tid,
+ basename, line, format == PrefixFormat::kRaw ? "RAW: " : "", message);
+}
+
+// This method is fairly hot, and the library always passes a huge `buf`, so we
+// save some bounds-checking cycles by not trying to do precise truncation.
+// Truncating at a field boundary is probably a better UX anyway.
+//
+// The prefix is written in three parts, each of which does a single
+// bounds-check and truncation:
+// 1. severity, timestamp, and thread ID
+// 2. filename
+// 3. line number and bracket
+size_t FormatLogPrefix(y_absl::LogSeverity severity, y_absl::Time timestamp,
+ log_internal::Tid tid, y_absl::string_view basename,
+ int line, PrefixFormat format, y_absl::Span<char>& buf) {
+ auto prefix_size = FormatBoundedFields(severity, timestamp, tid, buf);
+ prefix_size += log_internal::AppendTruncated(basename, buf);
+ prefix_size += FormatLineNumber(line, buf);
+ if (format == PrefixFormat::kRaw)
+ prefix_size += log_internal::AppendTruncated("RAW: ", buf);
+ return prefix_size;
+}
+
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_format.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_format.h
new file mode 100644
index 00000000000..5e5e09f44e2
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_format.h
@@ -0,0 +1,78 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: log/internal/log_format.h
+// -----------------------------------------------------------------------------
+//
+// This file declares routines implementing formatting of log message and log
+// prefix.
+
+#ifndef Y_ABSL_LOG_INTERNAL_LOG_FORMAT_H_
+#define Y_ABSL_LOG_INTERNAL_LOG_FORMAT_H_
+
+#include <stddef.h>
+
+#include <util/generic/string.h>
+
+#include "y_absl/base/config.h"
+#include "y_absl/base/log_severity.h"
+#include "y_absl/log/internal/config.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/time/civil_time.h"
+#include "y_absl/time/time.h"
+#include "y_absl/types/span.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+
+enum class PrefixFormat {
+ kNotRaw,
+ kRaw,
+};
+
+// Formats log message based on provided data.
+TString FormatLogMessage(y_absl::LogSeverity severity,
+ y_absl::CivilSecond civil_second,
+ y_absl::Duration subsecond, log_internal::Tid tid,
+ y_absl::string_view basename, int line,
+ PrefixFormat format, y_absl::string_view message);
+
+// Formats various entry metadata into a text string meant for use as a
+// prefix on a log message string. Writes into `buf`, advances `buf` to point
+// at the remainder of the buffer (i.e. past any written bytes), and returns the
+// number of bytes written.
+//
+// In addition to calling `buf->remove_prefix()` (or the equivalent), this
+// function may also do `buf->remove_suffix(buf->size())` in cases where no more
+// bytes (i.e. no message data) should be written into the buffer. For example,
+// if the prefix ought to be:
+// I0926 09:00:00.000000 1234567 foo.cc:123]
+// `buf` is too small, the function might fill the whole buffer:
+// I0926 09:00:00.000000 1234
+// (note the apparrently incorrect thread ID), or it might write less:
+// I0926 09:00:00.000000
+// In this case, it might also empty `buf` prior to returning to prevent
+// message data from being written into the space where a reader would expect to
+// see a thread ID.
+size_t FormatLogPrefix(y_absl::LogSeverity severity, y_absl::Time timestamp,
+ log_internal::Tid tid, y_absl::string_view basename,
+ int line, PrefixFormat format, y_absl::Span<char>& buf);
+
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_LOG_INTERNAL_LOG_FORMAT_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_impl.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_impl.h
new file mode 100644
index 00000000000..588d1949219
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_impl.h
@@ -0,0 +1,282 @@
+// Copyright 2022 The Abseil Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef Y_ABSL_LOG_INTERNAL_LOG_IMPL_H_
+#define Y_ABSL_LOG_INTERNAL_LOG_IMPL_H_
+
+#include "y_absl/log/absl_vlog_is_on.h"
+#include "y_absl/log/internal/conditions.h"
+#include "y_absl/log/internal/log_message.h"
+#include "y_absl/log/internal/strip.h"
+
+// Y_ABSL_LOG()
+#define Y_ABSL_LOG_INTERNAL_LOG_IMPL(severity) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, true) \
+ Y_ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
+
+// Y_ABSL_PLOG()
+#define Y_ABSL_LOG_INTERNAL_PLOG_IMPL(severity) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, true) \
+ Y_ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() \
+ .WithPerror()
+
+// Y_ABSL_DLOG()
+#ifndef NDEBUG
+#define Y_ABSL_LOG_INTERNAL_DLOG_IMPL(severity) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, true) \
+ Y_ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
+#else
+#define Y_ABSL_LOG_INTERNAL_DLOG_IMPL(severity) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, false) \
+ Y_ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
+#endif
+
+// The `switch` ensures that this expansion is the beginning of a statement (as
+// opposed to an expression). The use of both `case 0` and `default` is to
+// suppress a compiler warning.
+#define Y_ABSL_LOG_INTERNAL_VLOG_IMPL(verbose_level) \
+ switch (const int absl_logging_internal_verbose_level = (verbose_level)) \
+ case 0: \
+ default: \
+ Y_ABSL_LOG_INTERNAL_LOG_IF_IMPL( \
+ _INFO, Y_ABSL_VLOG_IS_ON(absl_logging_internal_verbose_level)) \
+ .WithVerbosity(absl_logging_internal_verbose_level)
+
+#ifndef NDEBUG
+#define Y_ABSL_LOG_INTERNAL_DVLOG_IMPL(verbose_level) \
+ switch (const int absl_logging_internal_verbose_level = (verbose_level)) \
+ case 0: \
+ default: \
+ Y_ABSL_LOG_INTERNAL_DLOG_IF_IMPL( \
+ _INFO, Y_ABSL_VLOG_IS_ON(absl_logging_internal_verbose_level)) \
+ .WithVerbosity(absl_logging_internal_verbose_level)
+#else
+#define Y_ABSL_LOG_INTERNAL_DVLOG_IMPL(verbose_level) \
+ switch (const int absl_logging_internal_verbose_level = (verbose_level)) \
+ case 0: \
+ default: \
+ Y_ABSL_LOG_INTERNAL_DLOG_IF_IMPL( \
+ _INFO, false && Y_ABSL_VLOG_IS_ON(absl_logging_internal_verbose_level)) \
+ .WithVerbosity(absl_logging_internal_verbose_level)
+#endif
+
+#define Y_ABSL_LOG_INTERNAL_LOG_IF_IMPL(severity, condition) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, condition) \
+ Y_ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
+#define Y_ABSL_LOG_INTERNAL_PLOG_IF_IMPL(severity, condition) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, condition) \
+ Y_ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() \
+ .WithPerror()
+
+#ifndef NDEBUG
+#define Y_ABSL_LOG_INTERNAL_DLOG_IF_IMPL(severity, condition) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, condition) \
+ Y_ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
+#else
+#define Y_ABSL_LOG_INTERNAL_DLOG_IF_IMPL(severity, condition) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, false && (condition)) \
+ Y_ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
+#endif
+
+// Y_ABSL_LOG_EVERY_N
+#define Y_ABSL_LOG_INTERNAL_LOG_EVERY_N_IMPL(severity, n) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryN, n) \
+ Y_ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
+
+// Y_ABSL_LOG_FIRST_N
+#define Y_ABSL_LOG_INTERNAL_LOG_FIRST_N_IMPL(severity, n) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(FirstN, n) \
+ Y_ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
+
+// Y_ABSL_LOG_EVERY_POW_2
+#define Y_ABSL_LOG_INTERNAL_LOG_EVERY_POW_2_IMPL(severity) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryPow2) \
+ Y_ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
+
+// Y_ABSL_LOG_EVERY_N_SEC
+#define Y_ABSL_LOG_INTERNAL_LOG_EVERY_N_SEC_IMPL(severity, n_seconds) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryNSec, n_seconds) \
+ Y_ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
+
+#define Y_ABSL_LOG_INTERNAL_PLOG_EVERY_N_IMPL(severity, n) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryN, n) \
+ Y_ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() \
+ .WithPerror()
+
+#define Y_ABSL_LOG_INTERNAL_PLOG_FIRST_N_IMPL(severity, n) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(FirstN, n) \
+ Y_ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() \
+ .WithPerror()
+
+#define Y_ABSL_LOG_INTERNAL_PLOG_EVERY_POW_2_IMPL(severity) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryPow2) \
+ Y_ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() \
+ .WithPerror()
+
+#define Y_ABSL_LOG_INTERNAL_PLOG_EVERY_N_SEC_IMPL(severity, n_seconds) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryNSec, n_seconds) \
+ Y_ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() \
+ .WithPerror()
+
+#ifndef NDEBUG
+#define Y_ABSL_LOG_INTERNAL_DLOG_EVERY_N_IMPL(severity, n) \
+ Y_ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, true) \
+ (EveryN, n) Y_ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
+
+#define Y_ABSL_LOG_INTERNAL_DLOG_FIRST_N_IMPL(severity, n) \
+ Y_ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, true) \
+ (FirstN, n) Y_ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
+
+#define Y_ABSL_LOG_INTERNAL_DLOG_EVERY_POW_2_IMPL(severity) \
+ Y_ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, true) \
+ (EveryPow2) Y_ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
+
+#define Y_ABSL_LOG_INTERNAL_DLOG_EVERY_N_SEC_IMPL(severity, n_seconds) \
+ Y_ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, true) \
+ (EveryNSec, n_seconds) Y_ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
+
+#else // def NDEBUG
+#define Y_ABSL_LOG_INTERNAL_DLOG_EVERY_N_IMPL(severity, n) \
+ Y_ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, false) \
+ (EveryN, n) Y_ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
+
+#define Y_ABSL_LOG_INTERNAL_DLOG_FIRST_N_IMPL(severity, n) \
+ Y_ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, false) \
+ (FirstN, n) Y_ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
+
+#define Y_ABSL_LOG_INTERNAL_DLOG_EVERY_POW_2_IMPL(severity) \
+ Y_ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, false) \
+ (EveryPow2) Y_ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
+
+#define Y_ABSL_LOG_INTERNAL_DLOG_EVERY_N_SEC_IMPL(severity, n_seconds) \
+ Y_ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, false) \
+ (EveryNSec, n_seconds) Y_ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
+#endif // def NDEBUG
+
+#define Y_ABSL_LOG_INTERNAL_VLOG_EVERY_N_IMPL(verbose_level, n) \
+ switch (const int absl_logging_internal_verbose_level = (verbose_level)) \
+ case 0: \
+ default: \
+ Y_ABSL_LOG_INTERNAL_CONDITION_INFO( \
+ STATEFUL, Y_ABSL_VLOG_IS_ON(absl_logging_internal_verbose_level)) \
+ (EveryN, n) Y_ABSL_LOGGING_INTERNAL_LOG_INFO.InternalStream().WithVerbosity( \
+ absl_logging_internal_verbose_level)
+
+#define Y_ABSL_LOG_INTERNAL_VLOG_FIRST_N_IMPL(verbose_level, n) \
+ switch (const int absl_logging_internal_verbose_level = (verbose_level)) \
+ case 0: \
+ default: \
+ Y_ABSL_LOG_INTERNAL_CONDITION_INFO( \
+ STATEFUL, Y_ABSL_VLOG_IS_ON(absl_logging_internal_verbose_level)) \
+ (FirstN, n) Y_ABSL_LOGGING_INTERNAL_LOG_INFO.InternalStream().WithVerbosity( \
+ absl_logging_internal_verbose_level)
+
+#define Y_ABSL_LOG_INTERNAL_VLOG_EVERY_POW_2_IMPL(verbose_level) \
+ switch (const int absl_logging_internal_verbose_level = (verbose_level)) \
+ case 0: \
+ default: \
+ Y_ABSL_LOG_INTERNAL_CONDITION_INFO( \
+ STATEFUL, Y_ABSL_VLOG_IS_ON(absl_logging_internal_verbose_level)) \
+ (EveryPow2) Y_ABSL_LOGGING_INTERNAL_LOG_INFO.InternalStream().WithVerbosity( \
+ absl_logging_internal_verbose_level)
+
+#define Y_ABSL_LOG_INTERNAL_VLOG_EVERY_N_SEC_IMPL(verbose_level, n_seconds) \
+ switch (const int absl_logging_internal_verbose_level = (verbose_level)) \
+ case 0: \
+ default: \
+ Y_ABSL_LOG_INTERNAL_CONDITION_INFO( \
+ STATEFUL, Y_ABSL_VLOG_IS_ON(absl_logging_internal_verbose_level)) \
+ (EveryNSec, n_seconds) Y_ABSL_LOGGING_INTERNAL_LOG_INFO.InternalStream() \
+ .WithVerbosity(absl_logging_internal_verbose_level)
+
+#define Y_ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_IMPL(severity, condition, n) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryN, n) \
+ Y_ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
+
+#define Y_ABSL_LOG_INTERNAL_LOG_IF_FIRST_N_IMPL(severity, condition, n) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(FirstN, n) \
+ Y_ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
+
+#define Y_ABSL_LOG_INTERNAL_LOG_IF_EVERY_POW_2_IMPL(severity, condition) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryPow2) \
+ Y_ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
+
+#define Y_ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_SEC_IMPL(severity, condition, \
+ n_seconds) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryNSec, \
+ n_seconds) \
+ Y_ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
+
+#define Y_ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_IMPL(severity, condition, n) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryN, n) \
+ Y_ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() \
+ .WithPerror()
+
+#define Y_ABSL_LOG_INTERNAL_PLOG_IF_FIRST_N_IMPL(severity, condition, n) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(FirstN, n) \
+ Y_ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() \
+ .WithPerror()
+
+#define Y_ABSL_LOG_INTERNAL_PLOG_IF_EVERY_POW_2_IMPL(severity, condition) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryPow2) \
+ Y_ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() \
+ .WithPerror()
+
+#define Y_ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_SEC_IMPL(severity, condition, \
+ n_seconds) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryNSec, \
+ n_seconds) \
+ Y_ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() \
+ .WithPerror()
+
+#ifndef NDEBUG
+#define Y_ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_IMPL(severity, condition, n) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryN, n) \
+ Y_ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
+
+#define Y_ABSL_LOG_INTERNAL_DLOG_IF_FIRST_N_IMPL(severity, condition, n) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(FirstN, n) \
+ Y_ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
+
+#define Y_ABSL_LOG_INTERNAL_DLOG_IF_EVERY_POW_2_IMPL(severity, condition) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryPow2) \
+ Y_ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
+
+#define Y_ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_SEC_IMPL(severity, condition, \
+ n_seconds) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryNSec, \
+ n_seconds) \
+ Y_ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
+
+#else // def NDEBUG
+#define Y_ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_IMPL(severity, condition, n) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, false && (condition))( \
+ EveryN, n) Y_ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
+
+#define Y_ABSL_LOG_INTERNAL_DLOG_IF_FIRST_N_IMPL(severity, condition, n) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, false && (condition))( \
+ FirstN, n) Y_ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
+
+#define Y_ABSL_LOG_INTERNAL_DLOG_IF_EVERY_POW_2_IMPL(severity, condition) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, false && (condition))( \
+ EveryPow2) Y_ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
+
+#define Y_ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_SEC_IMPL(severity, condition, \
+ n_seconds) \
+ Y_ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, false && (condition))( \
+ EveryNSec, n_seconds) \
+ Y_ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
+#endif // def NDEBUG
+
+#endif // Y_ABSL_LOG_INTERNAL_LOG_IMPL_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_message.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_message.cc
new file mode 100644
index 00000000000..b4f83ad3b3e
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_message.cc
@@ -0,0 +1,726 @@
+//
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "y_absl/log/internal/log_message.h"
+
+#include <stddef.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+
+#include <algorithm>
+#include <array>
+#include <atomic>
+#include <ios>
+#include <memory>
+#include <ostream>
+#include <util/generic/string.h>
+#include <tuple>
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/base/config.h"
+#include "y_absl/base/internal/raw_logging.h"
+#include "y_absl/base/internal/strerror.h"
+#include "y_absl/base/internal/sysinfo.h"
+#include "y_absl/base/log_severity.h"
+#include "y_absl/container/inlined_vector.h"
+#include "y_absl/debugging/internal/examine_stack.h"
+#include "y_absl/log/globals.h"
+#include "y_absl/log/internal/append_truncated.h"
+#include "y_absl/log/internal/globals.h"
+#include "y_absl/log/internal/log_format.h"
+#include "y_absl/log/internal/log_sink_set.h"
+#include "y_absl/log/internal/proto.h"
+#include "y_absl/log/log_entry.h"
+#include "y_absl/log/log_sink.h"
+#include "y_absl/log/log_sink_registry.h"
+#include "y_absl/memory/memory.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/time/clock.h"
+#include "y_absl/time/time.h"
+#include "y_absl/types/span.h"
+
+extern "C" Y_ABSL_ATTRIBUTE_WEAK void Y_ABSL_INTERNAL_C_SYMBOL(
+ AbslInternalOnFatalLogMessage)(const y_absl::LogEntry&) {
+ // Default - Do nothing
+}
+
+static int IsFatalErrorsThrow = true;
+namespace y_absl {
+ bool FatalErrorsThrowException() {
+ return IsFatalErrorsThrow;
+ }
+}
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+
+namespace {
+// message `logging.proto.Event`
+enum EventTag : uint8_t {
+ kFileName = 2,
+ kFileLine = 3,
+ kTimeNsecs = 4,
+ kSeverity = 5,
+ kThreadId = 6,
+ kValue = 7,
+ kSequenceNumber = 9,
+ kThreadName = 10,
+};
+
+// message `logging.proto.Value`
+enum ValueTag : uint8_t {
+ kString = 1,
+ kStringLiteral = 6,
+};
+
+// Decodes a `logging.proto.Value` from `buf` and writes a string representation
+// into `dst`. The string representation will be truncated if `dst` is not
+// large enough to hold it. Returns false if `dst` has size zero or one (i.e.
+// sufficient only for a nul-terminator) and no decoded data could be written.
+// This function may or may not write a nul-terminator into `dst`, and it may or
+// may not truncate the data it writes in order to do make space for that nul
+// terminator. In any case, `dst` will be advanced to point at the byte where
+// subsequent writes should begin.
+bool PrintValue(y_absl::Span<char>& dst, y_absl::Span<const char> buf) {
+ if (dst.size() <= 1) return false;
+ ProtoField field;
+ while (field.DecodeFrom(&buf)) {
+ switch (field.tag()) {
+ case ValueTag::kString:
+ case ValueTag::kStringLiteral:
+ if (field.type() == WireType::kLengthDelimited)
+ if (log_internal::AppendTruncated(field.string_value(), dst) <
+ field.string_value().size())
+ return false;
+ }
+ }
+ return true;
+}
+
+// See `logging.proto.Severity`
+int32_t ProtoSeverity(y_absl::LogSeverity severity, int verbose_level) {
+ switch (severity) {
+ case y_absl::LogSeverity::kInfo:
+ if (verbose_level == y_absl::LogEntry::kNoVerbosityLevel) return 800;
+ return 600 - verbose_level;
+ case y_absl::LogSeverity::kWarning:
+ return 900;
+ case y_absl::LogSeverity::kError:
+ return 950;
+ case y_absl::LogSeverity::kFatal:
+ return 1100;
+ default:
+ return 800;
+ }
+}
+
+y_absl::string_view Basename(y_absl::string_view filepath) {
+#ifdef _WIN32
+ size_t path = filepath.find_last_of("/\\");
+#else
+ size_t path = filepath.find_last_of('/');
+#endif
+ if (path != filepath.npos) filepath.remove_prefix(path + 1);
+ return filepath;
+}
+
+void WriteToString(const char* data, void* str) {
+ reinterpret_cast<TString*>(str)->append(data);
+}
+void WriteToStream(const char* data, void* os) {
+ auto* cast_os = static_cast<std::ostream*>(os);
+ *cast_os << data;
+}
+} // namespace
+
+struct LogMessage::LogMessageData final {
+ LogMessageData(const char* file, int line, y_absl::LogSeverity severity,
+ y_absl::Time timestamp);
+ LogMessageData(const LogMessageData&) = delete;
+ LogMessageData& operator=(const LogMessageData&) = delete;
+
+ // `LogEntry` sent to `LogSink`s; contains metadata.
+ y_absl::LogEntry entry;
+
+ // true => this was first fatal msg
+ bool first_fatal;
+ // true => all failures should be quiet
+ bool fail_quietly;
+ // true => PLOG was requested
+ bool is_perror;
+
+ // Extra `LogSink`s to log to, in addition to `global_sinks`.
+ y_absl::InlinedVector<y_absl::LogSink*, 16> extra_sinks;
+ // If true, log to `extra_sinks` but not to `global_sinks` or hardcoded
+ // non-sink targets (e.g. stderr, log files).
+ bool extra_sinks_only;
+
+ std::ostream manipulated; // ostream with IO manipulators applied
+
+ // A `logging.proto.Event` proto message is built into `encoded_buf`.
+ std::array<char, kLogMessageBufferSize> encoded_buf;
+ // `encoded_remaining()` is the suffix of `encoded_buf` that has not been
+ // filled yet. If a datum to be encoded does not fit into
+ // `encoded_remaining()` and cannot be truncated to fit, the size of
+ // `encoded_remaining()` will be zeroed to prevent encoding of any further
+ // data. Note that in this case its `data()` pointer will not point past the
+ // end of `encoded_buf`.
+ // The first use of `encoded_remaining()` is our chance to record metadata
+ // after any modifications (e.g. by `AtLocation()`) but before any data have
+ // been recorded. We want to record metadata before data so that data are
+ // preferentially truncated if we run out of buffer.
+ y_absl::Span<char>& encoded_remaining() {
+ if (encoded_remaining_actual_do_not_use_directly.data() == nullptr) {
+ encoded_remaining_actual_do_not_use_directly =
+ y_absl::MakeSpan(encoded_buf);
+ InitializeEncodingAndFormat();
+ }
+ return encoded_remaining_actual_do_not_use_directly;
+ }
+ y_absl::Span<char> encoded_remaining_actual_do_not_use_directly;
+
+ // A formatted string message is built in `string_buf`.
+ std::array<char, kLogMessageBufferSize> string_buf;
+
+ void InitializeEncodingAndFormat();
+ void FinalizeEncodingAndFormat();
+};
+
+LogMessage::LogMessageData::LogMessageData(const char* file, int line,
+ y_absl::LogSeverity severity,
+ y_absl::Time timestamp)
+ : extra_sinks_only(false), manipulated(nullptr) {
+ // Legacy defaults for LOG's ostream:
+ manipulated.setf(std::ios_base::showbase | std::ios_base::boolalpha);
+ entry.full_filename_ = file;
+ entry.base_filename_ = Basename(file);
+ entry.line_ = line;
+ entry.prefix_ = y_absl::ShouldPrependLogPrefix();
+ entry.severity_ = y_absl::NormalizeLogSeverity(severity);
+ entry.verbose_level_ = y_absl::LogEntry::kNoVerbosityLevel;
+ entry.timestamp_ = timestamp;
+ entry.tid_ = y_absl::base_internal::GetCachedTID();
+}
+
+void LogMessage::LogMessageData::InitializeEncodingAndFormat() {
+ EncodeStringTruncate(EventTag::kFileName, entry.source_filename(),
+ &encoded_remaining());
+ EncodeVarint(EventTag::kFileLine, entry.source_line(), &encoded_remaining());
+ EncodeVarint(EventTag::kTimeNsecs, y_absl::ToUnixNanos(entry.timestamp()),
+ &encoded_remaining());
+ EncodeVarint(EventTag::kSeverity,
+ ProtoSeverity(entry.log_severity(), entry.verbosity()),
+ &encoded_remaining());
+ EncodeVarint(EventTag::kThreadId, entry.tid(), &encoded_remaining());
+}
+
+void LogMessage::LogMessageData::FinalizeEncodingAndFormat() {
+ // Note that `encoded_remaining()` may have zero size without pointing past
+ // the end of `encoded_buf`, so the difference between `data()` pointers is
+ // used to compute the size of `encoded_data`.
+ y_absl::Span<const char> encoded_data(
+ encoded_buf.data(),
+ static_cast<size_t>(encoded_remaining().data() - encoded_buf.data()));
+ // `string_remaining` is the suffix of `string_buf` that has not been filled
+ // yet.
+ y_absl::Span<char> string_remaining(string_buf);
+ // We may need to write a newline and nul-terminator at the end of the decoded
+ // string data. Rather than worry about whether those should overwrite the
+ // end of the string (if the buffer is full) or be appended, we avoid writing
+ // into the last two bytes so we always have space to append.
+ string_remaining.remove_suffix(2);
+ entry.prefix_len_ =
+ entry.prefix() ? log_internal::FormatLogPrefix(
+ entry.log_severity(), entry.timestamp(), entry.tid(),
+ entry.source_basename(), entry.source_line(),
+ log_internal::ThreadIsLoggingToLogSink()
+ ? PrefixFormat::kRaw
+ : PrefixFormat::kNotRaw,
+ string_remaining)
+ : 0;
+ // Decode data from `encoded_buf` until we run out of data or we run out of
+ // `string_remaining`.
+ ProtoField field;
+ while (field.DecodeFrom(&encoded_data)) {
+ switch (field.tag()) {
+ case EventTag::kValue:
+ if (field.type() != WireType::kLengthDelimited) continue;
+ if (PrintValue(string_remaining, field.bytes_value())) continue;
+ break;
+ }
+ }
+ auto chars_written =
+ static_cast<size_t>(string_remaining.data() - string_buf.data());
+ string_buf[chars_written++] = '\n';
+ string_buf[chars_written++] = '\0';
+ entry.text_message_with_prefix_and_newline_and_nul_ =
+ y_absl::MakeSpan(string_buf).subspan(0, chars_written);
+}
+
+LogMessage::LogMessage(const char* file, int line, y_absl::LogSeverity severity)
+ : data_(y_absl::make_unique<LogMessageData>(file, line, severity,
+ y_absl::Now())) {
+ data_->first_fatal = false;
+ data_->is_perror = false;
+ data_->fail_quietly = false;
+
+ // This logs a backtrace even if the location is subsequently changed using
+ // AtLocation. This quirk, and the behavior when AtLocation is called twice,
+ // are fixable but probably not worth fixing.
+ LogBacktraceIfNeeded();
+}
+
+LogMessage::LogMessage(const char* file, int line, InfoTag)
+ : LogMessage(file, line, y_absl::LogSeverity::kInfo) {}
+LogMessage::LogMessage(const char* file, int line, WarningTag)
+ : LogMessage(file, line, y_absl::LogSeverity::kWarning) {}
+LogMessage::LogMessage(const char* file, int line, ErrorTag)
+ : LogMessage(file, line, y_absl::LogSeverity::kError) {}
+
+LogMessage::~LogMessage() {
+#ifdef Y_ABSL_MIN_LOG_LEVEL
+ if (data_->entry.log_severity() <
+ static_cast<y_absl::LogSeverity>(Y_ABSL_MIN_LOG_LEVEL) &&
+ data_->entry.log_severity() < y_absl::LogSeverity::kFatal) {
+ return;
+ }
+#endif
+ Flush();
+}
+
+LogMessage& LogMessage::AtLocation(y_absl::string_view file, int line) {
+ data_->entry.full_filename_ = file;
+ data_->entry.base_filename_ = Basename(file);
+ data_->entry.line_ = line;
+ LogBacktraceIfNeeded();
+ return *this;
+}
+
+LogMessage& LogMessage::NoPrefix() {
+ data_->entry.prefix_ = false;
+ return *this;
+}
+
+LogMessage& LogMessage::WithVerbosity(int verbose_level) {
+ if (verbose_level == y_absl::LogEntry::kNoVerbosityLevel) {
+ data_->entry.verbose_level_ = y_absl::LogEntry::kNoVerbosityLevel;
+ } else {
+ data_->entry.verbose_level_ = std::max(0, verbose_level);
+ }
+ return *this;
+}
+
+LogMessage& LogMessage::WithTimestamp(y_absl::Time timestamp) {
+ data_->entry.timestamp_ = timestamp;
+ return *this;
+}
+
+LogMessage& LogMessage::WithThreadID(y_absl::LogEntry::tid_t tid) {
+ data_->entry.tid_ = tid;
+ return *this;
+}
+
+LogMessage& LogMessage::WithMetadataFrom(const y_absl::LogEntry& entry) {
+ data_->entry.full_filename_ = entry.full_filename_;
+ data_->entry.base_filename_ = entry.base_filename_;
+ data_->entry.line_ = entry.line_;
+ data_->entry.prefix_ = entry.prefix_;
+ data_->entry.severity_ = entry.severity_;
+ data_->entry.verbose_level_ = entry.verbose_level_;
+ data_->entry.timestamp_ = entry.timestamp_;
+ data_->entry.tid_ = entry.tid_;
+ return *this;
+}
+
+LogMessage& LogMessage::WithPerror() {
+ data_->is_perror = true;
+ return *this;
+}
+
+LogMessage& LogMessage::ToSinkAlso(y_absl::LogSink* sink) {
+ Y_ABSL_INTERNAL_CHECK(sink, "null LogSink*");
+ data_->extra_sinks.push_back(sink);
+ return *this;
+}
+
+LogMessage& LogMessage::ToSinkOnly(y_absl::LogSink* sink) {
+ Y_ABSL_INTERNAL_CHECK(sink, "null LogSink*");
+ data_->extra_sinks.clear();
+ data_->extra_sinks.push_back(sink);
+ data_->extra_sinks_only = true;
+ return *this;
+}
+
+#ifdef __ELF__
+extern "C" void __gcov_dump() Y_ABSL_ATTRIBUTE_WEAK;
+extern "C" void __gcov_flush() Y_ABSL_ATTRIBUTE_WEAK;
+#endif
+
+void LogMessage::FailWithoutStackTrace() {
+ // Now suppress repeated trace logging:
+ log_internal::SetSuppressSigabortTrace(true);
+#if defined _DEBUG && defined COMPILER_MSVC
+ // When debugging on windows, avoid the obnoxious dialog.
+ __debugbreak();
+#endif
+
+#ifdef __ELF__
+ // For b/8737634, flush coverage if we are in coverage mode.
+ if (&__gcov_dump != nullptr) {
+ __gcov_dump();
+ } else if (&__gcov_flush != nullptr) {
+ __gcov_flush();
+ }
+#endif
+
+ abort();
+}
+
+void LogMessage::FailQuietly() {
+ // _exit. Calling abort() would trigger all sorts of death signal handlers
+ // and a detailed stack trace. Calling exit() would trigger the onexit
+ // handlers, including the heap-leak checker, which is guaranteed to fail in
+ // this case: we probably just new'ed the TString that we logged.
+ // Anyway, if you're calling Fail or FailQuietly, you're trying to bail out
+ // of the program quickly, and it doesn't make much sense for FailQuietly to
+ // offer different guarantees about exit behavior than Fail does. (And as a
+ // consequence for QCHECK and CHECK to offer different exit behaviors)
+ _exit(1);
+}
+
+LogMessage& LogMessage::operator<<(const TString& v) {
+ CopyToEncodedBuffer<StringType::kNotLiteral>(v);
+ return *this;
+}
+
+LogMessage& LogMessage::operator<<(y_absl::string_view v) {
+ CopyToEncodedBuffer<StringType::kNotLiteral>(v);
+ return *this;
+}
+LogMessage& LogMessage::operator<<(std::ostream& (*m)(std::ostream& os)) {
+ OstreamView view(*data_);
+ data_->manipulated << m;
+ return *this;
+}
+LogMessage& LogMessage::operator<<(std::ios_base& (*m)(std::ios_base& os)) {
+ OstreamView view(*data_);
+ data_->manipulated << m;
+ return *this;
+}
+template LogMessage& LogMessage::operator<<(const char& v);
+template LogMessage& LogMessage::operator<<(const signed char& v);
+template LogMessage& LogMessage::operator<<(const unsigned char& v);
+template LogMessage& LogMessage::operator<<(const short& v); // NOLINT
+template LogMessage& LogMessage::operator<<(const unsigned short& v); // NOLINT
+template LogMessage& LogMessage::operator<<(const int& v);
+template LogMessage& LogMessage::operator<<(const unsigned int& v);
+template LogMessage& LogMessage::operator<<(const long& v); // NOLINT
+template LogMessage& LogMessage::operator<<(const unsigned long& v); // NOLINT
+template LogMessage& LogMessage::operator<<(const long long& v); // NOLINT
+template LogMessage& LogMessage::operator<<(
+ const unsigned long long& v); // NOLINT
+template LogMessage& LogMessage::operator<<(void* const& v);
+template LogMessage& LogMessage::operator<<(const void* const& v);
+template LogMessage& LogMessage::operator<<(const float& v);
+template LogMessage& LogMessage::operator<<(const double& v);
+template LogMessage& LogMessage::operator<<(const bool& v);
+
+void LogMessage::Flush() {
+ if (data_->entry.log_severity() < y_absl::MinLogLevel()) return;
+
+ if (data_->is_perror) {
+ InternalStream() << ": " << y_absl::base_internal::StrError(errno_saver_())
+ << " [" << errno_saver_() << "]";
+ }
+
+ // Have we already seen a fatal message?
+ Y_ABSL_CONST_INIT static std::atomic<bool> seen_fatal(false);
+ if (data_->entry.log_severity() == y_absl::LogSeverity::kFatal &&
+ y_absl::log_internal::ExitOnDFatal()) {
+ // Exactly one LOG(FATAL) message is responsible for aborting the process,
+ // even if multiple threads LOG(FATAL) concurrently.
+ bool expected_seen_fatal = false;
+ if (seen_fatal.compare_exchange_strong(expected_seen_fatal, true,
+ std::memory_order_relaxed)) {
+ data_->first_fatal = true;
+ }
+ }
+
+ data_->FinalizeEncodingAndFormat();
+ data_->entry.encoding_ =
+ y_absl::string_view(data_->encoded_buf.data(),
+ static_cast<size_t>(data_->encoded_remaining().data() -
+ data_->encoded_buf.data()));
+ SendToLog();
+}
+
+void LogMessage::SetFailQuietly() { data_->fail_quietly = true; }
+
+LogMessage::OstreamView::OstreamView(LogMessageData& message_data)
+ : data_(message_data), encoded_remaining_copy_(data_.encoded_remaining()) {
+ // This constructor sets the `streambuf` up so that streaming into an attached
+ // ostream encodes string data in-place. To do that, we write appropriate
+ // headers into the buffer using a copy of the buffer view so that we can
+ // decide not to keep them later if nothing is ever streamed in. We don't
+ // know how much data we'll get, but we can use the size of the remaining
+ // buffer as an upper bound and fill in the right size once we know it.
+ message_start_ =
+ EncodeMessageStart(EventTag::kValue, encoded_remaining_copy_.size(),
+ &encoded_remaining_copy_);
+ string_start_ =
+ EncodeMessageStart(ValueTag::kString, encoded_remaining_copy_.size(),
+ &encoded_remaining_copy_);
+ setp(encoded_remaining_copy_.data(),
+ encoded_remaining_copy_.data() + encoded_remaining_copy_.size());
+ data_.manipulated.rdbuf(this);
+}
+
+LogMessage::OstreamView::~OstreamView() {
+ data_.manipulated.rdbuf(nullptr);
+ if (!string_start_.data()) {
+ // The second field header didn't fit. Whether the first one did or not, we
+ // shouldn't commit `encoded_remaining_copy_`, and we also need to zero the
+ // size of `data_->encoded_remaining()` so that no more data are encoded.
+ data_.encoded_remaining().remove_suffix(data_.encoded_remaining().size());
+ return;
+ }
+ const y_absl::Span<const char> contents(pbase(),
+ static_cast<size_t>(pptr() - pbase()));
+ if (contents.empty()) return;
+ encoded_remaining_copy_.remove_prefix(contents.size());
+ EncodeMessageLength(string_start_, &encoded_remaining_copy_);
+ EncodeMessageLength(message_start_, &encoded_remaining_copy_);
+ data_.encoded_remaining() = encoded_remaining_copy_;
+}
+
+std::ostream& LogMessage::OstreamView::stream() { return data_.manipulated; }
+
+bool LogMessage::IsFatal() const {
+ return data_->entry.log_severity() == y_absl::LogSeverity::kFatal &&
+ y_absl::log_internal::ExitOnDFatal();
+}
+
+void LogMessage::PrepareToDie() {
+ // If we log a FATAL message, flush all the log destinations, then toss
+ // a signal for others to catch. We leave the logs in a state that
+ // someone else can use them (as long as they flush afterwards)
+ if (data_->first_fatal) {
+ // Notify observers about the upcoming fatal error.
+ Y_ABSL_INTERNAL_C_SYMBOL(AbslInternalOnFatalLogMessage)(data_->entry);
+ }
+
+ if (!data_->fail_quietly) {
+ // Log the message first before we start collecting stack trace.
+ log_internal::LogToSinks(data_->entry, y_absl::MakeSpan(data_->extra_sinks),
+ data_->extra_sinks_only);
+
+ // `DumpStackTrace` generates an empty string under MSVC.
+ // Adding the constant prefix here simplifies testing.
+ data_->entry.stacktrace_ = "*** Check failure stack trace: ***\n";
+ debugging_internal::DumpStackTrace(
+ 0, log_internal::MaxFramesInLogStackTrace(),
+ log_internal::ShouldSymbolizeLogStackTrace(), WriteToString,
+ &data_->entry.stacktrace_);
+ }
+}
+
+void LogMessage::Die() {
+ y_absl::FlushLogSinks();
+
+ if (data_->fail_quietly) {
+ FailQuietly();
+ } else {
+ FailWithoutStackTrace();
+ }
+}
+
+class FatalException : public std::exception {
+ public:
+ FatalException(const char* filename, int line, const TString& message)
+ : filename_(filename), line_(line), message_(message) {}
+ virtual ~FatalException() throw() {}
+ const char* what() const throw() override { return message_.c_str(); }
+ const char* filename() const { return filename_; }
+ int line() const { return line_; }
+ const TString& message() const { return message_; }
+
+ private:
+ const char* filename_;
+ const int line_;
+ const TString message_;
+};
+
+void LogMessage::SendToLog() {
+ if (IsFatal() && !::y_absl::FatalErrorsThrowException()) PrepareToDie();
+
+ // Also log to all registered sinks, even if OnlyLogToStderr() is set.
+ log_internal::LogToSinks(data_->entry, y_absl::MakeSpan(data_->extra_sinks),
+ data_->extra_sinks_only);
+ if (IsFatal() && !::y_absl::FatalErrorsThrowException()) Die();
+}
+
+void LogMessage::LogBacktraceIfNeeded() {
+ if (!y_absl::log_internal::IsInitialized()) return;
+
+ if (!y_absl::log_internal::ShouldLogBacktraceAt(data_->entry.source_basename(),
+ data_->entry.source_line()))
+ return;
+ OstreamView view(*data_);
+ view.stream() << " (stacktrace:\n";
+#ifndef Y_ABSL_DONT_USE_DEBUG_LIBRARY
+ debugging_internal::DumpStackTrace(
+ 1, log_internal::MaxFramesInLogStackTrace(),
+ log_internal::ShouldSymbolizeLogStackTrace(), WriteToStream,
+ &view.stream());
+ view.stream() << ") ";
+#else
+ view.stream() << "abseil disable stacktrace prining) ";
+#endif
+}
+
+// Encodes into `data_->encoded_remaining()` a partial `logging.proto.Event`
+// containing the specified string data using a `Value` field appropriate to
+// `str_type`. Truncates `str` if necessary, but emits nothing and marks the
+// buffer full if even the field headers do not fit.
+template <LogMessage::StringType str_type>
+void LogMessage::CopyToEncodedBuffer(y_absl::string_view str) {
+ auto encoded_remaining_copy = data_->encoded_remaining();
+ auto start = EncodeMessageStart(
+ EventTag::kValue, BufferSizeFor(WireType::kLengthDelimited) + str.size(),
+ &encoded_remaining_copy);
+ // If the `logging.proto.Event.value` field header did not fit,
+ // `EncodeMessageStart` will have zeroed `encoded_remaining_copy`'s size and
+ // `EncodeStringTruncate` will fail too.
+ if (EncodeStringTruncate(str_type == StringType::kLiteral
+ ? ValueTag::kStringLiteral
+ : ValueTag::kString,
+ str, &encoded_remaining_copy)) {
+ // The string may have been truncated, but the field header fit.
+ EncodeMessageLength(start, &encoded_remaining_copy);
+ data_->encoded_remaining() = encoded_remaining_copy;
+ } else {
+ // The field header(s) did not fit; zero `encoded_remaining()` so we don't
+ // write anything else later.
+ data_->encoded_remaining().remove_suffix(data_->encoded_remaining().size());
+ }
+}
+template void LogMessage::CopyToEncodedBuffer<LogMessage::StringType::kLiteral>(
+ y_absl::string_view str);
+template void LogMessage::CopyToEncodedBuffer<
+ LogMessage::StringType::kNotLiteral>(y_absl::string_view str);
+template <LogMessage::StringType str_type>
+void LogMessage::CopyToEncodedBuffer(char ch, size_t num) {
+ auto encoded_remaining_copy = data_->encoded_remaining();
+ auto value_start = EncodeMessageStart(
+ EventTag::kValue, BufferSizeFor(WireType::kLengthDelimited) + num,
+ &encoded_remaining_copy);
+ auto str_start = EncodeMessageStart(str_type == StringType::kLiteral
+ ? ValueTag::kStringLiteral
+ : ValueTag::kString,
+ num, &encoded_remaining_copy);
+ if (str_start.data()) {
+ // The field headers fit.
+ log_internal::AppendTruncated(ch, num, encoded_remaining_copy);
+ EncodeMessageLength(str_start, &encoded_remaining_copy);
+ EncodeMessageLength(value_start, &encoded_remaining_copy);
+ data_->encoded_remaining() = encoded_remaining_copy;
+ } else {
+ // The field header(s) did not fit; zero `encoded_remaining()` so we don't
+ // write anything else later.
+ data_->encoded_remaining().remove_suffix(data_->encoded_remaining().size());
+ }
+}
+template void LogMessage::CopyToEncodedBuffer<LogMessage::StringType::kLiteral>(
+ char ch, size_t num);
+template void LogMessage::CopyToEncodedBuffer<
+ LogMessage::StringType::kNotLiteral>(char ch, size_t num);
+
+// We intentionally don't return from these destructors. Disable MSVC's warning
+// about the destructor never returning as we do so intentionally here.
+#if defined(_MSC_VER) && !defined(__clang__)
+#pragma warning(push)
+#pragma warning(disable : 4722)
+#endif
+
+LogMessageFatal::LogMessageFatal(const char* file, int line)
+ : LogMessage(file, line, y_absl::LogSeverity::kFatal), file_{file}, line_{line} {}
+
+LogMessageFatal& LogMessageFatal::TryThrow() {
+ if (::y_absl::FatalErrorsThrowException()) {
+ throw FatalException(file_, line_, "LogMessageFatal exception");
+ }
+ return *this;
+}
+
+LogMessageFatal::LogMessageFatal(const char* file, int line,
+ y_absl::string_view failure_msg)
+ : LogMessage(file, line, y_absl::LogSeverity::kFatal) {
+ *this << "Check failed: " << failure_msg << " ";
+}
+
+LogMessageFatal::~LogMessageFatal() {
+ Flush();
+ if (!::y_absl::FatalErrorsThrowException())
+ FailWithoutStackTrace();
+}
+
+LogMessageDebugFatal::LogMessageDebugFatal(const char* file, int line)
+ : LogMessage(file, line, y_absl::LogSeverity::kFatal) {}
+
+LogMessageDebugFatal::~LogMessageDebugFatal() {
+ Flush();
+ FailWithoutStackTrace();
+}
+
+LogMessageQuietlyDebugFatal::LogMessageQuietlyDebugFatal(const char* file,
+ int line)
+ : LogMessage(file, line, y_absl::LogSeverity::kFatal) {
+ SetFailQuietly();
+}
+
+LogMessageQuietlyDebugFatal::~LogMessageQuietlyDebugFatal() {
+ Flush();
+ FailQuietly();
+}
+
+LogMessageQuietlyFatal::LogMessageQuietlyFatal(const char* file, int line)
+ : LogMessage(file, line, y_absl::LogSeverity::kFatal) {
+ SetFailQuietly();
+}
+
+LogMessageQuietlyFatal::LogMessageQuietlyFatal(const char* file, int line,
+ y_absl::string_view failure_msg)
+ : LogMessageQuietlyFatal(file, line) {
+ *this << "Check failed: " << failure_msg << " ";
+}
+
+LogMessageQuietlyFatal::~LogMessageQuietlyFatal() {
+ Flush();
+ FailQuietly();
+}
+#if defined(_MSC_VER) && !defined(__clang__)
+#pragma warning(pop)
+#endif
+
+} // namespace log_internal
+
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_message.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_message.h
new file mode 100644
index 00000000000..85354fd8c64
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_message.h
@@ -0,0 +1,398 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: log/internal/log_message.h
+// -----------------------------------------------------------------------------
+//
+// This file declares `class y_absl::log_internal::LogMessage`. This class more or
+// less represents a particular log message. LOG/CHECK macros create a
+// temporary instance of `LogMessage` and then stream values to it. At the end
+// of the LOG/CHECK statement, LogMessage instance goes out of scope and
+// `~LogMessage` directs the message to the registered log sinks.
+// Heap-allocation of `LogMessage` is unsupported. Construction outside of a
+// `LOG` macro is unsupported.
+
+#ifndef Y_ABSL_LOG_INTERNAL_LOG_MESSAGE_H_
+#define Y_ABSL_LOG_INTERNAL_LOG_MESSAGE_H_
+
+#include <ios>
+#include <memory>
+#include <ostream>
+#include <streambuf>
+#include <util/generic/string.h>
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/base/config.h"
+#include "y_absl/base/internal/errno_saver.h"
+#include "y_absl/base/log_severity.h"
+#include "y_absl/log/internal/nullguard.h"
+#include "y_absl/log/log_entry.h"
+#include "y_absl/log/log_sink.h"
+#include "y_absl/strings/has_absl_stringify.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/time/time.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+constexpr int kLogMessageBufferSize = 15000;
+
+class LogMessage {
+ public:
+ struct InfoTag {};
+ struct WarningTag {};
+ struct ErrorTag {};
+
+ // Used for `LOG`.
+ LogMessage(const char* file, int line,
+ y_absl::LogSeverity severity) Y_ABSL_ATTRIBUTE_COLD;
+ // These constructors are slightly smaller/faster to call; the severity is
+ // curried into the function pointer.
+ LogMessage(const char* file, int line,
+ InfoTag) Y_ABSL_ATTRIBUTE_COLD Y_ABSL_ATTRIBUTE_NOINLINE;
+ LogMessage(const char* file, int line,
+ WarningTag) Y_ABSL_ATTRIBUTE_COLD Y_ABSL_ATTRIBUTE_NOINLINE;
+ LogMessage(const char* file, int line,
+ ErrorTag) Y_ABSL_ATTRIBUTE_COLD Y_ABSL_ATTRIBUTE_NOINLINE;
+ LogMessage(const LogMessage&) = delete;
+ LogMessage& operator=(const LogMessage&) = delete;
+ ~LogMessage() Y_ABSL_ATTRIBUTE_COLD;
+
+ // Overrides the location inferred from the callsite. The string pointed to
+ // by `file` must be valid until the end of the statement.
+ LogMessage& AtLocation(y_absl::string_view file, int line);
+ // Omits the prefix from this line. The prefix includes metadata about the
+ // logged data such as source code location and timestamp.
+ LogMessage& NoPrefix();
+ // Sets the verbosity field of the logged message as if it was logged by
+ // `VLOG(verbose_level)`. Unlike `VLOG`, this method does not affect
+ // evaluation of the statement when the specified `verbose_level` has been
+ // disabled. The only effect is on `y_absl::LogSink` implementations which
+ // make use of the `y_absl::LogSink::verbosity()` value. The value
+ // `y_absl::LogEntry::kNoVerbosityLevel` can be specified to mark the message
+ // not verbose.
+ LogMessage& WithVerbosity(int verbose_level);
+ // Uses the specified timestamp instead of one collected in the constructor.
+ LogMessage& WithTimestamp(y_absl::Time timestamp);
+ // Uses the specified thread ID instead of one collected in the constructor.
+ LogMessage& WithThreadID(y_absl::LogEntry::tid_t tid);
+ // Copies all metadata (but no data) from the specified `y_absl::LogEntry`.
+ LogMessage& WithMetadataFrom(const y_absl::LogEntry& entry);
+ // Appends to the logged message a colon, a space, a textual description of
+ // the current value of `errno` (as by strerror(3)), and the numerical value
+ // of `errno`.
+ LogMessage& WithPerror();
+ // Sends this message to `*sink` in addition to whatever other sinks it would
+ // otherwise have been sent to. `sink` must not be null.
+ LogMessage& ToSinkAlso(y_absl::LogSink* sink);
+ // Sends this message to `*sink` and no others. `sink` must not be null.
+ LogMessage& ToSinkOnly(y_absl::LogSink* sink);
+
+ // Don't call this method from outside this library.
+ LogMessage& InternalStream() { return *this; }
+
+ // By-value overloads for small, common types let us overlook common failures
+ // to define globals and static data members (i.e. in a .cc file).
+ // clang-format off
+ // The CUDA toolchain cannot handle these <<<'s:
+ LogMessage& operator<<(char v) { return operator<< <char>(v); }
+ LogMessage& operator<<(signed char v) { return operator<< <signed char>(v); }
+ LogMessage& operator<<(unsigned char v) {
+ return operator<< <unsigned char>(v);
+ }
+ LogMessage& operator<<(signed short v) { // NOLINT
+ return operator<< <signed short>(v); // NOLINT
+ }
+ LogMessage& operator<<(signed int v) { return operator<< <signed int>(v); }
+ LogMessage& operator<<(signed long v) { // NOLINT
+ return operator<< <signed long>(v); // NOLINT
+ }
+ LogMessage& operator<<(signed long long v) { // NOLINT
+ return operator<< <signed long long>(v); // NOLINT
+ }
+ LogMessage& operator<<(unsigned short v) { // NOLINT
+ return operator<< <unsigned short>(v); // NOLINT
+ }
+ LogMessage& operator<<(unsigned int v) {
+ return operator<< <unsigned int>(v);
+ }
+ LogMessage& operator<<(unsigned long v) { // NOLINT
+ return operator<< <unsigned long>(v); // NOLINT
+ }
+ LogMessage& operator<<(unsigned long long v) { // NOLINT
+ return operator<< <unsigned long long>(v); // NOLINT
+ }
+ LogMessage& operator<<(void* v) { return operator<< <void*>(v); }
+ LogMessage& operator<<(const void* v) { return operator<< <const void*>(v); }
+ LogMessage& operator<<(float v) { return operator<< <float>(v); }
+ LogMessage& operator<<(double v) { return operator<< <double>(v); }
+ LogMessage& operator<<(bool v) { return operator<< <bool>(v); }
+ // clang-format on
+
+ // These overloads are more efficient since no `ostream` is involved.
+ LogMessage& operator<<(const TString& v);
+ LogMessage& operator<<(y_absl::string_view v);
+
+ // Handle stream manipulators e.g. std::endl.
+ LogMessage& operator<<(std::ostream& (*m)(std::ostream& os));
+ LogMessage& operator<<(std::ios_base& (*m)(std::ios_base& os));
+
+ // Literal strings. This allows us to record C string literals as literals in
+ // the logging.proto.Value.
+ //
+ // Allow this overload to be inlined to prevent generating instantiations of
+ // this template for every value of `SIZE` encountered in each source code
+ // file. That significantly increases linker input sizes. Inlining is cheap
+ // because the argument to this overload is almost always a string literal so
+ // the call to `strlen` can be replaced at compile time. The overload for
+ // `char[]` below should not be inlined. The compiler typically does not have
+ // the string at compile time and cannot replace the call to `strlen` so
+ // inlining it increases the binary size. See the discussion on
+ // cl/107527369.
+ template <int SIZE>
+ LogMessage& operator<<(const char (&buf)[SIZE]);
+
+ // This prevents non-const `char[]` arrays from looking like literals.
+ template <int SIZE>
+ LogMessage& operator<<(char (&buf)[SIZE]) Y_ABSL_ATTRIBUTE_NOINLINE;
+
+ // Types that support `AbslStringify()` are serialized that way.
+ template <typename T,
+ typename std::enable_if<y_absl::HasAbslStringify<T>::value,
+ int>::type = 0>
+ LogMessage& operator<<(const T& v) Y_ABSL_ATTRIBUTE_NOINLINE;
+
+ // Types that don't support `AbslStringify()` but do support streaming into a
+ // `std::ostream&` are serialized that way.
+ template <typename T,
+ typename std::enable_if<!y_absl::HasAbslStringify<T>::value,
+ int>::type = 0>
+ LogMessage& operator<<(const T& v) Y_ABSL_ATTRIBUTE_NOINLINE;
+
+ // Note: We explicitly do not support `operator<<` for non-const references
+ // because it breaks logging of non-integer bitfield types (i.e., enums).
+
+ protected:
+ // Call `abort()` or similar to perform `LOG(FATAL)` crash. It is assumed
+ // that the caller has already generated and written the trace as appropriate.
+ [[noreturn]] static void FailWithoutStackTrace();
+
+ // Similar to `FailWithoutStackTrace()`, but without `abort()`. Terminates
+ // the process with an error exit code.
+ [[noreturn]] static void FailQuietly();
+
+ // Dispatches the completed `y_absl::LogEntry` to applicable `y_absl::LogSink`s.
+ // This might as well be inlined into `~LogMessage` except that
+ // `~LogMessageFatal` needs to call it early.
+ void Flush();
+
+ // After this is called, failures are done as quiet as possible for this log
+ // message.
+ void SetFailQuietly();
+
+ private:
+ struct LogMessageData; // Opaque type containing message state
+ friend class AsLiteralImpl;
+ friend class StringifySink;
+
+ // This streambuf writes directly into the structured logging buffer so that
+ // arbitrary types can be encoded as string data (using
+ // `operator<<(std::ostream &, ...)` without any extra allocation or copying.
+ // Space is reserved before the data to store the length field, which is
+ // filled in by `~OstreamView`.
+ class OstreamView final : public std::streambuf {
+ public:
+ explicit OstreamView(LogMessageData& message_data);
+ ~OstreamView() override;
+ OstreamView(const OstreamView&) = delete;
+ OstreamView& operator=(const OstreamView&) = delete;
+ std::ostream& stream();
+
+ private:
+ LogMessageData& data_;
+ y_absl::Span<char> encoded_remaining_copy_;
+ y_absl::Span<char> message_start_;
+ y_absl::Span<char> string_start_;
+ };
+
+ enum class StringType {
+ kLiteral,
+ kNotLiteral,
+ };
+ template <StringType str_type>
+ void CopyToEncodedBuffer(y_absl::string_view str) Y_ABSL_ATTRIBUTE_NOINLINE;
+ template <StringType str_type>
+ void CopyToEncodedBuffer(char ch, size_t num) Y_ABSL_ATTRIBUTE_NOINLINE;
+
+ // Returns `true` if the message is fatal or enabled debug-fatal.
+ bool IsFatal() const;
+
+ // Records some tombstone-type data in anticipation of `Die`.
+ void PrepareToDie();
+ void Die();
+
+ void SendToLog();
+
+ // Checks `FLAGS_log_backtrace_at` and appends a backtrace if appropriate.
+ void LogBacktraceIfNeeded();
+
+ // This should be the first data member so that its initializer captures errno
+ // before any other initializers alter it (e.g. with calls to new) and so that
+ // no other destructors run afterward an alter it (e.g. with calls to delete).
+ y_absl::base_internal::ErrnoSaver errno_saver_;
+
+ // We keep the data in a separate struct so that each instance of `LogMessage`
+ // uses less stack space.
+ std::unique_ptr<LogMessageData> data_;
+};
+
+// Helper class so that `AbslStringify()` can modify the LogMessage.
+class StringifySink final {
+ public:
+ explicit StringifySink(LogMessage& message) : message_(message) {}
+
+ void Append(size_t count, char ch) {
+ message_.CopyToEncodedBuffer<LogMessage::StringType::kNotLiteral>(ch,
+ count);
+ }
+
+ void Append(y_absl::string_view v) {
+ message_.CopyToEncodedBuffer<LogMessage::StringType::kNotLiteral>(v);
+ }
+
+ // For types that implement `AbslStringify` using `y_absl::Format()`.
+ friend void AbslFormatFlush(StringifySink* sink, y_absl::string_view v) {
+ sink->Append(v);
+ }
+
+ private:
+ LogMessage& message_;
+};
+
+// Note: the following is declared `Y_ABSL_ATTRIBUTE_NOINLINE`
+template <typename T,
+ typename std::enable_if<y_absl::HasAbslStringify<T>::value, int>::type>
+LogMessage& LogMessage::operator<<(const T& v) {
+ StringifySink sink(*this);
+ // Replace with public API.
+ AbslStringify(sink, v);
+ return *this;
+}
+
+// Note: the following is declared `Y_ABSL_ATTRIBUTE_NOINLINE`
+template <typename T,
+ typename std::enable_if<!y_absl::HasAbslStringify<T>::value, int>::type>
+LogMessage& LogMessage::operator<<(const T& v) {
+ OstreamView view(*data_);
+ view.stream() << log_internal::NullGuard<T>().Guard(v);
+ return *this;
+}
+
+template <int SIZE>
+LogMessage& LogMessage::operator<<(const char (&buf)[SIZE]) {
+ CopyToEncodedBuffer<StringType::kLiteral>(buf);
+ return *this;
+}
+
+// Note: the following is declared `Y_ABSL_ATTRIBUTE_NOINLINE`
+template <int SIZE>
+LogMessage& LogMessage::operator<<(char (&buf)[SIZE]) {
+ CopyToEncodedBuffer<StringType::kNotLiteral>(buf);
+ return *this;
+}
+// We instantiate these specializations in the library's TU to save space in
+// other TUs. Since the template is marked `Y_ABSL_ATTRIBUTE_NOINLINE` we will be
+// emitting a function call either way.
+extern template LogMessage& LogMessage::operator<<(const char& v);
+extern template LogMessage& LogMessage::operator<<(const signed char& v);
+extern template LogMessage& LogMessage::operator<<(const unsigned char& v);
+extern template LogMessage& LogMessage::operator<<(const short& v); // NOLINT
+extern template LogMessage& LogMessage::operator<<(
+ const unsigned short& v); // NOLINT
+extern template LogMessage& LogMessage::operator<<(const int& v);
+extern template LogMessage& LogMessage::operator<<(
+ const unsigned int& v); // NOLINT
+extern template LogMessage& LogMessage::operator<<(const long& v); // NOLINT
+extern template LogMessage& LogMessage::operator<<(
+ const unsigned long& v); // NOLINT
+extern template LogMessage& LogMessage::operator<<(
+ const long long& v); // NOLINT
+extern template LogMessage& LogMessage::operator<<(
+ const unsigned long long& v); // NOLINT
+extern template LogMessage& LogMessage::operator<<(void* const& v);
+extern template LogMessage& LogMessage::operator<<(const void* const& v);
+extern template LogMessage& LogMessage::operator<<(const float& v);
+extern template LogMessage& LogMessage::operator<<(const double& v);
+extern template LogMessage& LogMessage::operator<<(const bool& v);
+
+extern template void LogMessage::CopyToEncodedBuffer<
+ LogMessage::StringType::kLiteral>(y_absl::string_view str);
+extern template void LogMessage::CopyToEncodedBuffer<
+ LogMessage::StringType::kNotLiteral>(y_absl::string_view str);
+extern template void
+LogMessage::CopyToEncodedBuffer<LogMessage::StringType::kLiteral>(char ch,
+ size_t num);
+extern template void LogMessage::CopyToEncodedBuffer<
+ LogMessage::StringType::kNotLiteral>(char ch, size_t num);
+
+// `LogMessageFatal` ensures the process will exit in failure after logging this
+// message.
+class LogMessageFatal final : public LogMessage {
+ public:
+ LogMessageFatal(const char* file, int line) Y_ABSL_ATTRIBUTE_COLD;
+ LogMessageFatal(const char* file, int line,
+ y_absl::string_view failure_msg) Y_ABSL_ATTRIBUTE_COLD;
+ LogMessageFatal& TryThrow() Y_ABSL_ATTRIBUTE_COLD;
+ ~LogMessageFatal();
+ private:
+ const char* file_ {nullptr};
+ int line_ = 0;
+};
+
+// `LogMessageDebugFatal` ensures the process will exit in failure after logging
+// this message. It matches LogMessageFatal but is not [[noreturn]] as it's used
+// for DLOG(FATAL) variants.
+class LogMessageDebugFatal final : public LogMessage {
+ public:
+ LogMessageDebugFatal(const char* file, int line) Y_ABSL_ATTRIBUTE_COLD;
+ ~LogMessageDebugFatal();
+};
+
+class LogMessageQuietlyDebugFatal final : public LogMessage {
+ public:
+ // DLOG(QFATAL) calls this instead of LogMessageQuietlyFatal to make sure the
+ // destructor is not [[noreturn]] even if this is always FATAL as this is only
+ // invoked when DLOG() is enabled.
+ LogMessageQuietlyDebugFatal(const char* file, int line) Y_ABSL_ATTRIBUTE_COLD;
+ ~LogMessageQuietlyDebugFatal();
+};
+
+// Used for LOG(QFATAL) to make sure it's properly understood as [[noreturn]].
+class LogMessageQuietlyFatal final : public LogMessage {
+ public:
+ LogMessageQuietlyFatal(const char* file, int line) Y_ABSL_ATTRIBUTE_COLD;
+ LogMessageQuietlyFatal(const char* file, int line,
+ y_absl::string_view failure_msg) Y_ABSL_ATTRIBUTE_COLD;
+ [[noreturn]] ~LogMessageQuietlyFatal();
+};
+
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+extern "C" Y_ABSL_ATTRIBUTE_WEAK void Y_ABSL_INTERNAL_C_SYMBOL(
+ AbslInternalOnFatalLogMessage)(const y_absl::LogEntry&);
+
+#endif // Y_ABSL_LOG_INTERNAL_LOG_MESSAGE_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_sink_set.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_sink_set.cc
new file mode 100644
index 00000000000..da058daba1e
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_sink_set.cc
@@ -0,0 +1,296 @@
+//
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "y_absl/log/internal/log_sink_set.h"
+
+#ifndef Y_ABSL_HAVE_THREAD_LOCAL
+#include <pthread.h>
+#endif
+
+#ifdef __ANDROID__
+#include <android/log.h>
+#endif
+
+#ifdef _WIN32
+#include <windows.h>
+#endif
+
+#include <algorithm>
+#include <vector>
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/base/call_once.h"
+#include "y_absl/base/config.h"
+#include "y_absl/base/internal/raw_logging.h"
+#include "y_absl/base/log_severity.h"
+#include "y_absl/base/no_destructor.h"
+#include "y_absl/base/thread_annotations.h"
+#include "y_absl/cleanup/cleanup.h"
+#include "y_absl/log/globals.h"
+#include "y_absl/log/internal/config.h"
+#include "y_absl/log/internal/globals.h"
+#include "y_absl/log/log_entry.h"
+#include "y_absl/log/log_sink.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/synchronization/mutex.h"
+#include "y_absl/types/span.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+namespace {
+
+// Returns a mutable reference to a thread-local variable that should be true if
+// a globally-registered `LogSink`'s `Send()` is currently being invoked on this
+// thread.
+bool& ThreadIsLoggingStatus() {
+#ifdef Y_ABSL_HAVE_THREAD_LOCAL
+ Y_ABSL_CONST_INIT thread_local bool thread_is_logging = false;
+ return thread_is_logging;
+#else
+ Y_ABSL_CONST_INIT static pthread_key_t thread_is_logging_key;
+ static const bool unused = [] {
+ if (pthread_key_create(&thread_is_logging_key, [](void* data) {
+ delete reinterpret_cast<bool*>(data);
+ })) {
+ perror("pthread_key_create failed!");
+ abort();
+ }
+ return true;
+ }();
+ (void)unused; // Fixes -wunused-variable warning
+ bool* thread_is_logging_ptr =
+ reinterpret_cast<bool*>(pthread_getspecific(thread_is_logging_key));
+
+ if (Y_ABSL_PREDICT_FALSE(!thread_is_logging_ptr)) {
+ thread_is_logging_ptr = new bool{false};
+ if (pthread_setspecific(thread_is_logging_key, thread_is_logging_ptr)) {
+ perror("pthread_setspecific failed");
+ abort();
+ }
+ }
+ return *thread_is_logging_ptr;
+#endif
+}
+
+class StderrLogSink final : public LogSink {
+ public:
+ ~StderrLogSink() override = default;
+
+ void Send(const y_absl::LogEntry& entry) override {
+ if (entry.log_severity() < y_absl::StderrThreshold() &&
+ y_absl::log_internal::IsInitialized()) {
+ return;
+ }
+
+ Y_ABSL_CONST_INIT static y_absl::once_flag warn_if_not_initialized;
+ y_absl::call_once(warn_if_not_initialized, []() {
+ if (y_absl::log_internal::IsInitialized()) return;
+ const char w[] =
+ "WARNING: All log messages before y_absl::InitializeLog() is called"
+ " are written to STDERR\n";
+ y_absl::log_internal::WriteToStderr(w, y_absl::LogSeverity::kWarning);
+ });
+
+ if (!entry.stacktrace().empty()) {
+ y_absl::log_internal::WriteToStderr(entry.stacktrace(),
+ entry.log_severity());
+ } else {
+ // TODO(b/226937039): do this outside else condition once we avoid
+ // ReprintFatalMessage
+ y_absl::log_internal::WriteToStderr(
+ entry.text_message_with_prefix_and_newline(), entry.log_severity());
+ }
+ }
+};
+
+#if defined(__ANDROID__)
+class AndroidLogSink final : public LogSink {
+ public:
+ ~AndroidLogSink() override = default;
+
+ void Send(const y_absl::LogEntry& entry) override {
+ const int level = AndroidLogLevel(entry);
+ const char* const tag = GetAndroidNativeTag();
+ __android_log_write(level, tag,
+ entry.text_message_with_prefix_and_newline_c_str());
+ if (entry.log_severity() == y_absl::LogSeverity::kFatal)
+ __android_log_write(ANDROID_LOG_FATAL, tag, "terminating.\n");
+ }
+
+ private:
+ static int AndroidLogLevel(const y_absl::LogEntry& entry) {
+ switch (entry.log_severity()) {
+ case y_absl::LogSeverity::kFatal:
+ return ANDROID_LOG_FATAL;
+ case y_absl::LogSeverity::kError:
+ return ANDROID_LOG_ERROR;
+ case y_absl::LogSeverity::kWarning:
+ return ANDROID_LOG_WARN;
+ default:
+ if (entry.verbosity() >= 2) return ANDROID_LOG_VERBOSE;
+ if (entry.verbosity() == 1) return ANDROID_LOG_DEBUG;
+ return ANDROID_LOG_INFO;
+ }
+ }
+};
+#endif // !defined(__ANDROID__)
+
+#if defined(_WIN32)
+class WindowsDebuggerLogSink final : public LogSink {
+ public:
+ ~WindowsDebuggerLogSink() override = default;
+
+ void Send(const y_absl::LogEntry& entry) override {
+ if (entry.log_severity() < y_absl::StderrThreshold() &&
+ y_absl::log_internal::IsInitialized()) {
+ return;
+ }
+ ::OutputDebugStringA(entry.text_message_with_prefix_and_newline_c_str());
+ }
+};
+#endif // !defined(_WIN32)
+
+class GlobalLogSinkSet final {
+ public:
+ GlobalLogSinkSet() {
+#if defined(__myriad2__) || defined(__Fuchsia__)
+ // myriad2 and Fuchsia do not log to stderr by default.
+#else
+ static y_absl::NoDestructor<StderrLogSink> stderr_log_sink;
+ AddLogSink(stderr_log_sink.get());
+#endif
+#ifdef __ANDROID__
+ static y_absl::NoDestructor<AndroidLogSink> android_log_sink;
+ AddLogSink(android_log_sink.get());
+#endif
+#if defined(_WIN32)
+ static y_absl::NoDestructor<WindowsDebuggerLogSink> debugger_log_sink;
+ AddLogSink(debugger_log_sink.get());
+#endif // !defined(_WIN32)
+ }
+
+ void LogToSinks(const y_absl::LogEntry& entry,
+ y_absl::Span<y_absl::LogSink*> extra_sinks, bool extra_sinks_only)
+ Y_ABSL_LOCKS_EXCLUDED(guard_) {
+ SendToSinks(entry, extra_sinks);
+
+ if (!extra_sinks_only) {
+ if (ThreadIsLoggingToLogSink()) {
+ y_absl::log_internal::WriteToStderr(
+ entry.text_message_with_prefix_and_newline(), entry.log_severity());
+ } else {
+ y_absl::ReaderMutexLock global_sinks_lock(&guard_);
+ ThreadIsLoggingStatus() = true;
+ // Ensure the "thread is logging" status is reverted upon leaving the
+ // scope even in case of exceptions.
+ auto status_cleanup =
+ y_absl::MakeCleanup([] { ThreadIsLoggingStatus() = false; });
+ SendToSinks(entry, y_absl::MakeSpan(sinks_));
+ }
+ }
+ }
+
+ void AddLogSink(y_absl::LogSink* sink) Y_ABSL_LOCKS_EXCLUDED(guard_) {
+ {
+ y_absl::WriterMutexLock global_sinks_lock(&guard_);
+ auto pos = std::find(sinks_.begin(), sinks_.end(), sink);
+ if (pos == sinks_.end()) {
+ sinks_.push_back(sink);
+ return;
+ }
+ }
+ Y_ABSL_INTERNAL_LOG(FATAL, "Duplicate log sinks are not supported");
+ }
+
+ void RemoveLogSink(y_absl::LogSink* sink) Y_ABSL_LOCKS_EXCLUDED(guard_) {
+ {
+ y_absl::WriterMutexLock global_sinks_lock(&guard_);
+ auto pos = std::find(sinks_.begin(), sinks_.end(), sink);
+ if (pos != sinks_.end()) {
+ sinks_.erase(pos);
+ return;
+ }
+ }
+ Y_ABSL_INTERNAL_LOG(FATAL, "Mismatched log sink being removed");
+ }
+
+ void FlushLogSinks() Y_ABSL_LOCKS_EXCLUDED(guard_) {
+ if (ThreadIsLoggingToLogSink()) {
+ // The thread_local condition demonstrates that we're already holding the
+ // lock in order to iterate over `sinks_` for dispatch. The thread-safety
+ // annotations don't know this, so we use `Y_ABSL_NO_THREAD_SAFETY_ANALYSIS`
+ guard_.AssertReaderHeld();
+ FlushLogSinksLocked();
+ } else {
+ y_absl::ReaderMutexLock global_sinks_lock(&guard_);
+ // In case if LogSink::Flush overload decides to log
+ ThreadIsLoggingStatus() = true;
+ // Ensure the "thread is logging" status is reverted upon leaving the
+ // scope even in case of exceptions.
+ auto status_cleanup =
+ y_absl::MakeCleanup([] { ThreadIsLoggingStatus() = false; });
+ FlushLogSinksLocked();
+ }
+ }
+
+ private:
+ void FlushLogSinksLocked() Y_ABSL_SHARED_LOCKS_REQUIRED(guard_) {
+ for (y_absl::LogSink* sink : sinks_) {
+ sink->Flush();
+ }
+ }
+
+ // Helper routine for LogToSinks.
+ static void SendToSinks(const y_absl::LogEntry& entry,
+ y_absl::Span<y_absl::LogSink*> sinks) {
+ for (y_absl::LogSink* sink : sinks) {
+ sink->Send(entry);
+ }
+ }
+
+ using LogSinksSet = std::vector<y_absl::LogSink*>;
+ y_absl::Mutex guard_;
+ LogSinksSet sinks_ Y_ABSL_GUARDED_BY(guard_);
+};
+
+// Returns reference to the global LogSinks set.
+GlobalLogSinkSet& GlobalSinks() {
+ static y_absl::NoDestructor<GlobalLogSinkSet> global_sinks;
+ return *global_sinks;
+}
+
+} // namespace
+
+bool ThreadIsLoggingToLogSink() { return ThreadIsLoggingStatus(); }
+
+void LogToSinks(const y_absl::LogEntry& entry,
+ y_absl::Span<y_absl::LogSink*> extra_sinks, bool extra_sinks_only) {
+ log_internal::GlobalSinks().LogToSinks(entry, extra_sinks, extra_sinks_only);
+}
+
+void AddLogSink(y_absl::LogSink* sink) {
+ log_internal::GlobalSinks().AddLogSink(sink);
+}
+
+void RemoveLogSink(y_absl::LogSink* sink) {
+ log_internal::GlobalSinks().RemoveLogSink(sink);
+}
+
+void FlushLogSinks() { log_internal::GlobalSinks().FlushLogSinks(); }
+
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_sink_set.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_sink_set.h
new file mode 100644
index 00000000000..1b0fa0bfa4e
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/log_sink_set.h
@@ -0,0 +1,54 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: log/internal/log_sink_set.h
+// -----------------------------------------------------------------------------
+
+#ifndef Y_ABSL_LOG_INTERNAL_LOG_SINK_SET_H_
+#define Y_ABSL_LOG_INTERNAL_LOG_SINK_SET_H_
+
+#include "y_absl/base/config.h"
+#include "y_absl/log/log_entry.h"
+#include "y_absl/log/log_sink.h"
+#include "y_absl/types/span.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+
+// Returns true if a globally-registered `LogSink`'s `Send()` is currently
+// being invoked on this thread.
+bool ThreadIsLoggingToLogSink();
+
+// This function may log to two sets of sinks:
+//
+// * If `extra_sinks_only` is true, it will dispatch only to `extra_sinks`.
+// `LogMessage::ToSinkAlso` and `LogMessage::ToSinkOnly` are used to attach
+// extra sinks to the entry.
+// * Otherwise it will also log to the global sinks set. This set is managed
+// by `y_absl::AddLogSink` and `y_absl::RemoveLogSink`.
+void LogToSinks(const y_absl::LogEntry& entry,
+ y_absl::Span<y_absl::LogSink*> extra_sinks, bool extra_sinks_only);
+
+// Implementation for operations with log sink set.
+void AddLogSink(y_absl::LogSink* sink);
+void RemoveLogSink(y_absl::LogSink* sink);
+void FlushLogSinks();
+
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_LOG_INTERNAL_LOG_SINK_SET_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/nullguard.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/nullguard.cc
new file mode 100644
index 00000000000..d07801841b6
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/nullguard.cc
@@ -0,0 +1,35 @@
+// Copyright 2023 The Abseil Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "y_absl/log/internal/nullguard.h"
+
+#include <array>
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/base/config.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+
+Y_ABSL_CONST_INIT Y_ABSL_DLL const std::array<char, 7> kCharNull{
+ {'(', 'n', 'u', 'l', 'l', ')', '\0'}};
+Y_ABSL_CONST_INIT Y_ABSL_DLL const std::array<signed char, 7> kSignedCharNull{
+ {'(', 'n', 'u', 'l', 'l', ')', '\0'}};
+Y_ABSL_CONST_INIT Y_ABSL_DLL const std::array<unsigned char, 7> kUnsignedCharNull{
+ {'(', 'n', 'u', 'l', 'l', ')', '\0'}};
+
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/nullguard.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/nullguard.h
new file mode 100644
index 00000000000..5497372700b
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/nullguard.h
@@ -0,0 +1,88 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: log/internal/nullguard.h
+// -----------------------------------------------------------------------------
+//
+// NullGuard exists such that NullGuard<T>::Guard(v) returns v, unless passed a
+// nullptr_t, or a null char* or const char*, in which case it returns "(null)".
+// This allows streaming NullGuard<T>::Guard(v) to an output stream without
+// hitting undefined behavior for null values.
+
+#ifndef Y_ABSL_LOG_INTERNAL_NULLGUARD_H_
+#define Y_ABSL_LOG_INTERNAL_NULLGUARD_H_
+
+#include <array>
+#include <cstddef>
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/base/config.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+
+Y_ABSL_CONST_INIT Y_ABSL_DLL extern const std::array<char, 7> kCharNull;
+Y_ABSL_CONST_INIT Y_ABSL_DLL extern const std::array<signed char, 7>
+ kSignedCharNull;
+Y_ABSL_CONST_INIT Y_ABSL_DLL extern const std::array<unsigned char, 7>
+ kUnsignedCharNull;
+
+template <typename T>
+struct NullGuard final {
+ static const T& Guard(const T& v) { return v; }
+};
+template <>
+struct NullGuard<char*> final {
+ static const char* Guard(const char* v) { return v ? v : kCharNull.data(); }
+};
+template <>
+struct NullGuard<const char*> final {
+ static const char* Guard(const char* v) { return v ? v : kCharNull.data(); }
+};
+template <>
+struct NullGuard<signed char*> final {
+ static const signed char* Guard(const signed char* v) {
+ return v ? v : kSignedCharNull.data();
+ }
+};
+template <>
+struct NullGuard<const signed char*> final {
+ static const signed char* Guard(const signed char* v) {
+ return v ? v : kSignedCharNull.data();
+ }
+};
+template <>
+struct NullGuard<unsigned char*> final {
+ static const unsigned char* Guard(const unsigned char* v) {
+ return v ? v : kUnsignedCharNull.data();
+ }
+};
+template <>
+struct NullGuard<const unsigned char*> final {
+ static const unsigned char* Guard(const unsigned char* v) {
+ return v ? v : kUnsignedCharNull.data();
+ }
+};
+template <>
+struct NullGuard<std::nullptr_t> final {
+ static const char* Guard(const std::nullptr_t&) { return kCharNull.data(); }
+};
+
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_LOG_INTERNAL_NULLGUARD_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/nullstream.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/nullstream.h
new file mode 100644
index 00000000000..13886eae7f8
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/nullstream.h
@@ -0,0 +1,127 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: log/internal/nullstream.h
+// -----------------------------------------------------------------------------
+//
+// Classes `NullStream`, `NullStreamMaybeFatal ` and `NullStreamFatal`
+// implement a subset of the `LogMessage` API and are used instead when logging
+// of messages has been disabled.
+
+#ifndef Y_ABSL_LOG_INTERNAL_NULLSTREAM_H_
+#define Y_ABSL_LOG_INTERNAL_NULLSTREAM_H_
+
+#ifdef _WIN32
+#include <cstdlib>
+#else
+#include <unistd.h>
+#endif
+#include <ios>
+#include <ostream>
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/base/config.h"
+#include "y_absl/base/log_severity.h"
+#include "y_absl/strings/string_view.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+
+// A `NullStream` implements the API of `LogMessage` (a few methods and
+// `operator<<`) but does nothing. All methods are defined inline so the
+// compiler can eliminate the whole instance and discard anything that's
+// streamed in.
+class NullStream {
+ public:
+ NullStream& AtLocation(y_absl::string_view, int) { return *this; }
+ template <typename SourceLocationType>
+ NullStream& AtLocation(SourceLocationType) {
+ return *this;
+ }
+ NullStream& NoPrefix() { return *this; }
+ NullStream& WithVerbosity(int) { return *this; }
+ template <typename TimeType>
+ NullStream& WithTimestamp(TimeType) {
+ return *this;
+ }
+ template <typename Tid>
+ NullStream& WithThreadID(Tid) {
+ return *this;
+ }
+ template <typename LogEntryType>
+ NullStream& WithMetadataFrom(const LogEntryType&) {
+ return *this;
+ }
+ NullStream& WithPerror() { return *this; }
+ template <typename LogSinkType>
+ NullStream& ToSinkAlso(LogSinkType*) {
+ return *this;
+ }
+ template <typename LogSinkType>
+ NullStream& ToSinkOnly(LogSinkType*) {
+ return *this;
+ }
+ template <typename LogSinkType>
+ NullStream& OutputToSink(LogSinkType*, bool) {
+ return *this;
+ }
+ NullStream& InternalStream() { return *this; }
+};
+template <typename T>
+inline NullStream& operator<<(NullStream& str, const T&) {
+ return str;
+}
+inline NullStream& operator<<(NullStream& str,
+ std::ostream& (*)(std::ostream& os)) {
+ return str;
+}
+inline NullStream& operator<<(NullStream& str,
+ std::ios_base& (*)(std::ios_base& os)) {
+ return str;
+}
+
+// `NullStreamMaybeFatal` implements the process termination semantics of
+// `LogMessage`, which is used for `DFATAL` severity and expression-defined
+// severity e.g. `LOG(LEVEL(HowBadIsIt()))`. Like `LogMessage`, it terminates
+// the process when destroyed if the passed-in severity equals `FATAL`.
+class NullStreamMaybeFatal final : public NullStream {
+ public:
+ explicit NullStreamMaybeFatal(y_absl::LogSeverity severity)
+ : fatal_(severity == y_absl::LogSeverity::kFatal) {}
+ ~NullStreamMaybeFatal() {
+ if (fatal_) {
+ _exit(1);
+ }
+ }
+
+ private:
+ bool fatal_;
+};
+
+// `NullStreamFatal` implements the process termination semantics of
+// `LogMessageFatal`, which means it always terminates the process. `DFATAL`
+// and expression-defined severity use `NullStreamMaybeFatal` above.
+class NullStreamFatal final : public NullStream {
+ public:
+ NullStreamFatal() = default;
+ [[noreturn]] ~NullStreamFatal() { _exit(1); }
+};
+
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_LOG_INTERNAL_GLOBALS_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/proto.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/proto.cc
new file mode 100644
index 00000000000..52803c217ee
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/proto.cc
@@ -0,0 +1,220 @@
+// Copyright 2020 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "y_absl/log/internal/proto.h"
+
+#include <algorithm>
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
+#include <cstring>
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/base/config.h"
+#include "y_absl/types/span.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+namespace {
+void EncodeRawVarint(uint64_t value, size_t size, y_absl::Span<char> *buf) {
+ for (size_t s = 0; s < size; s++) {
+ (*buf)[s] = static_cast<char>((value & 0x7f) | (s + 1 == size ? 0 : 0x80));
+ value >>= 7;
+ }
+ buf->remove_prefix(size);
+}
+constexpr uint64_t MakeTagType(uint64_t tag, WireType type) {
+ return tag << 3 | static_cast<uint64_t>(type);
+}
+} // namespace
+
+bool EncodeVarint(uint64_t tag, uint64_t value, y_absl::Span<char> *buf) {
+ const uint64_t tag_type = MakeTagType(tag, WireType::kVarint);
+ const size_t tag_type_size = VarintSize(tag_type);
+ const size_t value_size = VarintSize(value);
+ if (tag_type_size + value_size > buf->size()) {
+ buf->remove_suffix(buf->size());
+ return false;
+ }
+ EncodeRawVarint(tag_type, tag_type_size, buf);
+ EncodeRawVarint(value, value_size, buf);
+ return true;
+}
+
+bool Encode64Bit(uint64_t tag, uint64_t value, y_absl::Span<char> *buf) {
+ const uint64_t tag_type = MakeTagType(tag, WireType::k64Bit);
+ const size_t tag_type_size = VarintSize(tag_type);
+ if (tag_type_size + sizeof(value) > buf->size()) {
+ buf->remove_suffix(buf->size());
+ return false;
+ }
+ EncodeRawVarint(tag_type, tag_type_size, buf);
+ for (size_t s = 0; s < sizeof(value); s++) {
+ (*buf)[s] = static_cast<char>(value & 0xff);
+ value >>= 8;
+ }
+ buf->remove_prefix(sizeof(value));
+ return true;
+}
+
+bool Encode32Bit(uint64_t tag, uint32_t value, y_absl::Span<char> *buf) {
+ const uint64_t tag_type = MakeTagType(tag, WireType::k32Bit);
+ const size_t tag_type_size = VarintSize(tag_type);
+ if (tag_type_size + sizeof(value) > buf->size()) {
+ buf->remove_suffix(buf->size());
+ return false;
+ }
+ EncodeRawVarint(tag_type, tag_type_size, buf);
+ for (size_t s = 0; s < sizeof(value); s++) {
+ (*buf)[s] = static_cast<char>(value & 0xff);
+ value >>= 8;
+ }
+ buf->remove_prefix(sizeof(value));
+ return true;
+}
+
+bool EncodeBytes(uint64_t tag, y_absl::Span<const char> value,
+ y_absl::Span<char> *buf) {
+ const uint64_t tag_type = MakeTagType(tag, WireType::kLengthDelimited);
+ const size_t tag_type_size = VarintSize(tag_type);
+ uint64_t length = value.size();
+ const size_t length_size = VarintSize(length);
+ if (tag_type_size + length_size + value.size() > buf->size()) {
+ buf->remove_suffix(buf->size());
+ return false;
+ }
+ EncodeRawVarint(tag_type, tag_type_size, buf);
+ EncodeRawVarint(length, length_size, buf);
+ memcpy(buf->data(), value.data(), value.size());
+ buf->remove_prefix(value.size());
+ return true;
+}
+
+bool EncodeBytesTruncate(uint64_t tag, y_absl::Span<const char> value,
+ y_absl::Span<char> *buf) {
+ const uint64_t tag_type = MakeTagType(tag, WireType::kLengthDelimited);
+ const size_t tag_type_size = VarintSize(tag_type);
+ uint64_t length = value.size();
+ const size_t length_size =
+ VarintSize(std::min<uint64_t>(length, buf->size()));
+ if (tag_type_size + length_size <= buf->size() &&
+ tag_type_size + length_size + value.size() > buf->size()) {
+ value.remove_suffix(tag_type_size + length_size + value.size() -
+ buf->size());
+ length = value.size();
+ }
+ if (tag_type_size + length_size + value.size() > buf->size()) {
+ buf->remove_suffix(buf->size());
+ return false;
+ }
+ EncodeRawVarint(tag_type, tag_type_size, buf);
+ EncodeRawVarint(length, length_size, buf);
+ memcpy(buf->data(), value.data(), value.size());
+ buf->remove_prefix(value.size());
+ return true;
+}
+
+Y_ABSL_MUST_USE_RESULT y_absl::Span<char> EncodeMessageStart(
+ uint64_t tag, uint64_t max_size, y_absl::Span<char> *buf) {
+ const uint64_t tag_type = MakeTagType(tag, WireType::kLengthDelimited);
+ const size_t tag_type_size = VarintSize(tag_type);
+ max_size = std::min<uint64_t>(max_size, buf->size());
+ const size_t length_size = VarintSize(max_size);
+ if (tag_type_size + length_size > buf->size()) {
+ buf->remove_suffix(buf->size());
+ return y_absl::Span<char>();
+ }
+ EncodeRawVarint(tag_type, tag_type_size, buf);
+ const y_absl::Span<char> ret = buf->subspan(0, length_size);
+ EncodeRawVarint(0, length_size, buf);
+ return ret;
+}
+
+void EncodeMessageLength(y_absl::Span<char> msg, const y_absl::Span<char> *buf) {
+ if (!msg.data()) return;
+ assert(buf->data() >= msg.data());
+ if (buf->data() < msg.data()) return;
+ EncodeRawVarint(
+ static_cast<uint64_t>(buf->data() - (msg.data() + msg.size())),
+ msg.size(), &msg);
+}
+
+namespace {
+uint64_t DecodeVarint(y_absl::Span<const char> *buf) {
+ uint64_t value = 0;
+ size_t s = 0;
+ while (s < buf->size()) {
+ value |= static_cast<uint64_t>(static_cast<unsigned char>((*buf)[s]) & 0x7f)
+ << 7 * s;
+ if (!((*buf)[s++] & 0x80)) break;
+ }
+ buf->remove_prefix(s);
+ return value;
+}
+
+uint64_t Decode64Bit(y_absl::Span<const char> *buf) {
+ uint64_t value = 0;
+ size_t s = 0;
+ while (s < buf->size()) {
+ value |= static_cast<uint64_t>(static_cast<unsigned char>((*buf)[s]))
+ << 8 * s;
+ if (++s == sizeof(value)) break;
+ }
+ buf->remove_prefix(s);
+ return value;
+}
+
+uint32_t Decode32Bit(y_absl::Span<const char> *buf) {
+ uint32_t value = 0;
+ size_t s = 0;
+ while (s < buf->size()) {
+ value |= static_cast<uint32_t>(static_cast<unsigned char>((*buf)[s]))
+ << 8 * s;
+ if (++s == sizeof(value)) break;
+ }
+ buf->remove_prefix(s);
+ return value;
+}
+} // namespace
+
+bool ProtoField::DecodeFrom(y_absl::Span<const char> *data) {
+ if (data->empty()) return false;
+ const uint64_t tag_type = DecodeVarint(data);
+ tag_ = tag_type >> 3;
+ type_ = static_cast<WireType>(tag_type & 0x07);
+ switch (type_) {
+ case WireType::kVarint:
+ value_ = DecodeVarint(data);
+ break;
+ case WireType::k64Bit:
+ value_ = Decode64Bit(data);
+ break;
+ case WireType::kLengthDelimited: {
+ value_ = DecodeVarint(data);
+ data_ = data->subspan(
+ 0, static_cast<size_t>(std::min<uint64_t>(value_, data->size())));
+ data->remove_prefix(data_.size());
+ break;
+ }
+ case WireType::k32Bit:
+ value_ = Decode32Bit(data);
+ break;
+ }
+ return true;
+}
+
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/proto.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/proto.h
new file mode 100644
index 00000000000..145e05ac92d
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/proto.h
@@ -0,0 +1,288 @@
+// Copyright 2020 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// -----------------------------------------------------------------------------
+// File: internal/proto.h
+// -----------------------------------------------------------------------------
+//
+// Declares functions for serializing and deserializing data to and from memory
+// buffers in protocol buffer wire format. This library takes no steps to
+// ensure that the encoded data matches with any message specification.
+
+#ifndef Y_ABSL_LOG_INTERNAL_PROTO_H_
+#define Y_ABSL_LOG_INTERNAL_PROTO_H_
+
+#include <cstddef>
+#include <cstdint>
+#include <limits>
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/base/casts.h"
+#include "y_absl/base/config.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/types/span.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+
+// y_absl::Span<char> represents a view into the available space in a mutable
+// buffer during encoding. Encoding functions shrink the span as they go so
+// that the same view can be passed to a series of Encode functions. If the
+// data do not fit, nothing is encoded, the view is set to size zero (so that
+// all subsequent encode calls fail), and false is returned. Otherwise true is
+// returned.
+
+// In particular, attempting to encode a series of data into an insufficient
+// buffer has consistent and efficient behavior without any caller-side error
+// checking. Individual values will be encoded in their entirety or not at all
+// (unless one of the `Truncate` functions is used). Once a value is omitted
+// because it does not fit, no subsequent values will be encoded to preserve
+// ordering; the decoded sequence will be a prefix of the original sequence.
+
+// There are two ways to encode a message-typed field:
+//
+// * Construct its contents in a separate buffer and use `EncodeBytes` to copy
+// it into the primary buffer with type, tag, and length.
+// * Use `EncodeMessageStart` to write type and tag fields and reserve space for
+// the length field, then encode the contents directly into the buffer, then
+// use `EncodeMessageLength` to write the actual length into the reserved
+// bytes. This works fine if the actual length takes fewer bytes to encode
+// than were reserved, although you don't get your extra bytes back.
+// This approach will always produce a valid encoding, but your protocol may
+// require that the whole message field by omitted if the buffer is too small
+// to contain all desired subfields. In this case, operate on a copy of the
+// buffer view and assign back only if everything fit, i.e. if the last
+// `Encode` call returned true.
+
+// Encodes the specified integer as a varint field and returns true if it fits.
+// Used for int32_t, int64_t, uint32_t, uint64_t, bool, and enum field types.
+// Consumes up to kMaxVarintSize * 2 bytes (20).
+bool EncodeVarint(uint64_t tag, uint64_t value, y_absl::Span<char> *buf);
+inline bool EncodeVarint(uint64_t tag, int64_t value, y_absl::Span<char> *buf) {
+ return EncodeVarint(tag, static_cast<uint64_t>(value), buf);
+}
+inline bool EncodeVarint(uint64_t tag, uint32_t value, y_absl::Span<char> *buf) {
+ return EncodeVarint(tag, static_cast<uint64_t>(value), buf);
+}
+inline bool EncodeVarint(uint64_t tag, int32_t value, y_absl::Span<char> *buf) {
+ return EncodeVarint(tag, static_cast<uint64_t>(value), buf);
+}
+
+// Encodes the specified integer as a varint field using ZigZag encoding and
+// returns true if it fits.
+// Used for sint32 and sint64 field types.
+// Consumes up to kMaxVarintSize * 2 bytes (20).
+inline bool EncodeVarintZigZag(uint64_t tag, int64_t value,
+ y_absl::Span<char> *buf) {
+ if (value < 0)
+ return EncodeVarint(tag, 2 * static_cast<uint64_t>(-(value + 1)) + 1, buf);
+ return EncodeVarint(tag, 2 * static_cast<uint64_t>(value), buf);
+}
+
+// Encodes the specified integer as a 64-bit field and returns true if it fits.
+// Used for fixed64 and sfixed64 field types.
+// Consumes up to kMaxVarintSize + 8 bytes (18).
+bool Encode64Bit(uint64_t tag, uint64_t value, y_absl::Span<char> *buf);
+inline bool Encode64Bit(uint64_t tag, int64_t value, y_absl::Span<char> *buf) {
+ return Encode64Bit(tag, static_cast<uint64_t>(value), buf);
+}
+inline bool Encode64Bit(uint64_t tag, uint32_t value, y_absl::Span<char> *buf) {
+ return Encode64Bit(tag, static_cast<uint64_t>(value), buf);
+}
+inline bool Encode64Bit(uint64_t tag, int32_t value, y_absl::Span<char> *buf) {
+ return Encode64Bit(tag, static_cast<uint64_t>(value), buf);
+}
+
+// Encodes the specified double as a 64-bit field and returns true if it fits.
+// Used for double field type.
+// Consumes up to kMaxVarintSize + 8 bytes (18).
+inline bool EncodeDouble(uint64_t tag, double value, y_absl::Span<char> *buf) {
+ return Encode64Bit(tag, y_absl::bit_cast<uint64_t>(value), buf);
+}
+
+// Encodes the specified integer as a 32-bit field and returns true if it fits.
+// Used for fixed32 and sfixed32 field types.
+// Consumes up to kMaxVarintSize + 4 bytes (14).
+bool Encode32Bit(uint64_t tag, uint32_t value, y_absl::Span<char> *buf);
+inline bool Encode32Bit(uint64_t tag, int32_t value, y_absl::Span<char> *buf) {
+ return Encode32Bit(tag, static_cast<uint32_t>(value), buf);
+}
+
+// Encodes the specified float as a 32-bit field and returns true if it fits.
+// Used for float field type.
+// Consumes up to kMaxVarintSize + 4 bytes (14).
+inline bool EncodeFloat(uint64_t tag, float value, y_absl::Span<char> *buf) {
+ return Encode32Bit(tag, y_absl::bit_cast<uint32_t>(value), buf);
+}
+
+// Encodes the specified bytes as a length-delimited field and returns true if
+// they fit.
+// Used for string, bytes, message, and packed-repeated field type.
+// Consumes up to kMaxVarintSize * 2 + value.size() bytes (20 + value.size()).
+bool EncodeBytes(uint64_t tag, y_absl::Span<const char> value,
+ y_absl::Span<char> *buf);
+
+// Encodes as many of the specified bytes as will fit as a length-delimited
+// field and returns true as long as the field header (`tag_type` and `length`)
+// fits.
+// Used for string, bytes, message, and packed-repeated field type.
+// Consumes up to kMaxVarintSize * 2 + value.size() bytes (20 + value.size()).
+bool EncodeBytesTruncate(uint64_t tag, y_absl::Span<const char> value,
+ y_absl::Span<char> *buf);
+
+// Encodes the specified string as a length-delimited field and returns true if
+// it fits.
+// Used for string, bytes, message, and packed-repeated field type.
+// Consumes up to kMaxVarintSize * 2 + value.size() bytes (20 + value.size()).
+inline bool EncodeString(uint64_t tag, y_absl::string_view value,
+ y_absl::Span<char> *buf) {
+ return EncodeBytes(tag, value, buf);
+}
+
+// Encodes as much of the specified string as will fit as a length-delimited
+// field and returns true as long as the field header (`tag_type` and `length`)
+// fits.
+// Used for string, bytes, message, and packed-repeated field type.
+// Consumes up to kMaxVarintSize * 2 + value.size() bytes (20 + value.size()).
+inline bool EncodeStringTruncate(uint64_t tag, y_absl::string_view value,
+ y_absl::Span<char> *buf) {
+ return EncodeBytesTruncate(tag, value, buf);
+}
+
+// Encodes the header for a length-delimited field containing up to `max_size`
+// bytes or the number remaining in the buffer, whichever is less. If the
+// header fits, a non-nullptr `Span` is returned; this must be passed to
+// `EncodeMessageLength` after all contents are encoded to finalize the length
+// field. If the header does not fit, a nullptr `Span` is returned which is
+// safe to pass to `EncodeMessageLength` but need not be.
+// Used for string, bytes, message, and packed-repeated field type.
+// Consumes up to kMaxVarintSize * 2 bytes (20).
+Y_ABSL_MUST_USE_RESULT y_absl::Span<char> EncodeMessageStart(uint64_t tag,
+ uint64_t max_size,
+ y_absl::Span<char> *buf);
+
+// Finalizes the length field in `msg` so that it encompasses all data encoded
+// since the call to `EncodeMessageStart` which returned `msg`. Does nothing if
+// `msg` is a `nullptr` `Span`.
+void EncodeMessageLength(y_absl::Span<char> msg, const y_absl::Span<char> *buf);
+
+enum class WireType : uint64_t {
+ kVarint = 0,
+ k64Bit = 1,
+ kLengthDelimited = 2,
+ k32Bit = 5,
+};
+
+constexpr size_t VarintSize(uint64_t value) {
+ return value < 128 ? 1 : 1 + VarintSize(value >> 7);
+}
+constexpr size_t MinVarintSize() {
+ return VarintSize((std::numeric_limits<uint64_t>::min)());
+}
+constexpr size_t MaxVarintSize() {
+ return VarintSize((std::numeric_limits<uint64_t>::max)());
+}
+
+constexpr uint64_t MaxVarintForSize(size_t size) {
+ return size >= 10 ? (std::numeric_limits<uint64_t>::max)()
+ : (static_cast<uint64_t>(1) << size * 7) - 1;
+}
+
+// `BufferSizeFor` returns a number of bytes guaranteed to be sufficient to
+// store encoded fields of the specified WireTypes regardless of tag numbers and
+// data values. This only makes sense for `WireType::kLengthDelimited` if you
+// add in the length of the contents yourself, e.g. for string and bytes fields
+// by adding the lengths of any encoded strings to the return value or for
+// submessage fields by enumerating the fields you may encode into their
+// contents.
+constexpr size_t BufferSizeFor() { return 0; }
+template <typename... T>
+constexpr size_t BufferSizeFor(WireType type, T... tail) {
+ // tag_type + data + ...
+ return MaxVarintSize() +
+ (type == WireType::kVarint ? MaxVarintSize() : //
+ type == WireType::k64Bit ? 8 : //
+ type == WireType::k32Bit ? 4 : MaxVarintSize()) + //
+ BufferSizeFor(tail...);
+}
+
+// y_absl::Span<const char> represents a view into the un-processed space in a
+// buffer during decoding. Decoding functions shrink the span as they go so
+// that the same view can be decoded iteratively until all data are processed.
+// In general, if the buffer is exhausted but additional bytes are expected by
+// the decoder, it will return values as if the additional bytes were zeros.
+// Length-delimited fields are an exception - if the encoded length field
+// indicates more data bytes than are available in the buffer, the `bytes_value`
+// and `string_value` accessors will return truncated views.
+
+class ProtoField final {
+ public:
+ // Consumes bytes from `data` and returns true if there were any bytes to
+ // decode.
+ bool DecodeFrom(y_absl::Span<const char> *data);
+ uint64_t tag() const { return tag_; }
+ WireType type() const { return type_; }
+
+ // These value accessors will return nonsense if the data were not encoded in
+ // the corresponding wiretype from the corresponding C++ (or other language)
+ // type.
+
+ double double_value() const { return y_absl::bit_cast<double>(value_); }
+ float float_value() const {
+ return y_absl::bit_cast<float>(static_cast<uint32_t>(value_));
+ }
+ int32_t int32_value() const { return static_cast<int32_t>(value_); }
+ int64_t int64_value() const { return static_cast<int64_t>(value_); }
+ int32_t sint32_value() const {
+ if (value_ % 2) return static_cast<int32_t>(0 - ((value_ - 1) / 2) - 1);
+ return static_cast<int32_t>(value_ / 2);
+ }
+ int64_t sint64_value() const {
+ if (value_ % 2) return 0 - ((value_ - 1) / 2) - 1;
+ return value_ / 2;
+ }
+ uint32_t uint32_value() const { return static_cast<uint32_t>(value_); }
+ uint64_t uint64_value() const { return value_; }
+ bool bool_value() const { return value_ != 0; }
+ // To decode an enum, call int32_value() and cast to the appropriate type.
+ // Note that the official C++ proto compiler treats enum fields with values
+ // that do not correspond to a defined enumerator as unknown fields.
+
+ // To decode fields within a submessage field, call
+ // `DecodeNextField(field.BytesValue())`.
+ y_absl::Span<const char> bytes_value() const { return data_; }
+ y_absl::string_view string_value() const {
+ const auto data = bytes_value();
+ return y_absl::string_view(data.data(), data.size());
+ }
+ // Returns the encoded length of a length-delimited field. This equals
+ // `bytes_value().size()` except when the latter has been truncated due to
+ // buffer underrun.
+ uint64_t encoded_length() const { return value_; }
+
+ private:
+ uint64_t tag_;
+ WireType type_;
+ // For `kTypeVarint`, `kType64Bit`, and `kType32Bit`, holds the decoded value.
+ // For `kTypeLengthDelimited`, holds the decoded length.
+ uint64_t value_;
+ y_absl::Span<const char> data_;
+};
+
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_LOG_INTERNAL_PROTO_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/strip.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/strip.h
new file mode 100644
index 00000000000..ce85b61f86d
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/strip.h
@@ -0,0 +1,108 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: log/internal/strip.h
+// -----------------------------------------------------------------------------
+//
+
+#ifndef Y_ABSL_LOG_INTERNAL_STRIP_H_
+#define Y_ABSL_LOG_INTERNAL_STRIP_H_
+
+#include "y_absl/base/attributes.h" // IWYU pragma: keep
+#include "y_absl/base/log_severity.h"
+#include "y_absl/log/internal/log_message.h"
+#include "y_absl/log/internal/nullstream.h"
+
+// `Y_ABSL_LOGGING_INTERNAL_LOG_*` evaluates to a temporary `LogMessage` object or
+// to a related object with a compatible API but different behavior. This set
+// of defines comes in three flavors: vanilla, plus two variants that strip some
+// logging in subtly different ways for subtly different reasons (see below).
+#if defined(STRIP_LOG) && STRIP_LOG
+
+// Attribute for marking variables used in implementation details of logging
+// macros as unused, but only when `STRIP_LOG` is defined.
+// With `STRIP_LOG` on, not marking them triggers `-Wunused-but-set-variable`,
+// With `STRIP_LOG` off, marking them triggers `-Wused-but-marked-unused`.
+//
+// TODO(b/290784225): Replace this macro with attribute [[maybe_unused]] when
+// Abseil stops supporting C++14.
+#define Y_ABSL_LOG_INTERNAL_ATTRIBUTE_UNUSED_IF_STRIP_LOG Y_ABSL_ATTRIBUTE_UNUSED
+
+#define Y_ABSL_LOGGING_INTERNAL_LOG_INFO ::y_absl::log_internal::NullStream()
+#define Y_ABSL_LOGGING_INTERNAL_LOG_WARNING ::y_absl::log_internal::NullStream()
+#define Y_ABSL_LOGGING_INTERNAL_LOG_ERROR ::y_absl::log_internal::NullStream()
+#define Y_ABSL_LOGGING_INTERNAL_LOG_FATAL ::y_absl::log_internal::NullStreamFatal()
+#define Y_ABSL_LOGGING_INTERNAL_LOG_QFATAL ::y_absl::log_internal::NullStreamFatal()
+#define Y_ABSL_LOGGING_INTERNAL_LOG_DFATAL \
+ ::y_absl::log_internal::NullStreamMaybeFatal(::y_absl::kLogDebugFatal)
+#define Y_ABSL_LOGGING_INTERNAL_LOG_LEVEL(severity) \
+ ::y_absl::log_internal::NullStreamMaybeFatal(absl_log_internal_severity)
+
+// Fatal `DLOG`s expand a little differently to avoid being `[[noreturn]]`.
+#define Y_ABSL_LOGGING_INTERNAL_DLOG_FATAL \
+ ::y_absl::log_internal::NullStreamMaybeFatal(::y_absl::LogSeverity::kFatal)
+#define Y_ABSL_LOGGING_INTERNAL_DLOG_QFATAL \
+ ::y_absl::log_internal::NullStreamMaybeFatal(::y_absl::LogSeverity::kFatal)
+
+#define Y_ABSL_LOG_INTERNAL_CHECK(failure_message) Y_ABSL_LOGGING_INTERNAL_LOG_FATAL
+#define Y_ABSL_LOG_INTERNAL_QCHECK(failure_message) \
+ Y_ABSL_LOGGING_INTERNAL_LOG_QFATAL
+
+#else // !defined(STRIP_LOG) || !STRIP_LOG
+
+#define Y_ABSL_LOG_INTERNAL_ATTRIBUTE_UNUSED_IF_STRIP_LOG
+
+#define Y_ABSL_LOGGING_INTERNAL_LOG_INFO \
+ ::y_absl::log_internal::LogMessage( \
+ __FILE__, __LINE__, ::y_absl::log_internal::LogMessage::InfoTag{})
+#define Y_ABSL_LOGGING_INTERNAL_LOG_WARNING \
+ ::y_absl::log_internal::LogMessage( \
+ __FILE__, __LINE__, ::y_absl::log_internal::LogMessage::WarningTag{})
+#define Y_ABSL_LOGGING_INTERNAL_LOG_ERROR \
+ ::y_absl::log_internal::LogMessage( \
+ __FILE__, __LINE__, ::y_absl::log_internal::LogMessage::ErrorTag{})
+#define Y_ABSL_LOGGING_INTERNAL_LOG_FATAL \
+ ::y_absl::log_internal::LogMessageFatal(__FILE__, __LINE__).TryThrow()
+#define Y_ABSL_LOGGING_INTERNAL_LOG_QFATAL \
+ ::y_absl::log_internal::LogMessageQuietlyFatal(__FILE__, __LINE__)
+#define Y_ABSL_LOGGING_INTERNAL_LOG_DFATAL \
+ ::y_absl::log_internal::LogMessage(__FILE__, __LINE__, ::y_absl::kLogDebugFatal)
+#define Y_ABSL_LOGGING_INTERNAL_LOG_LEVEL(severity) \
+ ::y_absl::log_internal::LogMessage(__FILE__, __LINE__, \
+ absl_log_internal_severity)
+
+// Fatal `DLOG`s expand a little differently to avoid being `[[noreturn]]`.
+#define Y_ABSL_LOGGING_INTERNAL_DLOG_FATAL \
+ ::y_absl::log_internal::LogMessageDebugFatal(__FILE__, __LINE__)
+#define Y_ABSL_LOGGING_INTERNAL_DLOG_QFATAL \
+ ::y_absl::log_internal::LogMessageQuietlyDebugFatal(__FILE__, __LINE__)
+
+// These special cases dispatch to special-case constructors that allow us to
+// avoid an extra function call and shrink non-LTO binaries by a percent or so.
+#define Y_ABSL_LOG_INTERNAL_CHECK(failure_message) \
+ ::y_absl::log_internal::LogMessageFatal(__FILE__, __LINE__, failure_message).TryThrow()
+#define Y_ABSL_LOG_INTERNAL_QCHECK(failure_message) \
+ ::y_absl::log_internal::LogMessageQuietlyFatal(__FILE__, __LINE__, \
+ failure_message)
+#endif // !defined(STRIP_LOG) || !STRIP_LOG
+
+// This part of a non-fatal `DLOG`s expands the same as `LOG`.
+#define Y_ABSL_LOGGING_INTERNAL_DLOG_INFO Y_ABSL_LOGGING_INTERNAL_LOG_INFO
+#define Y_ABSL_LOGGING_INTERNAL_DLOG_WARNING Y_ABSL_LOGGING_INTERNAL_LOG_WARNING
+#define Y_ABSL_LOGGING_INTERNAL_DLOG_ERROR Y_ABSL_LOGGING_INTERNAL_LOG_ERROR
+#define Y_ABSL_LOGGING_INTERNAL_DLOG_DFATAL Y_ABSL_LOGGING_INTERNAL_LOG_DFATAL
+#define Y_ABSL_LOGGING_INTERNAL_DLOG_LEVEL Y_ABSL_LOGGING_INTERNAL_LOG_LEVEL
+
+#endif // Y_ABSL_LOG_INTERNAL_STRIP_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/vlog_config.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/vlog_config.cc
new file mode 100644
index 00000000000..82022ead9af
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/vlog_config.cc
@@ -0,0 +1,340 @@
+// Copyright 2022 The Abseil Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "y_absl/log/internal/vlog_config.h"
+
+#include <stddef.h>
+
+#include <algorithm>
+#include <atomic>
+#include <functional>
+#include <memory>
+#include <util/generic/string.h>
+#include <utility>
+#include <vector>
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/base/config.h"
+#include "y_absl/base/const_init.h"
+#include "y_absl/base/internal/spinlock.h"
+#include "y_absl/base/no_destructor.h"
+#include "y_absl/base/optimization.h"
+#include "y_absl/base/thread_annotations.h"
+#include "y_absl/log/internal/fnmatch.h"
+#include "y_absl/memory/memory.h"
+#include "y_absl/strings/numbers.h"
+#include "y_absl/strings/str_split.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/strings/strip.h"
+#include "y_absl/synchronization/mutex.h"
+#include "y_absl/types/optional.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+
+namespace {
+bool ModuleIsPath(y_absl::string_view module_pattern) {
+#ifdef _WIN32
+ return module_pattern.find_first_of("/\\") != module_pattern.npos;
+#else
+ return module_pattern.find('/') != module_pattern.npos;
+#endif
+}
+} // namespace
+
+bool VLogSite::SlowIsEnabled(int stale_v, int level) {
+ if (Y_ABSL_PREDICT_TRUE(stale_v != kUninitialized)) {
+ // Because of the prerequisites to this function, we know that stale_v is
+ // either uninitialized or >= level. If it's not uninitialized, that means
+ // it must be >= level, thus we should log.
+ return true;
+ }
+ stale_v = log_internal::RegisterAndInitialize(this);
+ return Y_ABSL_PREDICT_FALSE(stale_v >= level);
+}
+
+bool VLogSite::SlowIsEnabled0(int stale_v) { return SlowIsEnabled(stale_v, 0); }
+bool VLogSite::SlowIsEnabled1(int stale_v) { return SlowIsEnabled(stale_v, 1); }
+bool VLogSite::SlowIsEnabled2(int stale_v) { return SlowIsEnabled(stale_v, 2); }
+bool VLogSite::SlowIsEnabled3(int stale_v) { return SlowIsEnabled(stale_v, 3); }
+bool VLogSite::SlowIsEnabled4(int stale_v) { return SlowIsEnabled(stale_v, 4); }
+bool VLogSite::SlowIsEnabled5(int stale_v) { return SlowIsEnabled(stale_v, 5); }
+
+namespace {
+struct VModuleInfo final {
+ TString module_pattern;
+ bool module_is_path; // i.e. it contains a path separator.
+ int vlog_level;
+
+ // Allocates memory.
+ VModuleInfo(y_absl::string_view module_pattern_arg, bool module_is_path_arg,
+ int vlog_level_arg)
+ : module_pattern(TString(module_pattern_arg)),
+ module_is_path(module_is_path_arg),
+ vlog_level(vlog_level_arg) {}
+};
+
+// `mutex` guards all of the data structures that aren't lock-free.
+// To avoid problems with the heap checker which calls into `VLOG`, `mutex` must
+// be a `SpinLock` that prevents fiber scheduling instead of a `Mutex`.
+Y_ABSL_CONST_INIT y_absl::base_internal::SpinLock mutex(
+ y_absl::kConstInit, y_absl::base_internal::SCHEDULE_KERNEL_ONLY);
+
+// `GetUpdateSitesMutex()` serializes updates to all of the sites (i.e. those in
+// `site_list_head`) themselves.
+y_absl::Mutex* GetUpdateSitesMutex() {
+ // Chromium requires no global destructors, so we can't use the
+ // y_absl::kConstInit idiom since y_absl::Mutex as a non-trivial destructor.
+ static y_absl::NoDestructor<y_absl::Mutex> update_sites_mutex Y_ABSL_ACQUIRED_AFTER(
+ mutex);
+ return update_sites_mutex.get();
+}
+
+Y_ABSL_CONST_INIT int global_v Y_ABSL_GUARDED_BY(mutex) = 0;
+// `site_list_head` is the head of a singly-linked list. Traversal, insertion,
+// and reads are atomic, so no locks are required, but updates to existing
+// elements are guarded by `GetUpdateSitesMutex()`.
+Y_ABSL_CONST_INIT std::atomic<VLogSite*> site_list_head{nullptr};
+Y_ABSL_CONST_INIT std::vector<VModuleInfo>* vmodule_info Y_ABSL_GUARDED_BY(mutex)
+ Y_ABSL_PT_GUARDED_BY(mutex){nullptr};
+
+// Only used for lisp.
+Y_ABSL_CONST_INIT std::vector<std::function<void()>>* update_callbacks
+ Y_ABSL_GUARDED_BY(GetUpdateSitesMutex())
+ Y_ABSL_PT_GUARDED_BY(GetUpdateSitesMutex()){nullptr};
+
+// Allocates memory.
+std::vector<VModuleInfo>& get_vmodule_info()
+ Y_ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex) {
+ if (!vmodule_info) vmodule_info = new std::vector<VModuleInfo>;
+ return *vmodule_info;
+}
+
+// Does not allocate or take locks.
+int VLogLevel(y_absl::string_view file, const std::vector<VModuleInfo>* infos,
+ int current_global_v) {
+ // `infos` is null during a call to `VLOG` prior to setting `vmodule` (e.g. by
+ // parsing flags). We can't allocate in `VLOG`, so we treat null as empty
+ // here and press on.
+ if (!infos || infos->empty()) return current_global_v;
+ // Get basename for file
+ y_absl::string_view basename = file;
+ {
+ const size_t sep = basename.rfind('/');
+ if (sep != basename.npos) {
+ basename.remove_prefix(sep + 1);
+#ifdef _WIN32
+ } else {
+ const size_t sep = basename.rfind('\\');
+ if (sep != basename.npos) basename.remove_prefix(sep + 1);
+#endif
+ }
+ }
+
+ y_absl::string_view stem = file, stem_basename = basename;
+ {
+ const size_t sep = stem_basename.find('.');
+ if (sep != stem_basename.npos) {
+ stem.remove_suffix(stem_basename.size() - sep);
+ stem_basename.remove_suffix(stem_basename.size() - sep);
+ }
+ if (y_absl::ConsumeSuffix(&stem_basename, "-inl")) {
+ stem.remove_suffix(y_absl::string_view("-inl").size());
+ }
+ }
+ for (const auto& info : *infos) {
+ if (info.module_is_path) {
+ // If there are any slashes in the pattern, try to match the full
+ // name.
+ if (FNMatch(info.module_pattern, stem)) {
+ return info.vlog_level == kUseFlag ? current_global_v : info.vlog_level;
+ }
+ } else if (FNMatch(info.module_pattern, stem_basename)) {
+ return info.vlog_level == kUseFlag ? current_global_v : info.vlog_level;
+ }
+ }
+
+ return current_global_v;
+}
+
+// Allocates memory.
+int AppendVModuleLocked(y_absl::string_view module_pattern, int log_level)
+ Y_ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex) {
+ for (const auto& info : get_vmodule_info()) {
+ if (FNMatch(info.module_pattern, module_pattern)) {
+ // This is a memory optimization to avoid storing patterns that will never
+ // match due to exit early semantics. Primarily optimized for our own unit
+ // tests.
+ return info.vlog_level;
+ }
+ }
+ bool module_is_path = ModuleIsPath(module_pattern);
+ get_vmodule_info().emplace_back(TString(module_pattern), module_is_path,
+ log_level);
+ return global_v;
+}
+
+// Allocates memory.
+int PrependVModuleLocked(y_absl::string_view module_pattern, int log_level)
+ Y_ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex) {
+ y_absl::optional<int> old_log_level;
+ for (const auto& info : get_vmodule_info()) {
+ if (FNMatch(info.module_pattern, module_pattern)) {
+ old_log_level = info.vlog_level;
+ break;
+ }
+ }
+ bool module_is_path = ModuleIsPath(module_pattern);
+ auto iter = get_vmodule_info().emplace(get_vmodule_info().cbegin(),
+ TString(module_pattern),
+ module_is_path, log_level);
+
+ // This is a memory optimization to avoid storing patterns that will never
+ // match due to exit early semantics. Primarily optimized for our own unit
+ // tests.
+ get_vmodule_info().erase(
+ std::remove_if(++iter, get_vmodule_info().end(),
+ [module_pattern](const VModuleInfo& info) {
+ return FNMatch(info.module_pattern, module_pattern);
+ }),
+ get_vmodule_info().cend());
+ return old_log_level.value_or(global_v);
+}
+} // namespace
+
+int VLogLevel(y_absl::string_view file) Y_ABSL_LOCKS_EXCLUDED(mutex) {
+ y_absl::base_internal::SpinLockHolder l(&mutex);
+ return VLogLevel(file, vmodule_info, global_v);
+}
+
+int RegisterAndInitialize(VLogSite* v) Y_ABSL_LOCKS_EXCLUDED(mutex) {
+ // std::memory_order_seq_cst is overkill in this function, but given that this
+ // path is intended to be slow, it's not worth the brain power to relax that.
+ VLogSite* h = site_list_head.load(std::memory_order_seq_cst);
+
+ VLogSite* old = nullptr;
+ if (v->next_.compare_exchange_strong(old, h, std::memory_order_seq_cst,
+ std::memory_order_seq_cst)) {
+ // Multiple threads may attempt to register this site concurrently.
+ // By successfully setting `v->next` this thread commits to being *the*
+ // thread that installs `v` in the list.
+ while (!site_list_head.compare_exchange_weak(
+ h, v, std::memory_order_seq_cst, std::memory_order_seq_cst)) {
+ v->next_.store(h, std::memory_order_seq_cst);
+ }
+ }
+
+ int old_v = VLogSite::kUninitialized;
+ int new_v = VLogLevel(v->file_);
+ // No loop, if someone else set this, we should respect their evaluation of
+ // `VLogLevel`. This may mean we return a stale `v`, but `v` itself will
+ // always arrive at the freshest value. Otherwise, we could be writing a
+ // stale value and clobbering the fresher one.
+ if (v->v_.compare_exchange_strong(old_v, new_v, std::memory_order_seq_cst,
+ std::memory_order_seq_cst)) {
+ return new_v;
+ }
+ return old_v;
+}
+
+void UpdateVLogSites() Y_ABSL_UNLOCK_FUNCTION(mutex)
+ Y_ABSL_LOCKS_EXCLUDED(GetUpdateSitesMutex()) {
+ std::vector<VModuleInfo> infos = get_vmodule_info();
+ int current_global_v = global_v;
+ // We need to grab `GetUpdateSitesMutex()` before we release `mutex` to ensure
+ // that updates are not interleaved (resulting in an inconsistent final state)
+ // and to ensure that the final state in the sites matches the final state of
+ // `vmodule_info`. We unlock `mutex` to ensure that uninitialized sites don't
+ // have to wait on all updates in order to acquire `mutex` and initialize
+ // themselves.
+ y_absl::MutexLock ul(GetUpdateSitesMutex());
+ mutex.Unlock();
+ VLogSite* n = site_list_head.load(std::memory_order_seq_cst);
+ // Because sites are added to the list in the order they are executed, there
+ // tend to be clusters of entries with the same file.
+ const char* last_file = nullptr;
+ int last_file_level = 0;
+ while (n != nullptr) {
+ if (n->file_ != last_file) {
+ last_file = n->file_;
+ last_file_level = VLogLevel(n->file_, &infos, current_global_v);
+ }
+ n->v_.store(last_file_level, std::memory_order_seq_cst);
+ n = n->next_.load(std::memory_order_seq_cst);
+ }
+ if (update_callbacks) {
+ for (auto& cb : *update_callbacks) {
+ cb();
+ }
+ }
+}
+
+void UpdateVModule(y_absl::string_view vmodule)
+ Y_ABSL_LOCKS_EXCLUDED(mutex, GetUpdateSitesMutex()) {
+ std::vector<std::pair<y_absl::string_view, int>> glob_levels;
+ for (y_absl::string_view glob_level : y_absl::StrSplit(vmodule, ',')) {
+ const size_t eq = glob_level.rfind('=');
+ if (eq == glob_level.npos) continue;
+ const y_absl::string_view glob = glob_level.substr(0, eq);
+ int level;
+ if (!y_absl::SimpleAtoi(glob_level.substr(eq + 1), &level)) continue;
+ glob_levels.emplace_back(glob, level);
+ }
+ mutex.Lock(); // Unlocked by UpdateVLogSites().
+ get_vmodule_info().clear();
+ for (const auto& it : glob_levels) {
+ const y_absl::string_view glob = it.first;
+ const int level = it.second;
+ AppendVModuleLocked(glob, level);
+ }
+ UpdateVLogSites();
+}
+
+int UpdateGlobalVLogLevel(int v)
+ Y_ABSL_LOCKS_EXCLUDED(mutex, GetUpdateSitesMutex()) {
+ mutex.Lock(); // Unlocked by UpdateVLogSites().
+ const int old_global_v = global_v;
+ if (v == global_v) {
+ mutex.Unlock();
+ return old_global_v;
+ }
+ global_v = v;
+ UpdateVLogSites();
+ return old_global_v;
+}
+
+int PrependVModule(y_absl::string_view module_pattern, int log_level)
+ Y_ABSL_LOCKS_EXCLUDED(mutex, GetUpdateSitesMutex()) {
+ mutex.Lock(); // Unlocked by UpdateVLogSites().
+ int old_v = PrependVModuleLocked(module_pattern, log_level);
+ UpdateVLogSites();
+ return old_v;
+}
+
+void OnVLogVerbosityUpdate(std::function<void()> cb)
+ Y_ABSL_LOCKS_EXCLUDED(GetUpdateSitesMutex()) {
+ y_absl::MutexLock ul(GetUpdateSitesMutex());
+ if (!update_callbacks)
+ update_callbacks = new std::vector<std::function<void()>>;
+ update_callbacks->push_back(std::move(cb));
+}
+
+VLogSite* SetVModuleListHeadForTestOnly(VLogSite* v) {
+ return site_list_head.exchange(v, std::memory_order_seq_cst);
+}
+
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/vlog_config.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/vlog_config.h
new file mode 100644
index 00000000000..00131b78201
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/vlog_config.h
@@ -0,0 +1,163 @@
+// Copyright 2022 The Abseil Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// vlog_config.h
+// -----------------------------------------------------------------------------
+//
+// This header file defines `VLogSite`, a public primitive that represents
+// a callsite for the `VLOG` family of macros and related libraries.
+// It also declares and defines multiple internal utilities used to implement
+// `VLOG`, such as `VLogSiteManager`.
+
+#ifndef Y_ABSL_LOG_INTERNAL_VLOG_CONFIG_H_
+#define Y_ABSL_LOG_INTERNAL_VLOG_CONFIG_H_
+
+// IWYU pragma: private, include "y_absl/log/log.h"
+
+#include <atomic>
+#include <cstdint>
+#include <functional>
+#include <limits>
+#include <type_traits>
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/base/config.h"
+#include "y_absl/base/optimization.h"
+#include "y_absl/base/thread_annotations.h"
+#include "y_absl/strings/string_view.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+
+class SyntheticBinary;
+class VLogSite;
+
+int RegisterAndInitialize(VLogSite* v);
+void UpdateVLogSites();
+constexpr int kUseFlag = (std::numeric_limits<int16_t>::min)();
+
+// Represents a unique callsite for a `VLOG()` or `VLOG_IS_ON()` call.
+//
+// Libraries that provide `VLOG`-like functionality should use this to
+// efficiently handle --vmodule.
+//
+// VLogSite objects must not be destroyed until the program exits. Doing so will
+// probably yield nasty segfaults in VLogSiteManager::UpdateLogSites(). The
+// recommendation is to make all such objects function-local statics.
+class VLogSite final {
+ public:
+ // `f` must not be destroyed until the program exits.
+ explicit constexpr VLogSite(const char* f)
+ : file_(f), v_(kUninitialized), next_(nullptr) {}
+ VLogSite(const VLogSite&) = delete;
+ VLogSite& operator=(const VLogSite&) = delete;
+
+ // Inlining the function yields a ~3x performance improvement at the cost of a
+ // 1.5x code size increase at the call site.
+ // Takes locks but does not allocate memory.
+ Y_ABSL_ATTRIBUTE_ALWAYS_INLINE
+ bool IsEnabled(int level) {
+ int stale_v = v_.load(std::memory_order_relaxed);
+ if (Y_ABSL_PREDICT_TRUE(level > stale_v)) {
+ return false;
+ }
+
+ // We put everything other than the fast path, i.e. vlogging is initialized
+ // but not on, behind an out-of-line function to reduce code size.
+ // "level" is almost always a call-site constant, so we can save a bit
+ // of code space by special-casing for a few common levels.
+#if Y_ABSL_HAVE_BUILTIN(__builtin_constant_p) || defined(__GNUC__)
+ if (__builtin_constant_p(level)) {
+ if (level == 0) return SlowIsEnabled0(stale_v);
+ if (level == 1) return SlowIsEnabled1(stale_v);
+ if (level == 2) return SlowIsEnabled2(stale_v);
+ if (level == 3) return SlowIsEnabled3(stale_v);
+ if (level == 4) return SlowIsEnabled4(stale_v);
+ if (level == 5) return SlowIsEnabled5(stale_v);
+ }
+#endif
+ return SlowIsEnabled(stale_v, level);
+ }
+
+ private:
+ friend int log_internal::RegisterAndInitialize(VLogSite* v);
+ friend void log_internal::UpdateVLogSites();
+ friend class log_internal::SyntheticBinary;
+ static constexpr int kUninitialized = (std::numeric_limits<int>::max)();
+
+ // SlowIsEnabled performs slower checks to determine whether a log site is
+ // enabled. Because it is expected to be called somewhat rarely
+ // (comparatively), it is not inlined to save on code size.
+ //
+ // Prerequisites to calling SlowIsEnabled:
+ // 1) stale_v is uninitialized OR
+ // 2) stale_v is initialized and >= level (meaning we must log).
+ // Takes locks but does not allocate memory.
+ Y_ABSL_ATTRIBUTE_NOINLINE
+ bool SlowIsEnabled(int stale_v, int level);
+ Y_ABSL_ATTRIBUTE_NOINLINE bool SlowIsEnabled0(int stale_v);
+ Y_ABSL_ATTRIBUTE_NOINLINE bool SlowIsEnabled1(int stale_v);
+ Y_ABSL_ATTRIBUTE_NOINLINE bool SlowIsEnabled2(int stale_v);
+ Y_ABSL_ATTRIBUTE_NOINLINE bool SlowIsEnabled3(int stale_v);
+ Y_ABSL_ATTRIBUTE_NOINLINE bool SlowIsEnabled4(int stale_v);
+ Y_ABSL_ATTRIBUTE_NOINLINE bool SlowIsEnabled5(int stale_v);
+
+ // This object is too size-sensitive to use y_absl::string_view.
+ const char* const file_;
+ std::atomic<int> v_;
+ std::atomic<VLogSite*> next_;
+};
+static_assert(std::is_trivially_destructible<VLogSite>::value,
+ "VLogSite must be trivially destructible");
+
+// Returns the current verbose log level of `file`.
+// Does not allocate memory.
+int VLogLevel(y_absl::string_view file);
+
+// Registers a site `v` to get updated as `vmodule` and `v` change. Also
+// initializes the site based on their current values, and returns that result.
+// Does not allocate memory.
+int RegisterAndInitialize(VLogSite* v);
+
+// Allocates memory.
+void UpdateVLogSites();
+
+// Completely overwrites the saved value of `vmodule`.
+// Allocates memory.
+void UpdateVModule(y_absl::string_view vmodule);
+
+// Updates the global verbosity level to `v` and returns the prior value.
+// Allocates memory.
+int UpdateGlobalVLogLevel(int v);
+
+// Atomically prepends `module_pattern=log_level` to the start of vmodule.
+// Returns the prior value for `module_pattern` if there was an exact match and
+// `global_v` otherwise.
+// Allocates memory.
+int PrependVModule(y_absl::string_view module_pattern, int log_level);
+
+// Registers `on_update` to be called whenever `v` or `vmodule` change.
+// Allocates memory.
+void OnVLogVerbosityUpdate(std::function<void()> cb);
+
+// Does not allocate memory.
+VLogSite* SetVModuleListHeadForTestOnly(VLogSite* v);
+
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_LOG_INTERNAL_VLOG_CONFIG_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/voidify.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/voidify.h
new file mode 100644
index 00000000000..873619392db
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/internal/voidify.h
@@ -0,0 +1,44 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: log/internal/voidify.h
+// -----------------------------------------------------------------------------
+//
+// This class is used to explicitly ignore values in the conditional logging
+// macros. This avoids compiler warnings like "value computed is not used" and
+// "statement has no effect".
+
+#ifndef Y_ABSL_LOG_INTERNAL_VOIDIFY_H_
+#define Y_ABSL_LOG_INTERNAL_VOIDIFY_H_
+
+#include "y_absl/base/config.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+namespace log_internal {
+
+class Voidify final {
+ public:
+ // This has to be an operator with a precedence lower than << but higher than
+ // ?:
+ template <typename T>
+ void operator&&(const T&) const&& {}
+};
+
+} // namespace log_internal
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_LOG_INTERNAL_VOIDIFY_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/log.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/log.h
new file mode 100644
index 00000000000..261e451bcad
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/log.h
@@ -0,0 +1,365 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: log/log.h
+// -----------------------------------------------------------------------------
+//
+// This header declares a family of LOG macros.
+//
+// Basic invocation looks like this:
+//
+// LOG(INFO) << "Found " << num_cookies << " cookies";
+//
+// Most `LOG` macros take a severity level argument. The severity levels are
+// `INFO`, `WARNING`, `ERROR`, and `FATAL`. They are defined
+// in y_absl/base/log_severity.h.
+// * The `FATAL` severity level terminates the program with a stack trace after
+// logging its message. Error handlers registered with `RunOnFailure`
+// (process_state.h) are run, but exit handlers registered with `atexit(3)`
+// are not.
+// * The `QFATAL` pseudo-severity level is equivalent to `FATAL` but triggers
+// quieter termination messages, e.g. without a full stack trace, and skips
+// running registered error handlers.
+// * The `DFATAL` pseudo-severity level is defined as `FATAL` in debug mode and
+// as `ERROR` otherwise.
+// Some preprocessor shenanigans are used to ensure that e.g. `LOG(INFO)` has
+// the same meaning even if a local symbol or preprocessor macro named `INFO` is
+// defined. To specify a severity level using an expression instead of a
+// literal, use `LEVEL(expr)`.
+// Example:
+//
+// LOG(LEVEL(stale ? y_absl::LogSeverity::kWarning : y_absl::LogSeverity::kInfo))
+// << "Cookies are " << days << " days old";
+
+// `LOG` macros evaluate to an unterminated statement. The value at the end of
+// the statement supports some chainable methods:
+//
+// * .AtLocation(y_absl::string_view file, int line)
+// .AtLocation(y_absl::SourceLocation loc)
+// Overrides the location inferred from the callsite. The string pointed to
+// by `file` must be valid until the end of the statement.
+// * .NoPrefix()
+// Omits the prefix from this line. The prefix includes metadata about the
+// logged data such as source code location and timestamp.
+// * .WithVerbosity(int verbose_level)
+// Sets the verbosity field of the logged message as if it was logged by
+// `VLOG(verbose_level)`. Unlike `VLOG`, this method does not affect
+// evaluation of the statement when the specified `verbose_level` has been
+// disabled. The only effect is on `LogSink` implementations which make use
+// of the `y_absl::LogSink::verbosity()` value. The value
+// `y_absl::LogEntry::kNoVerbosityLevel` can be specified to mark the message
+// not verbose.
+// * .WithTimestamp(y_absl::Time timestamp)
+// Uses the specified timestamp instead of one collected at the time of
+// execution.
+// * .WithThreadID(y_absl::LogEntry::tid_t tid)
+// Uses the specified thread ID instead of one collected at the time of
+// execution.
+// * .WithMetadataFrom(const y_absl::LogEntry &entry)
+// Copies all metadata (but no data) from the specified `y_absl::LogEntry`.
+// This can be used to change the severity of a message, but it has some
+// limitations:
+// * `Y_ABSL_MIN_LOG_LEVEL` is evaluated against the severity passed into
+// `LOG` (or the implicit `FATAL` level of `CHECK`).
+// * `LOG(FATAL)` and `CHECK` terminate the process unconditionally, even if
+// the severity is changed later.
+// `.WithMetadataFrom(entry)` should almost always be used in combination
+// with `LOG(LEVEL(entry.log_severity()))`.
+// * .WithPerror()
+// Appends to the logged message a colon, a space, a textual description of
+// the current value of `errno` (as by `strerror(3)`), and the numerical
+// value of `errno`.
+// * .ToSinkAlso(y_absl::LogSink* sink)
+// Sends this message to `*sink` in addition to whatever other sinks it
+// would otherwise have been sent to. `sink` must not be null.
+// * .ToSinkOnly(y_absl::LogSink* sink)
+// Sends this message to `*sink` and no others. `sink` must not be null.
+//
+// No interfaces in this header are async-signal-safe; their use in signal
+// handlers is unsupported and may deadlock your program or eat your lunch.
+//
+// Many logging statements are inherently conditional. For example,
+// `LOG_IF(INFO, !foo)` does nothing if `foo` is true. Even seemingly
+// unconditional statements like `LOG(INFO)` might be disabled at
+// compile-time to minimize binary size or for security reasons.
+//
+// * Except for the condition in a `CHECK` or `QCHECK` statement, programs must
+// not rely on evaluation of expressions anywhere in logging statements for
+// correctness. For example, this is ok:
+//
+// CHECK((fp = fopen("config.ini", "r")) != nullptr);
+//
+// But this is probably not ok:
+//
+// LOG(INFO) << "Server status: " << StartServerAndReturnStatusString();
+//
+// The example below is bad too; the `i++` in the `LOG_IF` condition might
+// not be evaluated, resulting in an infinite loop:
+//
+// for (int i = 0; i < 1000000;)
+// LOG_IF(INFO, i++ % 1000 == 0) << "Still working...";
+//
+// * Except where otherwise noted, conditions which cause a statement not to log
+// also cause expressions not to be evaluated. Programs may rely on this for
+// performance reasons, e.g. by streaming the result of an expensive function
+// call into a `DLOG` or `LOG_EVERY_N` statement.
+// * Care has been taken to ensure that expressions are parsed by the compiler
+// even if they are never evaluated. This means that syntax errors will be
+// caught and variables will be considered used for the purposes of
+// unused-variable diagnostics. For example, this statement won't compile
+// even if `INFO`-level logging has been compiled out:
+//
+// int number_of_cakes = 40;
+// LOG(INFO) << "Number of cakes: " << number_of_cake; // Note the typo!
+//
+// Similarly, this won't produce unused-variable compiler diagnostics even
+// if `INFO`-level logging is compiled out:
+//
+// {
+// char fox_line1[] = "Hatee-hatee-hatee-ho!";
+// LOG_IF(ERROR, false) << "The fox says " << fox_line1;
+// char fox_line2[] = "A-oo-oo-oo-ooo!";
+// LOG(INFO) << "The fox also says " << fox_line2;
+// }
+//
+// This error-checking is not perfect; for example, symbols that have been
+// declared but not defined may not produce link errors if used in logging
+// statements that compile away.
+//
+// Expressions streamed into these macros are formatted using `operator<<` just
+// as they would be if streamed into a `std::ostream`, however it should be
+// noted that their actual type is unspecified.
+//
+// To implement a custom formatting operator for a type you own, there are two
+// options: `AbslStringify()` or `std::ostream& operator<<(std::ostream&, ...)`.
+// It is recommended that users make their types loggable through
+// `AbslStringify()` as it is a universal stringification extension that also
+// enables `y_absl::StrFormat` and `y_absl::StrCat` support. If both
+// `AbslStringify()` and `std::ostream& operator<<(std::ostream&, ...)` are
+// defined, `AbslStringify()` will be used.
+//
+// To use the `AbslStringify()` API, define a friend function template in your
+// type's namespace with the following signature:
+//
+// template <typename Sink>
+// void AbslStringify(Sink& sink, const UserDefinedType& value);
+//
+// `Sink` has the same interface as `y_absl::FormatSink`, but without
+// `PutPaddedString()`.
+//
+// Example:
+//
+// struct Point {
+// template <typename Sink>
+// friend void AbslStringify(Sink& sink, const Point& p) {
+// y_absl::Format(&sink, "(%v, %v)", p.x, p.y);
+// }
+//
+// int x;
+// int y;
+// };
+//
+// To use `std::ostream& operator<<(std::ostream&, ...)`, define
+// `std::ostream& operator<<(std::ostream&, ...)` in your type's namespace (for
+// ADL) just as you would to stream it to `std::cout`.
+//
+// Currently `AbslStringify()` ignores output manipulators but this is not
+// guaranteed behavior and may be subject to change in the future. If you would
+// like guaranteed behavior regarding output manipulators, please use
+// `std::ostream& operator<<(std::ostream&, ...)` to make custom types loggable
+// instead.
+//
+// Those macros that support streaming honor output manipulators and `fmtflag`
+// changes that output data (e.g. `std::ends`) or control formatting of data
+// (e.g. `std::hex` and `std::fixed`), however flushing such a stream is
+// ignored. The message produced by a log statement is sent to registered
+// `y_absl::LogSink` instances at the end of the statement; those sinks are
+// responsible for their own flushing (e.g. to disk) semantics.
+//
+// Flag settings are not carried over from one `LOG` statement to the next; this
+// is a bit different than e.g. `std::cout`:
+//
+// LOG(INFO) << std::hex << 0xdeadbeef; // logs "0xdeadbeef"
+// LOG(INFO) << 0xdeadbeef; // logs "3735928559"
+
+#ifndef Y_ABSL_LOG_LOG_H_
+#define Y_ABSL_LOG_LOG_H_
+
+#include "y_absl/log/internal/log_impl.h"
+
+// LOG()
+//
+// `LOG` takes a single argument which is a severity level. Data streamed in
+// comprise the logged message.
+// Example:
+//
+// LOG(INFO) << "Found " << num_cookies << " cookies";
+#define LOG(severity) Y_ABSL_LOG_INTERNAL_LOG_IMPL(_##severity)
+
+// PLOG()
+//
+// `PLOG` behaves like `LOG` except that a description of the current state of
+// `errno` is appended to the streamed message.
+#define PLOG(severity) Y_ABSL_LOG_INTERNAL_PLOG_IMPL(_##severity)
+
+// DLOG()
+//
+// `DLOG` behaves like `LOG` in debug mode (i.e. `#ifndef NDEBUG`). Otherwise
+// it compiles away and does nothing. Note that `DLOG(FATAL)` does not
+// terminate the program if `NDEBUG` is defined.
+#define DLOG(severity) Y_ABSL_LOG_INTERNAL_DLOG_IMPL(_##severity)
+
+// `VLOG` uses numeric levels to provide verbose logging that can configured at
+// runtime, including at a per-module level. `VLOG` statements are logged at
+// `INFO` severity if they are logged at all; the numeric levels are on a
+// different scale than the proper severity levels. Positive levels are
+// disabled by default. Negative levels should not be used.
+// Example:
+//
+// VLOG(1) << "I print when you run the program with --v=1 or higher";
+// VLOG(2) << "I print when you run the program with --v=2 or higher";
+//
+// See vlog_is_on.h for further documentation, including the usage of the
+// --vmodule flag to log at different levels in different source files.
+//
+// `VLOG` does not produce any output when verbose logging is not enabled.
+// However, simply testing whether verbose logging is enabled can be expensive.
+// If you don't intend to enable verbose logging in non-debug builds, consider
+// using `DVLOG` instead.
+#define VLOG(severity) Y_ABSL_LOG_INTERNAL_VLOG_IMPL(severity)
+
+// `DVLOG` behaves like `VLOG` in debug mode (i.e. `#ifndef NDEBUG`).
+// Otherwise, it compiles away and does nothing.
+#define DVLOG(severity) Y_ABSL_LOG_INTERNAL_DVLOG_IMPL(severity)
+
+// `LOG_IF` and friends add a second argument which specifies a condition. If
+// the condition is false, nothing is logged.
+// Example:
+//
+// LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
+//
+// There is no `VLOG_IF` because the order of evaluation of the arguments is
+// ambiguous and the alternate spelling with an `if`-statement is trivial.
+#define LOG_IF(severity, condition) \
+ Y_ABSL_LOG_INTERNAL_LOG_IF_IMPL(_##severity, condition)
+#define PLOG_IF(severity, condition) \
+ Y_ABSL_LOG_INTERNAL_PLOG_IF_IMPL(_##severity, condition)
+#define DLOG_IF(severity, condition) \
+ Y_ABSL_LOG_INTERNAL_DLOG_IF_IMPL(_##severity, condition)
+
+// LOG_EVERY_N
+//
+// An instance of `LOG_EVERY_N` increments a hidden zero-initialized counter
+// every time execution passes through it and logs the specified message when
+// the counter's value is a multiple of `n`, doing nothing otherwise. Each
+// instance has its own counter. The counter's value can be logged by streaming
+// the symbol `COUNTER`. `LOG_EVERY_N` is thread-safe.
+// Example:
+//
+// LOG_EVERY_N(WARNING, 1000) << "Got a packet with a bad CRC (" << COUNTER
+// << " total)";
+#define LOG_EVERY_N(severity, n) \
+ Y_ABSL_LOG_INTERNAL_LOG_EVERY_N_IMPL(_##severity, n)
+
+// LOG_FIRST_N
+//
+// `LOG_FIRST_N` behaves like `LOG_EVERY_N` except that the specified message is
+// logged when the counter's value is less than `n`. `LOG_FIRST_N` is
+// thread-safe.
+#define LOG_FIRST_N(severity, n) \
+ Y_ABSL_LOG_INTERNAL_LOG_FIRST_N_IMPL(_##severity, n)
+
+// LOG_EVERY_POW_2
+//
+// `LOG_EVERY_POW_2` behaves like `LOG_EVERY_N` except that the specified
+// message is logged when the counter's value is a power of 2.
+// `LOG_EVERY_POW_2` is thread-safe.
+#define LOG_EVERY_POW_2(severity) \
+ Y_ABSL_LOG_INTERNAL_LOG_EVERY_POW_2_IMPL(_##severity)
+
+// LOG_EVERY_N_SEC
+//
+// An instance of `LOG_EVERY_N_SEC` uses a hidden state variable to log the
+// specified message at most once every `n_seconds`. A hidden counter of
+// executions (whether a message is logged or not) is also maintained and can be
+// logged by streaming the symbol `COUNTER`. `LOG_EVERY_N_SEC` is thread-safe.
+// Example:
+//
+// LOG_EVERY_N_SEC(INFO, 2.5) << "Got " << COUNTER << " cookies so far";
+#define LOG_EVERY_N_SEC(severity, n_seconds) \
+ Y_ABSL_LOG_INTERNAL_LOG_EVERY_N_SEC_IMPL(_##severity, n_seconds)
+
+#define PLOG_EVERY_N(severity, n) \
+ Y_ABSL_LOG_INTERNAL_PLOG_EVERY_N_IMPL(_##severity, n)
+#define PLOG_FIRST_N(severity, n) \
+ Y_ABSL_LOG_INTERNAL_PLOG_FIRST_N_IMPL(_##severity, n)
+#define PLOG_EVERY_POW_2(severity) \
+ Y_ABSL_LOG_INTERNAL_PLOG_EVERY_POW_2_IMPL(_##severity)
+#define PLOG_EVERY_N_SEC(severity, n_seconds) \
+ Y_ABSL_LOG_INTERNAL_PLOG_EVERY_N_SEC_IMPL(_##severity, n_seconds)
+
+#define DLOG_EVERY_N(severity, n) \
+ Y_ABSL_LOG_INTERNAL_DLOG_EVERY_N_IMPL(_##severity, n)
+#define DLOG_FIRST_N(severity, n) \
+ Y_ABSL_LOG_INTERNAL_DLOG_FIRST_N_IMPL(_##severity, n)
+#define DLOG_EVERY_POW_2(severity) \
+ Y_ABSL_LOG_INTERNAL_DLOG_EVERY_POW_2_IMPL(_##severity)
+#define DLOG_EVERY_N_SEC(severity, n_seconds) \
+ Y_ABSL_LOG_INTERNAL_DLOG_EVERY_N_SEC_IMPL(_##severity, n_seconds)
+
+#define VLOG_EVERY_N(severity, n) \
+ Y_ABSL_LOG_INTERNAL_VLOG_EVERY_N_IMPL(severity, n)
+#define VLOG_FIRST_N(severity, n) \
+ Y_ABSL_LOG_INTERNAL_VLOG_FIRST_N_IMPL(severity, n)
+#define VLOG_EVERY_POW_2(severity) \
+ Y_ABSL_LOG_INTERNAL_VLOG_EVERY_POW_2_IMPL(severity)
+#define VLOG_EVERY_N_SEC(severity, n_seconds) \
+ Y_ABSL_LOG_INTERNAL_VLOG_EVERY_N_SEC_IMPL(severity, n_seconds)
+
+// `LOG_IF_EVERY_N` and friends behave as the corresponding `LOG_EVERY_N`
+// but neither increment a counter nor log a message if condition is false (as
+// `LOG_IF`).
+// Example:
+//
+// LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << COUNTER
+// << "th big cookie";
+#define LOG_IF_EVERY_N(severity, condition, n) \
+ Y_ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_IMPL(_##severity, condition, n)
+#define LOG_IF_FIRST_N(severity, condition, n) \
+ Y_ABSL_LOG_INTERNAL_LOG_IF_FIRST_N_IMPL(_##severity, condition, n)
+#define LOG_IF_EVERY_POW_2(severity, condition) \
+ Y_ABSL_LOG_INTERNAL_LOG_IF_EVERY_POW_2_IMPL(_##severity, condition)
+#define LOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \
+ Y_ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds)
+
+#define PLOG_IF_EVERY_N(severity, condition, n) \
+ Y_ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_IMPL(_##severity, condition, n)
+#define PLOG_IF_FIRST_N(severity, condition, n) \
+ Y_ABSL_LOG_INTERNAL_PLOG_IF_FIRST_N_IMPL(_##severity, condition, n)
+#define PLOG_IF_EVERY_POW_2(severity, condition) \
+ Y_ABSL_LOG_INTERNAL_PLOG_IF_EVERY_POW_2_IMPL(_##severity, condition)
+#define PLOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \
+ Y_ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds)
+
+#define DLOG_IF_EVERY_N(severity, condition, n) \
+ Y_ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_IMPL(_##severity, condition, n)
+#define DLOG_IF_FIRST_N(severity, condition, n) \
+ Y_ABSL_LOG_INTERNAL_DLOG_IF_FIRST_N_IMPL(_##severity, condition, n)
+#define DLOG_IF_EVERY_POW_2(severity, condition) \
+ Y_ABSL_LOG_INTERNAL_DLOG_IF_EVERY_POW_2_IMPL(_##severity, condition)
+#define DLOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \
+ Y_ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds)
+
+#endif // Y_ABSL_LOG_LOG_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/log_entry.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/log/log_entry.cc
new file mode 100644
index 00000000000..086b7bce1d3
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/log_entry.cc
@@ -0,0 +1,41 @@
+//
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "y_absl/log/log_entry.h"
+
+#include "y_absl/base/config.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+
+#ifdef Y_ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
+constexpr int LogEntry::kNoVerbosityLevel;
+constexpr int LogEntry::kNoVerboseLevel;
+#endif
+
+// https://github.com/abseil/abseil-cpp/issues/1465
+// CMake builds on Apple platforms error when libraries are empty.
+// Our CMake configuration can avoid this error on header-only libraries,
+// but since this library is conditionally empty, including a single
+// variable is an easy workaround.
+#ifdef __APPLE__
+namespace log_internal {
+extern const char kAvoidEmptyLogEntryLibraryWarning;
+const char kAvoidEmptyLogEntryLibraryWarning = 0;
+} // namespace log_internal
+#endif // __APPLE__
+
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/log_entry.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/log_entry.h
new file mode 100644
index 00000000000..5da3cff84ea
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/log_entry.h
@@ -0,0 +1,221 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: log/log_entry.h
+// -----------------------------------------------------------------------------
+//
+// This header declares `class y_absl::LogEntry`, which represents a log record as
+// passed to `LogSink::Send`. Data returned by pointer or by reference or by
+// `y_absl::string_view` must be copied if they are needed after the lifetime of
+// the `y_absl::LogEntry`.
+
+#ifndef Y_ABSL_LOG_LOG_ENTRY_H_
+#define Y_ABSL_LOG_LOG_ENTRY_H_
+
+#include <cstddef>
+#include <util/generic/string.h>
+
+#include "y_absl/base/attributes.h"
+#include "y_absl/base/config.h"
+#include "y_absl/base/log_severity.h"
+#include "y_absl/log/internal/config.h"
+#include "y_absl/strings/string_view.h"
+#include "y_absl/time/time.h"
+#include "y_absl/types/span.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+
+namespace log_internal {
+// Test only friend.
+class LogEntryTestPeer;
+class LogMessage;
+} // namespace log_internal
+
+// LogEntry
+//
+// Represents a single entry in a log, i.e., one `LOG` statement or failed
+// `CHECK`.
+//
+// `LogEntry` is thread-compatible.
+class LogEntry final {
+ public:
+ using tid_t = log_internal::Tid;
+
+ // For non-verbose log entries, `verbosity()` returns `kNoVerbosityLevel`.
+ static constexpr int kNoVerbosityLevel = -1;
+ static constexpr int kNoVerboseLevel = -1; // TO BE removed
+
+ // Pass `LogEntry` by reference, and do not store it as its state does not
+ // outlive the call to `LogSink::Send()`.
+ LogEntry(const LogEntry&) = delete;
+ LogEntry& operator=(const LogEntry&) = delete;
+
+ // Source file and line where the log message occurred. Taken from `__FILE__`
+ // and `__LINE__` unless overridden by `LOG(...).AtLocation(...)`.
+ //
+ // Take special care not to use the values returned by `source_filename()` and
+ // `source_basename()` after the lifetime of the entry. This is always
+ // incorrect, but it will often work in practice because they usually point
+ // into a statically allocated character array obtained from `__FILE__`.
+ // Statements like `LOG(INFO).AtLocation(TString(...), ...)` will expose
+ // the bug. If you need the data later, you must copy them.
+ y_absl::string_view source_filename() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return full_filename_;
+ }
+ y_absl::string_view source_basename() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return base_filename_;
+ }
+ int source_line() const { return line_; }
+
+ // LogEntry::prefix()
+ //
+ // True unless the metadata prefix was suppressed once by
+ // `LOG(...).NoPrefix()` or globally by `y_absl::EnableLogPrefix(false)`.
+ // Implies `text_message_with_prefix() == text_message()`.
+ bool prefix() const { return prefix_; }
+
+ // LogEntry::log_severity()
+ //
+ // Returns this entry's severity. For `LOG`, taken from the first argument;
+ // for `CHECK`, always `y_absl::LogSeverity::kFatal`.
+ y_absl::LogSeverity log_severity() const { return severity_; }
+
+ // LogEntry::verbosity()
+ //
+ // Returns this entry's verbosity, or `kNoVerbosityLevel` for a non-verbose
+ // entry. Taken from the argument to `VLOG` or from
+ // `LOG(...).WithVerbosity(...)`.
+ int verbosity() const { return verbose_level_; }
+
+ // LogEntry::timestamp()
+ //
+ // Returns the time at which this entry was written. Captured during
+ // evaluation of `LOG`, but can be overridden by
+ // `LOG(...).WithTimestamp(...)`.
+ //
+ // Take care not to rely on timestamps increasing monotonically, or even to
+ // rely on timestamps having any particular relationship with reality (since
+ // they can be overridden).
+ y_absl::Time timestamp() const { return timestamp_; }
+
+ // LogEntry::tid()
+ //
+ // Returns the ID of the thread that wrote this entry. Captured during
+ // evaluation of `LOG`, but can be overridden by `LOG(...).WithThreadID(...)`.
+ //
+ // Take care not to *rely* on reported thread IDs as they can be overridden as
+ // specified above.
+ tid_t tid() const { return tid_; }
+
+ // Text-formatted version of the log message. An underlying buffer holds
+ // these contiguous data:
+ //
+ // * A prefix formed by formatting metadata (timestamp, filename, line number,
+ // etc.)
+ // The prefix may be empty - see `LogEntry::prefix()` - and may rarely be
+ // truncated if the metadata are very long.
+ // * The streamed data
+ // The data may be empty if nothing was streamed, or may be truncated to fit
+ // the buffer.
+ // * A newline
+ // * A nul terminator
+ //
+ // The newline and nul terminator will be present even if the prefix and/or
+ // data are truncated.
+ //
+ // These methods give access to the most commonly useful substrings of the
+ // buffer's contents. Other combinations can be obtained with substring
+ // arithmetic.
+ //
+ // The buffer does not outlive the entry; if you need the data later, you must
+ // copy them.
+ y_absl::string_view text_message_with_prefix_and_newline() const
+ Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return y_absl::string_view(
+ text_message_with_prefix_and_newline_and_nul_.data(),
+ text_message_with_prefix_and_newline_and_nul_.size() - 1);
+ }
+ y_absl::string_view text_message_with_prefix() const
+ Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return y_absl::string_view(
+ text_message_with_prefix_and_newline_and_nul_.data(),
+ text_message_with_prefix_and_newline_and_nul_.size() - 2);
+ }
+ y_absl::string_view text_message_with_newline() const
+ Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return y_absl::string_view(
+ text_message_with_prefix_and_newline_and_nul_.data() + prefix_len_,
+ text_message_with_prefix_and_newline_and_nul_.size() - prefix_len_ - 1);
+ }
+ y_absl::string_view text_message() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return y_absl::string_view(
+ text_message_with_prefix_and_newline_and_nul_.data() + prefix_len_,
+ text_message_with_prefix_and_newline_and_nul_.size() - prefix_len_ - 2);
+ }
+ const char* text_message_with_prefix_and_newline_c_str() const
+ Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return text_message_with_prefix_and_newline_and_nul_.data();
+ }
+
+ // Returns a serialized protobuf holding the operands streamed into this
+ // log message. The message definition is not yet published.
+ //
+ // The buffer does not outlive the entry; if you need the data later, you must
+ // copy them.
+ y_absl::string_view encoded_message() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return encoding_;
+ }
+
+ // LogEntry::stacktrace()
+ //
+ // Optional stacktrace, e.g. for `FATAL` logs and failed `CHECK`s.
+ //
+ // Fatal entries are dispatched to each sink twice: first with all data and
+ // metadata but no stacktrace, and then with the stacktrace. This is done
+ // because stacktrace collection is sometimes slow and fallible, and it's
+ // critical to log enough information to diagnose the failure even if the
+ // stacktrace collection hangs.
+ //
+ // The buffer does not outlive the entry; if you need the data later, you must
+ // copy them.
+ y_absl::string_view stacktrace() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return stacktrace_;
+ }
+
+ private:
+ LogEntry() = default;
+
+ y_absl::string_view full_filename_;
+ y_absl::string_view base_filename_;
+ int line_;
+ bool prefix_;
+ y_absl::LogSeverity severity_;
+ int verbose_level_; // >=0 for `VLOG`, etc.; otherwise `kNoVerbosityLevel`.
+ y_absl::Time timestamp_;
+ tid_t tid_;
+ y_absl::Span<const char> text_message_with_prefix_and_newline_and_nul_;
+ size_t prefix_len_;
+ y_absl::string_view encoding_;
+ TString stacktrace_;
+
+ friend class log_internal::LogEntryTestPeer;
+ friend class log_internal::LogMessage;
+};
+
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_LOG_LOG_ENTRY_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/log_sink.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/log/log_sink.cc
new file mode 100644
index 00000000000..fd7b8ad80c3
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/log_sink.cc
@@ -0,0 +1,23 @@
+// Copyright 2022 The Abseil Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "y_absl/log/log_sink.h"
+
+#include "y_absl/base/config.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+void LogSink::KeyFunction() const {}
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/log_sink.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/log_sink.h
new file mode 100644
index 00000000000..a99bce3b794
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/log_sink.h
@@ -0,0 +1,71 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: log/log_sink.h
+// -----------------------------------------------------------------------------
+//
+// This header declares the interface class `y_absl::LogSink`.
+
+#ifndef Y_ABSL_LOG_LOG_SINK_H_
+#define Y_ABSL_LOG_LOG_SINK_H_
+
+#include "y_absl/base/config.h"
+#include "y_absl/log/log_entry.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+
+// y_absl::LogSink
+//
+// `y_absl::LogSink` is an interface which can be extended to intercept and
+// process particular messages (with `LOG.ToSinkOnly()` or
+// `LOG.ToSinkAlso()`) or all messages (if registered with
+// `y_absl::AddLogSink`). Implementations must not take any locks that might be
+// held by the `LOG` caller.
+class LogSink {
+ public:
+ virtual ~LogSink() = default;
+
+ // LogSink::Send()
+ //
+ // `Send` is called synchronously during the log statement. `Send` must be
+ // thread-safe.
+ //
+ // It is safe to use `LOG` within an implementation of `Send`. `ToSinkOnly`
+ // and `ToSinkAlso` are safe in general but can be used to create an infinite
+ // loop if you try.
+ virtual void Send(const y_absl::LogEntry& entry) = 0;
+
+ // LogSink::Flush()
+ //
+ // Sinks that buffer messages should override this method to flush the buffer
+ // and return. `Flush` must be thread-safe.
+ virtual void Flush() {}
+
+ protected:
+ LogSink() = default;
+ // Implementations may be copyable and/or movable.
+ LogSink(const LogSink&) = default;
+ LogSink& operator=(const LogSink&) = default;
+
+ private:
+ // https://lld.llvm.org/missingkeyfunction.html#missing-key-function
+ virtual void KeyFunction() const final; // NOLINT(readability/inheritance)
+};
+
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_LOG_LOG_SINK_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/log_sink_registry.h b/contrib/restricted/abseil-cpp-tstring/y_absl/log/log_sink_registry.h
new file mode 100644
index 00000000000..6f8ded05812
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/log_sink_registry.h
@@ -0,0 +1,61 @@
+// Copyright 2022 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// -----------------------------------------------------------------------------
+// File: log/log_sink_registry.h
+// -----------------------------------------------------------------------------
+//
+// This header declares APIs to operate on global set of registered log sinks.
+
+#ifndef Y_ABSL_LOG_LOG_SINK_REGISTRY_H_
+#define Y_ABSL_LOG_LOG_SINK_REGISTRY_H_
+
+#include "y_absl/base/config.h"
+#include "y_absl/log/internal/log_sink_set.h"
+#include "y_absl/log/log_sink.h"
+
+namespace y_absl {
+Y_ABSL_NAMESPACE_BEGIN
+
+// AddLogSink(), RemoveLogSink()
+//
+// Adds or removes a `y_absl::LogSink` as a consumer of logging data.
+//
+// These functions are thread-safe.
+//
+// It is an error to attempt to add a sink that's already registered or to
+// attempt to remove one that isn't.
+//
+// To avoid unbounded recursion, dispatch to registered `y_absl::LogSink`s is
+// disabled per-thread while running the `Send()` method of registered
+// `y_absl::LogSink`s. Affected messages are dispatched to a special internal
+// sink instead which writes them to `stderr`.
+//
+// Do not call these inside `y_absl::LogSink::Send`.
+inline void AddLogSink(y_absl::LogSink* sink) { log_internal::AddLogSink(sink); }
+inline void RemoveLogSink(y_absl::LogSink* sink) {
+ log_internal::RemoveLogSink(sink);
+}
+
+// FlushLogSinks()
+//
+// Calls `y_absl::LogSink::Flush` on all registered sinks.
+//
+// Do not call this inside `y_absl::LogSink::Send`.
+inline void FlushLogSinks() { log_internal::FlushLogSinks(); }
+
+Y_ABSL_NAMESPACE_END
+} // namespace y_absl
+
+#endif // Y_ABSL_LOG_LOG_SINK_REGISTRY_H_
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/log/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/log/ya.make
new file mode 100644
index 00000000000..74000ae8eef
--- /dev/null
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/log/ya.make
@@ -0,0 +1,58 @@
+# Generated by devtools/yamaker.
+
+LIBRARY()
+
+LICENSE(Apache-2.0)
+
+LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
+
+VERSION(20240722.0)
+
+PEERDIR(
+ contrib/restricted/abseil-cpp-tstring/y_absl/base
+ contrib/restricted/abseil-cpp-tstring/y_absl/container
+ contrib/restricted/abseil-cpp-tstring/y_absl/debugging
+ contrib/restricted/abseil-cpp-tstring/y_absl/flags
+ contrib/restricted/abseil-cpp-tstring/y_absl/hash
+ contrib/restricted/abseil-cpp-tstring/y_absl/numeric
+ contrib/restricted/abseil-cpp-tstring/y_absl/profiling
+ contrib/restricted/abseil-cpp-tstring/y_absl/strings
+ contrib/restricted/abseil-cpp-tstring/y_absl/synchronization
+ contrib/restricted/abseil-cpp-tstring/y_absl/time
+ contrib/restricted/abseil-cpp-tstring/y_absl/types
+)
+
+ADDINCL(
+ GLOBAL contrib/restricted/abseil-cpp-tstring
+)
+
+IF (OS_ANDROID)
+ LDFLAGS(-llog)
+ENDIF()
+
+NO_COMPILER_WARNINGS()
+
+IF(Y_ABSL_DONT_USE_DEBUG)
+ CFLAGS(-DY_ABSL_DONT_USE_DEBUG_LIBRARY=1)
+ENDIF()
+
+SRCS(
+ die_if_null.cc
+ flags.cc
+ globals.cc
+ initialize.cc
+ internal/check_op.cc
+ internal/conditions.cc
+ internal/fnmatch.cc
+ internal/globals.cc
+ internal/log_format.cc
+ internal/log_message.cc
+ internal/log_sink_set.cc
+ internal/nullguard.cc
+ internal/proto.cc
+ internal/vlog_config.cc
+ log_entry.cc
+ log_sink.cc
+)
+
+END()
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/status/internal/status_internal.h b/contrib/restricted/abseil-cpp-tstring/y_absl/status/internal/status_internal.h
index 70d0c322d01..228d20154e7 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/status/internal/status_internal.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/status/internal/status_internal.h
@@ -32,16 +32,7 @@
// Disabled for SWIG as it doesn't parse attributes correctly.
namespace y_absl {
Y_ABSL_NAMESPACE_BEGIN
-// Returned Status objects may not be ignored. Codesearch doesn't handle ifdefs
-// as part of a class definitions (b/6995610), so we use a forward declaration.
-//
-// TODO(b/176172494): Y_ABSL_MUST_USE_RESULT should expand to the more strict
-// [[nodiscard]]. For now, just use [[nodiscard]] directly when it is available.
-#if Y_ABSL_HAVE_CPP_ATTRIBUTE(nodiscard)
-class [[nodiscard]] Y_ABSL_ATTRIBUTE_TRIVIAL_ABI Status;
-#else
-class Y_ABSL_MUST_USE_RESULT Y_ABSL_ATTRIBUTE_TRIVIAL_ABI Status;
-#endif
+class Y_ABSL_ATTRIBUTE_TRIVIAL_ABI Status;
Y_ABSL_NAMESPACE_END
} // namespace y_absl
#endif // !SWIG
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/cordz_info.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/cordz_info.cc
index 320a01edd45..200c2bc2fcb 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/cordz_info.cc
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/cordz_info.cc
@@ -307,9 +307,14 @@ CordzInfo::CordzInfo(CordRep* rep, const CordzInfo* src,
MethodIdentifier method, int64_t sampling_stride)
: rep_(rep),
stack_depth_(
+#ifdef Y_ABSL_DONT_USE_DEBUG_LIBRARY
+ 0
+#else
static_cast<size_t>(y_absl::GetStackTrace(stack_,
/*max_depth=*/kMaxStackDepth,
- /*skip_count=*/1))),
+ /*skip_count=*/1))
+#endif
+ ),
parent_stack_depth_(FillParentStack(src, parent_stack_)),
method_(method),
parent_method_(GetParentMethod(src)),
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/bind.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/bind.h
index 39058de4876..efc0d8f3a2a 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/bind.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/bind.h
@@ -172,8 +172,10 @@ class FormatSpecTemplate
template <FormatConversionCharSet... C>
FormatSpecTemplate(const ExtendedParsedFormat<C...>& pc) // NOLINT
: Base(&pc) {
+#ifndef __NVCC__
CheckArity<sizeof...(C), sizeof...(Args)>();
CheckMatches<C...>(y_absl::make_index_sequence<sizeof...(C)>{});
+#endif
}
};
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/checker.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/checker.h
index 2aafe0016a6..61d52d4d5de 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/checker.h
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/checker.h
@@ -30,7 +30,7 @@
// more details.
#if Y_ABSL_HAVE_ATTRIBUTE(enable_if) && !defined(__native_client__) && \
!defined(__INTELLISENSE__)
-#define Y_ABSL_INTERNAL_ENABLE_FORMAT_CHECKER 1
+//#define Y_ABSL_INTERNAL_ENABLE_FORMAT_CHECKER 1
#endif // Y_ABSL_HAVE_ATTRIBUTE(enable_if) && !defined(__native_client__) &&
// !defined(__INTELLISENSE__)
#endif // Y_ABSL_INTERNAL_ENABLE_FORMAT_CHECKER
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/ya.make
index 26ff4370a6f..74d25c05f58 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/ya.make
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/ya.make
@@ -21,6 +21,10 @@ NO_COMPILER_WARNINGS()
SRCDIR(contrib/restricted/abseil-cpp-tstring/y_absl)
+IF(Y_ABSL_DONT_USE_DEBUG)
+ CFLAGS(-DY_ABSL_DONT_USE_DEBUG_LIBRARY=1)
+ENDIF()
+
SRCS(
crc/crc32c.cc
crc/internal/cpu_detect.cc
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/mutex.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/mutex.cc
index 9cccfab498f..8fb7c97e393 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/mutex.cc
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/mutex.cc
@@ -434,9 +434,14 @@ static SynchEvent* GetSynchEvent(const void* addr) {
// if event recording is on
static void PostSynchEvent(void* obj, int ev) {
SynchEvent* e = GetSynchEvent(obj);
+#ifdef Y_ABSL_DONT_USE_DEBUG_LIBRARY
+ constexpr bool DONT_COLLECT_STACK_TRACE = 1;
+#else
+ constexpr bool DONT_COLLECT_STACK_TRACE = 0;
+#endif
// logging is on if event recording is on and either there's no event struct,
// or it explicitly says to log
- if (e == nullptr || e->log) {
+ if ((e == nullptr || e->log) && !DONT_COLLECT_STACK_TRACE) {
void* pcs[40];
int n = y_absl::GetStackTrace(pcs, Y_ABSL_ARRAYSIZE(pcs), 1);
// A buffer with enough space for the ASCII for all the PCs, even on a
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/ya.make
index 6957a5d1816..a4eee05708c 100644
--- a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/ya.make
+++ b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/ya.make
@@ -20,6 +20,10 @@ ADDINCL(
GLOBAL contrib/restricted/abseil-cpp-tstring
)
+IF(Y_ABSL_DONT_USE_DEBUG)
+ CFLAGS(-DY_ABSL_DONT_USE_DEBUG_LIBRARY=1)
+ENDIF()
+
NO_COMPILER_WARNINGS()
SRCS(
diff --git a/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp b/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp
index a307cf60746..c6a633a8114 100644
--- a/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp
+++ b/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp
@@ -4,8 +4,6 @@
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/io/zero_copy_stream.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/strutil.h>
#include "cpp_styleguide.h"
#include <util/stream/output.h>
@@ -494,7 +492,7 @@ namespace NPlugins {
vars["extendee" ] = ClassName(Descriptor_->containing_type(), true);
vars["type_traits" ] = type_traits_;
vars["name" ] = Descriptor_->name();
- vars["field_type" ] = SimpleItoa(static_cast<int>(Descriptor_->type()));
+ vars["field_type" ] = std::to_string(static_cast<int>(Descriptor_->type()));
vars["packed" ] = Descriptor_->options().packed() ? "true" : "false";
printer->Print(vars,
diff --git a/contrib/tools/protoc/ya.make.induced_deps b/contrib/tools/protoc/ya.make.induced_deps
index 3d70a8bf3f2..bc73a807a2d 100644
--- a/contrib/tools/protoc/ya.make.induced_deps
+++ b/contrib/tools/protoc/ya.make.induced_deps
@@ -3,9 +3,6 @@ INDUCED_DEPS(cpp
${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/generated_message_reflection.h
${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/io/coded_stream.h
${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/reflection_ops.h
- ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/stubs/common.h
- ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/stubs/once.h
- ${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/stubs/port.h
${ARCADIA_ROOT}/contrib/libs/protobuf/src/google/protobuf/wire_format.h
)
INDUCED_DEPS(h+cpp