From ae71c23147a0a0fc80cf51e200152597631a6da1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Fri, 17 Apr 2020 17:43:04 +0200 Subject: [PATCH] [poincare] Override method Unit::node to return UnitNode --- poincare/include/poincare/unit.h | 1 + poincare/src/unit.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/poincare/include/poincare/unit.h b/poincare/include/poincare/unit.h index 6f5596cec..2d05ad88a 100644 --- a/poincare/include/poincare/unit.h +++ b/poincare/include/poincare/unit.h @@ -731,6 +731,7 @@ public: void chooseBestMultipleForValue(double & value, const int exponent, ExpressionNode::ReductionContext reductionContext); private: + UnitNode * node() const { return static_cast(Expression::node()); } Expression removeUnit(Expression * unit); }; diff --git a/poincare/src/unit.cpp b/poincare/src/unit.cpp index 3b1e58654..91a4b3ef2 100644 --- a/poincare/src/unit.cpp +++ b/poincare/src/unit.cpp @@ -285,7 +285,7 @@ Expression Unit::shallowReduce(ExpressionNode::ReductionContext reductionContext if (reductionContext.unitConversion() == ExpressionNode::UnitConversion::None) { return *this; } - UnitNode * unitNode = static_cast(node()); + UnitNode * unitNode = node(); const Dimension * dim = unitNode->dimension(); const Representative * rep = unitNode->representative(); const Prefix * pre = unitNode->prefix(); @@ -315,7 +315,7 @@ Expression Unit::shallowReduce(ExpressionNode::ReductionContext reductionContext void Unit::chooseBestMultipleForValue(double & value, const int exponent, ExpressionNode::ReductionContext reductionContext) { assert(value != 0 && !std::isnan(value) && !std::isinf(value) && exponent != 0); - UnitNode * unitNode = static_cast(node()); + UnitNode * unitNode = node(); const Dimension * dim = unitNode->dimension(); /* Find in the Dimension 'dim' which unit (Representative and Prefix) make * the value closer to 1.