summaryrefslogtreecommitdiffstats
path: root/tools/aidl
diff options
context:
space:
mode:
authorAdrian Taylor <adrian@macrobug.com>2009-02-13 09:52:17 +0000
committerAdrian Taylor <adrian@macrobug.com>2009-02-13 09:53:11 +0000
commit754270601a268cfe0ab679768aa33423feb1f974 (patch)
treea1710a8a0757a92b582e50744af0af402fe8a685 /tools/aidl
parenteef3c54deb1cb66455ae385075333f163e5fb838 (diff)
downloadframeworks_base-754270601a268cfe0ab679768aa33423feb1f974.zip
frameworks_base-754270601a268cfe0ab679768aa33423feb1f974.tar.gz
frameworks_base-754270601a268cfe0ab679768aa33423feb1f974.tar.bz2
Removing "import" statements from AIDL-generated .java files.
AIDL generates unnecessary "import" statements. These cause warnings within Eclipse when the default Eclipse warnings settings are used. This is inconvenient since the generated .java files are not editable. Some pesky organisations have a zero-warnings policy too, so there's no option but to fiddle with the Eclipse settings. This patch ensures that all usages of class names within the generated code are fully-qualified. In practice, they were nearly all fully-qualified already. And this patch also removes the generation of the import statements, since they are redundant if we're using fully-qualified names everywhere. This should fix issue 43 in the Google Code Android issues tracker. http://code.google.com/p/android/issues/detail?id=43 I would appreciate if somebody who knows exactly how 'aidl' works could confirm that there's no reason 'import' statements would have been necessary except for the bits I've fixed. (I think unqualified names were used much more frequently in early versions of aidl, which might explain why import statements are generated so eagerly).
Diffstat (limited to 'tools/aidl')
-rwxr-xr-xtools/aidl/AST.cpp17
-rw-r--r--tools/aidl/generate_java.cpp6
2 files changed, 3 insertions, 20 deletions
diff --git a/tools/aidl/AST.cpp b/tools/aidl/AST.cpp
index 91802a9..1856cb9 100755
--- a/tools/aidl/AST.cpp
+++ b/tools/aidl/AST.cpp
@@ -841,23 +841,6 @@ Document::Write(FILE* to)
fprintf(to, "package %s;\n", this->package.c_str());
}
- // gather the types for the import statements
- set<Type*> types;
- N = this->classes.size();
- for (i=0; i<N; i++) {
- Class* c = this->classes[i];
- c->GatherTypes(&types);
- }
-
- set<Type*>::iterator it;
- for (it=types.begin(); it!=types.end(); it++) {
- Type* t = *it;
- string pkg = t->Package();
- if (pkg.length() != 0 && pkg != this->package) {
- fprintf(to, "import %s;\n", t->ImportType().c_str());
- }
- }
-
N = this->classes.size();
for (i=0; i<N; i++) {
Class* c = this->classes[i];
diff --git a/tools/aidl/generate_java.cpp b/tools/aidl/generate_java.cpp
index 25d47a2..da20d1f 100644
--- a/tools/aidl/generate_java.cpp
+++ b/tools/aidl/generate_java.cpp
@@ -134,7 +134,7 @@ StubClass::make_as_interface(Type *interfaceType)
Method* m = new Method;
m->comment = "/**\n * Cast an IBinder object into an ";
- m->comment += interfaceType->Name();
+ m->comment += interfaceType->QualifiedName();
m->comment += " interface,\n";
m->comment += " * generating a proxy if needed.\n */";
m->modifiers = PUBLIC | STATIC;
@@ -324,7 +324,7 @@ generate_method(const method_type* method, Class* interface,
transactCodeName += method->name.data;
char transactCodeValue[50];
- sprintf(transactCodeValue, "(IBinder.FIRST_CALL_TRANSACTION + %d)", index);
+ sprintf(transactCodeValue, "(android.os.IBinder.FIRST_CALL_TRANSACTION + %d)", index);
Field* transactCode = new Field(STATIC | FINAL,
new Variable(INT_TYPE, transactCodeName));
@@ -518,7 +518,7 @@ generate_method(const method_type* method, Class* interface,
new LiteralExpression("Stub." + transactCodeName),
_data, _reply ? _reply : NULL_VALUE,
new LiteralExpression(
- oneway ? "IBinder.FLAG_ONEWAY" : "0"));
+ oneway ? "android.os.IBinder.FLAG_ONEWAY" : "0"));
tryStatement->statements->Add(call);
// throw back exceptions.