diff options
author | Jie Dai <jied@google.com> | 2014-04-21 14:29:03 -0700 |
---|---|---|
committer | Diego GarcĂa <xaethos@google.com> | 2014-04-23 09:27:07 -0700 |
commit | a0a4f14521bd29a472d51fb7c4c5c45a82643453 (patch) | |
tree | fc731e2fc629d7f67b0cdb5ee5e529d8b363c94a /src | |
parent | ea68d73c08b3b9319faef8ef9cd283e773a6ef20 (diff) | |
download | external_protobuf-a0a4f14521bd29a472d51fb7c4c5c45a82643453.zip external_protobuf-a0a4f14521bd29a472d51fb7c4c5c45a82643453.tar.gz external_protobuf-a0a4f14521bd29a472d51fb7c4c5c45a82643453.tar.bz2 |
Adds --ignore_service nano proto compiler flag
Nano proto compiler normally throws an error if any service is
defined. If --ignore-services=true is set, no error is thrown and the
service is simply skipped.
Change-Id: Id82583555085cc55550d03a485d3f0189885240b
Diffstat (limited to 'src')
3 files changed, 13 insertions, 2 deletions
diff --git a/src/google/protobuf/compiler/javanano/javanano_file.cc b/src/google/protobuf/compiler/javanano/javanano_file.cc index bdc51c4..98586b4 100644 --- a/src/google/protobuf/compiler/javanano/javanano_file.cc +++ b/src/google/protobuf/compiler/javanano/javanano_file.cc @@ -105,7 +105,7 @@ bool FileGenerator::Validate(string* error) { return false; } - if (file_->service_count() != 0) { + if (file_->service_count() != 0 && !params_.ignore_services()) { error->assign(file_->name()); error->append( ": Java NANO_RUNTIME does not support services\""); diff --git a/src/google/protobuf/compiler/javanano/javanano_generator.cc b/src/google/protobuf/compiler/javanano/javanano_generator.cc index d514dd8..0e12103 100644 --- a/src/google/protobuf/compiler/javanano/javanano_generator.cc +++ b/src/google/protobuf/compiler/javanano/javanano_generator.cc @@ -142,6 +142,8 @@ bool JavaNanoGenerator::Generate(const FileDescriptor* file, params.set_use_reference_types_for_primitives(option_value == "reftypes"); } else if (option_name == "generate_equals") { params.set_generate_equals(option_value == "true"); + } else if (option_name == "ignore_services") { + params.set_ignore_services(option_value == "true"); } else { *error = "Ignore unknown javanano generator option: " + option_name; } diff --git a/src/google/protobuf/compiler/javanano/javanano_params.h b/src/google/protobuf/compiler/javanano/javanano_params.h index 24aece3..889395e 100644 --- a/src/google/protobuf/compiler/javanano/javanano_params.h +++ b/src/google/protobuf/compiler/javanano/javanano_params.h @@ -62,6 +62,7 @@ class Params { bool optional_field_accessors_; bool use_reference_types_for_primitives_; bool generate_equals_; + bool ignore_services_; public: Params(const string & base_name) : @@ -73,7 +74,8 @@ class Params { java_enum_style_(false), optional_field_accessors_(false), use_reference_types_for_primitives_(false), - generate_equals_(false) { + generate_equals_(false), + ignore_services_(false) { } const string& base_name() const { @@ -195,6 +197,13 @@ class Params { bool generate_equals() const { return generate_equals_; } + + void set_ignore_services(bool value) { + ignore_services_ = value; + } + bool ignore_services() const { + return ignore_services_; + } }; } // namespace javanano |