Resolve constant expressions for external constants.
* Allow constant expressions to be used as array sizes
and as annotation values.
Bug: 31592132 allow constant expressions to be used as array sizes.
Bug: 31628863 Autofill values for enum type
Test: `make android.hardware.tests.expression@1.0` compiles
and generates enum class Color with autofilled values.
Test: `make hidl_test_java` succeeds.
Test: `make hidl_test && adb sync && adb shell hidl_test` succeeds.
Test: `mma`
Change-Id: I57377ec608503d4741d305e98144264b07973055
diff --git a/Annotation.cpp b/Annotation.cpp
index 7b63054..62a7563 100644
--- a/Annotation.cpp
+++ b/Annotation.cpp
@@ -26,6 +26,15 @@
std::vector<std::string> *values)
: mName(name), mValues(values) {}
+AnnotationParam::AnnotationParam(const std::string &name,
+ std::vector<ConstantExpression *> *values)
+ : mName(name) {
+ mValues = new std::vector<std::string>();
+ for(ConstantExpression *ce : *values) {
+ mValues->push_back(ce->value() + " /* " + ce->description() + " */");
+ }
+}
+
const std::string &AnnotationParam::getName() const {
return mName;
}