am 9be7e740: Merge "Change reftypes_primitive_enums to reftypes_compat_mode."
* commit '9be7e7401174d75e87e21fdc5f43549594a714bb': Change reftypes_primitive_enums to reftypes_compat_mode.
This commit is contained in:
commit
4d6e9c5f6d
@ -140,9 +140,12 @@ bool JavaNanoGenerator::Generate(const FileDescriptor* file,
|
|||||||
} else if (option_name == "optional_field_style") {
|
} else if (option_name == "optional_field_style") {
|
||||||
params.set_optional_field_accessors(option_value == "accessors");
|
params.set_optional_field_accessors(option_value == "accessors");
|
||||||
params.set_use_reference_types_for_primitives(option_value == "reftypes"
|
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(
|
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") {
|
} else if (option_name == "generate_equals") {
|
||||||
params.set_generate_equals(option_value == "true");
|
params.set_generate_equals(option_value == "true");
|
||||||
} else if (option_name == "ignore_services") {
|
} else if (option_name == "ignore_services") {
|
||||||
|
@ -245,16 +245,20 @@ void MessageGenerator::Generate(io::Printer* printer) {
|
|||||||
" _classInitialized = true;\n"
|
" _classInitialized = true;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" }\n"
|
" }\n");
|
||||||
" clear();\n"
|
if (params_.generate_clear()) {
|
||||||
"}\n");
|
printer->Print(" clear();\n");
|
||||||
|
}
|
||||||
|
printer->Print("}\n");
|
||||||
} else {
|
} else {
|
||||||
printer->Print(
|
if (params_.generate_clear()) {
|
||||||
"\n"
|
printer->Print(
|
||||||
"public $classname$() {\n"
|
"\n"
|
||||||
" clear();\n"
|
"public $classname$() {\n"
|
||||||
"}\n",
|
" clear();\n"
|
||||||
"classname", descriptor_->name());
|
"}\n",
|
||||||
|
"classname", descriptor_->name());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Other methods in this class
|
// Other methods in this class
|
||||||
@ -440,6 +444,9 @@ void MessageGenerator::GenerateSerializeOneField(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MessageGenerator::GenerateClear(io::Printer* printer) {
|
void MessageGenerator::GenerateClear(io::Printer* printer) {
|
||||||
|
if (!params_.generate_clear()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
printer->Print(
|
printer->Print(
|
||||||
"\n"
|
"\n"
|
||||||
"public $classname$ clear() {\n",
|
"public $classname$ clear() {\n",
|
||||||
|
@ -65,6 +65,7 @@ class Params {
|
|||||||
bool ignore_services_;
|
bool ignore_services_;
|
||||||
bool parcelable_messages_;
|
bool parcelable_messages_;
|
||||||
bool reftypes_primitive_enums_;
|
bool reftypes_primitive_enums_;
|
||||||
|
bool generate_clear_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Params(const string & base_name) :
|
Params(const string & base_name) :
|
||||||
@ -79,7 +80,8 @@ class Params {
|
|||||||
generate_equals_(false),
|
generate_equals_(false),
|
||||||
ignore_services_(false),
|
ignore_services_(false),
|
||||||
parcelable_messages_(false),
|
parcelable_messages_(false),
|
||||||
reftypes_primitive_enums_(false) {
|
reftypes_primitive_enums_(false),
|
||||||
|
generate_clear_(true) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const string& base_name() const {
|
const string& base_name() const {
|
||||||
@ -222,6 +224,13 @@ class Params {
|
|||||||
bool reftypes_primitive_enums() const {
|
bool reftypes_primitive_enums() const {
|
||||||
return reftypes_primitive_enums_;
|
return reftypes_primitive_enums_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_generate_clear(bool value) {
|
||||||
|
generate_clear_ = value;
|
||||||
|
}
|
||||||
|
bool generate_clear() const {
|
||||||
|
return generate_clear_;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace javanano
|
} // namespace javanano
|
||||||
|
Loading…
Reference in New Issue
Block a user