summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Duff <bduff@google.com>2014-10-01 12:55:00 -0700
committerBrian Duff <bduff@google.com>2014-10-01 12:55:00 -0700
commit907e776a4015b6b55987f008429ba66babb920a1 (patch)
tree3761669e811d2bcfa31b96f43e4b0a16c4d04d9c
parent7d1ca13f3781e8ccff0ecfab42250f1058c9152d (diff)
downloadexternal_protobuf-907e776a4015b6b55987f008429ba66babb920a1.zip
external_protobuf-907e776a4015b6b55987f008429ba66babb920a1.tar.gz
external_protobuf-907e776a4015b6b55987f008429ba66babb920a1.tar.bz2
Change reftypes_primitive_enums to reftypes_compat_mode.
Make the clear() method stripped in reftypes_compat_mode. Change-Id: I0ec35537856f59a6ecf231bfd74df995c858e2b2
-rw-r--r--src/google/protobuf/compiler/javanano/javanano_generator.cc7
-rw-r--r--src/google/protobuf/compiler/javanano/javanano_message.cc25
-rw-r--r--src/google/protobuf/compiler/javanano/javanano_params.h11
3 files changed, 31 insertions, 12 deletions
diff --git a/src/google/protobuf/compiler/javanano/javanano_generator.cc b/src/google/protobuf/compiler/javanano/javanano_generator.cc
index 1936e45..b1e75e3 100644
--- a/src/google/protobuf/compiler/javanano/javanano_generator.cc
+++ b/src/google/protobuf/compiler/javanano/javanano_generator.cc
@@ -140,9 +140,12 @@ bool JavaNanoGenerator::Generate(const FileDescriptor* file,
} else if (option_name == "optional_field_style") {
params.set_optional_field_accessors(option_value == "accessors");
params.set_use_reference_types_for_primitives(option_value == "reftypes"
- || option_value == "reftypes_primitive_enums");
+ || option_value == "reftypes_compat_mode");
params.set_reftypes_primitive_enums(
- option_value == "reftypes_primitive_enums");
+ option_value == "reftypes_compat_mode");
+ if (option_value == "reftypes_compat_mode") {
+ params.set_generate_clear(false);
+ }
} else if (option_name == "generate_equals") {
params.set_generate_equals(option_value == "true");
} else if (option_name == "ignore_services") {
diff --git a/src/google/protobuf/compiler/javanano/javanano_message.cc b/src/google/protobuf/compiler/javanano/javanano_message.cc
index cc44cd3..7c52ca3 100644
--- a/src/google/protobuf/compiler/javanano/javanano_message.cc
+++ b/src/google/protobuf/compiler/javanano/javanano_message.cc
@@ -245,16 +245,20 @@ void MessageGenerator::Generate(io::Printer* printer) {
" _classInitialized = true;\n"
" }\n"
" }\n"
- " }\n"
- " clear();\n"
- "}\n");
+ " }\n");
+ if (params_.generate_clear()) {
+ printer->Print(" clear();\n");
+ }
+ printer->Print("}\n");
} else {
- printer->Print(
- "\n"
- "public $classname$() {\n"
- " clear();\n"
- "}\n",
- "classname", descriptor_->name());
+ if (params_.generate_clear()) {
+ printer->Print(
+ "\n"
+ "public $classname$() {\n"
+ " clear();\n"
+ "}\n",
+ "classname", descriptor_->name());
+ }
}
// Other methods in this class
@@ -440,6 +444,9 @@ void MessageGenerator::GenerateSerializeOneField(
}
void MessageGenerator::GenerateClear(io::Printer* printer) {
+ if (!params_.generate_clear()) {
+ return;
+ }
printer->Print(
"\n"
"public $classname$ clear() {\n",
diff --git a/src/google/protobuf/compiler/javanano/javanano_params.h b/src/google/protobuf/compiler/javanano/javanano_params.h
index 1512b4c..4691f36 100644
--- a/src/google/protobuf/compiler/javanano/javanano_params.h
+++ b/src/google/protobuf/compiler/javanano/javanano_params.h
@@ -65,6 +65,7 @@ class Params {
bool ignore_services_;
bool parcelable_messages_;
bool reftypes_primitive_enums_;
+ bool generate_clear_;
public:
Params(const string & base_name) :
@@ -79,7 +80,8 @@ class Params {
generate_equals_(false),
ignore_services_(false),
parcelable_messages_(false),
- reftypes_primitive_enums_(false) {
+ reftypes_primitive_enums_(false),
+ generate_clear_(true) {
}
const string& base_name() const {
@@ -222,6 +224,13 @@ class Params {
bool reftypes_primitive_enums() const {
return reftypes_primitive_enums_;
}
+
+ void set_generate_clear(bool value) {
+ generate_clear_ = value;
+ }
+ bool generate_clear() const {
+ return generate_clear_;
+ }
};
} // namespace javanano