aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/protoc/src/google/protobuf
diff options
context:
space:
mode:
authorAlexander Smirnov <alex@ydb.tech>2024-07-08 15:54:05 +0000
committerAlexander Smirnov <alex@ydb.tech>2024-07-08 15:54:05 +0000
commitfc7be18c76af2e700641f3598c4856baeef1428e (patch)
tree11dbca45eb321c3a4dd08b12152acc6ef5dd3fa9 /contrib/libs/protoc/src/google/protobuf
parentec0e7ed6da6fb317741fd8468602949a1362eca5 (diff)
parentc92cb9d3a19331916f0c274d80e67f02a62caa9b (diff)
downloadydb-fc7be18c76af2e700641f3598c4856baeef1428e.tar.gz
Merge branch 'rightlib' into mergelibs-240708-1553
Diffstat (limited to 'contrib/libs/protoc/src/google/protobuf')
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/code_generator.h4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc20
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h1027
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.cc)6
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum_field.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.cc)75
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum_field.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.h)19
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.cc)6
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/field.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc)58
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/field.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h)39
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/file.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc)83
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/file.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.h)6
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/generator.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.cc)14
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/generator.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.h)0
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/helpers.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc)140
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/helpers.h1065
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/map_field.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.cc)43
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/map_field.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.h)9
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/message.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc)830
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/message.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.h)20
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/message_field.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.cc)80
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/message_field.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.h)13
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/message_layout_helper.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_layout_helper.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/names.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_names.h)10
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/options.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_options.h)5
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/padding_optimizer.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc)4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/padding_optimizer.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/parse_function_generator.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc)64
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/parse_function_generator.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.h)4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/primitive_field.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc)79
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/primitive_field.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.h)19
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/service.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.cc)4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/service.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/string_field.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.cc)98
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/string_field.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.h)14
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum_field.cc2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum_field.h2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_field_base.cc7
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_field_base.h1
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_helpers.cc7
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_helpers.h2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_map_field.h2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message.cc12
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message_field.cc4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message_field.h2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_primitive_field.h2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/context.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.cc)8
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/context.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/doc_comment.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.cc)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/doc_comment.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.h)0
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/enum.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.cc)15
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/enum.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.h)0
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.cc)39
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field_lite.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.cc)37
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field_lite.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/enum_lite.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.cc)10
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/enum_lite.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.h)0
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/extension.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.cc)15
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/extension.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.h)0
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/extension_lite.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.cc)15
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/extension_lite.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/field.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.cc)26
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/field.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.h)0
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/file.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.cc)29
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/file.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/generator.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.cc)14
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/generator.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.h)0
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/generator_factory.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.cc)20
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/generator_factory.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.h)0
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/helpers.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc)36
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/helpers.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/kotlin_generator.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.cc)10
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/kotlin_generator.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.h)0
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/map_field.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.cc)29
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/map_field.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/map_field_lite.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.cc)29
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/map_field_lite.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.cc)65
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.cc)21
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder_lite.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.cc)21
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder_lite.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message_field.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.cc)39
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message_field.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message_field_lite.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.cc)39
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message_field_lite.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message_lite.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.cc)65
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/message_lite.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.h)7
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/name_resolver.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.cc)11
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/name_resolver.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.h)5
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/names.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_names.h)0
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/options.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_options.h)0
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.cc)32
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field_lite.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.cc)32
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field_lite.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/service.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.cc)15
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/service.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.h)0
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/shared_code_generator.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.cc)8
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/shared_code_generator.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/string_field.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.cc)32
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/string_field.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/string_field_lite.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.cc)34
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/string_field_lite.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/js/js_generator.cc3937
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/js/js_generator.h336
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/js/well_known_types_embed.cc270
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/js/well_known_types_embed.h43
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/main.cc22
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc1
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.cc1
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.h10
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.cc136
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.h27
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_generator.cc3
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_map_field.h2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message.cc2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc1
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.h4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h8
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/parser.cc118
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/parser.h6
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/perlxs/perlxs_generator.cc2045
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/perlxs/perlxs_generator.h153
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/perlxs/perlxs_helpers.cc35
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/perlxs/perlxs_helpers.h19
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/php/php_generator.cc129
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc3
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc640
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h522
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/python/generator.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.cc)17
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/python/generator.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.h)2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/python/helpers.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/python/python_helpers.cc)6
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/python/helpers.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/python/python_helpers.h)0
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/python/pyi_generator.cc (renamed from contrib/libs/protoc/src/google/protobuf/compiler/python/python_pyi_generator.cc)216
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/python/pyi_generator.h (renamed from contrib/libs/protoc/src/google/protobuf/compiler/python/python_pyi_generator.h)30
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/ruby/ruby_generator.cc2
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/subprocess.cc14
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.h4
151 files changed, 3911 insertions, 9584 deletions
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 81f0ea748e..2bbd80d650 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.h
@@ -189,9 +189,9 @@ typedef GeneratorContext OutputDirectory;
// Several code generators treat the parameter argument as holding a
// list of options separated by commas. This helper function parses
// a set of comma-delimited name/value pairs: e.g.,
-// "foo=bar,baz,qux=corge"
+// "foo=bar,baz,moo=corge"
// parses to the pairs:
-// ("foo", "bar"), ("baz", ""), ("qux", "corge")
+// ("foo", "bar"), ("baz", ""), ("moo", "corge")
PROTOC_EXPORT void ParseGeneratorParameter(
const TProtoStringType&, std::vector<std::pair<TProtoStringType, TProtoStringType> >*);
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 e1cbfee896..3de6dc2f6d 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
@@ -34,8 +34,6 @@
#include <google/protobuf/compiler/command_line_interface.h>
-#include <cstdint>
-
#include <google/protobuf/stubs/platform_macros.h>
#include <stdio.h>
@@ -70,20 +68,20 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/compiler/subprocess.h>
-#include <google/protobuf/compiler/zip_writer.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/descriptor.h>
-#include <google/protobuf/dynamic_message.h>
#include <google/protobuf/text_format.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/stringprintf.h>
-#include <google/protobuf/stubs/substitute.h>
-#include <google/protobuf/io/io_win32.h>
#include <google/protobuf/stubs/map_util.h>
#include <google/protobuf/stubs/stl_util.h>
@@ -2251,6 +2249,10 @@ bool CommandLineInterface::GenerateDependencyManifestFile(
}
}
+ if (!descriptor_set_out_name_.empty()) {
+ output_filenames.push_back(descriptor_set_out_name_);
+ }
+
int fd;
do {
fd = open(dependency_out_name_.c_str(),
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h
index f7735da12f..fe2ff1369a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h
@@ -1,1026 +1 @@
-// 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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
-#define GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
-
-#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/cpp_names.h>
-#include <google/protobuf/compiler/cpp/cpp_options.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/port.h>
-#include <google/protobuf/stubs/strutil.h>
-
-// Must be included last.
-#include <google/protobuf/port_def.inc>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-enum class ArenaDtorNeeds { kNone = 0, kOnDemand = 1, kRequired = 2 };
-
-inline TProtoStringType ProtobufNamespace(const Options& /* options */) {
- return "PROTOBUF_NAMESPACE_ID";
-}
-
-inline TProtoStringType MacroPrefix(const Options& /* options */) {
- return "GOOGLE_PROTOBUF";
-}
-
-inline TProtoStringType DeprecatedAttribute(const Options& /* options */,
- const FieldDescriptor* d) {
- return d->options().deprecated() ? "PROTOBUF_DEPRECATED " : "";
-}
-
-inline TProtoStringType DeprecatedAttribute(const Options& /* options */,
- const EnumValueDescriptor* d) {
- return d->options().deprecated() ? "PROTOBUF_DEPRECATED_ENUM " : "";
-}
-
-// Commonly-used separator comments. Thick is a line of '=', thin is a line
-// of '-'.
-extern const char kThickSeparator[];
-extern const char kThinSeparator[];
-
-void SetCommonVars(const Options& options,
- std::map<TProtoStringType, TProtoStringType>* variables);
-
-// Variables to access message data from the message scope.
-void SetCommonMessageDataVariables(
- std::map<TProtoStringType, TProtoStringType>* variables);
-
-void SetUnknownFieldsVariable(const Descriptor* descriptor,
- const Options& options,
- std::map<TProtoStringType, TProtoStringType>* variables);
-
-bool GetBootstrapBasename(const Options& options, const TProtoStringType& basename,
- TProtoStringType* bootstrap_basename);
-bool MaybeBootstrap(const Options& options, GeneratorContext* generator_context,
- bool bootstrap_flag, TProtoStringType* basename);
-bool IsBootstrapProto(const Options& options, const FileDescriptor* file);
-
-// Name space of the proto file. This namespace is such that the string
-// "<namespace>::some_name" is the correct fully qualified namespace.
-// This means if the package is empty the namespace is "", and otherwise
-// the namespace is "::foo::bar::...::baz" without trailing semi-colons.
-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);
-
-// Returns true if it's safe to reset "field" to zero.
-bool CanInitializeByZeroing(const FieldDescriptor* field);
-
-TProtoStringType ClassName(const Descriptor* descriptor);
-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);
-
-// DEPRECATED just use ClassName or QualifiedClassName, a boolean is very
-// unreadable at the callsite.
-// Returns the non-nested type name for the given type. If "qualified" is
-// true, prefix the type with the full namespace. For example, if you had:
-// package foo.bar;
-// message Baz { message Qux {} }
-// Then the qualified ClassName for Qux would be:
-// ::foo::bar::Baz_Qux
-// While the non-qualified version would be:
-// Baz_Qux
-inline TProtoStringType ClassName(const Descriptor* descriptor, bool qualified) {
- return qualified ? QualifiedClassName(descriptor, Options())
- : ClassName(descriptor);
-}
-
-inline TProtoStringType ClassName(const EnumDescriptor* descriptor, bool qualified) {
- return qualified ? QualifiedClassName(descriptor, Options())
- : ClassName(descriptor);
-}
-
-// Returns the extension name prefixed with the class name if nested but without
-// the package name.
-TProtoStringType ExtensionName(const FieldDescriptor* d);
-
-TProtoStringType QualifiedExtensionName(const FieldDescriptor* d,
- const Options& options);
-TProtoStringType QualifiedExtensionName(const FieldDescriptor* d);
-
-// Type name of default instance.
-TProtoStringType DefaultInstanceType(const Descriptor* descriptor,
- const Options& options);
-
-// Non-qualified name of the default_instance of this message.
-TProtoStringType DefaultInstanceName(const Descriptor* descriptor,
- const Options& options);
-
-// Non-qualified name of the default instance pointer. This is used only for
-// implicit weak fields, where we need an extra indirection.
-TProtoStringType DefaultInstancePtr(const Descriptor* descriptor,
- const Options& options);
-
-// Fully qualified name of the default_instance of this message.
-TProtoStringType QualifiedDefaultInstanceName(const Descriptor* descriptor,
- const Options& options);
-
-// Fully qualified name of the default instance pointer.
-TProtoStringType QualifiedDefaultInstancePtr(const Descriptor* descriptor,
- const Options& options);
-
-// DescriptorTable variable name.
-TProtoStringType DescriptorTableName(const FileDescriptor* file,
- const Options& options);
-
-// When declaring symbol externs from another file, this macro will supply the
-// dllexport needed for the target file, if any.
-TProtoStringType FileDllExport(const FileDescriptor* file, const Options& options);
-
-// Name of the base class: google::protobuf::Message or google::protobuf::MessageLite.
-TProtoStringType SuperClassName(const Descriptor* descriptor,
- const Options& options);
-
-// Adds an underscore if necessary to prevent conflicting with a keyword.
-TProtoStringType ResolveKeyword(const TProtoStringType& 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);
-
-// Returns the (unqualified) private member name for this field in C++ code.
-TProtoStringType FieldMemberName(const FieldDescriptor* field);
-
-// Returns an estimate of the compiler's alignment for the field. This
-// can't guarantee to be correct because the generated code could be compiled on
-// different systems with different alignment rules. The estimates below assume
-// 64-bit pointers.
-int EstimateAlignmentSize(const FieldDescriptor* field);
-
-// Get the unqualified name that should be used for a field's field
-// number constant.
-TProtoStringType FieldConstantName(const FieldDescriptor* field);
-
-// Returns the scope where the field was defined (for extensions, this is
-// different from the message type to which the field applies).
-inline const Descriptor* FieldScope(const FieldDescriptor* field) {
- return field->is_extension() ? field->extension_scope()
- : field->containing_type();
-}
-
-// Returns the fully-qualified type name field->message_type(). Usually this
-// is just ClassName(field->message_type(), true);
-TProtoStringType FieldMessageTypeName(const FieldDescriptor* field,
- const Options& options);
-
-// Get the C++ type name for a primitive type (e.g. "double", "::google::protobuf::int32", etc.).
-const char* PrimitiveTypeName(FieldDescriptor::CppType type);
-TProtoStringType PrimitiveTypeName(const Options& options,
- FieldDescriptor::CppType type);
-
-// Get the declared type name in CamelCase format, as is used e.g. for the
-// methods of WireFormat. For example, TYPE_INT32 becomes "Int32".
-const char* DeclaredTypeMethodName(FieldDescriptor::Type type);
-
-// Return the code that evaluates to the number when compiled.
-TProtoStringType Int32ToString(int number);
-
-// Get code that evaluates to the field's default value.
-TProtoStringType DefaultValue(const Options& options, const FieldDescriptor* field);
-
-// Compatibility function for callers outside proto2.
-TProtoStringType DefaultValue(const FieldDescriptor* field);
-
-// Convert a file name into a valid identifier.
-TProtoStringType FilenameIdentifier(const TProtoStringType& 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,
- const Options& options);
-inline TProtoStringType UniqueName(const TProtoStringType& name, const FileDescriptor* d,
- const Options& options) {
- return UniqueName(name, d->name(), options);
-}
-inline TProtoStringType UniqueName(const TProtoStringType& name, const Descriptor* d,
- const Options& options) {
- return UniqueName(name, d->file(), options);
-}
-inline TProtoStringType UniqueName(const TProtoStringType& name, const EnumDescriptor* d,
- const Options& options) {
- return UniqueName(name, d->file(), options);
-}
-inline TProtoStringType UniqueName(const TProtoStringType& name,
- const ServiceDescriptor* d,
- const Options& options) {
- return UniqueName(name, d->file(), options);
-}
-
-// Versions for call sites that only support the internal runtime (like proto1
-// support).
-inline Options InternalRuntimeOptions() {
- Options options;
- options.opensource_runtime = false;
- return options;
-}
-inline TProtoStringType UniqueName(const TProtoStringType& name,
- const TProtoStringType& filename) {
- return UniqueName(name, filename, InternalRuntimeOptions());
-}
-inline TProtoStringType UniqueName(const TProtoStringType& name,
- const FileDescriptor* d) {
- return UniqueName(name, d->name(), InternalRuntimeOptions());
-}
-inline TProtoStringType UniqueName(const TProtoStringType& name, const Descriptor* d) {
- return UniqueName(name, d->file(), InternalRuntimeOptions());
-}
-inline TProtoStringType UniqueName(const TProtoStringType& name,
- const EnumDescriptor* d) {
- return UniqueName(name, d->file(), InternalRuntimeOptions());
-}
-inline TProtoStringType UniqueName(const TProtoStringType& 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,
- const Options& options);
-
-// Escape C++ trigraphs by escaping question marks to \?
-TProtoStringType EscapeTrigraphs(const TProtoStringType& to_escape);
-
-// Escaped function name to eliminate naming conflict.
-TProtoStringType SafeFunctionName(const Descriptor* descriptor,
- const FieldDescriptor* field,
- const TProtoStringType& prefix);
-
-// Returns true if generated messages have public unknown fields accessors
-inline bool PublicUnknownFieldsAccessors(const Descriptor* message) {
- return message->file()->syntax() != FileDescriptor::SYNTAX_PROTO3;
-}
-
-// Returns the optimize mode for <file>, respecting <options.enforce_lite>.
-FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file,
- const Options& options);
-
-// Determines whether unknown fields will be stored in an UnknownFieldSet or
-// a string.
-inline bool UseUnknownFieldSet(const FileDescriptor* file,
- const Options& options) {
- return GetOptimizeFor(file, options) != FileOptions::LITE_RUNTIME;
-}
-
-inline bool IsWeak(const FieldDescriptor* field, const Options& options) {
- if (field->options().weak()) {
- GOOGLE_CHECK(!options.opensource_runtime);
- return true;
- }
- return false;
-}
-
-bool IsStringInlined(const FieldDescriptor* descriptor, const Options& options);
-
-// For a string field, returns the effective ctype. If the actual ctype is
-// not supported, returns the default of STRING.
-FieldOptions::CType EffectiveStringCType(const FieldDescriptor* field,
- const Options& options);
-
-inline bool IsCord(const FieldDescriptor* field, const Options& options) {
- return field->cpp_type() == FieldDescriptor::CPPTYPE_STRING &&
- EffectiveStringCType(field, options) == FieldOptions::CORD;
-}
-
-inline bool IsString(const FieldDescriptor* field, const Options& options) {
- return field->cpp_type() == FieldDescriptor::CPPTYPE_STRING &&
- EffectiveStringCType(field, options) == FieldOptions::STRING;
-}
-
-inline bool IsStringPiece(const FieldDescriptor* field,
- const Options& options) {
- return field->cpp_type() == FieldDescriptor::CPPTYPE_STRING &&
- 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);
-
-// Is the given field a supported lazy field?
-bool IsLazy(const FieldDescriptor* field, const Options& options,
- MessageSCCAnalyzer* scc_analyzer);
-
-// Is this an explicit (non-profile driven) lazy field, as denoted by
-// lazy/unverified_lazy in the descriptor?
-inline bool IsExplicitLazy(const FieldDescriptor* field) {
- return field->options().lazy() || field->options().unverified_lazy();
-}
-
-inline bool IsLazilyVerifiedLazy(const FieldDescriptor* field,
- const Options& options) {
- // TODO(b/211906113): Make lazy() imply eagerly verified lazy.
- return IsExplicitLazy(field) && !field->is_repeated() &&
- field->type() == FieldDescriptor::TYPE_MESSAGE &&
- GetOptimizeFor(field->file(), options) != FileOptions::LITE_RUNTIME &&
- !options.opensource_runtime;
-}
-
-inline bool IsEagerlyVerifiedLazy(const FieldDescriptor* field,
- const Options& options,
- MessageSCCAnalyzer* scc_analyzer) {
- // TODO(b/211906113): Make lazy() imply eagerly verified lazy.
- return IsLazy(field, options, scc_analyzer) && !IsExplicitLazy(field);
-}
-
-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);
-
-// Does the file have any repeated fields, necessitating the file to include
-// repeated_field.h? This does not include repeated extensions, since those are
-// all stored internally in an ExtensionSet, not a separate RepeatedField*.
-bool HasRepeatedFields(const FileDescriptor* file);
-
-// Does the file have any string/bytes fields with ctype=STRING_PIECE? This
-// does not include extensions, since ctype is ignored for extensions.
-bool HasStringPieceFields(const FileDescriptor* file, const Options& options);
-
-// Does the file have any string/bytes fields with ctype=CORD? This does not
-// include extensions, since ctype is ignored for extensions.
-bool HasCordFields(const FileDescriptor* file, const Options& options);
-
-// Does the file have any map fields, necessitating the file to include
-// map_field_inl.h and map.h.
-bool HasMapFields(const FileDescriptor* file);
-
-// Does this file have any enum type definitions?
-bool HasEnumDefinitions(const FileDescriptor* file);
-
-// Does this file have generated parsing, serialization, and other
-// standard methods for which reflection-based fallback implementations exist?
-inline bool HasGeneratedMethods(const FileDescriptor* file,
- const Options& options) {
- return GetOptimizeFor(file, options) != FileOptions::CODE_SIZE;
-}
-
-// Do message classes in this file have descriptor and reflection methods?
-inline bool HasDescriptorMethods(const FileDescriptor* file,
- const Options& options) {
- return GetOptimizeFor(file, options) != FileOptions::LITE_RUNTIME;
-}
-
-// Should we generate generic services for this file?
-inline bool HasGenericServices(const FileDescriptor* file,
- const Options& options) {
- return file->service_count() > 0 &&
- GetOptimizeFor(file, options) != FileOptions::LITE_RUNTIME &&
- file->options().cc_generic_services();
-}
-
-inline bool IsProto2MessageSet(const Descriptor* descriptor,
- const Options& options) {
- return !options.opensource_runtime &&
- options.enforce_mode != EnforceOptimizeMode::kLiteRuntime &&
- !options.lite_implicit_weak_fields &&
- descriptor->options().message_set_wire_format() &&
- descriptor->full_name() == "google.protobuf.bridge.MessageSet";
-}
-
-inline bool IsMapEntryMessage(const Descriptor* descriptor) {
- return descriptor->options().map_entry();
-}
-
-// Returns true if the field's CPPTYPE is string or message.
-bool IsStringOrMessage(const FieldDescriptor* field);
-
-TProtoStringType UnderscoresToCamelCase(const TProtoStringType& 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 "_i_give_permission_to_break_this_code_default_" + FieldName(field) +
- "_";
-}
-
-// Semantically distinct from MakeDefaultName in that it gives the C++ code
-// referencing a default field from the message scope, rather than just the
-// variable name.
-// For example, declarations of default variables should always use just
-// MakeDefaultName to produce code like:
-// Type _i_give_permission_to_break_this_code_default_field_;
-//
-// Code that references these should use MakeDefaultFieldName, in case the field
-// exists at some nested level like:
-// internal_container_._i_give_permission_to_break_this_code_default_field_;
-inline TProtoStringType MakeDefaultFieldName(const FieldDescriptor* field) {
- return MakeDefaultName(field);
-}
-
-inline TProtoStringType MakeVarintCachedSizeName(const FieldDescriptor* field) {
- return StrCat("_", FieldName(field), "_cached_byte_size_");
-}
-
-// Semantically distinct from MakeVarintCachedSizeName in that it gives the C++
-// code referencing the object from the message scope, rather than just the
-// variable name.
-// For example, declarations of default variables should always use just
-// MakeVarintCachedSizeName to produce code like:
-// Type _field_cached_byte_size_;
-//
-// Code that references these variables should use
-// MakeVarintCachedSizeFieldName, in case the field exists at some nested level
-// like:
-// internal_container_._field_cached_byte_size_;
-inline TProtoStringType MakeVarintCachedSizeFieldName(const FieldDescriptor* field) {
- return StrCat("_", FieldName(field), "_cached_byte_size_");
-}
-
-// Note: A lot of libraries detect Any protos based on Descriptor::full_name()
-// while the two functions below use FileDescriptor::name(). In a sane world the
-// two approaches should be equivalent. But if you are dealing with descriptors
-// from untrusted sources, you might need to match semantics across libraries.
-bool IsAnyMessage(const FileDescriptor* descriptor, const Options& options);
-bool IsAnyMessage(const Descriptor* descriptor, const Options& options);
-
-bool IsWellKnownMessage(const FileDescriptor* descriptor);
-
-inline TProtoStringType IncludeGuard(const FileDescriptor* file, bool pb_h,
- bool deps,
- 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" : ""));
-
- 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;
- } else {
- // Ideally this case would use distinct include guards for opensource and
- // google3 protos also. (The behavior of "first #included wins" is not
- // ideal). But unfortunately some legacy code includes both and depends on
- // 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;
- }
-}
-
-// Returns the OptimizeMode for this file, furthermore it updates a status
-// bool if has_opt_codesize_extension is non-null. If this status bool is true
-// it means this file contains an extension that itself is defined as
-// optimized_for = CODE_SIZE.
-FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file,
- const Options& options,
- bool* has_opt_codesize_extension);
-inline FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file,
- const Options& options) {
- return GetOptimizeFor(file, options, nullptr);
-}
-inline bool NeedsEagerDescriptorAssignment(const FileDescriptor* file,
- const Options& options) {
- bool has_opt_codesize_extension;
- if (GetOptimizeFor(file, options, &has_opt_codesize_extension) ==
- FileOptions::CODE_SIZE &&
- has_opt_codesize_extension) {
- // If this filedescriptor contains an extension from another file which
- // is optimized_for = CODE_SIZE. We need to be careful in the ordering so
- // we eagerly build the descriptors in the dependencies before building
- // the descriptors of this file.
- return true;
- } else {
- // If we have a generated code based parser we never need eager
- // initialization of descriptors of our deps.
- return false;
- }
-}
-
-// This orders the messages in a .pb.cc as it's outputted by file.cc
-void FlattenMessagesInFile(const FileDescriptor* file,
- std::vector<const Descriptor*>* result);
-inline std::vector<const Descriptor*> FlattenMessagesInFile(
- const FileDescriptor* file) {
- std::vector<const Descriptor*> result;
- FlattenMessagesInFile(file, &result);
- return result;
-}
-
-template <typename F>
-void ForEachMessage(const Descriptor* descriptor, F&& func) {
- for (int i = 0; i < descriptor->nested_type_count(); i++)
- ForEachMessage(descriptor->nested_type(i), std::forward<F&&>(func));
- func(descriptor);
-}
-
-template <typename F>
-void ForEachMessage(const FileDescriptor* descriptor, F&& func) {
- for (int i = 0; i < descriptor->message_type_count(); i++)
- ForEachMessage(descriptor->message_type(i), std::forward<F&&>(func));
-}
-
-bool HasWeakFields(const Descriptor* desc, const Options& options);
-bool HasWeakFields(const FileDescriptor* desc, const Options& options);
-
-// Returns true if the "required" restriction check should be ignored for the
-// given field.
-inline static bool ShouldIgnoreRequiredFieldCheck(const FieldDescriptor* field,
- const Options& options) {
- // Do not check "required" for lazily verified lazy fields.
- return IsLazilyVerifiedLazy(field, options);
-}
-
-struct MessageAnalysis {
- bool is_recursive = false;
- bool contains_cord = false;
- bool contains_extension = false;
- bool contains_required = false;
- bool contains_weak = false; // Implicit weak as well.
-};
-
-// This class is used in FileGenerator, to ensure linear instead of
-// quadratic performance, if we do this per message we would get O(V*(V+E)).
-// Logically this is just only used in message.cc, but in the header for
-// FileGenerator to help share it.
-class PROTOC_EXPORT MessageSCCAnalyzer {
- public:
- explicit MessageSCCAnalyzer(const Options& options) : options_(options) {}
-
- MessageAnalysis GetSCCAnalysis(const SCC* scc);
-
- bool HasRequiredFields(const Descriptor* descriptor) {
- MessageAnalysis result = GetSCCAnalysis(GetSCC(descriptor));
- return result.contains_required || result.contains_extension;
- }
- bool HasWeakField(const Descriptor* descriptor) {
- MessageAnalysis result = GetSCCAnalysis(GetSCC(descriptor));
- return result.contains_weak;
- }
- const SCC* GetSCC(const Descriptor* descriptor) {
- return analyzer_.GetSCC(descriptor);
- }
-
- private:
- struct DepsGenerator {
- std::vector<const Descriptor*> operator()(const Descriptor* desc) const {
- std::vector<const Descriptor*> deps;
- for (int i = 0; i < desc->field_count(); i++) {
- if (desc->field(i)->message_type()) {
- deps.push_back(desc->field(i)->message_type());
- }
- }
- return deps;
- }
- };
- SCCAnalyzer<DepsGenerator> analyzer_;
- Options options_;
- std::map<const SCC*, MessageAnalysis> analysis_cache_;
-};
-
-void ListAllFields(const Descriptor* d,
- std::vector<const FieldDescriptor*>* fields);
-void ListAllFields(const FileDescriptor* d,
- std::vector<const FieldDescriptor*>* fields);
-
-template <class T>
-void ForEachField(const Descriptor* d, T&& func) {
- for (int i = 0; i < d->nested_type_count(); i++) {
- ForEachField(d->nested_type(i), std::forward<T&&>(func));
- }
- for (int i = 0; i < d->extension_count(); i++) {
- func(d->extension(i));
- }
- for (int i = 0; i < d->field_count(); i++) {
- func(d->field(i));
- }
-}
-
-template <class T>
-void ForEachField(const FileDescriptor* d, T&& func) {
- for (int i = 0; i < d->message_type_count(); i++) {
- ForEachField(d->message_type(i), std::forward<T&&>(func));
- }
- for (int i = 0; i < d->extension_count(); i++) {
- func(d->extension(i));
- }
-}
-
-void ListAllTypesForServices(const FileDescriptor* fd,
- std::vector<const Descriptor*>* types);
-
-// Indicates whether we should use implicit weak fields for this file.
-bool UsingImplicitWeakFields(const FileDescriptor* file,
- const Options& options);
-
-// Indicates whether to treat this field as implicitly weak.
-bool IsImplicitWeakField(const FieldDescriptor* field, const Options& options,
- MessageSCCAnalyzer* scc_analyzer);
-
-inline bool HasSimpleBaseClass(const Descriptor* desc, const Options& options) {
- if (!HasDescriptorMethods(desc->file(), options)) return false;
- if (desc->extension_range_count() != 0) return false;
- if (desc->field_count() == 0) return true;
- // TODO(jorg): Support additional common message types with only one
- // or two fields
- return false;
-}
-
-inline bool HasSimpleBaseClasses(const FileDescriptor* file,
- const Options& options) {
- bool v = false;
- ForEachMessage(file, [&v, &options](const Descriptor* desc) {
- v |= HasSimpleBaseClass(desc, options);
- });
- return v;
-}
-
-inline TProtoStringType SimpleBaseClass(const Descriptor* desc,
- const Options& options) {
- if (!HasDescriptorMethods(desc->file(), options)) return "";
- if (desc->extension_range_count() != 0) return "";
- if (desc->field_count() == 0) {
- return "ZeroFieldsBase";
- }
- // TODO(jorg): Support additional common message types with only one
- // or two fields
- return "";
-}
-
-// 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
-// the format string $1$, $2$, etc... are substituted for the first, second, ...
-// direct argument respectively in the format call, it accepts both strings and
-// integers. The implementation verifies all arguments are used and are "first"
-// used in order of appearance in the argument list. For example,
-//
-// Format("return array[$1$];", 3) -> "return array[3];"
-// Format("array[$2$] = $1$;", "Bla", 3) -> FATAL error (wrong order)
-// Format("array[$1$] = $2$;", 3, "Bla") -> "array[3] = Bla;"
-//
-// The arguments can be used more than once like
-//
-// Format("array[$1$] = $2$; // Index = $1$", 3, "Bla") ->
-// "array[3] = Bla; // Index = 3"
-//
-// If you use more arguments use the following style to help the reader,
-//
-// Format("int $1$() {\n"
-// " array[$2$] = $3$;\n"
-// " return $4$;"
-// "}\n",
-// funname, // 1
-// idx, // 2
-// varname, // 3
-// retval); // 4
-//
-// but consider using named variables. Named variables like $foo$, with some
-// identifier foo, are looked up in the map. One additional feature is that
-// spaces are accepted between the '$' delimiters, $ foo$ will
-// substiture to " bar" if foo stands for "bar", but in case it's empty
-// will substitute to "". Hence, for example,
-//
-// Format(vars, "$dllexport $void fun();") -> "void fun();"
-// "__declspec(export) void fun();"
-//
-// which is convenient to prevent double, leading or trailing spaces.
-class PROTOC_EXPORT Formatter {
- public:
- explicit Formatter(io::Printer* printer) : printer_(printer) {}
- Formatter(io::Printer* printer,
- const std::map<TProtoStringType, TProtoStringType>& vars)
- : printer_(printer), vars_(vars) {}
-
- template <typename T>
- void Set(const TProtoStringType& key, const T& value) {
- vars_[key] = ToString(value);
- }
-
- void AddMap(const std::map<TProtoStringType, TProtoStringType>& vars) {
- for (const auto& keyval : vars) vars_[keyval.first] = keyval.second;
- }
-
- template <typename... Args>
- void operator()(const char* format, const Args&... args) const {
- printer_->FormatInternal({ToString(args)...}, vars_, format);
- }
-
- void Indent() const { printer_->Indent(); }
- void Outdent() const { printer_->Outdent(); }
- io::Printer* printer() const { return printer_; }
-
- class PROTOC_EXPORT ScopedIndenter {
- public:
- explicit ScopedIndenter(Formatter* format) : format_(format) {
- format_->Indent();
- }
- ~ScopedIndenter() { format_->Outdent(); }
-
- private:
- Formatter* format_;
- };
-
- PROTOBUF_NODISCARD ScopedIndenter ScopedIndent() {
- return ScopedIndenter(this);
- }
- template <typename... Args>
- PROTOBUF_NODISCARD ScopedIndenter ScopedIndent(const char* format,
- const Args&&... args) {
- (*this)(format, static_cast<Args&&>(args)...);
- return ScopedIndenter(this);
- }
-
- class PROTOC_EXPORT SaveState {
- public:
- explicit SaveState(Formatter* format)
- : format_(format), vars_(format->vars_) {}
- ~SaveState() { format_->vars_.swap(vars_); }
-
- private:
- Formatter* format_;
- std::map<TProtoStringType, TProtoStringType> vars_;
- };
-
- private:
- io::Printer* printer_;
- std::map<TProtoStringType, TProtoStringType> vars_;
-
- // Convenience overloads to accept different types as arguments.
- static TProtoStringType ToString(const TProtoStringType& s) { return s; }
- template <typename I, typename = typename std::enable_if<
- std::is_integral<I>::value>::type>
- static TProtoStringType ToString(I x) {
- return StrCat(x);
- }
- 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);
- }
- static TProtoStringType ToString(const OneofDescriptor* d) { return Payload(d); }
-
- template <typename Descriptor>
- static TProtoStringType Payload(const Descriptor* descriptor) {
- std::vector<int> path;
- descriptor->GetLocationPath(&path);
- GeneratedCodeInfo::Annotation annotation;
- for (int index : path) {
- annotation.add_path(index);
- }
- annotation.set_source_file(descriptor->file()->name());
- return annotation.SerializeAsString();
- }
-};
-
-template <class T>
-void PrintFieldComment(const Formatter& format, 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')));
-}
-
-class PROTOC_EXPORT NamespaceOpener {
- public:
- explicit NamespaceOpener(const Formatter& format)
- : printer_(format.printer()) {}
- NamespaceOpener(const TProtoStringType& name, const Formatter& format)
- : NamespaceOpener(format) {
- 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]);
- }
- }
- }
-
- private:
- io::Printer* printer_;
- 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,
- const Formatter& format);
-
-void GenerateUtf8CheckCodeForCord(const FieldDescriptor* field,
- const Options& options, bool for_parse,
- const char* 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;
-};
-
-template <typename T>
-FieldRangeImpl<T> FieldRange(const T* desc) {
- return {desc};
-}
-
-struct OneOfRangeImpl {
- struct Iterator {
- using iterator_category = std::forward_iterator_tag;
- using value_type = const OneofDescriptor*;
- using difference_type = int;
-
- value_type operator*() { return descriptor->oneof_decl(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 Descriptor* descriptor;
- };
-
- Iterator begin() const { return {0, descriptor}; }
- Iterator end() const {
- return {descriptor->real_oneof_decl_count(), descriptor};
- }
-
- const Descriptor* descriptor;
-};
-
-inline OneOfRangeImpl OneOfRange(const Descriptor* desc) { return {desc}; }
-
-PROTOC_EXPORT TProtoStringType StripProto(const TProtoStringType& filename);
-
-bool EnableMessageOwnedArena(const Descriptor* desc, const Options& options);
-
-bool ShouldVerify(const Descriptor* descriptor, const Options& options,
- MessageSCCAnalyzer* scc_analyzer);
-bool ShouldVerify(const FileDescriptor* file, const Options& options,
- MessageSCCAnalyzer* scc_analyzer);
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#endif // GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
+#include "helpers.h" \ No newline at end of file
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum.cc
index 960dfcadf7..91d0b9442b 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/cpp/cpp_enum.h>
+#include <google/protobuf/compiler/cpp/enum.h>
#include <cstdint>
#include <limits>
@@ -40,8 +40,8 @@
#include <google/protobuf/io/printer.h>
#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
-#include <google/protobuf/compiler/cpp/cpp_names.h>
+#include <google/protobuf/compiler/cpp/helpers.h>
+#include <google/protobuf/compiler/cpp/names.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum.h
index 652a26b6db..550f43b1ed 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum.h
@@ -40,7 +40,7 @@
#include <string>
#include <google/protobuf/descriptor.h>
-#include <google/protobuf/compiler/cpp/cpp_options.h>
+#include <google/protobuf/compiler/cpp/options.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum_field.cc
index f50fca4926..dc8dc52481 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum_field.cc
@@ -32,12 +32,13 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/cpp/cpp_enum_field.h>
+#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/cpp_helpers.h>
+#include <google/protobuf/compiler/cpp/field.h>
+#include <google/protobuf/compiler/cpp/helpers.h>
namespace google {
namespace protobuf {
@@ -55,8 +56,9 @@ void SetEnumVariables(const FieldDescriptor* descriptor,
(*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);
+ MakeVarintCachedSizeFieldName(descriptor, cold);
}
} // namespace
@@ -110,6 +112,7 @@ void EnumFieldGenerator::GenerateInlineAccessorDefinitions(
" $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"
@@ -123,7 +126,7 @@ void EnumFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
void EnumFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
- format("_internal_set_$name$(from._internal_$name$());\n");
+ format("_this->_internal_set_$name$(from._internal_$name$());\n");
}
void EnumFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
@@ -131,15 +134,10 @@ void EnumFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
format("swap($field$, other->$field$);\n");
}
-void EnumFieldGenerator::GenerateConstructorCode(io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("$field$ = $default$;\n");
-}
-
void EnumFieldGenerator::GenerateCopyConstructorCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$field$ = from.$field$;\n");
+ format("_this->$field$ = from.$field$;\n");
}
void EnumFieldGenerator::GenerateSerializeWithCachedSizesToArray(
@@ -158,10 +156,26 @@ void EnumFieldGenerator::GenerateByteSize(io::Printer* printer) const {
" ::_pbi::WireFormatLite::EnumSize(this->_internal_$name$());\n");
}
-void EnumFieldGenerator::GenerateConstinitInitializer(
+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_);
- format("$name$_($default$)\n");
+ 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$){}");
}
// ===================================================================
@@ -322,7 +336,7 @@ void RepeatedEnumFieldGenerator::GenerateClearingCode(
void RepeatedEnumFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$field$.MergeFrom(from.$field$);\n");
+ format("_this->$field$.MergeFrom(from.$field$);\n");
}
void RepeatedEnumFieldGenerator::GenerateSwappingCode(
@@ -336,6 +350,12 @@ void RepeatedEnumFieldGenerator::GenerateConstructorCode(
// 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_);
@@ -392,13 +412,36 @@ void RepeatedEnumFieldGenerator::GenerateByteSize(io::Printer* printer) const {
format("}\n");
}
-void RepeatedEnumFieldGenerator::GenerateConstinitInitializer(
+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("$name$_()");
+ format("decltype($field$){from.$field$}");
if (descriptor_->is_packed() &&
HasGeneratedMethods(descriptor_->file(), options_)) {
- format("\n, $cached_byte_size_name$(0)");
+ // std::atomic has no copy constructor.
+ format("\n, /*decltype($cached_byte_size_field$)*/{0}");
}
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum_field.h
index 2a4ca5162b..61bae855cd 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/enum_field.h
@@ -38,7 +38,7 @@
#include <map>
#include <string>
-#include <google/protobuf/compiler/cpp/cpp_field.h>
+#include <google/protobuf/compiler/cpp/field.h>
namespace google {
namespace protobuf {
@@ -57,12 +57,15 @@ class EnumFieldGenerator : public FieldGenerator {
void GenerateClearingCode(io::Printer* printer) const override;
void GenerateMergingCode(io::Printer* printer) const override;
void GenerateSwappingCode(io::Printer* printer) const override;
- void GenerateConstructorCode(io::Printer* printer) const override;
+ void 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 GenerateConstinitInitializer(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);
@@ -98,11 +101,17 @@ class RepeatedEnumFieldGenerator : public FieldGenerator {
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 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 GenerateConstinitInitializer(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);
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.cc
index ef6cc81241..ed85f75960 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.cc
@@ -32,13 +32,13 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/cpp/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/cpp_helpers.h>
+#include <google/protobuf/compiler/cpp/helpers.h>
#include <google/protobuf/descriptor.pb.h>
namespace google {
@@ -78,7 +78,7 @@ ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor,
break;
}
SetCommonVars(options, &variables_);
- SetCommonMessageDataVariables(&variables_);
+ SetCommonMessageDataVariables(descriptor_->containing_type(), &variables_);
variables_["extendee"] =
QualifiedClassName(descriptor_->containing_type(), options_);
variables_["type_traits"] = type_traits_;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.h
index 5a32e84554..b94b178868 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.h
@@ -39,7 +39,7 @@
#include <string>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/compiler/cpp/cpp_options.h>
+#include <google/protobuf/compiler/cpp/options.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field.cc
index 895f094c70..d5359b6d24 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/cpp/cpp_field.h>
+#include <google/protobuf/compiler/cpp/field.h>
#include <cstdint>
#include <memory>
@@ -40,16 +40,16 @@
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
-#include <google/protobuf/compiler/cpp/cpp_primitive_field.h>
-#include <google/protobuf/compiler/cpp/cpp_string_field.h>
+#include <google/protobuf/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/cpp_enum_field.h>
-#include <google/protobuf/compiler/cpp/cpp_map_field.h>
-#include <google/protobuf/compiler/cpp/cpp_message_field.h>
+#include <google/protobuf/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>
namespace google {
@@ -236,7 +236,7 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
std::map<TProtoStringType, TProtoStringType>* variables,
const Options& options) {
SetCommonVars(options, variables);
- SetCommonMessageDataVariables(variables);
+ SetCommonMessageDataVariables(descriptor->containing_type(), variables);
(*variables)["ns"] = Namespace(descriptor, options);
(*variables)["name"] = FieldName(descriptor);
@@ -244,7 +244,8 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
(*variables)["number"] = StrCat(descriptor->number());
(*variables)["classname"] = ClassName(FieldScope(descriptor), false);
(*variables)["declared_type"] = DeclaredTypeMethodName(descriptor->type());
- (*variables)["field"] = FieldMemberName(descriptor);
+ bool split = ShouldSplit(descriptor, options);
+ (*variables)["field"] = FieldMemberName(descriptor, split);
(*variables)["tag_size"] = StrCat(
WireFormat::TagSize(descriptor->number(), descriptor->type()));
@@ -252,13 +253,8 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
(*variables)["set_hasbit"] = "";
(*variables)["clear_hasbit"] = "";
- if (HasHasbit(descriptor)) {
- (*variables)["set_hasbit_io"] =
- StrCat("_Internal::set_has_", FieldName(descriptor), "(&",
- (*variables)["has_bits"], ");");
- } else {
- (*variables)["set_hasbit_io"] = "";
- }
+ (*variables)["maybe_prepare_split_message"] =
+ split ? " PrepareSplitMessageForWrite();\n" : "";
AddAccessorAnnotations(descriptor, options, variables);
@@ -304,6 +300,36 @@ void FieldGenerator::SetInlinedStringIndex(arc_i32 inlined_string_index) {
"u");
}
+void FieldGenerator::GenerateAggregateInitializer(io::Printer* printer) const {
+ Formatter format(printer, variables_);
+ if (ShouldSplit(descriptor_, options_)) {
+ format("decltype(Impl_::Split::$name$_){arena}");
+ return;
+ }
+ format("decltype($field$){arena}");
+}
+
+void FieldGenerator::GenerateConstexprAggregateInitializer(
+ io::Printer* printer) const {
+ Formatter format(printer, variables_);
+ format("/*decltype($field$)*/{}");
+}
+
+void FieldGenerator::GenerateCopyAggregateInitializer(
+ io::Printer* printer) const {
+ Formatter format(printer, variables_);
+ format("decltype($field$){from.$field$}");
+}
+
+void FieldGenerator::GenerateCopyConstructorCode(io::Printer* printer) 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_);
+ format("$field$ = from.$field$;\n");
+ }
+}
+
void SetCommonOneofFieldVariables(
const FieldDescriptor* descriptor,
std::map<TProtoStringType, TProtoStringType>* variables) {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field.h
index 9c3ec7fde4..95eb96f499 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/field.h
@@ -41,8 +41,8 @@
#include <string>
#include <google/protobuf/descriptor.h>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
-#include <google/protobuf/compiler/cpp/cpp_options.h>
+#include <google/protobuf/compiler/cpp/helpers.h>
+#include <google/protobuf/compiler/cpp/options.h>
namespace google {
namespace protobuf {
@@ -136,7 +136,7 @@ class FieldGenerator {
virtual void GenerateMergingCode(io::Printer* printer) const = 0;
// Generates a copy constructor
- virtual void GenerateCopyConstructorCode(io::Printer* printer) const = 0;
+ virtual void GenerateCopyConstructorCode(io::Printer* printer) const;
// Generate lines of code (statements, not declarations) which swaps
// this field and the corresponding field of another message, which
@@ -150,6 +150,9 @@ class FieldGenerator {
// method, invoked by each of the generated constructors.
virtual void GenerateConstructorCode(io::Printer* printer) const = 0;
+ // Generate initialization code for private members in the cold struct.
+ virtual void GenerateCreateSplitMessageCode(io::Printer* printer) const {}
+
// Generate 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.
@@ -165,10 +168,32 @@ class FieldGenerator {
}
// Generate initialization code for private members declared by
- // GeneratePrivateMembers(), specifically for the constexpr constructor.
- // These go into the constructor's initializer list and must follow that
- // syntax (eg `field_(args)`). Does not include `:` or `,` separators.
- virtual void GenerateConstinitInitializer(io::Printer* printer) const {}
+ // 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.
+ //
+ // 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
+ // 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()
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/file.cc
index f27d876e2a..2d79ec11e5 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/file.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/cpp/cpp_file.h>
+#include <google/protobuf/compiler/cpp/file.h>
#include <iostream>
#include <map>
@@ -46,12 +46,12 @@
#include <google/protobuf/compiler/scc.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/cpp/cpp_enum.h>
-#include <google/protobuf/compiler/cpp/cpp_extension.h>
-#include <google/protobuf/compiler/cpp/cpp_field.h>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
-#include <google/protobuf/compiler/cpp/cpp_message.h>
-#include <google/protobuf/compiler/cpp/cpp_service.h>
+#include <google/protobuf/compiler/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>
// Must be last.
@@ -496,10 +496,40 @@ void FileGenerator::GenerateSourceDefaultInstance(int idx,
io::Printer* printer) {
Formatter format(printer, variables_);
MessageGenerator* generator = message_generators_[idx].get();
+ // Generate the split instance first because it's needed in the constexpr
+ // constructor.
+ 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);
- // 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"
@@ -511,14 +541,11 @@ void FileGenerator::GenerateSourceDefaultInstance(int idx,
"};\n",
DefaultInstanceType(generator->descriptor_, options_),
generator->classname_);
- // 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_),
- DefaultInstanceName(generator->descriptor_, options_));
+ 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);
@@ -526,11 +553,11 @@ void FileGenerator::GenerateSourceDefaultInstance(int idx,
// Force the initialization of the inlined string in the default instance.
format(
"PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 std::true_type "
- "$1$::_init_inline_$2$_ = "
+ "$1$::Impl_::_init_inline_$2$_ = "
"($3$._instance.$4$.Init(), std::true_type{});\n",
ClassName(generator->descriptor_), FieldName(field),
DefaultInstanceName(generator->descriptor_, options_),
- FieldMemberName(field));
+ FieldMemberName(field, ShouldSplit(field, options_)));
}
}
@@ -963,6 +990,7 @@ 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_) {
@@ -983,6 +1011,14 @@ class FileGenerator::ForwardDeclarations {
class_desc, classname, DefaultInstanceType(class_desc, options),
DefaultInstanceName(class_desc, options));
}
+ 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));
+ }
}
void PrintTopLevelDecl(const Formatter& format,
@@ -998,6 +1034,7 @@ class FileGenerator::ForwardDeclarations {
private:
std::map<TProtoStringType, const Descriptor*> classes_;
std::map<TProtoStringType, const EnumDescriptor*> enums_;
+ std::map<TProtoStringType, const Descriptor*> splits_;
};
static void PublicImportDFS(const FileDescriptor* fd,
@@ -1071,6 +1108,12 @@ void FileGenerator::GenerateForwardDeclarations(io::Printer* printer) {
if (d && !public_set.count(d->file()))
decls[Namespace(d, options_)].AddEnum(d);
}
+ for (const auto& mg : message_generators_) {
+ 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);
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/file.h
index d8eff2feed..805b4979bf 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/file.h
@@ -42,10 +42,10 @@
#include <vector>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/compiler/cpp/cpp_field.h>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
+#include <google/protobuf/compiler/cpp/field.h>
+#include <google/protobuf/compiler/cpp/helpers.h>
#include <google/protobuf/compiler/scc.h>
-#include <google/protobuf/compiler/cpp/cpp_options.h>
+#include <google/protobuf/compiler/cpp/options.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/generator.cc
index 69443f5bf2..0da2027a1e 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/generator.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/cpp/cpp_generator.h>
+#include <google/protobuf/compiler/cpp/generator.h>
#include <memory>
#include <string>
@@ -42,8 +42,8 @@
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/io/zero_copy_stream.h>
-#include <google/protobuf/compiler/cpp/cpp_file.h>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
+#include <google/protobuf/compiler/cpp/file.h>
+#include <google/protobuf/compiler/cpp/helpers.h>
#include <google/protobuf/descriptor.pb.h>
namespace google {
@@ -135,12 +135,12 @@ bool CppGenerator::Generate(const FileDescriptor* file,
.insert(options[i].second.substr(pos, next_pos - pos));
pos = next_pos + 1;
} while (pos < options[i].second.size());
- } else if (options[i].first == "verified_lazy_message_sets") {
- file_options.unverified_lazy_message_sets = false;
+ } else if (options[i].first == "verified_lazy") {
+ file_options.unverified_lazy = false;
} else if (options[i].first == "unverified_lazy_message_sets") {
file_options.unverified_lazy_message_sets = true;
- } else if (options[i].first == "eagerly_verified_lazy") {
- file_options.eagerly_verified_lazy = true;
+ } else if (options[i].first == "message_owned_arena_trial") {
+ file_options.message_owned_arena_trial = true;
} else if (options[i].first == "force_eagerly_verified_lazy") {
file_options.force_eagerly_verified_lazy = true;
} else if (options[i].first == "experimental_tail_call_table_mode") {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/generator.h
index aa63845d30..aa63845d30 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/generator.h
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/helpers.cc
index f726d0fc9b..48879f29d5 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/helpers.cc
@@ -32,12 +32,13 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
+#include <google/protobuf/compiler/cpp/helpers.h>
#include <cstdint>
#include <functional>
#include <limits>
#include <map>
+#include <memory>
#include <queue>
#include <unordered_set>
#include <vector>
@@ -45,8 +46,8 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/descriptor.h>
-#include <google/protobuf/compiler/cpp/cpp_names.h>
-#include <google/protobuf/compiler/cpp/cpp_options.h>
+#include <google/protobuf/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>
@@ -182,18 +183,53 @@ void SetIntVar(const Options& options, const TProtoStringType& type,
std::map<TProtoStringType, TProtoStringType>* variables) {
(*variables)[type] = IntTypeName(options, type);
}
-bool IsEagerlyVerifiedLazyImpl(const FieldDescriptor* field,
- const Options& options,
- MessageSCCAnalyzer* scc_analyzer) {
+
+// 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;
}
+// 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
bool IsLazy(const FieldDescriptor* field, const Options& options,
MessageSCCAnalyzer* scc_analyzer) {
return IsLazilyVerifiedLazy(field, options) ||
- IsEagerlyVerifiedLazyImpl(field, options, scc_analyzer);
+ IsEagerlyVerifiedLazy(field, options, scc_analyzer);
+}
+
+// Returns true if "field" is a message field that is backed by LazyField per
+// profile (go/pdlazy).
+inline bool IsEagerlyVerifiedLazyByProfile(const FieldDescriptor* field,
+ const Options& options,
+ MessageSCCAnalyzer* scc_analyzer) {
+ return false;
+}
+
+bool IsEagerlyVerifiedLazy(const FieldDescriptor* field, const Options& options,
+ MessageSCCAnalyzer* scc_analyzer) {
+ return false;
+}
+
+bool IsLazilyVerifiedLazy(const FieldDescriptor* field,
+ const Options& options) {
+ return false;
}
void SetCommonVars(const Options& options,
@@ -234,15 +270,20 @@ void SetCommonVars(const Options& options,
}
void SetCommonMessageDataVariables(
+ const Descriptor* descriptor,
std::map<TProtoStringType, TProtoStringType>* variables) {
- (*variables)["any_metadata"] = "_any_metadata_";
- (*variables)["cached_size"] = "_cached_size_";
- (*variables)["extensions"] = "_extensions_";
- (*variables)["has_bits"] = "_has_bits_";
- (*variables)["inlined_string_donated_array"] = "_inlined_string_donated_";
- (*variables)["oneof_case"] = "_oneof_case_";
- (*variables)["tracker"] = "_tracker_";
- (*variables)["weak_field_map"] = "_weak_field_map_";
+ 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,
@@ -407,29 +448,32 @@ TProtoStringType Namespace(const EnumDescriptor* d, const Options& options) {
}
TProtoStringType DefaultInstanceType(const Descriptor* descriptor,
- const Options& options) {
- return ClassName(descriptor) + "DefaultTypeInternal";
+ const Options& /*options*/, bool split) {
+ return ClassName(descriptor) + (split ? "__Impl_Split" : "") +
+ "DefaultTypeInternal";
}
TProtoStringType DefaultInstanceName(const Descriptor* descriptor,
- const Options& options) {
- return "_" + ClassName(descriptor, false) + "_default_instance_";
+ const Options& /*options*/, bool split) {
+ return "_" + ClassName(descriptor, false) + (split ? "__Impl_Split" : "") +
+ "_default_instance_";
}
TProtoStringType DefaultInstancePtr(const Descriptor* descriptor,
- const Options& options) {
- return DefaultInstanceName(descriptor, options) + "ptr_";
+ const Options& options, bool split) {
+ return DefaultInstanceName(descriptor, options, split) + "ptr_";
}
TProtoStringType QualifiedDefaultInstanceName(const Descriptor* descriptor,
- const Options& options) {
+ const Options& options, bool split) {
return QualifiedFileLevelSymbol(
- descriptor->file(), DefaultInstanceName(descriptor, options), options);
+ descriptor->file(), DefaultInstanceName(descriptor, options, split),
+ options);
}
TProtoStringType QualifiedDefaultInstancePtr(const Descriptor* descriptor,
- const Options& options) {
- return QualifiedDefaultInstanceName(descriptor, options) + "ptr_";
+ const Options& options, bool split) {
+ return QualifiedDefaultInstanceName(descriptor, options, split) + "ptr_";
}
TProtoStringType DescriptorTableName(const FileDescriptor* file,
@@ -469,12 +513,17 @@ TProtoStringType FieldName(const FieldDescriptor* field) {
return result;
}
-TProtoStringType FieldMemberName(const FieldDescriptor* field) {
+TProtoStringType FieldMemberName(const FieldDescriptor* field, bool split) {
+ StringPiece prefix =
+ IsMapEntryMessage(field->containing_type()) ? "" : "_impl_.";
+ StringPiece split_prefix = split ? "_split_->" : "";
if (field->real_containing_oneof() == nullptr) {
- return StrCat(FieldName(field), "_");
+ return StrCat(prefix, split_prefix, FieldName(field), "_");
}
- return StrCat(field->containing_oneof()->name(), "_.", FieldName(field),
- "_");
+ // Oneof fields are never split.
+ GOOGLE_CHECK(!split);
+ return StrCat(prefix, field->containing_oneof()->name(), "_.",
+ FieldName(field), "_");
}
TProtoStringType OneofCaseConstantName(const FieldDescriptor* field) {
@@ -855,6 +904,9 @@ bool HasLazyFields(const FileDescriptor* file, const Options& options,
return false;
}
+bool ShouldSplit(const Descriptor*, const Options&) { return false; }
+bool ShouldSplit(const FieldDescriptor*, const 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) {
@@ -991,6 +1043,16 @@ bool ShouldVerify(const FileDescriptor* file, const Options& options,
return false;
}
+bool IsUtf8String(const FieldDescriptor* field) {
+ return IsProto3(field->file()) &&
+ field->type() == FieldDescriptor::TYPE_STRING;
+}
+
+VerifySimpleType ShouldVerifySimple(const Descriptor* descriptor) {
+ (void)descriptor;
+ return VerifySimpleType::kCustom;
+}
+
bool IsStringOrMessage(const FieldDescriptor* field) {
switch (field->cpp_type()) {
case FieldDescriptor::CPPTYPE_INT32:
@@ -1509,12 +1571,32 @@ FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file,
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)) {
+ if (f->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) return true;
+ }
+ return false;
+}
+
} // 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
new file mode 100644
index 0000000000..690a577591
--- /dev/null
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/helpers.h
@@ -0,0 +1,1065 @@
+// 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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
+#define GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
+
+#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>
+
+// Must be included last.
+#include <google/protobuf/port_def.inc>
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
+enum class ArenaDtorNeeds { kNone = 0, kOnDemand = 1, kRequired = 2 };
+
+inline TProtoStringType ProtobufNamespace(const Options& /* options */) {
+ return "PROTOBUF_NAMESPACE_ID";
+}
+
+inline TProtoStringType MacroPrefix(const Options& /* options */) {
+ return "GOOGLE_PROTOBUF";
+}
+
+inline TProtoStringType DeprecatedAttribute(const Options& /* options */,
+ const FieldDescriptor* d) {
+ return d->options().deprecated() ? "PROTOBUF_DEPRECATED " : "";
+}
+
+inline TProtoStringType DeprecatedAttribute(const Options& /* options */,
+ const EnumValueDescriptor* d) {
+ return d->options().deprecated() ? "PROTOBUF_DEPRECATED_ENUM " : "";
+}
+
+// Commonly-used separator comments. Thick is a line of '=', thin is a line
+// of '-'.
+extern const char kThickSeparator[];
+extern const char kThinSeparator[];
+
+void SetCommonVars(const Options& options,
+ std::map<TProtoStringType, TProtoStringType>* variables);
+
+// Variables to access message data from the message scope.
+void SetCommonMessageDataVariables(
+ const Descriptor* descriptor,
+ std::map<TProtoStringType, TProtoStringType>* variables);
+
+void SetUnknownFieldsVariable(const Descriptor* descriptor,
+ const Options& options,
+ std::map<TProtoStringType, TProtoStringType>* variables);
+
+bool GetBootstrapBasename(const Options& options, const TProtoStringType& basename,
+ TProtoStringType* bootstrap_basename);
+bool MaybeBootstrap(const Options& options, GeneratorContext* generator_context,
+ bool bootstrap_flag, TProtoStringType* basename);
+bool IsBootstrapProto(const Options& options, const FileDescriptor* file);
+
+// Name space of the proto file. This namespace is such that the string
+// "<namespace>::some_name" is the correct fully qualified namespace.
+// This means if the package is empty the namespace is "", and otherwise
+// the namespace is "::foo::bar::...::baz" without trailing semi-colons.
+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);
+
+// Returns true if it's safe to reset "field" to zero.
+bool CanInitializeByZeroing(const FieldDescriptor* field);
+
+TProtoStringType ClassName(const Descriptor* descriptor);
+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);
+
+// DEPRECATED just use ClassName or QualifiedClassName, a boolean is very
+// unreadable at the callsite.
+// Returns the non-nested type name for the given type. If "qualified" is
+// true, prefix the type with the full namespace. For example, if you had:
+// package foo.bar;
+// message Baz { message Moo {} }
+// Then the qualified ClassName for Moo would be:
+// ::foo::bar::Baz_Moo
+// While the non-qualified version would be:
+// Baz_Moo
+inline TProtoStringType ClassName(const Descriptor* descriptor, bool qualified) {
+ return qualified ? QualifiedClassName(descriptor, Options())
+ : ClassName(descriptor);
+}
+
+inline TProtoStringType ClassName(const EnumDescriptor* descriptor, bool qualified) {
+ return qualified ? QualifiedClassName(descriptor, Options())
+ : ClassName(descriptor);
+}
+
+// Returns the extension name prefixed with the class name if nested but without
+// the package name.
+TProtoStringType ExtensionName(const FieldDescriptor* d);
+
+TProtoStringType QualifiedExtensionName(const FieldDescriptor* d,
+ const Options& options);
+TProtoStringType QualifiedExtensionName(const FieldDescriptor* d);
+
+// Type name of default instance.
+TProtoStringType DefaultInstanceType(const Descriptor* descriptor,
+ const Options& options, bool split = false);
+
+// Non-qualified name of the default_instance of this message.
+TProtoStringType DefaultInstanceName(const Descriptor* descriptor,
+ const Options& options, bool split = false);
+
+// Non-qualified name of the default instance pointer. This is used only for
+// implicit weak fields, where we need an extra indirection.
+TProtoStringType DefaultInstancePtr(const Descriptor* descriptor,
+ const Options& options, bool split = false);
+
+// Fully qualified name of the default_instance of this message.
+TProtoStringType QualifiedDefaultInstanceName(const Descriptor* descriptor,
+ const Options& options,
+ bool split = false);
+
+// Fully qualified name of the default instance pointer.
+TProtoStringType QualifiedDefaultInstancePtr(const Descriptor* descriptor,
+ const Options& options,
+ bool split = false);
+
+// DescriptorTable variable name.
+TProtoStringType DescriptorTableName(const FileDescriptor* file,
+ const Options& options);
+
+// When declaring symbol externs from another file, this macro will supply the
+// dllexport needed for the target file, if any.
+TProtoStringType FileDllExport(const FileDescriptor* file, const Options& options);
+
+// Name of the base class: google::protobuf::Message or google::protobuf::MessageLite.
+TProtoStringType SuperClassName(const Descriptor* descriptor,
+ const Options& options);
+
+// Adds an underscore if necessary to prevent conflicting with a keyword.
+TProtoStringType ResolveKeyword(const TProtoStringType& 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);
+
+// Returns the (unqualified) private member name for this field in C++ code.
+TProtoStringType FieldMemberName(const FieldDescriptor* field, bool split);
+
+// Returns an estimate of the compiler's alignment for the field. This
+// can't guarantee to be correct because the generated code could be compiled on
+// different systems with different alignment rules. The estimates below assume
+// 64-bit pointers.
+int EstimateAlignmentSize(const FieldDescriptor* field);
+
+// Get the unqualified name that should be used for a field's field
+// number constant.
+TProtoStringType FieldConstantName(const FieldDescriptor* field);
+
+// Returns the scope where the field was defined (for extensions, this is
+// different from the message type to which the field applies).
+inline const Descriptor* FieldScope(const FieldDescriptor* field) {
+ return field->is_extension() ? field->extension_scope()
+ : field->containing_type();
+}
+
+// Returns the fully-qualified type name field->message_type(). Usually this
+// is just ClassName(field->message_type(), true);
+TProtoStringType FieldMessageTypeName(const FieldDescriptor* field,
+ const Options& options);
+
+// Get the C++ type name for a primitive type (e.g. "double", "::google::protobuf::int32", etc.).
+const char* PrimitiveTypeName(FieldDescriptor::CppType type);
+TProtoStringType PrimitiveTypeName(const Options& options,
+ FieldDescriptor::CppType type);
+
+// Get the declared type name in CamelCase format, as is used e.g. for the
+// methods of WireFormat. For example, TYPE_INT32 becomes "Int32".
+const char* DeclaredTypeMethodName(FieldDescriptor::Type type);
+
+// Return the code that evaluates to the number when compiled.
+TProtoStringType Int32ToString(int number);
+
+// Get code that evaluates to the field's default value.
+TProtoStringType DefaultValue(const Options& options, const FieldDescriptor* field);
+
+// Compatibility function for callers outside proto2.
+TProtoStringType DefaultValue(const FieldDescriptor* field);
+
+// Convert a file name into a valid identifier.
+TProtoStringType FilenameIdentifier(const TProtoStringType& 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,
+ const Options& options);
+inline TProtoStringType UniqueName(const TProtoStringType& name, const FileDescriptor* d,
+ const Options& options) {
+ return UniqueName(name, d->name(), options);
+}
+inline TProtoStringType UniqueName(const TProtoStringType& name, const Descriptor* d,
+ const Options& options) {
+ return UniqueName(name, d->file(), options);
+}
+inline TProtoStringType UniqueName(const TProtoStringType& name, const EnumDescriptor* d,
+ const Options& options) {
+ return UniqueName(name, d->file(), options);
+}
+inline TProtoStringType UniqueName(const TProtoStringType& name,
+ const ServiceDescriptor* d,
+ const Options& options) {
+ return UniqueName(name, d->file(), options);
+}
+
+// Versions for call sites that only support the internal runtime (like proto1
+// support).
+inline Options InternalRuntimeOptions() {
+ Options options;
+ options.opensource_runtime = false;
+ return options;
+}
+inline TProtoStringType UniqueName(const TProtoStringType& name,
+ const TProtoStringType& filename) {
+ return UniqueName(name, filename, InternalRuntimeOptions());
+}
+inline TProtoStringType UniqueName(const TProtoStringType& name,
+ const FileDescriptor* d) {
+ return UniqueName(name, d->name(), InternalRuntimeOptions());
+}
+inline TProtoStringType UniqueName(const TProtoStringType& name, const Descriptor* d) {
+ return UniqueName(name, d->file(), InternalRuntimeOptions());
+}
+inline TProtoStringType UniqueName(const TProtoStringType& name,
+ const EnumDescriptor* d) {
+ return UniqueName(name, d->file(), InternalRuntimeOptions());
+}
+inline TProtoStringType UniqueName(const TProtoStringType& 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,
+ const Options& options);
+
+// Escape C++ trigraphs by escaping question marks to \?
+TProtoStringType EscapeTrigraphs(const TProtoStringType& to_escape);
+
+// Escaped function name to eliminate naming conflict.
+TProtoStringType SafeFunctionName(const Descriptor* descriptor,
+ const FieldDescriptor* field,
+ const TProtoStringType& prefix);
+
+// Returns true if generated messages have public unknown fields accessors
+inline bool PublicUnknownFieldsAccessors(const Descriptor* message) {
+ return message->file()->syntax() != FileDescriptor::SYNTAX_PROTO3;
+}
+
+// Returns the optimize mode for <file>, respecting <options.enforce_lite>.
+FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file,
+ const Options& options);
+
+// Determines whether unknown fields will be stored in an UnknownFieldSet or
+// a string.
+inline bool UseUnknownFieldSet(const FileDescriptor* file,
+ const Options& options) {
+ return GetOptimizeFor(file, options) != FileOptions::LITE_RUNTIME;
+}
+
+inline bool IsWeak(const FieldDescriptor* field, const Options& options) {
+ if (field->options().weak()) {
+ GOOGLE_CHECK(!options.opensource_runtime);
+ return true;
+ }
+ return false;
+}
+
+bool IsStringInlined(const FieldDescriptor* descriptor, const Options& options);
+
+// For a string field, returns the effective ctype. If the actual ctype is
+// not supported, returns the default of STRING.
+FieldOptions::CType EffectiveStringCType(const FieldDescriptor* field,
+ const Options& options);
+
+inline bool IsCord(const FieldDescriptor* field, const Options& options) {
+ return field->cpp_type() == FieldDescriptor::CPPTYPE_STRING &&
+ EffectiveStringCType(field, options) == FieldOptions::CORD;
+}
+
+inline bool IsString(const FieldDescriptor* field, const Options& options) {
+ return field->cpp_type() == FieldDescriptor::CPPTYPE_STRING &&
+ EffectiveStringCType(field, options) == FieldOptions::STRING;
+}
+
+inline bool IsStringPiece(const FieldDescriptor* field,
+ const Options& options) {
+ return field->cpp_type() == FieldDescriptor::CPPTYPE_STRING &&
+ 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);
+
+// Is the given field a supported lazy field?
+bool IsLazy(const FieldDescriptor* field, const Options& options,
+ MessageSCCAnalyzer* scc_analyzer);
+
+// Is this an explicit (non-profile driven) lazy field, as denoted by
+// lazy/unverified_lazy in the descriptor?
+inline bool IsExplicitLazy(const FieldDescriptor* field) {
+ return field->options().lazy() || field->options().unverified_lazy();
+}
+
+bool IsEagerlyVerifiedLazy(const FieldDescriptor* field, const Options& options,
+ MessageSCCAnalyzer* scc_analyzer);
+
+bool IsLazilyVerifiedLazy(const FieldDescriptor* field, const Options& options);
+
+// Is the given message being split (go/pdsplit)?
+bool ShouldSplit(const Descriptor* desc, const Options& options);
+
+// Is the given field being split out?
+bool ShouldSplit(const FieldDescriptor* field, 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);
+
+// Does the file have any repeated fields, necessitating the file to include
+// repeated_field.h? This does not include repeated extensions, since those are
+// all stored internally in an ExtensionSet, not a separate RepeatedField*.
+bool HasRepeatedFields(const FileDescriptor* file);
+
+// Does the file have any string/bytes fields with ctype=STRING_PIECE? This
+// does not include extensions, since ctype is ignored for extensions.
+bool HasStringPieceFields(const FileDescriptor* file, const Options& options);
+
+// Does the file have any string/bytes fields with ctype=CORD? This does not
+// include extensions, since ctype is ignored for extensions.
+bool HasCordFields(const FileDescriptor* file, const Options& options);
+
+// Does the file have any map fields, necessitating the file to include
+// map_field_inl.h and map.h.
+bool HasMapFields(const FileDescriptor* file);
+
+// Does this file have any enum type definitions?
+bool HasEnumDefinitions(const FileDescriptor* file);
+
+// Does this file have generated parsing, serialization, and other
+// standard methods for which reflection-based fallback implementations exist?
+inline bool HasGeneratedMethods(const FileDescriptor* file,
+ const Options& options) {
+ return GetOptimizeFor(file, options) != FileOptions::CODE_SIZE;
+}
+
+// Do message classes in this file have descriptor and reflection methods?
+inline bool HasDescriptorMethods(const FileDescriptor* file,
+ const Options& options) {
+ return GetOptimizeFor(file, options) != FileOptions::LITE_RUNTIME;
+}
+
+// Should we generate generic services for this file?
+inline bool HasGenericServices(const FileDescriptor* file,
+ const Options& options) {
+ return file->service_count() > 0 &&
+ GetOptimizeFor(file, options) != FileOptions::LITE_RUNTIME &&
+ file->options().cc_generic_services();
+}
+
+inline bool IsProto2MessageSet(const Descriptor* descriptor,
+ const Options& options) {
+ return !options.opensource_runtime &&
+ options.enforce_mode != EnforceOptimizeMode::kLiteRuntime &&
+ !options.lite_implicit_weak_fields &&
+ descriptor->options().message_set_wire_format() &&
+ descriptor->full_name() == "google.protobuf.bridge.MessageSet";
+}
+
+inline bool IsMapEntryMessage(const Descriptor* descriptor) {
+ return descriptor->options().map_entry();
+}
+
+// Returns true if the field's CPPTYPE is string or message.
+bool IsStringOrMessage(const FieldDescriptor* field);
+
+TProtoStringType UnderscoresToCamelCase(const TProtoStringType& 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_",
+ FieldName(field), "_");
+}
+
+// Semantically distinct from MakeDefaultName in that it gives the C++ code
+// referencing a default field from the message scope, rather than just the
+// variable name.
+// For example, declarations of default variables should always use just
+// MakeDefaultName to produce code like:
+// Type _i_give_permission_to_break_this_code_default_field_;
+//
+// Code that references these should use MakeDefaultFieldName, in case the field
+// exists at some nested level like:
+// internal_container_._i_give_permission_to_break_this_code_default_field_;
+inline TProtoStringType MakeDefaultFieldName(const FieldDescriptor* field) {
+ return StrCat("Impl_::", MakeDefaultName(field));
+}
+
+inline TProtoStringType MakeVarintCachedSizeName(const FieldDescriptor* field) {
+ return StrCat("_", FieldName(field), "_cached_byte_size_");
+}
+
+// Semantically distinct from MakeVarintCachedSizeName in that it gives the C++
+// code referencing the object from the message scope, rather than just the
+// variable name.
+// For example, declarations of default variables should always use just
+// MakeVarintCachedSizeName to produce code like:
+// Type _field_cached_byte_size_;
+//
+// Code that references these variables should use
+// MakeVarintCachedSizeFieldName, in case the field exists at some nested level
+// like:
+// internal_container_._field_cached_byte_size_;
+inline TProtoStringType MakeVarintCachedSizeFieldName(const FieldDescriptor* field,
+ bool split) {
+ return StrCat("_impl_.", split ? "_split_->" : "", "_",
+ FieldName(field), "_cached_byte_size_");
+}
+
+// Note: A lot of libraries detect Any protos based on Descriptor::full_name()
+// while the two functions below use FileDescriptor::name(). In a sane world the
+// two approaches should be equivalent. But if you are dealing with descriptors
+// from untrusted sources, you might need to match semantics across libraries.
+bool IsAnyMessage(const FileDescriptor* descriptor, const Options& options);
+bool IsAnyMessage(const Descriptor* descriptor, const Options& options);
+
+bool IsWellKnownMessage(const FileDescriptor* descriptor);
+
+inline TProtoStringType IncludeGuard(const FileDescriptor* file, bool pb_h,
+ bool deps,
+ 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" : ""));
+
+ 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;
+ } else {
+ // Ideally this case would use distinct include guards for opensource and
+ // google3 protos also. (The behavior of "first #included wins" is not
+ // ideal). But unfortunately some legacy code includes both and depends on
+ // 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;
+ }
+}
+
+// Returns the OptimizeMode for this file, furthermore it updates a status
+// bool if has_opt_codesize_extension is non-null. If this status bool is true
+// it means this file contains an extension that itself is defined as
+// optimized_for = CODE_SIZE.
+FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file,
+ const Options& options,
+ bool* has_opt_codesize_extension);
+inline FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file,
+ const Options& options) {
+ return GetOptimizeFor(file, options, nullptr);
+}
+inline bool NeedsEagerDescriptorAssignment(const FileDescriptor* file,
+ const Options& options) {
+ bool has_opt_codesize_extension;
+ if (GetOptimizeFor(file, options, &has_opt_codesize_extension) ==
+ FileOptions::CODE_SIZE &&
+ has_opt_codesize_extension) {
+ // If this filedescriptor contains an extension from another file which
+ // is optimized_for = CODE_SIZE. We need to be careful in the ordering so
+ // we eagerly build the descriptors in the dependencies before building
+ // the descriptors of this file.
+ return true;
+ } else {
+ // If we have a generated code based parser we never need eager
+ // initialization of descriptors of our deps.
+ return false;
+ }
+}
+
+// This orders the messages in a .pb.cc as it's outputted by file.cc
+void FlattenMessagesInFile(const FileDescriptor* file,
+ std::vector<const Descriptor*>* result);
+inline std::vector<const Descriptor*> FlattenMessagesInFile(
+ const FileDescriptor* file) {
+ std::vector<const Descriptor*> result;
+ FlattenMessagesInFile(file, &result);
+ return result;
+}
+
+template <typename F>
+void ForEachMessage(const Descriptor* descriptor, F&& func) {
+ for (int i = 0; i < descriptor->nested_type_count(); i++)
+ ForEachMessage(descriptor->nested_type(i), std::forward<F&&>(func));
+ func(descriptor);
+}
+
+template <typename F>
+void ForEachMessage(const FileDescriptor* descriptor, F&& func) {
+ for (int i = 0; i < descriptor->message_type_count(); i++)
+ ForEachMessage(descriptor->message_type(i), std::forward<F&&>(func));
+}
+
+bool HasWeakFields(const Descriptor* desc, const Options& options);
+bool HasWeakFields(const FileDescriptor* desc, const Options& options);
+
+// Returns true if the "required" restriction check should be ignored for the
+// given field.
+inline static bool ShouldIgnoreRequiredFieldCheck(const FieldDescriptor* field,
+ const Options& options) {
+ // Do not check "required" for lazily verified lazy fields.
+ return IsLazilyVerifiedLazy(field, options);
+}
+
+struct MessageAnalysis {
+ bool is_recursive = false;
+ bool contains_cord = false;
+ bool contains_extension = false;
+ bool contains_required = false;
+ bool contains_weak = false; // Implicit weak as well.
+};
+
+// This class is used in FileGenerator, to ensure linear instead of
+// quadratic performance, if we do this per message we would get O(V*(V+E)).
+// Logically this is just only used in message.cc, but in the header for
+// FileGenerator to help share it.
+class PROTOC_EXPORT MessageSCCAnalyzer {
+ public:
+ explicit MessageSCCAnalyzer(const Options& options) : options_(options) {}
+
+ MessageAnalysis GetSCCAnalysis(const SCC* scc);
+
+ bool HasRequiredFields(const Descriptor* descriptor) {
+ MessageAnalysis result = GetSCCAnalysis(GetSCC(descriptor));
+ return result.contains_required || result.contains_extension;
+ }
+ bool HasWeakField(const Descriptor* descriptor) {
+ MessageAnalysis result = GetSCCAnalysis(GetSCC(descriptor));
+ return result.contains_weak;
+ }
+ const SCC* GetSCC(const Descriptor* descriptor) {
+ return analyzer_.GetSCC(descriptor);
+ }
+
+ private:
+ struct DepsGenerator {
+ std::vector<const Descriptor*> operator()(const Descriptor* desc) const {
+ std::vector<const Descriptor*> deps;
+ for (int i = 0; i < desc->field_count(); i++) {
+ if (desc->field(i)->message_type()) {
+ deps.push_back(desc->field(i)->message_type());
+ }
+ }
+ return deps;
+ }
+ };
+ SCCAnalyzer<DepsGenerator> analyzer_;
+ Options options_;
+ std::map<const SCC*, MessageAnalysis> analysis_cache_;
+};
+
+void ListAllFields(const Descriptor* d,
+ std::vector<const FieldDescriptor*>* fields);
+void ListAllFields(const FileDescriptor* d,
+ std::vector<const FieldDescriptor*>* fields);
+
+template <class T>
+void ForEachField(const Descriptor* d, T&& func) {
+ for (int i = 0; i < d->nested_type_count(); i++) {
+ ForEachField(d->nested_type(i), std::forward<T&&>(func));
+ }
+ for (int i = 0; i < d->extension_count(); i++) {
+ func(d->extension(i));
+ }
+ for (int i = 0; i < d->field_count(); i++) {
+ func(d->field(i));
+ }
+}
+
+template <class T>
+void ForEachField(const FileDescriptor* d, T&& func) {
+ for (int i = 0; i < d->message_type_count(); i++) {
+ ForEachField(d->message_type(i), std::forward<T&&>(func));
+ }
+ for (int i = 0; i < d->extension_count(); i++) {
+ func(d->extension(i));
+ }
+}
+
+void ListAllTypesForServices(const FileDescriptor* fd,
+ std::vector<const Descriptor*>* types);
+
+// Indicates whether we should use implicit weak fields for this file.
+bool UsingImplicitWeakFields(const FileDescriptor* file,
+ const Options& options);
+
+// Indicates whether to treat this field as implicitly weak.
+bool IsImplicitWeakField(const FieldDescriptor* field, const Options& options,
+ MessageSCCAnalyzer* scc_analyzer);
+
+inline bool HasSimpleBaseClass(const Descriptor* desc, const Options& options) {
+ if (!HasDescriptorMethods(desc->file(), options)) return false;
+ if (desc->extension_range_count() != 0) return false;
+ if (desc->field_count() == 0) return true;
+ // TODO(jorg): Support additional common message types with only one
+ // or two fields
+ return false;
+}
+
+inline bool HasSimpleBaseClasses(const FileDescriptor* file,
+ const Options& options) {
+ bool v = false;
+ ForEachMessage(file, [&v, &options](const Descriptor* desc) {
+ v |= HasSimpleBaseClass(desc, options);
+ });
+ return v;
+}
+
+inline TProtoStringType SimpleBaseClass(const Descriptor* desc,
+ const Options& options) {
+ if (!HasDescriptorMethods(desc->file(), options)) return "";
+ if (desc->extension_range_count() != 0) return "";
+ if (desc->field_count() == 0) {
+ return "ZeroFieldsBase";
+ }
+ // TODO(jorg): Support additional common message types with only one
+ // or two fields
+ return "";
+}
+
+// Returns true if this message has a _tracker_ field.
+inline bool HasTracker(const Descriptor* desc, const Options& options) {
+ return options.field_listener_options.inject_field_listener_events &&
+ desc->file()->options().optimize_for() !=
+ google::protobuf::FileOptions::LITE_RUNTIME;
+}
+
+// Returns true if this message needs an Impl_ struct for it's data.
+inline bool HasImplData(const Descriptor* desc, const Options& options) {
+ return !HasSimpleBaseClass(desc, options);
+}
+
+// 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
+// the format string $1$, $2$, etc... are substituted for the first, second, ...
+// direct argument respectively in the format call, it accepts both strings and
+// integers. The implementation verifies all arguments are used and are "first"
+// used in order of appearance in the argument list. For example,
+//
+// Format("return array[$1$];", 3) -> "return array[3];"
+// Format("array[$2$] = $1$;", "Bla", 3) -> FATAL error (wrong order)
+// Format("array[$1$] = $2$;", 3, "Bla") -> "array[3] = Bla;"
+//
+// The arguments can be used more than once like
+//
+// Format("array[$1$] = $2$; // Index = $1$", 3, "Bla") ->
+// "array[3] = Bla; // Index = 3"
+//
+// If you use more arguments use the following style to help the reader,
+//
+// Format("int $1$() {\n"
+// " array[$2$] = $3$;\n"
+// " return $4$;"
+// "}\n",
+// funname, // 1
+// idx, // 2
+// varname, // 3
+// retval); // 4
+//
+// but consider using named variables. Named variables like $foo$, with some
+// identifier foo, are looked up in the map. One additional feature is that
+// spaces are accepted between the '$' delimiters, $ foo$ will
+// substitute to " bar" if foo stands for "bar", but in case it's empty
+// will substitute to "". Hence, for example,
+//
+// Format(vars, "$dllexport $void fun();") -> "void fun();"
+// "__declspec(export) void fun();"
+//
+// which is convenient to prevent double, leading or trailing spaces.
+class PROTOC_EXPORT Formatter {
+ public:
+ explicit Formatter(io::Printer* printer) : printer_(printer) {}
+ Formatter(io::Printer* printer,
+ const std::map<TProtoStringType, TProtoStringType>& vars)
+ : printer_(printer), vars_(vars) {}
+
+ template <typename T>
+ void Set(const TProtoStringType& key, const T& value) {
+ vars_[key] = ToString(value);
+ }
+
+ void AddMap(const std::map<TProtoStringType, TProtoStringType>& vars) {
+ for (const auto& keyval : vars) vars_[keyval.first] = keyval.second;
+ }
+
+ template <typename... Args>
+ void operator()(const char* format, const Args&... args) const {
+ printer_->FormatInternal({ToString(args)...}, vars_, format);
+ }
+
+ void Indent() const { printer_->Indent(); }
+ void Outdent() const { printer_->Outdent(); }
+ io::Printer* printer() const { return printer_; }
+
+ class PROTOC_EXPORT ScopedIndenter {
+ public:
+ explicit ScopedIndenter(Formatter* format) : format_(format) {
+ format_->Indent();
+ }
+ ~ScopedIndenter() { format_->Outdent(); }
+
+ private:
+ Formatter* format_;
+ };
+
+ PROTOBUF_NODISCARD ScopedIndenter ScopedIndent() {
+ return ScopedIndenter(this);
+ }
+ template <typename... Args>
+ PROTOBUF_NODISCARD ScopedIndenter ScopedIndent(const char* format,
+ const Args&&... args) {
+ (*this)(format, static_cast<Args&&>(args)...);
+ return ScopedIndenter(this);
+ }
+
+ class PROTOC_EXPORT SaveState {
+ public:
+ explicit SaveState(Formatter* format)
+ : format_(format), vars_(format->vars_) {}
+ ~SaveState() { format_->vars_.swap(vars_); }
+
+ private:
+ Formatter* format_;
+ std::map<TProtoStringType, TProtoStringType> vars_;
+ };
+
+ private:
+ io::Printer* printer_;
+ std::map<TProtoStringType, TProtoStringType> vars_;
+
+ // Convenience overloads to accept different types as arguments.
+ static TProtoStringType ToString(const TProtoStringType& s) { return s; }
+ template <typename I, typename = typename std::enable_if<
+ std::is_integral<I>::value>::type>
+ static TProtoStringType ToString(I x) {
+ return StrCat(x);
+ }
+ 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);
+ }
+ static TProtoStringType ToString(const OneofDescriptor* d) { return Payload(d); }
+
+ template <typename Descriptor>
+ static TProtoStringType Payload(const Descriptor* descriptor) {
+ std::vector<int> path;
+ descriptor->GetLocationPath(&path);
+ GeneratedCodeInfo::Annotation annotation;
+ for (int index : path) {
+ annotation.add_path(index);
+ }
+ annotation.set_source_file(descriptor->file()->name());
+ return annotation.SerializeAsString();
+ }
+};
+
+template <class T>
+void PrintFieldComment(const Formatter& format, 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')));
+}
+
+class PROTOC_EXPORT NamespaceOpener {
+ public:
+ explicit NamespaceOpener(const Formatter& format)
+ : printer_(format.printer()) {}
+ NamespaceOpener(const TProtoStringType& name, const Formatter& format)
+ : NamespaceOpener(format) {
+ 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]);
+ }
+ }
+ }
+
+ private:
+ io::Printer* printer_;
+ 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,
+ const Formatter& format);
+
+void GenerateUtf8CheckCodeForCord(const FieldDescriptor* field,
+ const Options& options, bool for_parse,
+ const char* 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;
+};
+
+template <typename T>
+FieldRangeImpl<T> FieldRange(const T* desc) {
+ return {desc};
+}
+
+struct OneOfRangeImpl {
+ struct Iterator {
+ using iterator_category = std::forward_iterator_tag;
+ using value_type = const OneofDescriptor*;
+ using difference_type = int;
+
+ value_type operator*() { return descriptor->oneof_decl(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 Descriptor* descriptor;
+ };
+
+ Iterator begin() const { return {0, descriptor}; }
+ Iterator end() const {
+ return {descriptor->real_oneof_decl_count(), descriptor};
+ }
+
+ const Descriptor* descriptor;
+};
+
+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);
+
+bool ShouldVerify(const Descriptor* descriptor, const Options& options,
+ MessageSCCAnalyzer* scc_analyzer);
+bool ShouldVerify(const FileDescriptor* file, const Options& options,
+ MessageSCCAnalyzer* scc_analyzer);
+
+// Indicates whether to use predefined verify methods for a given message. If a
+// message is "simple" and needs no special verification per field (e.g. message
+// field, repeated packed, UTF8 string, etc.), we can use either VerifySimple or
+// VerifySimpleAlwaysCheckInt32 methods as all verification can be done based on
+// the wire type.
+//
+// Otherwise, we need "custom" verify methods tailored to a message to pass
+// which field needs a special verification; i.e. InternalVerify.
+enum class VerifySimpleType {
+ kSimpleInt32Never, // Use VerifySimple
+ kSimpleInt32Always, // Use VerifySimpleAlwaysCheckInt32
+ kCustom, // Use InternalVerify and check only for int32
+ kCustomInt32Never, // Use InternalVerify but never check for int32
+ kCustomInt32Always, // Use InternalVerify and always check for int32
+};
+
+// Returns VerifySimpleType if messages can be verified by predefined methods.
+VerifySimpleType ShouldVerifySimple(const Descriptor* descriptor);
+
+bool IsUtf8String(const FieldDescriptor* field);
+
+bool HasMessageFieldOrExtension(const Descriptor* desc);
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+#include <google/protobuf/port_undef.inc>
+
+#endif // GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/map_field.cc
index 4d3e00ac89..ba363f5267 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/map_field.cc
@@ -28,12 +28,12 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <google/protobuf/compiler/cpp/cpp_map_field.h>
+#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/cpp_helpers.h>
+#include <google/protobuf/compiler/cpp/helpers.h>
namespace google {
@@ -136,6 +136,7 @@ void MapFieldGenerator::GenerateInlineAccessorDefinitions(
"}\n"
"inline ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >*\n"
"$classname$::_internal_mutable_$name$() {\n"
+ "$maybe_prepare_split_message$"
" return $field$.MutableMap();\n"
"}\n"
"inline ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >*\n"
@@ -153,7 +154,7 @@ void MapFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
void MapFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$field$.MergeFrom(from.$field$);\n");
+ format("_this->$field$.MergeFrom(from.$field$);\n");
}
void MapFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
@@ -226,8 +227,7 @@ void MapFieldGenerator::GenerateSerializeWithCachedSizesToArray(
format);
}
}
- format(
- "};\n");
+ format("};\n");
}
format(
@@ -271,21 +271,48 @@ void MapFieldGenerator::GenerateIsInitialized(io::Printer* printer) const {
"false;\n");
}
-void MapFieldGenerator::GenerateConstinitInitializer(
+void MapFieldGenerator::GenerateConstexprAggregateInitializer(
io::Printer* printer) const {
Formatter format(printer, variables_);
if (HasDescriptorMethods(descriptor_->file(), options_)) {
- format("$name$_(::$proto_ns$::internal::ConstantInitialized{})");
+ format("/*decltype($field$)*/{::_pbi::ConstantInitialized()}");
} else {
- format("$name$_()");
+ format("/*decltype($field$)*/{}");
+ }
+}
+
+void MapFieldGenerator::GenerateCopyAggregateInitializer(
+ io::Printer* printer) const {
+ Formatter format(printer, variables_);
+ // MapField has no move constructor, which prevents explicit aggregate
+ // initialization pre-C++17.
+ format("/*decltype($field$)*/{}");
+}
+
+void MapFieldGenerator::GenerateAggregateInitializer(
+ io::Printer* printer) const {
+ Formatter format(printer, variables_);
+ if (ShouldSplit(descriptor_, options_)) {
+ format(
+ "/*decltype($classname$::Split::$name$_)*/"
+ "{::_pbi::ArenaInitialized(), arena}");
+ return;
}
+ // MapField has no move constructor.
+ format("/*decltype($field$)*/{::_pbi::ArenaInitialized(), arena}");
}
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");
+ format("$cached_split_ptr$->$name$_.~MapField$lite$();\n");
+ return;
+ }
format("$field$.Destruct();\n");
+ format("$field$.~MapField$lite$();\n");
}
void MapFieldGenerator::GenerateArenaDestructorCode(
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/map_field.h
index 9e71267c0f..678a128bd1 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/map_field.h
@@ -34,8 +34,8 @@
#include <map>
#include <string>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
-#include <google/protobuf/compiler/cpp/cpp_message_field.h>
+#include <google/protobuf/compiler/cpp/helpers.h>
+#include <google/protobuf/compiler/cpp/message_field.h>
namespace google {
namespace protobuf {
@@ -61,7 +61,10 @@ class MapFieldGenerator : public FieldGenerator {
io::Printer* printer) const override;
void GenerateByteSize(io::Printer* printer) const override;
void GenerateIsInitialized(io::Printer* printer) const override;
- void GenerateConstinitInitializer(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;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message.cc
index a56c6fbda1..77702a68df 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/cpp/cpp_message.h>
+#include <google/protobuf/compiler/cpp/message.h>
#include <algorithm>
#include <cstdint>
@@ -51,13 +51,14 @@
#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/cpp_enum.h>
-#include <google/protobuf/compiler/cpp/cpp_extension.h>
-#include <google/protobuf/compiler/cpp/cpp_field.h>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
-#include <google/protobuf/compiler/cpp/cpp_padding_optimizer.h>
-#include <google/protobuf/compiler/cpp/cpp_parse_function_generator.h>
+#include <google/protobuf/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>
@@ -83,7 +84,7 @@ 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 = "_has_bits_") {
+ StringPiece has_bits_var = "_impl_._has_bits_") {
std::vector<TProtoStringType> parts;
for (int i = 0; i < masks.size(); i++) {
if (masks[i] == 0) continue;
@@ -345,10 +346,10 @@ bool IsRequired(const std::vector<const FieldDescriptor*>& v) {
return v.front()->is_required();
}
-bool HasSingularString(const Descriptor* desc, const Options& options) {
+bool HasNonSplitOptionalString(const Descriptor* desc, const Options& options) {
for (const auto* field : FieldRange(desc)) {
if (IsString(field, options) && !field->is_repeated() &&
- !field->real_containing_oneof()) {
+ !field->real_containing_oneof() && !ShouldSplit(field, options)) {
return true;
}
}
@@ -403,7 +404,7 @@ static int popcnt(arc_ui32 n) {
class ColdChunkSkipper {
public:
ColdChunkSkipper(
- const Options& options,
+ const Descriptor* descriptor, const Options& options,
const std::vector<std::vector<const FieldDescriptor*>>& chunks,
const std::vector<int>& has_bit_indices, const double cold_threshold)
: chunks_(chunks),
@@ -411,7 +412,7 @@ class ColdChunkSkipper {
access_info_map_(options.access_info_map),
cold_threshold_(cold_threshold) {
SetCommonVars(options, &variables_);
- SetCommonMessageDataVariables(&variables_);
+ SetCommonMessageDataVariables(descriptor, &variables_);
}
// May open an external if check for a batch of cold fields. "from" is the
@@ -495,7 +496,7 @@ void ColdChunkSkipper::OnStartChunk(int chunk, int cached_has_word_index,
if (this_word == cached_has_word_index) {
format("(cached_has_bits & 0x$mask$u) != 0");
} else {
- format("($1$_has_bits_[$2$] & 0x$mask$u) != 0", from, this_word);
+ format("($1$_impl_._has_bits_[$2$] & 0x$mask$u) != 0", from, this_word);
}
}
format(")) {\n");
@@ -547,9 +548,7 @@ void GenerateExtensionAnnotations(
for (const auto& annotation : accessor_annotations_to_hooks) {
(*variables)[annotation.first] = "";
}
- if (!options.field_listener_options.inject_field_listener_events ||
- descriptor->file()->options().optimize_for() ==
- google::protobuf::FileOptions::LITE_RUNTIME) {
+ if (!HasTracker(descriptor, options)) {
return;
}
StringPiece tracker = (*variables)["tracker"];
@@ -617,7 +616,7 @@ MessageGenerator::MessageGenerator(
if (!message_layout_helper_) {
message_layout_helper_.reset(new PaddingOptimizer());
}
- SetCommonMessageDataVariables(&variables_);
+ SetCommonMessageDataVariables(descriptor, &variables_);
// Variables that apply to this class
variables_["classname"] = classname_;
@@ -630,9 +629,7 @@ MessageGenerator::MessageGenerator(
variables_["annotate_bytesize"] = "";
variables_["annotate_mergefrom"] = "";
- if (options.field_listener_options.inject_field_listener_events &&
- descriptor->file()->options().optimize_for() !=
- google::protobuf::FileOptions::LITE_RUNTIME) {
+ if (HasTracker(descriptor_, options_)) {
const TProtoStringType injector_template =
StrCat(" ", variables_["tracker"], ".");
@@ -649,7 +646,7 @@ MessageGenerator::MessageGenerator(
MaySetAnnotationVariable(options, "bytesize", injector_template,
"OnByteSize(this);\n", &variables_);
MaySetAnnotationVariable(options, "mergefrom", injector_template,
- "OnMergeFrom(this, &from);\n", &variables_);
+ "OnMergeFrom(_this, &from);\n", &variables_);
}
GenerateExtensionAnnotations(descriptor_, options_, &variables_);
@@ -1205,6 +1202,9 @@ void MessageGenerator::GenerateFieldClear(const FieldDescriptor* field,
format.Outdent();
format("}\n");
} else {
+ if (ShouldSplit(field, options_)) {
+ format("if (IsSplitMessageDefault()) return;\n");
+ }
field_generators_.get(field).GenerateClearingCode(format.printer());
if (HasHasbit(field)) {
int has_bit_index = HasBitIndex(field);
@@ -1245,13 +1245,12 @@ void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* printer) {
} else {
format(
"inline int $classname$::_internal_$name$_size() const {\n"
- " return $1$$2$.size();\n"
+ " return $field$$1$.size();\n"
"}\n"
"inline int $classname$::$name$_size() const {\n"
"$annotate_size$"
" return _internal_$name$_size();\n"
"}\n",
- FieldMemberName(field),
IsImplicitWeakField(field, options_, scc_analyzer_) &&
field->message_type()
? ".weak"
@@ -1398,6 +1397,11 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
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");
}
@@ -1510,11 +1514,13 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
if (HasDescriptorMethods(descriptor_->file(), options_)) {
format(
"bool PackFrom(const ::$proto_ns$::Message& message) {\n"
+ " $DCHK$_NE(&message, this);\n"
" return $any_metadata$.PackFrom(GetArena(), message);\n"
"}\n"
"bool PackFrom(const ::$proto_ns$::Message& message,\n"
" ::PROTOBUF_NAMESPACE_ID::ConstStringParam "
"type_url_prefix) {\n"
+ " $DCHK$_NE(&message, this);\n"
" return $any_metadata$.PackFrom(GetArena(), message, "
"type_url_prefix);\n"
"}\n"
@@ -1618,27 +1624,28 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
// argument is a generic Message instance, and only define the
// custom MergeFrom and CopyFrom instances when the source of the
// merge/copy is known to be the same class as the destination.
- // TODO(jorg): Define MergeFrom in terms of MergeImpl, rather than
- // the other way around, to save even more code size.
"using $superclass$::CopyFrom;\n"
"void CopyFrom(const $classname$& from);\n"
""
"using $superclass$::MergeFrom;\n"
- "void MergeFrom(const $classname$& from);\n"
+ "void MergeFrom("
+ " const $classname$& from) {\n"
+ " $classname$::MergeImpl(*this, from);\n"
+ "}\n"
"private:\n"
- "static void MergeImpl(::$proto_ns$::Message* to, const "
- "::$proto_ns$::Message& from);\n"
+ "static void MergeImpl(::$proto_ns$::Message& to_msg, const "
+ "::$proto_ns$::Message& from_msg);\n"
"public:\n");
} else {
format(
"using $superclass$::CopyFrom;\n"
"inline void CopyFrom(const $classname$& from) {\n"
- " $superclass$::CopyImpl(this, from);\n"
+ " $superclass$::CopyImpl(*this, from);\n"
"}\n"
""
"using $superclass$::MergeFrom;\n"
"void MergeFrom(const $classname$& from) {\n"
- " $superclass$::MergeImpl(this, from);\n"
+ " $superclass$::MergeImpl(*this, from);\n"
"}\n"
"public:\n");
}
@@ -1676,7 +1683,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"int GetCachedSize() const final { return "
"$cached_size$.Get(); }"
"\n\nprivate:\n"
- "void SharedCtor();\n"
+ "void SharedCtor(::$proto_ns$::Arena* arena, bool is_message_owned);\n"
"void SharedDtor();\n"
"void SetCachedSize(int size) const$ full_final$;\n"
"void InternalSwap($classname$* other);\n");
@@ -1747,6 +1754,17 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"\n");
}
+ if (ShouldSplit(descriptor_, options_)) {
+ format(
+ "private:\n"
+ "inline bool IsSplitMessageDefault() const {\n"
+ " return $split$ == reinterpret_cast<Impl_::Split*>(&$1$);\n"
+ "}\n"
+ "PROTOBUF_NOINLINE void PrepareSplitMessageForWrite();\n"
+ "public:\n",
+ DefaultInstanceName(descriptor_, options_, /*split=*/true));
+ }
+
format(
"// nested types ----------------------------------------------------\n"
"\n");
@@ -1837,12 +1855,21 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
: StrCat("::$proto_ns$::internal::HasBits<",
sizeof_has_bits, "> _has_bits_;\n");
+ format(
+ "template <typename T> friend class "
+ "::$proto_ns$::Arena::InternalHelper;\n"
+ "typedef void InternalArenaConstructable_;\n"
+ "typedef void DestructorSkippable_;\n");
+
// To minimize padding, data members are divided into three sections:
// (1) members assumed to align to 8 bytes
// (2) members corresponding to message fields, re-ordered to optimize
// alignment.
// (3) members assumed to align to 4 bytes.
+ format("struct Impl_ {\n");
+ format.Indent();
+
// Members assumed to align to 8 bytes:
if (descriptor_->extension_range_count() > 0) {
@@ -1851,9 +1878,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"\n");
}
- if (options_.field_listener_options.inject_field_listener_events &&
- descriptor_->file()->options().optimize_for() !=
- google::protobuf::FileOptions::LITE_RUNTIME) {
+ if (HasTracker(descriptor_, options_)) {
format("static ::$proto_ns$::AccessListener<$1$> _tracker_;\n",
ClassName(descriptor_));
}
@@ -1866,12 +1891,6 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
InlinedStringDonatedSize());
}
- format(
- "template <typename T> friend class "
- "::$proto_ns$::Arena::InternalHelper;\n"
- "typedef void InternalArenaConstructable_;\n"
- "typedef void DestructorSkippable_;\n");
-
if (!has_bit_indices_.empty()) {
// _has_bits_ is frequently accessed, so to reduce code size and improve
// speed, it should be close to the start of the object. Placing
@@ -1890,7 +1909,24 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
for (auto field : optimized_order_) {
const FieldGenerator& generator = field_generators_.get(field);
generator.GenerateStaticMembers(printer);
- generator.GeneratePrivateMembers(printer);
+ if (!ShouldSplit(field, options_)) {
+ generator.GeneratePrivateMembers(printer);
+ }
+ }
+ if (ShouldSplit(descriptor_, options_)) {
+ format("struct Split {\n");
+ format.Indent();
+ for (auto field : optimized_order_) {
+ if (!ShouldSplit(field, options_)) continue;
+ const FieldGenerator& generator = field_generators_.get(field);
+ generator.GeneratePrivateMembers(printer);
+ }
+ format.Outdent();
+ format(
+ " typedef void InternalArenaConstructable_;\n"
+ " typedef void DestructorSkippable_;\n"
+ "};\n"
+ "Split* _split_;\n");
}
// For each oneof generate a union
@@ -1941,6 +1977,22 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
format("::$proto_ns$::internal::AnyMetadata _any_metadata_;\n");
}
+ format.Outdent();
+ format("};\n");
+
+ // Only create the _impl_ field if it contains data.
+ if (HasImplData(descriptor_, options_)) {
+ format("union { Impl_ _impl_; };\n");
+ }
+
+ if (ShouldSplit(descriptor_, options_)) {
+ format(
+ "static Impl_::Split* CreateSplitMessage("
+ "::$proto_ns$::Arena* arena);\n");
+ format("friend struct $1$;\n",
+ DefaultInstanceType(descriptor_, options_, /*split=*/true));
+ }
+
// The TableStruct struct needs access to the private parts, in order to
// construct the offsets of all members.
format("friend struct ::$tablename$;\n");
@@ -2080,7 +2132,8 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
format("};\n\n");
for (auto field : FieldRange(descriptor_)) {
if (!IsFieldStripped(field, options_)) {
- field_generators_.get(field).GenerateInternalAccessorDefinitions(printer);
+ field_generators_.get(field).GenerateInternalAccessorDefinitions(
+ printer);
}
}
@@ -2130,7 +2183,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
GenerateMergeFrom(printer);
format("\n");
- GenerateClassSpecificMergeFrom(printer);
+ GenerateClassSpecificMergeImpl(printer);
format("\n");
GenerateCopyFrom(printer);
@@ -2140,6 +2193,15 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
format("\n");
}
+ if (ShouldSplit(descriptor_, options_)) {
+ format(
+ "void $classname$::PrepareSplitMessageForWrite() {\n"
+ " if (IsSplitMessageDefault()) {\n"
+ " $split$ = CreateSplitMessage(GetArenaForAllocation());\n"
+ " }\n"
+ "}\n");
+ }
+
GenerateVerify(printer);
GenerateSwap(printer);
@@ -2172,9 +2234,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
"\n");
}
- if (options_.field_listener_options.inject_field_listener_events &&
- descriptor_->file()->options().optimize_for() !=
- google::protobuf::FileOptions::LITE_RUNTIME) {
+ if (HasTracker(descriptor_, options_)) {
format(
"::$proto_ns$::AccessListener<$classtype$> "
"$1$::$tracker$(&FullMessageName);\n",
@@ -2230,7 +2290,11 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
// Don't use the top bit because that is for unused fields.
format("::_pbi::kInvalidFieldOffsetTag");
} else {
- format("PROTOBUF_FIELD_OFFSET($classtype$, $1$)", FieldMemberName(field));
+ format("PROTOBUF_FIELD_OFFSET($classtype$$1$, $2$)",
+ ShouldSplit(field, options_) ? "::Impl_::Split" : "",
+ ShouldSplit(field, options_)
+ ? FieldName(field) + "_"
+ : FieldMemberName(field, /*cold=*/false));
}
// Some information about a field is in the pdproto profile. The profile is
@@ -2250,7 +2314,7 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
int count = 0;
for (auto oneof : OneOfRange(descriptor_)) {
- format("PROTOBUF_FIELD_OFFSET($classtype$, $1$_),\n", oneof->name());
+ format("PROTOBUF_FIELD_OFFSET($classtype$, _impl_.$1$_),\n", oneof->name());
count++;
}
GOOGLE_CHECK_EQ(count, descriptor_->real_oneof_decl_count());
@@ -2286,18 +2350,181 @@ void MessageGenerator::GenerateSharedConstructorCode(io::Printer* printer) {
if (HasSimpleBaseClass(descriptor_, options_)) return;
Formatter format(printer, variables_);
- format("inline void $classname$::SharedCtor() {\n");
+ format(
+ "inline void $classname$::SharedCtor(\n"
+ " ::_pb::Arena* arena, bool is_message_owned) {\n"
+ " (void)arena;\n"
+ " (void)is_message_owned;\n");
- std::vector<bool> processed(optimized_order_.size(), false);
- GenerateConstructorBody(printer, processed, false);
+ format.Indent();
+ // Impl_ _impl_.
+ format("new (&_impl_) Impl_{");
+ format.Indent();
+ const char* field_sep = " ";
+ const auto put_sep = [&] {
+ format("\n$1$ ", field_sep);
+ field_sep = ",";
+ };
+
+ // Note: any fields without move/copy constructors can't be explicitly
+ // aggregate initialized pre-C++17.
+ if (descriptor_->extension_range_count() > 0) {
+ put_sep();
+ format("/*decltype($extensions$)*/{::_pbi::ArenaInitialized(), arena}");
+ }
+ if (!inlined_string_indices_.empty()) {
+ put_sep();
+ format("decltype($inlined_string_donated_array$){}");
+ }
+ bool need_to_emit_cached_size = !HasSimpleBaseClass(descriptor_, options_);
+ if (!has_bit_indices_.empty()) {
+ put_sep();
+ format("decltype($has_bits$){}");
+ if (need_to_emit_cached_size) {
+ put_sep();
+ format("/*decltype($cached_size$)*/{}");
+ need_to_emit_cached_size = false;
+ }
+ }
+
+ // 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);
+ }
+ if (ShouldSplit(descriptor_, options_)) {
+ put_sep();
+ format("decltype($split$){reinterpret_cast<Impl_::Split*>(&$1$)}",
+ DefaultInstanceName(descriptor_, options_, /*split=*/true));
+ }
+ for (auto oneof : OneOfRange(descriptor_)) {
+ put_sep();
+ format("decltype(_impl_.$1$_){}", oneof->name());
+ }
+
+ if (need_to_emit_cached_size) {
+ put_sep();
+ format("/*decltype($cached_size$)*/{}");
+ }
+
+ if (descriptor_->real_oneof_decl_count() != 0) {
+ put_sep();
+ format("/*decltype($oneof_case$)*/{}");
+ }
+ if (num_weak_fields_ > 0) {
+ put_sep();
+ format("decltype($weak_field_map$){arena}");
+ }
+ if (IsAnyMessage(descriptor_, options_)) {
+ put_sep();
+ // AnyMetadata has no move constructor.
+ format("/*decltype($any_metadata$)*/{&_impl_.type_url_, &_impl_.value_}");
+ }
+
+ format.Outdent();
+ format("\n};\n");
+
+ if (!inlined_string_indices_.empty()) {
+ // Donate inline string fields.
+ format.Indent();
+ // The last bit is the tracking bit for registering ArenaDtor. The bit is 1
+ // means ArenaDtor is not registered on construction, and on demand register
+ // is needed.
+ format("if (arena != nullptr) {\n");
+ if (NeedsArenaDestructor() == ArenaDtorNeeds::kOnDemand) {
+ format(
+ " if (!is_message_owned) {\n"
+ " $inlined_string_donated_array$[0] = ~0u;\n"
+ " } else {\n"
+ // We should not register ArenaDtor for MOA.
+ " $inlined_string_donated_array$[0] = 0xFFFFFFFEu;\n"
+ " }\n");
+ } else {
+ format(" $inlined_string_donated_array$[0] = 0xFFFFFFFEu;\n");
+ }
+ for (size_t i = 1; i < InlinedStringDonatedSize(); ++i) {
+ format(" $inlined_string_donated_array$[$1$] = ~0u;\n", i);
+ }
+ format("}\n");
+ format.Outdent();
+ }
+
+ for (const FieldDescriptor* field : optimized_order_) {
+ if (ShouldSplit(field, options_)) {
+ continue;
+ }
+ field_generators_.get(field).GenerateConstructorCode(printer);
+ }
for (auto oneof : OneOfRange(descriptor_)) {
format("clear_has_$1$();\n", oneof->name());
}
+ format.Outdent();
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) {
+ if (!ShouldSplit(descriptor_, options_)) return;
+
+ Formatter format(printer, variables_);
+ const char* field_sep = " ";
+ const auto put_sep = [&] {
+ format("\n$1$ ", field_sep);
+ field_sep = ",";
+ };
+ for (const auto* field : optimized_order_) {
+ if (ShouldSplit(field, options_)) {
+ put_sep();
+ field_generators_.get(field).GenerateConstexprAggregateInitializer(
+ printer);
+ }
+ }
+}
+
void MessageGenerator::GenerateSharedDestructorCode(io::Printer* printer) {
if (HasSimpleBaseClass(descriptor_, options_)) return;
Formatter format(printer, variables_);
@@ -2305,11 +2532,32 @@ void MessageGenerator::GenerateSharedDestructorCode(io::Printer* printer) {
format("inline void $classname$::SharedDtor() {\n");
format.Indent();
format("$DCHK$(GetArenaForAllocation() == nullptr);\n");
+
+ if (descriptor_->extension_range_count() > 0) {
+ format("$extensions$.~ExtensionSet();\n");
+ }
+
// Write the destructors for each field except oneof members.
// optimized_order_ does not contain oneof fields.
for (auto field : optimized_order_) {
+ if (ShouldSplit(field, options_)) {
+ continue;
+ }
field_generators_.get(field).GenerateDestructorCode(printer);
}
+ if (ShouldSplit(descriptor_, options_)) {
+ format("if (!IsSplitMessageDefault()) {\n");
+ format.Indent();
+ format("auto* $cached_split_ptr$ = $split$;\n");
+ for (auto field : optimized_order_) {
+ if (ShouldSplit(field, options_)) {
+ field_generators_.get(field).GenerateDestructorCode(printer);
+ }
+ }
+ format("delete $cached_split_ptr$;\n");
+ format.Outdent();
+ format("}\n");
+ }
// Generate code to destruct oneofs. Clearing should do the work.
for (auto oneof : OneOfRange(descriptor_)) {
@@ -2323,6 +2571,11 @@ void MessageGenerator::GenerateSharedDestructorCode(io::Printer* printer) {
if (num_weak_fields_) {
format("$weak_field_map$.ClearAll();\n");
}
+
+ if (IsAnyMessage(descriptor_, options_)) {
+ format("$any_metadata$.~AnyMetadata();\n");
+ }
+
format.Outdent();
format(
"}\n"
@@ -2358,10 +2611,23 @@ void MessageGenerator::GenerateArenaDestructorCode(io::Printer* printer) {
// Process non-oneof fields first.
for (auto field : optimized_order_) {
- if (IsFieldStripped(field, options_)) continue;
+ if (IsFieldStripped(field, options_) || ShouldSplit(field, options_))
+ continue;
const FieldGenerator& fg = field_generators_.get(field);
fg.GenerateArenaDestructorCode(printer);
}
+ 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);
+ }
+ format.Outdent();
+ format("}\n");
+ }
// Process oneof fields.
for (auto oneof : OneOfRange(descriptor_)) {
@@ -2378,72 +2644,118 @@ void MessageGenerator::GenerateArenaDestructorCode(io::Printer* printer) {
void MessageGenerator::GenerateConstexprConstructor(io::Printer* printer) {
Formatter format(printer, variables_);
+ if (IsMapEntryMessage(descriptor_) || !HasImplData(descriptor_, options_)) {
+ format(
+ "PROTOBUF_CONSTEXPR $classname$::$classname$(\n"
+ " ::_pbi::ConstantInitialized) {}\n");
+ return;
+ }
+
format(
"PROTOBUF_CONSTEXPR $classname$::$classname$(\n"
" ::_pbi::ConstantInitialized)");
+
+ bool need_to_emit_cached_size = !HasSimpleBaseClass(descriptor_, options_);
+ format(": _impl_{");
format.Indent();
- const char* field_sep = ":";
+ const char* field_sep = " ";
const auto put_sep = [&] {
format("\n$1$ ", field_sep);
field_sep = ",";
};
-
- if (!IsMapEntryMessage(descriptor_)) {
- // Process non-oneof fields first.
- for (auto field : optimized_order_) {
- auto& gen = field_generators_.get(field);
+ if (descriptor_->extension_range_count() > 0) {
+ put_sep();
+ format("/*decltype($extensions$)*/{}");
+ }
+ if (!inlined_string_indices_.empty()) {
+ put_sep();
+ format("/*decltype($inlined_string_donated_array$)*/{}");
+ }
+ if (!has_bit_indices_.empty()) {
+ put_sep();
+ format("/*decltype($has_bits$)*/{}");
+ if (need_to_emit_cached_size) {
put_sep();
- gen.GenerateConstinitInitializer(printer);
+ format("/*decltype($cached_size$)*/{}");
+ need_to_emit_cached_size = false;
}
-
- if (IsAnyMessage(descriptor_, options_)) {
- put_sep();
- format("_any_metadata_(&type_url_, &value_)");
+ }
+ for (auto field : optimized_order_) {
+ if (ShouldSplit(field, options_)) {
+ continue;
}
+ put_sep();
+ field_generators_.get(field).GenerateConstexprAggregateInitializer(
+ printer);
+ }
+ if (ShouldSplit(descriptor_, options_)) {
+ put_sep();
+ format("/*decltype($split$)*/&$1$._instance",
+ DefaultInstanceName(descriptor_, options_, /*split=*/true));
+ }
- if (descriptor_->real_oneof_decl_count() != 0) {
- put_sep();
- format("_oneof_case_{}");
- }
+ for (auto oneof : OneOfRange(descriptor_)) {
+ put_sep();
+ format("/*decltype(_impl_.$1$_)*/{}", oneof->name());
+ }
+
+ if (need_to_emit_cached_size) {
+ put_sep();
+ format("/*decltype($cached_size$)*/{}");
+ }
+
+ if (descriptor_->real_oneof_decl_count() != 0) {
+ put_sep();
+ format("/*decltype($oneof_case$)*/{}");
+ }
+
+ if (num_weak_fields_) {
+ put_sep();
+ format("/*decltype($weak_field_map$)*/{}");
+ }
+
+ if (IsAnyMessage(descriptor_, options_)) {
+ put_sep();
+ format(
+ "/*decltype($any_metadata$)*/{&_impl_.type_url_, "
+ "&_impl_.value_}");
}
format.Outdent();
- format("{}\n");
+ format("} {}\n");
}
-void MessageGenerator::GenerateConstructorBody(io::Printer* printer,
- std::vector<bool> processed,
- bool copy_constructor) const {
+void MessageGenerator::GenerateCopyConstructorBody(io::Printer* printer) const {
Formatter format(printer, variables_);
- const RunMap runs = FindRuns(
- optimized_order_, [copy_constructor, this](const FieldDescriptor* field) {
- return (copy_constructor && IsPOD(field)) ||
- (!copy_constructor &&
- CanBeManipulatedAsRawBytes(field, options_, scc_analyzer_));
+ const RunMap runs =
+ FindRuns(optimized_order_, [this](const FieldDescriptor* field) {
+ return IsPOD(field) && !ShouldSplit(field, options_);
});
- TProtoStringType pod_template;
- if (copy_constructor) {
- pod_template =
- "::memcpy(&$first$, &from.$first$,\n"
- " static_cast<size_t>(reinterpret_cast<char*>(&$last$) -\n"
- " reinterpret_cast<char*>(&$first$)) + sizeof($last$));\n";
- } else {
- pod_template =
- "::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(\n"
- " reinterpret_cast<char*>(&$first$) - "
- "reinterpret_cast<char*>(this)),\n"
- " 0, static_cast<size_t>(reinterpret_cast<char*>(&$last$) -\n"
- " reinterpret_cast<char*>(&$first$)) + sizeof($last$));\n";
- }
+ TProtoStringType pod_template =
+ "::memcpy(&$first$, &from.$first$,\n"
+ " static_cast<size_t>(reinterpret_cast<char*>(&$last$) -\n"
+ " reinterpret_cast<char*>(&$first$)) + sizeof($last$));\n";
- for (int i = 0; i < optimized_order_.size(); ++i) {
- if (processed[i]) {
- continue;
+ 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");
+ }
+ for (size_t i = 0; i < optimized_order_.size(); ++i) {
const FieldDescriptor* field = optimized_order_[i];
+ if (ShouldSplit(field, options_)) {
+ continue;
+ }
const auto it = runs.find(field);
// We only apply the memset technique to runs of more than one field, as
@@ -2451,9 +2763,10 @@ void MessageGenerator::GenerateConstructorBody(io::Printer* printer,
if (it != runs.end() && it->second > 1) {
// Use a memset, then skip run_length fields.
const size_t run_length = it->second;
- const TProtoStringType first_field_name = FieldMemberName(field);
+ const TProtoStringType first_field_name =
+ FieldMemberName(field, /*cold=*/false);
const TProtoStringType last_field_name =
- FieldMemberName(optimized_order_[i + run_length - 1]);
+ FieldMemberName(optimized_order_[i + run_length - 1], /*cold=*/false);
format.Set("first", first_field_name);
format.Set("last", last_field_name);
@@ -2463,11 +2776,7 @@ void MessageGenerator::GenerateConstructorBody(io::Printer* printer,
i += run_length - 1;
// ++i at the top of the loop.
} else {
- if (copy_constructor) {
- field_generators_.get(field).GenerateCopyConstructorCode(printer);
- } else {
- field_generators_.get(field).GenerateConstructorCode(printer);
- }
+ field_generators_.get(field).GenerateCopyConstructorCode(printer);
}
}
}
@@ -2475,78 +2784,14 @@ void MessageGenerator::GenerateConstructorBody(io::Printer* printer,
void MessageGenerator::GenerateStructors(io::Printer* printer) {
Formatter format(printer, variables_);
- TProtoStringType superclass;
- superclass = SuperClassName(descriptor_, options_);
- TProtoStringType initializer_with_arena = superclass + "(arena, is_message_owned)";
-
- if (descriptor_->extension_range_count() > 0) {
- initializer_with_arena += ",\n _extensions_(arena)";
- }
-
- // Initialize member variables with arena constructor.
- for (auto field : optimized_order_) {
- GOOGLE_DCHECK(!IsFieldStripped(field, options_));
- bool has_arena_constructor = field->is_repeated();
- if (!field->real_containing_oneof() &&
- (IsLazy(field, options_, scc_analyzer_) ||
- IsStringPiece(field, options_) ||
- (IsString(field, options_) && IsStringInlined(field, options_)))) {
- has_arena_constructor = true;
- }
- if (has_arena_constructor) {
- initializer_with_arena +=
- TProtoStringType(",\n ") + FieldName(field) + TProtoStringType("_(arena)");
- }
- }
-
- if (IsAnyMessage(descriptor_, options_)) {
- initializer_with_arena += ",\n _any_metadata_(&type_url_, &value_)";
- }
- if (num_weak_fields_ > 0) {
- initializer_with_arena += ", _weak_field_map_(arena)";
- }
-
- TProtoStringType initializer_null = superclass + "()";
- if (IsAnyMessage(descriptor_, options_)) {
- initializer_null += ", _any_metadata_(&type_url_, &value_)";
- }
- if (num_weak_fields_ > 0) {
- initializer_null += ", _weak_field_map_(nullptr)";
- }
-
format(
"$classname$::$classname$(::$proto_ns$::Arena* arena,\n"
" bool is_message_owned)\n"
- " : $1$ {\n",
- initializer_with_arena);
-
- if (!inlined_string_indices_.empty()) {
- // Donate inline string fields.
- format.Indent();
- // The last bit is the tracking bit for registering ArenaDtor. The bit is 1
- // means ArenaDtor is not registered on construction, and on demand register
- // is needed.
- format("if (arena != nullptr) {\n");
- if (NeedsArenaDestructor() == ArenaDtorNeeds::kOnDemand) {
- format(
- " if (!is_message_owned) {\n"
- " $inlined_string_donated_array$[0] = ~0u;\n"
- " } else {\n"
- // We should not register ArenaDtor for MOA.
- " $inlined_string_donated_array$[0] = 0xFFFFFFFEu;\n"
- " }\n");
- } else {
- format(" $inlined_string_donated_array$[0] = 0xFFFFFFFEu;\n");
- }
- for (size_t i = 1; i < InlinedStringDonatedSize(); ++i) {
- format(" $inlined_string_donated_array$[$1$] = ~0u;\n", i);
- }
- format("}\n");
- format.Outdent();
- }
+ " : $1$(arena, is_message_owned) {\n",
+ SuperClassName(descriptor_, options_));
if (!HasSimpleBaseClass(descriptor_, options_)) {
- format(" SharedCtor();\n");
+ format(" SharedCtor(arena, is_message_owned);\n");
if (NeedsArenaDestructor() == ArenaDtorNeeds::kRequired) {
format(
" if (arena != nullptr && !is_message_owned) {\n"
@@ -2576,40 +2821,81 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
} else {
format(
"$classname$::$classname$(const $classname$& from)\n"
- " : $superclass$()");
- format.Indent();
- format.Indent();
+ " : $superclass$() {\n");
format.Indent();
+ format("$classname$* const _this = this; (void)_this;\n");
- // Do not copy inlined_string_donated_, because this is not an arena
- // constructor.
+ if (HasImplData(descriptor_, options_)) {
+ const char* field_sep = " ";
+ const auto put_sep = [&] {
+ format("\n$1$ ", field_sep);
+ field_sep = ",";
+ };
- if (!has_bit_indices_.empty()) {
- format(",\n_has_bits_(from._has_bits_)");
- }
+ format("new (&_impl_) Impl_{");
+ format.Indent();
- std::vector<bool> processed(optimized_order_.size(), false);
- for (int i = 0; i < optimized_order_.size(); i++) {
- auto field = optimized_order_[i];
- if (!(field->is_repeated() && !(field->is_map())) &&
- !IsCord(field, options_)) {
- continue;
+ if (descriptor_->extension_range_count() > 0) {
+ put_sep();
+ format("/*decltype($extensions$)*/{}");
+ }
+ if (!inlined_string_indices_.empty()) {
+ // Do not copy inlined_string_donated_, because this is not an arena
+ // constructor.
+ put_sep();
+ format("decltype($inlined_string_donated_array$){}");
+ }
+ bool need_to_emit_cached_size =
+ !HasSimpleBaseClass(descriptor_, options_);
+ if (!has_bit_indices_.empty()) {
+ put_sep();
+ format("decltype($has_bits$){from.$has_bits$}");
+ if (need_to_emit_cached_size) {
+ put_sep();
+ format("/*decltype($cached_size$)*/{}");
+ need_to_emit_cached_size = false;
+ }
}
- processed[i] = true;
- format(",\n$1$_(from.$1$_)", FieldName(field));
- }
+ // Initialize member variables with arena constructor.
+ for (auto field : optimized_order_) {
+ if (ShouldSplit(field, options_)) {
+ continue;
+ }
+ put_sep();
+ field_generators_.get(field).GenerateCopyAggregateInitializer(printer);
+ }
+ if (ShouldSplit(descriptor_, options_)) {
+ put_sep();
+ format("decltype($split$){reinterpret_cast<Impl_::Split*>(&$1$)}",
+ DefaultInstanceName(descriptor_, options_, /*split=*/true));
+ }
+ for (auto oneof : OneOfRange(descriptor_)) {
+ put_sep();
+ format("decltype(_impl_.$1$_){}", oneof->name());
+ }
- if (IsAnyMessage(descriptor_, options_)) {
- format(",\n_any_metadata_(&type_url_, &value_)");
- }
- if (num_weak_fields_ > 0) {
- format(",\n_weak_field_map_(from._weak_field_map_)");
- }
+ if (need_to_emit_cached_size) {
+ put_sep();
+ format("/*decltype($cached_size$)*/{}");
+ }
- format.Outdent();
- format.Outdent();
- format(" {\n");
+ if (descriptor_->real_oneof_decl_count() != 0) {
+ put_sep();
+ format("/*decltype($oneof_case$)*/{}");
+ }
+ if (num_weak_fields_ > 0) {
+ put_sep();
+ format("decltype($weak_field_map$){from.$weak_field_map$}");
+ }
+ if (IsAnyMessage(descriptor_, options_)) {
+ put_sep();
+ format(
+ "/*decltype($any_metadata$)*/{&_impl_.type_url_, &_impl_.value_}");
+ }
+ format.Outdent();
+ format("};\n\n");
+ }
format(
"_internal_metadata_.MergeFrom<$unknown_fields_type$>(from._internal_"
@@ -2621,7 +2907,7 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
"from.$extensions$);\n");
}
- GenerateConstructorBody(printer, processed, true);
+ GenerateCopyConstructorBody(printer);
// Copy oneof fields. Oneof field requires oneof case check.
for (auto oneof : OneOfRange(descriptor_)) {
@@ -2659,6 +2945,10 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
// Generate the shared constructor code.
GenerateSharedConstructorCode(printer);
+ if (ShouldSplit(descriptor_, options_)) {
+ GenerateCreateSplitMessage(printer);
+ }
+
// Generate the destructor.
if (!HasSimpleBaseClass(descriptor_, options_)) {
format(
@@ -2756,6 +3046,7 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
// (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)));
@@ -2763,7 +3054,8 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
return same;
});
- ColdChunkSkipper cold_skipper(options_, chunks, has_bit_indices_, kColdRatio);
+ 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++) {
@@ -2773,7 +3065,7 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
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_);
for (const auto& field : chunk) {
if (CanInitializeByZeroing(field)) {
GOOGLE_CHECK(!saw_non_zero_init);
@@ -2813,17 +3105,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);
} else {
+ GOOGLE_CHECK_EQ(chunk_is_cold, ShouldSplit(memset_start, options_));
+ GOOGLE_CHECK_EQ(chunk_is_cold, ShouldSplit(memset_end, options_));
format(
"::memset(&$1$, 0, static_cast<size_t>(\n"
" reinterpret_cast<char*>(&$2$) -\n"
" reinterpret_cast<char*>(&$1$)) + sizeof($2$));\n",
- FieldMemberName(memset_start), FieldMemberName(memset_end));
+ FieldMemberName(memset_start, chunk_is_cold),
+ FieldMemberName(memset_end, chunk_is_cold));
}
}
@@ -2852,6 +3152,11 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
}
}
+ if (chunk_is_cold) {
+ format.Outdent();
+ format("}\n");
+ }
+
if (have_outer_if) {
format.Outdent();
format("}\n");
@@ -2950,7 +3255,7 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) {
std::map<TProtoStringType, TProtoStringType> vars;
SetUnknownFieldsVariable(descriptor_, options_, &vars);
format.AddMap(vars);
- if (HasSingularString(descriptor_, options_)) {
+ if (HasNonSplitOptionalString(descriptor_, options_)) {
format(
"auto* lhs_arena = GetArenaForAllocation();\n"
"auto* rhs_arena = other->GetArenaForAllocation();\n");
@@ -2966,11 +3271,15 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) {
// If possible, we swap several fields at once, including padding.
const RunMap runs =
FindRuns(optimized_order_, [this](const FieldDescriptor* field) {
- return CanBeManipulatedAsRawBytes(field, options_, scc_analyzer_);
+ return !ShouldSplit(field, options_) &&
+ CanBeManipulatedAsRawBytes(field, options_, scc_analyzer_);
});
- for (int i = 0; i < optimized_order_.size(); ++i) {
+ for (size_t i = 0; i < optimized_order_.size(); ++i) {
const FieldDescriptor* field = optimized_order_[i];
+ if (ShouldSplit(field, options_)) {
+ continue;
+ }
const auto it = runs.find(field);
// We only apply the memswap technique to runs of more than one field, as
@@ -2979,9 +3288,10 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) {
if (it != runs.end() && it->second > 1) {
// Use a memswap, then skip run_length fields.
const size_t run_length = it->second;
- const TProtoStringType first_field_name = FieldMemberName(field);
- const TProtoStringType last_field_name =
- FieldMemberName(optimized_order_[i + run_length - 1]);
+ const TProtoStringType first_field_name =
+ FieldMemberName(field, /*cold=*/false);
+ 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);
@@ -3000,16 +3310,16 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) {
field_generators_.get(field).GenerateSwappingCode(printer);
}
}
+ if (ShouldSplit(descriptor_, options_)) {
+ format("swap($split$, other->$split$);\n");
+ }
for (auto oneof : OneOfRange(descriptor_)) {
- format("swap($1$_, other->$1$_);\n", oneof->name());
+ format("swap(_impl_.$1$_, other->_impl_.$1$_);\n", oneof->name());
}
for (int i = 0; i < descriptor_->real_oneof_decl_count(); i++) {
- format(
- "swap($oneof_case$[$1$], "
- "other->$oneof_case$[$1$]);\n",
- i);
+ format("swap($oneof_case$[$1$], other->$oneof_case$[$1$]);\n", i);
}
if (num_weak_fields_) {
@@ -3050,17 +3360,11 @@ void MessageGenerator::GenerateMergeFrom(io::Printer* printer) {
format(
"const ::$proto_ns$::Message::ClassData "
"$classname$::_class_data_ = {\n"
- " ::$proto_ns$::Message::CopyWithSizeCheck,\n"
+ " ::$proto_ns$::Message::CopyWithSourceCheck,\n"
" $classname$::MergeImpl\n"
"};\n"
"const ::$proto_ns$::Message::ClassData*"
"$classname$::GetClassData() const { return &_class_data_; }\n"
- "\n"
- "void $classname$::MergeImpl(::$proto_ns$::Message* to,\n"
- " const ::$proto_ns$::Message& from) {\n"
- " static_cast<$classname$ *>(to)->MergeFrom(\n"
- " static_cast<const $classname$ &>(from));\n"
- "}\n"
"\n");
} else {
// Generate CheckTypeAndMergeFrom().
@@ -3087,29 +3391,50 @@ void MessageGenerator::GenerateMergeFrom(io::Printer* printer) {
}
}
-void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) {
+void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* printer) {
if (HasSimpleBaseClass(descriptor_, options_)) return;
// Generate the class-specific MergeFrom, which avoids the GOOGLE_CHECK and cast.
Formatter format(printer, variables_);
+ if (!HasDescriptorMethods(descriptor_->file(), options_)) {
+ // For messages that don't inherit from Message, just implement MergeFrom
+ // directly.
+ format(
+ "void $classname$::MergeFrom(const $classname$& from) {\n"
+ " $classname$* const _this = this;\n");
+ } else {
+ format(
+ "void $classname$::MergeImpl(::$proto_ns$::Message& to_msg, const "
+ "::$proto_ns$::Message& from_msg) {\n"
+ " auto* const _this = static_cast<$classname$*>(&to_msg);\n"
+ " auto& from = static_cast<const $classname$&>(from_msg);\n");
+ }
+ format.Indent();
format(
- "void $classname$::MergeFrom(const $classname$& from) {\n"
"$annotate_mergefrom$"
"// @@protoc_insertion_point(class_specific_merge_from_start:"
- "$full_name$)\n"
- " $DCHK$_NE(&from, this);\n");
- format.Indent();
+ "$full_name$)\n");
+ format("$DCHK$_NE(&from, _this);\n");
format(
"$uint32$ cached_has_bits = 0;\n"
"(void) cached_has_bits;\n\n");
+ if (ShouldSplit(descriptor_, options_)) {
+ format(
+ "if (!from.IsSplitMessageDefault()) {\n"
+ " _this->PrepareSplitMessageForWrite();\n"
+ "}\n");
+ }
+
std::vector<std::vector<const FieldDescriptor*>> chunks = CollectFields(
optimized_order_,
[&](const FieldDescriptor* a, const FieldDescriptor* b) -> bool {
- return HasByteIndex(a) == HasByteIndex(b);
+ return HasByteIndex(a) == HasByteIndex(b) &&
+ ShouldSplit(a, options_) == ShouldSplit(b, options_);
});
- ColdChunkSkipper cold_skipper(options_, chunks, has_bit_indices_, kColdRatio);
+ ColdChunkSkipper cold_skipper(descriptor_, options_, chunks, has_bit_indices_,
+ kColdRatio);
// cached_has_word_index maintains that:
// cached_has_bits = from._has_bits_[cached_has_word_index]
@@ -3198,7 +3523,8 @@ void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) {
if (deferred_has_bit_changes) {
// Flush the has bits for the primitives we deferred.
GOOGLE_CHECK_LE(0, cached_has_word_index);
- format("$has_bits$[$1$] |= cached_has_bits;\n", cached_has_word_index);
+ format("_this->$has_bits$[$1$] |= cached_has_bits;\n",
+ cached_has_word_index);
}
format.Outdent();
@@ -3235,7 +3561,7 @@ void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) {
}
if (num_weak_fields_) {
format(
- "$weak_field_map$.MergeFrom(from.$weak_field_map$);"
+ "_this->$weak_field_map$.MergeFrom(from.$weak_field_map$);"
"\n");
}
@@ -3243,12 +3569,13 @@ void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) {
// the opportunity for tail calls.
if (descriptor_->extension_range_count() > 0) {
format(
- "$extensions$.MergeFrom(internal_default_instance(), "
+ "_this->$extensions$.MergeFrom(internal_default_instance(), "
"from.$extensions$);\n");
}
format(
- "_internal_metadata_.MergeFrom<$unknown_fields_type$>(from._internal_"
+ "_this->_internal_metadata_.MergeFrom<$unknown_fields_type$>(from._"
+ "internal_"
"metadata_);\n");
format.Outdent();
@@ -3263,12 +3590,12 @@ void MessageGenerator::GenerateCopyFrom(io::Printer* printer) {
// takes in the Message base class as a parameter); instead we just
// let the base Message::CopyFrom take care of it. The base MergeFrom
// knows how to quickly confirm the types exactly match, and if so, will
- // use GetClassData() to get the address of Message::CopyWithSizeCheck,
+ // use GetClassData() to get the address of Message::CopyWithSourceCheck,
// which calls Clear() and then MergeFrom(), as well as making sure that
- // clearing the destination message doesn't alter the size of the source,
- // when in debug builds.
- // Most callers avoid this by passing a "from" message that is the same
- // type as the message being merged into, rather than a generic Message.
+ // clearing the destination message doesn't alter the source, when in debug
+ // builds. Most callers avoid this by passing a "from" message that is the
+ // same type as the message being merged into, rather than a generic
+ // Message.
}
// Generate the class-specific CopyFrom.
@@ -3280,20 +3607,33 @@ void MessageGenerator::GenerateCopyFrom(io::Printer* printer) {
format("if (&from == this) return;\n");
- if (!options_.opensource_runtime) {
+ if (!options_.opensource_runtime && HasMessageFieldOrExtension(descriptor_)) {
// This check is disabled in the opensource release because we're
// concerned that many users do not define NDEBUG in their release builds.
+ // 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");
+ if (HasDescriptorMethods(descriptor_->file(), options_)) {
+ format("FailIfCopyFromDescendant(*this, from);\n");
+ } else {
+ format("size_t from_size = from.ByteSizeLong();\n");
+ }
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"
- " \"another thread is modifying the source.\";\n"
- "#endif\n");
+ "Clear();\n");
+ if (!HasDescriptorMethods(descriptor_->file(), options_)) {
+ format(
+ "#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"
+ " \"another thread is modifying the source.\";\n"
+ "#endif\n");
+ }
} else {
format("Clear();\n");
}
@@ -3485,7 +3825,7 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
// Reload.
int new_index = has_bit_index / 32;
- format_("cached_has_bits = _has_bits_[$1$];\n", new_index);
+ format_("cached_has_bits = _impl_._has_bits_[$1$];\n", new_index);
cached_has_bit_index_ = new_index;
}
@@ -3878,14 +4218,16 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
std::vector<std::vector<const FieldDescriptor*>> chunks = CollectFields(
optimized_order_,
[&](const FieldDescriptor* a, const FieldDescriptor* b) -> bool {
- return a->label() == b->label() && HasByteIndex(a) == HasByteIndex(b);
+ return a->label() == b->label() && HasByteIndex(a) == HasByteIndex(b) &&
+ ShouldSplit(a, options_) == ShouldSplit(b, options_);
});
// Remove chunks with required fields.
chunks.erase(std::remove_if(chunks.begin(), chunks.end(), IsRequired),
chunks.end());
- ColdChunkSkipper cold_skipper(options_, chunks, has_bit_indices_, kColdRatio);
+ ColdChunkSkipper cold_skipper(descriptor_, options_, chunks, has_bit_indices_,
+ kColdRatio);
int cached_has_word_index = -1;
format(
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message.h
index 5e4bbe84b8..960bea8e5a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message.h
@@ -40,11 +40,11 @@
#include <set>
#include <string>
-#include <google/protobuf/compiler/cpp/cpp_field.h>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
-#include <google/protobuf/compiler/cpp/cpp_message_layout_helper.h>
-#include <google/protobuf/compiler/cpp/cpp_options.h>
-#include <google/protobuf/compiler/cpp/cpp_parse_function_generator.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>
namespace google {
namespace protobuf {
@@ -119,6 +119,9 @@ class MessageGenerator {
// default instance.
void GenerateConstexprConstructor(io::Printer* printer);
+ void GenerateCreateSplitMessage(io::Printer* printer);
+ void GenerateInitDefaultSplitInstance(io::Printer* printer);
+
// Generate standard Message methods.
void GenerateClear(io::Printer* printer);
void GenerateOneofClear(io::Printer* printer);
@@ -129,7 +132,7 @@ class MessageGenerator {
void GenerateSerializeWithCachedSizesBodyShuffled(io::Printer* printer);
void GenerateByteSize(io::Printer* printer);
void GenerateMergeFrom(io::Printer* printer);
- void GenerateClassSpecificMergeFrom(io::Printer* printer);
+ void GenerateClassSpecificMergeImpl(io::Printer* printer);
void GenerateCopyFrom(io::Printer* printer);
void GenerateSwap(io::Printer* printer);
void GenerateIsInitialized(io::Printer* printer);
@@ -161,9 +164,8 @@ class MessageGenerator {
void GenerateFieldClear(const FieldDescriptor* field, bool is_inline,
Formatter format);
- void GenerateConstructorBody(io::Printer* printer,
- std::vector<bool> already_processed,
- bool copy_constructor) const;
+ // Generates the body of the message's copy constructor.
+ void GenerateCopyConstructorBody(io::Printer* printer) const;
// Returns the level that this message needs ArenaDtor. If the message has
// a field that is not arena-exclusive, it needs an ArenaDtor
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message_field.cc
index 3b9f09c8c8..9a91fd9172 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message_field.cc
@@ -32,10 +32,11 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/cpp/cpp_message_field.h>
+#include <google/protobuf/compiler/cpp/message_field.h>
#include <google/protobuf/io/printer.h>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
+#include <google/protobuf/compiler/cpp/field.h>
+#include <google/protobuf/compiler/cpp/helpers.h>
#include <google/protobuf/stubs/strutil.h>
@@ -157,8 +158,7 @@ void MessageFieldGenerator::GenerateAccessorDeclarations(
}
void MessageFieldGenerator::GenerateNonInlineAccessorDefinitions(
- io::Printer* printer) const {
-}
+ io::Printer* printer) const {}
void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
io::Printer* printer) const {
@@ -179,6 +179,7 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
format(
"inline void $classname$::unsafe_arena_set_allocated_$name$(\n"
" $type$* $name$) {\n"
+ "$maybe_prepare_split_message$"
// If we're not on an arena, free whatever we were holding before.
// (If we are on arena, we can just forget the earlier pointer.)
" if (GetArenaForAllocation() == nullptr) {\n"
@@ -204,6 +205,7 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
"inline $type$* $classname$::$release_name$() {\n"
"$type_reference_function$"
"$annotate_release$"
+ "$maybe_prepare_split_message$"
" $clear_hasbit$\n"
" $type$* temp = $casted_member$;\n"
" $field$ = nullptr;\n"
@@ -222,6 +224,7 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
"$annotate_release$"
" // @@protoc_insertion_point(field_release:$full_name$)\n"
"$type_reference_function$"
+ "$maybe_prepare_split_message$"
" $clear_hasbit$\n"
" $type$* temp = $casted_member$;\n"
" $field$ = nullptr;\n"
@@ -244,6 +247,9 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
" return $casted_member$;\n"
"}\n"
"inline $type$* $classname$::mutable_$name$() {\n"
+ // TODO(b/122856539): add tests to make sure all write accessors are able
+ // to prepare split message allocation.
+ "$maybe_prepare_split_message$"
" $type$* _msg = _internal_mutable_$name$();\n"
"$annotate_mutable$"
" // @@protoc_insertion_point(field_mutable:$full_name$)\n"
@@ -255,7 +261,9 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
format(
"inline void $classname$::set_allocated_$name$($type$* $name$) {\n"
" ::$proto_ns$::Arena* message_arena = GetArenaForAllocation();\n");
- format(" if (message_arena == nullptr) {\n");
+ format(
+ "$maybe_prepare_split_message$"
+ " if (message_arena == nullptr) {\n");
if (IsCrossFileMessage(descriptor_)) {
format(
" delete reinterpret_cast< ::$proto_ns$::MessageLite*>($field$);\n");
@@ -407,12 +415,12 @@ void MessageFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
if (implicit_weak_field_) {
format(
- "_Internal::mutable_$name$(this)->CheckTypeAndMergeFrom(\n"
+ "_Internal::mutable_$name$(_this)->CheckTypeAndMergeFrom(\n"
" _Internal::$name$(&from));\n");
} else {
format(
- "_internal_mutable_$name$()->$type$::MergeFrom(from._internal_$name$())"
- ";\n");
+ "_this->_internal_mutable_$name$()->$type$::MergeFrom(\n"
+ " from._internal_$name$());\n");
}
}
@@ -435,17 +443,13 @@ void MessageFieldGenerator::GenerateDestructorCode(io::Printer* printer) const {
// care when handling them.
format("if (this != internal_default_instance()) ");
}
+ if (ShouldSplit(descriptor_, options_)) {
+ format("delete $cached_split_ptr$->$name$_;\n");
+ return;
+ }
format("delete $field$;\n");
}
-void MessageFieldGenerator::GenerateConstructorCode(
- io::Printer* printer) const {
- GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
-
- Formatter format(printer, variables_);
- format("$field$ = nullptr;\n");
-}
-
void MessageFieldGenerator::GenerateCopyConstructorCode(
io::Printer* printer) const {
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
@@ -453,9 +457,7 @@ void MessageFieldGenerator::GenerateCopyConstructorCode(
Formatter format(printer, variables_);
format(
"if (from._internal_has_$name$()) {\n"
- " $field$ = new $type$(*from.$field$);\n"
- "} else {\n"
- " $field$ = nullptr;\n"
+ " _this->$field$ = new $type$(*from.$field$);\n"
"}\n");
}
@@ -500,10 +502,26 @@ void MessageFieldGenerator::GenerateIsInitialized(io::Printer* printer) const {
"}\n");
}
-void MessageFieldGenerator::GenerateConstinitInitializer(
+void MessageFieldGenerator::GenerateConstexprAggregateInitializer(
io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$name$_(nullptr)");
+ format("/*decltype($field$)*/nullptr");
+}
+
+void MessageFieldGenerator::GenerateCopyAggregateInitializer(
+ io::Printer* printer) const {
+ Formatter format(printer, variables_);
+ format("decltype($field$){nullptr}");
+}
+
+void MessageFieldGenerator::GenerateAggregateInitializer(
+ io::Printer* printer) const {
+ Formatter format(printer, variables_);
+ if (ShouldSplit(descriptor_, options_)) {
+ format("decltype(Impl_::Split::$name$_){nullptr}");
+ return;
+ }
+ format("decltype($field$){nullptr}");
}
// ===================================================================
@@ -830,7 +848,7 @@ void RepeatedMessageFieldGenerator::GenerateMergingCode(
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_);
- format("$field$.MergeFrom(from.$field$);\n");
+ format("_this->$field$.MergeFrom(from.$field$);\n");
}
void RepeatedMessageFieldGenerator::GenerateSwappingCode(
@@ -846,6 +864,18 @@ void RepeatedMessageFieldGenerator::GenerateConstructorCode(
// Not needed for repeated fields.
}
+void RepeatedMessageFieldGenerator::GenerateDestructorCode(
+ io::Printer* printer) const {
+ GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
+
+ Formatter format(printer, variables_);
+ if (implicit_weak_field_) {
+ format("$field$.~WeakRepeatedPtrField();\n");
+ } else {
+ format("$field$.~RepeatedPtrField();\n");
+ }
+}
+
void RepeatedMessageFieldGenerator::GenerateSerializeWithCachedSizesToArray(
io::Printer* printer) const {
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
@@ -922,12 +952,6 @@ void RepeatedMessageFieldGenerator::GenerateIsInitialized(
}
}
-void RepeatedMessageFieldGenerator::GenerateConstinitInitializer(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("$name$_()");
-}
-
} // namespace cpp
} // namespace compiler
} // namespace protobuf
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message_field.h
index 528b419704..70c42c0eac 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message_field.h
@@ -38,8 +38,8 @@
#include <map>
#include <string>
-#include <google/protobuf/compiler/cpp/cpp_field.h>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
+#include <google/protobuf/compiler/cpp/field.h>
+#include <google/protobuf/compiler/cpp/helpers.h>
namespace google {
namespace protobuf {
@@ -67,13 +67,16 @@ class MessageFieldGenerator : public FieldGenerator {
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 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 GenerateConstinitInitializer(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_;
@@ -124,11 +127,11 @@ class RepeatedMessageFieldGenerator : public FieldGenerator {
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;
- void GenerateConstinitInitializer(io::Printer* printer) const override;
private:
const bool implicit_weak_field_;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_layout_helper.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message_layout_helper.h
index 80860053f1..a8813a1f22 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_layout_helper.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/message_layout_helper.h
@@ -36,7 +36,7 @@
#define GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_LAYOUT_HELPER_H__
#include <google/protobuf/descriptor.h>
-#include <google/protobuf/compiler/cpp/cpp_options.h>
+#include <google/protobuf/compiler/cpp/options.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_names.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/names.h
index 39563cd0cd..8220f7dde8 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_names.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/names.h
@@ -51,9 +51,9 @@ namespace cpp {
//
// For example, if you had:
// package foo.bar;
-// message Baz { message Qux {} }
+// message Baz { message Moo {} }
// Then the non-qualified version would be:
-// Baz_Qux
+// Baz_Moo
TProtoStringType ClassName(const Descriptor* descriptor);
TProtoStringType ClassName(const EnumDescriptor* enum_descriptor);
@@ -61,9 +61,9 @@ TProtoStringType ClassName(const EnumDescriptor* enum_descriptor);
//
// For example, if you had:
// package foo.bar;
-// message Baz { message Qux {} }
-// Then the qualified ClassName for Qux would be:
-// ::foo::bar::Baz_Qux
+// 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);
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_options.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/options.h
index 48512a64c8..14546ca618 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_options.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/options.h
@@ -80,9 +80,10 @@ struct Options {
bool opensource_runtime = false;
bool annotate_accessor = false;
bool unused_field_stripping = false;
- bool unverified_lazy_message_sets = true;
- bool eagerly_verified_lazy = true;
+ bool 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;
#ifdef PROTOBUF_STABLE_EXPERIMENTS
bool force_eagerly_verified_lazy = true;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/padding_optimizer.cc
index f48ba718a5..20910520d6 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/padding_optimizer.cc
@@ -28,9 +28,9 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <google/protobuf/compiler/cpp/cpp_padding_optimizer.h>
+#include <google/protobuf/compiler/cpp/padding_optimizer.h>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
+#include <google/protobuf/compiler/cpp/helpers.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/padding_optimizer.h
index ebdb17de61..9c76f38c47 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/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/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/cpp_parse_function_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/parse_function_generator.cc
index e033856f0c..1b97182acd 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/parse_function_generator.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/compiler/cpp/cpp_parse_function_generator.h>
+#include <google/protobuf/compiler/cpp/parse_function_generator.h>
#include <algorithm>
#include <limits>
@@ -36,7 +36,7 @@
#include <utility>
#include <google/protobuf/wire_format.h>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
+#include <google/protobuf/compiler/cpp/helpers.h>
namespace google {
namespace protobuf {
@@ -231,8 +231,7 @@ std::vector<const FieldDescriptor*> FilterMiniParsedFields(
break;
case FieldDescriptor::TYPE_ENUM:
- if (field->is_repeated() &&
- !HasPreservingUnknownEnumSemantics(field)) {
+ 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
@@ -244,15 +243,15 @@ std::vector<const FieldDescriptor*> FilterMiniParsedFields(
}
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_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:
@@ -291,8 +290,9 @@ TailCallTableInfo::TailCallTableInfo(
GOOGLE_LOG_IF(DFATAL, ordered_fields.empty())
<< "Invalid message: " << descriptor->full_name() << " has "
<< oneof_count << " oneof declarations, but no fields";
- aux_entries.push_back(StrCat(
- "_fl::Offset{offsetof(", ClassName(descriptor), ", _oneof_case_)}"));
+ aux_entries.push_back(StrCat("_fl::Offset{offsetof(",
+ ClassName(descriptor),
+ ", _impl_._oneof_case_)}"));
}
// If this message has any inlined string fields, store the donation state
@@ -301,7 +301,7 @@ TailCallTableInfo::TailCallTableInfo(
aux_entries.resize(2); // pad if necessary
aux_entries[1] =
StrCat("_fl::Offset{offsetof(", ClassName(descriptor),
- ", _inlined_string_donated_)}");
+ ", _impl_._inlined_string_donated_)}");
}
// Fill in mini table entries.
@@ -444,7 +444,7 @@ ParseFunctionGenerator::ParseFunctionGenerator(
inlined_string_indices, scc_analyzer));
}
SetCommonVars(options_, &variables_);
- SetCommonMessageDataVariables(&variables_);
+ SetCommonMessageDataVariables(descriptor_, &variables_);
SetUnknownFieldsVariable(descriptor_, options_, &variables_);
variables_["classname"] = ClassName(descriptor, false);
}
@@ -547,13 +547,13 @@ void ParseFunctionGenerator::GenerateTailcallFallbackFunction(
if (num_hasbits_ > 0) {
// Sync hasbits
- format("typed_msg->_has_bits_[0] = hasbits;\n");
+ format("typed_msg->_impl_._has_bits_[0] = hasbits;\n");
}
format("arc_ui32 tag = data.tag();\n");
format.Set("msg", "typed_msg->");
format.Set("this", "typed_msg");
- format.Set("has_bits", "typed_msg->_has_bits_");
+ format.Set("has_bits", "typed_msg->_impl_._has_bits_");
format.Set("next_tag", "goto next_tag");
GenerateParseIterationBody(format, descriptor_,
tc_table_info_->fallback_fields);
@@ -649,7 +649,7 @@ void ParseFunctionGenerator::GenerateLoopingParseFunction(Formatter& format) {
format("_Internal::HasBits has_bits{};\n");
format.Set("has_bits", "has_bits");
} else {
- format.Set("has_bits", "_has_bits_");
+ format.Set("has_bits", "_impl_._has_bits_");
}
format.Set("next_tag", "continue");
format("while (!ctx->Done(&ptr)) {\n");
@@ -665,7 +665,7 @@ void ParseFunctionGenerator::GenerateLoopingParseFunction(Formatter& format) {
format.Outdent();
format("message_done:\n");
- if (hasbits_size) format(" _has_bits_.Or(has_bits);\n");
+ if (hasbits_size) format(" _impl_._has_bits_.Or(has_bits);\n");
format(
" return ptr;\n"
@@ -774,7 +774,7 @@ void ParseFunctionGenerator::GenerateTailCallTable(Formatter& format) {
{
auto header_scope = format.ScopedIndent();
if (num_hasbits_ > 0 || IsMapEntryMessage(descriptor_)) {
- format("PROTOBUF_FIELD_OFFSET($classname$, _has_bits_),\n");
+ format("PROTOBUF_FIELD_OFFSET($classname$, _impl_._has_bits_),\n");
} else {
format("0, // no _has_bits_\n");
}
@@ -899,11 +899,14 @@ void ParseFunctionGenerator::GenerateFastFieldEntries(Formatter& format) {
if (info.func_name.empty()) {
format("{::_pbi::TcParser::MiniParse, {}},\n");
} else {
+ bool cold = ShouldSplit(info.field, options_);
format(
"{$1$,\n"
- " {$2$, $3$, $4$, PROTOBUF_FIELD_OFFSET($classname$, $5$)}},\n",
+ " {$2$, $3$, $4$, PROTOBUF_FIELD_OFFSET($classname$$5$, $6$)}},\n",
info.func_name, info.coded_tag, info.hasbit_idx, info.aux_idx,
- FieldMemberName(info.field));
+ cold ? "::Impl_::Split" : "",
+ cold ? FieldName(info.field) + "_"
+ : FieldMemberName(info.field, /*cold=*/false));
}
}
}
@@ -1048,8 +1051,11 @@ void ParseFunctionGenerator::GenerateFieldEntries(Formatter& format) {
format("/* weak */ 0, 0, 0, 0");
} else {
const OneofDescriptor* oneof = field->real_containing_oneof();
- format("PROTOBUF_FIELD_OFFSET($classname$, $1$), $2$, $3$,\n ",
- FieldMemberName(field),
+ 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_);
}
@@ -1550,7 +1556,8 @@ void ParseFunctionGenerator::GenerateFieldSwitch(
format.Indent();
for (const auto* field : fields) {
- format.Set("field", FieldMemberName(field));
+ bool cold = ShouldSplit(field, options_);
+ format.Set("field", FieldMemberName(field, cold));
PrintFieldComment(format, field);
format("case $1$:\n", field->number());
format.Indent();
@@ -1559,6 +1566,9 @@ void ParseFunctionGenerator::GenerateFieldSwitch(
format("if (PROTOBUF_PREDICT_TRUE(static_cast<$uint8$>(tag) == $1$)) {\n",
expected_tag & 0xFF);
format.Indent();
+ if (cold) {
+ format("$msg$PrepareSplitMessageForWrite();\n");
+ }
auto wiretype = WireFormatLite::GetTagWireType(expected_tag);
arc_ui32 tag = WireFormatLite::MakeTag(field->number(), wiretype);
int tag_size = io::CodedOutputStream::VarintSize32(tag);
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/parse_function_generator.h
index 3c8209534a..7e2b674852 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/parse_function_generator.h
@@ -38,8 +38,8 @@
#include <google/protobuf/io/printer.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/wire_format_lite.h>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
-#include <google/protobuf/compiler/cpp/cpp_options.h>
+#include <google/protobuf/compiler/cpp/helpers.h>
+#include <google/protobuf/compiler/cpp/options.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/primitive_field.cc
index 910b59a21a..9dbf16ae7e 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/primitive_field.cc
@@ -32,12 +32,12 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/cpp/cpp_primitive_field.h>
+#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/cpp_helpers.h>
+#include <google/protobuf/compiler/cpp/helpers.h>
namespace google {
namespace protobuf {
@@ -105,8 +105,9 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
(*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);
+ MakeVarintCachedSizeFieldName(descriptor, cold);
(*variables)["tag"] = StrCat(internal::WireFormat::MakeTag(descriptor));
int fixed_size = FixedSize(descriptor->type());
if (fixed_size != -1) {
@@ -165,6 +166,7 @@ void PrimitiveFieldGenerator::GenerateInlineAccessorDefinitions(
" $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"
@@ -178,7 +180,7 @@ void PrimitiveFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
void PrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
- format("_internal_set_$name$(from._internal_$name$());\n");
+ format("_this->_internal_set_$name$(from._internal_$name$());\n");
}
void PrimitiveFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
@@ -186,16 +188,10 @@ void PrimitiveFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
format("swap($field$, other->$field$);\n");
}
-void PrimitiveFieldGenerator::GenerateConstructorCode(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("$field$ = $default$;\n");
-}
-
void PrimitiveFieldGenerator::GenerateCopyConstructorCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$field$ = from.$field$;\n");
+ format("_this->$field$ = from.$field$;\n");
}
void PrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray(
@@ -230,10 +226,26 @@ void PrimitiveFieldGenerator::GenerateByteSize(io::Printer* printer) const {
}
}
-void PrimitiveFieldGenerator::GenerateConstinitInitializer(
+void PrimitiveFieldGenerator::GenerateConstexprAggregateInitializer(
io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$name$_($default$)");
+ 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$){}");
}
// ===================================================================
@@ -398,7 +410,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateClearingCode(
void RepeatedPrimitiveFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$field$.MergeFrom(from.$field$);\n");
+ format("_this->$field$.MergeFrom(from.$field$);\n");
}
void RepeatedPrimitiveFieldGenerator::GenerateSwappingCode(
@@ -407,6 +419,12 @@ void RepeatedPrimitiveFieldGenerator::GenerateSwappingCode(
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_);
@@ -460,7 +478,8 @@ void RepeatedPrimitiveFieldGenerator::GenerateByteSize(
format(
"if (data_size > 0) {\n"
" total_size += $tag_size$ +\n"
- " ::_pbi::WireFormatLite::Int32Size(static_cast<$int32$>(data_size));\n"
+ " "
+ "::_pbi::WireFormatLite::Int32Size(static_cast<$int32$>(data_size));\n"
"}\n");
if (FixedSize(descriptor_->type()) == -1) {
format(
@@ -480,13 +499,37 @@ void RepeatedPrimitiveFieldGenerator::GenerateByteSize(
format("}\n");
}
-void RepeatedPrimitiveFieldGenerator::GenerateConstinitInitializer(
+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("$name$_()");
+ 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_)) {
- format("\n, $cached_byte_size_name$(0)");
+ // std::atomic has no move constructor.
+ format("\n, /*decltype($cached_byte_size_field$)*/{0}");
}
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/primitive_field.h
index 77ac598e90..bb8a08aa14 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/primitive_field.h
@@ -38,7 +38,7 @@
#include <map>
#include <string>
-#include <google/protobuf/compiler/cpp/cpp_field.h>
+#include <google/protobuf/compiler/cpp/field.h>
namespace google {
namespace protobuf {
@@ -58,12 +58,15 @@ class PrimitiveFieldGenerator : public FieldGenerator {
void GenerateClearingCode(io::Printer* printer) const override;
void GenerateMergingCode(io::Printer* printer) const override;
void GenerateSwappingCode(io::Printer* printer) const override;
- void GenerateConstructorCode(io::Printer* printer) const override;
+ void 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 GenerateConstinitInitializer(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);
@@ -99,11 +102,17 @@ class RepeatedPrimitiveFieldGenerator : public FieldGenerator {
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 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 GenerateConstinitInitializer(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);
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/service.cc
index 7bf589fa38..fae7128a09 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/service.cc
@@ -32,11 +32,11 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/cpp/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/cpp_helpers.h>
+#include <google/protobuf/compiler/cpp/helpers.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/service.h
index d237f9d732..56982cf566 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/service.h
@@ -39,7 +39,7 @@
#include <string>
#include <google/protobuf/descriptor.h>
-#include <google/protobuf/compiler/cpp/cpp_options.h>
+#include <google/protobuf/compiler/cpp/options.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/string_field.cc
index 4d8744976b..5f30d3b511 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/string_field.cc
@@ -32,11 +32,11 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/cpp/cpp_string_field.h>
+#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/cpp_helpers.h>
+#include <google/protobuf/compiler/cpp/helpers.h>
#include <google/protobuf/descriptor.pb.h>
@@ -115,11 +115,7 @@ void StringFieldGenerator::GeneratePrivateMembers(io::Printer* printer) const {
// allocating arena is null. This is required to support message-owned
// arena (go/path-to-arenas) where a root proto is destroyed but
// InlinedStringField may have arena-allocated memory.
- //
- // `_init_inline_xxx` is used for initializing default instances.
- format(
- "union { ::$proto_ns$::internal::InlinedStringField $name$_; };\n"
- "static std::true_type _init_inline_$name$_;\n");
+ format("::$proto_ns$::internal::InlinedStringField $name$_;\n");
}
}
@@ -130,6 +126,10 @@ void StringFieldGenerator::GenerateStaticMembers(io::Printer* printer) const {
"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(
@@ -215,6 +215,7 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
"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"
@@ -226,6 +227,7 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
"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(), "
@@ -240,6 +242,7 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
}
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"
@@ -280,6 +283,7 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
format(
"inline TProtoStringType* $classname$::$release_name$() {\n"
"$annotate_release$"
+ "$maybe_prepare_split_message$"
" // @@protoc_insertion_point(field_release:$full_name$)\n");
if (HasHasbit(descriptor_)) {
@@ -311,6 +315,7 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
format(
"}\n"
"inline void $classname$::set_allocated_$name$(TProtoStringType* $name$) {\n"
+ "$maybe_prepare_split_message$"
" if ($name$ != nullptr) {\n"
" $set_hasbit$\n"
" } else {\n"
@@ -403,7 +408,7 @@ void StringFieldGenerator::GenerateMessageClearingCode(
void StringFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
// TODO(gpike): improve this
- format("_internal_set_$name$(from._internal_$name$());\n");
+ format("_this->_internal_set_$name$(from._internal_$name$());\n");
}
void StringFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
@@ -440,12 +445,27 @@ void StringFieldGenerator::GenerateConstructorCode(io::Printer* printer) const {
}
}
+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 (&$field$) ::_pbi::InlinedStringField();\n");
+ format("new (&_this->$field$) ::_pbi::InlinedStringField();\n");
}
if (HasHasbit(descriptor_)) {
@@ -458,13 +478,13 @@ void StringFieldGenerator::GenerateCopyConstructorCode(
if (!inlined_) {
format(
- "$field$.Set(from._internal_$name$(), \n"
- " GetArenaForAllocation());\n");
+ "_this->$field$.Set(from._internal_$name$(), \n"
+ " _this->GetArenaForAllocation());\n");
} else {
format(
- "$field$.Set(from._internal_$name$(),\n"
- " GetArenaForAllocation(), _internal_$name$_donated(), "
- "&$donating_states_word$, $mask_for_undonate$, this);\n");
+ "_this->$field$.Set(from._internal_$name$(),\n"
+ " _this->GetArenaForAllocation(), _this->_internal_$name$_donated(), "
+ "&_this->$donating_states_word$, $mask_for_undonate$, _this);\n");
}
format.Outdent();
@@ -474,6 +494,10 @@ void StringFieldGenerator::GenerateCopyConstructorCode(
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;
}
@@ -481,6 +505,7 @@ void StringFieldGenerator::GenerateDestructorCode(io::Printer* printer) const {
// 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");
}
@@ -522,22 +547,43 @@ void StringFieldGenerator::GenerateByteSize(io::Printer* printer) const {
" this->_internal_$name$());\n");
}
-void StringFieldGenerator::GenerateConstinitInitializer(
+void StringFieldGenerator::GenerateConstexprAggregateInitializer(
io::Printer* printer) const {
Formatter format(printer, variables_);
if (inlined_) {
- format("$name$_(nullptr, false)");
+ format("/*decltype($field$)*/{nullptr, false}");
return;
}
if (descriptor_->default_value_string().empty()) {
format(
- "$name$_(&::_pbi::fixed_address_empty_string, "
- "::_pbi::ConstantInitialized{})");
+ "/*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("$name$_(nullptr, ::_pbi::ConstantInitialized{})");
+ format("decltype($field$)(arena)");
}
}
+void StringFieldGenerator::GenerateCopyAggregateInitializer(
+ io::Printer* printer) const {
+ Formatter format(printer, variables_);
+ format("decltype($field$){}");
+}
+
// ===================================================================
StringOneofFieldGenerator::StringOneofFieldGenerator(
@@ -858,7 +904,7 @@ void RepeatedStringFieldGenerator::GenerateClearingCode(
void RepeatedStringFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
- format("$field$.MergeFrom(from.$field$);\n");
+ format("_this->$field$.MergeFrom(from.$field$);\n");
}
void RepeatedStringFieldGenerator::GenerateSwappingCode(
@@ -867,6 +913,12 @@ void RepeatedStringFieldGenerator::GenerateSwappingCode(
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_);
@@ -899,12 +951,6 @@ void RepeatedStringFieldGenerator::GenerateByteSize(
"}\n");
}
-void RepeatedStringFieldGenerator::GenerateConstinitInitializer(
- io::Printer* printer) const {
- Formatter format(printer, variables_);
- format("$name$_()");
-}
-
} // namespace cpp
} // namespace compiler
} // namespace protobuf
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/string_field.h
index 845bf073a9..db5f18bfb7 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/string_field.h
@@ -38,7 +38,7 @@
#include <map>
#include <string>
-#include <google/protobuf/compiler/cpp/cpp_field.h>
+#include <google/protobuf/compiler/cpp/field.h>
namespace google {
namespace protobuf {
@@ -63,13 +63,17 @@ class StringFieldGenerator : public FieldGenerator {
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 GenerateConstinitInitializer(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;
@@ -112,11 +116,13 @@ class RepeatedStringFieldGenerator : public FieldGenerator {
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 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 GenerateConstinitInitializer(io::Printer* printer) const override;
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedStringFieldGenerator);
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 186fa27e5b..55fb60c504 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
@@ -109,7 +109,7 @@ void EnumOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) {
printer->Print(
variables_,
"$oneof_name$_ = input.ReadEnum();\n"
- "$oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n");
+ "$oneof_name$Case_ = $oneof_property_name$OneofCase.$oneof_case_name$;\n");
}
void EnumOneofFieldGenerator::GenerateSerializationCode(io::Printer* printer) {
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 b887a28734..5d1e5f0a99 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,6 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_ENUM_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_CSHARP_ENUM_FIELD_H__
-#include <string>
-
#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/compiler/csharp/csharp_primitive_field.h>
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 ec39b10888..7b1806e192 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
@@ -130,8 +130,9 @@ void FieldGeneratorBase::SetCommonOneofFieldVariables(
} else {
(*variables)["has_property_check"] =
oneof_name() + "Case_ == " + oneof_property_name() +
- "OneofCase." + property_name();
+ "OneofCase." + oneof_case_name();
}
+ (*variables)["oneof_case_name"] = oneof_case_name();
(*variables)["oneof_property_name"] = oneof_property_name();
}
@@ -187,6 +188,10 @@ void FieldGeneratorBase::AddPublicMemberAttributes(io::Printer* printer) {
WriteGeneratedCodeAttributes(printer);
}
+TProtoStringType FieldGeneratorBase::oneof_case_name() {
+ return GetOneofCaseName(descriptor_);
+}
+
TProtoStringType FieldGeneratorBase::oneof_property_name() {
return UnderscoresToCamelCase(descriptor_->containing_oneof()->name(), true);
}
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 154f67ae9c..e553202792 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
@@ -85,6 +85,7 @@ class FieldGeneratorBase : public SourceGeneratorBase {
std::map<TProtoStringType, TProtoStringType>* variables);
TProtoStringType oneof_property_name();
+ TProtoStringType oneof_case_name();
TProtoStringType oneof_name();
TProtoStringType property_name();
TProtoStringType name();
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 b80131b024..8b5d09e531 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
@@ -393,6 +393,13 @@ TProtoStringType GetPropertyName(const FieldDescriptor* descriptor) {
return property_name;
}
+TProtoStringType GetOneofCaseName(const FieldDescriptor* descriptor) {
+ // The name in a oneof case enum is the same as for the property, but as we always have a "None"
+ // value as well, we need to reserve that by appending an underscore.
+ TProtoStringType property_name = GetPropertyName(descriptor);
+ return property_name == "None" ? "None_" : property_name;
+}
+
TProtoStringType GetOutputFile(const FileDescriptor* descriptor,
const TProtoStringType file_extension,
const bool generate_directories,
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 db93b6211e..0a325464dc 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
@@ -87,6 +87,8 @@ TProtoStringType GetFieldConstantName(const FieldDescriptor* field);
TProtoStringType GetPropertyName(const FieldDescriptor* descriptor);
+TProtoStringType GetOneofCaseName(const FieldDescriptor* descriptor);
+
int GetFixedSize(FieldDescriptor::Type type);
TProtoStringType UnderscoresToCamelCase(const TProtoStringType& input,
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 e8212498c9..b03f65b74a 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,6 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_MAP_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_CSHARP_MAP_FIELD_H__
-#include <string>
-
#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/compiler/csharp/csharp_field_base.h>
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 cc966488f7..e96b329cab 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
@@ -238,8 +238,8 @@ void MessageGenerator::Generate(io::Printer* printer) {
printer->Print("None = 0,\n");
for (int j = 0; j < oneof->field_count(); j++) {
const FieldDescriptor* field = oneof->field(j);
- printer->Print("$field_property_name$ = $index$,\n",
- "field_property_name", GetPropertyName(field),
+ printer->Print("$oneof_case_name$ = $index$,\n",
+ "oneof_case_name", GetOneofCaseName(field),
"index", StrCat(field->number()));
}
printer->Outdent();
@@ -403,10 +403,10 @@ void MessageGenerator::GenerateCloningCode(io::Printer* printer) {
for (int j = 0; j < oneof->field_count(); j++) {
const FieldDescriptor* field = oneof->field(j);
std::unique_ptr<FieldGeneratorBase> generator(CreateFieldGeneratorInternal(field));
- vars["field_property_name"] = GetPropertyName(field);
+ vars["oneof_case_name"] = GetOneofCaseName(field);
printer->Print(
vars,
- "case $property_name$OneofCase.$field_property_name$:\n");
+ "case $property_name$OneofCase.$oneof_case_name$:\n");
printer->Indent();
generator->GenerateCloningCode(printer);
printer->Print("break;\n");
@@ -635,10 +635,10 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) {
printer->Indent();
for (int j = 0; j < oneof->field_count(); j++) {
const FieldDescriptor* field = oneof->field(j);
- vars["field_property_name"] = GetPropertyName(field);
+ vars["oneof_case_name"] = GetOneofCaseName(field);
printer->Print(
vars,
- "case $property_name$OneofCase.$field_property_name$:\n");
+ "case $property_name$OneofCase.$oneof_case_name$:\n");
printer->Indent();
std::unique_ptr<FieldGeneratorBase> generator(CreateFieldGeneratorInternal(field));
generator->GenerateMergingCode(printer);
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 034fbd9242..487d01ddef 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
@@ -225,7 +225,7 @@ void MessageOneofFieldGenerator::GenerateMembers(io::Printer* printer) {
" get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : null; }\n"
" set {\n"
" $oneof_name$_ = value;\n"
- " $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$property_name$;\n"
+ " $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$oneof_case_name$;\n"
" }\n"
"}\n");
if (SupportsPresenceApi(descriptor_)) {
@@ -236,7 +236,7 @@ void MessageOneofFieldGenerator::GenerateMembers(io::Printer* printer) {
printer->Print(
variables_,
"$access_level$ bool Has$property_name$ {\n"
- " get { return $oneof_name$Case_ == $oneof_property_name$OneofCase.$property_name$; }\n"
+ " get { return $oneof_name$Case_ == $oneof_property_name$OneofCase.$oneof_case_name$; }\n"
"}\n");
printer->Print(
variables_,
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 1da8bea08d..2da1d71701 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,6 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_MESSAGE_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_CSHARP_MESSAGE_FIELD_H__
-#include <string>
-
#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/compiler/csharp/csharp_field_base.h>
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 9df1dd6abd..e7d51168d1 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
@@ -296,7 +296,7 @@ void PrimitiveOneofFieldGenerator::GenerateMembers(io::Printer* printer) {
}
printer->Print(
variables_,
- " $oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n"
+ " $oneof_name$Case_ = $oneof_property_name$OneofCase.$oneof_case_name$;\n"
" }\n"
"}\n");
if (SupportsPresenceApi(descriptor_)) {
@@ -307,7 +307,7 @@ void PrimitiveOneofFieldGenerator::GenerateMembers(io::Printer* printer) {
printer->Print(
variables_,
"$access_level$ bool Has$property_name$ {\n"
- " get { return $oneof_name$Case_ == $oneof_property_name$OneofCase.$property_name$; }\n"
+ " get { return $oneof_name$Case_ == $oneof_property_name$OneofCase.$oneof_case_name$; }\n"
"}\n");
printer->Print(
variables_,
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 f0dbfad791..e98c3698a0 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,6 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_PRIMITIVE_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_CSHARP_PRIMITIVE_FIELD_H__
-#include <string>
-
#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/compiler/csharp/csharp_field_base.h>
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 d462273c4a..c142195cf5 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
@@ -128,7 +128,7 @@ void ReflectionClassGenerator::WriteIntroduction(io::Printer* printer) {
"// Generated by the protocol buffer compiler. DO NOT EDIT!\n"
"// source: $file_name$\n"
"// </auto-generated>\n"
- "#pragma warning disable 1591, 0612, 3021\n"
+ "#pragma warning disable 1591, 0612, 3021, 8981\n"
"#region Designer generated code\n"
"\n"
"using pb = global::Google.Protobuf;\n"
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 23d3c0daba..6d6717cc02 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,6 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_ENUM_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_ENUM_FIELD_H__
-#include <string>
-
#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/compiler/csharp/csharp_field_base.h>
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 c584f2bd6f..ea252ced34 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,6 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_MESSAGE_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_MESSAGE_FIELD_H__
-#include <string>
-
#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/compiler/csharp/csharp_field_base.h>
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 36be81d069..2b470e12c9 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,6 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_PRIMITIVE_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_PRIMITIVE_FIELD_H__
-#include <string>
-
#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/compiler/csharp/csharp_field_base.h>
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 578f54ba69..e638dd862a 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
@@ -233,7 +233,7 @@ void WrapperOneofFieldGenerator::GenerateMembers(io::Printer* printer) {
" get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : ($type_name$) null; }\n"
" set {\n"
" $oneof_name$_ = value;\n"
- " $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$property_name$;\n"
+ " $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$oneof_case_name$;\n"
" }\n"
"}\n");
if (SupportsPresenceApi(descriptor_)) {
@@ -244,7 +244,7 @@ void WrapperOneofFieldGenerator::GenerateMembers(io::Printer* printer) {
printer->Print(
variables_,
"$access_level$ bool Has$property_name$ {\n"
- " get { return $oneof_name$Case_ == $oneof_property_name$OneofCase.$property_name$; }\n"
+ " get { return $oneof_name$Case_ == $oneof_property_name$OneofCase.$oneof_case_name$; }\n"
"}\n");
printer->Print(
variables_,
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 57c4f5e76b..cc8a3137d6 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,6 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_WRAPPER_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_CSHARP_WRAPPER_FIELD_H__
-#include <string>
-
#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/compiler/csharp/csharp_field_base.h>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/context.cc
index 9ee161f7f3..463aa1f5ab 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/context.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/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/java_field.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.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>
namespace google {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/context.h
index 3fa6af1778..c224ab73f5 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/context.h
@@ -36,7 +36,7 @@
#include <vector>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/compiler/java/java_options.h>
+#include <google/protobuf/compiler/java/options.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/doc_comment.cc
index 2252d122fa..ec7dce7d34 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/doc_comment.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_doc_comment.h>
+#include <google/protobuf/compiler/java/doc_comment.h>
#include <vector>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/doc_comment.h
index 52d6f77474..52d6f77474 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/doc_comment.h
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum.cc
index 8574527f0b..5ba5e630c0 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum.cc
@@ -32,19 +32,22 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/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/java_context.h>
-#include <google/protobuf/compiler/java/java_doc_comment.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/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>
+// Must be last.
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -390,3 +393,5 @@ bool EnumGenerator::CanUseEnumValues() {
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum.h
index 0a2c363b53..0a2c363b53 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum.h
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field.cc
index 59df1132e7..97e1742cc9 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_enum_field.h>
+#include <google/protobuf/compiler/java/enum_field.h>
#include <cstdint>
#include <map>
@@ -43,10 +43,13 @@
#include <google/protobuf/io/printer.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/java/java_context.h>
-#include <google/protobuf/compiler/java/java_doc_comment.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/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>
+
+// Must be last.
+#include <google/protobuf/port_def.inc>
namespace google {
namespace protobuf {
@@ -280,7 +283,7 @@ void ImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$public var $kt_name$: $kt_type$\n"
+ "$kt_deprecation$ 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,7 +294,7 @@ void ImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
/* builder */ false);
printer->Print(variables_,
- "public fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
@@ -299,7 +302,7 @@ void ImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(
variables_,
- "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
" return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
"}\n");
}
@@ -859,7 +862,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers(
"}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
- LIST_INDEXED_GETTER,
+ LIST_INDEXED_SETTER,
/* builder */ true);
printer->Print(
variables_,
@@ -1082,12 +1085,12 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$ public val $kt_name$: "
+ "$kt_deprecation$ val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -1100,7 +1103,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -1112,7 +1115,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun com.google.protobuf.kotlin.DslList"
+ "inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: $kt_type$) {\n"
" add(value)\n"
@@ -1123,7 +1126,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -1136,7 +1139,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -1148,7 +1151,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "public operator fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -1159,7 +1162,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
@@ -1174,3 +1177,5 @@ TProtoStringType RepeatedImmutableEnumFieldGenerator::GetBoxedType() const {
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field.h
index 3fb65ae546..6cf28fb126 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field.h
@@ -38,7 +38,7 @@
#include <map>
#include <string>
-#include <google/protobuf/compiler/java/java_field.h>
+#include <google/protobuf/compiler/java/field.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field_lite.cc
index 33cff57cf3..c90939ada6 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field_lite.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_enum_field_lite.h>
+#include <google/protobuf/compiler/java/enum_field_lite.h>
#include <cstdint>
#include <map>
@@ -43,10 +43,13 @@
#include <google/protobuf/io/printer.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/java/java_context.h>
-#include <google/protobuf/compiler/java/java_doc_comment.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/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>
+
+// Must be last.
+#include <google/protobuf/port_def.inc>
namespace google {
namespace protobuf {
@@ -285,7 +288,7 @@ void ImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$public var $kt_name$: $kt_type$\n"
+ "$kt_deprecation$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,7 +299,7 @@ void ImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
/* builder */ false);
printer->Print(variables_,
- "public fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
@@ -304,7 +307,7 @@ void ImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(
variables_,
- "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
" return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
"}\n");
}
@@ -824,12 +827,12 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$ public val $kt_name$: "
+ "$kt_deprecation$ val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -842,7 +845,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -854,7 +857,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun com.google.protobuf.kotlin.DslList"
+ "inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: $kt_type$) {\n"
" add(value)\n"
@@ -865,7 +868,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -878,7 +881,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -890,7 +893,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "public operator fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -901,7 +904,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
@@ -916,3 +919,5 @@ TProtoStringType RepeatedImmutableEnumFieldLiteGenerator::GetBoxedType() const {
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field_lite.h
index eb8e8cd313..df2f6fa10a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_field_lite.h
@@ -39,7 +39,7 @@
#include <map>
#include <string>
-#include <google/protobuf/compiler/java/java_field.h>
+#include <google/protobuf/compiler/java/field.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_lite.cc
index 7ec742d19f..7fdd4ab9b8 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_lite.cc
@@ -32,17 +32,17 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/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/java_context.h>
-#include <google/protobuf/compiler/java/java_doc_comment.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/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>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_lite.h
index 50f3fe7b1a..50f3fe7b1a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum_lite.h
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/extension.cc
index d90994503d..0983366c4f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/extension.cc
@@ -32,14 +32,17 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/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/java_context.h>
-#include <google/protobuf/compiler/java/java_doc_comment.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/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>
+
+// Must be last.
+#include <google/protobuf/port_def.inc>
namespace google {
namespace protobuf {
@@ -170,3 +173,5 @@ int ImmutableExtensionGenerator::GenerateRegistrationCode(
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/extension.h
index f9bd326f9b..f9bd326f9b 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/extension.h
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/extension_lite.cc
index 0135d9ee03..d51d9d2ba8 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/extension_lite.cc
@@ -28,14 +28,17 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <google/protobuf/compiler/java/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/java_context.h>
-#include <google/protobuf/compiler/java/java_doc_comment.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/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>
+
+// Must be last.
+#include <google/protobuf/port_def.inc>
namespace google {
namespace protobuf {
@@ -113,3 +116,5 @@ int ImmutableExtensionLiteGenerator::GenerateRegistrationCode(
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/extension_lite.h
index 3e13db7028..0d013c862c 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/extension_lite.h
@@ -35,7 +35,7 @@
#include <string>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/compiler/java/java_extension.h>
+#include <google/protobuf/compiler/java/extension.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/field.cc
index 9373e568cf..84487ac7a1 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/field.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_field.h>
+#include <google/protobuf/compiler/java/field.h>
#include <memory>
@@ -41,18 +41,18 @@
#include <google/protobuf/io/printer.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
-#include <google/protobuf/compiler/java/java_context.h>
-#include <google/protobuf/compiler/java/java_enum_field.h>
-#include <google/protobuf/compiler/java/java_enum_field_lite.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_map_field.h>
-#include <google/protobuf/compiler/java/java_map_field_lite.h>
-#include <google/protobuf/compiler/java/java_message_field.h>
-#include <google/protobuf/compiler/java/java_message_field_lite.h>
-#include <google/protobuf/compiler/java/java_primitive_field.h>
-#include <google/protobuf/compiler/java/java_primitive_field_lite.h>
-#include <google/protobuf/compiler/java/java_string_field.h>
-#include <google/protobuf/compiler/java/java_string_field_lite.h>
+#include <google/protobuf/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>
namespace google {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/field.h
index 481fbdb456..481fbdb456 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/field.h
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/file.cc
index c2261ddfeb..401599765b 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/file.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_file.h>
+#include <google/protobuf/compiler/java/file.h>
#include <memory>
#include <set>
@@ -42,18 +42,21 @@
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/dynamic_message.h>
#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/java/java_context.h>
-#include <google/protobuf/compiler/java/java_enum.h>
-#include <google/protobuf/compiler/java/java_enum_lite.h>
-#include <google/protobuf/compiler/java/java_extension.h>
-#include <google/protobuf/compiler/java/java_generator_factory.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_message.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/compiler/java/java_service.h>
-#include <google/protobuf/compiler/java/java_shared_code_generator.h>
+#include <google/protobuf/compiler/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>
+// Must be last.
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -247,7 +250,7 @@ bool FileGenerator::Validate(TProtoStringType* error) {
<< "generate full runtime code for Java. To use Java Lite runtime, "
<< "users should use the Java Lite plugin instead. See:\n"
<< " "
- "https://github.com/protocolbuffers/protobuf/blob/master/java/"
+ "https://github.com/protocolbuffers/protobuf/blob/main/java/"
"lite.md";
}
return true;
@@ -732,3 +735,5 @@ bool FileGenerator::ShouldIncludeDependency(const FileDescriptor* descriptor,
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/file.h
index 7a5a8ec01d..0063a18816 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/file.h
@@ -40,7 +40,7 @@
#include <vector>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/compiler/java/java_options.h>
+#include <google/protobuf/compiler/java/options.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/generator.cc
index ce198c7692..03be2a417e 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/generator.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_generator.h>
+#include <google/protobuf/compiler/java/generator.h>
#include <memory>
@@ -40,12 +40,12 @@
#include <google/protobuf/io/printer.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/stubs/stringprintf.h>
-#include <google/protobuf/compiler/java/java_file.h>
-#include <google/protobuf/compiler/java/java_generator_factory.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/compiler/java/java_options.h>
-#include <google/protobuf/compiler/java/java_shared_code_generator.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 <google/protobuf/stubs/strutil.h>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/generator.h
index e08c980788..e08c980788 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/generator.h
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/generator_factory.cc
index 3a62adb103..dd526ba7c7 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/generator_factory.cc
@@ -30,17 +30,17 @@
// Author: liujisi@google.com (Pherl Liu)
-#include <google/protobuf/compiler/java/java_generator_factory.h>
+#include <google/protobuf/compiler/java/generator_factory.h>
-#include <google/protobuf/compiler/java/java_context.h>
-#include <google/protobuf/compiler/java/java_enum_field.h>
-#include <google/protobuf/compiler/java/java_extension.h>
-#include <google/protobuf/compiler/java/java_extension_lite.h>
-#include <google/protobuf/compiler/java/java_field.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_message.h>
-#include <google/protobuf/compiler/java/java_message_lite.h>
-#include <google/protobuf/compiler/java/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/java_generator_factory.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/generator_factory.h
index 807bca383a..807bca383a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/generator_factory.h
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/helpers.cc
index 3f1f058c9e..96444c58fa 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/helpers.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_helpers.h>
+#include <google/protobuf/compiler/java/helpers.h>
#include <algorithm>
#include <cstdint>
@@ -44,11 +44,14 @@
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/stubs/substitute.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/compiler/java/java_names.h>
+#include <google/protobuf/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 *>
+// Must be last.
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -83,8 +86,7 @@ const char* kForbiddenWordList[] = {
"AllFields",
"DescriptorForType",
"InitializationErrorString",
- // TODO(b/219045204): re-enable
- // "UnknownFields",
+ "UnknownFields",
// obsolete. kept for backwards compatibility of generated code
"CachedSize",
};
@@ -261,18 +263,18 @@ TProtoStringType UnderscoresToCamelCaseCheckReserved(const FieldDescriptor* fiel
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) {
- // 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",
- });
return kKotlinForbiddenNames->find(field_name) !=
kKotlinForbiddenNames->end();
}
@@ -1109,3 +1111,5 @@ void EscapeUtf16ToString(uint16_t code, TProtoStringType* output) {
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/helpers.h
index 59bb718bc9..7f4c4aad14 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/helpers.h
@@ -40,7 +40,7 @@
#include <google/protobuf/io/printer.h>
#include <google/protobuf/descriptor.h>
-#include <google/protobuf/compiler/java/java_context.h>
+#include <google/protobuf/compiler/java/context.h>
#include <google/protobuf/descriptor.pb.h>
namespace google {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/kotlin_generator.cc
index fc0d823671..570840cfc1 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/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/java_kotlin_generator.h>
+#include <google/protobuf/compiler/java/kotlin_generator.h>
#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/compiler/java/java_file.h>
-#include <google/protobuf/compiler/java/java_generator.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_options.h>
+#include <google/protobuf/compiler/java/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 {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/kotlin_generator.h
index 195acb6537..195acb6537 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/kotlin_generator.h
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/map_field.cc
index 7a93f4696d..37bad491c0 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/map_field.cc
@@ -28,13 +28,16 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <google/protobuf/compiler/java/java_map_field.h>
+#include <google/protobuf/compiler/java/map_field.h>
#include <google/protobuf/io/printer.h>
-#include <google/protobuf/compiler/java/java_context.h>
-#include <google/protobuf/compiler/java/java_doc_comment.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/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>
+
+// Must be last.
+#include <google/protobuf/port_def.inc>
namespace google {
namespace protobuf {
@@ -695,13 +698,13 @@ void ImmutableMapFieldGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "$kt_deprecation$ public val $kt_name$: "
+ "$kt_deprecation$ val $kt_name$: "
"com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -714,7 +717,7 @@ void ImmutableMapFieldGenerator::GenerateKotlinDslMembers(
printer->Print(
variables_,
"@JvmName(\"put$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslMap"
+ "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"
@@ -726,7 +729,7 @@ void ImmutableMapFieldGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"set$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun com.google.protobuf.kotlin.DslMap"
+ "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"
@@ -737,7 +740,7 @@ void ImmutableMapFieldGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"remove$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslMap"
+ "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"
@@ -748,7 +751,7 @@ void ImmutableMapFieldGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"putAll$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslMap"
+ "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"
@@ -760,7 +763,7 @@ void ImmutableMapFieldGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"clear$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslMap"
+ "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"
@@ -887,3 +890,5 @@ TProtoStringType ImmutableMapFieldGenerator::GetBoxedType() const {
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/map_field.h
index 1d2b7ad398..fe0a4819a9 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/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/java_field.h>
+#include <google/protobuf/compiler/java/field.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/map_field_lite.cc
index 8817f27339..807743afcf 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/map_field_lite.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/compiler/java/java_map_field_lite.h>
+#include <google/protobuf/compiler/java/map_field_lite.h>
#include <cstdint>
#include <google/protobuf/io/printer.h>
-#include <google/protobuf/compiler/java/java_context.h>
-#include <google/protobuf/compiler/java/java_doc_comment.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/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>
+
+// Must be last.
+#include <google/protobuf/port_def.inc>
namespace google {
namespace protobuf {
@@ -835,13 +838,13 @@ void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "$kt_deprecation$ public val $kt_name$: "
+ "$kt_deprecation$ val $kt_name$: "
"com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -854,7 +857,7 @@ void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(
variables_,
"@JvmName(\"put$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslMap"
+ "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"
@@ -866,7 +869,7 @@ void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"set$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun com.google.protobuf.kotlin.DslMap"
+ "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"
@@ -877,7 +880,7 @@ void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"remove$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslMap"
+ "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"
@@ -888,7 +891,7 @@ void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"putAll$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslMap"
+ "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"
@@ -900,7 +903,7 @@ void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"clear$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslMap"
+ "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"
@@ -920,3 +923,5 @@ TProtoStringType ImmutableMapFieldLiteGenerator::GetBoxedType() const {
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/map_field_lite.h
index f2773f5b35..de2cc51057 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/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/java_field.h>
+#include <google/protobuf/compiler/java/field.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/message.cc
index 9a5c25a538..bcd437821f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_message.h>
+#include <google/protobuf/compiler/java/message.h>
#include <algorithm>
#include <cstdint>
@@ -45,17 +45,20 @@
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
-#include <google/protobuf/compiler/java/java_context.h>
-#include <google/protobuf/compiler/java/java_doc_comment.h>
-#include <google/protobuf/compiler/java/java_enum.h>
-#include <google/protobuf/compiler/java/java_extension.h>
-#include <google/protobuf/compiler/java/java_generator_factory.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_message_builder.h>
-#include <google/protobuf/compiler/java/java_message_builder_lite.h>
-#include <google/protobuf/compiler/java/java_name_resolver.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>
+// Must be last.
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -1410,10 +1413,10 @@ void ImmutableMessageGenerator::GenerateKotlinDsl(io::Printer* printer) const {
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
"@com.google.protobuf.kotlin.ProtoDslMarker\n");
printer->Print(
- "public class Dsl private constructor(\n"
+ "class Dsl private constructor(\n"
" private val _builder: $message$.Builder\n"
") {\n"
- " public companion object {\n"
+ " companion object {\n"
" @kotlin.jvm.JvmSynthetic\n"
" @kotlin.PublishedApi\n"
" internal fun _create(builder: $message$.Builder): Dsl = "
@@ -1435,10 +1438,10 @@ void ImmutableMessageGenerator::GenerateKotlinDsl(io::Printer* printer) const {
for (auto oneof : oneofs_) {
printer->Print(
- "public val $oneof_name$Case: $message$.$oneof_capitalized_name$Case\n"
+ "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"
- "public fun clear$oneof_capitalized_name$() {\n"
+ "fun clear$oneof_capitalized_name$() {\n"
" _builder.clear$oneof_capitalized_name$()\n"
"}\n",
"oneof_name", context_->GetOneofGeneratorInfo(oneof)->name,
@@ -1459,7 +1462,7 @@ void ImmutableMessageGenerator::GenerateKotlinMembers(
io::Printer* printer) const {
printer->Print(
"@kotlin.jvm.JvmName(\"-initialize$camelcase_name$\")\n"
- "public inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> "
+ "inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> "
"kotlin.Unit): "
"$message$ "
"=\n"
@@ -1469,7 +1472,7 @@ void ImmutableMessageGenerator::GenerateKotlinMembers(
"message_kt", name_resolver_->GetKotlinExtensionsClassName(descriptor_),
"message", name_resolver_->GetClassName(descriptor_, true));
- printer->Print("public object $name$Kt {\n", "name", descriptor_->name());
+ printer->Print("object $name$Kt {\n", "name", descriptor_->name());
printer->Indent();
GenerateKotlinDsl(printer);
for (int i = 0; i < descriptor_->nested_type_count(); i++) {
@@ -1485,7 +1488,7 @@ void ImmutableMessageGenerator::GenerateTopLevelKotlinMembers(
io::Printer* printer) const {
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "public inline fun $message$.copy(block: $message_kt$.Dsl.() -> "
+ "inline fun $message$.copy(block: $message_kt$.Dsl.() -> "
"kotlin.Unit): "
"$message$ =\n"
" $message_kt$.Dsl._create(this.toBuilder()).apply { block() "
@@ -1525,7 +1528,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@Suppress(\"UNCHECKED_CAST\")\n"
"@kotlin.jvm.JvmSynthetic\n"
- "public operator fun <T : kotlin.Any> get(extension: "
+ "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$, "
@@ -1541,7 +1544,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
"@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n"
- "public operator fun <E : kotlin.Any> get(\n"
+ "operator fun <E : kotlin.Any> get(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, List<E>>\n"
"): com.google.protobuf.kotlin.ExtensionList<E, $message$> {\n"
" return com.google.protobuf.kotlin.ExtensionList(extension, "
@@ -1551,7 +1554,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "public operator fun contains(extension: "
+ "operator fun contains(extension: "
"com.google.protobuf.ExtensionLite<$message$, *>): "
"Boolean {\n"
" return _builder.hasExtension(extension)\n"
@@ -1560,7 +1563,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "public fun clear(extension: "
+ "fun clear(extension: "
"com.google.protobuf.ExtensionLite<$message$, *>) "
"{\n"
" _builder.clearExtension(extension)\n"
@@ -1580,7 +1583,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun <T : Comparable<T>> set(\n"
+ "inline operator fun <T : Comparable<T>> set(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, T>,\n"
" value: T\n"
") {\n"
@@ -1591,7 +1594,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun set(\n"
+ "inline operator fun set(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, "
"com.google.protobuf.ByteString>,\n"
" value: com.google.protobuf.ByteString\n"
@@ -1603,7 +1606,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun <T : com.google.protobuf.MessageLite> set(\n"
+ "inline operator fun <T : com.google.protobuf.MessageLite> set(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, T>,\n"
" value: T\n"
") {\n"
@@ -1613,7 +1616,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "public fun <E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, "
+ "fun <E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.add(value: E) {\n"
" _builder.addExtension(this.extension, value)\n"
"}\n\n",
@@ -1622,7 +1625,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun <E : kotlin.Any> "
+ "inline operator fun <E : kotlin.Any> "
"com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.plusAssign"
"(value: E) {\n"
@@ -1632,7 +1635,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "public fun <E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, "
+ "fun <E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.addAll(values: Iterable<E>) {\n"
" for (value in values) {\n"
" add(value)\n"
@@ -1643,7 +1646,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun <E : kotlin.Any> "
+ "inline operator fun <E : kotlin.Any> "
"com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.plusAssign(values: "
"Iterable<E>) {\n"
@@ -1653,7 +1656,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "public operator fun <E : kotlin.Any> "
+ "operator fun <E : kotlin.Any> "
"com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.set(index: Int, value: "
"E) {\n"
@@ -1664,7 +1667,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline fun com.google.protobuf.kotlin.ExtensionList<*, "
+ "inline fun com.google.protobuf.kotlin.ExtensionList<*, "
"$message$>.clear() {\n"
" clear(extension)\n"
"}\n\n",
@@ -1749,3 +1752,5 @@ void ImmutableMessageGenerator::GenerateAnyMethods(io::Printer* printer) {
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/message.h
index cc24d73d35..2dbd0dd9bc 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message.h
@@ -38,7 +38,7 @@
#include <map>
#include <string>
-#include <google/protobuf/compiler/java/java_field.h>
+#include <google/protobuf/compiler/java/field.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder.cc
index e8ff5fa33b..3bbb7ae382 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_message_builder.h>
+#include <google/protobuf/compiler/java/message_builder.h>
#include <algorithm>
#include <map>
@@ -44,15 +44,18 @@
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
-#include <google/protobuf/compiler/java/java_context.h>
-#include <google/protobuf/compiler/java/java_doc_comment.h>
-#include <google/protobuf/compiler/java/java_enum.h>
-#include <google/protobuf/compiler/java/java_extension.h>
-#include <google/protobuf/compiler/java/java_generator_factory.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.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>
+// Must be last.
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -710,3 +713,5 @@ void MessageBuilderGenerator::GenerateIsInitialized(io::Printer* printer) {
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder.h
index 619bf9eca1..f9c9a00a0c 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder.h
@@ -38,7 +38,7 @@
#include <map>
#include <string>
-#include <google/protobuf/compiler/java/java_field.h>
+#include <google/protobuf/compiler/java/field.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder_lite.cc
index 5f90e8d691..bf41a71107 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder_lite.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_message_builder_lite.h>
+#include <google/protobuf/compiler/java/message_builder_lite.h>
#include <algorithm>
#include <map>
@@ -44,15 +44,18 @@
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
-#include <google/protobuf/compiler/java/java_context.h>
-#include <google/protobuf/compiler/java/java_doc_comment.h>
-#include <google/protobuf/compiler/java/java_enum.h>
-#include <google/protobuf/compiler/java/java_extension.h>
-#include <google/protobuf/compiler/java/java_generator_factory.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.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>
+// Must be last.
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -149,3 +152,5 @@ void MessageBuilderLiteGenerator::GenerateCommonBuilderMethods(
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder_lite.h
index 03ecbf870b..0d895fcf05 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_builder_lite.h
@@ -38,7 +38,7 @@
#include <map>
#include <string>
-#include <google/protobuf/compiler/java/java_field.h>
+#include <google/protobuf/compiler/java/field.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field.cc
index 5db89dbe21..a16abfcb34 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_message_field.h>
+#include <google/protobuf/compiler/java/message_field.h>
#include <map>
#include <string>
@@ -40,10 +40,13 @@
#include <google/protobuf/io/printer.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/java/java_context.h>
-#include <google/protobuf/compiler/java/java_doc_comment.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/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>
+
+// Must be last.
+#include <google/protobuf/port_def.inc>
namespace google {
namespace protobuf {
@@ -418,7 +421,7 @@ void ImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$public var $kt_name$: $kt_type$\n"
+ "$kt_deprecation$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"
@@ -429,14 +432,14 @@ void ImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
/* builder */ false);
printer->Print(variables_,
- "public fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(
variables_,
- "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
" return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
"}\n");
@@ -446,7 +449,7 @@ void ImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
void ImmutableMessageFieldGenerator::GenerateKotlinOrNull(io::Printer* printer) const {
if (descriptor_->has_optional_keyword()) {
printer->Print(variables_,
- "public val $classname$Kt.Dsl.$name$OrNull: $kt_type$?\n"
+ "val $classname$Kt.Dsl.$name$OrNull: $kt_type$?\n"
" get() = $kt_dsl_builder$.$name$OrNull\n");
}
}
@@ -1416,12 +1419,12 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$ public val $kt_name$: "
+ "$kt_deprecation$ val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -1434,7 +1437,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -1446,7 +1449,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun com.google.protobuf.kotlin.DslList"
+ "inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: $kt_type$) {\n"
" add(value)\n"
@@ -1457,7 +1460,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -1470,7 +1473,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -1482,7 +1485,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "public operator fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -1493,7 +1496,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
@@ -1504,3 +1507,5 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field.h
index 94a144d4ae..602612e4ad 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field.h
@@ -38,7 +38,7 @@
#include <map>
#include <string>
-#include <google/protobuf/compiler/java/java_field.h>
+#include <google/protobuf/compiler/java/field.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field_lite.cc
index 523190d85a..23d3c410f6 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field_lite.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_message_field_lite.h>
+#include <google/protobuf/compiler/java/message_field_lite.h>
#include <cstdint>
#include <map>
@@ -41,10 +41,13 @@
#include <google/protobuf/io/printer.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/java/java_context.h>
-#include <google/protobuf/compiler/java/java_doc_comment.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/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>
+
+// Must be last.
+#include <google/protobuf/port_def.inc>
namespace google {
namespace protobuf {
@@ -287,7 +290,7 @@ void ImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$public var $kt_name$: $kt_type$\n"
+ "$kt_deprecation$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"
@@ -298,14 +301,14 @@ void ImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
/* builder */ false);
printer->Print(variables_,
- "public fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(
variables_,
- "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
" return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
"}\n");
GenerateKotlinOrNull(printer);
@@ -314,7 +317,7 @@ void ImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
void ImmutableMessageFieldLiteGenerator::GenerateKotlinOrNull(io::Printer* printer) const {
if (descriptor_->has_optional_keyword()) {
printer->Print(variables_,
- "public val $classname$Kt.Dsl.$name$OrNull: $kt_type$?\n"
+ "val $classname$Kt.Dsl.$name$OrNull: $kt_type$?\n"
" get() = $kt_dsl_builder$.$name$OrNull\n");
}
}
@@ -803,12 +806,12 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$ public val $kt_name$: "
+ "$kt_deprecation$ val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -821,7 +824,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -833,7 +836,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun com.google.protobuf.kotlin.DslList"
+ "inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: $kt_type$) {\n"
" add(value)\n"
@@ -844,7 +847,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -857,7 +860,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -869,7 +872,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "public operator fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -880,7 +883,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
@@ -891,3 +894,5 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field_lite.h
index 189d760afe..5bf9607bc8 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_field_lite.h
@@ -39,7 +39,7 @@
#include <map>
#include <string>
-#include <google/protobuf/compiler/java/java_field.h>
+#include <google/protobuf/compiler/java/field.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_lite.cc
index 615dece6cb..90bd4b2382 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_lite.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_message_lite.h>
+#include <google/protobuf/compiler/java/message_lite.h>
#include <algorithm>
#include <cstdint>
@@ -45,17 +45,20 @@
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
-#include <google/protobuf/compiler/java/java_context.h>
-#include <google/protobuf/compiler/java/java_doc_comment.h>
-#include <google/protobuf/compiler/java/java_enum_lite.h>
-#include <google/protobuf/compiler/java/java_extension_lite.h>
-#include <google/protobuf/compiler/java/java_generator_factory.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_message_builder.h>
-#include <google/protobuf/compiler/java/java_message_builder_lite.h>
-#include <google/protobuf/compiler/java/java_name_resolver.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>
+// Must be last.
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -731,10 +734,10 @@ void ImmutableMessageLiteGenerator::GenerateKotlinDsl(
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
"@com.google.protobuf.kotlin.ProtoDslMarker\n");
printer->Print(
- "public class Dsl private constructor(\n"
+ "class Dsl private constructor(\n"
" private val _builder: $message$.Builder\n"
") {\n"
- " public companion object {\n"
+ " companion object {\n"
" @kotlin.jvm.JvmSynthetic\n"
" @kotlin.PublishedApi\n"
" internal fun _create(builder: $message$.Builder): Dsl = "
@@ -756,10 +759,10 @@ void ImmutableMessageLiteGenerator::GenerateKotlinDsl(
for (auto oneof : oneofs_) {
printer->Print(
- "public val $oneof_name$Case: $message$.$oneof_capitalized_name$Case\n"
+ "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"
- "public fun clear$oneof_capitalized_name$() {\n"
+ "fun clear$oneof_capitalized_name$() {\n"
" _builder.clear$oneof_capitalized_name$()\n"
"}\n",
"oneof_name", context_->GetOneofGeneratorInfo(oneof)->name,
@@ -780,7 +783,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinMembers(
io::Printer* printer) const {
printer->Print(
"@kotlin.jvm.JvmName(\"-initialize$camelcase_name$\")\n"
- "public inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> "
+ "inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> "
"kotlin.Unit): "
"$message$ =\n"
" $message_kt$.Dsl._create($message$.newBuilder()).apply { block() "
@@ -789,7 +792,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinMembers(
"message_kt", name_resolver_->GetKotlinExtensionsClassName(descriptor_),
"message", name_resolver_->GetClassName(descriptor_, true));
- printer->Print("public object $name$Kt {\n", "name", descriptor_->name());
+ printer->Print("object $name$Kt {\n", "name", descriptor_->name());
printer->Indent();
GenerateKotlinDsl(printer);
for (int i = 0; i < descriptor_->nested_type_count(); i++) {
@@ -804,7 +807,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinMembers(
void ImmutableMessageLiteGenerator::GenerateTopLevelKotlinMembers(
io::Printer* printer) const {
printer->Print(
- "public inline fun $message$.copy(block: $message_kt$.Dsl.() -> "
+ "inline fun $message$.copy(block: $message_kt$.Dsl.() -> "
"kotlin.Unit): "
"$message$ =\n"
" $message_kt$.Dsl._create(this.toBuilder()).apply { block() "
@@ -846,7 +849,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@Suppress(\"UNCHECKED_CAST\")\n"
"@kotlin.jvm.JvmSynthetic\n"
- "public operator fun <T : kotlin.Any> get(extension: "
+ "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$, "
@@ -862,7 +865,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
"@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n"
- "public operator fun <E : kotlin.Any> get(\n"
+ "operator fun <E : kotlin.Any> get(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, List<E>>\n"
"): com.google.protobuf.kotlin.ExtensionList<E, $message$> {\n"
" return com.google.protobuf.kotlin.ExtensionList(extension, "
@@ -872,7 +875,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "public operator fun contains(extension: "
+ "operator fun contains(extension: "
"com.google.protobuf.ExtensionLite<$message$, *>): "
"Boolean {\n"
" return _builder.hasExtension(extension)\n"
@@ -881,7 +884,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "public fun clear(extension: "
+ "fun clear(extension: "
"com.google.protobuf.ExtensionLite<$message$, *>) "
"{\n"
" _builder.clearExtension(extension)\n"
@@ -901,7 +904,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun <T : Comparable<T>> set(\n"
+ "inline operator fun <T : Comparable<T>> set(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, T>,\n"
" value: T\n"
") {\n"
@@ -912,7 +915,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun set(\n"
+ "inline operator fun set(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, "
"com.google.protobuf.ByteString>,\n"
" value: com.google.protobuf.ByteString\n"
@@ -924,7 +927,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun <T : com.google.protobuf.MessageLite> set(\n"
+ "inline operator fun <T : com.google.protobuf.MessageLite> set(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, T>,\n"
" value: T\n"
") {\n"
@@ -934,7 +937,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "public fun<E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, "
+ "fun<E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.add(value: E) {\n"
" _builder.addExtension(this.extension, value)\n"
"}\n\n",
@@ -943,7 +946,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun <E : kotlin.Any> "
+ "inline operator fun <E : kotlin.Any> "
"com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.plusAssign"
"(value: E) {\n"
@@ -953,7 +956,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "public fun<E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, "
+ "fun<E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.addAll(values: Iterable<E>) {\n"
" for (value in values) {\n"
" add(value)\n"
@@ -964,7 +967,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun <E : kotlin.Any> "
+ "inline operator fun <E : kotlin.Any> "
"com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.plusAssign(values: "
"Iterable<E>) {\n"
@@ -974,7 +977,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "public operator fun <E : kotlin.Any> "
+ "operator fun <E : kotlin.Any> "
"com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.set(index: Int, value: "
"E) {\n"
@@ -985,7 +988,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline fun com.google.protobuf.kotlin.ExtensionList<*, "
+ "inline fun com.google.protobuf.kotlin.ExtensionList<*, "
"$message$>.clear() {\n"
" clear(extension)\n"
"}\n\n",
@@ -996,3 +999,5 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_lite.h
index c0afbc99ec..d1e4b68949 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/message_lite.h
@@ -35,11 +35,8 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_LITE_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_LITE_H__
-#include <map>
-#include <string>
-
-#include <google/protobuf/compiler/java/java_field.h>
-#include <google/protobuf/compiler/java/java_message.h>
+#include <google/protobuf/compiler/java/field.h>
+#include <google/protobuf/compiler/java/message.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/name_resolver.cc
index a257409ab7..5cadecadf3 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/name_resolver.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/compiler/java/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/java_helpers.h>
-#include <google/protobuf/compiler/java/java_names.h>
+#include <google/protobuf/compiler/java/helpers.h>
+#include <google/protobuf/compiler/java/names.h>
+
+// Must be last.
+#include <google/protobuf/port_def.inc>
namespace google {
namespace protobuf {
@@ -378,3 +381,5 @@ TProtoStringType ClassNameResolver::GetDowngradedClassName(
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/name_resolver.h
index 46f699c6aa..9744e8739f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/name_resolver.h
@@ -36,6 +36,9 @@
#include <google/protobuf/stubs/common.h>
+// Must be last.
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
class Descriptor;
@@ -151,4 +154,6 @@ class ClassNameResolver {
} // namespace protobuf
} // namespace google
+#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/java_names.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/names.h
index 9aeddc81cc..9aeddc81cc 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_names.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/names.h
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_options.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/options.h
index 1454c23206..1454c23206 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_options.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/options.h
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field.cc
index abe88b67e0..adb556a892 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_primitive_field.h>
+#include <google/protobuf/compiler/java/primitive_field.h>
#include <cstdint>
#include <map>
@@ -43,10 +43,10 @@
#include <google/protobuf/io/printer.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/java/java_context.h>
-#include <google/protobuf/compiler/java/java_doc_comment.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/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>
namespace google {
namespace protobuf {
@@ -320,7 +320,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$public var $kt_name$: $kt_type$\n"
+ "$kt_deprecation$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"
@@ -331,7 +331,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
/* builder */ false);
printer->Print(variables_,
- "public fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
@@ -339,7 +339,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(
variables_,
- "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
" return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
"}\n");
}
@@ -849,12 +849,12 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$ public val $kt_name$: "
+ "$kt_deprecation$ val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -867,7 +867,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -879,7 +879,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun com.google.protobuf.kotlin.DslList"
+ "inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: $kt_type$) {\n"
" add(value)\n"
@@ -890,7 +890,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -903,7 +903,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -915,7 +915,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "public operator fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -926,7 +926,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field.h
index 8883b83d66..a2c0041388 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field.h
@@ -38,7 +38,7 @@
#include <map>
#include <string>
-#include <google/protobuf/compiler/java/java_field.h>
+#include <google/protobuf/compiler/java/field.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field_lite.cc
index 20ba2a4051..5fd47c47e1 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field_lite.cc
@@ -32,7 +32,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_primitive_field_lite.h>
+#include <google/protobuf/compiler/java/primitive_field_lite.h>
#include <cstdint>
#include <map>
@@ -43,10 +43,10 @@
#include <google/protobuf/io/printer.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/java/java_context.h>
-#include <google/protobuf/compiler/java/java_doc_comment.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/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>
namespace google {
namespace protobuf {
@@ -325,7 +325,7 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$public var $kt_name$: $kt_type$\n"
+ "$kt_deprecation$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"
@@ -336,7 +336,7 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
/* builder */ false);
printer->Print(variables_,
- "public fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
@@ -344,7 +344,7 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(
variables_,
- "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
" return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
"}\n");
}
@@ -671,12 +671,12 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$ public val $kt_name$: "
+ "$kt_deprecation$ val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -689,7 +689,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -701,7 +701,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun com.google.protobuf.kotlin.DslList"
+ "inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: $kt_type$) {\n"
" add(value)\n"
@@ -712,7 +712,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -725,7 +725,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -737,7 +737,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "public operator fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -748,7 +748,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field_lite.h
index a7f03e2acc..1eaf8d8e09 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/primitive_field_lite.h
@@ -39,7 +39,7 @@
#include <map>
#include <string>
-#include <google/protobuf/compiler/java/java_field.h>
+#include <google/protobuf/compiler/java/field.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/service.cc
index 59e11deb77..602ab4c7b9 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/service.cc
@@ -32,14 +32,17 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/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/java_context.h>
-#include <google/protobuf/compiler/java/java_doc_comment.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/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>
+
+// Must be last.
+#include <google/protobuf/port_def.inc>
namespace google {
namespace protobuf {
@@ -472,3 +475,5 @@ void ImmutableServiceGenerator::GenerateBlockingMethodSignature(
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/service.h
index a03a3de561..a03a3de561 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/service.h
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/shared_code_generator.cc
index 7d7e95dfba..0a8b8edb01 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/shared_code_generator.cc
@@ -30,7 +30,7 @@
// Author: xiaofeng@google.com (Feng Xiao)
-#include <google/protobuf/compiler/java/java_shared_code_generator.h>
+#include <google/protobuf/compiler/java/shared_code_generator.h>
#include <memory>
@@ -39,9 +39,9 @@
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/compiler/java/java_names.h>
+#include <google/protobuf/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>
namespace google {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/shared_code_generator.h
index 93fe6d7996..026124715a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/shared_code_generator.h
@@ -40,7 +40,7 @@
#include <vector>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/compiler/java/java_options.h>
+#include <google/protobuf/compiler/java/options.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field.cc
index 5628441a74..066e3bd701 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field.cc
@@ -33,7 +33,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_string_field.h>
+#include <google/protobuf/compiler/java/string_field.h>
#include <cstdint>
#include <map>
@@ -44,10 +44,10 @@
#include <google/protobuf/io/printer.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/java/java_context.h>
-#include <google/protobuf/compiler/java/java_doc_comment.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/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>
namespace google {
namespace protobuf {
@@ -379,7 +379,7 @@ void ImmutableStringFieldGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$public var $kt_name$: kotlin.String\n"
+ "$kt_deprecation$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"
@@ -390,7 +390,7 @@ void ImmutableStringFieldGenerator::GenerateKotlinDslMembers(
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
/* builder */ false);
printer->Print(variables_,
- "public fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
@@ -398,7 +398,7 @@ void ImmutableStringFieldGenerator::GenerateKotlinDslMembers(
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(
variables_,
- "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
" return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
"}\n");
}
@@ -963,13 +963,13 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
// property for List<String>
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(variables_,
- "$kt_deprecation$public val $kt_name$: "
+ "$kt_deprecation$ val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -983,7 +983,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -996,7 +996,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun com.google.protobuf.kotlin.DslList"
+ "inline operator fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: kotlin.String) {\n"
" add(value)\n"
@@ -1009,7 +1009,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -1023,7 +1023,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -1036,7 +1036,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "public operator fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -1047,7 +1047,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "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/java_string_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field.h
index f282163b55..3a83f1fc2a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field.h
@@ -39,7 +39,7 @@
#include <map>
#include <string>
-#include <google/protobuf/compiler/java/java_field.h>
+#include <google/protobuf/compiler/java/field.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field_lite.cc
index d2cfad0dcd..91cb53d484 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field_lite.cc
@@ -33,7 +33,7 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_string_field_lite.h>
+#include <google/protobuf/compiler/java/string_field_lite.h>
#include <cstdint>
#include <map>
@@ -44,10 +44,10 @@
#include <google/protobuf/io/printer.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/java/java_context.h>
-#include <google/protobuf/compiler/java/java_doc_comment.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/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>
namespace google {
namespace protobuf {
@@ -313,7 +313,7 @@ void ImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$public var $kt_name$: kotlin.String\n"
+ "$kt_deprecation$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"
@@ -324,7 +324,7 @@ void ImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
/* builder */ false);
printer->Print(variables_,
- "public fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
@@ -332,7 +332,7 @@ void ImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(
variables_,
- "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
" return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
"}\n");
}
@@ -748,17 +748,17 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
// property for List<String>
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(
variables_,
- "$kt_deprecation$public val $kt_name$: "
+ "$kt_deprecation$ val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>\n"
- " @kotlin.OptIn"
+ "@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
" get() = com.google.protobuf.kotlin.DslList(\n"
" $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
@@ -770,7 +770,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -783,7 +783,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun com.google.protobuf.kotlin.DslList"
+ "inline operator fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: kotlin.String) {\n"
" add(value)\n"
@@ -796,7 +796,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -810,7 +810,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "public inline operator fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -823,7 +823,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "public operator fun com.google.protobuf.kotlin.DslList"
+ "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"
@@ -834,7 +834,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "public fun com.google.protobuf.kotlin.DslList"
+ "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/java_string_field_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field_lite.h
index 02cf5c1657..73e51e3238 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/string_field_lite.h
@@ -40,7 +40,7 @@
#include <map>
#include <string>
-#include <google/protobuf/compiler/java/java_field.h>
+#include <google/protobuf/compiler/java/field.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/js/js_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/js/js_generator.cc
deleted file mode 100644
index 8c9fadf067..0000000000
--- a/contrib/libs/protoc/src/google/protobuf/compiler/js/js_generator.cc
+++ /dev/null
@@ -1,3937 +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 <assert.h>
-#include <google/protobuf/compiler/js/js_generator.h>
-#include <google/protobuf/compiler/js/well_known_types_embed.h>
-#include <google/protobuf/compiler/scc.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/common.h>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/stringprintf.h>
-#include <google/protobuf/stubs/strutil.h>
-
-#include <algorithm>
-#include <limits>
-#include <map>
-#include <memory>
-#include <string>
-#include <utility>
-#include <vector>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace js {
-
-// Sorted list of JavaScript keywords. These cannot be used as names. If they
-// appear, we prefix them with "pb_".
-const char* kKeyword[] = {
- "abstract", "boolean", "break", "byte", "case",
- "catch", "char", "class", "const", "continue",
- "debugger", "default", "delete", "do", "double",
- "else", "enum", "export", "extends", "false",
- "final", "finally", "float", "for", "function",
- "goto", "if", "implements", "import", "in",
- "instanceof", "int", "interface", "long", "native",
- "new", "null", "package", "private", "protected",
- "public", "return", "short", "static", "super",
- "switch", "synchronized", "this", "throw", "throws",
- "transient", "try", "typeof", "var", "void",
- "volatile", "while", "with",
-};
-
-static const int kNumKeyword = sizeof(kKeyword) / sizeof(char*);
-
-namespace {
-
-// The mode of operation for bytes fields. Historically JSPB always carried
-// bytes as JS {string}, containing base64 content by convention. With binary
-// and proto3 serialization the new convention is to represent it as binary
-// data in Uint8Array. See b/26173701 for background on the migration.
-enum BytesMode {
- BYTES_DEFAULT, // Default type for getBytesField to return.
- BYTES_B64, // Explicitly coerce to base64 string where needed.
- BYTES_U8, // Explicitly coerce to Uint8Array where needed.
-};
-
-bool IsReserved(const TProtoStringType& ident) {
- for (int i = 0; i < kNumKeyword; i++) {
- if (ident == kKeyword[i]) {
- return true;
- }
- }
- return false;
-}
-
-TProtoStringType GetSnakeFilename(const TProtoStringType& filename) {
- TProtoStringType snake_name = filename;
- ReplaceCharacters(&snake_name, "/", '_');
- return snake_name;
-}
-
-// Given a filename like foo/bar/baz.proto, returns the corresponding JavaScript
-// file foo/bar/baz.js.
-TProtoStringType GetJSFilename(const GeneratorOptions& options,
- const TProtoStringType& filename) {
- return StripProto(filename) + options.GetFileNameExtension();
-}
-
-// Given a filename like foo/bar/baz.proto, returns the root directory
-// path ../../
-TProtoStringType GetRootPath(const TProtoStringType& from_filename,
- const TProtoStringType& to_filename) {
- if (to_filename.find("google/protobuf") == 0) {
- // Well-known types (.proto files in the google/protobuf directory) are
- // assumed to come from the 'google-protobuf' npm package. We may want to
- // generalize this exception later by letting others put generated code in
- // their own npm packages.
- return "google-protobuf/";
- }
-
- size_t slashes = std::count(from_filename.begin(), from_filename.end(), '/');
- if (slashes == 0) {
- return "./";
- }
- TProtoStringType result = "";
- for (size_t i = 0; i < slashes; i++) {
- result += "../";
- }
- return result;
-}
-
-// Returns the alias we assign to the module of the given .proto filename
-// when importing.
-TProtoStringType ModuleAlias(const TProtoStringType& filename) {
- // This scheme could technically cause problems if a file includes any 2 of:
- // foo/bar_baz.proto
- // foo_bar_baz.proto
- // foo_bar/baz.proto
- //
- // We'll worry about this problem if/when we actually see it. This name isn't
- // exposed to users so we can change it later if we need to.
- TProtoStringType basename = StripProto(filename);
- ReplaceCharacters(&basename, "-", '$');
- ReplaceCharacters(&basename, "/", '_');
- ReplaceCharacters(&basename, ".", '_');
- return basename + "_pb";
-}
-
-// Returns the fully normalized JavaScript namespace for the given
-// file descriptor's package.
-TProtoStringType GetNamespace(const GeneratorOptions& options,
- const FileDescriptor* file) {
- if (!options.namespace_prefix.empty()) {
- return options.namespace_prefix;
- } else if (!file->package().empty()) {
- return "proto." + file->package();
- } else {
- return "proto";
- }
-}
-
-// Returns the name of the message with a leading dot and taking into account
-// nesting, for example ".OuterMessage.InnerMessage", or returns empty if
-// descriptor is null. This function does not handle namespacing, only message
-// nesting.
-TProtoStringType GetNestedMessageName(const Descriptor* descriptor) {
- if (descriptor == NULL) {
- return "";
- }
- TProtoStringType result =
- StripPrefixString(descriptor->full_name(), descriptor->file()->package());
- // Add a leading dot if one is not already present.
- if (!result.empty() && result[0] != '.') {
- result = "." + result;
- }
- return result;
-}
-
-// Returns the path prefix for a message or enumeration that
-// lives under the given file and containing type.
-TProtoStringType GetPrefix(const GeneratorOptions& options,
- const FileDescriptor* file_descriptor,
- const Descriptor* containing_type) {
- TProtoStringType prefix = GetNamespace(options, file_descriptor) +
- GetNestedMessageName(containing_type);
- if (!prefix.empty()) {
- prefix += ".";
- }
- return prefix;
-}
-
-// Returns the fully normalized JavaScript path prefix for the given
-// message descriptor.
-TProtoStringType GetMessagePathPrefix(const GeneratorOptions& options,
- const Descriptor* descriptor) {
- return GetPrefix(options, descriptor->file(), descriptor->containing_type());
-}
-
-// Returns the fully normalized JavaScript path for the given
-// message descriptor.
-TProtoStringType GetMessagePath(const GeneratorOptions& options,
- const Descriptor* descriptor) {
- return GetMessagePathPrefix(options, descriptor) + descriptor->name();
-}
-
-// Returns the fully normalized JavaScript path prefix for the given
-// enumeration descriptor.
-TProtoStringType GetEnumPathPrefix(const GeneratorOptions& options,
- const EnumDescriptor* enum_descriptor) {
- return GetPrefix(options, enum_descriptor->file(),
- enum_descriptor->containing_type());
-}
-
-// Returns the fully normalized JavaScript path for the given
-// enumeration descriptor.
-TProtoStringType GetEnumPath(const GeneratorOptions& options,
- const EnumDescriptor* enum_descriptor) {
- return GetEnumPathPrefix(options, enum_descriptor) + enum_descriptor->name();
-}
-
-TProtoStringType MaybeCrossFileRef(const GeneratorOptions& options,
- const FileDescriptor* from_file,
- const Descriptor* to_message) {
- if ((options.import_style == GeneratorOptions::kImportCommonJs ||
- options.import_style == GeneratorOptions::kImportCommonJsStrict) &&
- from_file != to_message->file()) {
- // Cross-file ref in CommonJS needs to use the module alias instead of
- // the global name.
- return ModuleAlias(to_message->file()->name()) +
- GetNestedMessageName(to_message->containing_type()) + "." +
- to_message->name();
- } else {
- // Within a single file we use a full name.
- return GetMessagePath(options, to_message);
- }
-}
-
-TProtoStringType SubmessageTypeRef(const GeneratorOptions& options,
- const FieldDescriptor* field) {
- GOOGLE_CHECK(field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE);
- return MaybeCrossFileRef(options, field->file(), field->message_type());
-}
-
-// - Object field name: LOWER_UNDERSCORE -> LOWER_CAMEL, except for group fields
-// (UPPER_CAMEL -> LOWER_CAMEL), with "List" (or "Map") appended if appropriate,
-// and with reserved words triggering a "pb_" prefix.
-// - Getters/setters: LOWER_UNDERSCORE -> UPPER_CAMEL, except for group fields
-// (use the name directly), then append "List" if appropriate, then append "$"
-// if resulting name is equal to a reserved word.
-// - Enums: just uppercase.
-
-// Locale-independent version of ToLower that deals only with ASCII A-Z.
-char ToLowerASCII(char c) {
- if (c >= 'A' && c <= 'Z') {
- return (c - 'A') + 'a';
- } else {
- return c;
- }
-}
-
-std::vector<TProtoStringType> ParseLowerUnderscore(const TProtoStringType& input) {
- std::vector<TProtoStringType> words;
- TProtoStringType running = "";
- for (int i = 0; i < input.size(); i++) {
- if (input[i] == '_') {
- if (!running.empty()) {
- words.push_back(running);
- running.clear();
- }
- } else {
- running += ToLowerASCII(input[i]);
- }
- }
- if (!running.empty()) {
- words.push_back(running);
- }
- return words;
-}
-
-std::vector<TProtoStringType> ParseUpperCamel(const TProtoStringType& input) {
- std::vector<TProtoStringType> words;
- TProtoStringType running = "";
- for (int i = 0; i < input.size(); i++) {
- if (input[i] >= 'A' && input[i] <= 'Z' && !running.empty()) {
- words.push_back(running);
- running.clear();
- }
- running += ToLowerASCII(input[i]);
- }
- if (!running.empty()) {
- words.push_back(running);
- }
- return words;
-}
-
-TProtoStringType ToLowerCamel(const std::vector<TProtoStringType>& words) {
- TProtoStringType result;
- for (int i = 0; i < words.size(); i++) {
- TProtoStringType word = words[i];
- if (i == 0 && (word[0] >= 'A' && word[0] <= 'Z')) {
- word[0] = (word[0] - 'A') + 'a';
- } else if (i != 0 && (word[0] >= 'a' && word[0] <= 'z')) {
- word[0] = (word[0] - 'a') + 'A';
- }
- result += word;
- }
- return result;
-}
-
-TProtoStringType ToUpperCamel(const std::vector<TProtoStringType>& words) {
- TProtoStringType result;
- for (int i = 0; i < words.size(); i++) {
- TProtoStringType word = words[i];
- if (word[0] >= 'a' && word[0] <= 'z') {
- word[0] = (word[0] - 'a') + 'A';
- }
- result += word;
- }
- return result;
-}
-
-// Based on code from descriptor.cc (Thanks Kenton!)
-// Uppercases the entire string, turning ValueName into
-// VALUENAME.
-TProtoStringType ToEnumCase(const TProtoStringType& input) {
- TProtoStringType result;
- result.reserve(input.size());
-
- for (int i = 0; i < input.size(); i++) {
- if ('a' <= input[i] && input[i] <= 'z') {
- result.push_back(input[i] - 'a' + 'A');
- } else {
- result.push_back(input[i]);
- }
- }
-
- return result;
-}
-
-TProtoStringType ToLower(const TProtoStringType& input) {
- TProtoStringType result;
- result.reserve(input.size());
-
- for (int i = 0; i < input.size(); i++) {
- if ('A' <= input[i] && input[i] <= 'Z') {
- result.push_back(input[i] - 'A' + 'a');
- } else {
- result.push_back(input[i]);
- }
- }
-
- return result;
-}
-
-// When we're generating one output file per SCC, this is the filename
-// that top-level extensions should go in.
-// e.g. one proto file (test.proto):
-// package a;
-// extends Foo {
-// ...
-// }
-// If "with_filename" equals true, the extension filename will be
-// "proto.a_test_extensions.js", otherwise will be "proto.a.js"
-TProtoStringType GetExtensionFileName(const GeneratorOptions& options,
- const FileDescriptor* file,
- bool with_filename) {
- TProtoStringType snake_name = StripProto(GetSnakeFilename(file->name()));
- return options.output_dir + "/" + ToLower(GetNamespace(options, file)) +
- (with_filename ? ("_" + snake_name + "_extensions") : "") +
- options.GetFileNameExtension();
-}
-// When we're generating one output file per SCC, this is the filename
-// that all messages in the SCC should go in.
-// If with_package equals true, filename will have package prefix,
-// If the filename length is longer than 200, the filename will be the
-// SCC's proto filename with suffix "_long_sccs_(index)" (if with_package equals
-// true it still has package prefix)
-TProtoStringType GetMessagesFileName(const GeneratorOptions& options, const SCC* scc,
- bool with_package) {
- static std::map<const Descriptor*, TProtoStringType>* long_name_dict =
- new std::map<const Descriptor*, TProtoStringType>();
- TProtoStringType package_base =
- with_package
- ? ToLower(GetNamespace(options, scc->GetRepresentative()->file()) +
- "_")
- : "";
- TProtoStringType filename_base = "";
- std::vector<TProtoStringType> all_message_names;
- for (auto one_desc : scc->descriptors) {
- if (one_desc->containing_type() == nullptr) {
- all_message_names.push_back(ToLower(one_desc->name()));
- }
- }
- sort(all_message_names.begin(), all_message_names.end());
- for (auto one_message : all_message_names) {
- if (!filename_base.empty()) {
- filename_base += "_";
- }
- filename_base += one_message;
- }
- if (filename_base.size() + package_base.size() > 200) {
- if ((*long_name_dict).find(scc->GetRepresentative()) ==
- (*long_name_dict).end()) {
- TProtoStringType snake_name = StripProto(
- GetSnakeFilename(scc->GetRepresentative()->file()->name()));
- (*long_name_dict)[scc->GetRepresentative()] =
- StrCat(snake_name, "_long_sccs_",
- static_cast<uint64>((*long_name_dict).size()));
- }
- filename_base = (*long_name_dict)[scc->GetRepresentative()];
- }
- return options.output_dir + "/" + package_base + filename_base +
- options.GetFileNameExtension();
-}
-
-// When we're generating one output file per type name, this is the filename
-// that a top-level enum should go in.
-// If with_package equals true, filename will have package prefix.
-TProtoStringType GetEnumFileName(const GeneratorOptions& options,
- const EnumDescriptor* desc, bool with_package) {
- return options.output_dir + "/" +
- (with_package ? ToLower(GetNamespace(options, desc->file()) + "_")
- : "") +
- ToLower(desc->name()) + options.GetFileNameExtension();
-}
-
-// Returns the message/response ID, if set.
-TProtoStringType GetMessageId(const Descriptor* desc) { return TProtoStringType(); }
-
-bool IgnoreExtensionField(const FieldDescriptor* field) {
- // Exclude descriptor extensions from output "to avoid clutter" (from original
- // codegen).
- if (!field->is_extension()) return false;
- const FileDescriptor* file = field->containing_type()->file();
- return file->name() == "net/proto2/proto/descriptor.proto" ||
- file->name() == "google/protobuf/descriptor.proto";
-}
-
-// Used inside Google only -- do not remove.
-bool IsResponse(const Descriptor* desc) { return false; }
-
-bool IgnoreField(const FieldDescriptor* field) {
- return IgnoreExtensionField(field);
-}
-
-// Do we ignore this message type?
-bool IgnoreMessage(const Descriptor* d) { return d->options().map_entry(); }
-
-// Does JSPB ignore this entire oneof? True only if all fields are ignored.
-bool IgnoreOneof(const OneofDescriptor* oneof) {
- if (oneof->is_synthetic()) return true;
- for (int i = 0; i < oneof->field_count(); i++) {
- if (!IgnoreField(oneof->field(i))) {
- return false;
- }
- }
- return true;
-}
-
-TProtoStringType JSIdent(const GeneratorOptions& options,
- const FieldDescriptor* field, bool is_upper_camel,
- bool is_map, bool drop_list) {
- TProtoStringType result;
- if (field->type() == FieldDescriptor::TYPE_GROUP) {
- result = is_upper_camel
- ? ToUpperCamel(ParseUpperCamel(field->message_type()->name()))
- : ToLowerCamel(ParseUpperCamel(field->message_type()->name()));
- } else {
- result = is_upper_camel ? ToUpperCamel(ParseLowerUnderscore(field->name()))
- : ToLowerCamel(ParseLowerUnderscore(field->name()));
- }
- if (is_map || field->is_map()) {
- // JSPB-style or proto3-style map.
- result += "Map";
- } else if (!drop_list && field->is_repeated()) {
- // Repeated field.
- result += "List";
- }
- return result;
-}
-
-TProtoStringType JSObjectFieldName(const GeneratorOptions& options,
- const FieldDescriptor* field) {
- TProtoStringType name = JSIdent(options, field,
- /* is_upper_camel = */ false,
- /* is_map = */ false,
- /* drop_list = */ false);
- if (IsReserved(name)) {
- name = "pb_" + name;
- }
- return name;
-}
-
-TProtoStringType JSByteGetterSuffix(BytesMode bytes_mode) {
- switch (bytes_mode) {
- case BYTES_DEFAULT:
- return "";
- case BYTES_B64:
- return "B64";
- case BYTES_U8:
- return "U8";
- default:
- assert(false);
- }
- return "";
-}
-
-// Returns the field name as a capitalized portion of a getter/setter method
-// name, e.g. MyField for .getMyField().
-TProtoStringType JSGetterName(const GeneratorOptions& options,
- const FieldDescriptor* field,
- BytesMode bytes_mode = BYTES_DEFAULT,
- bool drop_list = false) {
- TProtoStringType name = JSIdent(options, field,
- /* is_upper_camel = */ true,
- /* is_map = */ false, drop_list);
- if (field->type() == FieldDescriptor::TYPE_BYTES) {
- TProtoStringType suffix = JSByteGetterSuffix(bytes_mode);
- if (!suffix.empty()) {
- name += "_as" + suffix;
- }
- }
- if (name == "Extension" || name == "JsPbMessageId") {
- // Avoid conflicts with base-class names.
- name += "$";
- }
- return name;
-}
-
-TProtoStringType JSOneofName(const OneofDescriptor* oneof) {
- return ToUpperCamel(ParseLowerUnderscore(oneof->name()));
-}
-
-// Returns the index corresponding to this field in the JSPB array (underlying
-// data storage array).
-TProtoStringType JSFieldIndex(const FieldDescriptor* field) {
- // Determine whether this field is a member of a group. Group fields are a bit
- // wonky: their "containing type" is a message type created just for the
- // group, and that type's parent type has a field with the group-message type
- // as its message type and TYPE_GROUP as its field type. For such fields, the
- // index we use is relative to the field number of the group submessage field.
- // For all other fields, we just use the field number.
- const Descriptor* containing_type = field->containing_type();
- const Descriptor* parent_type = containing_type->containing_type();
- if (parent_type != NULL) {
- for (int i = 0; i < parent_type->field_count(); i++) {
- if (parent_type->field(i)->type() == FieldDescriptor::TYPE_GROUP &&
- parent_type->field(i)->message_type() == containing_type) {
- return StrCat(field->number() - parent_type->field(i)->number());
- }
- }
- }
- return StrCat(field->number());
-}
-
-TProtoStringType JSOneofIndex(const OneofDescriptor* oneof) {
- int index = -1;
- for (int i = 0; i < oneof->containing_type()->oneof_decl_count(); i++) {
- const OneofDescriptor* o = oneof->containing_type()->oneof_decl(i);
- if (o->is_synthetic()) continue;
- // If at least one field in this oneof is not JSPB-ignored, count the oneof.
- for (int j = 0; j < o->field_count(); j++) {
- const FieldDescriptor* f = o->field(j);
- if (!IgnoreField(f)) {
- index++;
- break; // inner loop
- }
- }
- if (o == oneof) {
- break;
- }
- }
- return StrCat(index);
-}
-
-// Decodes a codepoint in \x0000 -- \xFFFF.
-uint16 DecodeUTF8Codepoint(uint8* bytes, size_t* length) {
- if (*length == 0) {
- return 0;
- }
- size_t expected = 0;
- if ((*bytes & 0x80) == 0) {
- expected = 1;
- } else if ((*bytes & 0xe0) == 0xc0) {
- expected = 2;
- } else if ((*bytes & 0xf0) == 0xe0) {
- expected = 3;
- } else {
- // Too long -- don't accept.
- *length = 0;
- return 0;
- }
-
- if (*length < expected) {
- // Not enough bytes -- don't accept.
- *length = 0;
- return 0;
- }
-
- *length = expected;
- switch (expected) {
- case 1:
- return bytes[0];
- case 2:
- return ((bytes[0] & 0x1F) << 6) | ((bytes[1] & 0x3F) << 0);
- case 3:
- return ((bytes[0] & 0x0F) << 12) | ((bytes[1] & 0x3F) << 6) |
- ((bytes[2] & 0x3F) << 0);
- default:
- return 0;
- }
-}
-
-// Escapes the contents of a string to be included within double-quotes ("") in
-// JavaScript. The input data should be a UTF-8 encoded C++ string of chars.
-// Returns false if |out| was truncated because |in| contained invalid UTF-8 or
-// codepoints outside the BMP.
-// TODO(b/115551870): Support codepoints outside the BMP.
-bool EscapeJSString(const TProtoStringType& in, TProtoStringType* out) {
- size_t decoded = 0;
- for (size_t i = 0; i < in.size(); i += decoded) {
- uint16 codepoint = 0;
- // Decode the next UTF-8 codepoint.
- size_t have_bytes = in.size() - i;
- uint8 bytes[3] = {
- static_cast<uint8>(in[i]),
- static_cast<uint8>(((i + 1) < in.size()) ? in[i + 1] : 0),
- static_cast<uint8>(((i + 2) < in.size()) ? in[i + 2] : 0),
- };
- codepoint = DecodeUTF8Codepoint(bytes, &have_bytes);
- if (have_bytes == 0) {
- return false;
- }
- decoded = have_bytes;
-
- switch (codepoint) {
- case '\'':
- *out += "\\x27";
- break;
- case '"':
- *out += "\\x22";
- break;
- case '<':
- *out += "\\x3c";
- break;
- case '=':
- *out += "\\x3d";
- break;
- case '>':
- *out += "\\x3e";
- break;
- case '&':
- *out += "\\x26";
- break;
- case '\b':
- *out += "\\b";
- break;
- case '\t':
- *out += "\\t";
- break;
- case '\n':
- *out += "\\n";
- break;
- case '\f':
- *out += "\\f";
- break;
- case '\r':
- *out += "\\r";
- break;
- case '\\':
- *out += "\\\\";
- break;
- default:
- // TODO(b/115551870): Once we're supporting codepoints outside the BMP,
- // use a single Unicode codepoint escape if the output language is
- // ECMAScript 2015 or above. Otherwise, use a surrogate pair.
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#String_literals
- if (codepoint >= 0x20 && codepoint <= 0x7e) {
- *out += static_cast<char>(codepoint);
- } else if (codepoint >= 0x100) {
- *out += StringPrintf("\\u%04x", codepoint);
- } else {
- *out += StringPrintf("\\x%02x", codepoint);
- }
- break;
- }
- }
- return true;
-}
-
-TProtoStringType EscapeBase64(const TProtoStringType& in) {
- static const char* kAlphabet =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
- TProtoStringType result;
-
- for (size_t i = 0; i < in.size(); i += 3) {
- int value = (in[i] << 16) | (((i + 1) < in.size()) ? (in[i + 1] << 8) : 0) |
- (((i + 2) < in.size()) ? (in[i + 2] << 0) : 0);
- result += kAlphabet[(value >> 18) & 0x3f];
- result += kAlphabet[(value >> 12) & 0x3f];
- if ((i + 1) < in.size()) {
- result += kAlphabet[(value >> 6) & 0x3f];
- } else {
- result += '=';
- }
- if ((i + 2) < in.size()) {
- result += kAlphabet[(value >> 0) & 0x3f];
- } else {
- result += '=';
- }
- }
-
- return result;
-}
-
-// Post-process the result of SimpleFtoa/SimpleDtoa to *exactly* match the
-// original codegen's formatting (which is just .toString() on java.lang.Double
-// or java.lang.Float).
-TProtoStringType PostProcessFloat(TProtoStringType result) {
- // If inf, -inf or nan, replace with +Infinity, -Infinity or NaN.
- if (result == "inf") {
- return "Infinity";
- } else if (result == "-inf") {
- return "-Infinity";
- } else if (result == "nan") {
- return "NaN";
- }
-
- // If scientific notation (e.g., "1e10"), (i) capitalize the "e", (ii)
- // ensure that the mantissa (portion prior to the "e") has at least one
- // fractional digit (after the decimal point), and (iii) strip any unnecessary
- // leading zeroes and/or '+' signs from the exponent.
- TProtoStringType::size_type exp_pos = result.find('e');
- if (exp_pos != TProtoStringType::npos) {
- TProtoStringType mantissa = result.substr(0, exp_pos);
- TProtoStringType exponent = result.substr(exp_pos + 1);
-
- // Add ".0" to mantissa if no fractional part exists.
- if (mantissa.find('.') == TProtoStringType::npos) {
- mantissa += ".0";
- }
-
- // Strip the sign off the exponent and store as |exp_neg|.
- bool exp_neg = false;
- if (!exponent.empty() && exponent[0] == '+') {
- exponent = exponent.substr(1);
- } else if (!exponent.empty() && exponent[0] == '-') {
- exp_neg = true;
- exponent = exponent.substr(1);
- }
-
- // Strip any leading zeroes off the exponent.
- while (exponent.size() > 1 && exponent[0] == '0') {
- exponent = exponent.substr(1);
- }
-
- return mantissa + "E" + TProtoStringType(exp_neg ? "-" : "") + exponent;
- }
-
- // Otherwise, this is an ordinary decimal number. Append ".0" if result has no
- // decimal/fractional part in order to match output of original codegen.
- if (result.find('.') == TProtoStringType::npos) {
- result += ".0";
- }
-
- return result;
-}
-
-TProtoStringType FloatToString(float value) {
- TProtoStringType result = SimpleFtoa(value);
- return PostProcessFloat(result);
-}
-
-TProtoStringType DoubleToString(double value) {
- TProtoStringType result = SimpleDtoa(value);
- return PostProcessFloat(result);
-}
-
-bool InRealOneof(const FieldDescriptor* field) {
- return field->containing_oneof() &&
- !field->containing_oneof()->is_synthetic();
-}
-
-// Return true if this is an integral field that should be represented as string
-// in JS.
-bool IsIntegralFieldWithStringJSType(const FieldDescriptor* field) {
- switch (field->cpp_type()) {
- case FieldDescriptor::CPPTYPE_INT64:
- case FieldDescriptor::CPPTYPE_UINT64:
- // The default value of JSType is JS_NORMAL, which behaves the same as
- // JS_NUMBER.
- return field->options().jstype() == FieldOptions::JS_STRING;
- default:
- return false;
- }
-}
-
-TProtoStringType MaybeNumberString(const FieldDescriptor* field,
- const TProtoStringType& orig) {
- return IsIntegralFieldWithStringJSType(field) ? ("\"" + orig + "\"") : orig;
-}
-
-TProtoStringType JSFieldDefault(const FieldDescriptor* field) {
- if (field->is_repeated()) {
- return "[]";
- }
-
- switch (field->cpp_type()) {
- case FieldDescriptor::CPPTYPE_INT32:
- return MaybeNumberString(field, StrCat(field->default_value_int32()));
- case FieldDescriptor::CPPTYPE_UINT32:
- // The original codegen is in Java, and Java protobufs store unsigned
- // integer values as signed integer values. In order to exactly match the
- // output, we need to reinterpret as base-2 signed. Ugh.
- return MaybeNumberString(
- field, StrCat(static_cast<int32>(field->default_value_uint32())));
- case FieldDescriptor::CPPTYPE_INT64:
- return MaybeNumberString(field, StrCat(field->default_value_int64()));
- case FieldDescriptor::CPPTYPE_UINT64:
- // See above note for uint32 -- reinterpreting as signed.
- return MaybeNumberString(
- field, StrCat(static_cast<int64>(field->default_value_uint64())));
- case FieldDescriptor::CPPTYPE_ENUM:
- return StrCat(field->default_value_enum()->number());
- case FieldDescriptor::CPPTYPE_BOOL:
- return field->default_value_bool() ? "true" : "false";
- case FieldDescriptor::CPPTYPE_FLOAT:
- return FloatToString(field->default_value_float());
- case FieldDescriptor::CPPTYPE_DOUBLE:
- return DoubleToString(field->default_value_double());
- case FieldDescriptor::CPPTYPE_STRING:
- if (field->type() == FieldDescriptor::TYPE_STRING) {
- TProtoStringType out;
- bool is_valid = EscapeJSString(field->default_value_string(), &out);
- if (!is_valid) {
- // TODO(b/115551870): Decide whether this should be a hard error.
- GOOGLE_LOG(WARNING)
- << "The default value for field " << field->full_name()
- << " was truncated since it contained invalid UTF-8 or"
- " codepoints outside the basic multilingual plane.";
- }
- return "\"" + out + "\"";
- } else { // Bytes
- return "\"" + EscapeBase64(field->default_value_string()) + "\"";
- }
- case FieldDescriptor::CPPTYPE_MESSAGE:
- return "null";
- }
- GOOGLE_LOG(FATAL) << "Shouldn't reach here.";
- return "";
-}
-
-TProtoStringType ProtoTypeName(const GeneratorOptions& options,
- const FieldDescriptor* field) {
- switch (field->type()) {
- case FieldDescriptor::TYPE_BOOL:
- return "bool";
- 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_STRING:
- return "string";
- case FieldDescriptor::TYPE_BYTES:
- return "bytes";
- case FieldDescriptor::TYPE_GROUP:
- return GetMessagePath(options, field->message_type());
- case FieldDescriptor::TYPE_ENUM:
- return GetEnumPath(options, field->enum_type());
- case FieldDescriptor::TYPE_MESSAGE:
- return GetMessagePath(options, field->message_type());
- default:
- return "";
- }
-}
-
-TProtoStringType JSIntegerTypeName(const FieldDescriptor* field) {
- return IsIntegralFieldWithStringJSType(field) ? "string" : "number";
-}
-
-TProtoStringType JSStringTypeName(const GeneratorOptions& options,
- const FieldDescriptor* field,
- BytesMode bytes_mode) {
- if (field->type() == FieldDescriptor::TYPE_BYTES) {
- switch (bytes_mode) {
- case BYTES_DEFAULT:
- return "(string|Uint8Array)";
- case BYTES_B64:
- return "string";
- case BYTES_U8:
- return "Uint8Array";
- default:
- assert(false);
- }
- }
- return "string";
-}
-
-TProtoStringType JSTypeName(const GeneratorOptions& options,
- const FieldDescriptor* field, BytesMode bytes_mode) {
- switch (field->cpp_type()) {
- case FieldDescriptor::CPPTYPE_BOOL:
- return "boolean";
- case FieldDescriptor::CPPTYPE_INT32:
- return JSIntegerTypeName(field);
- case FieldDescriptor::CPPTYPE_INT64:
- return JSIntegerTypeName(field);
- case FieldDescriptor::CPPTYPE_UINT32:
- return JSIntegerTypeName(field);
- case FieldDescriptor::CPPTYPE_UINT64:
- return JSIntegerTypeName(field);
- case FieldDescriptor::CPPTYPE_FLOAT:
- return "number";
- case FieldDescriptor::CPPTYPE_DOUBLE:
- return "number";
- case FieldDescriptor::CPPTYPE_STRING:
- return JSStringTypeName(options, field, bytes_mode);
- case FieldDescriptor::CPPTYPE_ENUM:
- return GetEnumPath(options, field->enum_type());
- case FieldDescriptor::CPPTYPE_MESSAGE:
- return GetMessagePath(options, field->message_type());
- default:
- return "";
- }
-}
-
-// Used inside Google only -- do not remove.
-bool UseBrokenPresenceSemantics(const GeneratorOptions& options,
- const FieldDescriptor* field) {
- return false;
-}
-
-// Returns true for fields that return "null" from accessors when they are
-// unset. This should normally only be true for non-repeated submessages, but we
-// have legacy users who relied on old behavior where accessors behaved this
-// way.
-bool ReturnsNullWhenUnset(const GeneratorOptions& options,
- const FieldDescriptor* field) {
- if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
- field->is_optional()) {
- return true;
- }
-
- // TODO(haberman): remove this case and unconditionally return false.
- return UseBrokenPresenceSemantics(options, field) && !field->is_repeated() &&
- !field->has_default_value();
-}
-
-// In a sane world, this would be the same as ReturnsNullWhenUnset(). But in
-// the status quo, some fields declare that they never return null/undefined
-// even though they actually do:
-// * required fields
-// * optional enum fields
-// * proto3 primitive fields.
-bool DeclaredReturnTypeIsNullable(const GeneratorOptions& options,
- const FieldDescriptor* field) {
- if (field->is_required() || field->type() == FieldDescriptor::TYPE_ENUM) {
- return false;
- }
-
- if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 &&
- field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) {
- return false;
- }
-
- return ReturnsNullWhenUnset(options, field);
-}
-
-bool SetterAcceptsUndefined(const GeneratorOptions& options,
- const FieldDescriptor* field) {
- if (ReturnsNullWhenUnset(options, field)) {
- return true;
- }
-
- // Broken presence semantics always accepts undefined for setters.
- return UseBrokenPresenceSemantics(options, field);
-}
-
-bool SetterAcceptsNull(const GeneratorOptions& options,
- const FieldDescriptor* field) {
- if (ReturnsNullWhenUnset(options, field)) {
- return true;
- }
-
- // With broken presence semantics, fields with defaults accept "null" for
- // setters, but other fields do not. This is a strange quirk of the old
- // codegen.
- return UseBrokenPresenceSemantics(options, field) &&
- field->has_default_value();
-}
-
-// Returns types which are known to by non-nullable by default.
-// The style guide requires that we omit "!" in this case.
-bool IsPrimitive(const TProtoStringType& type) {
- return type == "undefined" || type == "string" || type == "number" ||
- type == "boolean";
-}
-
-TProtoStringType JSFieldTypeAnnotation(const GeneratorOptions& options,
- const FieldDescriptor* field,
- bool is_setter_argument, bool force_present,
- bool singular_if_not_packed,
- BytesMode bytes_mode = BYTES_DEFAULT,
- bool force_singular = false) {
- TProtoStringType jstype = JSTypeName(options, field, bytes_mode);
-
- if (!force_singular && field->is_repeated() &&
- (field->is_packed() || !singular_if_not_packed)) {
- if (field->type() == FieldDescriptor::TYPE_BYTES &&
- bytes_mode == BYTES_DEFAULT) {
- jstype = "(Array<!Uint8Array>|Array<string>)";
- } else {
- if (!IsPrimitive(jstype)) {
- jstype = "!" + jstype;
- }
- jstype = "Array<" + jstype + ">";
- }
- }
-
- bool is_null_or_undefined = false;
-
- if (is_setter_argument) {
- if (SetterAcceptsNull(options, field)) {
- jstype = "?" + jstype;
- is_null_or_undefined = true;
- }
-
- if (SetterAcceptsUndefined(options, field)) {
- jstype += "|undefined";
- is_null_or_undefined = true;
- }
- } else if (force_present) {
- // Don't add null or undefined.
- } else {
- if (DeclaredReturnTypeIsNullable(options, field)) {
- jstype = "?" + jstype;
- is_null_or_undefined = true;
- }
- }
-
- if (!is_null_or_undefined && !IsPrimitive(jstype)) {
- jstype = "!" + jstype;
- }
-
- return jstype;
-}
-
-TProtoStringType JSBinaryReaderMethodType(const FieldDescriptor* field) {
- TProtoStringType name = field->type_name();
- if (name[0] >= 'a' && name[0] <= 'z') {
- name[0] = (name[0] - 'a') + 'A';
- }
- return IsIntegralFieldWithStringJSType(field) ? (name + "String") : name;
-}
-
-TProtoStringType JSBinaryReadWriteMethodName(const FieldDescriptor* field,
- bool is_writer) {
- TProtoStringType name = JSBinaryReaderMethodType(field);
- if (field->is_packed()) {
- name = "Packed" + name;
- } else if (is_writer && field->is_repeated()) {
- name = "Repeated" + name;
- }
- return name;
-}
-
-TProtoStringType JSBinaryReaderMethodName(const GeneratorOptions& options,
- const FieldDescriptor* field) {
- return "jspb.BinaryReader.prototype.read" +
- JSBinaryReadWriteMethodName(field, /* is_writer = */ false);
-}
-
-TProtoStringType JSBinaryWriterMethodName(const GeneratorOptions& options,
- const FieldDescriptor* field) {
- if (field->containing_type() &&
- field->containing_type()->options().message_set_wire_format()) {
- return "jspb.BinaryWriter.prototype.writeMessageSet";
- }
- return "jspb.BinaryWriter.prototype.write" +
- JSBinaryReadWriteMethodName(field, /* is_writer = */ true);
-}
-
-TProtoStringType JSTypeTag(const FieldDescriptor* desc) {
- switch (desc->type()) {
- case FieldDescriptor::TYPE_DOUBLE:
- case FieldDescriptor::TYPE_FLOAT:
- return "Float";
- case FieldDescriptor::TYPE_INT32:
- case FieldDescriptor::TYPE_UINT32:
- case FieldDescriptor::TYPE_INT64:
- case FieldDescriptor::TYPE_UINT64:
- case FieldDescriptor::TYPE_FIXED32:
- case FieldDescriptor::TYPE_FIXED64:
- case FieldDescriptor::TYPE_SINT32:
- case FieldDescriptor::TYPE_SINT64:
- case FieldDescriptor::TYPE_SFIXED32:
- case FieldDescriptor::TYPE_SFIXED64:
- if (IsIntegralFieldWithStringJSType(desc)) {
- return "StringInt";
- } else {
- return "Int";
- }
- case FieldDescriptor::TYPE_BOOL:
- return "Boolean";
- case FieldDescriptor::TYPE_STRING:
- return "String";
- case FieldDescriptor::TYPE_BYTES:
- return "Bytes";
- case FieldDescriptor::TYPE_ENUM:
- return "Enum";
- default:
- assert(false);
- }
- return "";
-}
-
-bool HasRepeatedFields(const GeneratorOptions& options,
- const Descriptor* desc) {
- for (int i = 0; i < desc->field_count(); i++) {
- if (desc->field(i)->is_repeated() && !desc->field(i)->is_map()) {
- return true;
- }
- }
- return false;
-}
-
-static const char* kRepeatedFieldArrayName = ".repeatedFields_";
-
-TProtoStringType RepeatedFieldsArrayName(const GeneratorOptions& options,
- const Descriptor* desc) {
- return HasRepeatedFields(options, desc)
- ? (GetMessagePath(options, desc) + kRepeatedFieldArrayName)
- : "null";
-}
-
-bool HasOneofFields(const Descriptor* desc) {
- for (int i = 0; i < desc->field_count(); i++) {
- if (InRealOneof(desc->field(i))) {
- return true;
- }
- }
- return false;
-}
-
-static const char* kOneofGroupArrayName = ".oneofGroups_";
-
-TProtoStringType OneofFieldsArrayName(const GeneratorOptions& options,
- const Descriptor* desc) {
- return HasOneofFields(desc)
- ? (GetMessagePath(options, desc) + kOneofGroupArrayName)
- : "null";
-}
-
-TProtoStringType RepeatedFieldNumberList(const GeneratorOptions& options,
- const Descriptor* desc) {
- std::vector<TProtoStringType> numbers;
- for (int i = 0; i < desc->field_count(); i++) {
- if (desc->field(i)->is_repeated() && !desc->field(i)->is_map()) {
- numbers.push_back(JSFieldIndex(desc->field(i)));
- }
- }
- return "[" + Join(numbers, ",") + "]";
-}
-
-TProtoStringType OneofGroupList(const Descriptor* desc) {
- // List of arrays (one per oneof), each of which is a list of field indices
- std::vector<TProtoStringType> oneof_entries;
- for (int i = 0; i < desc->oneof_decl_count(); i++) {
- const OneofDescriptor* oneof = desc->oneof_decl(i);
- if (IgnoreOneof(oneof)) {
- continue;
- }
-
- std::vector<TProtoStringType> oneof_fields;
- for (int j = 0; j < oneof->field_count(); j++) {
- if (IgnoreField(oneof->field(j))) {
- continue;
- }
- oneof_fields.push_back(JSFieldIndex(oneof->field(j)));
- }
- oneof_entries.push_back("[" + Join(oneof_fields, ",") + "]");
- }
- return "[" + Join(oneof_entries, ",") + "]";
-}
-
-TProtoStringType JSOneofArray(const GeneratorOptions& options,
- const FieldDescriptor* field) {
- return OneofFieldsArrayName(options, field->containing_type()) + "[" +
- JSOneofIndex(field->containing_oneof()) + "]";
-}
-
-TProtoStringType RelativeTypeName(const FieldDescriptor* field) {
- assert(field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM ||
- field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE);
- // For a field with an enum or message type, compute a name relative to the
- // path name of the message type containing this field.
- TProtoStringType package = field->file()->package();
- TProtoStringType containing_type = field->containing_type()->full_name() + ".";
- TProtoStringType type = (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM)
- ? field->enum_type()->full_name()
- : field->message_type()->full_name();
-
- // |prefix| is advanced as we find separators '.' past the common package
- // prefix that yield common prefixes in the containing type's name and this
- // type's name.
- int prefix = 0;
- for (int i = 0; i < type.size() && i < containing_type.size(); i++) {
- if (type[i] != containing_type[i]) {
- break;
- }
- if (type[i] == '.' && i >= package.size()) {
- prefix = i + 1;
- }
- }
-
- return type.substr(prefix);
-}
-
-TProtoStringType JSExtensionsObjectName(const GeneratorOptions& options,
- const FileDescriptor* from_file,
- const Descriptor* desc) {
- if (desc->full_name() == "google.protobuf.bridge.MessageSet") {
- // TODO(haberman): fix this for the kImportCommonJs case.
- return "jspb.Message.messageSetExtensions";
- } else {
- return MaybeCrossFileRef(options, from_file, desc) + ".extensions";
- }
-}
-
-static const int kMapKeyField = 1;
-static const int kMapValueField = 2;
-
-const FieldDescriptor* MapFieldKey(const FieldDescriptor* field) {
- assert(field->is_map());
- return field->message_type()->FindFieldByNumber(kMapKeyField);
-}
-
-const FieldDescriptor* MapFieldValue(const FieldDescriptor* field) {
- assert(field->is_map());
- return field->message_type()->FindFieldByNumber(kMapValueField);
-}
-
-TProtoStringType FieldDefinition(const GeneratorOptions& options,
- const FieldDescriptor* field) {
- if (field->is_map()) {
- const FieldDescriptor* key_field = MapFieldKey(field);
- const FieldDescriptor* value_field = MapFieldValue(field);
- TProtoStringType key_type = ProtoTypeName(options, key_field);
- TProtoStringType value_type;
- if (value_field->type() == FieldDescriptor::TYPE_ENUM ||
- value_field->type() == FieldDescriptor::TYPE_MESSAGE) {
- value_type = RelativeTypeName(value_field);
- } else {
- value_type = ProtoTypeName(options, value_field);
- }
- return StringPrintf("map<%s, %s> %s = %d;", key_type.c_str(),
- value_type.c_str(), field->name().c_str(),
- field->number());
- } else {
- TProtoStringType qualifier =
- field->is_repeated() ? "repeated"
- : (field->is_optional() ? "optional" : "required");
- TProtoStringType type, name;
- if (field->type() == FieldDescriptor::TYPE_ENUM ||
- field->type() == FieldDescriptor::TYPE_MESSAGE) {
- type = RelativeTypeName(field);
- name = field->name();
- } else if (field->type() == FieldDescriptor::TYPE_GROUP) {
- type = "group";
- name = field->message_type()->name();
- } else {
- type = ProtoTypeName(options, field);
- name = field->name();
- }
- return StringPrintf("%s %s %s = %d;", qualifier.c_str(), type.c_str(),
- name.c_str(), field->number());
- }
-}
-
-TProtoStringType FieldComments(const FieldDescriptor* field, BytesMode bytes_mode) {
- TProtoStringType comments;
- if (field->type() == FieldDescriptor::TYPE_BYTES && bytes_mode == BYTES_U8) {
- comments +=
- " * Note that Uint8Array is not supported on all browsers.\n"
- " * @see http://caniuse.com/Uint8Array\n";
- }
- return comments;
-}
-
-bool ShouldGenerateExtension(const FieldDescriptor* field) {
- return field->is_extension() && !IgnoreField(field);
-}
-
-bool HasExtensions(const Descriptor* desc) {
- for (int i = 0; i < desc->extension_count(); i++) {
- if (ShouldGenerateExtension(desc->extension(i))) {
- return true;
- }
- }
- for (int i = 0; i < desc->nested_type_count(); i++) {
- if (HasExtensions(desc->nested_type(i))) {
- return true;
- }
- }
- return false;
-}
-
-bool HasExtensions(const FileDescriptor* file) {
- for (int i = 0; i < file->extension_count(); i++) {
- if (ShouldGenerateExtension(file->extension(i))) {
- return true;
- }
- }
- for (int i = 0; i < file->message_type_count(); i++) {
- if (HasExtensions(file->message_type(i))) {
- return true;
- }
- }
- return false;
-}
-
-bool HasMap(const GeneratorOptions& options, const Descriptor* desc) {
- for (int i = 0; i < desc->field_count(); i++) {
- if (desc->field(i)->is_map()) {
- return true;
- }
- }
- for (int i = 0; i < desc->nested_type_count(); i++) {
- if (HasMap(options, desc->nested_type(i))) {
- return true;
- }
- }
- return false;
-}
-
-bool FileHasMap(const GeneratorOptions& options, const FileDescriptor* desc) {
- for (int i = 0; i < desc->message_type_count(); i++) {
- if (HasMap(options, desc->message_type(i))) {
- return true;
- }
- }
- return false;
-}
-
-bool IsExtendable(const Descriptor* desc) {
- return desc->extension_range_count() > 0;
-}
-
-// Returns the max index in the underlying data storage array beyond which the
-// extension object is used.
-TProtoStringType GetPivot(const Descriptor* desc) {
- static const int kDefaultPivot = 500;
-
- // Find the max field number
- int max_field_number = 0;
- for (int i = 0; i < desc->field_count(); i++) {
- if (!IgnoreField(desc->field(i)) &&
- desc->field(i)->number() > max_field_number) {
- max_field_number = desc->field(i)->number();
- }
- }
-
- int pivot = -1;
- if (IsExtendable(desc) || (max_field_number >= kDefaultPivot)) {
- pivot = ((max_field_number + 1) < kDefaultPivot) ? (max_field_number + 1)
- : kDefaultPivot;
- }
-
- return StrCat(pivot);
-}
-
-// Whether this field represents presence. For fields with presence, we
-// generate extra methods (clearFoo() and hasFoo()) for this field.
-bool HasFieldPresence(const GeneratorOptions& options,
- const FieldDescriptor* field) {
- // This returns false for repeated fields and maps, but we still do
- // generate clearFoo() methods for these through a special case elsewhere.
- return field->has_presence();
-}
-
-// We use this to implement the semantics that same file can be generated
-// multiple times, but only the last one keep the short name. Others all use
-// long name with extra information to distinguish (For message and enum, the
-// extra information is package name, for file level extension, the extra
-// information is proto's filename).
-// We never actually write the files, but we keep a set of which descriptors
-// were the final one for a given filename.
-class FileDeduplicator {
- public:
- explicit FileDeduplicator(const GeneratorOptions& options) {}
-
- // params:
- // filenames: a pair of {short filename, full filename}
- // (short filename don't have extra information, full filename
- // contains extra information)
- // desc: The Descriptor or SCC pointer or EnumDescriptor.
- bool AddFile(const std::pair<TProtoStringType, TProtoStringType> filenames,
- const void* desc) {
- if (descs_by_shortname_.find(filenames.first) !=
- descs_by_shortname_.end()) {
- // Change old pointer's actual name to full name.
- auto short_name_desc = descs_by_shortname_[filenames.first];
- allowed_descs_actual_name_[short_name_desc] =
- allowed_descs_full_name_[short_name_desc];
- }
- descs_by_shortname_[filenames.first] = desc;
- allowed_descs_actual_name_[desc] = filenames.first;
- allowed_descs_full_name_[desc] = filenames.second;
-
- return true;
- }
-
- void GetAllowedMap(std::map<const void*, TProtoStringType>* allowed_set) {
- *allowed_set = allowed_descs_actual_name_;
- }
-
- private:
- // The map that restores all the descs that are using short name as filename.
- std::map<TProtoStringType, const void*> descs_by_shortname_;
- // The final actual filename map.
- std::map<const void*, TProtoStringType> allowed_descs_actual_name_;
- // The full name map.
- std::map<const void*, TProtoStringType> allowed_descs_full_name_;
-};
-
-void DepthFirstSearch(const FileDescriptor* file,
- std::vector<const FileDescriptor*>* list,
- std::set<const FileDescriptor*>* seen) {
- if (!seen->insert(file).second) {
- return;
- }
-
- // Add all dependencies.
- for (int i = 0; i < file->dependency_count(); i++) {
- DepthFirstSearch(file->dependency(i), list, seen);
- }
-
- // Add this file.
- list->push_back(file);
-}
-
-// A functor for the predicate to remove_if() below. Returns true if a given
-// FileDescriptor is not in the given set.
-class NotInSet {
- public:
- explicit NotInSet(const std::set<const FileDescriptor*>& file_set)
- : file_set_(file_set) {}
-
- bool operator()(const FileDescriptor* file) {
- return file_set_.count(file) == 0;
- }
-
- private:
- const std::set<const FileDescriptor*>& file_set_;
-};
-
-// This function generates an ordering of the input FileDescriptors that matches
-// the logic of the old code generator. The order is significant because two
-// different input files can generate the same output file, and the last one
-// needs to win.
-void GenerateJspbFileOrder(const std::vector<const FileDescriptor*>& input,
- std::vector<const FileDescriptor*>* ordered) {
- // First generate an ordering of all reachable files (including dependencies)
- // with depth-first search. This mimics the behavior of --include_imports,
- // which is what the old codegen used.
- ordered->clear();
- std::set<const FileDescriptor*> seen;
- std::set<const FileDescriptor*> input_set;
- for (int i = 0; i < input.size(); i++) {
- DepthFirstSearch(input[i], ordered, &seen);
- input_set.insert(input[i]);
- }
-
- // Now remove the entries that are not actually in our input list.
- ordered->erase(
- std::remove_if(ordered->begin(), ordered->end(), NotInSet(input_set)),
- ordered->end());
-}
-
-// If we're generating code in file-per-type mode, avoid overwriting files
-// by choosing the last descriptor that writes each filename and permitting
-// only those to generate code.
-
-struct DepsGenerator {
- std::vector<const Descriptor*> operator()(const Descriptor* desc) const {
- std::vector<const Descriptor*> deps;
- auto maybe_add = [&](const Descriptor* d) {
- if (d) deps.push_back(d);
- };
- for (int i = 0; i < desc->field_count(); i++) {
- if (!IgnoreField(desc->field(i))) {
- maybe_add(desc->field(i)->message_type());
- }
- }
- for (int i = 0; i < desc->extension_count(); i++) {
- maybe_add(desc->extension(i)->message_type());
- maybe_add(desc->extension(i)->containing_type());
- }
- for (int i = 0; i < desc->nested_type_count(); i++) {
- maybe_add(desc->nested_type(i));
- }
- maybe_add(desc->containing_type());
-
- return deps;
- }
-};
-
-bool GenerateJspbAllowedMap(const GeneratorOptions& options,
- const std::vector<const FileDescriptor*>& files,
- std::map<const void*, TProtoStringType>* allowed_set,
- SCCAnalyzer<DepsGenerator>* analyzer) {
- std::vector<const FileDescriptor*> files_ordered;
- GenerateJspbFileOrder(files, &files_ordered);
-
- // Choose the last descriptor for each filename.
- FileDeduplicator dedup(options);
- std::set<const SCC*> added;
- for (int i = 0; i < files_ordered.size(); i++) {
- for (int j = 0; j < files_ordered[i]->message_type_count(); j++) {
- const Descriptor* desc = files_ordered[i]->message_type(j);
- if (added.insert(analyzer->GetSCC(desc)).second &&
- !dedup.AddFile(
- std::make_pair(
- GetMessagesFileName(options, analyzer->GetSCC(desc), false),
- GetMessagesFileName(options, analyzer->GetSCC(desc), true)),
- analyzer->GetSCC(desc))) {
- return false;
- }
- }
- for (int j = 0; j < files_ordered[i]->enum_type_count(); j++) {
- const EnumDescriptor* desc = files_ordered[i]->enum_type(j);
- if (!dedup.AddFile(std::make_pair(GetEnumFileName(options, desc, false),
- GetEnumFileName(options, desc, true)),
- desc)) {
- return false;
- }
- }
-
- // Pull out all free-floating extensions and generate files for those too.
- bool has_extension = false;
-
- for (int j = 0; j < files_ordered[i]->extension_count(); j++) {
- if (ShouldGenerateExtension(files_ordered[i]->extension(j))) {
- has_extension = true;
- }
- }
-
- if (has_extension) {
- if (!dedup.AddFile(
- std::make_pair(
- GetExtensionFileName(options, files_ordered[i], false),
- GetExtensionFileName(options, files_ordered[i], true)),
- files_ordered[i])) {
- return false;
- }
- }
- }
-
- dedup.GetAllowedMap(allowed_set);
-
- return true;
-}
-
-// Embeds base64 encoded GeneratedCodeInfo proto in a comment at the end of
-// file.
-void EmbedCodeAnnotations(const GeneratedCodeInfo& annotations,
- io::Printer* printer) {
- // Serialize annotations proto into base64 string.
- TProtoStringType meta_content;
- annotations.SerializeToString(&meta_content);
- TProtoStringType meta_64;
- Base64Escape(meta_content, &meta_64);
-
- // Print base64 encoded annotations at the end of output file in
- // a comment.
- printer->Print("\n// Below is base64 encoded GeneratedCodeInfo proto");
- printer->Print("\n// $encoded_proto$\n", "encoded_proto", meta_64);
-}
-
-bool IsWellKnownTypeFile(const FileDescriptor* file) {
- return HasPrefixString(file->name(), "google/protobuf/");
-}
-
-} // anonymous namespace
-
-void Generator::GenerateHeader(const GeneratorOptions& options,
- const FileDescriptor* file,
- io::Printer* printer) const {
- if (file != nullptr) {
- printer->Print("// source: $filename$\n", "filename", file->name());
- }
- printer->Print(
- "/**\n"
- " * @fileoverview\n"
- " * @enhanceable\n"
- // TODO(b/152440355): requireType/requires diverged from internal version.
- " * @suppress {missingRequire} reports error on implicit type usages.\n"
- " * @suppress {messageConventions} JS Compiler reports an "
- "error if a variable or\n"
- " * field starts with 'MSG_' and isn't a translatable "
- "message.\n"
- " * @public\n"
- " */\n"
- "// GENERATED CODE -- DO NOT EDIT!\n"
- "/* eslint-disable */\n"
- "// @ts-nocheck\n"
- "\n");
-}
-
-void Generator::FindProvidesForFile(const GeneratorOptions& options,
- io::Printer* printer,
- const FileDescriptor* file,
- std::set<TProtoStringType>* provided) const {
- for (int i = 0; i < file->message_type_count(); i++) {
- FindProvidesForMessage(options, printer, file->message_type(i), provided);
- }
- for (int i = 0; i < file->enum_type_count(); i++) {
- FindProvidesForEnum(options, printer, file->enum_type(i), provided);
- }
-}
-
-void Generator::FindProvides(const GeneratorOptions& options,
- io::Printer* printer,
- const std::vector<const FileDescriptor*>& files,
- std::set<TProtoStringType>* provided) const {
- for (int i = 0; i < files.size(); i++) {
- FindProvidesForFile(options, printer, files[i], provided);
- }
-
- printer->Print("\n");
-}
-
-void FindProvidesForOneOfEnum(const GeneratorOptions& options,
- const OneofDescriptor* oneof,
- std::set<TProtoStringType>* provided) {
- TProtoStringType name = GetMessagePath(options, oneof->containing_type()) + "." +
- JSOneofName(oneof) + "Case";
- provided->insert(name);
-}
-
-void FindProvidesForOneOfEnums(const GeneratorOptions& options,
- io::Printer* printer, const Descriptor* desc,
- std::set<TProtoStringType>* provided) {
- if (HasOneofFields(desc)) {
- for (int i = 0; i < desc->oneof_decl_count(); i++) {
- if (IgnoreOneof(desc->oneof_decl(i))) {
- continue;
- }
- FindProvidesForOneOfEnum(options, desc->oneof_decl(i), provided);
- }
- }
-}
-
-void Generator::FindProvidesForMessage(const GeneratorOptions& options,
- io::Printer* printer,
- const Descriptor* desc,
- std::set<TProtoStringType>* provided) const {
- if (IgnoreMessage(desc)) {
- return;
- }
-
- TProtoStringType name = GetMessagePath(options, desc);
- provided->insert(name);
-
- for (int i = 0; i < desc->enum_type_count(); i++) {
- FindProvidesForEnum(options, printer, desc->enum_type(i), provided);
- }
-
- FindProvidesForOneOfEnums(options, printer, desc, provided);
-
- for (int i = 0; i < desc->nested_type_count(); i++) {
- FindProvidesForMessage(options, printer, desc->nested_type(i), provided);
- }
-}
-void Generator::FindProvidesForEnum(const GeneratorOptions& options,
- io::Printer* printer,
- const EnumDescriptor* enumdesc,
- std::set<TProtoStringType>* provided) const {
- TProtoStringType name = GetEnumPath(options, enumdesc);
- provided->insert(name);
-}
-
-void Generator::FindProvidesForFields(
- const GeneratorOptions& options, io::Printer* printer,
- const std::vector<const FieldDescriptor*>& fields,
- std::set<TProtoStringType>* provided) const {
- for (int i = 0; i < fields.size(); i++) {
- const FieldDescriptor* field = fields[i];
-
- if (IgnoreField(field)) {
- continue;
- }
-
- TProtoStringType name = GetNamespace(options, field->file()) + "." +
- JSObjectFieldName(options, field);
- provided->insert(name);
- }
-}
-
-void Generator::GenerateProvides(const GeneratorOptions& options,
- io::Printer* printer,
- std::set<TProtoStringType>* provided) const {
- for (std::set<TProtoStringType>::iterator it = provided->begin();
- it != provided->end(); ++it) {
- if (options.import_style == GeneratorOptions::kImportClosure) {
- printer->Print("goog.provide('$name$');\n", "name", *it);
- } else {
- // We aren't using Closure's import system, but we use goog.exportSymbol()
- // to construct the expected tree of objects, eg.
- //
- // goog.exportSymbol('foo.bar.Baz', null, this);
- //
- // // Later generated code expects foo.bar = {} to exist:
- // foo.bar.Baz = function() { /* ... */ }
-
- // Do not use global scope in strict mode
- if (options.import_style == GeneratorOptions::kImportCommonJsStrict) {
- TProtoStringType namespaceObject = *it;
- // Remove "proto." from the namespace object
- GOOGLE_CHECK_EQ(0, namespaceObject.compare(0, 6, "proto."));
- namespaceObject.erase(0, 6);
- printer->Print("goog.exportSymbol('$name$', null, proto);\n", "name",
- namespaceObject);
- } else {
- printer->Print("goog.exportSymbol('$name$', null, global);\n", "name",
- *it);
- }
- }
- }
-}
-
-void Generator::GenerateRequiresForSCC(const GeneratorOptions& options,
- io::Printer* printer, const SCC* scc,
- std::set<TProtoStringType>* provided) const {
- std::set<TProtoStringType> required;
- std::set<TProtoStringType> forwards;
- bool have_message = false;
- bool has_extension = false;
- bool has_map = false;
- for (auto desc : scc->descriptors) {
- if (desc->containing_type() == nullptr) {
- FindRequiresForMessage(options, desc, &required, &forwards,
- &have_message);
- has_extension = (has_extension || HasExtensions(desc));
- has_map = (has_map || HasMap(options, desc));
- }
- }
-
- GenerateRequiresImpl(options, printer, &required, &forwards, provided,
- /* require_jspb = */ have_message,
- /* require_extension = */ has_extension,
- /* require_map = */ has_map);
-}
-
-void Generator::GenerateRequiresForLibrary(
- const GeneratorOptions& options, io::Printer* printer,
- const std::vector<const FileDescriptor*>& files,
- std::set<TProtoStringType>* provided) const {
- GOOGLE_CHECK_EQ(options.import_style, GeneratorOptions::kImportClosure);
- // For Closure imports we need to import every message type individually.
- std::set<TProtoStringType> required;
- std::set<TProtoStringType> forwards;
- bool have_extensions = false;
- bool have_map = false;
- bool have_message = false;
-
- for (int i = 0; i < files.size(); i++) {
- for (int j = 0; j < files[i]->message_type_count(); j++) {
- const Descriptor* desc = files[i]->message_type(j);
- if (!IgnoreMessage(desc)) {
- FindRequiresForMessage(options, desc, &required, &forwards,
- &have_message);
- }
- }
-
- if (!have_extensions && HasExtensions(files[i])) {
- have_extensions = true;
- }
-
- if (!have_map && FileHasMap(options, files[i])) {
- have_map = true;
- }
-
- for (int j = 0; j < files[i]->extension_count(); j++) {
- const FieldDescriptor* extension = files[i]->extension(j);
- if (IgnoreField(extension)) {
- continue;
- }
- if (extension->containing_type()->full_name() !=
- "google.protobuf.bridge.MessageSet") {
- required.insert(GetMessagePath(options, extension->containing_type()));
- }
- FindRequiresForField(options, extension, &required, &forwards);
- have_extensions = true;
- }
- }
-
- GenerateRequiresImpl(options, printer, &required, &forwards, provided,
- /* require_jspb = */ have_message,
- /* require_extension = */ have_extensions,
- /* require_map = */ have_map);
-}
-
-void Generator::GenerateRequiresForExtensions(
- const GeneratorOptions& options, io::Printer* printer,
- const std::vector<const FieldDescriptor*>& fields,
- std::set<TProtoStringType>* provided) const {
- std::set<TProtoStringType> required;
- std::set<TProtoStringType> forwards;
- for (int i = 0; i < fields.size(); i++) {
- const FieldDescriptor* field = fields[i];
- if (IgnoreField(field)) {
- continue;
- }
- FindRequiresForExtension(options, field, &required, &forwards);
- }
-
- GenerateRequiresImpl(options, printer, &required, &forwards, provided,
- /* require_jspb = */ false,
- /* require_extension = */ fields.size() > 0,
- /* require_map = */ false);
-}
-
-void Generator::GenerateRequiresImpl(const GeneratorOptions& options,
- io::Printer* printer,
- std::set<TProtoStringType>* required,
- std::set<TProtoStringType>* forwards,
- std::set<TProtoStringType>* provided,
- bool require_jspb, bool require_extension,
- bool require_map) const {
- if (require_jspb) {
- required->insert("jspb.Message");
- required->insert("jspb.BinaryReader");
- required->insert("jspb.BinaryWriter");
- }
- if (require_extension) {
- required->insert("jspb.ExtensionFieldBinaryInfo");
- required->insert("jspb.ExtensionFieldInfo");
- }
- if (require_map) {
- required->insert("jspb.Map");
- }
-
- std::set<TProtoStringType>::iterator it;
- for (it = required->begin(); it != required->end(); ++it) {
- if (provided->find(*it) != provided->end()) {
- continue;
- }
- printer->Print("goog.require('$name$');\n", "name", *it);
- }
-
- printer->Print("\n");
-
- for (it = forwards->begin(); it != forwards->end(); ++it) {
- if (provided->find(*it) != provided->end()) {
- continue;
- }
- printer->Print("goog.forwardDeclare('$name$');\n", "name", *it);
- }
-}
-
-bool NamespaceOnly(const Descriptor* desc) { return false; }
-
-void Generator::FindRequiresForMessage(const GeneratorOptions& options,
- const Descriptor* desc,
- std::set<TProtoStringType>* required,
- std::set<TProtoStringType>* forwards,
- bool* have_message) const {
- if (!NamespaceOnly(desc)) {
- *have_message = true;
- for (int i = 0; i < desc->field_count(); i++) {
- const FieldDescriptor* field = desc->field(i);
- if (IgnoreField(field)) {
- continue;
- }
- FindRequiresForField(options, field, required, forwards);
- }
- }
-
- for (int i = 0; i < desc->extension_count(); i++) {
- const FieldDescriptor* field = desc->extension(i);
- if (IgnoreField(field)) {
- continue;
- }
- FindRequiresForExtension(options, field, required, forwards);
- }
-
- for (int i = 0; i < desc->nested_type_count(); i++) {
- FindRequiresForMessage(options, desc->nested_type(i), required, forwards,
- have_message);
- }
-}
-
-void Generator::FindRequiresForField(const GeneratorOptions& options,
- const FieldDescriptor* field,
- std::set<TProtoStringType>* required,
- std::set<TProtoStringType>* forwards) const {
- if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM &&
- // N.B.: file-level extensions with enum type do *not* create
- // dependencies, as per original codegen.
- !(field->is_extension() && field->extension_scope() == nullptr)) {
- if (options.add_require_for_enums) {
- required->insert(GetEnumPath(options, field->enum_type()));
- } else {
- forwards->insert(GetEnumPath(options, field->enum_type()));
- }
- } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- if (!IgnoreMessage(field->message_type())) {
- required->insert(GetMessagePath(options, field->message_type()));
- }
- }
-}
-
-void Generator::FindRequiresForExtension(
- const GeneratorOptions& options, const FieldDescriptor* field,
- std::set<TProtoStringType>* required, std::set<TProtoStringType>* forwards) const {
- if (field->containing_type()->full_name() !=
- "google.protobuf.bridge.MessageSet") {
- required->insert(GetMessagePath(options, field->containing_type()));
- }
- FindRequiresForField(options, field, required, forwards);
-}
-
-void Generator::GenerateTestOnly(const GeneratorOptions& options,
- io::Printer* printer) const {
- if (options.testonly) {
- printer->Print("goog.setTestOnly();\n\n");
- }
- printer->Print("\n");
-}
-
-void Generator::GenerateClassesAndEnums(const GeneratorOptions& options,
- io::Printer* printer,
- const FileDescriptor* file) const {
- for (int i = 0; i < file->message_type_count(); i++) {
- GenerateClassConstructorAndDeclareExtensionFieldInfo(options, printer,
- file->message_type(i));
- }
- for (int i = 0; i < file->message_type_count(); i++) {
- GenerateClass(options, printer, file->message_type(i));
- }
- for (int i = 0; i < file->enum_type_count(); i++) {
- GenerateEnum(options, printer, file->enum_type(i));
- }
-}
-
-void Generator::GenerateClass(const GeneratorOptions& options,
- io::Printer* printer,
- const Descriptor* desc) const {
- if (IgnoreMessage(desc)) {
- return;
- }
-
- if (!NamespaceOnly(desc)) {
- printer->Print("\n");
- GenerateClassFieldInfo(options, printer, desc);
-
- GenerateClassToObject(options, printer, desc);
- // These must come *before* the extension-field info generation in
- // GenerateClassRegistration so that references to the binary
- // serialization/deserialization functions may be placed in the extension
- // objects.
- GenerateClassDeserializeBinary(options, printer, desc);
- GenerateClassSerializeBinary(options, printer, desc);
- }
-
- // Recurse on nested types. These must come *before* the extension-field
- // info generation in GenerateClassRegistration so that extensions that
- // reference nested types proceed the definitions of the nested types.
- for (int i = 0; i < desc->enum_type_count(); i++) {
- GenerateEnum(options, printer, desc->enum_type(i));
- }
- for (int i = 0; i < desc->nested_type_count(); i++) {
- GenerateClass(options, printer, desc->nested_type(i));
- }
-
- if (!NamespaceOnly(desc)) {
- GenerateClassRegistration(options, printer, desc);
- GenerateClassFields(options, printer, desc);
-
- if (options.import_style != GeneratorOptions::kImportClosure) {
- for (int i = 0; i < desc->extension_count(); i++) {
- GenerateExtension(options, printer, desc->extension(i));
- }
- }
- }
-}
-
-void Generator::GenerateClassConstructor(const GeneratorOptions& options,
- io::Printer* printer,
- const Descriptor* desc) const {
- printer->Print(
- "/**\n"
- " * Generated by JsPbCodeGenerator.\n"
- " * @param {Array=} opt_data Optional initial data array, typically "
- "from a\n"
- " * server response, or constructed directly in Javascript. The array "
- "is used\n"
- " * in place and becomes part of the constructed object. It is not "
- "cloned.\n"
- " * If no data is provided, the constructed object will be empty, but "
- "still\n"
- " * valid.\n"
- " * @extends {jspb.Message}\n"
- " * @constructor\n"
- " */\n"
- "$classprefix$$classname$ = function(opt_data) {\n",
- "classprefix", GetMessagePathPrefix(options, desc), "classname",
- desc->name());
- printer->Annotate("classname", desc);
- TProtoStringType message_id = GetMessageId(desc);
- printer->Print(
- " jspb.Message.initialize(this, opt_data, $messageId$, $pivot$, "
- "$rptfields$, $oneoffields$);\n",
- "messageId",
- !message_id.empty() ? ("'" + message_id + "'")
- : (IsResponse(desc) ? "''" : "0"),
- "pivot", GetPivot(desc), "rptfields",
- RepeatedFieldsArrayName(options, desc), "oneoffields",
- OneofFieldsArrayName(options, desc));
- printer->Print(
- "};\n"
- "goog.inherits($classname$, jspb.Message);\n"
- "if (goog.DEBUG && !COMPILED) {\n"
- // displayName overrides Function.prototype.displayName
- // http://google3/javascript/externs/es3.js?l=511
- " /**\n"
- " * @public\n"
- " * @override\n"
- " */\n"
- " $classname$.displayName = '$classname$';\n"
- "}\n",
- "classname", GetMessagePath(options, desc));
-}
-
-void Generator::GenerateClassConstructorAndDeclareExtensionFieldInfo(
- const GeneratorOptions& options, io::Printer* printer,
- const Descriptor* desc) const {
- if (!NamespaceOnly(desc)) {
- GenerateClassConstructor(options, printer, desc);
- if (IsExtendable(desc) &&
- desc->full_name() != "google.protobuf.bridge.MessageSet") {
- GenerateClassExtensionFieldInfo(options, printer, desc);
- }
- }
- for (int i = 0; i < desc->nested_type_count(); i++) {
- if (!IgnoreMessage(desc->nested_type(i))) {
- GenerateClassConstructorAndDeclareExtensionFieldInfo(
- options, printer, desc->nested_type(i));
- }
- }
-}
-
-void Generator::GenerateClassFieldInfo(const GeneratorOptions& options,
- io::Printer* printer,
- const Descriptor* desc) const {
- if (HasRepeatedFields(options, desc)) {
- printer->Print(
- "/**\n"
- " * List of repeated fields within this message type.\n"
- " * @private {!Array<number>}\n"
- " * @const\n"
- " */\n"
- "$classname$$rptfieldarray$ = $rptfields$;\n"
- "\n",
- "classname", GetMessagePath(options, desc), "rptfieldarray",
- kRepeatedFieldArrayName, "rptfields",
- RepeatedFieldNumberList(options, desc));
- }
-
- if (HasOneofFields(desc)) {
- printer->Print(
- "/**\n"
- " * Oneof group definitions for this message. Each group defines the "
- "field\n"
- " * numbers belonging to that group. When of these fields' value is "
- "set, all\n"
- " * other fields in the group are cleared. During deserialization, if "
- "multiple\n"
- " * fields are encountered for a group, only the last value seen will "
- "be kept.\n"
- " * @private {!Array<!Array<number>>}\n"
- " * @const\n"
- " */\n"
- "$classname$$oneofgrouparray$ = $oneofgroups$;\n"
- "\n",
- "classname", GetMessagePath(options, desc), "oneofgrouparray",
- kOneofGroupArrayName, "oneofgroups", OneofGroupList(desc));
-
- for (int i = 0; i < desc->oneof_decl_count(); i++) {
- if (IgnoreOneof(desc->oneof_decl(i))) {
- continue;
- }
- GenerateOneofCaseDefinition(options, printer, desc->oneof_decl(i));
- }
- }
-}
-
-void Generator::GenerateClassXid(const GeneratorOptions& options,
- io::Printer* printer,
- const Descriptor* desc) const {
- printer->Print(
- "\n"
- "\n"
- "$class$.prototype.messageXid = xid('$class$');\n",
- "class", GetMessagePath(options, desc));
-}
-
-void Generator::GenerateOneofCaseDefinition(
- const GeneratorOptions& options, io::Printer* printer,
- const OneofDescriptor* oneof) const {
- printer->Print(
- "/**\n"
- " * @enum {number}\n"
- " */\n"
- "$classname$.$oneof$Case = {\n"
- " $upcase$_NOT_SET: 0",
- "classname", GetMessagePath(options, oneof->containing_type()), "oneof",
- JSOneofName(oneof), "upcase", ToEnumCase(oneof->name()));
-
- for (int i = 0; i < oneof->field_count(); i++) {
- if (IgnoreField(oneof->field(i))) {
- continue;
- }
-
- printer->Print(
- ",\n"
- " $upcase$: $number$",
- "upcase", ToEnumCase(oneof->field(i)->name()), "number",
- JSFieldIndex(oneof->field(i)));
- printer->Annotate("upcase", oneof->field(i));
- }
-
- printer->Print(
- "\n"
- "};\n"
- "\n"
- "/**\n"
- " * @return {$class$.$oneof$Case}\n"
- " */\n"
- "$class$.prototype.get$oneof$Case = function() {\n"
- " return /** @type {$class$.$oneof$Case} */(jspb.Message."
- "computeOneofCase(this, $class$.oneofGroups_[$oneofindex$]));\n"
- "};\n"
- "\n",
- "class", GetMessagePath(options, oneof->containing_type()), "oneof",
- JSOneofName(oneof), "oneofindex", JSOneofIndex(oneof));
-}
-
-void Generator::GenerateClassToObject(const GeneratorOptions& options,
- io::Printer* printer,
- const Descriptor* desc) const {
- printer->Print(
- "\n"
- "\n"
- "if (jspb.Message.GENERATE_TO_OBJECT) {\n"
- "/**\n"
- " * Creates an object representation of this proto.\n"
- " * Field names that are reserved in JavaScript and will be renamed to "
- "pb_name.\n"
- " * Optional fields that are not set will be set to undefined.\n"
- " * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.\n"
- " * For the list of reserved names please see:\n"
- " * net/proto2/compiler/js/internal/generator.cc#kKeyword.\n"
- " * @param {boolean=} opt_includeInstance Deprecated. whether to include "
- "the\n"
- " * JSPB instance for transitional soy proto support:\n"
- " * http://goto/soy-param-migration\n"
- " * @return {!Object}\n"
- " */\n"
- "$classname$.prototype.toObject = function(opt_includeInstance) {\n"
- " return $classname$.toObject(opt_includeInstance, this);\n"
- "};\n"
- "\n"
- "\n"
- "/**\n"
- " * Static version of the {@see toObject} method.\n"
- " * @param {boolean|undefined} includeInstance Deprecated. Whether to "
- "include\n"
- " * the JSPB instance for transitional soy proto support:\n"
- " * http://goto/soy-param-migration\n"
- " * @param {!$classname$} msg The msg instance to transform.\n"
- " * @return {!Object}\n"
- " * @suppress {unusedLocalVariables} f is only used for nested messages\n"
- " */\n"
- "$classname$.toObject = function(includeInstance, msg) {\n"
- " var f, obj = {",
- "classname", GetMessagePath(options, desc));
-
- bool first = true;
- for (int i = 0; i < desc->field_count(); i++) {
- const FieldDescriptor* field = desc->field(i);
- if (IgnoreField(field)) {
- continue;
- }
-
- if (!first) {
- printer->Print(",\n ");
- } else {
- printer->Print("\n ");
- first = false;
- }
-
- GenerateClassFieldToObject(options, printer, field);
- }
-
- if (!first) {
- printer->Print("\n };\n\n");
- } else {
- printer->Print("\n\n };\n\n");
- }
-
- if (IsExtendable(desc)) {
- printer->Print(
- " jspb.Message.toObjectExtension(/** @type {!jspb.Message} */ (msg), "
- "obj,\n"
- " $extObject$, $class$.prototype.getExtension,\n"
- " includeInstance);\n",
- "extObject", JSExtensionsObjectName(options, desc->file(), desc),
- "class", GetMessagePath(options, desc));
- }
-
- printer->Print(
- " if (includeInstance) {\n"
- " obj.$$jspbMessageInstance = msg;\n"
- " }\n"
- " return obj;\n"
- "};\n"
- "}\n"
- "\n"
- "\n",
- "classname", GetMessagePath(options, desc));
-}
-
-void Generator::GenerateFieldValueExpression(io::Printer* printer,
- const char* obj_reference,
- const FieldDescriptor* field,
- bool use_default) const {
- const bool is_float_or_double =
- field->cpp_type() == FieldDescriptor::CPPTYPE_FLOAT ||
- field->cpp_type() == FieldDescriptor::CPPTYPE_DOUBLE;
- const bool is_boolean = field->cpp_type() == FieldDescriptor::CPPTYPE_BOOL;
-
- const TProtoStringType with_default = use_default ? "WithDefault" : "";
- const TProtoStringType default_arg =
- use_default ? StrCat(", ", JSFieldDefault(field)) : "";
- const TProtoStringType cardinality = field->is_repeated() ? "Repeated" : "";
- TProtoStringType type = "";
- if (is_float_or_double) {
- type = "FloatingPoint";
- }
- if (is_boolean) {
- type = "Boolean";
- }
-
- // Prints the appropriate function, among:
- // - getField
- // - getBooleanField
- // - getFloatingPointField => Replaced by getOptionalFloatingPointField to
- // preserve backward compatibility.
- // - getFieldWithDefault
- // - getBooleanFieldWithDefault
- // - getFloatingPointFieldWithDefault
- // - getRepeatedField
- // - getRepeatedBooleanField
- // - getRepeatedFloatingPointField
- if (is_float_or_double && !field->is_repeated() && !use_default) {
- printer->Print(
- "jspb.Message.getOptionalFloatingPointField($obj$, "
- "$index$$default$)",
- "obj", obj_reference, "index", JSFieldIndex(field), "default",
- default_arg);
- } else {
- printer->Print(
- "jspb.Message.get$cardinality$$type$Field$with_default$($obj$, "
- "$index$$default$)",
- "cardinality", cardinality, "type", type, "with_default", with_default,
- "obj", obj_reference, "index", JSFieldIndex(field), "default",
- default_arg);
- }
-}
-
-void Generator::GenerateClassFieldToObject(const GeneratorOptions& options,
- io::Printer* printer,
- const FieldDescriptor* field) const {
- printer->Print("$fieldname$: ", "fieldname",
- JSObjectFieldName(options, field));
-
- if (field->is_map()) {
- const FieldDescriptor* value_field = MapFieldValue(field);
- // If the map values are of a message type, we must provide their static
- // toObject() method; otherwise we pass undefined for that argument.
- TProtoStringType value_to_object;
- if (value_field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- value_to_object =
- GetMessagePath(options, value_field->message_type()) + ".toObject";
- } else {
- value_to_object = "undefined";
- }
- printer->Print(
- "(f = msg.get$name$()) ? f.toObject(includeInstance, $valuetoobject$) "
- ": []",
- "name", JSGetterName(options, field), "valuetoobject", value_to_object);
- } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- // Message field.
- if (field->is_repeated()) {
- {
- printer->Print(
- "jspb.Message.toObjectList(msg.get$getter$(),\n"
- " $type$.toObject, includeInstance)",
- "getter", JSGetterName(options, field), "type",
- SubmessageTypeRef(options, field));
- }
- } else {
- printer->Print(
- "(f = msg.get$getter$()) && "
- "$type$.toObject(includeInstance, f)",
- "getter", JSGetterName(options, field), "type",
- SubmessageTypeRef(options, field));
- }
- } else if (field->type() == FieldDescriptor::TYPE_BYTES) {
- // For bytes fields we want to always return the B64 data.
- printer->Print("msg.get$getter$()", "getter",
- JSGetterName(options, field, BYTES_B64));
- } else {
- bool use_default = field->has_default_value();
-
- if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 &&
- // Repeated fields get initialized to their default in the constructor
- // (why?), so we emit a plain getField() call for them.
- !field->is_repeated()) {
- // Proto3 puts all defaults (including implicit defaults) in toObject().
- // But for proto2 we leave the existing semantics unchanged: unset fields
- // without default are unset.
- use_default = true;
- }
-
- // We don't implement this by calling the accessors, because the semantics
- // of the accessors are changing independently of the toObject() semantics.
- // We are migrating the accessors to return defaults instead of null, but
- // it may take longer to migrate toObject (or we might not want to do it at
- // all). So we want to generate independent code.
- // The accessor for unset optional values without default should return
- // null. Those are converted to undefined in the generated object.
- if (!use_default) {
- printer->Print("(f = ");
- }
- GenerateFieldValueExpression(printer, "msg", field, use_default);
- if (!use_default) {
- printer->Print(") == null ? undefined : f");
- }
- }
-}
-
-void Generator::GenerateObjectTypedef(const GeneratorOptions& options,
- io::Printer* printer,
- const Descriptor* desc) const {
- // TODO(b/122687752): Consider renaming nested messages called ObjectFormat
- // to prevent collisions.
- const TProtoStringType type_name = GetMessagePath(options, desc) + ".ObjectFormat";
-
- printer->Print(
- "/**\n"
- " * The raw object form of $messageName$ as accepted by the `fromObject` "
- "method.\n"
- " * @record\n"
- " */\n"
- "$typeName$ = function() {\n",
- "messageName", desc->name(), "typeName", type_name);
-
- for (int i = 0; i < desc->field_count(); i++) {
- if (i > 0) {
- printer->Print("\n");
- }
- printer->Print(
- " /** @type {$fieldType$|undefined} */\n"
- " this.$fieldName$;\n",
- "fieldName", JSObjectFieldName(options, desc->field(i)),
- // TODO(b/121097361): Add type checking for field values.
- "fieldType", "?");
- }
-
- printer->Print("};\n\n");
-}
-
-void Generator::GenerateClassFromObject(const GeneratorOptions& options,
- io::Printer* printer,
- const Descriptor* desc) const {
- printer->Print("if (jspb.Message.GENERATE_FROM_OBJECT) {\n\n");
-
- GenerateObjectTypedef(options, printer, desc);
-
- printer->Print(
- "/**\n"
- " * Loads data from an object into a new instance of this proto.\n"
- " * @param {!$classname$.ObjectFormat} obj\n"
- " * The object representation of this proto to load the data from.\n"
- " * @return {!$classname$}\n"
- " */\n"
- "$classname$.fromObject = function(obj) {\n"
- " var msg = new $classname$();\n",
- "classname", GetMessagePath(options, desc));
-
- for (int i = 0; i < desc->field_count(); i++) {
- const FieldDescriptor* field = desc->field(i);
- if (!IgnoreField(field)) {
- GenerateClassFieldFromObject(options, printer, field);
- }
- }
-
- printer->Print(
- " return msg;\n"
- "};\n"
- "}\n\n");
-}
-
-void Generator::GenerateClassFieldFromObject(
- const GeneratorOptions& options, io::Printer* printer,
- const FieldDescriptor* field) const {
- if (field->is_map()) {
- const FieldDescriptor* value_field = MapFieldValue(field);
- if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) {
- // Since the map values are of message type, we have to do some extra work
- // to recursively call fromObject() on them before setting the map field.
- printer->Print(
- " obj.$name$ && jspb.Message.setWrapperField(\n"
- " msg, $index$, jspb.Map.fromObject(obj.$name$, $fieldclass$, "
- "$fieldclass$.fromObject));\n",
- "name", JSObjectFieldName(options, field), "index",
- JSFieldIndex(field), "fieldclass",
- GetMessagePath(options, value_field->message_type()));
- } else {
- // `msg` is a newly-constructed message object that has not yet built any
- // map containers wrapping underlying arrays, so we can simply directly
- // set the array here without fear of a stale wrapper.
- printer->Print(
- " obj.$name$ && "
- "jspb.Message.setField(msg, $index$, obj.$name$);\n",
- "name", JSObjectFieldName(options, field), "index",
- JSFieldIndex(field));
- }
- } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- // Message field (singular or repeated)
- if (field->is_repeated()) {
- {
- printer->Print(
- " obj.$name$ && "
- "jspb.Message.setRepeatedWrapperField(\n"
- " msg, $index$, obj.$name$.map(\n"
- " $fieldclass$.fromObject));\n",
- "name", JSObjectFieldName(options, field), "index",
- JSFieldIndex(field), "fieldclass",
- SubmessageTypeRef(options, field));
- }
- } else {
- printer->Print(
- " obj.$name$ && jspb.Message.setWrapperField(\n"
- " msg, $index$, $fieldclass$.fromObject(obj.$name$));\n",
- "name", JSObjectFieldName(options, field), "index",
- JSFieldIndex(field), "fieldclass", SubmessageTypeRef(options, field));
- }
- } else {
- // Simple (primitive) field.
- printer->Print(
- " obj.$name$ != null && jspb.Message.setField(msg, $index$, "
- "obj.$name$);\n",
- "name", JSObjectFieldName(options, field), "index",
- JSFieldIndex(field));
- }
-}
-
-void Generator::GenerateClassRegistration(const GeneratorOptions& options,
- io::Printer* printer,
- const Descriptor* desc) const {
- // Register any extensions defined inside this message type.
- for (int i = 0; i < desc->extension_count(); i++) {
- const FieldDescriptor* extension = desc->extension(i);
- if (ShouldGenerateExtension(extension)) {
- GenerateExtension(options, printer, extension);
- }
- }
-}
-
-void Generator::GenerateClassFields(const GeneratorOptions& options,
- io::Printer* printer,
- const Descriptor* desc) const {
- for (int i = 0; i < desc->field_count(); i++) {
- if (!IgnoreField(desc->field(i))) {
- GenerateClassField(options, printer, desc->field(i));
- }
- }
-}
-
-void GenerateBytesWrapper(const GeneratorOptions& options, io::Printer* printer,
- const FieldDescriptor* field, BytesMode bytes_mode) {
- TProtoStringType type =
- JSFieldTypeAnnotation(options, field,
- /* is_setter_argument = */ false,
- /* force_present = */ false,
- /* singular_if_not_packed = */ false, bytes_mode);
- printer->Print(
- "/**\n"
- " * $fielddef$\n"
- "$comment$"
- " * This is a type-conversion wrapper around `get$defname$()`\n"
- " * @return {$type$}\n"
- " */\n"
- "$class$.prototype.get$name$ = function() {\n"
- " return /** @type {$type$} */ (jspb.Message.bytes$list$As$suffix$(\n"
- " this.get$defname$()));\n"
- "};\n"
- "\n"
- "\n",
- "fielddef", FieldDefinition(options, field), "comment",
- FieldComments(field, bytes_mode), "type", type, "class",
- GetMessagePath(options, field->containing_type()), "name",
- JSGetterName(options, field, bytes_mode), "list",
- field->is_repeated() ? "List" : "", "suffix",
- JSByteGetterSuffix(bytes_mode), "defname",
- JSGetterName(options, field, BYTES_DEFAULT));
-}
-
-void Generator::GenerateClassField(const GeneratorOptions& options,
- io::Printer* printer,
- const FieldDescriptor* field) const {
- if (field->is_map()) {
- const FieldDescriptor* key_field = MapFieldKey(field);
- const FieldDescriptor* value_field = MapFieldValue(field);
- // Map field: special handling to instantiate the map object on demand.
- TProtoStringType key_type =
- JSFieldTypeAnnotation(options, key_field,
- /* is_setter_argument = */ false,
- /* force_present = */ true,
- /* singular_if_not_packed = */ false);
- TProtoStringType value_type =
- JSFieldTypeAnnotation(options, value_field,
- /* is_setter_argument = */ false,
- /* force_present = */ true,
- /* singular_if_not_packed = */ false);
-
- printer->Print(
- "/**\n"
- " * $fielddef$\n"
- " * @param {boolean=} opt_noLazyCreate Do not create the map if\n"
- " * empty, instead returning `undefined`\n"
- " * @return {!jspb.Map<$keytype$,$valuetype$>}\n"
- " */\n",
- "fielddef", FieldDefinition(options, field), "keytype", key_type,
- "valuetype", value_type);
- printer->Print(
- "$class$.prototype.$gettername$ = function(opt_noLazyCreate) {\n"
- " return /** @type {!jspb.Map<$keytype$,$valuetype$>} */ (\n",
- "class", GetMessagePath(options, field->containing_type()),
- "gettername", "get" + JSGetterName(options, field), "keytype", key_type,
- "valuetype", value_type);
- printer->Annotate("gettername", field);
- printer->Print(
- " jspb.Message.getMapField(this, $index$, opt_noLazyCreate",
- "index", JSFieldIndex(field));
-
- if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) {
- printer->Print(
- ",\n"
- " $messageType$",
- "messageType", GetMessagePath(options, value_field->message_type()));
- } else {
- printer->Print(
- ",\n"
- " null");
- }
-
- printer->Print("));\n");
-
- printer->Print(
- "};\n"
- "\n"
- "\n");
- } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- // Message field: special handling in order to wrap the underlying data
- // array with a message object.
-
- printer->Print(
- "/**\n"
- " * $fielddef$\n"
- "$comment$"
- " * @return {$type$}\n"
- " */\n",
- "fielddef", FieldDefinition(options, field), "comment",
- FieldComments(field, BYTES_DEFAULT), "type",
- JSFieldTypeAnnotation(options, field,
- /* is_setter_argument = */ false,
- /* force_present = */ false,
- /* singular_if_not_packed = */ false));
- printer->Print(
- "$class$.prototype.$gettername$ = function() {\n"
- " return /** @type{$type$} */ (\n"
- " jspb.Message.get$rpt$WrapperField(this, $wrapperclass$, "
- "$index$$required$));\n"
- "};\n"
- "\n"
- "\n",
- "class", GetMessagePath(options, field->containing_type()),
- "gettername", "get" + JSGetterName(options, field), "type",
- JSFieldTypeAnnotation(options, field,
- /* is_setter_argument = */ false,
- /* force_present = */ false,
- /* singular_if_not_packed = */ false),
- "rpt", (field->is_repeated() ? "Repeated" : ""), "index",
- JSFieldIndex(field), "wrapperclass", SubmessageTypeRef(options, field),
- "required",
- (field->label() == FieldDescriptor::LABEL_REQUIRED ? ", 1" : ""));
- printer->Annotate("gettername", field);
- printer->Print(
- "/**\n"
- " * @param {$optionaltype$} value\n"
- " * @return {!$class$} returns this\n"
- "*/\n"
- "$class$.prototype.$settername$ = function(value) {\n"
- " return jspb.Message.set$oneoftag$$repeatedtag$WrapperField(",
- "optionaltype",
- JSFieldTypeAnnotation(options, field,
- /* is_setter_argument = */ true,
- /* force_present = */ false,
- /* singular_if_not_packed = */ false),
- "class", GetMessagePath(options, field->containing_type()),
- "settername", "set" + JSGetterName(options, field), "oneoftag",
- (InRealOneof(field) ? "Oneof" : ""), "repeatedtag",
- (field->is_repeated() ? "Repeated" : ""));
- printer->Annotate("settername", field);
-
- printer->Print(
- "this, $index$$oneofgroup$, value);\n"
- "};\n"
- "\n"
- "\n",
- "index", JSFieldIndex(field), "oneofgroup",
- (InRealOneof(field) ? (", " + JSOneofArray(options, field)) : ""));
-
- if (field->is_repeated()) {
- GenerateRepeatedMessageHelperMethods(options, printer, field);
- }
-
- } else {
- bool untyped = false;
-
- // Simple (primitive) field, either singular or repeated.
-
- // TODO(b/26173701): Always use BYTES_DEFAULT for the getter return type;
- // at this point we "lie" to non-binary users and tell the return
- // type is always base64 string, pending a LSC to migrate to typed getters.
- BytesMode bytes_mode =
- field->type() == FieldDescriptor::TYPE_BYTES && !options.binary
- ? BYTES_B64
- : BYTES_DEFAULT;
- TProtoStringType typed_annotation =
- JSFieldTypeAnnotation(options, field,
- /* is_setter_argument = */ false,
- /* force_present = */ false,
- /* singular_if_not_packed = */ false,
- /* bytes_mode = */ bytes_mode);
- if (untyped) {
- printer->Print(
- "/**\n"
- " * @return {?} Raw field, untyped.\n"
- " */\n");
- } else {
- printer->Print(
- "/**\n"
- " * $fielddef$\n"
- "$comment$"
- " * @return {$type$}\n"
- " */\n",
- "fielddef", FieldDefinition(options, field), "comment",
- FieldComments(field, bytes_mode), "type", typed_annotation);
- }
-
- printer->Print("$class$.prototype.$gettername$ = function() {\n", "class",
- GetMessagePath(options, field->containing_type()),
- "gettername", "get" + JSGetterName(options, field));
- printer->Annotate("gettername", field);
-
- if (untyped) {
- printer->Print(" return ");
- } else {
- printer->Print(" return /** @type {$type$} */ (", "type",
- typed_annotation);
- }
-
- bool use_default = !ReturnsNullWhenUnset(options, field);
-
- // Raw fields with no default set should just return undefined.
- if (untyped && !field->has_default_value()) {
- use_default = false;
- }
-
- // Repeated fields get initialized to their default in the constructor
- // (why?), so we emit a plain getField() call for them.
- if (field->is_repeated()) {
- use_default = false;
- }
-
- GenerateFieldValueExpression(printer, "this", field, use_default);
-
- if (untyped) {
- printer->Print(
- ";\n"
- "};\n"
- "\n"
- "\n");
- } else {
- printer->Print(
- ");\n"
- "};\n"
- "\n"
- "\n");
- }
-
- if (field->type() == FieldDescriptor::TYPE_BYTES && !untyped) {
- GenerateBytesWrapper(options, printer, field, BYTES_B64);
- GenerateBytesWrapper(options, printer, field, BYTES_U8);
- }
-
- printer->Print(
- "/**\n"
- " * @param {$optionaltype$} value\n"
- " * @return {!$class$} returns this\n"
- " */\n",
- "class", GetMessagePath(options, field->containing_type()),
- "optionaltype",
- untyped ? "*"
- : JSFieldTypeAnnotation(options, field,
- /* is_setter_argument = */ true,
- /* force_present = */ false,
- /* singular_if_not_packed = */ false));
-
- if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 &&
- !field->is_repeated() && !field->is_map() &&
- !HasFieldPresence(options, field)) {
- // Proto3 non-repeated and non-map fields without presence use the
- // setProto3*Field function.
- printer->Print(
- "$class$.prototype.$settername$ = function(value) {\n"
- " return jspb.Message.setProto3$typetag$Field(this, $index$, "
- "value);"
- "\n"
- "};\n"
- "\n"
- "\n",
- "class", GetMessagePath(options, field->containing_type()),
- "settername", "set" + JSGetterName(options, field), "typetag",
- JSTypeTag(field), "index", JSFieldIndex(field));
- printer->Annotate("settername", field);
- } else {
- // Otherwise, use the regular setField function.
- printer->Print(
- "$class$.prototype.$settername$ = function(value) {\n"
- " return jspb.Message.set$oneoftag$Field(this, $index$",
- "class", GetMessagePath(options, field->containing_type()),
- "settername", "set" + JSGetterName(options, field), "oneoftag",
- (InRealOneof(field) ? "Oneof" : ""), "index", JSFieldIndex(field));
- printer->Annotate("settername", field);
- printer->Print(
- "$oneofgroup$, $type$value$rptvalueinit$$typeclose$);\n"
- "};\n"
- "\n"
- "\n",
- "type",
- untyped ? "/** @type{string|number|boolean|Array|undefined} */(" : "",
- "typeclose", untyped ? ")" : "", "oneofgroup",
- (InRealOneof(field) ? (", " + JSOneofArray(options, field)) : ""),
- "rptvalueinit", (field->is_repeated() ? " || []" : ""));
- }
-
- if (untyped) {
- printer->Print(
- "/**\n"
- " * Clears the value.\n"
- " * @return {!$class$} returns this\n"
- " */\n",
- "class", GetMessagePath(options, field->containing_type()));
- }
-
- if (field->is_repeated()) {
- GenerateRepeatedPrimitiveHelperMethods(options, printer, field, untyped);
- }
- }
-
- // Generate clearFoo() method for map fields, repeated fields, and other
- // fields with presence.
- if (field->is_map()) {
- // clang-format off
- printer->Print(
- "/**\n"
- " * Clears values from the map. The map will be non-null.\n"
- " * @return {!$class$} returns this\n"
- " */\n"
- "$class$.prototype.$clearername$ = function() {\n"
- " this.$gettername$().clear();\n"
- " return this;"
- "};\n"
- "\n"
- "\n",
- "class", GetMessagePath(options, field->containing_type()),
- "clearername", "clear" + JSGetterName(options, field),
- "gettername", "get" + JSGetterName(options, field));
- // clang-format on
- printer->Annotate("clearername", field);
- } else if (field->is_repeated() ||
- (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
- !field->is_required())) {
- // Fields where we can delegate to the regular setter.
- // clang-format off
- printer->Print(
- "/**\n"
- " * $jsdoc$\n"
- " * @return {!$class$} returns this\n"
- " */\n"
- "$class$.prototype.$clearername$ = function() {\n"
- " return this.$settername$($clearedvalue$);\n"
- "};\n"
- "\n"
- "\n",
- "jsdoc", field->is_repeated()
- ? "Clears the list making it empty but non-null."
- : "Clears the message field making it undefined.",
- "class", GetMessagePath(options, field->containing_type()),
- "clearername", "clear" + JSGetterName(options, field),
- "settername", "set" + JSGetterName(options, field),
- "clearedvalue", (field->is_repeated() ? "[]" : "undefined"));
- // clang-format on
- printer->Annotate("clearername", field);
- } else if (HasFieldPresence(options, field)) {
- // Fields where we can't delegate to the regular setter because it doesn't
- // accept "undefined" as an argument.
- // clang-format off
- printer->Print(
- "/**\n"
- " * Clears the field making it undefined.\n"
- " * @return {!$class$} returns this\n"
- " */\n"
- "$class$.prototype.$clearername$ = function() {\n"
- " return jspb.Message.set$maybeoneof$Field(this, "
- "$index$$maybeoneofgroup$, ",
- "class", GetMessagePath(options, field->containing_type()),
- "clearername", "clear" + JSGetterName(options, field),
- "maybeoneof", (InRealOneof(field) ? "Oneof" : ""),
- "maybeoneofgroup", (InRealOneof(field)
- ? (", " + JSOneofArray(options, field))
- : ""),
- "index", JSFieldIndex(field));
- // clang-format on
- printer->Annotate("clearername", field);
- printer->Print(
- "$clearedvalue$);\n"
- "};\n"
- "\n"
- "\n",
- "clearedvalue", (field->is_repeated() ? "[]" : "undefined"));
- }
-
- if (HasFieldPresence(options, field)) {
- printer->Print(
- "/**\n"
- " * Returns whether this field is set.\n"
- " * @return {boolean}\n"
- " */\n"
- "$class$.prototype.$hasername$ = function() {\n"
- " return jspb.Message.getField(this, $index$) != null;\n"
- "};\n"
- "\n"
- "\n",
- "class", GetMessagePath(options, field->containing_type()), "hasername",
- "has" + JSGetterName(options, field), "index", JSFieldIndex(field));
- printer->Annotate("hasername", field);
- }
-}
-
-void Generator::GenerateRepeatedPrimitiveHelperMethods(
- const GeneratorOptions& options, io::Printer* printer,
- const FieldDescriptor* field, bool untyped) const {
- // clang-format off
- printer->Print(
- "/**\n"
- " * @param {$optionaltype$} value\n"
- " * @param {number=} opt_index\n"
- " * @return {!$class$} returns this\n"
- " */\n"
- "$class$.prototype.$addername$ = function(value, opt_index) {\n"
- " return jspb.Message.addToRepeatedField(this, "
- "$index$",
- "class", GetMessagePath(options, field->containing_type()), "addername",
- "add" + JSGetterName(options, field, BYTES_DEFAULT,
- /* drop_list = */ true),
- "optionaltype",
- JSFieldTypeAnnotation(
- options, field,
- /* is_setter_argument = */ false,
- /* force_present = */ true,
- /* singular_if_not_packed = */ false,
- BYTES_DEFAULT,
- /* force_singular = */ true),
- "index", JSFieldIndex(field));
- printer->Annotate("addername", field);
- printer->Print(
- "$oneofgroup$, $type$value$rptvalueinit$$typeclose$, "
- "opt_index);\n"
- "};\n"
- "\n"
- "\n",
- "type", untyped ? "/** @type{string|number|boolean|!Uint8Array} */(" : "",
- "typeclose", untyped ? ")" : "", "oneofgroup",
- (InRealOneof(field) ? (", " + JSOneofArray(options, field)) : ""),
- "rptvalueinit", "");
- // clang-format on
-}
-
-void Generator::GenerateRepeatedMessageHelperMethods(
- const GeneratorOptions& options, io::Printer* printer,
- const FieldDescriptor* field) const {
- printer->Print(
- "/**\n"
- " * @param {!$optionaltype$=} opt_value\n"
- " * @param {number=} opt_index\n"
- " * @return {!$optionaltype$}\n"
- " */\n"
- "$class$.prototype.$addername$ = function(opt_value, opt_index) {\n"
- " return jspb.Message.addTo$repeatedtag$WrapperField(",
- "optionaltype", JSTypeName(options, field, BYTES_DEFAULT), "class",
- GetMessagePath(options, field->containing_type()), "addername",
- "add" + JSGetterName(options, field, BYTES_DEFAULT,
- /* drop_list = */ true),
- "repeatedtag", (field->is_repeated() ? "Repeated" : ""));
-
- printer->Annotate("addername", field);
- printer->Print(
- "this, $index$$oneofgroup$, opt_value, $ctor$, opt_index);\n"
- "};\n"
- "\n"
- "\n",
- "index", JSFieldIndex(field), "oneofgroup",
- (InRealOneof(field) ? (", " + JSOneofArray(options, field)) : ""), "ctor",
- GetMessagePath(options, field->message_type()));
-}
-
-void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options,
- io::Printer* printer,
- const Descriptor* desc) const {
- if (IsExtendable(desc)) {
- printer->Print(
- "\n"
- "/**\n"
- " * The extensions registered with this message class. This is a "
- "map of\n"
- " * extension field number to fieldInfo object.\n"
- " *\n"
- " * For example:\n"
- " * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, "
- "ctor: proto.example.MyMessage} }\n"
- " *\n"
- " * fieldName contains the JsCompiler renamed field name property "
- "so that it\n"
- " * works in OPTIMIZED mode.\n"
- " *\n"
- " * @type {!Object<number, jspb.ExtensionFieldInfo>}\n"
- " */\n"
- "$class$.extensions = {};\n"
- "\n",
- "class", GetMessagePath(options, desc));
-
- printer->Print(
- "\n"
- "/**\n"
- " * The extensions registered with this message class. This is a "
- "map of\n"
- " * extension field number to fieldInfo object.\n"
- " *\n"
- " * For example:\n"
- " * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, "
- "ctor: proto.example.MyMessage} }\n"
- " *\n"
- " * fieldName contains the JsCompiler renamed field name property "
- "so that it\n"
- " * works in OPTIMIZED mode.\n"
- " *\n"
- " * @type {!Object<number, jspb.ExtensionFieldBinaryInfo>}\n"
- " */\n"
- "$class$.extensionsBinary = {};\n"
- "\n",
- "class", GetMessagePath(options, desc));
- }
-}
-
-void Generator::GenerateClassDeserializeBinary(const GeneratorOptions& options,
- io::Printer* printer,
- const Descriptor* desc) const {
- // TODO(cfallin): Handle lazy decoding when requested by field option and/or
- // by default for 'bytes' fields and packed repeated fields.
-
- printer->Print(
- "/**\n"
- " * Deserializes binary data (in protobuf wire format).\n"
- " * @param {jspb.ByteSource} bytes The bytes to deserialize.\n"
- " * @return {!$class$}\n"
- " */\n"
- "$class$.deserializeBinary = function(bytes) {\n"
- " var reader = new jspb.BinaryReader(bytes);\n"
- " var msg = new $class$;\n"
- " return $class$.deserializeBinaryFromReader(msg, reader);\n"
- "};\n"
- "\n"
- "\n"
- "/**\n"
- " * Deserializes binary data (in protobuf wire format) from the\n"
- " * given reader into the given message object.\n"
- " * @param {!$class$} msg The message object to deserialize into.\n"
- " * @param {!jspb.BinaryReader} reader The BinaryReader to use.\n"
- " * @return {!$class$}\n"
- " */\n"
- "$class$.deserializeBinaryFromReader = function(msg, reader) {\n"
- " while (reader.nextField()) {\n",
- "class", GetMessagePath(options, desc));
- printer->Print(
- " if (reader.isEndGroup()) {\n"
- " break;\n"
- " }\n"
- " var field = reader.getFieldNumber();\n"
- " switch (field) {\n");
-
- for (int i = 0; i < desc->field_count(); i++) {
- if (!IgnoreField(desc->field(i))) {
- GenerateClassDeserializeBinaryField(options, printer, desc->field(i));
- }
- }
-
- printer->Print(" default:\n");
- if (IsExtendable(desc)) {
- printer->Print(
- " jspb.Message.readBinaryExtension(msg, reader,\n"
- " $extobj$Binary,\n"
- " $class$.prototype.getExtension,\n"
- " $class$.prototype.setExtension);\n"
- " break;\n"
- " }\n",
- "extobj", JSExtensionsObjectName(options, desc->file(), desc), "class",
- GetMessagePath(options, desc));
- } else {
- printer->Print(
- " reader.skipField();\n"
- " break;\n"
- " }\n");
- }
-
- printer->Print(
- " }\n"
- " return msg;\n"
- "};\n"
- "\n"
- "\n");
-}
-
-void Generator::GenerateClassDeserializeBinaryField(
- const GeneratorOptions& options, io::Printer* printer,
- const FieldDescriptor* field) const {
- printer->Print(" case $num$:\n", "num", StrCat(field->number()));
-
- if (field->is_map()) {
- const FieldDescriptor* key_field = MapFieldKey(field);
- const FieldDescriptor* value_field = MapFieldValue(field);
- printer->Print(
- " var value = msg.get$name$();\n"
- " reader.readMessage(value, function(message, reader) {\n",
- "name", JSGetterName(options, field));
-
- printer->Print(
- " jspb.Map.deserializeBinary(message, reader, "
- "$keyReaderFn$, $valueReaderFn$",
- "keyReaderFn", JSBinaryReaderMethodName(options, key_field),
- "valueReaderFn", JSBinaryReaderMethodName(options, value_field));
-
- if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) {
- printer->Print(", $messageType$.deserializeBinaryFromReader",
- "messageType",
- GetMessagePath(options, value_field->message_type()));
- } else {
- printer->Print(", null");
- }
- printer->Print(", $defaultKey$", "defaultKey", JSFieldDefault(key_field));
- if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) {
- printer->Print(", new $messageType$()", "messageType",
- GetMessagePath(options, value_field->message_type()));
- } else {
- printer->Print(", $defaultValue$", "defaultValue",
- JSFieldDefault(value_field));
- }
- printer->Print(");\n");
- printer->Print(" });\n");
- } else {
- if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- printer->Print(
- " var value = new $fieldclass$;\n"
- " reader.read$msgOrGroup$($grpfield$value,"
- "$fieldclass$.deserializeBinaryFromReader);\n",
- "fieldclass", SubmessageTypeRef(options, field), "msgOrGroup",
- (field->type() == FieldDescriptor::TYPE_GROUP) ? "Group" : "Message",
- "grpfield",
- (field->type() == FieldDescriptor::TYPE_GROUP)
- ? (StrCat(field->number()) + ", ")
- : "");
- } else if (field->is_packable()) {
- printer->Print(
- " var values = /** @type {$fieldtype$} */ "
- "(reader.isDelimited() "
- "? reader.readPacked$reader$() : [reader.read$reader$()]);\n",
- "fieldtype",
- JSFieldTypeAnnotation(options, field, false, true,
- /* singular_if_not_packed */ false, BYTES_U8),
- "reader", JSBinaryReaderMethodType(field));
- } else {
- printer->Print(
- " var value = /** @type {$fieldtype$} */ "
- "(reader.read$reader$());\n",
- "fieldtype",
- JSFieldTypeAnnotation(options, field, false, true,
- /* singular_if_not_packed */ true, BYTES_U8),
- "reader",
- JSBinaryReadWriteMethodName(field, /* is_writer = */ false));
- }
-
- if (field->is_packable()) {
- printer->Print(
- " for (var i = 0; i < values.length; i++) {\n"
- " msg.add$name$(values[i]);\n"
- " }\n",
- "name",
- JSGetterName(options, field, BYTES_DEFAULT, /* drop_list = */ true));
- } else if (field->is_repeated()) {
- printer->Print(
- " msg.add$name$(value);\n", "name",
- JSGetterName(options, field, BYTES_DEFAULT, /* drop_list = */ true));
- } else {
- // Singular fields, and packed repeated fields, receive a |value| either
- // as the field's value or as the array of all the field's values; set
- // this as the field's value directly.
- printer->Print(" msg.set$name$(value);\n", "name",
- JSGetterName(options, field));
- }
- }
-
- printer->Print(" break;\n");
-}
-
-void Generator::GenerateClassSerializeBinary(const GeneratorOptions& options,
- io::Printer* printer,
- const Descriptor* desc) const {
- printer->Print(
- "/**\n"
- " * Serializes the message to binary data (in protobuf wire format).\n"
- " * @return {!Uint8Array}\n"
- " */\n"
- "$class$.prototype.serializeBinary = function() {\n"
- " var writer = new jspb.BinaryWriter();\n"
- " $class$.serializeBinaryToWriter(this, writer);\n"
- " return writer.getResultBuffer();\n"
- "};\n"
- "\n"
- "\n"
- "/**\n"
- " * Serializes the given message to binary data (in protobuf wire\n"
- " * format), writing to the given BinaryWriter.\n"
- " * @param {!$class$} message\n"
- " * @param {!jspb.BinaryWriter} writer\n"
- " * @suppress {unusedLocalVariables} f is only used for nested messages\n"
- " */\n"
- "$class$.serializeBinaryToWriter = function(message, "
- "writer) {\n"
- " var f = undefined;\n",
- "class", GetMessagePath(options, desc));
-
- for (int i = 0; i < desc->field_count(); i++) {
- if (!IgnoreField(desc->field(i))) {
- GenerateClassSerializeBinaryField(options, printer, desc->field(i));
- }
- }
-
- if (IsExtendable(desc)) {
- printer->Print(
- " jspb.Message.serializeBinaryExtensions(message, writer,\n"
- " $extobj$Binary, $class$.prototype.getExtension);\n",
- "extobj", JSExtensionsObjectName(options, desc->file(), desc), "class",
- GetMessagePath(options, desc));
- }
-
- printer->Print(
- "};\n"
- "\n"
- "\n");
-}
-
-void Generator::GenerateClassSerializeBinaryField(
- const GeneratorOptions& options, io::Printer* printer,
- const FieldDescriptor* field) const {
- if (HasFieldPresence(options, field) &&
- field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) {
- TProtoStringType typed_annotation =
- JSFieldTypeAnnotation(options, field,
- /* is_setter_argument = */ false,
- /* force_present = */ false,
- /* singular_if_not_packed = */ false,
- /* bytes_mode = */ BYTES_DEFAULT);
- printer->Print(
- " f = /** @type {$type$} */ "
- "(jspb.Message.getField(message, $index$));\n",
- "index", JSFieldIndex(field), "type", typed_annotation);
- } else {
- printer->Print(
- " f = message.get$name$($nolazy$);\n", "name",
- JSGetterName(options, field, BYTES_U8),
- // No lazy creation for maps containers -- fastpath the empty case.
- "nolazy", field->is_map() ? "true" : "");
- }
-
- // Print an `if (condition)` statement that evaluates to true if the field
- // goes on the wire.
- if (field->is_map()) {
- printer->Print(" if (f && f.getLength() > 0) {\n");
- } else if (field->is_repeated()) {
- printer->Print(" if (f.length > 0) {\n");
- } else {
- if (HasFieldPresence(options, field)) {
- printer->Print(" if (f != null) {\n");
- } else {
- // No field presence: serialize onto the wire only if value is
- // non-default. Defaults are documented here:
- // https://goto.google.com/lhdfm
- switch (field->cpp_type()) {
- case FieldDescriptor::CPPTYPE_INT32:
- case FieldDescriptor::CPPTYPE_INT64:
- case FieldDescriptor::CPPTYPE_UINT32:
- case FieldDescriptor::CPPTYPE_UINT64: {
- if (IsIntegralFieldWithStringJSType(field)) {
- // We can use `parseInt` here even though it will not be precise for
- // 64-bit quantities because we are only testing for zero/nonzero,
- // and JS numbers (64-bit floating point values, i.e., doubles) are
- // integer-precise in the range that includes zero.
- printer->Print(" if (parseInt(f, 10) !== 0) {\n");
- } else {
- printer->Print(" if (f !== 0) {\n");
- }
- break;
- }
-
- case FieldDescriptor::CPPTYPE_ENUM:
- case FieldDescriptor::CPPTYPE_FLOAT:
- case FieldDescriptor::CPPTYPE_DOUBLE:
- printer->Print(" if (f !== 0.0) {\n");
- break;
- case FieldDescriptor::CPPTYPE_BOOL:
- printer->Print(" if (f) {\n");
- break;
- case FieldDescriptor::CPPTYPE_STRING:
- printer->Print(" if (f.length > 0) {\n");
- break;
- default:
- assert(false);
- break;
- }
- }
- }
-
- // Write the field on the wire.
- if (field->is_map()) {
- const FieldDescriptor* key_field = MapFieldKey(field);
- const FieldDescriptor* value_field = MapFieldValue(field);
- printer->Print(
- " f.serializeBinary($index$, writer, "
- "$keyWriterFn$, $valueWriterFn$",
- "index", StrCat(field->number()), "keyWriterFn",
- JSBinaryWriterMethodName(options, key_field), "valueWriterFn",
- JSBinaryWriterMethodName(options, value_field));
-
- if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) {
- printer->Print(", $messageType$.serializeBinaryToWriter", "messageType",
- GetMessagePath(options, value_field->message_type()));
- }
-
- printer->Print(");\n");
- } else {
- printer->Print(
- " writer.write$method$(\n"
- " $index$,\n"
- " f",
- "method", JSBinaryReadWriteMethodName(field, /* is_writer = */ true),
- "index", StrCat(field->number()));
-
- if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
- !field->is_map()) {
- printer->Print(
- ",\n"
- " $submsg$.serializeBinaryToWriter\n",
- "submsg", SubmessageTypeRef(options, field));
- } else {
- printer->Print("\n");
- }
-
- printer->Print(" );\n");
- }
-
- // Close the `if`.
- printer->Print(" }\n");
-}
-
-void Generator::GenerateEnum(const GeneratorOptions& options,
- io::Printer* printer,
- const EnumDescriptor* enumdesc) const {
- printer->Print(
- "/**\n"
- " * @enum {number}\n"
- " */\n"
- "$enumprefix$$name$ = {\n",
- "enumprefix", GetEnumPathPrefix(options, enumdesc), "name",
- enumdesc->name());
- printer->Annotate("name", enumdesc);
-
- std::set<TProtoStringType> used_name;
- std::vector<int> valid_index;
- for (int i = 0; i < enumdesc->value_count(); i++) {
- if (enumdesc->options().allow_alias() &&
- !used_name.insert(ToEnumCase(enumdesc->value(i)->name())).second) {
- continue;
- }
- valid_index.push_back(i);
- }
- for (auto i : valid_index) {
- const EnumValueDescriptor* value = enumdesc->value(i);
- printer->Print(" $name$: $value$$comma$\n", "name",
- ToEnumCase(value->name()), "value", StrCat(value->number()),
- "comma", (i == valid_index.back()) ? "" : ",");
- printer->Annotate("name", value);
- }
-
- printer->Print(
- "};\n"
- "\n");
-}
-
-void Generator::GenerateExtension(const GeneratorOptions& options,
- io::Printer* printer,
- const FieldDescriptor* field) const {
- TProtoStringType extension_scope =
- (field->extension_scope()
- ? GetMessagePath(options, field->extension_scope())
- : GetNamespace(options, field->file()));
-
- const TProtoStringType extension_object_name = JSObjectFieldName(options, field);
- printer->Print(
- "\n"
- "/**\n"
- " * A tuple of {field number, class constructor} for the extension\n"
- " * field named `$nameInComment$`.\n"
- " * @type {!jspb.ExtensionFieldInfo<$extensionType$>}\n"
- " */\n"
- "$class$.$name$ = new jspb.ExtensionFieldInfo(\n",
- "nameInComment", extension_object_name, "name", extension_object_name,
- "class", extension_scope, "extensionType",
- JSFieldTypeAnnotation(options, field,
- /* is_setter_argument = */ false,
- /* force_present = */ true,
- /* singular_if_not_packed = */ false));
- printer->Annotate("name", field);
- printer->Print(
- " $index$,\n"
- " {$name$: 0},\n"
- " $ctor$,\n"
- " /** @type {?function((boolean|undefined),!jspb.Message=): "
- "!Object} */ (\n"
- " $toObject$),\n"
- " $repeated$);\n",
- "index", StrCat(field->number()), "name", extension_object_name, "ctor",
- (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE
- ? SubmessageTypeRef(options, field)
- : TProtoStringType("null")),
- "toObject",
- (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE
- ? (SubmessageTypeRef(options, field) + ".toObject")
- : TProtoStringType("null")),
- "repeated", (field->is_repeated() ? "1" : "0"));
-
- printer->Print(
- "\n"
- "$extendName$Binary[$index$] = new jspb.ExtensionFieldBinaryInfo(\n"
- " $class$.$name$,\n"
- " $binaryReaderFn$,\n"
- " $binaryWriterFn$,\n"
- " $binaryMessageSerializeFn$,\n"
- " $binaryMessageDeserializeFn$,\n",
- "extendName",
- JSExtensionsObjectName(options, field->file(), field->containing_type()),
- "index", StrCat(field->number()), "class", extension_scope, "name",
- extension_object_name, "binaryReaderFn",
- JSBinaryReaderMethodName(options, field), "binaryWriterFn",
- JSBinaryWriterMethodName(options, field), "binaryMessageSerializeFn",
- (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE)
- ? (SubmessageTypeRef(options, field) + ".serializeBinaryToWriter")
- : "undefined",
- "binaryMessageDeserializeFn",
- (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE)
- ? (SubmessageTypeRef(options, field) + ".deserializeBinaryFromReader")
- : "undefined");
-
- printer->Print(" $isPacked$);\n", "isPacked",
- (field->is_packed() ? "true" : "false"));
-
- printer->Print(
- "// This registers the extension field with the extended class, so that\n"
- "// toObject() will function correctly.\n"
- "$extendName$[$index$] = $class$.$name$;\n"
- "\n",
- "extendName",
- JSExtensionsObjectName(options, field->file(), field->containing_type()),
- "index", StrCat(field->number()), "class", extension_scope, "name",
- extension_object_name);
-}
-
-bool GeneratorOptions::ParseFromOptions(
- const std::vector<std::pair<TProtoStringType, TProtoStringType> >& options,
- TProtoStringType* error) {
- for (int i = 0; i < options.size(); i++) {
- if (options[i].first == "add_require_for_enums") {
- if (options[i].second != "") {
- *error = "Unexpected option value for add_require_for_enums";
- return false;
- }
- add_require_for_enums = true;
- } else if (options[i].first == "binary") {
- if (options[i].second != "") {
- *error = "Unexpected option value for binary";
- return false;
- }
- binary = true;
- } else if (options[i].first == "testonly") {
- if (options[i].second != "") {
- *error = "Unexpected option value for testonly";
- return false;
- }
- testonly = true;
-
- } else if (options[i].first == "error_on_name_conflict") {
- GOOGLE_LOG(WARNING) << "Ignoring error_on_name_conflict option, this "
- "will be removed in a future release";
- } else if (options[i].first == "output_dir") {
- output_dir = options[i].second;
- } else if (options[i].first == "namespace_prefix") {
- namespace_prefix = options[i].second;
- } else if (options[i].first == "library") {
- library = options[i].second;
- } else if (options[i].first == "import_style") {
- if (options[i].second == "closure") {
- import_style = kImportClosure;
- } else if (options[i].second == "commonjs") {
- import_style = kImportCommonJs;
- } else if (options[i].second == "commonjs_strict") {
- import_style = kImportCommonJsStrict;
- } else if (options[i].second == "browser") {
- import_style = kImportBrowser;
- } else if (options[i].second == "es6") {
- import_style = kImportEs6;
- } else {
- *error = "Unknown import style " + options[i].second + ", expected " +
- "one of: closure, commonjs, browser, es6.";
- }
- } else if (options[i].first == "extension") {
- extension = options[i].second;
- } else if (options[i].first == "one_output_file_per_input_file") {
- if (!options[i].second.empty()) {
- *error = "Unexpected option value for one_output_file_per_input_file";
- return false;
- }
- one_output_file_per_input_file = true;
- } else if (options[i].first == "annotate_code") {
- if (!options[i].second.empty()) {
- *error = "Unexpected option value for annotate_code";
- return false;
- }
- annotate_code = true;
- } else {
- // Assume any other option is an output directory, as long as it is a bare
- // `key` rather than a `key=value` option.
- if (options[i].second != "") {
- *error = "Unknown option: " + options[i].first;
- return false;
- }
- output_dir = options[i].first;
- }
- }
-
- if (import_style != kImportClosure &&
- (add_require_for_enums || testonly || !library.empty() ||
- extension != ".js" || one_output_file_per_input_file)) {
- *error =
- "The add_require_for_enums, testonly, library, extension, and "
- "one_output_file_per_input_file options should only be "
- "used for import_style=closure";
- return false;
- }
-
- return true;
-}
-
-GeneratorOptions::OutputMode GeneratorOptions::output_mode() const {
- // We use one output file per input file if we are not using Closure or if
- // this is explicitly requested.
- if (import_style != kImportClosure || one_output_file_per_input_file) {
- return kOneOutputFilePerInputFile;
- }
-
- // If a library name is provided, we put everything in that one file.
- if (!library.empty()) {
- return kEverythingInOneFile;
- }
-
- // Otherwise, we create one output file per SCC.
- return kOneOutputFilePerSCC;
-}
-
-void Generator::GenerateFilesInDepOrder(
- const GeneratorOptions& options, io::Printer* printer,
- const std::vector<const FileDescriptor*>& files) const {
- // Build a std::set over all files so that the DFS can detect when it recurses
- // into a dep not specified in the user's command line.
- std::set<const FileDescriptor*> all_files(files.begin(), files.end());
- // Track the in-progress set of files that have been generated already.
- std::set<const FileDescriptor*> generated;
- for (int i = 0; i < files.size(); i++) {
- GenerateFileAndDeps(options, printer, files[i], &all_files, &generated);
- }
-}
-
-void Generator::GenerateFileAndDeps(
- const GeneratorOptions& options, io::Printer* printer,
- const FileDescriptor* root, std::set<const FileDescriptor*>* all_files,
- std::set<const FileDescriptor*>* generated) const {
- // Skip if already generated.
- if (generated->find(root) != generated->end()) {
- return;
- }
- generated->insert(root);
-
- // Generate all dependencies before this file's content.
- for (int i = 0; i < root->dependency_count(); i++) {
- const FileDescriptor* dep = root->dependency(i);
- GenerateFileAndDeps(options, printer, dep, all_files, generated);
- }
-
- // Generate this file's content. Only generate if the file is part of the
- // original set requested to be generated; i.e., don't take all transitive
- // deps down to the roots.
- if (all_files->find(root) != all_files->end()) {
- GenerateClassesAndEnums(options, printer, root);
- }
-}
-
-bool Generator::GenerateFile(const FileDescriptor* file,
- const GeneratorOptions& options,
- GeneratorContext* context,
- bool use_short_name) const {
- TProtoStringType filename =
- options.output_dir + "/" +
- GetJSFilename(options, use_short_name
- ? file->name().substr(file->name().rfind('/'))
- : file->name());
- std::unique_ptr<io::ZeroCopyOutputStream> output(context->Open(filename));
- GOOGLE_CHECK(output);
- GeneratedCodeInfo annotations;
- io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
- &annotations);
- io::Printer printer(output.get(), '$',
- options.annotate_code ? &annotation_collector : nullptr);
-
- GenerateFile(options, &printer, file);
-
- if (printer.failed()) {
- return false;
- }
-
- if (options.annotate_code) {
- EmbedCodeAnnotations(annotations, &printer);
- }
-
- return true;
-}
-
-void Generator::GenerateFile(const GeneratorOptions& options,
- io::Printer* printer,
- const FileDescriptor* file) const {
- GenerateHeader(options, file, printer);
-
- // Generate "require" statements.
- if ((options.import_style == GeneratorOptions::kImportCommonJs ||
- options.import_style == GeneratorOptions::kImportCommonJsStrict)) {
- printer->Print("var jspb = require('google-protobuf');\n");
- printer->Print("var goog = jspb;\n");
-
- // Do not use global scope in strict mode
- if (options.import_style == GeneratorOptions::kImportCommonJsStrict) {
- printer->Print("var proto = {};\n\n");
- } else {
- // To get the global object we call a function with .call(null), this will
- // set "this" inside the function to the global object. This does not work
- // if we are running in strict mode ("use strict"), so we fallback to the
- // following things (in order from first to last):
- // - window: defined in browsers
- // - global: defined in most server side environments like NodeJS
- // - self: defined inside Web Workers (WorkerGlobalScope)
- // - Function('return this')(): this will work on most platforms, but it
- // may be blocked by things like CSP.
- // Function('') is almost the same as eval('')
- printer->Print(
- "var global = (function() { return this || window || global || self "
- "|| Function('return this')(); }).call(null);\n\n");
- }
-
- for (int i = 0; i < file->dependency_count(); i++) {
- const TProtoStringType& name = file->dependency(i)->name();
- printer->Print(
- "var $alias$ = require('$file$');\n"
- "goog.object.extend(proto, $alias$);\n",
- "alias", ModuleAlias(name), "file",
- GetRootPath(file->name(), name) + GetJSFilename(options, name));
- }
- }
-
- std::set<TProtoStringType> provided;
- std::set<const FieldDescriptor*> extensions;
- for (int i = 0; i < file->extension_count(); i++) {
- // We honor the jspb::ignore option here only when working with
- // Closure-style imports. Use of this option is discouraged and so we want
- // to avoid adding new support for it.
- if (options.import_style == GeneratorOptions::kImportClosure &&
- IgnoreField(file->extension(i))) {
- continue;
- }
- provided.insert(GetNamespace(options, file) + "." +
- JSObjectFieldName(options, file->extension(i)));
- extensions.insert(file->extension(i));
- }
-
- FindProvidesForFile(options, printer, file, &provided);
- GenerateProvides(options, printer, &provided);
- std::vector<const FileDescriptor*> files;
- files.push_back(file);
- if (options.import_style == GeneratorOptions::kImportClosure) {
- GenerateRequiresForLibrary(options, printer, files, &provided);
- }
-
- GenerateClassesAndEnums(options, printer, file);
-
- // Generate code for top-level extensions. Extensions nested inside messages
- // are emitted inside GenerateClassesAndEnums().
- for (std::set<const FieldDescriptor*>::const_iterator it = extensions.begin();
- it != extensions.end(); ++it) {
- GenerateExtension(options, printer, *it);
- }
-
- // if provided is empty, do not export anything
- if (options.import_style == GeneratorOptions::kImportCommonJs &&
- !provided.empty()) {
- printer->Print("goog.object.extend(exports, $package$);\n", "package",
- GetNamespace(options, file));
- } else if (options.import_style == GeneratorOptions::kImportCommonJsStrict) {
- printer->Print("goog.object.extend(exports, proto);\n", "package",
- GetNamespace(options, file));
- }
-
- // Emit well-known type methods.
- for (FileToc* toc = well_known_types_js; toc->name != NULL; toc++) {
- TProtoStringType name = TProtoStringType("google/protobuf/") + toc->name;
- if (name == StripProto(file->name()) + ".js") {
- printer->Print(toc->data);
- }
- }
-}
-
-bool Generator::GenerateAll(const std::vector<const FileDescriptor*>& files,
- const TProtoStringType& parameter,
- GeneratorContext* context,
- TProtoStringType* error) const {
- std::vector<std::pair<TProtoStringType, TProtoStringType> > option_pairs;
- ParseGeneratorParameter(parameter, &option_pairs);
- GeneratorOptions options;
- if (!options.ParseFromOptions(option_pairs, error)) {
- return false;
- }
-
- if (options.output_mode() == GeneratorOptions::kEverythingInOneFile) {
- // All output should go in a single file.
- TProtoStringType filename = options.output_dir + "/" + options.library +
- options.GetFileNameExtension();
- std::unique_ptr<io::ZeroCopyOutputStream> output(context->Open(filename));
- GOOGLE_CHECK(output.get());
- GeneratedCodeInfo annotations;
- io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
- &annotations);
- io::Printer printer(
- output.get(), '$',
- options.annotate_code ? &annotation_collector : nullptr);
-
- // Pull out all extensions -- we need these to generate all
- // provides/requires.
- std::vector<const FieldDescriptor*> extensions;
- for (int i = 0; i < files.size(); i++) {
- for (int j = 0; j < files[i]->extension_count(); j++) {
- const FieldDescriptor* extension = files[i]->extension(j);
- extensions.push_back(extension);
- }
- }
-
- if (files.size() == 1) {
- GenerateHeader(options, files[0], &printer);
- } else {
- GenerateHeader(options, nullptr, &printer);
- }
-
- std::set<TProtoStringType> provided;
- FindProvides(options, &printer, files, &provided);
- FindProvidesForFields(options, &printer, extensions, &provided);
- GenerateProvides(options, &printer, &provided);
- GenerateTestOnly(options, &printer);
- GenerateRequiresForLibrary(options, &printer, files, &provided);
-
- GenerateFilesInDepOrder(options, &printer, files);
-
- for (int i = 0; i < extensions.size(); i++) {
- if (ShouldGenerateExtension(extensions[i])) {
- GenerateExtension(options, &printer, extensions[i]);
- }
- }
-
- if (printer.failed()) {
- return false;
- }
- if (options.annotate_code) {
- EmbedCodeAnnotations(annotations, &printer);
- }
- } else if (options.output_mode() == GeneratorOptions::kOneOutputFilePerSCC) {
- std::set<const Descriptor*> have_printed;
- SCCAnalyzer<DepsGenerator> analyzer;
- std::map<const void*, TProtoStringType> allowed_map;
- if (!GenerateJspbAllowedMap(options, files, &allowed_map, &analyzer)) {
- return false;
- }
-
- bool generated = false;
- for (int i = 0; i < files.size(); i++) {
- const FileDescriptor* file = files[i];
- // Force well known type to generate in a whole file.
- if (IsWellKnownTypeFile(file)) {
- if (!GenerateFile(file, options, context, true)) {
- return false;
- }
- generated = true;
- continue;
- }
- for (int j = 0; j < file->message_type_count(); j++) {
- const Descriptor* desc = file->message_type(j);
- if (have_printed.count(desc) ||
- allowed_map.count(analyzer.GetSCC(desc)) == 0) {
- continue;
- }
-
- generated = true;
- const SCC* scc = analyzer.GetSCC(desc);
- const TProtoStringType& filename = allowed_map[scc];
- std::unique_ptr<io::ZeroCopyOutputStream> output(
- context->Open(filename));
- GOOGLE_CHECK(output.get());
- GeneratedCodeInfo annotations;
- io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
- &annotations);
- io::Printer printer(
- output.get(), '$',
- options.annotate_code ? &annotation_collector : nullptr);
-
- GenerateHeader(options, file, &printer);
-
- std::set<TProtoStringType> provided;
- for (auto one_desc : scc->descriptors) {
- if (one_desc->containing_type() == nullptr) {
- FindProvidesForMessage(options, &printer, one_desc, &provided);
- }
- }
- GenerateProvides(options, &printer, &provided);
- GenerateTestOnly(options, &printer);
- GenerateRequiresForSCC(options, &printer, scc, &provided);
-
- for (auto one_desc : scc->descriptors) {
- if (one_desc->containing_type() == nullptr) {
- GenerateClassConstructorAndDeclareExtensionFieldInfo(
- options, &printer, one_desc);
- }
- }
- for (auto one_desc : scc->descriptors) {
- if (one_desc->containing_type() == nullptr) {
- GenerateClass(options, &printer, one_desc);
- }
- }
-
- for (auto one_desc : scc->descriptors) {
- have_printed.insert(one_desc);
- }
-
- if (printer.failed()) {
- return false;
- }
- if (options.annotate_code) {
- EmbedCodeAnnotations(annotations, &printer);
- }
- }
- for (int j = 0; j < file->enum_type_count(); j++) {
- const EnumDescriptor* enumdesc = file->enum_type(j);
- if (allowed_map.count(enumdesc) == 0) {
- continue;
- }
-
- generated = true;
- const TProtoStringType& filename = allowed_map[enumdesc];
- std::unique_ptr<io::ZeroCopyOutputStream> output(
- context->Open(filename));
- GOOGLE_CHECK(output.get());
- GeneratedCodeInfo annotations;
- io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
- &annotations);
- io::Printer printer(
- output.get(), '$',
- options.annotate_code ? &annotation_collector : nullptr);
-
- GenerateHeader(options, file, &printer);
-
- std::set<TProtoStringType> provided;
- FindProvidesForEnum(options, &printer, enumdesc, &provided);
- GenerateProvides(options, &printer, &provided);
- GenerateTestOnly(options, &printer);
-
- GenerateEnum(options, &printer, enumdesc);
-
- if (printer.failed()) {
- return false;
- }
- if (options.annotate_code) {
- EmbedCodeAnnotations(annotations, &printer);
- }
- }
- // File-level extensions (message-level extensions are generated under
- // the enclosing message).
- if (allowed_map.count(file) == 1) {
- generated = true;
- const TProtoStringType& filename = allowed_map[file];
-
- std::unique_ptr<io::ZeroCopyOutputStream> output(
- context->Open(filename));
- GOOGLE_CHECK(output.get());
- GeneratedCodeInfo annotations;
- io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
- &annotations);
- io::Printer printer(
- output.get(), '$',
- options.annotate_code ? &annotation_collector : nullptr);
-
- GenerateHeader(options, file, &printer);
-
- std::set<TProtoStringType> provided;
- std::vector<const FieldDescriptor*> fields;
-
- for (int j = 0; j < files[i]->extension_count(); j++) {
- if (ShouldGenerateExtension(files[i]->extension(j))) {
- fields.push_back(files[i]->extension(j));
- }
- }
-
- FindProvidesForFields(options, &printer, fields, &provided);
- GenerateProvides(options, &printer, &provided);
- GenerateTestOnly(options, &printer);
- GenerateRequiresForExtensions(options, &printer, fields, &provided);
-
- for (int j = 0; j < files[i]->extension_count(); j++) {
- if (ShouldGenerateExtension(files[i]->extension(j))) {
- GenerateExtension(options, &printer, files[i]->extension(j));
- }
- }
- if (options.annotate_code) {
- EmbedCodeAnnotations(annotations, &printer);
- }
- }
- }
- if (!generated) {
- TProtoStringType filename = options.output_dir + "/" +
- "empty_no_content_void_file" +
- options.GetFileNameExtension();
- std::unique_ptr<io::ZeroCopyOutputStream> output(context->Open(filename));
- }
- } else /* options.output_mode() == kOneOutputFilePerInputFile */ {
- // Generate one output file per input (.proto) file.
-
- for (int i = 0; i < files.size(); i++) {
- const FileDescriptor* file = files[i];
- if (!GenerateFile(file, options, context, false)) {
- return false;
- }
- }
- }
- return true;
-}
-
-} // namespace js
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/js/js_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/js/js_generator.h
deleted file mode 100644
index 6486382e63..0000000000
--- a/contrib/libs/protoc/src/google/protobuf/compiler/js/js_generator.h
+++ /dev/null
@@ -1,336 +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.
-
-// Generates JavaScript code for a given .proto file.
-//
-#ifndef GOOGLE_PROTOBUF_COMPILER_JS_GENERATOR_H__
-#define GOOGLE_PROTOBUF_COMPILER_JS_GENERATOR_H__
-
-#include <set>
-#include <string>
-
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/compiler/scc.h>
-#include <google/protobuf/compiler/code_generator.h>
-
-#include <google/protobuf/port_def.inc>
-
-namespace google {
-namespace protobuf {
-
-class Descriptor;
-class EnumDescriptor;
-class FieldDescriptor;
-class OneofDescriptor;
-class FileDescriptor;
-
-namespace io {
-class Printer;
-}
-
-namespace compiler {
-namespace js {
-
-struct GeneratorOptions {
- // Output path.
- TProtoStringType output_dir;
- // Namespace prefix.
- TProtoStringType namespace_prefix;
- // Enable binary-format support?
- bool binary;
- // What style of imports should be used.
- enum ImportStyle {
- kImportClosure, // goog.require()
- kImportCommonJs, // require()
- kImportCommonJsStrict, // require() with no global export
- kImportBrowser, // no import statements
- kImportEs6, // import { member } from ''
- } import_style;
-
- GeneratorOptions()
- : output_dir("."),
- namespace_prefix(""),
- binary(false),
- import_style(kImportClosure),
- add_require_for_enums(false),
- testonly(false),
- library(""),
- extension(".js"),
- one_output_file_per_input_file(false),
- annotate_code(false) {}
-
- bool ParseFromOptions(
- const std::vector<std::pair<TProtoStringType, TProtoStringType> >& options,
- TProtoStringType* error);
-
- // Returns the file name extension to use for generated code.
- TProtoStringType GetFileNameExtension() const {
- return import_style == kImportClosure ? extension : "_pb.js";
- }
-
- enum OutputMode {
- // Create an output file for each input .proto file.
- kOneOutputFilePerInputFile,
- // Create an output file for each type.
- kOneOutputFilePerSCC,
- // Put everything in a single file named by the library option.
- kEverythingInOneFile,
- };
-
- // Indicates how to output the generated code based on the provided options.
- OutputMode output_mode() const;
-
- // The remaining options are only relevant when we are using kImportClosure.
-
- // Add a `goog.requires()` call for each enum type used. If not set, a
- // forward declaration with `goog.forwardDeclare` is produced instead.
- bool add_require_for_enums;
- // Set this as a test-only module via `goog.setTestOnly();`.
- bool testonly;
- // Create a library with name <name>_lib.js rather than a separate .js file
- // per type?
- TProtoStringType library;
- // The extension to use for output file names.
- TProtoStringType extension;
- // Create a separate output file for each input file?
- bool one_output_file_per_input_file;
- // If true, we should append annotations as comments on the last line for
- // generated .js file. Annotations used by tools like https://kythe.io
- // to provide cross-references between .js and .proto files. Annotations
- // are encoded as base64 proto of GeneratedCodeInfo message (see
- // descriptor.proto).
- bool annotate_code;
-};
-
-// CodeGenerator implementation which generates a JavaScript source file and
-// header. If you create your own protocol compiler binary and you want it to
-// support JavaScript output, you can do so by registering an instance of this
-// CodeGenerator with the CommandLineInterface in your main() function.
-class PROTOC_EXPORT Generator : public CodeGenerator {
- public:
- Generator() {}
- virtual ~Generator() {}
-
- bool Generate(const FileDescriptor* file, const TProtoStringType& parameter,
- GeneratorContext* context, TProtoStringType* error) const override {
- *error = "Unimplemented Generate() method. Call GenerateAll() instead.";
- return false;
- }
-
- bool HasGenerateAll() const override { return true; }
-
- bool GenerateAll(const std::vector<const FileDescriptor*>& files,
- const TProtoStringType& parameter, GeneratorContext* context,
- TProtoStringType* error) const override;
-
- uint64_t GetSupportedFeatures() const override {
- return FEATURE_PROTO3_OPTIONAL;
- }
-
- private:
- void GenerateHeader(const GeneratorOptions& options,
- const FileDescriptor* file, io::Printer* printer) const;
-
- // Generate goog.provides() calls.
- void FindProvides(const GeneratorOptions& options, io::Printer* printer,
- const std::vector<const FileDescriptor*>& file,
- std::set<TProtoStringType>* provided) const;
- void FindProvidesForFile(const GeneratorOptions& options,
- io::Printer* printer, const FileDescriptor* file,
- std::set<TProtoStringType>* provided) const;
- void FindProvidesForMessage(const GeneratorOptions& options,
- io::Printer* printer, const Descriptor* desc,
- std::set<TProtoStringType>* provided) const;
- void FindProvidesForEnum(const GeneratorOptions& options,
- io::Printer* printer, const EnumDescriptor* enumdesc,
- std::set<TProtoStringType>* provided) const;
- // For extension fields at file scope.
- void FindProvidesForFields(const GeneratorOptions& options,
- io::Printer* printer,
- const std::vector<const FieldDescriptor*>& fields,
- std::set<TProtoStringType>* provided) const;
- // Print the goog.provides() found by the methods above.
- void GenerateProvides(const GeneratorOptions& options, io::Printer* printer,
- std::set<TProtoStringType>* provided) const;
-
- // Generate goog.setTestOnly() if indicated.
- void GenerateTestOnly(const GeneratorOptions& options,
- io::Printer* printer) const;
-
- // Generate goog.requires() calls.
- void GenerateRequiresForLibrary(
- const GeneratorOptions& options, io::Printer* printer,
- const std::vector<const FileDescriptor*>& files,
- std::set<TProtoStringType>* provided) const;
- void GenerateRequiresForSCC(const GeneratorOptions& options,
- io::Printer* printer, const SCC* scc,
- std::set<TProtoStringType>* provided) const;
- // For extension fields at file scope.
- void GenerateRequiresForExtensions(
- const GeneratorOptions& options, io::Printer* printer,
- const std::vector<const FieldDescriptor*>& fields,
- std::set<TProtoStringType>* provided) const;
- void GenerateRequiresImpl(const GeneratorOptions& options,
- io::Printer* printer,
- std::set<TProtoStringType>* required,
- std::set<TProtoStringType>* forwards,
- std::set<TProtoStringType>* provided, bool require_jspb,
- bool require_extension, bool require_map) const;
- void FindRequiresForMessage(const GeneratorOptions& options,
- const Descriptor* desc,
- std::set<TProtoStringType>* required,
- std::set<TProtoStringType>* forwards,
- bool* have_message) const;
- void FindRequiresForField(const GeneratorOptions& options,
- const FieldDescriptor* field,
- std::set<TProtoStringType>* required,
- std::set<TProtoStringType>* forwards) const;
- void FindRequiresForExtension(const GeneratorOptions& options,
- const FieldDescriptor* field,
- std::set<TProtoStringType>* required,
- std::set<TProtoStringType>* forwards) const;
- // Generate all things in a proto file into one file.
- // If use_short_name is true, the generated file's name will only be short
- // name that without directory, otherwise filename equals file->name()
- bool GenerateFile(const FileDescriptor* file, const GeneratorOptions& options,
- GeneratorContext* context, bool use_short_name) const;
- void GenerateFile(const GeneratorOptions& options, io::Printer* printer,
- const FileDescriptor* file) const;
-
- // Generate definitions for all message classes and enums in all files,
- // processing the files in dependence order.
- void GenerateFilesInDepOrder(
- const GeneratorOptions& options, io::Printer* printer,
- const std::vector<const FileDescriptor*>& file) const;
- // Helper for above.
- void GenerateFileAndDeps(const GeneratorOptions& options,
- io::Printer* printer, const FileDescriptor* root,
- std::set<const FileDescriptor*>* all_files,
- std::set<const FileDescriptor*>* generated) const;
-
- // Generate definitions for all message classes and enums.
- void GenerateClassesAndEnums(const GeneratorOptions& options,
- io::Printer* printer,
- const FileDescriptor* file) const;
-
- void GenerateFieldValueExpression(io::Printer* printer,
- const char* obj_reference,
- const FieldDescriptor* field,
- bool use_default) const;
-
- // Generate definition for one class.
- void GenerateClass(const GeneratorOptions& options, io::Printer* printer,
- const Descriptor* desc) const;
- void GenerateClassConstructor(const GeneratorOptions& options,
- io::Printer* printer,
- const Descriptor* desc) const;
- void GenerateClassFieldInfo(const GeneratorOptions& options,
- io::Printer* printer,
- const Descriptor* desc) const;
- void GenerateClassConstructorAndDeclareExtensionFieldInfo(
- const GeneratorOptions& options, io::Printer* printer,
- const Descriptor* desc) const;
- void GenerateClassXid(const GeneratorOptions& options, io::Printer* printer,
- const Descriptor* desc) const;
- void GenerateOneofCaseDefinition(const GeneratorOptions& options,
- io::Printer* printer,
- const OneofDescriptor* oneof) const;
- void GenerateObjectTypedef(const GeneratorOptions& options,
- io::Printer* printer,
- const Descriptor* desc) const;
- void GenerateClassToObject(const GeneratorOptions& options,
- io::Printer* printer,
- const Descriptor* desc) const;
- void GenerateClassFieldToObject(const GeneratorOptions& options,
- io::Printer* printer,
- const FieldDescriptor* field) const;
- void GenerateClassFromObject(const GeneratorOptions& options,
- io::Printer* printer,
- const Descriptor* desc) const;
- void GenerateClassFieldFromObject(const GeneratorOptions& options,
- io::Printer* printer,
- const FieldDescriptor* field) const;
- void GenerateClassRegistration(const GeneratorOptions& options,
- io::Printer* printer,
- const Descriptor* desc) const;
- void GenerateClassFields(const GeneratorOptions& options,
- io::Printer* printer, const Descriptor* desc) const;
- void GenerateClassField(const GeneratorOptions& options, io::Printer* printer,
- const FieldDescriptor* desc) const;
- void GenerateClassExtensionFieldInfo(const GeneratorOptions& options,
- io::Printer* printer,
- const Descriptor* desc) const;
- void GenerateClassDeserialize(const GeneratorOptions& options,
- io::Printer* printer,
- const Descriptor* desc) const;
- void GenerateClassDeserializeBinary(const GeneratorOptions& options,
- io::Printer* printer,
- const Descriptor* desc) const;
- void GenerateClassDeserializeBinaryField(const GeneratorOptions& options,
- io::Printer* printer,
- const FieldDescriptor* field) const;
- void GenerateClassSerializeBinary(const GeneratorOptions& options,
- io::Printer* printer,
- const Descriptor* desc) const;
- void GenerateClassSerializeBinaryField(const GeneratorOptions& options,
- io::Printer* printer,
- const FieldDescriptor* field) const;
-
- // Generate definition for one enum.
- void GenerateEnum(const GeneratorOptions& options, io::Printer* printer,
- const EnumDescriptor* enumdesc) const;
-
- // Generate an extension definition.
- void GenerateExtension(const GeneratorOptions& options, io::Printer* printer,
- const FieldDescriptor* field) const;
-
- // Generate addFoo() method for repeated primitive fields.
- void GenerateRepeatedPrimitiveHelperMethods(const GeneratorOptions& options,
- io::Printer* printer,
- const FieldDescriptor* field,
- bool untyped) const;
-
- // Generate addFoo() method for repeated message fields.
- void GenerateRepeatedMessageHelperMethods(const GeneratorOptions& options,
- io::Printer* printer,
- const FieldDescriptor* field) const;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Generator);
-};
-
-} // namespace js
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JS_GENERATOR_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/js/well_known_types_embed.cc b/contrib/libs/protoc/src/google/protobuf/compiler/js/well_known_types_embed.cc
deleted file mode 100644
index 5cb73657e7..0000000000
--- a/contrib/libs/protoc/src/google/protobuf/compiler/js/well_known_types_embed.cc
+++ /dev/null
@@ -1,270 +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/js/well_known_types_embed.h>
-
-struct FileToc well_known_types_js[] = {
- {"any.js",
- "/* This code will be inserted into generated code for\n"
- " * google/protobuf/any.proto. */\n"
- "\n"
- "/**\n"
- " * Returns the type name contained in this instance, if any.\n"
- " * @return {string|undefined}\n"
- " */\n"
- "proto.google.protobuf.Any.prototype.getTypeName = function() {\n"
- " return this.getTypeUrl().split('/').pop();\n"
- "};\n"
- "\n"
- "\n"
- "/**\n"
- " * Packs the given message instance into this Any.\n"
- " * For binary format usage only.\n"
- " * @param {!Uint8Array} serialized The serialized data to pack.\n"
- " * @param {string} name The type name of this message object.\n"
- " * @param {string=} opt_typeUrlPrefix the type URL prefix.\n"
- " */\n"
- "proto.google.protobuf.Any.prototype.pack = function(serialized, name,\n"
- " opt_typeUrlPrefix) "
- "{\n"
- " if (!opt_typeUrlPrefix) {\n"
- " opt_typeUrlPrefix = 'type.googleapis.com/';\n"
- " }\n"
- "\n"
- " if (opt_typeUrlPrefix.substr(-1) != '/') {\n"
- " this.setTypeUrl(opt_typeUrlPrefix + '/' + name);\n"
- " } else {\n"
- " this.setTypeUrl(opt_typeUrlPrefix + name);\n"
- " }\n"
- "\n"
- " this.setValue(serialized);\n"
- "};\n"
- "\n"
- "\n"
- "/**\n"
- " * @template T\n"
- " * Unpacks this Any into the given message object.\n"
- " * @param {function(Uint8Array):T} deserialize Function that will "
- "deserialize\n"
- " * the binary data properly.\n"
- " * @param {string} name The expected type name of this message object.\n"
- " * @return {?T} If the name matched the expected name, returns the "
- "deserialized\n"
- " * object, otherwise returns null.\n"
- " */\n"
- "proto.google.protobuf.Any.prototype.unpack = function(deserialize, name) "
- "{\n"
- " if (this.getTypeName() == name) {\n"
- " return deserialize(this.getValue_asU8());\n"
- " } else {\n"
- " return null;\n"
- " }\n"
- "};\n"
- },
- {"timestamp.js",
- "/* This code will be inserted into generated code for\n"
- " * google/protobuf/timestamp.proto. */\n"
- "\n"
- "/**\n"
- " * Returns a JavaScript 'Date' object corresponding to this Timestamp.\n"
- " * @return {!Date}\n"
- " */\n"
- "proto.google.protobuf.Timestamp.prototype.toDate = function() {\n"
- " var seconds = this.getSeconds();\n"
- " var nanos = this.getNanos();\n"
- "\n"
- " return new Date((seconds * 1000) + (nanos / 1000000));\n"
- "};\n"
- "\n"
- "\n"
- "/**\n"
- " * Sets the value of this Timestamp object to be the given Date.\n"
- " * @param {!Date} value The value to set.\n"
- " */\n"
- "proto.google.protobuf.Timestamp.prototype.fromDate = function(value) {\n"
- " this.setSeconds(Math.floor(value.getTime() / 1000));\n"
- " this.setNanos(value.getMilliseconds() * 1000000);\n"
- "};\n"
- "\n"
- "\n"
- "/**\n"
- " * Factory method that returns a Timestamp object with value equal to\n"
- " * the given Date.\n"
- " * @param {!Date} value The value to set.\n"
- " * @return {!proto.google.protobuf.Timestamp}\n"
- " */\n"
- "proto.google.protobuf.Timestamp.fromDate = function(value) {\n"
- " var timestamp = new proto.google.protobuf.Timestamp();\n"
- " timestamp.fromDate(value);\n"
- " return timestamp;\n"
- "};\n"},
- {"struct.js",
- "/* This code will be inserted into generated code for\n"
- " * google/protobuf/struct.proto. */\n"
- "\n"
- "/**\n"
- " * Typedef representing plain JavaScript values that can go into a\n"
- " * Struct.\n"
- " * @typedef {null|number|string|boolean|Array|Object}\n"
- " */\n"
- "proto.google.protobuf.JavaScriptValue;\n"
- "\n"
- "\n"
- "/**\n"
- " * Converts this Value object to a plain JavaScript value.\n"
- " * @return {?proto.google.protobuf.JavaScriptValue} a plain JavaScript\n"
- " * value representing this Struct.\n"
- " */\n"
- "proto.google.protobuf.Value.prototype.toJavaScript = function() {\n"
- " var kindCase = proto.google.protobuf.Value.KindCase;\n"
- " switch (this.getKindCase()) {\n"
- " case kindCase.NULL_VALUE:\n"
- " return null;\n"
- " case kindCase.NUMBER_VALUE:\n"
- " return this.getNumberValue();\n"
- " case kindCase.STRING_VALUE:\n"
- " return this.getStringValue();\n"
- " case kindCase.BOOL_VALUE:\n"
- " return this.getBoolValue();\n"
- " case kindCase.STRUCT_VALUE:\n"
- " return this.getStructValue().toJavaScript();\n"
- " case kindCase.LIST_VALUE:\n"
- " return this.getListValue().toJavaScript();\n"
- " default:\n"
- " throw new Error('Unexpected struct type');\n"
- " }\n"
- "};\n"
- "\n"
- "\n"
- "/**\n"
- " * Converts this JavaScript value to a new Value proto.\n"
- " * @param {!proto.google.protobuf.JavaScriptValue} value The value to\n"
- " * convert.\n"
- " * @return {!proto.google.protobuf.Value} The newly constructed value.\n"
- " */\n"
- "proto.google.protobuf.Value.fromJavaScript = function(value) {\n"
- " var ret = new proto.google.protobuf.Value();\n"
- " switch (goog.typeOf(value)) {\n"
- " case 'string':\n"
- " ret.setStringValue(/** @type {string} */ (value));\n"
- " break;\n"
- " case 'number':\n"
- " ret.setNumberValue(/** @type {number} */ (value));\n"
- " break;\n"
- " case 'boolean':\n"
- " ret.setBoolValue(/** @type {boolean} */ (value));\n"
- " break;\n"
- " case 'null':\n"
- " ret.setNullValue(proto.google.protobuf.NullValue.NULL_VALUE);\n"
- " break;\n"
- " case 'array':\n"
- " ret.setListValue(proto.google.protobuf.ListValue.fromJavaScript(\n"
- " /** @type{!Array} */ (value)));\n"
- " break;\n"
- " case 'object':\n"
- " ret.setStructValue(proto.google.protobuf.Struct.fromJavaScript(\n"
- " /** @type{!Object} */ (value)));\n"
- " break;\n"
- " default:\n"
- " throw new Error('Unexpected struct type.');\n"
- " }\n"
- "\n"
- " return ret;\n"
- "};\n"
- "\n"
- "\n"
- "/**\n"
- " * Converts this ListValue object to a plain JavaScript array.\n"
- " * @return {!Array} a plain JavaScript array representing this List.\n"
- " */\n"
- "proto.google.protobuf.ListValue.prototype.toJavaScript = function() {\n"
- " var ret = [];\n"
- " var values = this.getValuesList();\n"
- "\n"
- " for (var i = 0; i < values.length; i++) {\n"
- " ret[i] = values[i].toJavaScript();\n"
- " }\n"
- "\n"
- " return ret;\n"
- "};\n"
- "\n"
- "\n"
- "/**\n"
- " * Constructs a ListValue protobuf from this plain JavaScript array.\n"
- " * @param {!Array} array a plain JavaScript array\n"
- " * @return {proto.google.protobuf.ListValue} a new ListValue object\n"
- " */\n"
- "proto.google.protobuf.ListValue.fromJavaScript = function(array) {\n"
- " var ret = new proto.google.protobuf.ListValue();\n"
- "\n"
- " for (var i = 0; i < array.length; i++) {\n"
- " "
- "ret.addValues(proto.google.protobuf.Value.fromJavaScript(array[i]));\n"
- " }\n"
- "\n"
- " return ret;\n"
- "};\n"
- "\n"
- "\n"
- "/**\n"
- " * Converts this Struct object to a plain JavaScript object.\n"
- " * @return {!Object<string, !proto.google.protobuf.JavaScriptValue>} a "
- "plain\n"
- " * JavaScript object representing this Struct.\n"
- " */\n"
- "proto.google.protobuf.Struct.prototype.toJavaScript = function() {\n"
- " var ret = {};\n"
- "\n"
- " this.getFieldsMap().forEach(function(value, key) {\n"
- " ret[key] = value.toJavaScript();\n"
- " });\n"
- "\n"
- " return ret;\n"
- "};\n"
- "\n"
- "\n"
- "/**\n"
- " * Constructs a Struct protobuf from this plain JavaScript object.\n"
- " * @param {!Object} obj a plain JavaScript object\n"
- " * @return {proto.google.protobuf.Struct} a new Struct object\n"
- " */\n"
- "proto.google.protobuf.Struct.fromJavaScript = function(obj) {\n"
- " var ret = new proto.google.protobuf.Struct();\n"
- " var map = ret.getFieldsMap();\n"
- "\n"
- " for (var property in obj) {\n"
- " var val = obj[property];\n"
- " map.set(property, proto.google.protobuf.Value.fromJavaScript(val));\n"
- " }\n"
- "\n"
- " return ret;\n"
- "};\n"},
- {NULL, NULL} // Terminate the list.
-};
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/js/well_known_types_embed.h b/contrib/libs/protoc/src/google/protobuf/compiler/js/well_known_types_embed.h
deleted file mode 100644
index 174c665e45..0000000000
--- a/contrib/libs/protoc/src/google/protobuf/compiler/js/well_known_types_embed.h
+++ /dev/null
@@ -1,43 +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_JS_WELL_KNOWN_TYPES_EMBED_H__
-#define GOOGLE_PROTOBUF_COMPILER_JS_WELL_KNOWN_TYPES_EMBED_H__
-
-#include <stddef.h>
-
-struct FileToc {
- const char* name;
- const char* data;
-};
-
-extern struct FileToc well_known_types_js[];
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JS_WELL_KNOWN_TYPES_EMBED_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/main.cc b/contrib/libs/protoc/src/google/protobuf/compiler/main.cc
index ce6b49d84e..39609468ab 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/main.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/main.cc
@@ -28,17 +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/compiler/cpp/cpp_generator.h>
-#include <google/protobuf/compiler/java/java_generator.h>
-#include <google/protobuf/compiler/java/java_kotlin_generator.h>
-#include <google/protobuf/compiler/js/js_generator.h>
+#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/perlxs/perlxs_generator.h>
-#include <google/protobuf/compiler/python/python_generator.h>
-#include <google/protobuf/compiler/python/python_pyi_generator.h>
#include <google/protobuf/compiler/csharp/csharp_generator.h>
#include <google/protobuf/compiler/objectivec/objectivec_generator.h>
#include <google/protobuf/compiler/php/php_generator.h>
+#include <google/protobuf/compiler/python/generator.h>
+#include <google/protobuf/compiler/python/pyi_generator.h>
#include <google/protobuf/compiler/ruby/ruby_generator.h>
// Must be included last.
@@ -102,16 +100,6 @@ int ProtobufMain(int argc, char* argv[]) {
objectivec::ObjectiveCGenerator objc_generator;
cli.RegisterGenerator("--objc_out", "--objc_opt", &objc_generator,
"Generate Objective-C header and source.");
-
- // Proto2 Perl/XS
- perlxs::PerlXSGenerator perlxs_generator;
- cli.RegisterGenerator("--perlxs_out", &perlxs_generator,
- "Generate Perl/XS source files.");
-
- // JavaScript
- js::Generator js_generator;
- cli.RegisterGenerator("--js_out", "--js_opt", &js_generator,
- "Generate JavaScript source.");
return cli.Run(argc, argv);
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc
index 9f87d2c71e..bcecc7b373 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc
@@ -34,7 +34,6 @@
#include <google/protobuf/compiler/objectivec/objectivec_enum_field.h>
#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
namespace google {
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/objectivec_enum_field.h
index 8c27a3702f..fea75f7a84 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h
@@ -56,7 +56,7 @@ class EnumFieldGenerator : public SingleFieldGenerator {
bool include_external_types) const override;
protected:
- EnumFieldGenerator(const FieldDescriptor* descriptor);
+ explicit EnumFieldGenerator(const FieldDescriptor* descriptor);
virtual ~EnumFieldGenerator();
};
@@ -67,7 +67,7 @@ class RepeatedEnumFieldGenerator : public RepeatedFieldGenerator {
virtual void FinishInitialization() override;
protected:
- RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor);
+ explicit RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor);
virtual ~RepeatedEnumFieldGenerator();
};
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.cc
index cd0ad8a016..e73a664db1 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.cc
@@ -37,7 +37,6 @@
#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/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
namespace google {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.h
index bc1fb11b8a..3e968946fa 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_field.h
@@ -95,7 +95,7 @@ class FieldGenerator {
TProtoStringType raw_field_name() const { return variable("raw_field_name"); }
protected:
- FieldGenerator(const FieldDescriptor* descriptor);
+ explicit FieldGenerator(const FieldDescriptor* descriptor);
virtual void FinishInitialization(void);
bool WantsHasProperty(void) const;
@@ -119,7 +119,7 @@ class SingleFieldGenerator : public FieldGenerator {
virtual bool RuntimeUsesHasBit(void) const override;
protected:
- SingleFieldGenerator(const FieldDescriptor* descriptor);
+ explicit SingleFieldGenerator(const FieldDescriptor* descriptor);
};
// Subclass with common support for when the field ends up as an ObjC Object.
@@ -134,7 +134,7 @@ class ObjCObjFieldGenerator : public SingleFieldGenerator {
virtual void GeneratePropertyDeclaration(io::Printer* printer) const override;
protected:
- ObjCObjFieldGenerator(const FieldDescriptor* descriptor);
+ explicit ObjCObjFieldGenerator(const FieldDescriptor* descriptor);
};
class RepeatedFieldGenerator : public ObjCObjFieldGenerator {
@@ -152,14 +152,14 @@ class RepeatedFieldGenerator : public ObjCObjFieldGenerator {
virtual bool RuntimeUsesHasBit(void) const override;
protected:
- RepeatedFieldGenerator(const FieldDescriptor* descriptor);
+ explicit RepeatedFieldGenerator(const FieldDescriptor* descriptor);
virtual void FinishInitialization(void) override;
};
// Convenience class which constructs FieldGenerators for a Descriptor.
class FieldGeneratorMap {
public:
- FieldGeneratorMap(const Descriptor* descriptor);
+ explicit FieldGeneratorMap(const Descriptor* descriptor);
~FieldGeneratorMap();
FieldGeneratorMap(const FieldGeneratorMap&) = delete;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.cc
index 0f4828c3ac..e1bb09f996 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.cc
@@ -117,46 +117,77 @@ bool FileContainsExtensions(const FileDescriptor* file) {
return false;
}
-// Helper for CollectMinimalFileDepsContainingExtensionsWorker that marks all
-// deps as visited and prunes them from the needed files list.
-void PruneFileAndDepsMarkingAsVisited(
- const FileDescriptor* file,
- std::vector<const FileDescriptor*>* files,
- std::set<const FileDescriptor*>* files_visited) {
- std::vector<const FileDescriptor*>::iterator iter =
- std::find(files->begin(), files->end(), file);
- if (iter != files->end()) {
- files->erase(iter);
- }
- files_visited->insert(file);
+bool IsDirectDependency(const FileDescriptor* dep, const FileDescriptor* file) {
for (int i = 0; i < file->dependency_count(); i++) {
- PruneFileAndDepsMarkingAsVisited(file->dependency(i), files, files_visited);
+ if (dep == file->dependency(i)) {
+ return true;
+ }
}
+ return false;
}
-// Helper for CollectMinimalFileDepsContainingExtensions.
-void CollectMinimalFileDepsContainingExtensionsWorker(
- const FileDescriptor* file,
- std::vector<const FileDescriptor*>* files,
- std::set<const FileDescriptor*>* files_visited) {
- if (files_visited->find(file) != files_visited->end()) {
- return;
- }
- files_visited->insert(file);
-
- if (FileContainsExtensions(file)) {
- files->push_back(file);
- for (int i = 0; i < file->dependency_count(); i++) {
- const FileDescriptor* dep = file->dependency(i);
- PruneFileAndDepsMarkingAsVisited(dep, files, files_visited);
- }
- } else {
- for (int i = 0; i < file->dependency_count(); i++) {
- const FileDescriptor* dep = file->dependency(i);
- CollectMinimalFileDepsContainingExtensionsWorker(dep, files,
- files_visited);
+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
@@ -168,32 +199,23 @@ void CollectMinimalFileDepsContainingExtensionsWorker(
// There are comments about what the expected code should be line and limited
// testing objectivec/Tests/GPBUnittestProtos2.m around compilation (#imports
// specifically).
-void CollectMinimalFileDepsContainingExtensions(
- const FileDescriptor* file,
- std::vector<const FileDescriptor*>* files) {
- std::set<const FileDescriptor*> files_visited;
- for (int i = 0; i < file->dependency_count(); i++) {
- const FileDescriptor* dep = file->dependency(i);
- CollectMinimalFileDepsContainingExtensionsWorker(dep, files,
- &files_visited);
- }
+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;
}
-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;
-}
-
-} // namespace
-
FileGenerator::FileGenerator(const FileDescriptor* file,
- const GenerationOptions& generation_options)
+ 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++) {
@@ -374,8 +396,8 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
"\n");
}
- std::vector<const FileDescriptor*> deps_with_extensions;
- CollectMinimalFileDepsContainingExtensions(file_, &deps_with_extensions);
+ 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 =
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.h
index 6d2c970f81..de37930eb3 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.h
@@ -31,8 +31,9 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_FILE_H__
#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_FILE_H__
-#include <string>
+#include <map>
#include <set>
+#include <string>
#include <vector>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/io/printer.h>
@@ -59,8 +60,29 @@ class FileGenerator {
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();
+
+ const 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;
+ };
+ const MinDepsEntry& CollectMinimalFileDepsContainingExtensionsInternal(const FileDescriptor* file);
+ std::map<const FileDescriptor*, MinDepsEntry> deps_info_cache_;
+ };
+
FileGenerator(const FileDescriptor* file,
- const GenerationOptions& generation_options);
+ const GenerationOptions& generation_options,
+ CommonState& common_state);
~FileGenerator();
FileGenerator(const FileGenerator&) = delete;
@@ -72,6 +94,7 @@ class FileGenerator {
private:
const FileDescriptor* file_;
const GenerationOptions& generation_options_;
+ CommonState& common_state_;
TProtoStringType root_class_name_;
bool is_bundled_proto_;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_generator.cc
index 552d7e7273..586cdb025b 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_generator.cc
@@ -269,9 +269,10 @@ bool ObjectiveCGenerator::GenerateAll(
return false;
}
+ FileGenerator::CommonState state;
for (int i = 0; i < files.size(); i++) {
const FileDescriptor* file = files[i];
- FileGenerator file_generator(file, generation_options);
+ FileGenerator file_generator(file, generation_options, state);
TProtoStringType filepath = FilePath(file);
// Generate header.
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_map_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_map_field.h
index 2ec2e43435..a75aa961d8 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_map_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_map_field.h
@@ -50,7 +50,7 @@ class MapFieldGenerator : public RepeatedFieldGenerator {
MapFieldGenerator& operator=(const MapFieldGenerator&) = delete;
protected:
- MapFieldGenerator(const FieldDescriptor* descriptor);
+ explicit MapFieldGenerator(const FieldDescriptor* descriptor);
virtual ~MapFieldGenerator();
virtual void DetermineObjectiveCClassDefinitions(
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message.cc
index ab5b29628f..bf73592e56 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message.cc
@@ -41,8 +41,6 @@
#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/wire_format.h>
-#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/descriptor.pb.h>
namespace google {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc
index 828b75c868..8ae073a12a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc
@@ -34,7 +34,6 @@
#include <google/protobuf/compiler/objectivec/objectivec_message_field.h>
#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
namespace google {
namespace protobuf {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.h
index 44b5aabcfd..50ddb633cc 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_message_field.h
@@ -44,7 +44,7 @@ class MessageFieldGenerator : public ObjCObjFieldGenerator {
friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field);
protected:
- MessageFieldGenerator(const FieldDescriptor* descriptor);
+ explicit MessageFieldGenerator(const FieldDescriptor* descriptor);
MessageFieldGenerator(const MessageFieldGenerator&) = delete;
MessageFieldGenerator& operator=(const MessageFieldGenerator&) = delete;
@@ -63,7 +63,7 @@ class RepeatedMessageFieldGenerator : public RepeatedFieldGenerator {
friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field);
protected:
- RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor);
+ explicit RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor);
virtual ~RepeatedMessageFieldGenerator();
RepeatedMessageFieldGenerator(const RepeatedMessageFieldGenerator&) = delete;
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc
index c8233b1441..f83e2691ae 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc
@@ -35,8 +35,6 @@
#include <google/protobuf/compiler/objectivec/objectivec_primitive_field.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/wire_format_lite.h>
namespace google {
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/objectivec_primitive_field.h
index 291d11a2e3..06a1528a82 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h
@@ -31,8 +31,6 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_PRIMITIVE_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_PRIMITIVE_FIELD_H__
-#include <map>
-#include <string>
#include <google/protobuf/compiler/objectivec/objectivec_field.h>
namespace google {
@@ -44,7 +42,7 @@ class PrimitiveFieldGenerator : public SingleFieldGenerator {
friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field);
protected:
- PrimitiveFieldGenerator(const FieldDescriptor* descriptor);
+ explicit PrimitiveFieldGenerator(const FieldDescriptor* descriptor);
virtual ~PrimitiveFieldGenerator();
PrimitiveFieldGenerator(const PrimitiveFieldGenerator&) = delete;
@@ -60,7 +58,7 @@ class PrimitiveObjFieldGenerator : public ObjCObjFieldGenerator {
friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field);
protected:
- PrimitiveObjFieldGenerator(const FieldDescriptor* descriptor);
+ explicit PrimitiveObjFieldGenerator(const FieldDescriptor* descriptor);
virtual ~PrimitiveObjFieldGenerator();
PrimitiveObjFieldGenerator(const PrimitiveObjFieldGenerator&) = delete;
@@ -72,7 +70,7 @@ class RepeatedPrimitiveFieldGenerator : public RepeatedFieldGenerator {
friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field);
protected:
- RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor);
+ explicit RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor);
virtual ~RepeatedPrimitiveFieldGenerator();
RepeatedPrimitiveFieldGenerator(const RepeatedPrimitiveFieldGenerator&) =
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc b/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc
index 332556e9c4..2900d324d2 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc
@@ -64,32 +64,33 @@ namespace {
typedef std::unordered_map<TProtoStringType, FieldDescriptorProto::Type> TypeNameMap;
-TypeNameMap MakeTypeNameTable() {
- TypeNameMap result;
-
- result["double"] = FieldDescriptorProto::TYPE_DOUBLE;
- result["float"] = FieldDescriptorProto::TYPE_FLOAT;
- result["uint64"] = FieldDescriptorProto::TYPE_UINT64;
- result["fixed64"] = FieldDescriptorProto::TYPE_FIXED64;
- result["fixed32"] = FieldDescriptorProto::TYPE_FIXED32;
- result["bool"] = FieldDescriptorProto::TYPE_BOOL;
- result["string"] = FieldDescriptorProto::TYPE_STRING;
- result["group"] = FieldDescriptorProto::TYPE_GROUP;
-
- result["bytes"] = FieldDescriptorProto::TYPE_BYTES;
- result["uint32"] = FieldDescriptorProto::TYPE_UINT32;
- result["sfixed32"] = FieldDescriptorProto::TYPE_SFIXED32;
- result["sfixed64"] = FieldDescriptorProto::TYPE_SFIXED64;
- result["int32"] = FieldDescriptorProto::TYPE_INT32;
- result["int64"] = FieldDescriptorProto::TYPE_INT64;
- result["sint32"] = FieldDescriptorProto::TYPE_SINT32;
- result["sint64"] = FieldDescriptorProto::TYPE_SINT64;
-
- return result;
+const TypeNameMap& GetTypeNameTable() {
+ static auto* table = new auto([]() {
+ TypeNameMap result;
+
+ result["double"] = FieldDescriptorProto::TYPE_DOUBLE;
+ result["float"] = FieldDescriptorProto::TYPE_FLOAT;
+ result["uint64"] = FieldDescriptorProto::TYPE_UINT64;
+ result["fixed64"] = FieldDescriptorProto::TYPE_FIXED64;
+ result["fixed32"] = FieldDescriptorProto::TYPE_FIXED32;
+ result["bool"] = FieldDescriptorProto::TYPE_BOOL;
+ result["string"] = FieldDescriptorProto::TYPE_STRING;
+ result["group"] = FieldDescriptorProto::TYPE_GROUP;
+
+ result["bytes"] = FieldDescriptorProto::TYPE_BYTES;
+ result["uint32"] = FieldDescriptorProto::TYPE_UINT32;
+ result["sfixed32"] = FieldDescriptorProto::TYPE_SFIXED32;
+ result["sfixed64"] = FieldDescriptorProto::TYPE_SFIXED64;
+ result["int32"] = FieldDescriptorProto::TYPE_INT32;
+ result["int64"] = FieldDescriptorProto::TYPE_INT64;
+ result["sint32"] = FieldDescriptorProto::TYPE_SINT32;
+ result["sint64"] = FieldDescriptorProto::TYPE_SINT64;
+
+ return result;
+ }());
+ return *table;
}
-const TypeNameMap kTypeNames = MakeTypeNameTable();
-
// 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) {
@@ -972,37 +973,14 @@ bool Parser::ParseMessageFieldNoLabel(
if (TryConsume("map")) {
if (LookingAt("<")) {
map_field.is_map_field = true;
+ DO(ParseMapType(&map_field, field, location));
} else {
// False positive
type_parsed = true;
type_name = "map";
}
}
- if (map_field.is_map_field) {
- if (field->has_oneof_index()) {
- AddError("Map fields are not allowed in oneofs.");
- return false;
- }
- if (field->has_label()) {
- AddError(
- "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.");
- return false;
- }
- field->set_label(FieldDescriptorProto::LABEL_REPEATED);
- DO(Consume("<"));
- DO(ParseType(&map_field.key_type, &map_field.key_type_name));
- DO(Consume(","));
- DO(ParseType(&map_field.value_type, &map_field.value_type_name));
- DO(Consume(">"));
- // Defer setting of the type name of the map field until the
- // field name is parsed. Add the source location though.
- location.AddPath(FieldDescriptorProto::kTypeNameFieldNumber);
- } else {
+ if (!map_field.is_map_field) {
// Handle the case where no explicit label is given for a non-map field.
if (!field->has_label() && DefaultToOptionalFields()) {
field->set_label(FieldDescriptorProto::LABEL_OPTIONAL);
@@ -1014,8 +992,8 @@ bool Parser::ParseMessageFieldNoLabel(
field->set_label(FieldDescriptorProto::LABEL_OPTIONAL);
}
- // Handle the case where the actual type is a message or enum named "map",
- // which we already consumed in the code above.
+ // Handle the case where the actual type is a message or enum named
+ // "map", which we already consumed in the code above.
if (!type_parsed) {
DO(ParseType(&type, &type_name));
}
@@ -1123,6 +1101,34 @@ bool Parser::ParseMessageFieldNoLabel(
return true;
}
+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.");
+ return false;
+ }
+ if (field->has_label()) {
+ AddError(
+ "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.");
+ return false;
+ }
+ field->set_label(FieldDescriptorProto::LABEL_REPEATED);
+ DO(Consume("<"));
+ DO(ParseType(&map_field->key_type, &map_field->key_type_name));
+ DO(Consume(","));
+ DO(ParseType(&map_field->value_type, &map_field->value_type_name));
+ DO(Consume(">"));
+ // Defer setting of the type name of the map field until the
+ // field name is parsed. Add the source location though.
+ type_name_location.AddPath(FieldDescriptorProto::kTypeNameFieldNumber);
+ return true;
+}
+
void Parser::GenerateMapEntry(const MapField& map_field,
FieldDescriptorProto* field,
RepeatedPtrField<DescriptorProto>* messages) {
@@ -2261,8 +2267,9 @@ bool Parser::ParseLabel(FieldDescriptorProto::Label* label,
bool Parser::ParseType(FieldDescriptorProto::Type* type,
TProtoStringType* type_name) {
- TypeNameMap::const_iterator iter = kTypeNames.find(input_->current().text);
- if (iter != kTypeNames.end()) {
+ const auto& type_names_table = GetTypeNameTable();
+ auto iter = type_names_table.find(input_->current().text);
+ if (iter != type_names_table.end()) {
*type = iter->second;
input_->Next();
} else {
@@ -2274,8 +2281,9 @@ bool Parser::ParseType(FieldDescriptorProto::Type* type,
bool Parser::ParseUserDefinedType(TProtoStringType* type_name) {
type_name->clear();
- TypeNameMap::const_iterator iter = kTypeNames.find(input_->current().text);
- if (iter != kTypeNames.end()) {
+ const auto& type_names_table = GetTypeNameTable();
+ auto iter = type_names_table.find(input_->current().text);
+ if (iter != type_names_table.end()) {
// Note: The only place enum types are allowed is for field types, but
// 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
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/parser.h b/contrib/libs/protoc/src/google/protobuf/compiler/parser.h
index f60a97c44c..c92b5f28f4 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/parser.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/parser.h
@@ -122,6 +122,7 @@ class PROTOBUF_EXPORT Parser {
private:
class LocationRecorder;
+ struct MapField;
// =================================================================
// Error recovery helpers
@@ -378,6 +379,9 @@ class PROTOBUF_EXPORT Parser {
const LocationRecorder& field_location,
const FileDescriptorProto* containing_file);
+ bool ParseMapType(MapField* map_field, FieldDescriptorProto* field,
+ LocationRecorder& type_name_location);
+
// Parse an "extensions" declaration.
bool ParseExtensions(DescriptorProto* message,
const LocationRecorder& extensions_location,
@@ -480,7 +484,7 @@ class PROTOBUF_EXPORT Parser {
// Parses a single part of a multipart option name. A multipart name consists
// of names separated by dots. Each name is either an identifier or a series
// of identifiers separated by dots and enclosed in parentheses. E.g.,
- // "foo.(bar.baz).qux".
+ // "foo.(bar.baz).moo".
bool ParseOptionNamePart(UninterpretedOption* uninterpreted_option,
const LocationRecorder& part_location,
const FileDescriptorProto* containing_file);
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/perlxs/perlxs_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/perlxs/perlxs_generator.cc
deleted file mode 100644
index 7c5f0fa395..0000000000
--- a/contrib/libs/protoc/src/google/protobuf/compiler/perlxs/perlxs_generator.cc
+++ /dev/null
@@ -1,2045 +0,0 @@
-#include <iostream>
-#include <sstream>
-#include <memory>
-
-#include <google/protobuf/compiler/perlxs/perlxs_generator.h>
-#include <google/protobuf/compiler/perlxs/perlxs_helpers.h>
-#include <google/protobuf/descriptor.h>
-#include "google/protobuf/descriptor.pb.h"
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/io/zero_copy_stream.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace perlxs {
-
-inline bool HasFieldPresence(const FileDescriptor* file) {
- return file->syntax() != FileDescriptor::SYNTAX_PROTO3;
-}
-
-bool HasHasMethod(const FieldDescriptor* field) {
- if (HasFieldPresence(field->file())) {
- // In proto1/proto2, every field has a has_$name$() method.
- return true;
- }
- // For message types without true field presence, only fields with a message
- // type have a has_$name$() method.
- return field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE;
-}
-
-
-PerlXSGenerator::PerlXSGenerator() {}
-PerlXSGenerator::~PerlXSGenerator() {}
-
-
-bool
-PerlXSGenerator::Generate(const FileDescriptor* file,
- const TProtoStringType& parameter,
- OutputDirectory* outdir,
- TProtoStringType* error) const
-{
- // Each top-level message get its own XS source file, Perl module,
- // and typemap. Each top-level enum gets its own Perl module. The
- // files are generated in the perlxs_out directory.
-
- for ( int i = 0; i < file->message_type_count(); i++ ) {
- const Descriptor* message_type = file->message_type(i);
-
- GenerateMessageXS(message_type, outdir);
- GenerateMessagePOD(message_type, outdir);
- GenerateMessageModule(message_type, outdir);
- }
-
- for ( int i = 0; i < file->enum_type_count(); i++ ) {
- const EnumDescriptor* enum_type = file->enum_type(i);
-
- GenerateEnumModule(enum_type, outdir);
- }
-
- return true;
-}
-
-bool
-PerlXSGenerator::ProcessOption(const TProtoStringType& option)
-{
- size_t equals;
- bool recognized = false;
-
- equals = option.find_first_of('=');
- if (equals != TProtoStringType::npos) {
- TProtoStringType name = option.substr(0, equals);
- TProtoStringType value;
-
- if (option.length() > equals) {
- value = option.substr(equals + 1);
- }
-
- // Right now, we only recognize the --perlxs-package option.
- if (name == "--perlxs-package") {
- perlxs_package_ = value;
- recognized = true;
- }
- }
-
- return recognized;
-}
-
-void
-PerlXSGenerator::GenerateMessageXS(const Descriptor* descriptor,
- OutputDirectory* outdir) const
-{
- TProtoStringType filename = descriptor->name() + ".xs";
- std::unique_ptr<io::ZeroCopyOutputStream> output(outdir->Open(filename));
- io::Printer printer(output.get(), '$'); // '$' works well in the .xs file
-
- TProtoStringType base = cpp::StripProto(descriptor->file()->name());
-
- // Boilerplate at the top of the file.
-
- printer.Print(
- "#include <stdint.h>\n"
- "#include <sstream>\n"
- "#include <google/protobuf/stubs/common.h>\n"
- "#include <google/protobuf/io/zero_copy_stream.h>\n"
- "#include \"$base$.pb.h\"\n"
- "#ifdef __cplusplus\n"
- "extern \"C\" {\n"
- "#endif\n"
- "#include \"EXTERN.h\"\n"
- "#include \"perl.h\"\n"
- "#include \"XSUB.h\"\n"
- "#ifdef __cplusplus\n"
- "}\n"
- "#endif\n"
- "#ifdef do_open\n"
- "#undef do_open\n"
- "#endif\n"
- "#ifdef do_close\n"
- "#undef do_close\n"
- "#endif\n"
- "#ifdef New\n"
- "#undef New\n"
- "#endif\n"
- "\n"
- // "using namespace std;\n"
- "\n",
- "base",
- base);
-
- // ZeroCopyOutputStream implementation (for improved pack() performance)
-
- printer.Print("class $base$_OutputStream :\n"
- " public google::protobuf::io::ZeroCopyOutputStream {\n"
- "public:\n"
- " explicit $base$_OutputStream(SV * sv) :\n"
- " sv_(sv), len_(0) {}\n"
- " ~$base$_OutputStream() {}\n"
- "\n"
- " bool Next(void** data, int* size)\n"
- " {\n"
- " STRLEN nlen = len_ << 1;\n"
- "\n"
- " if ( nlen < 16 ) nlen = 16;\n"
- " SvGROW(sv_, nlen);\n"
- " *data = SvEND(sv_) + len_;\n"
- " *size = SvLEN(sv_) - len_;\n"
- " len_ = nlen;\n"
- "\n"
- " return true;\n"
- " }\n"
- "\n"
- " void BackUp(int count)\n"
- " {\n"
- " SvCUR_set(sv_, SvLEN(sv_) - count);\n"
- " len_ -= count;\n"
- " }\n"
- "\n"
- " void Sync() {\n"
- " if ( SvCUR(sv_) == 0 ) {\n"
- " SvCUR_set(sv_, len_);\n"
- " }\n"
- " }\n"
- "\n"
- " int64_t ByteCount() const\n"
- " {\n"
- " return (arc_i64)SvCUR(sv_);\n"
- " }\n"
- "\n"
- "private:\n"
- " SV * sv_;\n"
- " STRLEN len_;\n"
- "\n"
- " GOOGLE_DISALLOW_EVIL_CONSTRUCTORS($base$_OutputStream);\n"
- "};\n"
- "\n"
- "\n",
- "base",
- base);
-
- // Typedefs, Statics, and XS packages
-
- std::set<const Descriptor*> seen;
-
- GenerateFileXSTypedefs(descriptor->file(), printer, seen);
-
- printer.Print("\n\n");
-
- GenerateMessageStatics(descriptor, printer);
-
- printer.Print("\n\n");
-
- GenerateMessageXSPackage(descriptor, printer);
-}
-
-
-void
-PerlXSGenerator::GenerateMessageModule(const Descriptor* descriptor,
- OutputDirectory* outdir) const
-{
- TProtoStringType filename = descriptor->name() + ".pm";
- std::unique_ptr<io::ZeroCopyOutputStream> output(outdir->Open(filename));
- io::Printer printer(output.get(), '*'); // '*' works well in the .pm file
-
- std::map<TProtoStringType, TProtoStringType> vars;
-
- vars["package"] = MessageModuleName(descriptor);
- vars["message"] = descriptor->full_name();
- vars["name"] = descriptor->name();
-
- printer.Print(vars,
- "package *package*;\n"
- "\n"
- "use strict;\n"
- "use warnings;\n"
- "use vars qw(@ISA $AUTOLOAD $VERSION);\n"
- "\n"
- "$VERSION = '1.0';\n"
- "\n"
- "use Exporter;\n"
- "\n"
- "require DynaLoader;\n"
- "require AutoLoader;\n"
- "\n"
- "@ISA = qw(DynaLoader Exporter);\n"
- "\n"
- "bootstrap *package* $VERSION;\n"
- "\n"
- "1;\n"
- "\n"
- "__END__\n"
- "\n");
-}
-
-
-void
-PerlXSGenerator::GenerateMessagePOD(const Descriptor* descriptor,
- OutputDirectory* outdir) const
-{
- TProtoStringType filename = descriptor->name() + ".pod";
- std::unique_ptr<io::ZeroCopyOutputStream> output(outdir->Open(filename));
- io::Printer printer(output.get(), '*'); // '*' works well in the .pod file
-
- std::map<TProtoStringType, TProtoStringType> vars;
-
- vars["package"] = MessageModuleName(descriptor);
- vars["message"] = descriptor->full_name();
- vars["name"] = descriptor->name();
-
- // Generate POD documentation for the module.
-
- printer.Print(vars,
- "=pod\n"
- "\n"
- "=head1 NAME\n"
- "\n"
- "*package* - Perl/XS interface to *message*\n"
- "\n"
- "=head1 SYNOPSIS\n"
- "\n"
- "=head2 Serializing messages\n"
- "\n"
- " #!/usr/bin/perl\n"
- "\n"
- " use strict;\n"
- " use warnings;\n"
- " use *package*;\n"
- "\n"
- " my $*name* = *package*->new;\n"
- " # Set fields in $*name*...\n"
- " my $pack*name* = $*name*->pack();\n"
- "\n"
- "=head2 Unserializing messages\n"
- "\n"
- " #!/usr/bin/perl\n"
- "\n"
- " use strict;\n"
- " use warnings;\n"
- " use *package*;\n"
- "\n"
- " my $pack*name*; # Read this from somewhere...\n"
- " my $*name* = *package*->new;\n"
- " if ( $*name*->unpack($pack*name*) ) {\n"
- " print \"OK\"\n"
- " } else {\n"
- " print \"NOT OK\"\n"
- " }\n"
- "\n"
- "=head1 DESCRIPTION\n"
- "\n"
- "*package* defines the following classes:\n"
- "\n"
- "=over 5\n"
- "\n");
-
- // List of classes
-
- GenerateDescriptorClassNamePOD(descriptor, printer);
-
- printer.Print("\n"
- "=back\n"
- "\n");
-
- GenerateDescriptorMethodPOD(descriptor, printer);
-
- printer.Print(vars,
- "=head1 AUTHOR\n"
- "\n"
- "Generated from *message* by the protoc compiler.\n"
- "\n"
- "=head1 SEE ALSO\n"
- "\n");
-
- // Top-level messages in dependency files (recursively expanded)
-
- printer.Print("http://code.google.com/p/protobuf\n"
- "\n"
- "=cut\n"
- "\n");
-}
-
-
-void
-PerlXSGenerator::GenerateDescriptorClassNamePOD(const Descriptor* descriptor,
- io::Printer& printer) const
-{
- for ( int i = 0; i < descriptor->enum_type_count(); i++ ) {
- printer.Print("=item C<*name*>\n"
- "\n"
- "A wrapper around the *enum* enum\n"
- "\n",
- "name", EnumClassName(descriptor->enum_type(i)),
- "enum", descriptor->enum_type(i)->full_name());
- }
-
- for ( int i = 0; i < descriptor->nested_type_count(); i++ ) {
- GenerateDescriptorClassNamePOD(descriptor->nested_type(i), printer);
- }
-
- printer.Print("=item C<*name*>\n"
- "\n"
- "A wrapper around the *message* message\n"
- "\n",
- "name", MessageClassName(descriptor),
- "message", descriptor->full_name());
-}
-
-
-void
-PerlXSGenerator::GenerateDescriptorMethodPOD(const Descriptor* descriptor,
- io::Printer& printer) const
-{
- for ( int i = 0; i < descriptor->enum_type_count(); i++ ) {
- const EnumDescriptor * enum_descriptor = descriptor->enum_type(i);
- printer.Print("=head1 C<*name*> values\n"
- "\n"
- "=over 4\n"
- "\n",
- "name", EnumClassName(enum_descriptor));
-
- for ( int j = 0; j < enum_descriptor->value_count(); j++ ) {
- PODPrintEnumValue(enum_descriptor->value(j), printer);
- }
-
- printer.Print("\n"
- "=back\n"
- "\n");
- }
-
- for ( int i = 0; i < descriptor->nested_type_count(); i++ ) {
- GenerateDescriptorMethodPOD(descriptor->nested_type(i), printer);
- }
-
- // Constructor
-
- std::map<TProtoStringType, TProtoStringType> vars;
-
- vars["name"] = MessageClassName(descriptor);
- vars["value"] = descriptor->name();
-
- printer.Print(vars,
- "=head1 *name* Constructor\n"
- "\n"
- "=over 4\n"
- "\n"
- "=item B<$*value* = *name*-E<gt>new( [$arg] )>\n"
- "\n"
- "Constructs an instance of C<*name*>. If a hashref argument\n"
- "is supplied, it is copied into the message instance as if\n"
- "the copy_from() method were called immediately after\n"
- "construction. Otherwise, if a scalar argument is supplied,\n"
- "it is interpreted as a serialized instance of the message\n"
- "type, and the scalar is parsed to populate the message\n"
- "fields. Otherwise, if no argument is supplied, an empty\n"
- "message instance is constructed.\n"
- "\n"
- "=back\n"
- "\n"
- "=head1 *name* Methods\n"
- "\n"
- "=over 4\n"
- "\n");
-
- // Common message methods
-
- printer.Print(vars,
- "=item B<$*value*2-E<gt>copy_from($*value*1)>\n"
- "\n"
- "Copies the contents of C<*value*1> into C<*value*2>.\n"
- "C<*value*2> is another instance of the same message type.\n"
- "\n"
- "=item B<$*value*2-E<gt>copy_from($hashref)>\n"
- "\n"
- "Copies the contents of C<hashref> into C<*value*2>.\n"
- "C<hashref> is a Data::Dumper-style representation of an\n"
- "instance of the message type.\n"
- "\n"
- "=item B<$*value*2-E<gt>merge_from($*value*1)>\n"
- "\n"
- "Merges the contents of C<*value*1> into C<*value*2>.\n"
- "C<*value*2> is another instance of the same message type.\n"
- "\n"
- "=item B<$*value*2-E<gt>merge_from($hashref)>\n"
- "\n"
- "Merges the contents of C<hashref> into C<*value*2>.\n"
- "C<hashref> is a Data::Dumper-style representation of an\n"
- "instance of the message type.\n"
- "\n"
- "=item B<$*value*-E<gt>clear()>\n"
- "\n"
- "Clears the contents of C<*value*>.\n"
- "\n"
- "=item B<$init = $*value*-E<gt>is_initialized()>\n"
- "\n"
- "Returns 1 if C<*value*> has been initialized with data.\n"
- "\n"
- "=item B<$errstr = $*value*-E<gt>error_string()>\n"
- "\n"
- "Returns a comma-delimited TProtoStringType of initialization errors.\n"
- "\n"
- "=item B<$*value*-E<gt>discard_unknown_fields()>\n"
- "\n"
- "Discards unknown fields from C<*value*>.\n"
- "\n"
- "=item B<$dstr = $*value*-E<gt>debug_string()>\n"
- "\n"
- "Returns a TProtoStringType representation of C<*value*>.\n"
- "\n"
- "=item B<$dstr = $*value*-E<gt>short_debug_string()>\n"
- "\n"
- "Returns a short TProtoStringType representation of C<*value*>.\n"
- "\n"
- "=item B<$ok = $*value*-E<gt>unpack($TProtoStringType)>\n"
- "\n"
- "Attempts to parse C<TProtoStringType> into C<*value*>, returning 1 "
- "on success and 0 on failure.\n"
- "\n"
- "=item B<$TProtoStringType = $*value*-E<gt>pack()>\n"
- "\n"
- "Serializes C<*value*> into C<TProtoStringType>.\n"
- "\n"
- "=item B<$length = $*value*-E<gt>length()>\n"
- "\n"
- "Returns the serialized length of C<*value*>.\n"
- "\n"
- "=item B<@fields = $*value*-E<gt>fields()>\n"
- "\n"
- "Returns the defined fields of C<*value*>.\n"
- "\n"
- "=item B<$hashref = $*value*-E<gt>to_hashref()>\n"
- "\n"
- "Exports the message to a hashref suitable for use in the\n"
- "C<copy_from> or C<merge_from> methods.\n"
- "\n");
-
- // Message field accessors
-
- for ( int i = 0; i < descriptor->field_count(); i++ ) {
- const FieldDescriptor* field = descriptor->field(i);
-
- vars["field"] = field->name();
- vars["type"] = PODFieldTypeString(field);
-
- // has_blah or blah_size methods
-
- if ( field->is_repeated() ) {
- printer.Print(vars,
- "=item B<$*field*_size = $*value*-E<gt>*field*_size()>\n"
- "\n"
- "Returns the number of C<*field*> elements present "
- "in C<*value*>.\n"
- "\n");
- } else {
- printer.Print(vars,
- "=item B<$has_*field* = $*value*-E<gt>has_*field*()>\n"
- "\n"
- "Returns 1 if the C<*field*> element of C<*value*> "
- "is set, 0 otherwise.\n"
- "\n");
- }
-
- // clear_blah method
-
- printer.Print(vars,
- "=item B<$*value*-E<gt>clear_*field*()>\n"
- "\n"
- "Clears the C<*field*> element(s) of C<*value*>.\n"
- "\n");
-
- // getters
-
- if ( field->is_repeated() ) {
- printer.Print(vars,
- "=item B<@*field*_list = $*value*-E<gt>*field*()>\n"
- "\n"
- "Returns all values of C<*field*> in an array. Each "
- "element of C<*field*_list> will be *type*.\n"
- "\n"
- "=item B<$*field*_elem = $*value*-E<gt>*field*($index)>\n"
- "\n"
- "Returns C<*field*> element C<index> from C<*value*>. "
- "C<*field*> will be *type*, unless C<index> is out of "
- "range, in which case it will be undef.\n"
- "\n");
- } else {
- printer.Print(vars,
- "=item B<$*field* = $*value*-E<gt>*field*()>\n"
- "\n"
- "Returns C<*field*> from C<*value*>. C<*field*> will "
- "be *type*.\n"
- "\n");
- }
-
- // setters
-
- if ( field->is_repeated() ) {
- printer.Print(vars,
- "=item B<$*value*-E<gt>add_*field*($value)>\n"
- "\n"
- "Adds C<value> to the list of C<*field*> in C<*value*>. "
- "C<value> must be *type*.\n"
- "\n");
- } else {
- printer.Print(vars,
- "=item B<$*value*-E<gt>set_*field*($value)>\n"
- "\n"
- "Sets the value of C<*field*> in C<*value*> to "
- "C<value>. C<value> must be *type*.\n"
- "\n");
- }
- }
-
- printer.Print("\n"
- "=back\n"
- "\n");
-}
-
-
-void
-PerlXSGenerator::GenerateEnumModule(const EnumDescriptor* enum_descriptor,
- OutputDirectory* outdir) const
-{
- TProtoStringType filename = enum_descriptor->name() + ".pm";
- std::unique_ptr<io::ZeroCopyOutputStream> output(outdir->Open(filename));
- io::Printer printer(output.get(), '*'); // '*' works well in the .pm file
-
- std::map<TProtoStringType, TProtoStringType> vars;
-
- vars["package"] = EnumClassName(enum_descriptor);
- vars["enum"] = enum_descriptor->full_name();
-
- printer.Print(vars,
- "package *package*;\n"
- "\n"
- "use strict;\n"
- "use warnings;\n"
- "\n");
-
- // Each enum value is exported as a constant.
-
- for ( int i = 0; i < enum_descriptor->value_count(); i++ ) {
- std::ostringstream ost;
- ost << enum_descriptor->value(i)->number();
- printer.Print("use constant *value* => *number*;\n",
- "value", enum_descriptor->value(i)->name(),
- "number", ost.str().c_str());
- }
-
- printer.Print("\n"
- "1;\n"
- "\n"
- "__END__\n"
- "\n");
-
- // Now generate POD for the enum.
-
- printer.Print(vars,
- "=pod\n"
- "\n"
- "=head1 NAME\n"
- "\n"
- "*package* - Perl interface to *enum*\n"
- "\n"
- "=head1 SYNOPSIS\n"
- "\n"
- " use *package*;\n"
- "\n");
-
- for ( int i = 0; i < enum_descriptor->value_count(); i++ ) {
- printer.Print(" my $*value* = *package*::*value*;\n",
- "package", vars["package"],
- "value", enum_descriptor->value(i)->name());
- }
-
- printer.Print(vars,
- "\n"
- "=head1 DESCRIPTION\n"
- "\n"
- "*package* defines the following constants:\n"
- "\n"
- "=over 4\n"
- "\n");
-
- for ( int i = 0; i < enum_descriptor->value_count(); i++ ) {
- PODPrintEnumValue(enum_descriptor->value(i), printer);
- }
-
- printer.Print(vars,
- "\n"
- "=back\n"
- "\n"
- "=head1 AUTHOR\n"
- "\n"
- "Generated from *enum* by the protoc compiler.\n"
- "\n"
- "=head1 SEE ALSO\n"
- "\n"
- "http://code.google.com/p/protobuf\n"
- "\n"
- "=cut\n"
- "\n");
-}
-
-
-void
-PerlXSGenerator::GenerateFileXSTypedefs(const FileDescriptor* file,
- io::Printer& printer,
- std::set<const Descriptor*>& seen) const
-{
- for ( int i = 0; i < file->dependency_count(); i++ ) {
- GenerateFileXSTypedefs(file->dependency(i), printer, seen);
- }
-
- for ( int i = 0; i < file->message_type_count(); i++ ) {
- GenerateMessageXSTypedefs(file->message_type(i), printer, seen);
- }
-}
-
-
-void
-PerlXSGenerator::GenerateMessageXSTypedefs(const Descriptor* descriptor,
- io::Printer& printer,
- std::set<const Descriptor*>& seen) const
-{
- for ( int i = 0; i < descriptor->nested_type_count(); i++ ) {
- GenerateMessageXSTypedefs(descriptor->nested_type(i), printer, seen);
- }
-
- if ( seen.find(descriptor) == seen.end() ) {
- TProtoStringType cn = cpp::ClassName(descriptor, true);
- TProtoStringType un = StringReplace(cn, "::", "__", true);
-
- seen.insert(descriptor);
- printer.Print("typedef $classname$ $underscores$;\n",
- "classname", cn,
- "underscores", un);
- }
-}
-
-
-void
-PerlXSGenerator::GenerateMessageStatics(const Descriptor* descriptor,
- io::Printer& printer) const
-{
- for ( int i = 0; i < descriptor->nested_type_count(); i++ ) {
- GenerateMessageStatics(descriptor->nested_type(i), printer);
- }
-
- std::map<TProtoStringType, TProtoStringType> vars;
-
- TProtoStringType cn = cpp::ClassName(descriptor, true);
- TProtoStringType un = StringReplace(cn, "::", "__", true);
-
- vars["depth"] = "0";
- vars["fieldtype"] = cn;
- vars["classname"] = cn;
- vars["underscores"] = un;
-
- // from_hashref static helper
-
- printer.Print(vars,
- "static $classname$ *\n"
- "$underscores$_from_hashref ( SV * sv0 )\n"
- "{\n"
- " $fieldtype$ * msg$depth$ = new $fieldtype$;\n"
- "\n");
-
- printer.Indent();
- MessageFromHashref(descriptor, printer, vars, 0);
- printer.Outdent();
-
- printer.Print("\n"
- " return msg0;\n"
- "}\n"
- "\n");
-}
-
-
-void
-PerlXSGenerator::GenerateMessageXSFieldAccessors(const FieldDescriptor* field,
- io::Printer& printer,
- const TProtoStringType& classname) const
-{
- const Descriptor* descriptor = field->containing_type();
- TProtoStringType cppname = cpp::FieldName(field);
- TProtoStringType perlclass = MessageClassName(descriptor);
- bool repeated = field->is_repeated();
-
- std::map<TProtoStringType, TProtoStringType> vars;
-
- vars["classname"] = classname;
- vars["cppname"] = cppname;
- vars["perlname"] = field->name();
- vars["perlclass"] = perlclass;
-
- FieldDescriptor::CppType fieldtype = field->cpp_type();
- FieldDescriptor::Type type = field->type();
-
- if ( fieldtype == FieldDescriptor::CPPTYPE_MESSAGE ) {
- vars["fieldtype"] = cpp::ClassName(field->message_type(), true);
- vars["fieldclass"] = MessageClassName(field->message_type());
- }
-
- // For repeated fields, we need an index argument.
-
- if ( repeated ) {
- vars["i"] = "index";
- } else {
- vars["i"] = "";
- }
-
- // -------------------------------------------------------------------
- // First, the has_X method or X_size method.
- // -------------------------------------------------------------------
-
- if ( repeated ) {
- printer.Print(vars,
- "I32\n"
- "$perlname$_size(svTHIS)\n"
- " SV * svTHIS;\n"
- " CODE:\n");
- GenerateTypemapInput(descriptor, printer, "THIS");
- printer.Print(vars,
- " RETVAL = THIS->$cppname$_size();\n"
- "\n"
- " OUTPUT:\n"
- " RETVAL\n");
- } else if ( HasHasMethod(field) ) {
- printer.Print(vars,
- "I32\n"
- "has_$perlname$(svTHIS)\n"
- " SV * svTHIS;\n"
- " CODE:\n");
- GenerateTypemapInput(descriptor, printer, "THIS");
- printer.Print(vars,
- " RETVAL = THIS->has_$cppname$();\n"
- "\n"
- " OUTPUT:\n"
- " RETVAL\n");
- }
-
- printer.Print("\n\n");
-
- // -------------------------------------------------------------------
- // Next, the "clear" method.
- // -------------------------------------------------------------------
-
- printer.Print(vars,
- "void\n"
- "clear_$perlname$(svTHIS)\n"
- " SV * svTHIS;\n"
- " CODE:\n");
- GenerateTypemapInput(descriptor, printer, "THIS");
- printer.Print(vars,
- " THIS->clear_$cppname$();\n"
- "\n"
- "\n");
-
- // -------------------------------------------------------------------
- // Next, the "get" method.
- // -------------------------------------------------------------------
-
- // Repeated fields have an optional index argument.
-
- if ( repeated ) {
- printer.Print(vars,
- "void\n"
- "$perlname$(svTHIS, ...)\n");
- } else {
- printer.Print(vars,
- "void\n"
- "$perlname$(svTHIS)\n");
- }
-
- printer.Print(" SV * svTHIS;\n"
- "PREINIT:\n"
- " SV * sv;\n");
-
- if ( repeated ) {
- printer.Print(" int index = 0;\n");
- }
-
- // We need to store 64-bit integers as strings in Perl.
-
- if ( fieldtype == FieldDescriptor::CPPTYPE_INT64 ||
- fieldtype == FieldDescriptor::CPPTYPE_UINT64 ) {
- printer.Print(" std::ostringstream ost;\n");
- }
-
- if ( fieldtype == FieldDescriptor::CPPTYPE_MESSAGE ) {
- printer.Print(vars,
- " $fieldtype$ * val = NULL;\n");
- }
-
- // We'll use PPCODE in either case, just to make this a little
- // simpler.
-
- printer.Print("\n"
- " PPCODE:\n");
-
- GenerateTypemapInput(descriptor, printer, "THIS");
-
- // For repeated fields, we need to check the usage ourselves.
-
- if ( repeated ) {
- printer.Print(vars,
- " if ( items == 2 ) {\n"
- " index = SvIV(ST(1));\n"
- " } else if ( items > 2 ) {\n"
- " croak(\"Usage: $perlclass$::$perlname$(CLASS, [index])\");\n"
- " }\n");
- }
-
- // There are three possibilities now:
- //
- // 1) The user wants a particular element of a repeated field.
- // 2) The user wants all elements of a repeated field.
- // 3) The user wants the value of a non-repeated field.
-
- if ( repeated ) {
- printer.Print(vars,
- " if ( THIS != NULL ) {\n"
- " if ( items == 1 ) {\n"
- " int count = THIS->$cppname$_size();\n"
- "\n"
- " EXTEND(SP, count);\n"
- " for ( int index = 0; index < count; index++ ) {\n");
- PerlSVGetHelper(printer,vars,fieldtype,5);
- printer.Print(vars,
- " PUSHs(sv);\n"
- " }\n"
- " } else if ( index >= 0 &&\n"
- " index < THIS->$cppname$_size() ) {\n"
- " EXTEND(SP,1);\n");
- PerlSVGetHelper(printer,vars,fieldtype,4);
- printer.Print(" PUSHs(sv);\n"
- " } else {\n"
- " EXTEND(SP,1);\n"
- " PUSHs(&PL_sv_undef);\n"
- " }\n"
- " }\n");
- } else {
- printer.Print(" if ( THIS != NULL ) {\n"
- " EXTEND(SP,1);\n");
- PerlSVGetHelper(printer,vars,fieldtype,3);
- printer.Print(" PUSHs(sv);\n"
- " }\n");
- }
-
- printer.Print("\n\n");
-
- // -------------------------------------------------------------------
- // Finally, the "set" method.
- // -------------------------------------------------------------------
-
- if ( repeated ) {
- printer.Print(vars,
- "void\n"
- "add_$perlname$(svTHIS, svVAL)\n");
- } else {
- printer.Print(vars,
- "void\n"
- "set_$perlname$(svTHIS, svVAL)\n");
- }
-
- printer.Print(" SV * svTHIS\n");
-
- // What is the incoming type?
-
- switch ( fieldtype ) {
- case FieldDescriptor::CPPTYPE_ENUM:
- vars["etype"] = cpp::ClassName(field->enum_type(), true);
- // Fall through
- case FieldDescriptor::CPPTYPE_INT32:
- case FieldDescriptor::CPPTYPE_BOOL:
- vars["value"] = "svVAL";
- printer.Print(" IV svVAL\n"
- "\n"
- " CODE:\n");
- break;
- case FieldDescriptor::CPPTYPE_UINT32:
- vars["value"] = "svVAL";
- printer.Print(" UV svVAL\n"
- "\n"
- " CODE:\n");
- break;
- case FieldDescriptor::CPPTYPE_FLOAT:
- case FieldDescriptor::CPPTYPE_DOUBLE:
- vars["value"] = "svVAL";
- printer.Print(" NV svVAL\n"
- "\n"
- " CODE:\n");
- break;
- case FieldDescriptor::CPPTYPE_INT64:
- vars["value"] = "lval";
- printer.Print(" char *svVAL\n"
- "\n"
- " PREINIT:\n"
- " long long lval;\n"
- "\n"
- " CODE:\n"
- " lval = strtoll((svVAL) ? svVAL : \"\", NULL, 0);\n");
- break;
- case FieldDescriptor::CPPTYPE_UINT64:
- vars["value"] = "lval";
- printer.Print(" char *svVAL\n"
- "\n"
- " PREINIT:\n"
- " unsigned long long lval;\n"
- "\n"
- " CODE:\n"
- " lval = strtoull((svVAL) ? svVAL : \"\", NULL, 0);\n");
- break;
- case FieldDescriptor::CPPTYPE_STRING:
- vars["value"] = "sval";
- printer.Print(" SV *svVAL\n"
- "\n"
- " PREINIT:\n"
- " char * str;\n"
- " STRLEN len;\n");
- if ( type == FieldDescriptor::TYPE_STRING ) {
- printer.Print(vars,
- " TString $value$;\n");
- }
- printer.Print("\n"
- " CODE:\n");
- break;
- case FieldDescriptor::CPPTYPE_MESSAGE:
- printer.Print(vars,
- " SV * svVAL\n"
- " CODE:\n");
- break;
- default:
- vars["value"] = "svVAL";
- break;
- }
-
- GenerateTypemapInput(descriptor, printer, "THIS");
-
- if ( fieldtype == FieldDescriptor::CPPTYPE_MESSAGE ) {
- GenerateTypemapInput(field->message_type(), printer, "VAL");
- }
-
- if ( repeated ) {
- if ( fieldtype == FieldDescriptor::CPPTYPE_MESSAGE ) {
- printer.Print(vars,
- " if ( VAL != NULL ) {\n"
- " $fieldtype$ * mval = THIS->add_$cppname$();\n"
- " mval->CopyFrom(*VAL);\n"
- " }\n");
- } else if ( fieldtype == FieldDescriptor::CPPTYPE_ENUM ) {
- printer.Print(vars,
- " if ( $etype$_IsValid(svVAL) ) {\n"
- " THIS->add_$cppname$(($etype$)svVAL);\n"
- " }\n");
- } else if ( fieldtype == FieldDescriptor::CPPTYPE_STRING ) {
- printer.Print(" str = SvPV(svVAL, len);\n");
- if ( type == FieldDescriptor::TYPE_BYTES ) {
- printer.Print(vars,
- " THIS->add_$cppname$(str, len);\n");
- } else if ( type == FieldDescriptor::TYPE_STRING ) {
- printer.Print(vars,
- " $value$.assign(str, len);\n"
- " THIS->add_$cppname$($value$);\n");
- }
- } else {
- printer.Print(vars,
- " THIS->add_$cppname$($value$);\n");
- }
- } else {
- if ( fieldtype == FieldDescriptor::CPPTYPE_MESSAGE ) {
- printer.Print(vars,
- " if ( VAL != NULL ) {\n"
- " $fieldtype$ * mval = THIS->mutable_$cppname$();\n"
- " mval->CopyFrom(*VAL);\n"
- " }\n");
- } else if ( fieldtype == FieldDescriptor::CPPTYPE_ENUM ) {
- printer.Print(vars,
- " if ( $etype$_IsValid(svVAL) ) {\n"
- " THIS->set_$cppname$(($etype$)svVAL);\n"
- " }\n");
- } else if ( fieldtype == FieldDescriptor::CPPTYPE_STRING ) {
- printer.Print(" str = SvPV(svVAL, len);\n");
- if ( type == FieldDescriptor::TYPE_STRING ) {
- printer.Print(vars,
- " sval.assign(str, len);\n"
- " THIS->set_$cppname$($value$);\n");
- } else if ( type == FieldDescriptor::TYPE_BYTES ) {
- printer.Print(vars,
- " THIS->set_$cppname$(str, len);\n");
- } else {
- // Can't get here
- }
- } else {
- printer.Print(vars,
- " THIS->set_$cppname$($value$);\n");
- }
- }
-
- printer.Print("\n\n");
-}
-
-
-void
-PerlXSGenerator::GenerateMessageXSCommonMethods(const Descriptor* descriptor,
- io::Printer& printer,
- const TProtoStringType& classname) const
-{
- std::map<TProtoStringType, TProtoStringType> vars;
-#if (GOOGLE_PROTOBUF_VERSION >= 2002000)
- FileOptions::OptimizeMode mode;
-#endif // GOOGLE_PROTOBUF_VERSION
- TProtoStringType cn = cpp::ClassName(descriptor, true);
- TProtoStringType un = StringReplace(cn, "::", "__", true);
-
-#if (GOOGLE_PROTOBUF_VERSION >= 2002000)
- mode = descriptor->file()->options().optimize_for();
-#endif // GOOGLE_PROTOBUF_VERSION
-
- vars["classname"] = classname;
- vars["perlclass"] = MessageClassName(descriptor);
- vars["underscores"] = un;
-
- // copy_from
-
- printer.Print(vars,
- "void\n"
- "copy_from(svTHIS, sv)\n"
- " SV * svTHIS\n"
- " SV * sv\n"
- " CODE:\n");
- GenerateTypemapInput(descriptor, printer, "THIS");
- printer.Print(vars,
- " if ( THIS != NULL && sv != NULL ) {\n"
- " if ( sv_derived_from(sv, \"$perlclass$\") ) {\n"
- " IV tmp = SvIV((SV *)SvRV(sv));\n"
- " $classname$ * other = "
- "INT2PTR($underscores$ *, tmp);\n"
- "\n"
- " THIS->CopyFrom(*other);\n"
- " } else if ( SvROK(sv) &&\n"
- " SvTYPE(SvRV(sv)) == SVt_PVHV ) {\n"
- " $classname$ * other = "
- "$underscores$_from_hashref(sv);\n"
- " THIS->CopyFrom(*other);\n"
- " delete other;\n"
- " }\n"
- " }\n"
- "\n"
- "\n");
-
- // merge_from
-
- printer.Print(vars,
- "void\n"
- "merge_from(svTHIS, sv)\n"
- " SV * svTHIS\n"
- " SV * sv\n"
- " CODE:\n");
- GenerateTypemapInput(descriptor, printer, "THIS");
- printer.Print(vars,
- " if ( THIS != NULL && sv != NULL ) {\n"
- " if ( sv_derived_from(sv, \"$perlclass$\") ) {\n"
- " IV tmp = SvIV((SV *)SvRV(sv));\n"
- " $classname$ * other = "
- "INT2PTR($underscores$ *, tmp);\n"
- "\n"
- " THIS->MergeFrom(*other);\n"
- " } else if ( SvROK(sv) &&\n"
- " SvTYPE(SvRV(sv)) == SVt_PVHV ) {\n"
- " $classname$ * other = "
- "$underscores$_from_hashref(sv);\n"
- " THIS->MergeFrom(*other);\n"
- " delete other;\n"
- " }\n"
- " }\n"
- "\n"
- "\n");
-
- // clear
-
- printer.Print(vars,
- "void\n"
- "clear(svTHIS)\n"
- " SV * svTHIS\n"
- " CODE:\n");
- GenerateTypemapInput(descriptor, printer, "THIS");
- printer.Print(vars,
- " if ( THIS != NULL ) {\n"
- " THIS->Clear();\n"
- " }\n"
- "\n"
- "\n");
-
- // is_initialized
-
- printer.Print(vars,
- "int\n"
- "is_initialized(svTHIS)\n"
- " SV * svTHIS\n"
- " CODE:\n");
- GenerateTypemapInput(descriptor, printer, "THIS");
- printer.Print(vars,
- " if ( THIS != NULL ) {\n"
- " RETVAL = THIS->IsInitialized();\n"
- " } else {\n"
- " RETVAL = 0;\n"
- " }\n"
- "\n"
- " OUTPUT:\n"
- " RETVAL\n"
- "\n"
- "\n");
-
- // error_string
-
- printer.Print(vars,
- "SV *\n"
- "error_string(svTHIS)\n"
- " SV * svTHIS\n"
- " PREINIT:\n"
- " TString estr;\n"
- "\n"
- " CODE:\n");
- GenerateTypemapInput(descriptor, printer, "THIS");
- printer.Print(vars,
- " if ( THIS != NULL ) {\n"
- " estr = THIS->InitializationErrorString();\n"
- " }\n"
- " RETVAL = newSVpv(estr.c_str(), estr.length());\n"
- "\n"
- " OUTPUT:\n"
- " RETVAL\n"
- "\n"
- "\n");
-
- // LITE_RUNTIME does not include certain methods.
-
-#if (GOOGLE_PROTOBUF_VERSION >= 2002000)
- if (mode != FileOptions::LITE_RUNTIME) {
-#endif // GOOGLE_PROTOBUF_VERSION
-
- // discard_unknown_fields
-
- printer.Print(vars,
- "void\n"
- "discard_unkown_fields(svTHIS)\n"
- " SV * svTHIS\n"
- " CODE:\n");
- GenerateTypemapInput(descriptor, printer, "THIS");
- printer.Print(vars,
- " if ( THIS != NULL ) {\n"
- " THIS->DiscardUnknownFields();\n"
- " }\n"
- "\n"
- "\n");
-
- // debug_string
-
- printer.Print(vars,
- "SV *\n"
- "debug_string(svTHIS)\n"
- " SV * svTHIS\n"
- " PREINIT:\n"
- " TString dstr;\n"
- "\n"
- " CODE:\n");
- GenerateTypemapInput(descriptor, printer, "THIS");
- printer.Print(vars,
- " if ( THIS != NULL ) {\n"
- " dstr = THIS->DebugString();\n"
- " }\n"
- " RETVAL = newSVpv(dstr.c_str(), dstr.length());\n"
- "\n"
- " OUTPUT:\n"
- " RETVAL\n"
- "\n"
- "\n");
-
- // short_debug_string
-
- printer.Print(vars,
- "SV *\n"
- "short_debug_string(svTHIS)\n"
- " SV * svTHIS\n"
- " PREINIT:\n"
- " TString dstr;\n"
- "\n"
- " CODE:\n");
- GenerateTypemapInput(descriptor, printer, "THIS");
- printer.Print(vars,
- " if ( THIS != NULL ) {\n"
- " dstr = THIS->ShortDebugString();\n"
- " }\n"
- " RETVAL = newSVpv(dstr.c_str(), dstr.length());\n"
- "\n"
- " OUTPUT:\n"
- " RETVAL\n"
- "\n"
- "\n");
-#if (GOOGLE_PROTOBUF_VERSION >= 2002000)
- }
-#endif // GOOGLE_PROTOBUF_VERSION
-
- // unpack
-
- printer.Print(vars,
- "int\n"
- "unpack(svTHIS, arg)\n"
- " SV * svTHIS\n"
- " SV * arg\n"
- " PREINIT:\n"
- " STRLEN len;\n"
- " char * str;\n"
- "\n"
- " CODE:\n");
- GenerateTypemapInput(descriptor, printer, "THIS");
- printer.Print(vars,
- " if ( THIS != NULL ) {\n"
- " str = SvPV(arg, len);\n"
- " if ( str != NULL ) {\n"
- " RETVAL = THIS->ParseFromArray(str, len);\n"
- " } else {\n"
- " RETVAL = 0;\n"
- " }\n"
- " } else {\n"
- " RETVAL = 0;\n"
- " }\n"
- "\n"
- " OUTPUT:\n"
- " RETVAL\n"
- "\n"
- "\n");
-
- // pack
-
- printer.Print(vars,
- "SV *\n"
- "pack(svTHIS)\n"
- " SV * svTHIS\n");
-
- // This may be controlled by a custom option at some point.
-#if NO_ZERO_COPY
- printer.Print(vars,
- " PREINIT:\n"
- " TProtoStringType output;\n"
- "\n");
-#endif
-
- printer.Print(vars,
- " CODE:\n");
- GenerateTypemapInput(descriptor, printer, "THIS");
- printer.Print(vars,
- " if ( THIS != NULL ) {\n");
-
- vars["base"] = cpp::StripProto(descriptor->file()->name());
-
- printer.Print(vars,
- " RETVAL = newSVpvn(\"\", 0);\n"
- " $base$_OutputStream os(RETVAL);\n"
- " if ( THIS->IsInitialized() ) {\n"
- " if ( THIS->SerializePartialToZeroCopyStream(&os)"
- "!= true ) {\n"
- " SvREFCNT_dec(RETVAL);\n"
- " RETVAL = Nullsv;\n"
- " } else {\n"
- " os.Sync();\n"
- " }\n"
- " } else {\n"
- " croak(\"Can't serialize message of type "
- "'$perlclass$' because it is missing required fields: %s\",\n"
- " THIS->InitializationErrorString().c_str());\n"
- " }\n");
-
- printer.Print(vars,
- " } else {\n"
- " RETVAL = Nullsv;\n"
- " }\n"
- "\n"
- " OUTPUT:\n"
- " RETVAL\n"
- "\n"
- "\n");
-
- // length
-
- printer.Print(vars,
- "int\n"
- "length(svTHIS)\n"
- " SV * svTHIS\n"
- " CODE:\n");
- GenerateTypemapInput(descriptor, printer, "THIS");
- printer.Print(vars,
- " if ( THIS != NULL ) {\n"
- " RETVAL = THIS->ByteSize();\n"
- " } else {\n"
- " RETVAL = 0;\n"
- " }\n"
- "\n"
- " OUTPUT:\n"
- " RETVAL\n"
- "\n"
- "\n");
-
- // fields
-
- std::ostringstream field_count;
-
- field_count << descriptor->field_count();
- vars["field_count"] = field_count.str();
- printer.Print(vars,
- "void\n"
- "fields(svTHIS)\n"
- " SV * svTHIS\n"
- " PPCODE:\n"
- " (void)svTHIS;\n"
- " EXTEND(SP, $field_count$);\n");
-
- for ( int i = 0; i < descriptor->field_count(); i++ ) {
- const FieldDescriptor* field = descriptor->field(i);
- vars["field"] = field->name();
- printer.Print(vars,
- " PUSHs(sv_2mortal(newSVpv(\"$field$\",0)));\n"
- );
- }
-
- printer.Print("\n\n");
-
- // to_hashref
-
- printer.Print(vars,
- "SV *\n"
- "to_hashref(svTHIS)\n"
- " SV * svTHIS\n"
- " CODE:\n");
- GenerateTypemapInput(descriptor, printer, "THIS");
- printer.Print(vars,
- " if ( THIS != NULL ) {\n"
- " HV * hv0 = newHV();\n"
- " $classname$ * msg0 = THIS;\n"
- "\n");
-
- vars["depth"] = "0";
- vars["fieldtype"] = classname;
-
- printer.Indent();
- printer.Indent();
- printer.Indent();
- MessageToHashref(descriptor, printer, vars, 0);
- printer.Outdent();
- printer.Outdent();
- printer.Outdent();
-
- printer.Print(" RETVAL = newRV_noinc((SV *)hv0);\n"
- " } else {\n"
- " RETVAL = Nullsv;\n"
- " }\n"
- "\n"
- " OUTPUT:\n"
- " RETVAL\n"
- "\n"
- "\n");
-}
-
-void
-PerlXSGenerator::GenerateMessageXSPackage(const Descriptor* descriptor,
- io::Printer& printer) const
-{
- for ( int i = 0; i < descriptor->nested_type_count(); i++ ) {
- GenerateMessageXSPackage(descriptor->nested_type(i), printer);
- }
-
- std::map<TProtoStringType, TProtoStringType> vars;
-
- TProtoStringType cn = cpp::ClassName(descriptor, true);
- TProtoStringType mn = MessageModuleName(descriptor);
- TProtoStringType pn = MessageClassName(descriptor);
- TProtoStringType un = StringReplace(cn, "::", "__", true);
-
- vars["module"] = mn;
- vars["classname"] = cn;
- vars["package"] = pn;
- vars["underscores"] = un;
-
- printer.Print(vars,
- "MODULE = $module$ PACKAGE = $package$\n"
- "PROTOTYPES: ENABLE\n"
- "\n"
- "\n");
-
- // BOOT (if there are enum types)
-
- int enum_count = descriptor->enum_type_count();
-
- if ( enum_count > 0 ) {
- printer.Print("BOOT:\n"
- " {\n"
- " HV * stash;\n\n");
-
- printer.Indent();
- printer.Indent();
- for ( int i = 0; i < enum_count; i++ ) {
- const EnumDescriptor * etype = descriptor->enum_type(i);
- int vcount = etype->value_count();
-
- printer.Print("stash = gv_stashpv(\"$package$::$name$\", TRUE);\n",
- "package", pn,
- "name", etype->name());
- for ( int j = 0; j < vcount; j++ ) {
- const EnumValueDescriptor * vdesc = etype->value(j);
- printer.Print(
- "newCONSTSUB(stash, \"$name$\", newSViv($classname$::$name$));\n",
- "classname", cn,
- "name", vdesc->name()
- );
- }
- }
- printer.Outdent();
- printer.Outdent();
- printer.Print(" }\n\n\n");
- }
-
- // Constructor
-
- printer.Print(vars,
- "SV *\n"
- "$classname$::new (...)\n"
- " PREINIT:\n"
- " $classname$ * rv = NULL;\n"
- "\n"
- " CODE:\n"
- " if ( strcmp(CLASS,\"$package$\") ) {\n"
- " croak(\"invalid class %s\",CLASS);\n"
- " }\n"
- " if ( items == 2 && ST(1) != Nullsv ) {\n"
- " if ( SvROK(ST(1)) && "
- "SvTYPE(SvRV(ST(1))) == SVt_PVHV ) {\n"
- " rv = $underscores$_from_hashref(ST(1));\n"
- " } else {\n"
- " STRLEN len;\n"
- " char * str;\n"
- "\n"
- " rv = new $classname$;\n"
- " str = SvPV(ST(1), len);\n"
- " if ( str != NULL ) {\n"
- " rv->ParseFromArray(str, len);\n"
- " }\n"
- " }\n"
- " } else {\n"
- " rv = new $classname$;\n"
- " }\n"
- " RETVAL = newSV(0);\n"
- " sv_setref_pv(RETVAL, \"$package$\", (void *)rv);\n"
- "\n"
- " OUTPUT:\n"
- " RETVAL\n"
- "\n"
- "\n");
-
- // Destructor
-
- printer.Print(vars,
- "void\n"
- "DESTROY(svTHIS)\n"
- " SV * svTHIS;\n"
- " CODE:\n");
- GenerateTypemapInput(descriptor, printer, "THIS");
- printer.Print(" if ( THIS != NULL ) {\n"
- " delete THIS;\n"
- " }\n"
- "\n"
- "\n");
-
- // Message methods (copy_from, parse_from, etc).
-
- GenerateMessageXSCommonMethods(descriptor, printer, cn);
-
- // Field accessors
-
- for ( int i = 0; i < descriptor->field_count(); i++ ) {
- GenerateMessageXSFieldAccessors(descriptor->field(i), printer, cn);
- }
-}
-
-
-void
-PerlXSGenerator::GenerateTypemapInput(const Descriptor* descriptor,
- io::Printer& printer,
- const TProtoStringType& svname) const
-{
- std::map<TProtoStringType, TProtoStringType> vars;
-
- TProtoStringType cn = cpp::ClassName(descriptor, true);
-
- vars["classname"] = cn;
- vars["perlclass"] = MessageClassName(descriptor);
- vars["underscores"] = StringReplace(cn, "::", "__", true);
- vars["svname"] = svname;
-
- printer.Print(vars,
- " $classname$ * $svname$;\n"
- " if ( sv_derived_from(sv$svname$, \"$perlclass$\") ) {\n"
- " IV tmp = SvIV((SV *)SvRV(sv$svname$));\n"
- " $svname$ = INT2PTR($underscores$ *, tmp);\n"
- " } else {\n"
- " croak(\"$svname$ is not of type $perlclass$\");\n"
- " }\n");
-}
-
-// Returns the containing Perl module name for a message descriptor.
-
-TProtoStringType
-PerlXSGenerator::MessageModuleName(const Descriptor* descriptor) const
-{
- const Descriptor *container = descriptor;
-
- while (container->containing_type() != NULL) {
- container = container->containing_type();
- }
-
- return MessageClassName(container);
-}
-
-// Returns the Perl class name for a message descriptor.
-
-TProtoStringType
-PerlXSGenerator::MessageClassName(const Descriptor* descriptor) const
-{
- return PackageName(descriptor->full_name(), descriptor->file()->package());
-}
-
-// Returns the Perl class name for a message descriptor.
-
-TProtoStringType
-PerlXSGenerator::EnumClassName(const EnumDescriptor* descriptor) const
-{
- return PackageName(descriptor->full_name(), descriptor->file()->package());
-}
-
-// Possibly replace the package prefix with the --perlxs-package value
-
-TProtoStringType
-PerlXSGenerator::PackageName(const TProtoStringType& name, const TProtoStringType& package) const
-{
- TProtoStringType output;
-
- if (!perlxs_package_.empty()) {
- output = StringReplace(name, package.c_str(), perlxs_package_.c_str(), false);
- output = StringReplace(output, ".", "::", true);
- } else {
- output = StringReplace(name, ".", "::", true);
- }
-
- return output;
-}
-
-void
-PerlXSGenerator::PerlSVGetHelper(io::Printer& printer,
- const std::map<TProtoStringType, TProtoStringType>& vars,
- FieldDescriptor::CppType fieldtype,
- int depth) const
-{
- for ( int i = 0; i < depth; i++ ) {
- printer.Indent();
- }
-
- switch ( fieldtype ) {
- case FieldDescriptor::CPPTYPE_INT32:
- case FieldDescriptor::CPPTYPE_BOOL:
- case FieldDescriptor::CPPTYPE_ENUM:
- printer.Print(vars,
- "sv = sv_2mortal(newSViv(THIS->$cppname$($i$)));\n");
- break;
- case FieldDescriptor::CPPTYPE_UINT32:
- printer.Print(vars,
- "sv = sv_2mortal(newSVuv(THIS->$cppname$($i$)));\n");
- break;
- case FieldDescriptor::CPPTYPE_FLOAT:
- case FieldDescriptor::CPPTYPE_DOUBLE:
- printer.Print(vars,
- "sv = sv_2mortal(newSVnv(THIS->$cppname$($i$)));\n");
- break;
- case FieldDescriptor::CPPTYPE_INT64:
- case FieldDescriptor::CPPTYPE_UINT64:
- printer.Print(vars,
- "ost.str(\"\");\n"
- "ost << THIS->$cppname$($i$);\n"
- "sv = sv_2mortal(newSVpv(ost.str().c_str(),\n"
- " ost.str().length()));\n");
- break;
- case FieldDescriptor::CPPTYPE_STRING:
- printer.Print(vars,
- "sv = sv_2mortal(newSVpv(THIS->$cppname$($i$).c_str(),\n"
- " "
- "THIS->$cppname$($i$).length()));\n");
- break;
- case FieldDescriptor::CPPTYPE_MESSAGE:
- printer.Print(vars,
- "val = new $fieldtype$;\n"
- "val->CopyFrom(THIS->$cppname$($i$));\n"
- "sv = sv_newmortal();\n"
- "sv_setref_pv(sv, \"$fieldclass$\", (void *)val);\n");
- break;
- default:
- printer.Print("sv = &PL_sv_undef;\n");
- break;
- }
-
- for ( int i = 0; i < depth; i++ ) {
- printer.Outdent();
- }
-}
-
-void
-PerlXSGenerator::PODPrintEnumValue(const EnumValueDescriptor *value,
- io::Printer& printer) const
-{
- std::ostringstream ost;
- printer.Print("=item B<*value*>\n"
- "\n",
- "value", value->name());
- ost << value->number();
- printer.Print("This constant has a value of *number*.\n"
- "\n",
- "number", ost.str().c_str());
-}
-
-TProtoStringType
-PerlXSGenerator::PODFieldTypeString(const FieldDescriptor* field) const
-{
- TProtoStringType type;
-
- switch ( field->cpp_type() ) {
- case FieldDescriptor::CPPTYPE_INT32:
- type = "a 32-bit signed integer";
- break;
- case FieldDescriptor::CPPTYPE_BOOL:
- type = "a Boolean value";
- break;
- case FieldDescriptor::CPPTYPE_ENUM:
- type = "a value of " + EnumClassName(field->enum_type());
- break;
- case FieldDescriptor::CPPTYPE_UINT32:
- type = "a 32-bit unsigned integer";
- break;
- case FieldDescriptor::CPPTYPE_FLOAT:
- case FieldDescriptor::CPPTYPE_DOUBLE:
- type = "a floating point number";
- break;
- case FieldDescriptor::CPPTYPE_INT64:
- type = "a 64-bit signed integer";
- break;
- case FieldDescriptor::CPPTYPE_UINT64:
- type = "a 64-bit unsigned integer";
- break;
- case FieldDescriptor::CPPTYPE_STRING:
- type = "a TProtoStringType";
- break;
- case FieldDescriptor::CPPTYPE_MESSAGE:
- type = "an instance of " + MessageClassName(field->message_type());
- break;
- default:
- type = "an unknown type";
- break;
- }
-
- return type;
-}
-
-void
-PerlXSGenerator::StartFieldToHashref(const FieldDescriptor * field,
- io::Printer& printer,
- std::map<TProtoStringType, TProtoStringType>& vars,
- int depth) const
-{
- SetupDepthVars(vars, depth);
-
- if ( field->is_repeated() ) {
- vars["i"] = "i" + vars["pdepth"];
- printer.Print(vars,
- "if ( msg$pdepth$->$cppname$_size() > 0 ) {\n");
- printer.Indent();
- printer.Print(vars,
- "AV * av$pdepth$ = newAV();\n"
- "SV * sv$pdepth$ = newRV_noinc((SV *)av$pdepth$);\n"
- "\n"
- "for ( int $i$ = 0; "
- "$i$ < msg$pdepth$->$cppname$_size(); $i$++ ) {\n");
- } else {
- vars["i"] = "";
- if ( HasHasMethod(field) ) {
- printer.Print(vars,
- "if ( msg$pdepth$->has_$cppname$() ) {\n");
- }
- else {
- printer.Print(vars,
- "{\n");
- }
- }
- printer.Indent();
-}
-
-void
-PerlXSGenerator::FieldToHashrefHelper(io::Printer& printer,
- std::map<TProtoStringType, TProtoStringType>& vars,
- const FieldDescriptor* field) const
-{
- vars["msg"] = "msg" + vars["pdepth"];
- if ( field->is_repeated() ) {
- vars["sv"] = "sv" + vars["depth"];
- } else {
- vars["sv"] = "sv" + vars["pdepth"];
- }
-
- switch ( field->cpp_type() ) {
- case FieldDescriptor::CPPTYPE_INT32:
- case FieldDescriptor::CPPTYPE_BOOL:
- case FieldDescriptor::CPPTYPE_ENUM:
- printer.Print(vars,
- "SV * $sv$ = newSViv($msg$->$cppname$($i$));\n");
- break;
- case FieldDescriptor::CPPTYPE_UINT32:
- printer.Print(vars,
- "SV * $sv$ = newSVuv($msg$->$cppname$($i$));\n");
- break;
- case FieldDescriptor::CPPTYPE_FLOAT:
- case FieldDescriptor::CPPTYPE_DOUBLE:
- printer.Print(vars,
- "SV * $sv$ = newSVnv($msg$->$cppname$($i$));\n");
- break;
- case FieldDescriptor::CPPTYPE_INT64:
- case FieldDescriptor::CPPTYPE_UINT64:
- printer.Print(vars,
- "std::ostringstream ost$pdepth$;\n"
- "\n"
- "ost$pdepth$ << $msg$->$cppname$($i$);\n"
- "SV * $sv$ = newSVpv(ost$pdepth$.str().c_str(),"
- " ost$pdepth$.str().length());\n");
- break;
- case FieldDescriptor::CPPTYPE_STRING:
- case FieldDescriptor::CPPTYPE_MESSAGE:
- default:
- printer.Print(vars,
- "SV * $sv$ = newSVpv($msg$->"
- "$cppname$($i$).c_str(), $msg$->"
- "$cppname$($i$).length());\n");
- break;
- }
-}
-
-void
-PerlXSGenerator::EndFieldToHashref(const FieldDescriptor * field,
- io::Printer& printer,
- std::map<TProtoStringType, TProtoStringType>& vars,
- int depth) const
-{
- vars["field"] = field->name();
-
- SetupDepthVars(vars, depth);
-
- if ( field->is_repeated() ) {
- printer.Print(vars,
- "av_push(av$pdepth$, sv$depth$);\n");
- printer.Outdent();
- printer.Print(vars,
- "}\n"
- "hv_store(hv$pdepth$, \"$field$\", "
- "sizeof(\"$field$\") - 1, sv$pdepth$, 0);\n");
- } else {
- if ( field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE ) {
- printer.Print(vars,
- "hv_store(hv$pdepth$, \"$field$\", "
- "sizeof(\"$field$\") - 1, sv$depth$, 0);\n");
- } else {
- printer.Print(vars,
- "hv_store(hv$pdepth$, \"$field$\", "
- "sizeof(\"$field$\") - 1, sv$pdepth$, 0);\n");
- }
- }
- printer.Outdent();
- printer.Print("}\n");
-}
-
-void
-PerlXSGenerator::MessageToHashref(const Descriptor * descriptor,
- io::Printer& printer,
- std::map<TProtoStringType, TProtoStringType>& vars,
- int depth) const
-{
- int i;
-
- // Iterate the fields
-
- for ( i = 0; i < descriptor->field_count(); i++ ) {
- const FieldDescriptor* field = descriptor->field(i);
- FieldDescriptor::CppType fieldtype = field->cpp_type();
-
- vars["field"] = field->name();
- vars["cppname"] = cpp::FieldName(field);
-
- StartFieldToHashref(field, printer, vars, depth);
-
- if ( fieldtype == FieldDescriptor::CPPTYPE_MESSAGE ) {
- vars["fieldtype"] = cpp::ClassName(field->message_type(), true);
- printer.Print(vars,
- "$fieldtype$ * msg$ndepth$ = msg$pdepth$->"
- "mutable_$cppname$($i$);\n"
- "HV * hv$ndepth$ = newHV();\n"
- "SV * sv$depth$ = newRV_noinc((SV *)hv$ndepth$);\n"
- "\n");
- MessageToHashref(field->message_type(), printer, vars, depth + 2);
- SetupDepthVars(vars, depth);
- } else {
- FieldToHashrefHelper(printer, vars, field);
- }
-
- EndFieldToHashref(field, printer, vars, depth);
- }
-}
-
-void
-PerlXSGenerator::FieldFromHashrefHelper(io::Printer& printer,
- std::map<TProtoStringType, TProtoStringType>& vars,
- const FieldDescriptor * field) const
-{
- vars["msg"] = "msg" + vars["pdepth"];
- vars["var"] = "*sv" + vars["depth"];
-
- if ( field->is_repeated() ) {
- vars["do"] = "add";
- } else {
- vars["do"] = "set";
- }
-
- switch ( field->cpp_type() ) {
- case FieldDescriptor::CPPTYPE_INT32:
- case FieldDescriptor::CPPTYPE_BOOL:
- printer.Print(vars,
- "$msg$->$do$_$cppname$(SvIV($var$));\n");
- break;
- case FieldDescriptor::CPPTYPE_ENUM:
- vars["etype"] = cpp::ClassName(field->enum_type(), true);
- printer.Print(vars,
- "$msg$->$do$_$cppname$"
- "(($etype$)SvIV($var$));\n");
- break;
- case FieldDescriptor::CPPTYPE_UINT32:
- printer.Print(vars,
- "$msg$->$do$_$cppname$(SvUV($var$));\n");
- break;
- case FieldDescriptor::CPPTYPE_FLOAT:
- case FieldDescriptor::CPPTYPE_DOUBLE:
- printer.Print(vars,
- "$msg$->$do$_$cppname$(SvNV($var$));\n");
- break;
- case FieldDescriptor::CPPTYPE_INT64:
- printer.Print(vars,
- "arc_i64 iv$pdepth$ = "
- "strtoll(SvPV_nolen($var$), NULL, 0);\n"
- "\n"
- "$msg$->$do$_$cppname$(iv$pdepth$);\n");
- break;
- case FieldDescriptor::CPPTYPE_UINT64:
- printer.Print(vars,
- "arc_ui64 uv$pdepth$ = "
- "strtoull(SvPV_nolen($var$), NULL, 0);\n"
- "\n"
- "$msg$->$do$_$cppname$(uv$pdepth$);\n");
- break;
- case FieldDescriptor::CPPTYPE_STRING:
- printer.Print("STRLEN len;\n"
- "char * str;\n");
-
- if ( field->type() == FieldDescriptor::TYPE_STRING ) {
- printer.Print("TString sval;\n");
- }
-
- printer.Print(vars,
- "\n"
- "str = SvPV($var$, len);\n");
-
- if ( field->type() == FieldDescriptor::TYPE_STRING ) {
- printer.Print(vars,
- "sval.assign(str, len);\n"
- "$msg$->$do$_$cppname$(sval);\n");
- } else if ( field->type() == FieldDescriptor::TYPE_BYTES ) {
- printer.Print(vars,
- "$msg$->$do$_$cppname$(str, len);\n");
- } else {
- // Can't get here
- }
- break;
- case FieldDescriptor::CPPTYPE_MESSAGE:
- // Should never get here.
- default:
- break;
- }
-}
-
-void
-PerlXSGenerator::MessageFromHashref(const Descriptor * descriptor,
- io::Printer& printer,
- std::map<TProtoStringType, TProtoStringType>& vars,
- int depth) const
-{
- int i;
-
- SetupDepthVars(vars, depth);
-
- printer.Print(vars,
- "if ( SvROK(sv$pdepth$) && "
- "SvTYPE(SvRV(sv$pdepth$)) == SVt_PVHV ) {\n");
- printer.Indent();
- printer.Print(vars,
- "HV * hv$pdepth$ = (HV *)SvRV(sv$pdepth$);\n"
- "SV ** sv$depth$;\n"
- "\n");
-
- // Iterate the fields
-
- for ( i = 0; i < descriptor->field_count(); i++ ) {
- const FieldDescriptor* field = descriptor->field(i);
-
- vars["field"] = field->name();
- vars["cppname"] = cpp::FieldName(field);
-
- if ( field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE ) {
- vars["fieldtype"] = cpp::ClassName(field->message_type(), true);
- }
-
- printer.Print(vars,
- "if ( (sv$depth$ = hv_fetch(hv$pdepth$, "
- "\"$field$\", sizeof(\"$field$\") - 1, 0)) != NULL ) {\n");
-
- printer.Indent();
-
- if ( field->is_repeated() ) {
- printer.Print(vars,
- "if ( SvROK(*sv$depth$) && "
- "SvTYPE(SvRV(*sv$depth$)) == SVt_PVAV ) {\n");
- printer.Indent();
- printer.Print(vars,
- "AV * av$depth$ = (AV *)SvRV(*sv$depth$);\n"
- "\n"
- "for ( int i$depth$ = 0; "
- "i$depth$ <= av_len(av$depth$); i$depth$++ ) {\n");
- printer.Indent();
-
- if ( field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE ) {
- printer.Print(vars,
- "$fieldtype$ * msg$ndepth$ = "
- "msg$pdepth$->add_$cppname$();\n"
- "SV ** sv$depth$;\n"
- "SV * sv$ndepth$;\n"
- "\n"
- "if ( (sv$depth$ = "
- "av_fetch(av$depth$, i$depth$, 0)) != NULL ) {\n"
- " sv$ndepth$ = *sv$depth$;\n");
- } else {
- printer.Print(vars,
- "SV ** sv$depth$;\n"
- "\n"
- "if ( (sv$depth$ = "
- "av_fetch(av$depth$, i$depth$, 0)) != NULL ) {\n");
- }
- printer.Indent();
- } else {
- if ( field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE ) {
- printer.Print(vars,
- "$fieldtype$ * msg$ndepth$ = "
- "msg$pdepth$->mutable_$cppname$();\n"
- "SV * sv$ndepth$ = *sv$depth$;\n"
- "\n");
- }
- }
-
- if ( field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE ) {
- MessageFromHashref(field->message_type(), printer, vars, depth + 2);
- SetupDepthVars(vars, depth);
- } else {
- FieldFromHashrefHelper(printer, vars, field);
- }
-
- if ( field->is_repeated() ) {
- printer.Outdent();
- printer.Print("}\n");
- printer.Outdent();
- printer.Print("}\n");
- printer.Outdent();
- printer.Print("}\n");
- }
-
- printer.Outdent();
- printer.Print("}\n");
- }
-
- printer.Outdent();
- printer.Print("}\n");
-}
-
-} // namespace perlxs
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/perlxs/perlxs_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/perlxs/perlxs_generator.h
deleted file mode 100644
index c29eac03e3..0000000000
--- a/contrib/libs/protoc/src/google/protobuf/compiler/perlxs/perlxs_generator.h
+++ /dev/null
@@ -1,153 +0,0 @@
-#ifndef GOOGLE_PROTOBUF_COMPILER_PERLXS_GENERATOR_H__
-#define GOOGLE_PROTOBUF_COMPILER_PERLXS_GENERATOR_H__
-
-#include <iostream>
-#include <vector>
-#include <map>
-#include <set>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/compiler/cpp/cpp_helpers.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/strutil.h>
-
-namespace google {
-namespace protobuf {
-
-class Descriptor;
-class EnumDescriptor;
-class EnumValueDescriptor;
-class FieldDescriptor;
-class ServiceDescriptor;
-
-namespace io { class Printer; }
-
-namespace compiler {
-namespace perlxs {
-
-// CodeGenerator implementation for generated Perl/XS protocol buffer
-// classes. If you create your own protocol compiler binary and you
-// want it to support Perl/XS output, you can do so by registering an
-// instance of this CodeGenerator with the CommandLineInterface in
-// your main() function.
-class LIBPROTOC_EXPORT PerlXSGenerator : public CodeGenerator {
- public:
- PerlXSGenerator();
- virtual ~PerlXSGenerator();
-
- // implements CodeGenerator ----------------------------------------
- virtual bool Generate(const FileDescriptor* file,
- const TProtoStringType& parameter,
- OutputDirectory* output_directory,
- TProtoStringType* error) const;
-
- bool ProcessOption(const TProtoStringType& option);
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PerlXSGenerator);
-
- private:
- void GenerateXS(const FileDescriptor* file,
- OutputDirectory* output_directory,
- TProtoStringType& base) const;
-
- void GenerateMessageXS(const Descriptor* descriptor,
- OutputDirectory* outdir) const;
-
- void GenerateMessageModule(const Descriptor* descriptor,
- OutputDirectory* outdir) const;
-
- void GenerateMessagePOD(const Descriptor* descriptor,
- OutputDirectory* outdir) const;
-
- void GenerateDescriptorClassNamePOD(const Descriptor* descriptor,
- io::Printer& printer) const;
-
- void GenerateDescriptorMethodPOD(const Descriptor* descriptor,
- io::Printer& printer) const;
-
- void GenerateEnumModule(const EnumDescriptor* enum_descriptor,
- OutputDirectory* outdir) const;
-
- void GenerateMessageXSFieldAccessors(const FieldDescriptor* field,
- io::Printer& printer,
- const TProtoStringType& classname) const;
-
- void GenerateMessageXSCommonMethods(const Descriptor* descriptor,
- io::Printer& printer,
- const TProtoStringType& classname) const;
-
- void GenerateFileXSTypedefs(const FileDescriptor* file,
- io::Printer& printer,
- std::set<const Descriptor*>& seen) const;
-
- void GenerateMessageXSTypedefs(const Descriptor* descriptor,
- io::Printer& printer,
- std::set<const Descriptor*>& seen) const;
-
- void GenerateMessageStatics(const Descriptor* descriptor,
- io::Printer& printer) const;
-
- void GenerateMessageXSPackage(const Descriptor* descriptor,
- io::Printer& printer) const;
-
- void GenerateTypemapInput(const Descriptor* descriptor,
- io::Printer& printer,
- const TProtoStringType& svname) const;
-
- TProtoStringType MessageModuleName(const Descriptor* descriptor) const;
-
- TProtoStringType MessageClassName(const Descriptor* descriptor) const;
-
- TProtoStringType EnumClassName(const EnumDescriptor* descriptor) const;
-
- TProtoStringType PackageName(const TProtoStringType& name, const TProtoStringType& package) const;
-
- void PerlSVGetHelper(io::Printer& printer,
- const std::map<TProtoStringType, TProtoStringType>& vars,
- FieldDescriptor::CppType fieldtype,
- int depth) const;
-
- void PODPrintEnumValue(const EnumValueDescriptor *value,
- io::Printer& printer) const;
-
- TProtoStringType PODFieldTypeString(const FieldDescriptor* field) const;
-
- void StartFieldToHashref(const FieldDescriptor * field,
- io::Printer& printer,
- std::map<TProtoStringType, TProtoStringType>& vars,
- int depth) const;
-
- void FieldToHashrefHelper(io::Printer& printer,
- std::map<TProtoStringType, TProtoStringType>& vars,
- const FieldDescriptor* field) const;
-
- void EndFieldToHashref(const FieldDescriptor * field,
- io::Printer& printer,
- std::map<TProtoStringType, TProtoStringType>& vars,
- int depth) const;
-
- void MessageToHashref(const Descriptor * descriptor,
- io::Printer& printer,
- std::map<TProtoStringType, TProtoStringType>& vars,
- int depth) const;
-
- void FieldFromHashrefHelper(io::Printer& printer,
- std::map<TProtoStringType, TProtoStringType>& vars,
- const FieldDescriptor * field) const;
-
- void MessageFromHashref(const Descriptor * descriptor,
- io::Printer& printer,
- std::map<TProtoStringType, TProtoStringType>& vars,
- int depth) const;
-
- private:
- // --perlxs-package option (if given)
- TProtoStringType perlxs_package_;
-};
-
-} // namespace perlxs
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-#endif // GOOGLE_PROTOBUF_COMPILER_PERLXS_GENERATOR_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/perlxs/perlxs_helpers.cc b/contrib/libs/protoc/src/google/protobuf/compiler/perlxs/perlxs_helpers.cc
deleted file mode 100644
index a1e5b5d340..0000000000
--- a/contrib/libs/protoc/src/google/protobuf/compiler/perlxs/perlxs_helpers.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <sstream>
-#include <vector>
-#include <google/protobuf/compiler/perlxs/perlxs_helpers.h>
-#include "google/protobuf/descriptor.pb.h"
-#include <google/protobuf/io/printer.h>
-
-namespace google {
-namespace protobuf {
-
-extern TProtoStringType StringReplace(const TProtoStringType& s, const TProtoStringType& oldsub,
- const TProtoStringType& newsub, bool replace_all);
-
-namespace compiler {
-namespace perlxs {
-
-void
-SetupDepthVars(std::map<TProtoStringType, TProtoStringType>& vars, int depth)
-{
- std::ostringstream ost_pdepth;
- std::ostringstream ost_depth;
- std::ostringstream ost_ndepth;
-
- ost_pdepth << depth;
- ost_depth << depth + 1;
- ost_ndepth << depth + 2;
-
- vars["pdepth"] = ost_pdepth.str();
- vars["depth"] = ost_depth.str();
- vars["ndepth"] = ost_ndepth.str();
-}
-
-} // namespace perlxs
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/perlxs/perlxs_helpers.h b/contrib/libs/protoc/src/google/protobuf/compiler/perlxs/perlxs_helpers.h
deleted file mode 100644
index 5454877f5a..0000000000
--- a/contrib/libs/protoc/src/google/protobuf/compiler/perlxs/perlxs_helpers.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef GOOGLE_PROTOBUF_COMPILER_PERLXS_HELPERS_H__
-#define GOOGLE_PROTOBUF_COMPILER_PERLXS_HELPERS_H__
-
-#include <map>
-#include <google/protobuf/stubs/common.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace perlxs {
-
-void SetupDepthVars(std::map<TProtoStringType, TProtoStringType>& vars, int depth);
-
-} // namespace perlxs
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_PERLXS_HELPERS_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 b06200a986..ecaccec339 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/php/php_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/php/php_generator.cc
@@ -50,29 +50,29 @@ const TProtoStringType kDescriptorMetadataFile =
const TProtoStringType kDescriptorDirName = "Google/Protobuf/Internal";
const TProtoStringType kDescriptorPackageName = "Google\\Protobuf\\Internal";
const char* const kReservedNames[] = {
- "abstract", "and", "array", "as", "break",
- "callable", "case", "catch", "class", "clone",
- "const", "continue", "declare", "default", "die",
- "do", "echo", "else", "elseif", "empty",
- "enddeclare", "endfor", "endforeach", "endif", "endswitch",
- "endwhile", "eval", "exit", "extends", "final",
- "finally", "fn", "for", "foreach", "function",
- "global", "goto", "if", "implements", "include",
- "include_once", "instanceof", "insteadof", "interface", "isset",
- "list", "match", "namespace", "new", "or",
- "parent", "print", "private", "protected", "public",
- "require", "require_once", "return", "self", "static",
- "switch", "throw", "trait", "try", "unset",
- "use", "var", "while", "xor", "yield",
- "int", "float", "bool", "string", "true",
- "false", "null", "void", "iterable"};
+ "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"
+ "self", "readonly"
};
-const int kReservedNamesSize = 79;
-const int kValidConstantNamesSize = 11;
+const int kReservedNamesSize = 80;
+const int kValidConstantNamesSize = 12;
const int kFieldSetter = 1;
const int kFieldGetter = 2;
const int kFieldProperty = 3;
@@ -422,6 +422,16 @@ TProtoStringType LegacyGeneratedClassFileName(const DescriptorType* desc,
return result + ".php";
}
+template <typename DescriptorType>
+TProtoStringType LegacyReadOnlyGeneratedClassFileName(const DescriptorType* desc,
+ const Options& options) {
+ TProtoStringType php_namespace = RootPhpNamespace(desc, options);
+ if (!php_namespace.empty()) {
+ return php_namespace + "/" + desc->name() + ".php";
+ }
+ return desc->name() + ".php";
+}
+
TProtoStringType GeneratedServiceFileName(const ServiceDescriptor* service,
const Options& options) {
TProtoStringType result = FullClassName(service, options) + "Interface";
@@ -492,9 +502,9 @@ TProtoStringType PhpSetterTypeName(const FieldDescriptor* field,
// accommodate for edge case with multiple types.
size_t start_pos = type.find("|");
if (start_pos != TProtoStringType::npos) {
- type.replace(start_pos, 1, "[]|");
+ type.replace(start_pos, 1, ">|array<");
}
- type += "[]|\\Google\\Protobuf\\Internal\\RepeatedField";
+ type = "array<" + type + ">|\\Google\\Protobuf\\Internal\\RepeatedField";
}
return type;
}
@@ -1304,6 +1314,33 @@ void LegacyGenerateClassFile(const FileDescriptor* file,
"fullname", newname);
}
+template <typename DescriptorType>
+void LegacyReadOnlyGenerateClassFile(const FileDescriptor* file,
+ const DescriptorType* desc, const Options& options,
+ GeneratorContext* generator_context) {
+ TProtoStringType filename = LegacyReadOnlyGeneratedClassFileName(desc, options);
+ 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));
+ 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);
+}
+
void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en,
const Options& options,
GeneratorContext* generator_context) {
@@ -1339,11 +1376,18 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en,
"name", fullname);
Indent(&printer);
+ bool hasReserved = false;
for (int i = 0; i < en->value_count(); i++) {
const EnumValueDescriptor* value = en->value(i);
GenerateEnumValueDocComment(&printer, value);
+
+ TProtoStringType prefix = ConstantNamePrefix(value->name());
+ if (!prefix.empty()) {
+ hasReserved = true;
+ }
+
printer.Print("const ^name^ = ^number^;\n",
- "name", ConstantNamePrefix(value->name()) + value->name(),
+ "name", prefix + value->name(),
"number", IntToString(value->number()));
}
@@ -1351,8 +1395,9 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en,
Indent(&printer);
for (int i = 0; i < en->value_count(); i++) {
const EnumValueDescriptor* value = en->value(i);
- printer.Print("self::^name^ => '^name^',\n",
- "name", ConstantNamePrefix(value->name()) + value->name());
+ printer.Print("self::^constant^ => '^name^',\n",
+ "constant", ConstantNamePrefix(value->name()) + value->name(),
+ "name", value->name());
}
Outdent(&printer);
printer.Print("];\n");
@@ -1382,12 +1427,22 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en,
printer.Print("$const = __CLASS__ . '::' . strtoupper($name);\n"
"if (!defined($const)) {\n");
Indent(&printer);
+ if (hasReserved) {
+ printer.Print("$pbconst = __CLASS__. '::PB' . strtoupper($name);\n"
+ "if (!defined($pbconst)) {\n");
+ Indent(&printer);
+ }
printer.Print("throw new UnexpectedValueException(sprintf(\n");
Indent(&printer);
Indent(&printer);
printer.Print("'Enum %s has no value defined for name %s', __CLASS__, $name));\n");
Outdent(&printer);
Outdent(&printer);
+ if (hasReserved) {
+ Outdent(&printer);
+ printer.Print("}\n"
+ "return constant($pbconst);\n");
+ }
Outdent(&printer);
printer.Print("}\n"
"return constant($const);\n");
@@ -1407,6 +1462,19 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en,
"old", LegacyFullClassName(en, options));
LegacyGenerateClassFile(file, en, options, generator_context);
}
+
+ // Write legacy file for backwards compatibility with "readonly" keywword
+ TProtoStringType lower = en->name();
+ lower.to_lower();
+ if (lower == "readonly") {
+ printer.Print(
+ "// Adding a class alias for backwards compatibility with the \"readonly\" keyword.\n");
+ printer.Print(
+ "class_alias(^new^::class, __NAMESPACE__ . '\\^old^');\n\n",
+ "new", fullname,
+ "old", en->name());
+ LegacyReadOnlyGenerateClassFile(file, en, options, generator_context);
+ }
}
void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message,
@@ -1523,6 +1591,19 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message,
LegacyGenerateClassFile(file, message, options, generator_context);
}
+ // Write legacy file for backwards compatibility with "readonly" keywword
+ TProtoStringType lower = message->name();
+ lower.to_lower();
+ if (lower == "readonly") {
+ printer.Print(
+ "// Adding a class alias for backwards compatibility with the \"readonly\" keyword.\n");
+ printer.Print(
+ "class_alias(^new^::class, __NAMESPACE__ . '\\^old^');\n\n",
+ "new", fullname,
+ "old", message->name());
+ LegacyReadOnlyGenerateClassFile(file, message, options, generator_context);
+ }
+
// Nested messages and enums.
for (int i = 0; i < message->nested_type_count(); i++) {
GenerateMessageFile(file, message->nested_type(i), options,
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc
index 2d7fc6fcb5..68e23498c1 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc
@@ -45,9 +45,10 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/plugin.pb.h>
#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/io/zero_copy_stream_impl.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 {
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 34126b9d9a..55fa2a6981 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc
@@ -23,11 +23,13 @@ namespace _pbi = _pb::internal;
PROTOBUF_NAMESPACE_OPEN
namespace compiler {
PROTOBUF_CONSTEXPR Version::Version(
- ::_pbi::ConstantInitialized)
- : suffix_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
- , major_(0)
- , minor_(0)
- , patch_(0){}
+ ::_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} {}
struct VersionDefaultTypeInternal {
PROTOBUF_CONSTEXPR VersionDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
@@ -38,11 +40,13 @@ struct VersionDefaultTypeInternal {
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 VersionDefaultTypeInternal _Version_default_instance_;
PROTOBUF_CONSTEXPR CodeGeneratorRequest::CodeGeneratorRequest(
- ::_pbi::ConstantInitialized)
- : file_to_generate_()
- , proto_file_()
- , parameter_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
- , compiler_version_(nullptr){}
+ ::_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_.compiler_version_)*/nullptr} {}
struct CodeGeneratorRequestDefaultTypeInternal {
PROTOBUF_CONSTEXPR CodeGeneratorRequestDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
@@ -53,11 +57,13 @@ struct CodeGeneratorRequestDefaultTypeInternal {
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_;
PROTOBUF_CONSTEXPR CodeGeneratorResponse_File::CodeGeneratorResponse_File(
- ::_pbi::ConstantInitialized)
- : name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
- , insertion_point_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
- , content_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
- , generated_code_info_(nullptr){}
+ ::_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_.generated_code_info_)*/nullptr} {}
struct CodeGeneratorResponse_FileDefaultTypeInternal {
PROTOBUF_CONSTEXPR CodeGeneratorResponse_FileDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
@@ -68,10 +74,12 @@ struct CodeGeneratorResponse_FileDefaultTypeInternal {
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_;
PROTOBUF_CONSTEXPR CodeGeneratorResponse::CodeGeneratorResponse(
- ::_pbi::ConstantInitialized)
- : file_()
- , error_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
- , supported_features_(arc_ui64{0u}){}
+ ::_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}} {}
struct CodeGeneratorResponseDefaultTypeInternal {
PROTOBUF_CONSTEXPR CodeGeneratorResponseDefaultTypeInternal()
: _instance(::_pbi::ConstantInitialized{}) {}
@@ -88,57 +96,57 @@ static const ::_pb::EnumDescriptor* file_level_enum_descriptors_google_2fprotobu
static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto = nullptr;
const arc_ui32 TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _has_bits_),
+ 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, major_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, minor_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, patch_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, suffix_),
+ 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, _has_bits_),
+ 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, file_to_generate_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, parameter_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, proto_file_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, compiler_version_),
+ 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, _has_bits_),
+ 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, name_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, insertion_point_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, content_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, generated_code_info_),
+ 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, _has_bits_),
+ 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, error_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, supported_features_),
- PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, file_),
+ 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,
@@ -225,7 +233,7 @@ constexpr int CodeGeneratorResponse::Feature_ARRAYSIZE;
class Version::_Internal {
public:
- using HasBits = decltype(std::declval<Version>()._has_bits_);
+ using HasBits = decltype(std::declval<Version>()._impl_._has_bits_);
static void set_has_major(HasBits* has_bits) {
(*has_bits)[0] |= 2u;
}
@@ -243,36 +251,51 @@ class Version::_Internal {
Version::Version(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor();
+ SharedCtor(arena, is_message_owned);
// @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.Version)
}
Version::Version(const Version& from)
- : ::PROTOBUF_NAMESPACE_ID::Message(),
- _has_bits_(from._has_bits_) {
+ : ::PROTOBUF_NAMESPACE_ID::Message() {
+ Version* const _this = this; (void)_this;
+ 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_){}};
+
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- suffix_.InitDefault();
+ _impl_.suffix_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- suffix_.Set("", GetArenaForAllocation());
+ _impl_.suffix_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_suffix()) {
- suffix_.Set(from._internal_suffix(),
- GetArenaForAllocation());
+ _this->_impl_.suffix_.Set(from._internal_suffix(),
+ _this->GetArenaForAllocation());
}
- ::memcpy(&major_, &from.major_,
- static_cast<size_t>(reinterpret_cast<char*>(&patch_) -
- reinterpret_cast<char*>(&major_)) + sizeof(patch_));
+ ::memcpy(&_impl_.major_, &from._impl_.major_,
+ 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() {
-suffix_.InitDefault();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- suffix_.Set("", GetArenaForAllocation());
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
- reinterpret_cast<char*>(&major_) - reinterpret_cast<char*>(this)),
- 0, static_cast<size_t>(reinterpret_cast<char*>(&patch_) -
- reinterpret_cast<char*>(&major_)) + sizeof(patch_));
+inline void Version::SharedCtor(
+ ::_pb::Arena* arena, bool is_message_owned) {
+ (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}
+ };
+ _impl_.suffix_.InitDefault();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.suffix_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
Version::~Version() {
@@ -286,11 +309,11 @@ Version::~Version() {
inline void Version::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- suffix_.Destroy();
+ _impl_.suffix_.Destroy();
}
void Version::SetCachedSize(int size) const {
- _cached_size_.Set(size);
+ _impl_._cached_size_.Set(size);
}
void Version::Clear() {
@@ -299,16 +322,16 @@ void Version::Clear() {
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
- cached_has_bits = _has_bits_[0];
+ cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x00000001u) {
- suffix_.ClearNonDefaultToEmpty();
+ _impl_.suffix_.ClearNonDefaultToEmpty();
}
if (cached_has_bits & 0x0000000eu) {
- ::memset(&major_, 0, static_cast<size_t>(
- reinterpret_cast<char*>(&patch_) -
- reinterpret_cast<char*>(&major_)) + sizeof(patch_));
+ ::memset(&_impl_.major_, 0, static_cast<size_t>(
+ reinterpret_cast<char*>(&_impl_.patch_) -
+ reinterpret_cast<char*>(&_impl_.major_)) + sizeof(_impl_.patch_));
}
- _has_bits_.Clear();
+ _impl_._has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
@@ -323,7 +346,7 @@ const char* Version::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx)
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
_Internal::set_has_major(&has_bits);
- major_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
+ _impl_.major_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;
@@ -332,7 +355,7 @@ const char* Version::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx)
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
_Internal::set_has_minor(&has_bits);
- minor_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
+ _impl_.minor_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;
@@ -341,7 +364,7 @@ const char* Version::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx)
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) {
_Internal::set_has_patch(&has_bits);
- patch_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
+ _impl_.patch_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;
@@ -374,7 +397,7 @@ const char* Version::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx)
CHK_(ptr != nullptr);
} // while
message_done:
- _has_bits_.Or(has_bits);
+ _impl_._has_bits_.Or(has_bits);
return ptr;
failure:
ptr = nullptr;
@@ -388,7 +411,7 @@ uint8_t* Version::_InternalSerialize(
arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
- cached_has_bits = _has_bits_[0];
+ cached_has_bits = _impl_._has_bits_[0];
// optional int32 major = 1;
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
@@ -433,7 +456,7 @@ size_t Version::ByteSizeLong() const {
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
- cached_has_bits = _has_bits_[0];
+ cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x0000000fu) {
// optional string suffix = 4;
if (cached_has_bits & 0x00000001u) {
@@ -458,45 +481,41 @@ size_t Version::ByteSizeLong() const {
}
}
- return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_);
+ return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
}
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Version::_class_data_ = {
- ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck,
+ ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck,
Version::MergeImpl
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Version::GetClassData() const { return &_class_data_; }
-void Version::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to,
- const ::PROTOBUF_NAMESPACE_ID::Message& from) {
- static_cast<Version *>(to)->MergeFrom(
- static_cast<const Version &>(from));
-}
-
-void Version::MergeFrom(const Version& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.Version)
- GOOGLE_DCHECK_NE(&from, this);
+void Version::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
+ 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;
(void) cached_has_bits;
- cached_has_bits = from._has_bits_[0];
+ cached_has_bits = from._impl_._has_bits_[0];
if (cached_has_bits & 0x0000000fu) {
if (cached_has_bits & 0x00000001u) {
- _internal_set_suffix(from._internal_suffix());
+ _this->_internal_set_suffix(from._internal_suffix());
}
if (cached_has_bits & 0x00000002u) {
- major_ = from.major_;
+ _this->_impl_.major_ = from._impl_.major_;
}
if (cached_has_bits & 0x00000004u) {
- minor_ = from.minor_;
+ _this->_impl_.minor_ = from._impl_.minor_;
}
if (cached_has_bits & 0x00000008u) {
- patch_ = from.patch_;
+ _this->_impl_.patch_ = from._impl_.patch_;
}
- _has_bits_[0] |= cached_has_bits;
+ _this->_impl_._has_bits_[0] |= cached_has_bits;
}
- _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
+ _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}
void Version::CopyFrom(const Version& from) {
@@ -515,17 +534,17 @@ void Version::InternalSwap(Version* other) {
auto* lhs_arena = GetArenaForAllocation();
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
- swap(_has_bits_[0], other->_has_bits_[0]);
+ swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &suffix_, lhs_arena,
- &other->suffix_, rhs_arena
+ &_impl_.suffix_, lhs_arena,
+ &other->_impl_.suffix_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
- PROTOBUF_FIELD_OFFSET(Version, patch_)
- + sizeof(Version::patch_)
- - PROTOBUF_FIELD_OFFSET(Version, major_)>(
- reinterpret_cast<char*>(&major_),
- reinterpret_cast<char*>(&other->major_));
+ PROTOBUF_FIELD_OFFSET(Version, _impl_.patch_)
+ + sizeof(Version::_impl_.patch_)
+ - PROTOBUF_FIELD_OFFSET(Version, _impl_.major_)>(
+ reinterpret_cast<char*>(&_impl_.major_),
+ reinterpret_cast<char*>(&other->_impl_.major_));
}
::PROTOBUF_NAMESPACE_ID::Metadata Version::GetMetadata() const {
@@ -538,7 +557,7 @@ void Version::InternalSwap(Version* other) {
class CodeGeneratorRequest::_Internal {
public:
- using HasBits = decltype(std::declval<CodeGeneratorRequest>()._has_bits_);
+ using HasBits = decltype(std::declval<CodeGeneratorRequest>()._impl_._has_bits_);
static void set_has_parameter(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -550,47 +569,59 @@ class CodeGeneratorRequest::_Internal {
const ::PROTOBUF_NAMESPACE_ID::compiler::Version&
CodeGeneratorRequest::_Internal::compiler_version(const CodeGeneratorRequest* msg) {
- return *msg->compiler_version_;
+ return *msg->_impl_.compiler_version_;
}
void CodeGeneratorRequest::clear_proto_file() {
- proto_file_.Clear();
+ _impl_.proto_file_.Clear();
}
CodeGeneratorRequest::CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
- file_to_generate_(arena),
- proto_file_(arena) {
- SharedCtor();
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
+ SharedCtor(arena, is_message_owned);
// @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.CodeGeneratorRequest)
}
CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from)
- : ::PROTOBUF_NAMESPACE_ID::Message(),
- _has_bits_(from._has_bits_),
- file_to_generate_(from.file_to_generate_),
- proto_file_(from.proto_file_) {
+ : ::PROTOBUF_NAMESPACE_ID::Message() {
+ CodeGeneratorRequest* const _this = this; (void)_this;
+ new (&_impl_) Impl_{
+ decltype(_impl_._has_bits_){from._impl_._has_bits_}
+ , /*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_.compiler_version_){nullptr}};
+
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- parameter_.InitDefault();
+ _impl_.parameter_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- parameter_.Set("", GetArenaForAllocation());
+ _impl_.parameter_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_parameter()) {
- parameter_.Set(from._internal_parameter(),
- GetArenaForAllocation());
+ _this->_impl_.parameter_.Set(from._internal_parameter(),
+ _this->GetArenaForAllocation());
}
if (from._internal_has_compiler_version()) {
- compiler_version_ = new ::PROTOBUF_NAMESPACE_ID::compiler::Version(*from.compiler_version_);
- } else {
- compiler_version_ = nullptr;
+ _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() {
-parameter_.InitDefault();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- parameter_.Set("", GetArenaForAllocation());
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-compiler_version_ = nullptr;
+inline void CodeGeneratorRequest::SharedCtor(
+ ::_pb::Arena* arena, bool is_message_owned) {
+ (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_.compiler_version_){nullptr}
+ };
+ _impl_.parameter_.InitDefault();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.parameter_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
CodeGeneratorRequest::~CodeGeneratorRequest() {
@@ -604,12 +635,14 @@ CodeGeneratorRequest::~CodeGeneratorRequest() {
inline void CodeGeneratorRequest::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- parameter_.Destroy();
- if (this != internal_default_instance()) delete compiler_version_;
+ _impl_.file_to_generate_.~RepeatedPtrField();
+ _impl_.proto_file_.~RepeatedPtrField();
+ _impl_.parameter_.Destroy();
+ if (this != internal_default_instance()) delete _impl_.compiler_version_;
}
void CodeGeneratorRequest::SetCachedSize(int size) const {
- _cached_size_.Set(size);
+ _impl_._cached_size_.Set(size);
}
void CodeGeneratorRequest::Clear() {
@@ -618,19 +651,19 @@ void CodeGeneratorRequest::Clear() {
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
- file_to_generate_.Clear();
- proto_file_.Clear();
- cached_has_bits = _has_bits_[0];
+ _impl_.file_to_generate_.Clear();
+ _impl_.proto_file_.Clear();
+ cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x00000003u) {
if (cached_has_bits & 0x00000001u) {
- parameter_.ClearNonDefaultToEmpty();
+ _impl_.parameter_.ClearNonDefaultToEmpty();
}
if (cached_has_bits & 0x00000002u) {
- GOOGLE_DCHECK(compiler_version_ != nullptr);
- compiler_version_->Clear();
+ GOOGLE_DCHECK(_impl_.compiler_version_ != nullptr);
+ _impl_.compiler_version_->Clear();
}
}
- _has_bits_.Clear();
+ _impl_._has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
@@ -707,7 +740,7 @@ const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::_pbi::ParseC
CHK_(ptr != nullptr);
} // while
message_done:
- _has_bits_.Or(has_bits);
+ _impl_._has_bits_.Or(has_bits);
return ptr;
failure:
ptr = nullptr;
@@ -731,7 +764,7 @@ uint8_t* CodeGeneratorRequest::_InternalSerialize(
target = stream->WriteString(1, s, target);
}
- cached_has_bits = _has_bits_[0];
+ cached_has_bits = _impl_._has_bits_[0];
// optional string parameter = 2;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -775,20 +808,20 @@ size_t CodeGeneratorRequest::ByteSizeLong() const {
// repeated string file_to_generate = 1;
total_size += 1 *
- ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(file_to_generate_.size());
- for (int i = 0, n = file_to_generate_.size(); i < n; i++) {
+ ::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(
- file_to_generate_.Get(i));
+ _impl_.file_to_generate_.Get(i));
}
// repeated .google.protobuf.FileDescriptorProto proto_file = 15;
total_size += 1UL * this->_internal_proto_file_size();
- for (const auto& msg : this->proto_file_) {
+ for (const auto& msg : this->_impl_.proto_file_) {
total_size +=
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
}
- cached_has_bits = _has_bits_[0];
+ cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x00000003u) {
// optional string parameter = 2;
if (cached_has_bits & 0x00000001u) {
@@ -801,44 +834,41 @@ size_t CodeGeneratorRequest::ByteSizeLong() const {
if (cached_has_bits & 0x00000002u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
- *compiler_version_);
+ *_impl_.compiler_version_);
}
}
- return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_);
+ return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
}
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData CodeGeneratorRequest::_class_data_ = {
- ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck,
+ ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck,
CodeGeneratorRequest::MergeImpl
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*CodeGeneratorRequest::GetClassData() const { return &_class_data_; }
-void CodeGeneratorRequest::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to,
- const ::PROTOBUF_NAMESPACE_ID::Message& from) {
- static_cast<CodeGeneratorRequest *>(to)->MergeFrom(
- static_cast<const CodeGeneratorRequest &>(from));
-}
-
-void CodeGeneratorRequest::MergeFrom(const CodeGeneratorRequest& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorRequest)
- GOOGLE_DCHECK_NE(&from, this);
+void CodeGeneratorRequest::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
+ 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;
(void) cached_has_bits;
- file_to_generate_.MergeFrom(from.file_to_generate_);
- proto_file_.MergeFrom(from.proto_file_);
- cached_has_bits = from._has_bits_[0];
+ _this->_impl_.file_to_generate_.MergeFrom(from._impl_.file_to_generate_);
+ _this->_impl_.proto_file_.MergeFrom(from._impl_.proto_file_);
+ cached_has_bits = from._impl_._has_bits_[0];
if (cached_has_bits & 0x00000003u) {
if (cached_has_bits & 0x00000001u) {
- _internal_set_parameter(from._internal_parameter());
+ _this->_internal_set_parameter(from._internal_parameter());
}
if (cached_has_bits & 0x00000002u) {
- _internal_mutable_compiler_version()->::PROTOBUF_NAMESPACE_ID::compiler::Version::MergeFrom(from._internal_compiler_version());
+ _this->_internal_mutable_compiler_version()->::PROTOBUF_NAMESPACE_ID::compiler::Version::MergeFrom(
+ from._internal_compiler_version());
}
}
- _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
+ _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}
void CodeGeneratorRequest::CopyFrom(const CodeGeneratorRequest& from) {
@@ -849,7 +879,7 @@ void CodeGeneratorRequest::CopyFrom(const CodeGeneratorRequest& from) {
}
bool CodeGeneratorRequest::IsInitialized() const {
- if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(proto_file_))
+ if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.proto_file_))
return false;
return true;
}
@@ -859,14 +889,14 @@ void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) {
auto* lhs_arena = GetArenaForAllocation();
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
- swap(_has_bits_[0], other->_has_bits_[0]);
- file_to_generate_.InternalSwap(&other->file_to_generate_);
- proto_file_.InternalSwap(&other->proto_file_);
+ 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(
- &parameter_, lhs_arena,
- &other->parameter_, rhs_arena
+ &_impl_.parameter_, lhs_arena,
+ &other->_impl_.parameter_, rhs_arena
);
- swap(compiler_version_, other->compiler_version_);
+ swap(_impl_.compiler_version_, other->_impl_.compiler_version_);
}
::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorRequest::GetMetadata() const {
@@ -879,7 +909,7 @@ void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) {
class CodeGeneratorResponse_File::_Internal {
public:
- using HasBits = decltype(std::declval<CodeGeneratorResponse_File>()._has_bits_);
+ using HasBits = decltype(std::declval<CodeGeneratorResponse_File>()._impl_._has_bits_);
static void set_has_name(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -897,68 +927,84 @@ class CodeGeneratorResponse_File::_Internal {
const ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo&
CodeGeneratorResponse_File::_Internal::generated_code_info(const CodeGeneratorResponse_File* msg) {
- return *msg->generated_code_info_;
+ return *msg->_impl_.generated_code_info_;
}
void CodeGeneratorResponse_File::clear_generated_code_info() {
- if (generated_code_info_ != nullptr) generated_code_info_->Clear();
- _has_bits_[0] &= ~0x00000008u;
+ 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();
+ SharedCtor(arena, is_message_owned);
// @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.CodeGeneratorResponse.File)
}
CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorResponse_File& from)
- : ::PROTOBUF_NAMESPACE_ID::Message(),
- _has_bits_(from._has_bits_) {
+ : ::PROTOBUF_NAMESPACE_ID::Message() {
+ CodeGeneratorResponse_File* const _this = this; (void)_this;
+ 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_.generated_code_info_){nullptr}};
+
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- name_.InitDefault();
+ _impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set("", GetArenaForAllocation());
+ _impl_.name_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_name()) {
- name_.Set(from._internal_name(),
- GetArenaForAllocation());
+ _this->_impl_.name_.Set(from._internal_name(),
+ _this->GetArenaForAllocation());
}
- insertion_point_.InitDefault();
+ _impl_.insertion_point_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- insertion_point_.Set("", GetArenaForAllocation());
+ _impl_.insertion_point_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_insertion_point()) {
- insertion_point_.Set(from._internal_insertion_point(),
- GetArenaForAllocation());
+ _this->_impl_.insertion_point_.Set(from._internal_insertion_point(),
+ _this->GetArenaForAllocation());
}
- content_.InitDefault();
+ _impl_.content_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- content_.Set("", GetArenaForAllocation());
+ _impl_.content_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_content()) {
- content_.Set(from._internal_content(),
- GetArenaForAllocation());
+ _this->_impl_.content_.Set(from._internal_content(),
+ _this->GetArenaForAllocation());
}
if (from._internal_has_generated_code_info()) {
- generated_code_info_ = new ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo(*from.generated_code_info_);
- } else {
- generated_code_info_ = nullptr;
+ _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() {
-name_.InitDefault();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- name_.Set("", GetArenaForAllocation());
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-insertion_point_.InitDefault();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- insertion_point_.Set("", GetArenaForAllocation());
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-content_.InitDefault();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- content_.Set("", GetArenaForAllocation());
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-generated_code_info_ = nullptr;
+inline void CodeGeneratorResponse_File::SharedCtor(
+ ::_pb::Arena* arena, bool is_message_owned) {
+ (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_.generated_code_info_){nullptr}
+ };
+ _impl_.name_.InitDefault();
+ #ifdef 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_.content_.InitDefault();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.content_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
CodeGeneratorResponse_File::~CodeGeneratorResponse_File() {
@@ -972,14 +1018,14 @@ CodeGeneratorResponse_File::~CodeGeneratorResponse_File() {
inline void CodeGeneratorResponse_File::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- name_.Destroy();
- insertion_point_.Destroy();
- content_.Destroy();
- if (this != internal_default_instance()) delete generated_code_info_;
+ _impl_.name_.Destroy();
+ _impl_.insertion_point_.Destroy();
+ _impl_.content_.Destroy();
+ if (this != internal_default_instance()) delete _impl_.generated_code_info_;
}
void CodeGeneratorResponse_File::SetCachedSize(int size) const {
- _cached_size_.Set(size);
+ _impl_._cached_size_.Set(size);
}
void CodeGeneratorResponse_File::Clear() {
@@ -988,23 +1034,23 @@ void CodeGeneratorResponse_File::Clear() {
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
- cached_has_bits = _has_bits_[0];
+ cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x0000000fu) {
if (cached_has_bits & 0x00000001u) {
- name_.ClearNonDefaultToEmpty();
+ _impl_.name_.ClearNonDefaultToEmpty();
}
if (cached_has_bits & 0x00000002u) {
- insertion_point_.ClearNonDefaultToEmpty();
+ _impl_.insertion_point_.ClearNonDefaultToEmpty();
}
if (cached_has_bits & 0x00000004u) {
- content_.ClearNonDefaultToEmpty();
+ _impl_.content_.ClearNonDefaultToEmpty();
}
if (cached_has_bits & 0x00000008u) {
- GOOGLE_DCHECK(generated_code_info_ != nullptr);
- generated_code_info_->Clear();
+ GOOGLE_DCHECK(_impl_.generated_code_info_ != nullptr);
+ _impl_.generated_code_info_->Clear();
}
}
- _has_bits_.Clear();
+ _impl_._has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
@@ -1075,7 +1121,7 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::_pbi::
CHK_(ptr != nullptr);
} // while
message_done:
- _has_bits_.Or(has_bits);
+ _impl_._has_bits_.Or(has_bits);
return ptr;
failure:
ptr = nullptr;
@@ -1089,7 +1135,7 @@ uint8_t* CodeGeneratorResponse_File::_InternalSerialize(
arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
- cached_has_bits = _has_bits_[0];
+ cached_has_bits = _impl_._has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -1143,7 +1189,7 @@ size_t CodeGeneratorResponse_File::ByteSizeLong() const {
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
- cached_has_bits = _has_bits_[0];
+ cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x0000000fu) {
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
@@ -1170,48 +1216,45 @@ size_t CodeGeneratorResponse_File::ByteSizeLong() const {
if (cached_has_bits & 0x00000008u) {
total_size += 2 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
- *generated_code_info_);
+ *_impl_.generated_code_info_);
}
}
- return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_);
+ return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
}
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData CodeGeneratorResponse_File::_class_data_ = {
- ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck,
+ ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck,
CodeGeneratorResponse_File::MergeImpl
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*CodeGeneratorResponse_File::GetClassData() const { return &_class_data_; }
-void CodeGeneratorResponse_File::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to,
- const ::PROTOBUF_NAMESPACE_ID::Message& from) {
- static_cast<CodeGeneratorResponse_File *>(to)->MergeFrom(
- static_cast<const CodeGeneratorResponse_File &>(from));
-}
-
-void CodeGeneratorResponse_File::MergeFrom(const CodeGeneratorResponse_File& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse.File)
- GOOGLE_DCHECK_NE(&from, this);
+void CodeGeneratorResponse_File::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
+ 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;
(void) cached_has_bits;
- cached_has_bits = from._has_bits_[0];
+ cached_has_bits = from._impl_._has_bits_[0];
if (cached_has_bits & 0x0000000fu) {
if (cached_has_bits & 0x00000001u) {
- _internal_set_name(from._internal_name());
+ _this->_internal_set_name(from._internal_name());
}
if (cached_has_bits & 0x00000002u) {
- _internal_set_insertion_point(from._internal_insertion_point());
+ _this->_internal_set_insertion_point(from._internal_insertion_point());
}
if (cached_has_bits & 0x00000004u) {
- _internal_set_content(from._internal_content());
+ _this->_internal_set_content(from._internal_content());
}
if (cached_has_bits & 0x00000008u) {
- _internal_mutable_generated_code_info()->::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo::MergeFrom(from._internal_generated_code_info());
+ _this->_internal_mutable_generated_code_info()->::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo::MergeFrom(
+ from._internal_generated_code_info());
}
}
- _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
+ _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}
void CodeGeneratorResponse_File::CopyFrom(const CodeGeneratorResponse_File& from) {
@@ -1230,20 +1273,20 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other)
auto* lhs_arena = GetArenaForAllocation();
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
- swap(_has_bits_[0], other->_has_bits_[0]);
+ swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &name_, lhs_arena,
- &other->name_, rhs_arena
+ &_impl_.name_, lhs_arena,
+ &other->_impl_.name_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &insertion_point_, lhs_arena,
- &other->insertion_point_, rhs_arena
+ &_impl_.insertion_point_, lhs_arena,
+ &other->_impl_.insertion_point_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &content_, lhs_arena,
- &other->content_, rhs_arena
+ &_impl_.content_, lhs_arena,
+ &other->_impl_.content_, rhs_arena
);
- swap(generated_code_info_, other->generated_code_info_);
+ swap(_impl_.generated_code_info_, other->_impl_.generated_code_info_);
}
::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorResponse_File::GetMetadata() const {
@@ -1256,7 +1299,7 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other)
class CodeGeneratorResponse::_Internal {
public:
- using HasBits = decltype(std::declval<CodeGeneratorResponse>()._has_bits_);
+ using HasBits = decltype(std::declval<CodeGeneratorResponse>()._impl_._has_bits_);
static void set_has_error(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
@@ -1267,34 +1310,48 @@ class CodeGeneratorResponse::_Internal {
CodeGeneratorResponse::CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
- : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
- file_(arena) {
- SharedCtor();
+ : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
+ SharedCtor(arena, is_message_owned);
// @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.CodeGeneratorResponse)
}
CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from)
- : ::PROTOBUF_NAMESPACE_ID::Message(),
- _has_bits_(from._has_bits_),
- file_(from.file_) {
+ : ::PROTOBUF_NAMESPACE_ID::Message() {
+ CodeGeneratorResponse* const _this = this; (void)_this;
+ new (&_impl_) Impl_{
+ 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_){}};
+
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
- error_.InitDefault();
+ _impl_.error_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- error_.Set("", GetArenaForAllocation());
+ _impl_.error_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_error()) {
- error_.Set(from._internal_error(),
- GetArenaForAllocation());
+ _this->_impl_.error_.Set(from._internal_error(),
+ _this->GetArenaForAllocation());
}
- supported_features_ = from.supported_features_;
+ _this->_impl_.supported_features_ = from._impl_.supported_features_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse)
}
-inline void CodeGeneratorResponse::SharedCtor() {
-error_.InitDefault();
-#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- error_.Set("", GetArenaForAllocation());
-#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
-supported_features_ = arc_ui64{0u};
+inline void CodeGeneratorResponse::SharedCtor(
+ ::_pb::Arena* arena, bool is_message_owned) {
+ (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}}
+ };
+ _impl_.error_.InitDefault();
+ #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+ _impl_.error_.Set("", GetArenaForAllocation());
+ #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
CodeGeneratorResponse::~CodeGeneratorResponse() {
@@ -1308,11 +1365,12 @@ CodeGeneratorResponse::~CodeGeneratorResponse() {
inline void CodeGeneratorResponse::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
- error_.Destroy();
+ _impl_.file_.~RepeatedPtrField();
+ _impl_.error_.Destroy();
}
void CodeGeneratorResponse::SetCachedSize(int size) const {
- _cached_size_.Set(size);
+ _impl_._cached_size_.Set(size);
}
void CodeGeneratorResponse::Clear() {
@@ -1321,13 +1379,13 @@ void CodeGeneratorResponse::Clear() {
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
- file_.Clear();
- cached_has_bits = _has_bits_[0];
+ _impl_.file_.Clear();
+ cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x00000001u) {
- error_.ClearNonDefaultToEmpty();
+ _impl_.error_.ClearNonDefaultToEmpty();
}
- supported_features_ = arc_ui64{0u};
- _has_bits_.Clear();
+ _impl_.supported_features_ = arc_ui64{0u};
+ _impl_._has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
@@ -1354,7 +1412,7 @@ const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::_pbi::Parse
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
_Internal::set_has_supported_features(&has_bits);
- supported_features_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
+ _impl_.supported_features_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
} else
goto handle_unusual;
@@ -1388,7 +1446,7 @@ const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::_pbi::Parse
CHK_(ptr != nullptr);
} // while
message_done:
- _has_bits_.Or(has_bits);
+ _impl_._has_bits_.Or(has_bits);
return ptr;
failure:
ptr = nullptr;
@@ -1402,7 +1460,7 @@ uint8_t* CodeGeneratorResponse::_InternalSerialize(
arc_ui32 cached_has_bits = 0;
(void) cached_has_bits;
- cached_has_bits = _has_bits_[0];
+ cached_has_bits = _impl_._has_bits_[0];
// optional string error = 1;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -1445,12 +1503,12 @@ size_t CodeGeneratorResponse::ByteSizeLong() const {
// repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15;
total_size += 1UL * this->_internal_file_size();
- for (const auto& msg : this->file_) {
+ for (const auto& msg : this->_impl_.file_) {
total_size +=
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
}
- cached_has_bits = _has_bits_[0];
+ cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x00000003u) {
// optional string error = 1;
if (cached_has_bits & 0x00000001u) {
@@ -1465,40 +1523,36 @@ size_t CodeGeneratorResponse::ByteSizeLong() const {
}
}
- return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_);
+ return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
}
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData CodeGeneratorResponse::_class_data_ = {
- ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck,
+ ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck,
CodeGeneratorResponse::MergeImpl
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*CodeGeneratorResponse::GetClassData() const { return &_class_data_; }
-void CodeGeneratorResponse::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to,
- const ::PROTOBUF_NAMESPACE_ID::Message& from) {
- static_cast<CodeGeneratorResponse *>(to)->MergeFrom(
- static_cast<const CodeGeneratorResponse &>(from));
-}
-
-void CodeGeneratorResponse::MergeFrom(const CodeGeneratorResponse& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse)
- GOOGLE_DCHECK_NE(&from, this);
+void CodeGeneratorResponse::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_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;
(void) cached_has_bits;
- file_.MergeFrom(from.file_);
- cached_has_bits = from._has_bits_[0];
+ _this->_impl_.file_.MergeFrom(from._impl_.file_);
+ cached_has_bits = from._impl_._has_bits_[0];
if (cached_has_bits & 0x00000003u) {
if (cached_has_bits & 0x00000001u) {
- _internal_set_error(from._internal_error());
+ _this->_internal_set_error(from._internal_error());
}
if (cached_has_bits & 0x00000002u) {
- supported_features_ = from.supported_features_;
+ _this->_impl_.supported_features_ = from._impl_.supported_features_;
}
- _has_bits_[0] |= cached_has_bits;
+ _this->_impl_._has_bits_[0] |= cached_has_bits;
}
- _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
+ _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}
void CodeGeneratorResponse::CopyFrom(const CodeGeneratorResponse& from) {
@@ -1517,13 +1571,13 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) {
auto* lhs_arena = GetArenaForAllocation();
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
- swap(_has_bits_[0], other->_has_bits_[0]);
- file_.InternalSwap(&other->file_);
+ swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
+ _impl_.file_.InternalSwap(&other->_impl_.file_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
- &error_, lhs_arena,
- &other->error_, rhs_arena
+ &_impl_.error_, lhs_arena,
+ &other->_impl_.error_, rhs_arena
);
- swap(supported_features_, other->supported_features_);
+ swap(_impl_.supported_features_, other->_impl_.supported_features_);
}
::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorResponse::GetMetadata() const {
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 64d7be56fd..ac9253cc58 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h
@@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
-#if PROTOBUF_VERSION < 3020000
+#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 3020002 < PROTOBUF_MIN_PROTOC_VERSION
+#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.
@@ -189,9 +189,11 @@ class PROTOC_EXPORT Version final :
using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom;
void CopyFrom(const Version& from);
using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom;
- void MergeFrom(const Version& from);
+ void MergeFrom( const Version& from) {
+ Version::MergeImpl(*this, from);
+ }
private:
- static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from);
+ static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg);
public:
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
@@ -200,10 +202,10 @@ class PROTOC_EXPORT Version 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;
- int GetCachedSize() const final { return _cached_size_.Get(); }
+ int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor();
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(Version* other);
@@ -297,12 +299,15 @@ class PROTOC_EXPORT Version final :
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
- ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_;
- mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr suffix_;
- arc_i32 major_;
- arc_i32 minor_;
- arc_i32 patch_;
+ struct Impl_ {
+ ::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_;
+ };
+ union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto;
};
// -------------------------------------------------------------------
@@ -394,9 +399,11 @@ class PROTOC_EXPORT CodeGeneratorRequest final :
using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom;
void CopyFrom(const CodeGeneratorRequest& from);
using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom;
- void MergeFrom(const CodeGeneratorRequest& from);
+ void MergeFrom( const CodeGeneratorRequest& from) {
+ CodeGeneratorRequest::MergeImpl(*this, from);
+ }
private:
- static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from);
+ static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg);
public:
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
@@ -405,10 +412,10 @@ class PROTOC_EXPORT CodeGeneratorRequest 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;
- int GetCachedSize() const final { return _cached_size_.Get(); }
+ int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor();
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(CodeGeneratorRequest* other);
@@ -523,12 +530,15 @@ class PROTOC_EXPORT CodeGeneratorRequest final :
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
- ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_;
- mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
- ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType> file_to_generate_;
- ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto > proto_file_;
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr parameter_;
- ::PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version_;
+ struct Impl_ {
+ ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_;
+ mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
+ ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType> file_to_generate_;
+ ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto > proto_file_;
+ ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr parameter_;
+ ::PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version_;
+ };
+ union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto;
};
// -------------------------------------------------------------------
@@ -620,9 +630,11 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final :
using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom;
void CopyFrom(const CodeGeneratorResponse_File& from);
using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom;
- void MergeFrom(const CodeGeneratorResponse_File& from);
+ void MergeFrom( const CodeGeneratorResponse_File& from) {
+ CodeGeneratorResponse_File::MergeImpl(*this, from);
+ }
private:
- static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from);
+ static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg);
public:
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
@@ -631,10 +643,10 @@ class PROTOC_EXPORT CodeGeneratorResponse_File 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;
- int GetCachedSize() const final { return _cached_size_.Get(); }
+ int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor();
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(CodeGeneratorResponse_File* other);
@@ -743,12 +755,15 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final :
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
- ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_;
- mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_;
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr insertion_point_;
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr content_;
- ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info_;
+ struct Impl_ {
+ ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_;
+ mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
+ ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_;
+ ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr insertion_point_;
+ ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr content_;
+ ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info_;
+ };
+ union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto;
};
// -------------------------------------------------------------------
@@ -840,9 +855,11 @@ class PROTOC_EXPORT CodeGeneratorResponse final :
using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom;
void CopyFrom(const CodeGeneratorResponse& from);
using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom;
- void MergeFrom(const CodeGeneratorResponse& from);
+ void MergeFrom( const CodeGeneratorResponse& from) {
+ CodeGeneratorResponse::MergeImpl(*this, from);
+ }
private:
- static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from);
+ static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg);
public:
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
@@ -851,10 +868,10 @@ class PROTOC_EXPORT CodeGeneratorResponse 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;
- int GetCachedSize() const final { return _cached_size_.Get(); }
+ int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
- void SharedCtor();
+ void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(CodeGeneratorResponse* other);
@@ -971,11 +988,14 @@ class PROTOC_EXPORT CodeGeneratorResponse final :
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
- ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_;
- mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
- ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File > file_;
- ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr error_;
- arc_ui64 supported_features_;
+ struct Impl_ {
+ ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_;
+ mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
+ ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File > file_;
+ ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr error_;
+ arc_ui64 supported_features_;
+ };
+ union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto;
};
// ===================================================================
@@ -991,26 +1011,26 @@ class PROTOC_EXPORT CodeGeneratorResponse final :
// optional int32 major = 1;
inline bool Version::_internal_has_major() const {
- bool value = (_has_bits_[0] & 0x00000002u) != 0;
+ 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() {
- major_ = 0;
- _has_bits_[0] &= ~0x00000002u;
+ _impl_.major_ = 0;
+ _impl_._has_bits_[0] &= ~0x00000002u;
}
inline arc_i32 Version::_internal_major() const {
- return major_;
+ return _impl_.major_;
}
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) {
- _has_bits_[0] |= 0x00000002u;
- major_ = value;
+ _impl_._has_bits_[0] |= 0x00000002u;
+ _impl_.major_ = value;
}
inline void Version::set_major(arc_i32 value) {
_internal_set_major(value);
@@ -1019,26 +1039,26 @@ inline void Version::set_major(arc_i32 value) {
// optional int32 minor = 2;
inline bool Version::_internal_has_minor() const {
- bool value = (_has_bits_[0] & 0x00000004u) != 0;
+ 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() {
- minor_ = 0;
- _has_bits_[0] &= ~0x00000004u;
+ _impl_.minor_ = 0;
+ _impl_._has_bits_[0] &= ~0x00000004u;
}
inline arc_i32 Version::_internal_minor() const {
- return minor_;
+ return _impl_.minor_;
}
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) {
- _has_bits_[0] |= 0x00000004u;
- minor_ = value;
+ _impl_._has_bits_[0] |= 0x00000004u;
+ _impl_.minor_ = value;
}
inline void Version::set_minor(arc_i32 value) {
_internal_set_minor(value);
@@ -1047,26 +1067,26 @@ inline void Version::set_minor(arc_i32 value) {
// optional int32 patch = 3;
inline bool Version::_internal_has_patch() const {
- bool value = (_has_bits_[0] & 0x00000008u) != 0;
+ 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() {
- patch_ = 0;
- _has_bits_[0] &= ~0x00000008u;
+ _impl_.patch_ = 0;
+ _impl_._has_bits_[0] &= ~0x00000008u;
}
inline arc_i32 Version::_internal_patch() const {
- return patch_;
+ return _impl_.patch_;
}
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) {
- _has_bits_[0] |= 0x00000008u;
- patch_ = value;
+ _impl_._has_bits_[0] |= 0x00000008u;
+ _impl_.patch_ = value;
}
inline void Version::set_patch(arc_i32 value) {
_internal_set_patch(value);
@@ -1075,15 +1095,15 @@ inline void Version::set_patch(arc_i32 value) {
// optional string suffix = 4;
inline bool Version::_internal_has_suffix() const {
- bool value = (_has_bits_[0] & 0x00000001u) != 0;
+ 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() {
- suffix_.ClearToEmpty();
- _has_bits_[0] &= ~0x00000001u;
+ _impl_.suffix_.ClearToEmpty();
+ _impl_._has_bits_[0] &= ~0x00000001u;
}
inline const TProtoStringType& Version::suffix() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.suffix)
@@ -1092,8 +1112,8 @@ inline const TProtoStringType& Version::suffix() const {
template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void Version::set_suffix(ArgT0&& arg0, ArgT... args) {
- _has_bits_[0] |= 0x00000001u;
- suffix_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.suffix_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix)
}
inline TProtoStringType* Version::mutable_suffix() {
@@ -1102,40 +1122,40 @@ inline TProtoStringType* Version::mutable_suffix() {
return _s;
}
inline const TProtoStringType& Version::_internal_suffix() const {
- return suffix_.Get();
+ return _impl_.suffix_.Get();
}
inline void Version::_internal_set_suffix(const TProtoStringType& value) {
- _has_bits_[0] |= 0x00000001u;
- suffix_.Set(value, GetArenaForAllocation());
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.suffix_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* Version::_internal_mutable_suffix() {
- _has_bits_[0] |= 0x00000001u;
- return suffix_.Mutable(GetArenaForAllocation());
+ _impl_._has_bits_[0] |= 0x00000001u;
+ return _impl_.suffix_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* Version::release_suffix() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.Version.suffix)
if (!_internal_has_suffix()) {
return nullptr;
}
- _has_bits_[0] &= ~0x00000001u;
- auto* p = suffix_.Release();
+ _impl_._has_bits_[0] &= ~0x00000001u;
+ auto* p = _impl_.suffix_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (suffix_.IsDefault()) {
- suffix_.Set("", GetArenaForAllocation());
+ 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) {
- _has_bits_[0] |= 0x00000001u;
+ _impl_._has_bits_[0] |= 0x00000001u;
} else {
- _has_bits_[0] &= ~0x00000001u;
+ _impl_._has_bits_[0] &= ~0x00000001u;
}
- suffix_.SetAllocated(suffix, GetArenaForAllocation());
+ _impl_.suffix_.SetAllocated(suffix, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (suffix_.IsDefault()) {
- suffix_.Set("", GetArenaForAllocation());
+ 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)
@@ -1147,13 +1167,13 @@ inline void Version::set_allocated_suffix(TProtoStringType* suffix) {
// repeated string file_to_generate = 1;
inline int CodeGeneratorRequest::_internal_file_to_generate_size() const {
- return file_to_generate_.size();
+ return _impl_.file_to_generate_.size();
}
inline int CodeGeneratorRequest::file_to_generate_size() const {
return _internal_file_to_generate_size();
}
inline void CodeGeneratorRequest::clear_file_to_generate() {
- file_to_generate_.Clear();
+ _impl_.file_to_generate_.Clear();
}
inline TProtoStringType* CodeGeneratorRequest::add_file_to_generate() {
TProtoStringType* _s = _internal_add_file_to_generate();
@@ -1161,7 +1181,7 @@ inline TProtoStringType* CodeGeneratorRequest::add_file_to_generate() {
return _s;
}
inline const TProtoStringType& CodeGeneratorRequest::_internal_file_to_generate(int index) const {
- return file_to_generate_.Get(index);
+ return _impl_.file_to_generate_.Get(index);
}
inline const TProtoStringType& CodeGeneratorRequest::file_to_generate(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
@@ -1169,68 +1189,68 @@ inline const TProtoStringType& CodeGeneratorRequest::file_to_generate(int index)
}
inline TProtoStringType* CodeGeneratorRequest::mutable_file_to_generate(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
- return file_to_generate_.Mutable(index);
+ return _impl_.file_to_generate_.Mutable(index);
}
inline void CodeGeneratorRequest::set_file_to_generate(int index, const TProtoStringType& value) {
- file_to_generate_.Mutable(index)->assign(value);
+ _impl_.file_to_generate_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
}
inline void CodeGeneratorRequest::set_file_to_generate(int index, TProtoStringType&& value) {
- file_to_generate_.Mutable(index)->assign(std::move(value));
+ _impl_.file_to_generate_.Mutable(index)->assign(std::move(value));
// @@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);
- file_to_generate_.Mutable(index)->assign(value);
+ _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) {
- file_to_generate_.Mutable(index)->assign(
+ _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 file_to_generate_.Add();
+ return _impl_.file_to_generate_.Add();
}
inline void CodeGeneratorRequest::add_file_to_generate(const TProtoStringType& value) {
- file_to_generate_.Add()->assign(value);
+ _impl_.file_to_generate_.Add()->assign(value);
// @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
}
inline void CodeGeneratorRequest::add_file_to_generate(TProtoStringType&& value) {
- file_to_generate_.Add(std::move(value));
+ _impl_.file_to_generate_.Add(std::move(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);
- file_to_generate_.Add()->assign(value);
+ _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) {
- file_to_generate_.Add()->assign(reinterpret_cast<const char*>(value), 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 const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>&
CodeGeneratorRequest::file_to_generate() const {
// @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
- return file_to_generate_;
+ return _impl_.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 &file_to_generate_;
+ return &_impl_.file_to_generate_;
}
// optional string parameter = 2;
inline bool CodeGeneratorRequest::_internal_has_parameter() const {
- bool value = (_has_bits_[0] & 0x00000001u) != 0;
+ 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() {
- parameter_.ClearToEmpty();
- _has_bits_[0] &= ~0x00000001u;
+ _impl_.parameter_.ClearToEmpty();
+ _impl_._has_bits_[0] &= ~0x00000001u;
}
inline const TProtoStringType& CodeGeneratorRequest::parameter() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.parameter)
@@ -1239,8 +1259,8 @@ inline const TProtoStringType& CodeGeneratorRequest::parameter() const {
template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void CodeGeneratorRequest::set_parameter(ArgT0&& arg0, ArgT... args) {
- _has_bits_[0] |= 0x00000001u;
- parameter_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.parameter_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter)
}
inline TProtoStringType* CodeGeneratorRequest::mutable_parameter() {
@@ -1249,40 +1269,40 @@ inline TProtoStringType* CodeGeneratorRequest::mutable_parameter() {
return _s;
}
inline const TProtoStringType& CodeGeneratorRequest::_internal_parameter() const {
- return parameter_.Get();
+ return _impl_.parameter_.Get();
}
inline void CodeGeneratorRequest::_internal_set_parameter(const TProtoStringType& value) {
- _has_bits_[0] |= 0x00000001u;
- parameter_.Set(value, GetArenaForAllocation());
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.parameter_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorRequest::_internal_mutable_parameter() {
- _has_bits_[0] |= 0x00000001u;
- return parameter_.Mutable(GetArenaForAllocation());
+ _impl_._has_bits_[0] |= 0x00000001u;
+ return _impl_.parameter_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorRequest::release_parameter() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.parameter)
if (!_internal_has_parameter()) {
return nullptr;
}
- _has_bits_[0] &= ~0x00000001u;
- auto* p = parameter_.Release();
+ _impl_._has_bits_[0] &= ~0x00000001u;
+ auto* p = _impl_.parameter_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (parameter_.IsDefault()) {
- parameter_.Set("", GetArenaForAllocation());
+ 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) {
- _has_bits_[0] |= 0x00000001u;
+ _impl_._has_bits_[0] |= 0x00000001u;
} else {
- _has_bits_[0] &= ~0x00000001u;
+ _impl_._has_bits_[0] &= ~0x00000001u;
}
- parameter_.SetAllocated(parameter, GetArenaForAllocation());
+ _impl_.parameter_.SetAllocated(parameter, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (parameter_.IsDefault()) {
- parameter_.Set("", GetArenaForAllocation());
+ 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)
@@ -1290,29 +1310,29 @@ inline void CodeGeneratorRequest::set_allocated_parameter(TProtoStringType* para
// repeated .google.protobuf.FileDescriptorProto proto_file = 15;
inline int CodeGeneratorRequest::_internal_proto_file_size() const {
- return proto_file_.size();
+ return _impl_.proto_file_.size();
}
inline int CodeGeneratorRequest::proto_file_size() const {
return _internal_proto_file_size();
}
inline ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* CodeGeneratorRequest::mutable_proto_file(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.proto_file)
- return proto_file_.Mutable(index);
+ return _impl_.proto_file_.Mutable(index);
}
inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto >*
CodeGeneratorRequest::mutable_proto_file() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorRequest.proto_file)
- return &proto_file_;
+ return &_impl_.proto_file_;
}
inline const ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto& CodeGeneratorRequest::_internal_proto_file(int index) const {
- return proto_file_.Get(index);
+ return _impl_.proto_file_.Get(index);
}
inline const ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto& CodeGeneratorRequest::proto_file(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.proto_file)
return _internal_proto_file(index);
}
inline ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* CodeGeneratorRequest::_internal_add_proto_file() {
- return proto_file_.Add();
+ return _impl_.proto_file_.Add();
}
inline ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* CodeGeneratorRequest::add_proto_file() {
::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* _add = _internal_add_proto_file();
@@ -1322,24 +1342,24 @@ inline ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* CodeGeneratorRequest::add_p
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto >&
CodeGeneratorRequest::proto_file() const {
// @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorRequest.proto_file)
- return proto_file_;
+ return _impl_.proto_file_;
}
// optional .google.protobuf.compiler.Version compiler_version = 3;
inline bool CodeGeneratorRequest::_internal_has_compiler_version() const {
- bool value = (_has_bits_[0] & 0x00000002u) != 0;
- PROTOBUF_ASSUME(!value || compiler_version_ != nullptr);
+ 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 (compiler_version_ != nullptr) compiler_version_->Clear();
- _has_bits_[0] &= ~0x00000002u;
+ if (_impl_.compiler_version_ != nullptr) _impl_.compiler_version_->Clear();
+ _impl_._has_bits_[0] &= ~0x00000002u;
}
inline const ::PROTOBUF_NAMESPACE_ID::compiler::Version& CodeGeneratorRequest::_internal_compiler_version() const {
- const ::PROTOBUF_NAMESPACE_ID::compiler::Version* p = compiler_version_;
+ const ::PROTOBUF_NAMESPACE_ID::compiler::Version* p = _impl_.compiler_version_;
return p != nullptr ? *p : reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::compiler::Version&>(
::PROTOBUF_NAMESPACE_ID::compiler::_Version_default_instance_);
}
@@ -1350,20 +1370,20 @@ inline const ::PROTOBUF_NAMESPACE_ID::compiler::Version& CodeGeneratorRequest::c
inline void CodeGeneratorRequest::unsafe_arena_set_allocated_compiler_version(
::PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version) {
if (GetArenaForAllocation() == nullptr) {
- delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(compiler_version_);
+ delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.compiler_version_);
}
- compiler_version_ = compiler_version;
+ _impl_.compiler_version_ = compiler_version;
if (compiler_version) {
- _has_bits_[0] |= 0x00000002u;
+ _impl_._has_bits_[0] |= 0x00000002u;
} else {
- _has_bits_[0] &= ~0x00000002u;
+ _impl_._has_bits_[0] &= ~0x00000002u;
}
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.compiler_version)
}
inline ::PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::release_compiler_version() {
- _has_bits_[0] &= ~0x00000002u;
- ::PROTOBUF_NAMESPACE_ID::compiler::Version* temp = compiler_version_;
- compiler_version_ = nullptr;
+ _impl_._has_bits_[0] &= ~0x00000002u;
+ ::PROTOBUF_NAMESPACE_ID::compiler::Version* temp = _impl_.compiler_version_;
+ _impl_.compiler_version_ = nullptr;
#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE
auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp);
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
@@ -1377,18 +1397,18 @@ inline ::PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::release
}
inline ::PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::unsafe_arena_release_compiler_version() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.compiler_version)
- _has_bits_[0] &= ~0x00000002u;
- ::PROTOBUF_NAMESPACE_ID::compiler::Version* temp = compiler_version_;
- compiler_version_ = nullptr;
+ _impl_._has_bits_[0] &= ~0x00000002u;
+ ::PROTOBUF_NAMESPACE_ID::compiler::Version* temp = _impl_.compiler_version_;
+ _impl_.compiler_version_ = nullptr;
return temp;
}
inline ::PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::_internal_mutable_compiler_version() {
- _has_bits_[0] |= 0x00000002u;
- if (compiler_version_ == nullptr) {
+ _impl_._has_bits_[0] |= 0x00000002u;
+ if (_impl_.compiler_version_ == nullptr) {
auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::Version>(GetArenaForAllocation());
- compiler_version_ = p;
+ _impl_.compiler_version_ = p;
}
- return compiler_version_;
+ return _impl_.compiler_version_;
}
inline ::PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::mutable_compiler_version() {
::PROTOBUF_NAMESPACE_ID::compiler::Version* _msg = _internal_mutable_compiler_version();
@@ -1398,7 +1418,7 @@ inline ::PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::mutable
inline void CodeGeneratorRequest::set_allocated_compiler_version(::PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version) {
::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation();
if (message_arena == nullptr) {
- delete compiler_version_;
+ delete _impl_.compiler_version_;
}
if (compiler_version) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
@@ -1407,11 +1427,11 @@ inline void CodeGeneratorRequest::set_allocated_compiler_version(::PROTOBUF_NAME
compiler_version = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, compiler_version, submessage_arena);
}
- _has_bits_[0] |= 0x00000002u;
+ _impl_._has_bits_[0] |= 0x00000002u;
} else {
- _has_bits_[0] &= ~0x00000002u;
+ _impl_._has_bits_[0] &= ~0x00000002u;
}
- compiler_version_ = compiler_version;
+ _impl_.compiler_version_ = compiler_version;
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.compiler_version)
}
@@ -1421,15 +1441,15 @@ inline void CodeGeneratorRequest::set_allocated_compiler_version(::PROTOBUF_NAME
// optional string name = 1;
inline bool CodeGeneratorResponse_File::_internal_has_name() const {
- bool value = (_has_bits_[0] & 0x00000001u) != 0;
+ 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() {
- name_.ClearToEmpty();
- _has_bits_[0] &= ~0x00000001u;
+ _impl_.name_.ClearToEmpty();
+ _impl_._has_bits_[0] &= ~0x00000001u;
}
inline const TProtoStringType& CodeGeneratorResponse_File::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.name)
@@ -1438,8 +1458,8 @@ inline const TProtoStringType& CodeGeneratorResponse_File::name() const {
template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void CodeGeneratorResponse_File::set_name(ArgT0&& arg0, ArgT... args) {
- _has_bits_[0] |= 0x00000001u;
- name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name)
}
inline TProtoStringType* CodeGeneratorResponse_File::mutable_name() {
@@ -1448,40 +1468,40 @@ inline TProtoStringType* CodeGeneratorResponse_File::mutable_name() {
return _s;
}
inline const TProtoStringType& CodeGeneratorResponse_File::_internal_name() const {
- return name_.Get();
+ return _impl_.name_.Get();
}
inline void CodeGeneratorResponse_File::_internal_set_name(const TProtoStringType& value) {
- _has_bits_[0] |= 0x00000001u;
- name_.Set(value, GetArenaForAllocation());
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.name_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorResponse_File::_internal_mutable_name() {
- _has_bits_[0] |= 0x00000001u;
- return name_.Mutable(GetArenaForAllocation());
+ _impl_._has_bits_[0] |= 0x00000001u;
+ 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()) {
return nullptr;
}
- _has_bits_[0] &= ~0x00000001u;
- auto* p = name_.Release();
+ _impl_._has_bits_[0] &= ~0x00000001u;
+ auto* p = _impl_.name_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault()) {
- name_.Set("", GetArenaForAllocation());
+ 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) {
- _has_bits_[0] |= 0x00000001u;
+ _impl_._has_bits_[0] |= 0x00000001u;
} else {
- _has_bits_[0] &= ~0x00000001u;
+ _impl_._has_bits_[0] &= ~0x00000001u;
}
- name_.SetAllocated(name, GetArenaForAllocation());
+ _impl_.name_.SetAllocated(name, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (name_.IsDefault()) {
- name_.Set("", GetArenaForAllocation());
+ 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)
@@ -1489,15 +1509,15 @@ inline void CodeGeneratorResponse_File::set_allocated_name(TProtoStringType* nam
// optional string insertion_point = 2;
inline bool CodeGeneratorResponse_File::_internal_has_insertion_point() const {
- bool value = (_has_bits_[0] & 0x00000002u) != 0;
+ 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() {
- insertion_point_.ClearToEmpty();
- _has_bits_[0] &= ~0x00000002u;
+ _impl_.insertion_point_.ClearToEmpty();
+ _impl_._has_bits_[0] &= ~0x00000002u;
}
inline const TProtoStringType& CodeGeneratorResponse_File::insertion_point() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
@@ -1506,8 +1526,8 @@ inline const TProtoStringType& CodeGeneratorResponse_File::insertion_point() con
template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void CodeGeneratorResponse_File::set_insertion_point(ArgT0&& arg0, ArgT... args) {
- _has_bits_[0] |= 0x00000002u;
- insertion_point_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ _impl_._has_bits_[0] |= 0x00000002u;
+ _impl_.insertion_point_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
}
inline TProtoStringType* CodeGeneratorResponse_File::mutable_insertion_point() {
@@ -1516,40 +1536,40 @@ inline TProtoStringType* CodeGeneratorResponse_File::mutable_insertion_point() {
return _s;
}
inline const TProtoStringType& CodeGeneratorResponse_File::_internal_insertion_point() const {
- return insertion_point_.Get();
+ return _impl_.insertion_point_.Get();
}
inline void CodeGeneratorResponse_File::_internal_set_insertion_point(const TProtoStringType& value) {
- _has_bits_[0] |= 0x00000002u;
- insertion_point_.Set(value, GetArenaForAllocation());
+ _impl_._has_bits_[0] |= 0x00000002u;
+ _impl_.insertion_point_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorResponse_File::_internal_mutable_insertion_point() {
- _has_bits_[0] |= 0x00000002u;
- return insertion_point_.Mutable(GetArenaForAllocation());
+ _impl_._has_bits_[0] |= 0x00000002u;
+ 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()) {
return nullptr;
}
- _has_bits_[0] &= ~0x00000002u;
- auto* p = insertion_point_.Release();
+ _impl_._has_bits_[0] &= ~0x00000002u;
+ auto* p = _impl_.insertion_point_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (insertion_point_.IsDefault()) {
- insertion_point_.Set("", GetArenaForAllocation());
+ 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) {
- _has_bits_[0] |= 0x00000002u;
+ _impl_._has_bits_[0] |= 0x00000002u;
} else {
- _has_bits_[0] &= ~0x00000002u;
+ _impl_._has_bits_[0] &= ~0x00000002u;
}
- insertion_point_.SetAllocated(insertion_point, GetArenaForAllocation());
+ _impl_.insertion_point_.SetAllocated(insertion_point, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (insertion_point_.IsDefault()) {
- insertion_point_.Set("", GetArenaForAllocation());
+ 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)
@@ -1557,15 +1577,15 @@ inline void CodeGeneratorResponse_File::set_allocated_insertion_point(TProtoStri
// optional string content = 15;
inline bool CodeGeneratorResponse_File::_internal_has_content() const {
- bool value = (_has_bits_[0] & 0x00000004u) != 0;
+ 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() {
- content_.ClearToEmpty();
- _has_bits_[0] &= ~0x00000004u;
+ _impl_.content_.ClearToEmpty();
+ _impl_._has_bits_[0] &= ~0x00000004u;
}
inline const TProtoStringType& CodeGeneratorResponse_File::content() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.content)
@@ -1574,8 +1594,8 @@ inline const TProtoStringType& CodeGeneratorResponse_File::content() const {
template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void CodeGeneratorResponse_File::set_content(ArgT0&& arg0, ArgT... args) {
- _has_bits_[0] |= 0x00000004u;
- content_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ _impl_._has_bits_[0] |= 0x00000004u;
+ _impl_.content_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content)
}
inline TProtoStringType* CodeGeneratorResponse_File::mutable_content() {
@@ -1584,40 +1604,40 @@ inline TProtoStringType* CodeGeneratorResponse_File::mutable_content() {
return _s;
}
inline const TProtoStringType& CodeGeneratorResponse_File::_internal_content() const {
- return content_.Get();
+ return _impl_.content_.Get();
}
inline void CodeGeneratorResponse_File::_internal_set_content(const TProtoStringType& value) {
- _has_bits_[0] |= 0x00000004u;
- content_.Set(value, GetArenaForAllocation());
+ _impl_._has_bits_[0] |= 0x00000004u;
+ _impl_.content_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorResponse_File::_internal_mutable_content() {
- _has_bits_[0] |= 0x00000004u;
- return content_.Mutable(GetArenaForAllocation());
+ _impl_._has_bits_[0] |= 0x00000004u;
+ 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()) {
return nullptr;
}
- _has_bits_[0] &= ~0x00000004u;
- auto* p = content_.Release();
+ _impl_._has_bits_[0] &= ~0x00000004u;
+ auto* p = _impl_.content_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (content_.IsDefault()) {
- content_.Set("", GetArenaForAllocation());
+ 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) {
- _has_bits_[0] |= 0x00000004u;
+ _impl_._has_bits_[0] |= 0x00000004u;
} else {
- _has_bits_[0] &= ~0x00000004u;
+ _impl_._has_bits_[0] &= ~0x00000004u;
}
- content_.SetAllocated(content, GetArenaForAllocation());
+ _impl_.content_.SetAllocated(content, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (content_.IsDefault()) {
- content_.Set("", GetArenaForAllocation());
+ 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)
@@ -1625,15 +1645,15 @@ inline void CodeGeneratorResponse_File::set_allocated_content(TProtoStringType*
// optional .google.protobuf.GeneratedCodeInfo generated_code_info = 16;
inline bool CodeGeneratorResponse_File::_internal_has_generated_code_info() const {
- bool value = (_has_bits_[0] & 0x00000008u) != 0;
- PROTOBUF_ASSUME(!value || generated_code_info_ != nullptr);
+ 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 = generated_code_info_;
+ const ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* p = _impl_.generated_code_info_;
return p != nullptr ? *p : reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo&>(
::PROTOBUF_NAMESPACE_ID::_GeneratedCodeInfo_default_instance_);
}
@@ -1644,20 +1664,20 @@ inline const ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo& CodeGeneratorResponse_F
inline void CodeGeneratorResponse_File::unsafe_arena_set_allocated_generated_code_info(
::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info) {
if (GetArenaForAllocation() == nullptr) {
- delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(generated_code_info_);
+ delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.generated_code_info_);
}
- generated_code_info_ = generated_code_info;
+ _impl_.generated_code_info_ = generated_code_info;
if (generated_code_info) {
- _has_bits_[0] |= 0x00000008u;
+ _impl_._has_bits_[0] |= 0x00000008u;
} else {
- _has_bits_[0] &= ~0x00000008u;
+ _impl_._has_bits_[0] &= ~0x00000008u;
}
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.generated_code_info)
}
inline ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::release_generated_code_info() {
- _has_bits_[0] &= ~0x00000008u;
- ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* temp = generated_code_info_;
- generated_code_info_ = nullptr;
+ _impl_._has_bits_[0] &= ~0x00000008u;
+ ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* temp = _impl_.generated_code_info_;
+ _impl_.generated_code_info_ = nullptr;
#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE
auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp);
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
@@ -1671,18 +1691,18 @@ inline ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::r
}
inline ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::unsafe_arena_release_generated_code_info() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.generated_code_info)
- _has_bits_[0] &= ~0x00000008u;
- ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* temp = generated_code_info_;
- generated_code_info_ = nullptr;
+ _impl_._has_bits_[0] &= ~0x00000008u;
+ ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* temp = _impl_.generated_code_info_;
+ _impl_.generated_code_info_ = nullptr;
return temp;
}
inline ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::_internal_mutable_generated_code_info() {
- _has_bits_[0] |= 0x00000008u;
- if (generated_code_info_ == nullptr) {
+ _impl_._has_bits_[0] |= 0x00000008u;
+ if (_impl_.generated_code_info_ == nullptr) {
auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo>(GetArenaForAllocation());
- generated_code_info_ = p;
+ _impl_.generated_code_info_ = p;
}
- return generated_code_info_;
+ return _impl_.generated_code_info_;
}
inline ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::mutable_generated_code_info() {
::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* _msg = _internal_mutable_generated_code_info();
@@ -1692,7 +1712,7 @@ inline ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::m
inline void CodeGeneratorResponse_File::set_allocated_generated_code_info(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info) {
::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation();
if (message_arena == nullptr) {
- delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(generated_code_info_);
+ delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.generated_code_info_);
}
if (generated_code_info) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
@@ -1702,11 +1722,11 @@ inline void CodeGeneratorResponse_File::set_allocated_generated_code_info(::PROT
generated_code_info = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, generated_code_info, submessage_arena);
}
- _has_bits_[0] |= 0x00000008u;
+ _impl_._has_bits_[0] |= 0x00000008u;
} else {
- _has_bits_[0] &= ~0x00000008u;
+ _impl_._has_bits_[0] &= ~0x00000008u;
}
- generated_code_info_ = generated_code_info;
+ _impl_.generated_code_info_ = generated_code_info;
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.generated_code_info)
}
@@ -1716,15 +1736,15 @@ inline void CodeGeneratorResponse_File::set_allocated_generated_code_info(::PROT
// optional string error = 1;
inline bool CodeGeneratorResponse::_internal_has_error() const {
- bool value = (_has_bits_[0] & 0x00000001u) != 0;
+ 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() {
- error_.ClearToEmpty();
- _has_bits_[0] &= ~0x00000001u;
+ _impl_.error_.ClearToEmpty();
+ _impl_._has_bits_[0] &= ~0x00000001u;
}
inline const TProtoStringType& CodeGeneratorResponse::error() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.error)
@@ -1733,8 +1753,8 @@ inline const TProtoStringType& CodeGeneratorResponse::error() const {
template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void CodeGeneratorResponse::set_error(ArgT0&& arg0, ArgT... args) {
- _has_bits_[0] |= 0x00000001u;
- error_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.error_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error)
}
inline TProtoStringType* CodeGeneratorResponse::mutable_error() {
@@ -1743,40 +1763,40 @@ inline TProtoStringType* CodeGeneratorResponse::mutable_error() {
return _s;
}
inline const TProtoStringType& CodeGeneratorResponse::_internal_error() const {
- return error_.Get();
+ return _impl_.error_.Get();
}
inline void CodeGeneratorResponse::_internal_set_error(const TProtoStringType& value) {
- _has_bits_[0] |= 0x00000001u;
- error_.Set(value, GetArenaForAllocation());
+ _impl_._has_bits_[0] |= 0x00000001u;
+ _impl_.error_.Set(value, GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorResponse::_internal_mutable_error() {
- _has_bits_[0] |= 0x00000001u;
- return error_.Mutable(GetArenaForAllocation());
+ _impl_._has_bits_[0] |= 0x00000001u;
+ return _impl_.error_.Mutable(GetArenaForAllocation());
}
inline TProtoStringType* CodeGeneratorResponse::release_error() {
// @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.error)
if (!_internal_has_error()) {
return nullptr;
}
- _has_bits_[0] &= ~0x00000001u;
- auto* p = error_.Release();
+ _impl_._has_bits_[0] &= ~0x00000001u;
+ auto* p = _impl_.error_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (error_.IsDefault()) {
- error_.Set("", GetArenaForAllocation());
+ 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) {
- _has_bits_[0] |= 0x00000001u;
+ _impl_._has_bits_[0] |= 0x00000001u;
} else {
- _has_bits_[0] &= ~0x00000001u;
+ _impl_._has_bits_[0] &= ~0x00000001u;
}
- error_.SetAllocated(error, GetArenaForAllocation());
+ _impl_.error_.SetAllocated(error, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
- if (error_.IsDefault()) {
- error_.Set("", GetArenaForAllocation());
+ 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)
@@ -1784,26 +1804,26 @@ inline void CodeGeneratorResponse::set_allocated_error(TProtoStringType* error)
// optional uint64 supported_features = 2;
inline bool CodeGeneratorResponse::_internal_has_supported_features() const {
- bool value = (_has_bits_[0] & 0x00000002u) != 0;
+ 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() {
- supported_features_ = arc_ui64{0u};
- _has_bits_[0] &= ~0x00000002u;
+ _impl_.supported_features_ = arc_ui64{0u};
+ _impl_._has_bits_[0] &= ~0x00000002u;
}
inline arc_ui64 CodeGeneratorResponse::_internal_supported_features() const {
- return supported_features_;
+ return _impl_.supported_features_;
}
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) {
- _has_bits_[0] |= 0x00000002u;
- supported_features_ = value;
+ _impl_._has_bits_[0] |= 0x00000002u;
+ _impl_.supported_features_ = value;
}
inline void CodeGeneratorResponse::set_supported_features(arc_ui64 value) {
_internal_set_supported_features(value);
@@ -1812,32 +1832,32 @@ inline void CodeGeneratorResponse::set_supported_features(arc_ui64 value) {
// repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15;
inline int CodeGeneratorResponse::_internal_file_size() const {
- return file_.size();
+ return _impl_.file_.size();
}
inline int CodeGeneratorResponse::file_size() const {
return _internal_file_size();
}
inline void CodeGeneratorResponse::clear_file() {
- file_.Clear();
+ _impl_.file_.Clear();
}
inline ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::mutable_file(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.file)
- return file_.Mutable(index);
+ return _impl_.file_.Mutable(index);
}
inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >*
CodeGeneratorResponse::mutable_file() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorResponse.file)
- return &file_;
+ return &_impl_.file_;
}
inline const ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File& CodeGeneratorResponse::_internal_file(int index) const {
- return file_.Get(index);
+ return _impl_.file_.Get(index);
}
inline const ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File& CodeGeneratorResponse::file(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.file)
return _internal_file(index);
}
inline ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::_internal_add_file() {
- return file_.Add();
+ return _impl_.file_.Add();
}
inline ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::add_file() {
::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* _add = _internal_add_file();
@@ -1847,7 +1867,7 @@ inline ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* CodeGenera
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >&
CodeGeneratorResponse::file() const {
// @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorResponse.file)
- return file_;
+ return _impl_.file_;
}
#ifdef __GNUC__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/python/generator.cc
index 7c723febb3..d1e4de467b 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/generator.cc
@@ -42,7 +42,7 @@
// performance-minded Python code leverage the fast C++ implementation
// directly.
-#include <google/protobuf/compiler/python/python_generator.h>
+#include <google/protobuf/compiler/python/generator.h>
#include <algorithm>
#include <limits>
@@ -54,15 +54,15 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/compiler/python/python_helpers.h>
-#include <google/protobuf/compiler/python/python_pyi_generator.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/zero_copy_stream.h>
-#include <google/protobuf/descriptor.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/stubs/substitute.h>
+#include <google/protobuf/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>
namespace google {
namespace protobuf {
@@ -91,11 +91,6 @@ TProtoStringType ModuleAlias(const TProtoStringType& filename) {
const char kDescriptorKey[] = "DESCRIPTOR";
-// Does the file have top-level enums?
-inline bool HasTopLevelEnums(const FileDescriptor* file) {
- return file->enum_type_count() > 0;
-}
-
// file output by this generator.
void PrintTopBoilerplate(io::Printer* printer, const FileDescriptor* file,
bool descriptor_proto) {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/python/generator.h
index 359d802aee..8111bf733f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/generator.h
@@ -37,8 +37,8 @@
#include <string>
-#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/stubs/mutex.h>
+#include <google/protobuf/compiler/code_generator.h>
// Must be included last.
#include <google/protobuf/port_def.inc>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_helpers.cc b/contrib/libs/protoc/src/google/protobuf/compiler/python/helpers.cc
index 7a9721c02c..ee7461bc83 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_helpers.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/helpers.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/python/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/stubs/strutil.h>
#include <google/protobuf/descriptor.pb.h>
namespace google {
@@ -69,7 +69,7 @@ const char* const kKeywords[] = {
"del", "elif", "else", "except", "finally", "for",
"from", "global", "if", "import", "in", "is",
"lambda", "nonlocal", "not", "or", "pass", "raise",
- "return", "try", "while", "with", "yield", "print",
+ "return", "try", "while", "with", "yield",
};
const char* const* kKeywordsEnd =
kKeywords + (sizeof(kKeywords) / sizeof(kKeywords[0]));
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_helpers.h b/contrib/libs/protoc/src/google/protobuf/compiler/python/helpers.h
index 8745698acf..8745698acf 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_helpers.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/helpers.h
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_pyi_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/python/pyi_generator.cc
index 89cfbf86fe..242cdd71f2 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_pyi_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/pyi_generator.cc
@@ -28,16 +28,16 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <google/protobuf/compiler/python/python_pyi_generator.h>
+#include <google/protobuf/compiler/python/pyi_generator.h>
#include <string>
-#include <google/protobuf/compiler/python/python_helpers.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/zero_copy_stream.h>
-#include <google/protobuf/descriptor.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/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 {
@@ -64,12 +64,21 @@ void PyiGenerator::PrintItemMap(
}
template <typename DescriptorT>
-TProtoStringType PyiGenerator::ModuleLevelName(const DescriptorT& descriptor) const {
+TProtoStringType PyiGenerator::ModuleLevelName(
+ const DescriptorT& descriptor,
+ const std::map<TProtoStringType, TProtoStringType>& import_map) const {
TProtoStringType name = NamePrefixedWithNestedTypes(descriptor, ".");
if (descriptor.file() != file_) {
- TProtoStringType module_name = ModuleName(descriptor.file()->name());
- std::vector<TProtoStringType> tokens = Split(module_name, ".");
- name = "_" + tokens.back() + "." + name;
+ TProtoStringType module_alias;
+ TProtoStringType filename = descriptor.file()->name();
+ 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();
+ } else {
+ module_alias = import_map.at(filename);
+ }
+ name = module_alias + "." + name;
}
return name;
}
@@ -82,9 +91,22 @@ struct ImportModules {
bool has_extendable = false; // _python_message
bool has_mapping = false; // typing.Mapping
bool has_optional = false; // typing.Optional
- bool has_union = false; // typing.Uion
+ bool has_union = false; // typing.Union
+ bool has_well_known_type = false;
};
+// Checks whether a descriptor name matches a well-known type.
+bool IsWellKnownType(const TProtoStringType& name) {
+ // LINT.IfChange(wktbases)
+ return (name == "google.protobuf.Any" ||
+ name == "google.protobuf.Duration" ||
+ name == "google.protobuf.FieldMask" ||
+ name == "google.protobuf.ListValue" ||
+ name == "google.protobuf.Struct" ||
+ name == "google.protobuf.Timestamp");
+ // LINT.ThenChange(//depot/google3/net/proto2/python/internal/well_known_types.py:wktbases)
+}
+
// Checks what modules should be imported for this message
// descriptor.
void CheckImportModules(const Descriptor* descriptor,
@@ -95,6 +117,9 @@ void CheckImportModules(const Descriptor* descriptor,
if (descriptor->enum_type_count() > 0) {
import_modules->has_enums = true;
}
+ if (IsWellKnownType(descriptor->full_name())) {
+ import_modules->has_well_known_type = true;
+ }
for (int i = 0; i < descriptor->field_count(); ++i) {
const FieldDescriptor* field = descriptor->field(i);
if (IsPythonKeyword(field->name())) {
@@ -129,23 +154,44 @@ void CheckImportModules(const Descriptor* descriptor,
}
}
+void PyiGenerator::PrintImportForDescriptor(
+ const FileDescriptor& desc,
+ std::map<TProtoStringType, TProtoStringType>* import_map,
+ std::set<TProtoStringType>* seen_aliases) const {
+ const TProtoStringType& filename = desc.name();
+ TProtoStringType module_name = StrippedModuleName(filename);
+ size_t last_dot_pos = module_name.rfind('.');
+ TProtoStringType import_statement;
+ if (last_dot_pos == TProtoStringType::npos) {
+ import_statement = "import " + module_name;
+ } else {
+ import_statement = "from " + module_name.substr(0, last_dot_pos) +
+ " import " + module_name.substr(last_dot_pos + 1);
+ module_name = module_name.substr(last_dot_pos + 1);
+ }
+ TProtoStringType alias = "_" + 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";
+ }
+ printer_->Print("$statement$ as $alias$\n", "statement",
+ import_statement, "alias", alias);
+ (*import_map)[filename] = alias;
+ seen_aliases->insert(alias);
+}
+
void PyiGenerator::PrintImports(
- std::map<TProtoStringType, TProtoStringType>* item_map) const {
+ std::map<TProtoStringType, TProtoStringType>* item_map,
+ std::map<TProtoStringType, TProtoStringType>* import_map) const {
// Prints imported dependent _pb2 files.
+ std::set<TProtoStringType> seen_aliases;
for (int i = 0; i < file_->dependency_count(); ++i) {
- const TProtoStringType& filename = file_->dependency(i)->name();
- TProtoStringType module_name = StrippedModuleName(filename);
- size_t last_dot_pos = module_name.rfind('.');
- TProtoStringType import_statement;
- if (last_dot_pos == TProtoStringType::npos) {
- import_statement = "import " + module_name;
- } else {
- import_statement = "from " + module_name.substr(0, last_dot_pos) +
- " import " + module_name.substr(last_dot_pos + 1);
- module_name = module_name.substr(last_dot_pos + 1);
+ const FileDescriptor* dep = file_->dependency(i);
+ PrintImportForDescriptor(*dep, import_map, &seen_aliases);
+ for (int j = 0; j < dep->public_dependency_count(); ++j) {
+ PrintImportForDescriptor(
+ *dep->public_dependency(j), import_map, &seen_aliases);
}
- printer_->Print("$statement$ as _$module_name$\n", "statement",
- import_statement, "module_name", module_name);
}
// Checks what modules should be imported.
@@ -177,6 +223,11 @@ void PyiGenerator::PrintImports(
"from google.protobuf.internal import python_message"
" as _python_message\n");
}
+ if (import_modules.has_well_known_type) {
+ printer_->Print(
+ "from google.protobuf.internal import well_known_types"
+ " as _well_known_types\n");
+ }
printer_->Print(
"from google.protobuf import"
" descriptor as _descriptor\n");
@@ -190,21 +241,18 @@ void PyiGenerator::PrintImports(
" _service\n");
}
printer_->Print("from typing import ");
- printer_->Print("ClassVar");
+ printer_->Print("ClassVar as _ClassVar");
if (import_modules.has_iterable) {
- printer_->Print(", Iterable");
+ printer_->Print(", Iterable as _Iterable");
}
if (import_modules.has_mapping) {
- printer_->Print(", Mapping");
+ printer_->Print(", Mapping as _Mapping");
}
if (import_modules.has_optional) {
- printer_->Print(", Optional");
- }
- if (file_->service_count() > 0) {
- printer_->Print(", Text");
+ printer_->Print(", Optional as _Optional");
}
if (import_modules.has_union) {
- printer_->Print(", Union");
+ printer_->Print(", Union as _Union");
}
printer_->Print("\n\n");
@@ -229,7 +277,7 @@ void PyiGenerator::PrintImports(
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);
+ ModuleLevelName(*enum_descriptor, *import_map);
}
}
// Top level extensions for public imports
@@ -248,9 +296,10 @@ void PyiGenerator::PrintEnum(const EnumDescriptor& enum_descriptor) const {
// 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>* item_map,
+ const std::map<TProtoStringType, TProtoStringType>& import_map) const {
// enum values
- TProtoStringType module_enum_name = ModuleLevelName(enum_descriptor);
+ TProtoStringType module_enum_name = ModuleLevelName(enum_descriptor, import_map);
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;
@@ -275,13 +324,15 @@ void PyiGenerator::AddExtensions(
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)[constant_name] = "_ClassVar[int]";
(*item_map)[extension_field->name()] = "_descriptor.FieldDescriptor";
}
}
// Returns the string format of a field's cpp_type
-TProtoStringType PyiGenerator::GetFieldType(const FieldDescriptor& field_des) const {
+TProtoStringType PyiGenerator::GetFieldType(
+ const FieldDescriptor& field_des, const Descriptor& containing_des,
+ const std::map<TProtoStringType, TProtoStringType>& import_map) const {
switch (field_des.cpp_type()) {
case FieldDescriptor::CPPTYPE_INT32:
case FieldDescriptor::CPPTYPE_UINT32:
@@ -294,29 +345,48 @@ TProtoStringType PyiGenerator::GetFieldType(const FieldDescriptor& field_des) co
case FieldDescriptor::CPPTYPE_BOOL:
return "bool";
case FieldDescriptor::CPPTYPE_ENUM:
- return ModuleLevelName(*field_des.enum_type());
+ return ModuleLevelName(*field_des.enum_type(), import_map);
case FieldDescriptor::CPPTYPE_STRING:
if (field_des.type() == FieldDescriptor::TYPE_STRING) {
return "str";
} else {
return "bytes";
}
- case FieldDescriptor::CPPTYPE_MESSAGE:
- return ModuleLevelName(*field_des.message_type());
+ case FieldDescriptor::CPPTYPE_MESSAGE: {
+ // 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);
+ if ((containing_des.containing_type() != nullptr &&
+ name == containing_des.name())) {
+ TProtoStringType module = ModuleName(field_des.file()->name());
+ name = module + "." + name;
+ }
+ return name;
+ }
default:
- GOOGLE_LOG(FATAL) << "Unsuppoted field type.";
+ GOOGLE_LOG(FATAL) << "Unsupported field type.";
}
return "";
}
-void PyiGenerator::PrintMessage(const Descriptor& message_descriptor,
- bool is_nested) const {
+void PyiGenerator::PrintMessage(
+ const Descriptor& message_descriptor, bool is_nested,
+ const std::map<TProtoStringType, TProtoStringType>& import_map) const {
if (!is_nested) {
printer_->Print("\n");
}
TProtoStringType class_name = message_descriptor.name();
- printer_->Print("class $class_name$(_message.Message):\n", "class_name",
- class_name);
+ TProtoStringType extra_base;
+ // 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();
+ } else {
+ extra_base = "";
+ }
+ printer_->Print("class $class_name$(_message.Message$extra_base$):\n",
+ "class_name", class_name, "extra_base", extra_base);
printer_->Indent();
printer_->Indent();
@@ -361,7 +431,7 @@ void PyiGenerator::PrintMessage(const Descriptor& message_descriptor,
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);
+ AddEnumValue(*entry, &item_map, import_map);
}
// Prints nested messages
@@ -374,7 +444,7 @@ void PyiGenerator::PrintMessage(const Descriptor& message_descriptor,
SortByName<Descriptor>());
for (const auto& entry : nested_messages) {
- PrintMessage(*entry, true);
+ PrintMessage(*entry, true, import_map);
}
// Adds extensions to item_map which will be ordered and printed later
@@ -384,7 +454,7 @@ void PyiGenerator::PrintMessage(const Descriptor& message_descriptor,
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]";
+ "_ClassVar[int]";
if (IsPythonKeyword(field_des.name())) {
continue;
}
@@ -395,16 +465,16 @@ void PyiGenerator::PrintMessage(const Descriptor& message_descriptor,
field_type = (value_des->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE
? "_containers.MessageMap["
: "_containers.ScalarMap[");
- field_type += GetFieldType(*key_des);
+ field_type += GetFieldType(*key_des, message_descriptor, import_map);
field_type += ", ";
- field_type += GetFieldType(*value_des);
+ field_type += GetFieldType(*value_des, message_descriptor, import_map);
} else {
if (field_des.is_repeated()) {
field_type = (field_des.cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE
? "_containers.RepeatedCompositeFieldContainer["
: "_containers.RepeatedScalarFieldContainer[");
}
- field_type += GetFieldType(field_des);
+ field_type += GetFieldType(field_des, message_descriptor, import_map);
}
if (field_des.is_repeated()) {
@@ -437,26 +507,31 @@ void PyiGenerator::PrintMessage(const Descriptor& message_descriptor,
printer_->Print(", $field_name$: ", "field_name", field_name);
if (field_des->is_repeated() ||
field_des->cpp_type() != FieldDescriptor::CPPTYPE_BOOL) {
- printer_->Print("Optional[");
+ printer_->Print("_Optional[");
}
if (field_des->is_map()) {
const Descriptor* map_entry = field_des->message_type();
- printer_->Print("Mapping[$key_type$, $value_type$]", "key_type",
- GetFieldType(*map_entry->field(0)), "value_type",
- GetFieldType(*map_entry->field(1)));
+ printer_->Print(
+ "_Mapping[$key_type$, $value_type$]", "key_type",
+ GetFieldType(*map_entry->field(0), message_descriptor, import_map),
+ "value_type",
+ GetFieldType(*map_entry->field(1), message_descriptor, import_map));
} else {
if (field_des->is_repeated()) {
- printer_->Print("Iterable[");
+ printer_->Print("_Iterable[");
}
if (field_des->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- printer_->Print("Union[$type_name$, Mapping]", "type_name",
- GetFieldType(*field_des));
+ printer_->Print(
+ "_Union[$type_name$, _Mapping]", "type_name",
+ GetFieldType(*field_des, message_descriptor, import_map));
} else {
if (field_des->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {
- printer_->Print("Union[$type_name$, str]", "type_name",
- ModuleLevelName(*field_des->enum_type()));
+ printer_->Print("_Union[$type_name$, str]", "type_name",
+ ModuleLevelName(*field_des->enum_type(), import_map));
} else {
- printer_->Print("$type_name$", "type_name", GetFieldType(*field_des));
+ printer_->Print(
+ "$type_name$", "type_name",
+ GetFieldType(*field_des, message_descriptor, import_map));
}
}
if (field_des->is_repeated()) {
@@ -478,8 +553,9 @@ void PyiGenerator::PrintMessage(const Descriptor& message_descriptor,
printer_->Outdent();
}
-void PyiGenerator::PrintMessages() const {
- // Order the descriptors by name to have same output with proto_to_pyi.py
+void PyiGenerator::PrintMessages(
+ const std::map<TProtoStringType, TProtoStringType>& import_map) 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) {
@@ -488,7 +564,7 @@ void PyiGenerator::PrintMessages() const {
std::sort(messages.begin(), messages.end(), SortByName<Descriptor>());
for (const auto& entry : messages) {
- PrintMessage(*entry, false);
+ PrintMessage(*entry, false, import_map);
}
}
@@ -517,9 +593,6 @@ bool PyiGenerator::Generate(const FileDescriptor* file,
MutexLock lock(&mutex_);
// Calculate file name.
file_ = file;
- // proto_to_pyi.py may set the output file name directly. To replace
- // proto_to_pyi.py in google3, protoc also accept --pyi_out to set
- // the output file name.
TProtoStringType filename =
parameter.empty() ? GetFileName(file, ".pyi") : parameter;
@@ -534,17 +607,22 @@ bool PyiGenerator::Generate(const FileDescriptor* file,
// Adds "DESCRIPTOR" into item_map.
item_map["DESCRIPTOR"] = "_descriptor.FileDescriptor";
- PrintImports(&item_map);
+
+ // import_map will be a mapping from filename to module alias, e.g.
+ // "google3/foo/bar.py" -> "_bar"
+ std::map<TProtoStringType, TProtoStringType> import_map;
+
+ PrintImports(&item_map, &import_map);
// Adds top level enum values to item_map.
for (int i = 0; i < file_->enum_type_count(); ++i) {
- AddEnumValue(*file_->enum_type(i), &item_map);
+ AddEnumValue(*file_->enum_type(i), &item_map, import_map);
}
// Adds top level extensions to item_map.
AddExtensions(*file_, &item_map);
// Prints item map
PrintItemMap(item_map);
- PrintMessages();
+ PrintMessages(import_map);
PrintTopLevelEnums();
if (HasGenericServices(file)) {
PrintServices();
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_pyi_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/python/pyi_generator.h
index d7f5437e49..c9bf296166 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_pyi_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/pyi_generator.h
@@ -36,10 +36,11 @@
#define GOOGLE_PROTOBUF_COMPILER_PYTHON_PYI_GENERATOR_H__
#include <map>
+#include <set>
#include <string>
-#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/stubs/mutex.h>
+#include <google/protobuf/compiler/code_generator.h>
// Must be included last.
#include <google/protobuf/port_def.inc>
@@ -65,26 +66,41 @@ class PROTOC_EXPORT PyiGenerator : public google::protobuf::compiler::CodeGenera
~PyiGenerator() override;
// CodeGenerator methods.
+ uint64_t GetSupportedFeatures() const override {
+ // Code generators must explicitly support proto3 optional.
+ return CodeGenerator::FEATURE_PROTO3_OPTIONAL;
+ }
bool Generate(const FileDescriptor* file, const TProtoStringType& parameter,
GeneratorContext* generator_context,
TProtoStringType* error) const override;
private:
- void PrintImports(std::map<TProtoStringType, TProtoStringType>* item_map) const;
+ void 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>* item_map,
+ const std::map<TProtoStringType, TProtoStringType>& import_map) const;
void PrintTopLevelEnums() const;
template <typename DescriptorT>
void AddExtensions(const DescriptorT& descriptor,
std::map<TProtoStringType, TProtoStringType>* item_map) const;
- void PrintMessages() const;
- void PrintMessage(const Descriptor& message_descriptor, bool is_nested) const;
+ void 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 PrintServices() const;
void PrintItemMap(const std::map<TProtoStringType, TProtoStringType>& item_map) const;
- TProtoStringType GetFieldType(const FieldDescriptor& field_des) const;
+ TProtoStringType GetFieldType(
+ const FieldDescriptor& field_des, const Descriptor& containing_des,
+ const std::map<TProtoStringType, TProtoStringType>& import_map) const;
template <typename DescriptorT>
- TProtoStringType ModuleLevelName(const DescriptorT& descriptor) const;
+ TProtoStringType ModuleLevelName(
+ const DescriptorT& descriptor,
+ const std::map<TProtoStringType, TProtoStringType>& import_map) const;
// Very coarse-grained lock to ensure that Generate() is reentrant.
// Guards file_ and printer_.
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 0e85c22f1e..4a26b6d951 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
@@ -158,7 +158,7 @@ TProtoStringType DefaultValueForField(const FieldDescriptor* field) {
for (int i = 0; i < default_str.length(); ++i) {
// Write the hex form of each byte.
os << "\\x" << std::hex << std::setw(2)
- << ((uint16)((unsigned char)default_str.at(i)));
+ << ((uint16_t)((unsigned char)default_str.at(i)));
}
os << "\".force_encoding(\"ASCII-8BIT\")";
}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.cc b/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.cc
index 1d01fb7e83..d09ceed9dc 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.cc
@@ -45,8 +45,8 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/message.h>
#include <google/protobuf/stubs/substitute.h>
+#include <google/protobuf/message.h>
namespace google {
namespace protobuf {
@@ -167,7 +167,11 @@ bool Subprocess::Communicate(const Message& input, Message* output,
GOOGLE_CHECK(child_handle_ != nullptr) << "Must call Start() first.";
- TProtoStringType input_data = input.SerializeAsString();
+ TProtoStringType input_data;
+ if (!input.SerializeToString(&input_data)) {
+ *error = "Failed to serialize request.";
+ return false;
+ }
TProtoStringType output_data;
int input_pos = 0;
@@ -369,7 +373,11 @@ bool Subprocess::Communicate(const Message& input, Message* output,
// Make sure SIGPIPE is disabled so that if the child dies it doesn't kill us.
SignalHandler* old_pipe_handler = signal(SIGPIPE, SIG_IGN);
- TProtoStringType input_data = input.SerializeAsString();
+ TProtoStringType input_data;
+ if (!input.SerializeToString(&input_data)) {
+ *error = "Failed to serialize request.";
+ return false;
+ }
TProtoStringType output_data;
int input_pos = 0;
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 1ebb2e2508..c25a1e096a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.h
@@ -29,6 +29,8 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Author: kenton@google.com (Kenton Varda)
+#ifndef GOOGLE_PROTOBUF_COMPILER_ZIP_WRITER_H__
+#define GOOGLE_PROTOBUF_COMPILER_ZIP_WRITER_H__
#include <cstdint>
#include <vector>
@@ -63,3 +65,5 @@ class ZipWriter {
} // namespace compiler
} // namespace protobuf
} // namespace google
+
+#endif // GOOGLE_PROTOBUF_COMPILER_ZIP_WRITER_H__