From acbcbbfe6de67ec619cbaad8c4436e844ddcc45b Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Sat, 23 Sep 2017 15:40:29 +0200 Subject: [PATCH] [poincare] Hierarchy::operands() is a "const Expression * const *" --- poincare/include/poincare/bounded_static_hierarchy.h | 2 +- poincare/include/poincare/dynamic_hierarchy.h | 8 ++++---- poincare/include/poincare/factorial.h | 2 +- poincare/include/poincare/hierarchy.h | 2 +- poincare/include/poincare/static_hierarchy.h | 8 ++++---- poincare/src/bounded_static_hierarchy.cpp | 2 +- poincare/src/dynamic_hierarchy.cpp | 8 ++++---- poincare/src/factorial.cpp | 2 +- poincare/src/power.cpp | 2 +- poincare/src/static_hierarchy.cpp | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/poincare/include/poincare/bounded_static_hierarchy.h b/poincare/include/poincare/bounded_static_hierarchy.h index 058a8dec6..a4479be0a 100644 --- a/poincare/include/poincare/bounded_static_hierarchy.h +++ b/poincare/include/poincare/bounded_static_hierarchy.h @@ -9,7 +9,7 @@ template class BoundedStaticHierarchy : public StaticHierarchy { public: BoundedStaticHierarchy(); - BoundedStaticHierarchy(Expression * const * operands, int numberOfOperands, bool cloneOperands = true); + BoundedStaticHierarchy(const Expression * const * operands, int numberOfOperands, bool cloneOperands = true); int numberOfOperands() const override { return m_numberOfOperands; } bool hasValidNumberOfOperands(int numberOfOperands) const override; private: diff --git a/poincare/include/poincare/dynamic_hierarchy.h b/poincare/include/poincare/dynamic_hierarchy.h index ff7c0dcf2..845845514 100644 --- a/poincare/include/poincare/dynamic_hierarchy.h +++ b/poincare/include/poincare/dynamic_hierarchy.h @@ -8,7 +8,7 @@ namespace Poincare { class DynamicHierarchy : public Hierarchy { public: DynamicHierarchy(); - DynamicHierarchy(Expression * const * operands, int numberOfOperands, bool cloneOperands = true); + DynamicHierarchy(const Expression * const * operands, int numberOfOperands, bool cloneOperands = true); ~DynamicHierarchy(); DynamicHierarchy(const DynamicHierarchy & other) = delete; DynamicHierarchy(DynamicHierarchy && other) = delete; @@ -16,12 +16,12 @@ public: DynamicHierarchy& operator=(DynamicHierarchy && other) = delete; int numberOfOperands() const override { return m_numberOfOperands; } - Expression * const * operands() const override { return m_operands; }; + const Expression * const * operands() const override { return m_operands; }; void removeOperand(const Expression * e, bool deleteAfterRemoval = true); - void addOperands(Expression * const * operands, int numberOfOperands); + void addOperands(const Expression * const * operands, int numberOfOperands); private: - Expression ** m_operands; + const Expression ** m_operands; int m_numberOfOperands; }; diff --git a/poincare/include/poincare/factorial.h b/poincare/include/poincare/factorial.h index 023dba217..3159f1ad6 100644 --- a/poincare/include/poincare/factorial.h +++ b/poincare/include/poincare/factorial.h @@ -8,7 +8,7 @@ namespace Poincare { class Factorial : public StaticHierarchy<1> { public: - Factorial(Expression * argument, bool clone = true); + Factorial(const Expression * argument, bool clone = true); Type type() const override; Expression * clone() const override; bool isCommutative() const override; diff --git a/poincare/include/poincare/hierarchy.h b/poincare/include/poincare/hierarchy.h index c5051c1d9..6303c36d3 100644 --- a/poincare/include/poincare/hierarchy.h +++ b/poincare/include/poincare/hierarchy.h @@ -11,7 +11,7 @@ public: void swapOperands(int i, int j) override; void replaceOperand(const Expression * oldOperand, Expression * newOperand, bool deleteOldOperand = true) override; void detachOperands(); // Removes all operands WITHOUT deleting them - virtual Expression * const * operands() const = 0; + virtual const Expression * const * operands() const = 0; }; } diff --git a/poincare/include/poincare/static_hierarchy.h b/poincare/include/poincare/static_hierarchy.h index 98881944f..59a392e18 100644 --- a/poincare/include/poincare/static_hierarchy.h +++ b/poincare/include/poincare/static_hierarchy.h @@ -11,7 +11,7 @@ class StaticHierarchy : public Hierarchy { public: StaticHierarchy(); - StaticHierarchy(Expression * const * operands, bool cloneOperands = true); + StaticHierarchy(const Expression * const * operands, bool cloneOperands = true); ~StaticHierarchy(); StaticHierarchy(const StaticHierarchy & other) = delete; StaticHierarchy(StaticHierarchy && other) = delete; @@ -20,11 +20,11 @@ public: virtual void setArgument(ListData * listData, int numberOfEntries, bool clone); int numberOfOperands() const override { return T; } - Expression * const * operands() const override { return m_operands; } + const Expression * const * operands() const override { return m_operands; } virtual bool hasValidNumberOfOperands(int numberOfOperands) const; protected: - void build(Expression * const * operands, int numberOfOperands, bool cloneOperands); - Expression * m_operands[T]; + void build(const Expression * const * operands, int numberOfOperands, bool cloneOperands); + const Expression * m_operands[T]; }; } diff --git a/poincare/src/bounded_static_hierarchy.cpp b/poincare/src/bounded_static_hierarchy.cpp index 729b9631f..2fc96789d 100644 --- a/poincare/src/bounded_static_hierarchy.cpp +++ b/poincare/src/bounded_static_hierarchy.cpp @@ -13,7 +13,7 @@ BoundedStaticHierarchy::BoundedStaticHierarchy() : } template -BoundedStaticHierarchy::BoundedStaticHierarchy(Expression * const * operands, int numberOfOperands, bool cloneOperands) : +BoundedStaticHierarchy::BoundedStaticHierarchy(const Expression * const * operands, int numberOfOperands, bool cloneOperands) : m_numberOfOperands(numberOfOperands) { StaticHierarchy::build(operands, numberOfOperands, cloneOperands); diff --git a/poincare/src/dynamic_hierarchy.cpp b/poincare/src/dynamic_hierarchy.cpp index f2fffcbb8..a1c0d5dde 100644 --- a/poincare/src/dynamic_hierarchy.cpp +++ b/poincare/src/dynamic_hierarchy.cpp @@ -12,12 +12,12 @@ DynamicHierarchy::DynamicHierarchy() : { } -DynamicHierarchy::DynamicHierarchy(Expression * const * operands, int numberOfOperands, bool cloneOperands) : +DynamicHierarchy::DynamicHierarchy(const Expression * const * operands, int numberOfOperands, bool cloneOperands) : m_numberOfOperands(numberOfOperands) { assert(operands != nullptr); assert(numberOfOperands >= 2); - m_operands = new Expression * [numberOfOperands]; + m_operands = new const Expression * [numberOfOperands]; for (int i=0; i 0); - Expression ** newOperands = new Expression * [m_numberOfOperands+numberOfOperands]; + const Expression ** newOperands = new const Expression * [m_numberOfOperands+numberOfOperands]; for (int i=0; i(&argument, clone) { } diff --git a/poincare/src/power.cpp b/poincare/src/power.cpp index 299813e3e..e7f4eafce 100644 --- a/poincare/src/power.cpp +++ b/poincare/src/power.cpp @@ -81,7 +81,7 @@ template Evaluation * Power::computeOnMatrices(Evaluation * m, ExpressionLayout * Power::privateCreateLayout(FloatDisplayMode floatDisplayMode, ComplexFormat complexFormat) const { assert(floatDisplayMode != FloatDisplayMode::Default); assert(complexFormat != ComplexFormat::Default); - Expression * indiceOperand = m_operands[1]; + const Expression * indiceOperand = m_operands[1]; // Delete eventual parentheses of the indice in the pretty print if (m_operands[1]->type() == Type::Parenthesis) { indiceOperand = (Expression *)m_operands[1]->operand(0); diff --git a/poincare/src/static_hierarchy.cpp b/poincare/src/static_hierarchy.cpp index b2ab76c82..49226e590 100644 --- a/poincare/src/static_hierarchy.cpp +++ b/poincare/src/static_hierarchy.cpp @@ -12,7 +12,7 @@ StaticHierarchy::StaticHierarchy() : } template -StaticHierarchy::StaticHierarchy(Expression * const * operands, bool cloneOperands) +StaticHierarchy::StaticHierarchy(const Expression * const * operands, bool cloneOperands) { build(operands, T, cloneOperands); } @@ -37,7 +37,7 @@ bool StaticHierarchy::hasValidNumberOfOperands(int numberOfOperands) const { } template -void StaticHierarchy::build(Expression * const * operands, int numberOfOperands, bool cloneOperands) { +void StaticHierarchy::build(const Expression * const * operands, int numberOfOperands, bool cloneOperands) { assert(operands != nullptr); assert(numberOfOperands <= T); for (int i=0; i < numberOfOperands; i++) {