Instance is the smallest unit of manifests/matrices.
Introduce forEachInstance on HalManifest and CompatibilityMatrix,
because <hal> are no longer the smallest unit of tests, but
rather a ManifestInstance / MatrixInstance object.
Bug: 73556059
Bug: 74247301
Test: libvintf_test
Test: vintf_object_test
Change-Id: If7186617db52acd67f255ac6e6c99f34a7570206
diff --git a/main.cpp b/main.cpp
index c4119c9..7843cb5 100644
--- a/main.cpp
+++ b/main.cpp
@@ -188,34 +188,38 @@
// if it does not exist and setting the corresponding indicator (as specified by "mutate").
void insert(const HalManifest* manifest, Table* table, const RowMutator& mutate) {
if (manifest == nullptr) return;
- manifest->forEachInstance([&](const auto& package, const auto& version, const auto& interface,
- const auto& instance, bool* /* stop */) {
- std::string key = toFQNameString(package, VersionRange{version.majorVer, version.minorVer},
- interface, instance);
+ manifest->forEachInstance([&](const auto& manifestInstance) {
+ std::string key = toFQNameString(manifestInstance.package(), manifestInstance.version(),
+ manifestInstance.interface(), manifestInstance.instance());
mutate(&(*table)[key]);
+ return true;
});
}
void insert(const CompatibilityMatrix* matrix, Table* table, const RowMutator& mutate) {
if (matrix == nullptr) return;
- matrix->forEachInstance([&](const auto& package, const auto& range, const auto& interface,
- const auto& instance, bool optional, bool* /* stop */) {
+ matrix->forEachInstance([&](const auto& matrixInstance) {
bool missed = false;
- for (auto minorVer = range.minMinor; minorVer <= range.maxMinor; ++minorVer) {
- std::string key = toFQNameString(package, VersionRange{range.majorVer, minorVer},
- interface, instance);
+ for (auto minorVer = matrixInstance.versionRange().minMinor;
+ minorVer <= matrixInstance.versionRange().maxMinor; ++minorVer) {
+ std::string key = toFQNameString(
+ matrixInstance.package(), Version{matrixInstance.versionRange().majorVer, minorVer},
+ matrixInstance.interface(), matrixInstance.instance());
auto it = table->find(key);
if (it == table->end()) {
missed = true;
} else {
mutate(&it->second);
- it->second.required = !optional;
+ it->second.required = !matrixInstance.optional();
}
}
if (missed) {
- std::string key = toFQNameString(package, range, interface, instance);
+ std::string key =
+ toFQNameString(matrixInstance.package(), matrixInstance.versionRange(),
+ matrixInstance.interface(), matrixInstance.instance());
mutate(&(*table)[key]);
}
+ return true;
});
}