From c3e6493aa43241688a307162f3417c176f3c0d4f Mon Sep 17 00:00:00 2001 From: Xiao Hang Date: Mon, 27 Jul 2015 17:46:22 -0700 Subject: [PATCH 1/2] Generate a package name suffix ".nano" for nano messages Also introducing an option javanano_use_deprecated_package to allow users to disable the suffix --- .../compiler/javanano/javanano_generator.cc | 9 +- .../compiler/javanano/javanano_helpers.cc | 8 + src/google/protobuf/descriptor.pb.cc | 170 ++++++++++++------ src/google/protobuf/descriptor.pb.h | 40 ++++- src/google/protobuf/descriptor.proto | 5 + 5 files changed, 174 insertions(+), 58 deletions(-) diff --git a/src/google/protobuf/compiler/javanano/javanano_generator.cc b/src/google/protobuf/compiler/javanano/javanano_generator.cc index ad215cb79e..a33eba1b06 100644 --- a/src/google/protobuf/compiler/javanano/javanano_generator.cc +++ b/src/google/protobuf/compiler/javanano/javanano_generator.cc @@ -67,8 +67,15 @@ void UpdateParamsRecursively(Params& params, file->name(), file->options().java_outer_classname()); } if (file->options().has_java_package()) { + string result = file->options().java_package(); + if (!file->options().javanano_use_deprecated_package()) { + if (!result.empty()) { + result += "."; + } + result += "nano"; + } params.set_java_package( - file->name(), file->options().java_package()); + file->name(), result); } if (file->options().has_java_multiple_files()) { params.set_java_multiple_files( diff --git a/src/google/protobuf/compiler/javanano/javanano_helpers.cc b/src/google/protobuf/compiler/javanano/javanano_helpers.cc index 0d2ae9db5a..5465655fb6 100644 --- a/src/google/protobuf/compiler/javanano/javanano_helpers.cc +++ b/src/google/protobuf/compiler/javanano/javanano_helpers.cc @@ -200,6 +200,14 @@ string FileJavaPackage(const Params& params, const FileDescriptor* file) { if (!result.empty()) result += '.'; result += file->package(); } + + if (!file->options().javanano_use_deprecated_package()) { + if (!result.empty()) { + result += "."; + } + result += "nano"; + } + return result; } } diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 30b3a3a7b2..d2070bc4c6 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -311,7 +311,7 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _internal_metadata_), -1); FileOptions_descriptor_ = file->message_type(9); - static const int FileOptions_offsets_[15] = { + static const int FileOptions_offsets_[16] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_package_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_outer_classname_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_multiple_files_), @@ -326,6 +326,7 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, cc_enable_arenas_), 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, javanano_use_deprecated_package_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, uninterpreted_option_), }; FileOptions_reflection_ = @@ -695,7 +696,7 @@ void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { "_type\030\002 \001(\t\022\023\n\013output_type\030\003 \001(\t\022/\n\007opti" "ons\030\004 \001(\0132\036.google.protobuf.MethodOption" "s\022\037\n\020client_streaming\030\005 \001(\010:\005false\022\037\n\020se" - "rver_streaming\030\006 \001(\010:\005false\"\201\005\n\013FileOpti" + "rver_streaming\030\006 \001(\010:\005false\"\252\005\n\013FileOpti" "ons\022\024\n\014java_package\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_" @@ -708,55 +709,56 @@ void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { "vices\030\022 \001(\010:\005false\022\031\n\ndeprecated\030\027 \001(\010:\005" "false\022\037\n\020cc_enable_arenas\030\037 \001(\010:\005false\022\031" "\n\021objc_class_prefix\030$ \001(\t\022\030\n\020csharp_name" - "space\030% \001(\t\022C\n\024uninterpreted_option\030\347\007 \003" - "(\0132$.google.protobuf.UninterpretedOption" - "\":\n\014OptimizeMode\022\t\n\005SPEED\020\001\022\r\n\tCODE_SIZE" - "\020\002\022\020\n\014LITE_RUNTIME\020\003*\t\010\350\007\020\200\200\200\200\002\"\346\001\n\016Mess" - "ageOptions\022&\n\027message_set_wire_format\030\001 " - "\001(\010:\005false\022.\n\037no_standard_descriptor_acc" - "essor\030\002 \001(\010:\005false\022\031\n\ndeprecated\030\003 \001(\010:\005" - "false\022\021\n\tmap_entry\030\007 \001(\010\022C\n\024uninterprete" - "d_option\030\347\007 \003(\0132$.google.protobuf.Uninte" - "rpretedOption*\t\010\350\007\020\200\200\200\200\002\"\230\003\n\014FieldOption" - "s\022:\n\005ctype\030\001 \001(\0162#.google.protobuf.Field" - "Options.CType:\006STRING\022\016\n\006packed\030\002 \001(\010\022\?\n" - "\006jstype\030\006 \001(\0162$.google.protobuf.FieldOpt" - "ions.JSType:\tJS_NORMAL\022\023\n\004lazy\030\005 \001(\010:\005fa" - "lse\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\023\n\004weak\030\n" - " \001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003" - "(\0132$.google.protobuf.UninterpretedOption" - "\"/\n\005CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRIN" - "G_PIECE\020\002\"5\n\006JSType\022\r\n\tJS_NORMAL\020\000\022\r\n\tJS" - "_STRING\020\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020\200\200\200\200\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\"z\n\rMetho" - "dOptions\022\031\n\ndeprecated\030! \001(\010:\005false\022C\n\024u" - "ninterpreted_option\030\347\007 \003(\0132$.google.prot" - "obuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023" - "UninterpretedOption\022;\n\004name\030\002 \003(\0132-.goog" - "le.protobuf.UninterpretedOption.NamePart" - "\022\030\n\020identifier_value\030\003 \001(\t\022\032\n\022positive_i" - "nt_value\030\004 \001(\004\022\032\n\022negative_int_value\030\005 \001" - "(\003\022\024\n\014double_value\030\006 \001(\001\022\024\n\014string_value" - "\030\007 \001(\014\022\027\n\017aggregate_value\030\010 \001(\t\0323\n\010NameP" - "art\022\021\n\tname_part\030\001 \002(\t\022\024\n\014is_extension\030\002" - " \002(\010\"\325\001\n\016SourceCodeInfo\022:\n\010location\030\001 \003(" - "\0132(.google.protobuf.SourceCodeInfo.Locat" - "ion\032\206\001\n\010Location\022\020\n\004path\030\001 \003(\005B\002\020\001\022\020\n\004sp" - "an\030\002 \003(\005B\002\020\001\022\030\n\020leading_comments\030\003 \001(\t\022\031" - "\n\021trailing_comments\030\004 \001(\t\022!\n\031leading_det" - "ached_comments\030\006 \003(\tBe\n\023com.google.proto" - "bufB\020DescriptorProtosH\001Z\ndescriptor\242\002\003GP" - "B\252\002\'Google.ProtocolBuffers.DescriptorPro" - "tos", 4963); + "space\030% \001(\t\022\'\n\037javanano_use_deprecated_p" + "ackage\030& \001(\010\022C\n\024uninterpreted_option\030\347\007 " + "\003(\0132$.google.protobuf.UninterpretedOptio" + "n\":\n\014OptimizeMode\022\t\n\005SPEED\020\001\022\r\n\tCODE_SIZ" + "E\020\002\022\020\n\014LITE_RUNTIME\020\003*\t\010\350\007\020\200\200\200\200\002\"\346\001\n\016Mes" + "sageOptions\022&\n\027message_set_wire_format\030\001" + " \001(\010:\005false\022.\n\037no_standard_descriptor_ac" + "cessor\030\002 \001(\010:\005false\022\031\n\ndeprecated\030\003 \001(\010:" + "\005false\022\021\n\tmap_entry\030\007 \001(\010\022C\n\024uninterpret" + "ed_option\030\347\007 \003(\0132$.google.protobuf.Unint" + "erpretedOption*\t\010\350\007\020\200\200\200\200\002\"\230\003\n\014FieldOptio" + "ns\022:\n\005ctype\030\001 \001(\0162#.google.protobuf.Fiel" + "dOptions.CType:\006STRING\022\016\n\006packed\030\002 \001(\010\022\?" + "\n\006jstype\030\006 \001(\0162$.google.protobuf.FieldOp" + "tions.JSType:\tJS_NORMAL\022\023\n\004lazy\030\005 \001(\010:\005f" + "alse\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\023\n\004weak\030" + "\n \001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 " + "\003(\0132$.google.protobuf.UninterpretedOptio" + "n\"/\n\005CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRI" + "NG_PIECE\020\002\"5\n\006JSType\022\r\n\tJS_NORMAL\020\000\022\r\n\tJ" + "S_STRING\020\001\022\r\n\tJS_NUMBER\020\002*\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\ndep" + "recated\030\003 \001(\010:\005false\022C\n\024uninterpreted_op" + "tion\030\347\007 \003(\0132$.google.protobuf.Uninterpre" + "tedOption*\t\010\350\007\020\200\200\200\200\002\"}\n\020EnumValueOptions" + "\022\031\n\ndeprecated\030\001 \001(\010:\005false\022C\n\024uninterpr" + "eted_option\030\347\007 \003(\0132$.google.protobuf.Uni" + "nterpretedOption*\t\010\350\007\020\200\200\200\200\002\"{\n\016ServiceOp" + "tions\022\031\n\ndeprecated\030! \001(\010:\005false\022C\n\024unin" + "terpreted_option\030\347\007 \003(\0132$.google.protobu" + "f.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"z\n\rMeth" + "odOptions\022\031\n\ndeprecated\030! \001(\010:\005false\022C\n\024" + "uninterpreted_option\030\347\007 \003(\0132$.google.pro" + "tobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"\236\002\n" + "\023UninterpretedOption\022;\n\004name\030\002 \003(\0132-.goo" + "gle.protobuf.UninterpretedOption.NamePar" + "t\022\030\n\020identifier_value\030\003 \001(\t\022\032\n\022positive_" + "int_value\030\004 \001(\004\022\032\n\022negative_int_value\030\005 " + "\001(\003\022\024\n\014double_value\030\006 \001(\001\022\024\n\014string_valu" + "e\030\007 \001(\014\022\027\n\017aggregate_value\030\010 \001(\t\0323\n\010Name" + "Part\022\021\n\tname_part\030\001 \002(\t\022\024\n\014is_extension\030" + "\002 \002(\010\"\325\001\n\016SourceCodeInfo\022:\n\010location\030\001 \003" + "(\0132(.google.protobuf.SourceCodeInfo.Loca" + "tion\032\206\001\n\010Location\022\020\n\004path\030\001 \003(\005B\002\020\001\022\020\n\004s" + "pan\030\002 \003(\005B\002\020\001\022\030\n\020leading_comments\030\003 \001(\t\022" + "\031\n\021trailing_comments\030\004 \001(\t\022!\n\031leading_de" + "tached_comments\030\006 \003(\tBh\n\023com.google.prot" + "obufB\020DescriptorProtosH\001Z\ndescriptor\242\002\003G" + "PB\252\002\'Google.ProtocolBuffers.DescriptorPr" + "otos\260\002\001", 5007); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/descriptor.proto", &protobuf_RegisterTypes); FileDescriptorSet::default_instance_ = new FileDescriptorSet(); @@ -7598,6 +7600,7 @@ const int FileOptions::kDeprecatedFieldNumber; const int FileOptions::kCcEnableArenasFieldNumber; const int FileOptions::kObjcClassPrefixFieldNumber; const int FileOptions::kCsharpNamespaceFieldNumber; +const int FileOptions::kJavananoUseDeprecatedPackageFieldNumber; const int FileOptions::kUninterpretedOptionFieldNumber; #endif // !_MSC_VER @@ -7635,6 +7638,7 @@ void FileOptions::SharedCtor() { cc_enable_arenas_ = false; objc_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); csharp_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + javanano_use_deprecated_package_ = false; ::memset(_has_bits_, 0, sizeof(_has_bits_)); } @@ -7701,8 +7705,8 @@ void FileOptions::Clear() { go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } } - if (_has_bits_[8 / 32] & 16128u) { - ZR_(java_generic_services_, cc_enable_arenas_); + if (_has_bits_[8 / 32] & 32512u) { + ZR_(java_generic_services_, javanano_use_deprecated_package_); if (has_objc_class_prefix()) { objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } @@ -7951,6 +7955,21 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } + if (input->ExpectTag(304)) goto parse_javanano_use_deprecated_package; + break; + } + + // optional bool javanano_use_deprecated_package = 38; + case 38: { + if (tag == 304) { + parse_javanano_use_deprecated_package: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( + input, &javanano_use_deprecated_package_))); + set_has_javanano_use_deprecated_package(); + } else { + goto handle_unusual; + } if (input->ExpectTag(7994)) goto parse_uninterpreted_option; break; } @@ -8098,6 +8117,11 @@ void FileOptions::SerializeWithCachedSizes( 37, this->csharp_namespace(), output); } + // optional bool javanano_use_deprecated_package = 38; + if (has_javanano_use_deprecated_package()) { + ::google::protobuf::internal::WireFormatLite::WriteBool(38, this->javanano_use_deprecated_package(), 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( @@ -8219,6 +8243,11 @@ void FileOptions::SerializeWithCachedSizes( 37, this->csharp_namespace(), target); } + // optional bool javanano_use_deprecated_package = 38; + if (has_javanano_use_deprecated_package()) { + target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(38, this->javanano_use_deprecated_package(), 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:: @@ -8290,7 +8319,7 @@ int FileOptions::ByteSize() const { } } - if (_has_bits_[8 / 32] & 16128u) { + if (_has_bits_[8 / 32] & 32512u) { // optional bool java_generic_services = 17 [default = false]; if (has_java_generic_services()) { total_size += 2 + 1; @@ -8325,6 +8354,11 @@ int FileOptions::ByteSize() const { this->csharp_namespace()); } + // optional bool javanano_use_deprecated_package = 38; + if (has_javanano_use_deprecated_package()) { + total_size += 2 + 1; + } + } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; total_size += 2 * this->uninterpreted_option_size(); @@ -8412,6 +8446,9 @@ void FileOptions::MergeFrom(const FileOptions& from) { set_has_csharp_namespace(); csharp_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_namespace_); } + if (from.has_javanano_use_deprecated_package()) { + set_javanano_use_deprecated_package(from.javanano_use_deprecated_package()); + } } _extensions_.MergeFrom(from._extensions_); if (from._internal_metadata_.have_unknown_fields()) { @@ -8457,6 +8494,7 @@ void FileOptions::InternalSwap(FileOptions* other) { std::swap(cc_enable_arenas_, other->cc_enable_arenas_); objc_class_prefix_.Swap(&other->objc_class_prefix_); csharp_namespace_.Swap(&other->csharp_namespace_); + std::swap(javanano_use_deprecated_package_, other->javanano_use_deprecated_package_); uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); @@ -8957,6 +8995,30 @@ void FileOptions::clear_csharp_namespace() { // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace) } +// optional bool javanano_use_deprecated_package = 38; +bool FileOptions::has_javanano_use_deprecated_package() const { + return (_has_bits_[0] & 0x00004000u) != 0; +} +void FileOptions::set_has_javanano_use_deprecated_package() { + _has_bits_[0] |= 0x00004000u; +} +void FileOptions::clear_has_javanano_use_deprecated_package() { + _has_bits_[0] &= ~0x00004000u; +} +void FileOptions::clear_javanano_use_deprecated_package() { + javanano_use_deprecated_package_ = false; + clear_has_javanano_use_deprecated_package(); +} + bool FileOptions::javanano_use_deprecated_package() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.javanano_use_deprecated_package) + return javanano_use_deprecated_package_; +} + void FileOptions::set_javanano_use_deprecated_package(bool value) { + set_has_javanano_use_deprecated_package(); + javanano_use_deprecated_package_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.javanano_use_deprecated_package) +} + // 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 b887b8cb29..2aa076ae34 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -2000,6 +2000,13 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message { ::std::string* release_csharp_namespace(); void set_allocated_csharp_namespace(::std::string* csharp_namespace); + // optional bool javanano_use_deprecated_package = 38; + bool has_javanano_use_deprecated_package() const; + void clear_javanano_use_deprecated_package(); + static const int kJavananoUseDeprecatedPackageFieldNumber = 38; + bool javanano_use_deprecated_package() const; + void set_javanano_use_deprecated_package(bool value); + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; void clear_uninterpreted_option(); @@ -2043,6 +2050,8 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message { inline void clear_has_objc_class_prefix(); inline void set_has_csharp_namespace(); inline void clear_has_csharp_namespace(); + inline void set_has_javanano_use_deprecated_package(); + inline void clear_has_javanano_use_deprecated_package(); ::google::protobuf::internal::ExtensionSet _extensions_; @@ -2057,13 +2066,14 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message { bool cc_generic_services_; int optimize_for_; ::google::protobuf::internal::ArenaStringPtr go_package_; - ::google::protobuf::internal::ArenaStringPtr objc_class_prefix_; - ::google::protobuf::internal::ArenaStringPtr csharp_namespace_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool java_generic_services_; bool py_generic_services_; bool deprecated_; bool cc_enable_arenas_; + bool javanano_use_deprecated_package_; + ::google::protobuf::internal::ArenaStringPtr objc_class_prefix_; + ::google::protobuf::internal::ArenaStringPtr csharp_namespace_; + ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); @@ -5892,6 +5902,30 @@ inline void FileOptions::set_allocated_csharp_namespace(::std::string* csharp_na // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace) } +// optional bool javanano_use_deprecated_package = 38; +inline bool FileOptions::has_javanano_use_deprecated_package() const { + return (_has_bits_[0] & 0x00004000u) != 0; +} +inline void FileOptions::set_has_javanano_use_deprecated_package() { + _has_bits_[0] |= 0x00004000u; +} +inline void FileOptions::clear_has_javanano_use_deprecated_package() { + _has_bits_[0] &= ~0x00004000u; +} +inline void FileOptions::clear_javanano_use_deprecated_package() { + javanano_use_deprecated_package_ = false; + clear_has_javanano_use_deprecated_package(); +} +inline bool FileOptions::javanano_use_deprecated_package() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.javanano_use_deprecated_package) + return javanano_use_deprecated_package_; +} +inline void FileOptions::set_javanano_use_deprecated_package(bool value) { + set_has_javanano_use_deprecated_package(); + javanano_use_deprecated_package_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.javanano_use_deprecated_package) +} + // 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 13f136cb10..b70b385b4e 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -42,6 +42,7 @@ syntax = "proto2"; package google.protobuf; option go_package = "descriptor"; option java_package = "com.google.protobuf"; +option javanano_use_deprecated_package = true; option java_outer_classname = "DescriptorProtos"; option csharp_namespace = "Google.ProtocolBuffers.DescriptorProtos"; option objc_class_prefix = "GPB"; @@ -369,6 +370,10 @@ message FileOptions { // Namespace for generated classes; defaults to the package. optional string csharp_namespace = 37; + // Whether the nano proto compiler should generate in the deprecated non-nano + // suffixed package. + optional bool javanano_use_deprecated_package = 38; + // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; From 801e92007fd6eac3fa5b4c386ba54089393680c7 Mon Sep 17 00:00:00 2001 From: Xiao Hang Date: Mon, 27 Jul 2015 17:46:22 -0700 Subject: [PATCH 2/2] Generate a package name suffix ".nano" for nano messages Also introducing an option javanano_use_deprecated_package to allow users to disable the suffix --- .../com/google/protobuf/nano/NanoTest.java | 10 +- .../compiler/javanano/javanano_generator.cc | 9 +- .../compiler/javanano/javanano_helpers.cc | 8 + src/google/protobuf/descriptor.pb.cc | 170 ++++++++++++------ src/google/protobuf/descriptor.pb.h | 40 ++++- src/google/protobuf/descriptor.proto | 5 + 6 files changed, 179 insertions(+), 63 deletions(-) diff --git a/javanano/src/test/java/com/google/protobuf/nano/NanoTest.java b/javanano/src/test/java/com/google/protobuf/nano/NanoTest.java index 3a75777ac6..87deb00b96 100644 --- a/javanano/src/test/java/com/google/protobuf/nano/NanoTest.java +++ b/javanano/src/test/java/com/google/protobuf/nano/NanoTest.java @@ -30,16 +30,16 @@ package com.google.protobuf.nano; -import com.google.protobuf.nano.MapTestProto.TestMap; +import com.google.protobuf.nano.MapTestProto.nano.TestMap; import com.google.protobuf.nano.CodedOutputByteBufferNano; -import com.google.protobuf.nano.MapTestProto.TestMap.MessageValue; +import com.google.protobuf.nano.MapTestProto.nano.TestMap.MessageValue; import com.google.protobuf.nano.NanoAccessorsOuterClass.TestNanoAccessors; import com.google.protobuf.nano.NanoHasOuterClass.TestAllTypesNanoHas; import com.google.protobuf.nano.NanoOuterClass.TestAllTypesNano; -import com.google.protobuf.nano.UnittestRecursiveNano.RecursiveMessageNano; +import com.google.protobuf.nano.UnittestRecursiveNano.nano.RecursiveMessageNano; import com.google.protobuf.nano.NanoReferenceTypesCompat; -import com.google.protobuf.nano.UnittestSimpleNano.SimpleMessageNano; -import com.google.protobuf.nano.UnittestSingleNano.SingleMessageNano; +import com.google.protobuf.nano.UnittestSimpleNano.nano.SimpleMessageNano; +import com.google.protobuf.nano.UnittestSingleNano.nano.SingleMessageNano; import com.google.protobuf.nano.testext.Extensions; import com.google.protobuf.nano.testext.Extensions.AnotherMessage; import com.google.protobuf.nano.testext.Extensions.MessageWithGroup; diff --git a/src/google/protobuf/compiler/javanano/javanano_generator.cc b/src/google/protobuf/compiler/javanano/javanano_generator.cc index ad215cb79e..a33eba1b06 100644 --- a/src/google/protobuf/compiler/javanano/javanano_generator.cc +++ b/src/google/protobuf/compiler/javanano/javanano_generator.cc @@ -67,8 +67,15 @@ void UpdateParamsRecursively(Params& params, file->name(), file->options().java_outer_classname()); } if (file->options().has_java_package()) { + string result = file->options().java_package(); + if (!file->options().javanano_use_deprecated_package()) { + if (!result.empty()) { + result += "."; + } + result += "nano"; + } params.set_java_package( - file->name(), file->options().java_package()); + file->name(), result); } if (file->options().has_java_multiple_files()) { params.set_java_multiple_files( diff --git a/src/google/protobuf/compiler/javanano/javanano_helpers.cc b/src/google/protobuf/compiler/javanano/javanano_helpers.cc index 0d2ae9db5a..5465655fb6 100644 --- a/src/google/protobuf/compiler/javanano/javanano_helpers.cc +++ b/src/google/protobuf/compiler/javanano/javanano_helpers.cc @@ -200,6 +200,14 @@ string FileJavaPackage(const Params& params, const FileDescriptor* file) { if (!result.empty()) result += '.'; result += file->package(); } + + if (!file->options().javanano_use_deprecated_package()) { + if (!result.empty()) { + result += "."; + } + result += "nano"; + } + return result; } } diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 30b3a3a7b2..d2070bc4c6 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -311,7 +311,7 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _internal_metadata_), -1); FileOptions_descriptor_ = file->message_type(9); - static const int FileOptions_offsets_[15] = { + static const int FileOptions_offsets_[16] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_package_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_outer_classname_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_multiple_files_), @@ -326,6 +326,7 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, cc_enable_arenas_), 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, javanano_use_deprecated_package_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, uninterpreted_option_), }; FileOptions_reflection_ = @@ -695,7 +696,7 @@ void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { "_type\030\002 \001(\t\022\023\n\013output_type\030\003 \001(\t\022/\n\007opti" "ons\030\004 \001(\0132\036.google.protobuf.MethodOption" "s\022\037\n\020client_streaming\030\005 \001(\010:\005false\022\037\n\020se" - "rver_streaming\030\006 \001(\010:\005false\"\201\005\n\013FileOpti" + "rver_streaming\030\006 \001(\010:\005false\"\252\005\n\013FileOpti" "ons\022\024\n\014java_package\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_" @@ -708,55 +709,56 @@ void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { "vices\030\022 \001(\010:\005false\022\031\n\ndeprecated\030\027 \001(\010:\005" "false\022\037\n\020cc_enable_arenas\030\037 \001(\010:\005false\022\031" "\n\021objc_class_prefix\030$ \001(\t\022\030\n\020csharp_name" - "space\030% \001(\t\022C\n\024uninterpreted_option\030\347\007 \003" - "(\0132$.google.protobuf.UninterpretedOption" - "\":\n\014OptimizeMode\022\t\n\005SPEED\020\001\022\r\n\tCODE_SIZE" - "\020\002\022\020\n\014LITE_RUNTIME\020\003*\t\010\350\007\020\200\200\200\200\002\"\346\001\n\016Mess" - "ageOptions\022&\n\027message_set_wire_format\030\001 " - "\001(\010:\005false\022.\n\037no_standard_descriptor_acc" - "essor\030\002 \001(\010:\005false\022\031\n\ndeprecated\030\003 \001(\010:\005" - "false\022\021\n\tmap_entry\030\007 \001(\010\022C\n\024uninterprete" - "d_option\030\347\007 \003(\0132$.google.protobuf.Uninte" - "rpretedOption*\t\010\350\007\020\200\200\200\200\002\"\230\003\n\014FieldOption" - "s\022:\n\005ctype\030\001 \001(\0162#.google.protobuf.Field" - "Options.CType:\006STRING\022\016\n\006packed\030\002 \001(\010\022\?\n" - "\006jstype\030\006 \001(\0162$.google.protobuf.FieldOpt" - "ions.JSType:\tJS_NORMAL\022\023\n\004lazy\030\005 \001(\010:\005fa" - "lse\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\023\n\004weak\030\n" - " \001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003" - "(\0132$.google.protobuf.UninterpretedOption" - "\"/\n\005CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRIN" - "G_PIECE\020\002\"5\n\006JSType\022\r\n\tJS_NORMAL\020\000\022\r\n\tJS" - "_STRING\020\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020\200\200\200\200\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\"z\n\rMetho" - "dOptions\022\031\n\ndeprecated\030! \001(\010:\005false\022C\n\024u" - "ninterpreted_option\030\347\007 \003(\0132$.google.prot" - "obuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023" - "UninterpretedOption\022;\n\004name\030\002 \003(\0132-.goog" - "le.protobuf.UninterpretedOption.NamePart" - "\022\030\n\020identifier_value\030\003 \001(\t\022\032\n\022positive_i" - "nt_value\030\004 \001(\004\022\032\n\022negative_int_value\030\005 \001" - "(\003\022\024\n\014double_value\030\006 \001(\001\022\024\n\014string_value" - "\030\007 \001(\014\022\027\n\017aggregate_value\030\010 \001(\t\0323\n\010NameP" - "art\022\021\n\tname_part\030\001 \002(\t\022\024\n\014is_extension\030\002" - " \002(\010\"\325\001\n\016SourceCodeInfo\022:\n\010location\030\001 \003(" - "\0132(.google.protobuf.SourceCodeInfo.Locat" - "ion\032\206\001\n\010Location\022\020\n\004path\030\001 \003(\005B\002\020\001\022\020\n\004sp" - "an\030\002 \003(\005B\002\020\001\022\030\n\020leading_comments\030\003 \001(\t\022\031" - "\n\021trailing_comments\030\004 \001(\t\022!\n\031leading_det" - "ached_comments\030\006 \003(\tBe\n\023com.google.proto" - "bufB\020DescriptorProtosH\001Z\ndescriptor\242\002\003GP" - "B\252\002\'Google.ProtocolBuffers.DescriptorPro" - "tos", 4963); + "space\030% \001(\t\022\'\n\037javanano_use_deprecated_p" + "ackage\030& \001(\010\022C\n\024uninterpreted_option\030\347\007 " + "\003(\0132$.google.protobuf.UninterpretedOptio" + "n\":\n\014OptimizeMode\022\t\n\005SPEED\020\001\022\r\n\tCODE_SIZ" + "E\020\002\022\020\n\014LITE_RUNTIME\020\003*\t\010\350\007\020\200\200\200\200\002\"\346\001\n\016Mes" + "sageOptions\022&\n\027message_set_wire_format\030\001" + " \001(\010:\005false\022.\n\037no_standard_descriptor_ac" + "cessor\030\002 \001(\010:\005false\022\031\n\ndeprecated\030\003 \001(\010:" + "\005false\022\021\n\tmap_entry\030\007 \001(\010\022C\n\024uninterpret" + "ed_option\030\347\007 \003(\0132$.google.protobuf.Unint" + "erpretedOption*\t\010\350\007\020\200\200\200\200\002\"\230\003\n\014FieldOptio" + "ns\022:\n\005ctype\030\001 \001(\0162#.google.protobuf.Fiel" + "dOptions.CType:\006STRING\022\016\n\006packed\030\002 \001(\010\022\?" + "\n\006jstype\030\006 \001(\0162$.google.protobuf.FieldOp" + "tions.JSType:\tJS_NORMAL\022\023\n\004lazy\030\005 \001(\010:\005f" + "alse\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\023\n\004weak\030" + "\n \001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 " + "\003(\0132$.google.protobuf.UninterpretedOptio" + "n\"/\n\005CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRI" + "NG_PIECE\020\002\"5\n\006JSType\022\r\n\tJS_NORMAL\020\000\022\r\n\tJ" + "S_STRING\020\001\022\r\n\tJS_NUMBER\020\002*\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\ndep" + "recated\030\003 \001(\010:\005false\022C\n\024uninterpreted_op" + "tion\030\347\007 \003(\0132$.google.protobuf.Uninterpre" + "tedOption*\t\010\350\007\020\200\200\200\200\002\"}\n\020EnumValueOptions" + "\022\031\n\ndeprecated\030\001 \001(\010:\005false\022C\n\024uninterpr" + "eted_option\030\347\007 \003(\0132$.google.protobuf.Uni" + "nterpretedOption*\t\010\350\007\020\200\200\200\200\002\"{\n\016ServiceOp" + "tions\022\031\n\ndeprecated\030! \001(\010:\005false\022C\n\024unin" + "terpreted_option\030\347\007 \003(\0132$.google.protobu" + "f.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"z\n\rMeth" + "odOptions\022\031\n\ndeprecated\030! \001(\010:\005false\022C\n\024" + "uninterpreted_option\030\347\007 \003(\0132$.google.pro" + "tobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"\236\002\n" + "\023UninterpretedOption\022;\n\004name\030\002 \003(\0132-.goo" + "gle.protobuf.UninterpretedOption.NamePar" + "t\022\030\n\020identifier_value\030\003 \001(\t\022\032\n\022positive_" + "int_value\030\004 \001(\004\022\032\n\022negative_int_value\030\005 " + "\001(\003\022\024\n\014double_value\030\006 \001(\001\022\024\n\014string_valu" + "e\030\007 \001(\014\022\027\n\017aggregate_value\030\010 \001(\t\0323\n\010Name" + "Part\022\021\n\tname_part\030\001 \002(\t\022\024\n\014is_extension\030" + "\002 \002(\010\"\325\001\n\016SourceCodeInfo\022:\n\010location\030\001 \003" + "(\0132(.google.protobuf.SourceCodeInfo.Loca" + "tion\032\206\001\n\010Location\022\020\n\004path\030\001 \003(\005B\002\020\001\022\020\n\004s" + "pan\030\002 \003(\005B\002\020\001\022\030\n\020leading_comments\030\003 \001(\t\022" + "\031\n\021trailing_comments\030\004 \001(\t\022!\n\031leading_de" + "tached_comments\030\006 \003(\tBh\n\023com.google.prot" + "obufB\020DescriptorProtosH\001Z\ndescriptor\242\002\003G" + "PB\252\002\'Google.ProtocolBuffers.DescriptorPr" + "otos\260\002\001", 5007); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/descriptor.proto", &protobuf_RegisterTypes); FileDescriptorSet::default_instance_ = new FileDescriptorSet(); @@ -7598,6 +7600,7 @@ const int FileOptions::kDeprecatedFieldNumber; const int FileOptions::kCcEnableArenasFieldNumber; const int FileOptions::kObjcClassPrefixFieldNumber; const int FileOptions::kCsharpNamespaceFieldNumber; +const int FileOptions::kJavananoUseDeprecatedPackageFieldNumber; const int FileOptions::kUninterpretedOptionFieldNumber; #endif // !_MSC_VER @@ -7635,6 +7638,7 @@ void FileOptions::SharedCtor() { cc_enable_arenas_ = false; objc_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); csharp_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + javanano_use_deprecated_package_ = false; ::memset(_has_bits_, 0, sizeof(_has_bits_)); } @@ -7701,8 +7705,8 @@ void FileOptions::Clear() { go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } } - if (_has_bits_[8 / 32] & 16128u) { - ZR_(java_generic_services_, cc_enable_arenas_); + if (_has_bits_[8 / 32] & 32512u) { + ZR_(java_generic_services_, javanano_use_deprecated_package_); if (has_objc_class_prefix()) { objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } @@ -7951,6 +7955,21 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } + if (input->ExpectTag(304)) goto parse_javanano_use_deprecated_package; + break; + } + + // optional bool javanano_use_deprecated_package = 38; + case 38: { + if (tag == 304) { + parse_javanano_use_deprecated_package: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( + input, &javanano_use_deprecated_package_))); + set_has_javanano_use_deprecated_package(); + } else { + goto handle_unusual; + } if (input->ExpectTag(7994)) goto parse_uninterpreted_option; break; } @@ -8098,6 +8117,11 @@ void FileOptions::SerializeWithCachedSizes( 37, this->csharp_namespace(), output); } + // optional bool javanano_use_deprecated_package = 38; + if (has_javanano_use_deprecated_package()) { + ::google::protobuf::internal::WireFormatLite::WriteBool(38, this->javanano_use_deprecated_package(), 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( @@ -8219,6 +8243,11 @@ void FileOptions::SerializeWithCachedSizes( 37, this->csharp_namespace(), target); } + // optional bool javanano_use_deprecated_package = 38; + if (has_javanano_use_deprecated_package()) { + target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(38, this->javanano_use_deprecated_package(), 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:: @@ -8290,7 +8319,7 @@ int FileOptions::ByteSize() const { } } - if (_has_bits_[8 / 32] & 16128u) { + if (_has_bits_[8 / 32] & 32512u) { // optional bool java_generic_services = 17 [default = false]; if (has_java_generic_services()) { total_size += 2 + 1; @@ -8325,6 +8354,11 @@ int FileOptions::ByteSize() const { this->csharp_namespace()); } + // optional bool javanano_use_deprecated_package = 38; + if (has_javanano_use_deprecated_package()) { + total_size += 2 + 1; + } + } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; total_size += 2 * this->uninterpreted_option_size(); @@ -8412,6 +8446,9 @@ void FileOptions::MergeFrom(const FileOptions& from) { set_has_csharp_namespace(); csharp_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_namespace_); } + if (from.has_javanano_use_deprecated_package()) { + set_javanano_use_deprecated_package(from.javanano_use_deprecated_package()); + } } _extensions_.MergeFrom(from._extensions_); if (from._internal_metadata_.have_unknown_fields()) { @@ -8457,6 +8494,7 @@ void FileOptions::InternalSwap(FileOptions* other) { std::swap(cc_enable_arenas_, other->cc_enable_arenas_); objc_class_prefix_.Swap(&other->objc_class_prefix_); csharp_namespace_.Swap(&other->csharp_namespace_); + std::swap(javanano_use_deprecated_package_, other->javanano_use_deprecated_package_); uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); @@ -8957,6 +8995,30 @@ void FileOptions::clear_csharp_namespace() { // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace) } +// optional bool javanano_use_deprecated_package = 38; +bool FileOptions::has_javanano_use_deprecated_package() const { + return (_has_bits_[0] & 0x00004000u) != 0; +} +void FileOptions::set_has_javanano_use_deprecated_package() { + _has_bits_[0] |= 0x00004000u; +} +void FileOptions::clear_has_javanano_use_deprecated_package() { + _has_bits_[0] &= ~0x00004000u; +} +void FileOptions::clear_javanano_use_deprecated_package() { + javanano_use_deprecated_package_ = false; + clear_has_javanano_use_deprecated_package(); +} + bool FileOptions::javanano_use_deprecated_package() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.javanano_use_deprecated_package) + return javanano_use_deprecated_package_; +} + void FileOptions::set_javanano_use_deprecated_package(bool value) { + set_has_javanano_use_deprecated_package(); + javanano_use_deprecated_package_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.javanano_use_deprecated_package) +} + // 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 b887b8cb29..2aa076ae34 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -2000,6 +2000,13 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message { ::std::string* release_csharp_namespace(); void set_allocated_csharp_namespace(::std::string* csharp_namespace); + // optional bool javanano_use_deprecated_package = 38; + bool has_javanano_use_deprecated_package() const; + void clear_javanano_use_deprecated_package(); + static const int kJavananoUseDeprecatedPackageFieldNumber = 38; + bool javanano_use_deprecated_package() const; + void set_javanano_use_deprecated_package(bool value); + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; void clear_uninterpreted_option(); @@ -2043,6 +2050,8 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message { inline void clear_has_objc_class_prefix(); inline void set_has_csharp_namespace(); inline void clear_has_csharp_namespace(); + inline void set_has_javanano_use_deprecated_package(); + inline void clear_has_javanano_use_deprecated_package(); ::google::protobuf::internal::ExtensionSet _extensions_; @@ -2057,13 +2066,14 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message { bool cc_generic_services_; int optimize_for_; ::google::protobuf::internal::ArenaStringPtr go_package_; - ::google::protobuf::internal::ArenaStringPtr objc_class_prefix_; - ::google::protobuf::internal::ArenaStringPtr csharp_namespace_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool java_generic_services_; bool py_generic_services_; bool deprecated_; bool cc_enable_arenas_; + bool javanano_use_deprecated_package_; + ::google::protobuf::internal::ArenaStringPtr objc_class_prefix_; + ::google::protobuf::internal::ArenaStringPtr csharp_namespace_; + ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); @@ -5892,6 +5902,30 @@ inline void FileOptions::set_allocated_csharp_namespace(::std::string* csharp_na // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace) } +// optional bool javanano_use_deprecated_package = 38; +inline bool FileOptions::has_javanano_use_deprecated_package() const { + return (_has_bits_[0] & 0x00004000u) != 0; +} +inline void FileOptions::set_has_javanano_use_deprecated_package() { + _has_bits_[0] |= 0x00004000u; +} +inline void FileOptions::clear_has_javanano_use_deprecated_package() { + _has_bits_[0] &= ~0x00004000u; +} +inline void FileOptions::clear_javanano_use_deprecated_package() { + javanano_use_deprecated_package_ = false; + clear_has_javanano_use_deprecated_package(); +} +inline bool FileOptions::javanano_use_deprecated_package() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.javanano_use_deprecated_package) + return javanano_use_deprecated_package_; +} +inline void FileOptions::set_javanano_use_deprecated_package(bool value) { + set_has_javanano_use_deprecated_package(); + javanano_use_deprecated_package_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.javanano_use_deprecated_package) +} + // 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 13f136cb10..b70b385b4e 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -42,6 +42,7 @@ syntax = "proto2"; package google.protobuf; option go_package = "descriptor"; option java_package = "com.google.protobuf"; +option javanano_use_deprecated_package = true; option java_outer_classname = "DescriptorProtos"; option csharp_namespace = "Google.ProtocolBuffers.DescriptorProtos"; option objc_class_prefix = "GPB"; @@ -369,6 +370,10 @@ message FileOptions { // Namespace for generated classes; defaults to the package. optional string csharp_namespace = 37; + // Whether the nano proto compiler should generate in the deprecated non-nano + // suffixed package. + optional bool javanano_use_deprecated_package = 38; + // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999;