Generate code for AIDL defined string constants
Also validate that constant names are not duplicated between
integer and string constants.
Bug: 28233277
Test: Unittests expanded to reflect this change.
Integration tests expanded to reflect this change.
Change-Id: If46619151cf6ff0146a2dfa90b863b096435a30a
diff --git a/ast_java.h b/ast_java.h
index cd318d7..3ec48b7 100644
--- a/ast_java.h
+++ b/ast_java.h
@@ -326,12 +326,24 @@
void Write(CodeWriter* to) const override;
};
-struct Constant : public ClassElement {
- std::string name;
- int value;
+struct IntConstant : public ClassElement {
+ const std::string name;
+ const int value;
- Constant() = default;
- virtual ~Constant() = default;
+ IntConstant(std::string name, int value)
+ : name(name), value(value) {}
+ virtual ~IntConstant() = default;
+
+ void Write(CodeWriter* to) const override;
+};
+
+struct StringConstant : public ClassElement {
+ const std::string name;
+ const std::string value;
+
+ StringConstant(std::string name, std::string value)
+ : name(name), value(value) {}
+ ~StringConstant() override = default;
void Write(CodeWriter* to) const override;
};