Refactor constant declarations.
In preparation for default values for parcelable members.
Bug: 110758329
Test: boot Pixel 2
Test: runtests.sh
Change-Id: Id9c3f6b2242d66e69206c17cabfd61f8921d40b7
diff --git a/aidl.cpp b/aidl.cpp
index e738235..c389c97 100644
--- a/aidl.cpp
+++ b/aidl.cpp
@@ -436,27 +436,14 @@
bool validate_constants(const AidlInterface& interface) {
bool success = true;
set<string> names;
- for (const std::unique_ptr<AidlIntConstant>& int_constant :
- interface.GetIntConstants()) {
- if (names.count(int_constant->GetName()) > 0) {
- LOG(ERROR) << "Found duplicate constant name '" << int_constant->GetName()
- << "'";
+ for (const std::unique_ptr<AidlConstantDeclaration>& constant :
+ interface.GetConstantDeclarations()) {
+ if (names.count(constant->GetName()) > 0) {
+ LOG(ERROR) << "Found duplicate constant name '" << constant->GetName() << "'";
success = false;
}
- names.insert(int_constant->GetName());
- // We've logged an error message for this on object construction.
- success = success && int_constant->IsValid();
- }
- for (const std::unique_ptr<AidlStringConstant>& string_constant :
- interface.GetStringConstants()) {
- if (names.count(string_constant->GetName()) > 0) {
- LOG(ERROR) << "Found duplicate constant name '" << string_constant->GetName()
- << "'";
- success = false;
- }
- names.insert(string_constant->GetName());
- // We've logged an error message for this on object construction.
- success = success && string_constant->IsValid();
+ names.insert(constant->GetName());
+ success = success && constant->CheckValid();
}
return success;
}