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/hidl-gen_y.yy b/hidl-gen_y.yy
index 698f69d..9ced71f 100644
--- a/hidl-gen_y.yy
+++ b/hidl-gen_y.yy
@@ -30,7 +30,6 @@
#include "hidl-gen_y.h"
#include <stdio.h>
-#include <utils/String8.h>
using namespace android;
@@ -132,10 +131,10 @@
android::Method *method;
android::CompoundType::Style compoundStyle;
std::vector<std::string> *stringVec;
- std::pair<std::string, std::vector<std::string> *> *annotationParam;
- android::DefaultKeyedVector<std::string, std::vector<std::string> *> *annotationParams;
+ android::AnnotationParam *annotationParam;
+ android::AnnotationParamVector *annotationParams;
android::Annotation *annotation;
- android::DefaultKeyedVector<std::string, android::Annotation *> *annotations;
+ std::vector<android::Annotation *> *annotations;
}
%%
@@ -143,12 +142,12 @@
opt_annotations
: /* empty */
{
- $$ = new DefaultKeyedVector<std::string, Annotation *>;
+ $$ = new std::vector<Annotation *>;
}
| opt_annotations annotation
{
$$ = $1;
- $$->add($2->name(), $2);
+ $$->push_back($2);
}
;
@@ -162,7 +161,7 @@
opt_annotation_params
: /* empty */
{
- $$ = new DefaultKeyedVector<std::string, std::vector<std::string> *>;
+ $$ = new AnnotationParamVector;
}
| '(' annotation_params ')'
{
@@ -173,20 +172,20 @@
annotation_params
: annotation_param
{
- $$ = new DefaultKeyedVector<std::string, std::vector<std::string> *>;
- $$->add($1->first, $1->second);
+ $$ = new AnnotationParamVector;
+ $$->push_back($1);
}
| annotation_params ',' annotation_param
{
$$ = $1;
- $$->add($3->first, $3->second);
+ $$->push_back($3);
}
;
annotation_param
: IDENTIFIER '=' annotation_value
{
- $$ = new std::pair<std::string, std::vector<std::string> *>($1, $3);
+ $$ = new AnnotationParam($1, $3);
}
;