diff options
-rw-r--r-- | aidl.cpp | 26 | ||||
-rw-r--r-- | aidl_language.h | 3 | ||||
-rw-r--r-- | generate_java_binder.cpp | 6 |
3 files changed, 26 insertions, 9 deletions
@@ -229,11 +229,18 @@ int check_types(const string& filename, if (it == method_names.end()) { method_names[m->GetName()] = m.get(); } else { - cerr << filename << ":" << m->GetLine() - << " attempt to redefine method " << m->GetName() << "," << endl - << filename << ":" << it->second->GetLine() - << " previously defined here." << endl; - err = 1; + if (m->HasId()) { + cerr << filename << ":" << m->GetLine() + << " redefining method " << m->GetName() << endl; + m->SetDeduplicate(true); + method_names[m->GetName()] = m.get(); + } else { + cerr << filename << ":" << m->GetLine() + << " attempt to redefine method " << m->GetName() << "," << endl + << filename << ":" << it->second->GetLine() + << " previously defined here." << endl; + err = 1; + } } } return err; @@ -603,10 +610,6 @@ AidlError load_and_validate_aidl( } } - // check the referenced types in parsed_doc to make sure we've imported them - if (check_types(input_file_name, interface.get(), types) != 0) { - err = AidlError::BAD_TYPE; - } if (err != AidlError::OK) { return err; } @@ -618,6 +621,11 @@ AidlError load_and_validate_aidl( return AidlError::BAD_METHOD_ID; } + // check the referenced types in parsed_doc to make sure we've imported them + if (check_types(input_file_name, interface.get(), types) != 0) { + return AidlError::BAD_TYPE; + } + if (returned_interface) *returned_interface = std::move(interface); diff --git a/aidl_language.h b/aidl_language.h index a23f4dc..bf4c70f 100644 --- a/aidl_language.h +++ b/aidl_language.h @@ -178,6 +178,8 @@ class AidlMethod : public AidlMember { bool HasId() const { return has_id_; } int GetId() { return id_; } void SetId(unsigned id) { id_ = id; } + bool IsDeduplicate() const { return deduplicate_; } + void SetDeduplicate(bool deduplicate) { deduplicate_ = deduplicate; } const std::vector<std::unique_ptr<AidlArgument>>& GetArguments() const { return arguments_; @@ -203,6 +205,7 @@ class AidlMethod : public AidlMember { std::vector<const AidlArgument*> out_arguments_; bool has_id_; int id_; + bool deduplicate_; DISALLOW_COPY_AND_ASSIGN(AidlMethod); }; diff --git a/generate_java_binder.cpp b/generate_java_binder.cpp index b692637..87d8d0c 100644 --- a/generate_java_binder.cpp +++ b/generate_java_binder.cpp @@ -271,6 +271,12 @@ static void generate_method(const AidlMethod& method, Class* interface, string transactCodeName = "TRANSACTION_"; transactCodeName += method.GetName(); + if (method.IsDeduplicate()) { + char tmp[16]; + sprintf(tmp, "_%d", index); + transactCodeName += tmp; + } + char transactCodeValue[60]; sprintf(transactCodeValue, "(android.os.IBinder.FIRST_CALL_TRANSACTION + %d)", index); |