From 26266cd4660ffe1f3d6015b715713ee654c5b936 Mon Sep 17 00:00:00 2001 From: Max Cai Date: Tue, 24 Sep 2013 17:40:37 +0100 Subject: Implement enum_style=java option. This javanano_out command line option creates a container interface at the normal place where the enum constants would reside, per enum definition. The java_multiple_files flag would now affect the file- scope enums with the shells. If the flag is true then file-scope container interfaces are created in their own files. Change-Id: Id52258fcff8d3dee9db8f3d8022147a811bf3565 --- src/google/protobuf/compiler/javanano/javanano_file.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/google/protobuf/compiler/javanano/javanano_file.cc') diff --git a/src/google/protobuf/compiler/javanano/javanano_file.cc b/src/google/protobuf/compiler/javanano/javanano_file.cc index 1a7b2a7..75d0e44 100644 --- a/src/google/protobuf/compiler/javanano/javanano_file.cc +++ b/src/google/protobuf/compiler/javanano/javanano_file.cc @@ -138,6 +138,13 @@ bool FileGenerator::Validate(string* error) { found_conflict = true; } } + if (params_.java_enum_style()) { + for (int i = 0; !found_conflict && i < file_->enum_type_count(); i++) { + if (file_->enum_type(i)->name() == classname_) { + found_conflict = true; + } + } + } if (found_conflict) { error->assign(file_->name()); error->append( @@ -237,6 +244,14 @@ void FileGenerator::GenerateSiblings(const string& package_dir, file_->message_type(i), output_directory, file_list, params_); } + + if (params_.java_enum_style()) { + for (int i = 0; i < file_->enum_type_count(); i++) { + GenerateSibling(package_dir, java_package_, + file_->enum_type(i), + output_directory, file_list, params_); + } + } } } -- cgit v1.1