Skip to content

Commit cf89d9a

Browse files
committed
DPL: support macOS < 10.13
1 parent ba99cd9 commit cf89d9a

File tree

1 file changed

+49
-4
lines changed

1 file changed

+49
-4
lines changed

Framework/Core/include/Framework/DataDescriptorMatcher.h

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,60 @@ class DataDescriptorMatcher
155155
}
156156
};
157157

158+
bool leftValue = false, rightValue = false;
159+
160+
// FIXME: Using std::visit is not API compatible due to a new
161+
// exception being thrown. This is the ABI compatible version.
162+
// Replace with:
163+
//
164+
// switch (mOp) {
165+
// case Op::Or:
166+
// return std::visit(eval, mLeft) || std::visit(eval, mRight);
167+
// case Op::And:
168+
// return std::visit(eval, mLeft) && std::visit(eval, mRight);
169+
// case Op::Xor:
170+
// return std::visit(eval, mLeft) ^ std::visit(eval, mRight);
171+
// case Op::Just:
172+
// return std::visit(eval, mLeft);
173+
// }
174+
// When we drop support for macOS 10.13
175+
176+
if (auto pval0 = std::get_if<OriginValueMatcher>(&mLeft)) {
177+
leftValue = pval0->match(d);
178+
} else if (auto pval1 = std::get_if<DescriptionValueMatcher>(&mLeft)) {
179+
leftValue = pval1->match(d);
180+
} else if (auto pval2 = std::get_if<SubSpecificationTypeValueMatcher>(&mLeft)) {
181+
leftValue = pval2->match(d);
182+
} else if (auto pval3 = std::get_if<std::unique_ptr<DataDescriptorMatcher>>(&mLeft)) {
183+
leftValue = (*pval3)->match(d);
184+
} else if (auto pval4 = std::get_if<ConstantValueMatcher>(&mLeft)) {
185+
leftValue = pval4->match(d);
186+
} else {
187+
throw std::runtime_error("Bad parsing tree");
188+
}
189+
190+
if (auto pval0 = std::get_if<OriginValueMatcher>(&mRight)) {
191+
rightValue = pval0->match(d);
192+
} else if (auto pval1 = std::get_if<DescriptionValueMatcher>(&mRight)) {
193+
rightValue = pval1->match(d);
194+
} else if (auto pval2 = std::get_if<SubSpecificationTypeValueMatcher>(&mRight)) {
195+
rightValue = pval2->match(d);
196+
} else if (auto pval3 = std::get_if<std::unique_ptr<DataDescriptorMatcher>>(&mRight)) {
197+
rightValue = (*pval3)->match(d);
198+
} else if (auto pval4 = std::get_if<ConstantValueMatcher>(&mRight)) {
199+
rightValue = pval4->match(d);
200+
}
201+
// There are cases in which not having a rightValue might be legitimate,
202+
// so we do not throw an exception.
158203
switch (mOp) {
159204
case Op::Or:
160-
return std::visit(eval, mLeft) || std::visit(eval, mRight);
205+
return leftValue || rightValue;
161206
case Op::And:
162-
return std::visit(eval, mLeft) && std::visit(eval, mRight);
207+
return leftValue && rightValue;
163208
case Op::Xor:
164-
return std::visit(eval, mLeft) ^ std::visit(eval, mRight);
209+
return leftValue ^ rightValue;
165210
case Op::Just:
166-
return std::visit(eval, mLeft);
211+
return leftValue;
167212
}
168213
};
169214

0 commit comments

Comments
 (0)