diff options
author | Steve Kondik <steve@cyngn.com> | 2015-03-27 16:44:29 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2015-10-30 14:51:32 -0700 |
commit | 2a3eb6a8b1c0501c2a222ff0a9647121cfe90329 (patch) | |
tree | d5cb5480ba7a11f6ac84ecd090052076f9720130 /tools/aidl | |
parent | 90dc458100b2dd1d231fe79127ef73a4cb7ec7fe (diff) | |
download | frameworks_base-2a3eb6a8b1c0501c2a222ff0a9647121cfe90329.zip frameworks_base-2a3eb6a8b1c0501c2a222ff0a9647121cfe90329.tar.gz frameworks_base-2a3eb6a8b1c0501c2a222ff0a9647121cfe90329.tar.bz2 |
aidl: Support for duplicate methods having different arguments
* Add support for duplicate methods in AIDL when they have different
ids, only when ids have been manually assigned to all methods.
* This is useful for backwards compatibility.
Change-Id: I9612d1633c48e31fe65b966777366a9a6b3ebf5c
Diffstat (limited to 'tools/aidl')
-rw-r--r-- | tools/aidl/aidl.cpp | 23 | ||||
-rw-r--r-- | tools/aidl/aidl_language.h | 1 | ||||
-rw-r--r-- | tools/aidl/generate_java_binder.cpp | 6 |
3 files changed, 22 insertions, 8 deletions
diff --git a/tools/aidl/aidl.cpp b/tools/aidl/aidl.cpp index 14c9f95..cd4fbe5 100644 --- a/tools/aidl/aidl.cpp +++ b/tools/aidl/aidl.cpp @@ -569,12 +569,19 @@ check_types(const char* filename, document_item_type* items) if (methodNames.find(m->name.data) == methodNames.end()) { methodNames[m->name.data] = m; } else { - fprintf(stderr,"%s:%d attempt to redefine method %s,\n", + if (m->hasId) { + fprintf(stderr, "%s:%d redefining method %s\n", filename, m->name.lineno, m->name.data); - method_type* old = methodNames[m->name.data]; - fprintf(stderr, "%s:%d previously defined here.\n", - filename, old->name.lineno); - err = 1; + m->deduplicate = true; + methodNames[m->name.data] = m; + } else { + fprintf(stderr,"%s:%d attempt to redefine method %s,\n", + filename, m->name.lineno, m->name.data); + method_type* old = methodNames[m->name.data]; + fprintf(stderr, "%s:%d previously defined here.\n", + filename, old->name.lineno); + err = 1; + } } } member = member->next; @@ -1014,9 +1021,6 @@ compile_aidl(Options& options) NAMES.Dump(); #endif - // check the referenced types in mainDoc to make sure we've imported them - err |= check_types(options.inputFileName.c_str(), mainDoc); - // finally, there really only needs to be one thing in mainDoc, and it // needs to be an interface. bool onlyParcelable = false; @@ -1028,6 +1032,9 @@ compile_aidl(Options& options) ((interface_type*)mainDoc)->interface_items); } + // check the referenced types in mainDoc to make sure we've imported them + err |= check_types(options.inputFileName.c_str(), mainDoc); + // after this, there shouldn't be any more errors because of the // input. if (err != 0 || mainDoc == NULL) { diff --git a/tools/aidl/aidl_language.h b/tools/aidl/aidl_language.h index de1370c..f3c850e 100644 --- a/tools/aidl/aidl_language.h +++ b/tools/aidl/aidl_language.h @@ -64,6 +64,7 @@ typedef struct method_type { buffer_type semicolon_token; buffer_type* comments_token; // points into this structure, DO NOT DELETE int assigned_id; + bool deduplicate; } method_type; enum { diff --git a/tools/aidl/generate_java_binder.cpp b/tools/aidl/generate_java_binder.cpp index f291ceb..1b538ca 100644 --- a/tools/aidl/generate_java_binder.cpp +++ b/tools/aidl/generate_java_binder.cpp @@ -260,6 +260,12 @@ generate_method(const method_type* method, Class* interface, string transactCodeName = "TRANSACTION_"; transactCodeName += method->name.data; + if (method->deduplicate) { + char tmp[16]; + sprintf(tmp, "_%d", index); + transactCodeName += tmp; + } + char transactCodeValue[60]; sprintf(transactCodeValue, "(android.os.IBinder.FIRST_CALL_TRANSACTION + %d)", index); |