summaryrefslogtreecommitdiffstats
path: root/aidl.cpp
diff options
context:
space:
mode:
authorChristopher Wiley <wiley@google.com>2015-10-13 01:16:52 +0000
committerChristopher Wiley <wiley@google.com>2015-10-13 01:16:52 +0000
commit2d0179a123a3d212fdd9d1baa02ce473b688b360 (patch)
tree7e3039c2e9a0bc855b471c8446acb991fec053bb /aidl.cpp
parente6af22640312894664b4443aba909b6fe49f17f5 (diff)
downloadandroid_system_tools_aidl-2d0179a123a3d212fdd9d1baa02ce473b688b360.tar.gz
android_system_tools_aidl-2d0179a123a3d212fdd9d1baa02ce473b688b360.tar.bz2
android_system_tools_aidl-2d0179a123a3d212fdd9d1baa02ce473b688b360.zip
Revert "Parse only one interface, only Parcelables are lists"
This reverts commit e6af22640312894664b4443aba909b6fe49f17f5. I suspect this change broke the build. It broke our unittests. Change-Id: I124b92d0a5b6e91fe21536b738c34e776bcf2c32
Diffstat (limited to 'aidl.cpp')
-rw-r--r--aidl.cpp72
1 files changed, 39 insertions, 33 deletions
diff --git a/aidl.cpp b/aidl.cpp
index fb9e92b..f5e1ca7 100644
--- a/aidl.cpp
+++ b/aidl.cpp
@@ -67,10 +67,10 @@ namespace {
const int kMinUserSetMethodId = 0;
const int kMaxUserSetMethodId = 16777214;
-bool check_filename(const std::string& filename,
- const std::string& package,
- const std::string& name,
- unsigned line) {
+int check_filename(const std::string& filename,
+ const std::string& package,
+ const std::string& name,
+ unsigned line) {
const char* p;
string expected;
string fn;
@@ -139,28 +139,31 @@ bool check_filename(const std::string& filename,
fprintf(stderr, "%s:%d interface %s should be declared in a file"
" called %s.\n",
filename.c_str(), line, name.c_str(), expected.c_str());
+ return 1;
}
- return valid;
+ return 0;
}
-bool check_filenames(const std::string& filename, const AidlDocumentItem* items) {
- if (! items)
- return true;
-
- if (items->item_type == INTERFACE_TYPE_BINDER) {
- const AidlInterface* c = reinterpret_cast<const AidlInterface*>(items);
- return check_filename(filename, c->GetPackage(), c->GetName(), c->GetLine());
- }
-
- bool success = true;
-
- for (const AidlParcelable* p = reinterpret_cast<const AidlParcelable*>(items);
- p; p = p->next)
- success &= check_filename(filename, p->GetPackage(), p->GetName(),
- p->GetLine());
-
- return success;
+int check_filenames(const std::string& filename, const AidlDocumentItem* items) {
+ int err = 0;
+ while (items) {
+ if (items->item_type == USER_DATA_TYPE) {
+ const AidlParcelable* p = reinterpret_cast<const AidlParcelable*>(items);
+ err |= check_filename(filename, p->GetPackage(), p->GetName(), p->GetLine());
+ }
+ else if (items->item_type == INTERFACE_TYPE_BINDER) {
+ const AidlInterface* c = reinterpret_cast<const AidlInterface*>(items);
+ err |= check_filename(filename, c->GetPackage(), c->GetName(), c->GetLine());
+ }
+ else {
+ fprintf(stderr, "aidl: internal error unkown document type %d.\n",
+ items->item_type);
+ return 1;
+ }
+ items = items->next;
+ }
+ return err;
}
char* rfind(char* str, char c) {
@@ -179,15 +182,17 @@ bool gather_types(const std::string& filename,
TypeNamespace* types) {
bool success = true;
- if (all_items->item_type == INTERFACE_TYPE_BINDER)
- return types->AddBinderType(reinterpret_cast<const AidlInterface *>(all_items), filename);
-
- for (const AidlParcelable* item =
- reinterpret_cast<const AidlParcelable *>(all_items);
- item; item = item->next) {
- success &= types->AddParcelableType(item, filename);
+ for (const AidlDocumentItem* item = all_items; item; item = item->next) {
+ if (item->item_type == USER_DATA_TYPE) {
+ const AidlParcelable* p = reinterpret_cast<const AidlParcelable*>(item);
+ success &= types->AddParcelableType(p, filename);
+ } else if (item->item_type == INTERFACE_TYPE_BINDER) {
+ const AidlInterface* c = reinterpret_cast<const AidlInterface*>(item);
+ success &= types->AddBinderType(c, filename);
+ } else {
+ LOG(FATAL) << "internal error";
+ }
}
-
return success;
}
@@ -518,14 +523,15 @@ int load_and_validate_aidl(const std::vector<std::string> preprocessed_files,
// Since we can't have two distinct classes with the same name and package,
// we can't actually declare parcelables in the same file.
if (parsed_doc == nullptr ||
- parsed_doc->item_type != INTERFACE_TYPE_BINDER) {
+ parsed_doc->item_type != INTERFACE_TYPE_BINDER ||
+ parsed_doc->next != nullptr) {
cerr << "aidl expects exactly one interface per input file";
return 1;
}
AidlInterface* interface = reinterpret_cast<AidlInterface*>(parsed_doc);
err |= check_filename(input_file_name.c_str(),
interface->GetPackage(), interface->GetName(),
- interface->GetLine()) ? 1 : 0;
+ interface->GetLine());
// parse the imports of the input file
ImportResolver import_resolver{io_delegate, import_paths};
@@ -555,7 +561,7 @@ int load_and_validate_aidl(const std::vector<std::string> preprocessed_files,
}
import->SetDocument(p.GetDocument());
- err |= check_filenames(import->GetFilename(), import->GetDocument()) ? 1 : 0;
+ err |= check_filenames(import->GetFilename(), import->GetDocument());
}
if (err != 0) {
return err;