From 1626c6949499a74fefcb82b55a739113163d2983 Mon Sep 17 00:00:00 2001 From: Eivind Kvedalen Date: Fri, 25 Mar 2016 15:41:41 +0100 Subject: [PATCH] Expressions: Moved Expression::priority to cpp file. --- src/App/Expression.cpp | 55 ++++++++++++++++++++++++++++++++++++------ src/App/Expression.h | 14 +++++------ 2 files changed, 55 insertions(+), 14 deletions(-) diff --git a/src/App/Expression.cpp b/src/App/Expression.cpp index 5bb6c68dd..eee2b4a58 100644 --- a/src/App/Expression.cpp +++ b/src/App/Expression.cpp @@ -207,6 +207,11 @@ Expression *UnitExpression::copy() const return new UnitExpression(owner, quantity, unitStr); } +int UnitExpression::priority() const +{ + return 20; +} + // // NumberExpression class // @@ -246,6 +251,11 @@ Expression *NumberExpression::copy() const return new NumberExpression(owner, quantity); } +int NumberExpression::priority() const +{ + return 20; +} + /** * Negate the stored value. */ @@ -529,21 +539,27 @@ Expression *OperatorExpression::copy() const int OperatorExpression::priority() const { switch (op) { + case EQ: + case NEQ: + case LT: + case GT: + case LTE: + case GTE: + return 1; case ADD: - return 5; case SUB: - return 5; + return 3; case MUL: - case UNIT: - return 10; case DIV: - return 10; + return 4; case POW: - return 10; + return 5; + case UNIT: case NEG: case POS: - return 15; + return 6; default: + assert(false); return 0; } } @@ -1177,6 +1193,11 @@ Expression *FunctionExpression::copy() const return new FunctionExpression(owner, f, a); } +int FunctionExpression::priority() const +{ + return 20; +} + /** * Compute the dependecy set of the expression. The set contains the names * of all Property objects this expression relies on. @@ -1347,6 +1368,11 @@ Expression *VariableExpression::copy() const return new VariableExpression(owner, var); } +int VariableExpression::priority() const +{ + return 20; +} + /** * Compute the dependecy of the expression. In this case \a props * is a set of strings, i.e the names of the Property objects, and @@ -1421,6 +1447,11 @@ std::string StringExpression::toString() const return quote(text); } +int StringExpression::priority() const +{ + return 20; +} + /** * Return a copy of the expression. */ @@ -1528,6 +1559,11 @@ Expression *ConstantExpression::copy() const return new ConstantExpression(owner, name.c_str(), quantity); } +int ConstantExpression::priority() const +{ + return 20; +} + TYPESYSTEM_SOURCE_ABSTRACT(App::BooleanExpression, App::NumberExpression); BooleanExpression::BooleanExpression(const DocumentObject *_owner, bool _value) @@ -1577,6 +1613,11 @@ Expression *RangeExpression::copy() const return new RangeExpression(owner, range.fromCellString(), range.toCellString()); } +int RangeExpression::priority() const +{ + return 20; +} + void RangeExpression::getDeps(std::set &props) const { Range i(range); diff --git a/src/App/Expression.h b/src/App/Expression.h index 3f3c0b523..1f78daf68 100644 --- a/src/App/Expression.h +++ b/src/App/Expression.h @@ -129,7 +129,7 @@ public: virtual Expression * copy() const; - virtual int priority() const { return 20; } + virtual int priority() const; void setUnit(const Base::Quantity &_quantity); @@ -165,7 +165,7 @@ public: virtual Expression * copy() const; - virtual int priority() const { return 20; } + virtual int priority() const; void negate(); @@ -183,7 +183,7 @@ public: virtual Expression * copy() const; - virtual int priority() const { return 20; } + virtual int priority() const; std::string getName() const { return name; } @@ -344,7 +344,7 @@ public: virtual Expression * copy() const; - virtual int priority() const { return 20; } + virtual int priority() const; virtual void getDeps(std::set &props) const; @@ -382,7 +382,7 @@ public: virtual Expression * copy() const; - virtual int priority() const { return 20; } + virtual int priority() const; virtual void getDeps(std::set &props) const; @@ -425,7 +425,7 @@ public: virtual std::string getText() const { return text; } - virtual int priority() const { return 20; } + virtual int priority() const; virtual Expression * copy() const; @@ -449,7 +449,7 @@ public: virtual Expression * copy() const; - virtual int priority() const { return 20; } + virtual int priority() const; virtual void getDeps(std::set &props) const;