Remove dependency on libutils.
As part of this, TypeDef has also been converted to a NamedType. This is
because originally, Scope contained just a KeyedVector<localname, idx> of
types which it contained, and an std::vector<type> which idx indexes into
(KeyedVector<localname, type> alone would have also worked). However, now
it contains a std::map<localname, idx> instead. Because of this, we have lost
the ability to iterate over the keys (localnames) in O(n). By converting
TypeDef to a NamedType, name => idx => type such that name == type->name.
This also means that in function hierarchy calling Scope::addType, we no
longer have to pass around the tuple (name, type) since type->name == name,
and we can pass around only type.
Change-Id: I8f85afe0e389979a2fd98ff5eeccf47e3fcc8307
diff --git a/Interface.cpp b/Interface.cpp
index a4059d0..66abf8b 100644
--- a/Interface.cpp
+++ b/Interface.cpp
@@ -25,10 +25,11 @@
namespace android {
Interface::Interface(
- const char *localName, Interface *super, AnnotationVector *annotations)
+ const char *localName, Interface *super,
+ std::vector<Annotation *> *annotations)
: Scope(localName),
mSuperType(super),
- mAnnotationsByName(annotations),
+ mAnnotations(annotations),
mIsJavaCompatibleInProgress(false) {
}
@@ -52,8 +53,8 @@
return mMethods;
}
-const AnnotationVector &Interface::annotations() const {
- return *mAnnotationsByName;
+const std::vector<Annotation *> &Interface::annotations() const {
+ return *mAnnotations;
}
std::string Interface::getBaseName() const {
@@ -217,21 +218,21 @@
out << "}\n";
}
// Generate declaration for each annotation.
- const AnnotationVector & annotations = method->annotations();
- for (size_t i = 0; i < annotations.size(); i++) {
+ for (const auto &annotation : method->annotations()) {
out << "callflow: {\n";
out.indent();
- std::string name = annotations.keyAt(i);
+ std::string name = annotation->name();
if (name == "entry") {
out << "entry: true\n";
} else if (name == "exit") {
out << "exit: true\n";
} else if (name == "callflow") {
- Annotation* annotation = annotations.valueAt(i);
- std::vector<std::string> * values = annotation->params()
- .valueFor("next");
- for (auto value : *values) {
- out << "next: " << value << "\n";
+ const AnnotationParam *param =
+ annotation->getParam("next");
+ if (param != nullptr) {
+ for (auto value : *param->getValues()) {
+ out << "next: " << value << "\n";
+ }
}
} else {
std::cerr << "Invalid annotation '"