mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-27 03:08:35 -06:00
cmGeneratorExpressionNode: use ctor arguments instead of macro
This commit is contained in:
committed by
Brad King
parent
36f36d6a49
commit
9e1df5df54
@@ -99,36 +99,42 @@ static const struct OneNode buildInterfaceNode;
|
|||||||
|
|
||||||
static const struct ZeroNode installInterfaceNode;
|
static const struct ZeroNode installInterfaceNode;
|
||||||
|
|
||||||
#define BOOLEAN_OP_NODE(OPNAME, OP, SUCCESS_VALUE, FAILURE_VALUE) \
|
struct BooleanOpNode : public cmGeneratorExpressionNode
|
||||||
static const struct OP##Node : public cmGeneratorExpressionNode \
|
{
|
||||||
{ \
|
BooleanOpNode(const char* op_, const char* successVal_,
|
||||||
OP##Node() {} /* NOLINT(modernize-use-equals-default) */ \
|
const char* failureVal_)
|
||||||
virtual int NumExpectedParameters() const { return OneOrMoreParameters; } \
|
: op(op_)
|
||||||
\
|
, successVal(successVal_)
|
||||||
std::string Evaluate(const std::vector<std::string>& parameters, \
|
, failureVal(failureVal_)
|
||||||
cmGeneratorExpressionContext* context, \
|
{
|
||||||
const GeneratorExpressionContent* content, \
|
}
|
||||||
cmGeneratorExpressionDAGChecker*) const \
|
|
||||||
{ \
|
|
||||||
for (std::string const& param : parameters) { \
|
|
||||||
if (param == #FAILURE_VALUE) { \
|
|
||||||
return #FAILURE_VALUE; \
|
|
||||||
} \
|
|
||||||
if (param != #SUCCESS_VALUE) { \
|
|
||||||
reportError(context, content->GetOriginalExpression(), \
|
|
||||||
"Parameters to $<" #OP \
|
|
||||||
"> must resolve to either '0' or '1'."); \
|
|
||||||
return std::string(); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
return #SUCCESS_VALUE; \
|
|
||||||
} \
|
|
||||||
} OPNAME;
|
|
||||||
|
|
||||||
BOOLEAN_OP_NODE(andNode, AND, 1, 0)
|
int NumExpectedParameters() const override { return OneOrMoreParameters; }
|
||||||
BOOLEAN_OP_NODE(orNode, OR, 0, 1)
|
|
||||||
|
|
||||||
#undef BOOLEAN_OP_NODE
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
||||||
|
cmGeneratorExpressionContext* context,
|
||||||
|
const GeneratorExpressionContent* content,
|
||||||
|
cmGeneratorExpressionDAGChecker*) const override
|
||||||
|
{
|
||||||
|
for (std::string const& param : parameters) {
|
||||||
|
if (param == this->failureVal) {
|
||||||
|
return this->failureVal;
|
||||||
|
}
|
||||||
|
if (param != this->successVal) {
|
||||||
|
std::ostringstream e;
|
||||||
|
e << "Parameters to $<" << this->op;
|
||||||
|
e << "> must resolve to either '0' or '1'.";
|
||||||
|
reportError(context, content->GetOriginalExpression(), e.str());
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this->successVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *const op, *const successVal, *const failureVal;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const BooleanOpNode andNode("AND", "1", "0"), orNode("OR", "0", "1");
|
||||||
|
|
||||||
static const struct NotNode : public cmGeneratorExpressionNode
|
static const struct NotNode : public cmGeneratorExpressionNode
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user