From 858c9fbb55d16d4e245849f4a3ee98fb5bdb81f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Fri, 18 Nov 2016 17:37:30 +0100 Subject: [PATCH] [poincare] Add constants to context class Change-Id: I31f1cdc6ac49062d5cac36c36f8f9650dac9ea61 --- poincare/include/poincare/context.h | 6 ++++-- poincare/src/context.cpp | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/poincare/include/poincare/context.h b/poincare/include/poincare/context.h index 81ad82af8..bf686b3c9 100644 --- a/poincare/include/poincare/context.h +++ b/poincare/include/poincare/context.h @@ -15,10 +15,12 @@ class Context { virtual const Expression * expressionForSymbol(const Symbol * symbol); virtual const Expression * scalarExpressionForIndex(int index); void setExpressionForSymbolName(Expression * expression, const Symbol * symbol); + static constexpr uint16_t k_maxNumberOfScalarExpressions = 26; + static constexpr uint16_t k_maxNumberOfListExpressions = 10; + static constexpr uint16_t k_maxNumberOfMatrixExpressions = 10; private: int symbolIndex(const Symbol * symbol) const; - static constexpr uint16_t k_maxNumberOfExpressions = 26; - Expression * m_expressions[k_maxNumberOfExpressions]; + Expression * m_expressions[k_maxNumberOfScalarExpressions]; static Float * defaultExpression(); }; diff --git a/poincare/src/context.cpp b/poincare/src/context.cpp index 4b51f1bbc..e0d231938 100644 --- a/poincare/src/context.cpp +++ b/poincare/src/context.cpp @@ -3,7 +3,7 @@ Context::Context() { - for (int i = 0; i < k_maxNumberOfExpressions; i++) { + for (int i = 0; i < k_maxNumberOfScalarExpressions; i++) { m_expressions[i] = nullptr; } } @@ -20,7 +20,7 @@ int Context::symbolIndex(const Symbol * symbol) const { const Expression * Context::expressionForSymbol(const Symbol * symbol) { int index = symbolIndex(symbol); - if (index < 0 || index >= k_maxNumberOfExpressions) { + if (index < 0 || index >= k_maxNumberOfScalarExpressions) { return nullptr; } if (m_expressions[index] == nullptr) { @@ -30,7 +30,7 @@ const Expression * Context::expressionForSymbol(const Symbol * symbol) { } const Expression * Context::scalarExpressionForIndex(int index) { - assert(index < k_maxNumberOfExpressions); + assert(index < k_maxNumberOfScalarExpressions); return m_expressions[index]; }