diff --git a/apps/calculation/calculation.cpp b/apps/calculation/calculation.cpp index a38f4ff36..dcb26d668 100644 --- a/apps/calculation/calculation.cpp +++ b/apps/calculation/calculation.cpp @@ -66,21 +66,18 @@ void Calculation::setContent(const char * c, Context * context, Expression * ans KDCoordinate Calculation::height(Context * context) { if (m_height < 0) { - ExpressionLayout * inputLayout = createInputLayout(); - KDCoordinate inputHeight = inputLayout->size().height(); - delete inputLayout; - Poincare::ExpressionLayout * approximateLayout = createApproximateOutputLayout(context); - KDCoordinate approximateOutputHeight = approximateLayout->size().height(); + LayoutRef inputLayout = createInputLayout(); + KDCoordinate inputHeight = inputLayout.layoutSize().height(); + LayoutRef approximateLayout = createApproximateOutputLayout(context); + KDCoordinate approximateOutputHeight = approximateLayout.layoutSize().height(); if (shouldOnlyDisplayApproximateOutput(context)) { m_height = inputHeight+approximateOutputHeight; } else { - Poincare::ExpressionLayout * exactLayout = createExactOutputLayout(context); - KDCoordinate exactOutputHeight = exactLayout->size().height(); - KDCoordinate outputHeight = max(exactLayout->baseline(), approximateLayout->baseline()) + max(exactOutputHeight-exactLayout->baseline(), approximateOutputHeight-approximateLayout->baseline()); - delete exactLayout; + LayoutRef exactLayout = createExactOutputLayout(context); + KDCoordinate exactOutputHeight = exactLayout.layoutSize().height(); + KDCoordinate outputHeight = max(exactLayout.baseline(), approximateLayout.baseline()) + max(exactOutputHeight-exactLayout.baseline(), approximateOutputHeight-approximateLayout.baseline()); m_height = inputHeight + outputHeight; } - delete approximateLayout; } return m_height; } @@ -104,11 +101,11 @@ Expression * Calculation::input() { return m_input; } -ExpressionLayout * Calculation::createInputLayout() { +LayoutRef Calculation::createInputLayout() { if (input() != nullptr) { return input()->createLayout(PrintFloat::Mode::Decimal, Expression::ComplexFormat::Cartesian); } - return nullptr; + return LayoutRef(nullptr); } bool Calculation::isEmpty() { @@ -156,11 +153,11 @@ Expression * Calculation::exactOutput(Context * context) { return m_exactOutput; } -ExpressionLayout * Calculation::createExactOutputLayout(Context * context) { +LayoutRef Calculation::createExactOutputLayout(Context * context) { if (exactOutput(context) != nullptr) { return exactOutput(context)->createLayout(); } - return nullptr; + return LayoutRef(nullptr); } Expression * Calculation::approximateOutput(Context * context) { @@ -178,11 +175,11 @@ Expression * Calculation::approximateOutput(Context * context) { return m_approximateOutput; } -ExpressionLayout * Calculation::createApproximateOutputLayout(Context * context) { +LayoutRef Calculation::createApproximateOutputLayout(Context * context) { if (approximateOutput(context) != nullptr) { return approximateOutput(context)->createLayout(); } - return nullptr; + return LayoutRef(nullptr); } bool Calculation::shouldOnlyDisplayApproximateOutput(Context * context) { diff --git a/apps/calculation/calculation.h b/apps/calculation/calculation.h index 68f692876..f626207a5 100644 --- a/apps/calculation/calculation.h +++ b/apps/calculation/calculation.h @@ -29,11 +29,11 @@ public: const char * exactOutputText(); const char * approximateOutputText(); Poincare::Expression * input(); - Poincare::ExpressionLayout * createInputLayout(); + Poincare::LayoutRef createInputLayout(); Poincare::Expression * approximateOutput(Poincare::Context * context); Poincare::Expression * exactOutput(Poincare::Context * context); - Poincare::ExpressionLayout * createExactOutputLayout(Poincare::Context * context); - Poincare::ExpressionLayout * createApproximateOutputLayout(Poincare::Context * context); + Poincare::LayoutRef createExactOutputLayout(Poincare::Context * context); + Poincare::LayoutRef createApproximateOutputLayout(Poincare::Context * context); bool isEmpty(); void tidy(); bool shouldOnlyDisplayApproximateOutput(Poincare::Context * context); diff --git a/apps/calculation/history_view_cell.cpp b/apps/calculation/history_view_cell.cpp index eea40852e..b6e4a645a 100644 --- a/apps/calculation/history_view_cell.cpp +++ b/apps/calculation/history_view_cell.cpp @@ -18,25 +18,10 @@ HistoryViewCell::HistoryViewCell(Responder * parentResponder) : { } -HistoryViewCell::~HistoryViewCell() { - if (m_inputLayout != nullptr) { - delete m_inputLayout; - m_inputLayout = nullptr; - } - if (m_exactOutputLayout != nullptr) { - delete m_exactOutputLayout; - m_exactOutputLayout = nullptr; - } - if (m_approximateOutputLayout != nullptr) { - delete m_approximateOutputLayout; - m_approximateOutputLayout = nullptr; - } -} - Shared::ScrollableExactApproximateExpressionsView * HistoryViewCell::outputView() { return &m_scrollableOutputView; - } + void HistoryViewCell::setEven(bool even) { EvenOddCell::setEven(even); m_inputView.setBackgroundColor(backgroundColor()); @@ -57,11 +42,11 @@ void HistoryViewCell::setHighlighted(bool highlight) { reloadScroll(); } -Poincare::ExpressionLayout * HistoryViewCell::expressionLayout() const { +Poincare::LayoutRef HistoryViewCell::layoutRef() const { if (m_selectedSubviewType == SubviewType::Input) { return m_inputLayout; } else { - return m_scrollableOutputView.expressionLayout(); + return m_scrollableOutputView.layoutRef(); } } @@ -109,27 +94,20 @@ void HistoryViewCell::layoutSubviews() { } void HistoryViewCell::setCalculation(Calculation * calculation) { - if (m_inputLayout) { - delete m_inputLayout; - } m_inputLayout = calculation->createInputLayout(); - m_inputView.setExpressionLayout(m_inputLayout); + m_inputView.setLayoutRef(m_inputLayout); App * calculationApp = (App *)app(); /* Both output expressions have to be updated at the same time. Otherwise, * when updating one layout, if the second one still points to a deleted * layout, calling to layoutSubviews() would fail. */ - if (m_exactOutputLayout) { - delete m_exactOutputLayout; - m_exactOutputLayout = nullptr; + if (m_exactOutputLayout.isDefined()) { + m_exactOutputLayout = Poincare::LayoutRef(nullptr); } if (!calculation->shouldOnlyDisplayApproximateOutput(calculationApp->localContext())) { m_exactOutputLayout = calculation->createExactOutputLayout(calculationApp->localContext()); } - if (m_approximateOutputLayout) { - delete m_approximateOutputLayout; - } m_approximateOutputLayout = calculation->createApproximateOutputLayout(calculationApp->localContext()); - Poincare::ExpressionLayout * outputExpressions[2] = {m_approximateOutputLayout, m_exactOutputLayout}; + Poincare::LayoutRef outputExpressions[2] = {m_approximateOutputLayout, m_exactOutputLayout}; m_scrollableOutputView.setExpressions(outputExpressions); I18n::Message equalMessage = calculation->exactAndApproximateDisplayedOutputsAreEqual(calculationApp->localContext()) == Calculation::EqualSign::Equal ? I18n::Message::Equal : I18n::Message::AlmostEqual; m_scrollableOutputView.setEqualMessage(equalMessage); diff --git a/apps/calculation/history_view_cell.h b/apps/calculation/history_view_cell.h index c581c3e21..4f7e060e6 100644 --- a/apps/calculation/history_view_cell.h +++ b/apps/calculation/history_view_cell.h @@ -15,7 +15,6 @@ public: Output }; HistoryViewCell(Responder * parentResponder); - ~HistoryViewCell(); void reloadCell() override; void reloadScroll(); void setEven(bool even) override; @@ -23,7 +22,7 @@ public: Responder * responder() override { return this; } - Poincare::ExpressionLayout * expressionLayout() const override; + Poincare::LayoutRef layoutRef() const override; KDColor backgroundColor() const override; void setCalculation(Calculation * calculation); int numberOfSubviews() const override; @@ -37,9 +36,9 @@ public: Shared::ScrollableExactApproximateExpressionsView * outputView(); private: constexpr static KDCoordinate k_resultWidth = 80; - Poincare::ExpressionLayout * m_inputLayout; - Poincare::ExpressionLayout * m_exactOutputLayout; - Poincare::ExpressionLayout * m_approximateOutputLayout; + Poincare::LayoutRef m_inputLayout; + Poincare::LayoutRef m_exactOutputLayout; + Poincare::LayoutRef m_approximateOutputLayout; ScrollableExpressionView m_inputView; Shared::ScrollableExactApproximateExpressionsView m_scrollableOutputView; SubviewType m_selectedSubviewType; diff --git a/apps/calculation/scrollable_expression_view.cpp b/apps/calculation/scrollable_expression_view.cpp index 70e10b526..a67639df0 100644 --- a/apps/calculation/scrollable_expression_view.cpp +++ b/apps/calculation/scrollable_expression_view.cpp @@ -10,8 +10,8 @@ ScrollableExpressionView::ScrollableExpressionView(Responder * parentResponder) { } -void ScrollableExpressionView::setExpressionLayout(ExpressionLayout * expressionLayout) { - m_expressionView.setExpressionLayout(expressionLayout); +void ScrollableExpressionView::setLayoutRef(LayoutRef layoutRef) { + m_expressionView.setLayoutRef(layoutRef); layoutSubviews(); } diff --git a/apps/calculation/scrollable_expression_view.h b/apps/calculation/scrollable_expression_view.h index 38ae2d8d4..2e3281833 100644 --- a/apps/calculation/scrollable_expression_view.h +++ b/apps/calculation/scrollable_expression_view.h @@ -8,7 +8,7 @@ namespace Calculation { class ScrollableExpressionView : public ScrollableView, public ScrollViewDataSource { public: ScrollableExpressionView(Responder * parentResponder); - void setExpressionLayout(Poincare::ExpressionLayout * expressionLayout); + void setLayoutRef(Poincare::LayoutRef layoutRef); void setBackgroundColor(KDColor backgroundColor) override; KDSize minimalSizeForOptimalDisplay() const override; private: diff --git a/apps/shared/expression_model.cpp b/apps/shared/expression_model.cpp index b962212d5..edcce43ff 100644 --- a/apps/shared/expression_model.cpp +++ b/apps/shared/expression_model.cpp @@ -10,16 +10,15 @@ namespace Shared { ExpressionModel::ExpressionModel() : m_text{0}, m_expression(nullptr), - m_layout(nullptr) + m_layoutRef(nullptr) { } ExpressionModel::~ExpressionModel() { /* We cannot call tidy here because tidy is a virtual function and does not * do the same thing for all children class. */ - if (m_layout != nullptr) { - delete m_layout; - m_layout = nullptr; + if (m_layoutRef.isDefined()) { + m_layoutRef = LayoutRef(nullptr); } if (m_expression != nullptr) { delete m_expression; @@ -44,15 +43,15 @@ Poincare::Expression * ExpressionModel::expression(Poincare::Context * context) return m_expression; } -Poincare::ExpressionLayout * ExpressionModel::layout() { - if (m_layout == nullptr) { +LayoutRef ExpressionModel::layoutRef() { + if (!m_layoutRef.isDefined()) { Expression * nonSimplifiedExpression = Expression::parse(m_text); if (nonSimplifiedExpression != nullptr) { - m_layout = nonSimplifiedExpression->createLayout(PrintFloat::Mode::Decimal); + m_layoutRef = nonSimplifiedExpression->createLayout(PrintFloat::Mode::Decimal); delete nonSimplifiedExpression; } } - return m_layout; + return m_layoutRef; } bool ExpressionModel::isDefined() { @@ -68,9 +67,8 @@ void ExpressionModel::setContent(const char * c) { /* We cannot call tidy here because tidy is a virtual function and does not * do the same thing for all children class. And here we want to delete only * the m_layout and m_expression. */ - if (m_layout != nullptr) { - delete m_layout; - m_layout = nullptr; + if (m_layoutRef.isDefined()) { + m_layoutRef = LayoutRef(nullptr); } if (m_expression != nullptr) { delete m_expression; @@ -79,9 +77,8 @@ void ExpressionModel::setContent(const char * c) { } void ExpressionModel::tidy() { - if (m_layout != nullptr) { - delete m_layout; - m_layout = nullptr; + if (m_layoutRef.isDefined()) { + m_layoutRef = LayoutRef(nullptr); } if (m_expression != nullptr) { delete m_expression; diff --git a/apps/shared/expression_model.h b/apps/shared/expression_model.h index eca8b3c44..4ad4e9c0c 100644 --- a/apps/shared/expression_model.h +++ b/apps/shared/expression_model.h @@ -17,7 +17,7 @@ public: ExpressionModel(ExpressionModel&& other) = delete; const char * text() const; Poincare::Expression * expression(Poincare::Context * context) const; - Poincare::ExpressionLayout * layout(); + Poincare::LayoutRef layoutRef(); /* Here, isDefined is the exact contrary of isEmpty. However, for Sequence * inheriting from ExpressionModel, isEmpty and isDefined have not exactly * opposite meaning. For instance, u(n+1)=u(n) & u(0) = ... is not empty and @@ -35,7 +35,7 @@ private: static_assert((k_dataLengthInBytes & 0x3) == 0, "The expression model data size is not a multiple of 4 bytes (cannot compute crc)"); // Assert that dataLengthInBytes is a multiple of 4 char m_text[k_expressionBufferSize]; mutable Poincare::Expression * m_expression; - mutable Poincare::ExpressionLayout * m_layout; + mutable Poincare::LayoutRef m_layoutRef; }; } diff --git a/apps/shared/expression_model_list_controller.cpp b/apps/shared/expression_model_list_controller.cpp index 77b374454..3eb4ee778 100644 --- a/apps/shared/expression_model_list_controller.cpp +++ b/apps/shared/expression_model_list_controller.cpp @@ -23,17 +23,18 @@ KDCoordinate ExpressionModelListController::expressionRowHeight(int j) { return Metric::StoreRowHeight; } ExpressionModel * m = modelStore()->modelAtIndex(j); - if (m->layout() == nullptr) { + if (!m->layoutRef().isDefined()) { return Metric::StoreRowHeight; } - KDCoordinate modelSize = m->layout()->size().height(); + KDCoordinate modelSize = m->layoutRef().layoutSize().height(); return modelSize + Metric::StoreRowHeight - KDText::charSize().height(); } void ExpressionModelListController::willDisplayExpressionCellAtIndex(HighlightCell * cell, int j) { EvenOddExpressionCell * myCell = (EvenOddExpressionCell *)cell; ExpressionModel * m = modelStore()->modelAtIndex(j); - myCell->setExpressionLayout(m->layout()); + myCell->setExpressionLayout(nullptr); //TODO + //myCell->setExpressionLayout(m->layout()); } /* Responder */ diff --git a/apps/shared/scrollable_exact_approximate_expressions_cell.h b/apps/shared/scrollable_exact_approximate_expressions_cell.h index 0c49a48a7..0baaec24b 100644 --- a/apps/shared/scrollable_exact_approximate_expressions_cell.h +++ b/apps/shared/scrollable_exact_approximate_expressions_cell.h @@ -9,8 +9,8 @@ namespace Shared { class ScrollableExactApproximateExpressionsCell : public ::EvenOddCell, public Responder { public: ScrollableExactApproximateExpressionsCell(Responder * parentResponder = nullptr); - void setExpressions(Poincare::ExpressionLayout ** expressionsLayout) { - return m_view.setExpressions(expressionsLayout); + void setExpressions(Poincare::LayoutRef * layoutRefs) { + return m_view.setExpressions(layoutRefs); // TODO rename setLayouts } void setEqualMessage(I18n::Message equalSignMessage) { return m_view.setEqualMessage(equalSignMessage); @@ -22,7 +22,7 @@ public: Responder * responder() override { return this; } - Poincare::ExpressionLayout * expressionLayout() const override { return m_view.expressionLayout(); } + Poincare::LayoutRef layoutRef() const override { return m_view.layoutRef(); } void didBecomeFirstResponder() override; constexpr static KDCoordinate k_margin = 5; private: diff --git a/apps/shared/scrollable_exact_approximate_expressions_view.cpp b/apps/shared/scrollable_exact_approximate_expressions_view.cpp index cb352ae6b..8276592b3 100644 --- a/apps/shared/scrollable_exact_approximate_expressions_view.cpp +++ b/apps/shared/scrollable_exact_approximate_expressions_view.cpp @@ -49,8 +49,8 @@ KDSize ScrollableExactApproximateExpressionsView::ContentCell::minimalSizeForOpt return approximateExpressionSize; } KDSize exactExpressionSize = m_exactExpressionView.minimalSizeForOptimalDisplay(); - KDCoordinate exactBaseline = m_exactExpressionView.expressionLayout()->baseline(); - KDCoordinate approximateBaseline = m_approximateExpressionView.expressionLayout()->baseline(); + KDCoordinate exactBaseline = m_exactExpressionView.layoutRef().baseline(); + KDCoordinate approximateBaseline = m_approximateExpressionView.layoutRef().baseline(); KDCoordinate height = max(exactBaseline, approximateBaseline) + max(exactExpressionSize.height()-exactBaseline, approximateExpressionSize.height()-approximateBaseline); KDSize approximateSignSize = m_approximateSign.minimalSizeForOptimalDisplay(); return KDSize(exactExpressionSize.width()+approximateSignSize.width()+approximateExpressionSize.width()+2*k_digitHorizontalMargin, height); @@ -61,16 +61,16 @@ void ScrollableExactApproximateExpressionsView::ContentCell::setSelectedSubviewT setHighlighted(isHighlighted()); } -Poincare::ExpressionLayout * ScrollableExactApproximateExpressionsView::ContentCell::expressionLayout() const { +Poincare::LayoutRef ScrollableExactApproximateExpressionsView::ContentCell::layoutRef() const { if (m_selectedSubviewType == SubviewType::ExactOutput) { - return m_exactExpressionView.expressionLayout(); + return m_exactExpressionView.layoutRef(); } else { - return m_approximateExpressionView.expressionLayout(); + return m_approximateExpressionView.layoutRef(); } } int ScrollableExactApproximateExpressionsView::ContentCell::numberOfSubviews() const { - if (m_exactExpressionView.expressionLayout() != nullptr) { + if (m_exactExpressionView.layoutRef().isDefined()) { return 3; } return 1; @@ -88,8 +88,8 @@ void ScrollableExactApproximateExpressionsView::ContentCell::layoutSubviews() { m_approximateExpressionView.setFrame(KDRect(0, 0, approximateExpressionSize.width(), height)); return; } - KDCoordinate exactBaseline = m_exactExpressionView.expressionLayout()->baseline(); - KDCoordinate approximateBaseline = m_approximateExpressionView.expressionLayout()->baseline(); + KDCoordinate exactBaseline = m_exactExpressionView.layoutRef().baseline(); + KDCoordinate approximateBaseline = m_approximateExpressionView.layoutRef().baseline(); KDCoordinate baseline = max(exactBaseline, approximateBaseline); KDSize exactExpressionSize = m_exactExpressionView.minimalSizeForOptimalDisplay(); KDSize approximateSignSize = m_approximateSign.minimalSizeForOptimalDisplay(); @@ -103,9 +103,10 @@ ScrollableExactApproximateExpressionsView::ScrollableExactApproximateExpressions m_contentCell() { } -void ScrollableExactApproximateExpressionsView::setExpressions(ExpressionLayout ** expressionsLayout) { - m_contentCell.approximateExpressionView()->setExpressionLayout(expressionsLayout[0]); - m_contentCell.exactExpressionView()->setExpressionLayout(expressionsLayout[1]); + +void ScrollableExactApproximateExpressionsView::setExpressions(Poincare::LayoutRef * layoutRefs) { + m_contentCell.approximateExpressionView()->setLayoutRef(layoutRefs[0]); + m_contentCell.exactExpressionView()->setLayoutRef(layoutRefs[1]); m_contentCell.layoutSubviews(); } @@ -114,7 +115,7 @@ void ScrollableExactApproximateExpressionsView::setEqualMessage(I18n::Message eq } void ScrollableExactApproximateExpressionsView::didBecomeFirstResponder() { - if (m_contentCell.exactExpressionView()->expressionLayout() == nullptr) { + if (!m_contentCell.exactExpressionView()->layoutRef().isDefined()) { setSelectedSubviewType(SubviewType::ApproximativeOutput); } else { setSelectedSubviewType(SubviewType::ExactOutput); @@ -122,7 +123,7 @@ void ScrollableExactApproximateExpressionsView::didBecomeFirstResponder() { } bool ScrollableExactApproximateExpressionsView::handleEvent(Ion::Events::Event event) { - if (m_contentCell.exactExpressionView()->expressionLayout() == nullptr) { + if (!m_contentCell.exactExpressionView()->layoutRef().isDefined()) { return ScrollableView::handleEvent(event); } bool rightExpressionIsVisible = minimalSizeForOptimalDisplay().width() - m_contentCell.approximateExpressionView()->minimalSizeForOptimalDisplay().width() - m_manualScrollingOffset.x() < bounds().width() diff --git a/apps/shared/scrollable_exact_approximate_expressions_view.h b/apps/shared/scrollable_exact_approximate_expressions_view.h index 5a7081187..759d1c1e6 100644 --- a/apps/shared/scrollable_exact_approximate_expressions_view.h +++ b/apps/shared/scrollable_exact_approximate_expressions_view.h @@ -15,7 +15,7 @@ public: ::EvenOddCell * evenOddCell() { return &m_contentCell; } - void setExpressions(Poincare::ExpressionLayout ** expressionsLayout); + void setExpressions(Poincare::LayoutRef * layoutRefs); void setEqualMessage(I18n::Message equalSignMessage); SubviewType selectedSubviewType() { return m_contentCell.selectedSubviewType(); @@ -26,8 +26,8 @@ public: void didBecomeFirstResponder() override; bool handleEvent(Ion::Events::Event event) override; KDSize minimalSizeForOptimalDisplay() const override; - Poincare::ExpressionLayout * expressionLayout() const { - return m_contentCell.expressionLayout(); + Poincare::LayoutRef layoutRef() const { + return m_contentCell.layoutRef(); } private: class ContentCell : public ::EvenOddCell { @@ -52,7 +52,7 @@ private: void setSelectedSubviewType(SubviewType subviewType); void layoutSubviews() override; int numberOfSubviews() const override; - Poincare::ExpressionLayout * expressionLayout() const override; + Poincare::LayoutRef layoutRef() const override; private: View * subviewAtIndex(int index) override; constexpr static KDCoordinate k_digitHorizontalMargin = 10; diff --git a/apps/shared/sum_graph_controller.cpp b/apps/shared/sum_graph_controller.cpp index 49a31a458..fcbff39a8 100644 --- a/apps/shared/sum_graph_controller.cpp +++ b/apps/shared/sum_graph_controller.cpp @@ -202,7 +202,7 @@ bool SumGraphController::handleEnter() { SumGraphController::LegendView::LegendView(SumGraphController * controller, char sumSymbol) : m_sum(0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), - m_sumLayout(nullptr), + m_sumLayoutRef(nullptr), m_legend(KDText::FontSize::Small, I18n::Message::Default, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), m_editableZone(controller, m_draftText, m_draftText, TextField::maxBufferSize(), controller, false, KDText::FontSize::Small, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), m_sumSymbol(sumSymbol) @@ -210,13 +210,6 @@ SumGraphController::LegendView::LegendView(SumGraphController * controller, char m_draftText[0] = 0; } -SumGraphController::LegendView::~LegendView() { - if (m_sumLayout != nullptr) { - delete m_sumLayout; - m_sumLayout = nullptr; - } -} - void SumGraphController::LegendView::drawRect(KDContext * ctx, KDRect rect) const { ctx->fillRect(bounds(), Palette::GreyMiddle); } @@ -238,28 +231,26 @@ void SumGraphController::LegendView::setEditableZone(double d) { void SumGraphController::LegendView::setSumSymbol(Step step, double start, double end, double result, ExpressionLayout * functionLayout) { assert(step == Step::Result || functionLayout == nullptr); - if (m_sumLayout) { - delete m_sumLayout; - m_sumLayout = nullptr; - } const char sigma[] = {' ', m_sumSymbol}; if (step == Step::FirstParameter) { - m_sumLayout = LayoutEngine::createStringLayout(sigma, sizeof(sigma)); + m_sumLayoutRef = LayoutEngine::createStringLayout(sigma, sizeof(sigma)); } else if (step == Step::SecondParameter) { char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits)]; PrintFloat::convertFloatToText(start, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits), Constant::MediumNumberOfSignificantDigits, PrintFloat::Mode::Decimal); - m_sumLayout = new CondensedSumLayout( + m_sumLayoutRef = LayoutEngine::createStringLayout(sigma, sizeof(sigma));/* TODO new CondensedSumLayout( LayoutEngine::createStringLayout(sigma, sizeof(sigma)), LayoutEngine::createStringLayout(buffer, strlen(buffer), KDText::FontSize::Small), new EmptyLayout(EmptyLayout::Color::Yellow, false, KDText::FontSize::Small, false), - false); + false); */ } else { + m_sumLayoutRef = LayoutEngine::createStringLayout(sigma, sizeof(sigma)); +/* TODO char buffer[2+PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; PrintFloat::convertFloatToText(start, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, PrintFloat::Mode::Decimal); - ExpressionLayout * start = LayoutEngine::createStringLayout(buffer, strlen(buffer), KDText::FontSize::Small); + ExpressionLayout * start = LayoutEngine::createStringLayout(buffer, strlen(buffer), KDText::FontSize::Small); PrintFloat::convertFloatToText(end, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, PrintFloat::Mode::Decimal); - ExpressionLayout * end = LayoutEngine::createStringLayout(buffer, strlen(buffer), KDText::FontSize::Small); - m_sumLayout = new CondensedSumLayout( + ExpressionLayout * end = LayoutEngine::createStringLayout(buffer, strlen(buffer), KDText::FontSize::Small); + m_sumLayoutRef = new CondensedSumLayout( LayoutEngine::createStringLayout(sigma, sizeof(sigma)), start, end, @@ -269,10 +260,10 @@ void SumGraphController::LegendView::setSumSymbol(Step step, double start, doubl PrintFloat::convertFloatToText(result, buffer+2, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); childrenLayouts[2] = LayoutEngine::createStringLayout(buffer, strlen(buffer), KDText::FontSize::Small); childrenLayouts[1] = functionLayout; - childrenLayouts[0] = m_sumLayout; - m_sumLayout = new HorizontalLayout(childrenLayouts, 3, false); + childrenLayouts[0] = m_sumLayoutRef; + m_sumLayoutRef = new HorizontalLayout(childrenLayouts, 3, false);*/ } - m_sum.setExpressionLayout(m_sumLayout); + m_sum.setLayoutRef(m_sumLayoutRef); if (step == Step::Result) { m_sum.setAlignment(0.5f, 0.5f); } else { diff --git a/apps/shared/sum_graph_controller.h b/apps/shared/sum_graph_controller.h index 98a110957..e40a74bf8 100644 --- a/apps/shared/sum_graph_controller.h +++ b/apps/shared/sum_graph_controller.h @@ -49,7 +49,6 @@ private: class LegendView : public View { public: LegendView(SumGraphController * controller, char sumSymbol); - ~LegendView(); LegendView(const LegendView& other) = delete; LegendView(LegendView&& other) = delete; LegendView& operator=(const LegendView& other) = delete; @@ -71,7 +70,7 @@ private: void layoutSubviews() override; void layoutSubviews(Step step); ExpressionView m_sum; - Poincare::ExpressionLayout * m_sumLayout; + Poincare::LayoutRef m_sumLayoutRef; MessageTextView m_legend; TextField m_editableZone; char m_draftText[TextField::maxBufferSize()]; diff --git a/apps/variable_box_controller.cpp b/apps/variable_box_controller.cpp index 02a8ea27a..e17506dfc 100644 --- a/apps/variable_box_controller.cpp +++ b/apps/variable_box_controller.cpp @@ -148,16 +148,16 @@ void VariableBoxController::ContentViewController::willDisplayCellForIndex(Highl if (evaluation) { /* TODO: implement list contexts */ // TODO: handle matrix and scalar! - ExpressionLayout * layout = expressionLayoutForIndex(index); + LayoutRef layoutR = layoutRefForIndex(index); const Matrix * matrixEvaluation = static_cast(evaluation); - myCell->setExpressionLayout(layout); + myCell->setLayoutRef(layoutR); char buffer[2*PrintFloat::bufferSizeForFloatsWithPrecision(2)+1]; int numberOfChars = PrintFloat::convertFloatToText(matrixEvaluation->numberOfRows(), buffer, PrintFloat::bufferSizeForFloatsWithPrecision(2), 2, PrintFloat::Mode::Decimal); buffer[numberOfChars++] = 'x'; PrintFloat::convertFloatToText(matrixEvaluation->numberOfColumns(), buffer+numberOfChars, PrintFloat::bufferSizeForFloatsWithPrecision(2), 2, PrintFloat::Mode::Decimal); myCell->setSubtitle(buffer); } else { - myCell->setExpressionLayout(nullptr); + myCell->setLayoutRef(LayoutRef(nullptr)); myCell->setSubtitle(I18n::translate(I18n::Message::Empty)); } } @@ -166,9 +166,9 @@ KDCoordinate VariableBoxController::ContentViewController::rowHeight(int index) if (m_currentPage == Page::RootMenu || m_currentPage == Page::Scalar) { return Metric::ToolboxRowHeight; } - ExpressionLayout * expressionLayout = expressionLayoutForIndex(index); - if (expressionLayout) { - return expressionLayout->size().height()+k_leafMargin; + LayoutRef layoutR = layoutRefForIndex(index); + if (layoutR.isDefined()) { + return layoutR.layoutSize().height()+k_leafMargin; } return Metric::ToolboxRowHeight; } @@ -252,10 +252,10 @@ const Expression * VariableBoxController::ContentViewController::expressionForIn return nullptr; } -ExpressionLayout * VariableBoxController::ContentViewController::expressionLayoutForIndex(int index) { +LayoutRef VariableBoxController::ContentViewController::layoutRefForIndex(int index) { if (m_currentPage == Page::Matrix) { const Symbol symbol = Symbol::matrixSymbol('0'+(char)index); - return m_context->expressionLayoutForSymbol(&symbol); + return m_context->layoutRefForSymbol(&symbol); } #if LIST_VARIABLES if (m_currentPage == Page::List) { diff --git a/apps/variable_box_controller.h b/apps/variable_box_controller.h index 2ada661ea..22c36e1b1 100644 --- a/apps/variable_box_controller.h +++ b/apps/variable_box_controller.h @@ -53,7 +53,7 @@ private: void putLabelAtIndexInBuffer(int index, char * buffer); I18n::Message nodeLabelAtIndex(int index); const Poincare::Expression * expressionForIndex(int index); - Poincare::ExpressionLayout * expressionLayoutForIndex(int index); + Poincare::LayoutRef layoutRefForIndex(int index); Poincare::GlobalContext * m_context; Responder * m_sender; int m_firstSelectedRow; diff --git a/apps/variable_box_leaf_cell.cpp b/apps/variable_box_leaf_cell.cpp index 2fe428367..6123ca501 100644 --- a/apps/variable_box_leaf_cell.cpp +++ b/apps/variable_box_leaf_cell.cpp @@ -76,8 +76,8 @@ void VariableBoxLeafCell::setSubtitle(const char * text) { layoutSubviews(); } -void VariableBoxLeafCell::setExpressionLayout(ExpressionLayout * expressionLayout) { - m_expressionView.setExpressionLayout(expressionLayout); +void VariableBoxLeafCell::setLayoutRef(LayoutRef layoutRef) { + m_expressionView.setLayoutRef(layoutRef); } void VariableBoxLeafCell::drawRect(KDContext * ctx, KDRect rect) const { diff --git a/apps/variable_box_leaf_cell.h b/apps/variable_box_leaf_cell.h index dcff304ef..e021fab17 100644 --- a/apps/variable_box_leaf_cell.h +++ b/apps/variable_box_leaf_cell.h @@ -11,7 +11,7 @@ public: void reloadCell() override; void setLabel(const char * text); void setSubtitle(const char * text); - void setExpressionLayout(Poincare::ExpressionLayout * expressionLayout); + void setLayoutRef(Poincare::LayoutRef layoutRef); void drawRect(KDContext * ctx, KDRect rect) const override; const char * text() const override { return m_labelView.text(); diff --git a/escher/include/escher/clipboard.h b/escher/include/escher/clipboard.h index ad7135cc6..0a9c5e58d 100644 --- a/escher/include/escher/clipboard.h +++ b/escher/include/escher/clipboard.h @@ -8,7 +8,7 @@ class Clipboard { public: static Clipboard * sharedClipboard(); void store(const char * storedText); - void store(Poincare::ExpressionLayout * layout); + void store(Poincare::LayoutRef layoutR); const char * storedText(); void reset(); private: diff --git a/escher/include/escher/even_odd_expression_cell.h b/escher/include/escher/even_odd_expression_cell.h index dc6dd2e56..3d7380c8c 100644 --- a/escher/include/escher/even_odd_expression_cell.h +++ b/escher/include/escher/even_odd_expression_cell.h @@ -17,7 +17,7 @@ public: void setAlignment(float horizontalAlignment, float verticalAlignment); void setLeftMargin(KDCoordinate margin); void setRightMargin(KDCoordinate margin); - Poincare::ExpressionLayout * expressionLayout() const override { return m_expressionView.expressionLayout(); } + Poincare::LayoutRef layoutRef() const override { return m_expressionView.layoutRef(); } void drawRect(KDContext * ctx, KDRect rect) const override; protected: int numberOfSubviews() const override; diff --git a/escher/include/escher/expression_table_cell.h b/escher/include/escher/expression_table_cell.h index d0b9e01be..da87ab8ee 100644 --- a/escher/include/escher/expression_table_cell.h +++ b/escher/include/escher/expression_table_cell.h @@ -10,7 +10,7 @@ public: View * labelView() const override; void setHighlighted(bool highlight) override; void setExpressionLayout(Poincare::ExpressionLayout * expressionLayout); - Poincare::ExpressionLayout * expressionLayout() const override { return m_labelExpressionView.expressionLayout(); } + Poincare::LayoutRef layoutRef() const override { return m_labelExpressionView.layoutRef(); } private: ExpressionView m_labelExpressionView; }; diff --git a/escher/include/escher/highlight_cell.h b/escher/include/escher/highlight_cell.h index 7f87db90b..a9ad67969 100644 --- a/escher/include/escher/highlight_cell.h +++ b/escher/include/escher/highlight_cell.h @@ -4,6 +4,7 @@ #include #include #include +#include class HighlightCell : public View { public: @@ -17,8 +18,8 @@ public: virtual const char * text() const { return nullptr; } - virtual Poincare::ExpressionLayout * expressionLayout() const { - return nullptr; + virtual Poincare::LayoutRef layoutRef() const { + return Poincare::LayoutRef(nullptr); } protected: bool m_highlighted; diff --git a/escher/src/clipboard.cpp b/escher/src/clipboard.cpp index 5d18289d9..9445e668d 100644 --- a/escher/src/clipboard.cpp +++ b/escher/src/clipboard.cpp @@ -10,8 +10,8 @@ void Clipboard::store(const char * storedText) { strlcpy(m_textBuffer, storedText, TextField::maxBufferSize()); } -void Clipboard::store(Poincare::ExpressionLayout * layout) { - layout->writeTextInBuffer(m_textBuffer, TextField::maxBufferSize(), Poincare::Preferences::sharedPreferences()->numberOfSignificantDigits()); +void Clipboard::store(Poincare::LayoutRef layoutR) { + layoutR.writeTextInBuffer(m_textBuffer, TextField::maxBufferSize(), Poincare::Preferences::sharedPreferences()->numberOfSignificantDigits()); } const char * Clipboard::storedText() { diff --git a/escher/src/layout_field.cpp b/escher/src/layout_field.cpp index 031022da1..c3167b742 100644 --- a/escher/src/layout_field.cpp +++ b/escher/src/layout_field.cpp @@ -93,7 +93,8 @@ bool LayoutField::handleEventWithText(const char * text, bool indentation, bool } else if (resultLayoutRef.isHorizontal()) { /* If the layout is horizontal, pick the first open parenthesis. For now, * all horizontal layouts in MathToolbox have parentheses. */ - for (LayoutRef l : resultLayoutRef.directChildren()) { + for (int i = 0; i < resultLayoutRef.numberOfChildren(); i++) { + LayoutRef l = resultLayoutRef.childAtIndex(i); if (l.isLeftParenthesis()) { pointedLayoutRef = l; break; diff --git a/escher/src/selectable_table_view.cpp b/escher/src/selectable_table_view.cpp index 58178070e..62ecf73ac 100644 --- a/escher/src/selectable_table_view.cpp +++ b/escher/src/selectable_table_view.cpp @@ -128,9 +128,9 @@ bool SelectableTableView::handleEvent(Ion::Events::Event event) { Clipboard::sharedClipboard()->store(text); return true; } - Poincare::ExpressionLayout * layout = cell->expressionLayout(); - if (layout) { - Clipboard::sharedClipboard()->store(layout); + Poincare::LayoutRef layoutR = cell->layoutRef(); + if (layoutR.isDefined()) { + Clipboard::sharedClipboard()->store(layoutR); return true; } } diff --git a/poincare/include/poincare/absolute_value.h b/poincare/include/poincare/absolute_value.h index c5b75d48d..7ea0090cb 100644 --- a/poincare/include/poincare/absolute_value.h +++ b/poincare/include/poincare/absolute_value.h @@ -16,7 +16,7 @@ public: private: Expression * setSign(Sign s, Context & context, AngleUnit angleUnit) override; /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "abs"); } diff --git a/poincare/include/poincare/addition.h b/poincare/include/poincare/addition.h index aa00d6313..00b8ad601 100644 --- a/poincare/include/poincare/addition.h +++ b/poincare/include/poincare/addition.h @@ -32,7 +32,7 @@ public: private: /* Layout */ bool needParenthesisWithParent(const Expression * e) const override; - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { return LayoutEngine::createInfixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { diff --git a/poincare/include/poincare/arc_cosine.h b/poincare/include/poincare/arc_cosine.h index 71ae77674..e3731a648 100644 --- a/poincare/include/poincare/arc_cosine.h +++ b/poincare/include/poincare/arc_cosine.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -14,8 +15,9 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + //return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/arc_sine.h b/poincare/include/poincare/arc_sine.h index 3aa871d05..0ec4295da 100644 --- a/poincare/include/poincare/arc_sine.h +++ b/poincare/include/poincare/arc_sine.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -14,8 +15,9 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + //return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/arc_tangent.h b/poincare/include/poincare/arc_tangent.h index e915ab332..dd0c197a4 100644 --- a/poincare/include/poincare/arc_tangent.h +++ b/poincare/include/poincare/arc_tangent.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -14,8 +15,9 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + //return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/binomial_coefficient.h b/poincare/include/poincare/binomial_coefficient.h index b5085bb67..35b58a631 100644 --- a/poincare/include/poincare/binomial_coefficient.h +++ b/poincare/include/poincare/binomial_coefficient.h @@ -15,7 +15,7 @@ public: private: constexpr static int k_maxNValue = 300; /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "binomial"); } diff --git a/poincare/include/poincare/ceiling.h b/poincare/include/poincare/ceiling.h index e55e96f8c..3080c7ed9 100644 --- a/poincare/include/poincare/ceiling.h +++ b/poincare/include/poincare/ceiling.h @@ -14,7 +14,7 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); } diff --git a/poincare/include/poincare/char_layout_node.h b/poincare/include/poincare/char_layout_node.h index c45796efb..37e2aa50a 100644 --- a/poincare/include/poincare/char_layout_node.h +++ b/poincare/include/poincare/char_layout_node.h @@ -2,7 +2,6 @@ #define POINCARE_CHAR_LAYOUT_NODE_H #include -#include #include #include @@ -19,9 +18,7 @@ public: void setFontSize(KDText::FontSize fontSize) { m_fontSize = fontSize; } // LayoutNode - int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { - return LayoutEngine::writeOneCharInBuffer(buffer, bufferSize, m_char); - } + int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override; void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override; void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override; diff --git a/poincare/include/poincare/complex.h b/poincare/include/poincare/complex.h index 47545eaa3..44b47aaf2 100644 --- a/poincare/include/poincare/complex.h +++ b/poincare/include/poincare/complex.h @@ -43,7 +43,7 @@ public: private: Complex(T a, T b); /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat) const override; /* Simplification */ static Expression * CreateDecimal(T f); Expression * shallowReduce(Context & context, AngleUnit angleUnit) override; @@ -54,8 +54,8 @@ private: /* convertComplexToText and convertFloatToTextPrivate return the string length * of the buffer (does not count the 0 last char)*/ int convertComplexToText(char * buffer, int bufferSize, int numberOfSignificantDigits, PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat, char multiplicationSign) const; - ExpressionLayout * createPolarLayout(PrintFloat::Mode floatDisplayMode) const; - ExpressionLayout * createCartesianLayout(PrintFloat::Mode floatDisplayMode) const; + //ExpressionLayout * createPolarLayout(PrintFloat::Mode floatDisplayMode) const; + //ExpressionLayout * createCartesianLayout(PrintFloat::Mode floatDisplayMode) const; T m_a; T m_b; }; diff --git a/poincare/include/poincare/complex_argument.h b/poincare/include/poincare/complex_argument.h index 14d283528..02352b066 100644 --- a/poincare/include/poincare/complex_argument.h +++ b/poincare/include/poincare/complex_argument.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -14,8 +15,9 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + //return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/confidence_interval.h b/poincare/include/poincare/confidence_interval.h index f4e815703..4acaf340a 100644 --- a/poincare/include/poincare/confidence_interval.h +++ b/poincare/include/poincare/confidence_interval.h @@ -3,6 +3,7 @@ #include #include +#include //TODO remove namespace Poincare { @@ -14,8 +15,9 @@ public: int polynomialDegree(char symbolName) const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + //return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/conjugate.h b/poincare/include/poincare/conjugate.h index e43767171..db77c2994 100644 --- a/poincare/include/poincare/conjugate.h +++ b/poincare/include/poincare/conjugate.h @@ -14,7 +14,7 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "conj"); } diff --git a/poincare/include/poincare/cosine.h b/poincare/include/poincare/cosine.h index b19ec7bad..8f059c4d0 100644 --- a/poincare/include/poincare/cosine.h +++ b/poincare/include/poincare/cosine.h @@ -6,6 +6,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -19,8 +20,9 @@ public: template static Complex computeOnComplex(const Complex c, AngleUnit angleUnit = AngleUnit::Radian); private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + //return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/decimal.h b/poincare/include/poincare/decimal.h index 52f25d4ec..65d929039 100644 --- a/poincare/include/poincare/decimal.h +++ b/poincare/include/poincare/decimal.h @@ -31,7 +31,7 @@ private: int simplificationOrderSameType(const Expression * e, bool canBeInterrupted) const override; /* Layout */ bool needParenthesisWithParent(const Expression * e) const override; - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; /* Simplification */ Expression * shallowReduce(Context& context, AngleUnit angleUnit) override; Expression * shallowBeautify(Context& context, AngleUnit angleUnit) override; diff --git a/poincare/include/poincare/derivative.h b/poincare/include/poincare/derivative.h index 85e10c3a4..9cc0d0f29 100644 --- a/poincare/include/poincare/derivative.h +++ b/poincare/include/poincare/derivative.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -15,8 +16,9 @@ public: int polynomialDegree(char symbolName) const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + //return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/determinant.h b/poincare/include/poincare/determinant.h index 7db860bc1..9cff27f3b 100644 --- a/poincare/include/poincare/determinant.h +++ b/poincare/include/poincare/determinant.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -14,8 +15,9 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + //return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/division.h b/poincare/include/poincare/division.h index 0337ec310..460787667 100644 --- a/poincare/include/poincare/division.h +++ b/poincare/include/poincare/division.h @@ -20,7 +20,7 @@ public: private: /* Layout */ bool needParenthesisWithParent(const Expression * e) const override; - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "/"); } diff --git a/poincare/include/poincare/division_quotient.h b/poincare/include/poincare/division_quotient.h index 318d09c0e..6747d284a 100644 --- a/poincare/include/poincare/division_quotient.h +++ b/poincare/include/poincare/division_quotient.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -14,8 +15,9 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + //return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/division_remainder.h b/poincare/include/poincare/division_remainder.h index 05a79ea73..dce48e7c2 100644 --- a/poincare/include/poincare/division_remainder.h +++ b/poincare/include/poincare/division_remainder.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -14,8 +15,9 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + // return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/empty_expression.h b/poincare/include/poincare/empty_expression.h index 09d1cbb9d..495c13682 100644 --- a/poincare/include/poincare/empty_expression.h +++ b/poincare/include/poincare/empty_expression.h @@ -17,7 +17,7 @@ public: int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; /* Evaluation */ Expression * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate(context, angleUnit); } Expression * privateApproximate(DoublePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate(context, angleUnit); } diff --git a/poincare/include/poincare/equal.h b/poincare/include/poincare/equal.h index 14d775f23..7ff8d3e39 100644 --- a/poincare/include/poincare/equal.h +++ b/poincare/include/poincare/equal.h @@ -19,7 +19,7 @@ private: /* Simplification */ Expression * shallowReduce(Context& context, AngleUnit angleUnit) override; /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "="); } diff --git a/poincare/include/poincare/expression.h b/poincare/include/poincare/expression.h index 90cc058fa..3f100b2b5 100644 --- a/poincare/include/poincare/expression.h +++ b/poincare/include/poincare/expression.h @@ -1,7 +1,7 @@ #ifndef POINCARE_EXPRESSION_H #define POINCARE_EXPRESSION_H -#include +#include #include extern "C" { #include @@ -249,7 +249,7 @@ public: bool isEqualToItsApproximationLayout(Expression * approximation, int bufferSize, int numberOfSignificantDigits, Context & context); /* Layout Engine */ - ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode = PrintFloat::Mode::Default, ComplexFormat complexFormat = ComplexFormat::Default) const; // Returned object must be deleted + LayoutRef createLayout(PrintFloat::Mode floatDisplayMode = PrintFloat::Mode::Default, ComplexFormat complexFormat = ComplexFormat::Default) const; virtual int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const = 0; /* Simplification */ @@ -315,7 +315,7 @@ private: //TODO: What should be the implementation for complex? virtual int simplificationOrderSameType(const Expression * e, bool canBeInterrupted) const { return 0; } /* Layout Engine */ - virtual ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const = 0; + virtual LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const = 0; /* Simplification */ Expression * deepBeautify(Context & context, AngleUnit angleUnit); Expression * deepReduce(Context & context, AngleUnit angleUnit); diff --git a/poincare/include/poincare/factor.h b/poincare/include/poincare/factor.h index 4ded7f021..8de7892b9 100644 --- a/poincare/include/poincare/factor.h +++ b/poincare/include/poincare/factor.h @@ -7,6 +7,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -17,8 +18,9 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + //return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/factorial.h b/poincare/include/poincare/factorial.h index 35c04b3fe..2f7842a69 100644 --- a/poincare/include/poincare/factorial.h +++ b/poincare/include/poincare/factorial.h @@ -15,7 +15,7 @@ private: constexpr static int k_maxOperandValue = 100; /* Layout */ bool needParenthesisWithParent(const Expression * e) const override; - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override; /* Simplication */ Expression * shallowReduce(Context& context, AngleUnit angleUnit) override; diff --git a/poincare/include/poincare/floor.h b/poincare/include/poincare/floor.h index 8a4196f32..c64bd8612 100644 --- a/poincare/include/poincare/floor.h +++ b/poincare/include/poincare/floor.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -14,9 +15,9 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { - return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); + return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); } const char * name() const { return "floor"; } /* Simplification */ diff --git a/poincare/include/poincare/frac_part.h b/poincare/include/poincare/frac_part.h index 2fb4f6d88..a55d70db6 100644 --- a/poincare/include/poincare/frac_part.h +++ b/poincare/include/poincare/frac_part.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -14,8 +15,9 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + //return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/global_context.h b/poincare/include/poincare/global_context.h index d6c4d480a..e25775c1c 100644 --- a/poincare/include/poincare/global_context.h +++ b/poincare/include/poincare/global_context.h @@ -22,7 +22,7 @@ public: /* The expression recorded in global context is already a expression. * Otherwise, we would need the context and the angle unit to evaluate it */ const Expression * expressionForSymbol(const Symbol * symbol) override; - ExpressionLayout * expressionLayoutForSymbol(const Symbol * symbol); + LayoutRef layoutRefForSymbol(const Symbol * symbol); void setExpressionForSymbolName(const Expression * expression, const Symbol * symbol, Context & context) override; static constexpr uint16_t k_maxNumberOfScalarExpressions = 26; static constexpr uint16_t k_maxNumberOfListExpressions = 10; @@ -33,7 +33,7 @@ private: Complex * m_expressions[k_maxNumberOfScalarExpressions]; Matrix * m_matrixExpressions[k_maxNumberOfMatrixExpressions]; /* Matrix layout memoization */ - ExpressionLayout * m_matrixLayout[k_maxNumberOfMatrixExpressions]; + LayoutRef m_matrixLayouts[k_maxNumberOfMatrixExpressions]; Complex m_pi; Complex m_e; Complex m_i; diff --git a/poincare/include/poincare/great_common_divisor.h b/poincare/include/poincare/great_common_divisor.h index 83d8f5d9e..0540535b4 100644 --- a/poincare/include/poincare/great_common_divisor.h +++ b/poincare/include/poincare/great_common_divisor.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -14,8 +15,9 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + // return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/hyperbolic_arc_cosine.h b/poincare/include/poincare/hyperbolic_arc_cosine.h index 8bc94757e..4ae9ec6e2 100644 --- a/poincare/include/poincare/hyperbolic_arc_cosine.h +++ b/poincare/include/poincare/hyperbolic_arc_cosine.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -14,8 +15,9 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + // return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/hyperbolic_arc_sine.h b/poincare/include/poincare/hyperbolic_arc_sine.h index 41f7ac7bc..2596b6b1d 100644 --- a/poincare/include/poincare/hyperbolic_arc_sine.h +++ b/poincare/include/poincare/hyperbolic_arc_sine.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -14,8 +15,9 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + // return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/hyperbolic_arc_tangent.h b/poincare/include/poincare/hyperbolic_arc_tangent.h index 1beaa2947..8cd59453f 100644 --- a/poincare/include/poincare/hyperbolic_arc_tangent.h +++ b/poincare/include/poincare/hyperbolic_arc_tangent.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -14,8 +15,9 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + // return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/hyperbolic_cosine.h b/poincare/include/poincare/hyperbolic_cosine.h index a3325b86f..aa21b03b8 100644 --- a/poincare/include/poincare/hyperbolic_cosine.h +++ b/poincare/include/poincare/hyperbolic_cosine.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -15,8 +16,9 @@ public: template static Complex computeOnComplex(const Complex c, AngleUnit angleUnit); private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + // return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/hyperbolic_sine.h b/poincare/include/poincare/hyperbolic_sine.h index 83b4c5f2f..f85dedca0 100644 --- a/poincare/include/poincare/hyperbolic_sine.h +++ b/poincare/include/poincare/hyperbolic_sine.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -15,11 +16,12 @@ public: template static Complex computeOnComplex(const Complex c, AngleUnit angleUnit); private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + //return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { - return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); + return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); } const char * name() const { return "sinh"; } /* Simplification */ diff --git a/poincare/include/poincare/hyperbolic_tangent.h b/poincare/include/poincare/hyperbolic_tangent.h index 4ec0dabed..e18ae5700 100644 --- a/poincare/include/poincare/hyperbolic_tangent.h +++ b/poincare/include/poincare/hyperbolic_tangent.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -15,8 +16,9 @@ public: template static Complex computeOnComplex(const Complex c, AngleUnit angleUnit); private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + //return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/imaginary_part.h b/poincare/include/poincare/imaginary_part.h index 2c5757b7b..064c395a4 100644 --- a/poincare/include/poincare/imaginary_part.h +++ b/poincare/include/poincare/imaginary_part.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -14,8 +15,9 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + // return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/integer.h b/poincare/include/poincare/integer.h index af28e53c1..565d6267c 100644 --- a/poincare/include/poincare/integer.h +++ b/poincare/include/poincare/integer.h @@ -7,7 +7,9 @@ namespace Poincare { class ExpressionLayout; - +/*class LayoutNode; +class LayoutReference; +*/ /* All algorithm should be improved with: * Modern Computer Arithmetic, Richard P. Brent and Paul Zimmermann */ @@ -52,7 +54,7 @@ public: // Layout int writeTextInBuffer(char * buffer, int bufferSize) const; - ExpressionLayout * createLayout() const; + //LayoutReference createLayout() const; // Approximation template T approximate() const; diff --git a/poincare/include/poincare/integral.h b/poincare/include/poincare/integral.h index 2c3ab3f98..0c24d7a05 100644 --- a/poincare/include/poincare/integral.h +++ b/poincare/include/poincare/integral.h @@ -16,7 +16,7 @@ public: int polynomialDegree(char symbolName) const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "int"); } diff --git a/poincare/include/poincare/layout_engine.h b/poincare/include/poincare/layout_engine.h index 1256621cc..8481c13f6 100644 --- a/poincare/include/poincare/layout_engine.h +++ b/poincare/include/poincare/layout_engine.h @@ -2,20 +2,20 @@ #define POINCARE_LAYOUT_ENGINE_H #include -#include +#include namespace Poincare { class LayoutEngine { public: - /* Expression to ExpressionLayout */ - static ExpressionLayout * createInfixLayout(const Expression * expression, PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat, const char * operatorName); - static ExpressionLayout * createPrefixLayout(const Expression * expression, PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat, const char * operatorName); + /* Expression to LayoutRef */ + static LayoutRef createInfixLayout(const Expression * expression, PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat, const char * operatorName); + static LayoutRef createPrefixLayout(const Expression * expression, PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat, const char * operatorName); /* Create special layouts */ - static ExpressionLayout * createParenthesedLayout(ExpressionLayout * layout, bool cloneLayout); - static ExpressionLayout * createStringLayout(const char * buffer, int bufferSize, KDText::FontSize fontSize = KDText::FontSize::Large); + static LayoutRef createParenthesedLayout(LayoutRef layout, bool cloneLayout); + static LayoutRef createStringLayout(const char * buffer, int bufferSize, KDText::FontSize fontSize = KDText::FontSize::Large); static ExpressionLayout * createLogLayout(ExpressionLayout * argument, ExpressionLayout * index); /* Expression to Text */ diff --git a/poincare/include/poincare/layout_node.h b/poincare/include/poincare/layout_node.h index 13ad7061c..f93a4338c 100644 --- a/poincare/include/poincare/layout_node.h +++ b/poincare/include/poincare/layout_node.h @@ -25,6 +25,7 @@ public: virtual bool hasText() const { return false; } //TODO virtual char XNTChar() const { return 'x'; } virtual bool isHorizontal() const { return false; } + virtual bool isLeftParenthesis() const { return false; } // Rendering void draw(KDContext * ctx, KDPoint p, KDColor expressionColor = KDColorBlack, KDColor backgroundColor = KDColorWhite); diff --git a/poincare/include/poincare/layout_reference.h b/poincare/include/poincare/layout_reference.h index 90070ce42..5737ce1d3 100644 --- a/poincare/include/poincare/layout_reference.h +++ b/poincare/include/poincare/layout_reference.h @@ -44,6 +44,7 @@ public: } bool isHorizontal() const { return this->typedNode()->isHorizontal(); } + bool isLeftParenthesis() const { return this->typedNode()->isLeftParenthesis(); } bool hasText() { return this->typedNode()->hasText(); } char XNTChar() const { return this->typedNode()->XNTChar(); } KDSize layoutSize() { return this->typedNode()->layoutSize(); } diff --git a/poincare/include/poincare/least_common_multiple.h b/poincare/include/poincare/least_common_multiple.h index eddf83d93..8da3cef98 100644 --- a/poincare/include/poincare/least_common_multiple.h +++ b/poincare/include/poincare/least_common_multiple.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -14,8 +15,9 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + // return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/logarithm.h b/poincare/include/poincare/logarithm.h index ded4cce79..aa4221d3d 100644 --- a/poincare/include/poincare/logarithm.h +++ b/poincare/include/poincare/logarithm.h @@ -15,7 +15,7 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "log"); } diff --git a/poincare/include/poincare/matrix.h b/poincare/include/poincare/matrix.h index 4115b6b06..b7962e77b 100644 --- a/poincare/include/poincare/matrix.h +++ b/poincare/include/poincare/matrix.h @@ -41,7 +41,7 @@ private: /* rowCanonize turns a matrix in its reduced row echelon form. */ void rowCanonize(Context & context, AngleUnit angleUnit, Multiplication * m = nullptr); /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; /* Evaluation */ Expression * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate(context, angleUnit); } Expression * privateApproximate(DoublePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate(context, angleUnit); } diff --git a/poincare/include/poincare/matrix_dimension.h b/poincare/include/poincare/matrix_dimension.h index f6b608b4c..71655e449 100644 --- a/poincare/include/poincare/matrix_dimension.h +++ b/poincare/include/poincare/matrix_dimension.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -14,8 +15,9 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO +// return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/matrix_inverse.h b/poincare/include/poincare/matrix_inverse.h index 0acae6ef6..675b56875 100644 --- a/poincare/include/poincare/matrix_inverse.h +++ b/poincare/include/poincare/matrix_inverse.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -14,8 +15,9 @@ public: Expression * clone() const override; private: /* Evaluation */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO +// return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/matrix_trace.h b/poincare/include/poincare/matrix_trace.h index 14b140ad6..710d3ce6a 100644 --- a/poincare/include/poincare/matrix_trace.h +++ b/poincare/include/poincare/matrix_trace.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -14,8 +15,9 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + // return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/matrix_transpose.h b/poincare/include/poincare/matrix_transpose.h index 42ad6455a..c0b3e09db 100644 --- a/poincare/include/poincare/matrix_transpose.h +++ b/poincare/include/poincare/matrix_transpose.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -14,8 +15,9 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + //return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/multiplication.h b/poincare/include/poincare/multiplication.h index 18ec2a876..d2edd226a 100644 --- a/poincare/include/poincare/multiplication.h +++ b/poincare/include/poincare/multiplication.h @@ -35,7 +35,7 @@ private: Expression * setSign(Sign s, Context & context, AngleUnit angleUnit) override; /* Layout */ bool needParenthesisWithParent(const Expression * e) const override; - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override; /* Simplification */ Expression * shallowReduce(Context& context, AngleUnit angleUnit) override; diff --git a/poincare/include/poincare/naperian_logarithm.h b/poincare/include/poincare/naperian_logarithm.h index 89a5173d1..244041555 100644 --- a/poincare/include/poincare/naperian_logarithm.h +++ b/poincare/include/poincare/naperian_logarithm.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -14,8 +15,9 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + // return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/nth_root.h b/poincare/include/poincare/nth_root.h index dfd8f5392..3a5c35c05 100644 --- a/poincare/include/poincare/nth_root.h +++ b/poincare/include/poincare/nth_root.h @@ -14,7 +14,7 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "root"); } diff --git a/poincare/include/poincare/opposite.h b/poincare/include/poincare/opposite.h index 809aa4c43..a83dc3df4 100644 --- a/poincare/include/poincare/opposite.h +++ b/poincare/include/poincare/opposite.h @@ -18,7 +18,7 @@ public: private: /* Layout */ bool needParenthesisWithParent(const Expression * e) const override; - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override; /* Simplification */ Expression * shallowReduce(Context& context, AngleUnit angleUnit) override; diff --git a/poincare/include/poincare/parenthesis.h b/poincare/include/poincare/parenthesis.h index e3589c1d1..ee9965a67 100644 --- a/poincare/include/poincare/parenthesis.h +++ b/poincare/include/poincare/parenthesis.h @@ -15,7 +15,7 @@ public: int polynomialDegree(char symbolName) const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, ""); } diff --git a/poincare/include/poincare/permute_coefficient.h b/poincare/include/poincare/permute_coefficient.h index 63ad49a78..9ed509d0e 100644 --- a/poincare/include/poincare/permute_coefficient.h +++ b/poincare/include/poincare/permute_coefficient.h @@ -4,6 +4,7 @@ #include #include #include +#include //TODO remove namespace Poincare { @@ -15,8 +16,9 @@ public: private: constexpr static int k_maxNValue = 100; /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO +// return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/power.h b/poincare/include/poincare/power.h index a87b668dd..a074c0d9b 100644 --- a/poincare/include/poincare/power.h +++ b/poincare/include/poincare/power.h @@ -5,6 +5,7 @@ #include #include #include +#include namespace Poincare { @@ -30,7 +31,7 @@ private: /* Property */ Expression * setSign(Sign s, Context & context, AngleUnit angleUnit) override; /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; bool needParenthesisWithParent(const Expression * e) const override; int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/prediction_interval.h b/poincare/include/poincare/prediction_interval.h index bccc77f8c..2f3fc7adb 100644 --- a/poincare/include/poincare/prediction_interval.h +++ b/poincare/include/poincare/prediction_interval.h @@ -3,6 +3,8 @@ #include #include +#include +#include //TODO remove namespace Poincare { @@ -14,8 +16,9 @@ public: int polynomialDegree(char symbolName) const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + // return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/randint.h b/poincare/include/poincare/randint.h index 39d99e031..8eb650f8c 100644 --- a/poincare/include/poincare/randint.h +++ b/poincare/include/poincare/randint.h @@ -3,6 +3,8 @@ #include #include +#include +#include //TODO remove namespace Poincare { @@ -13,8 +15,9 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO +// return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/random.h b/poincare/include/poincare/random.h index 537b89106..1b61d1e0c 100644 --- a/poincare/include/poincare/random.h +++ b/poincare/include/poincare/random.h @@ -4,6 +4,7 @@ #include #include #include +#include namespace Poincare { @@ -17,8 +18,9 @@ public: private: Expression * setSign(Sign s, Context & context, AngleUnit angleUnit) override; /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + /*return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());*/ } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/rational.h b/poincare/include/poincare/rational.h index 075a43060..13b8241b6 100644 --- a/poincare/include/poincare/rational.h +++ b/poincare/include/poincare/rational.h @@ -43,7 +43,7 @@ public: static int NaturalOrder(const Rational & i, const Rational & j); private: bool needParenthesisWithParent(const Expression * e) const override; - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override; Expression * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate(context, angleUnit); } Expression * privateApproximate(DoublePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate(context, angleUnit); } diff --git a/poincare/include/poincare/real_part.h b/poincare/include/poincare/real_part.h index 16b6fdfd4..d4fe41f81 100644 --- a/poincare/include/poincare/real_part.h +++ b/poincare/include/poincare/real_part.h @@ -4,6 +4,7 @@ #include #include #include +#include namespace Poincare { @@ -14,8 +15,9 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + //return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/round.h b/poincare/include/poincare/round.h index fa0bd81da..cb26f2c48 100644 --- a/poincare/include/poincare/round.h +++ b/poincare/include/poincare/round.h @@ -4,6 +4,7 @@ #include #include #include +#include namespace Poincare { @@ -14,8 +15,9 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + //return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/sequence.h b/poincare/include/poincare/sequence.h index 6815ce4f4..88f1a0064 100644 --- a/poincare/include/poincare/sequence.h +++ b/poincare/include/poincare/sequence.h @@ -10,7 +10,7 @@ namespace Poincare { class Sequence : public StaticHierarchy<3> { using StaticHierarchy<3>::StaticHierarchy; private: - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); } diff --git a/poincare/include/poincare/simplification_root.h b/poincare/include/poincare/simplification_root.h index f692eda8c..049224c6c 100644 --- a/poincare/include/poincare/simplification_root.h +++ b/poincare/include/poincare/simplification_root.h @@ -20,8 +20,8 @@ public: Expression * clone() const override { return nullptr; } int polynomialDegree(char symbolName) const override { return -1; } Type type() const override { return Expression::Type::SimplificationRoot; } - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return nullptr; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return LayoutRef(nullptr); //TODO } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return 0; } Expression * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { diff --git a/poincare/include/poincare/sine.h b/poincare/include/poincare/sine.h index 0c4fa57e3..da9e2debe 100644 --- a/poincare/include/poincare/sine.h +++ b/poincare/include/poincare/sine.h @@ -5,6 +5,7 @@ #include #include #include +#include namespace Poincare { @@ -18,8 +19,9 @@ public: template static Complex computeOnComplex(const Complex c, AngleUnit angleUnit = AngleUnit::Radian); private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO +// return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/square_root.h b/poincare/include/poincare/square_root.h index 52b9f33f4..065b1541f 100644 --- a/poincare/include/poincare/square_root.h +++ b/poincare/include/poincare/square_root.h @@ -14,7 +14,7 @@ public: Expression * clone() const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override; /* Simplification */ Expression * shallowReduce(Context& context, AngleUnit angleUnit) override; diff --git a/poincare/include/poincare/store.h b/poincare/include/poincare/store.h index f47b8e342..1e0d915e9 100644 --- a/poincare/include/poincare/store.h +++ b/poincare/include/poincare/store.h @@ -18,7 +18,7 @@ private: /* Simplification */ Expression * shallowReduce(Context& context, AngleUnit angleUnit) override; /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override; /* Evalutation */ Expression * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate(context, angleUnit); } diff --git a/poincare/include/poincare/subtraction.h b/poincare/include/poincare/subtraction.h index 6d611b6bb..223962455 100644 --- a/poincare/include/poincare/subtraction.h +++ b/poincare/include/poincare/subtraction.h @@ -4,6 +4,7 @@ #include #include #include +#include namespace Poincare { @@ -17,8 +18,9 @@ public: private: /* Layout */ bool needParenthesisWithParent(const Expression * e) const override; - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createInfixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + return CharLayoutRef('a'); //TODO + // return LayoutEngine::createInfixLayout(this, floatDisplayMode, complexFormat, name()); } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/symbol.h b/poincare/include/poincare/symbol.h index edd1d1cd1..2cf4259f4 100644 --- a/poincare/include/poincare/symbol.h +++ b/poincare/include/poincare/symbol.h @@ -67,7 +67,7 @@ private: /* Comparison */ int simplificationOrderSameType(const Expression * e, bool canBeInterrupted) const override; /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override; /* Evaluation */ Expression * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate(context, angleUnit); } diff --git a/poincare/include/poincare/tangent.h b/poincare/include/poincare/tangent.h index 640a2fad3..6606029b7 100644 --- a/poincare/include/poincare/tangent.h +++ b/poincare/include/poincare/tangent.h @@ -4,7 +4,7 @@ #include #include #include - +#include namespace Poincare { @@ -16,8 +16,9 @@ public: float characteristicXRange(Context & context, AngleUnit angleUnit = AngleUnit::Default) const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { - return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override { + //return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name()); + return CharLayoutRef('a'); //TODO } int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name()); diff --git a/poincare/include/poincare/tree_reference.h b/poincare/include/poincare/tree_reference.h index 78b37c5db..0ffead61e 100644 --- a/poincare/include/poincare/tree_reference.h +++ b/poincare/include/poincare/tree_reference.h @@ -65,6 +65,7 @@ public: int nodeRetainCount() const { return node()->retainCount(); } void incrementNumberOfChildren(int increment = 1) { return node()->incrementNumberOfChildren(increment); } void decrementNumberOfChildren(int decrement = 1) { return node()->decrementNumberOfChildren(decrement); } + int numberOfDescendants(bool includeSelf) const { return node()->numberOfDescendants(includeSelf);} // Serialization bool needsParenthesisWithParent(TreeReference parentRef) { return node()->needsParenthesisWithParent(parentRef.node()); } diff --git a/poincare/include/poincare/undefined.h b/poincare/include/poincare/undefined.h index a0b1a0b24..857cbbb2c 100644 --- a/poincare/include/poincare/undefined.h +++ b/poincare/include/poincare/undefined.h @@ -14,7 +14,7 @@ public: int polynomialDegree(char symbolName) const override; private: /* Layout */ - ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; + LayoutRef privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override; /* Evaluation */ Expression * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate(context, angleUnit); } Expression * privateApproximate(DoublePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate(context, angleUnit); } diff --git a/poincare/src/absolute_value.cpp b/poincare/src/absolute_value.cpp index 5751149b8..773eac040 100644 --- a/poincare/src/absolute_value.cpp +++ b/poincare/src/absolute_value.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "layout/absolute_value_layout.h" +#include extern "C" { #include @@ -24,10 +24,10 @@ Expression * AbsoluteValue::setSign(Sign s, Context & context, AngleUnit angleUn return this; } -ExpressionLayout * AbsoluteValue::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { +LayoutRef AbsoluteValue::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { assert(floatDisplayMode != PrintFloat::Mode::Default); assert(complexFormat != ComplexFormat::Default); - return new AbsoluteValueLayout(operand(0)->createLayout(floatDisplayMode, complexFormat), false); + return CharLayoutRef('a'); //TODO } Expression * AbsoluteValue::shallowReduce(Context& context, AngleUnit angleUnit) { diff --git a/poincare/src/binomial_coefficient.cpp b/poincare/src/binomial_coefficient.cpp index 51c0c62ba..777cf4f94 100644 --- a/poincare/src/binomial_coefficient.cpp +++ b/poincare/src/binomial_coefficient.cpp @@ -3,6 +3,7 @@ #include #include #include "layout/binomial_coefficient_layout.h" +#include extern "C" { #include @@ -72,14 +73,15 @@ Expression * BinomialCoefficient::shallowReduce(Context& context, AngleUnit angl return replaceWith(new Rational(result), true); } -ExpressionLayout * BinomialCoefficient::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { - assert(floatDisplayMode != PrintFloat::Mode::Default); +LayoutRef BinomialCoefficient::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { + return CharLayoutRef('a'); //TODO + /*assert(floatDisplayMode != PrintFloat::Mode::Default); assert(complexFormat != ComplexFormat::Default); return new BinomialCoefficientLayout( operand(0)->createLayout(floatDisplayMode, complexFormat), operand(1)->createLayout(floatDisplayMode, complexFormat), false); -} +*/} template Expression * BinomialCoefficient::templatedApproximate(Context& context, AngleUnit angleUnit) const { diff --git a/poincare/src/ceiling.cpp b/poincare/src/ceiling.cpp index 4d8af70bb..a3feb6b03 100644 --- a/poincare/src/ceiling.cpp +++ b/poincare/src/ceiling.cpp @@ -8,6 +8,7 @@ extern "C" { #include } +#include namespace Poincare { @@ -59,10 +60,11 @@ Complex Ceiling::computeOnComplex(const Complex c, AngleUnit angleUnit) { return Complex::Float(std::ceil(c.a())); } -ExpressionLayout * Ceiling::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { - assert(floatDisplayMode != PrintFloat::Mode::Default); +LayoutRef Ceiling::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { + return CharLayoutRef('a'); //TODO + /*assert(floatDisplayMode != PrintFloat::Mode::Default); assert(complexFormat != ComplexFormat::Default); return new CeilingLayout(m_operands[0]->createLayout(floatDisplayMode, complexFormat), false); -} +*/} } diff --git a/poincare/src/char_layout_node.cpp b/poincare/src/char_layout_node.cpp index 5bcaec05d..5723207f8 100644 --- a/poincare/src/char_layout_node.cpp +++ b/poincare/src/char_layout_node.cpp @@ -1,7 +1,13 @@ #include +#include namespace Poincare { +// LayoutNode +int CharLayoutNode::writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits) const { + return LayoutEngine::writeOneCharInBuffer(buffer, bufferSize, m_char); +} + void CharLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) { if (cursor->position() == LayoutCursor::Position::Right) { cursor->setPosition(LayoutCursor::Position::Left); diff --git a/poincare/src/complex.cpp b/poincare/src/complex.cpp index 7ca360614..0f02dc3d6 100644 --- a/poincare/src/complex.cpp +++ b/poincare/src/complex.cpp @@ -20,6 +20,8 @@ extern "C" { #include } +#include + namespace Poincare { template @@ -213,13 +215,14 @@ Complex::Complex(T a, T b) : } template -ExpressionLayout * Complex::privateCreateLayout(PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat) const { - assert(floatDisplayMode != PrintFloat::Mode::Default); +LayoutRef Complex::privateCreateLayout(PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat) const { + return CharLayoutRef('a'); //TODO + /* assert(floatDisplayMode != PrintFloat::Mode::Default); if (complexFormat == Expression::ComplexFormat::Polar) { return createPolarLayout(floatDisplayMode); } return createCartesianLayout(floatDisplayMode); -} +*/} template Expression * Complex::CreateDecimal(T f) { @@ -306,7 +309,7 @@ int Complex::convertComplexToText(char * buffer, int bufferSize, int numberOf return numberOfChars; } -template +/*template ExpressionLayout * Complex::createPolarLayout(PrintFloat::Mode floatDisplayMode) const { char bufferBase[PrintFloat::k_maxFloatBufferLength+2]; int numberOfCharInBase = 0; @@ -349,7 +352,7 @@ ExpressionLayout * Complex::createCartesianLayout(PrintFloat::Mode floatDispl char buffer[PrintFloat::k_maxComplexBufferLength]; int numberOfChars = convertComplexToText(buffer, PrintFloat::k_maxComplexBufferLength, Preferences::sharedPreferences()->numberOfSignificantDigits(), floatDisplayMode, Expression::ComplexFormat::Cartesian, Ion::Charset::MiddleDot); return LayoutEngine::createStringLayout(buffer, numberOfChars); -} +}*/ template class Complex; template class Complex; diff --git a/poincare/src/conjugate.cpp b/poincare/src/conjugate.cpp index 57461ae00..d27f96ac6 100644 --- a/poincare/src/conjugate.cpp +++ b/poincare/src/conjugate.cpp @@ -2,6 +2,7 @@ #include #include #include "layout/conjugate_layout.h" +#include extern "C" { #include @@ -19,11 +20,12 @@ Expression * Conjugate::clone() const { return a; } -ExpressionLayout * Conjugate::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { - assert(floatDisplayMode != PrintFloat::Mode::Default); +LayoutRef Conjugate::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { + return CharLayoutRef('a'); //TODO + /*assert(floatDisplayMode != PrintFloat::Mode::Default); assert(complexFormat != ComplexFormat::Default); return new ConjugateLayout(operand(0)->createLayout(floatDisplayMode, complexFormat), false); -} +*/} Expression * Conjugate::shallowReduce(Context& context, AngleUnit angleUnit) { Expression * e = Expression::shallowReduce(context, angleUnit); diff --git a/poincare/src/decimal.cpp b/poincare/src/decimal.cpp index 305049255..654d2c43a 100644 --- a/poincare/src/decimal.cpp +++ b/poincare/src/decimal.cpp @@ -9,6 +9,7 @@ extern "C" { #include } +#include namespace Poincare { @@ -217,8 +218,9 @@ bool Decimal::needParenthesisWithParent(const Expression * e) const { return e->isOfType(types, 7); } -ExpressionLayout * Decimal::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { - char buffer[k_maxBufferSize]; +LayoutRef Decimal::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { + return CharLayoutRef('a'); //TODO + /*char buffer[k_maxBufferSize]; int numberOfChars = convertToText(buffer, k_maxBufferSize, floatDisplayMode, PrintFloat::k_numberOfStoredSignificantDigits); return LayoutEngine::createStringLayout(buffer, numberOfChars); } @@ -241,7 +243,7 @@ Expression * Decimal::shallowReduce(Context& context, AngleUnit angleUnit) { } else { denominator = Integer::Power(Integer(10), Integer(numberOfDigits-1-m_exponent)); } - return replaceWith(new Rational(numerator, denominator), true); + return replaceWith(new Rational(numerator, denominator), true);*/ } Expression * Decimal::shallowBeautify(Context & context, AngleUnit angleUnit) { diff --git a/poincare/src/division.cpp b/poincare/src/division.cpp index de9b576a8..4e54be4a7 100644 --- a/poincare/src/division.cpp +++ b/poincare/src/division.cpp @@ -97,13 +97,14 @@ Complex Division::compute(const Complex c, const Complex d) { return Complex::Cartesian((temp*aa + ab) / norm, (temp*bb + ba) / norm); } -ExpressionLayout * Division::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { - assert(floatDisplayMode != PrintFloat::Mode::Default); +LayoutRef Division::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { + return CharLayoutRef('a'); //TODO + /* assert(floatDisplayMode != PrintFloat::Mode::Default); assert(complexFormat != ComplexFormat::Default); const Expression * numerator = operand(0)->type() == Type::Parenthesis ? operand(0)->operand(0) : operand(0); const Expression * denominator = operand(1)->type() == Type::Parenthesis ? operand(1)->operand(0) : operand(1); return new FractionLayout(numerator->createLayout(floatDisplayMode, complexFormat), denominator->createLayout(floatDisplayMode, complexFormat), false); -} +*/} template Matrix * Division::computeOnComplexAndMatrix(const Complex * c, const Matrix * n) { Matrix * inverse = n->createApproximateInverse(); diff --git a/poincare/src/empty_expression.cpp b/poincare/src/empty_expression.cpp index 9e416269c..13d22f174 100644 --- a/poincare/src/empty_expression.cpp +++ b/poincare/src/empty_expression.cpp @@ -2,6 +2,7 @@ #include #include #include +#include extern "C" { #include @@ -17,8 +18,9 @@ int EmptyExpression::writeTextInBuffer(char * buffer, int bufferSize, int number return LayoutEngine::writeOneCharInBuffer(buffer, bufferSize, Ion::Charset::Empty); } -ExpressionLayout * EmptyExpression::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { - return new EmptyLayout(); +LayoutRef EmptyExpression::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { + return CharLayoutRef('a'); //TODO + // return new EmptyLayout(); } template Complex * EmptyExpression::templatedApproximate(Context& context, AngleUnit angleUnit) const { diff --git a/poincare/src/equal.cpp b/poincare/src/equal.cpp index 58db799c9..ee9e35a3d 100644 --- a/poincare/src/equal.cpp +++ b/poincare/src/equal.cpp @@ -50,14 +50,15 @@ Expression * Equal::shallowReduce(Context& context, AngleUnit angleUnit) { return this; } -ExpressionLayout * Equal::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { - assert(floatDisplayMode != PrintFloat::Mode::Default); +LayoutRef Equal::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { + return CharLayoutRef('a'); //TODO + /*assert(floatDisplayMode != PrintFloat::Mode::Default); assert(complexFormat != ComplexFormat::Default); HorizontalLayout * result = new HorizontalLayout(); result->addOrMergeChildAtIndex(operand(0)->createLayout(floatDisplayMode, complexFormat), 0, false); result->addChildAtIndex(new CharLayout('='), result->numberOfChildren()); result->addOrMergeChildAtIndex(operand(1)->createLayout(floatDisplayMode, complexFormat), result->numberOfChildren(), false); - return result; + return result;*/ } template diff --git a/poincare/src/expression.cpp b/poincare/src/expression.cpp index 22e30cfcd..6f3450c75 100644 --- a/poincare/src/expression.cpp +++ b/poincare/src/expression.cpp @@ -345,7 +345,7 @@ bool Expression::isEqualToItsApproximationLayout(Expression * approximation, int /* Layout */ -ExpressionLayout * Expression::createLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { +LayoutRef Expression::createLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { switch (floatDisplayMode) { case PrintFloat::Mode::Default: switch (complexFormat) { diff --git a/poincare/src/factorial.cpp b/poincare/src/factorial.cpp index bb1c048b7..983c4f6bc 100644 --- a/poincare/src/factorial.cpp +++ b/poincare/src/factorial.cpp @@ -11,6 +11,7 @@ extern "C" { #include } #include +#include namespace Poincare { @@ -92,13 +93,15 @@ Complex Factorial::computeOnComplex(const Complex c, AngleUnit angleUnit) return Complex::Float(std::round(result)); } -ExpressionLayout * Factorial::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { - assert(floatDisplayMode != PrintFloat::Mode::Default); +LayoutRef Factorial::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { + return CharLayoutRef('a'); //TODO + /*assert(floatDisplayMode != PrintFloat::Mode::Default); assert(complexFormat != ComplexFormat::Default); HorizontalLayout * result = new HorizontalLayout(); result->addOrMergeChildAtIndex(operand(0)->createLayout(floatDisplayMode, complexFormat), 0, false); result->addChildAtIndex(new CharLayout('!'), result->numberOfChildren()); return result; +*/ } int Factorial::writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits) const { diff --git a/poincare/src/floor.cpp b/poincare/src/floor.cpp index fa9b02daa..a8302a05b 100644 --- a/poincare/src/floor.cpp +++ b/poincare/src/floor.cpp @@ -56,10 +56,11 @@ Complex Floor::computeOnComplex(const Complex c, AngleUnit angleUnit) { return Complex::Float(std::floor(c.a())); } -ExpressionLayout * Floor::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { - assert(floatDisplayMode != PrintFloat::Mode::Default); +LayoutRef Floor::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { + return CharLayoutRef('a'); //TODO +/* assert(floatDisplayMode != PrintFloat::Mode::Default); assert(complexFormat != ComplexFormat::Default); - return new FloorLayout(m_operands[0]->createLayout(floatDisplayMode, complexFormat), false); + return new FloorLayout(m_operands[0]->createLayout(floatDisplayMode, complexFormat), false);*/ } } diff --git a/poincare/src/global_context.cpp b/poincare/src/global_context.cpp index 479e61cfe..835eadf58 100644 --- a/poincare/src/global_context.cpp +++ b/poincare/src/global_context.cpp @@ -8,6 +8,17 @@ namespace Poincare { GlobalContext::GlobalContext() : + m_matrixLayouts{ + LayoutRef(nullptr), + LayoutRef(nullptr), + LayoutRef(nullptr), + LayoutRef(nullptr), + LayoutRef(nullptr), + LayoutRef(nullptr), + LayoutRef(nullptr), + LayoutRef(nullptr), + LayoutRef(nullptr), + LayoutRef(nullptr)}, //TODO find better way to initialize m_pi(Complex::Float(M_PI)), m_e(Complex::Float(M_E)), m_i(Complex::Cartesian(0.0, 1.0)) @@ -17,7 +28,6 @@ GlobalContext::GlobalContext() : } for (int i = 0; i < k_maxNumberOfMatrixExpressions ; i++) { m_matrixExpressions[i] = nullptr; - m_matrixLayout[i] = nullptr; } } @@ -33,10 +43,6 @@ GlobalContext::~GlobalContext() { delete m_matrixExpressions[i]; } m_matrixExpressions[i] = nullptr; - if (m_matrixLayout[i] != nullptr) { - delete m_matrixLayout[i]; - } - m_matrixLayout[i] = nullptr; } } @@ -78,13 +84,13 @@ const Expression * GlobalContext::expressionForSymbol(const Symbol * symbol) { return m_expressions[index]; } -ExpressionLayout * GlobalContext::expressionLayoutForSymbol(const Symbol * symbol) { +LayoutRef GlobalContext::layoutRefForSymbol(const Symbol * symbol) { if (symbol->isMatrixSymbol()) { int index = symbolIndex(symbol); - if (m_matrixLayout[index] == nullptr && m_matrixExpressions[index] != nullptr) { - m_matrixLayout[index] = m_matrixExpressions[index]->createLayout(); + if (!m_matrixLayouts[index].isDefined() && m_matrixExpressions[index] != nullptr) { + m_matrixLayouts[index] = m_matrixExpressions[index]->createLayout(); } - return m_matrixLayout[index]; + return m_matrixLayouts[index]; } return nullptr; } @@ -99,9 +105,8 @@ void GlobalContext::setExpressionForSymbolName(const Expression * expression, co delete m_matrixExpressions[indexMatrix]; m_matrixExpressions[indexMatrix] = nullptr; } - if (m_matrixLayout[indexMatrix] != nullptr) { - delete m_matrixLayout[indexMatrix]; - m_matrixLayout[indexMatrix] = nullptr; + if (m_matrixLayouts[indexMatrix] != nullptr) { + m_matrixLayouts[indexMatrix] = LayoutRef(nullptr); } if (evaluation != nullptr) { if (evaluation->type() == Expression::Type::Complex) { diff --git a/poincare/src/integer.cpp b/poincare/src/integer.cpp index a55a19dac..d69de58ed 100644 --- a/poincare/src/integer.cpp +++ b/poincare/src/integer.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include extern "C" { @@ -600,11 +601,14 @@ int Integer::writeTextInBuffer(char * buffer, int bufferSize) const { return size; } -ExpressionLayout * Integer::createLayout() const { +/*LayoutRef Integer::createLayout() const { + return CharLayoutRef('a'); //TODO +/* char buffer[255]; int numberOfChars = writeTextInBuffer(buffer, 255); return LayoutEngine::createStringLayout(buffer, numberOfChars); -} + +}*/ template float Poincare::Integer::approximate() const; template double Poincare::Integer::approximate() const; diff --git a/poincare/src/integral.cpp b/poincare/src/integral.cpp index 3246ee5fd..2c24f3844 100644 --- a/poincare/src/integral.cpp +++ b/poincare/src/integral.cpp @@ -10,6 +10,7 @@ extern "C" { } #include "layout/integral_layout.h" #include "layout/horizontal_layout.h" +#include namespace Poincare { @@ -66,7 +67,9 @@ Complex * Integral::templatedApproximate(Context & context, AngleUnit angleUn return new Complex(Complex::Float(result)); } -ExpressionLayout * Integral::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { +LayoutRef Integral::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { + return CharLayoutRef('a'); //TODO + /* assert(floatDisplayMode != PrintFloat::Mode::Default); assert(complexFormat != ComplexFormat::Default); return new IntegralLayout( @@ -74,7 +77,7 @@ ExpressionLayout * Integral::privateCreateLayout(PrintFloat::Mode floatDisplayMo operand(1)->createLayout(floatDisplayMode, complexFormat), operand(2)->createLayout(floatDisplayMode, complexFormat), false); -} +*/} template T Integral::functionValueAtAbscissa(T x, Context & context, AngleUnit angleUnit) const { diff --git a/poincare/src/layout_engine.cpp b/poincare/src/layout_engine.cpp index 8a82ba026..153177c0e 100644 --- a/poincare/src/layout_engine.cpp +++ b/poincare/src/layout_engine.cpp @@ -4,18 +4,29 @@ #include "layout/left_parenthesis_layout.h" #include "layout/right_parenthesis_layout.h" #include "layout/vertical_offset_layout.h" +#include +#include + extern "C" { #include } namespace Poincare { -ExpressionLayout * LayoutEngine::createInfixLayout(const Expression * expression, PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat, const char * operatorName) { +LayoutRef LayoutEngine::createInfixLayout(const Expression * expression, PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat, const char * operatorName) { assert(floatDisplayMode != PrintFloat::Mode::Default); assert(complexFormat != Expression::ComplexFormat::Default); int numberOfOperands = expression->numberOfOperands(); assert(numberOfOperands > 1); - HorizontalLayout * result = new HorizontalLayout(); + HorizontalLayoutRef result; + result.addChildAtIndex(expression->operand(0)->createLayout(), 0); + for (int i = 1; i < numberOfOperands; i++) { + result.addChildAtIndex(createStringLayout(operatorName, strlen(operatorName)), result.numberOfChildren()); + result.addChildAtIndex( + expression->operand(i)->createLayout(floatDisplayMode, complexFormat), + result.numberOfChildren()); + } + /* result->addOrMergeChildAtIndex(expression->operand(0)->createLayout(), 0, true); for (int i = 1; i < numberOfOperands; i++) { result->addOrMergeChildAtIndex(createStringLayout(operatorName, strlen(operatorName)), result->numberOfChildren(), true); @@ -24,16 +35,30 @@ ExpressionLayout * LayoutEngine::createInfixLayout(const Expression * expression createParenthesedLayout(expression->operand(i)->createLayout(floatDisplayMode, complexFormat), false) : expression->operand(i)->createLayout(floatDisplayMode, complexFormat), result->numberOfChildren(), true); - } + }*/ return result; } -ExpressionLayout * LayoutEngine::createPrefixLayout(const Expression * expression, PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat, const char * operatorName) { +LayoutRef LayoutEngine::createPrefixLayout(const Expression * expression, PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat, const char * operatorName) { assert(floatDisplayMode != PrintFloat::Mode::Default); assert(complexFormat != Expression::ComplexFormat::Default); - HorizontalLayout * result = new HorizontalLayout(); - + HorizontalLayoutRef result; // Add the operator name. + result.addChildAtIndex(createStringLayout(operatorName, strlen(operatorName)), 0); + + // Create the layout of arguments separated by commas. + HorizontalLayoutRef args; + int numberOfOperands = expression->numberOfOperands(); + if (numberOfOperands > 0) { + args.addChildAtIndex(expression->operand(0)->createLayout(floatDisplayMode, complexFormat), 0); + for (int i = 1; i < numberOfOperands; i++) { + args.addChildAtIndex(CharLayoutRef(','), args.numberOfChildren()); + args.addChildAtIndex(expression->operand(i)->createLayout(floatDisplayMode, complexFormat), args.numberOfChildren()); + } + } + // Add the parenthesed arguments. + result.addChildAtIndex(createParenthesedLayout(args, false), result.numberOfChildren()); + /*// Add the operator name. result->addOrMergeChildAtIndex(createStringLayout(operatorName, strlen(operatorName)), 0, true); // Create the layout of arguments separated by commas. @@ -49,35 +74,36 @@ ExpressionLayout * LayoutEngine::createPrefixLayout(const Expression * expressio } } // Add the parenthesed arguments. - result->addOrMergeChildAtIndex(createParenthesedLayout(args, false), result->numberOfChildren(), true); + result->addOrMergeChildAtIndex(createParenthesedLayout(args, false), result->numberOfChildren(), true);*/ return result; } -ExpressionLayout * LayoutEngine::createParenthesedLayout(ExpressionLayout * layout, bool cloneLayout) { - HorizontalLayout * result = new HorizontalLayout(); - result->addChildAtIndex(new LeftParenthesisLayout(), 0); - if (layout != nullptr) { - result->addOrMergeChildAtIndex(cloneLayout ? layout->clone() : layout, 1, true); +LayoutRef LayoutEngine::createParenthesedLayout(LayoutRef layoutRef, bool cloneLayout) { + HorizontalLayoutRef result; + result.addChildAtIndex(CharLayoutRef('('), 0); + if (layoutRef.isDefined()) { + result.addChildAtIndex(cloneLayout ? layoutRef.clone() : layoutRef, 1); } - result->addChildAtIndex(new RightParenthesisLayout(), result->numberOfChildren()); + result.addChildAtIndex(CharLayoutRef(')'), result.numberOfChildren()); return result; } -ExpressionLayout * LayoutEngine::createStringLayout(const char * buffer, int bufferSize, KDText::FontSize fontSize) { +LayoutRef LayoutEngine::createStringLayout(const char * buffer, int bufferSize, KDText::FontSize fontSize) { assert(bufferSize > 0); - HorizontalLayout * resultLayout = new HorizontalLayout(); + HorizontalLayoutRef resultLayout; for (int i = 0; i < bufferSize; i++) { - resultLayout->addChildAtIndex(new CharLayout(buffer[i], fontSize), i); + resultLayout.addChildAtIndex(CharLayoutRef(buffer[i], fontSize), i); } return resultLayout; } ExpressionLayout * LayoutEngine::createLogLayout(ExpressionLayout * argument, ExpressionLayout * index) { - HorizontalLayout * resultLayout = static_cast(createStringLayout("log", 3)); + return nullptr; + /*HorizontalLayout * resultLayout = static_cast(createStringLayout("log", 3)); VerticalOffsetLayout * offsetLayout = new VerticalOffsetLayout(index, VerticalOffsetLayout::Type::Subscript, false); resultLayout->addChildAtIndex(offsetLayout, resultLayout->numberOfChildren()); resultLayout->addOrMergeChildAtIndex(createParenthesedLayout(argument, false), resultLayout->numberOfChildren(), true); - return resultLayout; + return resultLayout;*/ } int LayoutEngine::writeInfixExpressionTextInBuffer(const Expression * expression, char * buffer, int bufferSize, int numberOfDigits, const char * operatorName) { diff --git a/poincare/src/logarithm.cpp b/poincare/src/logarithm.cpp index a8e979dc0..d7ddc1f53 100644 --- a/poincare/src/logarithm.cpp +++ b/poincare/src/logarithm.cpp @@ -228,13 +228,14 @@ Expression * Logarithm::templatedApproximate(Context& context, AngleUnit angleUn return new Complex(result); } -ExpressionLayout * Logarithm::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { - assert(floatDisplayMode != PrintFloat::Mode::Default); +LayoutRef Logarithm::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { + return CharLayoutRef('a'); //TODO + /*assert(floatDisplayMode != PrintFloat::Mode::Default); assert(complexFormat != ComplexFormat::Default); if (numberOfOperands() == 1) { return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, "log"); } - return LayoutEngine::createLogLayout(operand(0)->createLayout(floatDisplayMode, complexFormat), operand(1)->createLayout(floatDisplayMode, complexFormat)); + return LayoutEngine::createLogLayout(operand(0)->createLayout(floatDisplayMode, complexFormat), operand(1)->createLayout(floatDisplayMode, complexFormat));*/ } } diff --git a/poincare/src/matrix.cpp b/poincare/src/matrix.cpp index 2b3e0f52f..e567f0e66 100644 --- a/poincare/src/matrix.cpp +++ b/poincare/src/matrix.cpp @@ -164,8 +164,9 @@ void Matrix::rowCanonize(Context & context, AngleUnit angleUnit, Multiplication } } -ExpressionLayout * Matrix::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { - assert(floatDisplayMode != PrintFloat::Mode::Default); +LayoutRef Matrix::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { + return CharLayoutRef('a'); //TODO + /* assert(floatDisplayMode != PrintFloat::Mode::Default); assert(complexFormat != ComplexFormat::Default); ExpressionLayout ** childrenLayouts = new ExpressionLayout * [numberOfOperands()]; for (int i = 0; i < numberOfOperands(); i++) { @@ -173,7 +174,7 @@ ExpressionLayout * Matrix::privateCreateLayout(PrintFloat::Mode floatDisplayMode } ExpressionLayout * layout = new MatrixLayout(childrenLayouts, numberOfRows(), numberOfColumns(), false); delete [] childrenLayouts; - return layout; + return layout;*/ } int Matrix::rank(Context & context, AngleUnit angleUnit, bool inPlace) { diff --git a/poincare/src/multiplication.cpp b/poincare/src/multiplication.cpp index 860f30ff4..532af5ad8 100644 --- a/poincare/src/multiplication.cpp +++ b/poincare/src/multiplication.cpp @@ -85,9 +85,12 @@ bool Multiplication::needParenthesisWithParent(const Expression * e) const { return e->isOfType(types, 3); } -ExpressionLayout * Multiplication::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { +LayoutRef Multiplication::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { + return CharLayoutRef('a'); //TODO +/* const char middleDotString[] = {Ion::Charset::MiddleDot, 0}; return LayoutEngine::createInfixLayout(this, floatDisplayMode, complexFormat, middleDotString); +*/ } int Multiplication::writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits) const { diff --git a/poincare/src/nth_root.cpp b/poincare/src/nth_root.cpp index 8f8005aec..3a32a88c6 100644 --- a/poincare/src/nth_root.cpp +++ b/poincare/src/nth_root.cpp @@ -38,10 +38,13 @@ Expression * NthRoot::shallowReduce(Context& context, AngleUnit angleUnit) { return p->shallowReduce(context, angleUnit); } -ExpressionLayout * NthRoot::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { +LayoutRef NthRoot::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { + return CharLayoutRef('a'); //TODO + /* assert(floatDisplayMode != PrintFloat::Mode::Default); assert(complexFormat != ComplexFormat::Default); return new NthRootLayout(operand(0)->createLayout(floatDisplayMode, complexFormat), operand(1)->createLayout(floatDisplayMode, complexFormat), false); +*/ } template diff --git a/poincare/src/opposite.cpp b/poincare/src/opposite.cpp index 249ad84ce..dedce8527 100644 --- a/poincare/src/opposite.cpp +++ b/poincare/src/opposite.cpp @@ -12,6 +12,8 @@ extern "C" { #include } +#include + namespace Poincare { Expression::Type Opposite::type() const { @@ -66,8 +68,9 @@ Expression * Opposite::shallowReduce(Context& context, AngleUnit angleUnit) { return m->shallowReduce(context, angleUnit); } -ExpressionLayout * Opposite::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { - assert(floatDisplayMode != PrintFloat::Mode::Default); +LayoutRef Opposite::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { + return CharLayoutRef('a'); //TODO +/* assert(floatDisplayMode != PrintFloat::Mode::Default); assert(complexFormat != ComplexFormat::Default); HorizontalLayout * result = new HorizontalLayout(new CharLayout('-'), false); if (operand(0)->type() == Type::Opposite) { @@ -76,7 +79,7 @@ ExpressionLayout * Opposite::privateCreateLayout(PrintFloat::Mode floatDisplayMo result->addOrMergeChildAtIndex(operand(0)->createLayout(floatDisplayMode, complexFormat), 1, false); } return result; - +*/ } int Opposite::writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits) const { diff --git a/poincare/src/parenthesis.cpp b/poincare/src/parenthesis.cpp index 09240a108..e990da75d 100644 --- a/poincare/src/parenthesis.cpp +++ b/poincare/src/parenthesis.cpp @@ -1,4 +1,5 @@ #include +#include extern "C" { #include @@ -21,10 +22,12 @@ int Parenthesis::polynomialDegree(char symbolName) const { return operand(0)->polynomialDegree(symbolName); } -ExpressionLayout * Parenthesis::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { +LayoutRef Parenthesis::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { + return CharLayoutRef('('); //TODO +/* assert(floatDisplayMode != PrintFloat::Mode::Default); assert(complexFormat != ComplexFormat::Default); - return LayoutEngine::createParenthesedLayout(operand(0)->createLayout(floatDisplayMode, complexFormat), false); + return LayoutEngine::createParenthesedLayout(operand(0)->createLayout(floatDisplayMode, complexFormat), false);*/ } Expression * Parenthesis::shallowReduce(Context& context, AngleUnit angleUnit) { diff --git a/poincare/src/power.cpp b/poincare/src/power.cpp index b20c500c4..28dcdcb34 100644 --- a/poincare/src/power.cpp +++ b/poincare/src/power.cpp @@ -175,8 +175,9 @@ bool Power::needParenthesisWithParent(const Expression * e) const { return e->isOfType(types, 2); } -ExpressionLayout * Power::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { - assert(floatDisplayMode != PrintFloat::Mode::Default); +LayoutRef Power::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { + return CharLayoutRef('a'); //TODO + /* assert(floatDisplayMode != PrintFloat::Mode::Default); assert(complexFormat != ComplexFormat::Default); const Expression * indiceOperand = m_operands[1]; // Delete eventual parentheses of the indice in the pretty print @@ -190,7 +191,7 @@ ExpressionLayout * Power::privateCreateLayout(PrintFloat::Mode floatDisplayMode, VerticalOffsetLayout::Type::Superscript, false), result->numberOfChildren()); - return result; + return result;*/ } int Power::simplificationOrderSameType(const Expression * e, bool canBeInterrupted) const { diff --git a/poincare/src/rational.cpp b/poincare/src/rational.cpp index 03e9c1954..aa2117b9a 100644 --- a/poincare/src/rational.cpp +++ b/poincare/src/rational.cpp @@ -8,6 +8,7 @@ extern "C" { #include #include #include "layout/fraction_layout.h" +#include namespace Poincare { @@ -151,13 +152,15 @@ bool Rational::needParenthesisWithParent(const Expression * e) const { return e->isOfType(types, 3); } -ExpressionLayout * Rational::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { +LayoutRef Rational::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { + return CharLayoutRef('a'); //TODO + /* ExpressionLayout * numeratorLayout = m_numerator.createLayout(); if (m_denominator.isOne()) { return numeratorLayout; } ExpressionLayout * denominatorLayout = m_denominator.createLayout(); - return new FractionLayout(numeratorLayout, denominatorLayout, false); + return new FractionLayout(numeratorLayout, denominatorLayout, false);*/ } int Rational::writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits) const { diff --git a/poincare/src/sequence.cpp b/poincare/src/sequence.cpp index 07aeb5159..d0dcef341 100644 --- a/poincare/src/sequence.cpp +++ b/poincare/src/sequence.cpp @@ -3,6 +3,7 @@ #include #include #include +#include extern "C" { #include #include @@ -11,10 +12,12 @@ extern "C" { namespace Poincare { -ExpressionLayout * Sequence::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { - assert(floatDisplayMode != PrintFloat::Mode::Default); +LayoutRef Sequence::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { + return CharLayoutRef('a'); //TODO +/* assert(floatDisplayMode != PrintFloat::Mode::Default); assert(complexFormat != ComplexFormat::Default); return createSequenceLayoutWithArgumentLayouts(operand(0)->createLayout(floatDisplayMode, complexFormat), operand(1)->createLayout(floatDisplayMode, complexFormat), operand(2)->createLayout(floatDisplayMode, complexFormat)); +*/ } template diff --git a/poincare/src/square_root.cpp b/poincare/src/square_root.cpp index 7b8105b7a..683137a27 100644 --- a/poincare/src/square_root.cpp +++ b/poincare/src/square_root.cpp @@ -8,6 +8,7 @@ extern "C" { } #include #include +#include namespace Poincare { @@ -49,10 +50,12 @@ Expression * SquareRoot::shallowReduce(Context& context, AngleUnit angleUnit) { return p->shallowReduce(context, angleUnit); } -ExpressionLayout * SquareRoot::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { - assert(floatDisplayMode != PrintFloat::Mode::Default); +LayoutRef SquareRoot::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { + return CharLayoutRef('a'); //TODO + /* assert(floatDisplayMode != PrintFloat::Mode::Default); assert(complexFormat != ComplexFormat::Default); return new NthRootLayout(operand(0)->createLayout(floatDisplayMode, complexFormat), false); +*/ } } diff --git a/poincare/src/store.cpp b/poincare/src/store.cpp index 31164a008..098b69a3d 100644 --- a/poincare/src/store.cpp +++ b/poincare/src/store.cpp @@ -9,6 +9,7 @@ extern "C" { #include #include "layout/char_layout.h" #include "layout/horizontal_layout.h" +#include namespace Poincare { @@ -34,14 +35,15 @@ Expression * Store::shallowReduce(Context& context, AngleUnit angleUnit) { return replaceWith(editableOperand(1), true)->shallowReduce(context, angleUnit); } -ExpressionLayout * Store::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { - assert(floatDisplayMode != PrintFloat::Mode::Default); +LayoutRef Store::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { + return CharLayoutRef('a'); //TODO + /*assert(floatDisplayMode != PrintFloat::Mode::Default); assert(complexFormat != ComplexFormat::Default); HorizontalLayout * result = new HorizontalLayout(); result->addOrMergeChildAtIndex(value()->createLayout(floatDisplayMode, complexFormat), 0, false); result->addChildAtIndex(new CharLayout(Ion::Charset::Sto), result->numberOfChildren()); result->addOrMergeChildAtIndex(symbol()->createLayout(floatDisplayMode, complexFormat), result->numberOfChildren(), false); - return result; + return result;*/ } template diff --git a/poincare/src/symbol.cpp b/poincare/src/symbol.cpp index 21a349b6a..9730df9df 100644 --- a/poincare/src/symbol.cpp +++ b/poincare/src/symbol.cpp @@ -12,6 +12,8 @@ #include "layout/horizontal_layout.h" #include "layout/vertical_offset_layout.h" +#include + #include #include @@ -244,7 +246,9 @@ char Symbol::name() const { return m_name; } -ExpressionLayout * Symbol::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { +LayoutRef Symbol::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { + return CharLayoutRef('a'); //TODO +/* assert(floatDisplayMode != PrintFloat::Mode::Default); assert(complexFormat != ComplexFormat::Default); if (m_name == SpecialSymbols::Ans) { @@ -289,7 +293,7 @@ ExpressionLayout * Symbol::privateCreateLayout(PrintFloat::Mode floatDisplayMode if (isMatrixSymbol() || isSeriesSymbol(m_name) || isRegressionSymbol(m_name)) { return LayoutEngine::createStringLayout(textForSpecialSymbols(m_name), 2); } - return LayoutEngine::createStringLayout(&m_name, 1); + return LayoutEngine::createStringLayout(&m_name, 1);*/ } int Symbol::writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits) const { diff --git a/poincare/src/undefined.cpp b/poincare/src/undefined.cpp index c5600b15c..678854151 100644 --- a/poincare/src/undefined.cpp +++ b/poincare/src/undefined.cpp @@ -1,5 +1,6 @@ #include #include +#include extern "C" { #include @@ -24,10 +25,11 @@ template Complex * Undefined::templatedApproximate(Context& conte return new Complex(Complex::Float(NAN)); } -ExpressionLayout * Undefined::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { - char buffer[16]; +LayoutRef Undefined::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const { + /*char buffer[16]; int numberOfChars = PrintFloat::convertFloatToText(NAN, buffer, 16, 1, floatDisplayMode); - return LayoutEngine::createStringLayout(buffer, numberOfChars); + return LayoutEngine::createStringLayout(buffer, numberOfChars);*/ + return CharLayoutRef('a'); //TODO } int Undefined::writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits) const {