summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorExpressionNode.cxx
diff options
context:
space:
mode:
authorLeonid Pospelov <pospelovlm@yandex.ru>2019-04-15 19:55:07 (GMT)
committerBrad King <brad.king@kitware.com>2019-04-22 14:41:28 (GMT)
commit9e1df5df5479b78d65d37e58b5cd0c93d70838ae (patch)
tree6bdc9b0eefe0ca215c26074dbbddcf5bedada1fa /Source/cmGeneratorExpressionNode.cxx
parent36f36d6a49976527a13a77d1ffff1fcdc5c3f5ba (diff)
downloadCMake-9e1df5df5479b78d65d37e58b5cd0c93d70838ae.zip
CMake-9e1df5df5479b78d65d37e58b5cd0c93d70838ae.tar.gz
CMake-9e1df5df5479b78d65d37e58b5cd0c93d70838ae.tar.bz2
cmGeneratorExpressionNode: use ctor arguments instead of macro
Diffstat (limited to 'Source/cmGeneratorExpressionNode.cxx')
-rw-r--r--Source/cmGeneratorExpressionNode.cxx66
1 files changed, 36 insertions, 30 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 306c9c7..5b4e4ed 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -99,36 +99,42 @@ static const struct OneNode buildInterfaceNode;
static const struct ZeroNode installInterfaceNode;
-#define BOOLEAN_OP_NODE(OPNAME, OP, SUCCESS_VALUE, FAILURE_VALUE) \
- static const struct OP##Node : public cmGeneratorExpressionNode \
- { \
- OP##Node() {} /* NOLINT(modernize-use-equals-default) */ \
- virtual int NumExpectedParameters() const { return OneOrMoreParameters; } \
- \
- std::string Evaluate(const std::vector<std::string>& parameters, \
- 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)
-BOOLEAN_OP_NODE(orNode, OR, 0, 1)
-
-#undef BOOLEAN_OP_NODE
+struct BooleanOpNode : public cmGeneratorExpressionNode
+{
+ BooleanOpNode(const char* op_, const char* successVal_,
+ const char* failureVal_)
+ : op(op_)
+ , successVal(successVal_)
+ , failureVal(failureVal_)
+ {
+ }
+
+ int NumExpectedParameters() const override { return OneOrMoreParameters; }
+
+ 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
{