Make string matching the last resort way to look up types
That is, Find(const AidlType&) will call FindByName(const std::string&)
rather than the other way around. Later we'll use annotations in the
AidlType to pick one of several different type name strings.
Bug: 26729450
Test: unittests continue to pass
Change-Id: I10fcb88eabda30b88d5457ecfc8931755a0aa872
diff --git a/type_java.cpp b/type_java.cpp
index febc9cb..f056610 100644
--- a/type_java.cpp
+++ b/type_java.cpp
@@ -702,9 +702,8 @@
void InterfaceType::CreateFromParcel(StatementBlock* addTo, Variable* v,
Variable* parcel, Variable**) const {
// v = Interface.asInterface(parcel.readStrongBinder());
- string stub_type = v->type->QualifiedName() + ".Stub";
addTo->Add(new Assignment(
- v, new MethodCall(m_types->Find(stub_type), "asInterface", 1,
+ v, new MethodCall(stub_, "asInterface", 1,
new MethodCall(parcel, "readStrongBinder"))));
}
@@ -856,17 +855,6 @@
FALSE_VALUE = new LiteralExpression("false");
}
-const Type* JavaTypeNamespace::Find(const char* package,
- const char* name) const {
- string s;
- if (package != nullptr && *package != '\0') {
- s += package;
- s += '.';
- }
- s += name;
- return Find(s);
-}
-
bool JavaTypeNamespace::AddParcelableType(const AidlParcelable& p,
const std::string& filename) {
Type* type =
@@ -897,7 +885,7 @@
}
bool JavaTypeNamespace::AddListType(const std::string& contained_type_name) {
- const Type* contained_type = Find(contained_type_name);
+ const Type* contained_type = FindTypeByCanonicalName(contained_type_name);
if (!contained_type) {
return false;
}