am 081ac0fc: am 9e6afdf9: Merge "Add two codegen parameters to nano."

* commit '081ac0fc81819ad6d124d4133e6d2e4037ca9c5b':
  Add two codegen parameters to nano.
pull/91/head
Ulas Kirazci 11 years ago committed by Android Git Automerger
commit e527ce9217
  1. 13
      src/google/protobuf/compiler/javanano/javanano_generator.cc
  2. 19
      src/google/protobuf/compiler/javanano/javanano_params.h

@ -119,12 +119,23 @@ bool JavaNanoGenerator::Generate(const FileDescriptor* file,
} else if (options[i].first == "java_multiple_files") {
params.set_override_java_multiple_files(options[i].second == "true");
} else if (options[i].first == "java_nano_generate_has") {
params.set_generate_has(options[i].second == "true");
params.set_generate_has(options[i].second == "true");
} else if (options[i].first == "enum_style") {
params.set_java_enum_style(options[i].second == "java");
} else if (options[i].first == "optional_field_style") {
params.set_optional_field_accessors(options[i].second == "accessors");
} else {
*error = "Ignore unknown javanano generator option: " + options[i].first;
}
}
// Check illegal parameter combinations
if (params.generate_has() && params.optional_field_accessors()) {
error->assign("java_nano_generate_has=true cannot be used in conjunction"
" with optional_field_style=accessors");
return false;
}
// -----------------------------------------------------------------
FileGenerator file_generator(file, params);

@ -58,6 +58,8 @@ class Params {
NameMap java_outer_classnames_;
NameSet java_multiple_files_;
bool generate_has_;
bool java_enum_style_;
bool optional_field_accessors_;
public:
Params(const string & base_name) :
@ -65,7 +67,9 @@ class Params {
base_name_(base_name),
override_java_multiple_files_(JAVANANO_MUL_UNSET),
store_unknown_fields_(false),
generate_has_(false) {
generate_has_(false),
java_enum_style_(false),
optional_field_accessors_(false) {
}
const string& base_name() const {
@ -160,6 +164,19 @@ class Params {
return generate_has_;
}
void set_java_enum_style(bool value) {
java_enum_style_ = value;
}
bool java_enum_style() const {
return java_enum_style_;
}
void set_optional_field_accessors(bool value) {
optional_field_accessors_ = value;
}
bool optional_field_accessors() const {
return optional_field_accessors_;
}
};
} // namespace javanano

Loading…
Cancel
Save