diff options
Diffstat (limited to 'src')
22 files changed, 762 insertions, 250 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 6a91044d..bcd81576 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -169,6 +169,7 @@ nobase_include_HEADERS = \ google/protobuf/compiler/python/python_generator.h \ google/protobuf/compiler/ruby/ruby_generator.h \ google/protobuf/util/type_resolver.h \ + google/protobuf/util/delimited_message_util.h \ google/protobuf/util/field_comparator.h \ google/protobuf/util/field_mask_util.h \ google/protobuf/util/json_util.h \ @@ -267,6 +268,7 @@ libprotobuf_la_SOURCES = \ google/protobuf/io/zero_copy_stream_impl.cc \ google/protobuf/compiler/importer.cc \ google/protobuf/compiler/parser.cc \ + google/protobuf/util/delimited_message_util.cc \ google/protobuf/util/field_comparator.cc \ google/protobuf/util/field_mask_util.cc \ google/protobuf/util/internal/constants.h \ @@ -800,6 +802,7 @@ protobuf_test_SOURCES = \ google/protobuf/compiler/ruby/ruby_generator_unittest.cc \ google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc \ google/protobuf/compiler/csharp/csharp_generator_unittest.cc \ + google/protobuf/util/delimited_message_util_test.cc \ google/protobuf/util/field_comparator_test.cc \ google/protobuf/util/field_mask_util_test.cc \ google/protobuf/util/internal/default_value_objectwriter_test.cc \ diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc index 0e5e2f18..f2e013c0 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.cc +++ b/src/google/protobuf/compiler/cpp/cpp_file.cc @@ -54,6 +54,39 @@ namespace google { namespace protobuf { namespace compiler { namespace cpp { +namespace { +// The list of names that are defined as macros on some platforms. We need to +// #undef them for the generated code to compile. +const char* kMacroNames[] = {"major", "minor"}; + +bool IsMacroName(const string& name) { + // Just do a linear search as the number of elements is very small. + for (int i = 0; i < GOOGLE_ARRAYSIZE(kMacroNames); ++i) { + if (name == kMacroNames[i]) return true; + } + return false; +} + +void CollectMacroNames(const Descriptor* message, vector<string>* names) { + for (int i = 0; i < message->field_count(); ++i) { + const FieldDescriptor* field = message->field(i); + if (IsMacroName(field->name())) { + names->push_back(field->name()); + } + } + for (int i = 0; i < message->nested_type_count(); ++i) { + CollectMacroNames(message->nested_type(i), names); + } +} + +void CollectMacroNames(const FileDescriptor* file, vector<string>* names) { + for (int i = 0; i < file->message_type_count(); ++i) { + CollectMacroNames(file->message_type(i), names); + } +} + + +} // namespace // =================================================================== @@ -103,10 +136,23 @@ FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options) FileGenerator::~FileGenerator() {} +void FileGenerator::GenerateMacroUndefs(io::Printer* printer) { + vector<string> names_to_undef; + CollectMacroNames(file_, &names_to_undef); + for (int i = 0; i < names_to_undef.size(); ++i) { + printer->Print( + "#ifdef $name$\n" + "#undef $name$\n" + "#endif\n", + "name", names_to_undef[i]); + } +} + void FileGenerator::GenerateHeader(io::Printer* printer) { printer->Print( "// @@protoc_insertion_point(includes)\n"); + GenerateMacroUndefs(printer); GenerateForwardDeclarations(printer); diff --git a/src/google/protobuf/compiler/cpp/cpp_file.h b/src/google/protobuf/compiler/cpp/cpp_file.h index 25d6eabf..e3fbb96d 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.h +++ b/src/google/protobuf/compiler/cpp/cpp_file.h @@ -133,6 +133,15 @@ class FileGenerator { void GenerateProto2NamespaceEnumSpecializations(io::Printer* printer); + // Sometimes the names we use in a .proto file happen to be defined as macros + // on some platforms (e.g., macro/minor used in plugin.proto are defined as + // macros in sys/types.h on FreeBSD and a few other platforms). To make the + // generated code compile on these platforms, we either have to undef the + // macro for these few platforms, or rename the field name for all platforms. + // Since these names are part of protobuf public API, renaming is generally + // a breaking change so we prefer the #undef approach. + void GenerateMacroUndefs(io::Printer* printer); + const FileDescriptor* file_; const Options options_; diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc index 6274ba29..1373ffc2 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message.cc @@ -1462,9 +1462,9 @@ GenerateClassDefinition(io::Printer* printer) { // Some InitDefault and Shutdown are defined as static member functions of // TableStruct such that they are also allowed to access private members. printer->Print( - "friend struct $dllexport_decl$ $file_namespace$::TableStruct;\n", + "friend struct $file_namespace$::TableStruct;\n", // Vars. - "dllexport_decl", options_.dllexport_decl, "file_namespace", + "file_namespace", FileLevelNamespace(descriptor_->file()->name())); printer->Outdent(); diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 7f35d712..db72ea1a 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -90,7 +90,7 @@ std::string MessagePrefix(const Descriptor* message) { message->file()->package() == "google.protobuf") { return "GPB"; } else { - return ""; + return (message->file()->options()).php_class_prefix(); } } @@ -103,8 +103,12 @@ std::string MessageName(const Descriptor* message, bool is_descriptor) { } message_name = MessagePrefix(message) + message_name; - return PhpName(message->file()->package(), is_descriptor) + '\\' + - message_name; + if (message->file()->package() == "") { + return message_name; + } else { + return PhpName(message->file()->package(), is_descriptor) + '\\' + + message_name; + } } std::string MessageFullName(const Descriptor* message, bool is_descriptor) { diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 1b91daca..ff8b949f 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -30,6 +30,12 @@ #include <google/protobuf/unknown_field_set.h> #include <google/protobuf/descriptor.pb.h> // @@protoc_insertion_point(includes) +#ifdef major +#undef major +#endif +#ifdef minor +#undef minor +#endif namespace google { namespace protobuf { class DescriptorProto; @@ -270,7 +276,7 @@ class LIBPROTOC_EXPORT Version : public ::google::protobuf::Message /* @@protoc_ ::google::protobuf::int32 major_; ::google::protobuf::int32 minor_; ::google::protobuf::int32 patch_; - friend struct LIBPROTOC_EXPORT protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -421,7 +427,7 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto > proto_file_; ::google::protobuf::internal::ArenaStringPtr parameter_; ::google::protobuf::compiler::Version* compiler_version_; - friend struct LIBPROTOC_EXPORT protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -560,7 +566,7 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::internal::ArenaStringPtr insertion_point_; ::google::protobuf::internal::ArenaStringPtr content_; - friend struct LIBPROTOC_EXPORT protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -678,7 +684,7 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File > file_; ::google::protobuf::internal::ArenaStringPtr error_; - friend struct LIBPROTOC_EXPORT protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; }; // =================================================================== diff --git a/src/google/protobuf/compiler/zip_writer.cc b/src/google/protobuf/compiler/zip_writer.cc index 458cced2..07d52b18 100644 --- a/src/google/protobuf/compiler/zip_writer.cc +++ b/src/google/protobuf/compiler/zip_writer.cc @@ -28,36 +28,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// 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: ambrose@google.com (Ambrose Feinstein), // kenton@google.com (Kenton Varda) // diff --git a/src/google/protobuf/compiler/zip_writer.h b/src/google/protobuf/compiler/zip_writer.h index 03db4d57..737f4d42 100644 --- a/src/google/protobuf/compiler/zip_writer.h +++ b/src/google/protobuf/compiler/zip_writer.h @@ -28,36 +28,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// 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) #include <vector> diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 2a270d65..57fbfd86 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -252,22 +252,24 @@ const ::google::protobuf::uint32 TableStruct::offsets[] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, objc_class_prefix_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_namespace_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, swift_prefix_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, php_class_prefix_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, uninterpreted_option_), 0, 1, - 6, 7, 8, - 14, - 2, 9, + 15, + 2, 10, 11, 12, 13, + 14, 3, 4, 5, + 6, ~0u, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _has_bits_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _internal_metadata_), @@ -421,20 +423,20 @@ static const ::google::protobuf::internal::MigrationSchema schemas[] = { { 116, 123, sizeof(EnumValueDescriptorProto)}, { 126, 133, sizeof(ServiceDescriptorProto)}, { 136, 146, sizeof(MethodDescriptorProto)}, - { 152, 172, sizeof(FileOptions)}, - { 188, 197, sizeof(MessageOptions)}, - { 202, 213, sizeof(FieldOptions)}, - { 220, 225, sizeof(OneofOptions)}, - { 226, 233, sizeof(EnumOptions)}, - { 236, 242, sizeof(EnumValueOptions)}, - { 244, 250, sizeof(ServiceOptions)}, - { 252, 259, sizeof(MethodOptions)}, - { 262, 268, sizeof(UninterpretedOption_NamePart)}, - { 270, 281, sizeof(UninterpretedOption)}, - { 288, 297, sizeof(SourceCodeInfo_Location)}, - { 302, 307, sizeof(SourceCodeInfo)}, - { 308, 316, sizeof(GeneratedCodeInfo_Annotation)}, - { 320, 325, sizeof(GeneratedCodeInfo)}, + { 152, 173, sizeof(FileOptions)}, + { 190, 199, sizeof(MessageOptions)}, + { 204, 215, sizeof(FieldOptions)}, + { 222, 227, sizeof(OneofOptions)}, + { 228, 235, sizeof(EnumOptions)}, + { 238, 244, sizeof(EnumValueOptions)}, + { 246, 252, sizeof(ServiceOptions)}, + { 254, 261, sizeof(MethodOptions)}, + { 264, 270, sizeof(UninterpretedOption_NamePart)}, + { 272, 283, sizeof(UninterpretedOption)}, + { 290, 299, sizeof(SourceCodeInfo_Location)}, + { 304, 309, sizeof(SourceCodeInfo)}, + { 310, 318, sizeof(GeneratedCodeInfo_Annotation)}, + { 322, 327, sizeof(GeneratedCodeInfo)}, }; static ::google::protobuf::Message const * const file_default_instances[] = { @@ -662,7 +664,7 @@ void AddDescriptorsImpl() { "\n\013output_type\030\003 \001(\t\022/\n\007options\030\004 \001(\0132\036.g" "oogle.protobuf.MethodOptions\022\037\n\020client_s" "treaming\030\005 \001(\010:\005false\022\037\n\020server_streamin" - "g\030\006 \001(\010:\005false\"\232\005\n\013FileOptions\022\024\n\014java_p" + "g\030\006 \001(\010:\005false\"\264\005\n\013FileOptions\022\024\n\014java_p" "ackage\030\001 \001(\t\022\034\n\024java_outer_classname\030\010 \001" "(\t\022\"\n\023java_multiple_files\030\n \001(\010:\005false\022)" "\n\035java_generate_equals_and_hash\030\024 \001(\010B\002\030" @@ -675,70 +677,71 @@ void AddDescriptorsImpl() { "se\022\031\n\ndeprecated\030\027 \001(\010:\005false\022\037\n\020cc_enab" "le_arenas\030\037 \001(\010:\005false\022\031\n\021objc_class_pre" "fix\030$ \001(\t\022\030\n\020csharp_namespace\030% \001(\t\022\024\n\014s" - "wift_prefix\030\' \001(\t\022C\n\024uninterpreted_optio" + "wift_prefix\030\' \001(\t\022\030\n\020php_class_prefix\030( " + "\001(\t\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.goo" + "gle.protobuf.UninterpretedOption\":\n\014Opti" + "mizeMode\022\t\n\005SPEED\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LI" + "TE_RUNTIME\020\003*\t\010\350\007\020\200\200\200\200\002J\004\010&\020\'\"\354\001\n\016Messag" + "eOptions\022&\n\027message_set_wire_format\030\001 \001(" + "\010:\005false\022.\n\037no_standard_descriptor_acces" + "sor\030\002 \001(\010:\005false\022\031\n\ndeprecated\030\003 \001(\010:\005fa" + "lse\022\021\n\tmap_entry\030\007 \001(\010\022C\n\024uninterpreted_" + "option\030\347\007 \003(\0132$.google.protobuf.Uninterp" + "retedOption*\t\010\350\007\020\200\200\200\200\002J\004\010\010\020\t\"\236\003\n\014FieldOp" + "tions\022:\n\005ctype\030\001 \001(\0162#.google.protobuf.F" + "ieldOptions.CType:\006STRING\022\016\n\006packed\030\002 \001(" + "\010\022\?\n\006jstype\030\006 \001(\0162$.google.protobuf.Fiel" + "dOptions.JSType:\tJS_NORMAL\022\023\n\004lazy\030\005 \001(\010" + ":\005false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\023\n\004we" + "ak\030\n \001(\010:\005false\022C\n\024uninterpreted_option\030" + "\347\007 \003(\0132$.google.protobuf.UninterpretedOp" + "tion\"/\n\005CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014S" + "TRING_PIECE\020\002\"5\n\006JSType\022\r\n\tJS_NORMAL\020\000\022\r" + "\n\tJS_STRING\020\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020\200\200\200\200\002J" + "\004\010\004\020\005\"^\n\014OneofOptions\022C\n\024uninterpreted_o" + "ption\030\347\007 \003(\0132$.google.protobuf.Uninterpr" + "etedOption*\t\010\350\007\020\200\200\200\200\002\"\215\001\n\013EnumOptions\022\023\n" + "\013allow_alias\030\002 \001(\010\022\031\n\ndeprecated\030\003 \001(\010:\005" + "false\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.g" + "oogle.protobuf.UninterpretedOption*\t\010\350\007\020" + "\200\200\200\200\002\"}\n\020EnumValueOptions\022\031\n\ndeprecated\030" + "\001 \001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 " + "\003(\0132$.google.protobuf.UninterpretedOptio" + "n*\t\010\350\007\020\200\200\200\200\002\"{\n\016ServiceOptions\022\031\n\ndeprec" + "ated\030! \001(\010:\005false\022C\n\024uninterpreted_optio" "n\030\347\007 \003(\0132$.google.protobuf.Uninterpreted" - "Option\":\n\014OptimizeMode\022\t\n\005SPEED\020\001\022\r\n\tCOD" - "E_SIZE\020\002\022\020\n\014LITE_RUNTIME\020\003*\t\010\350\007\020\200\200\200\200\002J\004\010" - "&\020\'\"\354\001\n\016MessageOptions\022&\n\027message_set_wi" - "re_format\030\001 \001(\010:\005false\022.\n\037no_standard_de" - "scriptor_accessor\030\002 \001(\010:\005false\022\031\n\ndeprec" - "ated\030\003 \001(\010:\005false\022\021\n\tmap_entry\030\007 \001(\010\022C\n\024" - "uninterpreted_option\030\347\007 \003(\0132$.google.pro" - "tobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002J\004\010\010" - "\020\t\"\236\003\n\014FieldOptions\022:\n\005ctype\030\001 \001(\0162#.goo" - "gle.protobuf.FieldOptions.CType:\006STRING\022" - "\016\n\006packed\030\002 \001(\010\022\?\n\006jstype\030\006 \001(\0162$.google" - ".protobuf.FieldOptions.JSType:\tJS_NORMAL" - "\022\023\n\004lazy\030\005 \001(\010:\005false\022\031\n\ndeprecated\030\003 \001(" - "\010:\005false\022\023\n\004weak\030\n \001(\010:\005false\022C\n\024uninter" - "preted_option\030\347\007 \003(\0132$.google.protobuf.U" - "ninterpretedOption\"/\n\005CType\022\n\n\006STRING\020\000\022" - "\010\n\004CORD\020\001\022\020\n\014STRING_PIECE\020\002\"5\n\006JSType\022\r\n" - "\tJS_NORMAL\020\000\022\r\n\tJS_STRING\020\001\022\r\n\tJS_NUMBER" - "\020\002*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005\"^\n\014OneofOptions\022C\n\024u" - "ninterpreted_option\030\347\007 \003(\0132$.google.prot" - "obuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"\215\001\n\013" - "EnumOptions\022\023\n\013allow_alias\030\002 \001(\010\022\031\n\ndepr" - "ecated\030\003 \001(\010:\005false\022C\n\024uninterpreted_opt" - "ion\030\347\007 \003(\0132$.google.protobuf.Uninterpret" - "edOption*\t\010\350\007\020\200\200\200\200\002\"}\n\020EnumValueOptions\022" - "\031\n\ndeprecated\030\001 \001(\010:\005false\022C\n\024uninterpre" - "ted_option\030\347\007 \003(\0132$.google.protobuf.Unin" - "terpretedOption*\t\010\350\007\020\200\200\200\200\002\"{\n\016ServiceOpt" - "ions\022\031\n\ndeprecated\030! \001(\010:\005false\022C\n\024unint" - "erpreted_option\030\347\007 \003(\0132$.google.protobuf" - ".UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"\255\002\n\rMeth" - "odOptions\022\031\n\ndeprecated\030! \001(\010:\005false\022_\n\021" - "idempotency_level\030\" \001(\0162/.google.protobu" - "f.MethodOptions.IdempotencyLevel:\023IDEMPO" - "TENCY_UNKNOWN\022C\n\024uninterpreted_option\030\347\007" - " \003(\0132$.google.protobuf.UninterpretedOpti" - "on\"P\n\020IdempotencyLevel\022\027\n\023IDEMPOTENCY_UN" - "KNOWN\020\000\022\023\n\017NO_SIDE_EFFECTS\020\001\022\016\n\nIDEMPOTE" - "NT\020\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023UninterpretedOption\022" - ";\n\004name\030\002 \003(\0132-.google.protobuf.Uninterp" - "retedOption.NamePart\022\030\n\020identifier_value" - "\030\003 \001(\t\022\032\n\022positive_int_value\030\004 \001(\004\022\032\n\022ne" - "gative_int_value\030\005 \001(\003\022\024\n\014double_value\030\006" - " \001(\001\022\024\n\014string_value\030\007 \001(\014\022\027\n\017aggregate_" - "value\030\010 \001(\t\0323\n\010NamePart\022\021\n\tname_part\030\001 \002" - "(\t\022\024\n\014is_extension\030\002 \002(\010\"\325\001\n\016SourceCodeI" - "nfo\022:\n\010location\030\001 \003(\0132(.google.protobuf." - "SourceCodeInfo.Location\032\206\001\n\010Location\022\020\n\004" - "path\030\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020lead" - "ing_comments\030\003 \001(\t\022\031\n\021trailing_comments\030" - "\004 \001(\t\022!\n\031leading_detached_comments\030\006 \003(\t" - "\"\247\001\n\021GeneratedCodeInfo\022A\n\nannotation\030\001 \003" - "(\0132-.google.protobuf.GeneratedCodeInfo.A" - "nnotation\032O\n\nAnnotation\022\020\n\004path\030\001 \003(\005B\002\020" - "\001\022\023\n\013source_file\030\002 \001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n" - "\003end\030\004 \001(\005B\214\001\n\023com.google.protobufB\020Desc" - "riptorProtosH\001Z>github.com/golang/protob" - "uf/protoc-gen-go/descriptor;descriptor\242\002" - "\003GPB\252\002\032Google.Protobuf.Reflection" + "Option*\t\010\350\007\020\200\200\200\200\002\"\255\002\n\rMethodOptions\022\031\n\nd" + "eprecated\030! \001(\010:\005false\022_\n\021idempotency_le" + "vel\030\" \001(\0162/.google.protobuf.MethodOption" + "s.IdempotencyLevel:\023IDEMPOTENCY_UNKNOWN\022" + "C\n\024uninterpreted_option\030\347\007 \003(\0132$.google." + "protobuf.UninterpretedOption\"P\n\020Idempote" + "ncyLevel\022\027\n\023IDEMPOTENCY_UNKNOWN\020\000\022\023\n\017NO_" + "SIDE_EFFECTS\020\001\022\016\n\nIDEMPOTENT\020\002*\t\010\350\007\020\200\200\200\200" + "\002\"\236\002\n\023UninterpretedOption\022;\n\004name\030\002 \003(\0132" + "-.google.protobuf.UninterpretedOption.Na" + "mePart\022\030\n\020identifier_value\030\003 \001(\t\022\032\n\022posi" + "tive_int_value\030\004 \001(\004\022\032\n\022negative_int_val" + "ue\030\005 \001(\003\022\024\n\014double_value\030\006 \001(\001\022\024\n\014string" + "_value\030\007 \001(\014\022\027\n\017aggregate_value\030\010 \001(\t\0323\n" + "\010NamePart\022\021\n\tname_part\030\001 \002(\t\022\024\n\014is_exten" + "sion\030\002 \002(\010\"\325\001\n\016SourceCodeInfo\022:\n\010locatio" + "n\030\001 \003(\0132(.google.protobuf.SourceCodeInfo" + ".Location\032\206\001\n\010Location\022\020\n\004path\030\001 \003(\005B\002\020\001" + "\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020leading_comments\030\003" + " \001(\t\022\031\n\021trailing_comments\030\004 \001(\t\022!\n\031leadi" + "ng_detached_comments\030\006 \003(\t\"\247\001\n\021Generated" + "CodeInfo\022A\n\nannotation\030\001 \003(\0132-.google.pr" + "otobuf.GeneratedCodeInfo.Annotation\032O\n\nA" + "nnotation\022\020\n\004path\030\001 \003(\005B\002\020\001\022\023\n\013source_fi" + "le\030\002 \001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n\003end\030\004 \001(\005B\214\001\n" + "\023com.google.protobufB\020DescriptorProtosH\001" + "Z>github.com/golang/protobuf/protoc-gen-" + "go/descriptor;descriptor\242\002\003GPB\252\002\032Google." + "Protobuf.Reflection" }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - descriptor, 5553); + descriptor, 5579); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/descriptor.proto", &protobuf_RegisterTypes); ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); @@ -8076,6 +8079,7 @@ const int FileOptions::kCcEnableArenasFieldNumber; const int FileOptions::kObjcClassPrefixFieldNumber; const int FileOptions::kCsharpNamespaceFieldNumber; const int FileOptions::kSwiftPrefixFieldNumber; +const int FileOptions::kPhpClassPrefixFieldNumber; const int FileOptions::kUninterpretedOptionFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -8119,6 +8123,10 @@ FileOptions::FileOptions(const FileOptions& from) if (from.has_swift_prefix()) { swift_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.swift_prefix_); } + php_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_php_class_prefix()) { + php_class_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.php_class_prefix_); + } ::memcpy(&java_multiple_files_, &from.java_multiple_files_, reinterpret_cast<char*>(&optimize_for_) - reinterpret_cast<char*>(&java_multiple_files_) + sizeof(optimize_for_)); @@ -8133,6 +8141,7 @@ void FileOptions::SharedCtor() { objc_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); csharp_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); swift_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + php_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); ::memset(&java_multiple_files_, 0, reinterpret_cast<char*>(&cc_enable_arenas_) - reinterpret_cast<char*>(&java_multiple_files_) + sizeof(cc_enable_arenas_)); optimize_for_ = 1; @@ -8150,6 +8159,7 @@ void FileOptions::SharedDtor() { objc_class_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); csharp_namespace_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); swift_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + php_class_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } void FileOptions::SetCachedSize(int size) const { @@ -8179,7 +8189,7 @@ void FileOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FileOptions) _extensions_.Clear(); uninterpreted_option_.Clear(); - if (_has_bits_[0 / 32] & 63u) { + if (_has_bits_[0 / 32] & 127u) { if (has_java_package()) { GOOGLE_DCHECK(!java_package_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); (*java_package_.UnsafeRawStringPointer())->clear(); @@ -8204,14 +8214,15 @@ void FileOptions::Clear() { GOOGLE_DCHECK(!swift_prefix_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); (*swift_prefix_.UnsafeRawStringPointer())->clear(); } + if (has_php_class_prefix()) { + GOOGLE_DCHECK(!php_class_prefix_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*php_class_prefix_.UnsafeRawStringPointer())->clear(); + } } - if (_has_bits_[0 / 32] & 192u) { - ::memset(&java_multiple_files_, 0, reinterpret_cast<char*>(&java_generate_equals_and_hash_) - - reinterpret_cast<char*>(&java_multiple_files_) + sizeof(java_generate_equals_and_hash_)); - } - if (_has_bits_[8 / 32] & 32512u) { - ::memset(&java_string_check_utf8_, 0, reinterpret_cast<char*>(&cc_enable_arenas_) - - reinterpret_cast<char*>(&java_string_check_utf8_) + sizeof(cc_enable_arenas_)); + java_multiple_files_ = false; + if (_has_bits_[8 / 32] & 65280u) { + ::memset(&java_generate_equals_and_hash_, 0, reinterpret_cast<char*>(&cc_enable_arenas_) - + reinterpret_cast<char*>(&java_generate_equals_and_hash_) + sizeof(cc_enable_arenas_)); optimize_for_ = 1; } _has_bits_.Clear(); @@ -8455,6 +8466,22 @@ bool FileOptions::MergePartialFromCodedStream( break; } + // optional string php_class_prefix = 40; + case 40: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(322u)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_php_class_prefix())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->php_class_prefix().data(), this->php_class_prefix().length(), + ::google::protobuf::internal::WireFormat::PARSE, + "google.protobuf.FileOptions.php_class_prefix"); + } else { + goto handle_unusual; + } + break; + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { if (static_cast< ::google::protobuf::uint8>(tag) == @@ -8605,6 +8632,16 @@ void FileOptions::SerializeWithCachedSizes( 39, this->swift_prefix(), output); } + // optional string php_class_prefix = 40; + if (has_php_class_prefix()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->php_class_prefix().data(), this->php_class_prefix().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "google.protobuf.FileOptions.php_class_prefix"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 40, this->php_class_prefix(), output); + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( @@ -8738,6 +8775,17 @@ void FileOptions::SerializeWithCachedSizes( 39, this->swift_prefix(), target); } + // optional string php_class_prefix = 40; + if (has_php_class_prefix()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->php_class_prefix().data(), this->php_class_prefix().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "google.protobuf.FileOptions.php_class_prefix"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 40, this->php_class_prefix(), target); + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: @@ -8822,18 +8870,25 @@ size_t FileOptions::ByteSizeLong() const { this->swift_prefix()); } + // optional string php_class_prefix = 40; + if (has_php_class_prefix()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->php_class_prefix()); + } + // optional bool java_multiple_files = 10 [default = false]; if (has_java_multiple_files()) { total_size += 1 + 1; } + } + if (_has_bits_[8 / 32] & 65280u) { // optional bool java_generate_equals_and_hash = 20 [deprecated = true]; if (has_java_generate_equals_and_hash()) { total_size += 2 + 1; } - } - if (_has_bits_[8 / 32] & 32512u) { // optional bool java_string_check_utf8 = 27 [default = false]; if (has_java_string_check_utf8()) { total_size += 2 + 1; @@ -8924,14 +8979,18 @@ void FileOptions::MergeFrom(const FileOptions& from) { set_has_swift_prefix(); swift_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.swift_prefix_); } + if (from.has_php_class_prefix()) { + set_has_php_class_prefix(); + php_class_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.php_class_prefix_); + } if (from.has_java_multiple_files()) { set_java_multiple_files(from.java_multiple_files()); } + } + if (from._has_bits_[8 / 32] & 65280u) { if (from.has_java_generate_equals_and_hash()) { set_java_generate_equals_and_hash(from.java_generate_equals_and_hash()); } - } - if (from._has_bits_[8 / 32] & 32512u) { if (from.has_java_string_check_utf8()) { set_java_string_check_utf8(from.java_string_check_utf8()); } @@ -8991,6 +9050,7 @@ void FileOptions::InternalSwap(FileOptions* other) { objc_class_prefix_.Swap(&other->objc_class_prefix_); csharp_namespace_.Swap(&other->csharp_namespace_); swift_prefix_.Swap(&other->swift_prefix_); + php_class_prefix_.Swap(&other->php_class_prefix_); std::swap(java_multiple_files_, other->java_multiple_files_); std::swap(java_generate_equals_and_hash_, other->java_generate_equals_and_hash_); std::swap(java_string_check_utf8_, other->java_string_check_utf8_); @@ -9140,13 +9200,13 @@ void FileOptions::set_allocated_java_outer_classname(::std::string* java_outer_c // optional bool java_multiple_files = 10 [default = false]; bool FileOptions::has_java_multiple_files() const { - return (_has_bits_[0] & 0x00000040u) != 0; + return (_has_bits_[0] & 0x00000080u) != 0; } void FileOptions::set_has_java_multiple_files() { - _has_bits_[0] |= 0x00000040u; + _has_bits_[0] |= 0x00000080u; } void FileOptions::clear_has_java_multiple_files() { - _has_bits_[0] &= ~0x00000040u; + _has_bits_[0] &= ~0x00000080u; } void FileOptions::clear_java_multiple_files() { java_multiple_files_ = false; @@ -9164,13 +9224,13 @@ void FileOptions::set_java_multiple_files(bool value) { // optional bool java_generate_equals_and_hash = 20 [deprecated = true]; bool FileOptions::has_java_generate_equals_and_hash() const { - return (_has_bits_[0] & 0x00000080u) != 0; + return (_has_bits_[0] & 0x00000100u) != 0; } void FileOptions::set_has_java_generate_equals_and_hash() { - _has_bits_[0] |= 0x00000080u; + _has_bits_[0] |= 0x00000100u; } void FileOptions::clear_has_java_generate_equals_and_hash() { - _has_bits_[0] &= ~0x00000080u; + _has_bits_[0] &= ~0x00000100u; } void FileOptions::clear_java_generate_equals_and_hash() { java_generate_equals_and_hash_ = false; @@ -9188,13 +9248,13 @@ void FileOptions::set_java_generate_equals_and_hash(bool value) { // optional bool java_string_check_utf8 = 27 [default = false]; bool FileOptions::has_java_string_check_utf8() const { - return (_has_bits_[0] & 0x00000100u) != 0; + return (_has_bits_[0] & 0x00000200u) != 0; } void FileOptions::set_has_java_string_check_utf8() { - _has_bits_[0] |= 0x00000100u; + _has_bits_[0] |= 0x00000200u; } void FileOptions::clear_has_java_string_check_utf8() { - _has_bits_[0] &= ~0x00000100u; + _has_bits_[0] &= ~0x00000200u; } void FileOptions::clear_java_string_check_utf8() { java_string_check_utf8_ = false; @@ -9212,13 +9272,13 @@ void FileOptions::set_java_string_check_utf8(bool value) { // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; bool FileOptions::has_optimize_for() const { - return (_has_bits_[0] & 0x00004000u) != 0; + return (_has_bits_[0] & 0x00008000u) != 0; } void FileOptions::set_has_optimize_for() { - _has_bits_[0] |= 0x00004000u; + _has_bits_[0] |= 0x00008000u; } void FileOptions::clear_has_optimize_for() { - _has_bits_[0] &= ~0x00004000u; + _has_bits_[0] &= ~0x00008000u; } void FileOptions::clear_optimize_for() { optimize_for_ = 1; @@ -9299,13 +9359,13 @@ void FileOptions::set_allocated_go_package(::std::string* go_package) { // optional bool cc_generic_services = 16 [default = false]; bool FileOptions::has_cc_generic_services() const { - return (_has_bits_[0] & 0x00000200u) != 0; + return (_has_bits_[0] & 0x00000400u) != 0; } void FileOptions::set_has_cc_generic_services() { - _has_bits_[0] |= 0x00000200u; + _has_bits_[0] |= 0x00000400u; } void FileOptions::clear_has_cc_generic_services() { - _has_bits_[0] &= ~0x00000200u; + _has_bits_[0] &= ~0x00000400u; } void FileOptions::clear_cc_generic_services() { cc_generic_services_ = false; @@ -9323,13 +9383,13 @@ void FileOptions::set_cc_generic_services(bool value) { // optional bool java_generic_services = 17 [default = false]; bool FileOptions::has_java_generic_services() const { - return (_has_bits_[0] & 0x00000400u) != 0; + return (_has_bits_[0] & 0x00000800u) != 0; } void FileOptions::set_has_java_generic_services() { - _has_bits_[0] |= 0x00000400u; + _has_bits_[0] |= 0x00000800u; } void FileOptions::clear_has_java_generic_services() { - _has_bits_[0] &= ~0x00000400u; + _has_bits_[0] &= ~0x00000800u; } void FileOptions::clear_java_generic_services() { java_generic_services_ = false; @@ -9347,13 +9407,13 @@ void FileOptions::set_java_generic_services(bool value) { // optional bool py_generic_services = 18 [default = false]; bool FileOptions::has_py_generic_services() const { - return (_has_bits_[0] & 0x00000800u) != 0; + return (_has_bits_[0] & 0x00001000u) != 0; } void FileOptions::set_has_py_generic_services() { - _has_bits_[0] |= 0x00000800u; + _has_bits_[0] |= 0x00001000u; } void FileOptions::clear_has_py_generic_services() { - _has_bits_[0] &= ~0x00000800u; + _has_bits_[0] &= ~0x00001000u; } void FileOptions::clear_py_generic_services() { py_generic_services_ = false; @@ -9371,13 +9431,13 @@ void FileOptions::set_py_generic_services(bool value) { // optional bool deprecated = 23 [default = false]; bool FileOptions::has_deprecated() const { - return (_has_bits_[0] & 0x00001000u) != 0; + return (_has_bits_[0] & 0x00002000u) != 0; } void FileOptions::set_has_deprecated() { - _has_bits_[0] |= 0x00001000u; + _has_bits_[0] |= 0x00002000u; } void FileOptions::clear_has_deprecated() { - _has_bits_[0] &= ~0x00001000u; + _has_bits_[0] &= ~0x00002000u; } void FileOptions::clear_deprecated() { deprecated_ = false; @@ -9395,13 +9455,13 @@ void FileOptions::set_deprecated(bool value) { // optional bool cc_enable_arenas = 31 [default = false]; bool FileOptions::has_cc_enable_arenas() const { - return (_has_bits_[0] & 0x00002000u) != 0; + return (_has_bits_[0] & 0x00004000u) != 0; } void FileOptions::set_has_cc_enable_arenas() { - _has_bits_[0] |= 0x00002000u; + _has_bits_[0] |= 0x00004000u; } void FileOptions::clear_has_cc_enable_arenas() { - _has_bits_[0] &= ~0x00002000u; + _has_bits_[0] &= ~0x00004000u; } void FileOptions::clear_cc_enable_arenas() { cc_enable_arenas_ = false; @@ -9603,6 +9663,68 @@ void FileOptions::set_allocated_swift_prefix(::std::string* swift_prefix) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.swift_prefix) } +// optional string php_class_prefix = 40; +bool FileOptions::has_php_class_prefix() const { + return (_has_bits_[0] & 0x00000040u) != 0; +} +void FileOptions::set_has_php_class_prefix() { + _has_bits_[0] |= 0x00000040u; +} +void FileOptions::clear_has_php_class_prefix() { + _has_bits_[0] &= ~0x00000040u; +} +void FileOptions::clear_php_class_prefix() { + php_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_php_class_prefix(); +} +const ::std::string& FileOptions::php_class_prefix() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_class_prefix) + return php_class_prefix_.GetNoArena(); +} +void FileOptions::set_php_class_prefix(const ::std::string& value) { + set_has_php_class_prefix(); + php_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_class_prefix) +} +#if LANG_CXX11 +void FileOptions::set_php_class_prefix(::std::string&& value) { + set_has_php_class_prefix(); + php_class_prefix_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.php_class_prefix) +} +#endif +void FileOptions::set_php_class_prefix(const char* value) { + set_has_php_class_prefix(); + php_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.php_class_prefix) +} +void FileOptions::set_php_class_prefix(const char* value, size_t size) { + set_has_php_class_prefix(); + php_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast<const char*>(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.php_class_prefix) +} +::std::string* FileOptions::mutable_php_class_prefix() { + set_has_php_class_prefix(); + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.php_class_prefix) + return php_class_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* FileOptions::release_php_class_prefix() { + // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_class_prefix) + clear_has_php_class_prefix(); + return php_class_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void FileOptions::set_allocated_php_class_prefix(::std::string* php_class_prefix) { + if (php_class_prefix != NULL) { + set_has_php_class_prefix(); + } else { + clear_has_php_class_prefix(); + } + php_class_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), php_class_prefix); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_class_prefix) +} + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int FileOptions::uninterpreted_option_size() const { return uninterpreted_option_.size(); diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 73b7a8dd..10708963 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -355,7 +355,7 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto > file_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -619,7 +619,7 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag ::google::protobuf::internal::ArenaStringPtr syntax_; ::google::protobuf::FileOptions* options_; ::google::protobuf::SourceCodeInfo* source_code_info_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -724,7 +724,7 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto mutable int _cached_size_; ::google::protobuf::int32 start_; ::google::protobuf::int32 end_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -829,7 +829,7 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protob mutable int _cached_size_; ::google::protobuf::int32 start_; ::google::protobuf::int32 end_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -1061,7 +1061,7 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* ::google::protobuf::RepeatedPtrField< ::std::string> reserved_name_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::MessageOptions* options_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -1374,7 +1374,7 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa ::google::protobuf::int32 oneof_index_; int label_; int type_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -1489,7 +1489,7 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa mutable int _cached_size_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::OneofOptions* options_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -1617,7 +1617,7 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto > value_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::EnumOptions* options_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -1742,7 +1742,7 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::EnumValueOptions* options_; ::google::protobuf::int32 number_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -1870,7 +1870,7 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto > method_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::ServiceOptions* options_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -2041,7 +2041,7 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess ::google::protobuf::MethodOptions* options_; bool client_streaming_; bool server_streaming_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -2250,6 +2250,21 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p ::std::string* release_swift_prefix(); void set_allocated_swift_prefix(::std::string* swift_prefix); + // optional string php_class_prefix = 40; + bool has_php_class_prefix() const; + void clear_php_class_prefix(); + static const int kPhpClassPrefixFieldNumber = 40; + const ::std::string& php_class_prefix() const; + void set_php_class_prefix(const ::std::string& value); + #if LANG_CXX11 + void set_php_class_prefix(::std::string&& value); + #endif + void set_php_class_prefix(const char* value); + void set_php_class_prefix(const char* value, size_t size); + ::std::string* mutable_php_class_prefix(); + ::std::string* release_php_class_prefix(); + void set_allocated_php_class_prefix(::std::string* php_class_prefix); + // optional bool java_multiple_files = 10 [default = false]; bool has_java_multiple_files() const; void clear_java_multiple_files(); @@ -2346,6 +2361,8 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p void clear_has_csharp_namespace(); void set_has_swift_prefix(); void clear_has_swift_prefix(); + void set_has_php_class_prefix(); + void clear_has_php_class_prefix(); ::google::protobuf::internal::ExtensionSet _extensions_; @@ -2359,6 +2376,7 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p ::google::protobuf::internal::ArenaStringPtr objc_class_prefix_; ::google::protobuf::internal::ArenaStringPtr csharp_namespace_; ::google::protobuf::internal::ArenaStringPtr swift_prefix_; + ::google::protobuf::internal::ArenaStringPtr php_class_prefix_; bool java_multiple_files_; bool java_generate_equals_and_hash_; bool java_string_check_utf8_; @@ -2368,7 +2386,7 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p bool deprecated_; bool cc_enable_arenas_; int optimize_for_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -2509,7 +2527,7 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* bool no_standard_descriptor_accessor_; bool deprecated_; bool map_entry_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -2726,7 +2744,7 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ bool lazy_; bool deprecated_; bool weak_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -2827,7 +2845,7 @@ class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@ ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -2948,7 +2966,7 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool allow_alias_; bool deprecated_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -3059,7 +3077,7 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message / mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool deprecated_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -3170,7 +3188,7 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool deprecated_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -3319,7 +3337,7 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @ ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool deprecated_; int idempotency_level_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -3435,7 +3453,7 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu mutable int _cached_size_; ::google::protobuf::internal::ArenaStringPtr name_part_; bool is_extension_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -3619,7 +3637,7 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag ::google::protobuf::uint64 positive_int_value_; ::google::protobuf::int64 negative_int_value_; double double_value_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -3791,7 +3809,7 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me ::google::protobuf::RepeatedPtrField< ::std::string> leading_detached_comments_; ::google::protobuf::internal::ArenaStringPtr leading_comments_; ::google::protobuf::internal::ArenaStringPtr trailing_comments_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -3891,7 +3909,7 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location > location_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -4028,7 +4046,7 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu ::google::protobuf::internal::ArenaStringPtr source_file_; ::google::protobuf::int32 begin_; ::google::protobuf::int32 end_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -4128,7 +4146,7 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation > annotation_; - friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; + friend struct protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct; }; // =================================================================== @@ -6585,13 +6603,13 @@ inline void FileOptions::set_allocated_java_outer_classname(::std::string* java_ // optional bool java_multiple_files = 10 [default = false]; inline bool FileOptions::has_java_multiple_files() const { - return (_has_bits_[0] & 0x00000040u) != 0; + return (_has_bits_[0] & 0x00000080u) != 0; } inline void FileOptions::set_has_java_multiple_files() { - _has_bits_[0] |= 0x00000040u; + _has_bits_[0] |= 0x00000080u; } inline void FileOptions::clear_has_java_multiple_files() { - _has_bits_[0] &= ~0x00000040u; + _has_bits_[0] &= ~0x00000080u; } inline void FileOptions::clear_java_multiple_files() { java_multiple_files_ = false; @@ -6609,13 +6627,13 @@ inline void FileOptions::set_java_multiple_files(bool value) { // optional bool java_generate_equals_and_hash = 20 [deprecated = true]; inline bool FileOptions::has_java_generate_equals_and_hash() const { - return (_has_bits_[0] & 0x00000080u) != 0; + return (_has_bits_[0] & 0x00000100u) != 0; } inline void FileOptions::set_has_java_generate_equals_and_hash() { - _has_bits_[0] |= 0x00000080u; + _has_bits_[0] |= 0x00000100u; } inline void FileOptions::clear_has_java_generate_equals_and_hash() { - _has_bits_[0] &= ~0x00000080u; + _has_bits_[0] &= ~0x00000100u; } inline void FileOptions::clear_java_generate_equals_and_hash() { java_generate_equals_and_hash_ = false; @@ -6633,13 +6651,13 @@ inline void FileOptions::set_java_generate_equals_and_hash(bool value) { // optional bool java_string_check_utf8 = 27 [default = false]; inline bool FileOptions::has_java_string_check_utf8() const { - return (_has_bits_[0] & 0x00000100u) != 0; + return (_has_bits_[0] & 0x00000200u) != 0; } inline void FileOptions::set_has_java_string_check_utf8() { - _has_bits_[0] |= 0x00000100u; + _has_bits_[0] |= 0x00000200u; } inline void FileOptions::clear_has_java_string_check_utf8() { - _has_bits_[0] &= ~0x00000100u; + _has_bits_[0] &= ~0x00000200u; } inline void FileOptions::clear_java_string_check_utf8() { java_string_check_utf8_ = false; @@ -6657,13 +6675,13 @@ inline void FileOptions::set_java_string_check_utf8(bool value) { // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; inline bool FileOptions::has_optimize_for() const { - return (_has_bits_[0] & 0x00004000u) != 0; + return (_has_bits_[0] & 0x00008000u) != 0; } inline void FileOptions::set_has_optimize_for() { - _has_bits_[0] |= 0x00004000u; + _has_bits_[0] |= 0x00008000u; } inline void FileOptions::clear_has_optimize_for() { - _has_bits_[0] &= ~0x00004000u; + _has_bits_[0] &= ~0x00008000u; } inline void FileOptions::clear_optimize_for() { optimize_for_ = 1; @@ -6744,13 +6762,13 @@ inline void FileOptions::set_allocated_go_package(::std::string* go_package) { // optional bool cc_generic_services = 16 [default = false]; inline bool FileOptions::has_cc_generic_services() const { - return (_has_bits_[0] & 0x00000200u) != 0; + return (_has_bits_[0] & 0x00000400u) != 0; } inline void FileOptions::set_has_cc_generic_services() { - _has_bits_[0] |= 0x00000200u; + _has_bits_[0] |= 0x00000400u; } inline void FileOptions::clear_has_cc_generic_services() { - _has_bits_[0] &= ~0x00000200u; + _has_bits_[0] &= ~0x00000400u; } inline void FileOptions::clear_cc_generic_services() { cc_generic_services_ = false; @@ -6768,13 +6786,13 @@ inline void FileOptions::set_cc_generic_services(bool value) { // optional bool java_generic_services = 17 [default = false]; inline bool FileOptions::has_java_generic_services() const { - return (_has_bits_[0] & 0x00000400u) != 0; + return (_has_bits_[0] & 0x00000800u) != 0; } inline void FileOptions::set_has_java_generic_services() { - _has_bits_[0] |= 0x00000400u; + _has_bits_[0] |= 0x00000800u; } inline void FileOptions::clear_has_java_generic_services() { - _has_bits_[0] &= ~0x00000400u; + _has_bits_[0] &= ~0x00000800u; } inline void FileOptions::clear_java_generic_services() { java_generic_services_ = false; @@ -6792,13 +6810,13 @@ inline void FileOptions::set_java_generic_services(bool value) { // optional bool py_generic_services = 18 [default = false]; inline bool FileOptions::has_py_generic_services() const { - return (_has_bits_[0] & 0x00000800u) != 0; + return (_has_bits_[0] & 0x00001000u) != 0; } inline void FileOptions::set_has_py_generic_services() { - _has_bits_[0] |= 0x00000800u; + _has_bits_[0] |= 0x00001000u; } inline void FileOptions::clear_has_py_generic_services() { - _has_bits_[0] &= ~0x00000800u; + _has_bits_[0] &= ~0x00001000u; } inline void FileOptions::clear_py_generic_services() { py_generic_services_ = false; @@ -6816,13 +6834,13 @@ inline void FileOptions::set_py_generic_services(bool value) { // optional bool deprecated = 23 [default = false]; inline bool FileOptions::has_deprecated() const { - return (_has_bits_[0] & 0x00001000u) != 0; + return (_has_bits_[0] & 0x00002000u) != 0; } inline void FileOptions::set_has_deprecated() { - _has_bits_[0] |= 0x00001000u; + _has_bits_[0] |= 0x00002000u; } inline void FileOptions::clear_has_deprecated() { - _has_bits_[0] &= ~0x00001000u; + _has_bits_[0] &= ~0x00002000u; } inline void FileOptions::clear_deprecated() { deprecated_ = false; @@ -6840,13 +6858,13 @@ inline void FileOptions::set_deprecated(bool value) { // optional bool cc_enable_arenas = 31 [default = false]; inline bool FileOptions::has_cc_enable_arenas() const { - return (_has_bits_[0] & 0x00002000u) != 0; + return (_has_bits_[0] & 0x00004000u) != 0; } inline void FileOptions::set_has_cc_enable_arenas() { - _has_bits_[0] |= 0x00002000u; + _has_bits_[0] |= 0x00004000u; } inline void FileOptions::clear_has_cc_enable_arenas() { - _has_bits_[0] &= ~0x00002000u; + _has_bits_[0] &= ~0x00004000u; } inline void FileOptions::clear_cc_enable_arenas() { cc_enable_arenas_ = false; @@ -7048,6 +7066,68 @@ inline void FileOptions::set_allocated_swift_prefix(::std::string* swift_prefix) // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.swift_prefix) } +// optional string php_class_prefix = 40; +inline bool FileOptions::has_php_class_prefix() const { + return (_has_bits_[0] & 0x00000040u) != 0; +} +inline void FileOptions::set_has_php_class_prefix() { + _has_bits_[0] |= 0x00000040u; +} +inline void FileOptions::clear_has_php_class_prefix() { + _has_bits_[0] &= ~0x00000040u; +} +inline void FileOptions::clear_php_class_prefix() { + php_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_php_class_prefix(); +} +inline const ::std::string& FileOptions::php_class_prefix() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_class_prefix) + return php_class_prefix_.GetNoArena(); +} +inline void FileOptions::set_php_class_prefix(const ::std::string& value) { + set_has_php_class_prefix(); + php_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_class_prefix) +} +#if LANG_CXX11 +inline void FileOptions::set_php_class_prefix(::std::string&& value) { + set_has_php_class_prefix(); + php_class_prefix_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.php_class_prefix) +} +#endif +inline void FileOptions::set_php_class_prefix(const char* value) { + set_has_php_class_prefix(); + php_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.php_class_prefix) +} +inline void FileOptions::set_php_class_prefix(const char* value, size_t size) { + set_has_php_class_prefix(); + php_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast<const char*>(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.php_class_prefix) +} +inline ::std::string* FileOptions::mutable_php_class_prefix() { + set_has_php_class_prefix(); + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.php_class_prefix) + return php_class_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* FileOptions::release_php_class_prefix() { + // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_class_prefix) + clear_has_php_class_prefix(); + return php_class_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void FileOptions::set_allocated_php_class_prefix(::std::string* php_class_prefix) { + if (php_class_prefix != NULL) { + set_has_php_class_prefix(); + } else { + clear_has_php_class_prefix(); + } + php_class_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), php_class_prefix); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_class_prefix) +} + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; inline int FileOptions::uninterpreted_option_size() const { return uninterpreted_option_.size(); diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto index e5f83e62..be223683 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -376,6 +376,10 @@ message FileOptions { // to prefix the types/symbols defined. optional string swift_prefix = 39; + // Sets the php class prefix which is prepended to all php generated classes + // from this .proto. Default is empty. + optional string php_class_prefix = 40; + // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; diff --git a/src/google/protobuf/stubs/stringpiece_unittest.cc b/src/google/protobuf/stubs/stringpiece_unittest.cc index a52d81f8..a6a87595 100644 --- a/src/google/protobuf/stubs/stringpiece_unittest.cc +++ b/src/google/protobuf/stubs/stringpiece_unittest.cc @@ -783,11 +783,13 @@ TEST(FindOneCharTest, EdgeCases) { EXPECT_EQ(StringPiece::npos, a.rfind('x')); } +#ifdef PROTOBUF_HAS_DEATH_TEST #ifndef NDEBUG TEST(NonNegativeLenTest, NonNegativeLen) { EXPECT_DEATH(StringPiece("xyz", -1), "len >= 0"); } #endif // ndef DEBUG +#endif // PROTOBUF_HAS_DEATH_TEST } // namespace } // namespace protobuf diff --git a/src/google/protobuf/util/delimited_message_util.cc b/src/google/protobuf/util/delimited_message_util.cc new file mode 100644 index 00000000..16378782 --- /dev/null +++ b/src/google/protobuf/util/delimited_message_util.cc @@ -0,0 +1,79 @@ +// Adapted from the patch of kenton@google.com (Kenton Varda) +// See https://github.com/google/protobuf/pull/710 for details. + +#include <google/protobuf/util/delimited_message_util.h> + +namespace google { +namespace protobuf { +namespace util { + +bool SerializeDelimitedToFileDescriptor(const MessageLite& message, int file_descriptor) { + io::FileOutputStream output(file_descriptor); + return SerializeDelimitedToZeroCopyStream(message, &output); +} + +bool SerializeDelimitedToOstream(const MessageLite& message, ostream* output) { + { + io::OstreamOutputStream zero_copy_output(output); + if (!SerializeDelimitedToZeroCopyStream(message, &zero_copy_output)) return false; + } + return output->good(); +} + +bool ParseDelimitedFromZeroCopyStream(MessageLite* message, io::ZeroCopyInputStream* input, bool* clean_eof) { + google::protobuf::io::CodedInputStream coded_input(input); + return ParseDelimitedFromCodedStream(message, &coded_input, clean_eof); +} + +bool ParseDelimitedFromCodedStream(MessageLite* message, io::CodedInputStream* input, bool* clean_eof) { + if (clean_eof != NULL) *clean_eof = false; + int start = input->CurrentPosition(); + + // Read the size. + uint32 size; + if (!input->ReadVarint32(&size)) { + if (clean_eof != NULL) *clean_eof = input->CurrentPosition() == start; + return false; + } + + // Tell the stream not to read beyond that size. + google::protobuf::io::CodedInputStream::Limit limit = input->PushLimit(size); + + // Parse the message. + if (!message->MergeFromCodedStream(input)) return false; + if (!input->ConsumedEntireMessage()) return false; + + // Release the limit. + input->PopLimit(limit); + + return true; +} + +bool SerializeDelimitedToZeroCopyStream(const MessageLite& message, io::ZeroCopyOutputStream* output) { + google::protobuf::io::CodedOutputStream coded_output(output); + return SerializeDelimitedToCodedStream(message, &coded_output); +} + +bool SerializeDelimitedToCodedStream(const MessageLite& message, io::CodedOutputStream* output) { + // Write the size. + int size = message.ByteSize(); + output->WriteVarint32(size); + + // Write the content. + uint8* buffer = output->GetDirectBufferForNBytesAndAdvance(size); + if (buffer != NULL) { + // Optimization: The message fits in one buffer, so use the faster + // direct-to-array serialization path. + message.SerializeWithCachedSizesToArray(buffer); + } else { + // Slightly-slower path when the message is multiple buffers. + message.SerializeWithCachedSizes(output); + if (output->HadError()) return false; + } + + return true; +} + +} // namespace util +} // namespace protobuf +} // namespace google diff --git a/src/google/protobuf/util/delimited_message_util.h b/src/google/protobuf/util/delimited_message_util.h new file mode 100644 index 00000000..302d4781 --- /dev/null +++ b/src/google/protobuf/util/delimited_message_util.h @@ -0,0 +1,66 @@ +// Adapted from the patch of kenton@google.com (Kenton Varda) +// See https://github.com/google/protobuf/pull/710 for details. + +#ifndef GOOGLE_PROTOBUF_UTIL_DELIMITED_MESSAGE_UTIL_H__ +#define GOOGLE_PROTOBUF_UTIL_DELIMITED_MESSAGE_UTIL_H__ + +#include <ostream> + +#include <google/protobuf/message_lite.h> +#include <google/protobuf/io/coded_stream.h> +#include <google/protobuf/io/zero_copy_stream_impl.h> + +namespace google { +namespace protobuf { +namespace util { + +// Write a single size-delimited message from the given stream. Delimited +// format allows a single file or stream to contain multiple messages, +// whereas normally writing multiple non-delimited messages to the same +// stream would cause them to be merged. A delimited message is a varint +// encoding the message size followed by a message of exactly that size. +// +// Note that if you want to *read* a delimited message from a file descriptor +// or istream, you will need to construct an io::FileInputStream or +// io::OstreamInputStream (implementations of io::ZeroCopyStream) and use the +// utility function ParseDelimitedFromZeroCopyStream(). You must then +// continue to use the same ZeroCopyInputStream to read all further data from +// the stream until EOF. This is because these ZeroCopyInputStream +// implementations are buffered: they read a big chunk of data at a time, +// then parse it. As a result, they may read past the end of the delimited +// message. There is no way for them to push the extra data back into the +// underlying source, so instead you must keep using the same stream object. +bool LIBPROTOBUF_EXPORT SerializeDelimitedToFileDescriptor(const MessageLite& message, int file_descriptor); + +bool LIBPROTOBUF_EXPORT SerializeDelimitedToOstream(const MessageLite& message, ostream* output); + +// Read a single size-delimited message from the given stream. Delimited +// format allows a single file or stream to contain multiple messages, +// whereas normally parsing consumes the entire input. A delimited message +// is a varint encoding the message size followed by a message of exactly +// that size. +// +// If |clean_eof| is not NULL, then it will be set to indicate whether the +// stream ended cleanly. That is, if the stream ends without this method +// having read any data at all from it, then *clean_eof will be set true, +// otherwise it will be set false. Note that these methods return false +// on EOF, but they also return false on other errors, so |clean_eof| is +// needed to distinguish a clean end from errors. +bool LIBPROTOBUF_EXPORT ParseDelimitedFromZeroCopyStream(MessageLite* message, io::ZeroCopyInputStream* input, bool* clean_eof); + +bool LIBPROTOBUF_EXPORT ParseDelimitedFromCodedStream(MessageLite* message, io::CodedInputStream* input, bool* clean_eof); + +// Write a single size-delimited message from the given stream. Delimited +// format allows a single file or stream to contain multiple messages, +// whereas normally writing multiple non-delimited messages to the same +// stream would cause them to be merged. A delimited message is a varint +// encoding the message size followed by a message of exactly that size. +bool LIBPROTOBUF_EXPORT SerializeDelimitedToZeroCopyStream(const MessageLite& message, io::ZeroCopyOutputStream* output); + +bool LIBPROTOBUF_EXPORT SerializeDelimitedToCodedStream(const MessageLite& message, io::CodedOutputStream* output); + +} // namespace util +} // namespace protobuf +} // namespace google + +#endif // GOOGLE_PROTOBUF_UTIL_DELIMITED_MESSAGE_UTIL_H__ diff --git a/src/google/protobuf/util/delimited_message_util_test.cc b/src/google/protobuf/util/delimited_message_util_test.cc new file mode 100644 index 00000000..b261d43c --- /dev/null +++ b/src/google/protobuf/util/delimited_message_util_test.cc @@ -0,0 +1,57 @@ +// Adapted from the patch of kenton@google.com (Kenton Varda) +// See https://github.com/google/protobuf/pull/710 for details. + +#include <google/protobuf/util/delimited_message_util.h> + +#include <sstream> + +#include <google/protobuf/test_util.h> +#include <google/protobuf/unittest.pb.h> +#include <google/protobuf/testing/googletest.h> +#include <gtest/gtest.h> + +namespace google { +namespace protobuf { +namespace util { + +TEST(DelimitedMessageUtilTest, DelimitedMessages) { + stringstream stream; + + { + protobuf_unittest::TestAllTypes message1; + TestUtil::SetAllFields(&message1); + EXPECT_TRUE(SerializeDelimitedToOstream(message1, &stream)); + + protobuf_unittest::TestPackedTypes message2; + TestUtil::SetPackedFields(&message2); + EXPECT_TRUE(SerializeDelimitedToOstream(message2, &stream)); + } + + { + bool clean_eof; + io::IstreamInputStream zstream(&stream); + + protobuf_unittest::TestAllTypes message1; + clean_eof = true; + EXPECT_TRUE(ParseDelimitedFromZeroCopyStream(&message1, + &zstream, &clean_eof)); + EXPECT_FALSE(clean_eof); + TestUtil::ExpectAllFieldsSet(message1); + + protobuf_unittest::TestPackedTypes message2; + clean_eof = true; + EXPECT_TRUE(ParseDelimitedFromZeroCopyStream(&message2, + &zstream, &clean_eof)); + EXPECT_FALSE(clean_eof); + TestUtil::ExpectPackedFieldsSet(message2); + + clean_eof = false; + EXPECT_FALSE(ParseDelimitedFromZeroCopyStream(&message2, + &zstream, &clean_eof)); + EXPECT_TRUE(clean_eof); + } +} + +} // namespace util +} // namespace protobuf +} // namespace google diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.cc b/src/google/protobuf/util/internal/default_value_objectwriter.cc index 1772219a..b33ad206 100644 --- a/src/google/protobuf/util/internal/default_value_objectwriter.cc +++ b/src/google/protobuf/util/internal/default_value_objectwriter.cc @@ -65,6 +65,7 @@ DefaultValueObjectWriter::DefaultValueObjectWriter( current_(NULL), root_(NULL), suppress_empty_list_(false), + preserve_proto_field_names_(false), field_scrub_callback_(NULL), ow_(ow) {} @@ -191,7 +192,8 @@ void DefaultValueObjectWriter::RegisterFieldScrubCallBack( DefaultValueObjectWriter::Node::Node( const string& name, const google::protobuf::Type* type, NodeKind kind, const DataPiece& data, bool is_placeholder, const std::vector<string>& path, - bool suppress_empty_list, FieldScrubCallBack* field_scrub_callback) + bool suppress_empty_list, bool preserve_proto_field_names, + FieldScrubCallBack* field_scrub_callback) : name_(name), type_(type), kind_(kind), @@ -200,6 +202,7 @@ DefaultValueObjectWriter::Node::Node( is_placeholder_(is_placeholder), path_(path), suppress_empty_list_(suppress_empty_list), + preserve_proto_field_names_(preserve_proto_field_names), field_scrub_callback_(field_scrub_callback) {} DefaultValueObjectWriter::Node* DefaultValueObjectWriter::Node::FindChild( @@ -363,16 +366,19 @@ void DefaultValueObjectWriter::Node::PopulateChildren( } // If oneof_index() != 0, the child field is part of a "oneof", which means - // the child field is optional and we shouldn't populate its default value. - if (field.oneof_index() != 0) continue; + // the child field is optional and we shouldn't populate its default + // primitive value. + if (field.oneof_index() != 0 && kind == PRIMITIVE) continue; // If the child field is of primitive type, sets its data to the default // value of its type. google::protobuf::scoped_ptr<Node> child(new Node( - field.json_name(), field_type, kind, + preserve_proto_field_names_ ? field.name() : field.json_name(), + field_type, kind, kind == PRIMITIVE ? CreateDefaultDataPieceForField(field, typeinfo) : DataPiece::NullData(), - true, path, suppress_empty_list_, field_scrub_callback_)); + true, path, suppress_empty_list_, preserve_proto_field_names_, + field_scrub_callback_)); new_children.push_back(child.release()); } // Adds all leftover nodes in children_ to the beginning of new_child. @@ -469,6 +475,7 @@ DefaultValueObjectWriter* DefaultValueObjectWriter::StartObject( std::vector<string> path; root_.reset(new Node(name.ToString(), &type_, OBJECT, DataPiece::NullData(), false, path, suppress_empty_list_, + preserve_proto_field_names_, field_scrub_callback_.get())); root_->PopulateChildren(typeinfo_); current_ = root_.get(); @@ -485,7 +492,8 @@ DefaultValueObjectWriter* DefaultValueObjectWriter::StartObject( : NULL), OBJECT, DataPiece::NullData(), false, child == NULL ? current_->path() : child->path(), - suppress_empty_list_, field_scrub_callback_.get())); + suppress_empty_list_, preserve_proto_field_names_, + field_scrub_callback_.get())); child = node.get(); current_->AddChild(node.release()); } @@ -517,6 +525,7 @@ DefaultValueObjectWriter* DefaultValueObjectWriter::StartList( std::vector<string> path; root_.reset(new Node(name.ToString(), &type_, LIST, DataPiece::NullData(), false, path, suppress_empty_list_, + preserve_proto_field_names_, field_scrub_callback_.get())); current_ = root_.get(); return this; @@ -527,7 +536,8 @@ DefaultValueObjectWriter* DefaultValueObjectWriter::StartList( google::protobuf::scoped_ptr<Node> node( new Node(name.ToString(), NULL, LIST, DataPiece::NullData(), false, child == NULL ? current_->path() : child->path(), - suppress_empty_list_, field_scrub_callback_.get())); + suppress_empty_list_, preserve_proto_field_names_, + field_scrub_callback_.get())); child = node.get(); current_->AddChild(node.release()); } @@ -588,7 +598,8 @@ void DefaultValueObjectWriter::RenderDataPiece(StringPiece name, google::protobuf::scoped_ptr<Node> node( new Node(name.ToString(), NULL, PRIMITIVE, data, false, child == NULL ? current_->path() : child->path(), - suppress_empty_list_, field_scrub_callback_.get())); + suppress_empty_list_, preserve_proto_field_names_, + field_scrub_callback_.get())); current_->AddChild(node.release()); } else { child->set_data(data); diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.h b/src/google/protobuf/util/internal/default_value_objectwriter.h index dc4551c9..ddf23594 100644 --- a/src/google/protobuf/util/internal/default_value_objectwriter.h +++ b/src/google/protobuf/util/internal/default_value_objectwriter.h @@ -126,6 +126,9 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { // are written. void set_suppress_empty_list(bool value) { suppress_empty_list_ = value; } + // If set to true, original proto field names are used + void set_preserve_proto_field_names(bool value) { preserve_proto_field_names_ = value; } + private: enum NodeKind { PRIMITIVE = 0, @@ -141,7 +144,7 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { Node(const string& name, const google::protobuf::Type* type, NodeKind kind, const DataPiece& data, bool is_placeholder, const std::vector<string>& path, bool suppress_empty_list, - FieldScrubCallBack* field_scrub_callback); + bool preserve_proto_field_names, FieldScrubCallBack* field_scrub_callback); virtual ~Node() { for (int i = 0; i < children_.size(); ++i) { delete children_[i]; @@ -220,6 +223,9 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { // Whether to suppress empty list output. bool suppress_empty_list_; + // Whether to preserve original proto field names + bool preserve_proto_field_names_; + // Pointer to function for determining whether a field needs to be scrubbed // or not. This callback is owned by the creator of this node. FieldScrubCallBack* field_scrub_callback_; @@ -268,6 +274,9 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { // Whether to suppress output of empty lists. bool suppress_empty_list_; + // Whether to preserve original proto field names + bool preserve_proto_field_names_; + // Unique Pointer to function for determining whether a field needs to be // scrubbed or not. FieldScrubCallBackPtr field_scrub_callback_; diff --git a/src/google/protobuf/util/internal/protostream_objectsource.cc b/src/google/protobuf/util/internal/protostream_objectsource.cc index f9fd7b01..61491af0 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource.cc +++ b/src/google/protobuf/util/internal/protostream_objectsource.cc @@ -121,6 +121,7 @@ ProtoStreamObjectSource::ProtoStreamObjectSource( type_(type), use_lower_camel_for_enums_(false), use_ints_for_enums_(false), + preserve_proto_field_names_(false), recursion_depth_(0), max_recursion_depth_(kDefaultMaxRecursionDepth), render_unknown_fields_(false), @@ -137,6 +138,7 @@ ProtoStreamObjectSource::ProtoStreamObjectSource( type_(type), use_lower_camel_for_enums_(false), use_ints_for_enums_(false), + preserve_proto_field_names_(false), recursion_depth_(0), max_recursion_depth_(kDefaultMaxRecursionDepth), render_unknown_fields_(false), @@ -200,7 +202,11 @@ Status ProtoStreamObjectSource::WriteMessage(const google::protobuf::Type& type, last_tag = tag; field = FindAndVerifyField(type, tag); if (field != NULL) { - field_name = field->json_name(); + if (preserve_proto_field_names_) { + field_name = field->name(); + } else { + field_name = field->json_name(); + } } } if (field == NULL) { diff --git a/src/google/protobuf/util/internal/protostream_objectsource.h b/src/google/protobuf/util/internal/protostream_objectsource.h index 63d5f455..5f443d9d 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource.h +++ b/src/google/protobuf/util/internal/protostream_objectsource.h @@ -116,6 +116,11 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource { use_ints_for_enums_ = value; } + // Sets whether to use original proto field names + void set_preserve_proto_field_names(bool value) { + preserve_proto_field_names_ = value; + } + // Sets the max recursion depth of proto message to be deserialized. Proto // messages over this depth will fail to be deserialized. // Default value is 64. @@ -294,6 +299,9 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource { // Whether to render enums as ints always. Defaults to false. bool use_ints_for_enums_; + // Whether to preserve proto field names + bool preserve_proto_field_names_; + // Tracks current recursion depth. mutable int recursion_depth_; diff --git a/src/google/protobuf/util/json_util.cc b/src/google/protobuf/util/json_util.cc index 129b6eaf..8595a881 100644 --- a/src/google/protobuf/util/json_util.cc +++ b/src/google/protobuf/util/json_util.cc @@ -83,12 +83,16 @@ util::Status BinaryToJsonStream(TypeResolver* resolver, RETURN_IF_ERROR(resolver->ResolveMessageType(type_url, &type)); converter::ProtoStreamObjectSource proto_source(&in_stream, resolver, type); proto_source.set_use_ints_for_enums(options.always_print_enums_as_ints); + proto_source.set_preserve_proto_field_names( + options.preserve_proto_field_names); io::CodedOutputStream out_stream(json_output); converter::JsonObjectWriter json_writer(options.add_whitespace ? " " : "", &out_stream); if (options.always_print_primitive_fields) { converter::DefaultValueObjectWriter default_value_writer( resolver, type, &json_writer); + default_value_writer.set_preserve_proto_field_names( + options.preserve_proto_field_names); return proto_source.WriteTo(&default_value_writer); } else { return proto_source.WriteTo(&json_writer); diff --git a/src/google/protobuf/util/json_util.h b/src/google/protobuf/util/json_util.h index 53b1d1ba..dd9a736f 100644 --- a/src/google/protobuf/util/json_util.h +++ b/src/google/protobuf/util/json_util.h @@ -64,10 +64,13 @@ struct JsonPrintOptions { // Whether to always print enums as ints. By default they are rendered as // strings. bool always_print_enums_as_ints; + // Whether to preserve proto field names + bool preserve_proto_field_names; JsonPrintOptions() : add_whitespace(false), always_print_primitive_fields(false), - always_print_enums_as_ints(false) { + always_print_enums_as_ints(false), + preserve_proto_field_names(false) { } }; diff --git a/src/google/protobuf/util/json_util_test.cc b/src/google/protobuf/util/json_util_test.cc index b0c2f494..7c03d674 100644 --- a/src/google/protobuf/util/json_util_test.cc +++ b/src/google/protobuf/util/json_util_test.cc @@ -51,6 +51,7 @@ using proto3::FOO; using proto3::BAR; using proto3::TestMessage; using proto3::TestMap; +using proto3::TestOneof; using testing::MapIn; static const char kTypeUrlPrefix[] = "type.googleapis.com"; @@ -158,6 +159,43 @@ TEST_F(JsonUtilTest, TestDefaultValues) { "\"repeatedMessageValue\":[]" "}", ToJson(m, options)); + + options.preserve_proto_field_names = true; + m.set_string_value("i am a test string value"); + m.set_bytes_value("i am a test bytes value"); + EXPECT_EQ( + "{\"bool_value\":false," + "\"int32_value\":0," + "\"int64_value\":\"0\"," + "\"uint32_value\":0," + "\"uint64_value\":\"0\"," + "\"float_value\":0," + "\"double_value\":0," + "\"string_value\":\"i am a test string value\"," + "\"bytes_value\":\"aSBhbSBhIHRlc3QgYnl0ZXMgdmFsdWU=\"," + "\"enum_value\":\"FOO\"," + "\"repeated_bool_value\":[]," + "\"repeated_int32_value\":[]," + "\"repeated_int64_value\":[]," + "\"repeated_uint32_value\":[]," + "\"repeated_uint64_value\":[]," + "\"repeated_float_value\":[]," + "\"repeated_double_value\":[]," + "\"repeated_string_value\":[]," + "\"repeated_bytes_value\":[]," + "\"repeated_enum_value\":[]," + "\"repeated_message_value\":[]" + "}", + ToJson(m, options)); +} + +TEST_F(JsonUtilTest, TestPreserveProtoFieldNames) { + TestMessage m; + m.mutable_message_value(); + + JsonPrintOptions options; + options.preserve_proto_field_names = true; + EXPECT_EQ("{\"message_value\":{}}", ToJson(m, options)); } TEST_F(JsonUtilTest, TestAlwaysPrintEnumsAsInts) { @@ -232,6 +270,21 @@ TEST_F(JsonUtilTest, ParsePrimitiveMapIn) { EXPECT_EQ(message.DebugString(), other.DebugString()); } +TEST_F(JsonUtilTest, PrintPrimitiveOneof) { + TestOneof message; + JsonPrintOptions options; + options.always_print_primitive_fields = true; + message.mutable_oneof_message_value(); + EXPECT_EQ( + "{\"oneofMessageValue\":{\"value\":0}}", + ToJson(message, options)); + + message.set_oneof_int32_value(1); + EXPECT_EQ( + "{\"oneofInt32Value\":1}", + ToJson(message, options)); +} + TEST_F(JsonUtilTest, TestParseIgnoreUnknownFields) { TestMessage m; JsonParseOptions options; |