Commit c3e6493a authored by Xiao Hang's avatar Xiao Hang

Generate a package name suffix ".nano" for nano messages

Also introducing an option javanano_use_deprecated_package to allow users to disable the suffix
parent f642c5cf
...@@ -67,8 +67,15 @@ void UpdateParamsRecursively(Params& params, ...@@ -67,8 +67,15 @@ void UpdateParamsRecursively(Params& params,
file->name(), file->options().java_outer_classname()); file->name(), file->options().java_outer_classname());
} }
if (file->options().has_java_package()) { 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( params.set_java_package(
file->name(), file->options().java_package()); file->name(), result);
} }
if (file->options().has_java_multiple_files()) { if (file->options().has_java_multiple_files()) {
params.set_java_multiple_files( params.set_java_multiple_files(
......
...@@ -200,6 +200,14 @@ string FileJavaPackage(const Params& params, const FileDescriptor* file) { ...@@ -200,6 +200,14 @@ string FileJavaPackage(const Params& params, const FileDescriptor* file) {
if (!result.empty()) result += '.'; if (!result.empty()) result += '.';
result += file->package(); result += file->package();
} }
if (!file->options().javanano_use_deprecated_package()) {
if (!result.empty()) {
result += ".";
}
result += "nano";
}
return result; return result;
} }
} }
......
This diff is collapsed.
...@@ -2000,6 +2000,13 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message { ...@@ -2000,6 +2000,13 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message {
::std::string* release_csharp_namespace(); ::std::string* release_csharp_namespace();
void set_allocated_csharp_namespace(::std::string* 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; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
int uninterpreted_option_size() const; int uninterpreted_option_size() const;
void clear_uninterpreted_option(); void clear_uninterpreted_option();
...@@ -2043,6 +2050,8 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message { ...@@ -2043,6 +2050,8 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message {
inline void clear_has_objc_class_prefix(); inline void clear_has_objc_class_prefix();
inline void set_has_csharp_namespace(); inline void set_has_csharp_namespace();
inline void clear_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_; ::google::protobuf::internal::ExtensionSet _extensions_;
...@@ -2057,13 +2066,14 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message { ...@@ -2057,13 +2066,14 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message {
bool cc_generic_services_; bool cc_generic_services_;
int optimize_for_; int optimize_for_;
::google::protobuf::internal::ArenaStringPtr go_package_; ::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 java_generic_services_;
bool py_generic_services_; bool py_generic_services_;
bool deprecated_; bool deprecated_;
bool cc_enable_arenas_; 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 LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();
friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
friend void protobuf_ShutdownFile_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 ...@@ -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) // @@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; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
inline int FileOptions::uninterpreted_option_size() const { inline int FileOptions::uninterpreted_option_size() const {
return uninterpreted_option_.size(); return uninterpreted_option_.size();
......
...@@ -42,6 +42,7 @@ syntax = "proto2"; ...@@ -42,6 +42,7 @@ syntax = "proto2";
package google.protobuf; package google.protobuf;
option go_package = "descriptor"; option go_package = "descriptor";
option java_package = "com.google.protobuf"; option java_package = "com.google.protobuf";
option javanano_use_deprecated_package = true;
option java_outer_classname = "DescriptorProtos"; option java_outer_classname = "DescriptorProtos";
option csharp_namespace = "Google.ProtocolBuffers.DescriptorProtos"; option csharp_namespace = "Google.ProtocolBuffers.DescriptorProtos";
option objc_class_prefix = "GPB"; option objc_class_prefix = "GPB";
...@@ -369,6 +370,10 @@ message FileOptions { ...@@ -369,6 +370,10 @@ message FileOptions {
// Namespace for generated classes; defaults to the package. // Namespace for generated classes; defaults to the package.
optional string csharp_namespace = 37; 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. // The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999; repeated UninterpretedOption uninterpreted_option = 999;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment